Diff
Modified: trunk/Source/WebCore/ChangeLog (256303 => 256304)
--- trunk/Source/WebCore/ChangeLog 2020-02-11 14:08:30 UTC (rev 256303)
+++ trunk/Source/WebCore/ChangeLog 2020-02-11 15:13:15 UTC (rev 256304)
@@ -1,3 +1,66 @@
+2020-02-11 Zalan Bujtas <[email protected]>
+
+ [LFC] Introduce Layout::InlineTextBox
+ https://bugs.webkit.org/show_bug.cgi?id=207530
+ <rdar://problem/59336020>
+
+ Reviewed by Antti Koivisto.
+
+ Any text that is directly contained inside a block container element (not inside an inline element) must be treated as an anonymous inline element.
+
+ * Sources.txt:
+ * layout/Verification.cpp:
+ (WebCore::Layout::checkForMatchingTextRuns):
+ * layout/inlineformatting/InlineFormattingContext.cpp:
+ (WebCore::Layout::InlineFormattingContext::collectInlineContentIfNeeded):
+ * layout/inlineformatting/InlineLineBreaker.cpp:
+ (WebCore::Layout::LineBreaker::tryBreakingTextRun const):
+ * layout/inlineformatting/InlineLineBuilder.cpp:
+ (WebCore::Layout::m_textContext):
+ * layout/inlineformatting/InlineSoftLineBreakItem.h:
+ (WebCore::Layout::InlineSoftLineBreakItem::createSoftLineBreakItem):
+ (WebCore::Layout::InlineSoftLineBreakItem::InlineSoftLineBreakItem):
+ * layout/inlineformatting/InlineTextItem.cpp:
+ (WebCore::Layout::InlineTextItem::createAndAppendTextItems):
+ (WebCore::Layout::InlineTextItem::isEmptyContent const):
+ * layout/inlineformatting/InlineTextItem.h:
+ (WebCore::Layout::InlineTextItem::inlineTextBox const):
+ (WebCore::Layout::InlineTextItem::createWhitespaceItem):
+ (WebCore::Layout::InlineTextItem::createNonWhitespaceItem):
+ (WebCore::Layout::InlineTextItem::createEmptyItem):
+ (WebCore::Layout::InlineTextItem::InlineTextItem):
+ (WebCore::Layout::InlineTextItem::left const):
+ (WebCore::Layout::InlineTextItem::right const):
+ * layout/inlineformatting/LineLayoutContext.cpp:
+ (WebCore::Layout::endsWithSoftWrapOpportunity):
+ * layout/inlineformatting/text/TextUtil.cpp:
+ (WebCore::Layout::TextUtil::width):
+ (WebCore::Layout::TextUtil::split):
+ * layout/inlineformatting/text/TextUtil.h:
+ * layout/integration/LayoutIntegrationBoxTree.cpp:
+ (WebCore::LayoutIntegration::BoxTree::buildTree):
+ * layout/layouttree/LayoutBox.cpp:
+ (WebCore::Layout::Box::Box):
+ (): Deleted.
+ * layout/layouttree/LayoutBox.h:
+ (WebCore::Layout::Box::isInlineTextBox const):
+ (WebCore::Layout::Box::hasTextContent const): Deleted.
+ (WebCore::Layout::Box::textContext const): Deleted.
+ * layout/layouttree/LayoutContainer.cpp:
+ (WebCore::Layout::Container::Container):
+ (): Deleted.
+ * layout/layouttree/LayoutInlineTextBox.cpp: Copied from Source/WebCore/layout/layouttree/TextContext.h.
+ (WebCore::Layout::InlineTextBox::InlineTextBox):
+ (WebCore::Layout::m_canUseSimplifiedContentMeasuring):
+ * layout/layouttree/LayoutInlineTextBox.h: Renamed from Source/WebCore/layout/layouttree/TextContext.h.
+ (WebCore::Layout::InlineTextBox::content const):
+ (WebCore::Layout::InlineTextBox::canUseSimplifiedContentMeasuring const):
+ * layout/layouttree/LayoutTreeBuilder.cpp:
+ (WebCore::Layout::TreeBuilder::createTextBox):
+ (WebCore::Layout::TreeBuilder::createLayoutBox):
+ (WebCore::Layout::outputLayoutBox):
+ * layout/layouttree/LayoutTreeBuilder.h:
+
2020-02-11 Carlos Garcia Campos <[email protected]>
Unreviewed. Fix WPE build after r256298
Modified: trunk/Source/WebCore/Headers.cmake (256303 => 256304)
--- trunk/Source/WebCore/Headers.cmake 2020-02-11 14:08:30 UTC (rev 256303)
+++ trunk/Source/WebCore/Headers.cmake 2020-02-11 15:13:15 UTC (rev 256304)
@@ -686,7 +686,6 @@
layout/layouttree/LayoutBox.h
layout/layouttree/LayoutReplaced.h
- layout/layouttree/TextContext.h
loader/AdClickAttribution.h
loader/CanvasActivityRecord.h
Modified: trunk/Source/WebCore/Sources.txt (256303 => 256304)
--- trunk/Source/WebCore/Sources.txt 2020-02-11 14:08:30 UTC (rev 256303)
+++ trunk/Source/WebCore/Sources.txt 2020-02-11 15:13:15 UTC (rev 256304)
@@ -1451,6 +1451,7 @@
layout/invalidation/InvalidationState.cpp
layout/layouttree/LayoutBox.cpp
layout/layouttree/LayoutContainer.cpp
+layout/layouttree/LayoutInlineTextBox.cpp
layout/layouttree/LayoutReplaced.cpp
layout/layouttree/LayoutTreeBuilder.cpp
layout/tableformatting/TableFormattingContext.cpp
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (256303 => 256304)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2020-02-11 14:08:30 UTC (rev 256303)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2020-02-11 15:13:15 UTC (rev 256304)
@@ -379,7 +379,6 @@
11310CF620BA4A560065A8D0 /* LayoutChildIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = 11100FC920927CBC0081AA6C /* LayoutChildIterator.h */; settings = {ATTRIBUTES = (Private, ); }; };
11310CF720BA4A620065A8D0 /* LayoutAncestorIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = 11100FCA2092868D0081AA6C /* LayoutAncestorIterator.h */; settings = {ATTRIBUTES = (Private, ); }; };
113409DA203E038000C66915 /* RenderTreeBuilderContinuation.h in Headers */ = {isa = PBXBuildFile; fileRef = 113409D8203E038000C66915 /* RenderTreeBuilderContinuation.h */; };
- 113A3CB42385860100AE3ECE /* TextContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 113A3CB22385860000AE3ECE /* TextContext.h */; settings = {ATTRIBUTES = (Private, ); }; };
113D0B521F9FDD2B00F611BB /* FrameViewLayoutContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 113D0B501F9FDD2B00F611BB /* FrameViewLayoutContext.h */; settings = {ATTRIBUTES = (Private, ); }; };
115CFA6A208AF7D0001E6991 /* FormattingContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 115CFA68208AF7D0001E6991 /* FormattingContext.h */; settings = {ATTRIBUTES = (Private, ); }; };
115CFA6E208AFAB7001E6991 /* BlockFormattingContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 115CFA6C208AFAB6001E6991 /* BlockFormattingContext.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -2050,6 +2049,7 @@
6ED878C5147493F4004C3597 /* RenderTableCaption.h in Headers */ = {isa = PBXBuildFile; fileRef = 6ED878C3147493F4004C3597 /* RenderTableCaption.h */; };
6ED8C37A183BFF8C009E53BD /* BoxShape.h in Headers */ = {isa = PBXBuildFile; fileRef = 6ED8C378183BFF8C009E53BD /* BoxShape.h */; settings = {ATTRIBUTES = (Private, ); }; };
6EE8A77310F803F3005A4A24 /* JSWebGLContextAttributes.h in Headers */ = {isa = PBXBuildFile; fileRef = 6EE8A77110F803F3005A4A24 /* JSWebGLContextAttributes.h */; };
+ 6F0B98B523F268EC00EEC2F2 /* LayoutInlineTextBox.h in Headers */ = {isa = PBXBuildFile; fileRef = 6F0B98B323F268EB00EEC2F2 /* LayoutInlineTextBox.h */; settings = {ATTRIBUTES = (Private, ); }; };
6F0CD695229ED32700C5994E /* InlineLineBuilder.h in Headers */ = {isa = PBXBuildFile; fileRef = 6F0CD694229ED32700C5994E /* InlineLineBuilder.h */; };
6F1CC1DE225F8B4900720AD2 /* InlineTextItem.h in Headers */ = {isa = PBXBuildFile; fileRef = 6F1CC1DD225F8B4200720AD2 /* InlineTextItem.h */; settings = {ATTRIBUTES = (Private, ); }; };
6F26BB6C23343E6F002F2BEA /* LayoutContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 6F26BB6B23343E5B002F2BEA /* LayoutContext.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -5915,7 +5915,6 @@
112FB350239C23C40087054A /* DisplayInlineRect.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DisplayInlineRect.h; 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>"; };
- 113A3CB22385860000AE3ECE /* TextContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextContext.h; sourceTree = "<group>"; };
113D0B4F1F9FDD2B00F611BB /* FrameViewLayoutContext.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = FrameViewLayoutContext.cpp; sourceTree = "<group>"; };
113D0B501F9FDD2B00F611BB /* FrameViewLayoutContext.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FrameViewLayoutContext.h; sourceTree = "<group>"; };
115CA83023328B1E00FD3B08 /* LayoutUnits.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = LayoutUnits.cpp; sourceTree = "<group>"; };
@@ -9294,6 +9293,8 @@
6EE8A77010F803F3005A4A24 /* JSWebGLContextAttributes.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWebGLContextAttributes.cpp; sourceTree = "<group>"; };
6EE8A77110F803F3005A4A24 /* JSWebGLContextAttributes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWebGLContextAttributes.h; sourceTree = "<group>"; };
6F0830DF20B46951008A945B /* BlockFormattingContextGeometry.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = BlockFormattingContextGeometry.cpp; sourceTree = "<group>"; };
+ 6F0B98B323F268EB00EEC2F2 /* LayoutInlineTextBox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LayoutInlineTextBox.h; sourceTree = "<group>"; };
+ 6F0B98B623F2690600EEC2F2 /* LayoutInlineTextBox.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = LayoutInlineTextBox.cpp; sourceTree = "<group>"; };
6F0CD692229ED31900C5994E /* InlineLineBuilder.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = InlineLineBuilder.cpp; sourceTree = "<group>"; };
6F0CD694229ED32700C5994E /* InlineLineBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InlineLineBuilder.h; sourceTree = "<group>"; };
6F10B08622B8568D0090E69C /* InlineFormattingContextQuirks.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = InlineFormattingContextQuirks.cpp; sourceTree = "<group>"; };
@@ -16743,12 +16744,13 @@
1199FA45208E35A3002358CC /* LayoutContainer.cpp */,
1199FA44208E35A3002358CC /* LayoutContainer.h */,
11B042FB20B0E21400828A6B /* LayoutDescendantIterator.h */,
+ 6F0B98B623F2690600EEC2F2 /* LayoutInlineTextBox.cpp */,
+ 6F0B98B323F268EB00EEC2F2 /* LayoutInlineTextBox.h */,
11100FC72092764C0081AA6C /* LayoutIterator.h */,
111C615720AD1AE1005B82FA /* LayoutReplaced.cpp */,
111C615620AD1AE1005B82FA /* LayoutReplaced.h */,
11100FD5209514DE0081AA6C /* LayoutTreeBuilder.cpp */,
11100FD7209514DF0081AA6C /* LayoutTreeBuilder.h */,
- 113A3CB22385860000AE3ECE /* TextContext.h */,
);
path = layouttree;
sourceTree = "<group>";
@@ -31301,6 +31303,7 @@
1199FA46208E35A3002358CC /* LayoutContainer.h in Headers */,
6F26BB6C23343E6F002F2BEA /* LayoutContext.h in Headers */,
11310CF520BA4A4C0065A8D0 /* LayoutDescendantIterator.h in Headers */,
+ 6F0B98B523F268EC00EEC2F2 /* LayoutInlineTextBox.h in Headers */,
E418025523D4549B00FFB071 /* LayoutIntegrationBoxTree.h in Headers */,
E4ABABDD236088FE00FA4345 /* LayoutIntegrationLineLayout.h in Headers */,
11310CF420BA4A3D0065A8D0 /* LayoutIterator.h in Headers */,
@@ -32698,7 +32701,6 @@
B2C3DA400D006C1D00EF6F26 /* TextCodecUserDefined.h in Headers */,
B2C3DA420D006C1D00EF6F26 /* TextCodecUTF16.h in Headers */,
9343CB8212F25E510033C5EE /* TextCodecUTF8.h in Headers */,
- 113A3CB42385860100AE3ECE /* TextContext.h in Headers */,
142B97CA13138943008BEF4B /* TextControlInnerElements.h in Headers */,
582DE3251C30C85400BE02A8 /* TextDecorationPainter.h in Headers */,
1C73A71521857587004CCEA5 /* TextDecorationThickness.h in Headers */,
Modified: trunk/Source/WebCore/layout/Verification.cpp (256303 => 256304)
--- trunk/Source/WebCore/layout/Verification.cpp 2020-02-11 14:08:30 UTC (rev 256303)
+++ trunk/Source/WebCore/layout/Verification.cpp 2020-02-11 15:13:15 UTC (rev 256304)
@@ -125,7 +125,7 @@
}
-static bool checkForMatchingTextRuns(const Display::Run& inlineRun, const InlineTextBox& inlineTextBox)
+static bool checkForMatchingTextRuns(const Display::Run& inlineRun, const WebCore::InlineTextBox& inlineTextBox)
{
return areEssentiallyEqual(inlineTextBox.left(), inlineRun.left())
&& areEssentiallyEqual(inlineTextBox.right(), inlineRun.right())
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp (256303 => 256304)
--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp 2020-02-11 14:08:30 UTC (rev 256303)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp 2020-02-11 15:13:15 UTC (rev 256304)
@@ -36,6 +36,7 @@
#include "LayoutBox.h"
#include "LayoutContainer.h"
#include "LayoutContext.h"
+#include "LayoutInlineTextBox.h"
#include "LayoutState.h"
#include "Logging.h"
#include "RuntimeEnabledFeatures.h"
@@ -338,8 +339,8 @@
else if (layoutBox.isAtomicInlineLevelBox())
formattingState.addInlineItem({ layoutBox, InlineItem::Type::Box });
else if (layoutBox.isAnonymous()) {
- ASSERT(layoutBox.hasTextContent());
- InlineTextItem::createAndAppendTextItems(formattingState.inlineItems(), layoutBox);
+ ASSERT(layoutBox.isInlineTextBox());
+ InlineTextItem::createAndAppendTextItems(formattingState.inlineItems(), downcast<InlineTextBox>(layoutBox));
} else if (layoutBox.isInlineBox())
formattingState.addInlineItem({ layoutBox, InlineItem::Type::ContainerEnd });
else
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLineBreaker.cpp (256303 => 256304)
--- trunk/Source/WebCore/layout/inlineformatting/InlineLineBreaker.cpp 2020-02-11 14:08:30 UTC (rev 256303)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLineBreaker.cpp 2020-02-11 15:13:15 UTC (rev 256304)
@@ -313,7 +313,7 @@
return PartialRun { inlineTextItem.length(), overflowRun.logicalWidth, false };
}
// FIXME: Pass in the content logical left to be able to measure tabs.
- auto splitData = TextUtil::split(inlineTextItem.layoutBox(), inlineTextItem.start(), inlineTextItem.length(), overflowRun.logicalWidth, availableWidth, { });
+ auto splitData = TextUtil::split(inlineTextItem.inlineTextBox(), inlineTextItem.start(), inlineTextItem.length(), overflowRun.logicalWidth, availableWidth, { });
return PartialRun { splitData.length, splitData.logicalWidth, false };
}
@@ -336,14 +336,13 @@
auto availableWidthExcludingHyphen = availableWidth - hyphenWidth;
if (availableWidthExcludingHyphen <= 0 || !enoughWidthForHyphenation(availableWidthExcludingHyphen, fontCascade.pixelSize()))
return { };
- leftSideLength = TextUtil::split(inlineTextItem.layoutBox(), inlineTextItem.start(), runLength, overflowRun.logicalWidth, availableWidthExcludingHyphen, { }).length;
+ leftSideLength = TextUtil::split(inlineTextItem.inlineTextBox(), inlineTextItem.start(), runLength, overflowRun.logicalWidth, availableWidthExcludingHyphen, { }).length;
}
if (leftSideLength < limitBefore)
return { };
- auto textContent = inlineTextItem.layoutBox().textContext()->content;
// Adjust before index to accommodate the limit-after value (it's the last potential hyphen location in this run).
auto hyphenBefore = std::min(leftSideLength, runLength - limitAfter) + 1;
- unsigned hyphenLocation = lastHyphenLocation(StringView(textContent).substring(inlineTextItem.start(), inlineTextItem.length()), hyphenBefore, style.locale());
+ unsigned hyphenLocation = lastHyphenLocation(StringView(inlineTextItem.inlineTextBox().content()).substring(inlineTextItem.start(), inlineTextItem.length()), hyphenBefore, style.locale());
if (!hyphenLocation || hyphenLocation < limitBefore)
return { };
// hyphenLocation is relative to the start of this InlineItemText.
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.cpp (256303 => 256304)
--- trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.cpp 2020-02-11 14:08:30 UTC (rev 256303)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.cpp 2020-02-11 15:13:15 UTC (rev 256304)
@@ -750,7 +750,7 @@
: m_type(softLineBreakItem.type())
, m_layoutBox(&softLineBreakItem.layoutBox())
, m_logicalRect({ 0, logicalLeft, 0, 0 })
- , m_textContext({ softLineBreakItem.position(), 1, softLineBreakItem.layoutBox().textContext()->content })
+ , m_textContext({ softLineBreakItem.position(), 1, softLineBreakItem.inlineTextBox().content() })
{
}
@@ -759,7 +759,7 @@
, m_layoutBox(&inlineTextItem.layoutBox())
, m_logicalRect({ 0, logicalLeft, logicalWidth, 0 })
, m_trailingWhitespaceType(trailingWhitespaceType(inlineTextItem))
- , m_textContext({ inlineTextItem.start(), m_trailingWhitespaceType == TrailingWhitespace::Collapsed ? 1 : inlineTextItem.length(), inlineTextItem.layoutBox().textContext()->content })
+ , m_textContext({ inlineTextItem.start(), m_trailingWhitespaceType == TrailingWhitespace::Collapsed ? 1 : inlineTextItem.length(), inlineTextItem.inlineTextBox().content() })
{
if (m_trailingWhitespaceType != TrailingWhitespace::None) {
m_trailingWhitespaceWidth = logicalWidth;
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineSoftLineBreakItem.h (256303 => 256304)
--- trunk/Source/WebCore/layout/inlineformatting/InlineSoftLineBreakItem.h 2020-02-11 14:08:30 UTC (rev 256303)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineSoftLineBreakItem.h 2020-02-11 15:13:15 UTC (rev 256304)
@@ -34,20 +34,21 @@
class InlineSoftLineBreakItem : public InlineItem {
public:
- static InlineSoftLineBreakItem createSoftLineBreakItem(const Box&, unsigned position);
+ static InlineSoftLineBreakItem createSoftLineBreakItem(const InlineTextBox&, unsigned position);
unsigned position() const { return m_startOrPosition; }
+ const InlineTextBox& inlineTextBox() const { return downcast<InlineTextBox>(layoutBox()); }
- InlineSoftLineBreakItem(const Box&, unsigned position);
+ InlineSoftLineBreakItem(const InlineTextBox&, unsigned position);
};
-inline InlineSoftLineBreakItem InlineSoftLineBreakItem::createSoftLineBreakItem(const Box& inlineBox, unsigned position)
+inline InlineSoftLineBreakItem InlineSoftLineBreakItem::createSoftLineBreakItem(const InlineTextBox& inlineTextBox, unsigned position)
{
- return { inlineBox, position };
+ return { inlineTextBox, position };
}
-inline InlineSoftLineBreakItem::InlineSoftLineBreakItem(const Box& inlineBox, unsigned position)
- : InlineItem(inlineBox, Type::SoftLineBreak)
+inline InlineSoftLineBreakItem::InlineSoftLineBreakItem(const InlineTextBox& inlineTextBox, unsigned position)
+ : InlineItem(inlineTextBox, Type::SoftLineBreak)
{
m_startOrPosition = position;
}
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineTextItem.cpp (256303 => 256304)
--- trunk/Source/WebCore/layout/inlineformatting/InlineTextItem.cpp 2020-02-11 14:08:30 UTC (rev 256303)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineTextItem.cpp 2020-02-11 15:13:15 UTC (rev 256304)
@@ -65,22 +65,21 @@
return textLength - startPosition;
}
-void InlineTextItem::createAndAppendTextItems(InlineItems& inlineContent, const Box& inlineBox)
+void InlineTextItem::createAndAppendTextItems(InlineItems& inlineContent, const InlineTextBox& inlineTextBox)
{
- auto& textContext = *inlineBox.textContext();
- auto text = textContext.content;
+ auto text = inlineTextBox.content();
if (!text.length())
- return inlineContent.append(InlineTextItem::createEmptyItem(inlineBox));
+ return inlineContent.append(InlineTextItem::createEmptyItem(inlineTextBox));
- auto& style = inlineBox.style();
+ auto& style = inlineTextBox.style();
auto& font = style.fontCascade();
LazyLineBreakIterator lineBreakIterator(text);
unsigned currentPosition = 0;
auto inlineItemWidth = [&](auto startPosition, auto length) -> Optional<InlineLayoutUnit> {
- if (!textContext.canUseSimplifiedContentMeasuring)
+ if (!inlineTextBox.canUseSimplifiedContentMeasuring())
return { };
- return TextUtil::width(inlineBox, startPosition, startPosition + length);
+ return TextUtil::width(inlineTextBox, startPosition, startPosition + length);
};
while (currentPosition < text.length()) {
@@ -90,7 +89,7 @@
// Segment breaks with preserve new line style (white-space: pre, pre-wrap, break-spaces and pre-line) compute to forced line break.
if (isSegmentBreakCandidate(text[currentPosition]) && style.preserveNewline()) {
- inlineContent.append(InlineSoftLineBreakItem::createSoftLineBreakItem(inlineBox, currentPosition));
+ inlineContent.append(InlineSoftLineBreakItem::createSoftLineBreakItem(inlineTextBox, currentPosition));
++currentPosition;
continue;
}
@@ -97,9 +96,9 @@
if (isWhitespaceCharacter(text[currentPosition], style.preserveNewline())) {
auto appendWhitespaceItem = [&] (auto startPosition, auto itemLength) {
- auto simpleSingleWhitespaceContent = textContext.canUseSimplifiedContentMeasuring && (itemLength == 1 || style.collapseWhiteSpace());
+ auto simpleSingleWhitespaceContent = inlineTextBox.canUseSimplifiedContentMeasuring() && (itemLength == 1 || style.collapseWhiteSpace());
auto width = simpleSingleWhitespaceContent ? makeOptional(InlineLayoutUnit { font.spaceWidth() }) : inlineItemWidth(startPosition, itemLength);
- inlineContent.append(InlineTextItem::createWhitespaceItem(inlineBox, startPosition, itemLength, width));
+ inlineContent.append(InlineTextItem::createWhitespaceItem(inlineTextBox, startPosition, itemLength, width));
};
auto length = moveToNextNonWhitespacePosition(text, currentPosition, style.preserveNewline());
@@ -116,7 +115,7 @@
}
auto length = moveToNextBreakablePosition(currentPosition, lineBreakIterator, style);
- inlineContent.append(InlineTextItem::createNonWhitespaceItem(inlineBox, currentPosition, length, inlineItemWidth(currentPosition, length)));
+ inlineContent.append(InlineTextItem::createNonWhitespaceItem(inlineTextBox, currentPosition, length, inlineItemWidth(currentPosition, length)));
currentPosition += length;
}
}
@@ -124,7 +123,7 @@
bool InlineTextItem::isEmptyContent() const
{
// FIXME: We should check for more zero width content and not just U+200B.
- return !m_length || (m_length == 1 && layoutBox().textContext()->content[start()] == zeroWidthSpace);
+ return !m_length || (m_length == 1 && inlineTextBox().content()[start()] == zeroWidthSpace);
}
}
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineTextItem.h (256303 => 256304)
--- trunk/Source/WebCore/layout/inlineformatting/InlineTextItem.h 2020-02-11 14:08:30 UTC (rev 256303)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineTextItem.h 2020-02-11 15:13:15 UTC (rev 256304)
@@ -29,6 +29,7 @@
#include "InlineFormattingState.h"
#include "InlineItem.h"
+#include "LayoutInlineTextBox.h"
namespace WebCore {
namespace Layout {
@@ -35,7 +36,7 @@
class InlineTextItem : public InlineItem {
public:
- static void createAndAppendTextItems(InlineItems&, const Box&);
+ static void createAndAppendTextItems(InlineItems&, const InlineTextBox&);
unsigned start() const { return m_startOrPosition; }
unsigned end() const { return start() + length(); }
@@ -46,6 +47,8 @@
Optional<InlineLayoutUnit> width() const { return m_hasWidth ? makeOptional(m_width) : Optional<InlineLayoutUnit> { }; }
bool isEmptyContent() const;
+ const InlineTextBox& inlineTextBox() const { return downcast<InlineTextBox>(layoutBox()); }
+
InlineTextItem left(unsigned length) const;
InlineTextItem right(unsigned length) const;
@@ -52,42 +55,42 @@
private:
using InlineItem::TextItemType;
- InlineTextItem(const Box&, unsigned start, unsigned length, Optional<InlineLayoutUnit> width, TextItemType);
- InlineTextItem(const Box&);
+ InlineTextItem(const InlineTextBox&, unsigned start, unsigned length, Optional<InlineLayoutUnit> width, TextItemType);
+ InlineTextItem(const InlineTextBox&);
- static InlineTextItem createWhitespaceItem(const Box&, unsigned start, unsigned length, Optional<InlineLayoutUnit> width);
- static InlineTextItem createNonWhitespaceItem(const Box&, unsigned start, unsigned length, Optional<InlineLayoutUnit> width);
- static InlineTextItem createEmptyItem(const Box&);
+ static InlineTextItem createWhitespaceItem(const InlineTextBox&, unsigned start, unsigned length, Optional<InlineLayoutUnit> width);
+ static InlineTextItem createNonWhitespaceItem(const InlineTextBox&, unsigned start, unsigned length, Optional<InlineLayoutUnit> width);
+ static InlineTextItem createEmptyItem(const InlineTextBox&);
};
-inline InlineTextItem InlineTextItem::createWhitespaceItem(const Box& inlineBox, unsigned start, unsigned length, Optional<InlineLayoutUnit> width)
+inline InlineTextItem InlineTextItem::createWhitespaceItem(const InlineTextBox& inlineTextBox, unsigned start, unsigned length, Optional<InlineLayoutUnit> width)
{
- return { inlineBox, start, length, width, TextItemType::Whitespace };
+ return { inlineTextBox, start, length, width, TextItemType::Whitespace };
}
-inline InlineTextItem InlineTextItem::createNonWhitespaceItem(const Box& inlineBox, unsigned start, unsigned length, Optional<InlineLayoutUnit> width)
+inline InlineTextItem InlineTextItem::createNonWhitespaceItem(const InlineTextBox& inlineTextBox, unsigned start, unsigned length, Optional<InlineLayoutUnit> width)
{
- return { inlineBox, start, length, width, TextItemType::NonWhitespace };
+ return { inlineTextBox, start, length, width, TextItemType::NonWhitespace };
}
-inline InlineTextItem InlineTextItem::createEmptyItem(const Box& inlineBox)
+inline InlineTextItem InlineTextItem::createEmptyItem(const InlineTextBox& inlineTextBox)
{
- return { inlineBox };
+ return { inlineTextBox };
}
-inline InlineTextItem::InlineTextItem(const Box& inlineBox, unsigned start, unsigned length, Optional<InlineLayoutUnit> width, TextItemType textItemType)
- : InlineItem(inlineBox, Type::Text)
+inline InlineTextItem::InlineTextItem(const InlineTextBox& inlineTextBox, unsigned start, unsigned length, Optional<InlineLayoutUnit> width, TextItemType textItemType)
+ : InlineItem(inlineTextBox, Type::Text)
{
m_startOrPosition = start;
m_length = length;
m_hasWidth = !!width;
- m_isCollapsible = textItemType == TextItemType::Whitespace && inlineBox.style().collapseWhiteSpace();
+ m_isCollapsible = textItemType == TextItemType::Whitespace && inlineTextBox.style().collapseWhiteSpace();
m_width = width.valueOr(0);
m_textItemType = textItemType;
}
-inline InlineTextItem::InlineTextItem(const Box& inlineBox)
- : InlineItem(inlineBox, Type::Text)
+inline InlineTextItem::InlineTextItem(const InlineTextBox& inlineTextBox)
+ : InlineItem(inlineTextBox, Type::Text)
{
}
@@ -96,7 +99,7 @@
RELEASE_ASSERT(length <= this->length());
ASSERT(m_textItemType != TextItemType::Undefined);
ASSERT(length);
- return { layoutBox(), start(), length, WTF::nullopt, m_textItemType };
+ return { inlineTextBox(), start(), length, WTF::nullopt, m_textItemType };
}
inline InlineTextItem InlineTextItem::right(unsigned length) const
@@ -104,7 +107,7 @@
RELEASE_ASSERT(length <= this->length());
ASSERT(m_textItemType != TextItemType::Undefined);
ASSERT(length);
- return { layoutBox(), end() - length, length, WTF::nullopt, m_textItemType };
+ return { inlineTextBox(), end() - length, length, WTF::nullopt, m_textItemType };
}
}
Modified: trunk/Source/WebCore/layout/inlineformatting/LineLayoutContext.cpp (256303 => 256304)
--- trunk/Source/WebCore/layout/inlineformatting/LineLayoutContext.cpp 2020-02-11 14:08:30 UTC (rev 256303)
+++ trunk/Source/WebCore/layout/inlineformatting/LineLayoutContext.cpp 2020-02-11 15:13:15 UTC (rev 256304)
@@ -43,13 +43,13 @@
return true;
// When both these non-whitespace runs belong to the same layout box, it's guaranteed that
// they are split at a soft breaking opportunity. See InlineTextItem::moveToNextBreakablePosition.
- if (¤tTextItem.layoutBox() == &nextInlineTextItem.layoutBox())
+ if (¤tTextItem.inlineTextBox() == &nextInlineTextItem.inlineTextBox())
return true;
// Now we need to collect at least 3 adjacent characters to be able to make a decision whether the previous text item ends with breaking opportunity.
// [ex-][ample] <- second to last[x] last[-] current[a]
// We need at least 1 character in the current inline text item and 2 more from previous inline items.
- auto previousContent = currentTextItem.layoutBox().textContext()->content;
- auto lineBreakIterator = LazyLineBreakIterator { nextInlineTextItem.layoutBox().textContext()->content };
+ auto previousContent = currentTextItem.inlineTextBox().content();
+ auto lineBreakIterator = LazyLineBreakIterator { nextInlineTextItem.inlineTextBox().content() };
auto previousContentLength = previousContent.length();
// FIXME: We should look into the entire uncommitted content for more text context.
UChar lastCharacter = previousContentLength ? previousContent[previousContentLength - 1] : 0;
Modified: trunk/Source/WebCore/layout/inlineformatting/text/TextUtil.cpp (256303 => 256304)
--- trunk/Source/WebCore/layout/inlineformatting/text/TextUtil.cpp 2020-02-11 14:08:30 UTC (rev 256303)
+++ trunk/Source/WebCore/layout/inlineformatting/text/TextUtil.cpp 2020-02-11 15:13:15 UTC (rev 256304)
@@ -31,6 +31,7 @@
#include "BreakLines.h"
#include "FontCascade.h"
#include "InlineTextItem.h"
+#include "LayoutInlineTextBox.h"
#include "RenderBox.h"
#include "RenderStyle.h"
@@ -44,18 +45,17 @@
auto font = inlineTextItem.style().fontCascade();
return font.spaceWidth() + font.wordSpacing();
}
- return TextUtil::width(inlineTextItem.layoutBox(), from, to, contentLogicalLeft);
+ return TextUtil::width(inlineTextItem.inlineTextBox(), from, to, contentLogicalLeft);
}
-InlineLayoutUnit TextUtil::width(const Box& inlineBox, unsigned from, unsigned to, InlineLayoutUnit contentLogicalLeft)
+InlineLayoutUnit TextUtil::width(const InlineTextBox& inlineTextBox, unsigned from, unsigned to, InlineLayoutUnit contentLogicalLeft)
{
- auto& style = inlineBox.style();
+ auto& style = inlineTextBox.style();
auto& font = style.fontCascade();
if (!font.size() || from == to)
return 0;
- auto& textContext = *inlineBox.textContext();
- auto& text = textContext.content;
+ auto text = inlineTextBox.content();
ASSERT(to <= text.length());
auto hasKerningOrLigatures = font.enableKerning() || font.requiresShaping();
auto measureWithEndSpace = hasKerningOrLigatures && to < text.length() && text[to] == ' ';
@@ -62,7 +62,7 @@
if (measureWithEndSpace)
++to;
float width = 0;
- if (textContext.canUseSimplifiedContentMeasuring) {
+ if (inlineTextBox.canUseSimplifiedContentMeasuring()) {
if (font.isFixedPitch())
width = fixedPitchWidth(text, style, from, to, contentLogicalLeft);
else
@@ -100,7 +100,7 @@
return std::max<InlineLayoutUnit>(0, InlineLayoutUnit(width));
}
-TextUtil::SplitData TextUtil::split(const Box& inlineBox, unsigned startPosition, unsigned length, InlineLayoutUnit textWidth, InlineLayoutUnit availableWidth, InlineLayoutUnit contentLogicalLeft)
+TextUtil::SplitData TextUtil::split(const InlineTextBox& inlineTextBox, unsigned startPosition, unsigned length, InlineLayoutUnit textWidth, InlineLayoutUnit availableWidth, InlineLayoutUnit contentLogicalLeft)
{
ASSERT(availableWidth >= 0);
auto left = startPosition;
@@ -113,7 +113,7 @@
InlineLayoutUnit leftSideWidth = 0;
while (left < right) {
auto middle = (left + right) / 2;
- auto width = TextUtil::width(inlineBox, startPosition, middle + 1, contentLogicalLeft);
+ auto width = TextUtil::width(inlineTextBox, startPosition, middle + 1, contentLogicalLeft);
if (width < availableWidth) {
left = middle + 1;
leftSideWidth = width;
Modified: trunk/Source/WebCore/layout/inlineformatting/text/TextUtil.h (256303 => 256304)
--- trunk/Source/WebCore/layout/inlineformatting/text/TextUtil.h 2020-02-11 14:08:30 UTC (rev 256303)
+++ trunk/Source/WebCore/layout/inlineformatting/text/TextUtil.h 2020-02-11 15:13:15 UTC (rev 256304)
@@ -37,18 +37,19 @@
namespace Layout {
+class InlineTextBox;
class InlineTextItem;
class TextUtil {
public:
static InlineLayoutUnit width(const InlineTextItem&, unsigned from, unsigned to, InlineLayoutUnit contentLogicalLeft = 0);
- static InlineLayoutUnit width(const Box&, unsigned from, unsigned to, InlineLayoutUnit contentLogicalLeft = 0);
+ static InlineLayoutUnit width(const InlineTextBox&, unsigned from, unsigned to, InlineLayoutUnit contentLogicalLeft = 0);
struct SplitData {
unsigned start { 0 };
unsigned length { 0 };
InlineLayoutUnit logicalWidth { 0 };
};
- static SplitData split(const Box&, unsigned startPosition, unsigned length, InlineLayoutUnit textWidth, InlineLayoutUnit availableWidth, InlineLayoutUnit contentLogicalLeft);
+ static SplitData split(const InlineTextBox&, unsigned startPosition, unsigned length, InlineLayoutUnit textWidth, InlineLayoutUnit availableWidth, InlineLayoutUnit contentLogicalLeft);
static bool shouldPreserveTrailingWhitespace(const RenderStyle&);
static unsigned findNextBreakablePosition(LazyLineBreakIterator&, unsigned startPosition, const RenderStyle&);
Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationBoxTree.cpp (256303 => 256304)
--- trunk/Source/WebCore/layout/integration/LayoutIntegrationBoxTree.cpp 2020-02-11 14:08:30 UTC (rev 256303)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationBoxTree.cpp 2020-02-11 15:13:15 UTC (rev 256304)
@@ -58,9 +58,7 @@
std::unique_ptr<Layout::Box> childBox;
if (is<RenderText>(childRenderer)) {
auto& textRenderer = downcast<RenderText>(childRenderer);
- auto textContent = Layout::TextContext { textRenderer.text(), textRenderer.canUseSimplifiedTextMeasuring() };
- childBox = makeUnique<Layout::Box>(WTFMove(textContent), RenderStyle::createAnonymousStyleWithDisplay(m_root.style(), DisplayType::Inline));
- childBox->setIsAnonymous();
+ childBox = makeUnique<Layout::InlineTextBox>(textRenderer.text(), textRenderer.canUseSimplifiedTextMeasuring(), RenderStyle::createAnonymousStyleWithDisplay(m_root.style(), DisplayType::Inline));
} else if (childRenderer.isLineBreak()) {
auto clonedStyle = RenderStyle::clone(childRenderer.style());
clonedStyle.setDisplay(DisplayType::Inline);
Modified: trunk/Source/WebCore/layout/layouttree/LayoutBox.cpp (256303 => 256304)
--- trunk/Source/WebCore/layout/layouttree/LayoutBox.cpp 2020-02-11 14:08:30 UTC (rev 256303)
+++ trunk/Source/WebCore/layout/layouttree/LayoutBox.cpp 2020-02-11 15:13:15 UTC (rev 256304)
@@ -40,10 +40,9 @@
WTF_MAKE_ISO_ALLOCATED_IMPL(Box);
-Box::Box(Optional<ElementAttributes> attributes, Optional<TextContext> textContext, RenderStyle&& style, BaseTypeFlags baseTypeFlags)
+Box::Box(Optional<ElementAttributes> attributes, RenderStyle&& style, BaseTypeFlags baseTypeFlags)
: m_style(WTFMove(style))
, m_elementAttributes(attributes)
- , m_textContext(textContext)
, m_baseTypeFlags(baseTypeFlags)
, m_hasRareData(false)
, m_isAnonymous(false)
@@ -53,16 +52,10 @@
}
Box::Box(Optional<ElementAttributes> attributes, RenderStyle&& style)
- : Box(attributes, { }, WTFMove(style), BaseTypeFlag::BoxFlag)
+ : Box(attributes, WTFMove(style), BaseTypeFlag::BoxFlag)
{
}
-Box::Box(TextContext&& textContext, RenderStyle&& style)
- : Box({ }, WTFMove(textContext), WTFMove(style), BaseTypeFlag::BoxFlag)
-{
- ASSERT(isInlineLevelBox());
-}
-
Box::~Box()
{
if (UNLIKELY(m_hasRareData))
Modified: trunk/Source/WebCore/layout/layouttree/LayoutBox.h (256303 => 256304)
--- trunk/Source/WebCore/layout/layouttree/LayoutBox.h 2020-02-11 14:08:30 UTC (rev 256303)
+++ trunk/Source/WebCore/layout/layouttree/LayoutBox.h 2020-02-11 15:13:15 UTC (rev 256304)
@@ -29,7 +29,6 @@
#include "LayoutReplaced.h"
#include "RenderStyle.h"
-#include "TextContext.h"
#include <wtf/IsoMalloc.h>
#include <wtf/WeakPtr.h>
@@ -64,14 +63,14 @@
};
enum BaseTypeFlag {
- BoxFlag = 1 << 0,
- ContainerFlag = 1 << 1
+ BoxFlag = 1 << 0,
+ InlineTextBox = 1 << 1,
+ ContainerFlag = 1 << 2
};
typedef unsigned BaseTypeFlags;
Box(Optional<ElementAttributes>, RenderStyle&&);
- Box(TextContext&&, RenderStyle&&);
- ~Box();
+ virtual ~Box();
bool establishesFormattingContext() const;
bool establishesBlockFormattingContext() const;
@@ -142,6 +141,7 @@
Box* nextSibling() { return m_nextSibling; }
bool isContainer() const { return m_baseTypeFlags & ContainerFlag; }
+ bool isInlineTextBox() const { return m_baseTypeFlags & InlineTextBox; }
bool isPaddingApplicable() const;
bool isOverflowVisible() const;
@@ -152,8 +152,6 @@
const Replaced* replaced() const;
// FIXME: Temporary until after intrinsic size change is tracked by Replaced.
Replaced* replaced();
- bool hasTextContent() const { return !!m_textContext; }
- const Optional<TextContext>& textContext() const { return m_textContext; }
// FIXME: Find a better place for random DOM things.
void setRowSpan(unsigned);
@@ -176,7 +174,7 @@
void setCachedDisplayBoxForLayoutState(LayoutState&, std::unique_ptr<Display::Box>) const;
protected:
- Box(Optional<ElementAttributes>, Optional<TextContext>, RenderStyle&&, BaseTypeFlags);
+ Box(Optional<ElementAttributes>, RenderStyle&&, BaseTypeFlags);
private:
class BoxRareData {
@@ -207,8 +205,6 @@
Box* m_previousSibling { nullptr };
Box* m_nextSibling { nullptr };
- const Optional<TextContext> m_textContext;
-
// First LayoutState gets a direct cache.
mutable WeakPtr<LayoutState> m_cachedLayoutState;
mutable std::unique_ptr<Display::Box> m_cachedDisplayBoxForLayoutState;
Modified: trunk/Source/WebCore/layout/layouttree/LayoutContainer.cpp (256303 => 256304)
--- trunk/Source/WebCore/layout/layouttree/LayoutContainer.cpp 2020-02-11 14:08:30 UTC (rev 256303)
+++ trunk/Source/WebCore/layout/layouttree/LayoutContainer.cpp 2020-02-11 15:13:15 UTC (rev 256304)
@@ -37,7 +37,7 @@
WTF_MAKE_ISO_ALLOCATED_IMPL(Container);
Container::Container(Optional<ElementAttributes> attributes, RenderStyle&& style, BaseTypeFlags baseTypeFlags)
- : Box(attributes, { }, WTFMove(style), baseTypeFlags | ContainerFlag)
+ : Box(attributes, WTFMove(style), baseTypeFlags | ContainerFlag)
{
}
Copied: trunk/Source/WebCore/layout/layouttree/LayoutInlineTextBox.cpp (from rev 256303, trunk/Source/WebCore/layout/layouttree/TextContext.h) (0 => 256304)
--- trunk/Source/WebCore/layout/layouttree/LayoutInlineTextBox.cpp (rev 0)
+++ trunk/Source/WebCore/layout/layouttree/LayoutInlineTextBox.cpp 2020-02-11 15:13:15 UTC (rev 256304)
@@ -0,0 +1,50 @@
+/*
+ * 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 "LayoutInlineTextBox.h"
+
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+
+#include "RenderStyle.h"
+#include <wtf/IsoMallocInlines.h>
+
+namespace WebCore {
+namespace Layout {
+
+WTF_MAKE_ISO_ALLOCATED_IMPL(InlineTextBox);
+
+InlineTextBox::InlineTextBox(String content, bool canUseSimplifiedContentMeasuring, RenderStyle&& style)
+ : Box({ }, WTFMove(style), Box::InlineTextBox)
+ , m_content(content)
+ , m_canUseSimplifiedContentMeasuring(canUseSimplifiedContentMeasuring)
+{
+ setIsAnonymous();
+}
+
+}
+}
+
+#endif
Copied: trunk/Source/WebCore/layout/layouttree/LayoutInlineTextBox.h (from rev 256303, trunk/Source/WebCore/layout/layouttree/TextContext.h) (0 => 256304)
--- trunk/Source/WebCore/layout/layouttree/LayoutInlineTextBox.h (rev 0)
+++ trunk/Source/WebCore/layout/layouttree/LayoutInlineTextBox.h 2020-02-11 15:13:15 UTC (rev 256304)
@@ -0,0 +1,57 @@
+/*
+ * 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 "LayoutBox.h"
+#include <wtf/IsoMalloc.h>
+
+namespace WebCore {
+
+namespace Layout {
+
+class InlineTextBox : public Box {
+ WTF_MAKE_ISO_ALLOCATED(InlineTextBox);
+public:
+ InlineTextBox(String, bool canUseSimplifiedContentMeasuring, RenderStyle&&);
+ virtual ~InlineTextBox() = default;
+
+ String content() const { return m_content; }
+ // FIXME: This should not be a box's property.
+ bool canUseSimplifiedContentMeasuring() const { return m_canUseSimplifiedContentMeasuring; }
+
+private:
+ String m_content;
+ bool m_canUseSimplifiedContentMeasuring { false };
+};
+
+}
+}
+
+SPECIALIZE_TYPE_TRAITS_LAYOUT_BOX(InlineTextBox, isInlineTextBox())
+
+#endif
Modified: trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp (256303 => 256304)
--- trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp 2020-02-11 14:08:30 UTC (rev 256303)
+++ trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp 2020-02-11 15:13:15 UTC (rev 256304)
@@ -42,6 +42,7 @@
#include "LayoutContainer.h"
#include "LayoutContext.h"
#include "LayoutDescendantIterator.h"
+#include "LayoutInlineTextBox.h"
#include "LayoutPhase.h"
#include "LayoutSize.h"
#include "LayoutState.h"
@@ -150,9 +151,9 @@
return box;
}
-Box& TreeBuilder::createTextBox(TextContext&& textContent, RenderStyle&& style)
+Box& TreeBuilder::createTextBox(String text, bool canUseSimplifiedTextMeasuring, RenderStyle&& style)
{
- auto newBox = makeUnique<Box>(WTFMove(textContent), WTFMove(style));
+ auto newBox = makeUnique<InlineTextBox>(text, canUseSimplifiedTextMeasuring, WTFMove(style));
auto& box = *newBox;
m_layoutTreeContent.addBox(WTFMove(newBox));
return box;
@@ -191,12 +192,11 @@
auto& textRenderer = downcast<RenderText>(childRenderer);
// RenderText::text() has already applied text-transform and text-security properties.
String text = textRenderer.text();
- auto textContent = TextContext { text, canUseSimplifiedTextMeasuring(text, parentContainer.style().fontCascade(), parentContainer.style().collapseWhiteSpace()) };
+ auto useSimplifiedTextMeasuring = canUseSimplifiedTextMeasuring(text, parentContainer.style().fontCascade(), parentContainer.style().collapseWhiteSpace());
if (parentContainer.style().display() == DisplayType::Inline)
- childLayoutBox = &createTextBox(WTFMove(textContent), RenderStyle::clone(parentContainer.style()));
+ childLayoutBox = &createTextBox(text, useSimplifiedTextMeasuring, RenderStyle::clone(parentContainer.style()));
else
- childLayoutBox = &createTextBox(WTFMove(textContent), RenderStyle::createAnonymousStyleWithDisplay(parentContainer.style(), DisplayType::Inline));
- childLayoutBox->setIsAnonymous();
+ childLayoutBox = &createTextBox(text, useSimplifiedTextMeasuring, RenderStyle::createAnonymousStyleWithDisplay(parentContainer.style(), DisplayType::Inline));
} else {
auto& renderer = downcast<RenderElement>(childRenderer);
auto displayType = renderer.style().display();
@@ -406,8 +406,8 @@
if (displayBox)
stream << " at (" << displayBox->left() << "," << displayBox->top() << ") size " << displayBox->width() << "x" << displayBox->height();
stream << " layout box->(" << &layoutBox << ")";
- if (layoutBox.isInlineLevelBox() && layoutBox.isAnonymous())
- stream << " text content [\"" << layoutBox.textContext()->content.utf8().data() << "\"]";
+ if (is<InlineTextBox>(layoutBox))
+ stream << " text content [\"" << downcast<InlineTextBox>(layoutBox).content().utf8().data() << "\"]";
stream.nextLine();
}
Modified: trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.h (256303 => 256304)
--- trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.h 2020-02-11 14:08:30 UTC (rev 256303)
+++ trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.h 2020-02-11 15:13:15 UTC (rev 256304)
@@ -91,7 +91,7 @@
Box* createLayoutBox(const Container& parentContainer, const RenderObject& childRenderer);
Box& createBox(Optional<Box::ElementAttributes>, RenderStyle&&);
- Box& createTextBox(TextContext&&, RenderStyle&&);
+ Box& createTextBox(String text, bool canUseSimplifiedTextMeasuring, RenderStyle&&);
Container& createContainer(Optional<Box::ElementAttributes>, RenderStyle&&);
LayoutTreeContent& m_layoutTreeContent;
Deleted: trunk/Source/WebCore/layout/layouttree/TextContext.h (256303 => 256304)
--- trunk/Source/WebCore/layout/layouttree/TextContext.h 2020-02-11 14:08:30 UTC (rev 256303)
+++ trunk/Source/WebCore/layout/layouttree/TextContext.h 2020-02-11 15:13:15 UTC (rev 256304)
@@ -1,44 +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 <wtf/text/StringView.h>
-
-namespace WebCore {
-namespace Layout {
-
-struct TextContext {
- WTF_MAKE_FAST_ALLOCATED;
-public:
- String content;
- bool canUseSimplifiedContentMeasuring { false };
-};
-
-}
-}
-#endif