Title: [282401] trunk/Source/WebCore
Revision
282401
Author
[email protected]
Date
2021-09-14 12:31:03 -0700 (Tue, 14 Sep 2021)

Log Message

[LFC][IFC] Introduce InlineInvalidation/InlineDamage
https://bugs.webkit.org/show_bug.cgi?id=229225
<rdar://problem/82324227>

Reviewed by Antti Koivisto.

This is in preparation for supporting partial inline layout.

The initial implementation is going to only support a single type of damage (content changed, style changed etc) on a single line.
Anything more involved either
1. folds into a full damage type of layout (i.e. no range support) e.g changing multiple images on different lines triggers vertical alignment on all the lines
2. triggers the lowest level type of layout e.g. changing content on the first line while resizing the containing block folds into NeedsContentUpdateAndLineLayout.

* CMakeLists.txt:
* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:
* layout/formattingContexts/inline/invalidation/InlineDamage.h: Added.
(WebCore::Layout::InlineDamage::type const):
(WebCore::Layout::InlineDamage::line const):
(WebCore::Layout::InlineDamage::setDamageType):
(WebCore::Layout::InlineDamage::setDamagedLine):
* layout/formattingContexts/inline/invalidation/InlineInvalidation.cpp: Added.
(WebCore::Layout::InlineInvalidation::InlineInvalidation):
(WebCore::Layout::InlineInvalidation::styleChanged):
(WebCore::Layout::InlineInvalidation::textInserted):
(WebCore::Layout::InlineInvalidation::textWillBeRemoved):
(WebCore::Layout::InlineInvalidation::inlineLevelBoxInserted):
(WebCore::Layout::InlineInvalidation::inlineLevelBoxWillBeRemoved):
* layout/formattingContexts/inline/invalidation/InlineInvalidation.h: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/CMakeLists.txt (282400 => 282401)


--- trunk/Source/WebCore/CMakeLists.txt	2021-09-14 19:26:58 UTC (rev 282400)
+++ trunk/Source/WebCore/CMakeLists.txt	2021-09-14 19:31:03 UTC (rev 282401)
@@ -112,6 +112,7 @@
     "${WEBCORE_DIR}/layout/formattingContexts/flex"
     "${WEBCORE_DIR}/layout/floats"
     "${WEBCORE_DIR}/layout/formattingContexts/inline"
+    "${WEBCORE_DIR}/layout/formattingContexts/invalidation"
     "${WEBCORE_DIR}/layout/formattingContexts/inline/text"
     "${WEBCORE_DIR}/layout/integration"
     "${WEBCORE_DIR}/layout/layouttree"

Modified: trunk/Source/WebCore/ChangeLog (282400 => 282401)


--- trunk/Source/WebCore/ChangeLog	2021-09-14 19:26:58 UTC (rev 282400)
+++ trunk/Source/WebCore/ChangeLog	2021-09-14 19:31:03 UTC (rev 282401)
@@ -1,3 +1,35 @@
+2021-09-14  Alan Bujtas  <[email protected]>
+
+        [LFC][IFC] Introduce InlineInvalidation/InlineDamage
+        https://bugs.webkit.org/show_bug.cgi?id=229225
+        <rdar://problem/82324227>
+
+        Reviewed by Antti Koivisto.
+
+        This is in preparation for supporting partial inline layout.
+
+        The initial implementation is going to only support a single type of damage (content changed, style changed etc) on a single line.
+        Anything more involved either
+        1. folds into a full damage type of layout (i.e. no range support) e.g changing multiple images on different lines triggers vertical alignment on all the lines
+        2. triggers the lowest level type of layout e.g. changing content on the first line while resizing the containing block folds into NeedsContentUpdateAndLineLayout.
+
+        * CMakeLists.txt:
+        * Sources.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * layout/formattingContexts/inline/invalidation/InlineDamage.h: Added.
+        (WebCore::Layout::InlineDamage::type const):
+        (WebCore::Layout::InlineDamage::line const):
+        (WebCore::Layout::InlineDamage::setDamageType):
+        (WebCore::Layout::InlineDamage::setDamagedLine):
+        * layout/formattingContexts/inline/invalidation/InlineInvalidation.cpp: Added.
+        (WebCore::Layout::InlineInvalidation::InlineInvalidation):
+        (WebCore::Layout::InlineInvalidation::styleChanged):
+        (WebCore::Layout::InlineInvalidation::textInserted):
+        (WebCore::Layout::InlineInvalidation::textWillBeRemoved):
+        (WebCore::Layout::InlineInvalidation::inlineLevelBoxInserted):
+        (WebCore::Layout::InlineInvalidation::inlineLevelBoxWillBeRemoved):
+        * layout/formattingContexts/inline/invalidation/InlineInvalidation.h: Added.
+
 2021-09-14  Myles C. Maxfield  <[email protected]>
 
         [Cocoa] Migrate to CTFontHasTable() from CTFontCopyAvailableTables()

