WebKit Bugzilla
Attachment 371229 Details for
Bug 198503
: [LFC][IFC] Add hard line break handling to LineBreaker
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-198503-20190603164308.patch (text/plain), 6.46 KB, created by
zalan
on 2019-06-03 16:43:10 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
zalan
Created:
2019-06-03 16:43:10 PDT
Size:
6.46 KB
patch
obsolete
>Subversion Revision: 246027 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 92f3ad00cbcf12694f0eee5a889bf1cf5bb686df..d1f71cd4bd0eed8e8556df67a2e987bde91cdbc5 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,21 @@ >+2019-06-03 Zalan Bujtas <zalan@apple.com> >+ >+ [LFC][IFC] Add hard line break handling to LineBreaker >+ https://bugs.webkit.org/show_bug.cgi?id=198503 >+ <rdar://problem/51373482> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ LineBreaker should simply return BreakingContext::Keep with the breaking opportunity of yes. >+ >+ * layout/inlineformatting/InlineFormattingContextLineLayout.cpp: >+ (WebCore::Layout::InlineFormattingContext::LineLayout::placeInlineItems const): >+ * layout/inlineformatting/InlineLineBreaker.cpp: >+ (WebCore::Layout::LineBreaker::breakingContext): >+ (WebCore::Layout::LineBreaker::wordBreakingBehavior const): >+ (WebCore::Layout::LineBreaker::isAtBreakingOpportunity): >+ * layout/inlineformatting/InlineLineBreaker.h: >+ > 2019-06-03 Zalan Bujtas <zalan@apple.com> > > [LFC][IFC] Remove InlineItem::width >diff --git a/Source/WebCore/layout/inlineformatting/InlineFormattingContextLineLayout.cpp b/Source/WebCore/layout/inlineformatting/InlineFormattingContextLineLayout.cpp >index b7d19cb6a614a889bf78841eb7dfe1f4cd105b91..b93cd9e746be4a8366d86904d4e6de8e822e1ffe 100644 >--- a/Source/WebCore/layout/inlineformatting/InlineFormattingContextLineLayout.cpp >+++ b/Source/WebCore/layout/inlineformatting/InlineFormattingContextLineLayout.cpp >@@ -214,11 +214,6 @@ InlineFormattingContext::LineLayout::LineContent InlineFormattingContext::LineLa > auto& inlineItem = lineInput.inlineItems[inlineItemIndex]; > auto inlineItemWidth = WebCore::Layout::inlineItemWidth(layoutState(), *inlineItem, currentLogicalRight); > >- if (inlineItem->isHardLineBreak()) { >- uncommittedContent.add(*inlineItem, inlineItemWidth); >- commitPendingContent(); >- return closeLine(); >- } > // FIXME: Ensure LineContext::trimmableWidth includes uncommitted content if needed. > auto breakingContext = lineBreaker.breakingContext(*inlineItem, inlineItemWidth, { availableWidth, currentLogicalRight, line->trailingTrimmableWidth(), !line->hasContent() }); > if (breakingContext.isAtBreakingOpportunity) >@@ -229,18 +224,24 @@ InlineFormattingContext::LineLayout::LineContent InlineFormattingContext::LineLa > return closeLine(); > > // Partial content stays on the current line. >- if (breakingContext.breakingBehavior == LineBreaker::BreakingBehavior::Break) { >+ if (breakingContext.breakingBehavior == LineBreaker::BreakingBehavior::Split) { > ASSERT(inlineItem->isText()); > > ASSERT_NOT_IMPLEMENTED_YET(); > return closeLine(); > } > >+ ASSERT(breakingContext.breakingBehavior == LineBreaker::BreakingBehavior::Keep); > if (inlineItem->isFloat()) { > handleFloat(*line, floatingContext, *inlineItem); > ++committedInlineItemCount; > continue; > } >+ if (inlineItem->isHardLineBreak()) { >+ uncommittedContent.add(*inlineItem, inlineItemWidth); >+ commitPendingContent(); >+ return closeLine(); >+ } > > uncommittedContent.add(*inlineItem, inlineItemWidth); > if (breakingContext.isAtBreakingOpportunity) >diff --git a/Source/WebCore/layout/inlineformatting/InlineLineBreaker.cpp b/Source/WebCore/layout/inlineformatting/InlineLineBreaker.cpp >index 2364f6b73a0f429c40fb89c0dd877748b0b5a343..996af40e86e32ca2a313e5a9ada938e11364f50f 100644 >--- a/Source/WebCore/layout/inlineformatting/InlineLineBreaker.cpp >+++ b/Source/WebCore/layout/inlineformatting/InlineLineBreaker.cpp >@@ -40,6 +40,9 @@ LineBreaker::BreakingContext LineBreaker::breakingContext(const InlineItem& inli > if (lineContext.isEmpty || logicalWidth <= lineContext.availableWidth) > return { BreakingBehavior::Keep, isAtBreakingOpportunity(inlineItem) }; > >+ if (inlineItem.isHardLineBreak()) >+ return { BreakingBehavior::Keep, isAtBreakingOpportunity(inlineItem) }; >+ > if (is<InlineTextItem>(inlineItem)) > return { wordBreakingBehavior(downcast<InlineTextItem>(inlineItem), lineContext.isEmpty), isAtBreakingOpportunity(inlineItem) }; > >@@ -62,20 +65,20 @@ LineBreaker::BreakingBehavior LineBreaker::wordBreakingBehavior(const InlineText > auto& style = inlineItem.style(); > > if (inlineItem.isWhitespace()) >- return style.collapseWhiteSpace() ? BreakingBehavior::Wrap : BreakingBehavior::Break; >+ return style.collapseWhiteSpace() ? BreakingBehavior::Wrap : BreakingBehavior::Split; > > auto shouldHypenate = !m_hyphenationIsDisabled && style.hyphens() == Hyphens::Auto && canHyphenate(style.locale()); > if (shouldHypenate) >- return BreakingBehavior::Break; >+ return BreakingBehavior::Split; > > if (style.autoWrap()) { > // Break any word > if (style.wordBreak() == WordBreak::BreakAll) >- return BreakingBehavior::Break; >+ return BreakingBehavior::Split; > > // Break first run on line. > if (lineIsEmpty && style.breakWords() && style.preserveNewline()) >- return BreakingBehavior::Break; >+ return BreakingBehavior::Split; > } > > // Non-breakable non-whitespace run. >@@ -84,6 +87,9 @@ LineBreaker::BreakingBehavior LineBreaker::wordBreakingBehavior(const InlineText > > bool LineBreaker::isAtBreakingOpportunity(const InlineItem& inlineItem) > { >+ if (inlineItem.isHardLineBreak()) >+ return true; >+ > if (is<InlineTextItem>(inlineItem)) > return downcast<InlineTextItem>(inlineItem).isWhitespace(); > return !inlineItem.isFloat() && !inlineItem.isContainerStart() && !inlineItem.isContainerEnd(); >diff --git a/Source/WebCore/layout/inlineformatting/InlineLineBreaker.h b/Source/WebCore/layout/inlineformatting/InlineLineBreaker.h >index 27ec2b8f938959008cda5bb13a6e4af1bb96927b..a845413c0329224b758e7adc6f6406de4448e174 100644 >--- a/Source/WebCore/layout/inlineformatting/InlineLineBreaker.h >+++ b/Source/WebCore/layout/inlineformatting/InlineLineBreaker.h >@@ -34,7 +34,7 @@ class InlineTextItem; > > class LineBreaker { > public: >- enum class BreakingBehavior { Keep, Break, Wrap }; >+ enum class BreakingBehavior { Keep, Split, Wrap }; > struct BreakingContext { > BreakingBehavior breakingBehavior; > bool isAtBreakingOpportunity { false };
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
koivisto
:
review+
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 198503
: 371229