| 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/web_contents_impl.h" | 9 #include "content/browser/web_contents/web_contents_impl.h" |
| 10 #include "content/common/view_messages.h" | 10 #include "content/common/view_messages.h" |
| 11 #include "content/public/browser/browser_thread.h" | 11 #include "content/public/browser/browser_thread.h" |
| 12 #include "content/public/browser/render_widget_host_view.h" | 12 #include "content/public/browser/render_widget_host_view.h" |
| 13 #include "ui/aura/window.h" | 13 #include "ui/aura/window.h" |
| 14 #include "ui/aura_extra/image_window_delegate.h" | 14 #include "ui/aura_extra/image_window_delegate.h" |
| 15 #include "ui/base/layout.h" | 15 #include "ui/base/layout.h" |
| 16 #include "ui/compositor/layer.h" | 16 #include "ui/compositor/layer.h" |
| 17 #include "ui/compositor/layer_animation_observer.h" | 17 #include "ui/compositor/layer_animation_observer.h" |
| 18 #include "ui/compositor/paint_context.h" | 18 #include "ui/compositor/paint_recorder.h" |
| 19 #include "ui/compositor/scoped_layer_animation_settings.h" | 19 #include "ui/compositor/scoped_layer_animation_settings.h" |
| 20 #include "ui/gfx/canvas.h" | 20 #include "ui/gfx/canvas.h" |
| 21 #include "ui/gfx/image/image_png_rep.h" | 21 #include "ui/gfx/image/image_png_rep.h" |
| 22 #include "ui/gfx/image/image_skia.h" | 22 #include "ui/gfx/image/image_skia.h" |
| 23 | 23 |
| 24 namespace content { | 24 namespace content { |
| 25 namespace { | 25 namespace { |
| 26 | 26 |
| 27 // Returns true if the entry's URL or any of the URLs in entry's redirect chain | 27 // Returns true if the entry's URL or any of the URLs in entry's redirect chain |
| 28 // match |url|. | 28 // match |url|. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 52 | 52 |
| 53 void SetImage(const gfx::Image& image) { | 53 void SetImage(const gfx::Image& image) { |
| 54 image_ = image; | 54 image_ = image; |
| 55 image_size_ = image.AsImageSkia().size(); | 55 image_size_ = image.AsImageSkia().size(); |
| 56 } | 56 } |
| 57 const gfx::Image& image() const { return image_; } | 57 const gfx::Image& image() const { return image_; } |
| 58 | 58 |
| 59 private: | 59 private: |
| 60 // Overridden from ui::LayerDelegate: | 60 // Overridden from ui::LayerDelegate: |
| 61 void OnPaintLayer(const ui::PaintContext& context) override { | 61 void OnPaintLayer(const ui::PaintContext& context) override { |
| 62 gfx::Canvas* canvas = context.canvas(); | 62 ui::PaintRecorder recorder(context); |
| 63 if (image_.IsEmpty()) { | 63 if (image_.IsEmpty()) { |
| 64 canvas->DrawColor(SK_ColorWHITE); | 64 recorder.canvas()->DrawColor(SK_ColorWHITE); |
| 65 } else { | 65 } else { |
| 66 SkISize size = canvas->sk_canvas()->getDeviceSize(); | 66 SkISize size = recorder.canvas()->sk_canvas()->getDeviceSize(); |
| 67 if (size.width() != image_size_.width() || | 67 if (size.width() != image_size_.width() || |
| 68 size.height() != image_size_.height()) { | 68 size.height() != image_size_.height()) { |
| 69 canvas->DrawColor(SK_ColorWHITE); | 69 recorder.canvas()->DrawColor(SK_ColorWHITE); |
| 70 } | 70 } |
| 71 canvas->DrawImageInt(image_.AsImageSkia(), 0, 0); | 71 recorder.canvas()->DrawImageInt(image_.AsImageSkia(), 0, 0); |
| 72 } | 72 } |
| 73 } | 73 } |
| 74 | 74 |
| 75 void OnDelegatedFrameDamage(const gfx::Rect& damage_rect_in_dip) override {} | 75 void OnDelegatedFrameDamage(const gfx::Rect& damage_rect_in_dip) override {} |
| 76 | 76 |
| 77 // Called when the layer's device scale factor has changed. | 77 // Called when the layer's device scale factor has changed. |
| 78 void OnDeviceScaleFactorChanged(float device_scale_factor) override {} | 78 void OnDeviceScaleFactorChanged(float device_scale_factor) override {} |
| 79 | 79 |
| 80 // Invoked prior to the bounds changing. The returned closured is run after | 80 // Invoked prior to the bounds changing. The returned closured is run after |
| 81 // the bounds change. | 81 // the bounds change. |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 | 308 |
| 309 void OverscrollNavigationOverlay::DidStopLoading() { | 309 void OverscrollNavigationOverlay::DidStopLoading() { |
| 310 // Don't compare URLs in this case - it's possible they won't match if | 310 // Don't compare URLs in this case - it's possible they won't match if |
| 311 // a gesture-nav initiated navigation was interrupted by some other in-site | 311 // a gesture-nav initiated navigation was interrupted by some other in-site |
| 312 // navigation ((e.g., from a script, or from a bookmark). | 312 // navigation ((e.g., from a script, or from a bookmark). |
| 313 loading_complete_ = true; | 313 loading_complete_ = true; |
| 314 StopObservingIfDone(); | 314 StopObservingIfDone(); |
| 315 } | 315 } |
| 316 | 316 |
| 317 } // namespace content | 317 } // namespace content |
| OLD | NEW |