Index: content/browser/renderer_host/touch_handle_drawable_aura.cc |
diff --git a/content/browser/renderer_host/touch_handle_drawable_aura.cc b/content/browser/renderer_host/touch_handle_drawable_aura.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..a69be6462f1f8121f69abd6e76b4fe9e08749f86 |
--- /dev/null |
+++ b/content/browser/renderer_host/touch_handle_drawable_aura.cc |
@@ -0,0 +1,144 @@ |
+// 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. |
+ |
+#include "content/browser/renderer_host/touch_handle_drawable_aura.h" |
+ |
+#include "ui/aura/window.h" |
+#include "ui/aura/window_targeter.h" |
+#include "ui/base/cursor/cursor.h" |
+#include "ui/base/hit_test.h" |
+#include "ui/events/event.h" |
+#include "ui/gfx/canvas.h" |
+ |
+namespace content { |
+namespace { |
+ |
+class TouchHandleDrawableAuraTargeter : public aura::WindowTargeter { |
+ protected: |
+ virtual bool EventLocationInsideBounds( |
+ ui::EventTarget* target, |
+ const ui::LocatedEvent& event) const override; |
+}; |
+ |
+bool TouchHandleDrawableAuraTargeter::EventLocationInsideBounds( |
+ ui::EventTarget* target, |
+ const ui::LocatedEvent& event) const { |
+ return false; |
+} |
+ |
+} |
+ |
+TouchHandleDrawableAura::TouchHandleDrawableAura(aura::Window* parent) |
+ : window_(new aura::Window(this)), |
+ enabled_(false), |
+ alpha_(0) { |
+ window_->SetTransparent(true); |
+ window_->Init(aura::WINDOW_LAYER_TEXTURED); |
+ window_->set_owned_by_parent(false); |
+ window_->SetEventTargeter( |
+ scoped_ptr<ui::EventTargeter>(new TouchHandleDrawableAuraTargeter)); |
+ parent->AddChild(window_.get()); |
+} |
+ |
+TouchHandleDrawableAura::~TouchHandleDrawableAura() { |
+} |
+ |
+void TouchHandleDrawableAura::SetEnabled(bool enabled) { |
+ if (enabled == enabled_) |
+ return; |
+ |
+ enabled_ = enabled; |
+ bool visible = alpha_ > 0; // XXX: float comparison |
+ if (enabled_ && visible) |
+ window_->Show(); |
+ else |
+ window_->Hide(); |
+} |
+ |
+void TouchHandleDrawableAura::SetOrientation( |
+ TouchHandleOrientation orientation) { |
+} |
+ |
+void TouchHandleDrawableAura::SetAlpha(float alpha) { |
+ if (alpha == alpha_) // XXX: float comparison |
+ return; |
+ |
+ alpha_ = alpha; |
+ window_->layer()->SetOpacity(alpha_); |
+ bool visible = alpha_ > 0; // XXX: float comparison |
+ if (enabled_ && visible) |
+ window_->Show(); |
+ else |
+ window_->Hide(); |
+} |
+ |
+void TouchHandleDrawableAura::SetFocus(const gfx::PointF& position) { |
+ window_->SetBounds(gfx::Rect(position.x() - 10, position.y(), 20, 50)); |
+} |
+ |
+bool TouchHandleDrawableAura::IntersectsWith(const gfx::RectF& rect) const { |
+ gfx::RectF r(window_->bounds()); |
+ r.Inset(-25, -25); |
+ return r.Intersects(rect); |
+} |
+ |
+gfx::Size TouchHandleDrawableAura::GetMinimumSize() const { |
+ return gfx::Size(20, 50); |
+} |
+ |
+gfx::Size TouchHandleDrawableAura::GetMaximumSize() const { |
+ return gfx::Size(20, 50); |
+} |
+ |
+void TouchHandleDrawableAura::OnBoundsChanged(const gfx::Rect& old_bounds, |
+ const gfx::Rect& new_bounds) { |
+} |
+ |
+gfx::NativeCursor TouchHandleDrawableAura::GetCursor(const gfx::Point& point) { |
+ return gfx::kNullCursor; |
+} |
+ |
+int TouchHandleDrawableAura::GetNonClientComponent( |
+ const gfx::Point& point) const { |
+ return HTCLIENT; |
+} |
+ |
+bool TouchHandleDrawableAura::ShouldDescendIntoChildForEventHandling( |
+ aura::Window* child, |
+ const gfx::Point& location) { |
+ return false; |
+} |
+ |
+bool TouchHandleDrawableAura::CanFocus() { |
+ return false; |
+} |
+ |
+void TouchHandleDrawableAura::OnCaptureLost() { |
+} |
+ |
+void TouchHandleDrawableAura::OnPaint(gfx::Canvas* canvas) { |
+ canvas->DrawColor(SK_ColorYELLOW); |
+} |
+ |
+void TouchHandleDrawableAura::OnDeviceScaleFactorChanged( |
+ float device_scale_factor) { |
+} |
+ |
+void TouchHandleDrawableAura::OnWindowDestroying(aura::Window* window) { |
+} |
+ |
+void TouchHandleDrawableAura::OnWindowDestroyed(aura::Window* window) { |
+} |
+ |
+void TouchHandleDrawableAura::OnWindowTargetVisibilityChanged(bool visible) { |
+} |
+ |
+bool TouchHandleDrawableAura::HasHitTestMask() const { |
+ return false; |
+} |
+ |
+void TouchHandleDrawableAura::GetHitTestMask(gfx::Path* mask) const { |
+} |
+ |
+} |