Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(371)

Side by Side Diff: content/browser/renderer_host/render_widget_host_impl.cc

Issue 300323005: Route selection bounds updates through the compositor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updates Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/renderer_host/render_widget_host_impl.h" 5 #include "content/browser/renderer_host/render_widget_host_impl.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 #include <set> 8 #include <set>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 111
112 const float window_width_dip = 112 const float window_width_dip =
113 std::ceil(metadata.page_scale_factor * metadata.viewport_size.width()); 113 std::ceil(metadata.page_scale_factor * metadata.viewport_size.width());
114 const float content_width_css = metadata.root_layer_size.width(); 114 const float content_width_css = metadata.root_layer_size.width();
115 if (content_width_css <= window_width_dip) 115 if (content_width_css <= window_width_dip)
116 view_flags |= InputRouter::MOBILE_VIEWPORT; 116 view_flags |= InputRouter::MOBILE_VIEWPORT;
117 117
118 return view_flags; 118 return view_flags;
119 } 119 }
120 120
121 // TODO(jdduke): Remove when all platforms use CompositorFrameMetadata directly
122 // and ViewHostMsg_SelectionBounds_Params is no long necessary.
123 bool GetSelectionBounds(const cc::CompositorFrameMetadata& metadata,
124 ViewHostMsg_SelectionBounds_Params* bounds) {
125 if (metadata.start_selection_handle.type == cc::SelectionHandle::IGNORED)
126 return false;
127 ViewHostMsg_SelectionBounds_Params params;
128 bounds->anchor_rect = metadata.start_selection_handle.bounds;
129 bounds->focus_rect = metadata.end_selection_handle.bounds;
130 if (metadata.start_selection_handle.type == cc::SelectionHandle::CENTER)
131 bounds->focus_rect = bounds->anchor_rect;
132 // TODO(jdduke): Determine from data.
133 bounds->anchor_dir = blink::WebTextDirectionDefault;
134 bounds->focus_dir = blink::WebTextDirectionDefault;
135 bounds->is_anchor_first =
136 metadata.start_selection_handle.type == cc::SelectionHandle::LEFT;
137 bounds->is_anchor_visible = metadata.start_selection_handle.visible;
138 bounds->is_focus_visible = metadata.end_selection_handle.visible;
139 return true;
140 }
141
121 // Implements the RenderWidgetHostIterator interface. It keeps a list of 142 // Implements the RenderWidgetHostIterator interface. It keeps a list of
122 // RenderWidgetHosts, and makes sure it returns a live RenderWidgetHost at each 143 // RenderWidgetHosts, and makes sure it returns a live RenderWidgetHost at each
123 // iteration (or NULL if there isn't any left). 144 // iteration (or NULL if there isn't any left).
124 class RenderWidgetHostIteratorImpl : public RenderWidgetHostIterator { 145 class RenderWidgetHostIteratorImpl : public RenderWidgetHostIterator {
125 public: 146 public:
126 RenderWidgetHostIteratorImpl() 147 RenderWidgetHostIteratorImpl()
127 : current_index_(0) { 148 : current_index_(0) {
128 } 149 }
129 150
130 virtual ~RenderWidgetHostIteratorImpl() { 151 virtual ~RenderWidgetHostIteratorImpl() {
(...skipping 1345 matching lines...) Expand 10 before | Expand all | Expand 10 after
1476 uint32 output_surface_id = param.a; 1497 uint32 output_surface_id = param.a;
1477 param.b.AssignTo(frame.get()); 1498 param.b.AssignTo(frame.get());
1478 1499
1479 for (size_t i = 0; i < frame->metadata.latency_info.size(); i++) 1500 for (size_t i = 0; i < frame->metadata.latency_info.size(); i++)
1480 AddLatencyInfoComponentIds(&frame->metadata.latency_info[i]); 1501 AddLatencyInfoComponentIds(&frame->metadata.latency_info[i]);
1481 1502
1482 input_router_->OnViewUpdated( 1503 input_router_->OnViewUpdated(
1483 GetInputRouterViewFlagsFromCompositorFrameMetadata(frame->metadata)); 1504 GetInputRouterViewFlagsFromCompositorFrameMetadata(frame->metadata));
1484 1505
1485 if (view_) { 1506 if (view_) {
1507 ViewHostMsg_SelectionBounds_Params bounds;
1508 if (GetSelectionBounds(frame->metadata, &bounds))
1509 OnSelectionBoundsChanged(bounds);
1510
1486 view_->OnSwapCompositorFrame(output_surface_id, frame.Pass()); 1511 view_->OnSwapCompositorFrame(output_surface_id, frame.Pass());
1487 view_->DidReceiveRendererFrame(); 1512 view_->DidReceiveRendererFrame();
1488 } else { 1513 } else {
1489 cc::CompositorFrameAck ack; 1514 cc::CompositorFrameAck ack;
1490 if (frame->gl_frame_data) { 1515 if (frame->gl_frame_data) {
1491 ack.gl_frame_data = frame->gl_frame_data.Pass(); 1516 ack.gl_frame_data = frame->gl_frame_data.Pass();
1492 ack.gl_frame_data->sync_point = 0; 1517 ack.gl_frame_data->sync_point = 0;
1493 } else if (frame->delegated_frame_data) { 1518 } else if (frame->delegated_frame_data) {
1494 cc::TransferableResource::ReturnResources( 1519 cc::TransferableResource::ReturnResources(
1495 frame->delegated_frame_data->resource_list, 1520 frame->delegated_frame_data->resource_list,
(...skipping 831 matching lines...) Expand 10 before | Expand all | Expand 10 after
2327 } 2352 }
2328 } 2353 }
2329 2354
2330 SkBitmap::Config RenderWidgetHostImpl::PreferredReadbackFormat() { 2355 SkBitmap::Config RenderWidgetHostImpl::PreferredReadbackFormat() {
2331 if (view_) 2356 if (view_)
2332 return view_->PreferredReadbackFormat(); 2357 return view_->PreferredReadbackFormat();
2333 return SkBitmap::kARGB_8888_Config; 2358 return SkBitmap::kARGB_8888_Config;
2334 } 2359 }
2335 2360
2336 } // namespace content 2361 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698