Changeset 232042 in webkit
- Timestamp:
- May 21, 2018 6:41:58 PM (6 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r232039 r232042 1 2018-05-21 Zalan Bujtas <zalan@apple.com> 2 3 [LFC] Add FormattingContext::validateGeometryConstraintsAfterLayout 4 https://bugs.webkit.org/show_bug.cgi?id=185811 5 6 Reviewed by Antti Koivisto. 7 8 Also implement LayoutDescendantIterator and fix LayoutIterator. 9 10 * WebCore.xcodeproj/project.pbxproj: 11 * layout/FormattingContext.cpp: 12 (WebCore::Layout::FormattingContext::validateGeometryConstraintsAfterLayout const): 13 * layout/FormattingContext.h: 14 * layout/blockformatting/BlockFormattingContext.cpp: 15 (WebCore::Layout::BlockFormattingContext::layout const): 16 * layout/layouttree/LayoutDescendantIterator.h: Added. 17 (WebCore::Layout::LayoutDescendantIterator<T>::LayoutDescendantIterator): 18 (WebCore::Layout::LayoutDescendantIterator<T>::operator): 19 (WebCore::Layout::LayoutDescendantIteratorAdapter<T>::LayoutDescendantIteratorAdapter): 20 (WebCore::Layout::LayoutDescendantIteratorAdapter<T>::begin): 21 (WebCore::Layout::LayoutDescendantIteratorAdapter<T>::end): 22 (WebCore::Layout::LayoutDescendantIteratorAdapter<T>::at): 23 (WebCore::Layout::descendantsOfType): 24 * layout/layouttree/LayoutIterator.h: 25 (WebCore::Layout::LayoutBoxTraversal::firstChild): 26 (WebCore::Layout::LayoutBoxTraversal::nextAncestorSibling): 27 (WebCore::Layout::LayoutBoxTraversal::next): 28 (WebCore::Layout::LayoutBoxTraversal::nextSkippingChildren): 29 (WebCore::Layout::Traversal::firstChild): 30 (WebCore::Layout::Traversal::nextSibling): 31 (WebCore::Layout::Traversal::previousSibling): 32 (WebCore::Layout::Traversal::findAncestorOfType): 33 (WebCore::Layout::Traversal::firstWithin): 34 (WebCore::Layout::Traversal::next): 35 (WebCore::Layout::LayoutIterator<T>::traversePreviousSibling): 36 (WebCore::Layout::LayoutIterator<T>::traverseAncestor): 37 (WebCore::Layout::Traversal::nextAncestorSibling): Deleted. 38 (WebCore::Layout::Traversal::nextWithin): Deleted. 39 1 40 2018-05-21 Basuke Suzuki <Basuke.Suzuki@sony.com> 2 41 -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r232032 r232042 5777 5777 1199FA59208E3C7F002358CC /* DisplayBox.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DisplayBox.h; sourceTree = "<group>"; }; 5778 5778 1199FA5A208E3C7F002358CC /* DisplayBox.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DisplayBox.cpp; sourceTree = "<group>"; }; 5779 11B042FB20B0E21400828A6B /* LayoutDescendantIterator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LayoutDescendantIterator.h; sourceTree = "<group>"; }; 5779 5780 11C5F1162003E7750001AE60 /* RenderTreeBuilderInline.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderTreeBuilderInline.cpp; sourceTree = "<group>"; }; 5780 5781 11C5F1182003E7760001AE60 /* RenderTreeBuilderInline.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderTreeBuilderInline.h; sourceTree = "<group>"; }; … … 15698 15699 1199FA45208E35A3002358CC /* LayoutContainer.cpp */, 15699 15700 1199FA44208E35A3002358CC /* LayoutContainer.h */, 15701 11B042FB20B0E21400828A6B /* LayoutDescendantIterator.h */, 15700 15702 1199FA52208E38D3002358CC /* LayoutInlineBox.cpp */, 15701 15703 1199FA51208E38D3002358CC /* LayoutInlineBox.h */, … … 26932 26934 buildActionMask = 2147483647; 26933 26935 files = ( 26934 29A812490FBB9CA900510293 /* WebAccessibilityObjectWrapperBase.h in Headers */,26935 AA478A7F16CD70C3007D1BB4 /* WebAccessibilityObjectWrapperMac.h in Headers */,26936 26936 7CD0E2B81F80A4820016A4CE /* AbortController.h in Headers */, 26937 26937 7CD0E2BF1F80A56E0016A4CE /* AbortSignal.h in Headers */, … … 30726 30726 FD7F299413D4C0CB00AD9535 /* WaveShaperNode.h in Headers */, 30727 30727 FD7F299713D4C0CB00AD9535 /* WaveShaperProcessor.h in Headers */, 30728 29A812490FBB9CA900510293 /* WebAccessibilityObjectWrapperBase.h in Headers */, 30728 30729 AAA728F716D1D8BC00D3BBC6 /* WebAccessibilityObjectWrapperIOS.h in Headers */, 30730 AA478A7F16CD70C3007D1BB4 /* WebAccessibilityObjectWrapperMac.h in Headers */, 30729 30731 2D3EF4481917915C00034184 /* WebActionDisablingCALayerDelegate.h in Headers */, 30730 30732 71025ED31F99F0CE004A250C /* WebAnimation.h in Headers */, -
trunk/Source/WebCore/layout/FormattingContext.cpp
r231958 r232042 33 33 #include "LayoutContainer.h" 34 34 #include "LayoutContext.h" 35 #include "LayoutDescendantIterator.h" 35 36 #include <wtf/IsoMallocInlines.h> 36 37 … … 443 444 } 444 445 445 } 446 #ifndef NDEBUG 447 void FormattingContext::validateGeometryConstraintsAfterLayout(const LayoutContext& layoutContext) const 448 { 449 if (!is<Container>(root())) 450 return; 451 auto& formattingContextRoot = downcast<Container>(root()); 452 // FIXME: add a descendantsOfType<> flavor that stops at nested formatting contexts 453 for (auto& layoutBox : descendantsOfType<Box>(formattingContextRoot)) { 454 if (&layoutBox.formattingContextRoot() != &formattingContextRoot) 455 continue; 456 auto* containingBlock = layoutBox.containingBlock(); 457 ASSERT(containingBlock); 458 auto containingBlockSize = layoutContext.displayBoxForLayoutBox(*containingBlock)->size(); 459 auto* displayBox = layoutContext.displayBoxForLayoutBox(layoutBox); 460 ASSERT(displayBox); 461 462 // 10.3.3 Block-level, non-replaced elements in normal flow 463 // 10.3.7 Absolutely positioned, non-replaced elements 464 if ((layoutBox.isBlockLevelBox() || layoutBox.isOutOfFlowPositioned()) && !layoutBox.replaced()) { 465 // margin-left + border-left-width + padding-left + width + padding-right + border-right-width + margin-right = width of containing block 466 ASSERT(displayBox->marginLeft() + displayBox->borderLeft() + displayBox->paddingLeft() + displayBox->width() 467 + displayBox->paddingRight() + displayBox->borderRight() + displayBox->marginRight() == containingBlockSize.width()); 468 } 469 470 // 10.6.4 Absolutely positioned, non-replaced elements 471 if (layoutBox.isOutOfFlowPositioned() && !layoutBox.replaced()) { 472 // top + margin-top + border-top-width + padding-top + height + padding-bottom + border-bottom-width + margin-bottom + bottom = height of containing block 473 ASSERT(displayBox->top() + displayBox->marginTop() + displayBox->borderTop() + displayBox->paddingTop() 474 + displayBox->paddingBottom() + displayBox->borderBottom() + displayBox->marginBottom() == containingBlockSize.height()); 475 } 476 } 446 477 } 447 478 #endif 479 } 480 } 481 #endif -
trunk/Source/WebCore/layout/FormattingContext.h
r231958 r232042 91 91 void computeReplacedWidth(LayoutContext&, const Box&, Display::Box&) const; 92 92 93 #ifndef NDEBUG 94 virtual void validateGeometryConstraintsAfterLayout(const LayoutContext&) const; 95 #endif 96 93 97 private: 94 98 void computeOutOfFlowNonReplacedHeight(LayoutContext&, const Box&, Display::Box&) const; -
trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp
r231953 r232042 113 113 // And take care of out-of-flow boxes as the final step. 114 114 layoutOutOfFlowDescendants(layoutContext); 115 #ifndef NDEBUG 116 validateGeometryConstraintsAfterLayout(layoutContext); 117 #endif 115 118 } 116 119 -
trunk/Source/WebCore/layout/layouttree/LayoutIterator.h
r231093 r232042 57 57 inline bool isLayoutBoxOfType(const U& layoutBox) { return TypeCastTraits<const T, const U>::isOfType(layoutBox); } 58 58 59 // Traversal helpers 60 namespace Traversal { 61 62 template <typename T, typename U> 63 inline const T* firstChild(U& current) 64 { 65 auto* object = current.firstChild(); 66 while (object && !isLayoutBoxOfType<T>(*object)) 67 object = object->nextSibling(); 68 return static_cast<const T*>(object); 69 } 70 71 template <typename T, typename U> 72 inline const T* lastChild(U& current) 73 { 74 auto* object = current.lastChild(); 75 while (object && !isLayoutBoxOfType<T>(*object)) 76 object = object->previousSibling(); 77 return static_cast<const T*>(object); 78 } 79 80 template <typename T, typename U> 81 inline const T* nextSibling(U& current) 82 { 83 auto* object = current.nextSibling(); 84 while (object && !isLayoutBoxOfType<T>(*object)) 85 object = object->nextSibling(); 86 return static_cast<const T*>(object); 87 } 88 89 template <typename T, typename U> 90 inline const T* previousSibling(U& current) 91 { 92 auto* object = current.previousSibling(); 93 while (object && !isLayoutBoxOfType<T>(*object)) 94 object = object->previousSibling(); 95 return static_cast<const T*>(object); 96 } 97 98 template <typename T> 99 inline const T* findAncestorOfType(const Box& current) 100 { 101 for (auto* ancestor = current.parent(); ancestor; ancestor = ancestor->parent()) { 102 if (isLayoutBoxOfType<T>(*ancestor)) 103 return static_cast<const T*>(ancestor); 104 } 59 namespace LayoutBoxTraversal { 60 61 template <typename U> 62 inline const Box* firstChild(U& object) 63 { 64 return object.firstChild(); 65 } 66 67 inline const Box* firstChild(const Box&) 68 { 105 69 return nullptr; 106 70 } 107 71 108 template <typename T, typename U> 109 inline const T* nextAncestorSibling(U& current, const Container* stayWithin) 72 inline const Box* nextAncestorSibling(const Box& current, const Container* stayWithin) 110 73 { 111 74 for (auto* ancestor = current.parent(); ancestor; ancestor = ancestor->parent()) { … … 118 81 } 119 82 120 template <typename T, typenameU>121 inline const T* nextWithin(U& current, const Container* stayWithin)83 template <typename U> 84 inline const Box* next(const U& current, const Container* stayWithin) 122 85 { 123 86 if (auto* child = firstChild(current)) … … 133 96 } 134 97 135 template <typename T, typename U> 136 inline const T* firstWithin(U& current) 137 { 138 auto* descendant = current.fistChild(); 98 inline const Box* nextSkippingChildren(Box& current, const Container* stayWithin) 99 { 100 if (¤t == stayWithin) 101 return nullptr; 102 103 if (auto* sibling = current.nextSibling()) 104 return sibling; 105 106 return nextAncestorSibling(current, stayWithin); 107 } 108 109 } 110 // Traversal helpers 111 namespace Traversal { 112 113 template <typename T, typename U> 114 inline const T* firstChild(U& current) 115 { 116 auto* object = LayoutBoxTraversal::firstChild(current); 117 while (object && !isLayoutBoxOfType<T>(*object)) 118 object = object->nextSibling(); 119 return static_cast<const T*>(object); 120 } 121 122 template <typename T, typename U> 123 inline const T* lastChild(U& current) 124 { 125 auto* object = current.lastChild(); 126 while (object && !isLayoutBoxOfType<T>(*object)) 127 object = object->previousSibling(); 128 return static_cast<const T*>(object); 129 } 130 131 template <typename T> 132 inline const T* nextSibling(const T& current) 133 { 134 auto* object = current.nextSibling(); 135 while (object && !isLayoutBoxOfType<T>(*object)) 136 object = object->nextSibling(); 137 return static_cast<const T*>(object); 138 } 139 140 template <typename T, typename U> 141 inline const T* previousSibling(const T& current) 142 { 143 auto* object = current.previousSibling(); 144 while (object && !isLayoutBoxOfType<T>(*object)) 145 object = object->previousSibling(); 146 return static_cast<const T*>(object); 147 } 148 149 template <typename T, typename U> 150 inline const T* findAncestorOfType(const T& current) 151 { 152 for (auto* ancestor = current.parent(); ancestor; ancestor = ancestor->parent()) { 153 if (isLayoutBoxOfType<T>(*ancestor)) 154 return static_cast<const T*>(ancestor); 155 } 156 return nullptr; 157 } 158 159 template <typename T, typename U> 160 inline const T* firstWithin(const U& stayWithin) 161 { 162 auto* descendant = LayoutBoxTraversal::firstChild(stayWithin); 139 163 while (descendant && !isLayoutBoxOfType<T>(*descendant)) 140 descendant = nextWithin(*descendant, ¤t);164 descendant = LayoutBoxTraversal::next(*descendant, &stayWithin); 141 165 return static_cast<const T*>(descendant); 142 166 } 143 167 144 168 template <typename T, typename U> 145 inline const T* next( U& current, const RenderObject* stayWithin)146 { 147 auto* descendant = nextWithin(current, stayWithin);169 inline const T* next(const U& current, const Container* stayWithin) 170 { 171 auto* descendant = LayoutBoxTraversal::next(current, stayWithin); 148 172 while (descendant && !isLayoutBoxOfType<T>(*descendant)) 149 descendant = nextWithin(*descendant, stayWithin);173 descendant = LayoutBoxTraversal::next(*descendant, stayWithin); 150 174 return static_cast<const T*>(descendant); 151 175 } … … 189 213 { 190 214 ASSERT(m_current); 191 m_current = Traversal::previousSibling<T>(m_current); 192 return *this; 193 } 194 215 m_current = Traversal::previousSibling<T>(*m_current); 216 return *this; 217 } 195 218 196 219 template <typename T> … … 199 222 ASSERT(m_current); 200 223 ASSERT(m_current != m_root); 201 m_current = Traversal::findAncestorOfType< constT>(*m_current);224 m_current = Traversal::findAncestorOfType<T>(*m_current); 202 225 return *this; 203 226 }
Note: See TracChangeset
for help on using the changeset viewer.