Remove direct reads to m_firstNodeInserted and m_lastLeafInserted in ReplaceSelection...
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 Sep 2011 20:31:41 +0000 (20:31 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 Sep 2011 20:31:41 +0000 (20:31 +0000)
commit950001a7c95a1caadd5ad52dc496d7806db27982
treede9f967a9b5a1704cb21eaefe140d110732a726f
parenta752d62f4ccfe3defdcb2781884f5fae8b745499
Remove direct reads to m_firstNodeInserted and m_lastLeafInserted in ReplaceSelectionCommand
https://bugs.webkit.org/show_bug.cgi?id=69023

Reviewed by Enrica Casucci.

Converted to removeUnrenderedTextNodesAtEnds to use InsertedNodes instead of m_firstNodeInserted
and m_lastLeafInserted. Extracted the logic to update nodes as InsertedNodes::willRemoveNode
(old one was renamed to InsertedNodes::willRemoveNodePreservingChildren).

Also extracted shouldPerformSmartReplace and addSpacesForSmartReplace out of doApply,
and rewrote the logic to obtain endNode and startNode using startOfInsertedContent and
endOfInsertedContent instead of m_firstNodeInserted and m_lastLeafInserted.

Finally, replaced the nullity checks of m_firstNodeInserted and m_lastLeafInserted in
completeHTMLReplacement by nullity checks of start and end positions.

* dom/Node.cpp:
(WebCore::Node::traversePreviousSibling): Added.
* dom/Node.h:
* editing/ReplaceSelectionCommand.cpp:
(WebCore::ReplaceSelectionCommand::InsertedNodes::willRemoveNodePreservingChildren): Renamed from
willRemoveNode.
(WebCore::ReplaceSelectionCommand::InsertedNodes::willRemoveNode): Extracted from
removeUnrenderedTextNodesAtEnds.
(WebCore::ReplaceSelectionCommand::removeRedundantStylesAndKeepStyleSpanInline):
(WebCore::ReplaceSelectionCommand::removeUnrenderedTextNodesAtEnds):
(WebCore::ReplaceSelectionCommand::positionAtEndOfInsertedContent): Made const.
(WebCore::ReplaceSelectionCommand::positionAtStartOfInsertedContent): Made const.
(WebCore::ReplaceSelectionCommand::handleStyleSpans): Takes firstNodeInserted instead of directly
accessing m_firstNodeInserted.
(WebCore::ReplaceSelectionCommand::doApply):
(WebCore::ReplaceSelectionCommand::shouldPerformSmartReplace):
(WebCore::ReplaceSelectionCommand::addSpacesForSmartReplace):
(WebCore::ReplaceSelectionCommand::completeHTMLReplacement):
* editing/ReplaceSelectionCommand.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@96353 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/dom/Node.cpp
Source/WebCore/dom/Node.h
Source/WebCore/editing/ReplaceSelectionCommand.cpp
Source/WebCore/editing/ReplaceSelectionCommand.h