| 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. | 4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. |
| 5 * All rights reserved. | 5 * All rights reserved. |
| 6 * | 6 * |
| 7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
| 8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
| 9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
| 10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 bool ltr = isLeftToRightDirection(); | 356 bool ltr = isLeftToRightDirection(); |
| 357 if (ltr != flowIsLTR) { | 357 if (ltr != flowIsLTR) { |
| 358 // Width in pixels of the visible portion of the box, excluding the | 358 // Width in pixels of the visible portion of the box, excluding the |
| 359 // ellipsis. | 359 // ellipsis. |
| 360 LayoutUnit visibleBoxWidth = | 360 LayoutUnit visibleBoxWidth = |
| 361 visibleRightEdge - visibleLeftEdge - ellipsisWidth; | 361 visibleRightEdge - visibleLeftEdge - ellipsisWidth; |
| 362 ellipsisX = flowIsLTR ? adjustedLogicalLeft + visibleBoxWidth | 362 ellipsisX = flowIsLTR ? adjustedLogicalLeft + visibleBoxWidth |
| 363 : logicalRight() - visibleBoxWidth; | 363 : logicalRight() - visibleBoxWidth; |
| 364 } | 364 } |
| 365 | 365 |
| 366 // The box's width includes partial glyphs, so respect that when placing | 366 // We measure the text using the second half of the previous character and |
| 367 // the ellipsis. | 367 // the first half of the current one when the text is rtl. This gives a |
| 368 int offset = offsetForPosition(ellipsisX); | 368 // more accurate position in rtl text. |
| 369 int offset = offsetForPosition(ellipsisX, !ltr); |
| 369 // Full truncation is only necessary when we're flowing left-to-right. | 370 // Full truncation is only necessary when we're flowing left-to-right. |
| 370 if (flowIsLTR && offset == 0 && ltr == flowIsLTR) { | 371 if (flowIsLTR && offset == 0 && ltr == flowIsLTR) { |
| 371 // No characters should be laid out. Set ourselves to full truncation and | 372 // No characters should be laid out. Set ourselves to full truncation and |
| 372 // place the ellipsis at the min of our start and the ellipsis edge. | 373 // place the ellipsis at the min of our start and the ellipsis edge. |
| 373 setTruncation(cFullTruncation); | 374 setTruncation(cFullTruncation); |
| 374 truncatedWidth += ellipsisWidth; | 375 truncatedWidth += ellipsisWidth; |
| 375 return std::min(ellipsisX, logicalLeft()); | 376 return std::min(ellipsisX, logicalLeft()); |
| 376 } | 377 } |
| 377 | 378 |
| 379 // When the text's direction doesn't match the flow's direction we can |
| 380 // choose an offset that starts outside the visible box: compensate for that |
| 381 // if necessary. |
| 382 if (flowIsLTR != ltr && logicalLeft() < 0 && offset >= m_start && |
| 383 positionForOffset(offset) < logicalLeft().abs()) |
| 384 offset++; |
| 385 |
| 378 // Set the truncation index on the text run. | 386 // Set the truncation index on the text run. |
| 379 setTruncation(offset); | 387 setTruncation(offset); |
| 380 | 388 |
| 381 // If we got here that means that we were only partially truncated and we | 389 // If we got here that means that we were only partially truncated and we |
| 382 // need to return the pixel offset at which to place the ellipsis. Where the | 390 // need to return the pixel offset at which to place the ellipsis. Where the |
| 383 // text and its flow have opposite directions then our offset into the text | 391 // text and its flow have opposite directions then our offset into the text |
| 384 // is at the start of the part that will be visible. | 392 // is at the start of the part that will be visible. |
| 385 LayoutUnit widthOfVisibleText(getLineLayoutItem().width( | 393 LayoutUnit widthOfVisibleText(getLineLayoutItem().width( |
| 386 ltr == flowIsLTR ? m_start : m_start + offset, | 394 ltr == flowIsLTR ? m_start : m_start + offset, |
| 387 ltr == flowIsLTR ? offset : m_len - offset, textPos(), | 395 ltr == flowIsLTR ? offset : m_len - offset, textPos(), |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 693 const int layoutObjectCharacterOffset = 75; | 701 const int layoutObjectCharacterOffset = 75; |
| 694 for (; printedCharacters < layoutObjectCharacterOffset; printedCharacters++) | 702 for (; printedCharacters < layoutObjectCharacterOffset; printedCharacters++) |
| 695 fputc(' ', stderr); | 703 fputc(' ', stderr); |
| 696 fprintf(stderr, "(%d,%d) \"%s\"\n", start(), start() + len(), | 704 fprintf(stderr, "(%d,%d) \"%s\"\n", start(), start() + len(), |
| 697 value.utf8().data()); | 705 value.utf8().data()); |
| 698 } | 706 } |
| 699 | 707 |
| 700 #endif | 708 #endif |
| 701 | 709 |
| 702 } // namespace blink | 710 } // namespace blink |
| OLD | NEW |