| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights | 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights |
| 3 * reserved. | 3 * reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 741 static bool IsStartOfDifferentDirection(const InlineBox* inline_box) { | 741 static bool IsStartOfDifferentDirection(const InlineBox* inline_box) { |
| 742 InlineBox* prev_box = inline_box->PrevLeafChild(); | 742 InlineBox* prev_box = inline_box->PrevLeafChild(); |
| 743 if (!prev_box) | 743 if (!prev_box) |
| 744 return true; | 744 return true; |
| 745 if (prev_box->Direction() == inline_box->Direction()) | 745 if (prev_box->Direction() == inline_box->Direction()) |
| 746 return true; | 746 return true; |
| 747 DCHECK_NE(prev_box->BidiLevel(), inline_box->BidiLevel()); | 747 DCHECK_NE(prev_box->BidiLevel(), inline_box->BidiLevel()); |
| 748 return prev_box->BidiLevel() > inline_box->BidiLevel(); | 748 return prev_box->BidiLevel() > inline_box->BidiLevel(); |
| 749 } | 749 } |
| 750 | 750 |
| 751 // TODO(yosin): We have a forward declaration here to reduce patch size. We'll |
| 752 // replice this with an implementation once review finished. |
| 753 static InlineBoxPosition AdjustInlineBoxPositionForTextDirection(InlineBox*, |
| 754 int, |
| 755 UnicodeBidi, |
| 756 TextDirection); |
| 757 |
| 751 template <typename Strategy> | 758 template <typename Strategy> |
| 752 static InlineBoxPosition ComputeInlineBoxPositionTemplate( | 759 static InlineBoxPosition ComputeInlineBoxPositionTemplate( |
| 753 const PositionTemplate<Strategy>& position, | 760 const PositionTemplate<Strategy>& position, |
| 754 TextAffinity affinity, | 761 TextAffinity affinity, |
| 755 TextDirection primary_direction) { | 762 TextDirection primary_direction) { |
| 756 InlineBox* inline_box = nullptr; | 763 InlineBox* inline_box = nullptr; |
| 757 int caret_offset = position.ComputeEditingOffset(); | 764 int caret_offset = position.ComputeEditingOffset(); |
| 758 Node* const anchor_node = position.AnchorNode(); | 765 Node* const anchor_node = position.AnchorNode(); |
| 759 LayoutObject* layout_object = | 766 LayoutObject* layout_object = |
| 760 anchor_node->IsShadowRoot() | 767 anchor_node->IsShadowRoot() |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 824 inline_box = SearchAheadForBetterMatch(text_layout_object); | 831 inline_box = SearchAheadForBetterMatch(text_layout_object); |
| 825 if (inline_box) | 832 if (inline_box) |
| 826 caret_offset = inline_box->CaretMinOffset(); | 833 caret_offset = inline_box->CaretMinOffset(); |
| 827 } | 834 } |
| 828 if (!inline_box) | 835 if (!inline_box) |
| 829 inline_box = candidate; | 836 inline_box = candidate; |
| 830 } | 837 } |
| 831 | 838 |
| 832 if (!inline_box) | 839 if (!inline_box) |
| 833 return InlineBoxPosition(inline_box, caret_offset); | 840 return InlineBoxPosition(inline_box, caret_offset); |
| 841 return AdjustInlineBoxPositionForTextDirection( |
| 842 inline_box, caret_offset, layout_object->Style()->GetUnicodeBidi(), |
| 843 primary_direction); |
| 844 } |
| 834 | 845 |
| 846 static InlineBoxPosition AdjustInlineBoxPositionForTextDirection( |
| 847 InlineBox* inline_box, |
| 848 int caret_offset, |
| 849 UnicodeBidi unicode_bidi, |
| 850 TextDirection primary_direction) { |
| 835 unsigned char level = inline_box->BidiLevel(); | 851 unsigned char level = inline_box->BidiLevel(); |
| 836 | 852 |
| 837 if (inline_box->Direction() == primary_direction) { | 853 if (inline_box->Direction() == primary_direction) { |
| 838 if (caret_offset == inline_box->CaretRightmostOffset()) { | 854 if (caret_offset == inline_box->CaretRightmostOffset()) { |
| 839 InlineBox* next_box = inline_box->NextLeafChild(); | 855 InlineBox* next_box = inline_box->NextLeafChild(); |
| 840 if (!next_box || next_box->BidiLevel() >= level) | 856 if (!next_box || next_box->BidiLevel() >= level) |
| 841 return InlineBoxPosition(inline_box, caret_offset); | 857 return InlineBoxPosition(inline_box, caret_offset); |
| 842 | 858 |
| 843 level = next_box->BidiLevel(); | 859 level = next_box->BidiLevel(); |
| 844 InlineBox* prev_box = inline_box; | 860 InlineBox* prev_box = inline_box; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 899 inline_box->PrevLeafChildIgnoringLineBreak()) { | 915 inline_box->PrevLeafChildIgnoringLineBreak()) { |
| 900 if (tertiary_box->BidiLevel() <= level) | 916 if (tertiary_box->BidiLevel() <= level) |
| 901 break; | 917 break; |
| 902 inline_box = tertiary_box; | 918 inline_box = tertiary_box; |
| 903 } | 919 } |
| 904 return InlineBoxPosition(inline_box, inline_box->CaretLeftmostOffset()); | 920 return InlineBoxPosition(inline_box, inline_box->CaretLeftmostOffset()); |
| 905 } | 921 } |
| 906 return InlineBoxPosition(inline_box, caret_offset); | 922 return InlineBoxPosition(inline_box, caret_offset); |
| 907 } | 923 } |
| 908 | 924 |
| 909 if (layout_object && | 925 if (unicode_bidi == UnicodeBidi::kPlaintext) { |
| 910 layout_object->Style()->GetUnicodeBidi() == UnicodeBidi::kPlaintext) { | |
| 911 if (inline_box->BidiLevel() < level) | 926 if (inline_box->BidiLevel() < level) |
| 912 return InlineBoxPosition(inline_box, inline_box->CaretLeftmostOffset()); | 927 return InlineBoxPosition(inline_box, inline_box->CaretLeftmostOffset()); |
| 913 return InlineBoxPosition(inline_box, inline_box->CaretRightmostOffset()); | 928 return InlineBoxPosition(inline_box, inline_box->CaretRightmostOffset()); |
| 914 } | 929 } |
| 915 | 930 |
| 916 InlineBox* next_box = inline_box->NextLeafChildIgnoringLineBreak(); | 931 InlineBox* next_box = inline_box->NextLeafChildIgnoringLineBreak(); |
| 917 if (!next_box || next_box->BidiLevel() < level) { | 932 if (!next_box || next_box->BidiLevel() < level) { |
| 918 // Right edge of a secondary run. Set to the left edge of the entire | 933 // Right edge of a secondary run. Set to the left edge of the entire |
| 919 // run. | 934 // run. |
| 920 while (InlineBox* prev_box = inline_box->PrevLeafChildIgnoringLineBreak()) { | 935 while (InlineBox* prev_box = inline_box->PrevLeafChildIgnoringLineBreak()) { |
| (...skipping 1562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2483 | 2498 |
| 2484 IntRect ComputeTextRect(const EphemeralRangeInFlatTree& range) { | 2499 IntRect ComputeTextRect(const EphemeralRangeInFlatTree& range) { |
| 2485 return EnclosingIntRect(ComputeTextRectTemplate(range)); | 2500 return EnclosingIntRect(ComputeTextRectTemplate(range)); |
| 2486 } | 2501 } |
| 2487 | 2502 |
| 2488 FloatRect ComputeTextFloatRect(const EphemeralRange& range) { | 2503 FloatRect ComputeTextFloatRect(const EphemeralRange& range) { |
| 2489 return ComputeTextRectTemplate(range); | 2504 return ComputeTextRectTemplate(range); |
| 2490 } | 2505 } |
| 2491 | 2506 |
| 2492 } // namespace blink | 2507 } // namespace blink |
| OLD | NEW |