Diff
Modified: trunk/Source/WebCore/ChangeLog (285049 => 285050)
--- trunk/Source/WebCore/ChangeLog 2021-10-29 21:08:22 UTC (rev 285049)
+++ trunk/Source/WebCore/ChangeLog 2021-10-29 21:09:10 UTC (rev 285050)
@@ -1,3 +1,23 @@
+2021-10-29 Alan Bujtas <[email protected]>
+
+ [LFC][IFC] Introduce InlineItemsBuilder
+ https://bugs.webkit.org/show_bug.cgi?id=232487
+
+ Reviewed by Antti Koivisto.
+
+ This builder is going to be used for constructing bidi compatible inline items.
+
+ * Sources.txt:
+ * WebCore.xcodeproj/project.pbxproj:
+ * layout/formattingContexts/inline/InlineFormattingContext.cpp:
+ (WebCore::Layout::InlineFormattingContext::collectContentIfNeeded):
+ * layout/formattingContexts/inline/InlineItemsBuilder.cpp: Added.
+ (WebCore::Layout::InlineItemsBuilder::InlineItemsBuilder):
+ (WebCore::Layout::InlineItemsBuilder::build):
+ * layout/formattingContexts/inline/InlineItemsBuilder.h: Added.
+ (WebCore::Layout::InlineItemsBuilder::root const):
+ (WebCore::Layout::InlineItemsBuilder::formattingState const):
+
2021-10-29 Darin Adler <[email protected]>
Create constants for all special frame names used in anchor target attribute values and elsewhere
Modified: trunk/Source/WebCore/Sources.txt (285049 => 285050)
--- trunk/Source/WebCore/Sources.txt 2021-10-29 21:08:22 UTC (rev 285049)
+++ trunk/Source/WebCore/Sources.txt 2021-10-29 21:09:10 UTC (rev 285050)
@@ -1511,6 +1511,7 @@
layout/formattingContexts/inline/InlineFormattingQuirks.cpp
layout/formattingContexts/inline/InlineFormattingState.cpp
layout/formattingContexts/inline/InlineItem.cpp
+layout/formattingContexts/inline/InlineItemsBuilder.cpp
layout/formattingContexts/inline/InlineLine.cpp
layout/formattingContexts/inline/InlineLineBox.cpp
layout/formattingContexts/inline/InlineLineBoxBuilder.cpp
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (285049 => 285050)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2021-10-29 21:08:22 UTC (rev 285049)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2021-10-29 21:09:10 UTC (rev 285050)
@@ -425,6 +425,7 @@
1199FA46208E35A3002358CC /* LayoutContainerBox.h in Headers */ = {isa = PBXBuildFile; fileRef = 1199FA44208E35A3002358CC /* LayoutContainerBox.h */; settings = {ATTRIBUTES = (Private, ); }; };
11C3227D26D958CE00328F4D /* InlineLineBoxBuilder.h in Headers */ = {isa = PBXBuildFile; fileRef = 11C3227C26D958CE00328F4D /* InlineLineBoxBuilder.h */; settings = {ATTRIBUTES = (Private, ); }; };
11CB2789203BA570004A1DC9 /* RenderTreeBuilderFullScreen.h in Headers */ = {isa = PBXBuildFile; fileRef = 11CB2787203BA570004A1DC9 /* RenderTreeBuilderFullScreen.h */; };
+ 11D0363C272C4CFD009ED70D /* InlineItemsBuilder.h in Headers */ = {isa = PBXBuildFile; fileRef = 11D0363B272C4CFD009ED70D /* InlineItemsBuilder.h */; };
11E51638261E1A0600E69F25 /* WebXRInputSpace.h in Headers */ = {isa = PBXBuildFile; fileRef = 11E51635261E1A0500E69F25 /* WebXRInputSpace.h */; };
11E5163C261E1A1500E69F25 /* WebXRGamepad.h in Headers */ = {isa = PBXBuildFile; fileRef = 11E5163A261E1A1400E69F25 /* WebXRGamepad.h */; };
1400D7A817136EA70077CE05 /* ScriptWrappableInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = 1400D7A717136EA70077CE05 /* ScriptWrappableInlines.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -6573,6 +6574,8 @@
11C5F134200527F90001AE60 /* RenderTreeBuilderMathML.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderTreeBuilderMathML.h; sourceTree = "<group>"; };
11CB2786203BA570004A1DC9 /* RenderTreeBuilderFullScreen.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RenderTreeBuilderFullScreen.cpp; sourceTree = "<group>"; };
11CB2787203BA570004A1DC9 /* RenderTreeBuilderFullScreen.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RenderTreeBuilderFullScreen.h; sourceTree = "<group>"; };
+ 11D03639272C4CE7009ED70D /* InlineItemsBuilder.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = InlineItemsBuilder.cpp; sourceTree = "<group>"; };
+ 11D0363B272C4CFD009ED70D /* InlineItemsBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InlineItemsBuilder.h; sourceTree = "<group>"; };
11D19C2E23159BAE008F24D3 /* TableFormattingGeometry.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = TableFormattingGeometry.cpp; sourceTree = "<group>"; };
11E51635261E1A0500E69F25 /* WebXRInputSpace.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebXRInputSpace.h; sourceTree = "<group>"; };
11E51637261E1A0500E69F25 /* WebXRInputSpace.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebXRInputSpace.cpp; sourceTree = "<group>"; };
@@ -18465,6 +18468,8 @@
115CFA7C208B8E10001E6991 /* InlineFormattingState.h */,
6F7B8CEC23626E6600C9FF15 /* InlineItem.cpp */,
6FE7CFA02177EEF1005B1573 /* InlineItem.h */,
+ 11D03639272C4CE7009ED70D /* InlineItemsBuilder.cpp */,
+ 11D0363B272C4CFD009ED70D /* InlineItemsBuilder.h */,
6FAAE71126A2814A00E07502 /* InlineLevelBox.h */,
6F0CD692229ED31900C5994E /* InlineLine.cpp */,
6F0CD694229ED32700C5994E /* InlineLine.h */,
@@ -33242,6 +33247,7 @@
115CFA7E208B8E10001E6991 /* InlineFormattingState.h in Headers */,
111FA1C726F0F30F003B8F16 /* InlineInvalidation.h in Headers */,
6FE7CFA22177EEF2005B1573 /* InlineItem.h in Headers */,
+ 11D0363C272C4CFD009ED70D /* InlineItemsBuilder.h in Headers */,
E4A664CC2521D4AF007081DC /* InlineIteratorBox.h in Headers */,
E4A664CF2521D4E2007081DC /* InlineIteratorBoxLegacyPath.h in Headers */,
E4A664CE2521D4C9007081DC /* InlineIteratorBoxModernPath.h in Headers */,
Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineFormattingContext.cpp (285049 => 285050)
--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineFormattingContext.cpp 2021-10-29 21:08:22 UTC (rev 285049)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineFormattingContext.cpp 2021-10-29 21:09:10 UTC (rev 285050)
@@ -34,6 +34,7 @@
#include "InlineDisplayBox.h"
#include "InlineDisplayContentBuilder.h"
#include "InlineFormattingState.h"
+#include "InlineItemsBuilder.h"
#include "InlineLineBox.h"
#include "InlineLineBoxBuilder.h"
#include "InlineTextItem.h"
@@ -522,51 +523,8 @@
auto& formattingState = this->formattingState();
if (!formattingState.inlineItems().isEmpty())
return;
- // Traverse the tree and create inline items out of inline boxes and leaf nodes. This essentially turns the tree inline structure into a flat one.
- // <span>text<span></span><img></span> -> [InlineBoxStart][InlineLevelBox][InlineBoxStart][InlineBoxEnd][InlineLevelBox][InlineBoxEnd]
- ASSERT(root().hasInFlowOrFloatingChild());
- LayoutQueue layoutQueue;
- layoutQueue.append(root().firstChild());
- while (!layoutQueue.isEmpty()) {
- while (true) {
- auto& layoutBox = *layoutQueue.last();
- auto isInlineBoxWithInlineContent = layoutBox.isInlineBox() && !layoutBox.isInlineTextBox() && !layoutBox.isLineBreakBox() && !layoutBox.isOutOfFlowPositioned();
- if (!isInlineBoxWithInlineContent)
- break;
- // This is the start of an inline box (e.g. <span>).
- formattingState.addInlineItem({ layoutBox, InlineItem::Type::InlineBoxStart });
- auto& inlineBoxWithInlineContent = downcast<ContainerBox>(layoutBox);
- if (!inlineBoxWithInlineContent.hasChild())
- break;
- layoutQueue.append(inlineBoxWithInlineContent.firstChild());
- }
-
- while (!layoutQueue.isEmpty()) {
- auto& layoutBox = *layoutQueue.takeLast();
- if (layoutBox.isOutOfFlowPositioned()) {
- // Let's not construct InlineItems for out-of-flow content as they don't participate in the inline layout.
- // However to be able to static positioning them, we need to compute their approximate positions.
- formattingState.addOutOfFlowBox(layoutBox);
- } else if (is<LineBreakBox>(layoutBox)) {
- auto& lineBreakBox = downcast<LineBreakBox>(layoutBox);
- formattingState.addInlineItem({ layoutBox, lineBreakBox.isOptional() ? InlineItem::Type::WordBreakOpportunity : InlineItem::Type::HardLineBreak });
- } else if (layoutBox.isFloatingPositioned())
- formattingState.addInlineItem({ layoutBox, InlineItem::Type::Float });
- else if (layoutBox.isAtomicInlineLevelBox())
- formattingState.addInlineItem({ layoutBox, InlineItem::Type::Box });
- else if (layoutBox.isInlineTextBox()) {
- InlineTextItem::createAndAppendTextItems(formattingState.inlineItems(), downcast<InlineTextBox>(layoutBox));
- } else if (layoutBox.isInlineBox())
- formattingState.addInlineItem({ layoutBox, InlineItem::Type::InlineBoxEnd });
- else
- ASSERT_NOT_REACHED();
-
- if (auto* nextSibling = layoutBox.nextSibling()) {
- layoutQueue.append(nextSibling);
- break;
- }
- }
- }
+ auto inlineItemsBuilder = InlineItemsBuilder { root(), formattingState };
+ inlineItemsBuilder.build();
}
InlineRect InlineFormattingContext::computeGeometryForLineContent(const LineBuilder::LineContent& lineContent)
Added: trunk/Source/WebCore/layout/formattingContexts/inline/InlineItemsBuilder.cpp (0 => 285050)
--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineItemsBuilder.cpp (rev 0)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineItemsBuilder.cpp 2021-10-29 21:09:10 UTC (rev 285050)
@@ -0,0 +1,94 @@
+/*
+ * 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. AND ITS CONTRIBUTORS ``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 ITS 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.
+ */
+
+#include "config.h"
+#include "InlineItemsBuilder.h"
+
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+
+namespace WebCore {
+namespace Layout {
+
+InlineItemsBuilder::InlineItemsBuilder(const ContainerBox& formattingContextRoot, InlineFormattingState& formattingState)
+ : m_root(formattingContextRoot)
+ , m_formattingState(formattingState)
+{
+}
+
+void InlineItemsBuilder::build()
+{
+ // Traverse the tree and create inline items out of inline boxes and leaf nodes. This essentially turns the tree inline structure into a flat one.
+ // <span>text<span></span><img></span> -> [InlineBoxStart][InlineLevelBox][InlineBoxStart][InlineBoxEnd][InlineLevelBox][InlineBoxEnd]
+ ASSERT(root().hasInFlowOrFloatingChild());
+ auto& formattingState = this->formattingState();
+
+ Vector<const Box*> layoutQueue;
+ layoutQueue.append(root().firstChild());
+ while (!layoutQueue.isEmpty()) {
+ while (true) {
+ auto& layoutBox = *layoutQueue.last();
+ auto isInlineBoxWithInlineContent = layoutBox.isInlineBox() && !layoutBox.isInlineTextBox() && !layoutBox.isLineBreakBox() && !layoutBox.isOutOfFlowPositioned();
+ if (!isInlineBoxWithInlineContent)
+ break;
+ // This is the start of an inline box (e.g. <span>).
+ formattingState.addInlineItem({ layoutBox, InlineItem::Type::InlineBoxStart });
+ auto& inlineBoxWithInlineContent = downcast<ContainerBox>(layoutBox);
+ if (!inlineBoxWithInlineContent.hasChild())
+ break;
+ layoutQueue.append(inlineBoxWithInlineContent.firstChild());
+ }
+
+ while (!layoutQueue.isEmpty()) {
+ auto& layoutBox = *layoutQueue.takeLast();
+ if (layoutBox.isOutOfFlowPositioned()) {
+ // Let's not construct InlineItems for out-of-flow content as they don't participate in the inline layout.
+ // However to be able to static positioning them, we need to compute their approximate positions.
+ formattingState.addOutOfFlowBox(layoutBox);
+ } else if (is<LineBreakBox>(layoutBox)) {
+ auto& lineBreakBox = downcast<LineBreakBox>(layoutBox);
+ formattingState.addInlineItem({ layoutBox, lineBreakBox.isOptional() ? InlineItem::Type::WordBreakOpportunity : InlineItem::Type::HardLineBreak });
+ } else if (layoutBox.isFloatingPositioned())
+ formattingState.addInlineItem({ layoutBox, InlineItem::Type::Float });
+ else if (layoutBox.isAtomicInlineLevelBox())
+ formattingState.addInlineItem({ layoutBox, InlineItem::Type::Box });
+ else if (layoutBox.isInlineTextBox()) {
+ InlineTextItem::createAndAppendTextItems(formattingState.inlineItems(), downcast<InlineTextBox>(layoutBox));
+ } else if (layoutBox.isInlineBox())
+ formattingState.addInlineItem({ layoutBox, InlineItem::Type::InlineBoxEnd });
+ else
+ ASSERT_NOT_REACHED();
+
+ if (auto* nextSibling = layoutBox.nextSibling()) {
+ layoutQueue.append(nextSibling);
+ break;
+ }
+ }
+ }
+}
+
+}
+}
+
+#endif
Added: trunk/Source/WebCore/layout/formattingContexts/inline/InlineItemsBuilder.h (0 => 285050)
--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineItemsBuilder.h (rev 0)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineItemsBuilder.h 2021-10-29 21:09:10 UTC (rev 285050)
@@ -0,0 +1,52 @@
+/*
+ * 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. AND ITS CONTRIBUTORS ``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 ITS 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
+
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+
+#include "InlineFormattingState.h"
+#include "LayoutContainerBox.h"
+
+namespace WebCore {
+namespace Layout {
+
+class InlineItemsBuilder {
+public:
+ InlineItemsBuilder(const ContainerBox& formattingContextRoot, InlineFormattingState&);
+ void build();
+
+private:
+ const ContainerBox& root() const { return m_root; }
+ InlineFormattingState& formattingState() const { return m_formattingState; }
+
+ const ContainerBox& m_root;
+ InlineFormattingState& m_formattingState;
+};
+
+}
+}
+
+#endif