summaryrefslogtreecommitdiffstats
path: root/cc
diff options
context:
space:
mode:
authorjdduke <jdduke@chromium.org>2015-04-23 12:36:44 -0700
committerCommit bot <commit-bot@chromium.org>2015-04-23 19:36:51 +0000
commit449b529362950ccdfc48715146a466d7278b75dd (patch)
treeec64c472a9264aa6a4f0d0cccf198a2610e9d58e /cc
parent2c2273d86f318ab7a46ce047266432e1f1089443 (diff)
downloadchromium_src-449b529362950ccdfc48715146a466d7278b75dd.zip
chromium_src-449b529362950ccdfc48715146a466d7278b75dd.tar.gz
chromium_src-449b529362950ccdfc48715146a466d7278b75dd.tar.bz2
Plumb selection bounds as a single unit
Route the new WebSelectionBounds selection unit from Blink atomically, rather than using a pair of data structures to indicate selection. This depends directly on crrev.com/929213004. BUG=466672,410543,417903 Review URL: https://codereview.chromium.org/1000243002 Cr-Commit-Position: refs/heads/master@{#326606}
Diffstat (limited to 'cc')
-rw-r--r--cc/BUILD.gn1
-rw-r--r--cc/cc.gyp1
-rw-r--r--cc/input/layer_selection_bound.h3
-rw-r--r--cc/input/selection.h38
-rw-r--r--cc/output/compositor_frame_metadata.h3
-rw-r--r--cc/output/viewport_selection_bound.h4
-rw-r--r--cc/trees/layer_tree_host.cc10
-rw-r--r--cc/trees/layer_tree_host.h6
-rw-r--r--cc/trees/layer_tree_host_impl.cc3
-rw-r--r--cc/trees/layer_tree_host_impl_unittest.cc42
-rw-r--r--cc/trees/layer_tree_impl.cc36
-rw-r--r--cc/trees/layer_tree_impl.h10
-rw-r--r--cc/trees/layer_tree_impl_unittest.cc235
13 files changed, 214 insertions, 178 deletions
diff --git a/cc/BUILD.gn b/cc/BUILD.gn
index b35560a..c0987c8 100644
--- a/cc/BUILD.gn
+++ b/cc/BUILD.gn
@@ -98,6 +98,7 @@ component("cc") {
"input/page_scale_animation.h",
"input/scroll_elasticity_helper.cc",
"input/scroll_elasticity_helper.h",
+ "input/selection.h",
"input/selection_bound_type.h",
"input/top_controls_manager.cc",
"input/top_controls_manager.h",
diff --git a/cc/cc.gyp b/cc/cc.gyp
index aeea018..96001ef 100644
--- a/cc/cc.gyp
+++ b/cc/cc.gyp
@@ -153,6 +153,7 @@
'input/scroll_elasticity_helper.cc',
'input/scroll_elasticity_helper.h',
'input/selection_bound_type.h',
+ 'input/selection.h',
'input/top_controls_manager.cc',
'input/top_controls_manager.h',
'input/top_controls_manager_client.h',
diff --git a/cc/input/layer_selection_bound.h b/cc/input/layer_selection_bound.h
index 21d5284..10b14d9 100644
--- a/cc/input/layer_selection_bound.h
+++ b/cc/input/layer_selection_bound.h
@@ -6,6 +6,7 @@
#define CC_INPUT_LAYER_SELECTION_BOUND_H_
#include "cc/base/cc_export.h"
+#include "cc/input/selection.h"
#include "cc/input/selection_bound_type.h"
#include "ui/gfx/geometry/point_f.h"
@@ -25,6 +26,8 @@ struct CC_EXPORT LayerSelectionBound {
bool operator==(const LayerSelectionBound& lhs, const LayerSelectionBound& rhs);
bool operator!=(const LayerSelectionBound& lhs, const LayerSelectionBound& rhs);
+typedef Selection<LayerSelectionBound> LayerSelection;
+
} // namespace cc
#endif // CC_INPUT_LAYER_SELECTION_BOUND_H_
diff --git a/cc/input/selection.h b/cc/input/selection.h
new file mode 100644
index 0000000..1f3c6eb
--- /dev/null
+++ b/cc/input/selection.h
@@ -0,0 +1,38 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CC_INPUT_SELECTION_H_
+#define CC_INPUT_SELECTION_H_
+
+#include "cc/base/cc_export.h"
+
+namespace cc {
+
+template <typename BoundType>
+struct CC_EXPORT Selection {
+ Selection() : is_editable(false), is_empty_text_form_control(false) {}
+ ~Selection() {}
+
+ BoundType start, end;
+ bool is_editable;
+ bool is_empty_text_form_control;
+};
+
+template <typename BoundType>
+inline bool operator==(const Selection<BoundType>& lhs,
+ const Selection<BoundType>& rhs) {
+ return lhs.start == rhs.start && lhs.end == rhs.end &&
+ lhs.is_editable == rhs.is_editable &&
+ lhs.is_empty_text_form_control == rhs.is_empty_text_form_control;
+}
+
+template <typename BoundType>
+inline bool operator!=(const Selection<BoundType>& lhs,
+ const Selection<BoundType>& rhs) {
+ return !(lhs == rhs);
+}
+
+} // namespace cc
+
+#endif // CC_INPUT_SELECTION_H_
diff --git a/cc/output/compositor_frame_metadata.h b/cc/output/compositor_frame_metadata.h
index e92a84d..999a6b4 100644
--- a/cc/output/compositor_frame_metadata.h
+++ b/cc/output/compositor_frame_metadata.h
@@ -44,8 +44,7 @@ class CC_EXPORT CompositorFrameMetadata {
// Provides selection region updates relative to the current viewport. If the
// selection is empty or otherwise unused, the bound types will indicate such.
- ViewportSelectionBound selection_start;
- ViewportSelectionBound selection_end;
+ ViewportSelection selection;
std::vector<ui::LatencyInfo> latency_info;
diff --git a/cc/output/viewport_selection_bound.h b/cc/output/viewport_selection_bound.h
index 77298e7..2e4fe3c 100644
--- a/cc/output/viewport_selection_bound.h
+++ b/cc/output/viewport_selection_bound.h
@@ -6,12 +6,14 @@
#define CC_OUTPUT_VIEWPORT_SELECTION_BOUND_H_
#include "cc/base/cc_export.h"
+#include "cc/input/selection.h"
#include "cc/input/selection_bound_type.h"
#include "ui/gfx/geometry/point_f.h"
namespace cc {
// Marker for a selection end-point in (DIP) viewport coordinates.
+// TODO(jdduke): Move this to ui/gfx and merge with ui::SelectionBound.
struct CC_EXPORT ViewportSelectionBound {
ViewportSelectionBound();
~ViewportSelectionBound();
@@ -27,6 +29,8 @@ CC_EXPORT bool operator==(const ViewportSelectionBound& lhs,
CC_EXPORT bool operator!=(const ViewportSelectionBound& lhs,
const ViewportSelectionBound& rhs);
+typedef Selection<ViewportSelectionBound> ViewportSelection;
+
} // namespace cc
#endif // CC_OUTPUT_VIEWPORT_SELECTION_BOUND_H_
diff --git a/cc/trees/layer_tree_host.cc b/cc/trees/layer_tree_host.cc
index 6dc3e96..53aea75 100644
--- a/cc/trees/layer_tree_host.cc
+++ b/cc/trees/layer_tree_host.cc
@@ -325,7 +325,7 @@ void LayerTreeHost::FinishCommitOnImplThread(LayerTreeHostImpl* host_impl) {
sync_tree->ClearViewportLayers();
}
- sync_tree->RegisterSelection(selection_start_, selection_end_);
+ sync_tree->RegisterSelection(selection_);
sync_tree->PushPageScaleFromMainThread(
page_scale_factor_, min_page_scale_factor_, max_page_scale_factor_);
@@ -1222,13 +1222,11 @@ void LayerTreeHost::RegisterViewportLayers(
outer_viewport_scroll_layer_ = outer_viewport_scroll_layer;
}
-void LayerTreeHost::RegisterSelection(const LayerSelectionBound& start,
- const LayerSelectionBound& end) {
- if (selection_start_ == start && selection_end_ == end)
+void LayerTreeHost::RegisterSelection(const LayerSelection& selection) {
+ if (selection_ == selection)
return;
- selection_start_ = start;
- selection_end_ = end;
+ selection_ = selection;
SetNeedsCommit();
}
diff --git a/cc/trees/layer_tree_host.h b/cc/trees/layer_tree_host.h
index 742578a..bd53413 100644
--- a/cc/trees/layer_tree_host.h
+++ b/cc/trees/layer_tree_host.h
@@ -182,8 +182,7 @@ class CC_EXPORT LayerTreeHost {
return outer_viewport_scroll_layer_.get();
}
- void RegisterSelection(const LayerSelectionBound& start,
- const LayerSelectionBound& end);
+ void RegisterSelection(const LayerSelection& selection);
const LayerTreeSettings& settings() const { return settings_; }
@@ -444,8 +443,7 @@ class CC_EXPORT LayerTreeHost {
scoped_refptr<Layer> inner_viewport_scroll_layer_;
scoped_refptr<Layer> outer_viewport_scroll_layer_;
- LayerSelectionBound selection_start_;
- LayerSelectionBound selection_end_;
+ LayerSelection selection_;
SharedBitmapManager* shared_bitmap_manager_;
gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager_;
diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc
index 7f40c98..1b1f6fc 100644
--- a/cc/trees/layer_tree_host_impl.cc
+++ b/cc/trees/layer_tree_host_impl.cc
@@ -1435,8 +1435,7 @@ CompositorFrameMetadata LayerTreeHostImpl::MakeCompositorFrameMetadata() const {
metadata.location_bar_content_translation =
gfx::Vector2dF(0.f, top_controls_manager_->ContentTopOffset());
- active_tree_->GetViewportSelection(&metadata.selection_start,
- &metadata.selection_end);
+ active_tree_->GetViewportSelection(&metadata.selection);
LayerImpl* root_layer_for_overflow = OuterViewportScrollLayer()
? OuterViewportScrollLayer()
diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc
index be18719..073d5ae 100644
--- a/cc/trees/layer_tree_host_impl_unittest.cc
+++ b/cc/trees/layer_tree_host_impl_unittest.cc
@@ -6525,23 +6525,21 @@ TEST_F(LayerTreeHostImplTest, SelectionBoundsPassedToCompositorFrameMetadata) {
// Ensure the default frame selection bounds are empty.
FakeOutputSurface* fake_output_surface =
static_cast<FakeOutputSurface*>(host_impl_->output_surface());
- const ViewportSelectionBound& selection_start_before =
- fake_output_surface->last_sent_frame().metadata.selection_start;
- const ViewportSelectionBound& selection_end_before =
- fake_output_surface->last_sent_frame().metadata.selection_end;
- EXPECT_EQ(ViewportSelectionBound(), selection_start_before);
- EXPECT_EQ(ViewportSelectionBound(), selection_end_before);
+ const ViewportSelection& selection_before =
+ fake_output_surface->last_sent_frame().metadata.selection;
+ EXPECT_EQ(ViewportSelectionBound(), selection_before.start);
+ EXPECT_EQ(ViewportSelectionBound(), selection_before.end);
// Plumb the layer-local selection bounds.
gfx::PointF selection_top(5, 0);
gfx::PointF selection_bottom(5, 5);
- LayerSelectionBound start, end;
- start.type = SELECTION_BOUND_CENTER;
- start.layer_id = root_layer_id;
- start.edge_bottom = selection_bottom;
- start.edge_top = selection_top;
- end = start;
- host_impl_->active_tree()->RegisterSelection(start, end);
+ LayerSelection selection;
+ selection.start.type = SELECTION_BOUND_CENTER;
+ selection.start.layer_id = root_layer_id;
+ selection.start.edge_bottom = selection_bottom;
+ selection.start.edge_top = selection_top;
+ selection.end = selection.start;
+ host_impl_->active_tree()->RegisterSelection(selection);
// Trigger a draw-swap sequence.
host_impl_->SetNeedsRedraw();
@@ -6554,16 +6552,14 @@ TEST_F(LayerTreeHostImplTest, SelectionBoundsPassedToCompositorFrameMetadata) {
EXPECT_TRUE(host_impl_->SwapBuffers(frame));
// Ensure the selection bounds have propagated to the frame metadata.
- const ViewportSelectionBound& selection_start_after =
- fake_output_surface->last_sent_frame().metadata.selection_start;
- const ViewportSelectionBound& selection_end_after =
- fake_output_surface->last_sent_frame().metadata.selection_end;
- EXPECT_EQ(start.type, selection_start_after.type);
- EXPECT_EQ(end.type, selection_end_after.type);
- EXPECT_EQ(selection_bottom, selection_start_after.edge_bottom);
- EXPECT_EQ(selection_top, selection_start_after.edge_top);
- EXPECT_TRUE(selection_start_after.visible);
- EXPECT_TRUE(selection_start_after.visible);
+ const ViewportSelection& selection_after =
+ fake_output_surface->last_sent_frame().metadata.selection;
+ EXPECT_EQ(selection.start.type, selection_after.start.type);
+ EXPECT_EQ(selection.end.type, selection_after.end.type);
+ EXPECT_EQ(selection_bottom, selection_after.start.edge_bottom);
+ EXPECT_EQ(selection_top, selection_after.start.edge_top);
+ EXPECT_TRUE(selection_after.start.visible);
+ EXPECT_TRUE(selection_after.start.visible);
}
class SimpleSwapPromiseMonitor : public SwapPromiseMonitor {
diff --git a/cc/trees/layer_tree_impl.cc b/cc/trees/layer_tree_impl.cc
index 7721976..25f48d6 100644
--- a/cc/trees/layer_tree_impl.cc
+++ b/cc/trees/layer_tree_impl.cc
@@ -226,7 +226,7 @@ void LayerTreeImpl::PushPropertiesTo(LayerTreeImpl* target_tree) {
target_tree->ClearViewportLayers();
}
- target_tree->RegisterSelection(selection_start_, selection_end_);
+ target_tree->RegisterSelection(selection_);
// This should match the property synchronization in
// LayerTreeHost::finishCommitOnImplThread().
@@ -1473,13 +1473,11 @@ LayerImpl* LayerTreeImpl::FindLayerThatIsHitByPointInTouchHandlerRegion(
return data_for_recursion.closest_match;
}
-void LayerTreeImpl::RegisterSelection(const LayerSelectionBound& start,
- const LayerSelectionBound& end) {
- selection_start_ = start;
- selection_end_ = end;
+void LayerTreeImpl::RegisterSelection(const LayerSelection& selection) {
+ selection_ = selection;
}
-static ViewportSelectionBound ComputeViewportSelection(
+static ViewportSelectionBound ComputeViewportSelectionBound(
const LayerSelectionBound& layer_bound,
LayerImpl* layer,
float device_scale_factor) {
@@ -1526,22 +1524,22 @@ static ViewportSelectionBound ComputeViewportSelection(
return viewport_bound;
}
-void LayerTreeImpl::GetViewportSelection(ViewportSelectionBound* start,
- ViewportSelectionBound* end) {
- DCHECK(start);
- DCHECK(end);
+void LayerTreeImpl::GetViewportSelection(ViewportSelection* selection) {
+ DCHECK(selection);
- *start = ComputeViewportSelection(
- selection_start_,
- selection_start_.layer_id ? LayerById(selection_start_.layer_id) : NULL,
+ selection->start = ComputeViewportSelectionBound(
+ selection_.start,
+ selection_.start.layer_id ? LayerById(selection_.start.layer_id) : NULL,
device_scale_factor());
- if (start->type == SELECTION_BOUND_CENTER ||
- start->type == SELECTION_BOUND_EMPTY) {
- *end = *start;
+ selection->is_editable = selection_.is_editable;
+ selection->is_empty_text_form_control = selection_.is_empty_text_form_control;
+ if (selection->start.type == SELECTION_BOUND_CENTER ||
+ selection->start.type == SELECTION_BOUND_EMPTY) {
+ selection->end = selection->start;
} else {
- *end = ComputeViewportSelection(
- selection_end_,
- selection_end_.layer_id ? LayerById(selection_end_.layer_id) : NULL,
+ selection->end = ComputeViewportSelectionBound(
+ selection_.end,
+ selection_.end.layer_id ? LayerById(selection_.end.layer_id) : NULL,
device_scale_factor());
}
}
diff --git a/cc/trees/layer_tree_impl.h b/cc/trees/layer_tree_impl.h
index d51c042..76911e1 100644
--- a/cc/trees/layer_tree_impl.h
+++ b/cc/trees/layer_tree_impl.h
@@ -51,7 +51,6 @@ class UIResourceRequest;
class VideoFrameControllerClient;
struct PendingPageScaleAnimation;
struct RendererCapabilities;
-struct SelectionHandle;
typedef std::vector<UIResourceRequest> UIResourceRequestQueue;
typedef SyncedProperty<AdditionGroup<float>> SyncedTopControls;
@@ -317,13 +316,11 @@ class CC_EXPORT LayerTreeImpl {
LayerImpl* FindLayerThatIsHitByPointInTouchHandlerRegion(
const gfx::PointF& screen_space_point);
- void RegisterSelection(const LayerSelectionBound& start,
- const LayerSelectionBound& end);
+ void RegisterSelection(const LayerSelection& selection);
// Compute the current selection handle location and visbility with respect to
// the viewport.
- void GetViewportSelection(ViewportSelectionBound* start,
- ViewportSelectionBound* end);
+ void GetViewportSelection(ViewportSelection* selection);
void set_top_controls_shrink_blink_size(bool shrink);
bool top_controls_shrink_blink_size() const {
@@ -376,8 +373,7 @@ class CC_EXPORT LayerTreeImpl {
LayerImpl* inner_viewport_scroll_layer_;
LayerImpl* outer_viewport_scroll_layer_;
- LayerSelectionBound selection_start_;
- LayerSelectionBound selection_end_;
+ LayerSelection selection_;
scoped_refptr<SyncedProperty<ScaleGroup>> page_scale_factor_;
float min_page_scale_factor_;
diff --git a/cc/trees/layer_tree_impl_unittest.cc b/cc/trees/layer_tree_impl_unittest.cc
index c4abd52..04c108f 100644
--- a/cc/trees/layer_tree_impl_unittest.cc
+++ b/cc/trees/layer_tree_impl_unittest.cc
@@ -1910,51 +1910,59 @@ TEST_F(LayerTreeImplTest, SelectionBoundsForSingleLayer) {
ASSERT_EQ(1u, RenderSurfaceLayerList().size());
ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size());
- LayerSelectionBound left_input;
- left_input.type = SELECTION_BOUND_LEFT;
- left_input.edge_top = gfx::PointF(10, 10);
- left_input.edge_bottom = gfx::PointF(10, 20);
- left_input.layer_id = root_layer_id;
+ LayerSelection input;
- LayerSelectionBound right_input;
- right_input.type = SELECTION_BOUND_RIGHT;
- right_input.edge_top = gfx::PointF(50, 10);
- right_input.edge_bottom = gfx::PointF(50, 30);
- right_input.layer_id = root_layer_id;
+ input.start.type = SELECTION_BOUND_LEFT;
+ input.start.edge_top = gfx::PointF(10, 10);
+ input.start.edge_bottom = gfx::PointF(10, 20);
+ input.start.layer_id = root_layer_id;
- ViewportSelectionBound left_output, right_output;
+ input.end.type = SELECTION_BOUND_RIGHT;
+ input.end.edge_top = gfx::PointF(50, 10);
+ input.end.edge_bottom = gfx::PointF(50, 30);
+ input.end.layer_id = root_layer_id;
+
+ ViewportSelection output;
// Empty input bounds should produce empty output bounds.
- host_impl().active_tree()->GetViewportSelection(&left_output, &right_output);
- EXPECT_EQ(ViewportSelectionBound(), left_output);
- EXPECT_EQ(ViewportSelectionBound(), right_output);
+ host_impl().active_tree()->GetViewportSelection(&output);
+ EXPECT_EQ(ViewportSelectionBound(), output.start);
+ EXPECT_EQ(ViewportSelectionBound(), output.end);
// Selection bounds should produce distinct left and right bounds.
- host_impl().active_tree()->RegisterSelection(left_input, right_input);
- host_impl().active_tree()->GetViewportSelection(&left_output, &right_output);
- EXPECT_EQ(left_input.type, left_output.type);
- EXPECT_EQ(left_input.edge_bottom, left_output.edge_bottom);
- EXPECT_EQ(left_input.edge_top, left_output.edge_top);
- EXPECT_TRUE(left_output.visible);
- EXPECT_EQ(right_input.type, right_output.type);
- EXPECT_EQ(right_input.edge_bottom, right_output.edge_bottom);
- EXPECT_EQ(right_input.edge_top, right_output.edge_top);
- EXPECT_TRUE(right_output.visible);
+ host_impl().active_tree()->RegisterSelection(input);
+ host_impl().active_tree()->GetViewportSelection(&output);
+ EXPECT_EQ(input.start.type, output.start.type);
+ EXPECT_EQ(input.start.edge_bottom, output.start.edge_bottom);
+ EXPECT_EQ(input.start.edge_top, output.start.edge_top);
+ EXPECT_TRUE(output.start.visible);
+ EXPECT_EQ(input.end.type, output.end.type);
+ EXPECT_EQ(input.end.edge_bottom, output.end.edge_bottom);
+ EXPECT_EQ(input.end.edge_top, output.end.edge_top);
+ EXPECT_TRUE(output.end.visible);
+ EXPECT_EQ(input.is_editable, output.is_editable);
+ EXPECT_EQ(input.is_empty_text_form_control,
+ output.is_empty_text_form_control);
// Insertion bounds should produce identical left and right bounds.
- LayerSelectionBound insertion_input;
- insertion_input.type = SELECTION_BOUND_CENTER;
- insertion_input.edge_top = gfx::PointF(15, 10);
- insertion_input.edge_bottom = gfx::PointF(15, 30);
- insertion_input.layer_id = root_layer_id;
- host_impl().active_tree()->RegisterSelection(insertion_input,
- LayerSelectionBound());
- host_impl().active_tree()->GetViewportSelection(&left_output, &right_output);
- EXPECT_EQ(insertion_input.type, left_output.type);
- EXPECT_EQ(insertion_input.edge_bottom, left_output.edge_bottom);
- EXPECT_EQ(insertion_input.edge_top, left_output.edge_top);
- EXPECT_TRUE(left_output.visible);
- EXPECT_EQ(left_output, right_output);
+ LayerSelection insertion_input;
+ insertion_input.start.type = SELECTION_BOUND_CENTER;
+ insertion_input.start.edge_top = gfx::PointF(15, 10);
+ insertion_input.start.edge_bottom = gfx::PointF(15, 30);
+ insertion_input.start.layer_id = root_layer_id;
+ insertion_input.is_editable = true;
+ insertion_input.is_empty_text_form_control = true;
+ insertion_input.end = insertion_input.start;
+ host_impl().active_tree()->RegisterSelection(insertion_input);
+ host_impl().active_tree()->GetViewportSelection(&output);
+ EXPECT_EQ(insertion_input.start.type, output.start.type);
+ EXPECT_EQ(insertion_input.start.edge_bottom, output.start.edge_bottom);
+ EXPECT_EQ(insertion_input.start.edge_top, output.start.edge_top);
+ EXPECT_EQ(insertion_input.is_editable, output.is_editable);
+ EXPECT_EQ(insertion_input.is_empty_text_form_control,
+ output.is_empty_text_form_control);
+ EXPECT_TRUE(output.start.visible);
+ EXPECT_EQ(output.start, output.end);
}
TEST_F(LayerTreeImplTest, SelectionBoundsForPartialOccludedLayers) {
@@ -2003,58 +2011,57 @@ TEST_F(LayerTreeImplTest, SelectionBoundsForPartialOccludedLayers) {
// Sanity check the scenario we just created.
ASSERT_EQ(1u, RenderSurfaceLayerList().size());
- LayerSelectionBound left_input;
- left_input.type = SELECTION_BOUND_LEFT;
- left_input.edge_top = gfx::PointF(25, 10);
- left_input.edge_bottom = gfx::PointF(25, 30);
- left_input.layer_id = clipped_layer_id;
+ LayerSelection input;
+ input.start.type = SELECTION_BOUND_LEFT;
+ input.start.edge_top = gfx::PointF(25, 10);
+ input.start.edge_bottom = gfx::PointF(25, 30);
+ input.start.layer_id = clipped_layer_id;
- LayerSelectionBound right_input;
- right_input.type = SELECTION_BOUND_RIGHT;
- right_input.edge_top = gfx::PointF(75, 10);
- right_input.edge_bottom = gfx::PointF(75, 30);
- right_input.layer_id = clipped_layer_id;
- host_impl().active_tree()->RegisterSelection(left_input, right_input);
+ input.end.type = SELECTION_BOUND_RIGHT;
+ input.end.edge_top = gfx::PointF(75, 10);
+ input.end.edge_bottom = gfx::PointF(75, 30);
+ input.end.layer_id = clipped_layer_id;
+ host_impl().active_tree()->RegisterSelection(input);
// The left bound should be occluded by the clip layer.
- ViewportSelectionBound left_output, right_output;
- host_impl().active_tree()->GetViewportSelection(&left_output, &right_output);
- EXPECT_EQ(left_input.type, left_output.type);
- gfx::PointF expected_left_output_top = left_input.edge_top;
- gfx::PointF expected_left_output_bottom = left_input.edge_bottom;
- expected_left_output_top.Offset(clipping_offset.x(), clipping_offset.y());
- expected_left_output_bottom.Offset(clipping_offset.x(), clipping_offset.y());
- EXPECT_EQ(expected_left_output_top, left_output.edge_top);
- EXPECT_EQ(expected_left_output_bottom, left_output.edge_bottom);
- EXPECT_TRUE(left_output.visible);
- EXPECT_EQ(right_input.type, right_output.type);
- gfx::PointF expected_right_output_top = right_input.edge_top;
- gfx::PointF expected_right_output_bottom = right_input.edge_bottom;
- expected_right_output_bottom.Offset(clipping_offset.x(), clipping_offset.y());
- expected_right_output_top.Offset(clipping_offset.x(), clipping_offset.y());
- EXPECT_EQ(expected_right_output_top, right_output.edge_top);
- EXPECT_EQ(expected_right_output_bottom, right_output.edge_bottom);
- EXPECT_FALSE(right_output.visible);
+ ViewportSelection output;
+ host_impl().active_tree()->GetViewportSelection(&output);
+ EXPECT_EQ(input.start.type, output.start.type);
+ gfx::PointF expected_output_start_top = input.start.edge_top;
+ gfx::PointF expected_output_edge_botom = input.start.edge_bottom;
+ expected_output_start_top.Offset(clipping_offset.x(), clipping_offset.y());
+ expected_output_edge_botom.Offset(clipping_offset.x(), clipping_offset.y());
+ EXPECT_EQ(expected_output_start_top, output.start.edge_top);
+ EXPECT_EQ(expected_output_edge_botom, output.start.edge_bottom);
+ EXPECT_TRUE(output.start.visible);
+ EXPECT_EQ(input.end.type, output.end.type);
+ gfx::PointF expected_output_end_top = input.end.edge_top;
+ gfx::PointF expected_output_end_bottom = input.end.edge_bottom;
+ expected_output_end_bottom.Offset(clipping_offset.x(), clipping_offset.y());
+ expected_output_end_top.Offset(clipping_offset.x(), clipping_offset.y());
+ EXPECT_EQ(expected_output_end_top, output.end.edge_top);
+ EXPECT_EQ(expected_output_end_bottom, output.end.edge_bottom);
+ EXPECT_FALSE(output.end.visible);
// Handles outside the viewport bounds should be marked invisible.
- left_input.edge_top = gfx::PointF(-25, 0);
- left_input.edge_bottom = gfx::PointF(-25, 20);
- host_impl().active_tree()->RegisterSelection(left_input, right_input);
- host_impl().active_tree()->GetViewportSelection(&left_output, &right_output);
- EXPECT_FALSE(left_output.visible);
-
- left_input.edge_top = gfx::PointF(0, -25);
- left_input.edge_bottom = gfx::PointF(0, -5);
- host_impl().active_tree()->RegisterSelection(left_input, right_input);
- host_impl().active_tree()->GetViewportSelection(&left_output, &right_output);
- EXPECT_FALSE(left_output.visible);
+ input.start.edge_top = gfx::PointF(-25, 0);
+ input.start.edge_bottom = gfx::PointF(-25, 20);
+ host_impl().active_tree()->RegisterSelection(input);
+ host_impl().active_tree()->GetViewportSelection(&output);
+ EXPECT_FALSE(output.start.visible);
+
+ input.start.edge_top = gfx::PointF(0, -25);
+ input.start.edge_bottom = gfx::PointF(0, -5);
+ host_impl().active_tree()->RegisterSelection(input);
+ host_impl().active_tree()->GetViewportSelection(&output);
+ EXPECT_FALSE(output.start.visible);
// If the handle bottom is partially visible, the handle is marked visible.
- left_input.edge_top = gfx::PointF(0, -20);
- left_input.edge_bottom = gfx::PointF(0, 1);
- host_impl().active_tree()->RegisterSelection(left_input, right_input);
- host_impl().active_tree()->GetViewportSelection(&left_output, &right_output);
- EXPECT_TRUE(left_output.visible);
+ input.start.edge_top = gfx::PointF(0, -20);
+ input.start.edge_bottom = gfx::PointF(0, 1);
+ host_impl().active_tree()->RegisterSelection(input);
+ host_impl().active_tree()->GetViewportSelection(&output);
+ EXPECT_TRUE(output.start.visible);
}
TEST_F(LayerTreeImplTest, SelectionBoundsForScaledLayers) {
@@ -2102,43 +2109,41 @@ TEST_F(LayerTreeImplTest, SelectionBoundsForScaledLayers) {
// Sanity check the scenario we just created.
ASSERT_EQ(1u, RenderSurfaceLayerList().size());
- LayerSelectionBound left_input;
- left_input.type = SELECTION_BOUND_LEFT;
- left_input.edge_top = gfx::PointF(10, 10);
- left_input.edge_bottom = gfx::PointF(10, 30);
- left_input.layer_id = root_layer_id;
+ LayerSelection input;
+ input.start.type = SELECTION_BOUND_LEFT;
+ input.start.edge_top = gfx::PointF(10, 10);
+ input.start.edge_bottom = gfx::PointF(10, 30);
+ input.start.layer_id = root_layer_id;
- LayerSelectionBound right_input;
- right_input.type = SELECTION_BOUND_RIGHT;
- right_input.edge_top = gfx::PointF(0, 0);
- right_input.edge_bottom = gfx::PointF(0, 20);
- right_input.layer_id = sub_layer_id;
- host_impl().active_tree()->RegisterSelection(left_input, right_input);
+ input.end.type = SELECTION_BOUND_RIGHT;
+ input.end.edge_top = gfx::PointF(0, 0);
+ input.end.edge_bottom = gfx::PointF(0, 20);
+ input.end.layer_id = sub_layer_id;
+ host_impl().active_tree()->RegisterSelection(input);
// The viewport bounds should be properly scaled by the page scale, but should
// remain in DIP coordinates.
- ViewportSelectionBound left_output, right_output;
- host_impl().active_tree()->GetViewportSelection(&left_output, &right_output);
- EXPECT_EQ(left_input.type, left_output.type);
- gfx::PointF expected_left_output_top = left_input.edge_top;
- gfx::PointF expected_left_output_bottom = left_input.edge_bottom;
- expected_left_output_top.Scale(page_scale_factor);
- expected_left_output_bottom.Scale(page_scale_factor);
- EXPECT_EQ(left_input.edge_top, left_output.edge_top);
- EXPECT_EQ(left_input.edge_bottom, left_output.edge_bottom);
- EXPECT_TRUE(left_output.visible);
- EXPECT_EQ(right_input.type, right_output.type);
-
- gfx::PointF expected_right_output_top = right_input.edge_top;
- gfx::PointF expected_right_output_bottom = right_input.edge_bottom;
- expected_right_output_top.Offset(sub_layer_offset.x(), sub_layer_offset.y());
- expected_right_output_bottom.Offset(sub_layer_offset.x(),
- sub_layer_offset.y());
- expected_right_output_top.Scale(page_scale_factor);
- expected_right_output_bottom.Scale(page_scale_factor);
- EXPECT_EQ(expected_right_output_top, right_output.edge_top);
- EXPECT_EQ(expected_right_output_bottom, right_output.edge_bottom);
- EXPECT_TRUE(right_output.visible);
+ ViewportSelection output;
+ host_impl().active_tree()->GetViewportSelection(&output);
+ EXPECT_EQ(input.start.type, output.start.type);
+ gfx::PointF expected_output_start_top = input.start.edge_top;
+ gfx::PointF expected_output_edge_botom = input.start.edge_bottom;
+ expected_output_start_top.Scale(page_scale_factor);
+ expected_output_edge_botom.Scale(page_scale_factor);
+ EXPECT_EQ(input.start.edge_top, output.start.edge_top);
+ EXPECT_EQ(input.start.edge_bottom, output.start.edge_bottom);
+ EXPECT_TRUE(output.start.visible);
+ EXPECT_EQ(input.end.type, output.end.type);
+
+ gfx::PointF expected_output_end_top = input.end.edge_top;
+ gfx::PointF expected_output_end_bottom = input.end.edge_bottom;
+ expected_output_end_top.Offset(sub_layer_offset.x(), sub_layer_offset.y());
+ expected_output_end_bottom.Offset(sub_layer_offset.x(), sub_layer_offset.y());
+ expected_output_end_top.Scale(page_scale_factor);
+ expected_output_end_bottom.Scale(page_scale_factor);
+ EXPECT_EQ(expected_output_end_top, output.end.edge_top);
+ EXPECT_EQ(expected_output_end_bottom, output.end.edge_bottom);
+ EXPECT_TRUE(output.end.visible);
}
TEST_F(LayerTreeImplTest, NumLayersTestOne) {