Modified: trunk/Source/WebCore/Sources.txt (282400 => 282401)


--- trunk/Source/WebCore/Sources.txt	2021-09-14 19:26:58 UTC (rev 282400)
+++ trunk/Source/WebCore/Sources.txt	2021-09-14 19:31:03 UTC (rev 282401)
@@ -1489,6 +1489,7 @@
 layout/formattingContexts/inline/InlineLineBuilder.cpp
 layout/formattingContexts/inline/InlineLineBoxVerticalAligner.cpp
 layout/formattingContexts/inline/InlineTextItem.cpp
+layout/formattingContexts/inline/invalidation/InlineInvalidation.cpp
 layout/formattingContexts/inline/text/TextUtil.cpp
 layout/integration/LayoutIntegrationBoxTree.cpp
 layout/integration/LayoutIntegrationCoverage.cpp

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (282400 => 282401)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2021-09-14 19:26:58 UTC (rev 282400)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2021-09-14 19:31:03 UTC (rev 282401)
@@ -391,6 +391,8 @@
 		0FFD45AA243C3027000D4BEA /* ScrollingTreeLatchingController.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FFD45A7243BF257000D4BEA /* ScrollingTreeLatchingController.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		0FFD4D6118651FA300512F6E /* AsyncScrollingCoordinator.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FFD4D5F18651FA300512F6E /* AsyncScrollingCoordinator.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		10FB084B14E15C7E00A3DB98 /* PublicURLManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 10FB084A14E15C7E00A3DB98 /* PublicURLManager.h */; };
