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