Changeset 109366 in webkit
- Timestamp:
- Mar 1, 2012, 10:45:26 AM (15 years ago)
- Location:
- branches/chromium/1025
- 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/1025/Source/WebCore/editing/ApplyBlockElementCommand.cpp
r102833 r109366 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/1025/Source/WebCore/editing/InsertListCommand.cpp
r93134 r109366 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/1025/Source/WebCore/editing/htmlediting.cpp
r105902 r109366 1073 1073 // or these functions need to be changed to iterate using actual VisiblePositions. 1074 1074 // FIXME: Deploy these functions everywhere that TextIterators are used to convert between VisiblePositions and indices. 1075 int indexForVisiblePosition(const VisiblePosition& visiblePosition, Element **scope)1075 int indexForVisiblePosition(const VisiblePosition& visiblePosition, RefPtr<Element>& scope) 1076 1076 { 1077 1077 if (visiblePosition.isNull()) 1078 1078 return 0; 1079 1079 1080 1080 Position p(visiblePosition.deepEquivalent()); 1081 1081 Document* document = p.anchorNode()->document(); 1082 1083 Element* root;1084 1082 Node* shadowRoot = p.anchorNode()->shadowTreeRootNode(); 1085 1083 1086 1084 if (shadowRoot) { 1087 1085 // Use the shadow root for form elements, since TextIterators will not enter shadow content. 1088 1086 ASSERT(shadowRoot->isElementNode()); 1089 root= static_cast<Element*>(shadowRoot);1087 scope = static_cast<Element*>(shadowRoot); 1090 1088 } else 1091 root = document->documentElement(); 1092 1093 if (scope) { 1094 ASSERT(!*scope); 1095 *scope = root; 1096 } 1097 1098 RefPtr<Range> range = Range::create(document, firstPositionInNode(root), p.parentAnchoredEquivalent()); 1099 1089 scope = document->documentElement(); 1090 1091 RefPtr<Range> range = Range::create(document, firstPositionInNode(scope.get()), p.parentAnchoredEquivalent()); 1092 1100 1093 return TextIterator::rangeLength(range.get(), true); 1101 1094 } -
branches/chromium/1025/Source/WebCore/editing/htmlediting.h
r104276 r109366 181 181 int comparePositions(const VisiblePosition&, const VisiblePosition&); 182 182 183 int indexForVisiblePosition(const VisiblePosition&, Element **scope);183 int indexForVisiblePosition(const VisiblePosition&, RefPtr<Element>& scope); 184 184 VisiblePosition visiblePositionForIndex(int index, Element *scope); 185 185
Note:
See TracChangeset
for help on using the changeset viewer.