| 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_hittest.h" |
| 9 #include "cc/surfaces/surface_manager.h" | 9 #include "cc/surfaces/surface_manager.h" |
| 10 #include "content/browser/compositor/surface_utils.h" | 10 #include "content/browser/compositor/surface_utils.h" |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 | 122 |
| 123 void CrossProcessFrameConnector::UpdateCursor(const WebCursor& cursor) { | 123 void CrossProcessFrameConnector::UpdateCursor(const WebCursor& cursor) { |
| 124 RenderWidgetHostViewBase* root_view = GetRootRenderWidgetHostView(); | 124 RenderWidgetHostViewBase* root_view = GetRootRenderWidgetHostView(); |
| 125 if (root_view) | 125 if (root_view) |
| 126 root_view->UpdateCursor(cursor); | 126 root_view->UpdateCursor(cursor); |
| 127 } | 127 } |
| 128 | 128 |
| 129 gfx::Point CrossProcessFrameConnector::TransformPointToRootCoordSpace( | 129 gfx::Point CrossProcessFrameConnector::TransformPointToRootCoordSpace( |
| 130 const gfx::Point& point, | 130 const gfx::Point& point, |
| 131 const cc::SurfaceId& surface_id) { | 131 const cc::SurfaceId& surface_id) { |
| 132 return TransformPointToCoordSpaceForView(point, GetRootRenderWidgetHostView(), | 132 gfx::Point transformed_point; |
| 133 surface_id); | 133 TransformPointToCoordSpaceForView(point, GetRootRenderWidgetHostView(), |
| 134 surface_id, &transformed_point); |
| 135 return transformed_point; |
| 134 } | 136 } |
| 135 | 137 |
| 136 gfx::Point CrossProcessFrameConnector::TransformPointToLocalCoordSpace( | 138 bool CrossProcessFrameConnector::TransformPointToLocalCoordSpace( |
| 137 const gfx::Point& point, | 139 const gfx::Point& point, |
| 138 const cc::SurfaceId& original_surface, | 140 const cc::SurfaceId& original_surface, |
| 139 const cc::SurfaceId& local_surface_id) { | 141 const cc::SurfaceId& local_surface_id, |
| 140 if (original_surface == local_surface_id) | 142 gfx::Point* transformed_point) { |
| 141 return point; | 143 if (original_surface == local_surface_id) { |
| 144 *transformed_point = point; |
| 145 return true; |
| 146 } |
| 142 | 147 |
| 143 // Transformations use physical pixels rather than DIP, so conversion | 148 // Transformations use physical pixels rather than DIP, so conversion |
| 144 // is necessary. | 149 // is necessary. |
| 145 gfx::Point transformed_point = | 150 *transformed_point = |
| 146 gfx::ConvertPointToPixel(view_->current_surface_scale_factor(), point); | 151 gfx::ConvertPointToPixel(view_->current_surface_scale_factor(), point); |
| 147 cc::SurfaceHittest hittest(nullptr, GetSurfaceManager()); | 152 cc::SurfaceHittest hittest(nullptr, GetSurfaceManager()); |
| 148 if (!hittest.TransformPointToTargetSurface(original_surface, local_surface_id, | 153 if (!hittest.TransformPointToTargetSurface(original_surface, local_surface_id, |
| 149 &transformed_point)) | 154 transformed_point)) |
| 150 DCHECK(false); | 155 return false; |
| 151 | 156 |
| 152 return gfx::ConvertPointToDIP(view_->current_surface_scale_factor(), | 157 *transformed_point = gfx::ConvertPointToDIP( |
| 153 transformed_point); | 158 view_->current_surface_scale_factor(), *transformed_point); |
| 159 return true; |
| 154 } | 160 } |
| 155 | 161 |
| 156 gfx::Point CrossProcessFrameConnector::TransformPointToCoordSpaceForView( | 162 bool CrossProcessFrameConnector::TransformPointToCoordSpaceForView( |
| 157 const gfx::Point& point, | 163 const gfx::Point& point, |
| 158 RenderWidgetHostViewBase* target_view, | 164 RenderWidgetHostViewBase* target_view, |
| 159 const cc::SurfaceId& local_surface_id) { | 165 const cc::SurfaceId& local_surface_id, |
| 166 gfx::Point* transformed_point) { |
| 160 RenderWidgetHostViewBase* root_view = GetRootRenderWidgetHostView(); | 167 RenderWidgetHostViewBase* root_view = GetRootRenderWidgetHostView(); |
| 161 if (!root_view) | 168 if (!root_view) |
| 162 return point; | 169 return false; |
| 163 | 170 |
| 164 // It is possible that neither the original surface or target surface is an | 171 // It is possible that neither the original surface or target surface is an |
| 165 // ancestor of the other in the RenderWidgetHostView tree (e.g. they could | 172 // ancestor of the other in the RenderWidgetHostView tree (e.g. they could |
| 166 // be siblings). To account for this, the point is first tranformed into the | 173 // be siblings). To account for this, the point is first transformed into the |
| 167 // root coordinate space and then the root is asked to perform the conversion. | 174 // root coordinate space and then the root is asked to perform the conversion. |
| 168 gfx::Point root_point = | 175 if (!root_view->TransformPointToLocalCoordSpace(point, local_surface_id, |
| 169 root_view->TransformPointToLocalCoordSpace(point, local_surface_id); | 176 transformed_point)) |
| 177 return false; |
| 170 | 178 |
| 171 if (target_view == root_view) | 179 if (target_view == root_view) |
| 172 return root_point; | 180 return true; |
| 173 | 181 |
| 174 return root_view->TransformPointToCoordSpaceForView(point, target_view); | 182 return root_view->TransformPointToCoordSpaceForView( |
| 183 *transformed_point, target_view, transformed_point); |
| 175 } | 184 } |
| 176 | 185 |
| 177 void CrossProcessFrameConnector::ForwardProcessAckedTouchEvent( | 186 void CrossProcessFrameConnector::ForwardProcessAckedTouchEvent( |
| 178 const TouchEventWithLatencyInfo& touch, | 187 const TouchEventWithLatencyInfo& touch, |
| 179 InputEventAckState ack_result) { | 188 InputEventAckState ack_result) { |
| 180 auto* main_view = GetRootRenderWidgetHostView(); | 189 auto* main_view = GetRootRenderWidgetHostView(); |
| 181 if (main_view) | 190 if (main_view) |
| 182 main_view->ProcessAckedTouchEvent(touch, ack_result); | 191 main_view->ProcessAckedTouchEvent(touch, ack_result); |
| 183 } | 192 } |
| 184 | 193 |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 | 378 |
| 370 if (parent) { | 379 if (parent) { |
| 371 return static_cast<RenderWidgetHostViewBase*>( | 380 return static_cast<RenderWidgetHostViewBase*>( |
| 372 parent->current_frame_host()->GetView()); | 381 parent->current_frame_host()->GetView()); |
| 373 } | 382 } |
| 374 | 383 |
| 375 return nullptr; | 384 return nullptr; |
| 376 } | 385 } |
| 377 | 386 |
| 378 } // namespace content | 387 } // namespace content |
| OLD | NEW |