Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(142)

Side by Side Diff: components/plugins/renderer/webview_plugin.cc

Issue 2211263003: WebViewPlugin: Make WebView resize take place synchronously. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2785
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/plugins/renderer/webview_plugin.h" 5 #include "components/plugins/renderer/webview_plugin.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 } 202 }
203 203
204 // Coordinates are relative to the containing window. 204 // Coordinates are relative to the containing window.
205 void WebViewPlugin::updateGeometry(const WebRect& window_rect, 205 void WebViewPlugin::updateGeometry(const WebRect& window_rect,
206 const WebRect& clip_rect, 206 const WebRect& clip_rect,
207 const WebRect& unobscured_rect, 207 const WebRect& unobscured_rect,
208 const WebVector<WebRect>& cut_outs_rects, 208 const WebVector<WebRect>& cut_outs_rects,
209 bool is_visible) { 209 bool is_visible) {
210 DCHECK(container_); 210 DCHECK(container_);
211 211
212 base::AutoReset<bool> is_resizing(&is_resizing_, true);
213
214 if (static_cast<gfx::Rect>(window_rect) != rect_) {
215 rect_ = window_rect;
216 web_view_->resize(rect_.size());
217 }
218
212 // Plugin updates are forbidden during Blink layout. Therefore, 219 // Plugin updates are forbidden during Blink layout. Therefore,
213 // UpdatePluginForNewGeometry must be posted to a task to run asynchronously. 220 // UpdatePluginForNewGeometry must be posted to a task to run asynchronously.
214 base::ThreadTaskRunnerHandle::Get()->PostTask( 221 base::ThreadTaskRunnerHandle::Get()->PostTask(
215 FROM_HERE, 222 FROM_HERE,
216 base::Bind(&WebViewPlugin::UpdatePluginForNewGeometry, 223 base::Bind(&WebViewPlugin::UpdatePluginForNewGeometry,
217 weak_factory_.GetWeakPtr(), window_rect, unobscured_rect)); 224 weak_factory_.GetWeakPtr(), window_rect, unobscured_rect));
218 } 225 }
219 226
220 void WebViewPlugin::updateFocus(bool focused, blink::WebFocusType focus_type) { 227 void WebViewPlugin::updateFocus(bool focused, blink::WebFocusType focus_type) {
221 focused_ = focused; 228 focused_ = focused;
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 if (container_) { 348 if (container_) {
342 web_view_->setZoomLevel( 349 web_view_->setZoomLevel(
343 blink::WebView::zoomFactorToZoomLevel(container_->pageZoomFactor())); 350 blink::WebView::zoomFactorToZoomLevel(container_->pageZoomFactor()));
344 } 351 }
345 } 352 }
346 353
347 void WebViewPlugin::UpdatePluginForNewGeometry( 354 void WebViewPlugin::UpdatePluginForNewGeometry(
348 const blink::WebRect& window_rect, 355 const blink::WebRect& window_rect,
349 const blink::WebRect& unobscured_rect) { 356 const blink::WebRect& unobscured_rect) {
350 DCHECK(container_); 357 DCHECK(container_);
358 if (!delegate_)
359 return;
351 360
352 base::AutoReset<bool> is_resizing(&is_resizing_, true); 361 // The delegate may instantiate a new plugin.
353 362 delegate_->OnUnobscuredRectUpdate(gfx::Rect(unobscured_rect));
354 if (static_cast<gfx::Rect>(window_rect) != rect_) { 363 // The delegate may have dirtied style and layout of the WebView.
355 rect_ = window_rect; 364 // See for example the resizePoster function in plugin_poster.html.
356 web_view_->resize(rect_.size()); 365 // Run the lifecycle now so that it is clean.
357 } 366 web_view_->updateAllLifecyclePhases();
358
359 if (delegate_) {
360 delegate_->OnUnobscuredRectUpdate(gfx::Rect(unobscured_rect));
361 // The delegate may have dirtied style and layout of the WebView.
362 // See for example the resizePoster function in plugin_poster.html.
363 // Run the lifecycle now so that it is clean.
364 web_view_->updateAllLifecyclePhases();
365 }
366 } 367 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698