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/cross_process_frame_connector.h" | 5 #include "content/browser/frame_host/cross_process_frame_connector.h" |
| 6 | 6 |
| 7 #include "cc/surfaces/surface.h" | 7 #include "cc/surfaces/surface.h" |
| 8 #include "cc/surfaces/surface_hittest.h" | |
| 8 #include "cc/surfaces/surface_manager.h" | 9 #include "cc/surfaces/surface_manager.h" |
| 9 #include "content/browser/compositor/surface_utils.h" | 10 #include "content/browser/compositor/surface_utils.h" |
| 10 #include "content/browser/frame_host/frame_tree.h" | 11 #include "content/browser/frame_host/frame_tree.h" |
| 11 #include "content/browser/frame_host/frame_tree_node.h" | 12 #include "content/browser/frame_host/frame_tree_node.h" |
| 12 #include "content/browser/frame_host/render_frame_host_manager.h" | 13 #include "content/browser/frame_host/render_frame_host_manager.h" |
| 13 #include "content/browser/frame_host/render_frame_proxy_host.h" | 14 #include "content/browser/frame_host/render_frame_proxy_host.h" |
| 14 #include "content/browser/frame_host/render_widget_host_view_child_frame.h" | 15 #include "content/browser/frame_host/render_widget_host_view_child_frame.h" |
| 15 #include "content/browser/renderer_host/render_view_host_impl.h" | 16 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 16 #include "content/browser/renderer_host/render_widget_host_delegate.h" | 17 #include "content/browser/renderer_host/render_widget_host_delegate.h" |
| 17 #include "content/browser/renderer_host/render_widget_host_impl.h" | 18 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 18 #include "content/browser/renderer_host/render_widget_host_input_event_router.h" | 19 #include "content/browser/renderer_host/render_widget_host_input_event_router.h" |
| 19 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 20 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
| 20 #include "content/common/frame_messages.h" | 21 #include "content/common/frame_messages.h" |
| 21 #include "gpu/ipc/common/gpu_messages.h" | 22 #include "gpu/ipc/common/gpu_messages.h" |
| 22 #include "third_party/WebKit/public/web/WebInputEvent.h" | 23 #include "third_party/WebKit/public/web/WebInputEvent.h" |
| 24 #include "ui/gfx/geometry/dip_util.h" | |
| 23 | 25 |
| 24 namespace content { | 26 namespace content { |
| 25 | 27 |
| 26 CrossProcessFrameConnector::CrossProcessFrameConnector( | 28 CrossProcessFrameConnector::CrossProcessFrameConnector( |
| 27 RenderFrameProxyHost* frame_proxy_in_parent_renderer) | 29 RenderFrameProxyHost* frame_proxy_in_parent_renderer) |
| 28 : frame_proxy_in_parent_renderer_(frame_proxy_in_parent_renderer), | 30 : frame_proxy_in_parent_renderer_(frame_proxy_in_parent_renderer), |
| 29 view_(nullptr), | 31 view_(nullptr), |
| 30 device_scale_factor_(1), | 32 device_scale_factor_(1), |
| 31 is_scroll_bubbling_(false) {} | 33 is_scroll_bubbling_(false) {} |
| 32 | 34 |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 129 } | 131 } |
| 130 | 132 |
| 131 void CrossProcessFrameConnector::UpdateCursor(const WebCursor& cursor) { | 133 void CrossProcessFrameConnector::UpdateCursor(const WebCursor& cursor) { |
| 132 RenderWidgetHostViewBase* root_view = GetRootRenderWidgetHostView(); | 134 RenderWidgetHostViewBase* root_view = GetRootRenderWidgetHostView(); |
| 133 if (root_view) | 135 if (root_view) |
| 134 root_view->UpdateCursor(cursor); | 136 root_view->UpdateCursor(cursor); |
| 135 } | 137 } |
| 136 | 138 |
| 137 gfx::Point CrossProcessFrameConnector::TransformPointToRootCoordSpace( | 139 gfx::Point CrossProcessFrameConnector::TransformPointToRootCoordSpace( |
| 138 const gfx::Point& point, | 140 const gfx::Point& point, |
| 139 cc::SurfaceId surface_id) { | 141 const cc::SurfaceId& surface_id) { |
| 140 gfx::Point transformed_point = point; | 142 return TransformPointToCoordSpaceForView(point, GetRootRenderWidgetHostView(), |
| 143 surface_id); | |
| 144 } | |
| 145 | |
| 146 gfx::Point CrossProcessFrameConnector::TransformPointToLocalCoordSpace( | |
| 147 const gfx::Point& point, | |
| 148 const cc::SurfaceId& original_surface, | |
| 149 const cc::SurfaceId& local_surface_id) { | |
| 150 if (original_surface == local_surface_id) | |
| 151 return point; | |
| 152 | |
| 153 // Transformations use physical pixels rather than DIP, so conversion | |
| 154 // is necessary. | |
| 155 gfx::Point point_in_pixels = | |
| 156 gfx::ConvertPointToPixel(device_scale_factor_, point); | |
| 157 gfx::Transform transform; | |
| 158 gfx::Point transformed_point = point_in_pixels; | |
| 159 cc::SurfaceHittest hittest(nullptr, GetSurfaceManager()); | |
| 160 // Two possibilities need to be considered: original_surface can be embedded | |
| 161 // in local_surface_id, or vice versa. | |
| 162 if (hittest.GetTransformToTargetSurface(local_surface_id, original_surface, | |
| 163 &transform) && | |
| 164 transform.GetInverse(&transform)) { | |
| 165 transform.TransformPoint(&transformed_point); | |
| 166 } else if (hittest.GetTransformToTargetSurface( | |
| 167 original_surface, local_surface_id, &transform)) { | |
| 168 // No need to invert the transform matrix in this case. | |
| 169 transform.TransformPoint(&transformed_point); | |
| 170 } else { | |
| 171 // Neither surface is embedded in the other, which violates the | |
| 172 // preconditions of this method. | |
| 173 DCHECK(false); | |
| 174 return point; | |
| 175 } | |
| 176 return gfx::ConvertPointToDIP(device_scale_factor_, transformed_point); | |
| 177 } | |
| 178 | |
| 179 gfx::Point CrossProcessFrameConnector::TransformPointToCoordSpaceForView( | |
| 180 const gfx::Point& point, | |
| 181 RenderWidgetHostViewBase* target_view, | |
| 182 const cc::SurfaceId& local_surface_id) { | |
| 141 RenderWidgetHostViewBase* root_view = GetRootRenderWidgetHostView(); | 183 RenderWidgetHostViewBase* root_view = GetRootRenderWidgetHostView(); |
| 142 if (root_view) | 184 if (!root_view) |
|
nasko
2016/07/27 22:52:13
How would root_view be null?
kenrb
2016/07/28 16:24:36
I don't know, but it might be possible for it to h
| |
| 143 root_view->TransformPointToLocalCoordSpace(point, surface_id, | 185 return point; |
| 144 &transformed_point); | 186 |
| 145 return transformed_point; | 187 // It is possible that neither the original surface or target surface is an |
| 188 // ancestor of the other in the RenderWidgetHostView tree (e.g. they could | |
| 189 // be siblings). To account for this, the point is first tranformed into the | |
| 190 // root coordinate space and then the root is asked to perform the conversion. | |
| 191 gfx::Point root_point = | |
| 192 root_view->TransformPointToLocalCoordSpace(point, local_surface_id); | |
| 193 | |
| 194 if (target_view == root_view) | |
| 195 return root_point; | |
| 196 | |
| 197 return root_view->TransformPointToCoordSpaceForView(point, target_view); | |
| 146 } | 198 } |
| 147 | 199 |
| 148 void CrossProcessFrameConnector::ForwardProcessAckedTouchEvent( | 200 void CrossProcessFrameConnector::ForwardProcessAckedTouchEvent( |
| 149 const TouchEventWithLatencyInfo& touch, | 201 const TouchEventWithLatencyInfo& touch, |
| 150 InputEventAckState ack_result) { | 202 InputEventAckState ack_result) { |
| 151 auto main_view = GetRootRenderWidgetHostView(); | 203 auto main_view = GetRootRenderWidgetHostView(); |
| 152 if (main_view) | 204 if (main_view) |
| 153 main_view->ProcessAckedTouchEvent(touch, ack_result); | 205 main_view->ProcessAckedTouchEvent(touch, ack_result); |
| 154 } | 206 } |
| 155 | 207 |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 350 | 402 |
| 351 if (parent) { | 403 if (parent) { |
| 352 return static_cast<RenderWidgetHostViewBase*>( | 404 return static_cast<RenderWidgetHostViewBase*>( |
| 353 parent->current_frame_host()->GetView()); | 405 parent->current_frame_host()->GetView()); |
| 354 } | 406 } |
| 355 | 407 |
| 356 return nullptr; | 408 return nullptr; |
| 357 } | 409 } |
| 358 | 410 |
| 359 } // namespace content | 411 } // namespace content |
| OLD | NEW |