+		111FA1C726F0F30F003B8F16 /* InlineInvalidation.h in Headers */ = {isa = PBXBuildFile; fileRef = 111FA1C526F0F30F003B8F16 /* InlineInvalidation.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		111FA1C826F0F30F003B8F16 /* InlineDamage.h in Headers */ = {isa = PBXBuildFile; fileRef = 111FA1C626F0F30F003B8F16 /* InlineDamage.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		11310CF220BA4A320065A8D0 /* LayoutTreeBuilder.h in Headers */ = {isa = PBXBuildFile; fileRef = 11100FD7209514DF0081AA6C /* LayoutTreeBuilder.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		11310CF320BA4A370065A8D0 /* LayoutReplacedBox.h in Headers */ = {isa = PBXBuildFile; fileRef = 111C615620AD1AE1005B82FA /* LayoutReplacedBox.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		11310CF420BA4A3D0065A8D0 /* LayoutIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = 11100FC72092764C0081AA6C /* LayoutIterator.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -6449,6 +6451,9 @@
 		11100FD7209514DF0081AA6C /* LayoutTreeBuilder.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LayoutTreeBuilder.h; sourceTree = "<group>"; };
 		111C615620AD1AE1005B82FA /* LayoutReplacedBox.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LayoutReplacedBox.h; sourceTree = "<group>"; };
 		111C615720AD1AE1005B82FA /* LayoutReplacedBox.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = LayoutReplacedBox.cpp; sourceTree = "<group>"; };
+		111FA1C526F0F30F003B8F16 /* InlineInvalidation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InlineInvalidation.h; sourceTree = "<group>"; };
+		111FA1C626F0F30F003B8F16 /* InlineDamage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InlineDamage.h; sourceTree = "<group>"; };
+		111FA1C926F0F438003B8F16 /* InlineInvalidation.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = InlineInvalidation.cpp; sourceTree = "<group>"; };
 		113409D7203E038000C66915 /* RenderTreeBuilderContinuation.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RenderTreeBuilderContinuation.cpp; sourceTree = "<group>"; };
 		113409D8203E038000C66915 /* RenderTreeBuilderContinuation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RenderTreeBuilderContinuation.h; sourceTree = "<group>"; };
 		113D0B4F1F9FDD2B00F611BB /* FrameViewLayoutContext.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = FrameViewLayoutContext.cpp; sourceTree = "<group>"; };
@@ -18115,6 +18120,16 @@
 			path = css;
 			sourceTree = "<group>";
 		};
+		111FA1C326F0F2E6003B8F16 /* invalidation */ = {
+			isa = PBXGroup;
+			children = (
+				111FA1C626F0F30F003B8F16 /* InlineDamage.h */,
+				111FA1C926F0F438003B8F16 /* InlineInvalidation.cpp */,
+				111FA1C526F0F30F003B8F16 /* InlineInvalidation.h */,
+			);
+			path = invalidation;
+			sourceTree = "<group>";
+		};
 		115CFA66208AF720001E6991 /* layout */ = {
 			isa = PBXGroup;
 			children = (
@@ -18188,6 +18203,7 @@
 		115CFA9A208BC140001E6991 /* inline */ = {
 			isa = PBXGroup;
 			children = (
+				111FA1C326F0F2E6003B8F16 /* invalidation */,
 				6FE7DDDD20EC6E8B008B5B4E /* text */,
 				6FE198132178397B00446F08 /* InlineContentBreaker.cpp */,
 				6FE198152178397C00446F08 /* InlineContentBreaker.h */,
@@ -32721,11 +32737,13 @@
 				CD063F831E23FA8900812BE3 /* InitDataRegistry.h in Headers */,
 				E30592641E27A3AD00D57C98 /* InlineClassicScript.h in Headers */,
 				6FE198172178397C00446F08 /* InlineContentBreaker.h in Headers */,
+				111FA1C826F0F30F003B8F16 /* InlineDamage.h in Headers */,
 				11513D0326D981E8004D3FAA /* InlineDisplayContentBuilder.h in Headers */,
 				6F7CA3CA208C2B2E002F29AB /* InlineFormattingContext.h in Headers */,
 				47C4D57D26508BCB00C7AB1F /* InlineFormattingGeometry.h in Headers */,
 				6FE636E82647962900F0951E /* InlineFormattingQuirks.h in Headers */,
 				115CFA7E208B8E10001E6991 /* InlineFormattingState.h in Headers */,
+				111FA1C726F0F30F003B8F16 /* InlineInvalidation.h in Headers */,
 				6FE7CFA22177EEF2005B1573 /* InlineItem.h in Headers */,
 				BCE789161120D6080060ECE5 /* InlineIterator.h in Headers */,
 				6FAAE71326A2814B00E07502 /* InlineLevelBox.h in Headers */,

Added: trunk/Source/WebCore/layout/formattingContexts/inline/invalidation/InlineDamage.h (0 => 282401)


--- trunk/Source/WebCore/layout/formattingContexts/inline/invalidation/InlineDamage.h	                        (rev 0)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/invalidation/InlineDamage.h	2021-09-14 19:31:03 UTC (rev 282401)
@@ -0,0 +1,67 @@
+/*
+ * 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 <wtf/IsoMallocInlines.h>
+
+namespace WebCore {
+namespace Layout {
+
+class InlineDamage {
+    WTF_MAKE_ISO_ALLOCATED_INLINE(InlineDamage);
+public:
+    InlineDamage() = default;
+
+    enum class Type {
+        // Content changed or some style property that drives soft wrap opportunities (e.g. going from white-space: pre to normal).
+        // This tells us to re-process the inline content and run line layout.
+        NeedsContentUpdateAndLineLayout,
+        // Same content but either the constraint or some style that may affect line breaking changed (e.g. font-size or containing block set new horizontal constraint). 
+        NeedsLineLayout,
+        // Line breaking positions are the same, only height related style changed (e.g img's height changes).
+        NeedsVerticalAdjustment,
+        // Line breaking positions are the same, runs may show up at a different horizontal position (e.g. text-align changes).
+        NeedsHorizontalAdjustment 
+    };
+    Type type() const { return m_damageType; }
+    // FIXME: Add support for damage range with multiple, different damage types.
+    std::optional<size_t> line() const { return m_damagedLine; }
+
+private:
+    friend class InlineInvalidation;
+
+    void setDamageType(Type type) { m_damageType = type; }
+    void setDamagedLine(size_t lineIndex) { m_damagedLine = lineIndex; }
+
+    Type m_damageType { Type::NeedsContentUpdateAndLineLayout };
+    std::optional<size_t> m_damagedLine;
+};
+
+}
+}
+#endif

Added: trunk/Source/WebCore/layout/formattingContexts/inline/invalidation/InlineInvalidation.cpp (0 => 282401)


--- trunk/Source/WebCore/layout/formattingContexts/inline/invalidation/InlineInvalidation.cpp	                        (rev 0)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/invalidation/InlineInvalidation.cpp	2021-09-14 19:31:03 UTC (rev 282401)
@@ -0,0 +1,83 @@
+/*
+ * 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 "InlineInvalidation.h"
+
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+
+#include "InlineDamage.h"
+
+namespace WebCore {
+namespace Layout {
+
+InlineInvalidation::InlineInvalidation(InlineDamage& inlineDamage)
+    : m_inlineDamage(inlineDamage)
+{
+}
+
+void InlineInvalidation::styleChanged(const Box& layoutBox, const RenderStyle& oldStyle)
+{
+    UNUSED_PARAM(layoutBox);
+    UNUSED_PARAM(oldStyle);
+
+    m_inlineDamage.setDamageType(InlineDamage::Type::NeedsContentUpdateAndLineLayout);
+}
+
+void InlineInvalidation::textInserted(const InlineTextBox& textBox, std::optional<size_t> offset, std::optional<size_t> length)
+{
+    UNUSED_PARAM(textBox);
+    UNUSED_PARAM(offset);
+    UNUSED_PARAM(length);
+
+    m_inlineDamage.setDamageType(InlineDamage::Type::NeedsContentUpdateAndLineLayout);
+}
+
+void InlineInvalidation::textWillBeRemoved(const InlineTextBox& textBox, std::optional<size_t> offset, std::optional<size_t> length)
+{
+    UNUSED_PARAM(textBox);
+    UNUSED_PARAM(offset);
+    UNUSED_PARAM(length);
+
+    m_inlineDamage.setDamageType(InlineDamage::Type::NeedsContentUpdateAndLineLayout);
+}
+
+void InlineInvalidation::inlineLevelBoxInserted(const Box& layoutBox)
+{
+    UNUSED_PARAM(layoutBox);
+
+    m_inlineDamage.setDamageType(InlineDamage::Type::NeedsContentUpdateAndLineLayout);
+}
+
+void InlineInvalidation::inlineLevelBoxWillBeRemoved(const Box& layoutBox)
+{
+    UNUSED_PARAM(layoutBox);
+
+    m_inlineDamage.setDamageType(InlineDamage::Type::NeedsContentUpdateAndLineLayout);
+}
+
+}
+}
+#endif

Added: trunk/Source/WebCore/layout/formattingContexts/inline/invalidation/InlineInvalidation.h (0 => 282401)


--- trunk/Source/WebCore/layout/formattingContexts/inline/invalidation/InlineInvalidation.h	                        (rev 0)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/invalidation/InlineInvalidation.h	2021-09-14 19:31:03 UTC (rev 282401)
@@ -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)
+
+namespace WebCore {
+namespace Layout {
+class InlineDamage;
+
+class InlineInvalidation {
+public:
+    InlineInvalidation(InlineDamage&);
+
+    void styleChanged(const Box&, const RenderStyle& oldStyle);
+
+    void textInserted(const InlineTextBox&, std::optional<size_t> offset, std::optional<size_t> length);
+    void textWillBeRemoved(const InlineTextBox&, std::optional<size_t> offset, std::optional<size_t> length);
+
+    void inlineLevelBoxInserted(const Box&);
+    void inlineLevelBoxWillBeRemoved(const Box&);
+
+private:
+    InlineDamage& m_inlineDamage;
+};
+
+}
+}
+#endif
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to