From f7c1f0909ae3faedfecfa77c87590ac851a5447d Mon Sep 17 00:00:00 2001 From: "dglazkov@chromium.org" Date: Tue, 5 Nov 2013 20:20:56 +0000 Subject: [PATCH] Turn on useUnfortunateSynchronousResizeMode. I had to add a RenderViewVisitor to ensure that all secondary windows get their resize mode values applied properly, but other than that, this is a simple flipping-the-flag type of thing. BUG=309760 R=jam Review URL: https://codereview.chromium.org/53493003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@233069 0039d316-1c4b-4281-b951-d872f2087c98 --- content/renderer/render_widget.cc | 4 ++-- content/renderer/resizing_mode_selector.cc | 15 ++++++--------- content/renderer/resizing_mode_selector.h | 2 +- content/shell/renderer/webkit_test_runner.cc | 17 ++++++++++++++++- 4 files changed, 25 insertions(+), 13 deletions(-) diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc index 506ef653a970..8fd2a224e879 100644 --- a/content/renderer/render_widget.cc +++ b/content/renderer/render_widget.cc @@ -648,7 +648,7 @@ void RenderWidget::Resize(const gfx::Size& new_size, const gfx::Rect& resizer_rect, bool is_fullscreen, ResizeAck resize_ack) { - if (!resizing_mode_selector_->is_synchronous_mode()) { + if (resizing_mode_selector_->NeverUsesSynchronousResize()) { // A resize ack shouldn't be requested if we have not ACK'd the previous // one. DCHECK(resize_ack != SEND_RESIZE_ACK || !next_paint_is_resize_ack()); @@ -687,7 +687,7 @@ void RenderWidget::Resize(const gfx::Size& new_size, // send an ACK if we are resized to a non-empty rect. webwidget_->resize(new_size); - if (!resizing_mode_selector_->is_synchronous_mode()) { + if (resizing_mode_selector_->NeverUsesSynchronousResize()) { // Resize should have caused an invalidation of the entire view. DCHECK(new_size.IsEmpty() || is_accelerated_compositing_active_ || paint_aggregator_.HasPendingUpdate()); diff --git a/content/renderer/resizing_mode_selector.cc b/content/renderer/resizing_mode_selector.cc index f5cc6ca6a76a..d717f5512a09 100644 --- a/content/renderer/resizing_mode_selector.cc +++ b/content/renderer/resizing_mode_selector.cc @@ -11,13 +11,11 @@ namespace content { -ResizingModeSelector::ResizingModeSelector() - : is_synchronous_mode_(false) { - // TODO(dglazkov): Remove this re-initialization once the transition to - // useUnfortunateAsynchronousResizeMode is complete. - // See http://crbug.com/309760 for details. - is_synchronous_mode_ = RenderThreadImpl::current() && - RenderThreadImpl::current()->layout_test_mode(); +ResizingModeSelector::ResizingModeSelector() : is_synchronous_mode_(false) {} + +bool ResizingModeSelector::NeverUsesSynchronousResize() const { + return !RenderThreadImpl::current() || // can be NULL when in unit tests + !RenderThreadImpl::current()->layout_test_mode(); } bool ResizingModeSelector::ShouldAbortOnResize( @@ -30,8 +28,7 @@ bool ResizingModeSelector::ShouldAbortOnResize( } void ResizingModeSelector::set_is_synchronous_mode(bool mode) { - // TODO(dglazkov): Actually set is_synchronous_mode_ once the transition to - // useUnfortunateAsynchronousResizeMode is complete. + is_synchronous_mode_ = mode; } bool ResizingModeSelector::is_synchronous_mode() const { diff --git a/content/renderer/resizing_mode_selector.h b/content/renderer/resizing_mode_selector.h index 67702fd4bd98..ac657e294cde 100644 --- a/content/renderer/resizing_mode_selector.h +++ b/content/renderer/resizing_mode_selector.h @@ -25,7 +25,7 @@ class RenderWidget; class ResizingModeSelector { public: ResizingModeSelector(); - + bool NeverUsesSynchronousResize() const; bool ShouldAbortOnResize(RenderWidget* widget, const ViewMsg_Resize_Params& params); diff --git a/content/shell/renderer/webkit_test_runner.cc b/content/shell/renderer/webkit_test_runner.cc index 627a8b1072ac..eca802b22908 100644 --- a/content/shell/renderer/webkit_test_runner.cc +++ b/content/shell/renderer/webkit_test_runner.cc @@ -186,6 +186,20 @@ class NavigateAwayVisitor : public RenderViewVisitor { DISALLOW_COPY_AND_ASSIGN(NavigateAwayVisitor); }; +class UseSynchronousResizeModeVisitor : public RenderViewVisitor { + public: + explicit UseSynchronousResizeModeVisitor(bool enable) : enable_(enable) {} + virtual ~UseSynchronousResizeModeVisitor() {} + + virtual bool Visit(RenderView* render_view) OVERRIDE { + UseSynchronousResizeMode(render_view, enable_); + return true; + } + + private: + bool enable_; +}; + } // namespace WebKitTestRunner::WebKitTestRunner(RenderView* render_view) @@ -350,7 +364,8 @@ std::string WebKitTestRunner::makeURLErrorDescription( } void WebKitTestRunner::useUnfortunateSynchronousResizeMode(bool enable) { - UseSynchronousResizeMode(render_view(), enable); + UseSynchronousResizeModeVisitor visitor(enable); + RenderView::ForEach(&visitor); } void WebKitTestRunner::enableAutoResizeMode(const WebSize& min_size, -- 2.11.4.GIT