[LFC] Box::isAnonymous() can not rely on the lack of ElementType.
https://bugs.webkit.org/show_bug.cgi?id=201106
<rdar://problem/54660287>
Reviewed by Antti Koivisto.
Add bool m_isAnonymous member to mark anonymous layout boxes. Anonymous boxes are not rare enough to include this variable in RareData.
* layout/layouttree/LayoutBox.h:
(WebCore::Layout::Box::setIsAnonymous):
* layout/layouttree/LayoutTreeBuilder.cpp:
(WebCore::Layout::TreeBuilder::createLayoutBox):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@249085 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index debda72..aca7582 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,18 @@
+2019-08-24 Zalan Bujtas <zalan@apple.com>
+
+ [LFC] Box::isAnonymous() can not rely on the lack of ElementType.
+ https://bugs.webkit.org/show_bug.cgi?id=201106
+ <rdar://problem/54660287>
+
+ Reviewed by Antti Koivisto.
+
+ Add bool m_isAnonymous member to mark anonymous layout boxes. Anonymous boxes are not rare enough to include this variable in RareData.
+
+ * layout/layouttree/LayoutBox.h:
+ (WebCore::Layout::Box::setIsAnonymous):
+ * layout/layouttree/LayoutTreeBuilder.cpp:
+ (WebCore::Layout::TreeBuilder::createLayoutBox):
+
2019-08-24 Antti Koivisto <antti@apple.com>
Implement layout system independent text box iterator
diff --git a/Source/WebCore/layout/layouttree/LayoutBox.cpp b/Source/WebCore/layout/layouttree/LayoutBox.cpp
index f2334e0..da84deb 100644
--- a/Source/WebCore/layout/layouttree/LayoutBox.cpp
+++ b/Source/WebCore/layout/layouttree/LayoutBox.cpp
@@ -43,6 +43,7 @@
, m_elementAttributes(attributes)
, m_baseTypeFlags(baseTypeFlags)
, m_hasRareData(false)
+ , m_isAnonymous(false)
{
if (isReplaced())
ensureRareData().replaced = makeUnique<Replaced>(*this);
diff --git a/Source/WebCore/layout/layouttree/LayoutBox.h b/Source/WebCore/layout/layouttree/LayoutBox.h
index 0b84f71..5805221 100644
--- a/Source/WebCore/layout/layouttree/LayoutBox.h
+++ b/Source/WebCore/layout/layouttree/LayoutBox.h
@@ -45,7 +45,7 @@
enum class ElementType {
Document,
Body,
- TableWrapperBox, // The table generates a principal block container box called the table wrapper box that contains the table box and any caption boxes.
+ TableWrapperBox, // The table generates a principal block container box called the table wrapper box that contains the table box and any caption boxes.
TableBox, // The table box is a block-level box that contains the table's internal table boxes.
TableColumn,
TableRow,
@@ -159,6 +159,8 @@
void setNextSibling(Box& nextSibling) { m_nextSibling = &nextSibling; }
void setPreviousSibling(Box& previousSibling) { m_previousSibling = &previousSibling; }
+ void setIsAnonymous() { m_isAnonymous = true; }
+
protected:
Box(Optional<ElementAttributes>, RenderStyle&&, BaseTypeFlags);
@@ -195,6 +197,7 @@
unsigned m_baseTypeFlags : 6;
bool m_hasRareData : 1;
+ bool m_isAnonymous : 1;
};
}
diff --git a/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp b/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp
index dbc93c4..346dfbd 100644
--- a/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp
+++ b/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp
@@ -131,6 +131,7 @@
childLayoutBox = makeUnique<Box>(downcast<RenderText>(childRenderer).originalText(), RenderStyle::clone(parentRenderer.style()));
else
childLayoutBox = makeUnique<Box>(downcast<RenderText>(childRenderer).originalText(), RenderStyle::createAnonymousStyleWithDisplay(parentRenderer.style(), DisplayType::Inline));
+ childLayoutBox->setIsAnonymous();
return childLayoutBox;
}
@@ -142,6 +143,7 @@
if (is<RenderTable>(renderer)) {
// Construct the principal table wrapper box (and not the table box itself).
childLayoutBox = makeUnique<Container>(Box::ElementAttributes { Box::ElementType::TableWrapperBox }, RenderStyle::clone(renderer.style()));
+ childLayoutBox->setIsAnonymous();
} else if (is<RenderReplaced>(renderer)) {
if (displayType == DisplayType::Block)
childLayoutBox = makeUnique<Box>(elementAttributes(renderer), RenderStyle::clone(renderer.style()));
@@ -190,6 +192,9 @@
childLayoutBox->setColumnSpan(columnSpan);
}
+ if (childRenderer.isAnonymous())
+ childLayoutBox->setIsAnonymous();
+
return childLayoutBox;
}