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

Unified Diff: ui/aura/image_window_delegate.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: Fixed overrides in TouchHandleDrawableAura Created 5 years, 11 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/aura/image_window_delegate.cc
diff --git a/content/browser/web_contents/aura/image_window_delegate.cc b/ui/aura/image_window_delegate.cc
similarity index 73%
rename from content/browser/web_contents/aura/image_window_delegate.cc
rename to ui/aura/image_window_delegate.cc
index 25878ea2c1c7bac602238f13a5cdd3507d1c7abb..fce4a2dacff418d03cdedc007503486f48cacb77 100644
--- a/content/browser/web_contents/aura/image_window_delegate.cc
+++ b/ui/aura/image_window_delegate.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "content/browser/web_contents/aura/image_window_delegate.h"
+#include "ui/aura/image_window_delegate.h"
#include "ui/base/cursor/cursor.h"
#include "ui/base/hit_test.h"
@@ -13,21 +13,35 @@
#include "ui/gfx/image/image.h"
#include "ui/gfx/image/image_skia.h"
-namespace content {
+namespace aura {
ImageWindowDelegate::ImageWindowDelegate()
- : size_mismatch_(false) {
+ : background_color_(SK_ColorWHITE),
+ self_destroy_(true),
+ size_mismatch_(false) {
}
ImageWindowDelegate::~ImageWindowDelegate() {
}
+void ImageWindowDelegate::SetBackgroundColor(SkColor color) {
+ background_color_ = color;
+}
+
void ImageWindowDelegate::SetImage(const gfx::Image& image) {
image_ = image;
if (!window_size_.IsEmpty() && !image_.IsEmpty())
size_mismatch_ = window_size_ != image_.AsImageSkia().size();
}
+void ImageWindowDelegate::SetImageOffset(gfx::Vector2d offset) {
+ offset_ = offset;
+}
+
+void ImageWindowDelegate::SetSelfDestroy(bool self_destroy) {
+ self_destroy_ = self_destroy;
+}
+
gfx::Size ImageWindowDelegate::GetMinimumSize() const {
return gfx::Size();
}
@@ -65,13 +79,12 @@ void ImageWindowDelegate::OnCaptureLost() {
}
void ImageWindowDelegate::OnPaint(gfx::Canvas* canvas) {
- if (image_.IsEmpty()) {
- canvas->DrawColor(SK_ColorWHITE);
- } else {
- if (size_mismatch_)
- canvas->DrawColor(SK_ColorWHITE);
- canvas->DrawImageInt(image_.AsImageSkia(), 0, 0);
+ if (background_color_ != SK_ColorTRANSPARENT &&
+ (image_.IsEmpty() || size_mismatch_ || !offset_.IsZero())) {
+ canvas->DrawColor(background_color_);
}
+ if (!image_.IsEmpty())
+ canvas->DrawImageInt(image_.AsImageSkia(), offset_.x(), offset_.y());
}
void ImageWindowDelegate::OnDeviceScaleFactorChanged(float scale_factor) {
@@ -81,7 +94,8 @@ void ImageWindowDelegate::OnWindowDestroying(aura::Window* window) {
}
void ImageWindowDelegate::OnWindowDestroyed(aura::Window* window) {
- delete this;
+ if (self_destroy_)
+ delete this;
}
void ImageWindowDelegate::OnWindowTargetVisibilityChanged(bool visible) {
@@ -94,4 +108,4 @@ bool ImageWindowDelegate::HasHitTestMask() const {
void ImageWindowDelegate::GetHitTestMask(gfx::Path* mask) const {
}
-} // namespace content
+} // namespace aura

Powered by Google App Engine
This is Rietveld 408576698