| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |