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

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

Issue 2683233005: Set caret width based on device scale factor (Closed)
Patch Set: 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
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 747 matching lines...) Expand 10 before | Expand all | Expand 10 after
758 if (!styleToUse->font().primaryFont()) 758 if (!styleToUse->font().primaryFont())
759 return LayoutRect(); 759 return LayoutRect();
760 760
761 int height = styleToUse->font().primaryFont()->getFontMetrics().height(); 761 int height = styleToUse->font().primaryFont()->getFontMetrics().height();
762 int top = caretBox->logicalTop().toInt(); 762 int top = caretBox->logicalTop().toInt();
763 763
764 // Go ahead and round left to snap it to the nearest pixel. 764 // Go ahead and round left to snap it to the nearest pixel.
765 LayoutUnit left = box->positionForOffset(caretOffset); 765 LayoutUnit left = box->positionForOffset(caretOffset);
766 766
767 // Distribute the caret's width to either side of the offset. 767 // Distribute the caret's width to either side of the offset.
768 LayoutUnit caretWidthLeftOfOffset = caretWidth() / 2; 768 LayoutUnit caretWidthLeftOfOffset =
769 caretWidth(frameView()->getHostWindow()) / 2;
oshima 2017/02/10 19:55:16 ditto
malaykeshav 2017/02/10 21:00:54 Done
769 left -= caretWidthLeftOfOffset; 770 left -= caretWidthLeftOfOffset;
770 LayoutUnit caretWidthRightOfOffset = caretWidth() - caretWidthLeftOfOffset; 771 LayoutUnit caretWidthRightOfOffset =
772 caretWidth(frameView()->getHostWindow()) - caretWidthLeftOfOffset;
771 773
772 left = LayoutUnit(left.round()); 774 left = LayoutUnit(left.round());
773 775
774 LayoutUnit rootLeft = box->root().logicalLeft(); 776 LayoutUnit rootLeft = box->root().logicalLeft();
775 LayoutUnit rootRight = box->root().logicalRight(); 777 LayoutUnit rootRight = box->root().logicalRight();
776 778
777 // FIXME: should we use the width of the root inline box or the 779 // FIXME: should we use the width of the root inline box or the
778 // width of the containing block for this? 780 // width of the containing block for this?
779 if (extraWidthToEndOfLine) 781 if (extraWidthToEndOfLine)
780 *extraWidthToEndOfLine = 782 *extraWidthToEndOfLine =
(...skipping 29 matching lines...) Expand all
810 812
811 // for unicode-bidi: plaintext, use inlineBoxBidiLevel() to test the correct 813 // for unicode-bidi: plaintext, use inlineBoxBidiLevel() to test the correct
812 // direction for the cursor. 814 // direction for the cursor.
813 if (rightAligned && style()->getUnicodeBidi() == UnicodeBidi::kPlaintext) { 815 if (rightAligned && style()->getUnicodeBidi() == UnicodeBidi::kPlaintext) {
814 if (inlineBox->bidiLevel() % 2 != 1) 816 if (inlineBox->bidiLevel() % 2 != 1)
815 rightAligned = false; 817 rightAligned = false;
816 } 818 }
817 819
818 if (rightAligned) { 820 if (rightAligned) {
819 left = std::max(left, leftEdge); 821 left = std::max(left, leftEdge);
820 left = std::min(left, rootRight - caretWidth()); 822 left = std::min(left, rootRight - caretWidth(frameView()->getHostWindow()));
821 } else { 823 } else {
822 left = std::min(left, rightEdge - caretWidthRightOfOffset); 824 left = std::min(left, rightEdge - caretWidthRightOfOffset);
823 left = std::max(left, rootLeft); 825 left = std::max(left, rootLeft);
824 } 826 }
825 827
826 return LayoutRect( 828 return LayoutRect(
827 style()->isHorizontalWritingMode() 829 style()->isHorizontalWritingMode()
828 ? IntRect(left.toInt(), top, caretWidth().toInt(), height) 830 ? IntRect(left.toInt(), top,
829 : IntRect(top, left.toInt(), height, caretWidth().toInt())); 831 caretWidth(frameView()->getHostWindow()).toInt(), height)
832 : IntRect(top, left.toInt(), height,
833 caretWidth(frameView()->getHostWindow()).toInt()));
830 } 834 }
831 835
832 ALWAYS_INLINE float LayoutText::widthFromFont( 836 ALWAYS_INLINE float LayoutText::widthFromFont(
833 const Font& f, 837 const Font& f,
834 int start, 838 int start,
835 int len, 839 int len,
836 float leadWidth, 840 float leadWidth,
837 float textWidthSoFar, 841 float textWidthSoFar,
838 TextDirection textDirection, 842 TextDirection textDirection,
839 HashSet<const SimpleFontData*>* fallbackFonts, 843 HashSet<const SimpleFontData*>* fallbackFonts,
(...skipping 1179 matching lines...) Expand 10 before | Expand all | Expand 10 after
2019 LayoutRect rect = LayoutRect( 2023 LayoutRect rect = LayoutRect(
2020 IntRect(firstRunX(), firstRunY(), linesBox.width(), linesBox.height())); 2024 IntRect(firstRunX(), firstRunY(), linesBox.width(), linesBox.height()));
2021 LayoutBlock* block = containingBlock(); 2025 LayoutBlock* block = containingBlock();
2022 if (block && hasTextBoxes()) 2026 if (block && hasTextBoxes())
2023 block->adjustChildDebugRect(rect); 2027 block->adjustChildDebugRect(rect);
2024 2028
2025 return rect; 2029 return rect;
2026 } 2030 }
2027 2031
2028 } // namespace blink 2032 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698