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

Side by Side Diff: third_party/WebKit/Source/core/paint/InlineTextBoxPainter.cpp

Issue 2681913002: Use the flow of the linebox's containing block when placing ellipsis (Closed)
Patch Set: bug 688957 Created 3 years, 10 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/TestExpectations ('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 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/paint/InlineTextBoxPainter.h" 5 #include "core/paint/InlineTextBoxPainter.h"
6 6
7 #include "core/editing/CompositionUnderline.h" 7 #include "core/editing/CompositionUnderline.h"
8 #include "core/editing/Editor.h" 8 #include "core/editing/Editor.h"
9 #include "core/editing/markers/DocumentMarkerController.h" 9 #include "core/editing/markers/DocumentMarkerController.h"
10 #include "core/frame/LocalFrame.h" 10 #include "core/frame/LocalFrame.h"
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 if (paintSelectedTextOnly || paintSelectedTextSeparately) 597 if (paintSelectedTextOnly || paintSelectedTextSeparately)
598 m_inlineTextBox.selectionStartEnd(selectionStart, selectionEnd); 598 m_inlineTextBox.selectionStartEnd(selectionStart, selectionEnd);
599 599
600 bool respectHyphen = 600 bool respectHyphen =
601 selectionEnd == static_cast<int>(m_inlineTextBox.len()) && 601 selectionEnd == static_cast<int>(m_inlineTextBox.len()) &&
602 m_inlineTextBox.hasHyphen(); 602 m_inlineTextBox.hasHyphen();
603 if (respectHyphen) 603 if (respectHyphen)
604 selectionEnd = textRun.length(); 604 selectionEnd = textRun.length();
605 605
606 bool ltr = m_inlineTextBox.isLeftToRightDirection(); 606 bool ltr = m_inlineTextBox.isLeftToRightDirection();
607 bool flowIsLTR = 607 bool flowIsLTR = m_inlineTextBox.getLineLayoutItem()
608 m_inlineTextBox.getLineLayoutItem().style()->isLeftToRightDirection(); 608 .containingBlock()
609 .style()
610 ->isLeftToRightDirection();
609 if (m_inlineTextBox.truncation() != cNoTruncation) { 611 if (m_inlineTextBox.truncation() != cNoTruncation) {
610 // In a mixed-direction flow the ellipsis is at the start of the text 612 // In a mixed-direction flow the ellipsis is at the start of the text
611 // rather than at the end of it. 613 // rather than at the end of it.
612 selectionStart = 614 selectionStart =
613 ltr == flowIsLTR 615 ltr == flowIsLTR
614 ? std::min<int>(selectionStart, m_inlineTextBox.truncation()) 616 ? std::min<int>(selectionStart, m_inlineTextBox.truncation())
615 : std::max<int>(selectionStart, m_inlineTextBox.truncation()); 617 : std::max<int>(selectionStart, m_inlineTextBox.truncation());
616 selectionEnd = 618 selectionEnd =
617 ltr == flowIsLTR 619 ltr == flowIsLTR
618 ? std::min<int>(selectionEnd, m_inlineTextBox.truncation()) 620 ? std::min<int>(selectionEnd, m_inlineTextBox.truncation())
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
987 // If the text color ends up being the same as the selection background, 989 // If the text color ends up being the same as the selection background,
988 // invert the selection background. 990 // invert the selection background.
989 if (textColor == c) 991 if (textColor == c)
990 c = Color(0xff - c.red(), 0xff - c.green(), 0xff - c.blue()); 992 c = Color(0xff - c.red(), 0xff - c.green(), 0xff - c.blue());
991 993
992 // If the text is truncated, let the thing being painted in the truncation 994 // If the text is truncated, let the thing being painted in the truncation
993 // draw its own highlight. 995 // draw its own highlight.
994 unsigned start = m_inlineTextBox.start(); 996 unsigned start = m_inlineTextBox.start();
995 int length = m_inlineTextBox.len(); 997 int length = m_inlineTextBox.len();
996 bool ltr = m_inlineTextBox.isLeftToRightDirection(); 998 bool ltr = m_inlineTextBox.isLeftToRightDirection();
997 bool flowIsLTR = 999 bool flowIsLTR = m_inlineTextBox.getLineLayoutItem()
998 m_inlineTextBox.getLineLayoutItem().style()->isLeftToRightDirection(); 1000 .containingBlock()
1001 .style()
1002 ->isLeftToRightDirection();
999 if (m_inlineTextBox.truncation() != cNoTruncation) { 1003 if (m_inlineTextBox.truncation() != cNoTruncation) {
1000 // In a mixed-direction flow the ellipsis is at the start of the text 1004 // In a mixed-direction flow the ellipsis is at the start of the text
1001 // so we need to start after it. Otherwise we just need to make sure 1005 // so we need to start after it. Otherwise we just need to make sure
1002 // the end of the text is where the ellipsis starts. 1006 // the end of the text is where the ellipsis starts.
1003 if (ltr != flowIsLTR) 1007 if (ltr != flowIsLTR)
1004 sPos = std::max<int>(sPos, m_inlineTextBox.truncation()); 1008 sPos = std::max<int>(sPos, m_inlineTextBox.truncation());
1005 else 1009 else
1006 length = m_inlineTextBox.truncation(); 1010 length = m_inlineTextBox.truncation();
1007 } 1011 }
1008 StringView string(m_inlineTextBox.getLineLayoutItem().text(), start, 1012 StringView string(m_inlineTextBox.getLineLayoutItem().text(), start,
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
1328 1332
1329 LayoutRect boxRect(boxOrigin, LayoutSize(m_inlineTextBox.logicalWidth(), 1333 LayoutRect boxRect(boxOrigin, LayoutSize(m_inlineTextBox.logicalWidth(),
1330 m_inlineTextBox.logicalHeight())); 1334 m_inlineTextBox.logicalHeight()));
1331 context.clip(FloatRect(boxRect)); 1335 context.clip(FloatRect(boxRect));
1332 context.drawHighlightForText(font, run, FloatPoint(boxOrigin), 1336 context.drawHighlightForText(font, run, FloatPoint(boxOrigin),
1333 boxRect.height().toInt(), color, 1337 boxRect.height().toInt(), color,
1334 paintOffsets.first, paintOffsets.second); 1338 paintOffsets.first, paintOffsets.second);
1335 } 1339 }
1336 1340
1337 } // namespace blink 1341 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/TestExpectations ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698