Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: expose content-bounds-updated event #35533

Merged
merged 5 commits into from Sep 13, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 12 additions & 4 deletions docs/api/web-contents.md
Expand Up @@ -130,10 +130,6 @@ Corresponds to the points in time when the spinner of the tab stopped spinning.

#### Event: 'dom-ready'

Returns:

* `event` Event

ckerr marked this conversation as resolved.
Show resolved Hide resolved
Emitted when the document in the top-level frame is loaded.

#### Event: 'page-title-updated'
Expand All @@ -156,6 +152,18 @@ Returns:

Emitted when page receives favicon urls.

#### Event: 'content-bounds-updated'

Returns:

* `event` Event
* `bounds` [Rectangle](structures/rectangle.md) - requested new content bounds

Emitted when the page calls `window.moveTo`, `window.resizeTo` or related APIs.

By default, this will move the window. To prevent that behavior, call
`event.preventDefault()`.

#### Event: 'did-create-window'

Returns:
Expand Down
5 changes: 3 additions & 2 deletions shell/browser/api/electron_api_web_contents.cc
Expand Up @@ -1182,8 +1182,9 @@ void WebContents::BeforeUnloadFired(content::WebContents* tab,

void WebContents::SetContentsBounds(content::WebContents* source,
const gfx::Rect& rect) {
for (ExtendedWebContentsObserver& observer : observers_)
observer.OnSetContentBounds(rect);
if (!Emit("content-bounds-updated", rect))
for (ExtendedWebContentsObserver& observer : observers_)
observer.OnSetContentBounds(rect);
}

void WebContents::CloseContents(content::WebContents* source) {
Expand Down