Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/browser/frame_host/render_widget_host_view_child_frame.h" | 5 #include "content/browser/frame_host/render_widget_host_view_child_frame.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 114 | 114 |
| 115 // The parent_view can be null in tests when using a TestWebContents. | 115 // The parent_view can be null in tests when using a TestWebContents. |
| 116 if (parent_view) { | 116 if (parent_view) { |
| 117 // Translate frame_rect by the parent's RenderWidgetHostView offset. | 117 // Translate frame_rect by the parent's RenderWidgetHostView offset. |
| 118 rect.Offset(parent_view->GetViewBounds().OffsetFromOrigin()); | 118 rect.Offset(parent_view->GetViewBounds().OffsetFromOrigin()); |
| 119 } | 119 } |
| 120 } | 120 } |
| 121 return rect; | 121 return rect; |
| 122 } | 122 } |
| 123 | 123 |
| 124 gfx::Size RenderWidgetHostViewChildFrame::GetVisibleViewportSize() const { | |
| 125 // For subframes, the visual viewport corresponds to the main frame size, so | |
| 126 // this bubbles up to the parent until it hits the main frame's | |
| 127 // RenderWidgetHostView. | |
| 128 // | |
| 129 // Currently this excludes webview guests, since they expect the visual | |
| 130 // viewport to return the guest's size rather than the page's; one reason why | |
| 131 // is that Blink ends up using the visual viewport to calculate things like | |
| 132 // window.innerWidth/innerHeight for main frames, and a guest is considered | |
| 133 // to be a main frame. This should be cleaned up eventually. | |
| 134 bool is_guest = BrowserPluginGuest::IsGuest( | |
| 135 static_cast<RenderViewHostImpl*>(RenderViewHost::From(host_))); | |
|
dcheng
2016/03/31 23:07:54
By the way, I think you can write RenderViewHostIm
alexmos
2016/04/01 00:44:54
Done.
| |
| 136 if (frame_connector_ && !is_guest) { | |
| 137 RenderWidgetHostView* parent_view = | |
| 138 frame_connector_->GetParentRenderWidgetHostView(); | |
| 139 // The parent_view can be null in unit tests when using a TestWebContents. | |
| 140 if (parent_view) | |
| 141 return parent_view->GetVisibleViewportSize(); | |
| 142 } | |
| 143 return GetViewBounds().size(); | |
| 144 } | |
| 145 | |
| 124 gfx::Vector2dF RenderWidgetHostViewChildFrame::GetLastScrollOffset() const { | 146 gfx::Vector2dF RenderWidgetHostViewChildFrame::GetLastScrollOffset() const { |
| 125 return last_scroll_offset_; | 147 return last_scroll_offset_; |
| 126 } | 148 } |
| 127 | 149 |
| 128 gfx::NativeView RenderWidgetHostViewChildFrame::GetNativeView() const { | 150 gfx::NativeView RenderWidgetHostViewChildFrame::GetNativeView() const { |
| 129 NOTREACHED(); | 151 NOTREACHED(); |
| 130 return NULL; | 152 return NULL; |
| 131 } | 153 } |
| 132 | 154 |
| 133 gfx::NativeViewId RenderWidgetHostViewChildFrame::GetNativeViewId() const { | 155 gfx::NativeViewId RenderWidgetHostViewChildFrame::GetNativeViewId() const { |
| (...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 573 | 595 |
| 574 bool RenderWidgetHostViewChildFrame::IsChildFrameForTesting() const { | 596 bool RenderWidgetHostViewChildFrame::IsChildFrameForTesting() const { |
| 575 return true; | 597 return true; |
| 576 } | 598 } |
| 577 | 599 |
| 578 cc::SurfaceId RenderWidgetHostViewChildFrame::SurfaceIdForTesting() const { | 600 cc::SurfaceId RenderWidgetHostViewChildFrame::SurfaceIdForTesting() const { |
| 579 return surface_id_; | 601 return surface_id_; |
| 580 }; | 602 }; |
| 581 | 603 |
| 582 } // namespace content | 604 } // namespace content |
| OLD | NEW |