- Revision
- 278086
- Author
- za...@apple.com
- Date
- 2021-05-26 09:30:22 -0700 (Wed, 26 May 2021)
Log Message
[LFC] Introduce containingBlockChain iterator
https://bugs.webkit.org/show_bug.cgi?id=226269
Reviewed by Antti Koivisto.
Let's use the range loop syntax to climb the containing block chain.
* WebCore.xcodeproj/project.pbxproj:
* layout/formattingContexts/table/TableFormattingQuirks.cpp:
(WebCore::Layout::TableFormattingQuirks::heightValueOfNearestContainingBlockWithFixedHeight const):
* layout/layouttree/LayoutContainingBlockChainIterator.h: Added.
(WebCore::Layout::LayoutContainingBlockChainIterator::operator* const):
(WebCore::Layout::LayoutContainingBlockChainIterator::operator-> const):
(WebCore::Layout::LayoutContainingBlockChainIterator::operator== const):
(WebCore::Layout::LayoutContainingBlockChainIterator::operator!= const):
(WebCore::Layout::LayoutContainingBlockChainIterator::LayoutContainingBlockChainIterator):
(WebCore::Layout::LayoutContainingBlockChainIterator::operator++):
(WebCore::Layout::LayoutContainingBlockChainIteratorAdapter::LayoutContainingBlockChainIteratorAdapter):
(WebCore::Layout::LayoutContainingBlockChainIteratorAdapter::begin):
(WebCore::Layout::LayoutContainingBlockChainIteratorAdapter::end):
(WebCore::Layout::containingBlockChainOf):
Modified Paths
Added Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (278085 => 278086)
--- trunk/Source/WebCore/ChangeLog 2021-05-26 15:35:24 UTC (rev 278085)
+++ trunk/Source/WebCore/ChangeLog 2021-05-26 16:30:22 UTC (rev 278086)
@@ -1,5 +1,29 @@
2021-05-26 Alan Bujtas <za...@apple.com>
+ [LFC] Introduce containingBlockChain iterator
+ https://bugs.webkit.org/show_bug.cgi?id=226269
+
+ Reviewed by Antti Koivisto.
+
+ Let's use the range loop syntax to climb the containing block chain.
+
+ * WebCore.xcodeproj/project.pbxproj:
+ * layout/formattingContexts/table/TableFormattingQuirks.cpp:
+ (WebCore::Layout::TableFormattingQuirks::heightValueOfNearestContainingBlockWithFixedHeight const):
+ * layout/layouttree/LayoutContainingBlockChainIterator.h: Added.
+ (WebCore::Layout::LayoutContainingBlockChainIterator::operator* const):
+ (WebCore::Layout::LayoutContainingBlockChainIterator::operator-> const):
+ (WebCore::Layout::LayoutContainingBlockChainIterator::operator== const):
+ (WebCore::Layout::LayoutContainingBlockChainIterator::operator!= const):
+ (WebCore::Layout::LayoutContainingBlockChainIterator::LayoutContainingBlockChainIterator):
+ (WebCore::Layout::LayoutContainingBlockChainIterator::operator++):
+ (WebCore::Layout::LayoutContainingBlockChainIteratorAdapter::LayoutContainingBlockChainIteratorAdapter):
+ (WebCore::Layout::LayoutContainingBlockChainIteratorAdapter::begin):
+ (WebCore::Layout::LayoutContainingBlockChainIteratorAdapter::end):
+ (WebCore::Layout::containingBlockChainOf):
+
+2021-05-26 Alan Bujtas <za...@apple.com>
+
REGRESSION: Safari v14.1 computes element height to be 33,554,432 pixels
https://bugs.webkit.org/show_bug.cgi?id=226006
<rdar://problem/78471122>
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (278085 => 278086)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2021-05-26 15:35:24 UTC (rev 278085)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2021-05-26 16:30:22 UTC (rev 278086)
@@ -2166,6 +2166,7 @@
6FB7D2DD250FD828000207AA /* FlexFormattingContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 6FB7D2D9250FD7FC000207AA /* FlexFormattingContext.h */; settings = {ATTRIBUTES = (Private, ); }; };
6FB7D2DE250FD82E000207AA /* FlexFormattingState.h in Headers */ = {isa = PBXBuildFile; fileRef = 6FB7D2DA250FD7FC000207AA /* FlexFormattingState.h */; settings = {ATTRIBUTES = (Private, ); }; };
6FC3F9472516756700A49BEA /* InlineLineRun.h in Headers */ = {isa = PBXBuildFile; fileRef = 6FC3F9452516756600A49BEA /* InlineLineRun.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 6FCBDB97265DF2C80021EA7B /* LayoutContainingBlockChainIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = 6FCBDB95265DF2C70021EA7B /* LayoutContainingBlockChainIterator.h */; settings = {ATTRIBUTES = (Private, ); }; };
6FCE1A1A22618ABD004F0343 /* LayoutIntegrationRun.h in Headers */ = {isa = PBXBuildFile; fileRef = 6FCE1A1822618AB3004F0343 /* LayoutIntegrationRun.h */; settings = {ATTRIBUTES = (Private, ); }; };
6FD09543251115220098877D /* LayoutGeometryRect.h in Headers */ = {isa = PBXBuildFile; fileRef = 6FD09541251115220098877D /* LayoutGeometryRect.h */; settings = {ATTRIBUTES = (Private, ); }; };
6FE198172178397C00446F08 /* InlineContentBreaker.h in Headers */ = {isa = PBXBuildFile; fileRef = 6FE198152178397C00446F08 /* InlineContentBreaker.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -10049,6 +10050,7 @@
6FC5CA9422E3599400B13E11 /* TableFormattingContext.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = TableFormattingContext.cpp; sourceTree = "<group>"; };
6FC5CA9522E3599400B13E11 /* TableFormattingContext.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TableFormattingContext.h; sourceTree = "<group>"; };
6FC5CA9622E3599500B13E11 /* TableFormattingState.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TableFormattingState.h; sourceTree = "<group>"; };
+ 6FCBDB95265DF2C70021EA7B /* LayoutContainingBlockChainIterator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LayoutContainingBlockChainIterator.h; sourceTree = "<group>"; };
6FCE1A1822618AB3004F0343 /* LayoutIntegrationRun.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LayoutIntegrationRun.h; sourceTree = "<group>"; };
6FD09541251115220098877D /* LayoutGeometryRect.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LayoutGeometryRect.h; sourceTree = "<group>"; };
6FE198132178397B00446F08 /* InlineContentBreaker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InlineContentBreaker.cpp; sourceTree = "<group>"; };
@@ -18250,6 +18252,7 @@
11100FC920927CBC0081AA6C /* LayoutChildIterator.h */,
1199FA45208E35A3002358CC /* LayoutContainerBox.cpp */,
1199FA44208E35A3002358CC /* LayoutContainerBox.h */,
+ 6FCBDB95265DF2C70021EA7B /* LayoutContainingBlockChainIterator.h */,
11B042FB20B0E21400828A6B /* LayoutDescendantIterator.h */,
6FD09541251115220098877D /* LayoutGeometryRect.h */,
6FB0ED112427B6C6002737E6 /* LayoutInitialContainingBlock.cpp */,
@@ -33991,6 +33994,7 @@
115CFA97208B952B001E6991 /* LayoutBox.h in Headers */,
11310CF620BA4A560065A8D0 /* LayoutChildIterator.h in Headers */,
1199FA46208E35A3002358CC /* LayoutContainerBox.h in Headers */,
+ 6FCBDB97265DF2C80021EA7B /* LayoutContainingBlockChainIterator.h in Headers */,
6F26BB6C23343E6F002F2BEA /* LayoutContext.h in Headers */,
11310CF520BA4A4C0065A8D0 /* LayoutDescendantIterator.h in Headers */,
6FD09543251115220098877D /* LayoutGeometryRect.h in Headers */,
Modified: trunk/Source/WebCore/layout/formattingContexts/table/TableFormattingQuirks.cpp (278085 => 278086)
--- trunk/Source/WebCore/layout/formattingContexts/table/TableFormattingQuirks.cpp 2021-05-26 15:35:24 UTC (rev 278085)
+++ trunk/Source/WebCore/layout/formattingContexts/table/TableFormattingQuirks.cpp 2021-05-26 16:30:22 UTC (rev 278086)
@@ -30,6 +30,7 @@
#include "LayoutBox.h"
#include "LayoutContainerBox.h"
+#include "LayoutContainingBlockChainIterator.h"
#include "LayoutState.h"
#include "TableFormattingContext.h"
@@ -65,13 +66,15 @@
return height.isFixed() ? makeOptional(LayoutUnit { height.value() }) : WTF::nullopt;
};
- auto& formattingContext = this->formattingContext();
- auto& tableBox = formattingContext.root();
- for (auto* ancestor = &layoutBox.containingBlock(); ancestor && ancestor != &tableBox; ancestor = &ancestor->containingBlock()) {
- if (auto fixedHeight = fixedLogicalHeight(*ancestor))
+ auto& tableBox = formattingContext().root();
+ for (auto& ancestor : containingBlockChain(layoutBox)) {
+ if (auto fixedHeight = fixedLogicalHeight(ancestor))
return *fixedHeight;
+ if (&ancestor == &tableBox)
+ return { };
}
- return fixedLogicalHeight(tableBox).valueOr(LayoutUnit { });
+ ASSERT_NOT_REACHED();
+ return { };
}
}
Added: trunk/Source/WebCore/layout/layouttree/LayoutContainingBlockChainIterator.h (0 => 278086)
--- trunk/Source/WebCore/layout/layouttree/LayoutContainingBlockChainIterator.h (rev 0)
+++ trunk/Source/WebCore/layout/layouttree/LayoutContainingBlockChainIterator.h 2021-05-26 16:30:22 UTC (rev 278086)
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "LayoutContainerBox.h"
+
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+
+namespace WebCore {
+namespace Layout {
+
+class LayoutContainingBlockChainIterator {
+public:
+ LayoutContainingBlockChainIterator() = default;
+ LayoutContainingBlockChainIterator(const ContainerBox&);
+ const ContainerBox& operator*() const { return *m_current; }
+ const ContainerBox* operator->() const { return m_current; }
+
+ LayoutContainingBlockChainIterator& operator++();
+ bool operator==(const LayoutContainingBlockChainIterator& other) const { return m_current == other.m_current; }
+ bool operator!=(const LayoutContainingBlockChainIterator& other) const { return !(*this == other); }
+
+private:
+ const ContainerBox* m_current { nullptr };
+};
+
+class LayoutContainingBlockChainIteratorAdapter {
+public:
+ LayoutContainingBlockChainIteratorAdapter(const ContainerBox&);
+ auto begin() { return LayoutContainingBlockChainIterator(m_containingBlock); }
+ auto end() { return LayoutContainingBlockChainIterator(); }
+
+private:
+ const ContainerBox& m_containingBlock;
+};
+
+LayoutContainingBlockChainIteratorAdapter containingBlockChain(const Box&);
+
+inline LayoutContainingBlockChainIterator::LayoutContainingBlockChainIterator(const ContainerBox& current)
+ : m_current(¤t)
+{
+}
+
+inline LayoutContainingBlockChainIterator& LayoutContainingBlockChainIterator::operator++()
+{
+ ASSERT(m_current);
+ m_current = m_current->isInitialContainingBlock() ? nullptr : &m_current->containingBlock();
+ return *this;
+}
+
+inline LayoutContainingBlockChainIteratorAdapter::LayoutContainingBlockChainIteratorAdapter(const ContainerBox& containingBlock)
+ : m_containingBlock(containingBlock)
+{
+}
+
+inline LayoutContainingBlockChainIteratorAdapter containingBlockChain(const Box& layoutBox)
+{
+ return LayoutContainingBlockChainIteratorAdapter(layoutBox.containingBlock());
+}
+
+}
+}
+#endif