summaryrefslogtreecommitdiffstats
path: root/components
diff options
context:
space:
mode:
authorJason Kersey <kerz@google.com>2016-03-07 20:21:16 -0800
committerJason Kersey <kerz@google.com>2016-03-08 04:22:58 +0000
commitb67631a9671ebab418020cb52d42f4681e7bdc2b (patch)
treed612dd8989b78f688fffef080c8941f5bb7ffc51 /components
parent890056bc883ac82c7a51fb7a614de3a509a177e7 (diff)
downloadchromium_src-b67631a9671ebab418020cb52d42f4681e7bdc2b.zip
chromium_src-b67631a9671ebab418020cb52d42f4681e7bdc2b.tar.gz
chromium_src-b67631a9671ebab418020cb52d42f4681e7bdc2b.tar.bz2
Decouple scheduling animation of webview plugins from layout.
Previously, any time the webview plugin needed to schedule animation, it dirtied layout in the containing frame. This was because it used to be the case that LayoutEmbeddedObject would run the webview plugin's lifecycle as part of layout. However, this is not right, for two reasons: 1. A lifecycle update for later phases may be needed for the plugin due to changes in the parent, even if layout is not dirty. This can lead to not running the webview lifecyle in some cases. https://codereview.chromium.org/1708923002 fixed this by always running the lifecycle of the webview plugin when the parent does. 2. Animation is scheduled for two reasons: lifecyle update, and actual animations, such as issuing resize events to script. It is valid to queue up async script events during a lifecycle update. (In one case in the referenced bug, FrameView:: sendResizeEventIfNeeded does this when it notices that layout changed the size of the frame). This CL fixes cases such as that, and builds up on the one fixing issue #1, by scheduling animation of the parent frame but not dirtying layout. BUG=590856 TBR=tommycli,fsamuel Review URL: https://codereview.chromium.org/1774653002 Cr-Commit-Position: refs/heads/master@{#379694} (cherry picked from commit 78ea22a8529ec7ac2ea07d7e69ddd1446f0ed262) Review URL: https://codereview.chromium.org/1770913004 . Cr-Commit-Position: refs/branch-heads/2623@{#594} Cr-Branched-From: 92d77538a86529ca35f9220bd3cd512cbea1f086-refs/heads/master@{#369907}
Diffstat (limited to 'components')
-rw-r--r--components/plugins/renderer/webview_plugin.cc23
-rw-r--r--components/plugins/renderer/webview_plugin.h2
-rw-r--r--components/test_runner/test_plugin.h2
3 files changed, 18 insertions, 9 deletions
diff --git a/components/plugins/renderer/webview_plugin.cc b/components/plugins/renderer/webview_plugin.cc
index 2869a77..02d8a0e 100644
--- a/components/plugins/renderer/webview_plugin.cc
+++ b/components/plugins/renderer/webview_plugin.cc
@@ -131,8 +131,8 @@ bool WebViewPlugin::initialize(WebPluginContainer* container) {
// scheduleAnimation, but due to timers controlling widget update,
// scheduleAnimation may be invoked before this initialize call (which
// comes through the widget update process). It doesn't hurt to mark
- // for layout again, and it does help us in the race-condition situation.
- container_->setNeedsLayout();
+ // for animation again, and it does help us in the race-condition situation.
+ container_->scheduleAnimation();
old_title_ = container_->element().getAttribute("title");
@@ -161,9 +161,7 @@ v8::Local<v8::Object> WebViewPlugin::v8ScriptableObject(v8::Isolate* isolate) {
return delegate_->GetV8ScriptableObject(isolate);
}
-// TODO(wkorman): Look into renaming this to something more in line with
-// either the Blink lifecycle or Compositor layer tree host nomenclature.
-void WebViewPlugin::layoutIfNeeded() {
+void WebViewPlugin::updateAllLifecyclePhases() {
web_view_->updateAllLifecyclePhases();
}
@@ -293,8 +291,19 @@ void WebViewPlugin::didChangeCursor(const WebCursorInfo& cursor) {
}
void WebViewPlugin::scheduleAnimation() {
- if (container_)
- container_->setNeedsLayout();
+ // 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_);
+ container_->scheduleAnimation();
+ }
}
void WebViewPlugin::didClearWindowObject(WebLocalFrame* frame) {
diff --git a/components/plugins/renderer/webview_plugin.h b/components/plugins/renderer/webview_plugin.h
index 20fa038..713ed659 100644
--- a/components/plugins/renderer/webview_plugin.h
+++ b/components/plugins/renderer/webview_plugin.h
@@ -88,7 +88,7 @@ class WebViewPlugin : public blink::WebPlugin,
v8::Local<v8::Object> v8ScriptableObject(v8::Isolate* isolate) override;
- void layoutIfNeeded() override;
+ void updateAllLifecyclePhases() override;
void paint(blink::WebCanvas* canvas, const blink::WebRect& rect) override;
// Coordinates are relative to the containing window.
diff --git a/components/test_runner/test_plugin.h b/components/test_runner/test_plugin.h
index 55c2832..65b60e4 100644
--- a/components/test_runner/test_plugin.h
+++ b/components/test_runner/test_plugin.h
@@ -63,7 +63,7 @@ class TestPlugin : public blink::WebPlugin, public cc::TextureLayerClient {
NPObject* scriptableObject() override;
bool canProcessDrag() const override;
bool supportsKeyboardFocus() const override;
- void layoutIfNeeded() override {}
+ void updateAllLifecyclePhases() override {}
void paint(blink::WebCanvas* canvas, const blink::WebRect& rect) override {}
void updateGeometry(const blink::WebRect& window_rect,
const blink::WebRect& clip_rect,