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

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutText.cpp

Issue 1656743002: Removing more implicit LayoutUnit construction (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix additional test Created 4 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
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 Apple Inc. All rights reserved. 4 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
5 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net) 5 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net)
6 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) 6 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com)
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 RootInlineBox& rootBox = box->root(); 618 RootInlineBox& rootBox = box->root();
619 LayoutUnit top = std::min(rootBox.selectionTop(), rootBox.lineTop()); 619 LayoutUnit top = std::min(rootBox.selectionTop(), rootBox.lineTop());
620 if (pointBlockDirection > top || (!blocksAreFlipped && pointBlockDirecti on == top)) { 620 if (pointBlockDirection > top || (!blocksAreFlipped && pointBlockDirecti on == top)) {
621 LayoutUnit bottom = rootBox.selectionBottom(); 621 LayoutUnit bottom = rootBox.selectionBottom();
622 if (rootBox.nextRootBox()) 622 if (rootBox.nextRootBox())
623 bottom = std::min(bottom, rootBox.nextRootBox()->lineTop()); 623 bottom = std::min(bottom, rootBox.nextRootBox()->lineTop());
624 624
625 if (pointBlockDirection < bottom || (blocksAreFlipped && pointBlockD irection == bottom)) { 625 if (pointBlockDirection < bottom || (blocksAreFlipped && pointBlockD irection == bottom)) {
626 ShouldAffinityBeDownstream shouldAffinityBeDownstream; 626 ShouldAffinityBeDownstream shouldAffinityBeDownstream;
627 if (lineDirectionPointFitsInBox(pointLineDirection, box, shouldA ffinityBeDownstream)) 627 if (lineDirectionPointFitsInBox(pointLineDirection, box, shouldA ffinityBeDownstream))
628 return createPositionWithAffinityForBoxAfterAdjustingOffsetF orBiDi(box, box->offsetForPosition(pointLineDirection.toFloat()), shouldAffinity BeDownstream); 628 return createPositionWithAffinityForBoxAfterAdjustingOffsetF orBiDi(box, box->offsetForPosition(pointLineDirection), shouldAffinityBeDownstre am);
629 } 629 }
630 } 630 }
631 lastBox = box; 631 lastBox = box;
632 } 632 }
633 633
634 if (lastBox) { 634 if (lastBox) {
635 ShouldAffinityBeDownstream shouldAffinityBeDownstream; 635 ShouldAffinityBeDownstream shouldAffinityBeDownstream;
636 lineDirectionPointFitsInBox(pointLineDirection, lastBox, shouldAffinityB eDownstream); 636 lineDirectionPointFitsInBox(pointLineDirection, lastBox, shouldAffinityB eDownstream);
637 return createPositionWithAffinityForBoxAfterAdjustingOffsetForBiDi(lastB ox, lastBox->offsetForPosition(pointLineDirection.toFloat()) + lastBox->start(), shouldAffinityBeDownstream); 637 return createPositionWithAffinityForBoxAfterAdjustingOffsetForBiDi(lastB ox, lastBox->offsetForPosition(pointLineDirection) + lastBox->start(), shouldAff inityBeDownstream);
638 } 638 }
639 return createPositionWithAffinity(0); 639 return createPositionWithAffinity(0);
640 } 640 }
641 641
642 LayoutRect LayoutText::localCaretRect(InlineBox* inlineBox, int caretOffset, Lay outUnit* extraWidthToEndOfLine) 642 LayoutRect LayoutText::localCaretRect(InlineBox* inlineBox, int caretOffset, Lay outUnit* extraWidthToEndOfLine)
643 { 643 {
644 if (!inlineBox) 644 if (!inlineBox)
645 return LayoutRect(); 645 return LayoutRect();
646 646
647 ASSERT(inlineBox->isInlineTextBox()); 647 ASSERT(inlineBox->isInlineTextBox());
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 lastLineMaxWidth = LayoutUnit(); 771 lastLineMaxWidth = LayoutUnit();
772 minWidth = LayoutUnit(); 772 minWidth = LayoutUnit();
773 maxWidth = LayoutUnit(); 773 maxWidth = LayoutUnit();
774 hasBreak = false; 774 hasBreak = false;
775 return; 775 return;
776 } 776 }
777 777
778 floatMinWidth = m_minWidth; 778 floatMinWidth = m_minWidth;
779 floatMaxWidth = m_maxWidth; 779 floatMaxWidth = m_maxWidth;
780 780
781 firstLineMinWidth = m_firstLineMinWidth; 781 firstLineMinWidth = LayoutUnit(m_firstLineMinWidth);
782 lastLineMinWidth = m_lastLineLineMinWidth; 782 lastLineMinWidth = LayoutUnit(m_lastLineLineMinWidth);
783 783
784 hasBreakableChar = m_hasBreakableChar; 784 hasBreakableChar = m_hasBreakableChar;
785 hasBreak = m_hasBreak; 785 hasBreak = m_hasBreak;
786 786
787 ASSERT(m_text); 787 ASSERT(m_text);
788 StringImpl& text = *m_text.impl(); 788 StringImpl& text = *m_text.impl();
789 if (text[0] == spaceCharacter || (text[0] == newlineCharacter && !style()->p reserveNewline()) || text[0] == tabulationCharacter) { 789 if (text[0] == spaceCharacter || (text[0] == newlineCharacter && !style()->p reserveNewline()) || text[0] == tabulationCharacter) {
790 const Font& font = style()->font(); // FIXME: This ignores first-line. 790 const Font& font = style()->font(); // FIXME: This ignores first-line.
791 if (stripFrontSpaces) { 791 if (stripFrontSpaces) {
792 const UChar spaceChar = spaceCharacter; 792 const UChar spaceChar = spaceCharacter;
793 TextRun run = constructTextRun(font, &spaceChar, 1, styleRef(), dire ction); 793 TextRun run = constructTextRun(font, &spaceChar, 1, styleRef(), dire ction);
794 float spaceWidth = font.width(run); 794 float spaceWidth = font.width(run);
795 floatMaxWidth -= spaceWidth; 795 floatMaxWidth -= spaceWidth;
796 } else { 796 } else {
797 floatMaxWidth += font.fontDescription().wordSpacing(); 797 floatMaxWidth += font.fontDescription().wordSpacing();
798 } 798 }
799 } 799 }
800 800
801 stripFrontSpaces = collapseWhiteSpace && m_hasEndWhiteSpace; 801 stripFrontSpaces = collapseWhiteSpace && m_hasEndWhiteSpace;
802 802
803 if (!style()->autoWrap() || floatMinWidth > floatMaxWidth) 803 if (!style()->autoWrap() || floatMinWidth > floatMaxWidth)
804 floatMinWidth = floatMaxWidth; 804 floatMinWidth = floatMaxWidth;
805 805
806 // Compute our max widths by scanning the string for newlines. 806 // Compute our max widths by scanning the string for newlines.
807 if (hasBreak) { 807 if (hasBreak) {
808 const Font& f = style()->font(); // FIXME: This ignores first-line. 808 const Font& f = style()->font(); // FIXME: This ignores first-line.
809 bool firstLine = true; 809 bool firstLine = true;
810 firstLineMaxWidth = floatMaxWidth; 810 firstLineMaxWidth = LayoutUnit(floatMaxWidth);
811 lastLineMaxWidth = floatMaxWidth; 811 lastLineMaxWidth = LayoutUnit(floatMaxWidth);
812 for (int i = 0; i < len; i++) { 812 for (int i = 0; i < len; i++) {
813 int linelen = 0; 813 int linelen = 0;
814 while (i + linelen < len && text[i + linelen] != newlineCharacter) 814 while (i + linelen < len && text[i + linelen] != newlineCharacter)
815 linelen++; 815 linelen++;
816 816
817 if (linelen) { 817 if (linelen) {
818 lastLineMaxWidth = widthFromFont(f, i, linelen, leadWidth, lastL ineMaxWidth.toFloat(), direction, nullptr, nullptr); 818 lastLineMaxWidth = LayoutUnit(widthFromFont(f, i, linelen, leadW idth, lastLineMaxWidth.toFloat(), direction, nullptr, nullptr));
819 if (firstLine) { 819 if (firstLine) {
820 firstLine = false; 820 firstLine = false;
821 leadWidth = 0.f; 821 leadWidth = 0.f;
822 firstLineMaxWidth = lastLineMaxWidth; 822 firstLineMaxWidth = lastLineMaxWidth;
823 } 823 }
824 i += linelen; 824 i += linelen;
825 } else if (firstLine) { 825 } else if (firstLine) {
826 firstLineMaxWidth = LayoutUnit(); 826 firstLineMaxWidth = LayoutUnit();
827 firstLine = false; 827 firstLine = false;
828 leadWidth = 0.f; 828 leadWidth = 0.f;
(...skipping 1046 matching lines...) Expand 10 before | Expand all | Expand 10 after
1875 for (InlineTextBox* box = firstTextBox(); box; box = box->nextTextBox()) { 1875 for (InlineTextBox* box = firstTextBox(); box; box = box->nextTextBox()) {
1876 paintInvalidationContainer.invalidateDisplayItemClientOnBacking(*box, in validationReason); 1876 paintInvalidationContainer.invalidateDisplayItemClientOnBacking(*box, in validationReason);
1877 if (box->truncation() != cNoTruncation) { 1877 if (box->truncation() != cNoTruncation) {
1878 if (EllipsisBox* ellipsisBox = box->root().ellipsisBox()) 1878 if (EllipsisBox* ellipsisBox = box->root().ellipsisBox())
1879 paintInvalidationContainer.invalidateDisplayItemClientOnBacking( *ellipsisBox, invalidationReason); 1879 paintInvalidationContainer.invalidateDisplayItemClientOnBacking( *ellipsisBox, invalidationReason);
1880 } 1880 }
1881 } 1881 }
1882 } 1882 }
1883 1883
1884 } // namespace blink 1884 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698