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 755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
766 if (!layout_object->IsText()) { | 766 if (!layout_object->IsText()) { |
767 inline_box = 0; | 767 inline_box = 0; |
768 if (CanHaveChildrenForEditing(anchor_node) && | 768 if (CanHaveChildrenForEditing(anchor_node) && |
769 layout_object->IsLayoutBlockFlow() && | 769 layout_object->IsLayoutBlockFlow() && |
770 HasRenderedNonAnonymousDescendantsWithHeight(layout_object)) { | 770 HasRenderedNonAnonymousDescendantsWithHeight(layout_object)) { |
771 // Try a visually equivalent position with possibly opposite | 771 // Try a visually equivalent position with possibly opposite |
772 // editability. This helps in case |this| is in an editable block | 772 // editability. This helps in case |this| is in an editable block |
773 // but surrounded by non-editable positions. It acts to negate the | 773 // but surrounded by non-editable positions. It acts to negate the |
774 // logic at the beginning of | 774 // logic at the beginning of |
775 // |LayoutObject::createPositionWithAffinity()|. | 775 // |LayoutObject::createPositionWithAffinity()|. |
776 PositionTemplate<Strategy> equivalent = | 776 const PositionTemplate<Strategy>& downstream_equivalent = |
777 DownstreamIgnoringEditingBoundaries(position); | 777 DownstreamIgnoringEditingBoundaries(position); |
778 if (equivalent == position) { | 778 if (downstream_equivalent != position) { |
779 equivalent = UpstreamIgnoringEditingBoundaries(position); | 779 return ComputeInlineBoxPosition( |
780 if (equivalent == position || | 780 downstream_equivalent, TextAffinity::kUpstream, primary_direction); |
781 DownstreamIgnoringEditingBoundaries(equivalent) == position) | |
782 return InlineBoxPosition(inline_box, caret_offset); | |
783 } | 781 } |
| 782 const PositionTemplate<Strategy>& upstream_equivalent = |
| 783 UpstreamIgnoringEditingBoundaries(position); |
| 784 if (upstream_equivalent == position || |
| 785 DownstreamIgnoringEditingBoundaries(upstream_equivalent) == position) |
| 786 return InlineBoxPosition(inline_box, caret_offset); |
784 | 787 |
785 return ComputeInlineBoxPosition(equivalent, TextAffinity::kUpstream, | 788 return ComputeInlineBoxPosition( |
786 primary_direction); | 789 upstream_equivalent, TextAffinity::kUpstream, primary_direction); |
787 } | 790 } |
788 if (layout_object->IsBox()) { | 791 if (layout_object->IsBox()) { |
789 inline_box = ToLayoutBox(layout_object)->InlineBoxWrapper(); | 792 inline_box = ToLayoutBox(layout_object)->InlineBoxWrapper(); |
790 if (!inline_box || (caret_offset > inline_box->CaretMinOffset() && | 793 if (!inline_box || (caret_offset > inline_box->CaretMinOffset() && |
791 caret_offset < inline_box->CaretMaxOffset())) | 794 caret_offset < inline_box->CaretMaxOffset())) |
792 return InlineBoxPosition(inline_box, caret_offset); | 795 return InlineBoxPosition(inline_box, caret_offset); |
793 } | 796 } |
794 } else { | 797 } else { |
795 LayoutText* text_layout_object = ToLayoutText(layout_object); | 798 LayoutText* text_layout_object = ToLayoutText(layout_object); |
796 | 799 |
(...skipping 1686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2483 | 2486 |
2484 IntRect ComputeTextRect(const EphemeralRangeInFlatTree& range) { | 2487 IntRect ComputeTextRect(const EphemeralRangeInFlatTree& range) { |
2485 return EnclosingIntRect(ComputeTextRectTemplate(range)); | 2488 return EnclosingIntRect(ComputeTextRectTemplate(range)); |
2486 } | 2489 } |
2487 | 2490 |
2488 FloatRect ComputeTextFloatRect(const EphemeralRange& range) { | 2491 FloatRect ComputeTextFloatRect(const EphemeralRange& range) { |
2489 return ComputeTextRectTemplate(range); | 2492 return ComputeTextRectTemplate(range); |
2490 } | 2493 } |
2491 | 2494 |
2492 } // namespace blink | 2495 } // namespace blink |
OLD | NEW |