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 "chrome/browser/ui/views/frame/contents_web_view.h" | 5 #include "chrome/browser/ui/views/frame/contents_web_view.h" |
6 | 6 |
7 #include "chrome/browser/themes/theme_properties.h" | 7 #include "chrome/browser/themes/theme_properties.h" |
8 #include "chrome/browser/ui/views/status_bubble_views.h" | 8 #include "chrome/browser/ui/views/status_bubble_views.h" |
9 #include "content/public/browser/web_contents.h" | 9 #include "content/public/browser/web_contents.h" |
10 #include "ui/aura/window.h" | |
11 #include "ui/base/theme_provider.h" | 10 #include "ui/base/theme_provider.h" |
12 #include "ui/compositor/layer_tree_owner.h" | 11 #include "ui/compositor/layer_tree_owner.h" |
13 #include "ui/views/background.h" | 12 #include "ui/views/background.h" |
| 13 |
| 14 #if defined(USE_AURA) |
| 15 #include "ui/aura/window.h" |
14 #include "ui/wm/core/window_util.h" | 16 #include "ui/wm/core/window_util.h" |
| 17 #endif |
15 | 18 |
16 ContentsWebView::ContentsWebView(content::BrowserContext* browser_context) | 19 ContentsWebView::ContentsWebView(content::BrowserContext* browser_context) |
17 : views::WebView(browser_context), | 20 : views::WebView(browser_context), |
18 status_bubble_(NULL) { | 21 status_bubble_(NULL) { |
19 } | 22 } |
20 | 23 |
21 ContentsWebView::~ContentsWebView() { | 24 ContentsWebView::~ContentsWebView() { |
22 } | 25 } |
23 | 26 |
24 void ContentsWebView::SetStatusBubble(StatusBubbleViews* status_bubble) { | 27 void ContentsWebView::SetStatusBubble(StatusBubbleViews* status_bubble) { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 // want the WebContents layer clone to be animated we move it to the | 79 // want the WebContents layer clone to be animated we move it to the |
77 // old_layer, which is the layer the animation happens on. This animation ends | 80 // old_layer, which is the layer the animation happens on. This animation ends |
78 // up owning the layer (and all its descendants). | 81 // up owning the layer (and all its descendants). |
79 old_layer->Add(cloned_layer_tree_->release()); | 82 old_layer->Add(cloned_layer_tree_->release()); |
80 cloned_layer_tree_.reset(); | 83 cloned_layer_tree_.reset(); |
81 } | 84 } |
82 | 85 |
83 void ContentsWebView::CloneWebContentsLayer() { | 86 void ContentsWebView::CloneWebContentsLayer() { |
84 if (!web_contents()) | 87 if (!web_contents()) |
85 return; | 88 return; |
| 89 #if defined(USE_AURA) |
| 90 // We don't need to clone the layers on non-Aura (Mac), because closing an |
| 91 // NSWindow does not animate. |
86 cloned_layer_tree_ = wm::RecreateLayers(web_contents()->GetNativeView()); | 92 cloned_layer_tree_ = wm::RecreateLayers(web_contents()->GetNativeView()); |
| 93 #endif |
87 if (!cloned_layer_tree_ || !cloned_layer_tree_->root()) { | 94 if (!cloned_layer_tree_ || !cloned_layer_tree_->root()) { |
88 cloned_layer_tree_.reset(); | 95 cloned_layer_tree_.reset(); |
89 return; | 96 return; |
90 } | 97 } |
91 | 98 |
92 SetPaintToLayer(true); | 99 SetPaintToLayer(true); |
93 set_layer_owner_delegate(this); | 100 set_layer_owner_delegate(this); |
94 | 101 |
95 // The cloned layer is in a different coordinate system them our layer (which | 102 // The cloned layer is in a different coordinate system them our layer (which |
96 // is now the new parent of the cloned layer). Convert coordinates so that the | 103 // is now the new parent of the cloned layer). Convert coordinates so that the |
97 // cloned layer appears at the right location. | 104 // cloned layer appears at the right location. |
98 gfx::Point origin; | 105 gfx::Point origin; |
99 ui::Layer::ConvertPointToLayer(cloned_layer_tree_->root(), layer(), &origin); | 106 ui::Layer::ConvertPointToLayer(cloned_layer_tree_->root(), layer(), &origin); |
100 cloned_layer_tree_->root()->SetBounds( | 107 cloned_layer_tree_->root()->SetBounds( |
101 gfx::Rect(origin, cloned_layer_tree_->root()->bounds().size())); | 108 gfx::Rect(origin, cloned_layer_tree_->root()->bounds().size())); |
102 layer()->Add(cloned_layer_tree_->root()); | 109 layer()->Add(cloned_layer_tree_->root()); |
103 } | 110 } |
104 | 111 |
105 void ContentsWebView::DestroyClonedLayer() { | 112 void ContentsWebView::DestroyClonedLayer() { |
106 cloned_layer_tree_.reset(); | 113 cloned_layer_tree_.reset(); |
107 SetPaintToLayer(false); | 114 SetPaintToLayer(false); |
108 set_layer_owner_delegate(NULL); | 115 set_layer_owner_delegate(NULL); |
109 } | 116 } |
OLD | NEW |