⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 109366 in webkit


Ignore:
Timestamp:
Mar 1, 2012, 10:45:26 AM (15 years ago)
Author:
cevans@google.com
Message:

Merge 108009
BUG=112542
Review URL: ​https://chromiumcodereview.appspot.com/9567016

Location:
branches/chromium/1025
Files:
4 edited
2 copied

Legend:

Unmodified
Added
Removed
  • branches/chromium/1025/Source/WebCore/editing/ApplyBlockElementCommand.cpp

    r102833 r109366  
    8181    ASSERT(!startOfSelection.isNull());
    8282    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);
    8787
    8888    formatSelection(startOfSelection, endOfSelection);
    … …  
    9494    ASSERT(startIndex <= endIndex);
    9595    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()));
    9898        if (start.isNotNull() && end.isNotNull())
    9999            setEndingSelection(VisibleSelection(start, end, endingSelection().isDirectional()));
  • branches/chromium/1025/Source/WebCore/editing/InsertListCommand.cpp

    r93134 r109366  
    153153                // the beginning of the document to the endOfSelection everytime this code is executed.
    154154                // 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);
    157157                doApplyForSingleParagraph(forceCreateList, listTag, currentSelection.get());
    158158                if (endOfSelection.isNull() || endOfSelection.isOrphan() || startOfLastParagraph.isNull() || startOfLastParagraph.isOrphan()) {
    159                     endOfSelection = visiblePositionForIndex(indexForEndOfSelection, scope);
     159                    endOfSelection = visiblePositionForIndex(indexForEndOfSelection, scope.get());
    160160                    // If endOfSelection is null, then some contents have been deleted from the document.
    161161                    // 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  
    10731073// or these functions need to be changed to iterate using actual VisiblePositions.
    10741074// FIXME: Deploy these functions everywhere that TextIterators are used to convert between VisiblePositions and indices.
    1075 int indexForVisiblePosition(const VisiblePosition& visiblePosition, Element **scope)
     1075int indexForVisiblePosition(const VisiblePosition& visiblePosition, RefPtr<Element>& scope)
    10761076{
    10771077    if (visiblePosition.isNull())
    10781078        return 0;
    1079        
     1079
    10801080    Position p(visiblePosition.deepEquivalent());
    10811081    Document* document = p.anchorNode()->document();
    1082    
    1083     Element* root;
    10841082    Node* shadowRoot = p.anchorNode()->shadowTreeRootNode();
    1085    
     1083
    10861084    if (shadowRoot) {
    10871085        // Use the shadow root for form elements, since TextIterators will not enter shadow content.
    10881086        ASSERT(shadowRoot->isElementNode());
    1089         root = static_cast<Element*>(shadowRoot);
     1087        scope = static_cast<Element*>(shadowRoot);
    10901088    } 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
    11001093    return TextIterator::rangeLength(range.get(), true);
    11011094}
  • branches/chromium/1025/Source/WebCore/editing/htmlediting.h

    r104276 r109366  
    181181int comparePositions(const VisiblePosition&, const VisiblePosition&);
    182182
    183 int indexForVisiblePosition(const VisiblePosition&, Element **scope);
     183int indexForVisiblePosition(const VisiblePosition&, RefPtr<Element>& scope);
    184184VisiblePosition visiblePositionForIndex(int index, Element *scope);
    185185
Note: See TracChangeset for help on using the changeset viewer.