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

Side by Side Diff: chrome/browser/android/compositor/layer/contextual_search_layer.cc

Issue 1061063005: [Contextual Search] Fix Promo behavior. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sync & rebase Created 5 years, 8 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/android/compositor/layer/contextual_search_layer.h" 5 #include "chrome/browser/android/compositor/layer/contextual_search_layer.h"
6 6
7 #include "cc/layers/layer.h" 7 #include "cc/layers/layer.h"
8 #include "cc/layers/nine_patch_layer.h" 8 #include "cc/layers/nine_patch_layer.h"
9 #include "cc/layers/solid_color_layer.h" 9 #include "cc/layers/solid_color_layer.h"
10 #include "cc/layers/ui_resource_layer.h" 10 #include "cc/layers/ui_resource_layer.h"
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 search_icon_->SetOpacity(search_icon_opacity); 139 search_icon_->SetOpacity(search_icon_opacity);
140 140
141 // --------------------------------------------------------------------------- 141 // ---------------------------------------------------------------------------
142 // Search Promo 142 // Search Promo
143 // --------------------------------------------------------------------------- 143 // ---------------------------------------------------------------------------
144 if (search_promo_visible) { 144 if (search_promo_visible) {
145 // Grab the Search Opt Out Promo resource. 145 // Grab the Search Opt Out Promo resource.
146 ui::ResourceManager::Resource* search_promo_resource = 146 ui::ResourceManager::Resource* search_promo_resource =
147 resource_manager_->GetResource(ui::ANDROID_RESOURCE_TYPE_DYNAMIC, 147 resource_manager_->GetResource(ui::ANDROID_RESOURCE_TYPE_DYNAMIC,
148 search_promo_resource_id); 148 search_promo_resource_id);
149 // Search Promo Container
150 if (search_promo_container_->parent() != layer_) {
151 // NOTE(pedrosimonetti): The Promo layer should be always placed before
152 // Search Bar Shadow to make sure it won't occlude the shadow.
153 layer_->InsertChild(search_promo_container_, 0);
154 }
149 155
150 if (search_promo_resource) { 156 if (search_promo_resource) {
151 // Search Promo Container
152 if (search_promo_container_->parent() != layer_)
153 layer_->AddChild(search_promo_container_);
154
155 int search_promo_content_height = search_promo_resource->size.height(); 157 int search_promo_content_height = search_promo_resource->size.height();
156 gfx::Size search_promo_size(search_panel_width, search_promo_height); 158 gfx::Size search_promo_size(search_panel_width, search_promo_height);
157 search_promo_container_->SetBounds(search_promo_size); 159 search_promo_container_->SetBounds(search_promo_size);
158 search_promo_container_->SetPosition(gfx::PointF(0.f, search_bar_height)); 160 search_promo_container_->SetPosition(gfx::PointF(0.f, search_bar_height));
159 search_promo_container_->SetMasksToBounds(true); 161 search_promo_container_->SetMasksToBounds(true);
160 162
161 // Search Promo 163 // Search Promo
162 if (search_promo_->parent() != search_promo_container_) 164 if (search_promo_->parent() != search_promo_container_)
163 search_promo_container_->AddChild(search_promo_); 165 search_promo_container_->AddChild(search_promo_);
164 166
165 search_promo_->SetUIResourceId(search_promo_resource->ui_resource->id()); 167 search_promo_->SetUIResourceId(search_promo_resource->ui_resource->id());
166 search_promo_->SetBounds(search_promo_resource->size); 168 search_promo_->SetBounds(search_promo_resource->size);
167 // Align promo at the bottom of the container so the confirmation button 169 // Align promo at the bottom of the container so the confirmation button
168 // is is not clipped when resizing the promo. 170 // is is not clipped when resizing the promo.
169 search_promo_->SetPosition( 171 search_promo_->SetPosition(
170 gfx::PointF(0.f, search_promo_height - search_promo_content_height)); 172 gfx::PointF(0.f, search_promo_height - search_promo_content_height));
171 search_promo_->SetOpacity(search_promo_opacity); 173 search_promo_->SetOpacity(search_promo_opacity);
172 } 174 }
173 } else { 175 } else {
174 // TODO(pedrosimonetti): confirm with dtrainor@ that we don't need to remove
175 // the child too (since it's going to be removed when the parent is gone).
176
177 // Search Promo Container 176 // Search Promo Container
178 if (search_promo_container_.get() && search_promo_container_->parent()) 177 if (search_promo_container_.get() && search_promo_container_->parent())
179 search_promo_container_->RemoveFromParent(); 178 search_promo_container_->RemoveFromParent();
180 } 179 }
181 180
182 // --------------------------------------------------------------------------- 181 // ---------------------------------------------------------------------------
183 // Search Content View 182 // Search Content View
184 // --------------------------------------------------------------------------- 183 // ---------------------------------------------------------------------------
185 content_view_container_->SetPosition( 184 content_view_container_->SetPosition(
186 gfx::PointF(0.f, search_bar_height + search_promo_height)); 185 gfx::PointF(0.f, search_bar_height + search_promo_height));
187 if (content_view_core && content_view_core->GetLayer().get()) { 186 if (content_view_core && content_view_core->GetLayer().get()) {
188 scoped_refptr<cc::Layer> content_view_layer = content_view_core->GetLayer(); 187 scoped_refptr<cc::Layer> content_view_layer = content_view_core->GetLayer();
189 if (content_view_layer->parent() != content_view_container_) 188 if (content_view_layer->parent() != content_view_container_)
190 content_view_container_->AddChild(content_view_layer); 189 content_view_container_->AddChild(content_view_layer);
191 } else { 190 } else {
192 content_view_container_->RemoveAllChildren(); 191 content_view_container_->RemoveAllChildren();
193 } 192 }
194 193
195 // --------------------------------------------------------------------------- 194 // ---------------------------------------------------------------------------
196 // Search Bar Shadow 195 // Search Bar Shadow
197 // --------------------------------------------------------------------------- 196 // ---------------------------------------------------------------------------
198 if (search_bar_shadow_visible) { 197 if (search_bar_shadow_visible) {
199 ui::ResourceManager::Resource* search_bar_shadow_resource = 198 ui::ResourceManager::Resource* search_bar_shadow_resource =
200 resource_manager_->GetResource(ui::ANDROID_RESOURCE_TYPE_STATIC, 199 resource_manager_->GetResource(ui::ANDROID_RESOURCE_TYPE_STATIC,
201 search_bar_shadow_resource_id); 200 search_bar_shadow_resource_id);
202 201
203 if (search_bar_shadow_resource) { 202 if (search_bar_shadow_resource) {
204 if (search_bar_shadow_->parent() != layer_) 203 if (search_bar_shadow_->parent() != layer_)
205 layer_->AddChild(search_bar_shadow_); 204 layer_->AddChild(search_bar_shadow_);
205
206 int shadow_height = search_bar_shadow_resource->size.height();
207 gfx::Size shadow_size(search_panel_width, shadow_height);
208
209 search_bar_shadow_->SetUIResourceId(
210 search_bar_shadow_resource->ui_resource->id());
211 search_bar_shadow_->SetBounds(shadow_size);
212 search_bar_shadow_->SetPosition(gfx::PointF(0.f, search_bar_height));
213 search_bar_shadow_->SetOpacity(search_bar_shadow_opacity);
206 } 214 }
207
208 int shadow_height = search_bar_shadow_resource->size.height();
209 gfx::Size shadow_size(search_panel_width, shadow_height);
210
211 search_bar_shadow_->SetUIResourceId(
212 search_bar_shadow_resource->ui_resource->id());
213 search_bar_shadow_->SetBounds(shadow_size);
214 search_bar_shadow_->SetPosition(gfx::PointF(0.f, search_bar_height));
215 search_bar_shadow_->SetOpacity(search_bar_shadow_opacity);
216 } else { 215 } else {
217 if (search_bar_shadow_.get() && search_bar_shadow_->parent()) 216 if (search_bar_shadow_.get() && search_bar_shadow_->parent())
218 search_bar_shadow_->RemoveFromParent(); 217 search_bar_shadow_->RemoveFromParent();
219 } 218 }
220 219
221 // --------------------------------------------------------------------------- 220 // ---------------------------------------------------------------------------
222 // Search Panel. 221 // Search Panel.
223 // --------------------------------------------------------------------------- 222 // ---------------------------------------------------------------------------
224 layer_->SetPosition(gfx::PointF(0.f, search_panel_y)); 223 layer_->SetPosition(gfx::PointF(0.f, search_panel_y));
225 224
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 352
354 ContextualSearchLayer::~ContextualSearchLayer() { 353 ContextualSearchLayer::~ContextualSearchLayer() {
355 } 354 }
356 355
357 scoped_refptr<cc::Layer> ContextualSearchLayer::layer() { 356 scoped_refptr<cc::Layer> ContextualSearchLayer::layer() {
358 return layer_; 357 return layer_;
359 } 358 }
360 359
361 } // namespace android 360 } // namespace android
362 } // namespace chrome 361 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchManagementDelegate.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698