Changeset 109365 in webkit
- Timestamp:
- Mar 1, 2012, 10:43:56 AM (15 years ago)
- Location:
- branches/chromium/963
- Files:
-
- 4 edited
- 2 copied
-
LayoutTests/editing/execCommand/applyblockelement-visiblepositionforindex-crash-expected.txt (copied) (copied from trunk/LayoutTests/editing/execCommand/applyblockelement-visiblepositionforindex-crash-expected.txt )
-
LayoutTests/editing/execCommand/applyblockelement-visiblepositionforindex-crash.html (copied) (copied from trunk/LayoutTests/editing/execCommand/applyblockelement-visiblepositionforindex-crash.html )
-
Source/WebCore/editing/ApplyBlockElementCommand.cpp (modified) (2 diffs)
-
Source/WebCore/editing/InsertListCommand.cpp (modified) (1 diff)
-
Source/WebCore/editing/htmlediting.cpp (modified) (1 diff)
-
Source/WebCore/editing/htmlediting.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/chromium/963/Source/WebCore/editing/ApplyBlockElementCommand.cpp
r95901 r109365 81 81 ASSERT(!startOfSelection.isNull()); 82 82 ASSERT(!endOfSelection.isNull()); 83 Element* startScope = 0;84 int startIndex = indexForVisiblePosition(startOfSelection, &startScope);85 Element* endScope = 0;86 int endIndex = indexForVisiblePosition(endOfSelection, &endScope);83 RefPtr<Element> startScope; 84 int startIndex = indexForVisiblePosition(startOfSelection, startScope); 85 RefPtr<Element> endScope; 86 int endIndex = indexForVisiblePosition(endOfSelection, endScope); 87 87 88 88 formatSelection(startOfSelection, endOfSelection); … … 94 94 ASSERT(startIndex <= endIndex); 95 95 if (startScope == endScope && startIndex >= 0 && startIndex <= endIndex) { 96 VisiblePosition start(visiblePositionForIndex(startIndex, startScope ));97 VisiblePosition end(visiblePositionForIndex(endIndex, endScope ));96 VisiblePosition start(visiblePositionForIndex(startIndex, startScope.get())); 97 VisiblePosition end(visiblePositionForIndex(endIndex, endScope.get())); 98 98 if (start.isNotNull() && end.isNotNull()) 99 99 setEndingSelection(VisibleSelection(start, end, endingSelection().isDirectional())); -
branches/chromium/963/Source/WebCore/editing/InsertListCommand.cpp
r93134 r109365 153 153 // the beginning of the document to the endOfSelection everytime this code is executed. 154 154 // But not using index is hard because there are so many ways we can lose selection inside doApplyForSingleParagraph. 155 Element* scope = 0;156 int indexForEndOfSelection = indexForVisiblePosition(endOfSelection, &scope);155 RefPtr<Element> scope; 156 int indexForEndOfSelection = indexForVisiblePosition(endOfSelection, scope); 157 157 doApplyForSingleParagraph(forceCreateList, listTag, currentSelection.get()); 158 158 if (endOfSelection.isNull() || endOfSelection.isOrphan() || startOfLastParagraph.isNull() || startOfLastParagraph.isOrphan()) { 159 endOfSelection = visiblePositionForIndex(indexForEndOfSelection, scope );159 endOfSelection = visiblePositionForIndex(indexForEndOfSelection, scope.get()); 160 160 // If endOfSelection is null, then some contents have been deleted from the document. 161 161 // This should never happen and if it did, exit early immediately because we've lost the loop invariant. -
branches/chromium/963/Source/WebCore/editing/htmlediting.cpp
r99918 r109365 1071 1071 // or these functions need to be changed to iterate using actual VisiblePositions. 1072 1072 // FIXME: Deploy these functions everywhere that TextIterators are used to convert between VisiblePositions and indices. 1073 int indexForVisiblePosition(const VisiblePosition& visiblePosition, Element **scope)1073 int indexForVisiblePosition(const VisiblePosition& visiblePosition, RefPtr<Element>& scope) 1074 1074 { 1075 1075 if (visiblePosition.isNull()) 1076 1076 return 0; 1077 1077 1078 1078 Position p(visiblePosition.deepEquivalent()); 1079 1079 Document* document = p.anchorNode()->document(); 1080 1081 Element* root;1082 1080 Node* shadowRoot = p.anchorNode()->shadowTreeRootNode(); 1083 1081 1084 1082 if (shadowRoot) { 1085 1083 // Use the shadow root for form elements, since TextIterators will not enter shadow content. 1086 1084 ASSERT(shadowRoot->isElementNode()); 1087 root= static_cast<Element*>(shadowRoot);1085 scope = static_cast<Element*>(shadowRoot); 1088 1086 } else 1089 root = document->documentElement(); 1090 1091 if (scope) { 1092 ASSERT(!*scope); 1093 *scope = root; 1094 } 1095 1096 RefPtr<Range> range = Range::create(document, firstPositionInNode(root), p.parentAnchoredEquivalent()); 1097 1087 scope = document->documentElement(); 1088 1089 RefPtr<Range> range = Range::create(document, firstPositionInNode(scope.get()), p.parentAnchoredEquivalent()); 1090 1098 1091 return TextIterator::rangeLength(range.get(), true); 1099 1092 } -
branches/chromium/963/Source/WebCore/editing/htmlediting.h
r99918 r109365 180 180 int comparePositions(const VisiblePosition&, const VisiblePosition&); 181 181 182 int indexForVisiblePosition(const VisiblePosition&, Element **scope);182 int indexForVisiblePosition(const VisiblePosition&, RefPtr<Element>& scope); 183 183 VisiblePosition visiblePositionForIndex(int index, Element *scope); 184 184
Note:
See TracChangeset
for help on using the changeset viewer.