Diff
Modified: trunk/Source/WebCore/ChangeLog (283364 => 283365)
--- trunk/Source/WebCore/ChangeLog 2021-10-01 13:19:54 UTC (rev 283364)
+++ trunk/Source/WebCore/ChangeLog 2021-10-01 13:41:33 UTC (rev 283365)
@@ -1,3 +1,49 @@
+2021-10-01 Antti Koivisto <an...@apple.com>
+
+ Move InlineWalker to a file of its own and make it use RenderIterator
+ https://bugs.webkit.org/show_bug.cgi?id=231069
+
+ Reviewed by Alan Bujtas.
+
+ It is confusing and overly complicated.
+
+ * WebCore.xcodeproj/project.pbxproj:
+ * layout/integration/LayoutIntegrationBoxTree.cpp:
+ (WebCore::LayoutIntegration::BoxTree::buildTree):
+ * layout/integration/LayoutIntegrationCoverage.cpp:
+ (WebCore::LayoutIntegration::canUseForLineLayoutWithReason):
+ * rendering/InlineIterator.h:
+ (WebCore::bidiNextSkippingEmptyInlines):
+ (WebCore::bidiNextShared): Deleted.
+
+ There is no need to share anything here.
+
+ (WebCore::bidiNextIncludingEmptyInlines): Deleted.
+ (WebCore::bidiFirstIncludingEmptyInlines): Deleted.
+ (WebCore::InlineWalker::InlineWalker): Deleted.
+ (WebCore::InlineWalker::root): Deleted.
+ (WebCore::InlineWalker::current): Deleted.
+ (WebCore::InlineWalker::atEndOfInline): Deleted.
+
+ None of the clients cared about the functionality where the iterator would stop at the end of a RenderInline.
+
+ (WebCore::InlineWalker::atEnd const): Deleted.
+ (WebCore::InlineWalker::advance): Deleted.
+ * rendering/InlineWalker.h: Added.
+ (WebCore::InlineWalker::InlineWalker):
+ (WebCore::InlineWalker::current):
+ (WebCore::InlineWalker::atEnd const):
+ (WebCore::InlineWalker::advance):
+ * rendering/LegacyLineLayout.cpp:
+ (WebCore::LegacyLineLayout::layoutLineBoxes):
+ * rendering/RenderBlock.cpp:
+ (WebCore::RenderBlock::simplifiedNormalFlowLayout):
+ * rendering/RenderIterator.h:
+ (WebCore::RenderIterator::operator bool const):
+ (WebCore::RenderConstIterator::operator bool const):
+ (WebCore::RenderIterator<T>::traverseNextSkippingChildren):
+ (WebCore::RenderConstIterator<T>::traverseNextSkippingChildren):
+
2021-10-01 Kimmo Kinnunen <kkinnu...@apple.com>
Cocoa GraphicsContextGLOpenGL should not be used by GraphicsContextGLCVANGLE
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (283364 => 283365)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2021-10-01 13:19:54 UTC (rev 283364)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2021-10-01 13:41:33 UTC (rev 283365)
@@ -5268,6 +5268,7 @@
E47C39311FE6E10200BBBC6B /* RenderTreeUpdaterGeneratedContent.h in Headers */ = {isa = PBXBuildFile; fileRef = E47C39251FE6E0DB00BBBC6B /* RenderTreeUpdaterGeneratedContent.h */; };
E47C39321FE6E10500BBBC6B /* RenderTreeBuilderList.h in Headers */ = {isa = PBXBuildFile; fileRef = E47C39281FE6E0DD00BBBC6B /* RenderTreeBuilderList.h */; };
E47C39331FE6E10800BBBC6B /* RenderTreeBuilderMultiColumn.h in Headers */ = {isa = PBXBuildFile; fileRef = E47C39271FE6E0DC00BBBC6B /* RenderTreeBuilderMultiColumn.h */; };
+ E47CEBC92706EF5200B8D8F5 /* InlineWalker.h in Headers */ = {isa = PBXBuildFile; fileRef = E47CEBC72706EF5100B8D8F5 /* InlineWalker.h */; };
E47E276516036ED200EE2AFB /* ExtensionStyleSheets.h in Headers */ = {isa = PBXBuildFile; fileRef = E47E276416036ED200EE2AFB /* ExtensionStyleSheets.h */; settings = {ATTRIBUTES = (Private, ); }; };
E47FC8A325B84D72005495FC /* LoadSchedulingMode.h in Headers */ = {isa = PBXBuildFile; fileRef = E47FC8A125B84D71005495FC /* LoadSchedulingMode.h */; settings = {ATTRIBUTES = (Private, ); }; };
E48137B91DB3B526005C59BF /* StyleValidity.h in Headers */ = {isa = PBXBuildFile; fileRef = E48137B81DB3B526005C59BF /* StyleValidity.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -16515,6 +16516,7 @@
E47C392A1FE6E0DE00BBBC6B /* RenderTreeBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderTreeBuilder.h; sourceTree = "<group>"; };
E47C392B1FE6E0DF00BBBC6B /* RenderTreeBuilderList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderTreeBuilderList.cpp; sourceTree = "<group>"; };
E47C392C1FE6E0DF00BBBC6B /* RenderTreeUpdater.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderTreeUpdater.h; sourceTree = "<group>"; };
+ E47CEBC72706EF5100B8D8F5 /* InlineWalker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InlineWalker.h; sourceTree = "<group>"; };
E47E276416036ED200EE2AFB /* ExtensionStyleSheets.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExtensionStyleSheets.h; sourceTree = "<group>"; };
E47E276716036EDC00EE2AFB /* ExtensionStyleSheets.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ExtensionStyleSheets.cpp; sourceTree = "<group>"; };
E47FC8A125B84D71005495FC /* LoadSchedulingMode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LoadSchedulingMode.h; sourceTree = "<group>"; };
@@ -29965,6 +29967,7 @@
E4F819C526FB4EBF0094E162 /* InlineBoxPainter.h */,
930C90DC19CF965300D6C21A /* InlineIterator.cpp */,
BCE789151120D6080060ECE5 /* InlineIterator.h */,
+ E47CEBC72706EF5100B8D8F5 /* InlineWalker.h */,
0FEC120B22BF2CC7004E9D35 /* LayerAncestorClippingStack.cpp */,
0FEC120922BF2CC7004E9D35 /* LayerAncestorClippingStack.h */,
580371631A66F1D300BAF519 /* LayerFragment.h */,
@@ -32990,6 +32993,7 @@
AA4C3A770B2B1679002334A2 /* InlineStyleSheetOwner.h in Headers */,
1C010701192594DF008A4201 /* InlineTextBoxStyle.h in Headers */,
6F1CC1DE225F8B4900720AD2 /* InlineTextItem.h in Headers */,
+ E47CEBC92706EF5200B8D8F5 /* InlineWalker.h in Headers */,
1CE8864126105BF2000C816C /* InMemoryDisplayList.h in Headers */,
2EB767571DA19BDF003E23B5 /* InputEvent.h in Headers */,
E52EFDF42112875A00AD282A /* InputMode.h in Headers */,
Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationBoxTree.cpp (283364 => 283365)
--- trunk/Source/WebCore/layout/integration/LayoutIntegrationBoxTree.cpp 2021-10-01 13:19:54 UTC (rev 283364)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationBoxTree.cpp 2021-10-01 13:41:33 UTC (rev 283365)
@@ -28,7 +28,7 @@
#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
-#include "InlineIterator.h"
+#include "InlineWalker.h"
#include "LayoutContainerBox.h"
#include "LayoutInlineTextBox.h"
#include "LayoutLineBreakBox.h"
@@ -144,8 +144,6 @@
};
for (auto walker = InlineWalker(m_flow); !walker.atEnd(); walker.advance()) {
- if (walker.atEndOfInline())
- continue;
auto& childRenderer = *walker.current();
auto childBox = createChildBox(childRenderer);
appendChild(makeUniqueRefFromNonNullUniquePtr(WTFMove(childBox)), childRenderer);
Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationCoverage.cpp (283364 => 283365)
--- trunk/Source/WebCore/layout/integration/LayoutIntegrationCoverage.cpp 2021-10-01 13:19:54 UTC (rev 283364)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationCoverage.cpp 2021-10-01 13:41:33 UTC (rev 283365)
@@ -647,7 +647,7 @@
SET_REASON_AND_RETURN_IF_NEEDED(FlowHasLineClamp, reasons, includeReasons);
// This currently covers <blockflow>#text</blockflow>, <blockflow>#text<br></blockflow> and mutiple (sibling) RenderText cases.
// The <blockflow><inline>#text</inline></blockflow> case is also popular and should be relatively easy to cover.
- for (auto walker = InlineWalker(const_cast<RenderBlockFlow&>(flow)); !walker.atEnd(); walker.advance()) {
+ for (auto walker = InlineWalker(flow); !walker.atEnd(); walker.advance()) {
if (auto childReasons = canUseForChild(flow, *walker.current(), includeReasons))
ADD_REASONS_AND_RETURN_IF_NEEDED(childReasons, reasons, includeReasons);
}
Modified: trunk/Source/WebCore/rendering/InlineIterator.h (283364 => 283365)
--- trunk/Source/WebCore/rendering/InlineIterator.h 2021-10-01 13:19:54 UTC (rev 283364)
+++ trunk/Source/WebCore/rendering/InlineIterator.h 2021-10-01 13:41:33 UTC (rev 283365)
@@ -199,12 +199,6 @@
return object->isTextOrLineBreak() || object->isFloating() || object->isOutOfFlowPositioned() || object->isReplaced();
}
-// This enum is only used for bidiNextShared()
-enum EmptyInlineBehavior {
- SkipEmptyInlines,
- IncludeEmptyInlines,
-};
-
static bool isEmptyInline(const RenderInline& renderer)
{
for (auto& current : childrenOfType<RenderObject>(renderer)) {
@@ -221,33 +215,19 @@
return true;
}
-// FIXME: This function is misleadingly named. It has little to do with bidi.
-// This function will iterate over inlines within a block, optionally notifying
-// a bidi resolver as it enters/exits inlines (so it can push/pop embedding levels).
template <class Observer>
-static inline RenderObject* bidiNextShared(RenderElement& root, RenderObject* current, Observer* observer = nullptr, EmptyInlineBehavior emptyInlineBehavior = SkipEmptyInlines, bool* endOfInlinePtr = nullptr)
+static inline RenderObject* bidiNextSkippingEmptyInlines(RenderElement& root, RenderObject* current, Observer* observer)
{
RenderObject* next = nullptr;
- // oldEndOfInline denotes if when we last stopped iterating if we were at the end of an inline.
- bool oldEndOfInline = endOfInlinePtr ? *endOfInlinePtr : false;
- bool endOfInline = false;
while (current) {
next = nullptr;
- if (!oldEndOfInline && !isIteratorTarget(current)) {
+ if (!isIteratorTarget(current)) {
next = downcast<RenderElement>(*current).firstChild();
notifyObserverEnteredObject(observer, next);
}
- // We hit this when either current has no children, or when current is not a renderer we care about.
if (!next) {
- // If it is a renderer we care about, and we're doing our inline-walk, return it.
- if (emptyInlineBehavior == IncludeEmptyInlines && !oldEndOfInline && is<RenderInline>(*current)) {
- next = current;
- endOfInline = true;
- break;
- }
-
while (current && current != &root) {
notifyObserverWillExitObject(observer, current);
@@ -258,11 +238,6 @@
}
current = current->parent();
- if (emptyInlineBehavior == IncludeEmptyInlines && current && current != &root && is<RenderInline>(*current)) {
- next = current;
- endOfInline = true;
- break;
- }
}
}
@@ -269,25 +244,14 @@
if (!next)
break;
- if (isIteratorTarget(next)
- || (is<RenderInline>(*next) && (emptyInlineBehavior == IncludeEmptyInlines || isEmptyInline(downcast<RenderInline>(*next)))))
+ if (isIteratorTarget(next) || (is<RenderInline>(*next) && isEmptyInline(downcast<RenderInline>(*next))))
break;
current = next;
}
- if (endOfInlinePtr)
- *endOfInlinePtr = endOfInline;
-
return next;
}
-template <class Observer>
-static inline RenderObject* bidiNextSkippingEmptyInlines(RenderElement& root, RenderObject* current, Observer* observer)
-{
- // The SkipEmptyInlines callers never care about endOfInlinePtr.
- return bidiNextShared(root, current, observer, SkipEmptyInlines);
-}
-
// This makes callers cleaner as they don't have to specify a type for the observer when not providing one.
static inline RenderObject* bidiNextSkippingEmptyInlines(RenderElement& root, RenderObject* current)
{
@@ -295,12 +259,6 @@
return bidiNextSkippingEmptyInlines(root, current, observer);
}
-static inline RenderObject* bidiNextIncludingEmptyInlines(RenderElement& root, RenderObject* current, bool* endOfInlinePtr = nullptr)
-{
- InlineBidiResolver* observer = nullptr; // Callers who include empty inlines, never use an observer.
- return bidiNextShared(root, current, observer, IncludeEmptyInlines, endOfInlinePtr);
-}
-
static inline RenderObject* bidiFirstSkippingEmptyInlines(RenderElement& root, InlineBidiResolver* resolver = nullptr)
{
RenderObject* renderer = root.firstChild();
@@ -328,18 +286,6 @@
return renderer;
}
-// FIXME: This method needs to be renamed when bidiNext finds a good name.
-static inline RenderObject* bidiFirstIncludingEmptyInlines(RenderElement& root)
-{
- RenderObject* o = root.firstChild();
- // If either there are no children to walk, or the first one is correct
- // then just return it.
- if (!o || o->isRenderInline() || isIteratorTarget(o))
- return o;
-
- return bidiNextIncludingEmptyInlines(root, o);
-}
-
inline void InlineIterator::fastIncrementInTextNode()
{
ASSERT(m_renderer);
@@ -373,37 +319,7 @@
m_refersToEndOfPreviousNode = true;
}
-// FIXME: This is used by RenderBlock for simplified layout, and has nothing to do with bidi
-// it shouldn't use functions called bidiFirst and bidiNext.
-class InlineWalker {
-public:
- InlineWalker(RenderElement& root)
- : m_root(root)
- , m_current(nullptr)
- , m_atEndOfInline(false)
- {
- // FIXME: This class should be taught how to do the SkipEmptyInlines codepath as well.
- m_current = bidiFirstIncludingEmptyInlines(m_root);
- }
- RenderElement& root() { return m_root; }
- RenderObject* current() { return m_current; }
-
- bool atEndOfInline() { return m_atEndOfInline; }
- bool atEnd() const { return !m_current; }
-
- RenderObject* advance()
- {
- // FIXME: Support SkipEmptyInlines and observer parameters.
- m_current = bidiNextIncludingEmptyInlines(m_root, m_current, &m_atEndOfInline);
- return m_current;
- }
-private:
- RenderElement& m_root;
- RenderObject* m_current;
- bool m_atEndOfInline;
-};
-
inline void InlineIterator::increment(InlineBidiResolver* resolver)
{
if (!m_renderer)
Added: trunk/Source/WebCore/rendering/InlineWalker.h (0 => 283365)
--- trunk/Source/WebCore/rendering/InlineWalker.h (rev 0)
+++ trunk/Source/WebCore/rendering/InlineWalker.h 2021-10-01 13:41:33 UTC (rev 283365)
@@ -0,0 +1,56 @@
+/*
+ * 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
+
+#include "RenderBlockFlow.h"
+#include "RenderDescendantIterator.h"
+#include "RenderInline.h"
+
+namespace WebCore {
+
+class InlineWalker {
+public:
+ InlineWalker(const RenderBlockFlow& root)
+ : m_iterator(root, root.firstChild())
+ {
+ }
+
+ RenderObject* current() { return m_iterator ? &*m_iterator : nullptr; }
+
+ bool atEnd() const { return !m_iterator; }
+
+ void advance()
+ {
+ if (is<RenderInline>(*m_iterator))
+ m_iterator.traverseNext();
+ else
+ m_iterator.traverseNextSkippingChildren();
+ }
+
+private:
+ RenderDescendantIterator<RenderObject> m_iterator;
+};
+
+} // namespace WebCore
Modified: trunk/Source/WebCore/rendering/LegacyLineLayout.cpp (283364 => 283365)
--- trunk/Source/WebCore/rendering/LegacyLineLayout.cpp 2021-10-01 13:19:54 UTC (rev 283364)
+++ trunk/Source/WebCore/rendering/LegacyLineLayout.cpp 2021-10-01 13:41:33 UTC (rev 283365)
@@ -32,6 +32,7 @@
#include "HTMLParserIdioms.h"
#include "InlineIterator.h"
#include "InlineTextBoxStyle.h"
+#include "InlineWalker.h"
#include "LayoutIntegrationRunIterator.h"
#include "LegacyInlineElementBox.h"
#include "LegacyInlineTextBox.h"
@@ -1767,7 +1768,7 @@
else
box.layoutIfNeeded();
}
- } else if (o.isTextOrLineBreak() || (is<RenderInline>(o) && !walker.atEndOfInline())) {
+ } else if (o.isTextOrLineBreak() || is<RenderInline>(o)) {
if (layoutState.isFullLayout() || o.selfNeedsLayout())
dirtyLineBoxesForRenderer(o, layoutState.isFullLayout());
o.clearNeedsLayout();
Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (283364 => 283365)
--- trunk/Source/WebCore/rendering/RenderBlock.cpp 2021-10-01 13:19:54 UTC (rev 283364)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp 2021-10-01 13:41:33 UTC (rev 283365)
@@ -40,6 +40,7 @@
#include "HitTestResult.h"
#include "ImageBuffer.h"
#include "InlineIterator.h"
+#include "InlineWalker.h"
#include "LayoutRepainter.h"
#include "LegacyInlineElementBox.h"
#include "LegacyInlineTextBox.h"
@@ -874,7 +875,7 @@
{
if (childrenInline()) {
ListHashSet<LegacyRootInlineBox*> lineBoxes;
- for (InlineWalker walker(*this); !walker.atEnd(); walker.advance()) {
+ for (InlineWalker walker(downcast<RenderBlockFlow>(*this)); !walker.atEnd(); walker.advance()) {
RenderObject& renderer = *walker.current();
if (!renderer.isOutOfFlowPositioned() && (renderer.isReplaced() || renderer.isFloating())) {
RenderBox& box = downcast<RenderBox>(renderer);
@@ -881,7 +882,7 @@
box.layoutIfNeeded();
if (box.inlineBoxWrapper())
lineBoxes.add(&box.inlineBoxWrapper()->root());
- } else if (is<RenderText>(renderer) || (is<RenderInline>(renderer) && !walker.atEndOfInline()))
+ } else if (is<RenderText>(renderer) || is<RenderInline>(renderer))
renderer.clearNeedsLayout();
}
Modified: trunk/Source/WebCore/rendering/RenderIterator.h (283364 => 283365)
--- trunk/Source/WebCore/rendering/RenderIterator.h 2021-10-01 13:19:54 UTC (rev 283364)
+++ trunk/Source/WebCore/rendering/RenderIterator.h 2021-10-01 13:41:33 UTC (rev 283365)
@@ -40,11 +40,14 @@
T& operator*();
T* operator->();
+ operator bool() const { return m_current; }
+
bool operator==(const RenderIterator& other) const;
bool operator!=(const RenderIterator& other) const;
RenderIterator& traverseNext();
RenderIterator& traverseNextSibling();
+ RenderIterator& traverseNextSkippingChildren();
RenderIterator& traversePreviousSibling();
RenderIterator& traverseAncestor();
@@ -62,11 +65,14 @@
const T& operator*() const;
const T* operator->() const;
+ operator bool() const { return m_current; }
+
bool operator==(const RenderConstIterator& other) const;
bool operator!=(const RenderConstIterator& other) const;
RenderConstIterator& traverseNext();
RenderConstIterator& traverseNextSibling();
+ RenderConstIterator& traverseNextSkippingChildren();
RenderConstIterator& traversePreviousSibling();
RenderConstIterator& traverseAncestor();
@@ -239,6 +245,14 @@
}
template <typename T>
+inline RenderIterator<T>& RenderIterator<T>::traverseNextSkippingChildren()
+{
+ ASSERT(m_current);
+ m_current = RenderObjectTraversal::nextSkippingChildren(*m_current, m_root);
+ return *this;
+}
+
+template <typename T>
inline RenderIterator<T>& RenderIterator<T>::traversePreviousSibling()
{
ASSERT(m_current);
@@ -315,6 +329,14 @@
}
template <typename T>
+inline RenderConstIterator<T>& RenderConstIterator<T>::traverseNextSkippingChildren()
+{
+ ASSERT(m_current);
+ m_current = RenderObjectTraversal::nextSkippingChildren(*m_current, m_root);
+ return *this;
+}
+
+template <typename T>
inline RenderConstIterator<T>& RenderConstIterator<T>::traversePreviousSibling()
{
ASSERT(m_current);