| 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 * |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 #include "platform/fonts/GlyphBuffer.h" | 50 #include "platform/fonts/GlyphBuffer.h" |
| 51 #include "platform/fonts/WidthIterator.h" | 51 #include "platform/fonts/WidthIterator.h" |
| 52 #include "platform/graphics/DrawLooperBuilder.h" | 52 #include "platform/graphics/DrawLooperBuilder.h" |
| 53 #include "platform/graphics/GraphicsContextStateSaver.h" | 53 #include "platform/graphics/GraphicsContextStateSaver.h" |
| 54 #include "wtf/Vector.h" | 54 #include "wtf/Vector.h" |
| 55 #include "wtf/text/CString.h" | 55 #include "wtf/text/CString.h" |
| 56 #include "wtf/text/StringBuilder.h" | 56 #include "wtf/text/StringBuilder.h" |
| 57 | 57 |
| 58 #include <algorithm> | 58 #include <algorithm> |
| 59 | 59 |
| 60 using namespace std; | |
| 61 | |
| 62 namespace WebCore { | 60 namespace WebCore { |
| 63 | 61 |
| 64 struct SameSizeAsInlineTextBox : public InlineBox { | 62 struct SameSizeAsInlineTextBox : public InlineBox { |
| 65 unsigned variables[1]; | 63 unsigned variables[1]; |
| 66 unsigned short variables2[2]; | 64 unsigned short variables2[2]; |
| 67 void* pointers[2]; | 65 void* pointers[2]; |
| 68 }; | 66 }; |
| 69 | 67 |
| 70 COMPILE_ASSERT(sizeof(InlineTextBox) == sizeof(SameSizeAsInlineTextBox), InlineT
extBox_should_stay_small); | 68 COMPILE_ASSERT(sizeof(InlineTextBox) == sizeof(SameSizeAsInlineTextBox), InlineT
extBox_should_stay_small); |
| 71 | 69 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 return root().selectionBottom(); | 133 return root().selectionBottom(); |
| 136 } | 134 } |
| 137 | 135 |
| 138 LayoutUnit InlineTextBox::selectionHeight() | 136 LayoutUnit InlineTextBox::selectionHeight() |
| 139 { | 137 { |
| 140 return root().selectionHeight(); | 138 return root().selectionHeight(); |
| 141 } | 139 } |
| 142 | 140 |
| 143 bool InlineTextBox::isSelected(int startPos, int endPos) const | 141 bool InlineTextBox::isSelected(int startPos, int endPos) const |
| 144 { | 142 { |
| 145 int sPos = max(startPos - m_start, 0); | 143 int sPos = std::max(startPos - m_start, 0); |
| 146 // The position after a hard line break is considered to be past its end. | 144 // The position after a hard line break is considered to be past its end. |
| 147 // See the corresponding code in InlineTextBox::selectionState. | 145 // See the corresponding code in InlineTextBox::selectionState. |
| 148 int ePos = min(endPos - m_start, int(m_len) + (isLineBreak() ? 0 : 1)); | 146 int ePos = std::min(endPos - m_start, int(m_len) + (isLineBreak() ? 0 : 1)); |
| 149 return (sPos < ePos); | 147 return (sPos < ePos); |
| 150 } | 148 } |
| 151 | 149 |
| 152 RenderObject::SelectionState InlineTextBox::selectionState() | 150 RenderObject::SelectionState InlineTextBox::selectionState() |
| 153 { | 151 { |
| 154 RenderObject::SelectionState state = renderer().selectionState(); | 152 RenderObject::SelectionState state = renderer().selectionState(); |
| 155 if (state == RenderObject::SelectionStart || state == RenderObject::Selectio
nEnd || state == RenderObject::SelectionBoth) { | 153 if (state == RenderObject::SelectionStart || state == RenderObject::Selectio
nEnd || state == RenderObject::SelectionBoth) { |
| 156 int startPos, endPos; | 154 int startPos, endPos; |
| 157 renderer().selectionStartEnd(startPos, endPos); | 155 renderer().selectionStartEnd(startPos, endPos); |
| 158 // The position after a hard line break is considered to be past its end
. | 156 // 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... |
| 190 RenderObject::SelectionInside : RenderObject::SelectionNone); | 188 RenderObject::SelectionInside : RenderObject::SelectionNone); |
| 191 } else | 189 } else |
| 192 ellipsis->setSelectionState(RenderObject::SelectionNone); | 190 ellipsis->setSelectionState(RenderObject::SelectionNone); |
| 193 } | 191 } |
| 194 | 192 |
| 195 return state; | 193 return state; |
| 196 } | 194 } |
| 197 | 195 |
| 198 LayoutRect InlineTextBox::localSelectionRect(int startPos, int endPos) | 196 LayoutRect InlineTextBox::localSelectionRect(int startPos, int endPos) |
| 199 { | 197 { |
| 200 int sPos = max(startPos - m_start, 0); | 198 int sPos = std::max(startPos - m_start, 0); |
| 201 int ePos = min(endPos - m_start, (int)m_len); | 199 int ePos = std::min(endPos - m_start, (int)m_len); |
| 202 | 200 |
| 203 if (sPos > ePos) | 201 if (sPos > ePos) |
| 204 return LayoutRect(); | 202 return LayoutRect(); |
| 205 | 203 |
| 206 FontCachePurgePreventer fontCachePurgePreventer; | 204 FontCachePurgePreventer fontCachePurgePreventer; |
| 207 | 205 |
| 208 LayoutUnit selTop = selectionTop(); | 206 LayoutUnit selTop = selectionTop(); |
| 209 LayoutUnit selHeight = selectionHeight(); | 207 LayoutUnit selHeight = selectionHeight(); |
| 210 RenderStyle* styleToUse = textRenderer().style(isFirstLineStyle()); | 208 RenderStyle* styleToUse = textRenderer().style(isFirstLineStyle()); |
| 211 const Font& font = styleToUse->font(); | 209 const Font& font = styleToUse->font(); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 int visibleBoxWidth = visibleRightEdge - visibleLeftEdge - ellipsis
Width; | 290 int visibleBoxWidth = visibleRightEdge - visibleLeftEdge - ellipsis
Width; |
| 293 ellipsisX = ltr ? logicalLeft() + visibleBoxWidth : logicalRight() -
visibleBoxWidth; | 291 ellipsisX = ltr ? logicalLeft() + visibleBoxWidth : logicalRight() -
visibleBoxWidth; |
| 294 } | 292 } |
| 295 | 293 |
| 296 int offset = offsetForPosition(ellipsisX, false); | 294 int offset = offsetForPosition(ellipsisX, false); |
| 297 if (offset == 0) { | 295 if (offset == 0) { |
| 298 // No characters should be rendered. Set ourselves to full truncati
on and place the ellipsis at the min of our start | 296 // No characters should be rendered. Set ourselves to full truncati
on and place the ellipsis at the min of our start |
| 299 // and the ellipsis edge. | 297 // and the ellipsis edge. |
| 300 m_truncation = cFullTruncation; | 298 m_truncation = cFullTruncation; |
| 301 truncatedWidth += ellipsisWidth; | 299 truncatedWidth += ellipsisWidth; |
| 302 return min(ellipsisX, logicalLeft()); | 300 return std::min(ellipsisX, logicalLeft()); |
| 303 } | 301 } |
| 304 | 302 |
| 305 // Set the truncation index on the text run. | 303 // Set the truncation index on the text run. |
| 306 m_truncation = offset; | 304 m_truncation = offset; |
| 307 | 305 |
| 308 // If we got here that means that we were only partially truncated and w
e need to return the pixel offset at which | 306 // If we got here that means that we were only partially truncated and w
e need to return the pixel offset at which |
| 309 // to place the ellipsis. | 307 // to place the ellipsis. |
| 310 float widthOfVisibleText = toRenderText(renderer()).width(m_start, offse
t, textPos(), flowIsLTR ? LTR : RTL, isFirstLineStyle()); | 308 float widthOfVisibleText = toRenderText(renderer()).width(m_start, offse
t, textPos(), flowIsLTR ? LTR : RTL, isFirstLineStyle()); |
| 311 | 309 |
| 312 // The ellipsis needs to be placed just after the last visible character
. | 310 // The ellipsis needs to be placed just after the last visible character
. |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 669 TextRun textRun = constructTextRun(styleToUse, font, string, maximumLength,
hasHyphen() ? &charactersWithHyphen : 0); | 667 TextRun textRun = constructTextRun(styleToUse, font, string, maximumLength,
hasHyphen() ? &charactersWithHyphen : 0); |
| 670 if (hasHyphen()) | 668 if (hasHyphen()) |
| 671 length = textRun.length(); | 669 length = textRun.length(); |
| 672 | 670 |
| 673 int sPos = 0; | 671 int sPos = 0; |
| 674 int ePos = 0; | 672 int ePos = 0; |
| 675 if (paintSelectedTextOnly || paintSelectedTextSeparately) | 673 if (paintSelectedTextOnly || paintSelectedTextSeparately) |
| 676 selectionStartEnd(sPos, ePos); | 674 selectionStartEnd(sPos, ePos); |
| 677 | 675 |
| 678 if (m_truncation != cNoTruncation) { | 676 if (m_truncation != cNoTruncation) { |
| 679 sPos = min<int>(sPos, m_truncation); | 677 sPos = std::min<int>(sPos, m_truncation); |
| 680 ePos = min<int>(ePos, m_truncation); | 678 ePos = std::min<int>(ePos, m_truncation); |
| 681 length = m_truncation; | 679 length = m_truncation; |
| 682 } | 680 } |
| 683 | 681 |
| 684 int emphasisMarkOffset = 0; | 682 int emphasisMarkOffset = 0; |
| 685 TextEmphasisPosition emphasisMarkPosition; | 683 TextEmphasisPosition emphasisMarkPosition; |
| 686 bool hasTextEmphasis = getEmphasisMarkPosition(styleToUse, emphasisMarkPosit
ion); | 684 bool hasTextEmphasis = getEmphasisMarkPosition(styleToUse, emphasisMarkPosit
ion); |
| 687 const AtomicString& emphasisMark = hasTextEmphasis ? styleToUse->textEmphasi
sMarkString() : nullAtom; | 685 const AtomicString& emphasisMark = hasTextEmphasis ? styleToUse->textEmphasi
sMarkString() : nullAtom; |
| 688 if (!emphasisMark.isEmpty()) | 686 if (!emphasisMark.isEmpty()) |
| 689 emphasisMarkOffset = emphasisMarkPosition == TextEmphasisPositionOver ?
-font.fontMetrics().ascent() - font.emphasisMarkDescent(emphasisMark) : font.fon
tMetrics().descent() + font.emphasisMarkAscent(emphasisMark); | 687 emphasisMarkOffset = emphasisMarkPosition == TextEmphasisPositionOver ?
-font.fontMetrics().ascent() - font.emphasisMarkDescent(emphasisMark) : font.fon
tMetrics().descent() + font.emphasisMarkAscent(emphasisMark); |
| 690 | 688 |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 791 startPos = 0; | 789 startPos = 0; |
| 792 endPos = textRenderer().textLength(); | 790 endPos = textRenderer().textLength(); |
| 793 } else { | 791 } else { |
| 794 textRenderer().selectionStartEnd(startPos, endPos); | 792 textRenderer().selectionStartEnd(startPos, endPos); |
| 795 if (renderer().selectionState() == RenderObject::SelectionStart) | 793 if (renderer().selectionState() == RenderObject::SelectionStart) |
| 796 endPos = textRenderer().textLength(); | 794 endPos = textRenderer().textLength(); |
| 797 else if (renderer().selectionState() == RenderObject::SelectionEnd) | 795 else if (renderer().selectionState() == RenderObject::SelectionEnd) |
| 798 startPos = 0; | 796 startPos = 0; |
| 799 } | 797 } |
| 800 | 798 |
| 801 sPos = max(startPos - m_start, 0); | 799 sPos = std::max(startPos - m_start, 0); |
| 802 ePos = min(endPos - m_start, (int)m_len); | 800 ePos = std::min(endPos - m_start, (int)m_len); |
| 803 } | 801 } |
| 804 | 802 |
| 805 void alignSelectionRectToDevicePixels(FloatRect& rect) | 803 void alignSelectionRectToDevicePixels(FloatRect& rect) |
| 806 { | 804 { |
| 807 float maxX = floorf(rect.maxX()); | 805 float maxX = floorf(rect.maxX()); |
| 808 rect.setX(floorf(rect.x())); | 806 rect.setX(floorf(rect.x())); |
| 809 rect.setWidth(roundf(maxX - rect.x())); | 807 rect.setWidth(roundf(maxX - rect.x())); |
| 810 } | 808 } |
| 811 | 809 |
| 812 void InlineTextBox::paintSelection(GraphicsContext* context, const FloatPoint& b
oxOrigin, RenderStyle* style, const Font& font, Color textColor) | 810 void InlineTextBox::paintSelection(GraphicsContext* context, const FloatPoint& b
oxOrigin, RenderStyle* style, const Font& font, Color textColor) |
| (...skipping 30 matching lines...) Expand all Loading... |
| 843 StringBuilder charactersWithHyphen; | 841 StringBuilder charactersWithHyphen; |
| 844 bool respectHyphen = ePos == length && hasHyphen(); | 842 bool respectHyphen = ePos == length && hasHyphen(); |
| 845 TextRun textRun = constructTextRun(style, font, string, textRenderer().textL
ength() - m_start, respectHyphen ? &charactersWithHyphen : 0); | 843 TextRun textRun = constructTextRun(style, font, string, textRenderer().textL
ength() - m_start, respectHyphen ? &charactersWithHyphen : 0); |
| 846 if (respectHyphen) | 844 if (respectHyphen) |
| 847 ePos = textRun.length(); | 845 ePos = textRun.length(); |
| 848 | 846 |
| 849 LayoutUnit selectionBottom = root().selectionBottom(); | 847 LayoutUnit selectionBottom = root().selectionBottom(); |
| 850 LayoutUnit selectionTop = root().selectionTopAdjustedForPrecedingBlock(); | 848 LayoutUnit selectionTop = root().selectionTopAdjustedForPrecedingBlock(); |
| 851 | 849 |
| 852 int deltaY = roundToInt(renderer().style()->isFlippedLinesWritingMode() ? se
lectionBottom - logicalBottom() : logicalTop() - selectionTop); | 850 int deltaY = roundToInt(renderer().style()->isFlippedLinesWritingMode() ? se
lectionBottom - logicalBottom() : logicalTop() - selectionTop); |
| 853 int selHeight = max(0, roundToInt(selectionBottom - selectionTop)); | 851 int selHeight = std::max(0, roundToInt(selectionBottom - selectionTop)); |
| 854 | 852 |
| 855 FloatPoint localOrigin(boxOrigin.x(), boxOrigin.y() - deltaY); | 853 FloatPoint localOrigin(boxOrigin.x(), boxOrigin.y() - deltaY); |
| 856 FloatRect clipRect(localOrigin, FloatSize(m_logicalWidth, selHeight)); | 854 FloatRect clipRect(localOrigin, FloatSize(m_logicalWidth, selHeight)); |
| 857 alignSelectionRectToDevicePixels(clipRect); | 855 alignSelectionRectToDevicePixels(clipRect); |
| 858 | 856 |
| 859 context->clip(clipRect); | 857 context->clip(clipRect); |
| 860 | 858 |
| 861 context->drawHighlightForText(font, textRun, localOrigin, selHeight, c, sPos
, ePos); | 859 context->drawHighlightForText(font, textRun, localOrigin, selHeight, c, sPos
, ePos); |
| 862 } | 860 } |
| 863 | 861 |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 999 context->adjustLineToPixelBoundaries(p1, p2, strokeThickness, context->strok
eStyle()); | 997 context->adjustLineToPixelBoundaries(p1, p2, strokeThickness, context->strok
eStyle()); |
| 1000 | 998 |
| 1001 Path path; | 999 Path path; |
| 1002 path.moveTo(p1); | 1000 path.moveTo(p1); |
| 1003 | 1001 |
| 1004 // Distance between decoration's axis and Bezier curve's control points. | 1002 // Distance between decoration's axis and Bezier curve's control points. |
| 1005 // The height of the curve is based on this distance. Use a minimum of 6 pix
els distance since | 1003 // The height of the curve is based on this distance. Use a minimum of 6 pix
els distance since |
| 1006 // the actual curve passes approximately at half of that distance, that is 3
pixels. | 1004 // the actual curve passes approximately at half of that distance, that is 3
pixels. |
| 1007 // The minimum height of the curve is also approximately 3 pixels. Increases
the curve's height | 1005 // The minimum height of the curve is also approximately 3 pixels. Increases
the curve's height |
| 1008 // as strockThickness increases to make the curve looks better. | 1006 // as strockThickness increases to make the curve looks better. |
| 1009 float controlPointDistance = 3 * max<float>(2, strokeThickness); | 1007 float controlPointDistance = 3 * std::max<float>(2, strokeThickness); |
| 1010 | 1008 |
| 1011 // Increment used to form the diamond shape between start point (p1), contro
l | 1009 // Increment used to form the diamond shape between start point (p1), contro
l |
| 1012 // points and end point (p2) along the axis of the decoration. Makes the | 1010 // points and end point (p2) along the axis of the decoration. Makes the |
| 1013 // curve wider as strockThickness increases to make the curve looks better. | 1011 // curve wider as strockThickness increases to make the curve looks better. |
| 1014 float step = 2 * max<float>(2, strokeThickness); | 1012 float step = 2 * std::max<float>(2, strokeThickness); |
| 1015 | 1013 |
| 1016 bool isVerticalLine = (p1.x() == p2.x()); | 1014 bool isVerticalLine = (p1.x() == p2.x()); |
| 1017 | 1015 |
| 1018 if (isVerticalLine) { | 1016 if (isVerticalLine) { |
| 1019 ASSERT(p1.x() == p2.x()); | 1017 ASSERT(p1.x() == p2.x()); |
| 1020 | 1018 |
| 1021 float xAxis = p1.x(); | 1019 float xAxis = p1.x(); |
| 1022 float y1; | 1020 float y1; |
| 1023 float y2; | 1021 float y2; |
| 1024 | 1022 |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1153 if (!linesAreOpaque && shadowCount > 1) { | 1151 if (!linesAreOpaque && shadowCount > 1) { |
| 1154 FloatRect clipRect(localOrigin, FloatSize(width, baseline + 2)); | 1152 FloatRect clipRect(localOrigin, FloatSize(width, baseline + 2)); |
| 1155 for (size_t i = shadowCount; i--; ) { | 1153 for (size_t i = shadowCount; i--; ) { |
| 1156 const ShadowData& s = shadowList->shadows()[i]; | 1154 const ShadowData& s = shadowList->shadows()[i]; |
| 1157 FloatRect shadowRect(localOrigin, FloatSize(width, baseline + 2)); | 1155 FloatRect shadowRect(localOrigin, FloatSize(width, baseline + 2)); |
| 1158 shadowRect.inflate(s.blur()); | 1156 shadowRect.inflate(s.blur()); |
| 1159 float shadowX = isHorizontal() ? s.x() : s.y(); | 1157 float shadowX = isHorizontal() ? s.x() : s.y(); |
| 1160 float shadowY = isHorizontal() ? s.y() : -s.x(); | 1158 float shadowY = isHorizontal() ? s.y() : -s.x(); |
| 1161 shadowRect.move(shadowX, shadowY); | 1159 shadowRect.move(shadowX, shadowY); |
| 1162 clipRect.unite(shadowRect); | 1160 clipRect.unite(shadowRect); |
| 1163 extraOffset = max(extraOffset, max(0.0f, shadowY) + s.blur()); | 1161 extraOffset = std::max(extraOffset, std::max(0.0f, shadowY) + s.blur
()); |
| 1164 } | 1162 } |
| 1165 context->clip(clipRect); | 1163 context->clip(clipRect); |
| 1166 extraOffset += baseline + 2; | 1164 extraOffset += baseline + 2; |
| 1167 localOrigin.move(0, extraOffset); | 1165 localOrigin.move(0, extraOffset); |
| 1168 } | 1166 } |
| 1169 | 1167 |
| 1170 for (size_t i = max(static_cast<size_t>(1), shadowCount); i--; ) { | 1168 for (size_t i = std::max(static_cast<size_t>(1), shadowCount); i--; ) { |
| 1171 // Even if we have no shadows, we still want to run the code below this
once. | 1169 // Even if we have no shadows, we still want to run the code below this
once. |
| 1172 if (i < shadowCount) { | 1170 if (i < shadowCount) { |
| 1173 if (!i) { | 1171 if (!i) { |
| 1174 // The last set of lines paints normally inside the clip. | 1172 // The last set of lines paints normally inside the clip. |
| 1175 localOrigin.move(0, -extraOffset); | 1173 localOrigin.move(0, -extraOffset); |
| 1176 extraOffset = 0; | 1174 extraOffset = 0; |
| 1177 } | 1175 } |
| 1178 const ShadowData& shadow = shadowList->shadows()[i]; | 1176 const ShadowData& shadow = shadowList->shadows()[i]; |
| 1179 float shadowX = isHorizontal() ? shadow.x() : shadow.y(); | 1177 float shadowX = isHorizontal() ? shadow.x() : shadow.y(); |
| 1180 float shadowY = isHorizontal() ? shadow.y() : -shadow.x(); | 1178 float shadowY = isHorizontal() ? shadow.y() : -shadow.x(); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1226 // Determine whether we need to measure text | 1224 // Determine whether we need to measure text |
| 1227 bool markerSpansWholeBox = true; | 1225 bool markerSpansWholeBox = true; |
| 1228 if (m_start <= (int)marker->startOffset()) | 1226 if (m_start <= (int)marker->startOffset()) |
| 1229 markerSpansWholeBox = false; | 1227 markerSpansWholeBox = false; |
| 1230 if ((end() + 1) != marker->endOffset()) // end points at the last char, not
past it | 1228 if ((end() + 1) != marker->endOffset()) // end points at the last char, not
past it |
| 1231 markerSpansWholeBox = false; | 1229 markerSpansWholeBox = false; |
| 1232 if (m_truncation != cNoTruncation) | 1230 if (m_truncation != cNoTruncation) |
| 1233 markerSpansWholeBox = false; | 1231 markerSpansWholeBox = false; |
| 1234 | 1232 |
| 1235 if (!markerSpansWholeBox || grammar) { | 1233 if (!markerSpansWholeBox || grammar) { |
| 1236 int startPosition = max<int>(marker->startOffset() - m_start, 0); | 1234 int startPosition = std::max<int>(marker->startOffset() - m_start, 0); |
| 1237 int endPosition = min<int>(marker->endOffset() - m_start, m_len); | 1235 int endPosition = std::min<int>(marker->endOffset() - m_start, m_len); |
| 1238 | 1236 |
| 1239 if (m_truncation != cNoTruncation) | 1237 if (m_truncation != cNoTruncation) |
| 1240 endPosition = min<int>(endPosition, m_truncation); | 1238 endPosition = std::min<int>(endPosition, m_truncation); |
| 1241 | 1239 |
| 1242 // Calculate start & width | 1240 // Calculate start & width |
| 1243 int deltaY = renderer().style()->isFlippedLinesWritingMode() ? selection
Bottom() - logicalBottom() : logicalTop() - selectionTop(); | 1241 int deltaY = renderer().style()->isFlippedLinesWritingMode() ? selection
Bottom() - logicalBottom() : logicalTop() - selectionTop(); |
| 1244 int selHeight = selectionHeight(); | 1242 int selHeight = selectionHeight(); |
| 1245 FloatPoint startPoint(boxOrigin.x(), boxOrigin.y() - deltaY); | 1243 FloatPoint startPoint(boxOrigin.x(), boxOrigin.y() - deltaY); |
| 1246 TextRun run = constructTextRun(style, font); | 1244 TextRun run = constructTextRun(style, font); |
| 1247 | 1245 |
| 1248 // FIXME: Convert the document markers to float rects. | 1246 // FIXME: Convert the document markers to float rects. |
| 1249 IntRect markerRect = enclosingIntRect(font.selectionRectForText(run, sta
rtPoint, selHeight, startPosition, endPosition)); | 1247 IntRect markerRect = enclosingIntRect(font.selectionRectForText(run, sta
rtPoint, selHeight, startPosition, endPosition)); |
| 1250 start = markerRect.x() - startPoint.x(); | 1248 start = markerRect.x() - startPoint.x(); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1279 pt->drawLineForDocumentMarker(FloatPoint(boxOrigin.x() + start, boxOrigin.y(
) + underlineOffset), width, lineStyleForMarkerType(marker->type())); | 1277 pt->drawLineForDocumentMarker(FloatPoint(boxOrigin.x() + start, boxOrigin.y(
) + underlineOffset), width, lineStyleForMarkerType(marker->type())); |
| 1280 } | 1278 } |
| 1281 | 1279 |
| 1282 void InlineTextBox::paintTextMatchMarker(GraphicsContext* pt, const FloatPoint&
boxOrigin, DocumentMarker* marker, RenderStyle* style, const Font& font) | 1280 void InlineTextBox::paintTextMatchMarker(GraphicsContext* pt, const FloatPoint&
boxOrigin, DocumentMarker* marker, RenderStyle* style, const Font& font) |
| 1283 { | 1281 { |
| 1284 // Use same y positioning and height as for selection, so that when the sele
ction and this highlight are on | 1282 // Use same y positioning and height as for selection, so that when the sele
ction and this highlight are on |
| 1285 // the same word there are no pieces sticking out. | 1283 // the same word there are no pieces sticking out. |
| 1286 int deltaY = renderer().style()->isFlippedLinesWritingMode() ? selectionBott
om() - logicalBottom() : logicalTop() - selectionTop(); | 1284 int deltaY = renderer().style()->isFlippedLinesWritingMode() ? selectionBott
om() - logicalBottom() : logicalTop() - selectionTop(); |
| 1287 int selHeight = selectionHeight(); | 1285 int selHeight = selectionHeight(); |
| 1288 | 1286 |
| 1289 int sPos = max(marker->startOffset() - m_start, (unsigned)0); | 1287 int sPos = std::max(marker->startOffset() - m_start, (unsigned)0); |
| 1290 int ePos = min(marker->endOffset() - m_start, (unsigned)m_len); | 1288 int ePos = std::min(marker->endOffset() - m_start, (unsigned)m_len); |
| 1291 TextRun run = constructTextRun(style, font); | 1289 TextRun run = constructTextRun(style, font); |
| 1292 | 1290 |
| 1293 // Always compute and store the rect associated with this marker. The comput
ed rect is in absolute coordinates. | 1291 // Always compute and store the rect associated with this marker. The comput
ed rect is in absolute coordinates. |
| 1294 IntRect markerRect = enclosingIntRect(font.selectionRectForText(run, IntPoin
t(x(), selectionTop()), selHeight, sPos, ePos)); | 1292 IntRect markerRect = enclosingIntRect(font.selectionRectForText(run, IntPoin
t(x(), selectionTop()), selHeight, sPos, ePos)); |
| 1295 markerRect = renderer().localToAbsoluteQuad(FloatRect(markerRect)).enclosing
BoundingBox(); | 1293 markerRect = renderer().localToAbsoluteQuad(FloatRect(markerRect)).enclosing
BoundingBox(); |
| 1296 toRenderedDocumentMarker(marker)->setRenderedRect(markerRect); | 1294 toRenderedDocumentMarker(marker)->setRenderedRect(markerRect); |
| 1297 | 1295 |
| 1298 // Optionally highlight the text | 1296 // Optionally highlight the text |
| 1299 if (renderer().frame()->editor().markedTextMatchesAreHighlighted()) { | 1297 if (renderer().frame()->editor().markedTextMatchesAreHighlighted()) { |
| 1300 Color color = marker->activeMatch() ? | 1298 Color color = marker->activeMatch() ? |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1582 printedCharacters = fprintf(stderr, "\t%s %p", obj.renderName(), &obj); | 1580 printedCharacters = fprintf(stderr, "\t%s %p", obj.renderName(), &obj); |
| 1583 const int rendererCharacterOffset = 24; | 1581 const int rendererCharacterOffset = 24; |
| 1584 for (; printedCharacters < rendererCharacterOffset; printedCharacters++) | 1582 for (; printedCharacters < rendererCharacterOffset; printedCharacters++) |
| 1585 fputc(' ', stderr); | 1583 fputc(' ', stderr); |
| 1586 fprintf(stderr, "(%d,%d) \"%s\"\n", start(), start() + len(), value.utf8().d
ata()); | 1584 fprintf(stderr, "(%d,%d) \"%s\"\n", start(), start() + len(), value.utf8().d
ata()); |
| 1587 } | 1585 } |
| 1588 | 1586 |
| 1589 #endif | 1587 #endif |
| 1590 | 1588 |
| 1591 } // namespace WebCore | 1589 } // namespace WebCore |
| OLD | NEW |