~jconti/ubuntu/oneiric/webkit/fix_doc_path

« back to all changes in this revision

Viewing changes to WebCore/editing/ReplaceSelectionCommand.cpp

* New upstream (semi-stable) release
* Fix building on IA64 (Closes: #547797)
  Thanks to Colin Watson <cjwatson@ubuntu.com>
* Fix building on alpha (Closes: #548499)
* Fix building on amd64 FreeBSD

Show diffs side-by-side

added added

removed removed

Lines of Context:
528
528
VisiblePosition ReplaceSelectionCommand::positionAtStartOfInsertedContent()
529
529
{
530
530
    // Return the inserted content's first VisiblePosition.
531
 
    return VisiblePosition(nextCandidate(positionBeforeNode(m_firstNodeInserted.get())));
 
531
    return VisiblePosition(nextCandidate(positionInParentBeforeNode(m_firstNodeInserted.get())));
532
532
}
533
533
 
534
534
// Remove style spans before insertion if they are unnecessary.  It's faster because we'll 
549
549
    
550
550
    Node* sourceDocumentStyleSpan = topNode;
551
551
    RefPtr<Node> copiedRangeStyleSpan = sourceDocumentStyleSpan->firstChild();
552
 
    
553
 
    RefPtr<CSSMutableStyleDeclaration> styleAtInsertionPos = rangeCompliantEquivalent(insertionPos).computedStyle()->deprecatedCopyInheritableProperties();
 
552
 
 
553
    RefPtr<CSSMutableStyleDeclaration> styleAtInsertionPos = editingStyleAtPosition(rangeCompliantEquivalent(insertionPos));
 
554
 
554
555
    String styleText = styleAtInsertionPos->cssText();
555
556
    
556
557
    if (styleText == static_cast<Element*>(sourceDocumentStyleSpan)->getAttribute(styleAttr)) {
606
607
    // styles from blockquoteNode are allowed to override those from the source document, see <rdar://problem/4930986> and <rdar://problem/5089327>.
607
608
    Node* blockquoteNode = isMailPasteAsQuotationNode(context) ? context : nearestMailBlockquote(context);
608
609
    if (blockquoteNode) {
609
 
        RefPtr<CSSMutableStyleDeclaration> blockquoteStyle = computedStyle(blockquoteNode)->deprecatedCopyInheritableProperties();
610
 
        RefPtr<CSSMutableStyleDeclaration> parentStyle = computedStyle(blockquoteNode->parentNode())->deprecatedCopyInheritableProperties();
 
610
        RefPtr<CSSMutableStyleDeclaration> blockquoteStyle = editingStyleAtPosition(Position(blockquoteNode, 0));
 
611
        RefPtr<CSSMutableStyleDeclaration> parentStyle = editingStyleAtPosition(Position(blockquoteNode->parentNode(), 0));
611
612
        parentStyle->diff(blockquoteStyle.get());
612
613
 
613
614
        CSSMutableStyleDeclaration::const_iterator end = blockquoteStyle->end();
618
619
 
619
620
        context = blockquoteNode->parentNode();
620
621
    }
621
 
    
622
 
    RefPtr<CSSMutableStyleDeclaration> contextStyle = computedStyle(context)->deprecatedCopyInheritableProperties();
623
 
    contextStyle->diff(sourceDocumentStyle.get());
624
 
    
 
622
 
 
623
    // This operation requires that only editing styles to be removed from sourceDocumentStyle.
 
624
    prepareEditingStyleToApplyAt(sourceDocumentStyle.get(), Position(context, 0));
 
625
 
625
626
    // Remove block properties in the span's style. This prevents properties that probably have no effect 
626
627
    // currently from affecting blocks later if the style is cloned for a new block element during a future 
627
628
    // editing operation.
655
656
    
656
657
    // Remove redundant styles.
657
658
    context = copiedRangeStyleSpan->parentNode();
658
 
    contextStyle = computedStyle(context)->deprecatedCopyInheritableProperties();
659
 
    contextStyle->diff(copiedRangeStyle.get());
660
 
    
 
659
    prepareEditingStyleToApplyAt(copiedRangeStyle.get(), Position(context, 0));
 
660
 
661
661
    // See the comments above about removing block properties.
662
662
    copiedRangeStyle->removeBlockProperties();
663
663
 
725
725
        return;
726
726
    
727
727
    if (m_matchStyle)
728
 
        m_insertionStyle = styleAtPosition(selection.start());
 
728
        m_insertionStyle = editingStyleAtPosition(selection.start(), IncludeTypingStyle);
729
729
    
730
730
    VisiblePosition visibleStart = selection.visibleStart();
731
731
    VisiblePosition visibleEnd = selection.visibleEnd();
794
794
        Node* br = endingSelection().start().node(); 
795
795
        ASSERT(br->hasTagName(brTag)); 
796
796
        // Insert content between the two blockquotes, but remove the br (since it was just a placeholder). 
797
 
        insertionPos = positionBeforeNode(br); 
 
797
        insertionPos = positionInParentBeforeNode(br);
798
798
        removeNode(br);
799
799
    }
800
800
    
817
817
        ASSERT(startBlock != currentRoot);
818
818
        VisiblePosition visibleInsertionPos(insertionPos);
819
819
        if (isEndOfBlock(visibleInsertionPos) && !(isStartOfBlock(visibleInsertionPos) && fragment.hasInterchangeNewlineAtEnd()))
820
 
            insertionPos = positionAfterNode(startBlock);
 
820
            insertionPos = positionInParentAfterNode(startBlock);
821
821
        else if (isStartOfBlock(visibleInsertionPos))
822
 
            insertionPos = positionBeforeNode(startBlock);
 
822
            insertionPos = positionInParentBeforeNode(startBlock);
823
823
    }
824
824
 
825
825
    // Paste into run of tabs splits the tab span.