Fixes in the logic for dismissing the GestureNav overlay.
[chromium-blink-merge.git] / content / browser / web_contents / aura / image_window_delegate.cc
blob440d55760d446e8eda7bfd123b6e435863053106
1 // Copyright (c) 2013 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.
5 #include "content/browser/web_contents/aura/image_window_delegate.h"
7 #include "ui/base/cursor/cursor.h"
8 #include "ui/base/hit_test.h"
9 #include "ui/compositor/compositor.h"
10 #include "ui/gfx/canvas.h"
11 #include "ui/gfx/image/image.h"
12 #include "ui/gfx/image/image_skia.h"
13 #include "ui/gfx/rect.h"
14 #include "ui/gfx/size.h"
16 namespace content {
18 ImageWindowDelegate::ImageWindowDelegate()
19 : size_mismatch_(false) {
22 ImageWindowDelegate::~ImageWindowDelegate() {
25 void ImageWindowDelegate::SetImage(const gfx::Image& image) {
26 image_ = image;
27 if (!window_size_.IsEmpty() && !image_.IsEmpty())
28 size_mismatch_ = window_size_ != image_.AsImageSkia().size();
31 gfx::Size ImageWindowDelegate::GetMinimumSize() const {
32 return gfx::Size();
35 gfx::Size ImageWindowDelegate::GetMaximumSize() const {
36 return gfx::Size();
39 void ImageWindowDelegate::OnBoundsChanged(const gfx::Rect& old_bounds,
40 const gfx::Rect& new_bounds) {
41 window_size_ = new_bounds.size();
42 if (!image_.IsEmpty())
43 size_mismatch_ = window_size_ != image_.AsImageSkia().size();
46 gfx::NativeCursor ImageWindowDelegate::GetCursor(const gfx::Point& point) {
47 return gfx::kNullCursor;
50 int ImageWindowDelegate::GetNonClientComponent(const gfx::Point& point) const {
51 return HTNOWHERE;
54 bool ImageWindowDelegate::ShouldDescendIntoChildForEventHandling(
55 aura::Window* child,
56 const gfx::Point& location) {
57 return false;
60 bool ImageWindowDelegate::CanFocus() {
61 return false;
64 void ImageWindowDelegate::OnCaptureLost() {
67 void ImageWindowDelegate::OnPaint(gfx::Canvas* canvas) {
68 if (image_.IsEmpty()) {
69 canvas->DrawColor(SK_ColorGRAY);
70 } else {
71 if (size_mismatch_)
72 canvas->DrawColor(SK_ColorWHITE);
73 canvas->DrawImageInt(image_.AsImageSkia(), 0, 0);
77 void ImageWindowDelegate::OnDeviceScaleFactorChanged(float scale_factor) {
80 void ImageWindowDelegate::OnWindowDestroying(aura::Window* window) {
83 void ImageWindowDelegate::OnWindowDestroyed(aura::Window* window) {
84 delete this;
87 void ImageWindowDelegate::OnWindowTargetVisibilityChanged(bool visible) {
90 bool ImageWindowDelegate::HasHitTestMask() const {
91 return false;
94 void ImageWindowDelegate::GetHitTestMask(gfx::Path* mask) const {
97 void ImageWindowDelegate::DidRecreateLayer(ui::Layer *old_layer,
98 ui::Layer *new_layer) {
101 } // namespace content