Commit bef4fc56 authored by mohsen@chromium.org's avatar mohsen@chromium.org

Use local coordinates in TouchEditable interface

In TouchEditable interface, almost all points are expected to be in
local coordinates of the editable view, except GetBounds() which wrongly
expects points in the parent view coordinates. Up to r244436, this was
not a problem since editable views completely covered their parents and
have the same coordinates with them. Fixing this situation to prevent
similar problems in the future.

BUG=334009

Review URL: https://codereview.chromium.org/138023004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@245152 0039d316-1c4b-4281-b951-d872f2087c98
parent 3472eee8
......@@ -248,7 +248,8 @@ void TouchEditableImplAura::GetSelectionEndPoints(gfx::Rect* p1,
}
gfx::Rect TouchEditableImplAura::GetBounds() {
return rwhva_ ? rwhva_->GetNativeView()->bounds() : gfx::Rect();
return rwhva_ ? gfx::Rect(rwhva_->GetNativeView()->bounds().size()) :
gfx::Rect();
}
gfx::NativeView TouchEditableImplAura::GetNativeView() const {
......
......@@ -15,6 +15,9 @@ namespace ui {
// using touch.
class UI_BASE_EXPORT TouchEditable : public ui::SimpleMenuModel::Delegate {
public:
// TODO(mohsen): Consider switching from local coordinates to screen
// coordinates in this interface and see if it will simplify things.
// Select everything between start and end (points are in view's local
// coordinate system). |start| is the logical start and |end| is the logical
// end of selection. Visually, |start| may lie after |end|.
......@@ -24,7 +27,8 @@ class UI_BASE_EXPORT TouchEditable : public ui::SimpleMenuModel::Delegate {
virtual void MoveCaretTo(const gfx::Point& point) = 0;
// Gets the end points of the current selection. The end points p1 and p2 must
// be the cursor rect for the start and end of selection:
// be the cursor rect for the start and end of selection (in local
// coordinates):
// ____________________________________
// | textfield with |selected text| |
// ------------------------------------
......@@ -34,7 +38,7 @@ class UI_BASE_EXPORT TouchEditable : public ui::SimpleMenuModel::Delegate {
// visually, p1 could be to the right of p2 in the figure above.
virtual void GetSelectionEndPoints(gfx::Rect* p1, gfx::Rect* p2) = 0;
// Gets the bounds of the client view in parent's coordinates.
// Gets the bounds of the client view in its local coordinates.
virtual gfx::Rect GetBounds() = 0;
// Gets the NativeView hosting the client.
......
......@@ -974,7 +974,7 @@ void Textfield::GetSelectionEndPoints(gfx::Rect* p1, gfx::Rect* p2) {
}
gfx::Rect Textfield::GetBounds() {
return bounds();
return GetLocalBounds();
}
gfx::NativeView Textfield::GetNativeView() const {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment