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

Unified Diff: third_party/WebKit/Source/core/layout/line/InlineTextBox.cpp

Issue 2728263002: Omit wrapped selection for text under inline containing block. (Closed)
Patch Set: Update baselines. 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
« no previous file with comments | « third_party/WebKit/LayoutTests/platform/win7/fast/text/flexbox-selection-nested-expected.png ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/layout/line/InlineTextBox.cpp
diff --git a/third_party/WebKit/Source/core/layout/line/InlineTextBox.cpp b/third_party/WebKit/Source/core/layout/line/InlineTextBox.cpp
index ebd781d489b5f128375c412680ba9a373ec7b232..425b875fd0f1515c89bb40e45afac0541596a53f 100644
--- a/third_party/WebKit/Source/core/layout/line/InlineTextBox.cpp
+++ b/third_party/WebKit/Source/core/layout/line/InlineTextBox.cpp
@@ -188,16 +188,39 @@ SelectionState InlineTextBox::getSelectionState() const {
bool InlineTextBox::hasWrappedSelectionNewline() const {
DCHECK(!getLineLayoutItem().needsLayout());
+
SelectionState state = getSelectionState();
- return (state == SelectionStart || state == SelectionInside)
- // Checking last leaf child can be slow, so we make sure to do this
- // only after the other simple conditionals.
- && (root().lastLeafChild() == this)
- // It's possible to have mixed LTR/RTL on a single line, and we only
- // want to paint a newline when we're the last leaf child and we make
- // sure there isn't a differently-directioned box following us.
- && ((!isLeftToRightDirection() && root().firstSelectedBox() == this) ||
- (isLeftToRightDirection() && root().lastSelectedBox() == this));
+ if (state != SelectionStart && state != SelectionInside)
+ return false;
+
+ // Checking last leaf child can be slow, so we make sure to do this
+ // only after checking selection state.
+ if (root().lastLeafChild() != this)
+ return false;
+
+ // It's possible to have mixed LTR/RTL on a single line, and we only
+ // want to paint a newline when we're the last leaf child and we make
+ // sure there isn't a differently-directioned box following us.
+ bool isLTR = isLeftToRightDirection();
+ if ((!isLTR && root().firstSelectedBox() != this) ||
+ (isLTR && root().lastSelectedBox() != this))
+ return false;
+
+ // If we're the last inline text box in containing block, our containing block
+ // is inline, and the selection continues into that block, then rely on the
+ // next inline text box (if any) to paint a wrapped new line as needed.
+ if (nextTextBox())
+ return true;
+ auto rootBlock = root().block();
+ if (rootBlock.isInline() && rootBlock.getSelectionState() != SelectionEnd &&
+ rootBlock.getSelectionState() != SelectionBoth &&
+ rootBlock.inlineBoxWrapper() &&
+ ((isLTR && rootBlock.inlineBoxWrapper()->nextOnLine()) ||
+ (!isLTR && rootBlock.inlineBoxWrapper()->prevOnLine()))) {
+ return false;
+ }
+
+ return true;
}
float InlineTextBox::newlineSpaceWidth() const {
« no previous file with comments | « third_party/WebKit/LayoutTests/platform/win7/fast/text/flexbox-selection-nested-expected.png ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698