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(RenderViewHostImpl::From(host_)); |
| 135 if (frame_connector_ && !is_guest) { |
| 136 RenderWidgetHostView* parent_view = |
| 137 frame_connector_->GetParentRenderWidgetHostView(); |
| 138 // The parent_view can be null in unit tests when using a TestWebContents. |
| 139 if (parent_view) |
| 140 return parent_view->GetVisibleViewportSize(); |
| 141 } |
| 142 return GetViewBounds().size(); |
| 143 } |
| 144 |
124 gfx::Vector2dF RenderWidgetHostViewChildFrame::GetLastScrollOffset() const { | 145 gfx::Vector2dF RenderWidgetHostViewChildFrame::GetLastScrollOffset() const { |
125 return last_scroll_offset_; | 146 return last_scroll_offset_; |
126 } | 147 } |
127 | 148 |
128 gfx::NativeView RenderWidgetHostViewChildFrame::GetNativeView() const { | 149 gfx::NativeView RenderWidgetHostViewChildFrame::GetNativeView() const { |
129 NOTREACHED(); | 150 NOTREACHED(); |
130 return NULL; | 151 return NULL; |
131 } | 152 } |
132 | 153 |
133 gfx::NativeViewId RenderWidgetHostViewChildFrame::GetNativeViewId() const { | 154 gfx::NativeViewId RenderWidgetHostViewChildFrame::GetNativeViewId() const { |
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
573 | 594 |
574 bool RenderWidgetHostViewChildFrame::IsChildFrameForTesting() const { | 595 bool RenderWidgetHostViewChildFrame::IsChildFrameForTesting() const { |
575 return true; | 596 return true; |
576 } | 597 } |
577 | 598 |
578 cc::SurfaceId RenderWidgetHostViewChildFrame::SurfaceIdForTesting() const { | 599 cc::SurfaceId RenderWidgetHostViewChildFrame::SurfaceIdForTesting() const { |
579 return surface_id_; | 600 return surface_id_; |
580 }; | 601 }; |
581 | 602 |
582 } // namespace content | 603 } // namespace content |
OLD | NEW |