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

Side by Side Diff: chrome/browser/ui/views/frame/contents_web_view.cc

Issue 2639203007: Update SetPaintToLayer to accept LayerType (Closed)
Patch Set: Refactor Created 3 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 unified diff | Download patch
OLDNEW
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/render_widget_host_view.h" 9 #include "content/public/browser/render_widget_host_view.h"
10 #include "content/public/browser/web_contents.h" 10 #include "content/public/browser/web_contents.h"
11 #include "ui/base/theme_provider.h" 11 #include "ui/base/theme_provider.h"
12 #include "ui/compositor/layer_tree_owner.h" 12 #include "ui/compositor/layer_tree_owner.h"
13 #include "ui/compositor/layer_type.h"
13 #include "ui/views/background.h" 14 #include "ui/views/background.h"
14 15
15 #if defined(USE_AURA) 16 #if defined(USE_AURA)
16 #include "ui/aura/window.h" 17 #include "ui/aura/window.h"
17 #include "ui/wm/core/window_util.h" 18 #include "ui/wm/core/window_util.h"
18 #endif 19 #endif
19 20
20 ContentsWebView::ContentsWebView(content::BrowserContext* browser_context) 21 ContentsWebView::ContentsWebView(content::BrowserContext* browser_context)
21 : views::WebView(browser_context), 22 : views::WebView(browser_context),
22 status_bubble_(nullptr) { 23 status_bubble_(nullptr) {
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 #if defined(USE_AURA) 99 #if defined(USE_AURA)
99 // We don't need to clone the layers on non-Aura (Mac), because closing an 100 // We don't need to clone the layers on non-Aura (Mac), because closing an
100 // NSWindow does not animate. 101 // NSWindow does not animate.
101 cloned_layer_tree_ = wm::RecreateLayers(web_contents()->GetNativeView()); 102 cloned_layer_tree_ = wm::RecreateLayers(web_contents()->GetNativeView());
102 #endif 103 #endif
103 if (!cloned_layer_tree_ || !cloned_layer_tree_->root()) { 104 if (!cloned_layer_tree_ || !cloned_layer_tree_->root()) {
104 cloned_layer_tree_.reset(); 105 cloned_layer_tree_.reset();
105 return; 106 return;
106 } 107 }
107 108
108 SetPaintToLayer(true); 109 SetPaintToLayer(ui::LAYER_TEXTURED);
109 set_layer_owner_delegate(this); 110 set_layer_owner_delegate(this);
110 111
111 // The cloned layer is in a different coordinate system them our layer (which 112 // The cloned layer is in a different coordinate system them our layer (which
112 // is now the new parent of the cloned layer). Convert coordinates so that the 113 // is now the new parent of the cloned layer). Convert coordinates so that the
113 // cloned layer appears at the right location. 114 // cloned layer appears at the right location.
114 gfx::Point origin; 115 gfx::Point origin;
115 ui::Layer::ConvertPointToLayer(cloned_layer_tree_->root(), layer(), &origin); 116 ui::Layer::ConvertPointToLayer(cloned_layer_tree_->root(), layer(), &origin);
116 cloned_layer_tree_->root()->SetBounds( 117 cloned_layer_tree_->root()->SetBounds(
117 gfx::Rect(origin, cloned_layer_tree_->root()->bounds().size())); 118 gfx::Rect(origin, cloned_layer_tree_->root()->bounds().size()));
118 layer()->Add(cloned_layer_tree_->root()); 119 layer()->Add(cloned_layer_tree_->root());
119 } 120 }
120 121
121 void ContentsWebView::DestroyClonedLayer() { 122 void ContentsWebView::DestroyClonedLayer() {
122 cloned_layer_tree_.reset(); 123 cloned_layer_tree_.reset();
123 SetPaintToLayer(false); 124 SetPaintToLayer(ui::LAYER_NOT_DRAWN);
124 set_layer_owner_delegate(nullptr); 125 set_layer_owner_delegate(nullptr);
125 } 126 }
126 127
127 void ContentsWebView::RenderViewReady() { 128 void ContentsWebView::RenderViewReady() {
128 // Apply the theme color to be the default background on startup. 129 // Apply the theme color to be the default background on startup.
129 OnThemeChanged(); 130 OnThemeChanged();
130 WebView::RenderViewReady(); 131 WebView::RenderViewReady();
131 } 132 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698