Diff
Modified: trunk/Source/WebCore/ChangeLog (231037 => 231038)
--- trunk/Source/WebCore/ChangeLog 2018-04-26 00:55:49 UTC (rev 231037)
+++ trunk/Source/WebCore/ChangeLog 2018-04-26 02:04:48 UTC (rev 231038)
@@ -1,3 +1,30 @@
+2018-04-25 Zalan Bujtas <[email protected]>
+
+ [LFC] Add support for is<> and downcast<>
+ https://bugs.webkit.org/show_bug.cgi?id=185016
+
+ Reviewed by Antti Koivisto.
+
+ * layout/layouttree/LayoutBlockContainer.cpp:
+ (WebCore::Layout::BlockContainer::BlockContainer):
+ * layout/layouttree/LayoutBlockContainer.h:
+ * layout/layouttree/LayoutBox.cpp:
+ (WebCore::Layout::Box::Box):
+ * layout/layouttree/LayoutBox.h:
+ (WebCore::Layout::Box::isContainer const):
+ (WebCore::Layout::Box::isBlockContainer const):
+ (WebCore::Layout::Box::isInlineBox const):
+ (WebCore::Layout::Box::isInlineContainer const):
+ * layout/layouttree/LayoutContainer.cpp:
+ (WebCore::Layout::Container::Container):
+ * layout/layouttree/LayoutContainer.h:
+ * layout/layouttree/LayoutInlineBox.cpp:
+ (WebCore::Layout::InlineBox::InlineBox):
+ * layout/layouttree/LayoutInlineBox.h:
+ * layout/layouttree/LayoutInlineContainer.cpp:
+ (WebCore::Layout::InlineContainer::InlineContainer):
+ * layout/layouttree/LayoutInlineContainer.h:
+
2018-04-25 Chris Dumez <[email protected]>
window.postMessage() / focus() / blur() throw a TypeError when called on a RemoteDOMWindow
Modified: trunk/Source/WebCore/layout/layouttree/LayoutBlockContainer.cpp (231037 => 231038)
--- trunk/Source/WebCore/layout/layouttree/LayoutBlockContainer.cpp 2018-04-26 00:55:49 UTC (rev 231037)
+++ trunk/Source/WebCore/layout/layouttree/LayoutBlockContainer.cpp 2018-04-26 02:04:48 UTC (rev 231038)
@@ -36,8 +36,8 @@
WTF_MAKE_ISO_ALLOCATED_IMPL(BlockContainer);
-BlockContainer::BlockContainer(RenderStyle&& style)
- : Container(WTFMove(style))
+BlockContainer::BlockContainer(RenderStyle&& style, BaseTypeFlags baseTypeFlags)
+ : Container(WTFMove(style), baseTypeFlags | BlockContainerFlag)
{
}
Modified: trunk/Source/WebCore/layout/layouttree/LayoutBlockContainer.h (231037 => 231038)
--- trunk/Source/WebCore/layout/layouttree/LayoutBlockContainer.h 2018-04-26 00:55:49 UTC (rev 231037)
+++ trunk/Source/WebCore/layout/layouttree/LayoutBlockContainer.h 2018-04-26 02:04:48 UTC (rev 231038)
@@ -39,7 +39,7 @@
class BlockContainer : public Container {
WTF_MAKE_ISO_ALLOCATED(BlockContainer);
public:
- BlockContainer(RenderStyle&&);
+ BlockContainer(RenderStyle&&, BaseTypeFlags);
bool establishesInlineFormattingContext() const final;
};
@@ -46,4 +46,7 @@
}
}
+
+SPECIALIZE_TYPE_TRAITS_LAYOUT_BOX(BlockContainer, isBlockContainer())
+
#endif
Modified: trunk/Source/WebCore/layout/layouttree/LayoutBox.cpp (231037 => 231038)
--- trunk/Source/WebCore/layout/layouttree/LayoutBox.cpp 2018-04-26 00:55:49 UTC (rev 231037)
+++ trunk/Source/WebCore/layout/layouttree/LayoutBox.cpp 2018-04-26 02:04:48 UTC (rev 231038)
@@ -36,8 +36,10 @@
WTF_MAKE_ISO_ALLOCATED_IMPL(Box);
-Box::Box(RenderStyle&& style)
+Box::Box(RenderStyle&& style, BaseTypeFlags baseTypeFlags)
: m_style(WTFMove(style))
+ , m_baseTypeFlags(baseTypeFlags)
+ , m_isAnonymous(false)
{
}
Modified: trunk/Source/WebCore/layout/layouttree/LayoutBox.h (231037 => 231038)
--- trunk/Source/WebCore/layout/layouttree/LayoutBox.h 2018-04-26 00:55:49 UTC (rev 231037)
+++ trunk/Source/WebCore/layout/layouttree/LayoutBox.h 2018-04-26 02:04:48 UTC (rev 231038)
@@ -42,8 +42,9 @@
WTF_MAKE_ISO_ALLOCATED(Box);
public:
friend class TreeBuilder;
+ typedef unsigned BaseTypeFlags;
- Box(RenderStyle&&);
+ Box(RenderStyle&&, BaseTypeFlags);
virtual ~Box();
bool establishesFormattingContext() const;
@@ -81,9 +82,21 @@
const Box* previousInFlowSibling() const;
const Box* previousInFlowOrFloatingSibling() const;
+ bool isContainer() const { return m_baseTypeFlags & ContainerFlag; }
+ bool isBlockContainer() const { return m_baseTypeFlags & BlockContainerFlag; }
+ bool isInlineBox() const { return m_baseTypeFlags & InlineBoxFlag; }
+ bool isInlineContainer() const { return m_baseTypeFlags & InlineContainerFlag; }
+
auto& weakPtrFactory() const { return m_weakFactory; }
protected:
+ enum BaseTypeFlag {
+ ContainerFlag = 1 << 0,
+ BlockContainerFlag = 1 << 1,
+ InlineBoxFlag = 1 << 2,
+ InlineContainerFlag = 1 << 3
+ };
+
bool isOverflowVisible() const;
private:
@@ -99,9 +112,17 @@
Box* m_previousSibling { nullptr };
Box* m_nextSibling { nullptr };
- bool m_isAnonymous { false };
+ unsigned m_baseTypeFlags : 3;
+ unsigned m_isAnonymous : 1;
+
};
}
}
+
+#define SPECIALIZE_TYPE_TRAITS_LAYOUT_BOX(ToValueTypeName, predicate) \
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::Layout::ToValueTypeName) \
+ static bool isType(const WebCore::Layout::Box& box) { return box.predicate; } \
+SPECIALIZE_TYPE_TRAITS_END()
+
#endif
Modified: trunk/Source/WebCore/layout/layouttree/LayoutContainer.cpp (231037 => 231038)
--- trunk/Source/WebCore/layout/layouttree/LayoutContainer.cpp 2018-04-26 00:55:49 UTC (rev 231037)
+++ trunk/Source/WebCore/layout/layouttree/LayoutContainer.cpp 2018-04-26 02:04:48 UTC (rev 231038)
@@ -36,8 +36,8 @@
WTF_MAKE_ISO_ALLOCATED_IMPL(Container);
-Container::Container(RenderStyle&& style)
- : Box(WTFMove(style))
+Container::Container(RenderStyle&& style, BaseTypeFlags baseTypeFlags)
+ : Box(WTFMove(style), baseTypeFlags | ContainerFlag)
{
}
Modified: trunk/Source/WebCore/layout/layouttree/LayoutContainer.h (231037 => 231038)
--- trunk/Source/WebCore/layout/layouttree/LayoutContainer.h 2018-04-26 00:55:49 UTC (rev 231037)
+++ trunk/Source/WebCore/layout/layouttree/LayoutContainer.h 2018-04-26 02:04:48 UTC (rev 231038)
@@ -42,7 +42,7 @@
public:
friend class TreeBuilder;
- Container(RenderStyle&&);
+ Container(RenderStyle&&, BaseTypeFlags);
const Box* firstChild() const { return m_firstChild; }
const Box* firstInFlowChild() const;
@@ -69,4 +69,7 @@
}
}
+
+SPECIALIZE_TYPE_TRAITS_LAYOUT_BOX(Container, isContainer())
+
#endif
Modified: trunk/Source/WebCore/layout/layouttree/LayoutInlineBox.cpp (231037 => 231038)
--- trunk/Source/WebCore/layout/layouttree/LayoutInlineBox.cpp 2018-04-26 00:55:49 UTC (rev 231037)
+++ trunk/Source/WebCore/layout/layouttree/LayoutInlineBox.cpp 2018-04-26 02:04:48 UTC (rev 231038)
@@ -25,3 +25,23 @@
#include "config.h"
#include "LayoutInlineBox.h"
+
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+
+#include "RenderStyle.h"
+#include <wtf/IsoMallocInlines.h>
+
+namespace WebCore {
+namespace Layout {
+
+WTF_MAKE_ISO_ALLOCATED_IMPL(InlineBox);
+
+InlineBox::InlineBox(RenderStyle&& style, BaseTypeFlags baseTypeFlags)
+ : Box(WTFMove(style), baseTypeFlags | InlineBoxFlag)
+{
+}
+
+}
+}
+
+#endif
Modified: trunk/Source/WebCore/layout/layouttree/LayoutInlineBox.h (231037 => 231038)
--- trunk/Source/WebCore/layout/layouttree/LayoutInlineBox.h 2018-04-26 00:55:49 UTC (rev 231037)
+++ trunk/Source/WebCore/layout/layouttree/LayoutInlineBox.h 2018-04-26 02:04:48 UTC (rev 231038)
@@ -39,9 +39,12 @@
class InlineBox : public Box {
WTF_MAKE_ISO_ALLOCATED(InlineBox);
public:
- InlineBox(RenderStyle&&);
+ InlineBox(RenderStyle&&, BaseTypeFlags);
};
}
}
+
+SPECIALIZE_TYPE_TRAITS_LAYOUT_BOX(InlineBox, isInlineBox())
+
#endif
Modified: trunk/Source/WebCore/layout/layouttree/LayoutInlineContainer.cpp (231037 => 231038)
--- trunk/Source/WebCore/layout/layouttree/LayoutInlineContainer.cpp 2018-04-26 00:55:49 UTC (rev 231037)
+++ trunk/Source/WebCore/layout/layouttree/LayoutInlineContainer.cpp 2018-04-26 02:04:48 UTC (rev 231038)
@@ -25,3 +25,23 @@
#include "config.h"
#include "LayoutInlineContainer.h"
+
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+
+#include "RenderStyle.h"
+#include <wtf/IsoMallocInlines.h>
+
+namespace WebCore {
+namespace Layout {
+
+WTF_MAKE_ISO_ALLOCATED_IMPL(InlineContainer);
+
+InlineContainer::InlineContainer(RenderStyle&& style, BaseTypeFlags baseTypeFlags)
+ : Container(WTFMove(style), baseTypeFlags | InlineContainerFlag)
+{
+}
+
+}
+}
+
+#endif
Modified: trunk/Source/WebCore/layout/layouttree/LayoutInlineContainer.h (231037 => 231038)
--- trunk/Source/WebCore/layout/layouttree/LayoutInlineContainer.h 2018-04-26 00:55:49 UTC (rev 231037)
+++ trunk/Source/WebCore/layout/layouttree/LayoutInlineContainer.h 2018-04-26 02:04:48 UTC (rev 231038)
@@ -39,9 +39,12 @@
class InlineContainer : public Container {
WTF_MAKE_ISO_ALLOCATED(InlineContainer);
public:
- InlineContainer(RenderStyle&&);
+ InlineContainer(RenderStyle&&, BaseTypeFlags);
};
}
}
+
+SPECIALIZE_TYPE_TRAITS_LAYOUT_BOX(InlineContainer, isInlineContainer())
+
#endif