Title: [258073] trunk/Source/WebCore
- Revision
- 258073
- Author
- [email protected]
- Date
- 2020-03-07 09:52:14 -0800 (Sat, 07 Mar 2020)
Log Message
[LFC][IFC] Use start-aligned horizontal adjustment when justify is not eligible.
https://bugs.webkit.org/show_bug.cgi?id=208762
<rdar://problem/60188433>
Reviewed by Antti Koivisto.
Make sure we apply "text-align: start" when "text-align: justify" is not eligible.
Currently "text-align: start" is a no-op, so no chnange in functionality (this might change in the future).
* layout/inlineformatting/InlineLineBuilder.cpp:
(WebCore::Layout::LineBuilder::alignHorizontally):
(WebCore::Layout::LineBuilder::removeTrailingTrimmableContent):
* layout/inlineformatting/InlineLineBuilder.h:
(WebCore::Layout::LineBuilder::isTextAlignJustify const): Deleted.
(WebCore::Layout::LineBuilder::isTextAlignRight const): Deleted.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (258072 => 258073)
--- trunk/Source/WebCore/ChangeLog 2020-03-07 17:26:21 UTC (rev 258072)
+++ trunk/Source/WebCore/ChangeLog 2020-03-07 17:52:14 UTC (rev 258073)
@@ -1,5 +1,23 @@
2020-03-07 Zalan Bujtas <[email protected]>
+ [LFC][IFC] Use start-aligned horizontal adjustment when justify is not eligible.
+ https://bugs.webkit.org/show_bug.cgi?id=208762
+ <rdar://problem/60188433>
+
+ Reviewed by Antti Koivisto.
+
+ Make sure we apply "text-align: start" when "text-align: justify" is not eligible.
+ Currently "text-align: start" is a no-op, so no chnange in functionality (this might change in the future).
+
+ * layout/inlineformatting/InlineLineBuilder.cpp:
+ (WebCore::Layout::LineBuilder::alignHorizontally):
+ (WebCore::Layout::LineBuilder::removeTrailingTrimmableContent):
+ * layout/inlineformatting/InlineLineBuilder.h:
+ (WebCore::Layout::LineBuilder::isTextAlignJustify const): Deleted.
+ (WebCore::Layout::LineBuilder::isTextAlignRight const): Deleted.
+
+2020-03-07 Zalan Bujtas <[email protected]>
+
[LFC][IFC] Do not text-align: justify the runs on the current line if they are followed by a forced break
https://bugs.webkit.org/show_bug.cgi?id=208761
<rdar://problem/59825136>
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.cpp (258072 => 258073)
--- trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.cpp 2020-03-07 17:26:21 UTC (rev 258072)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.cpp 2020-03-07 17:52:14 UTC (rev 258073)
@@ -236,20 +236,30 @@
void LineBuilder::alignHorizontally(const HangingContent& hangingContent, IsLastLineWithInlineContent isLastLine)
{
ASSERT(!m_isIntrinsicSizing);
+
auto availableWidth = this->availableWidth() + hangingContent.width();
if (m_runs.isEmpty() || availableWidth <= 0)
return;
- if (isTextAlignJustify()) {
- // Unless otherwise specified by text-align-last, the last line before a forced break or
- // the end of the block is start-aligned.
- if (!m_runs.last().isLineBreak() && isLastLine == IsLastLineWithInlineContent::No)
- justifyRuns(availableWidth);
+ auto computedHorizontalAlignment = [&] {
+ ASSERT(m_horizontalAlignment);
+ if (m_horizontalAlignment != TextAlignMode::Justify)
+ return *m_horizontalAlignment;
+ // Text is justified according to the method specified by the text-justify property,
+ // in order to exactly fill the line box. Unless otherwise specified by text-align-last,
+ // the last line before a forced break or the end of the block is start-aligned.
+ if (m_runs.last().isLineBreak() || isLastLine == IsLastLineWithInlineContent::Yes)
+ return TextAlignMode::Start;
+ return TextAlignMode::Justify;
+ }();
+
+ if (computedHorizontalAlignment == TextAlignMode::Justify) {
+ justifyRuns(availableWidth);
return;
}
- auto adjustmentForAlignment = [&]() -> Optional<InlineLayoutUnit> {
- switch (*m_horizontalAlignment) {
+ auto adjustmentForAlignment = [] (auto horizontalAlignment, auto availableWidth) -> Optional<InlineLayoutUnit> {
+ switch (horizontalAlignment) {
case TextAlignMode::Left:
case TextAlignMode::WebKitLeft:
case TextAlignMode::Start:
@@ -269,7 +279,7 @@
return { };
};
- auto adjustment = adjustmentForAlignment();
+ auto adjustment = adjustmentForAlignment(computedHorizontalAlignment, availableWidth);
if (!adjustment)
return;
// Horizontal alignment means that we not only adjust the runs but also make sure
@@ -288,7 +298,14 @@
// Complex line layout quirk: keep the trailing whitespace around when it is followed by a line break, unless the content overflows the line.
if (RuntimeEnabledFeatures::sharedFeatures().layoutFormattingContextIntegrationEnabled()) {
- if (m_runs.last().isLineBreak() && availableWidth() >= 0 && !isTextAlignRight()) {
+ auto isTextAlignRight = [&] {
+ ASSERT(m_horizontalAlignment);
+ return m_horizontalAlignment == TextAlignMode::Right
+ || m_horizontalAlignment == TextAlignMode::WebKitRight
+ || m_horizontalAlignment == TextAlignMode::End;
+ }();
+
+ if (m_runs.last().isLineBreak() && availableWidth() >= 0 && !isTextAlignRight) {
m_trimmableTrailingContent.reset();
return;
}
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.h (258072 => 258073)
--- trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.h 2020-03-07 17:26:21 UTC (rev 258072)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.h 2020-03-07 17:52:14 UTC (rev 258073)
@@ -186,8 +186,6 @@
void adjustBaselineAndLineHeight(const Run&);
InlineLayoutUnit runContentHeight(const Run&) const;
- bool isTextAlignJustify() const { return m_horizontalAlignment == TextAlignMode::Justify; };
- bool isTextAlignRight() const { return m_horizontalAlignment == TextAlignMode::Right || m_horizontalAlignment == TextAlignMode::WebKitRight || m_horizontalAlignment == TextAlignMode::End; }
void justifyRuns(InlineLayoutUnit availableWidth);
bool isVisuallyNonEmpty(const Run&) const;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes