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

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

Issue 1764043002: Update a webview plugin's WebView's lifecycle immediately after resizing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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
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/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 50
51 WebViewPlugin::WebViewPlugin(content::RenderView* render_view, 51 WebViewPlugin::WebViewPlugin(content::RenderView* render_view,
52 WebViewPlugin::Delegate* delegate, 52 WebViewPlugin::Delegate* delegate,
53 const WebPreferences& preferences) 53 const WebPreferences& preferences)
54 : content::RenderViewObserver(render_view), 54 : content::RenderViewObserver(render_view),
55 delegate_(delegate), 55 delegate_(delegate),
56 container_(nullptr), 56 container_(nullptr),
57 web_view_(WebView::create(this)), 57 web_view_(WebView::create(this)),
58 finished_loading_(false), 58 finished_loading_(false),
59 focused_(false), 59 focused_(false),
60 is_painting_(false) { 60 is_painting_(false),
61 is_resizing_(false) {
61 // ApplyWebPreferences before making a WebLocalFrame so that the frame sees a 62 // ApplyWebPreferences before making a WebLocalFrame so that the frame sees a
62 // consistent view of our preferences. 63 // consistent view of our preferences.
63 content::RenderView::ApplyWebPreferences(preferences, web_view_); 64 content::RenderView::ApplyWebPreferences(preferences, web_view_);
64 WebLocalFrame* web_local_frame = 65 WebLocalFrame* web_local_frame =
65 WebLocalFrame::create(blink::WebTreeScopeType::Document, this); 66 WebLocalFrame::create(blink::WebTreeScopeType::Document, this);
66 web_frame_ = web_local_frame; 67 web_frame_ = web_local_frame;
67 web_view_->setMainFrame(web_frame_); 68 web_view_->setMainFrame(web_frame_);
68 // TODO(dcheng): The main frame widget currently has a special case. 69 // TODO(dcheng): The main frame widget currently has a special case.
69 // Eliminate this once WebView is no longer a WebWidget. 70 // Eliminate this once WebView is no longer a WebWidget.
70 web_frame_widget_ = WebFrameWidget::create(this, web_view_, web_local_frame); 71 web_frame_widget_ = WebFrameWidget::create(this, web_view_, web_local_frame);
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 193
193 canvas->restore(); 194 canvas->restore();
194 } 195 }
195 196
196 // Coordinates are relative to the containing window. 197 // Coordinates are relative to the containing window.
197 void WebViewPlugin::updateGeometry(const WebRect& window_rect, 198 void WebViewPlugin::updateGeometry(const WebRect& window_rect,
198 const WebRect& clip_rect, 199 const WebRect& clip_rect,
199 const WebRect& unobscured_rect, 200 const WebRect& unobscured_rect,
200 const WebVector<WebRect>& cut_outs_rects, 201 const WebVector<WebRect>& cut_outs_rects,
201 bool is_visible) { 202 bool is_visible) {
203 base::AutoReset<bool> is_painting(
tommycli 2016/03/04 19:11:22 This should be called is_resizing right?
204 &is_resizing_, true);
205
202 if (static_cast<gfx::Rect>(window_rect) != rect_) { 206 if (static_cast<gfx::Rect>(window_rect) != rect_) {
203 rect_ = window_rect; 207 rect_ = window_rect;
204 WebSize newSize(window_rect.width, window_rect.height); 208 WebSize newSize(window_rect.width, window_rect.height);
205 web_view_->resize(newSize); 209 web_view_->resize(newSize);
206 } 210 }
207 211
208 if (delegate_) 212 if (delegate_) {
209 delegate_->OnUnobscuredRectUpdate(gfx::Rect(unobscured_rect)); 213 delegate_->OnUnobscuredRectUpdate(gfx::Rect(unobscured_rect));
214 // The delegate may have dirtied style and layout of the WebView.
215 // See for example the resizePoster function in plugin_poster.html.
216 // Run the lifecycle now so that it is clean.
217 web_view_->updateAllLifecyclePhases();
218 }
210 } 219 }
211 220
212 void WebViewPlugin::updateFocus(bool focused, blink::WebFocusType focus_type) { 221 void WebViewPlugin::updateFocus(bool focused, blink::WebFocusType focus_type) {
213 focused_ = focused; 222 focused_ = focused;
214 } 223 }
215 224
216 bool WebViewPlugin::acceptsInputEvents() { return true; } 225 bool WebViewPlugin::acceptsInputEvents() { return true; }
217 226
218 blink::WebInputEventResult WebViewPlugin::handleInputEvent( 227 blink::WebInputEventResult WebViewPlugin::handleInputEvent(
219 const WebInputEvent& event, 228 const WebInputEvent& event,
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 void WebViewPlugin::didInvalidateRect(const WebRect& rect) { 295 void WebViewPlugin::didInvalidateRect(const WebRect& rect) {
287 if (container_) 296 if (container_)
288 container_->invalidateRect(rect); 297 container_->invalidateRect(rect);
289 } 298 }
290 299
291 void WebViewPlugin::didChangeCursor(const WebCursorInfo& cursor) { 300 void WebViewPlugin::didChangeCursor(const WebCursorInfo& cursor) {
292 current_cursor_ = cursor; 301 current_cursor_ = cursor;
293 } 302 }
294 303
295 void WebViewPlugin::scheduleAnimation() { 304 void WebViewPlugin::scheduleAnimation() {
305 // Resizes must be self-contained: any lifecycle updating must
306 // be triggerd from within the WebView or this WebViewPlugin.
307 // This is because this WebViewPlugin is contained in another
308 // Web View which may be in the middle of updating its lifecycle,
309 // but after layout is done, and it is illegal to dirty earlier
310 // lifecycle stages during later ones.
311 if (is_resizing_)
312 return;
296 if (container_) { 313 if (container_) {
297 // This should never happen; see also crbug.com/545039 for context. 314 // This should never happen; see also crbug.com/545039 for context.
298 CHECK(!is_painting_); 315 CHECK(!is_painting_);
299 container_->setNeedsLayout(); 316 container_->setNeedsLayout();
300 } 317 }
301 } 318 }
302 319
303 void WebViewPlugin::didClearWindowObject(WebLocalFrame* frame) { 320 void WebViewPlugin::didClearWindowObject(WebLocalFrame* frame) {
304 if (!delegate_) 321 if (!delegate_)
305 return; 322 return;
(...skipping 19 matching lines...) Expand all
325 // By default RenderViewObservers are destroyed along with the RenderView. 342 // By default RenderViewObservers are destroyed along with the RenderView.
326 // WebViewPlugin has a custom destruction mechanism, so we disable this. 343 // WebViewPlugin has a custom destruction mechanism, so we disable this.
327 } 344 }
328 345
329 void WebViewPlugin::OnZoomLevelChanged() { 346 void WebViewPlugin::OnZoomLevelChanged() {
330 if (container_) { 347 if (container_) {
331 web_view_->setZoomLevel( 348 web_view_->setZoomLevel(
332 blink::WebView::zoomFactorToZoomLevel(container_->pageZoomFactor())); 349 blink::WebView::zoomFactorToZoomLevel(container_->pageZoomFactor()));
333 } 350 }
334 } 351 }
OLDNEW
« no previous file with comments | « components/plugins/renderer/webview_plugin.h ('k') | third_party/WebKit/Source/core/frame/FrameView.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698