Diff
Modified: trunk/Source/WebCore/ChangeLog (268123 => 268124)
--- trunk/Source/WebCore/ChangeLog 2020-10-07 15:20:00 UTC (rev 268123)
+++ trunk/Source/WebCore/ChangeLog 2020-10-07 15:47:16 UTC (rev 268124)
@@ -1,3 +1,72 @@
+2020-10-07 Antti Koivisto <an...@apple.com>
+
+ [LFC][Integration] Add line iterator
+ https://bugs.webkit.org/show_bug.cgi?id=217427
+
+ Reviewed by Zalan Bujtas.
+
+ Add line iterator. In this patch it is only used to replace onSameLine function.
+
+ * Sources.txt:
+ * WebCore.xcodeproj/project.pbxproj:
+ * dom/Position.cpp:
+ (WebCore::Position::rendersInDifferentPosition const):
+ * layout/integration/LayoutIntegrationLineIterator.cpp: Added.
+ (WebCore::LayoutIntegration::LineIterator::LineIterator):
+ (WebCore::LayoutIntegration::LineIterator::atEnd const):
+ (WebCore::LayoutIntegration::LineIterator::next const):
+ (WebCore::LayoutIntegration::LineIterator::previous const):
+ (WebCore::LayoutIntegration::LineIterator::traverseNext):
+ (WebCore::LayoutIntegration::LineIterator::traversePrevious):
+ * layout/integration/LayoutIntegrationLineIterator.h: Added.
+ (WebCore::LayoutIntegration::PathLine::operator!= const):
+ (WebCore::LayoutIntegration::LineIterator::LineIterator):
+ (WebCore::LayoutIntegration::LineIterator::operator++):
+ (WebCore::LayoutIntegration::LineIterator::operator bool const):
+ (WebCore::LayoutIntegration::LineIterator::operator== const):
+ (WebCore::LayoutIntegration::LineIterator::operator!= const):
+ (WebCore::LayoutIntegration::LineIterator::operator* const):
+ (WebCore::LayoutIntegration::LineIterator::operator-> const):
+ (WebCore::LayoutIntegration::PathLine::PathLine):
+ (WebCore::LayoutIntegration::PathLine::rect const):
+ (WebCore::LayoutIntegration::PathLine::operator== const):
+ * layout/integration/LayoutIntegrationLineIteratorLegacyPath.h: Added.
+ (WebCore::LayoutIntegration::LegacyLinePath::LegacyLinePath):
+ (WebCore::LayoutIntegration::LegacyLinePath::rect const):
+ (WebCore::LayoutIntegration::LegacyLinePath::traverseNext):
+ (WebCore::LayoutIntegration::LegacyLinePath::traversePrevious):
+ (WebCore::LayoutIntegration::LegacyLinePath::operator== const):
+ (WebCore::LayoutIntegration::LegacyLinePath::atEnd const):
+ (WebCore::LayoutIntegration::LegacyLinePath::setAtEnd):
+ * layout/integration/LayoutIntegrationLineIteratorModernPath.h: Added.
+ (WebCore::LayoutIntegration::ModernLinePath::ModernLinePath):
+ (WebCore::LayoutIntegration::ModernLinePath::rect const):
+ (WebCore::LayoutIntegration::ModernLinePath::traverseNext):
+ (WebCore::LayoutIntegration::ModernLinePath::traversePrevious):
+ (WebCore::LayoutIntegration::ModernLinePath::operator== const):
+ (WebCore::LayoutIntegration::ModernLinePath::atEnd const):
+ (WebCore::LayoutIntegration::ModernLinePath::setAtEnd):
+ (WebCore::LayoutIntegration::ModernLinePath::lines const):
+ (WebCore::LayoutIntegration::ModernLinePath::line const):
+ * layout/integration/LayoutIntegrationRunIterator.cpp:
+ (WebCore::LayoutIntegration::RunIterator::line const):
+ * layout/integration/LayoutIntegrationRunIterator.h:
+ (WebCore::LayoutIntegration::PathRun::logicalLeft const):
+ (WebCore::LayoutIntegration::PathRun::logicalRight const):
+ (WebCore::LayoutIntegration::PathRun::logicalWidth const):
+ (WebCore::LayoutIntegration::PathRun::logicalHeight const):
+ (WebCore::LayoutIntegration::PathRun::onSameLine const): Deleted.
+ * layout/integration/LayoutIntegrationRunIteratorLegacyPath.h:
+ (WebCore::LayoutIntegration::LegacyPath::operator== const):
+ (WebCore::LayoutIntegration::LegacyPath::rootInlineBox const):
+ (WebCore::LayoutIntegration::LegacyPath::onSameLine const): Deleted.
+ * layout/integration/LayoutIntegrationRunIteratorModernPath.h:
+ (WebCore::LayoutIntegration::verticallyRoundedRect):
+ (WebCore::LayoutIntegration::ModernPath::rect const):
+ (WebCore::LayoutIntegration::ModernPath::operator== const):
+ (WebCore::LayoutIntegration::linePosition): Deleted.
+ (WebCore::LayoutIntegration::ModernPath::onSameLine const): Deleted.
+
2020-10-07 Zalan Bujtas <za...@apple.com>
[LFC][IFC] Add initial support for inline content to clear intrusive floats
Modified: trunk/Source/WebCore/Headers.cmake (268123 => 268124)
--- trunk/Source/WebCore/Headers.cmake 2020-10-07 15:20:00 UTC (rev 268123)
+++ trunk/Source/WebCore/Headers.cmake 2020-10-07 15:47:16 UTC (rev 268124)
@@ -709,11 +709,13 @@
layout/integration/LayoutIntegrationInlineContent.h
layout/integration/LayoutIntegrationLine.h
+ layout/integration/LayoutIntegrationLineIterator.h
+ layout/integration/LayoutIntegrationLineIteratorLegacyPath.h
+ layout/integration/LayoutIntegrationLineIteratorModernPath.h
layout/integration/LayoutIntegrationRun.h
layout/integration/LayoutIntegrationRunIterator.h
layout/integration/LayoutIntegrationRunIteratorLegacyPath.h
layout/integration/LayoutIntegrationRunIteratorModernPath.h
-
layout/layouttree/LayoutBox.h
loader/AdClickAttribution.h
Modified: trunk/Source/WebCore/Sources.txt (268123 => 268124)
--- trunk/Source/WebCore/Sources.txt 2020-10-07 15:20:00 UTC (rev 268123)
+++ trunk/Source/WebCore/Sources.txt 2020-10-07 15:47:16 UTC (rev 268124)
@@ -1474,6 +1474,7 @@
layout/integration/LayoutIntegrationBoxTree.cpp
layout/integration/LayoutIntegrationCoverage.cpp
layout/integration/LayoutIntegrationInlineContent.cpp
+layout/integration/LayoutIntegrationLineIterator.cpp
layout/integration/LayoutIntegrationLineLayout.cpp
layout/integration/LayoutIntegrationPagination.cpp
layout/integration/LayoutIntegrationRunIterator.cpp
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (268123 => 268124)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2020-10-07 15:20:00 UTC (rev 268123)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2020-10-07 15:47:16 UTC (rev 268124)
@@ -5083,6 +5083,9 @@
E4C91A0E1802343100A17F6D /* TextPaintStyle.h in Headers */ = {isa = PBXBuildFile; fileRef = E4C91A0D1802343100A17F6D /* TextPaintStyle.h */; };
E4C91A16180999F100A17F6D /* RenderTextLineBoxes.h in Headers */ = {isa = PBXBuildFile; fileRef = E4C91A15180999F100A17F6D /* RenderTextLineBoxes.h */; settings = {ATTRIBUTES = (Private, ); }; };
E4D33F3B252AEECD00837D05 /* InlineRunAndOffset.h in Headers */ = {isa = PBXBuildFile; fileRef = E4D33F39252AEECC00837D05 /* InlineRunAndOffset.h */; };
+ E4D33F41252C4B8300837D05 /* LayoutIntegrationLineIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = E4D33F3F252C4B8200837D05 /* LayoutIntegrationLineIterator.h */; };
+ E4D33F44252C50E200837D05 /* LayoutIntegrationLineIteratorLegacyPath.h in Headers */ = {isa = PBXBuildFile; fileRef = E4D33F43252C50E200837D05 /* LayoutIntegrationLineIteratorLegacyPath.h */; };
+ E4D33F46252C50FC00837D05 /* LayoutIntegrationLineIteratorModernPath.h in Headers */ = {isa = PBXBuildFile; fileRef = E4D33F45252C50FB00837D05 /* LayoutIntegrationLineIteratorModernPath.h */; };
E4D58EB517B4DBDC00CBDCA8 /* StyleResolveForDocument.h in Headers */ = {isa = PBXBuildFile; fileRef = E4D58EB317B4DBDC00CBDCA8 /* StyleResolveForDocument.h */; };
E4D58EB917B4ED8900CBDCA8 /* StyleFontSizeFunctions.h in Headers */ = {isa = PBXBuildFile; fileRef = E4D58EB717B4ED8900CBDCA8 /* StyleFontSizeFunctions.h */; };
E4D58EBB17B8F12800CBDCA8 /* ElementTraversal.h in Headers */ = {isa = PBXBuildFile; fileRef = E4D58EBA17B8F12800CBDCA8 /* ElementTraversal.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -16081,6 +16084,10 @@
E4C91A15180999F100A17F6D /* RenderTextLineBoxes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderTextLineBoxes.h; sourceTree = "<group>"; };
E4C91A17180999FB00A17F6D /* RenderTextLineBoxes.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderTextLineBoxes.cpp; sourceTree = "<group>"; };
E4D33F39252AEECC00837D05 /* InlineRunAndOffset.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InlineRunAndOffset.h; sourceTree = "<group>"; };
+ E4D33F3F252C4B8200837D05 /* LayoutIntegrationLineIterator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LayoutIntegrationLineIterator.h; sourceTree = "<group>"; };
+ E4D33F42252C50A800837D05 /* LayoutIntegrationLineIterator.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = LayoutIntegrationLineIterator.cpp; sourceTree = "<group>"; };
+ E4D33F43252C50E200837D05 /* LayoutIntegrationLineIteratorLegacyPath.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LayoutIntegrationLineIteratorLegacyPath.h; sourceTree = "<group>"; };
+ E4D33F45252C50FB00837D05 /* LayoutIntegrationLineIteratorModernPath.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LayoutIntegrationLineIteratorModernPath.h; sourceTree = "<group>"; };
E4D58EB217B4DBDC00CBDCA8 /* StyleResolveForDocument.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StyleResolveForDocument.cpp; sourceTree = "<group>"; };
E4D58EB317B4DBDC00CBDCA8 /* StyleResolveForDocument.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StyleResolveForDocument.h; sourceTree = "<group>"; };
E4D58EB617B4ED8900CBDCA8 /* StyleFontSizeFunctions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StyleFontSizeFunctions.cpp; sourceTree = "<group>"; };
@@ -28566,6 +28573,8 @@
E4FB4B35239BEB10003C336A /* LayoutIntegrationInlineContent.cpp */,
E451C6332394058E00993190 /* LayoutIntegrationInlineContent.h */,
6FB47E612277425A00C7BCB0 /* LayoutIntegrationLine.h */,
+ E4D33F42252C50A800837D05 /* LayoutIntegrationLineIterator.cpp */,
+ E4D33F3F252C4B8200837D05 /* LayoutIntegrationLineIterator.h */,
E4ABABDE2360893D00FA4345 /* LayoutIntegrationLineLayout.cpp */,
E4ABABDB236088FD00FA4345 /* LayoutIntegrationLineLayout.h */,
E4312AB524B3265600678349 /* LayoutIntegrationPagination.cpp */,
@@ -28573,6 +28582,8 @@
6FCE1A1822618AB3004F0343 /* LayoutIntegrationRun.h */,
E4A664C72521B779007081DC /* LayoutIntegrationRunIterator.cpp */,
E4A664C62521B778007081DC /* LayoutIntegrationRunIterator.h */,
+ E4D33F43252C50E200837D05 /* LayoutIntegrationLineIteratorLegacyPath.h */,
+ E4D33F45252C50FB00837D05 /* LayoutIntegrationLineIteratorModernPath.h */,
E4A664C52521B778007081DC /* LayoutIntegrationRunIteratorLegacyPath.h */,
E4A664C42521B777007081DC /* LayoutIntegrationRunIteratorModernPath.h */,
);
@@ -31536,6 +31547,7 @@
371F4FFC0D25E7F300ECE0D5 /* FontRanges.h in Headers */,
C2AB0AF71E6B3C6C001348C5 /* FontSelectionAlgorithm.h in Headers */,
B2C3DA6B0D006CD600EF6F26 /* FontSelector.h in Headers */,
+ E4D33F46252C50FC00837D05 /* LayoutIntegrationLineIteratorModernPath.h in Headers */,
E419041F1CC6486B00C35F5D /* FontSelectorClient.h in Headers */,
F48D2A6C215623B400C6752B /* FontShadow.h in Headers */,
4A6E9FC813C17D570046A7F8 /* FontTaggedSettings.h in Headers */,
@@ -33027,6 +33039,7 @@
49D5DC2C0F423A73008F20FD /* Matrix3DTransformOperation.h in Headers */,
49E911C70EF86D47009D0CAF /* MatrixTransformOperation.h in Headers */,
5CBC8DAD1AAA302200E1C803 /* MediaAccessibilitySoftLink.h in Headers */,
+ E4D33F41252C4B8300837D05 /* LayoutIntegrationLineIterator.h in Headers */,
931BCC611124DFCB00BE70DD /* MediaCanStartListener.h in Headers */,
CDCC9BCF22387E9A00FFB51C /* MediaCapabilitiesDecodingInfo.h in Headers */,
CDCC9BD122387EAA00FFB51C /* MediaCapabilitiesEncodingInfo.h in Headers */,
@@ -34509,6 +34522,7 @@
0F1A0C38229A481800D37ADB /* VelocityData.h in Headers */,
DF4E38E025279595002A7481 /* VersionChecks.h in Headers */,
BCA257151293C010007A263D /* VerticalPositionCache.h in Headers */,
+ E4D33F44252C50E200837D05 /* LayoutIntegrationLineIteratorLegacyPath.h in Headers */,
52B0D4C01C57FD660077CE53 /* VideoFullscreenChangeObserver.h in Headers */,
3FBC4AF4189881560046EE38 /* VideoFullscreenInterfaceAVKit.h in Headers */,
52B0D4C21C57FF910077CE53 /* VideoFullscreenInterfaceMac.h in Headers */,
Modified: trunk/Source/WebCore/dom/Position.cpp (268123 => 268124)
--- trunk/Source/WebCore/dom/Position.cpp 2020-10-07 15:20:00 UTC (rev 268123)
+++ trunk/Source/WebCore/dom/Position.cpp 2020-10-07 15:47:16 UTC (rev 268124)
@@ -39,6 +39,7 @@
#include "InlineIterator.h"
#include "InlineRunAndOffset.h"
#include "InlineTextBox.h"
+#include "LayoutIntegrationLineIterator.h"
#include "LayoutIntegrationRunIterator.h"
#include "Logging.h"
#include "NodeTraversal.h"
@@ -1086,7 +1087,7 @@
if (!run1 || !run2)
return false;
- if (!run1->onSameLine(*run2))
+ if (run1.line() != run2.line())
return true;
if (nextRenderedEditable(deprecatedNode()) == position.deprecatedNode()
Added: trunk/Source/WebCore/layout/integration/LayoutIntegrationLineIterator.cpp (0 => 268124)
--- trunk/Source/WebCore/layout/integration/LayoutIntegrationLineIterator.cpp (rev 0)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationLineIterator.cpp 2020-10-07 15:47:16 UTC (rev 268124)
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2020 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 "LayoutIntegrationLineIterator.h"
+
+#include "LayoutIntegrationLineLayout.h"
+
+namespace WebCore {
+namespace LayoutIntegration {
+
+LineIterator::LineIterator(PathLine::PathVariant&& pathVariant)
+ : m_line(WTFMove(pathVariant))
+{
+}
+
+bool LineIterator::atEnd() const
+{
+ return WTF::switchOn(m_line.m_pathVariant, [](auto& path) {
+ return path.atEnd();
+ });
+}
+
+LineIterator LineIterator::next() const
+{
+ return LineIterator(*this).traverseNext();
+}
+
+LineIterator LineIterator::previous() const
+{
+ return LineIterator(*this).traversePrevious();
+}
+
+LineIterator& LineIterator::traverseNext()
+{
+ WTF::switchOn(m_line.m_pathVariant, [](auto& path) {
+ return path.traverseNext();
+ });
+ return *this;
+}
+
+LineIterator& LineIterator::traversePrevious()
+{
+ WTF::switchOn(m_line.m_pathVariant, [](auto& path) {
+ return path.traversePrevious();
+ });
+ return *this;
+}
+
+}
+}
+
Added: trunk/Source/WebCore/layout/integration/LayoutIntegrationLineIterator.h (0 => 268124)
--- trunk/Source/WebCore/layout/integration/LayoutIntegrationLineIterator.h (rev 0)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationLineIterator.h 2020-10-07 15:47:16 UTC (rev 268124)
@@ -0,0 +1,120 @@
+/*
+ * Copyright (C) 2020 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 "LayoutIntegrationLineIteratorLegacyPath.h"
+#include "LayoutIntegrationLineIteratorModernPath.h"
+#include <wtf/Variant.h>
+
+namespace WebCore {
+
+namespace LayoutIntegration {
+
+class LineIterator;
+class PathIterator;
+
+struct EndLineIterator { };
+
+class PathLine {
+public:
+ using PathVariant = Variant<
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+ ModernLinePath,
+#endif
+ LegacyLinePath
+ >;
+
+ PathLine(PathVariant&&);
+
+ FloatRect rect() const;
+
+ bool operator==(const PathLine&) const;
+ bool operator!=(const PathLine& other) const { return !(*this == other); }
+
+protected:
+ friend class LineIterator;
+
+ PathVariant m_pathVariant;
+};
+
+class LineIterator {
+public:
+ LineIterator() : m_line(LegacyLinePath { nullptr }) { };
+ LineIterator(PathLine::PathVariant&&);
+
+ LineIterator& operator++() { return traverseNext(); }
+ LineIterator& traverseNext();
+ LineIterator& traversePrevious();
+
+ LineIterator next() const;
+ LineIterator previous() const;
+
+ explicit operator bool() const { return !atEnd(); }
+
+ bool operator==(const LineIterator& other) const { return m_line == other.m_line; }
+ bool operator!=(const LineIterator& other) const { return m_line != other.m_line; }
+
+ bool operator==(EndLineIterator) const { return atEnd(); }
+ bool operator!=(EndLineIterator) const { return !atEnd(); }
+
+ const PathLine& operator*() const { return m_line; }
+ const PathLine* operator->() const { return &m_line; }
+
+ bool atEnd() const;
+
+private:
+ PathLine m_line;
+};
+
+LineIterator lineFor(const PathIterator&);
+
+// -----------------------------------------------
+
+inline PathLine::PathLine(PathVariant&& path)
+ : m_pathVariant(WTFMove(path))
+{
+}
+
+inline FloatRect PathLine::rect() const
+{
+ return WTF::switchOn(m_pathVariant, [](auto& path) {
+ return path.rect();
+ });
+}
+
+inline bool PathLine::operator==(const PathLine& other) const
+{
+ if (m_pathVariant.index() != other.m_pathVariant.index())
+ return false;
+
+ return WTF::switchOn(m_pathVariant, [&](const auto& path) {
+ return path == WTF::get<std::decay_t<decltype(path)>>(other.m_pathVariant);
+ });
+}
+
+}
+}
+
Added: trunk/Source/WebCore/layout/integration/LayoutIntegrationLineIteratorLegacyPath.h (0 => 268124)
--- trunk/Source/WebCore/layout/integration/LayoutIntegrationLineIteratorLegacyPath.h (rev 0)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationLineIteratorLegacyPath.h 2020-10-07 15:47:16 UTC (rev 268124)
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2020 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 "LayoutIntegrationInlineContent.h"
+#include "RootInlineBox.h"
+
+namespace WebCore {
+
+namespace LayoutIntegration {
+
+class LegacyLinePath {
+public:
+ LegacyLinePath(const RootInlineBox* rootInlineBox)
+ : m_rootInlineBox(rootInlineBox)
+ {
+ }
+ LegacyLinePath(LegacyLinePath&&) = default;
+ LegacyLinePath(const LegacyLinePath&) = default;
+ LegacyLinePath& operator=(const LegacyLinePath&) = default;
+ LegacyLinePath& operator=(LegacyLinePath&&) = default;
+
+ FloatRect rect() const { return m_rootInlineBox->frameRect(); }
+
+ void traverseNext()
+ {
+ m_rootInlineBox = m_rootInlineBox->nextRootBox();
+ }
+
+ void traversePrevious()
+ {
+ m_rootInlineBox = m_rootInlineBox->prevRootBox();
+ }
+
+ bool operator==(const LegacyLinePath& other) const { return m_rootInlineBox == other.m_rootInlineBox; }
+
+ bool atEnd() const { return !m_rootInlineBox; }
+ void setAtEnd() { m_rootInlineBox = nullptr; }
+
+private:
+
+ const RootInlineBox* m_rootInlineBox;
+};
+
+}
+}
Added: trunk/Source/WebCore/layout/integration/LayoutIntegrationLineIteratorModernPath.h (0 => 268124)
--- trunk/Source/WebCore/layout/integration/LayoutIntegrationLineIteratorModernPath.h (rev 0)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationLineIteratorModernPath.h 2020-10-07 15:47:16 UTC (rev 268124)
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2020 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 "LayoutIntegrationInlineContent.h"
+#include "LayoutIntegrationRunIteratorModernPath.h"
+
+namespace WebCore {
+
+namespace LayoutIntegration {
+
+class ModernLinePath {
+public:
+ ModernLinePath(const InlineContent& inlineContent, size_t lineIndex)
+ : m_inlineContent(&inlineContent)
+ , m_lineIndex(lineIndex)
+ {
+ ASSERT(lineIndex <= lines().size());
+ }
+ ModernLinePath(ModernLinePath&&) = default;
+ ModernLinePath(const ModernLinePath&) = default;
+ ModernLinePath& operator=(const ModernLinePath&) = default;
+ ModernLinePath& operator=(ModernLinePath&&) = default;
+
+ FloatRect rect() const { return verticallyRoundedRect(line().rect()); }
+
+ void traverseNext()
+ {
+ ASSERT(!atEnd());
+
+ ++m_lineIndex;
+ }
+
+ void traversePrevious()
+ {
+ ASSERT(!atEnd());
+ ASSERT(m_lineIndex);
+
+ --m_lineIndex;
+ }
+
+ bool operator==(const ModernLinePath& other) const { return m_inlineContent == other.m_inlineContent && m_lineIndex == other.m_lineIndex; }
+
+ bool atEnd() const { return m_lineIndex == lines().size(); }
+ void setAtEnd() { m_lineIndex = lines().size(); }
+
+private:
+ const InlineContent::Lines& lines() const { return m_inlineContent->lines; }
+ const Line& line() const { return lines()[m_lineIndex]; }
+
+ RefPtr<const InlineContent> m_inlineContent;
+ size_t m_lineIndex { 0 };
+};
+
+}
+}
+
+#endif
+
Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIterator.cpp (268123 => 268124)
--- trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIterator.cpp 2020-10-07 15:20:00 UTC (rev 268123)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIterator.cpp 2020-10-07 15:47:16 UTC (rev 268124)
@@ -26,6 +26,8 @@
#include "config.h"
#include "LayoutIntegrationRunIterator.h"
+
+#include "LayoutIntegrationLineIterator.h"
#include "LayoutIntegrationLineLayout.h"
#include "RenderBlockFlow.h"
#include "RenderLineBreak.h"
@@ -82,6 +84,19 @@
return LineRunIterator(*this).traversePreviousOnLineIgnoringLineBreak();
}
+LineIterator RunIterator::line() const
+{
+ return WTF::switchOn(m_run.m_pathVariant, [](const LegacyPath& path) {
+ return LineIterator(LegacyLinePath(&path.rootInlineBox()));
+ }
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+ , [](const ModernPath& path) {
+ return LineIterator(ModernLinePath(*path.m_inlineContent, path.run().lineIndex()));
+ }
+#endif
+ );
+}
+
TextRunIterator::TextRunIterator(PathRun::PathVariant&& pathVariant)
: RunIterator(WTFMove(pathVariant))
{
Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIterator.h (268123 => 268124)
--- trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIterator.h 2020-10-07 15:20:00 UTC (rev 268123)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIterator.h 2020-10-07 15:47:16 UTC (rev 268124)
@@ -38,6 +38,7 @@
namespace LayoutIntegration {
+class LineIterator;
class LineRunIterator;
class TextRunIterator;
@@ -58,6 +59,11 @@
FloatRect rect() const;
+ float logicalLeft() const { return isHorizontal() ? rect().x() : rect().y(); }
+ float logicalRight() const { return isHorizontal() ? rect().maxX() : rect().maxY(); }
+ float logicalWidth() const { return isHorizontal() ? rect().width() : rect().height(); }
+ float logicalHeight() const { return isHorizontal() ? rect().height() : rect().width(); }
+
float baseline() const;
bool isHorizontal() const;
@@ -74,8 +80,6 @@
TextDirection direction() const { return bidiLevel() % 2 ? TextDirection::RTL : TextDirection::LTR; }
bool isLeftToRightDirection() const { return direction() == TextDirection::LTR; }
- bool onSameLine(const PathRun&) const;
-
const RenderObject& renderer() const;
// For intermediate porting steps only.
@@ -136,6 +140,8 @@
LineRunIterator nextOnLineIgnoringLineBreak() const;
LineRunIterator previousOnLineIgnoringLineBreak() const;
+ LineIterator line() const;
+
protected:
void setAtEnd();
@@ -274,16 +280,6 @@
});
}
-inline bool PathRun::onSameLine(const PathRun& other) const
-{
- if (m_pathVariant.index() != other.m_pathVariant.index())
- return false;
-
- return WTF::switchOn(m_pathVariant, [&](const auto& path) {
- return path.onSameLine(WTF::get<std::decay_t<decltype(path)>>(other.m_pathVariant));
- });
-}
-
inline const RenderObject& PathRun::renderer() const
{
return WTF::switchOn(m_pathVariant, [](auto& path) -> const RenderObject& {
Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIteratorLegacyPath.h (268123 => 268124)
--- trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIteratorLegacyPath.h 2020-10-07 15:20:00 UTC (rev 268123)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIteratorLegacyPath.h 2020-10-07 15:47:16 UTC (rev 268124)
@@ -96,12 +96,12 @@
}
bool operator==(const LegacyPath& other) const { return m_inlineBox == other.m_inlineBox; }
- bool onSameLine(const LegacyPath& other) const { return &m_inlineBox->root() == &other.m_inlineBox->root(); }
bool atEnd() const { return !m_inlineBox; }
void setAtEnd() { m_inlineBox = nullptr; }
InlineBox* legacyInlineBox() const { return const_cast<InlineBox*>(m_inlineBox); }
+ const RootInlineBox& rootInlineBox() const { return m_inlineBox->root(); }
private:
const InlineTextBox* inlineTextBox() const { return downcast<InlineTextBox>(m_inlineBox); }
Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIteratorModernPath.h (268123 => 268124)
--- trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIteratorModernPath.h 2020-10-07 15:20:00 UTC (rev 268123)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIteratorModernPath.h 2020-10-07 15:47:16 UTC (rev 268124)
@@ -33,9 +33,9 @@
namespace LayoutIntegration {
-static FloatPoint linePosition(float left, float top)
+inline FloatRect verticallyRoundedRect(const FloatRect& rect)
{
- return FloatPoint(left, roundf(top));
+ return { FloatPoint(rect.x(), roundf(rect.y())), rect.size() };
}
class ModernPath {
@@ -53,7 +53,7 @@
bool isText() const { return !!run().textContent(); }
- FloatRect rect() const;
+ FloatRect rect() const { return verticallyRoundedRect(run().rect()); }
float baseline() const { return line().baseline(); }
@@ -149,7 +149,6 @@
}
bool operator==(const ModernPath& other) const { return m_inlineContent == other.m_inlineContent && m_runIndex == other.m_runIndex; }
- bool onSameLine(const ModernPath& other) const { return run().lineIndex() == other.run().lineIndex(); }
bool atEnd() const { return m_runIndex == runs().size() || !run().hasUnderlyingLayout(); }
void setAtEnd() { m_runIndex = runs().size(); }
@@ -161,6 +160,8 @@
}
private:
+ friend class RunIterator;
+
const InlineContent::Runs& runs() const { return m_inlineContent->runs; }
const Run& run() const { return runs()[m_runIndex]; }
const Line& line() const { return m_inlineContent->lineForRun(run()); }
@@ -169,14 +170,7 @@
size_t m_runIndex { 0 };
};
-inline FloatRect ModernPath::rect() const
-{
- auto rect = run().rect();
- auto position = linePosition(rect.x(), rect.y());
- return { position, rect.size() };
}
-
}
-}
#endif