Diff
Modified: trunk/Source/WebCore/ChangeLog (258903 => 258904)
--- trunk/Source/WebCore/ChangeLog 2020-03-24 03:40:45 UTC (rev 258903)
+++ trunk/Source/WebCore/ChangeLog 2020-03-24 04:09:30 UTC (rev 258904)
@@ -1,3 +1,46 @@
+2020-03-23 Zalan Bujtas <[email protected]>
+
+ [LFC] Layout::Box::initialContainingBlock() should return const InitialContainingBlock&
+ https://bugs.webkit.org/show_bug.cgi?id=209406
+ <rdar://problem/60749715>
+
+ Reviewed by Antti Koivisto.
+
+ Use is<InitialContainingBlock> where applicable.
+
+ * layout/FormattingContext.cpp:
+ (WebCore::Layout::FormattingContext::geometryForBox const):
+ (WebCore::Layout::FormattingContext::collectOutOfFlowDescendantsIfNeeded):
+ * layout/FormattingContextQuirks.cpp:
+ (WebCore::Layout::FormattingContext::Quirks::heightValueOfNearestContainingBlockWithFixedHeight):
+ * layout/blockformatting/BlockFormattingContextQuirks.cpp:
+ * layout/displaytree/DisplayPainter.cpp:
+ (WebCore::Display::absoluteDisplayBox):
+ * layout/invalidation/InvalidationState.cpp:
+ (WebCore::Layout::InvalidationState::markNeedsUpdate):
+ * layout/layouttree/LayoutBox.cpp:
+ (WebCore::Layout::Box::establishesBlockFormattingContext const):
+ (WebCore::Layout::Box::containingBlock const):
+ (WebCore::Layout::Box::formattingContextRoot const):
+ (WebCore::Layout::Box::initialContainingBlock const):
+ (WebCore::Layout::Box::isInFormattingContextOf const):
+ (WebCore::Layout::Box::isOverflowVisible const):
+ * layout/layouttree/LayoutBox.h:
+ (WebCore::Layout::Box::isInitialContainingBlock const):
+ (WebCore::Layout::Box::isInlineTextBox const):
+ (WebCore::Layout::Box::isLineBreakBox const):
+ (WebCore::Layout::Box::isReplacedBox const):
+ * layout/layouttree/LayoutInitialContainingBlock.cpp:
+ (WebCore::Layout::InitialContainingBlock::InitialContainingBlock):
+ * layout/layouttree/LayoutInlineTextBox.cpp:
+ (WebCore::Layout::InlineTextBox::InlineTextBox):
+ * layout/layouttree/LayoutLineBreakBox.cpp:
+ (WebCore::Layout::LineBreakBox::LineBreakBox):
+ * layout/layouttree/LayoutReplacedBox.cpp:
+ (WebCore::Layout::ReplacedBox::ReplacedBox):
+ * layout/layouttree/LayoutTreeBuilder.cpp:
+ (WebCore::Layout::outputLayoutBox):
+
2020-03-23 Justin Fan <[email protected]>
[ Mac wk2 Debug ] webgpu/whlsl/vector-compare.html is flaky crashing.
Modified: trunk/Source/WebCore/layout/FormattingContext.cpp (258903 => 258904)
--- trunk/Source/WebCore/layout/FormattingContext.cpp 2020-03-24 03:40:45 UTC (rev 258903)
+++ trunk/Source/WebCore/layout/FormattingContext.cpp 2020-03-24 04:09:30 UTC (rev 258904)
@@ -35,6 +35,7 @@
#include "LayoutContainerBox.h"
#include "LayoutContext.h"
#include "LayoutDescendantIterator.h"
+#include "LayoutInitialContainingBlock.h"
#include "LayoutReplacedBox.h"
#include "LayoutState.h"
#include "Logging.h"
@@ -192,7 +193,7 @@
UNUSED_PARAM(escapeReason);
#if ASSERT_ENABLED
auto isOkToAccessDisplayBox = [&] {
- if (!layoutBox.isInitialContainingBlock() && &layoutBox.formattingContextRoot() == &root()) {
+ if (!is<InitialContainingBlock>(layoutBox) && &layoutBox.formattingContextRoot() == &root()) {
// This is the non-escape case of accessing a box's geometry information within the same formatting context.
return true;
}
@@ -204,17 +205,17 @@
if (*escapeReason == EscapeReason::DocumentBoxStrechesToViewportQuirk) {
ASSERT(layoutState().inQuirksMode());
- return layoutBox.isInitialContainingBlock();
+ return is<InitialContainingBlock>(layoutBox);
}
if (*escapeReason == EscapeReason::BodyStrechesToViewportQuirk) {
ASSERT(layoutState().inQuirksMode());
- return layoutBox.isInitialContainingBlock() || layoutBox.isDocumentBox();
+ return is<InitialContainingBlock>(layoutBox) || layoutBox.isDocumentBox();
}
if (*escapeReason == EscapeReason::StrokeOverflowNeedsViewportGeometry)
- return layoutBox.isInitialContainingBlock();
+ return is<InitialContainingBlock>(layoutBox);
if (*escapeReason == EscapeReason::NeedsGeometryFromEstablishedFormattingContext) {
// This is the case when a formatting root collects geometry information from the established
@@ -243,7 +244,7 @@
ASSERT(layoutState().inQuirksMode());
// Find the first containing block with fixed height quirk. See Quirks::heightValueOfNearestContainingBlockWithFixedHeight.
// This is only to check if the targetFormattingRoot is an ancestor formatting root.
- if (layoutBox.isInitialContainingBlock())
+ if (is<InitialContainingBlock>(layoutBox))
return true;
auto& targetFormattingRoot = layoutBox.formattingContextRoot();
auto* ancestorFormattingContextRoot = &root().formattingContextRoot();
@@ -251,7 +252,7 @@
if (&targetFormattingRoot == ancestorFormattingContextRoot)
return true;
ancestorFormattingContextRoot = &ancestorFormattingContextRoot->formattingContextRoot();
- if (ancestorFormattingContextRoot->isInitialContainingBlock())
+ if (is<InitialContainingBlock>(*ancestorFormattingContextRoot))
return true;
}
return false;
@@ -280,7 +281,7 @@
auto& root = this->root();
if (!root.hasChild())
return;
- if (!root.isPositioned() && !root.isInitialContainingBlock())
+ if (!root.isPositioned() && !is<InitialContainingBlock>(root))
return;
// Collect the out-of-flow descendants at the formatting root level (as opposed to at the containing block level, though they might be the same).
// FIXME: Turn this into a register-self as boxes are being inserted.
Modified: trunk/Source/WebCore/layout/FormattingContextQuirks.cpp (258903 => 258904)
--- trunk/Source/WebCore/layout/FormattingContextQuirks.cpp 2020-03-24 03:40:45 UTC (rev 258903)
+++ trunk/Source/WebCore/layout/FormattingContextQuirks.cpp 2020-03-24 04:09:30 UTC (rev 258904)
@@ -30,6 +30,7 @@
#include "DisplayBox.h"
#include "LayoutBox.h"
+#include "LayoutInitialContainingBlock.h"
namespace WebCore {
namespace Layout {
@@ -59,7 +60,7 @@
bodyAndDocumentVerticalMarginPaddingAndBorder += verticalMargin.before.valueOr(0) + verticalMargin.after.valueOr(0) + verticalPadding + verticalBorder;
}
- if (containingBlock->isInitialContainingBlock())
+ if (is<InitialContainingBlock>(*containingBlock))
break;
containingBlock = &containingBlock->containingBlock();
}
Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextQuirks.cpp (258903 => 258904)
--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextQuirks.cpp 2020-03-24 03:40:45 UTC (rev 258903)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextQuirks.cpp 2020-03-24 04:09:30 UTC (rev 258904)
@@ -32,6 +32,7 @@
#include "DisplayBox.h"
#include "LayoutBox.h"
#include "LayoutContainerBox.h"
+#include "LayoutInitialContainingBlock.h"
#include "LayoutState.h"
namespace WebCore {
Modified: trunk/Source/WebCore/layout/displaytree/DisplayPainter.cpp (258903 => 258904)
--- trunk/Source/WebCore/layout/displaytree/DisplayPainter.cpp 2020-03-24 03:40:45 UTC (rev 258903)
+++ trunk/Source/WebCore/layout/displaytree/DisplayPainter.cpp 2020-03-24 04:09:30 UTC (rev 258904)
@@ -36,6 +36,7 @@
#include "InlineTextItem.h"
#include "IntRect.h"
#include "LayoutContainerBox.h"
+#include "LayoutInitialContainingBlock.h"
#include "LayoutState.h"
#include "RenderStyle.h"
#include "TextRun.h"
@@ -145,11 +146,11 @@
// Should never really happen but table code is way too incomplete.
if (!layoutState.hasDisplayBox(layoutBox))
return { };
- if (layoutBox.isInitialContainingBlock())
+ if (is<Layout::InitialContainingBlock>(layoutBox))
return layoutState.displayBoxForLayoutBox(layoutBox);
auto absoluteBox = Box { layoutState.displayBoxForLayoutBox(layoutBox) };
- for (auto* containingBlock = &layoutBox.containingBlock(); !containingBlock->isInitialContainingBlock(); containingBlock = &containingBlock->containingBlock())
+ for (auto* containingBlock = &layoutBox.containingBlock(); !is<Layout::InitialContainingBlock>(*containingBlock); containingBlock = &containingBlock->containingBlock())
absoluteBox.moveBy(layoutState.displayBoxForLayoutBox(*containingBlock).topLeft());
return absoluteBox;
}
Modified: trunk/Source/WebCore/layout/invalidation/InvalidationState.cpp (258903 => 258904)
--- trunk/Source/WebCore/layout/invalidation/InvalidationState.cpp 2020-03-24 03:40:45 UTC (rev 258903)
+++ trunk/Source/WebCore/layout/invalidation/InvalidationState.cpp 2020-03-24 04:09:30 UTC (rev 258904)
@@ -42,7 +42,7 @@
void InvalidationState::markNeedsUpdate(const Box& layoutBox)
{
// We never lay out the initial containing block. It always has pre-determined geometry.
- ASSERT(!layoutBox.isInitialContainingBlock());
+ ASSERT(!is<InitialContainingBlock>(layoutBox));
// FIXME: This is just a placeholder implementation.
m_formattingContextRoots.add(&layoutBox.formattingContextRoot());
}
Modified: trunk/Source/WebCore/layout/layouttree/LayoutBox.cpp (258903 => 258904)
--- trunk/Source/WebCore/layout/layouttree/LayoutBox.cpp 2020-03-24 03:40:45 UTC (rev 258903)
+++ trunk/Source/WebCore/layout/layouttree/LayoutBox.cpp 2020-03-24 04:09:30 UTC (rev 258904)
@@ -30,6 +30,7 @@
#include "DisplayBox.h"
#include "LayoutContainerBox.h"
+#include "LayoutInitialContainingBlock.h"
#include "LayoutPhase.h"
#include "LayoutState.h"
#include "RenderStyle.h"
@@ -70,7 +71,7 @@
bool Box::establishesBlockFormattingContext() const
{
// ICB always creates a new (inital) block formatting context.
- if (isInitialContainingBlock())
+ if (is<InitialContainingBlock>(*this))
return true;
if (isTableWrapperBox())
@@ -183,7 +184,7 @@
// Finding the containing block by traversing the tree during tree construction could provide incorrect result.
ASSERT(!Phase::isInTreeBuilding());
// If we ever end up here with the ICB, we must be doing something not-so-great.
- RELEASE_ASSERT(!isInitialContainingBlock());
+ RELEASE_ASSERT(!is<InitialContainingBlock>(*this));
// The containing block in which the root element lives is a rectangle called the initial containing block.
// For other elements, if the element's position is 'relative' or 'static', the containing block is formed by the
// content edge of the nearest block container ancestor box or which establishes a formatting context.
@@ -192,7 +193,7 @@
// 'position' of 'absolute', 'relative' or 'fixed'.
if (!isPositioned() || isInFlowPositioned()) {
auto* ancestor = parent();
- for (; !ancestor->isInitialContainingBlock(); ancestor = ancestor->parent()) {
+ for (; !is<InitialContainingBlock>(*ancestor); ancestor = ancestor->parent()) {
if (ancestor->isBlockContainerBox() || ancestor->establishesFormattingContext())
return *ancestor;
}
@@ -201,7 +202,7 @@
if (isFixedPositioned()) {
auto* ancestor = parent();
- for (; !ancestor->isInitialContainingBlock(); ancestor = ancestor->parent()) {
+ for (; !is<InitialContainingBlock>(*ancestor); ancestor = ancestor->parent()) {
if (ancestor->style().hasTransform())
return *ancestor;
}
@@ -210,7 +211,7 @@
if (isOutOfFlowPositioned()) {
auto* ancestor = parent();
- for (; !ancestor->isInitialContainingBlock(); ancestor = ancestor->parent()) {
+ for (; !is<InitialContainingBlock>(*ancestor); ancestor = ancestor->parent()) {
if (ancestor->isPositioned() || ancestor->style().hasTransform())
return *ancestor;
}
@@ -226,7 +227,7 @@
// Finding the context root by traversing the tree during tree construction could provide incorrect result.
ASSERT(!Phase::isInTreeBuilding());
// We should never need to ask this question on the ICB.
- ASSERT(!isInitialContainingBlock());
+ ASSERT(!is<InitialContainingBlock>(*this));
// A box lives in the same formatting context as its containing block unless the containing block establishes a formatting context.
// However relatively positioned (inflow) inline container lives in the formatting context where its parent lives unless
// the parent establishes a formatting context.
@@ -240,26 +241,26 @@
return ancestor.formattingContextRoot();
}
-const ContainerBox& Box::initialContainingBlock() const
+const InitialContainingBlock& Box::initialContainingBlock() const
{
- if (isInitialContainingBlock())
- return downcast<ContainerBox>(*this);
+ if (is<InitialContainingBlock>(*this))
+ return downcast<InitialContainingBlock>(*this);
auto* ancestor = parent();
for (; ancestor->parent(); ancestor = ancestor->parent()) { }
- return *ancestor;
+ return downcast<InitialContainingBlock>(*ancestor);
}
bool Box::isInFormattingContextOf(const ContainerBox& formattingContextRoot) const
{
ASSERT(formattingContextRoot.establishesFormattingContext());
- ASSERT(!isInitialContainingBlock());
+ ASSERT(!is<InitialContainingBlock>(*this));
auto* ancestor = &containingBlock();
while (ancestor) {
if (ancestor == &formattingContextRoot)
return true;
- if (ancestor->isInitialContainingBlock())
+ if (is<InitialContainingBlock>(*ancestor))
return false;
ancestor = &ancestor->containingBlock();
}
@@ -360,7 +361,7 @@
return isOverflowVisible;
return true;
}
- if (isInitialContainingBlock()) {
+ if (is<InitialContainingBlock>(*this)) {
auto* documentBox = downcast<ContainerBox>(*this).firstChild();
if (!documentBox || !documentBox->isDocumentBox() || !is<ContainerBox>(documentBox))
return isOverflowVisible;
Modified: trunk/Source/WebCore/layout/layouttree/LayoutBox.h (258903 => 258904)
--- trunk/Source/WebCore/layout/layouttree/LayoutBox.h 2020-03-24 03:40:45 UTC (rev 258903)
+++ trunk/Source/WebCore/layout/layouttree/LayoutBox.h 2020-03-24 04:09:30 UTC (rev 258904)
@@ -40,6 +40,7 @@
namespace Layout {
class ContainerBox;
+class InitialContainingBlock;
class LayoutState;
class TreeBuilder;
@@ -61,12 +62,12 @@
};
enum BaseTypeFlag {
- BoxFlag = 1 << 0,
- InlineTextBox = 1 << 1,
- LineBreakBox = 1 << 2,
- ReplacedBox = 1 << 3,
- InitialContainingBlock = 1 << 4,
- ContainerBoxFlag = 1 << 5
+ BoxFlag = 1 << 0,
+ InlineTextBoxFlag = 1 << 1,
+ LineBreakBoxFlag = 1 << 2,
+ ReplacedBoxFlag = 1 << 3,
+ InitialContainingBlockFlag = 1 << 4,
+ ContainerBoxFlag = 1 << 5
};
typedef unsigned BaseTypeFlags;
@@ -96,7 +97,7 @@
const ContainerBox& containingBlock() const;
const ContainerBox& formattingContextRoot() const;
- const ContainerBox& initialContainingBlock() const;
+ const InitialContainingBlock& initialContainingBlock() const;
bool isInFormattingContextOf(const ContainerBox&) const;
@@ -109,7 +110,7 @@
bool isInlineBlockBox() const;
bool isInlineTableBox() const;
bool isBlockContainerBox() const;
- bool isInitialContainingBlock() const { return m_baseTypeFlags & InitialContainingBlock; }
+ bool isInitialContainingBlock() const { return m_baseTypeFlags & InitialContainingBlockFlag; }
bool isDocumentBox() const { return m_elementAttributes && m_elementAttributes.value().elementType == ElementType::Document; }
bool isBodyBox() const { return m_elementAttributes && m_elementAttributes.value().elementType == ElementType::Body; }
@@ -138,9 +139,9 @@
Box* nextSibling() { return m_nextSibling; }
bool isContainerBox() const { return m_baseTypeFlags & ContainerBoxFlag; }
- bool isInlineTextBox() const { return m_baseTypeFlags & InlineTextBox; }
- bool isLineBreakBox() const { return m_baseTypeFlags & LineBreakBox; }
- bool isReplacedBox() const { return m_baseTypeFlags & ReplacedBox; }
+ bool isInlineTextBox() const { return m_baseTypeFlags & InlineTextBoxFlag; }
+ bool isLineBreakBox() const { return m_baseTypeFlags & LineBreakBoxFlag; }
+ bool isReplacedBox() const { return m_baseTypeFlags & ReplacedBoxFlag; }
bool isPaddingApplicable() const;
bool isOverflowVisible() const;
Modified: trunk/Source/WebCore/layout/layouttree/LayoutInitialContainingBlock.cpp (258903 => 258904)
--- trunk/Source/WebCore/layout/layouttree/LayoutInitialContainingBlock.cpp 2020-03-24 03:40:45 UTC (rev 258903)
+++ trunk/Source/WebCore/layout/layouttree/LayoutInitialContainingBlock.cpp 2020-03-24 04:09:30 UTC (rev 258904)
@@ -37,7 +37,7 @@
WTF_MAKE_ISO_ALLOCATED_IMPL(InitialContainingBlock);
InitialContainingBlock::InitialContainingBlock(RenderStyle&& style)
- : ContainerBox({ }, WTFMove(style), Box::InitialContainingBlock)
+ : ContainerBox({ }, WTFMove(style), Box::InitialContainingBlockFlag)
{
}
Modified: trunk/Source/WebCore/layout/layouttree/LayoutInlineTextBox.cpp (258903 => 258904)
--- trunk/Source/WebCore/layout/layouttree/LayoutInlineTextBox.cpp 2020-03-24 03:40:45 UTC (rev 258903)
+++ trunk/Source/WebCore/layout/layouttree/LayoutInlineTextBox.cpp 2020-03-24 04:09:30 UTC (rev 258904)
@@ -37,7 +37,7 @@
WTF_MAKE_ISO_ALLOCATED_IMPL(InlineTextBox);
InlineTextBox::InlineTextBox(String content, bool canUseSimplifiedContentMeasuring, RenderStyle&& style)
- : Box({ }, WTFMove(style), Box::InlineTextBox)
+ : Box({ }, WTFMove(style), Box::InlineTextBoxFlag)
, m_content(content)
, m_canUseSimplifiedContentMeasuring(canUseSimplifiedContentMeasuring)
{
Modified: trunk/Source/WebCore/layout/layouttree/LayoutLineBreakBox.cpp (258903 => 258904)
--- trunk/Source/WebCore/layout/layouttree/LayoutLineBreakBox.cpp 2020-03-24 03:40:45 UTC (rev 258903)
+++ trunk/Source/WebCore/layout/layouttree/LayoutLineBreakBox.cpp 2020-03-24 04:09:30 UTC (rev 258904)
@@ -37,7 +37,7 @@
WTF_MAKE_ISO_ALLOCATED_IMPL(LineBreakBox);
LineBreakBox::LineBreakBox(bool isOptional, RenderStyle&& style)
- : Box({ }, WTFMove(style), Box::LineBreakBox)
+ : Box({ }, WTFMove(style), Box::LineBreakBoxFlag)
, m_isOptional(isOptional)
{
}
Modified: trunk/Source/WebCore/layout/layouttree/LayoutReplacedBox.cpp (258903 => 258904)
--- trunk/Source/WebCore/layout/layouttree/LayoutReplacedBox.cpp 2020-03-24 03:40:45 UTC (rev 258903)
+++ trunk/Source/WebCore/layout/layouttree/LayoutReplacedBox.cpp 2020-03-24 04:09:30 UTC (rev 258904)
@@ -37,7 +37,7 @@
WTF_MAKE_ISO_ALLOCATED_IMPL(ReplacedBox);
ReplacedBox::ReplacedBox(RenderStyle&& style)
- : Box({ }, WTFMove(style), Box::ReplacedBox)
+ : Box({ }, WTFMove(style), Box::ReplacedBoxFlag)
{
}
Modified: trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp (258903 => 258904)
--- trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp 2020-03-24 03:40:45 UTC (rev 258903)
+++ trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp 2020-03-24 04:09:30 UTC (rev 258904)
@@ -394,7 +394,7 @@
if (layoutBox.isFloatingPositioned())
stream << "[float] ";
- if (layoutBox.isInitialContainingBlock())
+ if (is<InitialContainingBlock>(layoutBox))
stream << "Initial containing block";
else if (layoutBox.isDocumentBox())
stream << "HTML";