Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(460)

Unified Diff: third_party/WebKit/Source/core/layout/LayoutBlockFlowLine.cpp

Issue 2786753002: Fix text-align: center/right when line wraps at atomic inline and spaces (Closed)
Patch Set: Rebase Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/layout/LayoutBlockFlowLine.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutBlockFlowLine.cpp b/third_party/WebKit/Source/core/layout/LayoutBlockFlowLine.cpp
index 55223fbd5d9cf90b717ffb3a9f667f4d65add31c..4f9a1dfdbd6d1791e580ad24bbb13d78ddfb7c1f 100644
--- a/third_party/WebKit/Source/core/layout/LayoutBlockFlowLine.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutBlockFlowLine.cpp
@@ -383,6 +383,27 @@ ETextAlign LayoutBlockFlow::textAlignmentForLine(bool endsWithSoftBreak) const {
return alignment;
}
+static bool textAlignmentNeedsTrailingSpace(ETextAlign textAlign,
+ const ComputedStyle& style) {
+ switch (textAlign) {
+ case ETextAlign::kLeft:
+ case ETextAlign::kWebkitLeft:
+ return false;
+ case ETextAlign::kRight:
+ case ETextAlign::kWebkitRight:
+ case ETextAlign::kCenter:
+ case ETextAlign::kWebkitCenter:
+ case ETextAlign::kJustify:
+ return style.collapseWhiteSpace();
+ case ETextAlign::kStart:
+ return style.collapseWhiteSpace() && !style.isLeftToRightDirection();
+ case ETextAlign::kEnd:
+ return style.collapseWhiteSpace() && style.isLeftToRightDirection();
+ }
+ NOTREACHED();
+ return false;
+}
+
static void updateLogicalWidthForLeftAlignedBlock(
bool isLeftToRightDirection,
BidiRun* trailingSpaceRun,
@@ -752,8 +773,6 @@ void LayoutBlockFlow::computeInlineDirectionPositionsForLine(
GlyphOverflowAndFallbackFontsMap& textBoxDataMap,
VerticalPositionCache& verticalPositionCache,
const WordMeasurements& wordMeasurements) {
- ETextAlign textAlign =
- textAlignmentForLine(!reachedEnd && !lineBox->endsWithBreak());
// CSS 2.1: "'Text-indent' only affects a line if it is the first formatted
// line of an element. For example, the first line of an anonymous block
@@ -784,8 +803,8 @@ void LayoutBlockFlow::computeInlineDirectionPositionsForLine(
}
computeInlineDirectionPositionsForSegment(
- lineBox, lineInfo, textAlign, lineLogicalLeft, availableLogicalWidth,
- firstRun, trailingSpaceRun, textBoxDataMap, verticalPositionCache,
+ lineBox, lineInfo, lineLogicalLeft, availableLogicalWidth, firstRun,
+ trailingSpaceRun, textBoxDataMap, verticalPositionCache,
wordMeasurements);
// The widths of all runs are now known. We can now place every inline box
// (and compute accurate widths for the inline flow boxes).
@@ -796,7 +815,6 @@ void LayoutBlockFlow::computeInlineDirectionPositionsForLine(
BidiRun* LayoutBlockFlow::computeInlineDirectionPositionsForSegment(
RootInlineBox* lineBox,
const LineInfo& lineInfo,
- ETextAlign textAlign,
LayoutUnit& logicalLeft,
LayoutUnit& availableLogicalWidth,
BidiRun* firstRun,
@@ -809,6 +827,7 @@ BidiRun* LayoutBlockFlow::computeInlineDirectionPositionsForSegment(
bool isAfterExpansion = true;
ExpansionOpportunities expansions;
LayoutObject* previousObject = nullptr;
+ ETextAlign textAlign = lineInfo.textAlign();
TextJustify textJustify = style()->getTextJustify();
BidiRun* r = firstRun;
@@ -1160,6 +1179,14 @@ void LayoutBlockFlow::layoutRunsAndFloatsInRange(
resolver.setStatus(
BidiStatus(direction, isOverride(styleToUse.getUnicodeBidi())));
}
+
+ ETextAlign textAlign = textAlignmentForLine(
+ !endOfLine.atEnd() &&
+ !layoutState.lineInfo().previousLineBrokeCleanly());
+ layoutState.lineInfo().setTextAlign(textAlign);
+ resolver.setNeedsTrailingSpace(
+ textAlignmentNeedsTrailingSpace(textAlign, styleToUse));
+
// FIXME: This ownership is reversed. We should own the BidiRunList and
// pass it to createBidiRunsForLine.
BidiRunList<BidiRun>& bidiRuns = resolver.runs();
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutBlockFlow.h ('k') | third_party/WebKit/Source/core/layout/line/InlineIterator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698