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

Side by Side Diff: third_party/WebKit/Source/core/paint/PaintLayer.cpp

Issue 2854213004: Update layer size from LayoutBox::UpdateAfterLayout (Closed)
Patch Set: rebase Created 3 years, 7 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 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights
3 * reserved. 3 * reserved.
4 * 4 *
5 * Portions are Copyright (C) 1998 Netscape Communications Corporation. 5 * Portions are Copyright (C) 1998 Netscape Communications Corporation.
6 * 6 *
7 * Other contributors: 7 * Other contributors:
8 * Robert O'Callahan <roc+@cs.cmu.edu> 8 * Robert O'Callahan <roc+@cs.cmu.edu>
9 * David Baron <dbaron@fas.harvard.edu> 9 * David Baron <dbaron@fas.harvard.edu>
10 * Christian Biesinger <cbiesinger@web.de> 10 * Christian Biesinger <cbiesinger@web.de>
(...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after
781 child_has3d = true; 781 child_has3d = true;
782 782
783 if (child_has3d) { 783 if (child_has3d) {
784 has3d_transformed_descendant_ = true; 784 has3d_transformed_descendant_ = true;
785 break; 785 break;
786 } 786 }
787 } 787 }
788 } 788 }
789 789
790 void PaintLayer::UpdateLayerPosition() { 790 void PaintLayer::UpdateLayerPosition() {
791 // LayoutBoxes will call UpdateSizeAndScrollingAfterLayout() from
792 // LayoutBox::UpdateAfterLayout, but LayoutInlines will still need to update
bokan 2017/05/12 15:58:18 This may be a naive question as I'm a layout-outsi
szager1 2017/05/12 19:12:13 LayoutInline's don't run their own layout; instead
793 // their size.
794 if (GetLayoutObject().IsInline() && GetLayoutObject().IsLayoutInline())
795 UpdateSizeAndScrollingAfterLayout();
791 LayoutPoint local_point; 796 LayoutPoint local_point;
792 797 if (LayoutBox* box = GetLayoutBox()) {
793 bool did_resize = false;
794 if (GetLayoutObject().IsInline() && GetLayoutObject().IsLayoutInline()) {
795 LayoutInline& inline_flow = ToLayoutInline(GetLayoutObject());
796 IntRect line_box = EnclosingIntRect(inline_flow.LinesBoundingBox());
797 size_ = line_box.Size();
798 } else if (LayoutBox* box = GetLayoutBox()) {
799 IntSize new_size = PixelSnappedIntSize(box->Size(), box->Location());
800 did_resize = new_size != size_;
801 size_ = new_size;
802 local_point.MoveBy(box->PhysicalLocation()); 798 local_point.MoveBy(box->PhysicalLocation());
803 } 799 }
804 800
805 if (!GetLayoutObject().IsOutOfFlowPositioned() && 801 if (!GetLayoutObject().IsOutOfFlowPositioned() &&
806 !GetLayoutObject().IsColumnSpanAll()) { 802 !GetLayoutObject().IsColumnSpanAll()) {
807 // We must adjust our position by walking up the layout tree looking for the 803 // We must adjust our position by walking up the layout tree looking for the
808 // nearest enclosing object with a layer. 804 // nearest enclosing object with a layer.
809 LayoutObject* curr = GetLayoutObject().Container(); 805 LayoutObject* curr = GetLayoutObject().Container();
810 while (curr && !curr->HasLayer()) { 806 while (curr && !curr->HasLayer()) {
811 if (curr->IsBox() && !curr->IsTableRow()) { 807 if (curr->IsBox() && !curr->IsTableRow()) {
(...skipping 30 matching lines...) Expand all
842 LayoutSize new_offset = GetLayoutObject().OffsetForInFlowPosition(); 838 LayoutSize new_offset = GetLayoutObject().OffsetForInFlowPosition();
843 if (rare_data_ || !new_offset.IsZero()) 839 if (rare_data_ || !new_offset.IsZero())
844 EnsureRareData().offset_for_in_flow_position = new_offset; 840 EnsureRareData().offset_for_in_flow_position = new_offset;
845 local_point.Move(new_offset); 841 local_point.Move(new_offset);
846 } else if (rare_data_) { 842 } else if (rare_data_) {
847 rare_data_->offset_for_in_flow_position = LayoutSize(); 843 rare_data_->offset_for_in_flow_position = LayoutSize();
848 } 844 }
849 845
850 location_ = local_point; 846 location_ = local_point;
851 847
852 if (scrollable_area_ && did_resize)
853 scrollable_area_->VisibleSizeChanged();
854
855 #if DCHECK_IS_ON() 848 #if DCHECK_IS_ON()
856 needs_position_update_ = false; 849 needs_position_update_ = false;
857 #endif 850 #endif
858 } 851 }
859 852
860 void PaintLayer::UpdateScrollingAfterLayout() { 853 bool PaintLayer::UpdateSize() {
861 if (GetLayoutObject().HasOverflowClip()) 854 bool did_resize = false;
855 if (IsRootLayer() && RuntimeEnabledFeatures::rootLayerScrollingEnabled()) {
856 const IntSize new_size = GetLayoutObject().GetDocument().View()->Size();
857 did_resize = new_size != size_;
858 size_ = new_size;
859 } else if (GetLayoutObject().IsInline() &&
860 GetLayoutObject().IsLayoutInline()) {
861 LayoutInline& inline_flow = ToLayoutInline(GetLayoutObject());
862 IntRect line_box = EnclosingIntRect(inline_flow.LinesBoundingBox());
863 size_ = line_box.Size();
skobes 2017/05/16 22:22:22 Why is did_resize not set in this branch?
szager 2017/05/16 23:55:46 This preserves the existing logic. did_resize is
864 } else if (LayoutBox* box = GetLayoutBox()) {
865 IntSize new_size = PixelSnappedIntSize(box->Size(), box->Location());
866 did_resize = new_size != size_;
867 size_ = new_size;
868 }
869 return did_resize;
870 }
871
872 void PaintLayer::UpdateSizeAndScrollingAfterLayout() {
873 bool did_resize = UpdateSize();
874 if (GetLayoutObject().HasOverflowClip()) {
862 scrollable_area_->UpdateAfterLayout(); 875 scrollable_area_->UpdateAfterLayout();
876 if (did_resize)
877 scrollable_area_->VisibleSizeChanged();
bokan 2017/05/12 15:58:18 Any reason not to put this in UpdateSize().
szager1 2017/05/12 19:12:13 UpdateSize is also called from LayoutBoxModelObjec
878 }
863 } 879 }
864 880
865 TransformationMatrix PaintLayer::PerspectiveTransform() const { 881 TransformationMatrix PaintLayer::PerspectiveTransform() const {
866 if (!GetLayoutObject().HasTransformRelatedProperty()) 882 if (!GetLayoutObject().HasTransformRelatedProperty())
867 return TransformationMatrix(); 883 return TransformationMatrix();
868 884
869 const ComputedStyle& style = GetLayoutObject().StyleRef(); 885 const ComputedStyle& style = GetLayoutObject().StyleRef();
870 if (!style.HasPerspective()) 886 if (!style.HasPerspective())
871 return TransformationMatrix(); 887 return TransformationMatrix();
872 888
(...skipping 2454 matching lines...) Expand 10 before | Expand all | Expand 10 after
3327 } 3343 }
3328 3344
3329 void showLayerTree(const blink::LayoutObject* layoutObject) { 3345 void showLayerTree(const blink::LayoutObject* layoutObject) {
3330 if (!layoutObject) { 3346 if (!layoutObject) {
3331 LOG(INFO) << "Cannot showLayerTree. Root is (nil)"; 3347 LOG(INFO) << "Cannot showLayerTree. Root is (nil)";
3332 return; 3348 return;
3333 } 3349 }
3334 showLayerTree(layoutObject->EnclosingLayer()); 3350 showLayerTree(layoutObject->EnclosingLayer());
3335 } 3351 }
3336 #endif 3352 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698