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

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

Issue 698253004: Reland: Implement Aura side of unified touch text selection for contents (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "content/browser/renderer_host/touch_handle_drawable_aura.h"
6
7 #include "ui/aura/window.h"
8 #include "ui/aura/window_targeter.h"
9 #include "ui/base/cursor/cursor.h"
10 #include "ui/base/hit_test.h"
11 #include "ui/events/event.h"
12 #include "ui/gfx/canvas.h"
13
14 namespace content {
15 namespace {
16
17 class TouchHandleDrawableAuraTargeter : public aura::WindowTargeter {
18 protected:
19 virtual bool EventLocationInsideBounds(
20 ui::EventTarget* target,
21 const ui::LocatedEvent& event) const override;
22 };
23
24 bool TouchHandleDrawableAuraTargeter::EventLocationInsideBounds(
25 ui::EventTarget* target,
26 const ui::LocatedEvent& event) const {
27 return false;
28 }
29
30 }
31
32 TouchHandleDrawableAura::TouchHandleDrawableAura(aura::Window* parent)
33 : window_(new aura::Window(this)) {
34 window_->SetTransparent(true);
35 window_->Init(aura::WINDOW_LAYER_TEXTURED);
36 window_->set_owned_by_parent(false);
37 window_->SetEventTargeter(
38 scoped_ptr<ui::EventTargeter>(new TouchHandleDrawableAuraTargeter));
39 parent->AddChild(window_.get());
40 }
41
42 TouchHandleDrawableAura::~TouchHandleDrawableAura() {
43 }
44
45 void TouchHandleDrawableAura::SetEnabled(bool enabled) {
46 if (enabled == enabled_)
47 return;
48
49 enabled_ = enabled;
50 if (enabled_ && visible_)
51 window_->Show();
52 else
53 window_->Hide();
54 }
55
56 void TouchHandleDrawableAura::SetOrientation(
57 TouchHandleOrientation orientation) {
58 }
59
60 void TouchHandleDrawableAura::SetAlpha(float alpha) {
61 window_->layer()->SetOpacity(alpha);
62 }
63
64 void TouchHandleDrawableAura::SetFocus(const gfx::PointF& position) {
65 window_->SetBounds(gfx::Rect(position.x() - 10, position.y(), 20, 50));
66 }
67
68 void TouchHandleDrawableAura::SetVisible(bool visible) {
69 if (visible == visible_)
70 return;
71
72 visible_ = visible;
73 if (enabled_ && visible_)
74 window_->Show();
75 else
76 window_->Hide();
77 }
78
79 bool TouchHandleDrawableAura::IntersectsWith(const gfx::RectF& rect) const {
80 gfx::RectF r(window_->bounds());
81 r.Inset(-25, -25);
82 return r.Intersects(rect);
83 }
84
85 gfx::Size TouchHandleDrawableAura::GetMinimumSize() const {
86 return gfx::Size(20, 50);
87 }
88
89 gfx::Size TouchHandleDrawableAura::GetMaximumSize() const {
90 return gfx::Size(20, 50);
91 }
92
93 void TouchHandleDrawableAura::OnBoundsChanged(const gfx::Rect& old_bounds,
94 const gfx::Rect& new_bounds) {
95 }
96
97 gfx::NativeCursor TouchHandleDrawableAura::GetCursor(const gfx::Point& point) {
98 return gfx::kNullCursor;
99 }
100
101 int TouchHandleDrawableAura::GetNonClientComponent(
102 const gfx::Point& point) const {
103 return HTCLIENT;
104 }
105
106 bool TouchHandleDrawableAura::ShouldDescendIntoChildForEventHandling(
107 aura::Window* child,
108 const gfx::Point& location) {
109 return false;
110 }
111
112 bool TouchHandleDrawableAura::CanFocus() {
113 return false;
114 }
115
116 void TouchHandleDrawableAura::OnCaptureLost() {
117 }
118
119 void TouchHandleDrawableAura::OnPaint(gfx::Canvas* canvas) {
120 canvas->DrawColor(SK_ColorYELLOW);
121 }
122
123 void TouchHandleDrawableAura::OnDeviceScaleFactorChanged(
124 float device_scale_factor) {
125 }
126
127 void TouchHandleDrawableAura::OnWindowDestroying(aura::Window* window) {
128 }
129
130 void TouchHandleDrawableAura::OnWindowDestroyed(aura::Window* window) {
131 }
132
133 void TouchHandleDrawableAura::OnWindowTargetVisibilityChanged(bool visible) {
134 }
135
136 bool TouchHandleDrawableAura::HasHitTestMask() const {
137 return false;
138 }
139
140 void TouchHandleDrawableAura::GetHitTestMask(gfx::Path* mask) const {
141 }
142
143 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698