Chromium Code Reviews| OLD | NEW |
|---|---|
| 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. All r ights reserved. | 4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved. |
| 5 * | 5 * |
| 6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
| 7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
| 8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
| 9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
| 10 * | 10 * |
| 11 * This library is distributed in the hope that it will be useful, | 11 * This library is distributed in the hope that it will be useful, |
| 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 * Library General Public License for more details. | 14 * Library General Public License for more details. |
| 15 * | 15 * |
| 16 * You should have received a copy of the GNU Library General Public License | 16 * You should have received a copy of the GNU Library General Public License |
| 17 * along with this library; see the file COPYING.LIB. If not, write to | 17 * along with this library; see the file COPYING.LIB. If not, write to |
| 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 19 * Boston, MA 02110-1301, USA. | 19 * Boston, MA 02110-1301, USA. |
| 20 * | 20 * |
| 21 */ | 21 */ |
| 22 | 22 |
| 23 #include "config.h" | 23 #include "config.h" |
| 24 #include "core/rendering/InlineTextBox.h" | 24 #include "core/rendering/InlineTextBox.h" |
| 25 | 25 |
| 26 #include "core/dom/Document.h" | 26 #include "core/dom/Document.h" |
| 27 #include "core/dom/DocumentMarkerController.h" | 27 #include "core/dom/DocumentMarkerController.h" |
| 28 #include "core/dom/RenderedDocumentMarker.h" | 28 #include "core/dom/RenderedDocumentMarker.h" |
| 29 #include "core/dom/Text.h" | 29 #include "core/dom/Text.h" |
| 30 #include "core/editing/CompositionUnderline.h" | |
| 31 #include "core/editing/CompositionUnderlineRangeFilter.h" | |
| 30 #include "core/editing/Editor.h" | 32 #include "core/editing/Editor.h" |
| 31 #include "core/editing/InputMethodController.h" | 33 #include "core/editing/InputMethodController.h" |
| 32 #include "core/frame/LocalFrame.h" | 34 #include "core/frame/LocalFrame.h" |
| 33 #include "core/page/Page.h" | 35 #include "core/page/Page.h" |
| 34 #include "core/frame/Settings.h" | 36 #include "core/frame/Settings.h" |
| 35 #include "core/rendering/AbstractInlineTextBox.h" | 37 #include "core/rendering/AbstractInlineTextBox.h" |
| 36 #include "core/rendering/EllipsisBox.h" | 38 #include "core/rendering/EllipsisBox.h" |
| 37 #include "core/rendering/HitTestResult.h" | 39 #include "core/rendering/HitTestResult.h" |
| 38 #include "core/rendering/PaintInfo.h" | 40 #include "core/rendering/PaintInfo.h" |
| 39 #include "core/rendering/RenderBR.h" | 41 #include "core/rendering/RenderBR.h" |
| 40 #include "core/rendering/RenderBlock.h" | 42 #include "core/rendering/RenderBlock.h" |
| 41 #include "core/rendering/RenderCombineText.h" | 43 #include "core/rendering/RenderCombineText.h" |
| 42 #include "core/rendering/RenderRubyRun.h" | 44 #include "core/rendering/RenderRubyRun.h" |
| 43 #include "core/rendering/RenderRubyText.h" | 45 #include "core/rendering/RenderRubyText.h" |
| 44 #include "core/rendering/RenderTheme.h" | 46 #include "core/rendering/RenderTheme.h" |
| 45 #include "core/rendering/style/ShadowList.h" | 47 #include "core/rendering/style/ShadowList.h" |
| 46 #include "core/rendering/svg/SVGTextRunRenderingContext.h" | 48 #include "core/rendering/svg/SVGTextRunRenderingContext.h" |
| 47 #include "platform/fonts/FontCache.h" | 49 #include "platform/fonts/FontCache.h" |
| 48 #include "platform/fonts/WidthIterator.h" | 50 #include "platform/fonts/WidthIterator.h" |
| 49 #include "platform/graphics/DrawLooperBuilder.h" | 51 #include "platform/graphics/DrawLooperBuilder.h" |
| 50 #include "platform/graphics/GraphicsContextStateSaver.h" | 52 #include "platform/graphics/GraphicsContextStateSaver.h" |
| 51 #include "wtf/Vector.h" | 53 #include "wtf/Vector.h" |
| 52 #include "wtf/text/CString.h" | 54 #include "wtf/text/CString.h" |
| 53 #include "wtf/text/StringBuilder.h" | 55 #include "wtf/text/StringBuilder.h" |
| 54 | 56 |
| 57 #include <algorithm> | |
| 58 | |
| 55 using namespace std; | 59 using namespace std; |
| 56 | 60 |
| 57 namespace WebCore { | 61 namespace WebCore { |
| 58 | 62 |
| 59 struct SameSizeAsInlineTextBox : public InlineBox { | 63 struct SameSizeAsInlineTextBox : public InlineBox { |
| 60 unsigned variables[1]; | 64 unsigned variables[1]; |
| 61 unsigned short variables2[2]; | 65 unsigned short variables2[2]; |
| 62 void* pointers[2]; | 66 void* pointers[2]; |
| 63 }; | 67 }; |
| 64 | 68 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 130 return root().selectionBottom(); | 134 return root().selectionBottom(); |
| 131 } | 135 } |
| 132 | 136 |
| 133 LayoutUnit InlineTextBox::selectionHeight() | 137 LayoutUnit InlineTextBox::selectionHeight() |
| 134 { | 138 { |
| 135 return root().selectionHeight(); | 139 return root().selectionHeight(); |
| 136 } | 140 } |
| 137 | 141 |
| 138 bool InlineTextBox::isSelected(int startPos, int endPos) const | 142 bool InlineTextBox::isSelected(int startPos, int endPos) const |
| 139 { | 143 { |
| 140 int sPos = max(startPos - m_start, 0); | 144 int sPos = std::max(startPos - m_start, 0); |
|
yosin_UTC9
2014/06/12 06:23:17
nit: Sorry for confusion about my comment. You onl
huangs
2014/06/12 23:22:10
Done; undid changes to code I didn't touch.
| |
| 141 // The position after a hard line break is considered to be past its end. | 145 // The position after a hard line break is considered to be past its end. |
| 142 // See the corresponding code in InlineTextBox::selectionState. | 146 // See the corresponding code in InlineTextBox::selectionState. |
| 143 int ePos = min(endPos - m_start, int(m_len) + (isLineBreak() ? 0 : 1)); | 147 int ePos = std::min(endPos - m_start, int(m_len) + (isLineBreak() ? 0 : 1)); |
| 144 return (sPos < ePos); | 148 return (sPos < ePos); |
| 145 } | 149 } |
| 146 | 150 |
| 147 RenderObject::SelectionState InlineTextBox::selectionState() | 151 RenderObject::SelectionState InlineTextBox::selectionState() |
| 148 { | 152 { |
| 149 RenderObject::SelectionState state = renderer().selectionState(); | 153 RenderObject::SelectionState state = renderer().selectionState(); |
| 150 if (state == RenderObject::SelectionStart || state == RenderObject::Selectio nEnd || state == RenderObject::SelectionBoth) { | 154 if (state == RenderObject::SelectionStart || state == RenderObject::Selectio nEnd || state == RenderObject::SelectionBoth) { |
| 151 int startPos, endPos; | 155 int startPos, endPos; |
| 152 renderer().selectionStartEnd(startPos, endPos); | 156 renderer().selectionStartEnd(startPos, endPos); |
| 153 // The position after a hard line break is considered to be past its end . | 157 // The position after a hard line break is considered to be past its end . |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 185 RenderObject::SelectionInside : RenderObject::SelectionNone); | 189 RenderObject::SelectionInside : RenderObject::SelectionNone); |
| 186 } else | 190 } else |
| 187 ellipsis->setSelectionState(RenderObject::SelectionNone); | 191 ellipsis->setSelectionState(RenderObject::SelectionNone); |
| 188 } | 192 } |
| 189 | 193 |
| 190 return state; | 194 return state; |
| 191 } | 195 } |
| 192 | 196 |
| 193 LayoutRect InlineTextBox::localSelectionRect(int startPos, int endPos) | 197 LayoutRect InlineTextBox::localSelectionRect(int startPos, int endPos) |
| 194 { | 198 { |
| 195 int sPos = max(startPos - m_start, 0); | 199 int sPos = std::max(startPos - m_start, 0); |
| 196 int ePos = min(endPos - m_start, (int)m_len); | 200 int ePos = std::min(endPos - m_start, static_cast<int>(m_len)); |
|
yosin_UTC9
2014/06/12 06:23:17
nit: You don't need to change |(int)| to |static_c
huangs
2014/06/12 23:22:10
Done; undid changes to code I didn't touch.
| |
| 197 | 201 |
| 198 if (sPos > ePos) | 202 if (sPos > ePos) |
| 199 return LayoutRect(); | 203 return LayoutRect(); |
| 200 | 204 |
| 201 FontCachePurgePreventer fontCachePurgePreventer; | 205 FontCachePurgePreventer fontCachePurgePreventer; |
| 202 | 206 |
| 203 LayoutUnit selTop = selectionTop(); | 207 LayoutUnit selTop = selectionTop(); |
| 204 LayoutUnit selHeight = selectionHeight(); | 208 LayoutUnit selHeight = selectionHeight(); |
| 205 RenderStyle* styleToUse = textRenderer().style(isFirstLineStyle()); | 209 RenderStyle* styleToUse = textRenderer().style(isFirstLineStyle()); |
| 206 const Font& font = styleToUse->font(); | 210 const Font& font = styleToUse->font(); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 287 int visibleBoxWidth = visibleRightEdge - visibleLeftEdge - ellipsis Width; | 291 int visibleBoxWidth = visibleRightEdge - visibleLeftEdge - ellipsis Width; |
| 288 ellipsisX = ltr ? logicalLeft() + visibleBoxWidth : logicalRight() - visibleBoxWidth; | 292 ellipsisX = ltr ? logicalLeft() + visibleBoxWidth : logicalRight() - visibleBoxWidth; |
| 289 } | 293 } |
| 290 | 294 |
| 291 int offset = offsetForPosition(ellipsisX, false); | 295 int offset = offsetForPosition(ellipsisX, false); |
| 292 if (offset == 0) { | 296 if (offset == 0) { |
| 293 // No characters should be rendered. Set ourselves to full truncati on and place the ellipsis at the min of our start | 297 // No characters should be rendered. Set ourselves to full truncati on and place the ellipsis at the min of our start |
| 294 // and the ellipsis edge. | 298 // and the ellipsis edge. |
| 295 m_truncation = cFullTruncation; | 299 m_truncation = cFullTruncation; |
| 296 truncatedWidth += ellipsisWidth; | 300 truncatedWidth += ellipsisWidth; |
| 297 return min(ellipsisX, logicalLeft()); | 301 return std::min(ellipsisX, logicalLeft()); |
| 298 } | 302 } |
| 299 | 303 |
| 300 // Set the truncation index on the text run. | 304 // Set the truncation index on the text run. |
| 301 m_truncation = offset; | 305 m_truncation = offset; |
| 302 | 306 |
| 303 // If we got here that means that we were only partially truncated and w e need to return the pixel offset at which | 307 // If we got here that means that we were only partially truncated and w e need to return the pixel offset at which |
| 304 // to place the ellipsis. | 308 // to place the ellipsis. |
| 305 float widthOfVisibleText = toRenderText(renderer()).width(m_start, offse t, textPos(), flowIsLTR ? LTR : RTL, isFirstLineStyle()); | 309 float widthOfVisibleText = toRenderText(renderer()).width(m_start, offse t, textPos(), flowIsLTR ? LTR : RTL, isFirstLineStyle()); |
| 306 | 310 |
| 307 // The ellipsis needs to be placed just after the last visible character . | 311 // The ellipsis needs to be placed just after the last visible character . |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 628 | 632 |
| 629 // Set our font. | 633 // Set our font. |
| 630 const Font& font = styleToUse->font(); | 634 const Font& font = styleToUse->font(); |
| 631 | 635 |
| 632 FloatPoint textOrigin = FloatPoint(boxOrigin.x(), boxOrigin.y() + font.fontM etrics().ascent()); | 636 FloatPoint textOrigin = FloatPoint(boxOrigin.x(), boxOrigin.y() + font.fontM etrics().ascent()); |
| 633 | 637 |
| 634 if (combinedText) | 638 if (combinedText) |
| 635 combinedText->adjustTextOrigin(textOrigin, boxRect); | 639 combinedText->adjustTextOrigin(textOrigin, boxRect); |
| 636 | 640 |
| 637 // 1. Paint backgrounds behind text if needed. Examples of such backgrounds include selection | 641 // 1. Paint backgrounds behind text if needed. Examples of such backgrounds include selection |
| 638 // and composition underlines. | 642 // and composition highlights. |
| 639 if (paintInfo.phase != PaintPhaseSelection && paintInfo.phase != PaintPhaseT extClip && !isPrinting) { | 643 if (paintInfo.phase != PaintPhaseSelection && paintInfo.phase != PaintPhaseT extClip && !isPrinting) { |
| 644 if (containsComposition) { | |
| 645 if (useCustomUnderlines) { | |
| 646 // Paint custom background highlights for compositions. | |
| 647 const Vector<CompositionUnderline>& underlines = renderer().fram e()->inputMethodController().customCompositionUnderlines(); | |
| 648 CompositionUnderlineRangeFilter filter(underlines, start(), end( )); | |
| 649 for (CompositionUnderlineRangeFilter::ConstIterator it = filter. begin(); it != filter.end(); ++it) { | |
| 650 if ((*it).backgroundColor != Color::transparent) { | |
|
yosin_UTC9
2014/06/12 06:23:17
nit: It is better to use |it->backgroundColor|. We
huangs
2014/06/12 23:22:10
Done.
| |
| 651 unsigned paintStart = underlinePaintStart(*it); | |
| 652 unsigned paintEnd = underlinePaintEnd(*it); | |
| 653 paintCompositionBackground(context, boxOrigin, styleToUs e, font, (*it).backgroundColor, paintStart, paintEnd); | |
| 654 } | |
| 655 } | |
| 640 | 656 |
| 641 if (containsComposition && !useCustomUnderlines) { | 657 } else { |
| 642 paintCompositionBackground(context, boxOrigin, styleToUse, font, | 658 paintCompositionBackground(context, boxOrigin, styleToUse, font, RenderTheme::theme().platformDefaultCompositionBackgroundColor(), |
| 643 renderer().frame()->inputMethodController().compositionStart(), | 659 renderer().frame()->inputMethodController().compositionStart (), |
| 644 renderer().frame()->inputMethodController().compositionEnd()); | 660 renderer().frame()->inputMethodController().compositionEnd() ); |
| 661 } | |
| 645 } | 662 } |
| 646 | 663 |
| 647 paintDocumentMarkers(context, boxOrigin, styleToUse, font, true); | 664 paintDocumentMarkers(context, boxOrigin, styleToUse, font, true); |
| 648 | 665 |
| 649 if (haveSelection && !useCustomUnderlines) | 666 if (haveSelection && !useCustomUnderlines) |
| 650 paintSelection(context, boxOrigin, styleToUse, font, selectionFillCo lor); | 667 paintSelection(context, boxOrigin, styleToUse, font, selectionFillCo lor); |
| 651 } | 668 } |
| 652 | 669 |
| 653 // 2. Now paint the foreground, including text and decorations like underlin e/overline (in quirks mode only). | 670 // 2. Now paint the foreground, including text and decorations like underlin e/overline (in quirks mode only). |
| 654 int length = m_len; | 671 int length = m_len; |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 668 TextRun textRun = constructTextRun(styleToUse, font, string, maximumLength, hasHyphen() ? &charactersWithHyphen : 0); | 685 TextRun textRun = constructTextRun(styleToUse, font, string, maximumLength, hasHyphen() ? &charactersWithHyphen : 0); |
| 669 if (hasHyphen()) | 686 if (hasHyphen()) |
| 670 length = textRun.length(); | 687 length = textRun.length(); |
| 671 | 688 |
| 672 int sPos = 0; | 689 int sPos = 0; |
| 673 int ePos = 0; | 690 int ePos = 0; |
| 674 if (paintSelectedTextOnly || paintSelectedTextSeparately) | 691 if (paintSelectedTextOnly || paintSelectedTextSeparately) |
| 675 selectionStartEnd(sPos, ePos); | 692 selectionStartEnd(sPos, ePos); |
| 676 | 693 |
| 677 if (m_truncation != cNoTruncation) { | 694 if (m_truncation != cNoTruncation) { |
| 678 sPos = min<int>(sPos, m_truncation); | 695 sPos = std::min<int>(sPos, m_truncation); |
| 679 ePos = min<int>(ePos, m_truncation); | 696 ePos = std::min<int>(ePos, m_truncation); |
| 680 length = m_truncation; | 697 length = m_truncation; |
| 681 } | 698 } |
| 682 | 699 |
| 683 int emphasisMarkOffset = 0; | 700 int emphasisMarkOffset = 0; |
| 684 TextEmphasisPosition emphasisMarkPosition; | 701 TextEmphasisPosition emphasisMarkPosition; |
| 685 bool hasTextEmphasis = getEmphasisMarkPosition(styleToUse, emphasisMarkPosit ion); | 702 bool hasTextEmphasis = getEmphasisMarkPosition(styleToUse, emphasisMarkPosit ion); |
| 686 const AtomicString& emphasisMark = hasTextEmphasis ? styleToUse->textEmphasi sMarkString() : nullAtom; | 703 const AtomicString& emphasisMark = hasTextEmphasis ? styleToUse->textEmphasi sMarkString() : nullAtom; |
| 687 if (!emphasisMark.isEmpty()) | 704 if (!emphasisMark.isEmpty()) |
| 688 emphasisMarkOffset = emphasisMarkPosition == TextEmphasisPositionOver ? -font.fontMetrics().ascent() - font.emphasisMarkDescent(emphasisMark) : font.fon tMetrics().descent() + font.emphasisMarkAscent(emphasisMark); | 705 emphasisMarkOffset = emphasisMarkPosition == TextEmphasisPositionOver ? -font.fontMetrics().ascent() - font.emphasisMarkDescent(emphasisMark) : font.fon tMetrics().descent() + font.emphasisMarkAscent(emphasisMark); |
| 689 | 706 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 760 if (combinedText) | 777 if (combinedText) |
| 761 context->concatCTM(rotation(boxRect, Clockwise)); | 778 context->concatCTM(rotation(boxRect, Clockwise)); |
| 762 paintDecoration(context, boxOrigin, textDecorations, textShadow); | 779 paintDecoration(context, boxOrigin, textDecorations, textShadow); |
| 763 if (combinedText) | 780 if (combinedText) |
| 764 context->concatCTM(rotation(boxRect, Counterclockwise)); | 781 context->concatCTM(rotation(boxRect, Counterclockwise)); |
| 765 } | 782 } |
| 766 | 783 |
| 767 if (paintInfo.phase == PaintPhaseForeground) { | 784 if (paintInfo.phase == PaintPhaseForeground) { |
| 768 paintDocumentMarkers(context, boxOrigin, styleToUse, font, false); | 785 paintDocumentMarkers(context, boxOrigin, styleToUse, font, false); |
| 769 | 786 |
| 787 // Paint custom underlines for compositions. | |
| 770 if (useCustomUnderlines) { | 788 if (useCustomUnderlines) { |
| 771 const Vector<CompositionUnderline>& underlines = renderer().frame()- >inputMethodController().customCompositionUnderlines(); | 789 const Vector<CompositionUnderline>& underlines = renderer().frame()- >inputMethodController().customCompositionUnderlines(); |
| 772 size_t numUnderlines = underlines.size(); | 790 CompositionUnderlineRangeFilter filter(underlines, start(), end()); |
| 773 | 791 for (CompositionUnderlineRangeFilter::ConstIterator it = filter.begi n(); it != filter.end(); ++it) { |
| 774 for (size_t index = 0; index < numUnderlines; ++index) { | 792 paintCompositionUnderline(context, boxOrigin, *it); |
| 775 const CompositionUnderline& underline = underlines[index]; | |
| 776 | |
| 777 if (underline.endOffset <= start()) | |
| 778 // underline is completely before this run. This might be a n underline that sits | |
| 779 // before the first run we draw, or underlines that were wit hin runs we skipped | |
| 780 // due to truncation. | |
| 781 continue; | |
| 782 | |
| 783 if (underline.startOffset <= end()) { | |
| 784 // underline intersects this run. Paint it. | |
| 785 paintCompositionUnderline(context, boxOrigin, underline); | |
| 786 if (underline.endOffset > end() + 1) | |
| 787 // underline also runs into the next run. Bail now, no m ore marker advancement. | |
| 788 break; | |
| 789 } else | |
| 790 // underline is completely after this run, bail. A later ru n will paint it. | |
| 791 break; | |
| 792 } | 793 } |
| 793 } | 794 } |
| 794 } | 795 } |
| 795 | 796 |
| 796 if (shouldRotate) | 797 if (shouldRotate) |
| 797 context->concatCTM(rotation(boxRect, Counterclockwise)); | 798 context->concatCTM(rotation(boxRect, Counterclockwise)); |
| 798 } | 799 } |
| 799 | 800 |
| 800 void InlineTextBox::selectionStartEnd(int& sPos, int& ePos) | 801 void InlineTextBox::selectionStartEnd(int& sPos, int& ePos) |
| 801 { | 802 { |
| 802 int startPos, endPos; | 803 int startPos, endPos; |
| 803 if (renderer().selectionState() == RenderObject::SelectionInside) { | 804 if (renderer().selectionState() == RenderObject::SelectionInside) { |
| 804 startPos = 0; | 805 startPos = 0; |
| 805 endPos = textRenderer().textLength(); | 806 endPos = textRenderer().textLength(); |
| 806 } else { | 807 } else { |
| 807 textRenderer().selectionStartEnd(startPos, endPos); | 808 textRenderer().selectionStartEnd(startPos, endPos); |
| 808 if (renderer().selectionState() == RenderObject::SelectionStart) | 809 if (renderer().selectionState() == RenderObject::SelectionStart) |
| 809 endPos = textRenderer().textLength(); | 810 endPos = textRenderer().textLength(); |
| 810 else if (renderer().selectionState() == RenderObject::SelectionEnd) | 811 else if (renderer().selectionState() == RenderObject::SelectionEnd) |
| 811 startPos = 0; | 812 startPos = 0; |
| 812 } | 813 } |
| 813 | 814 |
| 814 sPos = max(startPos - m_start, 0); | 815 sPos = std::max(startPos - m_start, 0); |
| 815 ePos = min(endPos - m_start, (int)m_len); | 816 ePos = std::min(endPos - m_start, static_cast<int>(m_len)); |
| 816 } | 817 } |
| 817 | 818 |
| 818 void alignSelectionRectToDevicePixels(FloatRect& rect) | 819 void alignSelectionRectToDevicePixels(FloatRect& rect) |
| 819 { | 820 { |
| 820 float maxX = floorf(rect.maxX()); | 821 float maxX = floorf(rect.maxX()); |
| 821 rect.setX(floorf(rect.x())); | 822 rect.setX(floorf(rect.x())); |
| 822 rect.setWidth(roundf(maxX - rect.x())); | 823 rect.setWidth(roundf(maxX - rect.x())); |
| 823 } | 824 } |
| 824 | 825 |
| 825 void InlineTextBox::paintSelection(GraphicsContext* context, const FloatPoint& b oxOrigin, RenderStyle* style, const Font& font, Color textColor) | 826 void InlineTextBox::paintSelection(GraphicsContext* context, const FloatPoint& b oxOrigin, RenderStyle* style, const Font& font, Color textColor) |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 856 StringBuilder charactersWithHyphen; | 857 StringBuilder charactersWithHyphen; |
| 857 bool respectHyphen = ePos == length && hasHyphen(); | 858 bool respectHyphen = ePos == length && hasHyphen(); |
| 858 TextRun textRun = constructTextRun(style, font, string, textRenderer().textL ength() - m_start, respectHyphen ? &charactersWithHyphen : 0); | 859 TextRun textRun = constructTextRun(style, font, string, textRenderer().textL ength() - m_start, respectHyphen ? &charactersWithHyphen : 0); |
| 859 if (respectHyphen) | 860 if (respectHyphen) |
| 860 ePos = textRun.length(); | 861 ePos = textRun.length(); |
| 861 | 862 |
| 862 LayoutUnit selectionBottom = root().selectionBottom(); | 863 LayoutUnit selectionBottom = root().selectionBottom(); |
| 863 LayoutUnit selectionTop = root().selectionTopAdjustedForPrecedingBlock(); | 864 LayoutUnit selectionTop = root().selectionTopAdjustedForPrecedingBlock(); |
| 864 | 865 |
| 865 int deltaY = roundToInt(renderer().style()->isFlippedLinesWritingMode() ? se lectionBottom - logicalBottom() : logicalTop() - selectionTop); | 866 int deltaY = roundToInt(renderer().style()->isFlippedLinesWritingMode() ? se lectionBottom - logicalBottom() : logicalTop() - selectionTop); |
| 866 int selHeight = max(0, roundToInt(selectionBottom - selectionTop)); | 867 int selHeight = std::max(0, roundToInt(selectionBottom - selectionTop)); |
| 867 | 868 |
| 868 FloatPoint localOrigin(boxOrigin.x(), boxOrigin.y() - deltaY); | 869 FloatPoint localOrigin(boxOrigin.x(), boxOrigin.y() - deltaY); |
| 869 FloatRect clipRect(localOrigin, FloatSize(m_logicalWidth, selHeight)); | 870 FloatRect clipRect(localOrigin, FloatSize(m_logicalWidth, selHeight)); |
| 870 alignSelectionRectToDevicePixels(clipRect); | 871 alignSelectionRectToDevicePixels(clipRect); |
| 871 | 872 |
| 872 context->clip(clipRect); | 873 context->clip(clipRect); |
| 873 | 874 |
| 874 context->drawHighlightForText(font, textRun, localOrigin, selHeight, c, sPos , ePos); | 875 context->drawHighlightForText(font, textRun, localOrigin, selHeight, c, sPos , ePos); |
| 875 } | 876 } |
| 876 | 877 |
| 877 void InlineTextBox::paintCompositionBackground(GraphicsContext* context, const F loatPoint& boxOrigin, RenderStyle* style, const Font& font, int startPos, int en dPos) | 878 size_t InlineTextBox::underlinePaintStart(const CompositionUnderline& underline) |
|
yosin_UTC9
2014/06/12 06:23:17
nit: |size_t| -> |unsigned|
huangs
2014/06/12 23:22:10
Done.
| |
| 878 { | 879 { |
| 879 int offset = m_start; | 880 return std::max(static_cast<unsigned>(m_start), underline.startOffset); |
| 880 int sPos = max(startPos - offset, 0); | 881 } |
| 881 int ePos = min(endPos - offset, (int)m_len); | |
| 882 | 882 |
| 883 size_t InlineTextBox::underlinePaintEnd(const CompositionUnderline& underline) | |
|
yosin_UTC9
2014/06/12 06:23:17
nit: |size_t| -> |unsigned|
It seems both |Inline
huangs
2014/06/12 23:22:10
Done.
| |
| 884 { | |
| 885 unsigned paintEnd = std::min(end() + 1, underline.endOffset); // end() point s at the last char, not past it. | |
| 886 if (m_truncation != cNoTruncation) | |
| 887 paintEnd = std::min(paintEnd, static_cast<unsigned>(m_start + m_truncati on)); | |
| 888 return paintEnd; | |
| 889 } | |
| 890 | |
| 891 void InlineTextBox::paintCompositionBackground(GraphicsContext* context, const F loatPoint& boxOrigin, RenderStyle* style, const Font& font, Color backgroundColo r, int startPos, int endPos) | |
| 892 { | |
| 893 int sPos = std::max(startPos - m_start, 0); | |
| 894 int ePos = std::min(endPos - m_start, static_cast<int>(m_len)); | |
| 883 if (sPos >= ePos) | 895 if (sPos >= ePos) |
| 884 return; | 896 return; |
| 885 | 897 |
| 886 GraphicsContextStateSaver stateSaver(*context); | 898 GraphicsContextStateSaver stateSaver(*context); |
| 887 | 899 |
| 888 Color c = Color(225, 221, 85); | 900 updateGraphicsContext(context, backgroundColor, backgroundColor, 0); // Don' t draw text at all! |
| 889 | |
| 890 updateGraphicsContext(context, c, c, 0); // Don't draw text at all! | |
| 891 | 901 |
| 892 int deltaY = renderer().style()->isFlippedLinesWritingMode() ? selectionBott om() - logicalBottom() : logicalTop() - selectionTop(); | 902 int deltaY = renderer().style()->isFlippedLinesWritingMode() ? selectionBott om() - logicalBottom() : logicalTop() - selectionTop(); |
| 893 int selHeight = selectionHeight(); | 903 int selHeight = selectionHeight(); |
| 894 FloatPoint localOrigin(boxOrigin.x(), boxOrigin.y() - deltaY); | 904 FloatPoint localOrigin(boxOrigin.x(), boxOrigin.y() - deltaY); |
| 895 context->drawHighlightForText(font, constructTextRun(style, font), localOrig in, selHeight, c, sPos, ePos); | 905 context->drawHighlightForText(font, constructTextRun(style, font), localOrig in, selHeight, backgroundColor, sPos, ePos); |
| 896 } | 906 } |
| 897 | 907 |
| 898 static StrokeStyle textDecorationStyleToStrokeStyle(TextDecorationStyle decorati onStyle) | 908 static StrokeStyle textDecorationStyleToStrokeStyle(TextDecorationStyle decorati onStyle) |
| 899 { | 909 { |
| 900 StrokeStyle strokeStyle = SolidStroke; | 910 StrokeStyle strokeStyle = SolidStroke; |
| 901 switch (decorationStyle) { | 911 switch (decorationStyle) { |
| 902 case TextDecorationStyleSolid: | 912 case TextDecorationStyleSolid: |
| 903 strokeStyle = SolidStroke; | 913 strokeStyle = SolidStroke; |
| 904 break; | 914 break; |
| 905 case TextDecorationStyleDouble: | 915 case TextDecorationStyleDouble: |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1003 context->adjustLineToPixelBoundaries(p1, p2, strokeThickness, context->strok eStyle()); | 1013 context->adjustLineToPixelBoundaries(p1, p2, strokeThickness, context->strok eStyle()); |
| 1004 | 1014 |
| 1005 Path path; | 1015 Path path; |
| 1006 path.moveTo(p1); | 1016 path.moveTo(p1); |
| 1007 | 1017 |
| 1008 // Distance between decoration's axis and Bezier curve's control points. | 1018 // Distance between decoration's axis and Bezier curve's control points. |
| 1009 // The height of the curve is based on this distance. Use a minimum of 6 pix els distance since | 1019 // The height of the curve is based on this distance. Use a minimum of 6 pix els distance since |
| 1010 // the actual curve passes approximately at half of that distance, that is 3 pixels. | 1020 // the actual curve passes approximately at half of that distance, that is 3 pixels. |
| 1011 // The minimum height of the curve is also approximately 3 pixels. Increases the curve's height | 1021 // The minimum height of the curve is also approximately 3 pixels. Increases the curve's height |
| 1012 // as strockThickness increases to make the curve looks better. | 1022 // as strockThickness increases to make the curve looks better. |
| 1013 float controlPointDistance = 3 * max<float>(2, strokeThickness); | 1023 float controlPointDistance = 3 * std::max<float>(2, strokeThickness); |
| 1014 | 1024 |
| 1015 // Increment used to form the diamond shape between start point (p1), contro l | 1025 // Increment used to form the diamond shape between start point (p1), contro l |
| 1016 // points and end point (p2) along the axis of the decoration. Makes the | 1026 // points and end point (p2) along the axis of the decoration. Makes the |
| 1017 // curve wider as strockThickness increases to make the curve looks better. | 1027 // curve wider as strockThickness increases to make the curve looks better. |
| 1018 float step = 2 * max<float>(2, strokeThickness); | 1028 float step = 2 * std::max<float>(2, strokeThickness); |
| 1019 | 1029 |
| 1020 bool isVerticalLine = (p1.x() == p2.x()); | 1030 bool isVerticalLine = (p1.x() == p2.x()); |
| 1021 | 1031 |
| 1022 if (isVerticalLine) { | 1032 if (isVerticalLine) { |
| 1023 ASSERT(p1.x() == p2.x()); | 1033 ASSERT(p1.x() == p2.x()); |
| 1024 | 1034 |
| 1025 float xAxis = p1.x(); | 1035 float xAxis = p1.x(); |
| 1026 float y1; | 1036 float y1; |
| 1027 float y2; | 1037 float y2; |
| 1028 | 1038 |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1137 | 1147 |
| 1138 RenderStyle* styleToUse = renderer().style(isFirstLineStyle()); | 1148 RenderStyle* styleToUse = renderer().style(isFirstLineStyle()); |
| 1139 int baseline = styleToUse->fontMetrics().ascent(); | 1149 int baseline = styleToUse->fontMetrics().ascent(); |
| 1140 | 1150 |
| 1141 size_t shadowCount = shadowList ? shadowList->shadows().size() : 0; | 1151 size_t shadowCount = shadowList ? shadowList->shadows().size() : 0; |
| 1142 // Set the thick of the line to be 10% (or something else ?)of the computed font size and not less than 1px. | 1152 // Set the thick of the line to be 10% (or something else ?)of the computed font size and not less than 1px. |
| 1143 // Using computedFontSize should take care of zoom as well. | 1153 // Using computedFontSize should take care of zoom as well. |
| 1144 | 1154 |
| 1145 // Update Underline thickness, in case we have Faulty Font Metrics calculati ng underline thickness by old method. | 1155 // Update Underline thickness, in case we have Faulty Font Metrics calculati ng underline thickness by old method. |
| 1146 float textDecorationThickness = styleToUse->fontMetrics().underlineThickness (); | 1156 float textDecorationThickness = styleToUse->fontMetrics().underlineThickness (); |
| 1147 int fontHeightInt = (int)(styleToUse->fontMetrics().floatHeight() + 0.5); | 1157 int fontHeightInt = static_cast<int>(styleToUse->fontMetrics().floatHeight() + 0.5); |
| 1148 if ((textDecorationThickness == 0.f) || (textDecorationThickness >= (fontHei ghtInt >> 1))) | 1158 if ((textDecorationThickness == 0.f) || (textDecorationThickness >= (fontHei ghtInt >> 1))) |
| 1149 textDecorationThickness = std::max(1.f, styleToUse->computedFontSize() / 10.f); | 1159 textDecorationThickness = std::max(1.f, styleToUse->computedFontSize() / 10.f); |
| 1150 | 1160 |
| 1151 context->setStrokeThickness(textDecorationThickness); | 1161 context->setStrokeThickness(textDecorationThickness); |
| 1152 | 1162 |
| 1153 bool antialiasDecoration = shouldSetDecorationAntialias(overline.style, unde rline.style, linethrough.style) | 1163 bool antialiasDecoration = shouldSetDecorationAntialias(overline.style, unde rline.style, linethrough.style) |
| 1154 && RenderBoxModelObject::shouldAntialiasLines(context); | 1164 && RenderBoxModelObject::shouldAntialiasLines(context); |
| 1155 | 1165 |
| 1156 float extraOffset = 0; | 1166 float extraOffset = 0; |
| 1157 if (!linesAreOpaque && shadowCount > 1) { | 1167 if (!linesAreOpaque && shadowCount > 1) { |
| 1158 FloatRect clipRect(localOrigin, FloatSize(width, baseline + 2)); | 1168 FloatRect clipRect(localOrigin, FloatSize(width, baseline + 2)); |
| 1159 for (size_t i = shadowCount; i--; ) { | 1169 for (size_t i = shadowCount; i--; ) { |
| 1160 const ShadowData& s = shadowList->shadows()[i]; | 1170 const ShadowData& s = shadowList->shadows()[i]; |
| 1161 FloatRect shadowRect(localOrigin, FloatSize(width, baseline + 2)); | 1171 FloatRect shadowRect(localOrigin, FloatSize(width, baseline + 2)); |
| 1162 shadowRect.inflate(s.blur()); | 1172 shadowRect.inflate(s.blur()); |
| 1163 float shadowX = isHorizontal() ? s.x() : s.y(); | 1173 float shadowX = isHorizontal() ? s.x() : s.y(); |
| 1164 float shadowY = isHorizontal() ? s.y() : -s.x(); | 1174 float shadowY = isHorizontal() ? s.y() : -s.x(); |
| 1165 shadowRect.move(shadowX, shadowY); | 1175 shadowRect.move(shadowX, shadowY); |
| 1166 clipRect.unite(shadowRect); | 1176 clipRect.unite(shadowRect); |
| 1167 extraOffset = max(extraOffset, max(0.0f, shadowY) + s.blur()); | 1177 extraOffset = std::max(extraOffset, std::max(0.0f, shadowY) + s.blur ()); |
| 1168 } | 1178 } |
| 1169 context->clip(clipRect); | 1179 context->clip(clipRect); |
| 1170 extraOffset += baseline + 2; | 1180 extraOffset += baseline + 2; |
| 1171 localOrigin.move(0, extraOffset); | 1181 localOrigin.move(0, extraOffset); |
| 1172 } | 1182 } |
| 1173 | 1183 |
| 1174 for (size_t i = max(static_cast<size_t>(1), shadowCount); i--; ) { | 1184 for (size_t i = std::max(static_cast<size_t>(1), shadowCount); i--; ) { |
| 1175 // Even if we have no shadows, we still want to run the code below this once. | 1185 // Even if we have no shadows, we still want to run the code below this once. |
| 1176 if (i < shadowCount) { | 1186 if (i < shadowCount) { |
| 1177 if (!i) { | 1187 if (!i) { |
| 1178 // The last set of lines paints normally inside the clip. | 1188 // The last set of lines paints normally inside the clip. |
| 1179 localOrigin.move(0, -extraOffset); | 1189 localOrigin.move(0, -extraOffset); |
| 1180 extraOffset = 0; | 1190 extraOffset = 0; |
| 1181 } | 1191 } |
| 1182 const ShadowData& shadow = shadowList->shadows()[i]; | 1192 const ShadowData& shadow = shadowList->shadows()[i]; |
| 1183 float shadowX = isHorizontal() ? shadow.x() : shadow.y(); | 1193 float shadowX = isHorizontal() ? shadow.x() : shadow.y(); |
| 1184 float shadowY = isHorizontal() ? shadow.y() : -shadow.x(); | 1194 float shadowY = isHorizontal() ? shadow.y() : -shadow.x(); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1222 return; | 1232 return; |
| 1223 | 1233 |
| 1224 if (m_truncation == cFullTruncation) | 1234 if (m_truncation == cFullTruncation) |
| 1225 return; | 1235 return; |
| 1226 | 1236 |
| 1227 float start = 0; // start of line to draw, relative to tx | 1237 float start = 0; // start of line to draw, relative to tx |
| 1228 float width = m_logicalWidth; // how much line to draw | 1238 float width = m_logicalWidth; // how much line to draw |
| 1229 | 1239 |
| 1230 // Determine whether we need to measure text | 1240 // Determine whether we need to measure text |
| 1231 bool markerSpansWholeBox = true; | 1241 bool markerSpansWholeBox = true; |
| 1232 if (m_start <= (int)marker->startOffset()) | 1242 if (m_start <= static_cast<int>(marker->startOffset())) |
| 1233 markerSpansWholeBox = false; | 1243 markerSpansWholeBox = false; |
| 1234 if ((end() + 1) != marker->endOffset()) // end points at the last char, not past it | 1244 if ((end() + 1) != marker->endOffset()) // end points at the last char, not past it |
| 1235 markerSpansWholeBox = false; | 1245 markerSpansWholeBox = false; |
| 1236 if (m_truncation != cNoTruncation) | 1246 if (m_truncation != cNoTruncation) |
| 1237 markerSpansWholeBox = false; | 1247 markerSpansWholeBox = false; |
| 1238 | 1248 |
| 1239 if (!markerSpansWholeBox || grammar) { | 1249 if (!markerSpansWholeBox || grammar) { |
| 1240 int startPosition = max<int>(marker->startOffset() - m_start, 0); | 1250 int startPosition = std::max<int>(marker->startOffset() - m_start, 0); |
| 1241 int endPosition = min<int>(marker->endOffset() - m_start, m_len); | 1251 int endPosition = std::min<int>(marker->endOffset() - m_start, m_len); |
| 1242 | 1252 |
| 1243 if (m_truncation != cNoTruncation) | 1253 if (m_truncation != cNoTruncation) |
| 1244 endPosition = min<int>(endPosition, m_truncation); | 1254 endPosition = std::min<int>(endPosition, m_truncation); |
| 1245 | 1255 |
| 1246 // Calculate start & width | 1256 // Calculate start & width |
| 1247 int deltaY = renderer().style()->isFlippedLinesWritingMode() ? selection Bottom() - logicalBottom() : logicalTop() - selectionTop(); | 1257 int deltaY = renderer().style()->isFlippedLinesWritingMode() ? selection Bottom() - logicalBottom() : logicalTop() - selectionTop(); |
| 1248 int selHeight = selectionHeight(); | 1258 int selHeight = selectionHeight(); |
| 1249 FloatPoint startPoint(boxOrigin.x(), boxOrigin.y() - deltaY); | 1259 FloatPoint startPoint(boxOrigin.x(), boxOrigin.y() - deltaY); |
| 1250 TextRun run = constructTextRun(style, font); | 1260 TextRun run = constructTextRun(style, font); |
| 1251 | 1261 |
| 1252 // FIXME: Convert the document markers to float rects. | 1262 // FIXME: Convert the document markers to float rects. |
| 1253 IntRect markerRect = enclosingIntRect(font.selectionRectForText(run, sta rtPoint, selHeight, startPosition, endPosition)); | 1263 IntRect markerRect = enclosingIntRect(font.selectionRectForText(run, sta rtPoint, selHeight, startPosition, endPosition)); |
| 1254 start = markerRect.x() - startPoint.x(); | 1264 start = markerRect.x() - startPoint.x(); |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 1283 pt->drawLineForDocumentMarker(FloatPoint(boxOrigin.x() + start, boxOrigin.y( ) + underlineOffset), width, lineStyleForMarkerType(marker->type())); | 1293 pt->drawLineForDocumentMarker(FloatPoint(boxOrigin.x() + start, boxOrigin.y( ) + underlineOffset), width, lineStyleForMarkerType(marker->type())); |
| 1284 } | 1294 } |
| 1285 | 1295 |
| 1286 void InlineTextBox::paintTextMatchMarker(GraphicsContext* pt, const FloatPoint& boxOrigin, DocumentMarker* marker, RenderStyle* style, const Font& font) | 1296 void InlineTextBox::paintTextMatchMarker(GraphicsContext* pt, const FloatPoint& boxOrigin, DocumentMarker* marker, RenderStyle* style, const Font& font) |
| 1287 { | 1297 { |
| 1288 // Use same y positioning and height as for selection, so that when the sele ction and this highlight are on | 1298 // Use same y positioning and height as for selection, so that when the sele ction and this highlight are on |
| 1289 // the same word there are no pieces sticking out. | 1299 // the same word there are no pieces sticking out. |
| 1290 int deltaY = renderer().style()->isFlippedLinesWritingMode() ? selectionBott om() - logicalBottom() : logicalTop() - selectionTop(); | 1300 int deltaY = renderer().style()->isFlippedLinesWritingMode() ? selectionBott om() - logicalBottom() : logicalTop() - selectionTop(); |
| 1291 int selHeight = selectionHeight(); | 1301 int selHeight = selectionHeight(); |
| 1292 | 1302 |
| 1293 int sPos = max(marker->startOffset() - m_start, (unsigned)0); | 1303 int sPos = std::max(marker->startOffset() - m_start, 0U); |
| 1294 int ePos = min(marker->endOffset() - m_start, (unsigned)m_len); | 1304 int ePos = std::min(marker->endOffset() - m_start, static_cast<unsigned>(m_l en)); |
| 1295 TextRun run = constructTextRun(style, font); | 1305 TextRun run = constructTextRun(style, font); |
| 1296 | 1306 |
| 1297 // Always compute and store the rect associated with this marker. The comput ed rect is in absolute coordinates. | 1307 // Always compute and store the rect associated with this marker. The comput ed rect is in absolute coordinates. |
| 1298 IntRect markerRect = enclosingIntRect(font.selectionRectForText(run, IntPoin t(x(), selectionTop()), selHeight, sPos, ePos)); | 1308 IntRect markerRect = enclosingIntRect(font.selectionRectForText(run, IntPoin t(x(), selectionTop()), selHeight, sPos, ePos)); |
| 1299 markerRect = renderer().localToAbsoluteQuad(FloatRect(markerRect)).enclosing BoundingBox(); | 1309 markerRect = renderer().localToAbsoluteQuad(FloatRect(markerRect)).enclosing BoundingBox(); |
| 1300 toRenderedDocumentMarker(marker)->setRenderedRect(markerRect); | 1310 toRenderedDocumentMarker(marker)->setRenderedRect(markerRect); |
| 1301 | 1311 |
| 1302 // Optionally highlight the text | 1312 // Optionally highlight the text |
| 1303 if (renderer().frame()->editor().markedTextMatchesAreHighlighted()) { | 1313 if (renderer().frame()->editor().markedTextMatchesAreHighlighted()) { |
| 1304 Color color = marker->activeMatch() ? | 1314 Color color = marker->activeMatch() ? |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1364 } | 1374 } |
| 1365 | 1375 |
| 1366 } | 1376 } |
| 1367 } | 1377 } |
| 1368 | 1378 |
| 1369 void InlineTextBox::paintCompositionUnderline(GraphicsContext* ctx, const FloatP oint& boxOrigin, const CompositionUnderline& underline) | 1379 void InlineTextBox::paintCompositionUnderline(GraphicsContext* ctx, const FloatP oint& boxOrigin, const CompositionUnderline& underline) |
| 1370 { | 1380 { |
| 1371 if (m_truncation == cFullTruncation) | 1381 if (m_truncation == cFullTruncation) |
| 1372 return; | 1382 return; |
| 1373 | 1383 |
| 1374 float start = 0; // start of line to draw, relative to tx | 1384 unsigned paintStart = underlinePaintStart(underline); |
| 1375 float width = m_logicalWidth; // how much line to draw | 1385 unsigned paintEnd = underlinePaintEnd(underline); |
| 1376 bool useWholeWidth = true; | 1386 |
| 1377 unsigned paintStart = m_start; | 1387 // start of line to draw, relative to tx |
| 1378 unsigned paintEnd = end() + 1; // end points at the last char, not past it | 1388 float start = paintStart == static_cast<unsigned>(m_start) ? 0 : |
| 1379 if (paintStart <= underline.startOffset) { | 1389 toRenderText(renderer()).width(m_start, paintStart - m_start, textPos(), isLeftToRightDirection() ? LTR : RTL, isFirstLineStyle()); |
| 1380 paintStart = underline.startOffset; | 1390 // how much line to draw |
| 1381 useWholeWidth = false; | 1391 float width = (paintStart == static_cast<unsigned>(m_start) && paintEnd == s tatic_cast<unsigned>(end()) + 1) ? m_logicalWidth : |
| 1382 start = toRenderText(renderer()).width(m_start, paintStart - m_start, te xtPos(), isLeftToRightDirection() ? LTR : RTL, isFirstLineStyle()); | 1392 toRenderText(renderer()).width(paintStart, paintEnd - paintStart, textPo s() + start, isLeftToRightDirection() ? LTR : RTL, isFirstLineStyle()); |
| 1383 } | |
| 1384 if (paintEnd != underline.endOffset) { // end points at the last char, not past it | |
| 1385 paintEnd = min(paintEnd, (unsigned)underline.endOffset); | |
| 1386 useWholeWidth = false; | |
| 1387 } | |
| 1388 if (m_truncation != cNoTruncation) { | |
| 1389 paintEnd = min(paintEnd, (unsigned)m_start + m_truncation); | |
| 1390 useWholeWidth = false; | |
| 1391 } | |
| 1392 if (!useWholeWidth) { | |
| 1393 width = toRenderText(renderer()).width(paintStart, paintEnd - paintStart , textPos() + start, isLeftToRightDirection() ? LTR : RTL, isFirstLineStyle()); | |
| 1394 } | |
| 1395 | 1393 |
| 1396 // Thick marked text underlines are 2px thick as long as there is room for t he 2px line under the baseline. | 1394 // Thick marked text underlines are 2px thick as long as there is room for t he 2px line under the baseline. |
| 1397 // All other marked text underlines are 1px thick. | 1395 // All other marked text underlines are 1px thick. |
| 1398 // If there's not enough space the underline will touch or overlap character s. | 1396 // If there's not enough space the underline will touch or overlap character s. |
| 1399 int lineThickness = 1; | 1397 int lineThickness = 1; |
| 1400 int baseline = renderer().style(isFirstLineStyle())->fontMetrics().ascent(); | 1398 int baseline = renderer().style(isFirstLineStyle())->fontMetrics().ascent(); |
| 1401 if (underline.thick && logicalHeight() - baseline >= 2) | 1399 if (underline.thick && logicalHeight() - baseline >= 2) |
| 1402 lineThickness = 2; | 1400 lineThickness = 2; |
| 1403 | 1401 |
| 1404 // We need to have some space between underlines of subsequent clauses, beca use some input methods do not use different underline styles for those. | 1402 // We need to have some space between underlines of subsequent clauses, beca use some input methods do not use different underline styles for those. |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1579 printedCharacters = fprintf(stderr, "\t%s %p", obj.renderName(), &obj); | 1577 printedCharacters = fprintf(stderr, "\t%s %p", obj.renderName(), &obj); |
| 1580 const int rendererCharacterOffset = 24; | 1578 const int rendererCharacterOffset = 24; |
| 1581 for (; printedCharacters < rendererCharacterOffset; printedCharacters++) | 1579 for (; printedCharacters < rendererCharacterOffset; printedCharacters++) |
| 1582 fputc(' ', stderr); | 1580 fputc(' ', stderr); |
| 1583 fprintf(stderr, "(%d,%d) \"%s\"\n", start(), start() + len(), value.utf8().d ata()); | 1581 fprintf(stderr, "(%d,%d) \"%s\"\n", start(), start() + len(), value.utf8().d ata()); |
| 1584 } | 1582 } |
| 1585 | 1583 |
| 1586 #endif | 1584 #endif |
| 1587 | 1585 |
| 1588 } // namespace WebCore | 1586 } // namespace WebCore |
| OLD | NEW |