 Chromium Code Reviews
 Chromium Code Reviews Issue 12552004:
  Support bottom-right anchored fixed-position elements during a pinch gesture  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master
    
  
    Issue 12552004:
  Support bottom-right anchored fixed-position elements during a pinch gesture  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master| OLD | NEW | 
|---|---|
| 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 "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" | 
| 8 #include "cc/animation/animation.h" | 8 #include "cc/animation/animation.h" | 
| 9 #include "cc/animation/animation_events.h" | 9 #include "cc/animation/animation_events.h" | 
| 10 #include "cc/animation/layer_animation_controller.h" | 10 #include "cc/animation/layer_animation_controller.h" | 
| (...skipping 22 matching lines...) Expand all Loading... | |
| 33 parent_(NULL), | 33 parent_(NULL), | 
| 34 layer_tree_host_(NULL), | 34 layer_tree_host_(NULL), | 
| 35 scrollable_(false), | 35 scrollable_(false), | 
| 36 should_scroll_on_main_thread_(false), | 36 should_scroll_on_main_thread_(false), | 
| 37 have_wheel_event_handlers_(false), | 37 have_wheel_event_handlers_(false), | 
| 38 anchor_point_(0.5f, 0.5f), | 38 anchor_point_(0.5f, 0.5f), | 
| 39 background_color_(0), | 39 background_color_(0), | 
| 40 opacity_(1.f), | 40 opacity_(1.f), | 
| 41 anchor_point_z_(0.f), | 41 anchor_point_z_(0.f), | 
| 42 is_container_for_fixed_position_layers_(false), | 42 is_container_for_fixed_position_layers_(false), | 
| 43 fixed_to_container_layer_(false), | |
| 44 is_drawable_(false), | 43 is_drawable_(false), | 
| 45 masks_to_bounds_(false), | 44 masks_to_bounds_(false), | 
| 46 contents_opaque_(false), | 45 contents_opaque_(false), | 
| 47 double_sided_(true), | 46 double_sided_(true), | 
| 48 preserves_3d_(false), | 47 preserves_3d_(false), | 
| 49 use_parent_backface_visibility_(false), | 48 use_parent_backface_visibility_(false), | 
| 50 draw_checkerboard_for_missing_tiles_(false), | 49 draw_checkerboard_for_missing_tiles_(false), | 
| 51 force_render_surface_(false), | 50 force_render_surface_(false), | 
| 52 replica_layer_(NULL), | 51 replica_layer_(NULL), | 
| 53 raster_scale_(1.f), | 52 raster_scale_(1.f), | 
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 408 SetNeedsCommit(); | 407 SetNeedsCommit(); | 
| 409 } | 408 } | 
| 410 | 409 | 
| 411 void Layer::SetPosition(gfx::PointF position) { | 410 void Layer::SetPosition(gfx::PointF position) { | 
| 412 if (position_ == position) | 411 if (position_ == position) | 
| 413 return; | 412 return; | 
| 414 position_ = position; | 413 position_ = position; | 
| 415 SetNeedsCommit(); | 414 SetNeedsCommit(); | 
| 416 } | 415 } | 
| 417 | 416 | 
| 417 bool Layer::is_container_for_fixed_position_layers() const { | |
| 
Sami
2013/03/25 11:41:37
Any reason why this is on Layer instead LayerImpl?
 
trchen
2013/03/26 01:45:28
Extra transform may be applied in LayerImpl but tr
 | |
| 418 if (!transform_.IsIdentityOrTranslation()) | |
| 419 return true; | |
| 420 if (parent_ && !parent_->sublayer_transform_.IsIdentityOrTranslation()) | |
| 
Sami
2013/03/25 11:41:37
Should we also check sublayer_transform_ for this
 
trchen
2013/03/26 01:45:28
It is arguable but I would vote not. The point of
 
shawnsingh
2013/03/27 19:46:39
In reply to Sami asking "Should we also check subl
 | |
| 421 return true; | |
| 422 return is_container_for_fixed_position_layers_; | |
| 423 } | |
| 424 | |
| 418 void Layer::SetSublayerTransform(const gfx::Transform& sublayer_transform) { | 425 void Layer::SetSublayerTransform(const gfx::Transform& sublayer_transform) { | 
| 419 if (sublayer_transform_ == sublayer_transform) | 426 if (sublayer_transform_ == sublayer_transform) | 
| 420 return; | 427 return; | 
| 421 sublayer_transform_ = sublayer_transform; | 428 sublayer_transform_ = sublayer_transform; | 
| 422 SetNeedsCommit(); | 429 SetNeedsCommit(); | 
| 423 } | 430 } | 
| 424 | 431 | 
| 425 void Layer::SetTransform(const gfx::Transform& transform) { | 432 void Layer::SetTransform(const gfx::Transform& transform) { | 
| 426 if (transform_ == transform) | 433 if (transform_ == transform) | 
| 427 return; | 434 return; | 
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 525 | 532 | 
| 526 // Simply mark the contents as dirty. For non-root layers, the call to | 533 // Simply mark the contents as dirty. For non-root layers, the call to | 
| 527 // SetNeedsCommit will schedule a fresh compositing pass. | 534 // SetNeedsCommit will schedule a fresh compositing pass. | 
| 528 // For the root layer, SetNeedsCommit has no effect. | 535 // For the root layer, SetNeedsCommit has no effect. | 
| 529 if (DrawsContent() && !update_rect_.IsEmpty()) | 536 if (DrawsContent() && !update_rect_.IsEmpty()) | 
| 530 SetNeedsCommit(); | 537 SetNeedsCommit(); | 
| 531 } | 538 } | 
| 532 | 539 | 
| 533 bool Layer::DescendantIsFixedToContainerLayer() const { | 540 bool Layer::DescendantIsFixedToContainerLayer() const { | 
| 534 for (size_t i = 0; i < children_.size(); ++i) { | 541 for (size_t i = 0; i < children_.size(); ++i) { | 
| 535 if (children_[i]->fixed_to_container_layer() || | 542 if (children_[i]->position_constraint_.is_fixed_position() || | 
| 536 children_[i]->DescendantIsFixedToContainerLayer()) | 543 children_[i]->DescendantIsFixedToContainerLayer()) | 
| 537 return true; | 544 return true; | 
| 538 } | 545 } | 
| 539 return false; | 546 return false; | 
| 540 } | 547 } | 
| 541 | 548 | 
| 542 void Layer::SetIsContainerForFixedPositionLayers(bool container) { | 549 void Layer::SetIsContainerForFixedPositionLayers(bool container) { | 
| 543 if (is_container_for_fixed_position_layers_ == container) | 550 if (is_container_for_fixed_position_layers_ == container) | 
| 544 return; | 551 return; | 
| 545 is_container_for_fixed_position_layers_ = container; | 552 is_container_for_fixed_position_layers_ = container; | 
| 546 | 553 | 
| 547 if (layer_tree_host_ && layer_tree_host_->CommitRequested()) | 554 if (layer_tree_host_ && layer_tree_host_->CommitRequested()) | 
| 548 return; | 555 return; | 
| 549 | 556 | 
| 550 // Only request a commit if we have a fixed positioned descendant. | 557 // Only request a commit if we have a fixed positioned descendant. | 
| 551 if (DescendantIsFixedToContainerLayer()) | 558 if (DescendantIsFixedToContainerLayer()) | 
| 552 SetNeedsCommit(); | 559 SetNeedsCommit(); | 
| 553 } | 560 } | 
| 554 | 561 | 
| 555 void Layer::SetFixedToContainerLayer(bool fixed_to_container_layer) { | 562 void Layer::SetPositionConstraint(const LayerPositionConstraint& constraint) { | 
| 556 if (fixed_to_container_layer_ == fixed_to_container_layer) | 563 if (position_constraint_ == constraint) | 
| 557 return; | 564 return; | 
| 558 fixed_to_container_layer_ = fixed_to_container_layer; | 565 position_constraint_ = constraint; | 
| 559 SetNeedsCommit(); | 566 SetNeedsCommit(); | 
| 560 } | 567 } | 
| 561 | 568 | 
| 562 void Layer::PushPropertiesTo(LayerImpl* layer) { | 569 void Layer::PushPropertiesTo(LayerImpl* layer) { | 
| 563 layer->SetAnchorPoint(anchor_point_); | 570 layer->SetAnchorPoint(anchor_point_); | 
| 564 layer->SetAnchorPointZ(anchor_point_z_); | 571 layer->SetAnchorPointZ(anchor_point_z_); | 
| 565 layer->SetBackgroundColor(background_color_); | 572 layer->SetBackgroundColor(background_color_); | 
| 566 layer->SetBounds(bounds_); | 573 layer->SetBounds(bounds_); | 
| 567 layer->SetContentBounds(content_bounds()); | 574 layer->SetContentBounds(content_bounds()); | 
| 568 layer->SetContentsScale(contents_scale_x(), contents_scale_y()); | 575 layer->SetContentsScale(contents_scale_x(), contents_scale_y()); | 
| 569 layer->SetDebugName(debug_name_); | 576 layer->SetDebugName(debug_name_); | 
| (...skipping 10 matching lines...) Expand all Loading... | |
| 580 layer->SetHaveWheelEventHandlers(have_wheel_event_handlers_); | 587 layer->SetHaveWheelEventHandlers(have_wheel_event_handlers_); | 
| 581 layer->SetNonFastScrollableRegion(non_fast_scrollable_region_); | 588 layer->SetNonFastScrollableRegion(non_fast_scrollable_region_); | 
| 582 layer->SetTouchEventHandlerRegion(touch_event_handler_region_); | 589 layer->SetTouchEventHandlerRegion(touch_event_handler_region_); | 
| 583 layer->SetContentsOpaque(contents_opaque_); | 590 layer->SetContentsOpaque(contents_opaque_); | 
| 584 if (!layer->OpacityIsAnimatingOnImplOnly()) | 591 if (!layer->OpacityIsAnimatingOnImplOnly()) | 
| 585 layer->SetOpacity(opacity_); | 592 layer->SetOpacity(opacity_); | 
| 586 DCHECK(!(OpacityIsAnimating() && layer->OpacityIsAnimatingOnImplOnly())); | 593 DCHECK(!(OpacityIsAnimating() && layer->OpacityIsAnimatingOnImplOnly())); | 
| 587 layer->SetPosition(position_); | 594 layer->SetPosition(position_); | 
| 588 layer->SetIsContainerForFixedPositionLayers( | 595 layer->SetIsContainerForFixedPositionLayers( | 
| 589 is_container_for_fixed_position_layers_); | 596 is_container_for_fixed_position_layers_); | 
| 590 layer->SetFixedToContainerLayer(fixed_to_container_layer_); | 597 layer->SetFixedContainerSizeDelta(gfx::Vector2dF()); | 
| 598 layer->SetPositionConstraint(position_constraint_); | |
| 591 layer->SetPreserves3d(preserves_3d()); | 599 layer->SetPreserves3d(preserves_3d()); | 
| 592 layer->SetUseParentBackfaceVisibility(use_parent_backface_visibility_); | 600 layer->SetUseParentBackfaceVisibility(use_parent_backface_visibility_); | 
| 593 layer->SetSublayerTransform(sublayer_transform_); | 601 layer->SetSublayerTransform(sublayer_transform_); | 
| 594 if (!layer->TransformIsAnimatingOnImplOnly()) | 602 if (!layer->TransformIsAnimatingOnImplOnly()) | 
| 595 layer->SetTransform(transform_); | 603 layer->SetTransform(transform_); | 
| 596 DCHECK(!(TransformIsAnimating() && layer->TransformIsAnimatingOnImplOnly())); | 604 DCHECK(!(TransformIsAnimating() && layer->TransformIsAnimatingOnImplOnly())); | 
| 597 | 605 | 
| 598 layer->SetScrollable(scrollable_); | 606 layer->SetScrollable(scrollable_); | 
| 599 layer->SetScrollOffset(scroll_offset_); | 607 layer->SetScrollOffset(scroll_offset_); | 
| 600 layer->SetMaxScrollOffset(max_scroll_offset_); | 608 layer->SetMaxScrollOffset(max_scroll_offset_); | 
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 811 if (contents_opaque()) | 819 if (contents_opaque()) | 
| 812 return visible_content_rect(); | 820 return visible_content_rect(); | 
| 813 return Region(); | 821 return Region(); | 
| 814 } | 822 } | 
| 815 | 823 | 
| 816 ScrollbarLayer* Layer::ToScrollbarLayer() { | 824 ScrollbarLayer* Layer::ToScrollbarLayer() { | 
| 817 return NULL; | 825 return NULL; | 
| 818 } | 826 } | 
| 819 | 827 | 
| 820 } // namespace cc | 828 } // namespace cc | 
| OLD | NEW |