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

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

Issue 2546473003: Simplify computation of text selection top/bottom. (Closed)
Patch Set: Add new baselines. Created 4 years 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/win/paint/text/selection-no-clip-text-expected.txt ('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/RootInlineBox.cpp
diff --git a/third_party/WebKit/Source/core/layout/line/RootInlineBox.cpp b/third_party/WebKit/Source/core/layout/line/RootInlineBox.cpp
index cf52c32d61acb3c5cfbade7d8c9290da60a46619..811f819a068feb7ec6e953c6089c4a9c91c45146 100644
--- a/third_party/WebKit/Source/core/layout/line/RootInlineBox.cpp
+++ b/third_party/WebKit/Source/core/layout/line/RootInlineBox.cpp
@@ -389,7 +389,6 @@ InlineBox* RootInlineBox::lastSelectedBox() const {
LayoutUnit RootInlineBox::selectionTop() const {
LayoutUnit selectionTop = m_lineTop;
-
if (m_hasAnnotationsBefore)
selectionTop -= !getLineLayoutItem().style()->isFlippedLinesWritingMode()
? computeOverAnnotationAdjustment(m_lineTop)
@@ -399,25 +398,7 @@ LayoutUnit RootInlineBox::selectionTop() const {
!prevRootBox())
return selectionTop;
- LayoutUnit prevBottom = prevRootBox()->selectionBottom();
- if (prevBottom < selectionTop && block().containsFloats()) {
- // This line has actually been moved further down, probably from a large
pdr. 2016/12/01 21:54:48 I traced this code back 12 years and found it was
eae 2016/12/02 10:12:30 Nice detective work there pdr!
- // line-height, but possibly because the line was forced to clear floats.
- // If so, let's check the offsets, and only be willing to use the previous
- // line's bottom if the offsets are greater on both sides.
- LayoutUnit prevLeft =
- block().logicalLeftOffsetForLine(prevBottom, DoNotIndentText);
- LayoutUnit prevRight =
- block().logicalRightOffsetForLine(prevBottom, DoNotIndentText);
- LayoutUnit newLeft =
- block().logicalLeftOffsetForLine(selectionTop, DoNotIndentText);
- LayoutUnit newRight =
- block().logicalRightOffsetForLine(selectionTop, DoNotIndentText);
- if (prevLeft > newLeft || prevRight < newRight)
- return selectionTop;
- }
-
- return prevBottom;
+ return std::min(selectionTop, prevRootBox()->selectionBottom());
}
LayoutUnit RootInlineBox::selectionBottom() const {
@@ -434,25 +415,7 @@ LayoutUnit RootInlineBox::selectionBottom() const {
!nextRootBox())
return selectionBottom;
- LayoutUnit nextTop = nextRootBox()->selectionTop();
- if (nextTop > selectionBottom && block().containsFloats()) {
- // The next line has actually been moved further over, probably from a large
- // line-height, but possibly because the line was forced to clear floats.
- // If so, let's check the offsets, and only be willing to use the next
- // line's top if the offsets are greater on both sides.
- LayoutUnit nextLeft =
- block().logicalLeftOffsetForLine(nextTop, DoNotIndentText);
- LayoutUnit nextRight =
- block().logicalRightOffsetForLine(nextTop, DoNotIndentText);
- LayoutUnit newLeft =
- block().logicalLeftOffsetForLine(selectionBottom, DoNotIndentText);
- LayoutUnit newRight =
- block().logicalRightOffsetForLine(selectionBottom, DoNotIndentText);
- if (nextLeft > newLeft || nextRight < newRight)
- return selectionBottom;
- }
-
- return nextTop;
+ return std::max(selectionBottom, nextRootBox()->selectionTop());
}
LayoutUnit RootInlineBox::blockDirectionPointInLine() const {
« no previous file with comments | « third_party/WebKit/LayoutTests/platform/win/paint/text/selection-no-clip-text-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698