summaryrefslogtreecommitdiffstats
path: root/components/plugins
diff options
context:
space:
mode:
authorschenney <schenney@chromium.org>2015-07-23 13:11:53 -0700
committerCommit bot <commit-bot@chromium.org>2015-07-23 20:12:35 +0000
commitd45448239b0d64a73c7712262beab45ac142152d (patch)
tree3ef68a0bcfee4f30056bdad478c378690a0cf87e /components/plugins
parenta5116cc7d99a47e6d79986ab2ba5f5cfac1be1bf (diff)
downloadchromium_src-d45448239b0d64a73c7712262beab45ac142152d.zip
chromium_src-d45448239b0d64a73c7712262beab45ac142152d.tar.gz
chromium_src-d45448239b0d64a73c7712262beab45ac142152d.tar.bz2
Stop painting when layout is pending in WebView_Plugin
We should not be painting a WebViewPlugin while layout is pending - it may leave invalid state for painting. This patch flags when layout is pending and delays paint when necessary. TBR=chrishtr@chromium.org,tommycli@chromium.org,bauerb@chromium.org BUG=493375 Review URL: https://codereview.chromium.org/1254653002 Cr-Commit-Position: refs/heads/master@{#340153}
Diffstat (limited to 'components/plugins')
-rw-r--r--components/plugins/renderer/webview_plugin.cc12
-rw-r--r--components/plugins/renderer/webview_plugin.h3
2 files changed, 13 insertions, 2 deletions
diff --git a/components/plugins/renderer/webview_plugin.cc b/components/plugins/renderer/webview_plugin.cc
index c8ef592..26525de 100644
--- a/components/plugins/renderer/webview_plugin.cc
+++ b/components/plugins/renderer/webview_plugin.cc
@@ -49,7 +49,8 @@ WebViewPlugin::WebViewPlugin(WebViewPlugin::Delegate* delegate,
container_(NULL),
web_view_(WebView::create(this)),
finished_loading_(false),
- focused_(false) {
+ focused_(false),
+ animationNeeded_(false) {
// ApplyWebPreferences before making a WebLocalFrame so that the frame sees a
// consistent view of our preferences.
content::RenderView::ApplyWebPreferences(preferences, web_view_);
@@ -147,10 +148,18 @@ v8::Local<v8::Object> WebViewPlugin::v8ScriptableObject(v8::Isolate* isolate) {
}
void WebViewPlugin::layoutIfNeeded() {
+ animationNeeded_ = false;
web_view_->layout();
}
void WebViewPlugin::paint(WebCanvas* canvas, const WebRect& rect) {
+ // Do not paint before the container is set (that is, before initialize() has
+ // been called). We will be asked to paint again thanks to the initialize()
+ // method calling setNeedsLayout on the container. Without this check we
+ // may attempt to paint before the WebView's frame has been laid-out.
+ if (animationNeeded_)
+ return;
+
gfx::Rect paint_rect = gfx::IntersectRects(rect_, rect);
if (paint_rect.IsEmpty())
return;
@@ -270,6 +279,7 @@ void WebViewPlugin::didChangeCursor(const WebCursorInfo& cursor) {
}
void WebViewPlugin::scheduleAnimation() {
+ animationNeeded_ = true;
if (container_)
container_->setNeedsLayout();
}
diff --git a/components/plugins/renderer/webview_plugin.h b/components/plugins/renderer/webview_plugin.h
index e804fd3..246f7a9 100644
--- a/components/plugins/renderer/webview_plugin.h
+++ b/components/plugins/renderer/webview_plugin.h
@@ -169,10 +169,11 @@ class WebViewPlugin : public blink::WebPlugin,
blink::WebURLResponse response_;
std::list<std::string> data_;
- bool finished_loading_;
scoped_ptr<blink::WebURLError> error_;
blink::WebString old_title_;
+ bool finished_loading_;
bool focused_;
+ bool animationNeeded_;
};
#endif // COMPONENTS_PLUGINS_RENDERER_WEBVIEW_PLUGIN_H_