Skip to content

Commit

Permalink
Update a webview plugin's WebView's lifecycle immediately after resiz…
Browse files Browse the repository at this point in the history
…ing.

Remove the delay timer before updating a webview plugin's geometry, since
the referenced Blink compositing bug has been fixed.

BUG=591174

Review URL: https://codereview.chromium.org/1764043002

Cr-Commit-Position: refs/heads/master@{#379351}
  • Loading branch information
chrishtr authored and Commit bot committed Mar 4, 2016
1 parent 968291c commit 93e8a23
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
21 changes: 19 additions & 2 deletions components/plugins/renderer/webview_plugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ WebViewPlugin::WebViewPlugin(content::RenderView* render_view,
web_view_(WebView::create(this)),
finished_loading_(false),
focused_(false),
is_painting_(false) {
is_painting_(false),
is_resizing_(false) {
// ApplyWebPreferences before making a WebLocalFrame so that the frame sees a
// consistent view of our preferences.
content::RenderView::ApplyWebPreferences(preferences, web_view_);
Expand Down Expand Up @@ -199,14 +200,22 @@ void WebViewPlugin::updateGeometry(const WebRect& window_rect,
const WebRect& unobscured_rect,
const WebVector<WebRect>& cut_outs_rects,
bool is_visible) {
base::AutoReset<bool> is_resizing(
&is_resizing_, true);

if (static_cast<gfx::Rect>(window_rect) != rect_) {
rect_ = window_rect;
WebSize newSize(window_rect.width, window_rect.height);
web_view_->resize(newSize);
}

if (delegate_)
if (delegate_) {
delegate_->OnUnobscuredRectUpdate(gfx::Rect(unobscured_rect));
// The delegate may have dirtied style and layout of the WebView.
// See for example the resizePoster function in plugin_poster.html.
// Run the lifecycle now so that it is clean.
web_view_->updateAllLifecyclePhases();
}
}

void WebViewPlugin::updateFocus(bool focused, blink::WebFocusType focus_type) {
Expand Down Expand Up @@ -293,6 +302,14 @@ void WebViewPlugin::didChangeCursor(const WebCursorInfo& cursor) {
}

void WebViewPlugin::scheduleAnimation() {
// Resizes must be self-contained: any lifecycle updating must
// be triggerd from within the WebView or this WebViewPlugin.
// This is because this WebViewPlugin is contained in another
// Web View which may be in the middle of updating its lifecycle,
// but after layout is done, and it is illegal to dirty earlier
// lifecycle stages during later ones.
if (is_resizing_)
return;
if (container_) {
// This should never happen; see also crbug.com/545039 for context.
CHECK(!is_painting_);
Expand Down
1 change: 1 addition & 0 deletions components/plugins/renderer/webview_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ class WebViewPlugin : public blink::WebPlugin,
bool finished_loading_;
bool focused_;
bool is_painting_;
bool is_resizing_;
};

#endif // COMPONENTS_PLUGINS_RENDERER_WEBVIEW_PLUGIN_H_
2 changes: 2 additions & 0 deletions third_party/WebKit/Source/core/frame/FrameView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1797,6 +1797,8 @@ void FrameView::scheduleRelayout()

if (!shouldThrottleRendering())
page()->animator().scheduleVisualUpdate(m_frame.get());
// TODO(chrishtr): this is dangerous and probably incorrect, since layout can be rescheduled during
// the lifecycle in cases such as change of containing block chain. Remove it.
lifecycle().ensureStateAtMost(DocumentLifecycle::StyleClean);
}

Expand Down

0 comments on commit 93e8a23

Please sign in to comment.