| 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 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 return LayoutUnit(-1); | 394 return LayoutUnit(-1); |
| 395 } | 395 } |
| 396 | 396 |
| 397 bool ltr_ellipsis_within_box = | 397 bool ltr_ellipsis_within_box = |
| 398 flow_is_ltr && ellipsis_x < adjusted_logical_left + LogicalWidth(); | 398 flow_is_ltr && ellipsis_x < adjusted_logical_left + LogicalWidth(); |
| 399 bool rtl_ellipsis_within_box = | 399 bool rtl_ellipsis_within_box = |
| 400 !flow_is_ltr && ellipsis_x > adjusted_logical_left; | 400 !flow_is_ltr && ellipsis_x > adjusted_logical_left; |
| 401 if (ltr_ellipsis_within_box || rtl_ellipsis_within_box) { | 401 if (ltr_ellipsis_within_box || rtl_ellipsis_within_box) { |
| 402 found_box = true; | 402 found_box = true; |
| 403 | 403 |
| 404 // The inline box may have different directionality than it's parent. Since | |
| 405 // truncation behavior depends both on both the parent and the inline | |
| 406 // block's directionality, we must keep track of these separately. | |
| 407 bool ltr = IsLeftToRightDirection(); | |
| 408 if (ltr != flow_is_ltr) { | |
| 409 // Width in pixels of the visible portion of the box, excluding the | |
| 410 // ellipsis. | |
| 411 LayoutUnit visible_box_width = | |
| 412 visible_right_edge - visible_left_edge - ellipsis_width; | |
| 413 ellipsis_x = flow_is_ltr ? adjusted_logical_left + visible_box_width | |
| 414 : LogicalRight() - visible_box_width; | |
| 415 } | |
| 416 | |
| 417 // OffsetForPosition() expects the position relative to the root box. | 404 // OffsetForPosition() expects the position relative to the root box. |
| 418 if (ltr == flow_is_ltr && !flow_is_ltr && logical_left_offset < 0) | 405 ellipsis_x -= logical_left_offset; |
| 419 ellipsis_x -= logical_left_offset; | |
| 420 | 406 |
| 421 // We measure the text using the second half of the previous character and | 407 // We measure the text using the second half of the previous character and |
| 422 // the first half of the current one when the text is rtl. This gives a | 408 // the first half of the current one when the text is rtl. This gives a |
| 423 // more accurate position in rtl text. | 409 // more accurate position in rtl text. |
| 424 // TODO(crbug.com/722043: This doesn't always give the best results. | 410 // TODO(crbug.com/722043: This doesn't always give the best results. |
| 411 bool ltr = IsLeftToRightDirection(); |
| 425 int offset = OffsetForPosition(ellipsis_x, !ltr); | 412 int offset = OffsetForPosition(ellipsis_x, !ltr); |
| 426 // Full truncation is only necessary when we're flowing left-to-right. | 413 // Full truncation is only necessary when we're flowing left-to-right. |
| 427 if (flow_is_ltr && offset == 0 && ltr == flow_is_ltr) { | 414 if (flow_is_ltr && offset == 0 && ltr == flow_is_ltr) { |
| 428 // No characters should be laid out. Set ourselves to full truncation and | 415 // No characters should be laid out. Set ourselves to full truncation and |
| 429 // place the ellipsis at the min of our start and the ellipsis edge. | 416 // place the ellipsis at the min of our start and the ellipsis edge. |
| 430 SetTruncation(kCFullTruncation); | 417 SetTruncation(kCFullTruncation); |
| 431 truncated_width += ellipsis_width; | 418 truncated_width += ellipsis_width; |
| 432 return std::min(ellipsis_x, LogicalLeft()); | 419 return std::min(ellipsis_x, LogicalLeft()); |
| 433 } | 420 } |
| 434 | 421 |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 760 for (; printed_characters < kLayoutObjectCharacterOffset; | 747 for (; printed_characters < kLayoutObjectCharacterOffset; |
| 761 printed_characters++) | 748 printed_characters++) |
| 762 fputc(' ', stderr); | 749 fputc(' ', stderr); |
| 763 fprintf(stderr, "(%d,%d) \"%s\"\n", Start(), Start() + Len(), | 750 fprintf(stderr, "(%d,%d) \"%s\"\n", Start(), Start() + Len(), |
| 764 value.Utf8().data()); | 751 value.Utf8().data()); |
| 765 } | 752 } |
| 766 | 753 |
| 767 #endif | 754 #endif |
| 768 | 755 |
| 769 } // namespace blink | 756 } // namespace blink |
| OLD | NEW |