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

Side by Side Diff: cc/layers/layer.cc

Issue 12552004: Support bottom-right anchored fixed-position elements during a pinch gesture (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: forgot to save the comments. sorry. :( Created 7 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
« no previous file with comments | « cc/layers/layer.h ('k') | cc/layers/layer_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 The Chromium Authors. All rights reserved. 1 // Copyright 2010 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 "cc/layers/layer.h" 5 #include "cc/layers/layer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "cc/animation/animation.h" 10 #include "cc/animation/animation.h"
(...skipping 24 matching lines...) Expand all
35 parent_(NULL), 35 parent_(NULL),
36 layer_tree_host_(NULL), 36 layer_tree_host_(NULL),
37 scrollable_(false), 37 scrollable_(false),
38 should_scroll_on_main_thread_(false), 38 should_scroll_on_main_thread_(false),
39 have_wheel_event_handlers_(false), 39 have_wheel_event_handlers_(false),
40 anchor_point_(0.5f, 0.5f), 40 anchor_point_(0.5f, 0.5f),
41 background_color_(0), 41 background_color_(0),
42 opacity_(1.f), 42 opacity_(1.f),
43 anchor_point_z_(0.f), 43 anchor_point_z_(0.f),
44 is_container_for_fixed_position_layers_(false), 44 is_container_for_fixed_position_layers_(false),
45 fixed_to_container_layer_(false),
46 is_drawable_(false), 45 is_drawable_(false),
47 masks_to_bounds_(false), 46 masks_to_bounds_(false),
48 contents_opaque_(false), 47 contents_opaque_(false),
49 double_sided_(true), 48 double_sided_(true),
50 preserves_3d_(false), 49 preserves_3d_(false),
51 use_parent_backface_visibility_(false), 50 use_parent_backface_visibility_(false),
52 draw_checkerboard_for_missing_tiles_(false), 51 draw_checkerboard_for_missing_tiles_(false),
53 force_render_surface_(false), 52 force_render_surface_(false),
54 replica_layer_(NULL), 53 replica_layer_(NULL),
55 raster_scale_(1.f), 54 raster_scale_(1.f),
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 SetNeedsCommit(); 408 SetNeedsCommit();
410 } 409 }
411 410
412 void Layer::SetPosition(gfx::PointF position) { 411 void Layer::SetPosition(gfx::PointF position) {
413 if (position_ == position) 412 if (position_ == position)
414 return; 413 return;
415 position_ = position; 414 position_ = position;
416 SetNeedsCommit(); 415 SetNeedsCommit();
417 } 416 }
418 417
418 bool Layer::IsContainerForFixedPositionLayers() const {
419 if (!transform_.IsIdentityOrTranslation())
420 return true;
421 if (parent_ && !parent_->sublayer_transform_.IsIdentityOrTranslation())
422 return true;
423 return is_container_for_fixed_position_layers_;
424 }
425
419 void Layer::SetSublayerTransform(const gfx::Transform& sublayer_transform) { 426 void Layer::SetSublayerTransform(const gfx::Transform& sublayer_transform) {
420 if (sublayer_transform_ == sublayer_transform) 427 if (sublayer_transform_ == sublayer_transform)
421 return; 428 return;
422 sublayer_transform_ = sublayer_transform; 429 sublayer_transform_ = sublayer_transform;
423 SetNeedsCommit(); 430 SetNeedsCommit();
424 } 431 }
425 432
426 void Layer::SetTransform(const gfx::Transform& transform) { 433 void Layer::SetTransform(const gfx::Transform& transform) {
427 if (transform_ == transform) 434 if (transform_ == transform)
428 return; 435 return;
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 533
527 // Simply mark the contents as dirty. For non-root layers, the call to 534 // Simply mark the contents as dirty. For non-root layers, the call to
528 // SetNeedsCommit will schedule a fresh compositing pass. 535 // SetNeedsCommit will schedule a fresh compositing pass.
529 // For the root layer, SetNeedsCommit has no effect. 536 // For the root layer, SetNeedsCommit has no effect.
530 if (DrawsContent() && !update_rect_.IsEmpty()) 537 if (DrawsContent() && !update_rect_.IsEmpty())
531 SetNeedsCommit(); 538 SetNeedsCommit();
532 } 539 }
533 540
534 bool Layer::DescendantIsFixedToContainerLayer() const { 541 bool Layer::DescendantIsFixedToContainerLayer() const {
535 for (size_t i = 0; i < children_.size(); ++i) { 542 for (size_t i = 0; i < children_.size(); ++i) {
536 if (children_[i]->fixed_to_container_layer() || 543 if (children_[i]->position_constraint_.is_fixed_position() ||
537 children_[i]->DescendantIsFixedToContainerLayer()) 544 children_[i]->DescendantIsFixedToContainerLayer())
538 return true; 545 return true;
539 } 546 }
540 return false; 547 return false;
541 } 548 }
542 549
543 void Layer::SetIsContainerForFixedPositionLayers(bool container) { 550 void Layer::SetIsContainerForFixedPositionLayers(bool container) {
544 if (is_container_for_fixed_position_layers_ == container) 551 if (is_container_for_fixed_position_layers_ == container)
545 return; 552 return;
546 is_container_for_fixed_position_layers_ = container; 553 is_container_for_fixed_position_layers_ = container;
547 554
548 if (layer_tree_host_ && layer_tree_host_->CommitRequested()) 555 if (layer_tree_host_ && layer_tree_host_->CommitRequested())
549 return; 556 return;
550 557
551 // Only request a commit if we have a fixed positioned descendant. 558 // Only request a commit if we have a fixed positioned descendant.
552 if (DescendantIsFixedToContainerLayer()) 559 if (DescendantIsFixedToContainerLayer())
553 SetNeedsCommit(); 560 SetNeedsCommit();
554 } 561 }
555 562
556 void Layer::SetFixedToContainerLayer(bool fixed_to_container_layer) { 563 void Layer::SetPositionConstraint(const LayerPositionConstraint& constraint) {
557 if (fixed_to_container_layer_ == fixed_to_container_layer) 564 if (position_constraint_ == constraint)
558 return; 565 return;
559 fixed_to_container_layer_ = fixed_to_container_layer; 566 position_constraint_ = constraint;
560 SetNeedsCommit(); 567 SetNeedsCommit();
561 } 568 }
562 569
563 void Layer::PushPropertiesTo(LayerImpl* layer) { 570 void Layer::PushPropertiesTo(LayerImpl* layer) {
564 layer->SetAnchorPoint(anchor_point_); 571 layer->SetAnchorPoint(anchor_point_);
565 layer->SetAnchorPointZ(anchor_point_z_); 572 layer->SetAnchorPointZ(anchor_point_z_);
566 layer->SetBackgroundColor(background_color_); 573 layer->SetBackgroundColor(background_color_);
567 layer->SetBounds(bounds_); 574 layer->SetBounds(bounds_);
568 layer->SetContentBounds(content_bounds()); 575 layer->SetContentBounds(content_bounds());
569 layer->SetContentsScale(contents_scale_x(), contents_scale_y()); 576 layer->SetContentsScale(contents_scale_x(), contents_scale_y());
570 layer->SetDebugName(debug_name_); 577 layer->SetDebugName(debug_name_);
571 layer->SetDoubleSided(double_sided_); 578 layer->SetDoubleSided(double_sided_);
572 layer->SetDrawCheckerboardForMissingTiles( 579 layer->SetDrawCheckerboardForMissingTiles(
573 draw_checkerboard_for_missing_tiles_); 580 draw_checkerboard_for_missing_tiles_);
574 layer->SetForceRenderSurface(force_render_surface_); 581 layer->SetForceRenderSurface(force_render_surface_);
575 layer->SetDrawsContent(DrawsContent()); 582 layer->SetDrawsContent(DrawsContent());
576 layer->SetFilters(filters()); 583 layer->SetFilters(filters());
577 layer->SetFilter(filter()); 584 layer->SetFilter(filter());
578 layer->SetBackgroundFilters(background_filters()); 585 layer->SetBackgroundFilters(background_filters());
579 layer->SetMasksToBounds(masks_to_bounds_); 586 layer->SetMasksToBounds(masks_to_bounds_);
580 layer->SetShouldScrollOnMainThread(should_scroll_on_main_thread_); 587 layer->SetShouldScrollOnMainThread(should_scroll_on_main_thread_);
581 layer->SetHaveWheelEventHandlers(have_wheel_event_handlers_); 588 layer->SetHaveWheelEventHandlers(have_wheel_event_handlers_);
582 layer->SetNonFastScrollableRegion(non_fast_scrollable_region_); 589 layer->SetNonFastScrollableRegion(non_fast_scrollable_region_);
583 layer->SetTouchEventHandlerRegion(touch_event_handler_region_); 590 layer->SetTouchEventHandlerRegion(touch_event_handler_region_);
584 layer->SetContentsOpaque(contents_opaque_); 591 layer->SetContentsOpaque(contents_opaque_);
585 if (!layer->OpacityIsAnimatingOnImplOnly() && !OpacityIsAnimating()) 592 if (!layer->OpacityIsAnimatingOnImplOnly() && !OpacityIsAnimating())
586 layer->SetOpacity(opacity_); 593 layer->SetOpacity(opacity_);
587 DCHECK(!(OpacityIsAnimating() && layer->OpacityIsAnimatingOnImplOnly())); 594 DCHECK(!(OpacityIsAnimating() && layer->OpacityIsAnimatingOnImplOnly()));
588 layer->SetPosition(position_); 595 layer->SetPosition(position_);
589 layer->SetIsContainerForFixedPositionLayers( 596 layer->SetIsContainerForFixedPositionLayers(
590 is_container_for_fixed_position_layers_); 597 IsContainerForFixedPositionLayers());
591 layer->SetFixedToContainerLayer(fixed_to_container_layer_); 598 layer->SetFixedContainerSizeDelta(gfx::Vector2dF());
599 layer->SetPositionConstraint(position_constraint_);
592 layer->SetPreserves3d(preserves_3d()); 600 layer->SetPreserves3d(preserves_3d());
593 layer->SetUseParentBackfaceVisibility(use_parent_backface_visibility_); 601 layer->SetUseParentBackfaceVisibility(use_parent_backface_visibility_);
594 layer->SetSublayerTransform(sublayer_transform_); 602 layer->SetSublayerTransform(sublayer_transform_);
595 if (!layer->TransformIsAnimatingOnImplOnly() && !TransformIsAnimating()) 603 if (!layer->TransformIsAnimatingOnImplOnly() && !TransformIsAnimating())
596 layer->SetTransform(transform_); 604 layer->SetTransform(transform_);
597 DCHECK(!(TransformIsAnimating() && layer->TransformIsAnimatingOnImplOnly())); 605 DCHECK(!(TransformIsAnimating() && layer->TransformIsAnimatingOnImplOnly()));
598 606
599 layer->SetScrollable(scrollable_); 607 layer->SetScrollable(scrollable_);
600 layer->SetScrollOffset(scroll_offset_); 608 layer->SetScrollOffset(scroll_offset_);
601 layer->SetMaxScrollOffset(max_scroll_offset_); 609 layer->SetMaxScrollOffset(max_scroll_offset_);
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
820 828
821 ScrollbarLayer* Layer::ToScrollbarLayer() { 829 ScrollbarLayer* Layer::ToScrollbarLayer() {
822 return NULL; 830 return NULL;
823 } 831 }
824 832
825 RenderingStatsInstrumentation* Layer::rendering_stats_instrumentation() const { 833 RenderingStatsInstrumentation* Layer::rendering_stats_instrumentation() const {
826 return layer_tree_host_->rendering_stats_instrumentation(); 834 return layer_tree_host_->rendering_stats_instrumentation();
827 } 835 }
828 836
829 } // namespace cc 837 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/layer.h ('k') | cc/layers/layer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698