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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * (C) 1999 Lars Knoll (knoll@kde.org) 2 * (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 2000 Dirk Mueller (mueller@kde.org) 3 * (C) 2000 Dirk Mueller (mueller@kde.org)
4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. 4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 } else { 181 } else {
182 ellipsis->setSelectionState(SelectionNone); 182 ellipsis->setSelectionState(SelectionNone);
183 } 183 }
184 } 184 }
185 185
186 return state; 186 return state;
187 } 187 }
188 188
189 bool InlineTextBox::hasWrappedSelectionNewline() const { 189 bool InlineTextBox::hasWrappedSelectionNewline() const {
190 DCHECK(!getLineLayoutItem().needsLayout()); 190 DCHECK(!getLineLayoutItem().needsLayout());
191
191 SelectionState state = getSelectionState(); 192 SelectionState state = getSelectionState();
192 return (state == SelectionStart || state == SelectionInside) 193 if (state != SelectionStart && state != SelectionInside)
193 // Checking last leaf child can be slow, so we make sure to do this 194 return false;
194 // only after the other simple conditionals. 195
195 && (root().lastLeafChild() == this) 196 // Checking last leaf child can be slow, so we make sure to do this
196 // It's possible to have mixed LTR/RTL on a single line, and we only 197 // only after checking selection state.
197 // want to paint a newline when we're the last leaf child and we make 198 if (root().lastLeafChild() != this)
198 // sure there isn't a differently-directioned box following us. 199 return false;
199 && ((!isLeftToRightDirection() && root().firstSelectedBox() == this) || 200
200 (isLeftToRightDirection() && root().lastSelectedBox() == this)); 201 // It's possible to have mixed LTR/RTL on a single line, and we only
202 // want to paint a newline when we're the last leaf child and we make
203 // sure there isn't a differently-directioned box following us.
204 bool isLTR = isLeftToRightDirection();
205 if ((!isLTR && root().firstSelectedBox() != this) ||
206 (isLTR && root().lastSelectedBox() != this))
207 return false;
208
209 // If we're the last inline text box in containing block, our containing block
210 // is inline, and the selection continues into that block, then rely on the
211 // next inline text box (if any) to paint a wrapped new line as needed.
212 if (nextTextBox())
213 return true;
214 auto rootBlock = root().block();
215 if (rootBlock.isInline() && rootBlock.getSelectionState() != SelectionEnd &&
216 rootBlock.getSelectionState() != SelectionBoth &&
217 rootBlock.inlineBoxWrapper() &&
218 ((isLTR && rootBlock.inlineBoxWrapper()->nextOnLine()) ||
219 (!isLTR && rootBlock.inlineBoxWrapper()->prevOnLine()))) {
220 return false;
221 }
222
223 return true;
201 } 224 }
202 225
203 float InlineTextBox::newlineSpaceWidth() const { 226 float InlineTextBox::newlineSpaceWidth() const {
204 const ComputedStyle& styleToUse = 227 const ComputedStyle& styleToUse =
205 getLineLayoutItem().styleRef(isFirstLineStyle()); 228 getLineLayoutItem().styleRef(isFirstLineStyle());
206 return styleToUse.font().spaceWidth(); 229 return styleToUse.font().spaceWidth();
207 } 230 }
208 231
209 LayoutRect InlineTextBox::localSelectionRect(int startPos, int endPos) const { 232 LayoutRect InlineTextBox::localSelectionRect(int startPos, int endPos) const {
210 int sPos = std::max(startPos - m_start, 0); 233 int sPos = std::max(startPos - m_start, 0);
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
686 const int layoutObjectCharacterOffset = 75; 709 const int layoutObjectCharacterOffset = 75;
687 for (; printedCharacters < layoutObjectCharacterOffset; printedCharacters++) 710 for (; printedCharacters < layoutObjectCharacterOffset; printedCharacters++)
688 fputc(' ', stderr); 711 fputc(' ', stderr);
689 fprintf(stderr, "(%d,%d) \"%s\"\n", start(), start() + len(), 712 fprintf(stderr, "(%d,%d) \"%s\"\n", start(), start() + len(),
690 value.utf8().data()); 713 value.utf8().data());
691 } 714 }
692 715
693 #endif 716 #endif
694 717
695 } // namespace blink 718 } // namespace blink
OLDNEW
« 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