Title: [272332] trunk/Source/WebCore
- Revision
- 272332
- Author
- [email protected]
- Date
- 2021-02-03 11:48:24 -0800 (Wed, 03 Feb 2021)
Log Message
[LFC][IFC] Move away from using RenderStyle::preserveNewline
https://bugs.webkit.org/show_bug.cgi?id=221338
Reviewed by Antti Koivisto.
RenderStyle should just be a collection of setter and getter functions.
* layout/inlineformatting/InlineTextItem.cpp:
(WebCore::Layout::InlineTextItem::createAndAppendTextItems):
* layout/inlineformatting/text/TextUtil.cpp:
(WebCore::Layout::TextUtil::shouldPreserveSpacesAndTabs):
(WebCore::Layout::TextUtil::shouldPreserveNewline):
* layout/inlineformatting/text/TextUtil.h:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (272331 => 272332)
--- trunk/Source/WebCore/ChangeLog 2021-02-03 18:41:16 UTC (rev 272331)
+++ trunk/Source/WebCore/ChangeLog 2021-02-03 19:48:24 UTC (rev 272332)
@@ -1,3 +1,19 @@
+2021-02-03 Zalan Bujtas <[email protected]>
+
+ [LFC][IFC] Move away from using RenderStyle::preserveNewline
+ https://bugs.webkit.org/show_bug.cgi?id=221338
+
+ Reviewed by Antti Koivisto.
+
+ RenderStyle should just be a collection of setter and getter functions.
+
+ * layout/inlineformatting/InlineTextItem.cpp:
+ (WebCore::Layout::InlineTextItem::createAndAppendTextItems):
+ * layout/inlineformatting/text/TextUtil.cpp:
+ (WebCore::Layout::TextUtil::shouldPreserveSpacesAndTabs):
+ (WebCore::Layout::TextUtil::shouldPreserveNewline):
+ * layout/inlineformatting/text/TextUtil.h:
+
2021-02-03 Simon Fraser <[email protected]>
Optimize PointerCaptureController::elementWasRemoved()
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineTextItem.cpp (272331 => 272332)
--- trunk/Source/WebCore/layout/inlineformatting/InlineTextItem.cpp 2021-02-03 18:41:16 UTC (rev 272331)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineTextItem.cpp 2021-02-03 19:48:24 UTC (rev 272332)
@@ -73,6 +73,7 @@
auto& style = inlineTextBox.style();
auto& font = style.fontCascade();
auto whitespaceContentIsTreatedAsSingleSpace = !TextUtil::shouldPreserveSpacesAndTabs(inlineTextBox);
+ auto shouldPreseveNewline = TextUtil::shouldPreserveNewline(inlineTextBox);
LazyLineBreakIterator lineBreakIterator(text);
unsigned currentPosition = 0;
@@ -88,13 +89,13 @@
};
// 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()) {
+ if (isSegmentBreakCandidate(text[currentPosition]) && shouldPreseveNewline) {
inlineContent.append(InlineSoftLineBreakItem::createSoftLineBreakItem(inlineTextBox, currentPosition));
++currentPosition;
continue;
}
- if (auto length = moveToNextNonWhitespacePosition(text, currentPosition, style.preserveNewline())) {
+ if (auto length = moveToNextNonWhitespacePosition(text, currentPosition, shouldPreseveNewline)) {
auto appendWhitespaceItem = [&] (auto startPosition, auto itemLength) {
auto simpleSingleWhitespaceContent = inlineTextBox.canUseSimplifiedContentMeasuring() && (itemLength == 1 || whitespaceContentIsTreatedAsSingleSpace);
auto width = simpleSingleWhitespaceContent ? makeOptional(InlineLayoutUnit { font.spaceWidth() }) : inlineItemWidth(startPosition, itemLength);
Modified: trunk/Source/WebCore/layout/inlineformatting/text/TextUtil.cpp (272331 => 272332)
--- trunk/Source/WebCore/layout/inlineformatting/text/TextUtil.cpp 2021-02-03 18:41:16 UTC (rev 272331)
+++ trunk/Source/WebCore/layout/inlineformatting/text/TextUtil.cpp 2021-02-03 19:48:24 UTC (rev 272332)
@@ -160,10 +160,18 @@
bool TextUtil::shouldPreserveSpacesAndTabs(const Box& layoutBox)
{
+ // https://www.w3.org/TR/css-text-3/#white-space-property
auto whitespace = layoutBox.style().whiteSpace();
return whitespace == WhiteSpace::Pre || whitespace == WhiteSpace::PreWrap || whitespace == WhiteSpace::BreakSpaces;
}
+bool TextUtil::shouldPreserveNewline(const Box& layoutBox)
+{
+ auto whitespace = layoutBox.style().whiteSpace();
+ // https://www.w3.org/TR/css-text-3/#white-space-property
+ return whitespace == WhiteSpace::Pre || whitespace == WhiteSpace::PreWrap || whitespace == WhiteSpace::BreakSpaces || whitespace == WhiteSpace::PreLine;
}
+
}
+}
#endif
Modified: trunk/Source/WebCore/layout/inlineformatting/text/TextUtil.h (272331 => 272332)
--- trunk/Source/WebCore/layout/inlineformatting/text/TextUtil.h 2021-02-03 18:41:16 UTC (rev 272331)
+++ trunk/Source/WebCore/layout/inlineformatting/text/TextUtil.h 2021-02-03 19:48:24 UTC (rev 272332)
@@ -55,6 +55,7 @@
static unsigned findNextBreakablePosition(LazyLineBreakIterator&, unsigned startPosition, const RenderStyle&);
static bool shouldPreserveSpacesAndTabs(const Box&);
+ static bool shouldPreserveNewline(const Box&);
private:
static InlineLayoutUnit fixedPitchWidth(const StringView&, const RenderStyle&, unsigned from, unsigned to, InlineLayoutUnit contentLogicalLeft);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes