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

Unified Diff: ui/views/touchui/touch_selection_controller_impl.cc

Issue 2034863002: Move SelectionBound from ui/base/touch to ui/gfx to be used by cc (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated views_unittests Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: ui/views/touchui/touch_selection_controller_impl.cc
diff --git a/ui/views/touchui/touch_selection_controller_impl.cc b/ui/views/touchui/touch_selection_controller_impl.cc
index 8508ffc55aa0a1b17a291ff4341c6ddb791daa1a..1e80313596406b892fb638a4e9fe3bc6713c5138 100644
--- a/ui/views/touchui/touch_selection_controller_impl.cc
+++ b/ui/views/touchui/touch_selection_controller_impl.cc
@@ -116,13 +116,13 @@ gfx::Image* GetRightHandleImage() {
}
// Return the appropriate handle image based on the bound's type
-gfx::Image* GetHandleImage(ui::SelectionBound::Type bound_type) {
+gfx::Image* GetHandleImage(gfx::SelectionBound::Type bound_type) {
switch(bound_type) {
- case ui::SelectionBound::LEFT:
+ case gfx::SelectionBound::LEFT:
return GetLeftHandleImage();
- case ui::SelectionBound::CENTER:
+ case gfx::SelectionBound::CENTER:
return GetCenterHandleImage();
- case ui::SelectionBound::RIGHT:
+ case gfx::SelectionBound::RIGHT:
return GetRightHandleImage();
default:
NOTREACHED() << "Invalid touch handle bound type: " << bound_type;
@@ -132,7 +132,7 @@ gfx::Image* GetHandleImage(ui::SelectionBound::Type bound_type) {
// Calculates the bounds of the widget containing the selection handle based
// on the SelectionBound's type and location
-gfx::Rect GetSelectionWidgetBounds(const ui::SelectionBound& bound) {
+gfx::Rect GetSelectionWidgetBounds(const gfx::SelectionBound& bound) {
gfx::Size image_size = GetHandleImage(bound.type())->Size();
int widget_width = image_size.width() + 2 * kSelectionHandleHorizPadding;
int widget_height = bound.GetHeight() + image_size.height() +
@@ -142,14 +142,14 @@ gfx::Rect GetSelectionWidgetBounds(const ui::SelectionBound& bound) {
// the selection bound depending on the type of the bound.
int widget_left = 0;
switch (bound.type()) {
- case ui::SelectionBound::LEFT:
+ case gfx::SelectionBound::LEFT:
widget_left = bound.edge_top_rounded().x() - image_size.width() -
kSelectionHandleHorizPadding;
break;
- case ui::SelectionBound::RIGHT:
+ case gfx::SelectionBound::RIGHT:
widget_left = bound.edge_top_rounded().x() - kSelectionHandleHorizPadding;
break;
- case ui::SelectionBound::CENTER:
+ case gfx::SelectionBound::CENTER:
widget_left = bound.edge_top_rounded().x() - widget_width / 2;
break;
default:
@@ -175,9 +175,9 @@ gfx::Size GetMaxHandleImageSize() {
// Note that this is not quite correct because it does not take into account
// transforms such as rotation and scaling. This should be in TouchEditable.
// TODO(varunjain): Fix this.
-ui::SelectionBound ConvertFromScreen(ui::TouchEditable* client,
- const ui::SelectionBound& bound) {
- ui::SelectionBound result = bound;
+gfx::SelectionBound ConvertFromScreen(ui::TouchEditable* client,
+ const gfx::SelectionBound& bound) {
+ gfx::SelectionBound result = bound;
gfx::Point edge_bottom = bound.edge_bottom_rounded();
gfx::Point edge_top = bound.edge_top_rounded();
client->ConvertPointFromScreen(&edge_bottom);
@@ -186,9 +186,9 @@ ui::SelectionBound ConvertFromScreen(ui::TouchEditable* client,
return result;
}
-ui::SelectionBound ConvertToScreen(ui::TouchEditable* client,
- const ui::SelectionBound& bound) {
- ui::SelectionBound result = bound;
+gfx::SelectionBound ConvertToScreen(ui::TouchEditable* client,
+ const gfx::SelectionBound& bound) {
+ gfx::SelectionBound result = bound;
gfx::Point edge_bottom = bound.edge_bottom_rounded();
gfx::Point edge_top = bound.edge_top_rounded();
client->ConvertPointToScreen(&edge_bottom);
@@ -197,7 +197,7 @@ ui::SelectionBound ConvertToScreen(ui::TouchEditable* client,
return result;
}
-gfx::Rect BoundToRect(const ui::SelectionBound& bound) {
+gfx::Rect BoundToRect(const gfx::SelectionBound& bound) {
return gfx::BoundingRect(bound.edge_top_rounded(),
bound.edge_bottom_rounded());
}
@@ -249,7 +249,7 @@ class TouchSelectionControllerImpl::EditingHandleView
~EditingHandleView() override { SetWidgetVisible(false, false); }
- ui::SelectionBound::Type selection_bound_type() {
+ gfx::SelectionBound::Type selection_bound_type() {
return selection_bound_.type();
}
@@ -344,10 +344,10 @@ class TouchSelectionControllerImpl::EditingHandleView
// if necessary. Otherwise this will only update the internal state:
// |selection_bound_| and |image_|, so that the state is valid for the time
// this becomes visible.
- void SetBoundInScreen(const ui::SelectionBound& bound, bool is_visible) {
+ void SetBoundInScreen(const gfx::SelectionBound& bound, bool is_visible) {
bool update_bound_type = false;
// Cursor handle should always have the bound type CENTER
- DCHECK(!is_cursor_handle_ || bound.type() == ui::SelectionBound::CENTER);
+ DCHECK(!is_cursor_handle_ || bound.type() == gfx::SelectionBound::CENTER);
if (bound.type() != selection_bound_.type()) {
// Unless this is a cursor handle, do not set the type to CENTER -
@@ -355,7 +355,7 @@ class TouchSelectionControllerImpl::EditingHandleView
// or right handle image. If selection handles are dragged to be located
// at the same spot, the |bound|'s type here will be CENTER for both of
// them. In this case do not update the type of the |selection_bound_|.
- if (bound.type() != ui::SelectionBound::CENTER || is_cursor_handle_)
+ if (bound.type() != gfx::SelectionBound::CENTER || is_cursor_handle_)
update_bound_type = true;
}
if (update_bound_type) {
@@ -392,7 +392,7 @@ class TouchSelectionControllerImpl::EditingHandleView
TouchSelectionControllerImpl* controller_;
// In local coordinates
- ui::SelectionBound selection_bound_;
+ gfx::SelectionBound selection_bound_;
gfx::Image* image_;
// If true, this is a handle corresponding to the single cursor, otherwise it
@@ -463,11 +463,11 @@ TouchSelectionControllerImpl::~TouchSelectionControllerImpl() {
}
void TouchSelectionControllerImpl::SelectionChanged() {
- ui::SelectionBound anchor, focus;
+ gfx::SelectionBound anchor, focus;
client_view_->GetSelectionEndPoints(&anchor, &focus);
- ui::SelectionBound screen_bound_anchor =
+ gfx::SelectionBound screen_bound_anchor =
ConvertToScreen(client_view_, anchor);
- ui::SelectionBound screen_bound_focus = ConvertToScreen(client_view_, focus);
+ gfx::SelectionBound screen_bound_focus = ConvertToScreen(client_view_, focus);
gfx::Rect client_bounds = client_view_->GetBounds();
if (anchor.edge_top().y() < client_bounds.y()) {
auto anchor_edge_top = gfx::PointF(anchor.edge_top_rounded());
@@ -479,9 +479,9 @@ void TouchSelectionControllerImpl::SelectionChanged() {
focus_edge_top.set_y(client_bounds.y());
focus.SetEdgeTop(focus_edge_top);
}
- ui::SelectionBound screen_bound_anchor_clipped =
+ gfx::SelectionBound screen_bound_anchor_clipped =
ConvertToScreen(client_view_, anchor);
- ui::SelectionBound screen_bound_focus_clipped =
+ gfx::SelectionBound screen_bound_focus_clipped =
ConvertToScreen(client_view_, focus);
if (screen_bound_anchor_clipped == selection_bound_1_clipped_ &&
screen_bound_focus_clipped == selection_bound_2_clipped_)
@@ -579,7 +579,7 @@ void TouchSelectionControllerImpl::SelectionHandleDragged(
}
// Find the stationary selection handle.
- ui::SelectionBound anchor_bound =
+ gfx::SelectionBound anchor_bound =
selection_handle_1_.get() == dragging_handle_ ? selection_bound_2_
: selection_bound_1_;
@@ -602,14 +602,14 @@ void TouchSelectionControllerImpl::ConvertPointToClientView(
void TouchSelectionControllerImpl::SetHandleBound(
EditingHandleView* handle,
- const ui::SelectionBound& bound,
- const ui::SelectionBound& bound_in_screen) {
+ const gfx::SelectionBound& bound,
+ const gfx::SelectionBound& bound_in_screen) {
handle->SetWidgetVisible(ShouldShowHandleFor(bound), false);
handle->SetBoundInScreen(bound_in_screen, handle->IsWidgetVisible());
}
bool TouchSelectionControllerImpl::ShouldShowHandleFor(
- const ui::SelectionBound& bound) const {
+ const gfx::SelectionBound& bound) const {
if (bound.GetHeight() < kSelectionHandleBarMinHeight)
return false;
gfx::Rect client_bounds = client_view_->GetBounds();
@@ -719,20 +719,20 @@ void TouchSelectionControllerImpl::HideQuickMenu() {
gfx::Rect TouchSelectionControllerImpl::GetQuickMenuAnchorRect() const {
// Get selection end points in client_view's space.
- ui::SelectionBound b1_in_screen = selection_bound_1_clipped_;
- ui::SelectionBound b2_in_screen = cursor_handle_->IsWidgetVisible()
- ? b1_in_screen
- : selection_bound_2_clipped_;
+ gfx::SelectionBound b1_in_screen = selection_bound_1_clipped_;
+ gfx::SelectionBound b2_in_screen = cursor_handle_->IsWidgetVisible()
+ ? b1_in_screen
+ : selection_bound_2_clipped_;
// Convert from screen to client.
- ui::SelectionBound b1 = ConvertFromScreen(client_view_, b1_in_screen);
- ui::SelectionBound b2 = ConvertFromScreen(client_view_, b2_in_screen);
+ gfx::SelectionBound b1 = ConvertFromScreen(client_view_, b1_in_screen);
+ gfx::SelectionBound b2 = ConvertFromScreen(client_view_, b2_in_screen);
// if selection is completely inside the view, we display the quick menu in
// the middle of the end points on the top. Else, we show it above the visible
// handle. If no handle is visible, we do not show the menu.
gfx::Rect menu_anchor;
if (ShouldShowHandleFor(b1) && ShouldShowHandleFor(b2))
- menu_anchor = ui::RectBetweenSelectionBounds(b1_in_screen, b2_in_screen);
+ menu_anchor = gfx::RectBetweenSelectionBounds(b1_in_screen, b2_in_screen);
else if (ShouldShowHandleFor(b1))
menu_anchor = BoundToRect(b1_in_screen);
else if (ShouldShowHandleFor(b2))
@@ -751,7 +751,7 @@ gfx::NativeView TouchSelectionControllerImpl::GetCursorHandleNativeView() {
return cursor_handle_->GetWidget()->GetNativeView();
}
-ui::SelectionBound::Type
+gfx::SelectionBound::Type
TouchSelectionControllerImpl::GetSelectionHandle1Type() {
return selection_handle_1_->selection_bound_type();
}
@@ -781,7 +781,7 @@ bool TouchSelectionControllerImpl::IsCursorHandleVisible() {
}
gfx::Rect TouchSelectionControllerImpl::GetExpectedHandleBounds(
- const ui::SelectionBound& bound) {
+ const gfx::SelectionBound& bound) {
return GetSelectionWidgetBounds(bound);
}
« no previous file with comments | « ui/views/touchui/touch_selection_controller_impl.h ('k') | ui/views/touchui/touch_selection_controller_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698