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

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

Issue 986963002: Allow fullscreen manager and control container to be null (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed more comments from tedchoc Created 5 years, 9 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
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/fullscreen/FullscreenManager.java ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/tab_layer.h" 5 #include "chrome/browser/android/compositor/layer/tab_layer.h"
6 6
7 #include "base/i18n/rtl.h" 7 #include "base/i18n/rtl.h"
8 #include "cc/layers/image_layer.h" 8 #include "cc/layers/image_layer.h"
9 #include "cc/layers/layer.h" 9 #include "cc/layers/layer.h"
10 #include "cc/layers/layer_lists.h" 10 #include "cc/layers/layer_lists.h"
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 shadow_y /= border_scale; 139 shadow_y /= border_scale;
140 shadow_width /= border_scale; 140 shadow_width /= border_scale;
141 shadow_height /= border_scale; 141 shadow_height /= border_scale;
142 142
143 //---------------------------------------------------------------------------- 143 //----------------------------------------------------------------------------
144 // Precalculate Helper Values 144 // Precalculate Helper Values
145 //---------------------------------------------------------------------------- 145 //----------------------------------------------------------------------------
146 const gfx::RectF border_padding(border_resource->padding); 146 const gfx::RectF border_padding(border_resource->padding);
147 const gfx::RectF shadow_padding(shadow_resource->padding); 147 const gfx::RectF shadow_padding(shadow_resource->padding);
148 const gfx::RectF contour_padding(contour_resource->padding); 148 const gfx::RectF contour_padding(contour_resource->padding);
149 const gfx::RectF toolbar_padding(toolbar_resource->padding);
150 149
151 // If we're in portrait and we're RTL, the close button is on the left. 150 // If we're in portrait and we're RTL, the close button is on the left.
152 // Similarly if we're in landscape and we're in LTR, the close button is on 151 // Similarly if we're in landscape and we're in LTR, the close button is on
153 // the left. 152 // the left.
154 const bool close_button_on_left = is_portrait == l10n_util::IsLayoutRtl(); 153 const bool close_button_on_left = is_portrait == l10n_util::IsLayoutRtl();
155 const bool back_visible = cos(rotation_x * SK_MScalarPI / 180.0f) < 0 || 154 const bool back_visible = cos(rotation_x * SK_MScalarPI / 180.0f) < 0 ||
156 cos(rotation_y * SK_MScalarPI / 180.0f) < 0; 155 cos(rotation_y * SK_MScalarPI / 180.0f) < 0;
157 156
158 const float content_scale = width / content_width; 157 const float content_scale = width / content_width;
159 gfx::RectF content_area(0.f, 0.f, content_width, content_height); 158 gfx::RectF content_area(0.f, 0.f, content_width, content_height);
160 gfx::RectF scaled_local_content_area(shadow_x, shadow_y, shadow_width, 159 gfx::RectF scaled_local_content_area(shadow_x, shadow_y, shadow_width,
161 shadow_height); 160 shadow_height);
162 gfx::RectF descaled_local_content_area( 161 gfx::RectF descaled_local_content_area(
163 scaled_local_content_area.x() / content_scale, 162 scaled_local_content_area.x() / content_scale,
164 scaled_local_content_area.y() / content_scale, 163 scaled_local_content_area.y() / content_scale,
165 scaled_local_content_area.width() / content_scale, 164 scaled_local_content_area.width() / content_scale,
166 scaled_local_content_area.height() / content_scale); 165 scaled_local_content_area.height() / content_scale);
167 166
168 const gfx::Size shadow_padding_size( 167 const gfx::Size shadow_padding_size(
169 shadow_resource->size.width() - shadow_padding.width(), 168 shadow_resource->size.width() - shadow_padding.width(),
170 shadow_resource->size.height() - shadow_padding.height()); 169 shadow_resource->size.height() - shadow_padding.height());
171 const gfx::Size border_padding_size( 170 const gfx::Size border_padding_size(
172 border_resource->size.width() - border_padding.width(), 171 border_resource->size.width() - border_padding.width(),
173 border_resource->size.height() - border_padding.height()); 172 border_resource->size.height() - border_padding.height());
174 const gfx::Size contour_padding_size( 173 const gfx::Size contour_padding_size(
175 contour_resource->size.width() - contour_padding.width(), 174 contour_resource->size.width() - contour_padding.width(),
176 contour_resource->size.height() - contour_padding.height()); 175 contour_resource->size.height() - contour_padding.height());
177 176
178 gfx::Size toolbar_impact_size(toolbar_padding.size().width(),
179 toolbar_padding.size().height());
180 if (!show_toolbar || back_visible)
181 toolbar_impact_size.SetSize(0, 0);
182 const float close_btn_effective_width = close_btn_width * close_alpha; 177 const float close_btn_effective_width = close_btn_width * close_alpha;
183 178
184 //---------------------------------------------------------------------------- 179 float toolbar_impact_height = 0;
185 // Update Resource Ids For Layers That Impact Layout 180 if (toolbar_resource) {
186 //---------------------------------------------------------------------------- 181 //--------------------------------------------------------------------------
187 toolbar_layer_->PushResource(toolbar_resource, 182 // Update Resource Ids For Layers That Impact Layout
188 nullptr, 183 //--------------------------------------------------------------------------
189 anonymize_toolbar, 184 toolbar_layer_->PushResource(toolbar_resource, nullptr, anonymize_toolbar,
190 incognito_, 185 incognito_, false);
191 false); 186 if (show_toolbar && !back_visible)
187 toolbar_impact_height = toolbar_resource->padding.height();
188 }
192 189
193 //---------------------------------------------------------------------------- 190 //----------------------------------------------------------------------------
194 // Compute Alpha and Visibility 191 // Compute Alpha and Visibility
195 //---------------------------------------------------------------------------- 192 //----------------------------------------------------------------------------
196 border_alpha *= alpha; 193 border_alpha *= alpha;
197 contour_alpha *= alpha; 194 contour_alpha *= alpha;
198 shadow_alpha *= alpha; 195 shadow_alpha *= alpha;
199 close_alpha *= alpha; 196 close_alpha *= alpha;
200 toolbar_alpha *= alpha; 197 toolbar_alpha *= alpha;
201 198
(...skipping 18 matching lines...) Expand all
220 gfx::Size title_size(width - close_btn_effective_width, border_padding.y()); 217 gfx::Size title_size(width - close_btn_effective_width, border_padding.y());
221 gfx::Size back_logo_size; 218 gfx::Size back_logo_size;
222 // TODO(clholgat): Figure out why the back logo is null sometimes. 219 // TODO(clholgat): Figure out why the back logo is null sometimes.
223 if (back_logo_resource) 220 if (back_logo_resource)
224 back_logo_size = back_logo_resource->size; 221 back_logo_size = back_logo_resource->size;
225 222
226 // Store this size at a point as it might go negative during the inset 223 // Store this size at a point as it might go negative during the inset
227 // calculations. 224 // calculations.
228 gfx::Point desired_content_size_pt( 225 gfx::Point desired_content_size_pt(
229 descaled_local_content_area.width(), 226 descaled_local_content_area.width(),
230 descaled_local_content_area.height() - toolbar_impact_size.height()); 227 descaled_local_content_area.height() - toolbar_impact_height);
231 228
232 // Shrink the toolbar layer so we properly clip if it's offset. 229 // Shrink the toolbar layer so we properly clip if it's offset.
233 gfx::Size toolbar_size( 230 gfx::Size toolbar_size(
234 toolbar_layer_->layer()->bounds().width(), 231 toolbar_layer_->layer()->bounds().width(),
235 toolbar_layer_->layer()->bounds().height() - toolbar_y_offset); 232 toolbar_layer_->layer()->bounds().height() - toolbar_y_offset);
236 233
237 //---------------------------------------------------------------------------- 234 //----------------------------------------------------------------------------
238 // Compute Layer Positions 235 // Compute Layer Positions
239 //---------------------------------------------------------------------------- 236 //----------------------------------------------------------------------------
240 gfx::PointF shadow_position(-shadow_padding.x() * side_border_scale, 237 gfx::PointF shadow_position(-shadow_padding.x() * side_border_scale,
241 -shadow_padding.y()); 238 -shadow_padding.y());
242 gfx::PointF border_position(-border_padding.x() * side_border_scale, 239 gfx::PointF border_position(-border_padding.x() * side_border_scale,
243 -border_padding.y()); 240 -border_padding.y());
244 gfx::PointF contour_position(-contour_padding.x() * side_border_scale, 241 gfx::PointF contour_position(-contour_padding.x() * side_border_scale,
245 -contour_padding.y()); 242 -contour_padding.y());
246 gfx::PointF toolbar_position( 243 gfx::PointF toolbar_position(
247 0.f, toolbar_layer_->layer()->bounds().height() - toolbar_size.height()); 244 0.f, toolbar_layer_->layer()->bounds().height() - toolbar_size.height());
248 gfx::PointF content_position(0.f, toolbar_impact_size.height()); 245 gfx::PointF content_position(0.f, toolbar_impact_height);
249 gfx::PointF back_logo_position( 246 gfx::PointF back_logo_position(
250 ((descaled_local_content_area.width() - back_logo_->bounds().width()) * 247 ((descaled_local_content_area.width() - back_logo_->bounds().width()) *
251 content_scale) / 248 content_scale) /
252 2.0f, 249 2.0f,
253 ((descaled_local_content_area.height() - back_logo_->bounds().height()) * 250 ((descaled_local_content_area.height() - back_logo_->bounds().height()) *
254 content_scale) / 251 content_scale) /
255 2.0f); 252 2.0f);
256 gfx::PointF close_button_position; 253 gfx::PointF close_button_position;
257 gfx::PointF title_position; 254 gfx::PointF title_position;
258 255
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 289
293 // Scaled eventually, so have to descale the size difference first. 290 // Scaled eventually, so have to descale the size difference first.
294 toolbar_position.set_y(toolbar_position.y() + inset_diff / content_scale); 291 toolbar_position.set_y(toolbar_position.y() + inset_diff / content_scale);
295 content_position.set_y(content_position.y() + inset_diff / content_scale); 292 content_position.set_y(content_position.y() + inset_diff / content_scale);
296 desired_content_size_pt.set_y(desired_content_size_pt.y() - 293 desired_content_size_pt.set_y(desired_content_size_pt.y() -
297 inset_diff / content_scale); 294 inset_diff / content_scale);
298 } 295 }
299 296
300 const bool inset_toolbar = !inset_border; 297 const bool inset_toolbar = !inset_border;
301 if (!inset_toolbar) { 298 if (!inset_toolbar) {
302 float inset_diff = toolbar_impact_size.height(); 299 float inset_diff = toolbar_impact_height;
303 toolbar_position.set_y(toolbar_position.y() - inset_diff); 300 toolbar_position.set_y(toolbar_position.y() - inset_diff);
304 content_position.set_y(content_position.y() - inset_diff); 301 content_position.set_y(content_position.y() - inset_diff);
305 desired_content_size_pt.set_y(desired_content_size_pt.y() + inset_diff); 302 desired_content_size_pt.set_y(desired_content_size_pt.y() + inset_diff);
306 } 303 }
307 304
308 // Finally build the sizes that might have calculations that go negative. 305 // Finally build the sizes that might have calculations that go negative.
309 gfx::Size desired_content_size(desired_content_size_pt.x(), 306 gfx::Size desired_content_size(desired_content_size_pt.x(),
310 desired_content_size_pt.y()); 307 desired_content_size_pt.y());
311 308
312 //---------------------------------------------------------------------------- 309 //----------------------------------------------------------------------------
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 title_->AddChild(layer); 574 title_->AddChild(layer);
578 } 575 }
579 } 576 }
580 577
581 if (title) 578 if (title)
582 title->SetUIResourceIds(); 579 title->SetUIResourceIds();
583 } 580 }
584 581
585 } // namespace android 582 } // namespace android
586 } // namespace chrome 583 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/fullscreen/FullscreenManager.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698