| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/web_contents/aura/overscroll_navigation_overlay.h" | 5 #include "content/browser/web_contents/aura/overscroll_navigation_overlay.h" |
| 6 | 6 |
| 7 #include "content/browser/frame_host/navigation_entry_impl.h" | 7 #include "content/browser/frame_host/navigation_entry_impl.h" |
| 8 #include "content/browser/renderer_host/render_view_host_impl.h" | 8 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 9 #include "content/browser/web_contents/aura/image_window_delegate.h" | 9 #include "content/browser/web_contents/aura/image_window_delegate.h" |
| 10 #include "content/browser/web_contents/web_contents_impl.h" | 10 #include "content/browser/web_contents/web_contents_impl.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 return false; | 38 return false; |
| 39 } | 39 } |
| 40 | 40 |
| 41 } // namespace | 41 } // namespace |
| 42 | 42 |
| 43 // A LayerDelegate that paints an image for the layer. | 43 // A LayerDelegate that paints an image for the layer. |
| 44 class ImageLayerDelegate : public ui::LayerDelegate { | 44 class ImageLayerDelegate : public ui::LayerDelegate { |
| 45 public: | 45 public: |
| 46 ImageLayerDelegate() {} | 46 ImageLayerDelegate() {} |
| 47 | 47 |
| 48 virtual ~ImageLayerDelegate() {} | 48 ~ImageLayerDelegate() override {} |
| 49 | 49 |
| 50 void SetImage(const gfx::Image& image) { | 50 void SetImage(const gfx::Image& image) { |
| 51 image_ = image; | 51 image_ = image; |
| 52 image_size_ = image.AsImageSkia().size(); | 52 image_size_ = image.AsImageSkia().size(); |
| 53 } | 53 } |
| 54 const gfx::Image& image() const { return image_; } | 54 const gfx::Image& image() const { return image_; } |
| 55 | 55 |
| 56 private: | 56 private: |
| 57 // Overridden from ui::LayerDelegate: | 57 // Overridden from ui::LayerDelegate: |
| 58 virtual void OnPaintLayer(gfx::Canvas* canvas) override { | 58 void OnPaintLayer(gfx::Canvas* canvas) override { |
| 59 if (image_.IsEmpty()) { | 59 if (image_.IsEmpty()) { |
| 60 canvas->DrawColor(SK_ColorWHITE); | 60 canvas->DrawColor(SK_ColorWHITE); |
| 61 } else { | 61 } else { |
| 62 SkISize size = canvas->sk_canvas()->getDeviceSize(); | 62 SkISize size = canvas->sk_canvas()->getDeviceSize(); |
| 63 if (size.width() != image_size_.width() || | 63 if (size.width() != image_size_.width() || |
| 64 size.height() != image_size_.height()) { | 64 size.height() != image_size_.height()) { |
| 65 canvas->DrawColor(SK_ColorWHITE); | 65 canvas->DrawColor(SK_ColorWHITE); |
| 66 } | 66 } |
| 67 canvas->DrawImageInt(image_.AsImageSkia(), 0, 0); | 67 canvas->DrawImageInt(image_.AsImageSkia(), 0, 0); |
| 68 } | 68 } |
| 69 } | 69 } |
| 70 | 70 |
| 71 virtual void OnDelegatedFrameDamage( | 71 void OnDelegatedFrameDamage(const gfx::Rect& damage_rect_in_dip) override {} |
| 72 const gfx::Rect& damage_rect_in_dip) override {} | |
| 73 | 72 |
| 74 // Called when the layer's device scale factor has changed. | 73 // Called when the layer's device scale factor has changed. |
| 75 virtual void OnDeviceScaleFactorChanged(float device_scale_factor) override { | 74 void OnDeviceScaleFactorChanged(float device_scale_factor) override {} |
| 76 } | |
| 77 | 75 |
| 78 // Invoked prior to the bounds changing. The returned closured is run after | 76 // Invoked prior to the bounds changing. The returned closured is run after |
| 79 // the bounds change. | 77 // the bounds change. |
| 80 virtual base::Closure PrepareForLayerBoundsChange() override { | 78 base::Closure PrepareForLayerBoundsChange() override { |
| 81 return base::Closure(); | 79 return base::Closure(); |
| 82 } | 80 } |
| 83 | 81 |
| 84 gfx::Image image_; | 82 gfx::Image image_; |
| 85 gfx::Size image_size_; | 83 gfx::Size image_size_; |
| 86 | 84 |
| 87 DISALLOW_COPY_AND_ASSIGN(ImageLayerDelegate); | 85 DISALLOW_COPY_AND_ASSIGN(ImageLayerDelegate); |
| 88 }; | 86 }; |
| 89 | 87 |
| 90 // Responsible for fading out and deleting the layer of the overlay window. | 88 // Responsible for fading out and deleting the layer of the overlay window. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 103 DCHECK(layer_.get()); | 101 DCHECK(layer_.get()); |
| 104 ui::LayerAnimator* animator = layer_->GetAnimator(); | 102 ui::LayerAnimator* animator = layer_->GetAnimator(); |
| 105 // This makes SetOpacity() animate with default duration (which could be | 103 // This makes SetOpacity() animate with default duration (which could be |
| 106 // zero, e.g. when running tests). | 104 // zero, e.g. when running tests). |
| 107 ui::ScopedLayerAnimationSettings settings(animator); | 105 ui::ScopedLayerAnimationSettings settings(animator); |
| 108 animator->AddObserver(this); | 106 animator->AddObserver(this); |
| 109 layer_->SetOpacity(0); | 107 layer_->SetOpacity(0); |
| 110 } | 108 } |
| 111 | 109 |
| 112 // Overridden from ui::LayerAnimationObserver | 110 // Overridden from ui::LayerAnimationObserver |
| 113 virtual void OnLayerAnimationEnded( | 111 void OnLayerAnimationEnded(ui::LayerAnimationSequence* sequence) override { |
| 114 ui::LayerAnimationSequence* sequence) override { | |
| 115 delete this; | 112 delete this; |
| 116 } | 113 } |
| 117 | 114 |
| 118 virtual void OnLayerAnimationAborted( | 115 void OnLayerAnimationAborted(ui::LayerAnimationSequence* sequence) override { |
| 119 ui::LayerAnimationSequence* sequence) override { | |
| 120 delete this; | 116 delete this; |
| 121 } | 117 } |
| 122 | 118 |
| 123 virtual void OnLayerAnimationScheduled( | 119 void OnLayerAnimationScheduled( |
| 124 ui::LayerAnimationSequence* sequence) override {} | 120 ui::LayerAnimationSequence* sequence) override {} |
| 125 | 121 |
| 126 private: | 122 private: |
| 127 virtual ~OverlayDismissAnimator() {} | 123 ~OverlayDismissAnimator() override {} |
| 128 | 124 |
| 129 scoped_ptr<ui::Layer> layer_; | 125 scoped_ptr<ui::Layer> layer_; |
| 130 | 126 |
| 131 DISALLOW_COPY_AND_ASSIGN(OverlayDismissAnimator); | 127 DISALLOW_COPY_AND_ASSIGN(OverlayDismissAnimator); |
| 132 }; | 128 }; |
| 133 | 129 |
| 134 OverscrollNavigationOverlay::OverscrollNavigationOverlay( | 130 OverscrollNavigationOverlay::OverscrollNavigationOverlay( |
| 135 WebContentsImpl* web_contents) | 131 WebContentsImpl* web_contents) |
| 136 : web_contents_(web_contents), | 132 : web_contents_(web_contents), |
| 137 image_delegate_(NULL), | 133 image_delegate_(NULL), |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 | 305 |
| 310 void OverscrollNavigationOverlay::DidStopLoading(RenderViewHost* host) { | 306 void OverscrollNavigationOverlay::DidStopLoading(RenderViewHost* host) { |
| 311 // Don't compare URLs in this case - it's possible they won't match if | 307 // Don't compare URLs in this case - it's possible they won't match if |
| 312 // a gesture-nav initiated navigation was interrupted by some other in-site | 308 // a gesture-nav initiated navigation was interrupted by some other in-site |
| 313 // navigation ((e.g., from a script, or from a bookmark). | 309 // navigation ((e.g., from a script, or from a bookmark). |
| 314 loading_complete_ = true; | 310 loading_complete_ = true; |
| 315 StopObservingIfDone(); | 311 StopObservingIfDone(); |
| 316 } | 312 } |
| 317 | 313 |
| 318 } // namespace content | 314 } // namespace content |
| OLD | NEW |