Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(112)

Side by Side Diff: third_party/WebKit/Source/core/editing/VisibleUnits.cpp

Issue 2931673004: Make InlineBoxPosition constructor not to accept null-InlineBox (Closed)
Patch Set: 2017-06-12T14:51:57 Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 772 matching lines...) Expand 10 before | Expand all | Expand 10 after
783 const PositionTemplate<Strategy>& downstream_equivalent = 783 const PositionTemplate<Strategy>& downstream_equivalent =
784 DownstreamIgnoringEditingBoundaries(position); 784 DownstreamIgnoringEditingBoundaries(position);
785 if (downstream_equivalent != position) { 785 if (downstream_equivalent != position) {
786 return ComputeInlineBoxPosition( 786 return ComputeInlineBoxPosition(
787 downstream_equivalent, TextAffinity::kUpstream, primary_direction); 787 downstream_equivalent, TextAffinity::kUpstream, primary_direction);
788 } 788 }
789 const PositionTemplate<Strategy>& upstream_equivalent = 789 const PositionTemplate<Strategy>& upstream_equivalent =
790 UpstreamIgnoringEditingBoundaries(position); 790 UpstreamIgnoringEditingBoundaries(position);
791 if (upstream_equivalent == position || 791 if (upstream_equivalent == position ||
792 DownstreamIgnoringEditingBoundaries(upstream_equivalent) == position) 792 DownstreamIgnoringEditingBoundaries(upstream_equivalent) == position)
793 return InlineBoxPosition(inline_box, caret_offset); 793 return InlineBoxPosition();
794 794
795 return ComputeInlineBoxPosition( 795 return ComputeInlineBoxPosition(
796 upstream_equivalent, TextAffinity::kUpstream, primary_direction); 796 upstream_equivalent, TextAffinity::kUpstream, primary_direction);
797 } 797 }
798 if (layout_object->IsBox()) { 798 if (layout_object->IsBox()) {
799 inline_box = ToLayoutBox(layout_object)->InlineBoxWrapper(); 799 inline_box = ToLayoutBox(layout_object)->InlineBoxWrapper();
800 if (!inline_box || (caret_offset > inline_box->CaretMinOffset() && 800 if (!inline_box)
801 caret_offset < inline_box->CaretMaxOffset())) 801 return InlineBoxPosition();
802 if ((caret_offset > inline_box->CaretMinOffset() &&
803 caret_offset < inline_box->CaretMaxOffset()))
802 return InlineBoxPosition(inline_box, caret_offset); 804 return InlineBoxPosition(inline_box, caret_offset);
803 } 805 }
804 } else { 806 } else {
805 LayoutText* text_layout_object = ToLayoutText(layout_object); 807 LayoutText* text_layout_object = ToLayoutText(layout_object);
806 808
807 InlineTextBox* candidate = nullptr; 809 InlineTextBox* candidate = nullptr;
808 810
809 for (InlineTextBox* box : InlineTextBoxesOf(*text_layout_object)) { 811 for (InlineTextBox* box : InlineTextBoxesOf(*text_layout_object)) {
810 int caret_min_offset = box->CaretMinOffset(); 812 int caret_min_offset = box->CaretMinOffset();
811 int caret_max_offset = box->CaretMaxOffset(); 813 int caret_max_offset = box->CaretMaxOffset();
(...skipping 21 matching lines...) Expand all
833 affinity == TextAffinity::kDownstream) { 835 affinity == TextAffinity::kDownstream) {
834 inline_box = SearchAheadForBetterMatch(text_layout_object); 836 inline_box = SearchAheadForBetterMatch(text_layout_object);
835 if (inline_box) 837 if (inline_box)
836 caret_offset = inline_box->CaretMinOffset(); 838 caret_offset = inline_box->CaretMinOffset();
837 } 839 }
838 if (!inline_box) 840 if (!inline_box)
839 inline_box = candidate; 841 inline_box = candidate;
840 } 842 }
841 843
842 if (!inline_box) 844 if (!inline_box)
843 return InlineBoxPosition(inline_box, caret_offset); 845 return InlineBoxPosition();
844 return AdjustInlineBoxPositionForTextDirection( 846 return AdjustInlineBoxPositionForTextDirection(
845 inline_box, caret_offset, layout_object->Style()->GetUnicodeBidi(), 847 inline_box, caret_offset, layout_object->Style()->GetUnicodeBidi(),
846 primary_direction); 848 primary_direction);
847 } 849 }
848 850
849 static InlineBoxPosition AdjustInlineBoxPositionForTextDirection( 851 static InlineBoxPosition AdjustInlineBoxPositionForTextDirection(
850 InlineBox* inline_box, 852 InlineBox* inline_box,
851 int caret_offset, 853 int caret_offset,
852 UnicodeBidi unicode_bidi, 854 UnicodeBidi unicode_bidi,
853 TextDirection primary_direction) { 855 TextDirection primary_direction) {
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
1017 1019
1018 const InlineBoxPosition& box_position = 1020 const InlineBoxPosition& box_position =
1019 ComputeInlineBoxPosition(position.GetPosition(), position.Affinity()); 1021 ComputeInlineBoxPosition(position.GetPosition(), position.Affinity());
1020 1022
1021 if (box_position.inline_box) { 1023 if (box_position.inline_box) {
1022 return ComputeLocalCaretRect( 1024 return ComputeLocalCaretRect(
1023 LineLayoutAPIShim::LayoutObjectFrom( 1025 LineLayoutAPIShim::LayoutObjectFrom(
1024 box_position.inline_box->GetLineLayoutItem()), 1026 box_position.inline_box->GetLineLayoutItem()),
1025 box_position); 1027 box_position);
1026 } 1028 }
1027 return ComputeLocalCaretRect(layout_object, box_position); 1029 // DeleteSelectionCommandTest.deleteListFromTable goes here.
1030 return LocalCaretRect(
1031 layout_object,
1032 layout_object->LocalCaretRect(
1033 nullptr, position.GetPosition().ComputeEditingOffset()));
Xiaocheng 2017/06/12 18:53:41 Could you clarify this change? We should have |bo
yosin_UTC9 2017/06/13 06:55:00 Before this patch, we have box_positon.layout_obje
Xiaocheng 2017/06/13 17:25:03 Thanks!
1028 } 1034 }
1029 1035
1030 // This function was added because the caret rect that is calculated by 1036 // This function was added because the caret rect that is calculated by
1031 // using the line top value instead of the selection top. 1037 // using the line top value instead of the selection top.
1032 template <typename Strategy> 1038 template <typename Strategy>
1033 LocalCaretRect LocalSelectionRectOfPositionTemplate( 1039 LocalCaretRect LocalSelectionRectOfPositionTemplate(
1034 const PositionWithAffinityTemplate<Strategy>& position) { 1040 const PositionWithAffinityTemplate<Strategy>& position) {
1035 if (position.IsNull()) 1041 if (position.IsNull())
1036 return LocalCaretRect(); 1042 return LocalCaretRect();
1037 Node* const node = position.AnchorNode(); 1043 Node* const node = position.AnchorNode();
(...skipping 1024 matching lines...) Expand 10 before | Expand all | Expand 10 after
2062 2068
2063 IntRect ComputeTextRect(const EphemeralRangeInFlatTree& range) { 2069 IntRect ComputeTextRect(const EphemeralRangeInFlatTree& range) {
2064 return EnclosingIntRect(ComputeTextRectTemplate(range)); 2070 return EnclosingIntRect(ComputeTextRectTemplate(range));
2065 } 2071 }
2066 2072
2067 FloatRect ComputeTextFloatRect(const EphemeralRange& range) { 2073 FloatRect ComputeTextFloatRect(const EphemeralRange& range) {
2068 return ComputeTextRectTemplate(range); 2074 return ComputeTextRectTemplate(range);
2069 } 2075 }
2070 2076
2071 } // namespace blink 2077 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/editing/VisibleUnits.h ('k') | third_party/WebKit/Source/core/editing/VisibleUnitsTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698