Changeset 251843 in webkit
- Timestamp:
- Oct 31, 2019 7:51:34 AM (4 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r251841 r251843 1 2019-10-31 Zalan Bujtas <zalan@apple.com> 2 3 [LFC][IFC] Preserved segment breaks should produce ForcedLineBreak type of InlineItems 4 https://bugs.webkit.org/show_bug.cgi?id=203645 5 <rdar://problem/56763606> 6 7 Reviewed by Antti Koivisto. 8 9 This patch turns preserved segment breaks (e.g. \n) into a ForcedLineBreak. Non-preserved segments breaks are treated as whitespace characters. 10 It fixes a small type mismatch of having an InlineTextItem representing a non-text content (line break). 11 12 * layout/inlineformatting/InlineFormattingContext.cpp: 13 (WebCore::Layout::InlineFormattingContext::collectInlineContent): 14 * layout/inlineformatting/InlineItem.cpp: 15 (WebCore::Layout::InlineItem::InlineItem): 16 (WebCore::Layout::InlineItem::isForcedLineBreak const): Deleted. 17 (WebCore::Layout::InlineItem::isText const): Deleted. 18 * layout/inlineformatting/InlineItem.h: 19 (WebCore::Layout::InlineItem::isText const): 20 (WebCore::Layout::InlineItem::isForcedLineBreak const): 21 (WebCore::Layout::InlineItem::InlineItem): Deleted. 22 * layout/inlineformatting/InlineTextItem.cpp: 23 (WebCore::Layout::InlineTextItem::createAndAppendTextItems): 24 (WebCore::Layout::InlineTextItem::left const): 25 (WebCore::Layout::InlineTextItem::right const): 26 (WebCore::Layout::InlineTextItem::isWhitespace const): Deleted. 27 * layout/inlineformatting/InlineTextItem.h: 28 (WebCore::Layout::InlineTextItem::isWhitespace const): 29 1 30 2019-10-31 Antti Koivisto <antti@apple.com> 2 31 -
trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp
r251633 r251843 354 354 formattingState.addInlineItem(makeUnique<InlineItem>(layoutBox, InlineItem::Type::ContainerEnd)); 355 355 else if (layoutBox.isLineBreakBox()) 356 formattingState.addInlineItem(makeUnique<InlineItem>(layoutBox, InlineItem::Type:: LineBreakBox));356 formattingState.addInlineItem(makeUnique<InlineItem>(layoutBox, InlineItem::Type::ForcedLineBreak)); 357 357 else if (layoutBox.isFloatingPositioned()) 358 358 formattingState.addInlineItem(makeUnique<InlineItem>(layoutBox, InlineItem::Type::Float)); -
trunk/Source/WebCore/layout/inlineformatting/InlineItem.cpp
r251590 r251843 29 29 #if ENABLE(LAYOUT_FORMATTING_CONTEXT) 30 30 31 #include "InlineTextItem.h"32 33 31 namespace WebCore { 34 32 namespace Layout { 35 33 36 bool InlineItem::isForcedLineBreak() const 34 InlineItem::InlineItem(const Box& layoutBox, Type type) 35 : m_layoutBox(layoutBox) 36 , m_type(type) 37 37 { 38 if (type() == Type::LineBreakBox)39 return true;40 if (type() != Type::Text || !static_cast<const InlineTextItem*>(this)->isSegmentBreak())41 return false;42 // Segment break with preserve new line style (white-space: pre, pre-wrap, break-spaces and pre-line)43 return style().preserveNewline();44 }45 46 bool InlineItem::isText() const47 {48 // If this setup turns out to be a perf hit, we could easily switch over to generate-the-narrow-type way.49 return type() == Type::Text && !isForcedLineBreak();50 38 } 51 39 -
trunk/Source/WebCore/layout/inlineformatting/InlineItem.h
r251590 r251843 37 37 WTF_MAKE_FAST_ALLOCATED; 38 38 public: 39 enum class Type { Text, LineBreakBox, Box, Float, ContainerStart, ContainerEnd };39 enum class Type { Text, ForcedLineBreak, Box, Float, ContainerStart, ContainerEnd }; 40 40 InlineItem(const Box& layoutBox, Type); 41 41 … … 44 44 const RenderStyle& style() const { return m_layoutBox.style(); } 45 45 46 bool isText() const ;46 bool isText() const { return type() == Type::Text; } 47 47 bool isBox() const { return type() == Type::Box; } 48 48 bool isFloat() const { return type() == Type::Float; } 49 bool isForcedLineBreak() const ;49 bool isForcedLineBreak() const { return type() == Type::ForcedLineBreak; } 50 50 bool isContainerStart() const { return type() == Type::ContainerStart; } 51 51 bool isContainerEnd() const { return type() == Type::ContainerEnd; } … … 55 55 const Type m_type; 56 56 }; 57 58 inline InlineItem::InlineItem(const Box& layoutBox, Type type)59 : m_layoutBox(layoutBox)60 , m_type(type)61 {62 }63 57 64 58 #define SPECIALIZE_TYPE_TRAITS_INLINE_ITEM(ToValueTypeName, predicate) \ -
trunk/Source/WebCore/layout/inlineformatting/InlineTextItem.cpp
r251554 r251843 96 96 97 97 if (isSegmentBreakCandidate(text[currentPosition])) { 98 inlineContent.append(InlineTextItem::createSegmentBreakItem(inlineBox, currentPosition)); 98 // Segment breaks with preserve new line style (white-space: pre, pre-wrap, break-spaces and pre-line) compute to forced line break. 99 inlineContent.append(style.preserveNewline() ? makeUnique<InlineItem>(inlineBox, Type::ForcedLineBreak) 100 : InlineTextItem::createSegmentBreakItem(inlineBox, currentPosition)); 99 101 ++currentPosition; 100 102 continue; … … 149 151 { 150 152 RELEASE_ASSERT(length <= this->length()); 151 ASSERT(!isSegmentBreak());152 153 ASSERT(m_textItemType != TextItemType::Undefined); 153 154 return makeUnique<InlineTextItem>(layoutBox(), start(), length, m_textItemType); … … 157 158 { 158 159 RELEASE_ASSERT(length <= this->length()); 159 ASSERT(!isSegmentBreak());160 160 ASSERT(m_textItemType != TextItemType::Undefined); 161 161 return makeUnique<InlineTextItem>(layoutBox(), end() - length, length, m_textItemType); 162 }163 164 bool InlineTextItem::isWhitespace() const165 {166 if (isSegmentBreak())167 return !style().preserveNewline();168 return m_textItemType == TextItemType::Whitespace;169 162 } 170 163 -
trunk/Source/WebCore/layout/inlineformatting/InlineTextItem.h
r251590 r251843 47 47 unsigned length() const { return m_length; } 48 48 49 bool isWhitespace() const ;49 bool isWhitespace() const { return m_textItemType == TextItemType::Whitespace || isSegmentBreak(); } 50 50 bool isCollapsible() const { return isWhitespace() && style().collapseWhiteSpace(); } 51 51 bool isSegmentBreak() const { return m_textItemType == TextItemType::SegmentBreak; }
Note: See TracChangeset
for help on using the changeset viewer.