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 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 m_truncation = cFullTruncation; | 298 m_truncation = cFullTruncation; |
299 truncatedWidth += ellipsisWidth; | 299 truncatedWidth += ellipsisWidth; |
300 return min(ellipsisX, logicalLeft()); | 300 return min(ellipsisX, logicalLeft()); |
301 } | 301 } |
302 | 302 |
303 // Set the truncation index on the text run. | 303 // Set the truncation index on the text run. |
304 m_truncation = offset; | 304 m_truncation = offset; |
305 | 305 |
306 // 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 |
307 // to place the ellipsis. | 307 // to place the ellipsis. |
308 float widthOfVisibleText = toRenderText(renderer())->width(m_start, offs
et, textPos(), isFirstLineStyle()); | 308 float widthOfVisibleText = toRenderText(renderer())->width(m_start, offs
et, textPos(), flowIsLTR ? LTR : RTL, isFirstLineStyle()); |
309 | 309 |
310 // 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
. |
311 // Where "after" is defined by the flow directionality, not the inline | 311 // Where "after" is defined by the flow directionality, not the inline |
312 // box directionality. | 312 // box directionality. |
313 // e.g. In the case of an LTR inline box truncated in an RTL flow then w
e can | 313 // e.g. In the case of an LTR inline box truncated in an RTL flow then w
e can |
314 // have a situation such as |Hello| -> |...He| | 314 // have a situation such as |Hello| -> |...He| |
315 truncatedWidth += widthOfVisibleText + ellipsisWidth; | 315 truncatedWidth += widthOfVisibleText + ellipsisWidth; |
316 if (flowIsLTR) | 316 if (flowIsLTR) |
317 return logicalLeft() + widthOfVisibleText; | 317 return logicalLeft() + widthOfVisibleText; |
318 else | 318 else |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 if (m_truncation != cNoTruncation) { | 497 if (m_truncation != cNoTruncation) { |
498 if (renderer()->containingBlock()->style()->isLeftToRightDirection() !=
isLeftToRightDirection()) { | 498 if (renderer()->containingBlock()->style()->isLeftToRightDirection() !=
isLeftToRightDirection()) { |
499 // Make the visible fragment of text hug the edge closest to the res
t of the run by moving the origin | 499 // Make the visible fragment of text hug the edge closest to the res
t of the run by moving the origin |
500 // at which we start drawing text. | 500 // at which we start drawing text. |
501 // e.g. In the case of LTR text truncated in an RTL Context, the cor
rect behavior is: | 501 // e.g. In the case of LTR text truncated in an RTL Context, the cor
rect behavior is: |
502 // |Hello|CBA| -> |...He|CBA| | 502 // |Hello|CBA| -> |...He|CBA| |
503 // In order to draw the fragment "He" aligned to the right edge of i
t's box, we need to start drawing | 503 // In order to draw the fragment "He" aligned to the right edge of i
t's box, we need to start drawing |
504 // farther to the right. | 504 // farther to the right. |
505 // NOTE: WebKit's behavior differs from that of IE which appears to
just overlay the ellipsis on top of the | 505 // NOTE: WebKit's behavior differs from that of IE which appears to
just overlay the ellipsis on top of the |
506 // truncated string i.e. |Hello|CBA| -> |...lo|CBA| | 506 // truncated string i.e. |Hello|CBA| -> |...lo|CBA| |
507 LayoutUnit widthOfVisibleText = toRenderText(renderer())->width(m_st
art, m_truncation, textPos(), isFirstLineStyle()); | 507 LayoutUnit widthOfVisibleText = toRenderText(renderer())->width(m_st
art, m_truncation, textPos(), isLeftToRightDirection() ? LTR : RTL, isFirstLineS
tyle()); |
508 LayoutUnit widthOfHiddenText = m_logicalWidth - widthOfVisibleText; | 508 LayoutUnit widthOfHiddenText = m_logicalWidth - widthOfVisibleText; |
509 // FIXME: The hit testing logic also needs to take this translation
into account. | 509 // FIXME: The hit testing logic also needs to take this translation
into account. |
510 LayoutSize truncationOffset(isLeftToRightDirection() ? widthOfHidden
Text : -widthOfHiddenText, 0); | 510 LayoutSize truncationOffset(isLeftToRightDirection() ? widthOfHidden
Text : -widthOfHiddenText, 0); |
511 adjustedPaintOffset.move(isHorizontal() ? truncationOffset : truncat
ionOffset.transposedSize()); | 511 adjustedPaintOffset.move(isHorizontal() ? truncationOffset : truncat
ionOffset.transposedSize()); |
512 } | 512 } |
513 } | 513 } |
514 | 514 |
515 GraphicsContext* context = paintInfo.context; | 515 GraphicsContext* context = paintInfo.context; |
516 | 516 |
517 RenderObject* rendererToUse = renderer(); | 517 RenderObject* rendererToUse = renderer(); |
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1055 { | 1055 { |
1056 GraphicsContextStateSaver stateSaver(*context); | 1056 GraphicsContextStateSaver stateSaver(*context); |
1057 | 1057 |
1058 if (m_truncation == cFullTruncation) | 1058 if (m_truncation == cFullTruncation) |
1059 return; | 1059 return; |
1060 | 1060 |
1061 FloatPoint localOrigin = boxOrigin; | 1061 FloatPoint localOrigin = boxOrigin; |
1062 | 1062 |
1063 float width = m_logicalWidth; | 1063 float width = m_logicalWidth; |
1064 if (m_truncation != cNoTruncation) { | 1064 if (m_truncation != cNoTruncation) { |
1065 width = toRenderText(renderer())->width(m_start, m_truncation, textPos()
, isFirstLineStyle()); | 1065 width = toRenderText(renderer())->width(m_start, m_truncation, textPos()
, isLeftToRightDirection() ? LTR : RTL, isFirstLineStyle()); |
1066 if (!isLeftToRightDirection()) | 1066 if (!isLeftToRightDirection()) |
1067 localOrigin.move(m_logicalWidth - width, 0); | 1067 localOrigin.move(m_logicalWidth - width, 0); |
1068 } | 1068 } |
1069 | 1069 |
1070 // Get the text decoration colors. | 1070 // Get the text decoration colors. |
1071 Color underline, overline, linethrough; | 1071 Color underline, overline, linethrough; |
1072 renderer()->getTextDecorationColors(deco, underline, overline, linethrough,
true); | 1072 renderer()->getTextDecorationColors(deco, underline, overline, linethrough,
true); |
1073 if (isFirstLineStyle()) | 1073 if (isFirstLineStyle()) |
1074 renderer()->getTextDecorationColors(deco, underline, overline, linethrou
gh, true, true); | 1074 renderer()->getTextDecorationColors(deco, underline, overline, linethrou
gh, true, true); |
1075 | 1075 |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1342 return; | 1342 return; |
1343 | 1343 |
1344 float start = 0; // start of line to draw, relative to tx | 1344 float start = 0; // start of line to draw, relative to tx |
1345 float width = m_logicalWidth; // how much line to draw | 1345 float width = m_logicalWidth; // how much line to draw |
1346 bool useWholeWidth = true; | 1346 bool useWholeWidth = true; |
1347 unsigned paintStart = m_start; | 1347 unsigned paintStart = m_start; |
1348 unsigned paintEnd = end() + 1; // end points at the last char, not past it | 1348 unsigned paintEnd = end() + 1; // end points at the last char, not past it |
1349 if (paintStart <= underline.startOffset) { | 1349 if (paintStart <= underline.startOffset) { |
1350 paintStart = underline.startOffset; | 1350 paintStart = underline.startOffset; |
1351 useWholeWidth = false; | 1351 useWholeWidth = false; |
1352 start = toRenderText(renderer())->width(m_start, paintStart - m_start, t
extPos(), isFirstLineStyle()); | 1352 start = toRenderText(renderer())->width(m_start, paintStart - m_start, t
extPos(), isLeftToRightDirection() ? LTR : RTL, isFirstLineStyle()); |
1353 } | 1353 } |
1354 if (paintEnd != underline.endOffset) { // end points at the last char,
not past it | 1354 if (paintEnd != underline.endOffset) { // end points at the last char,
not past it |
1355 paintEnd = min(paintEnd, (unsigned)underline.endOffset); | 1355 paintEnd = min(paintEnd, (unsigned)underline.endOffset); |
1356 useWholeWidth = false; | 1356 useWholeWidth = false; |
1357 } | 1357 } |
1358 if (m_truncation != cNoTruncation) { | 1358 if (m_truncation != cNoTruncation) { |
1359 paintEnd = min(paintEnd, (unsigned)m_start + m_truncation); | 1359 paintEnd = min(paintEnd, (unsigned)m_start + m_truncation); |
1360 useWholeWidth = false; | 1360 useWholeWidth = false; |
1361 } | 1361 } |
1362 if (!useWholeWidth) { | 1362 if (!useWholeWidth) { |
1363 width = toRenderText(renderer())->width(paintStart, paintEnd - paintStar
t, textPos() + start, isFirstLineStyle()); | 1363 width = toRenderText(renderer())->width(paintStart, paintEnd - paintStar
t, textPos() + start, isLeftToRightDirection() ? LTR : RTL, isFirstLineStyle()); |
1364 } | 1364 } |
1365 | 1365 |
1366 // Thick marked text underlines are 2px thick as long as there is room for t
he 2px line under the baseline. | 1366 // Thick marked text underlines are 2px thick as long as there is room for t
he 2px line under the baseline. |
1367 // All other marked text underlines are 1px thick. | 1367 // All other marked text underlines are 1px thick. |
1368 // If there's not enough space the underline will touch or overlap character
s. | 1368 // If there's not enough space the underline will touch or overlap character
s. |
1369 int lineThickness = 1; | 1369 int lineThickness = 1; |
1370 int baseline = renderer()->style(isFirstLineStyle())->fontMetrics().ascent()
; | 1370 int baseline = renderer()->style(isFirstLineStyle())->fontMetrics().ascent()
; |
1371 if (underline.thick && logicalHeight() - baseline >= 2) | 1371 if (underline.thick && logicalHeight() - baseline >= 2) |
1372 lineThickness = 2; | 1372 lineThickness = 2; |
1373 | 1373 |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1555 printedCharacters = fprintf(stderr, "\t%s %p", obj->renderName(), obj); | 1555 printedCharacters = fprintf(stderr, "\t%s %p", obj->renderName(), obj); |
1556 const int rendererCharacterOffset = 24; | 1556 const int rendererCharacterOffset = 24; |
1557 for (; printedCharacters < rendererCharacterOffset; printedCharacters++) | 1557 for (; printedCharacters < rendererCharacterOffset; printedCharacters++) |
1558 fputc(' ', stderr); | 1558 fputc(' ', stderr); |
1559 fprintf(stderr, "(%d,%d) \"%s\"\n", start(), start() + len(), value.utf8().d
ata()); | 1559 fprintf(stderr, "(%d,%d) \"%s\"\n", start(), start() + len(), value.utf8().d
ata()); |
1560 } | 1560 } |
1561 | 1561 |
1562 #endif | 1562 #endif |
1563 | 1563 |
1564 } // namespace WebCore | 1564 } // namespace WebCore |
OLD | NEW |