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 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 | 249 |
250 LayoutPoint topPoint; | 250 LayoutPoint topPoint; |
251 LayoutUnit width; | 251 LayoutUnit width; |
252 LayoutUnit height; | 252 LayoutUnit height; |
253 if (isHorizontal()) { | 253 if (isHorizontal()) { |
254 topPoint = LayoutPoint(r.x(), selTop); | 254 topPoint = LayoutPoint(r.x(), selTop); |
255 width = logicalWidth; | 255 width = logicalWidth; |
256 height = selHeight; | 256 height = selHeight; |
257 if (hasWrappedSelectionNewline()) { | 257 if (hasWrappedSelectionNewline()) { |
258 if (!isLeftToRightDirection()) | 258 if (!isLeftToRightDirection()) |
259 topPoint.setX(topPoint.x() - newlineSpaceWidth()); | 259 topPoint.setX(LayoutUnit(topPoint.x() - newlineSpaceWidth())); |
260 width += newlineSpaceWidth(); | 260 width += newlineSpaceWidth(); |
261 } | 261 } |
262 } else { | 262 } else { |
263 topPoint = LayoutPoint(selTop, r.x()); | 263 topPoint = LayoutPoint(selTop, r.x()); |
264 width = selHeight; | 264 width = selHeight; |
265 height = logicalWidth; | 265 height = logicalWidth; |
266 // TODO(wkorman): RTL text embedded in top-to-bottom text can create | 266 // TODO(wkorman): RTL text embedded in top-to-bottom text can create |
267 // bottom-to-top situations. Add tests and ensure we handle correctly. | 267 // bottom-to-top situations. Add tests and ensure we handle correctly. |
268 if (hasWrappedSelectionNewline()) | 268 if (hasWrappedSelectionNewline()) |
269 height += newlineSpaceWidth(); | 269 height += newlineSpaceWidth(); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 setTruncation(cFullTruncation); | 352 setTruncation(cFullTruncation); |
353 truncatedWidth += ellipsisWidth; | 353 truncatedWidth += ellipsisWidth; |
354 return std::min(ellipsisX, logicalLeft()); | 354 return std::min(ellipsisX, logicalLeft()); |
355 } | 355 } |
356 | 356 |
357 // Set the truncation index on the text run. | 357 // Set the truncation index on the text run. |
358 setTruncation(offset); | 358 setTruncation(offset); |
359 | 359 |
360 // If we got here that means that we were only partially truncated and w
e need to return the pixel offset at which | 360 // If we got here that means that we were only partially truncated and w
e need to return the pixel offset at which |
361 // to place the ellipsis. | 361 // to place the ellipsis. |
362 LayoutUnit widthOfVisibleText = lineLayoutItem().width(m_start, offset,
textPos(), flowIsLTR ? LTR : RTL, isFirstLineStyle()); | 362 LayoutUnit widthOfVisibleText(lineLayoutItem().width(m_start, offset, te
xtPos(), flowIsLTR ? LTR : RTL, isFirstLineStyle())); |
363 | 363 |
364 // The ellipsis needs to be placed just after the last visible character
. | 364 // The ellipsis needs to be placed just after the last visible character
. |
365 // Where "after" is defined by the flow directionality, not the inline | 365 // Where "after" is defined by the flow directionality, not the inline |
366 // box directionality. | 366 // box directionality. |
367 // e.g. In the case of an LTR inline box truncated in an RTL flow then w
e can | 367 // e.g. In the case of an LTR inline box truncated in an RTL flow then w
e can |
368 // have a situation such as |Hello| -> |...He| | 368 // have a situation such as |Hello| -> |...He| |
369 truncatedWidth += widthOfVisibleText + ellipsisWidth; | 369 truncatedWidth += widthOfVisibleText + ellipsisWidth; |
370 if (flowIsLTR) | 370 if (flowIsLTR) |
371 return logicalLeft() + widthOfVisibleText; | 371 return logicalLeft() + widthOfVisibleText; |
372 return logicalRight() - widthOfVisibleText - ellipsisWidth; | 372 return logicalRight() - widthOfVisibleText - ellipsisWidth; |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 | 499 |
500 if (isLineBreak()) | 500 if (isLineBreak()) |
501 return logicalLeft(); | 501 return logicalLeft(); |
502 | 502 |
503 LineLayoutText text = lineLayoutItem(); | 503 LineLayoutText text = lineLayoutItem(); |
504 const ComputedStyle& styleToUse = text.styleRef(isFirstLineStyle()); | 504 const ComputedStyle& styleToUse = text.styleRef(isFirstLineStyle()); |
505 const Font& font = styleToUse.font(); | 505 const Font& font = styleToUse.font(); |
506 int from = !isLeftToRightDirection() ? offset - m_start : 0; | 506 int from = !isLeftToRightDirection() ? offset - m_start : 0; |
507 int to = !isLeftToRightDirection() ? m_len : offset - m_start; | 507 int to = !isLeftToRightDirection() ? m_len : offset - m_start; |
508 // FIXME: Do we need to add rightBearing here? | 508 // FIXME: Do we need to add rightBearing here? |
509 return font.selectionRectForText(constructTextRun(styleToUse, font), IntPoin
t(logicalLeft(), 0), 0, from, to).maxX(); | 509 return LayoutUnit(font.selectionRectForText(constructTextRun(styleToUse, fon
t), IntPoint(logicalLeft(), 0), 0, from, to).maxX()); |
510 } | 510 } |
511 | 511 |
512 bool InlineTextBox::containsCaretOffset(int offset) const | 512 bool InlineTextBox::containsCaretOffset(int offset) const |
513 { | 513 { |
514 // Offsets before the box are never "in". | 514 // Offsets before the box are never "in". |
515 if (offset < m_start) | 515 if (offset < m_start) |
516 return false; | 516 return false; |
517 | 517 |
518 int pastEnd = m_start + m_len; | 518 int pastEnd = m_start + m_len; |
519 | 519 |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
626 printedCharacters = fprintf(stderr, "\t%s %p", obj.name(), obj.debugPointer(
)); | 626 printedCharacters = fprintf(stderr, "\t%s %p", obj.name(), obj.debugPointer(
)); |
627 const int layoutObjectCharacterOffset = 75; | 627 const int layoutObjectCharacterOffset = 75; |
628 for (; printedCharacters < layoutObjectCharacterOffset; printedCharacters++) | 628 for (; printedCharacters < layoutObjectCharacterOffset; printedCharacters++) |
629 fputc(' ', stderr); | 629 fputc(' ', stderr); |
630 fprintf(stderr, "(%d,%d) \"%s\"\n", start(), start() + len(), value.utf8().d
ata()); | 630 fprintf(stderr, "(%d,%d) \"%s\"\n", start(), start() + len(), value.utf8().d
ata()); |
631 } | 631 } |
632 | 632 |
633 #endif | 633 #endif |
634 | 634 |
635 } // namespace blink | 635 } // namespace blink |
OLD | NEW |