Diff
Modified: trunk/Source/WebCore/ChangeLog (253253 => 253254)
--- trunk/Source/WebCore/ChangeLog 2019-12-07 14:49:50 UTC (rev 253253)
+++ trunk/Source/WebCore/ChangeLog 2019-12-07 15:21:02 UTC (rev 253254)
@@ -1,3 +1,36 @@
+2019-12-07 Antti Koivisto <[email protected]>
+
+ [LFC][IFC] Move LineBox to Display namespace
+ https://bugs.webkit.org/show_bug.cgi?id=204984
+
+ Reviewed by Zalan Bujtas.
+
+ It is a display type, like Display::Run.
+
+ * Sources.txt:
+ * WebCore.xcodeproj/project.pbxproj:
+ * layout/displaytree/DisplayInlineContent.cpp: Added.
+
+ Also added a cpp for Display::InlineContent.
+
+ (WebCore::Display:: const):
+ * layout/displaytree/DisplayInlineContent.h:
+ (WebCore::Display::InlineContent::lineBoxForRun const):
+ (WebCore::Display:: const): Deleted.
+ * layout/displaytree/DisplayLineBox.h: Renamed from Source/WebCore/layout/inlineformatting/InlineLineBox.h.
+ (WebCore::Display::LineBox::LineBox):
+ * layout/inlineformatting/InlineFormattingContext.cpp:
+ (WebCore::Layout::InlineFormattingContext::setDisplayBoxesForLine):
+ * layout/inlineformatting/InlineFormattingContextQuirks.cpp:
+ (WebCore::Layout::InlineFormattingContext::Quirks::lineHeightConstraints const):
+ * layout/inlineformatting/InlineFormattingState.h:
+ * layout/inlineformatting/InlineLineBuilder.cpp:
+ (WebCore::Layout::LineBuilder::initialize):
+ (WebCore::Layout::LineBuilder::halfLeadingMetrics):
+ * layout/inlineformatting/InlineLineBuilder.h:
+ (WebCore::Layout::LineBuilder::lineBox const):
+ * layout/inlineformatting/LineLayoutContext.h:
+
2019-12-07 Zalan Bujtas <[email protected]>
[LFC][IFC] Add support for breaking at previous breaking opportunities when the overflown content is unbreakable
Modified: trunk/Source/WebCore/Sources.txt (253253 => 253254)
--- trunk/Source/WebCore/Sources.txt 2019-12-07 14:49:50 UTC (rev 253253)
+++ trunk/Source/WebCore/Sources.txt 2019-12-07 15:21:02 UTC (rev 253254)
@@ -1432,6 +1432,7 @@
layout/blockformatting/BlockFormattingState.cpp
layout/blockformatting/BlockMarginCollapse.cpp
layout/displaytree/DisplayBox.cpp
+layout/displaytree/DisplayInlineContent.cpp
layout/displaytree/DisplayPainter.cpp
layout/floats/FloatAvoider.cpp
layout/floats/FloatBox.cpp
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (253253 => 253254)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2019-12-07 14:49:50 UTC (rev 253253)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2019-12-07 15:21:02 UTC (rev 253254)
@@ -2049,7 +2049,7 @@
6F995A3A1A70833700A735F4 /* JSWebGLVertexArrayObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 6F995A301A70833700A735F4 /* JSWebGLVertexArrayObject.h */; };
6FA4454E898F2FC168BC38C1 /* JSBeforeUnloadEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 29E04A27BED2F81F98E9022B /* JSBeforeUnloadEvent.h */; };
6FB11B5C21783FD000E2A574 /* TextUtil.h in Headers */ = {isa = PBXBuildFile; fileRef = 6FB11B5921783FCF00E2A574 /* TextUtil.h */; settings = {ATTRIBUTES = (Private, ); }; };
- 6FB47E632277425A00C7BCB0 /* InlineLineBox.h in Headers */ = {isa = PBXBuildFile; fileRef = 6FB47E612277425A00C7BCB0 /* InlineLineBox.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 6FB47E632277425A00C7BCB0 /* DisplayLineBox.h in Headers */ = {isa = PBXBuildFile; fileRef = 6FB47E612277425A00C7BCB0 /* DisplayLineBox.h */; settings = {ATTRIBUTES = (Private, ); }; };
6FB5E214221F2453003989CF /* ContentChangeObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = 6FB5E212221F2447003989CF /* ContentChangeObserver.h */; settings = {ATTRIBUTES = (Private, ); }; };
6FCE1A1A22618ABD004F0343 /* DisplayRun.h in Headers */ = {isa = PBXBuildFile; fileRef = 6FCE1A1822618AB3004F0343 /* DisplayRun.h */; settings = {ATTRIBUTES = (Private, ); }; };
6FD9CD54227E21C800E53957 /* DisplayRect.h in Headers */ = {isa = PBXBuildFile; fileRef = 6FD9CD52227E21C800E53957 /* DisplayRect.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -9333,7 +9333,7 @@
6FB11B5921783FCF00E2A574 /* TextUtil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextUtil.h; sourceTree = "<group>"; };
6FB11B5B21783FCF00E2A574 /* TextUtil.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextUtil.cpp; sourceTree = "<group>"; };
6FB22E30230097E300C20866 /* TableGrid.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TableGrid.h; sourceTree = "<group>"; };
- 6FB47E612277425A00C7BCB0 /* InlineLineBox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InlineLineBox.h; sourceTree = "<group>"; };
+ 6FB47E612277425A00C7BCB0 /* DisplayLineBox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DisplayLineBox.h; sourceTree = "<group>"; };
6FB5E212221F2447003989CF /* ContentChangeObserver.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ContentChangeObserver.h; sourceTree = "<group>"; };
6FBB860520B464B600DAD938 /* FormattingContextGeometry.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = FormattingContextGeometry.cpp; sourceTree = "<group>"; };
6FC5CA9222E3599300B13E11 /* TableFormattingState.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = TableFormattingState.cpp; sourceTree = "<group>"; };
@@ -15324,6 +15324,7 @@
E4E9B11C1814569C003ACCDF /* SimpleLineLayoutFunctions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SimpleLineLayoutFunctions.h; sourceTree = "<group>"; };
E4F9EEF0156D84C400D23E7E /* StyleSheetContents.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StyleSheetContents.cpp; sourceTree = "<group>"; };
E4F9EEF1156D84C400D23E7E /* StyleSheetContents.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StyleSheetContents.h; sourceTree = "<group>"; };
+ E4FB4B35239BEB10003C336A /* DisplayInlineContent.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DisplayInlineContent.cpp; sourceTree = "<group>"; };
E516698F20FF9916009D2C27 /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "[email protected]"; sourceTree = "<group>"; };
E517670220B88C1400D41167 /* DataListSuggestionInformation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DataListSuggestionInformation.h; sourceTree = "<group>"; };
E51A81DE17298D7700BFCA61 /* JSPerformance.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSPerformance.cpp; sourceTree = "<group>"; };
@@ -16724,7 +16725,6 @@
115CFA7C208B8E10001E6991 /* InlineFormattingState.h */,
6F7B8CEC23626E6600C9FF15 /* InlineItem.cpp */,
6FE7CFA02177EEF1005B1573 /* InlineItem.h */,
- 6FB47E612277425A00C7BCB0 /* InlineLineBox.h */,
6FE198132178397B00446F08 /* InlineLineBreaker.cpp */,
6FE198152178397C00446F08 /* InlineLineBreaker.h */,
6F0CD692229ED31900C5994E /* InlineLineBuilder.cpp */,
@@ -16743,7 +16743,9 @@
children = (
1199FA5A208E3C7F002358CC /* DisplayBox.cpp */,
1199FA59208E3C7F002358CC /* DisplayBox.h */,
+ E4FB4B35239BEB10003C336A /* DisplayInlineContent.cpp */,
E451C6332394058E00993190 /* DisplayInlineContent.h */,
+ 6FB47E612277425A00C7BCB0 /* DisplayLineBox.h */,
6F77868523491AC6004D9636 /* DisplayPainter.cpp */,
6F77868723491AD7004D9636 /* DisplayPainter.h */,
6FD9CD52227E21C800E53957 /* DisplayRect.h */,
@@ -30260,7 +30262,7 @@
115CFA7E208B8E10001E6991 /* InlineFormattingState.h in Headers */,
6FE7CFA22177EEF2005B1573 /* InlineItem.h in Headers */,
BCE789161120D6080060ECE5 /* InlineIterator.h in Headers */,
- 6FB47E632277425A00C7BCB0 /* InlineLineBox.h in Headers */,
+ 6FB47E632277425A00C7BCB0 /* DisplayLineBox.h in Headers */,
6FE198172178397C00446F08 /* InlineLineBreaker.h in Headers */,
6F0CD695229ED32700C5994E /* InlineLineBuilder.h in Headers */,
6F360E5023999421001512A7 /* InlineSoftLineBreakItem.h in Headers */,
Added: trunk/Source/WebCore/layout/displaytree/DisplayInlineContent.cpp (0 => 253254)
--- trunk/Source/WebCore/layout/displaytree/DisplayInlineContent.cpp (rev 0)
+++ trunk/Source/WebCore/layout/displaytree/DisplayInlineContent.cpp 2019-12-07 15:21:02 UTC (rev 253254)
@@ -0,0 +1,63 @@
+/*
+* Copyright (C) 2019 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.
+*/
+
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+
+#include "config.h"
+#include "DisplayInlineContent.h"
+
+namespace WebCore {
+namespace Display {
+
+WTF::IteratorRange<const Run*> InlineContent::runsForRect(const LayoutRect& rect) const
+{
+ // FIXME: Do something efficient.
+ const Run* first = nullptr;
+ for (auto& run : runs) {
+ LayoutRect runRect = run.logicalRect();
+ if (runRect.intersects(rect)) {
+ first = &run;
+ break;
+ }
+ }
+ if (!first)
+ return { nullptr, nullptr };
+
+ const Run* last = nullptr;
+ for (auto& run : WTF::makeReversedRange(runs)) {
+ LayoutRect runRect = run.logicalRect();
+ if (runRect.intersects(rect)) {
+ last = &run;
+ break;
+ }
+ }
+
+ return { first, last + 1 };
+}
+
+}
+}
+
+#endif
Modified: trunk/Source/WebCore/layout/displaytree/DisplayInlineContent.h (253253 => 253254)
--- trunk/Source/WebCore/layout/displaytree/DisplayInlineContent.h 2019-12-07 14:49:50 UTC (rev 253253)
+++ trunk/Source/WebCore/layout/displaytree/DisplayInlineContent.h 2019-12-07 15:21:02 UTC (rev 253254)
@@ -27,8 +27,8 @@
#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+#include "DisplayLineBox.h"
#include "DisplayRun.h"
-#include "InlineLineBox.h"
#include <wtf/IteratorRange.h>
#include <wtf/Vector.h>
@@ -37,42 +37,16 @@
struct InlineContent : public RefCounted<InlineContent> {
using Runs = Vector<Run, 10>;
- using LineBoxes = Vector<Layout::LineBox, 5>;
+ using LineBoxes = Vector<LineBox, 5>;
Runs runs;
LineBoxes lineBoxes;
- const Layout::LineBox& lineBoxForRun(const Run& run) const { return lineBoxes[run.lineIndex()]; }
+ const LineBox& lineBoxForRun(const Run& run) const { return lineBoxes[run.lineIndex()]; }
WTF::IteratorRange<const Run*> runsForRect(const LayoutRect&) const;
};
-inline WTF::IteratorRange<const Run*> InlineContent::runsForRect(const LayoutRect& rect) const
-{
- // FIXME: Do something efficient.
- const Run* first = nullptr;
- for (auto& run : runs) {
- LayoutRect runRect = run.logicalRect();
- if (runRect.intersects(rect)) {
- first = &run;
- break;
- }
- }
- if (!first)
- return { nullptr, nullptr };
-
- const Run* last = nullptr;
- for (auto& run : WTF::makeReversedRange(runs)) {
- LayoutRect runRect = run.logicalRect();
- if (runRect.intersects(rect)) {
- last = &run;
- break;
- }
- }
-
- return { first, last + 1 };
}
-
}
-}
#endif
Copied: trunk/Source/WebCore/layout/displaytree/DisplayLineBox.h (from rev 253253, trunk/Source/WebCore/layout/inlineformatting/InlineLineBox.h) (0 => 253254)
--- trunk/Source/WebCore/layout/displaytree/DisplayLineBox.h (rev 0)
+++ trunk/Source/WebCore/layout/displaytree/DisplayLineBox.h 2019-12-07 15:21:02 UTC (rev 253254)
@@ -0,0 +1,245 @@
+/*
+ * Copyright (C) 2019 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 "DisplayBox.h"
+
+namespace WebCore {
+namespace Display {
+
+class LineBox {
+ WTF_MAKE_FAST_ALLOCATED;
+public:
+ struct Baseline {
+ Baseline(LayoutUnit ascent, LayoutUnit descent);
+ Baseline() = default;
+
+ void setAscent(LayoutUnit);
+ void setDescent(LayoutUnit);
+
+ void reset();
+
+ LayoutUnit height() const { return ascent() + descent(); }
+ LayoutUnit ascent() const;
+ LayoutUnit descent() const;
+
+ private:
+#if !ASSERT_DISABLED
+ bool m_hasValidAscent { false };
+ bool m_hasValidDescent { false };
+#endif
+ LayoutUnit m_ascent;
+ LayoutUnit m_descent;
+ };
+
+ LineBox(Rect, const Baseline&, LayoutUnit baselineOffset);
+ LineBox() = default;
+
+ LayoutPoint logicalTopLeft() const { return m_rect.topLeft(); }
+
+ LayoutUnit logicalLeft() const { return m_rect.left(); }
+ LayoutUnit logicalRight() const { return m_rect.right(); }
+ LayoutUnit logicalTop() const { return m_rect.top(); }
+ LayoutUnit logicalBottom() const { return m_rect.bottom(); }
+
+ LayoutUnit logicalWidth() const { return m_rect.width(); }
+ LayoutUnit logicalHeight() const { return m_rect.height(); }
+
+ const Baseline& baseline() const;
+ // Baseline offset from line logical top. Note that offset does not necessarily equal to ascent.
+ //
+ // ------------------- line logical top ------------------- (top align)
+ // ^ ^
+ // | ^ |
+ // ^ | baseline offset | | baseline offset
+ // | | | |
+ // | ascent | | ascent |
+ // | | v v
+ // v v ------------------- baseline
+ // ----------------- baseline ^
+ // ^ | descent
+ // | descent v
+ // v
+ // ------------------- line logical bottom -------------------
+ LayoutUnit baselineOffset() const;
+ void setBaselineOffsetIfGreater(LayoutUnit);
+ void setAscentIfGreater(LayoutUnit);
+ void setDescentIfGreater(LayoutUnit);
+
+ void resetBaseline();
+ void resetDescent() { m_baseline.setDescent(0_lu); }
+
+ void setLogicalTopLeft(LayoutPoint logicalTopLeft) { m_rect.setTopLeft(logicalTopLeft); }
+ void setLogicalHeight(LayoutUnit logicalHeight) { m_rect.setHeight(logicalHeight); }
+
+ void setLogicalHeightIfGreater(LayoutUnit);
+ void setLogicalWidth(LayoutUnit logicalWidth) { m_rect.setWidth(logicalWidth); }
+
+ void moveHorizontally(LayoutUnit delta) { m_rect.moveHorizontally(delta); }
+
+ void expandHorizontally(LayoutUnit delta) { m_rect.expandHorizontally(delta); }
+ void shrinkHorizontally(LayoutUnit delta) { expandHorizontally(-delta); }
+
+ void expandVertically(LayoutUnit delta) { m_rect.expandVertically(delta); }
+ void shrinkVertically(LayoutUnit delta) { expandVertically(-delta); }
+
+ // https://www.w3.org/TR/CSS22/visuren.html#inline-formatting
+ // Line boxes that contain no text, no preserved white space, no inline elements with non-zero margins, padding, or borders,
+ // and no other in-flow content (such as images, inline blocks or inline tables), and do not end with a preserved newline
+ // must be treated as zero-height line boxes for the purposes of determining the positions of any elements inside of them,
+ // and must be treated as not existing for any other purpose.
+ // Note that it does not necessarily mean visually non-empty line. <span style="font-size: 0px">this is still considered non-empty</span>
+ bool isConsideredEmpty() const { return m_isConsideredEmpty; }
+ void setIsConsideredEmpty() { m_isConsideredEmpty = true; }
+ void setIsConsideredNonEmpty() { m_isConsideredEmpty = false; }
+
+private:
+#if !ASSERT_DISABLED
+ bool m_hasValidBaseline { false };
+ bool m_hasValidBaselineOffset { false };
+#endif
+ Rect m_rect;
+ Baseline m_baseline;
+ LayoutUnit m_baselineOffset;
+ bool m_isConsideredEmpty { true };
+};
+
+inline LineBox::LineBox(Rect rect, const Baseline& baseline, LayoutUnit baselineOffset)
+ : m_rect(rect)
+ , m_baseline(baseline)
+ , m_baselineOffset(baselineOffset)
+{
+#if !ASSERT_DISABLED
+ m_hasValidBaseline = true;
+ m_hasValidBaselineOffset = true;
+#endif
+}
+
+inline void LineBox::setLogicalHeightIfGreater(LayoutUnit logicalHeight)
+{
+ if (logicalHeight <= m_rect.height())
+ return;
+ m_rect.setHeight(logicalHeight);
+}
+
+inline const LineBox::Baseline& LineBox::baseline() const
+{
+ ASSERT(m_hasValidBaseline);
+ return m_baseline;
+}
+
+inline void LineBox::setBaselineOffsetIfGreater(LayoutUnit baselineOffset)
+{
+#if !ASSERT_DISABLED
+ m_hasValidBaselineOffset = true;
+#endif
+ m_baselineOffset = std::max(baselineOffset, m_baselineOffset);
+}
+
+inline void LineBox::setAscentIfGreater(LayoutUnit ascent)
+{
+ if (ascent < m_baseline.ascent())
+ return;
+ setBaselineOffsetIfGreater(ascent);
+ m_baseline.setAscent(ascent);
+}
+
+inline void LineBox::setDescentIfGreater(LayoutUnit descent)
+{
+ if (descent < m_baseline.descent())
+ return;
+ m_baseline.setDescent(descent);
+}
+
+inline LayoutUnit LineBox::baselineOffset() const
+{
+ ASSERT(m_hasValidBaselineOffset);
+ return m_baselineOffset;
+}
+
+inline void LineBox::resetBaseline()
+{
+#if !ASSERT_DISABLED
+ m_hasValidBaselineOffset = true;
+#endif
+ m_baselineOffset = 0_lu;
+ m_baseline.reset();
+}
+
+inline LineBox::Baseline::Baseline(LayoutUnit ascent, LayoutUnit descent)
+ : m_ascent(ascent)
+ , m_descent(descent)
+{
+#if !ASSERT_DISABLED
+ m_hasValidAscent = true;
+ m_hasValidDescent = true;
+#endif
+}
+
+inline void LineBox::Baseline::setAscent(LayoutUnit ascent)
+{
+#if !ASSERT_DISABLED
+ m_hasValidAscent = true;
+#endif
+ m_ascent = ascent;
+}
+
+inline void LineBox::Baseline::setDescent(LayoutUnit descent)
+{
+#if !ASSERT_DISABLED
+ m_hasValidDescent = true;
+#endif
+ m_descent = descent;
+}
+
+inline void LineBox::Baseline::reset()
+{
+#if !ASSERT_DISABLED
+ m_hasValidAscent = true;
+ m_hasValidDescent = true;
+#endif
+ m_ascent = 0_lu;
+ m_descent = 0_lu;
+}
+
+inline LayoutUnit LineBox::Baseline::ascent() const
+{
+ ASSERT(m_hasValidAscent);
+ return m_ascent;
+}
+
+inline LayoutUnit LineBox::Baseline::descent() const
+{
+ ASSERT(m_hasValidDescent);
+ return m_descent;
+}
+
+}
+}
+
+#endif
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp (253253 => 253254)
--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp 2019-12-07 14:49:50 UTC (rev 253253)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp 2019-12-07 15:21:02 UTC (rev 253254)
@@ -428,7 +428,7 @@
auto& inlineContent = formattingState.ensureDisplayInlineContent();
auto lineIndex = inlineContent.lineBoxes.size();
- inlineContent.lineBoxes.append(LineBox { lineContent.lineBox });
+ inlineContent.lineBoxes.append(Display::LineBox { lineContent.lineBox });
Optional<unsigned> lastTextItemIndex;
// Compute box final geometry.
auto& lineRuns = lineContent.runList;
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextQuirks.cpp (253253 => 253254)
--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextQuirks.cpp 2019-12-07 14:49:50 UTC (rev 253253)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextQuirks.cpp 2019-12-07 15:21:02 UTC (rev 253254)
@@ -86,12 +86,12 @@
auto lineHeight = formattingRoot.style().lineHeight();
if (lineHeight.isPercentOrCalculated()) {
auto initialBaselineOffset = LineBuilder::halfLeadingMetrics(formattingRoot.style().fontMetrics(), 0_lu).ascent();
- return { initialBaselineOffset, initialBaselineOffset, LineBox::Baseline { strutBaselineOffset, strutHeight - strutBaselineOffset } };
+ return { initialBaselineOffset, initialBaselineOffset, Display::LineBox::Baseline { strutBaselineOffset, strutHeight - strutBaselineOffset } };
}
// FIXME: The only reason why we use intValue() here is to match current inline tree (integral)behavior.
auto initialLineHeight = LayoutUnit { lineHeight.intValue() };
auto initialBaselineOffset = LineBuilder::halfLeadingMetrics(formattingRoot.style().fontMetrics(), initialLineHeight).ascent();
- return { initialLineHeight, initialBaselineOffset, LineBox::Baseline { strutBaselineOffset, strutHeight - strutBaselineOffset } };
+ return { initialLineHeight, initialBaselineOffset, Display::LineBox::Baseline { strutBaselineOffset, strutHeight - strutBaselineOffset } };
}
}
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingState.h (253253 => 253254)
--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingState.h 2019-12-07 14:49:50 UTC (rev 253253)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingState.h 2019-12-07 15:21:02 UTC (rev 253254)
@@ -28,10 +28,8 @@
#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
#include "DisplayInlineContent.h"
-#include "DisplayRun.h"
#include "FormattingState.h"
#include "InlineItem.h"
-#include "InlineLineBox.h"
#include <wtf/IsoMalloc.h>
namespace WebCore {
Deleted: trunk/Source/WebCore/layout/inlineformatting/InlineLineBox.h (253253 => 253254)
--- trunk/Source/WebCore/layout/inlineformatting/InlineLineBox.h 2019-12-07 14:49:50 UTC (rev 253253)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLineBox.h 2019-12-07 15:21:02 UTC (rev 253254)
@@ -1,245 +0,0 @@
-/*
- * Copyright (C) 2019 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 "DisplayBox.h"
-
-namespace WebCore {
-namespace Layout {
-
-class LineBox {
- WTF_MAKE_FAST_ALLOCATED;
-public:
- struct Baseline {
- Baseline(LayoutUnit ascent, LayoutUnit descent);
- Baseline() = default;
-
- void setAscent(LayoutUnit);
- void setDescent(LayoutUnit);
-
- void reset();
-
- LayoutUnit height() const { return ascent() + descent(); }
- LayoutUnit ascent() const;
- LayoutUnit descent() const;
-
- private:
-#if !ASSERT_DISABLED
- bool m_hasValidAscent { false };
- bool m_hasValidDescent { false };
-#endif
- LayoutUnit m_ascent;
- LayoutUnit m_descent;
- };
-
- LineBox(Display::Rect, const Baseline&, LayoutUnit baselineOffset);
- LineBox() = default;
-
- LayoutPoint logicalTopLeft() const { return m_rect.topLeft(); }
-
- LayoutUnit logicalLeft() const { return m_rect.left(); }
- LayoutUnit logicalRight() const { return m_rect.right(); }
- LayoutUnit logicalTop() const { return m_rect.top(); }
- LayoutUnit logicalBottom() const { return m_rect.bottom(); }
-
- LayoutUnit logicalWidth() const { return m_rect.width(); }
- LayoutUnit logicalHeight() const { return m_rect.height(); }
-
- const Baseline& baseline() const;
- // Baseline offset from line logical top. Note that offset does not necessarily equal to ascent.
- //
- // ------------------- line logical top ------------------- (top align)
- // ^ ^
- // | ^ |
- // ^ | baseline offset | | baseline offset
- // | | | |
- // | ascent | | ascent |
- // | | v v
- // v v ------------------- baseline
- // ----------------- baseline ^
- // ^ | descent
- // | descent v
- // v
- // ------------------- line logical bottom -------------------
- LayoutUnit baselineOffset() const;
- void setBaselineOffsetIfGreater(LayoutUnit);
- void setAscentIfGreater(LayoutUnit);
- void setDescentIfGreater(LayoutUnit);
-
- void resetBaseline();
- void resetDescent() { m_baseline.setDescent(0_lu); }
-
- void setLogicalTopLeft(LayoutPoint logicalTopLeft) { m_rect.setTopLeft(logicalTopLeft); }
- void setLogicalHeight(LayoutUnit logicalHeight) { m_rect.setHeight(logicalHeight); }
-
- void setLogicalHeightIfGreater(LayoutUnit);
- void setLogicalWidth(LayoutUnit logicalWidth) { m_rect.setWidth(logicalWidth); }
-
- void moveHorizontally(LayoutUnit delta) { m_rect.moveHorizontally(delta); }
-
- void expandHorizontally(LayoutUnit delta) { m_rect.expandHorizontally(delta); }
- void shrinkHorizontally(LayoutUnit delta) { expandHorizontally(-delta); }
-
- void expandVertically(LayoutUnit delta) { m_rect.expandVertically(delta); }
- void shrinkVertically(LayoutUnit delta) { expandVertically(-delta); }
-
- // https://www.w3.org/TR/CSS22/visuren.html#inline-formatting
- // Line boxes that contain no text, no preserved white space, no inline elements with non-zero margins, padding, or borders,
- // and no other in-flow content (such as images, inline blocks or inline tables), and do not end with a preserved newline
- // must be treated as zero-height line boxes for the purposes of determining the positions of any elements inside of them,
- // and must be treated as not existing for any other purpose.
- // Note that it does not necessarily mean visually non-empty line. <span style="font-size: 0px">this is still considered non-empty</span>
- bool isConsideredEmpty() const { return m_isConsideredEmpty; }
- void setIsConsideredEmpty() { m_isConsideredEmpty = true; }
- void setIsConsideredNonEmpty() { m_isConsideredEmpty = false; }
-
-private:
-#if !ASSERT_DISABLED
- bool m_hasValidBaseline { false };
- bool m_hasValidBaselineOffset { false };
-#endif
- Display::Rect m_rect;
- Baseline m_baseline;
- LayoutUnit m_baselineOffset;
- bool m_isConsideredEmpty { true };
-};
-
-inline LineBox::LineBox(Display::Rect rect, const Baseline& baseline, LayoutUnit baselineOffset)
- : m_rect(rect)
- , m_baseline(baseline)
- , m_baselineOffset(baselineOffset)
-{
-#if !ASSERT_DISABLED
- m_hasValidBaseline = true;
- m_hasValidBaselineOffset = true;
-#endif
-}
-
-inline void LineBox::setLogicalHeightIfGreater(LayoutUnit logicalHeight)
-{
- if (logicalHeight <= m_rect.height())
- return;
- m_rect.setHeight(logicalHeight);
-}
-
-inline const LineBox::Baseline& LineBox::baseline() const
-{
- ASSERT(m_hasValidBaseline);
- return m_baseline;
-}
-
-inline void LineBox::setBaselineOffsetIfGreater(LayoutUnit baselineOffset)
-{
-#if !ASSERT_DISABLED
- m_hasValidBaselineOffset = true;
-#endif
- m_baselineOffset = std::max(baselineOffset, m_baselineOffset);
-}
-
-inline void LineBox::setAscentIfGreater(LayoutUnit ascent)
-{
- if (ascent < m_baseline.ascent())
- return;
- setBaselineOffsetIfGreater(ascent);
- m_baseline.setAscent(ascent);
-}
-
-inline void LineBox::setDescentIfGreater(LayoutUnit descent)
-{
- if (descent < m_baseline.descent())
- return;
- m_baseline.setDescent(descent);
-}
-
-inline LayoutUnit LineBox::baselineOffset() const
-{
- ASSERT(m_hasValidBaselineOffset);
- return m_baselineOffset;
-}
-
-inline void LineBox::resetBaseline()
-{
-#if !ASSERT_DISABLED
- m_hasValidBaselineOffset = true;
-#endif
- m_baselineOffset = 0_lu;
- m_baseline.reset();
-}
-
-inline LineBox::Baseline::Baseline(LayoutUnit ascent, LayoutUnit descent)
- : m_ascent(ascent)
- , m_descent(descent)
-{
-#if !ASSERT_DISABLED
- m_hasValidAscent = true;
- m_hasValidDescent = true;
-#endif
-}
-
-inline void LineBox::Baseline::setAscent(LayoutUnit ascent)
-{
-#if !ASSERT_DISABLED
- m_hasValidAscent = true;
-#endif
- m_ascent = ascent;
-}
-
-inline void LineBox::Baseline::setDescent(LayoutUnit descent)
-{
-#if !ASSERT_DISABLED
- m_hasValidDescent = true;
-#endif
- m_descent = descent;
-}
-
-inline void LineBox::Baseline::reset()
-{
-#if !ASSERT_DISABLED
- m_hasValidAscent = true;
- m_hasValidDescent = true;
-#endif
- m_ascent = 0_lu;
- m_descent = 0_lu;
-}
-
-inline LayoutUnit LineBox::Baseline::ascent() const
-{
- ASSERT(m_hasValidAscent);
- return m_ascent;
-}
-
-inline LayoutUnit LineBox::Baseline::descent() const
-{
- ASSERT(m_hasValidDescent);
- return m_descent;
-}
-
-}
-}
-
-#endif
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.cpp (253253 => 253254)
--- trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.cpp 2019-12-07 14:49:50 UTC (rev 253253)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.cpp 2019-12-07 15:21:02 UTC (rev 253254)
@@ -178,8 +178,8 @@
m_initialStrut = { };
auto lineRect = Display::Rect { constraints.logicalTopLeft, 0_lu, initialLineHeight };
- auto baseline = LineBox::Baseline { initialBaselineOffset, initialLineHeight - initialBaselineOffset };
- m_lineBox = LineBox { lineRect, baseline, initialBaselineOffset };
+ auto baseline = Display::LineBox::Baseline { initialBaselineOffset, initialLineHeight - initialBaselineOffset };
+ m_lineBox = Display::LineBox { lineRect, baseline, initialBaselineOffset };
m_lineLogicalWidth = constraints.availableLogicalWidth;
m_hasIntrusiveFloat = constraints.lineIsConstrainedByFloat;
@@ -677,7 +677,7 @@
return false;
}
-LineBox::Baseline LineBuilder::halfLeadingMetrics(const FontMetrics& fontMetrics, LayoutUnit lineLogicalHeight)
+Display::LineBox::Baseline LineBuilder::halfLeadingMetrics(const FontMetrics& fontMetrics, LayoutUnit lineLogicalHeight)
{
auto ascent = fontMetrics.ascent();
auto descent = fontMetrics.descent();
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.h (253253 => 253254)
--- trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.h 2019-12-07 14:49:50 UTC (rev 253253)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.h 2019-12-07 15:21:02 UTC (rev 253254)
@@ -27,9 +27,9 @@
#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+#include "DisplayLineBox.h"
#include "DisplayRun.h"
#include "InlineItem.h"
-#include "InlineLineBox.h"
#include "InlineTextItem.h"
namespace WebCore {
@@ -49,7 +49,7 @@
struct HeightAndBaseline {
LayoutUnit height;
LayoutUnit baselineOffset;
- Optional<LineBox::Baseline> strut;
+ Optional<Display::LineBox::Baseline> strut;
};
Optional<HeightAndBaseline> heightAndBaseline;
};
@@ -67,7 +67,7 @@
LayoutUnit trailingTrimmableWidth() const { return m_trimmableContent.width(); }
bool isTrailingRunFullyTrimmable() const { return m_trimmableContent.isTrailingRunFullyTrimmable(); }
- const LineBox& lineBox() const { return m_lineBox; }
+ const Display::LineBox& lineBox() const { return m_lineBox; }
void moveLogicalLeft(LayoutUnit);
void moveLogicalRight(LayoutUnit);
void setHasIntrusiveFloat() { m_hasIntrusiveFloat = true; }
@@ -115,7 +115,7 @@
enum class IsLastLineWithInlineContent { No, Yes };
RunList close(IsLastLineWithInlineContent = IsLastLineWithInlineContent::No);
- static LineBox::Baseline halfLeadingMetrics(const FontMetrics&, LayoutUnit lineLogicalHeight);
+ static Display::LineBox::Baseline halfLeadingMetrics(const FontMetrics&, LayoutUnit lineLogicalHeight);
private:
LayoutUnit logicalTop() const { return m_lineBox.logicalTop(); }
@@ -225,12 +225,12 @@
const InlineFormattingContext& m_inlineFormattingContext;
InlineItemRunList m_inlineItemRuns;
TrimmableContent m_trimmableContent;
- Optional<LineBox::Baseline> m_initialStrut;
+ Optional<Display::LineBox::Baseline> m_initialStrut;
LayoutUnit m_lineLogicalWidth;
Optional<TextAlignMode> m_horizontalAlignment;
bool m_skipAlignment { false };
bool m_hasIntrusiveFloat { false };
- LineBox m_lineBox;
+ Display::LineBox m_lineBox;
Optional<bool> m_lineIsVisuallyEmptyBeforeTrimmableContent;
};
Modified: trunk/Source/WebCore/layout/inlineformatting/LineLayoutContext.h (253253 => 253254)
--- trunk/Source/WebCore/layout/inlineformatting/LineLayoutContext.h 2019-12-07 14:49:50 UTC (rev 253253)
+++ trunk/Source/WebCore/layout/inlineformatting/LineLayoutContext.h 2019-12-07 15:21:02 UTC (rev 253254)
@@ -46,7 +46,7 @@
Optional<PartialContent> partialContent;
Vector<WeakPtr<InlineItem>> floats;
const LineBuilder::RunList runList;
- const LineBox lineBox;
+ const Display::LineBox lineBox;
};
LineContent layoutLine(LineBuilder&, unsigned leadingInlineItemIndex, Optional<unsigned> partialLeadingContentLength);