LayoutTests:
authordarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 24 Aug 2006 22:07:45 +0000 (22:07 +0000)
committerdarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 24 Aug 2006 22:07:45 +0000 (22:07 +0000)
        Reviewed by Justin.

        - test for http://bugzilla.opendarwin.org/show_bug.cgi?id=10169
          REGRESSION: NativeTextArea: Text dragged from <input type=text> to textarea disappears

        * fast/forms/drag-into-textarea-expected.txt: Added.
        * fast/forms/drag-into-textarea.html: Added.

WebCore:

        Reviewed by Justin.

        - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=10169
          REGRESSION: NativeTextArea: Text dragged from <input type=text> to textarea disappears
        - eliminate the EditCommandPtr class from editing; use PassRefPtr and RefPtr instead
        - other editing-related cleanup

        Test: fast/forms/drag-into-textarea.html

        * bridge/mac/FrameMac.h: Changed EditCommandPtr parameters to use PassRefPtr<EditCommand> instead.
        * bridge/win/FrameWin.h: Ditto.
        * bridge/mac/FrameMac.mm:
        (WebCore::FrameMac::registerCommandForUndoOrRedo): Ditto.
        (WebCore::FrameMac::registerCommandForUndo): Ditto.
        (WebCore::FrameMac::registerCommandForRedo): Ditto.

        * bridge/mac/WebCoreFrameBridge.mm:
        (-[WebCoreFrameBridge replaceSelectionWithFragment:selectReplacement:smartReplace:matchStyle:]):
        Use applyCommand instead of EditCommandPtr. Also remove now-unneeded document parameter.
        (-[WebCoreFrameBridge moveSelectionToDragCaret:smartMove:]): Ditto.
        (-[WebCoreFrameBridge deleteSelectionWithSmartDelete:]): Ditto.

        * editing/AppendNodeCommand.h: Removed document parameter from constructor. Changed new child
        parameter to be a PassRefPtr. Reversed order of child and parent parameters.
        * editing/AppendNodeCommand.cpp:
        (WebCore::AppendNodeCommand::AppendNodeCommand): Ditto.
        (WebCore::AppendNodeCommand::doApply): Ditto.
        (WebCore::AppendNodeCommand::doUnapply): Ditto.

        * editing/ApplyStyleCommand.h: Removed document parameter from constructor.
        * editing/ApplyStyleCommand.cpp: (WebCore::ApplyStyleCommand::ApplyStyleCommand): Ditto.

        * editing/BreakBlockquoteCommand.h: Removed unneeded include of DeprecatedPtrList.h.
        * editing/BreakBlockquoteCommand.cpp: Moved the include of DeprecatedPtrList.h here.
        (WebCore::BreakBlockquoteCommand::doApply): Changed code to construct a Selection explicitly
        since setEndingSelection is no longer overloaded for Position.

        * editing/CompositeEditCommand.h: Added isFirstCommand function. Changed m_cmds from
        a DeprecatedValueList<EditCommandPtr> to a Vector<RefPtr<EditCommand>> and renamed it
        m_commands and made both doUnapply and doReapply private.
        * editing/CompositeEditCommand.cpp:
        (WebCore::CompositeEditCommand::doUnapply): Rewrote to use m_commands.
        (WebCore::CompositeEditCommand::doReapply): Ditto.
        (WebCore::CompositeEditCommand::applyCommandToComposite): Removed code to explicitly set up
        starting and ending selection -- now done inside setParent. Rewrote to use m_commands.
        (WebCore::CompositeEditCommand::applyStyle): Changed to not use EditCommandPtr.
        (WebCore::CompositeEditCommand::applyStyledElement): Ditto.
        (WebCore::CompositeEditCommand::removeStyledElement): Ditto.
        (WebCore::CompositeEditCommand::insertParagraphSeparator): Ditto.
        (WebCore::CompositeEditCommand::insertNodeBefore): Ditto.
        (WebCore::CompositeEditCommand::appendNode): Ditto.
        (WebCore::CompositeEditCommand::removeNode): Ditto.
        (WebCore::CompositeEditCommand::removeNodePreservingChildren): Ditto.
        (WebCore::CompositeEditCommand::splitTextNode): Ditto.
        (WebCore::CompositeEditCommand::splitElement): Ditto.
        (WebCore::CompositeEditCommand::mergeIdenticalElements): Ditto.
        (WebCore::CompositeEditCommand::wrapContentsInDummySpan): Ditto.
        (WebCore::CompositeEditCommand::splitTextNodeContainingElement): Ditto.
        (WebCore::CompositeEditCommand::joinTextNodes): Ditto.
        (WebCore::CompositeEditCommand::inputText): Ditto.
        (WebCore::CompositeEditCommand::insertTextIntoNode): Ditto.
        (WebCore::CompositeEditCommand::deleteTextFromNode): Ditto.
        (WebCore::CompositeEditCommand::replaceTextInNode): Ditto.
        (WebCore::CompositeEditCommand::deleteSelection): Ditto.
        (WebCore::CompositeEditCommand::removeCSSProperty): Ditto.
        (WebCore::CompositeEditCommand::removeNodeAttribute): Ditto. Also fixed a bug where the code
        would not remove an empty attribute -- will not come up in practice, but wrong in theory.
        (WebCore::CompositeEditCommand::setNodeAttribute): Changed to not use EditCommandPtr.
        (WebCore::CompositeEditCommand::rebalanceWhitespaceAt): Ditto.
        (WebCore::CompositeEditCommand::deleteInsignificantText): Rewrote to use a for loop.
        (WebCore::CompositeEditCommand::moveParagraphs): Changed to not use EditCommandPtr.
        (WebCore::CompositeEditCommand::breakOutOfEmptyListItem): Changed code to construct a
        Selection explicitly since setEndingSelection is no longer overloaded for Position.
        (WebCore::createBlockPlaceholderElement): Collapsed this code so that the
        block placeholder class string is no longer spread across multiple functions.
        Perhaps we can get rid of this altogether at some point.

        * editing/DeleteFromTextNodeCommand.h: Removed unneeded document parameter from one constructor.
        Also removed unneeded destructor.
        * editing/DeleteFromTextNodeCommand.cpp:
        (WebCore::DeleteFromTextNodeCommand::DeleteFromTextNodeCommand): Ditto.

        * editing/DeleteSelectionCommand.h: Removed unneeded document parameter from one constructor.
        * editing/DeleteSelectionCommand.cpp: (WebCore::DeleteSelectionCommand::DeleteSelectionCommand): Ditto.

        * editing/EditCommand.h: Removed ECommandState, isCompositeStep(), parent(), state(), setState(),
        and most overloads of setStartingSelection() and setEndingSelection(). Made document() protected
        and non-virtual. Made setStartingSelection() setEndingSelection(), and styleAtPosition() protected.
        Made doApply(), doUnapply(), and doReapply() private. Added startingRootEditableElement(),
        endingRootEditableElement(), m_startingRootEditableElement, and m_endingRootEditableElement, which
        are needed so we can determine which editable elements an editing operation affects. Changed setParent()
        and m_parent to use CompositeEditCommand instead of EditCommand. Removed EditCommandPtr. Added
        applyCommand() function that's convenient to use on a newly-created command.
        * editing/EditCommand.cpp:
        (WebCore::EditCommand::EditCommand): Removed initialization for m_state, and added it for starting
        and ending root editable elements.
        (WebCore::EditCommand::apply): Simplified check for top level by just checking m_parent. Removed
        code to assert and set m_start. Eliminated use of EditCommandPtr.
        (WebCore::EditCommand::unapply): Ditto.
        (WebCore::EditCommand::reapply): Ditto.
        (WebCore::EditCommand::setStartingSelection): Changed to set root editable element too. Also made this
        not change the starting selection of the parent unless this is the first command in the parent -- didn't
        make sense the way it was.
        (WebCore::EditCommand::setEndingSelection): Changed to set root editable element too.
        (WebCore::EditCommand::setParent): Added code to set the starting and ending selection on the child
        based on the ending selection of the parent, formerly done by callers.
        (WebCore::applyCommand): Added.

        * editing/FormatBlockCommand.h: Tweaked formatting.
        * editing/FormatBlockCommand.cpp: (WebCore::FormatBlockCommand::FormatBlockCommand): Ditto.
        * editing/InsertLineBreakCommand.h: Ditto.
        * editing/InsertLineBreakCommand.cpp: (WebCore::InsertLineBreakCommand::doApply):

        * editing/IndentOutdentCommand.cpp:
        (WebCore::IndentOutdentCommand::splitTreeToNode): Removed use of EditCommandPtr.
        (WebCore::IndentOutdentCommand::outdentParagraph): Updated for change to list type enum.
        (WebCore::IndentOutdentCommand::outdentRegion): Removed use of EditCommandPtr.

        * editing/InsertIntoTextNodeCommand.h: Removed unneeded document parameter to constructor.
        * editing/InsertIntoTextNodeCommand.cpp:
        (WebCore::InsertIntoTextNodeCommand::InsertIntoTextNodeCommand): Ditto.

        * editing/InsertListCommand.h: Renamed EListType to EList, and took the "Type" suffix off
        the constants.
        * editing/InsertListCommand.cpp:
        (WebCore::InsertListCommand::InsertListCommand): Ditto.
        (WebCore::InsertListCommand::doApply): Ditto.

        * editing/InsertNodeBeforeCommand.h: Removed unneeded document parameter from constructor
        and changed the parameter of the node to insert to a PassRefPtr.
        * editing/InsertNodeBeforeCommand.cpp:
        (WebCore::InsertNodeBeforeCommand::InsertNodeBeforeCommand): Ditto.

        * editing/InsertParagraphSeparatorCommand.cpp:
        (WebCore::InsertParagraphSeparatorCommand::doApply): Remvoed use of EditCommandPtr.

        * editing/InsertTextCommand.h: Changed insertTab to take const Position&.
        * editing/InsertTextCommand.cpp:
        (WebCore::InsertTextCommand::input): Ditto.
        (WebCore::InsertTextCommand::insertTab): Ditto.

        * editing/JSEditor.h: Tweaked formatting and names.
        * editing/JSEditor.cpp: Ditto. Also changed places that use EditCommandPtr.

        * editing/JoinTextNodesCommand.h: Removed unneeeded document pointer
        * editing/JoinTextNodesCommand.cpp:
        (WebCore::JoinTextNodesCommand::JoinTextNodesCommand): Ditto.
        * editing/MergeIdenticalElementsCommand.h: Ditto.
        * editing/MergeIdenticalElementsCommand.cpp:
        (WebCore::MergeIdenticalElementsCommand::MergeIdenticalElementsCommand): Ditto.

        * editing/ModifySelectionListLevel.h: Changed EListType to be named Type and be a member of
        IncreaseSelectionListLevelCommand. Also changed m_listElement to be a RefPtr<Node>.
        * editing/ModifySelectionListLevel.cpp:
        (WebCore::getStartEndListChildren): Changed parameters to be references instead of pointers.
        (WebCore::IncreaseSelectionListLevelCommand::IncreaseSelectionListLevelCommand):
        Changed to use Type instead of EListType.
        (WebCore::canIncreaseListLevel): Changed parameters to be references instead of pointers.
        (WebCore::IncreaseSelectionListLevelCommand::doApply): Updated for change to canIncreaseListLevel.
        (WebCore::IncreaseSelectionListLevelCommand::canIncreaseSelectionListLevel): Ditto.
        (WebCore::IncreaseSelectionListLevelCommand::increaseSelectionListLevelWithType):
        Changed to not use EditCommandPtr.
        (WebCore::canDecreaseListLevel): Changed parameters to be references instead of pointers.
        (WebCore::DecreaseSelectionListLevelCommand::doApply): Updated for change to canDecreaseListLevel.
        (WebCore::DecreaseSelectionListLevelCommand::canDecreaseSelectionListLevel): Ditto.
        (WebCore::DecreaseSelectionListLevelCommand::decreaseSelectionListLevel): Changed to not use
        EditCommandPtr.

        * editing/MoveSelectionCommand.h: Removed unnecessary document parameter and changed the fragment
        parameter to be a PassRefPtr.
        * editing/MoveSelectionCommand.cpp:
        (WebCore::MoveSelectionCommand::MoveSelectionCommand): Ditto.
        (WebCore::MoveSelectionCommand::doApply): Got rid of use of EditCommandPtr.

        * editing/RebalanceWhitespaceCommand.h: Removed unnecessary document parameter.
        * editing/RebalanceWhitespaceCommand.cpp:
        (WebCore::RebalanceWhitespaceCommand::RebalanceWhitespaceCommand): Ditto.
        (WebCore::RebalanceWhitespaceCommand::doApply): Got rid of use of EditCommandPtr.

        * editing/RemoveCSSPropertyCommand.h: Tweaked formatting.

        * editing/RemoveNodeAttributeCommand.h: Removed unnecessary document parameter.
        * editing/RemoveNodeAttributeCommand.cpp:
        (WebCore::RemoveNodeAttributeCommand::RemoveNodeAttributeCommand): Ditto.

        * editing/RemoveNodeCommand.h: Removed unnecessary document parameter.
        * editing/RemoveNodeCommand.cpp:
        (WebCore::RemoveNodeCommand::RemoveNodeCommand): Ditto.

        * editing/RemoveNodePreservingChildrenCommand.h: Removed unnecessary document parameter.
        * editing/RemoveNodePreservingChildrenCommand.cpp:
        (WebCore::RemoveNodePreservingChildrenCommand::RemoveNodePreservingChildrenCommand): Ditto.

        * editing/ReplaceSelectionCommand.h: Change fragment parameter to a PassRefPtr.
        * editing/ReplaceSelectionCommand.cpp:
        (WebCore::ReplacementFragment::ReplacementFragment): Ditto.
        (WebCore::ReplaceSelectionCommand::ReplaceSelectionCommand): Ditto.
        (WebCore::ReplaceSelectionCommand::doApply): Ditto.
        (WebCore::ReplaceSelectionCommand::completeHTMLReplacement): Ditto.

        * editing/Selection.h: Changed SEL_DEFAULT_AFFINITY to be a constant rather than
        a macro. Added constructors that take visible positions. Changed setBase and
        setExtent to take const Position& for better efficiency.
        * editing/Selection.cpp:
        (WebCore::Selection::Selection): Removed unnecessary double initialization of m_state
        and m_baseIsFirst in existing constructors. Added VisiblePosition-based constructors.

        * editing/SetNodeAttributeCommand.h: Removed unnneeded document parameter.
        * editing/SetNodeAttributeCommand.cpp:
        (WebCore::SetNodeAttributeCommand::SetNodeAttributeCommand): Ditto.

        * editing/SplitElementCommand.h: Removed unnneeded document parameter.
        * editing/SplitElementCommand.cpp:
        (WebCore::SplitElementCommand::SplitElementCommand): Ditto.

        * editing/SplitTextNodeCommand.h: Removed unnneeded document parameter.
        * editing/SplitTextNodeCommand.cpp:
        (WebCore::SplitTextNodeCommand::SplitTextNodeCommand): Ditto.

        * editing/SplitTextNodeContainingElementCommand.h: Removed unnneeded document parameter.
        * editing/SplitTextNodeContainingElementCommand.cpp:
        (WebCore::SplitTextNodeContainingElementCommand::SplitTextNodeContainingElementCommand): Ditto.

        * editing/TypingCommand.h: Replaced uses of EditCommandPtr with EditCommand*.
        Renamed openForMoveTyping() with isOpenForMoreTyping().
        * editing/TypingCommand.cpp:
        (WebCore::TypingCommand::deleteKeyPressed): Updated to remove use of EditCommandPtr.
        (WebCore::TypingCommand::forwardDeleteKeyPressed): Ditto.
        (WebCore::TypingCommand::insertText): Ditto.
        (WebCore::TypingCommand::insertLineBreak): Ditto.
        (WebCore::TypingCommand::insertParagraphSeparatorInQuotedContent): Ditto.
        (WebCore::TypingCommand::insertParagraphSeparator): Ditto.
        (WebCore::TypingCommand::isOpenForMoreTypingCommand): Ditto.
        (WebCore::TypingCommand::closeTyping): Ditto.
        (WebCore::TypingCommand::typingAddedToOpenCommand): Ditto.
        (WebCore::TypingCommand::insertTextRunWithoutNewlines): Ditto.

        * editing/WrapContentsInDummySpanCommand.h: Removed unnneeded document parameter.
        * editing/WrapContentsInDummySpanCommand.cpp:
        (WebCore::WrapContentsInDummySpanCommand::WrapContentsInDummySpanCommand): Ditto.

        * editing/htmlediting.h: Changed type of NON_BREAKING_SPACE to UChar instead of
        unsigned short.

        * page/Frame.h: Changed lastEditCommand() to return an EditCommand* and changed
        appliedEditing(), unappliedEditing(), reappliedEditing(), registerCommandForUndo(),
        and registerCommandForRedo() to take PassRefPtr<EditCommand>.
        * page/FramePrivate.h: Changed m_lastEditCommand to be a RefPtr<EditCommand>.
        * page/Frame.cpp:
        (WebCore::Frame::didOpenURL): Fixed for change to m_lastEditCommand.
        (WebCore::Frame::setFocusNodeIfNeeded): Call the rootEditableElement function
        from Selection to simplify the code.
        (WebCore::Frame::selectAll): Ditto.
        (WebCore::Frame::lastEditCommand): Updated for change to m_lastEditCommand.
        (WebCore::dispatchEditableContentChangedEvents): Added. This sends an event to
        both of the root editable elements involved in a change -- the start selection
        might be in a different element than the end selection.
        (WebCore::Frame::appliedEditing): Changed to call dispatchEditableContentChangedEvents,
        and to do it before setting the ending selection. Also update to use PassRefPtr instead
        of EditCommandPtr and change the order of setting m_lastEditCommand since passing it
        to registerCommandForUndo will take ownership and set it to 0.
        (WebCore::Frame::unappliedEditing): Ditto.
        (WebCore::Frame::reappliedEditing): Ditto.
        (WebCore::Frame::computeAndSetTypingStyle): Updated for removal of EditCommandPtr.
        (WebCore::Frame::applyStyle): Ditto.
        (WebCore::Frame::applyParagraphStyle): Ditto.

        * platform/gdk/FrameGdk.h: Updated for above changes.
        * platform/gdk/TemporaryLinkStubs.cpp: Updated for above changes.
        * platform/win/TemporaryLinkStubs.cpp: Updated for above changes.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@16026 268f45cc-cd09-0410-ab3c-d52691b4dbfc

83 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/forms/drag-into-textarea-expected.txt [new file with mode: 0644]
LayoutTests/fast/forms/drag-into-textarea.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/bridge/mac/FrameMac.h
WebCore/bridge/mac/FrameMac.mm
WebCore/bridge/mac/WebCoreEditCommand.h
WebCore/bridge/mac/WebCoreEditCommand.mm
WebCore/bridge/mac/WebCoreFrameBridge.mm
WebCore/bridge/win/FrameWin.h
WebCore/css/makeprop
WebCore/css/makevalues
WebCore/editing/AppendNodeCommand.cpp
WebCore/editing/AppendNodeCommand.h
WebCore/editing/ApplyStyleCommand.cpp
WebCore/editing/ApplyStyleCommand.h
WebCore/editing/BreakBlockquoteCommand.cpp
WebCore/editing/BreakBlockquoteCommand.h
WebCore/editing/CompositeEditCommand.cpp
WebCore/editing/CompositeEditCommand.h
WebCore/editing/DeleteFromTextNodeCommand.cpp
WebCore/editing/DeleteFromTextNodeCommand.h
WebCore/editing/DeleteSelectionCommand.cpp
WebCore/editing/DeleteSelectionCommand.h
WebCore/editing/EditCommand.cpp
WebCore/editing/EditCommand.h
WebCore/editing/FormatBlockCommand.cpp
WebCore/editing/FormatBlockCommand.h
WebCore/editing/IndentOutdentCommand.cpp
WebCore/editing/InsertIntoTextNodeCommand.cpp
WebCore/editing/InsertIntoTextNodeCommand.h
WebCore/editing/InsertLineBreakCommand.cpp
WebCore/editing/InsertLineBreakCommand.h
WebCore/editing/InsertListCommand.cpp
WebCore/editing/InsertListCommand.h
WebCore/editing/InsertNodeBeforeCommand.cpp
WebCore/editing/InsertNodeBeforeCommand.h
WebCore/editing/InsertParagraphSeparatorCommand.cpp
WebCore/editing/InsertTextCommand.cpp
WebCore/editing/InsertTextCommand.h
WebCore/editing/JSEditor.cpp
WebCore/editing/JSEditor.h
WebCore/editing/JoinTextNodesCommand.cpp
WebCore/editing/JoinTextNodesCommand.h
WebCore/editing/MergeIdenticalElementsCommand.cpp
WebCore/editing/MergeIdenticalElementsCommand.h
WebCore/editing/ModifySelectionListLevel.cpp
WebCore/editing/ModifySelectionListLevel.h
WebCore/editing/MoveSelectionCommand.cpp
WebCore/editing/MoveSelectionCommand.h
WebCore/editing/RebalanceWhitespaceCommand.cpp
WebCore/editing/RebalanceWhitespaceCommand.h
WebCore/editing/RemoveCSSPropertyCommand.h
WebCore/editing/RemoveNodeAttributeCommand.cpp
WebCore/editing/RemoveNodeAttributeCommand.h
WebCore/editing/RemoveNodeCommand.cpp
WebCore/editing/RemoveNodeCommand.h
WebCore/editing/RemoveNodePreservingChildrenCommand.cpp
WebCore/editing/RemoveNodePreservingChildrenCommand.h
WebCore/editing/ReplaceSelectionCommand.cpp
WebCore/editing/ReplaceSelectionCommand.h
WebCore/editing/Selection.cpp
WebCore/editing/Selection.h
WebCore/editing/SetNodeAttributeCommand.cpp
WebCore/editing/SetNodeAttributeCommand.h
WebCore/editing/SplitElementCommand.cpp
WebCore/editing/SplitElementCommand.h
WebCore/editing/SplitTextNodeCommand.cpp
WebCore/editing/SplitTextNodeCommand.h
WebCore/editing/SplitTextNodeContainingElementCommand.cpp
WebCore/editing/SplitTextNodeContainingElementCommand.h
WebCore/editing/TypingCommand.cpp
WebCore/editing/TypingCommand.h
WebCore/editing/WrapContentsInDummySpanCommand.cpp
WebCore/editing/WrapContentsInDummySpanCommand.h
WebCore/editing/htmlediting.h
WebCore/page/Frame.cpp
WebCore/page/Frame.h
WebCore/page/FramePrivate.h
WebCore/platform/gdk/FrameGdk.h
WebCore/platform/gdk/TemporaryLinkStubs.cpp
WebCore/platform/win/TemporaryLinkStubs.cpp

index 76e2be04abb7f39e9ad409fa76f14580d2261eb4..f7c3d80c7f96218de53410b7a6330a3d1a6ca8bc 100644 (file)
@@ -1,3 +1,13 @@
+2006-08-24  Darin Adler  <darin@apple.com>
+
+        Reviewed by Justin.
+
+        - test for http://bugzilla.opendarwin.org/show_bug.cgi?id=10169
+          REGRESSION: NativeTextArea: Text dragged from <input type=text> to textarea disappears
+
+        * fast/forms/drag-into-textarea-expected.txt: Added.
+        * fast/forms/drag-into-textarea.html: Added.
+
 2006-08-24  David Harrison  <harrison@apple.com>
 
         Updated expected results for this change:
diff --git a/LayoutTests/fast/forms/drag-into-textarea-expected.txt b/LayoutTests/fast/forms/drag-into-textarea-expected.txt
new file mode 100644 (file)
index 0000000..fb9c159
--- /dev/null
@@ -0,0 +1,18 @@
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldInsertNode:#document-fragment replacingDOMRange:range from 0 of DIV to 0 of DIV givenAction:WebViewInsertActionDropped
+EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 0 of #text > DIV to 39 of #text > DIV affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+This tests dragging text from an input element into a text area element.
+
+When the test is run, the follow text field should be empty:
+
+
+
+And the following text area should have text in it:
+
+
+
+Test succeeded!
+
+
diff --git a/LayoutTests/fast/forms/drag-into-textarea.html b/LayoutTests/fast/forms/drag-into-textarea.html
new file mode 100644 (file)
index 0000000..2826ece
--- /dev/null
@@ -0,0 +1,49 @@
+<script>
+
+function runTest() {
+    var input = document.getElementById("input");
+    var x = 8 + input.offsetLeft + input.offsetWidth / 2;
+    var y = 8 + input.offsetTop + input.offsetHeight / 2;
+
+    var textarea = document.getElementById("textarea");
+    var tx = 8 + textarea.offsetLeft + textarea.offsetWidth / 2;
+    var ty = 8 + textarea.offsetTop + textarea.offsetHeight / 2;
+
+    input.select();
+
+    if (!window.layoutTestController)
+        return;
+    if (!window.eventSender)
+        return;
+
+    layoutTestController.dumpAsText();
+    layoutTestController.waitUntilDone();
+    
+    eventSender.mouseMoveTo(x, y);
+    eventSender.mouseDown();
+    // Wait a moment so that the mouseDown will kick off a drag instead of a new selection.
+    // FIXME: Ugh, don't want delays in layout tests!
+    eventSender.leapForward(400);
+    eventSender.mouseMoveTo(tx, ty);
+    eventSender.mouseUp();
+
+    if (input.value == "" && textarea.value == "drag this text into the text area below")
+        document.getElementById("result").innerText = "Test succeeded!";
+    else
+        document.getElementById("result").innerText = "Test failed! Input value was " + input.value + " and text area value was " + textarea.value + ".";
+
+    layoutTestController.notifyDone();
+}
+
+</script>
+
+<body onload="runTest()">
+
+<p>This tests dragging text from an input element into a text area element.</p>
+<p>When the test is run, the follow text field should be empty:</p>
+<p><input id="input" type="text" value="drag this text into the text area below" size="50"></p>
+<p>And the following text area should have text in it:</p>
+<p><textarea id="textarea" cols="50" rows="10"></textarea></p>
+<p id="result">If the test has completed this sentence should be replaced by a success message.</p>
+
+</body>
index bed98fc70c62b71caa263c7b868e3a30a2f61b0f..3e7cbba67159f2edb9b8efb437adf41283f6ed24 100644 (file)
@@ -1,3 +1,276 @@
+2006-08-24  Darin Adler  <darin@apple.com>
+
+        Reviewed by Justin.
+
+        - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=10169
+          REGRESSION: NativeTextArea: Text dragged from <input type=text> to textarea disappears
+        - eliminate the EditCommandPtr class from editing; use PassRefPtr and RefPtr instead
+        - other editing-related cleanup
+
+        Test: fast/forms/drag-into-textarea.html
+
+        * bridge/mac/FrameMac.h: Changed EditCommandPtr parameters to use PassRefPtr<EditCommand> instead.
+        * bridge/win/FrameWin.h: Ditto.
+        * bridge/mac/FrameMac.mm:
+        (WebCore::FrameMac::registerCommandForUndoOrRedo): Ditto.
+        (WebCore::FrameMac::registerCommandForUndo): Ditto.
+        (WebCore::FrameMac::registerCommandForRedo): Ditto.
+
+        * bridge/mac/WebCoreFrameBridge.mm:
+        (-[WebCoreFrameBridge replaceSelectionWithFragment:selectReplacement:smartReplace:matchStyle:]):
+        Use applyCommand instead of EditCommandPtr. Also remove now-unneeded document parameter.
+        (-[WebCoreFrameBridge moveSelectionToDragCaret:smartMove:]): Ditto.
+        (-[WebCoreFrameBridge deleteSelectionWithSmartDelete:]): Ditto.
+
+        * editing/AppendNodeCommand.h: Removed document parameter from constructor. Changed new child
+        parameter to be a PassRefPtr. Reversed order of child and parent parameters.
+        * editing/AppendNodeCommand.cpp:
+        (WebCore::AppendNodeCommand::AppendNodeCommand): Ditto.
+        (WebCore::AppendNodeCommand::doApply): Ditto.
+        (WebCore::AppendNodeCommand::doUnapply): Ditto.
+
+        * editing/ApplyStyleCommand.h: Removed document parameter from constructor.
+        * editing/ApplyStyleCommand.cpp: (WebCore::ApplyStyleCommand::ApplyStyleCommand): Ditto.
+
+        * editing/BreakBlockquoteCommand.h: Removed unneeded include of DeprecatedPtrList.h.
+        * editing/BreakBlockquoteCommand.cpp: Moved the include of DeprecatedPtrList.h here.
+        (WebCore::BreakBlockquoteCommand::doApply): Changed code to construct a Selection explicitly
+        since setEndingSelection is no longer overloaded for Position.
+
+        * editing/CompositeEditCommand.h: Added isFirstCommand function. Changed m_cmds from
+        a DeprecatedValueList<EditCommandPtr> to a Vector<RefPtr<EditCommand>> and renamed it
+        m_commands and made both doUnapply and doReapply private.
+        * editing/CompositeEditCommand.cpp:
+        (WebCore::CompositeEditCommand::doUnapply): Rewrote to use m_commands.
+        (WebCore::CompositeEditCommand::doReapply): Ditto.
+        (WebCore::CompositeEditCommand::applyCommandToComposite): Removed code to explicitly set up
+        starting and ending selection -- now done inside setParent. Rewrote to use m_commands.
+        (WebCore::CompositeEditCommand::applyStyle): Changed to not use EditCommandPtr.
+        (WebCore::CompositeEditCommand::applyStyledElement): Ditto.
+        (WebCore::CompositeEditCommand::removeStyledElement): Ditto.
+        (WebCore::CompositeEditCommand::insertParagraphSeparator): Ditto.
+        (WebCore::CompositeEditCommand::insertNodeBefore): Ditto.
+        (WebCore::CompositeEditCommand::appendNode): Ditto.
+        (WebCore::CompositeEditCommand::removeNode): Ditto.
+        (WebCore::CompositeEditCommand::removeNodePreservingChildren): Ditto.
+        (WebCore::CompositeEditCommand::splitTextNode): Ditto.
+        (WebCore::CompositeEditCommand::splitElement): Ditto.
+        (WebCore::CompositeEditCommand::mergeIdenticalElements): Ditto.
+        (WebCore::CompositeEditCommand::wrapContentsInDummySpan): Ditto.
+        (WebCore::CompositeEditCommand::splitTextNodeContainingElement): Ditto.
+        (WebCore::CompositeEditCommand::joinTextNodes): Ditto.
+        (WebCore::CompositeEditCommand::inputText): Ditto.
+        (WebCore::CompositeEditCommand::insertTextIntoNode): Ditto.
+        (WebCore::CompositeEditCommand::deleteTextFromNode): Ditto.
+        (WebCore::CompositeEditCommand::replaceTextInNode): Ditto.
+        (WebCore::CompositeEditCommand::deleteSelection): Ditto.
+        (WebCore::CompositeEditCommand::removeCSSProperty): Ditto.
+        (WebCore::CompositeEditCommand::removeNodeAttribute): Ditto. Also fixed a bug where the code
+        would not remove an empty attribute -- will not come up in practice, but wrong in theory.
+        (WebCore::CompositeEditCommand::setNodeAttribute): Changed to not use EditCommandPtr.
+        (WebCore::CompositeEditCommand::rebalanceWhitespaceAt): Ditto.
+        (WebCore::CompositeEditCommand::deleteInsignificantText): Rewrote to use a for loop.
+        (WebCore::CompositeEditCommand::moveParagraphs): Changed to not use EditCommandPtr.
+        (WebCore::CompositeEditCommand::breakOutOfEmptyListItem): Changed code to construct a
+        Selection explicitly since setEndingSelection is no longer overloaded for Position.
+        (WebCore::createBlockPlaceholderElement): Collapsed this code so that the
+        block placeholder class string is no longer spread across multiple functions.
+        Perhaps we can get rid of this altogether at some point.
+
+        * editing/DeleteFromTextNodeCommand.h: Removed unneeded document parameter from one constructor.
+        Also removed unneeded destructor.
+        * editing/DeleteFromTextNodeCommand.cpp:
+        (WebCore::DeleteFromTextNodeCommand::DeleteFromTextNodeCommand): Ditto.
+
+        * editing/DeleteSelectionCommand.h: Removed unneeded document parameter from one constructor.
+        * editing/DeleteSelectionCommand.cpp: (WebCore::DeleteSelectionCommand::DeleteSelectionCommand): Ditto.
+
+        * editing/EditCommand.h: Removed ECommandState, isCompositeStep(), parent(), state(), setState(),
+        and most overloads of setStartingSelection() and setEndingSelection(). Made document() protected
+        and non-virtual. Made setStartingSelection() setEndingSelection(), and styleAtPosition() protected.
+        Made doApply(), doUnapply(), and doReapply() private. Added startingRootEditableElement(),
+        endingRootEditableElement(), m_startingRootEditableElement, and m_endingRootEditableElement, which
+        are needed so we can determine which editable elements an editing operation affects. Changed setParent()
+        and m_parent to use CompositeEditCommand instead of EditCommand. Removed EditCommandPtr. Added
+        applyCommand() function that's convenient to use on a newly-created command.
+        * editing/EditCommand.cpp:
+        (WebCore::EditCommand::EditCommand): Removed initialization for m_state, and added it for starting
+        and ending root editable elements.
+        (WebCore::EditCommand::apply): Simplified check for top level by just checking m_parent. Removed
+        code to assert and set m_start. Eliminated use of EditCommandPtr.
+        (WebCore::EditCommand::unapply): Ditto.
+        (WebCore::EditCommand::reapply): Ditto.
+        (WebCore::EditCommand::setStartingSelection): Changed to set root editable element too. Also made this
+        not change the starting selection of the parent unless this is the first command in the parent -- didn't
+        make sense the way it was.
+        (WebCore::EditCommand::setEndingSelection): Changed to set root editable element too.
+        (WebCore::EditCommand::setParent): Added code to set the starting and ending selection on the child
+        based on the ending selection of the parent, formerly done by callers.
+        (WebCore::applyCommand): Added.
+
+        * editing/FormatBlockCommand.h: Tweaked formatting.
+        * editing/FormatBlockCommand.cpp: (WebCore::FormatBlockCommand::FormatBlockCommand): Ditto.
+        * editing/InsertLineBreakCommand.h: Ditto.
+        * editing/InsertLineBreakCommand.cpp: (WebCore::InsertLineBreakCommand::doApply):
+
+        * editing/IndentOutdentCommand.cpp:
+        (WebCore::IndentOutdentCommand::splitTreeToNode): Removed use of EditCommandPtr.
+        (WebCore::IndentOutdentCommand::outdentParagraph): Updated for change to list type enum.
+        (WebCore::IndentOutdentCommand::outdentRegion): Removed use of EditCommandPtr.
+
+        * editing/InsertIntoTextNodeCommand.h: Removed unneeded document parameter to constructor.
+        * editing/InsertIntoTextNodeCommand.cpp:
+        (WebCore::InsertIntoTextNodeCommand::InsertIntoTextNodeCommand): Ditto.
+
+        * editing/InsertListCommand.h: Renamed EListType to EList, and took the "Type" suffix off
+        the constants.
+        * editing/InsertListCommand.cpp:
+        (WebCore::InsertListCommand::InsertListCommand): Ditto.
+        (WebCore::InsertListCommand::doApply): Ditto.
+
+        * editing/InsertNodeBeforeCommand.h: Removed unneeded document parameter from constructor
+        and changed the parameter of the node to insert to a PassRefPtr.
+        * editing/InsertNodeBeforeCommand.cpp:
+        (WebCore::InsertNodeBeforeCommand::InsertNodeBeforeCommand): Ditto.
+
+        * editing/InsertParagraphSeparatorCommand.cpp:
+        (WebCore::InsertParagraphSeparatorCommand::doApply): Remvoed use of EditCommandPtr.
+
+        * editing/InsertTextCommand.h: Changed insertTab to take const Position&.
+        * editing/InsertTextCommand.cpp:
+        (WebCore::InsertTextCommand::input): Ditto.
+        (WebCore::InsertTextCommand::insertTab): Ditto.
+
+        * editing/JSEditor.h: Tweaked formatting and names.
+        * editing/JSEditor.cpp: Ditto. Also changed places that use EditCommandPtr.
+
+        * editing/JoinTextNodesCommand.h: Removed unneeeded document pointer
+        * editing/JoinTextNodesCommand.cpp:
+        (WebCore::JoinTextNodesCommand::JoinTextNodesCommand): Ditto.
+        * editing/MergeIdenticalElementsCommand.h: Ditto.
+        * editing/MergeIdenticalElementsCommand.cpp:
+        (WebCore::MergeIdenticalElementsCommand::MergeIdenticalElementsCommand): Ditto.
+
+        * editing/ModifySelectionListLevel.h: Changed EListType to be named Type and be a member of
+        IncreaseSelectionListLevelCommand. Also changed m_listElement to be a RefPtr<Node>.
+        * editing/ModifySelectionListLevel.cpp:
+        (WebCore::getStartEndListChildren): Changed parameters to be references instead of pointers.
+        (WebCore::IncreaseSelectionListLevelCommand::IncreaseSelectionListLevelCommand):
+        Changed to use Type instead of EListType.
+        (WebCore::canIncreaseListLevel): Changed parameters to be references instead of pointers.
+        (WebCore::IncreaseSelectionListLevelCommand::doApply): Updated for change to canIncreaseListLevel.
+        (WebCore::IncreaseSelectionListLevelCommand::canIncreaseSelectionListLevel): Ditto.
+        (WebCore::IncreaseSelectionListLevelCommand::increaseSelectionListLevelWithType):
+        Changed to not use EditCommandPtr.
+        (WebCore::canDecreaseListLevel): Changed parameters to be references instead of pointers.
+        (WebCore::DecreaseSelectionListLevelCommand::doApply): Updated for change to canDecreaseListLevel.
+        (WebCore::DecreaseSelectionListLevelCommand::canDecreaseSelectionListLevel): Ditto.
+        (WebCore::DecreaseSelectionListLevelCommand::decreaseSelectionListLevel): Changed to not use
+        EditCommandPtr.
+
+        * editing/MoveSelectionCommand.h: Removed unnecessary document parameter and changed the fragment
+        parameter to be a PassRefPtr.
+        * editing/MoveSelectionCommand.cpp:
+        (WebCore::MoveSelectionCommand::MoveSelectionCommand): Ditto.
+        (WebCore::MoveSelectionCommand::doApply): Got rid of use of EditCommandPtr.
+
+        * editing/RebalanceWhitespaceCommand.h: Removed unnecessary document parameter.
+        * editing/RebalanceWhitespaceCommand.cpp:
+        (WebCore::RebalanceWhitespaceCommand::RebalanceWhitespaceCommand): Ditto.
+        (WebCore::RebalanceWhitespaceCommand::doApply): Got rid of use of EditCommandPtr.
+
+        * editing/RemoveCSSPropertyCommand.h: Tweaked formatting.
+
+        * editing/RemoveNodeAttributeCommand.h: Removed unnecessary document parameter.
+        * editing/RemoveNodeAttributeCommand.cpp:
+        (WebCore::RemoveNodeAttributeCommand::RemoveNodeAttributeCommand): Ditto.
+
+        * editing/RemoveNodeCommand.h: Removed unnecessary document parameter.
+        * editing/RemoveNodeCommand.cpp:
+        (WebCore::RemoveNodeCommand::RemoveNodeCommand): Ditto.
+
+        * editing/RemoveNodePreservingChildrenCommand.h: Removed unnecessary document parameter.
+        * editing/RemoveNodePreservingChildrenCommand.cpp:
+        (WebCore::RemoveNodePreservingChildrenCommand::RemoveNodePreservingChildrenCommand): Ditto.
+
+        * editing/ReplaceSelectionCommand.h: Change fragment parameter to a PassRefPtr.
+        * editing/ReplaceSelectionCommand.cpp:
+        (WebCore::ReplacementFragment::ReplacementFragment): Ditto.
+        (WebCore::ReplaceSelectionCommand::ReplaceSelectionCommand): Ditto.
+        (WebCore::ReplaceSelectionCommand::doApply): Ditto.
+        (WebCore::ReplaceSelectionCommand::completeHTMLReplacement): Ditto.
+
+        * editing/Selection.h: Changed SEL_DEFAULT_AFFINITY to be a constant rather than
+        a macro. Added constructors that take visible positions. Changed setBase and
+        setExtent to take const Position& for better efficiency.
+        * editing/Selection.cpp:
+        (WebCore::Selection::Selection): Removed unnecessary double initialization of m_state
+        and m_baseIsFirst in existing constructors. Added VisiblePosition-based constructors.
+
+        * editing/SetNodeAttributeCommand.h: Removed unnneeded document parameter.
+        * editing/SetNodeAttributeCommand.cpp:
+        (WebCore::SetNodeAttributeCommand::SetNodeAttributeCommand): Ditto.
+
+        * editing/SplitElementCommand.h: Removed unnneeded document parameter.
+        * editing/SplitElementCommand.cpp:
+        (WebCore::SplitElementCommand::SplitElementCommand): Ditto.
+
+        * editing/SplitTextNodeCommand.h: Removed unnneeded document parameter.
+        * editing/SplitTextNodeCommand.cpp:
+        (WebCore::SplitTextNodeCommand::SplitTextNodeCommand): Ditto.
+
+        * editing/SplitTextNodeContainingElementCommand.h: Removed unnneeded document parameter.
+        * editing/SplitTextNodeContainingElementCommand.cpp:
+        (WebCore::SplitTextNodeContainingElementCommand::SplitTextNodeContainingElementCommand): Ditto.
+
+        * editing/TypingCommand.h: Replaced uses of EditCommandPtr with EditCommand*.
+        Renamed openForMoveTyping() with isOpenForMoreTyping().
+        * editing/TypingCommand.cpp:
+        (WebCore::TypingCommand::deleteKeyPressed): Updated to remove use of EditCommandPtr.
+        (WebCore::TypingCommand::forwardDeleteKeyPressed): Ditto.
+        (WebCore::TypingCommand::insertText): Ditto.
+        (WebCore::TypingCommand::insertLineBreak): Ditto.
+        (WebCore::TypingCommand::insertParagraphSeparatorInQuotedContent): Ditto.
+        (WebCore::TypingCommand::insertParagraphSeparator): Ditto.
+        (WebCore::TypingCommand::isOpenForMoreTypingCommand): Ditto.
+        (WebCore::TypingCommand::closeTyping): Ditto.
+        (WebCore::TypingCommand::typingAddedToOpenCommand): Ditto.
+        (WebCore::TypingCommand::insertTextRunWithoutNewlines): Ditto.
+
+        * editing/WrapContentsInDummySpanCommand.h: Removed unnneeded document parameter.
+        * editing/WrapContentsInDummySpanCommand.cpp:
+        (WebCore::WrapContentsInDummySpanCommand::WrapContentsInDummySpanCommand): Ditto.
+
+        * editing/htmlediting.h: Changed type of NON_BREAKING_SPACE to UChar instead of
+        unsigned short.
+
+        * page/Frame.h: Changed lastEditCommand() to return an EditCommand* and changed
+        appliedEditing(), unappliedEditing(), reappliedEditing(), registerCommandForUndo(),
+        and registerCommandForRedo() to take PassRefPtr<EditCommand>.
+        * page/FramePrivate.h: Changed m_lastEditCommand to be a RefPtr<EditCommand>.
+        * page/Frame.cpp:
+        (WebCore::Frame::didOpenURL): Fixed for change to m_lastEditCommand.
+        (WebCore::Frame::setFocusNodeIfNeeded): Call the rootEditableElement function
+        from Selection to simplify the code.
+        (WebCore::Frame::selectAll): Ditto.
+        (WebCore::Frame::lastEditCommand): Updated for change to m_lastEditCommand.
+        (WebCore::dispatchEditableContentChangedEvents): Added. This sends an event to
+        both of the root editable elements involved in a change -- the start selection
+        might be in a different element than the end selection.
+        (WebCore::Frame::appliedEditing): Changed to call dispatchEditableContentChangedEvents,
+        and to do it before setting the ending selection. Also update to use PassRefPtr instead
+        of EditCommandPtr and change the order of setting m_lastEditCommand since passing it
+        to registerCommandForUndo will take ownership and set it to 0.
+        (WebCore::Frame::unappliedEditing): Ditto.
+        (WebCore::Frame::reappliedEditing): Ditto.
+        (WebCore::Frame::computeAndSetTypingStyle): Updated for removal of EditCommandPtr.
+        (WebCore::Frame::applyStyle): Ditto.
+        (WebCore::Frame::applyParagraphStyle): Ditto.
+
+        * platform/gdk/FrameGdk.h: Updated for above changes.
+        * platform/gdk/TemporaryLinkStubs.cpp: Updated for above changes.
+        * platform/win/TemporaryLinkStubs.cpp: Updated for above changes.
+
 2006-08-24  Brady Eidson  <beidson@apple.com>
 
         Reviewed by Alice
index 748c3b1b6312010033b01090a8e7634fbd2c37d4..e094213f89b922259c0e9b24118cb404b8c5808b 100644 (file)
                FAE04190097596C9000540BE /* SVGImageLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = FAE0418E097596C9000540BE /* SVGImageLoader.h */; };
 /* End PBXBuildFile section */
 
-/* Begin PBXBuildStyle section */
-               BC837C570A9D0AA0006B186A /* Development */ = {
-                       isa = PBXBuildStyle;
-                       buildSettings = {
-                               COPY_PHASE_STRIP = NO;
-                       };
-                       name = Development;
-               };
-               BC837C580A9D0AA0006B186A /* Deployment */ = {
-                       isa = PBXBuildStyle;
-                       buildSettings = {
-                               COPY_PHASE_STRIP = YES;
-                       };
-                       name = Deployment;
-               };
-/* End PBXBuildStyle section */
-
 /* Begin PBXContainerItemProxy section */
                DD041FF009D9E3250010AF2A /* PBXContainerItemProxy */ = {
                        isa = PBXContainerItemProxy;
                0867D690FE84028FC02AAC07 /* Project object */ = {
                        isa = PBXProject;
                        buildConfigurationList = 149C284308902B11008A9EFC /* Build configuration list for PBXProject "WebCore" */;
-                       buildSettings = {
-                       };
-                       buildStyles = (
-                               BC837C570A9D0AA0006B186A /* Development */,
-                               BC837C580A9D0AA0006B186A /* Deployment */,
-                       );
+                       compatibilityVersion = "Xcode 2.4";
                        hasScannedForEncodings = 1;
                        knownRegions = (
                                English,
                        mainGroup = 0867D691FE84028FC02AAC07 /* WebKit */;
                        productRefGroup = 034768DFFF38A50411DB9C8B /* Products */;
                        projectDirPath = "";
+                       projectRoot = "";
+                       shouldCheckCompatibility = 1;
                        targets = (
                                93F198A508245E59001E9ABC /* WebCore */,
                                DD041FBE09D9DDBE0010AF2A /* Derived Sources */,
index f7416c9bbb3d9006d054e43e10f94b78d3cc1199..d846e1de19b39626ad7c2977aa1755ce5d0e3a2c 100644 (file)
@@ -251,8 +251,8 @@ public:
     void addPluginRootObject(KJS::Bindings::RootObject* root);
     void cleanupPluginRootObjects();
     
-    virtual void registerCommandForUndo(const EditCommandPtr&);
-    virtual void registerCommandForRedo(const EditCommandPtr&);
+    virtual void registerCommandForUndo(PassRefPtr<EditCommand>);
+    virtual void registerCommandForRedo(PassRefPtr<EditCommand>);
     virtual void clearUndoRedoOperations();
     virtual void issueUndoCommand();
     virtual void issueRedoCommand();
@@ -337,7 +337,7 @@ private:
 
     void freeClipboard();
 
-    void registerCommandForUndoOrRedo(const EditCommandPtr &cmd, bool isRedo);
+    void registerCommandForUndoOrRedo(PassRefPtr<EditCommand>, bool isRedo);
 
     WebCoreFrameBridge* _bridge;
     
index b95b1b6eab4d5f4949bfb41b1776507978973f43..b05ac3a490aed148acdea8295a8ee86c6655da74 100644 (file)
@@ -3032,26 +3032,27 @@ void FrameMac::cleanupPluginRootObjects()
     m_rootObjects.clear();
 }
 
-void FrameMac::registerCommandForUndoOrRedo(const EditCommandPtr &cmd, bool isRedo)
-{
-    ASSERT(cmd.get());
-    WebCoreEditCommand *kwq = [WebCoreEditCommand commandWithEditCommand:cmd.get()];
-    NSUndoManager *undoManager = [_bridge undoManager];
-    [undoManager registerUndoWithTarget:_bridge selector:(isRedo ? @selector(redoEditing:) : @selector(undoEditing:)) object:kwq];
-    NSString *actionName = [_bridge nameForUndoAction:static_cast<WebUndoAction>(cmd.editingAction())];
+void FrameMac::registerCommandForUndoOrRedo(PassRefPtr<EditCommand> cmd, bool isRedo)
+{
+    ASSERT(cmd);
+    WebUndoAction action = static_cast<WebUndoAction>(cmd->editingAction());
+    NSUndoManager* undoManager = [_bridge undoManager];
+    WebCoreEditCommand* command = [WebCoreEditCommand commandWithEditCommand:cmd];
+    NSString* actionName = [_bridge nameForUndoAction:action];
+    [undoManager registerUndoWithTarget:_bridge selector:(isRedo ? @selector(redoEditing:) : @selector(undoEditing:)) object:command];
     if (actionName)
         [undoManager setActionName:actionName];
     _haveUndoRedoOperations = YES;
 }
 
-void FrameMac::registerCommandForUndo(const EditCommandPtr &cmd)
+void FrameMac::registerCommandForUndo(PassRefPtr<EditCommand> cmd)
 {
-    registerCommandForUndoOrRedo(cmd, NO);
+    registerCommandForUndoOrRedo(cmd, false);
 }
 
-void FrameMac::registerCommandForRedo(const EditCommandPtr &cmd)
+void FrameMac::registerCommandForRedo(PassRefPtr<EditCommand> cmd)
 {
-    registerCommandForUndoOrRedo(cmd, YES);
+    registerCommandForUndoOrRedo(cmd, true);
 }
 
 void FrameMac::clearUndoRedoOperations()
index 89dfdad70c4cc7c9bc2b18d667385aa3f5c2e47d..26927c7a54dcd786771bfdaebc8c197edf0abe2f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2004 Apple Computer, Inc.  All rights reserved.
+ * Copyright (C) 2004, 2006 Apple Computer, Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -23,6 +23,8 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
 
+#include <wtf/Forward.h>
+
 namespace WebCore {
     class EditCommand;
 }
@@ -32,7 +34,7 @@ namespace WebCore {
     WebCore::EditCommand *m_command;   
 }
 
-+ (WebCoreEditCommand *)commandWithEditCommand:(WebCore::EditCommand *)command;
++ (WebCoreEditCommand *)commandWithEditCommand:(PassRefPtr<WebCore::EditCommand>)command;
 - (WebCore::EditCommand *)command;
 
 @end
index c81092a78899eabf4e8926357ae0bf62592b86bc..f34687102e29b386e1c1b209afabbd73060a8f34 100644 (file)
 #import "WebCoreEditCommand.h"
 
 #import "EditCommand.h"
+#import <wtf/PassRefPtr.h>
 
 using namespace WebCore;
 
 @implementation WebCoreEditCommand
 
-- (id)initWithEditCommand:(EditCommand *)command
+- (id)initWithEditCommand:(PassRefPtr<WebCore::EditCommand>)command
 {
     ASSERT(command);
     [super init];
-    m_command = command;
-    command->ref();
+    m_command = command.release();
     return self;
 }
 
@@ -53,7 +53,7 @@ using namespace WebCore;
     [super finalize];
 }
 
-+ (WebCoreEditCommand *)commandWithEditCommand:(EditCommand *)command
++ (WebCoreEditCommand *)commandWithEditCommand:(PassRefPtr<WebCore::EditCommand>)command
 {
     return [[[WebCoreEditCommand alloc] initWithEditCommand:command] autorelease];
 }
index 81654133555d2828f92b42414e902cb5df08328f..cbb41fd43add658a5870557fad7479eb98c40f1c 100644 (file)
@@ -1967,7 +1967,7 @@ static HTMLFormElement *formElementFromDOMElement(DOMElement *element)
     if (!m_frame->hasSelection() || !fragment)
         return;
     
-    EditCommandPtr(new ReplaceSelectionCommand(m_frame->document(), [fragment _fragment], selectReplacement, smartReplace, matchStyle)).apply();
+    applyCommand(new ReplaceSelectionCommand(m_frame->document(), [fragment _fragment], selectReplacement, smartReplace, matchStyle));
     [self ensureSelectionVisible];
 }
 
@@ -2083,8 +2083,7 @@ static HTMLFormElement *formElementFromDOMElement(DOMElement *element)
 
 - (void)moveSelectionToDragCaret:(DOMDocumentFragment *)selectionFragment smartMove:(BOOL)smartMove
 {
-    Position base = m_frame->dragCaret().base();
-    EditCommandPtr(new MoveSelectionCommand(m_frame->document(), [selectionFragment _fragment], base, smartMove)).apply();
+    applyCommand(new MoveSelectionCommand([selectionFragment _fragment], m_frame->dragCaret().base(), smartMove));
 }
 
 - (VisiblePosition)_visiblePositionForPoint:(NSPoint)point
@@ -2159,7 +2158,7 @@ static HTMLFormElement *formElementFromDOMElement(DOMElement *element)
     if (!m_frame->hasSelection())
         return;
     
-    EditCommandPtr(new DeleteSelectionCommand(m_frame->document(), smartDelete)).apply();
+    applyCommand(new DeleteSelectionCommand(m_frame->document(), smartDelete));
 }
 
 - (void)deleteKeyPressedWithSmartDelete:(BOOL)smartDelete granularity:(WebBridgeSelectionGranularity)granularity
index 108018357a4f4c36479ed547f759c22e587457d6..e3856e8271242975781196cc02ac6b016f3dc609 100644 (file)
@@ -100,8 +100,8 @@ public:
     virtual KJS::Bindings::Instance* getObjectInstanceForWidget(Widget*);
     virtual KJS::Bindings::Instance* getAppletInstanceForWidget(Widget*);
     
-    virtual void registerCommandForUndo(const EditCommandPtr&);
-    virtual void registerCommandForRedo(const EditCommandPtr&);
+    virtual void registerCommandForUndo(PassRefPtr<EditCommand>);
+    virtual void registerCommandForRedo(PassRefPtr<EditCommand>);
     virtual void clearUndoRedoOperations();
     virtual void issueUndoCommand();
     virtual void issueRedoCommand();
index 14386a199afc0ae168f795f494becf2176c60b77..97a8381b87659c446db6ffece7bcf07a368771f4 100644 (file)
@@ -23,6 +23,7 @@
 #
 grep "^[^\#]" CSSPropertyNames.in > CSSPropertyNames.strip
 
+rm CSSPropertyNames.gperf
 echo '%{' > CSSPropertyNames.gperf
 echo '/* This file is automatically generated from CSSPropertyNames.in by makeprop, do not edit */' >> CSSPropertyNames.gperf
 echo '/* Copyright 1999 W. Bastian */' >> CSSPropertyNames.gperf
index 9ddbec1ad6e3b03246fc07e25247767301cf1d8b..c7e3f5b2f9455e03c64024eac2a4bbf560c84dd3 100644 (file)
@@ -23,6 +23,7 @@
 #
 grep "^[^\#]" CSSValueKeywords.in > CSSValueKeywords.strip
 
+rm CSSValueKeywords.gperf
 echo '%{' > CSSValueKeywords.gperf
 echo '/* This file is automatically generated from CSSValueKeywords.in by makevalues, do not edit */' >> CSSValueKeywords.gperf
 echo '/* Copyright 1999 W. Bastian */' >> CSSValueKeywords.gperf
index 1f92176ed92881da952bab1ba12afb669b33163f..69149cee13c6938875cd413361592e65b2501a7f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005 Apple Computer, Inc.  All rights reserved.
+ * Copyright (C) 2005, 2006 Apple Computer, Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 
 namespace WebCore {
 
-AppendNodeCommand::AppendNodeCommand(Document *document, Node *appendChild, Node *parentNode)
-    : EditCommand(document), m_appendChild(appendChild), m_parentNode(parentNode)
+AppendNodeCommand::AppendNodeCommand(Node* parentNode, PassRefPtr<Node> childToAppend)
+    : EditCommand(parentNode->document()), m_parentNode(parentNode), m_childToAppend(childToAppend)
 {
-    ASSERT(m_appendChild);
+    ASSERT(m_childToAppend);
     ASSERT(m_parentNode);
 }
 
 void AppendNodeCommand::doApply()
 {
-    ASSERT(m_appendChild);
+    ASSERT(m_childToAppend);
     ASSERT(m_parentNode);
     // If the child to append is already in a tree, appending it will remove it from it's old location
     // in an non-undoable way.  We might eventually find it useful to do an undoable remove in this case.
-    ASSERT(!m_appendChild->parent());
+    ASSERT(!m_childToAppend->parent());
     ASSERT(m_parentNode->isContentEditable() || !m_parentNode->attached());
 
     ExceptionCode ec = 0;
-    m_parentNode->appendChild(m_appendChild.get(), ec);
+    m_parentNode->appendChild(m_childToAppend.get(), ec);
     ASSERT(ec == 0);
 }
 
 void AppendNodeCommand::doUnapply()
 {
-    ASSERT(m_appendChild);
+    ASSERT(m_childToAppend);
     ASSERT(m_parentNode);
-    ASSERT(state() == Applied);
 
     ExceptionCode ec = 0;
-    m_parentNode->removeChild(m_appendChild.get(), ec);
+    m_parentNode->removeChild(m_childToAppend.get(), ec);
     ASSERT(ec == 0);
 }
 
index fdd1cc3ae91be9165eef3880dabac6d5ce54c37c..dc2846ccde55d2b0e7148308206f4572a0a9848e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005 Apple Computer, Inc.  All rights reserved.
+ * Copyright (C) 2005, 2006 Apple Computer, Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
 
-#ifndef __append_node_command_h__
-#define __append_node_command_h__
+#ifndef append_node_command_h__
+#define append_node_command_h__
 
 #include "EditCommand.h"
 
 namespace WebCore {
-    class Node;
-}
 
-namespace WebCore {
-
-class AppendNodeCommand : public EditCommand
-{
+class AppendNodeCommand : public EditCommand {
 public:
-    AppendNodeCommand(Document *, Node *appendChild, Node *parentNode);
-    virtual ~AppendNodeCommand() { }
+    AppendNodeCommand(Node* parentNode, PassRefPtr<Node> childToAppend);
 
     virtual void doApply();
     virtual void doUnapply();
 
-    Node *appendChild() const { return m_appendChild.get(); }
-    Node *parentNode() const { return m_parentNode.get(); }
+    Node* parentNode() const { return m_parentNode.get(); }
+    Node* childToAppend() const { return m_childToAppend.get(); }
 
 private:
-    RefPtr<Node> m_appendChild;
     RefPtr<Node> m_parentNode;
+    RefPtr<Node> m_childToAppend;
 };
 
 } // namespace WebCore
 
-#endif // __append_node_command_h__
-
+#endif // append_node_command_h__
index 6839f4101b85cf5dd0f3209905351493b9e94e31..1210463c67ad7cd37db82467d2d29016db6554ad 100644 (file)
@@ -280,8 +280,8 @@ ApplyStyleCommand::ApplyStyleCommand(Document* document, CSSStyleDeclaration* st
 {
 }
 
-ApplyStyleCommand::ApplyStyleCommand(Document* document, Element* element, bool removeOnly, EditAction editingAction)
-    : CompositeEditCommand(document)
+ApplyStyleCommand::ApplyStyleCommand(Element* element, bool removeOnly, EditAction editingAction)
+    : CompositeEditCommand(element->document())
     , m_style(new CSSMutableStyleDeclaration())
     , m_editingAction(editingAction)
     , m_propertyLevel(PropertyDefault)
index 99a291c17c2f2eb5b3abe132ca96f1a34b51afba..e9342a838e4cb81b207549ab1560c6a2b97c0b74 100644 (file)
@@ -32,14 +32,13 @@ namespace WebCore {
 
 class HTMLElement;
 
-class ApplyStyleCommand : public CompositeEditCommand
-{
+class ApplyStyleCommand : public CompositeEditCommand {
 public:
     enum EPropertyLevel { PropertyDefault, ForceBlockProperties };
 
     ApplyStyleCommand(Document*, CSSStyleDeclaration*, EditAction = EditActionChangeAttributes, EPropertyLevel = PropertyDefault);
     ApplyStyleCommand(Document*, CSSStyleDeclaration*, const Position& start, const Position& end, EditAction = EditActionChangeAttributes, EPropertyLevel = PropertyDefault);
-    ApplyStyleCommand(Document*, Element*, bool = false, EditAction = EditActionChangeAttributes);
+    ApplyStyleCommand(Element*, bool = false, EditAction = EditActionChangeAttributes);
 
     virtual void doApply();
     virtual EditAction editingAction() const;
@@ -49,7 +48,7 @@ public:
 private:
     // style-removal helpers
     bool isHTMLStyleNode(CSSMutableStyleDeclaration*, HTMLElement*);
-    void removeHTMLStyleNode(HTMLElement *);
+    void removeHTMLStyleNode(HTMLElement*);
     void removeHTMLFontStyle(CSSMutableStyleDeclaration*, HTMLElement*);
     void removeCSSStyle(CSSMutableStyleDeclaration*, HTMLElement*);
     void removeBlockStyle(CSSMutableStyleDeclaration*, const Position& start, const Position& end);
index 6bff0b21909c3e7858d0103b0d29aa59487bd0f8..1fd55f01bbbefcb85b152f23a78e49df775e9f04 100644 (file)
@@ -26,6 +26,7 @@
 #include "config.h"
 #include "BreakBlockquoteCommand.h"
 
+#include "DeprecatedPtrList.h"
 #include "Element.h"
 #include "HTMLNames.h"
 #include "Text.h"
@@ -155,7 +156,7 @@ void BreakBlockquoteCommand::doApply()
     }
     
     // Put the selection right before the break.
-    setEndingSelection(Position(breakNode.get(), 0), DOWNSTREAM);
+    setEndingSelection(Selection(Position(breakNode.get(), 0), DOWNSTREAM));
     rebalanceWhitespace();
 }
 
index a59dd706a177af2c3cdaa13c1da9662d4ac06746..9317752cfaf2b069ff619aee49c2dfa547c60991 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005 Apple Computer, Inc.  All rights reserved.
+ * Copyright (C) 2005, 2006 Apple Computer, Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 #define break_blockquote_command_h__
 
 #include "CompositeEditCommand.h"
-#include "DeprecatedPtrList.h"
 
 namespace WebCore {
 
-class BreakBlockquoteCommand : public CompositeEditCommand
-{
+class BreakBlockquoteCommand : public CompositeEditCommand {
 public:
-    BreakBlockquoteCommand(Document *);
-
+    BreakBlockquoteCommand(Document*);
     virtual void doApply();
 };
 
index 1fd985acafd764402650b61eba82f44fb9fe3570..4d9c967f3ae77b4000cb2a0761f9492ff2d1acd9 100644 (file)
@@ -66,8 +66,6 @@ namespace WebCore {
 
 using namespace HTMLNames;
 
-static const String &blockPlaceholderClassString();
-
 CompositeEditCommand::CompositeEditCommand(Document *document) 
     : EditCommand(document)
 {
@@ -75,139 +73,115 @@ CompositeEditCommand::CompositeEditCommand(Document *document)
 
 void CompositeEditCommand::doUnapply()
 {
-    if (m_cmds.count() == 0)
-        return;
-    
-    DeprecatedValueList<EditCommandPtr>::ConstIterator end;
-    for (DeprecatedValueList<EditCommandPtr>::ConstIterator it = m_cmds.fromLast(); it != end; --it)
-        (*it)->unapply();
-
-    setState(NotApplied);
+    size_t size = m_commands.size();
+    for (size_t i = size; i != 0; --i)
+        m_commands[i - 1]->unapply();
 }
 
 void CompositeEditCommand::doReapply()
 {
-    if (m_cmds.count() == 0)
-        return;
-
-    for (DeprecatedValueList<EditCommandPtr>::ConstIterator it = m_cmds.begin(); it != m_cmds.end(); ++it)
-        (*it)->reapply();
-
-    setState(Applied);
+    size_t size = m_commands.size();
+    for (size_t i = 0; i != size; ++i)
+        m_commands[i]->reapply();
 }
 
 //
 // sugary-sweet convenience functions to help create and apply edit commands in composite commands
 //
-void CompositeEditCommand::applyCommandToComposite(EditCommandPtr &cmd)
+void CompositeEditCommand::applyCommandToComposite(PassRefPtr<EditCommand> cmd)
 {
-    cmd.setStartingSelection(endingSelection());
-    cmd.setEndingSelection(endingSelection());
-    cmd.setParent(this);
-    cmd.apply();
-    m_cmds.append(cmd);
+    cmd->setParent(this);
+    cmd->apply();
+    m_commands.append(cmd);
 }
 
-void CompositeEditCommand::applyStyle(CSSStyleDeclaration *style, EditAction editingAction)
+void CompositeEditCommand::applyStyle(CSSStyleDeclarationstyle, EditAction editingAction)
 {
-    EditCommandPtr cmd(new ApplyStyleCommand(document(), style, editingAction));
-    applyCommandToComposite(cmd);
+    applyCommandToComposite(new ApplyStyleCommand(document(), style, editingAction));
 }
 
-void CompositeEditCommand::applyStyle(CSSStyleDeclaration *style, Position start, Position end, EditAction editingAction)
+void CompositeEditCommand::applyStyle(CSSStyleDeclaration* style, const Position& start, const Position& end, EditAction editingAction)
 {
-    EditCommandPtr cmd(new ApplyStyleCommand(document(), style, start, end, editingAction));
-    applyCommandToComposite(cmd);
+    applyCommandToComposite(new ApplyStyleCommand(document(), style, start, end, editingAction));
 }
 
 void CompositeEditCommand::applyStyledElement(Element* element)
 {
-    EditCommandPtr cmd(new ApplyStyleCommand(document(), element, false));
-    applyCommandToComposite(cmd);
+    applyCommandToComposite(new ApplyStyleCommand(element, false));
 }
 
 void CompositeEditCommand::removeStyledElement(Element* element)
 {
-    EditCommandPtr cmd(new ApplyStyleCommand(document(), element, true));
-    applyCommandToComposite(cmd);
+    applyCommandToComposite(new ApplyStyleCommand(element, true));
 }
 
 void CompositeEditCommand::insertParagraphSeparator()
 {
-    EditCommandPtr cmd(new InsertParagraphSeparatorCommand(document()));
-    applyCommandToComposite(cmd);
+    applyCommandToComposite(new InsertParagraphSeparatorCommand(document()));
 }
 
-void CompositeEditCommand::insertNodeBefore(Node *insertChild, Node *refChild)
+void CompositeEditCommand::insertNodeBefore(Node* insertChild, Node* refChild)
 {
     ASSERT(!refChild->hasTagName(bodyTag));
-    EditCommandPtr cmd(new InsertNodeBeforeCommand(document(), insertChild, refChild));
-    applyCommandToComposite(cmd);
+    applyCommandToComposite(new InsertNodeBeforeCommand(insertChild, refChild));
 }
 
-void CompositeEditCommand::insertNodeAfter(Node *insertChild, Node *refChild)
+void CompositeEditCommand::insertNodeAfter(Node* insertChild, Node* refChild)
 {
     ASSERT(!refChild->hasTagName(bodyTag));
-    if (refChild->parentNode()->lastChild() == refChild) {
+    if (refChild->parentNode()->lastChild() == refChild)
         appendNode(insertChild, refChild->parentNode());
-    }
     else {
         ASSERT(refChild->nextSibling());
         insertNodeBefore(insertChild, refChild->nextSibling());
     }
 }
 
-void CompositeEditCommand::insertNodeAt(Node *insertChild, Node *refChild, int offset)
+void CompositeEditCommand::insertNodeAt(Node* insertChild, Node* refChild, int offset)
 {
     if (canHaveChildrenForEditing(refChild)) {
-        Node *child = refChild->firstChild();
+        Nodechild = refChild->firstChild();
         for (int i = 0; child && i < offset; i++)
             child = child->nextSibling();
         if (child)
             insertNodeBefore(insertChild, child);
         else
             appendNode(insertChild, refChild);
-    }
-    else if (refChild->caretMinOffset() >= offset) {
+    } else if (refChild->caretMinOffset() >= offset) {
         insertNodeBefore(insertChild, refChild);
-    } 
-    else if (refChild->isTextNode() && refChild->caretMaxOffset() > offset) {
+    } else if (refChild->isTextNode() && refChild->caretMaxOffset() > offset) {
         splitTextNode(static_cast<Text *>(refChild), offset);
         insertNodeBefore(insertChild, refChild);
-    } 
-    else {
+    } else {
         insertNodeAfter(insertChild, refChild);
     }
 }
 
-void CompositeEditCommand::appendNode(Node *appendChild, Node *parent)
+void CompositeEditCommand::appendNode(Node* newChild, Node* parent)
 {
     ASSERT(canHaveChildrenForEditing(parent));
-    EditCommandPtr cmd(new AppendNodeCommand(document(), appendChild, parent));
-    applyCommandToComposite(cmd);
+    applyCommandToComposite(new AppendNodeCommand(parent, newChild));
 }
 
-void CompositeEditCommand::removeChildrenInRange(Node *node, int from, int to)
+void CompositeEditCommand::removeChildrenInRange(Nodenode, int from, int to)
 {
-    Node *nodeToRemove = node->childNode(from);
+    NodenodeToRemove = node->childNode(from);
     for (int i = from; i < to; i++) {
         ASSERT(nodeToRemove);
-        Node *next = nodeToRemove->nextSibling();
+        Nodenext = nodeToRemove->nextSibling();
         removeNode(nodeToRemove);
         nodeToRemove = next;
     }
 }
 
-void CompositeEditCommand::removeNode(Node *removeChild)
+void CompositeEditCommand::removeNode(NoderemoveChild)
 {
-    EditCommandPtr cmd(new RemoveNodeCommand(document(), removeChild));
-    applyCommandToComposite(cmd);
+    applyCommandToComposite(new RemoveNodeCommand(removeChild));
 }
 
-void CompositeEditCommand::removeNodePreservingChildren(Node *removeChild)
+void CompositeEditCommand::removeNodePreservingChildren(NoderemoveChild)
 {
-    EditCommandPtr cmd(new RemoveNodePreservingChildrenCommand(document(), removeChild));
-    applyCommandToComposite(cmd);
+    applyCommandToComposite(new RemoveNodePreservingChildrenCommand(removeChild));
 }
 
 void CompositeEditCommand::removeNodeAndPruneAncestors(Node* node)
@@ -244,71 +218,60 @@ void CompositeEditCommand::prune(PassRefPtr<Node> node)
 
 void CompositeEditCommand::splitTextNode(Text *text, int offset)
 {
-    EditCommandPtr cmd(new SplitTextNodeCommand(document(), text, offset));
-    applyCommandToComposite(cmd);
+    applyCommandToComposite(new SplitTextNodeCommand(text, offset));
 }
 
-void CompositeEditCommand::splitElement(Element *element, Node *atChild)
+void CompositeEditCommand::splitElement(Element* element, Node* atChild)
 {
-    EditCommandPtr cmd(new SplitElementCommand(document(), element, atChild));
-    applyCommandToComposite(cmd);
+    applyCommandToComposite(new SplitElementCommand(element, atChild));
 }
 
-void CompositeEditCommand::mergeIdenticalElements(Element *first, Element *second)
+void CompositeEditCommand::mergeIdenticalElements(Element* first, Element* second)
 {
     ASSERT(!first->isAncestor(second) && second != first);
     if (first->nextSibling() != second) {
         removeNode(second);
         insertNodeAfter(second, first);
     }
-    EditCommandPtr cmd(new MergeIdenticalElementsCommand(document(), first, second));
-    applyCommandToComposite(cmd);
+    applyCommandToComposite(new MergeIdenticalElementsCommand(first, second));
 }
 
-void CompositeEditCommand::wrapContentsInDummySpan(Element *element)
+void CompositeEditCommand::wrapContentsInDummySpan(Elementelement)
 {
-    EditCommandPtr cmd(new WrapContentsInDummySpanCommand(document(), element));
-    applyCommandToComposite(cmd);
+    applyCommandToComposite(new WrapContentsInDummySpanCommand(element));
 }
 
 void CompositeEditCommand::splitTextNodeContainingElement(Text *text, int offset)
 {
-    EditCommandPtr cmd(new SplitTextNodeContainingElementCommand(document(), text, offset));
-    applyCommandToComposite(cmd);
+    applyCommandToComposite(new SplitTextNodeContainingElementCommand(text, offset));
 }
 
 void CompositeEditCommand::joinTextNodes(Text *text1, Text *text2)
 {
-    EditCommandPtr cmd(new JoinTextNodesCommand(document(), text1, text2));
-    applyCommandToComposite(cmd);
+    applyCommandToComposite(new JoinTextNodesCommand(text1, text2));
 }
 
 void CompositeEditCommand::inputText(const String &text, bool selectInsertedText)
 {
-    InsertTextCommand *impl = new InsertTextCommand(document());
-    EditCommandPtr cmd(impl);
-    applyCommandToComposite(cmd);
-    impl->input(text, selectInsertedText);
+    RefPtr<InsertTextCommand> command = new InsertTextCommand(document());
+    applyCommandToComposite(command);
+    command->input(text, selectInsertedText);
 }
 
 void CompositeEditCommand::insertTextIntoNode(Text *node, int offset, const String &text)
 {
-    EditCommandPtr cmd(new InsertIntoTextNodeCommand(document(), node, offset, text));
-    applyCommandToComposite(cmd);
+    applyCommandToComposite(new InsertIntoTextNodeCommand(node, offset, text));
 }
 
 void CompositeEditCommand::deleteTextFromNode(Text *node, int offset, int count)
 {
-    EditCommandPtr cmd(new DeleteFromTextNodeCommand(document(), node, offset, count));
-    applyCommandToComposite(cmd);
+    applyCommandToComposite(new DeleteFromTextNodeCommand(node, offset, count));
 }
 
 void CompositeEditCommand::replaceTextInNode(Text *node, int offset, int count, const String &replacementText)
 {
-    EditCommandPtr deleteCommand(new DeleteFromTextNodeCommand(document(), node, offset, count));
-    applyCommandToComposite(deleteCommand);
-    EditCommandPtr insertCommand(new InsertIntoTextNodeCommand(document(), node, offset, replacementText));
-    applyCommandToComposite(insertCommand);
+    applyCommandToComposite(new DeleteFromTextNodeCommand(node, offset, count));
+    applyCommandToComposite(new InsertIntoTextNodeCommand(node, offset, replacementText));
 }
 
 Position CompositeEditCommand::positionOutsideTabSpan(const Position& pos)
@@ -316,7 +279,7 @@ Position CompositeEditCommand::positionOutsideTabSpan(const Position& pos)
     if (!isTabSpanTextNode(pos.node()))
         return pos;
     
-    Node *tabSpan = tabSpanNode(pos.node());
+    NodetabSpan = tabSpanNode(pos.node());
     
     if (pos.offset() <= pos.node()->caretMinOffset())
         return positionBeforeNode(tabSpan);
@@ -328,7 +291,7 @@ Position CompositeEditCommand::positionOutsideTabSpan(const Position& pos)
     return positionBeforeNode(tabSpan);
 }
 
-void CompositeEditCommand::insertNodeAtTabSpanPosition(Node *node, const Position& pos)
+void CompositeEditCommand::insertNodeAtTabSpanPosition(Nodenode, const Position& pos)
 {
     // insert node before, after, or at split of tab span
     Position insertPos = positionOutsideTabSpan(pos);
@@ -337,39 +300,31 @@ void CompositeEditCommand::insertNodeAtTabSpanPosition(Node *node, const Positio
 
 void CompositeEditCommand::deleteSelection(bool smartDelete, bool mergeBlocksAfterDelete, bool replace)
 {
-    if (endingSelection().isRange()) {
-        EditCommandPtr cmd(new DeleteSelectionCommand(document(), smartDelete, mergeBlocksAfterDelete, replace));
-        applyCommandToComposite(cmd);
-    }
+    if (endingSelection().isRange())
+        applyCommandToComposite(new DeleteSelectionCommand(document(), smartDelete, mergeBlocksAfterDelete, replace));
 }
 
 void CompositeEditCommand::deleteSelection(const Selection &selection, bool smartDelete, bool mergeBlocksAfterDelete, bool replace)
 {
-    if (selection.isRange()) {
-        EditCommandPtr cmd(new DeleteSelectionCommand(document(), selection, smartDelete, mergeBlocksAfterDelete, replace));
-        applyCommandToComposite(cmd);
-    }
+    if (selection.isRange())
+        applyCommandToComposite(new DeleteSelectionCommand(selection, smartDelete, mergeBlocksAfterDelete, replace));
 }
 
 void CompositeEditCommand::removeCSSProperty(CSSStyleDeclaration *decl, int property)
 {
-    EditCommandPtr cmd(new RemoveCSSPropertyCommand(document(), decl, property));
-    applyCommandToComposite(cmd);
+    applyCommandToComposite(new RemoveCSSPropertyCommand(document(), decl, property));
 }
 
-void CompositeEditCommand::removeNodeAttribute(Element *element, const QualifiedName& attribute)
+void CompositeEditCommand::removeNodeAttribute(Elementelement, const QualifiedName& attribute)
 {
-    String value = element->getAttribute(attribute);
-    if (value.isEmpty())
+    if (element->getAttribute(attribute).isNull())
         return;
-    EditCommandPtr cmd(new RemoveNodeAttributeCommand(document(), element, attribute));
-    applyCommandToComposite(cmd);
+    applyCommandToComposite(new RemoveNodeAttributeCommand(element, attribute));
 }
 
-void CompositeEditCommand::setNodeAttribute(Element *element, const QualifiedName& attribute, const String &value)
+void CompositeEditCommand::setNodeAttribute(Elementelement, const QualifiedName& attribute, const String &value)
 {
-    EditCommandPtr cmd(new SetNodeAttributeCommand(document(), element, attribute, value));
-    applyCommandToComposite(cmd);
+    applyCommandToComposite(new SetNodeAttributeCommand(element, attribute, value));
 }
 
 void CompositeEditCommand::rebalanceWhitespaceAt(const Position& position)
@@ -382,8 +337,7 @@ void CompositeEditCommand::rebalanceWhitespaceAt(const Position& position)
     RenderObject* renderer = textNode->renderer();
     if (renderer && !renderer->style()->collapseWhiteSpace())
         return;
-    EditCommandPtr cmd(new RebalanceWhitespaceCommand(document(), position));
-    applyCommandToComposite(cmd);    
+    applyCommandToComposite(new RebalanceWhitespaceCommand(position));    
 }
 
 void CompositeEditCommand::rebalanceWhitespace()
@@ -396,13 +350,13 @@ void CompositeEditCommand::rebalanceWhitespace()
     }
 }
 
-void CompositeEditCommand::deleteInsignificantText(Text *textNode, int start, int end)
+void CompositeEditCommand::deleteInsignificantText(TexttextNode, int start, int end)
 {
     if (!textNode || !textNode->renderer() || start >= end)
         return;
 
-    RenderText *textRenderer = static_cast<RenderText *>(textNode->renderer());
-    InlineTextBox *box = textRenderer->firstTextBox();
+    RenderText* textRenderer = static_cast<RenderText*>(textNode->renderer());
+    InlineTextBoxbox = textRenderer->firstTextBox();
     if (!box) {
         // whole text node is empty
         removeNode(textNode);
@@ -414,7 +368,7 @@ void CompositeEditCommand::deleteInsignificantText(Text *textNode, int start, in
         return;
 
     int removed = 0;
-    InlineTextBox *prevBox = 0;
+    InlineTextBoxprevBox = 0;
     RefPtr<StringImpl> str;
 
     // This loop structure works to process all gaps preceding a box,
@@ -457,7 +411,7 @@ void CompositeEditCommand::deleteInsignificantText(Text *textNode, int start, in
     }
 }
 
-void CompositeEditCommand::deleteInsignificantText(const Position &start, const Position &end)
+void CompositeEditCommand::deleteInsignificantText(const Position& start, const Position& end)
 {
     if (start.isNull() || end.isNull())
         return;
@@ -465,35 +419,30 @@ void CompositeEditCommand::deleteInsignificantText(const Position &start, const
     if (Range::compareBoundaryPoints(start, end) >= 0)
         return;
 
-    Node *node = start.node();
-    while (node) {
-        Node *next = node->traverseNextNode();
-    
+    Node* next;
+    for (Node* node = start.node(); node; node = next) {
+        next = node->traverseNextNode();
         if (node->isTextNode()) {
-            Text *textNode = static_cast<Text *>(node);
-            bool isStartNode = node == start.node();
-            bool isEndNode = node == end.node();
-            int startOffset = isStartNode ? start.offset() : 0;
-            int endOffset = isEndNode ? end.offset() : textNode->length();
+            Text* textNode = static_cast<Text*>(node);
+            int startOffset = node == start.node() ? start.offset() : 0;
+            int endOffset = node == end.node() ? end.offset() : textNode->length();
             deleteInsignificantText(textNode, startOffset, endOffset);
         }
-            
         if (node == end.node())
             break;
-        node = next;
     }
 }
 
-void CompositeEditCommand::deleteInsignificantTextDownstream(const Position &pos)
+void CompositeEditCommand::deleteInsignificantTextDownstream(const Positionpos)
 {
     Position end = VisiblePosition(pos, VP_DEFAULT_AFFINITY).next().deepEquivalent().downstream();
     deleteInsignificantText(pos, end);
 }
 
-Node *CompositeEditCommand::appendBlockPlaceholder(Node *node)
+Node* CompositeEditCommand::appendBlockPlaceholder(Node* node)
 {
     if (!node)
-        return NULL;
+        return 0;
     
     // Should assert isBlockFlow || isInlineFlow when deletion improves.  See 4244964.
     ASSERT(node->renderer());
@@ -503,10 +452,10 @@ Node *CompositeEditCommand::appendBlockPlaceholder(Node *node)
     return placeholder.get();
 }
 
-Node *CompositeEditCommand::insertBlockPlaceholder(const Position &pos)
+Node* CompositeEditCommand::insertBlockPlaceholder(const Position& pos)
 {
     if (pos.isNull())
-        return NULL;
+        return 0;
 
     // Should assert isBlockFlow || isInlineFlow when deletion improves.  See 4244964.
     ASSERT(pos.node()->renderer());
@@ -516,23 +465,23 @@ Node *CompositeEditCommand::insertBlockPlaceholder(const Position &pos)
     return placeholder.get();
 }
 
-Node *CompositeEditCommand::addBlockPlaceholderIfNeeded(Node *node)
+Node* CompositeEditCommand::addBlockPlaceholderIfNeeded(Node* node)
 {
     if (!node)
-        return false;
+        return 0;
 
     updateLayout();
 
     RenderObject *renderer = node->renderer();
     if (!renderer || !renderer->isBlockFlow())
-        return false;
+        return 0;
     
     // append the placeholder to make sure it follows
     // any unrendered blocks
     if (renderer->height() == 0 || (renderer->isListItem() && renderer->isEmpty()))
         return appendBlockPlaceholder(node);
 
-    return NULL;
+    return 0;
 }
 
 void CompositeEditCommand::removeBlockPlaceholder(const VisiblePosition& visiblePosition)
@@ -543,11 +492,9 @@ void CompositeEditCommand::removeBlockPlaceholder(const VisiblePosition& visible
     Position p = visiblePosition.deepEquivalent().downstream();
     if (p.node()->hasTagName(brTag) && p.offset() == 0 && isEndOfBlock(visiblePosition) && isStartOfBlock(visiblePosition))
         removeNode(p.node());
-        
-    return;
 }
 
-void CompositeEditCommand::moveParagraphContentsToNewBlockIfNecessary(const Position &pos)
+void CompositeEditCommand::moveParagraphContentsToNewBlockIfNecessary(const Positionpos)
 {
     if (pos.isNull())
         return;
@@ -591,10 +538,10 @@ void CompositeEditCommand::moveParagraphContentsToNewBlockIfNecessary(const Posi
 
     RefPtr<Node> newBlock = createDefaultParagraphElement(document());
 
-    Node *moveNode = paragraphStart.node();
+    NodemoveNode = paragraphStart.node();
     if (paragraphStart.offset() >= paragraphStart.node()->caretMaxOffset())
         moveNode = moveNode->traverseNextNode();
-    Node *endNode = end.node();
+    NodeendNode = end.node();
     
     if (!isAtomicNode(paragraphStart.node()))
         insertNodeAt(newBlock.get(), paragraphStart.node(), paragraphStart.offset());
@@ -605,7 +552,7 @@ void CompositeEditCommand::moveParagraphContentsToNewBlockIfNecessary(const Posi
     }
 
     while (moveNode && !isBlock(moveNode)) {
-        Node *next = moveNode->traverseNextSibling();
+        Nodenext = moveNode->traverseNextSibling();
         removeNode(moveNode);
         appendNode(moveNode, newBlock.get());
         if (moveNode == endNode)
@@ -618,7 +565,6 @@ Node* enclosingAnchorElement(Node* node)
 {
     while (node && !(node->isElementNode() && node->isLink()))
         node = node->parentNode();
-    
     return node;
 }
 
@@ -741,8 +687,7 @@ void CompositeEditCommand::moveParagraphs(const VisiblePosition& startOfParagrap
     destinationIndex = TextIterator::rangeLength(startToDestinationRange.get());
     
     setEndingSelection(destination);
-    EditCommandPtr cmd(new ReplaceSelectionCommand(document(), fragment.get(), true, false, !preserveStyle, false));
-    applyCommandToComposite(cmd);
+    applyCommandToComposite(new ReplaceSelectionCommand(document(), fragment.get(), true, false, !preserveStyle, false));
     
     if (preserveSelection && startIndex != -1) {
         setEndingSelection(Selection(TextIterator::rangeFromLocationAndLength(document(), destinationIndex + startIndex, 0)->startPosition(), 
@@ -760,12 +705,12 @@ bool CompositeEditCommand::breakOutOfEmptyListItem()
         
     RefPtr<CSSMutableStyleDeclaration> style = styleAtPosition(endingSelection().start());
 
-    Node *listNode = emptyListItem->parentNode();
+    NodelistNode = emptyListItem->parentNode();
     RefPtr<Node> newBlock = isListElement(listNode->parentNode()) ? createListItemElement(document()) : createDefaultParagraphElement(document());
     
     if (emptyListItem->renderer()->nextSibling()) {
         if (emptyListItem->renderer()->previousSibling())
-            splitElement(static_cast<Element *>(listNode), emptyListItem);
+            splitElement(static_cast<Element*>(listNode), emptyListItem);
         insertNodeBefore(newBlock.get(), listNode);
         removeNode(emptyListItem);
     } else {
@@ -774,7 +719,7 @@ bool CompositeEditCommand::breakOutOfEmptyListItem()
     }
     
     appendBlockPlaceholder(newBlock.get());
-    setEndingSelection(Position(newBlock.get(), 0), DOWNSTREAM);
+    setEndingSelection(Selection(Position(newBlock.get(), 0), DOWNSTREAM));
     
     CSSComputedStyleDeclaration endingStyle(endingSelection().start().node());
     endingStyle.diff(style.get());
@@ -789,14 +734,9 @@ PassRefPtr<Element> createBlockPlaceholderElement(Document* document)
     ExceptionCode ec = 0;
     RefPtr<Element> breakNode = document->createElementNS(xhtmlNamespaceURI, "br", ec);
     ASSERT(ec == 0);
-    breakNode->setAttribute(classAttr, blockPlaceholderClassString());
+    static String classString = "webkit-block-placeholder";
+    breakNode->setAttribute(classAttr, classString);
     return breakNode.release();
 }
 
-static const String &blockPlaceholderClassString()
-{
-    static String blockPlaceholderClassString = "webkit-block-placeholder";
-    return blockPlaceholderClassString;
-}
-
 } // namespace WebCore
index 6fc890908b4068f279aecd1f4e6eeb743bdf75af..9c2a454eddd57088068b286c99c5cef46f86bc9e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005 Apple Computer, Inc.  All rights reserved.
+ * Copyright (C) 2005, 2006 Apple Computer, Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 #define composite_edit_command_h__
 
 #include "EditCommand.h"
-#include "DeprecatedValueList.h"
+#include <wtf/Vector.h>
 
 namespace WebCore {
-    class CSSStyleDeclaration;
-    class String;
-    class Text;
-    class QualifiedName;
-}
 
-namespace WebCore {
+class CSSStyleDeclaration;
+class Text;
 
-class CompositeEditCommand : public EditCommand
-{
+class CompositeEditCommand : public EditCommand {
 public:
-    CompositeEditCommand(Document *);
+    CompositeEditCommand(Document*);
 
-    virtual void doUnapply();
-    virtual void doReapply();
+    bool isFirstCommand(EditCommand* c) { return !m_commands.isEmpty() && m_commands.first() == c; }
 
 protected:
     //
     // sugary-sweet convenience functions to help create and apply edit commands in composite commands
     //
-    void appendNode(Node *appendChild, Node *parentNode);
-    void applyCommandToComposite(EditCommandPtr &);
-    void applyStyle(CSSStyleDeclaration *style, EditAction editingAction=EditActionChangeAttributes);
-    void applyStyle(CSSStyleDeclaration *style, Position start, Position end, EditAction editingAction=EditActionChangeAttributes);
+    void appendNode(Node* appendChild, Node* parentNode);
+    void applyCommandToComposite(PassRefPtr<EditCommand>);
+    void applyStyle(CSSStyleDeclaration*, EditAction = EditActionChangeAttributes);
+    void applyStyle(CSSStyleDeclaration*, const Position& start, const Position& end, EditAction = EditActionChangeAttributes);
     void applyStyledElement(Element*);
     void removeStyledElement(Element*);
     void deleteKeyPressed();
-    void deleteSelection(bool smartDelete=false, bool mergeBlocksAfterDelete=true, bool replace=false);
-    void deleteSelection(const Selection &selection, bool smartDelete=false, bool mergeBlocksAfterDelete=true, bool replace=false);
-    virtual void deleteTextFromNode(Text *node, int offset, int count);
-    void inputText(const String &text, bool selectInsertedText = false);
-    void insertNodeAfter(Node *insertChild, Node *refChild);
-    void insertNodeAt(Node *insertChild, Node *refChild, int offset);
-    void insertNodeBefore(Node *insertChild, Node *refChild);
+    void deleteSelection(bool smartDelete = false, bool mergeBlocksAfterDelete = true, bool replace = false);
+    void deleteSelection(const Selection&, bool smartDelete = false, bool mergeBlocksAfterDelete = true, bool replace = false);
+    virtual void deleteTextFromNode(Textnode, int offset, int count);
+    void inputText(const String&, bool selectInsertedText = false);
+    void insertNodeAfter(Node* insertChild, Node* refChild);
+    void insertNodeAt(Node* insertChild, Node* refChild, int offset);
+    void insertNodeBefore(Node* insertChild, Node* refChild);
     void insertParagraphSeparator();
-    void insertTextIntoNode(Text *node, int offset, const String &text);
-    void joinTextNodes(Text *text1, Text *text2);
+    void insertTextIntoNode(Text* node, int offset, const String& text);
+    void joinTextNodes(Text*, Text*);
     void rebalanceWhitespace();
-    void rebalanceWhitespaceAt(const Position &position);
-    void removeCSSProperty(CSSStyleDeclaration *, int property);
-    void removeNodeAttribute(Element *, const QualifiedName& attribute);
-    void removeChildrenInRange(Node *node, int from, int to);
+    void rebalanceWhitespaceAt(const Position&);
+    void removeCSSProperty(CSSStyleDeclaration*, int property);
+    void removeNodeAttribute(Element*, const QualifiedName& attribute);
+    void removeChildrenInRange(Node*, int from, int to);
     virtual void removeNode(Node*);
     void removeNodePreservingChildren(Node*);
-    void removeNodeAndPruneAncestors(Node* node);
-    void prune(PassRefPtr<Node> node);
-    void replaceTextInNode(Text *node, int offset, int count, const String &replacementText);
-    Position positionOutsideTabSpan(const Position& pos);
-    void insertNodeAtTabSpanPosition(Node *node, const Position& pos);
-    void setNodeAttribute(Element *, const QualifiedName& attribute, const String &);
-    void splitTextNode(Text *text, int offset);
-    void splitElement(Element *element, Node *atChild);
-    void mergeIdenticalElements(Element *first, Element *second);
-    void wrapContentsInDummySpan(Element *element);
-    void splitTextNodeContainingElement(Text *text, int offset);
+    void removeNodeAndPruneAncestors(Node*);
+    void prune(PassRefPtr<Node>);
+    void replaceTextInNode(Text* node, int offset, int count, const String& replacementText);
+    Position positionOutsideTabSpan(const Position&);
+    void insertNodeAtTabSpanPosition(Node*, const Position&);
+    void setNodeAttribute(Element*, const QualifiedName& attribute, const String& value);
+    void splitTextNode(Text*, int offset);
+    void splitElement(Element*, Node* atChild);
+    void mergeIdenticalElements(Element*, Element*);
+    void wrapContentsInDummySpan(Element*);
+    void splitTextNodeContainingElement(Text*, int offset);
 
-    void deleteInsignificantText(Text *, int start, int end);
-    void deleteInsignificantText(const Position &start, const Position &end);
-    void deleteInsignificantTextDownstream(const Position &);
+    void deleteInsignificantText(Text*, int start, int end);
+    void deleteInsignificantText(const Position& start, const Position& end);
+    void deleteInsignificantTextDownstream(const Position&);
 
     Node *appendBlockPlaceholder(Node*);
-    Node *insertBlockPlaceholder(const Position &pos);
+    Node *insertBlockPlaceholder(const Position&);
     Node *addBlockPlaceholderIfNeeded(Node*);
     void removeBlockPlaceholder(const VisiblePosition&);
 
-    void moveParagraphContentsToNewBlockIfNecessary(const Position &);
+    void moveParagraphContentsToNewBlockIfNecessary(const Position&);
     
     void pushAnchorElementDown(Node*);
     void pushPartiallySelectedAnchorElementsDown();
@@ -105,9 +99,13 @@ protected:
     
     bool breakOutOfEmptyListItem();
 
-    DeprecatedValueList<EditCommandPtr> m_cmds;
+    Vector<RefPtr<EditCommand> > m_commands;
+
+private:
+    virtual void doUnapply();
+    virtual void doReapply();
 };
 
 } // namespace WebCore
 
-#endif // __composite_edit_command_h__
+#endif // composite_edit_command_h__
index b19994b85a543641c75251c964e7c0aafc0bd566..90f4514eaad05deca6cea967e9d10bc8903154b1 100644 (file)
@@ -30,8 +30,8 @@
 
 namespace WebCore {
 
-DeleteFromTextNodeCommand::DeleteFromTextNodeCommand(Document *document, Text *node, int offset, int count)
-    : EditCommand(document), m_node(node), m_offset(offset), m_count(count)
+DeleteFromTextNodeCommand::DeleteFromTextNodeCommand(Text *node, int offset, int count)
+    : EditCommand(node->document()), m_node(node), m_offset(offset), m_count(count)
 {
     ASSERT(m_node);
     ASSERT(m_offset >= 0);
index e47d11eb461e115226d86144447f1e6d94c7bce5..93ffa435bda37b6e07bbd24d6aa6938b3b6d5f35 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005 Apple Computer, Inc.  All rights reserved.
+ * Copyright (C) 2005, 2006 Apple Computer, Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 #include "EditCommand.h"
 
 namespace WebCore {
-    class Text;
-}
 
-namespace WebCore {
+class Text;
 
-class DeleteFromTextNodeCommand : public EditCommand
-{
+class DeleteFromTextNodeCommand : public EditCommand {
 public:
-    DeleteFromTextNodeCommand(Document *document, Text *node, int offset, int count);
-    virtual ~DeleteFromTextNodeCommand() { }
+    DeleteFromTextNodeCommand(Text*, int offset, int count);
 
     virtual void doApply();
     virtual void doUnapply();
 
-    Text *node() const { return m_node.get(); }
+    Textnode() const { return m_node.get(); }
     int offset() const { return m_offset; }
     int count() const { return m_count; }
 
@@ -56,4 +52,4 @@ private:
 
 } // namespace WebCore
 
-#endif // __delete_from_text_node_command_h__
+#endif // delete_from_text_node_command_h__
index 64bc0cb3ef00474b8679b7ac7cc40df406315b30..a9de108c6d75fca391a030c5f3e93bbf252d15e8 100644 (file)
@@ -57,8 +57,8 @@ DeleteSelectionCommand::DeleteSelectionCommand(Document *document, bool smartDel
 {
 }
 
-DeleteSelectionCommand::DeleteSelectionCommand(Document *document, const Selection &selection, bool smartDelete, bool mergeBlocksAfterDelete, bool replace)
-    : CompositeEditCommand(document), 
+DeleteSelectionCommand::DeleteSelectionCommand(const Selection& selection, bool smartDelete, bool mergeBlocksAfterDelete, bool replace)
+    : CompositeEditCommand(selection.start().node()->document()), 
       m_hasSelectionToDelete(true), 
       m_smartDelete(smartDelete), 
       m_mergeBlocksAfterDelete(mergeBlocksAfterDelete),
@@ -72,7 +72,7 @@ DeleteSelectionCommand::DeleteSelectionCommand(Document *document, const Selecti
 }
 
 void DeleteSelectionCommand::initializeStartEnd()
- {
+{
     Node* startSpecialContainer = 0;
     Node* endSpecialContainer = 0;
  
index bca6c42122b91963825a098c3689eda7273aef9c..6af56b9d494b384fccbe27700fee20cae94ba5d5 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005 Apple Computer, Inc.  All rights reserved.
+ * Copyright (C) 2005, 2006 Apple Computer, Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
 
-#ifndef __delete_selection_command_h__
-#define __delete_selection_command_h__
+#ifndef delete_selection_command_h__
+#define delete_selection_command_h__
 
 #include "CompositeEditCommand.h"
 
 namespace WebCore {
 
-class DeleteSelectionCommand : public CompositeEditCommand
-{ 
+class DeleteSelectionCommand : public CompositeEditCommand { 
 public:
-    DeleteSelectionCommand(Document *document, bool smartDelete=false, bool mergeBlocksAfterDelete=true, bool replace=false);
-    DeleteSelectionCommand(Document *document, const Selection &selection, bool smartDelete=false, bool mergeBlocksAfterDelete=true, bool replace=false);
+    DeleteSelectionCommand(Document*, bool smartDelete = false, bool mergeBlocksAfterDelete = true, bool replace = false);
+    DeleteSelectionCommand(const Selection&, bool smartDelete = false, bool mergeBlocksAfterDelete = true, bool replace = false);
 
     virtual void doApply();
     virtual EditAction editingAction() const;
@@ -79,4 +78,4 @@ private:
 
 } // namespace WebCore
 
-#endif // __delete_selection_command_h__
+#endif // delete_selection_command_h__
index 9c929a5567fc049cb5e1d3a758de526b1c6182a6..4062bec79e542de57a7c945b375f12234d7cb746 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005 Apple Computer, Inc.  All rights reserved.
+ * Copyright (C) 2005, 2006 Apple Computer, Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 #include "config.h"
 #include "EditCommand.h"
 
+#include "CompositeEditCommand.h"
+#include "CSSComputedStyleDeclaration.h"
+#include "CSSMutableStyleDeclaration.h"
 #include "Document.h"
+#include "Element.h"
+#include "EventNames.h"
 #include "Frame.h"
 #include "SelectionController.h"
 #include "VisiblePosition.h"
-#include "CSSComputedStyleDeclaration.h"
-#include "CSSMutableStyleDeclaration.h"
-#include "EventNames.h"
 #include "htmlediting.h"
 
 namespace WebCore {
 
 using namespace EventNames;
 
-#define IF_IMPL_NULL_RETURN_ARG(arg) do { \
-        if (*this == 0) { return arg; } \
-    } while (0)
-        
-#define IF_IMPL_NULL_RETURN do { \
-        if (*this == 0) { return; } \
-    } while (0)
-
-EditCommandPtr::EditCommandPtr()
-{
-}
-
-EditCommandPtr::EditCommandPtr(EditCommand *impl) : RefPtr<EditCommand>(impl)
-{
-}
-
-bool EditCommandPtr::isCompositeStep() const
-{
-    IF_IMPL_NULL_RETURN_ARG(false);        
-    return get()->isCompositeStep();
-}
-
-bool EditCommandPtr::isInsertTextCommand() const
-{
-    IF_IMPL_NULL_RETURN_ARG(false);        
-    return get()->isInsertTextCommand();
-}
-
-bool EditCommandPtr::isTypingCommand() const
-{
-    IF_IMPL_NULL_RETURN_ARG(false);        
-    return get()->isTypingCommand();
-}
-
-void EditCommandPtr::apply() const
-{
-    IF_IMPL_NULL_RETURN;
-    get()->apply();
-}
-
-void EditCommandPtr::unapply() const
-{
-    IF_IMPL_NULL_RETURN;
-    get()->unapply();
-}
-
-void EditCommandPtr::reapply() const
-{
-    IF_IMPL_NULL_RETURN;
-    get()->reapply();
-}
-
-EditAction EditCommandPtr::editingAction() const
-{
-    IF_IMPL_NULL_RETURN_ARG(EditActionUnspecified);
-    return get()->editingAction();
-}
-
-Document * const EditCommandPtr::document() const
-{
-    IF_IMPL_NULL_RETURN_ARG(0);
-    return get()->document();
-}
-
-Selection EditCommandPtr::startingSelection() const
-{
-    IF_IMPL_NULL_RETURN_ARG(Selection());
-    return get()->startingSelection();
-}
-
-Selection EditCommandPtr::endingSelection() const
-{
-    IF_IMPL_NULL_RETURN_ARG(Selection());
-    return get()->endingSelection();
-}
-
-void EditCommandPtr::setStartingSelection(const Selection &s) const
-{
-    IF_IMPL_NULL_RETURN;
-    get()->setStartingSelection(s);
-}
-
-void EditCommandPtr::setStartingSelection(const VisiblePosition &p) const
-{
-    IF_IMPL_NULL_RETURN;
-    get()->setStartingSelection(p);
-}
-
-void EditCommandPtr::setStartingSelection(const Position &p, EAffinity affinity) const
-{
-    IF_IMPL_NULL_RETURN;
-    Selection s = Selection(p, affinity);
-    get()->setStartingSelection(s);
-}
-
-void EditCommandPtr::setEndingSelection(const Selection &s) const
-{
-    IF_IMPL_NULL_RETURN;
-    get()->setEndingSelection(s);
-}
-
-void EditCommandPtr::setEndingSelection(const VisiblePosition &p) const
-{
-    IF_IMPL_NULL_RETURN;
-    get()->setEndingSelection(p);
-}
-
-void EditCommandPtr::setEndingSelection(const Position &p, EAffinity affinity) const
-{
-    IF_IMPL_NULL_RETURN;
-    Selection s = Selection(p, affinity);
-    get()->setEndingSelection(s);
-}
-
-CSSMutableStyleDeclaration *EditCommandPtr::typingStyle() const
-{
-    IF_IMPL_NULL_RETURN_ARG(0);
-    return get()->typingStyle();
-}
-
-void EditCommandPtr::setTypingStyle(PassRefPtr<CSSMutableStyleDeclaration> style) const
-{
-    IF_IMPL_NULL_RETURN;
-    get()->setTypingStyle(style);
-}
-
-EditCommandPtr EditCommandPtr::parent() const
-{
-    IF_IMPL_NULL_RETURN_ARG(0);
-    return get()->parent();
-}
-
-void EditCommandPtr::setParent(const EditCommandPtr &cmd) const
-{
-    IF_IMPL_NULL_RETURN;
-    get()->setParent(cmd.get());
-}
-
-EditCommandPtr &EditCommandPtr::emptyCommand()
-{
-    static EditCommandPtr m_emptyCommand;
-    return m_emptyCommand;
-}
-
-EditCommand::EditCommand(Document *document) 
-    : m_document(document), m_state(NotApplied), m_parent(0)
+EditCommand::EditCommand(Document* document) 
+    : m_document(document)
+    , m_startingSelection(document->frame()->selection().selection())
+    , m_endingSelection(m_startingSelection)
+    , m_startingRootEditableElement(m_startingSelection.rootEditableElement())
+    , m_endingRootEditableElement(m_startingRootEditableElement)
+    , m_parent(0)
 {
     ASSERT(m_document);
     ASSERT(m_document->frame());
-    m_startingSelection = m_document->frame()->selection().selection();
-    m_endingSelection = m_startingSelection;
+    setStartingSelection(m_document->frame()->selection().selection());
+    setEndingSelection(m_startingSelection);
 }
 
 EditCommand::~EditCommand()
@@ -200,12 +63,10 @@ void EditCommand::apply()
 {
     ASSERT(m_document);
     ASSERT(m_document->frame());
-    ASSERT(state() == NotApplied);
  
-    Frame *frame = m_document->frame();
+    Frameframe = m_document->frame();
     
-    bool topLevel = !isCompositeStep();
-    if (topLevel) {
+    if (!m_parent) {
         if (!endingSelection().isContentRichlyEditable()) {
             switch (editingAction()) {
                 case EditActionTyping:
@@ -221,20 +82,17 @@ void EditCommand::apply()
             }
         }
     }
-    
+
     doApply();
-    
-    m_state = Applied;
 
     // FIXME: Improve typing style.
     // See this bug: <rdar://problem/3769899> Implementation of typing style needs improvement
     if (!preservesTypingStyle())
         setTypingStyle(0);
 
-    if (topLevel) {
+    if (!m_parent) {
         updateLayout();
-        EditCommandPtr cmd(this);
-        frame->appliedEditing(cmd);
+        frame->appliedEditing(this);
     }
 }
 
@@ -242,18 +100,14 @@ void EditCommand::unapply()
 {
     ASSERT(m_document);
     ASSERT(m_document->frame());
-    ASSERT(state() == Applied);
  
-    Frame *frame = m_document->frame();
+    Frameframe = m_document->frame();
     
     doUnapply();
-    
-    m_state = NotApplied;
 
-    if (!isCompositeStep()) {
+    if (!m_parent) {
         updateLayout();
-        EditCommandPtr cmd(this);
-        frame->unappliedEditing(cmd);
+        frame->unappliedEditing(this);
     }
 }
 
@@ -261,18 +115,14 @@ void EditCommand::reapply()
 {
     ASSERT(m_document);
     ASSERT(m_document->frame());
-    ASSERT(state() == NotApplied);
  
-    Frame *frame = m_document->frame();
+    Frameframe = m_document->frame();
     
     doReapply();
-    
-    m_state = Applied;
 
-    if (!isCompositeStep()) {
+    if (!m_parent) {
         updateLayout();
-        EditCommandPtr cmd(this);
-        frame->reappliedEditing(cmd);
+        frame->reappliedEditing(this);
     }
 }
 
@@ -286,44 +136,24 @@ EditAction EditCommand::editingAction() const
     return EditActionUnspecified;
 }
 
-void EditCommand::setStartingSelection(const Selection &s)
-{
-    for (EditCommand *cmd = this; cmd; cmd = cmd->m_parent)
-        cmd->m_startingSelection = s;
-}
-
-void EditCommand::setStartingSelection(const VisiblePosition &p)
+void EditCommand::setStartingSelection(const Selection& s)
 {
-    Selection s = Selection(p.deepEquivalent(), p.affinity());
-    for (EditCommand *cmd = this; cmd; cmd = cmd->m_parent)
-        cmd->m_startingSelection = s;
-}
-
-void EditCommand::setStartingSelection(const Position &p, EAffinity affinity)
-{
-    Selection s = Selection(p, affinity);
-    for (EditCommand *cmd = this; cmd; cmd = cmd->m_parent)
+    Element* root = s.rootEditableElement();
+    for (EditCommand* cmd = this; cmd; cmd = cmd->m_parent) {
         cmd->m_startingSelection = s;
+        cmd->m_startingRootEditableElement = root;
+        if (!cmd->m_parent || cmd->m_parent->isFirstCommand(cmd))
+            break;
+    }
 }
 
 void EditCommand::setEndingSelection(const Selection &s)
 {
-    for (EditCommand *cmd = this; cmd; cmd = cmd->m_parent)
-        cmd->m_endingSelection = s;
-}
-
-void EditCommand::setEndingSelection(const VisiblePosition &p)
-{
-    Selection s = Selection(p.deepEquivalent(), p.affinity());
-    for (EditCommand *cmd = this; cmd; cmd = cmd->m_parent)
-        cmd->m_endingSelection = s;
-}
-
-void EditCommand::setEndingSelection(const Position &p, EAffinity affinity)
-{
-    Selection s = Selection(p, affinity);
-    for (EditCommand *cmd = this; cmd; cmd = cmd->m_parent)
+    Element* root = s.rootEditableElement();
+    for (EditCommand* cmd = this; cmd; cmd = cmd->m_parent) {
         cmd->m_endingSelection = s;
+        cmd->m_endingRootEditableElement = root;
+    }
 }
 
 void EditCommand::setTypingStyle(PassRefPtr<CSSMutableStyleDeclaration> style)
@@ -373,4 +203,20 @@ void EditCommand::updateLayout() const
     document()->updateLayoutIgnorePendingStylesheets();
 }
 
+void EditCommand::setParent(CompositeEditCommand* parent)
+{
+    ASSERT(parent);
+    ASSERT(!m_parent);
+    m_parent = parent;
+    m_startingSelection = parent->m_endingSelection;
+    m_endingSelection = parent->m_endingSelection;
+    m_startingRootEditableElement = parent->m_endingRootEditableElement;
+    m_endingRootEditableElement = parent->m_endingRootEditableElement;
+}
+
+void applyCommand(PassRefPtr<EditCommand> command)
+{
+    command->apply();
+}
+
 } // namespace WebCore
index e0a6b7be5e68fee4c8fbdb61f27352a155059e11..f919237b14e6b1bf8d7cfbb631efc05245c7a660 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005 Apple Computer, Inc.  All rights reserved.
+ * Copyright (C) 2005, 2006 Apple Computer, Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
 
-#ifndef edit_command_h__
-#define edit_command_h__
+#ifndef EditCommand_h
+#define EditCommand_h
 
 #include "EditAction.h"
 #include "Selection.h"
 
 namespace WebCore {
 
+class CompositeEditCommand;
 class CSSMutableStyleDeclaration;
-class Document;
-class VisiblePosition;
 
-//------------------------------------------------------------------------------------------
-// EditCommand
-
-class EditCommand : public Shared<EditCommand>
-{
+class EditCommand : public Shared<EditCommand> {
 public:
-    EditCommand(Document *);
+    EditCommand(Document*);
     virtual ~EditCommand();
 
-    bool isCompositeStep() const { return m_parent != 0; }
-    EditCommand *parent() const { return m_parent; }
-    void setParent(EditCommand *parent) { m_parent = parent; }
+    void setParent(CompositeEditCommand*);
 
-    enum ECommandState { NotApplied, Applied };
-    
     void apply();
     void unapply();
     void reapply();
 
-    virtual void doApply() = 0;
-    virtual void doUnapply() = 0;
-    virtual void doReapply();  // calls doApply()
-
     virtual EditAction editingAction() const;
 
-    virtual Document * const document() const { return m_document.get(); }
-
     Selection startingSelection() const { return m_startingSelection; }
     Selection endingSelection() const { return m_endingSelection; }
 
-    ECommandState state() const { return m_state; }
-    void setState(ECommandState state) { m_state = state; }
-
-    void setStartingSelection(const Selection &s);
-    void setStartingSelection(const VisiblePosition &p);
-    void setStartingSelection(const Position &p, EAffinity affinity);
-    void setEndingSelection(const Selection &s);
-    void setEndingSelection(const VisiblePosition &p);
-    void setEndingSelection(const Position &p, EAffinity affinity);
+    Element* startingRootEditableElement() const { return m_startingRootEditableElement.get(); }
+    Element* endingRootEditableElement() const { return m_endingRootEditableElement.get(); }
 
     CSSMutableStyleDeclaration* typingStyle() const { return m_typingStyle.get(); };
     void setTypingStyle(PassRefPtr<CSSMutableStyleDeclaration>);
     
-    PassRefPtr<CSSMutableStyleDeclaration> styleAtPosition(const Position&);
-    
     virtual bool isInsertTextCommand() const;
     virtual bool isTypingCommand() const;
 
+protected:
+    Document* document() const { return m_document.get(); }
+
+    void setStartingSelection(const Selection&);
+    void setEndingSelection(const Selection&);
+
+    PassRefPtr<CSSMutableStyleDeclaration> styleAtPosition(const Position&);
     void updateLayout() const;
-    
+
 private:
+    virtual void doApply() = 0;
+    virtual void doUnapply() = 0;
+    virtual void doReapply(); // calls doApply()
+
     virtual bool preservesTypingStyle() const;
 
     RefPtr<Document> m_document;
-    ECommandState m_state;
     Selection m_startingSelection;
     Selection m_endingSelection;
+    RefPtr<Element> m_startingRootEditableElement;
+    RefPtr<Element> m_endingRootEditableElement;
     RefPtr<CSSMutableStyleDeclaration> m_typingStyle;
-    EditCommand *m_parent;
+    CompositeEditCommand* m_parent;
 };
 
-class EditCommandPtr : public RefPtr<EditCommand>
-{
-public:
-    EditCommandPtr();
-    EditCommandPtr(EditCommand *);
-
-    bool isCompositeStep() const;
-
-    void apply() const;
-    void unapply() const;
-    void reapply() const;
-
-    EditAction editingAction() const;
-
-    Document * const document() const;
-
-    Selection startingSelection() const;
-    Selection endingSelection() const;
-
-    void setStartingSelection(const Selection &s) const;
-    void setStartingSelection(const VisiblePosition &p) const;
-    void setStartingSelection(const Position &p, EAffinity affinity) const;
-    void setEndingSelection(const Selection &s) const;
-    void setEndingSelection(const VisiblePosition &p) const;
-    void setEndingSelection(const Position &p, EAffinity affinity) const;
-
-    CSSMutableStyleDeclaration* typingStyle() const;
-    void setTypingStyle(PassRefPtr<CSSMutableStyleDeclaration>) const;
-
-    EditCommandPtr parent() const;
-    void setParent(const EditCommandPtr &) const;
-
-    bool isInsertTextCommand() const;
-    bool isInsertLineBreakCommand() const;
-    bool isTypingCommand() const;
-
-    static EditCommandPtr &emptyCommand();
-};
+void applyCommand(PassRefPtr<EditCommand>);
 
 } // namespace WebCore
 
-#endif // __edit_command_h__
+#endif // EditCommand_h
index 0c8fd725017dd47b226277fd19ed21584f2d4932..9bd8efc88fd579c337967a5b14ce3e0d1f5bc934 100644 (file)
@@ -38,9 +38,8 @@ using namespace HTMLNames;
 
 FormatBlockCommand::FormatBlockCommand(Document* document, const String& tagName) 
     : CompositeEditCommand(document), m_tagName(tagName)
-{}
-
-
+{
+}
 
 bool FormatBlockCommand::modifyRange()
 {
index 6f83c48df0b4a64b9e3c6ae5947e1ec595b319c0..cefc0e7a0919b116bac51debda348d12939b5d7f 100644 (file)
 
 namespace WebCore {
 
-class FormatBlockCommand : public CompositeEditCommand
-{
+class FormatBlockCommand : public CompositeEditCommand {
 public:
-    FormatBlockCommand(Document*, const String&);
+    FormatBlockCommand(Document*, const String& tagName);
     virtual void doApply();
     virtual EditAction editingAction() const { return EditActionFormatBlock; }
 private:
index 3e9de4ab4ffebfbcf72dd6d35943ebd513753a5b..bde239f05bb1bf7f55119e63086015e49521629d 100644 (file)
@@ -96,10 +96,8 @@ Node* IndentOutdentCommand::splitTreeToNode(Node* start, Node* end, bool splitAn
     for (node = start; node && node->parent() != end; node = node->parent()) {
         VisiblePosition positionInParent(Position(node->parent(), 0), DOWNSTREAM);
         VisiblePosition positionInNode(Position(node, 0), DOWNSTREAM);
-        if (positionInParent != positionInNode) {
-            EditCommandPtr cmd(new SplitElementCommand(document(), static_cast<Element*>(node->parent()), node));
-            applyCommandToComposite(cmd);
-        }
+        if (positionInParent != positionInNode)
+            applyCommandToComposite(new SplitElementCommand(static_cast<Element*>(node->parent()), node));
     }
     if (splitAncestor)
         return splitTreeToNode(end, end->parent());
@@ -171,18 +169,17 @@ void IndentOutdentCommand::outdentParagraph()
 
     // Handle the list case
     bool inList = false;
-    InsertListCommand::EListType typeOfList;
+    InsertListCommand::Type typeOfList;
     if (enclosingNode->hasTagName(olTag)) {
         inList = true;
-        typeOfList = InsertListCommand::OrderedListType;
+        typeOfList = InsertListCommand::OrderedList;
     } else if (enclosingNode->hasTagName(ulTag)) {
         inList = true;
-        typeOfList = InsertListCommand::UnorderedListType;
+        typeOfList = InsertListCommand::UnorderedList;
     }
     if (inList) {
         // Use InsertListCommand to remove the selection from the list
-        EditCommandPtr cmd(new InsertListCommand(document(), typeOfList, ""));
-        applyCommandToComposite(cmd);
+        applyCommandToComposite(new InsertListCommand(document(), typeOfList, ""));
         return;
     }
     // The selection is inside a blockquote
@@ -227,7 +224,7 @@ void IndentOutdentCommand::outdentRegion()
     while (endOfCurrentParagraph != endAfterSelection) {
         VisiblePosition endOfNextParagraph = endOfParagraph(endOfCurrentParagraph.next());
         if (endOfCurrentParagraph == endOfLastParagraph)
-            setEndingSelection(originalSelectionEnd, DOWNSTREAM);
+            setEndingSelection(Selection(originalSelectionEnd, DOWNSTREAM));
         else
             setEndingSelection(endOfCurrentParagraph);
         outdentParagraph();
index 21430ccccca559a35b4150016b1863139e78d4de..257f084148c002f114935c03ff4fa88e00133ef2 100644 (file)
@@ -30,8 +30,8 @@
 
 namespace WebCore {
 
-InsertIntoTextNodeCommand::InsertIntoTextNodeCommand(Document *document, Text *node, int offset, const String &text)
-    : EditCommand(document), m_node(node), m_offset(offset)
+InsertIntoTextNodeCommand::InsertIntoTextNodeCommand(Text *node, int offset, const String &text)
+    : EditCommand(node->document()), m_node(node), m_offset(offset)
 {
     ASSERT(m_node);
     ASSERT(m_offset >= 0);
index 0cdf0e45a1cceff61cc53125023bf0d828eaa8f2..a3fc691c0c771701471053c8ac10ce61363b9bb2 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005 Apple Computer, Inc.  All rights reserved.
+ * Copyright (C) 2005, 2006 Apple Computer, Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 #include "EditCommand.h"
 
 namespace WebCore {
-    class Text;
-    class String;
-}
 
-namespace WebCore {
+class Text;
 
-class InsertIntoTextNodeCommand : public EditCommand
-{
+class InsertIntoTextNodeCommand : public EditCommand {
 public:
-    InsertIntoTextNodeCommand(Document *document, Text *, int, const String &);
-    virtual ~InsertIntoTextNodeCommand() { }
+    InsertIntoTextNodeCommand(Text* node, int offset, const String& text);
 
     virtual void doApply();
     virtual void doUnapply();
 
-    Text *node() const { return m_node.get(); }
+    Textnode() const { return m_node.get(); }
     int offset() const { return m_offset; }
     String text() const { return m_text; }
 
@@ -56,4 +51,4 @@ private:
 
 } // namespace WebCore
 
-#endif // __insert_into_text_node_command_h__
+#endif // insert_into_text_node_command_h__
index a53422c2420171360615d93cea7b8fc533f63189..544f7ed29389c194c3d4d4d913c2a54976f8e1ef 100644 (file)
@@ -105,7 +105,7 @@ void InsertLineBreakCommand::doApply()
     
     if (isTabSpan) {
         insertNodeAtTabSpanPosition(nodeToInsert.get(), pos);
-        setEndingSelection(Position(nodeToInsert->traverseNextNode(), 0), DOWNSTREAM);
+        setEndingSelection(Selection(Position(nodeToInsert->traverseNextNode(), 0), DOWNSTREAM));
     } else if (isEndOfBlock(VisiblePosition(pos, selection.affinity()))) {
         Node* block = pos.node()->enclosingBlockFlowElement();
         
@@ -119,20 +119,20 @@ void InsertLineBreakCommand::doApply()
         if (!haveBreak)
             insertNodeAfter(createBreakElement(document()).get(), nodeToInsert.get());
             
-        setEndingSelection(Position(block, maxDeepOffset(block)), DOWNSTREAM);
+        setEndingSelection(Selection(Position(block, maxDeepOffset(block)), DOWNSTREAM));
     } else if (pos.offset() <= pos.node()->caretMinOffset()) {
         LOG(Editing, "input newline case 2");
         // Insert node before downstream position, and place caret there as well. 
         Position endingPosition = pos.downstream();
         insertNodeBeforePosition(nodeToInsert.get(), endingPosition);
-        setEndingSelection(endingPosition, DOWNSTREAM);
+        setEndingSelection(Selection(endingPosition, DOWNSTREAM));
     } else if (pos.offset() >= pos.node()->caretMaxOffset()) {
         LOG(Editing, "input newline case 3");
         // Insert BR after this node. Place caret in the position that is downstream
         // of the current position, reckoned before inserting the BR in between.
         Position endingPosition = pos.downstream();
         insertNodeAfterPosition(nodeToInsert.get(), pos);
-        setEndingSelection(endingPosition, DOWNSTREAM);
+        setEndingSelection(Selection(endingPosition, DOWNSTREAM));
     } else {
         // Split a text node
         LOG(Editing, "input newline case 4");
@@ -156,7 +156,7 @@ void InsertLineBreakCommand::doApply()
             insertTextIntoNode(textNode, 0, nonBreakingSpaceString());
         }
         
-        setEndingSelection(endingPosition, DOWNSTREAM);
+        setEndingSelection(Selection(endingPosition, DOWNSTREAM));
     }
 
     // Handle the case where there is a typing style.
index 201e18014eb1af2b5848cbe720e3b36a2ec2c9e8..79082b64bb41620850865602171f43f0ffdcefe0 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005 Apple Computer, Inc.  All rights reserved.
+ * Copyright (C) 2005, 2006 Apple Computer, Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 
 namespace WebCore {
 
-class InsertLineBreakCommand : public CompositeEditCommand
-{
+class InsertLineBreakCommand : public CompositeEditCommand {
 public:
-    InsertLineBreakCommand(Document *document);
+    InsertLineBreakCommand(Document*);
 
     virtual void doApply();
 
 private:
     virtual bool preservesTypingStyle() const;
-    void insertNodeAfterPosition(Node *node, const Position &pos);
-    void insertNodeBeforePosition(Node *node, const Position &pos);
+    void insertNodeAfterPosition(Node*, const Position&);
+    void insertNodeBeforePosition(Node*, const Position&);
 };
 
 } // namespace WebCore
index 8124eb240ea69af74358477e8b52ae7ae2e76cb2..bf4d6ccc21122f094814d7fa6f4fd4b0eef36deb 100644 (file)
@@ -45,9 +45,10 @@ Node* InsertListCommand::fixOrphanedListChild(Node* node)
     return listElement.get();
 }
 
-InsertListCommand::InsertListCommand(Document* document, EListType type, const String& id) 
+InsertListCommand::InsertListCommand(Document* document, Type type, const String& id) 
     : CompositeEditCommand(document), m_type(type), m_id(id), m_forceCreateList(false)
-{}
+{
+}
 
 bool InsertListCommand::modifyRange()
 {
@@ -94,7 +95,7 @@ void InsertListCommand::doApply()
         return;
     
     Node* selectionNode = endingSelection().start().node();
-    const QualifiedName listTag = (m_type == OrderedListType) ? olTag : ulTag;
+    const QualifiedName listTag = (m_type == OrderedList) ? olTag : ulTag;
     Node* listChildNode = enclosingListChild(selectionNode);
     bool switchListType = false;
     if (listChildNode) {
@@ -162,7 +163,7 @@ void InsertListCommand::doApply()
             appendNode(listItemElement.get(), nextList);
         else {
             // Create the list.
-            RefPtr<Element> listElement = m_type == OrderedListType ? createOrderedListElement(document()) : createUnorderedListElement(document());
+            RefPtr<Element> listElement = m_type == OrderedList ? createOrderedListElement(document()) : createUnorderedListElement(document());
             static_cast<HTMLElement*>(listElement.get())->setId(m_id);
             appendNode(listItemElement.get(), listElement.get());
             insertNodeAt(listElement.get(), start.deepEquivalent().node(), start.deepEquivalent().offset());
index b04cd6ad284c5a18bddd1d3a3351541ee74d445f..5ce7fbd5de0885b2c69cd9bf47415c324d94d9c1 100644 (file)
 
 namespace WebCore {
 
-class InsertListCommand : public CompositeEditCommand
-{
+class InsertListCommand : public CompositeEditCommand {
 public:
-    enum EListType { OrderedListType, UnorderedListType };
-    InsertListCommand(Document*, EListType, const String&);
+    enum Type { OrderedList, UnorderedList };
+    InsertListCommand(Document*, Type, const String&);
     virtual void doApply();
     virtual EditAction editingAction() const { return EditActionInsertList; }
 private:
     Node* fixOrphanedListChild(Node*);
     bool modifyRange();
-    EListType m_type;
+    Type m_type;
     String m_id;
     bool m_forceCreateList;
 };
index bad21e722dcb86a1359aa373f36835caf4011454..a80f28816560673d9c0fff269d4e72e8a3ead726 100644 (file)
@@ -28,8 +28,8 @@
 
 namespace WebCore {
 
-InsertNodeBeforeCommand::InsertNodeBeforeCommand(Document *document, Node *insertChild, Node *refChild)
-    : EditCommand(document), m_insertChild(insertChild), m_refChild(refChild)
+InsertNodeBeforeCommand::InsertNodeBeforeCommand(PassRefPtr<Node> insertChild, Node* refChild)
+    : EditCommand(refChild->document()), m_insertChild(insertChild), m_refChild(refChild)
 {
     ASSERT(m_insertChild);
     ASSERT(m_refChild);
index 394a6b8f7c2f19734c4807ba0637510e9f03504e..f5e20ab10cbf6b094436c8d12fd78e8b7b2c4938 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005 Apple Computer, Inc.  All rights reserved.
+ * Copyright (C) 2005, 2006 Apple Computer, Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
 
-#ifndef __insert_node_before_command_h__
-#define __insert_node_before_command_h__
+#ifndef insert_node_before_command_h__
+#define insert_node_before_command_h__
 
 #include "EditCommand.h"
 
 namespace WebCore {
 
-class InsertNodeBeforeCommand : public EditCommand
-{
+class InsertNodeBeforeCommand : public EditCommand {
 public:
-    InsertNodeBeforeCommand(Document *, Node *insertChild, Node *refChild);
-    virtual ~InsertNodeBeforeCommand() { }
+    InsertNodeBeforeCommand(PassRefPtr<Node>, Node* refChild);
 
     virtual void doApply();
     virtual void doUnapply();
 
-    Node *insertChild() const { return m_insertChild.get(); }
-    Node *refChild() const { return m_refChild.get(); }
+    NodeinsertChild() const { return m_insertChild.get(); }
+    NoderefChild() const { return m_refChild.get(); }
 
 private:
     RefPtr<Node> m_insertChild;
@@ -49,4 +47,4 @@ private:
 
 } // namespace WebCore
 
-#endif // __insert_node_before_command_h__
+#endif // insert_node_before_command_h__
index faf498ee479071f8532203791534ae8dd7907d56..ef81042dc43a02a621adfe5bb313c258f135827f 100644 (file)
@@ -100,11 +100,8 @@ void InsertParagraphSeparatorCommand::doApply()
     // FIXME: Turn into an InsertLineBreak in other cases where we don't want to do the splitting/cloning that
     // InsertParagraphSeparator does.
     Node* block = pos.node()->enclosingBlockFlowElement();
-    if (!block ||
-        !block->parentNode() ||
-        block->renderer() && block->renderer()->isTableCell()) {
-        EditCommandPtr cmd(new InsertLineBreakCommand(document())); 
-        applyCommandToComposite(cmd);
+    if (!block || !block->parentNode() || block->renderer() && block->renderer()->isTableCell()) {
+        applyCommandToComposite(new InsertLineBreakCommand(document()));
         return;
     }
     
@@ -157,7 +154,7 @@ void InsertParagraphSeparatorCommand::doApply()
             insertNodeAfter(blockToInsert.get(), startBlock);
 
         appendBlockPlaceholder(blockToInsert.get());
-        setEndingSelection(Position(blockToInsert.get(), 0), DOWNSTREAM);
+        setEndingSelection(Selection(Position(blockToInsert.get(), 0), DOWNSTREAM));
         applyStyleAfterInsertion();
         return;
     }
@@ -179,9 +176,9 @@ void InsertParagraphSeparatorCommand::doApply()
 
         insertNodeBefore(blockToInsert.get(), refNode);
         appendBlockPlaceholder(blockToInsert.get());
-        setEndingSelection(Position(blockToInsert.get(), 0), DOWNSTREAM);
+        setEndingSelection(Selection(Position(blockToInsert.get(), 0), DOWNSTREAM));
         applyStyleAfterInsertion();
-        setEndingSelection(pos, DOWNSTREAM);
+        setEndingSelection(Selection(pos, DOWNSTREAM));
         return;
     }
 
@@ -293,7 +290,7 @@ void InsertParagraphSeparatorCommand::doApply()
         }
     }
 
-    setEndingSelection(Position(blockToInsert.get(), 0), DOWNSTREAM);
+    setEndingSelection(Selection(Position(blockToInsert.get(), 0), DOWNSTREAM));
     applyStyleAfterInsertion();
 }
 
index df800b803be7467020e0cf79c536a8b98fa4273f..862b8f1dadd5300c74b2fe89f4ae084b6b3bde2b 100644 (file)
@@ -139,10 +139,10 @@ void InsertTextCommand::input(const String &text, bool selectInsertedText)
         applyStyle(typingStyle);
 
     if (!selectInsertedText)
-        setEndingSelection(endingSelection().end(), endingSelection().affinity());
+        setEndingSelection(Selection(endingSelection().end(), endingSelection().affinity()));
 }
 
-Position InsertTextCommand::insertTab(Position pos)
+Position InsertTextCommand::insertTab(const Position& pos)
 {
     Position insertPos = VisiblePosition(pos, DOWNSTREAM).deepEquivalent();
         
index 77533564fe599b15535ec4b285f845bed89de68d..a150abc82f8cb2b53ea6ac751e5d3a95a25e2515 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005 Apple Computer, Inc.  All rights reserved.
+ * Copyright (C) 2005, 2006 Apple Computer, Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
 
-#ifndef __insert_text_command_h__
-#define __insert_text_command_h__
+#ifndef insert_text_command_h__
+#define insert_text_command_h__
 
 #include "CompositeEditCommand.h"
 
 namespace WebCore {
 
-class InsertTextCommand : public CompositeEditCommand
-{
+class InsertTextCommand : public CompositeEditCommand {
 public:
-    InsertTextCommand(Document *document);
+    InsertTextCommand(Document*);
 
     virtual void doApply();
 
     void deleteCharacter();
-    void input(const String &text, bool selectInsertedText = false);
-    
+    void input(const Stringtext, bool selectInsertedText = false);
+
     unsigned charactersAdded() const { return m_charactersAdded; }
     
 private:
     virtual bool isInsertTextCommand() const;
 
-    Position prepareForTextInsertion(const Position& pos);
-    Position insertTab(Position pos);
+    Position prepareForTextInsertion(const Position&);
+    Position insertTab(const Position&);
 
     unsigned m_charactersAdded;
 };
 
 } // namespace WebCore
 
-#endif // __insert_text_command_h__
+#endif // insert_text_command_h__
index e8d82e2ae2e2faab27f93ec5c489bcdc3add343b..e5252fbe7649c12372c7d69fefdc60c0ee5d70cd 100644 (file)
@@ -54,88 +54,88 @@ namespace {
 bool supportsPasteCommand = false;
 
 struct CommandImp {
-    bool (*execFn)(Frame *frame, bool userInterface, const String &value);
-    bool (*enabledFn)(Frame *frame);
-    Frame::TriState (*stateFn)(Frame *frame);
-    String (*valueFn)(Frame *frame);
+    bool (*execFn)(Frame*, bool userInterface, const String& value);
+    bool (*enabledFn)(Frame*);
+    Frame::TriState (*stateFn)(Frame*);
+    String (*valueFn)(Frame*);
 };
 
-typedef HashMap<StringImpl *, const CommandImp *, CaseInsensitiveHash> CommandMap;
+typedef HashMap<StringImpl*, const CommandImp*, CaseInsensitiveHash> CommandMap;
 
-CommandMap *createCommandDictionary();
+CommandMapcreateCommandDictionary();
 
-const CommandImp *commandImp(const String &command)
+const CommandImp* commandImp(const String& command)
 {
-    static CommandMap *commandDictionary = createCommandDictionary();
+    static CommandMapcommandDictionary = createCommandDictionary();
     return commandDictionary->get(command.impl());
 }
 
 } // anonymous namespace
 
-bool JSEditor::execCommand(const String &command, bool userInterface, const String &value)
+bool JSEditor::execCommand(const String& command, bool userInterface, const String& value)
 {
-    const CommandImp *cmd = commandImp(command);
+    const CommandImpcmd = commandImp(command);
     if (!cmd)
         return false;
-    Frame *frame = m_doc->frame();
+    Frame* frame = m_document->frame();
     if (!frame)
         return false;
-    m_doc->updateLayoutIgnorePendingStylesheets();
-    return cmd->enabledFn(frame) && cmd->execFn(frame,  userInterface, value);
+    m_document->updateLayoutIgnorePendingStylesheets();
+    return cmd->enabledFn(frame) && cmd->execFn(frame, userInterface, value);
 }
 
-bool JSEditor::queryCommandEnabled(const String &command)
+bool JSEditor::queryCommandEnabled(const Stringcommand)
 {
-    const CommandImp *cmd = commandImp(command);
+    const CommandImpcmd = commandImp(command);
     if (!cmd)
         return false;
-    Frame *frame = m_doc->frame();
+    Frame* frame = m_document->frame();
     if (!frame)
         return false;
-    m_doc->updateLayoutIgnorePendingStylesheets();
+    m_document->updateLayoutIgnorePendingStylesheets();
     return cmd->enabledFn(frame);
 }
 
-bool JSEditor::queryCommandIndeterm(const String &command)
+bool JSEditor::queryCommandIndeterm(const Stringcommand)
 {
-    const CommandImp *cmd = commandImp(command);
+    const CommandImpcmd = commandImp(command);
     if (!cmd)
         return false;
-    Frame *frame = m_doc->frame();
+    Frame* frame = m_document->frame();
     if (!frame)
         return false;
-    m_doc->updateLayoutIgnorePendingStylesheets();
+    m_document->updateLayoutIgnorePendingStylesheets();
     return cmd->stateFn(frame) == Frame::mixedTriState;
 }
 
-bool JSEditor::queryCommandState(const String &command)
+bool JSEditor::queryCommandState(const Stringcommand)
 {
-    const CommandImp *cmd = commandImp(command);
+    const CommandImpcmd = commandImp(command);
     if (!cmd)
         return false;
-    Frame *frame = m_doc->frame();
+    Frame* frame = m_document->frame();
     if (!frame)
         return false;
-    m_doc->updateLayoutIgnorePendingStylesheets();
+    m_document->updateLayoutIgnorePendingStylesheets();
     return cmd->stateFn(frame) != Frame::falseTriState;
 }
 
-bool JSEditor::queryCommandSupported(const String &command)
+bool JSEditor::queryCommandSupported(const Stringcommand)
 {
     if (!supportsPasteCommand && command.lower() == "paste")
         return false;
     return commandImp(command) != 0;
 }
 
-String JSEditor::queryCommandValue(const String &command)
+String JSEditor::queryCommandValue(const Stringcommand)
 {
-    const CommandImp *cmd = commandImp(command);
+    const CommandImpcmd = commandImp(command);
     if (!cmd)
         return String();
-    Frame *frame = m_doc->frame();
+    Frame* frame = m_document->frame();
     if (!frame)
         return String();
-    m_doc->updateLayoutIgnorePendingStylesheets();
+    m_document->updateLayoutIgnorePendingStylesheets();
     return cmd->valueFn(frame);
 }
 
@@ -150,7 +150,7 @@ void JSEditor::setSupportsPasteCommand(bool flag)
 
 namespace {
 
-bool execStyleChange(Frame *frame, int propertyID, const String &propertyValue)
+bool execStyleChange(Frame* frame, int propertyID, const String& propertyValue)
 {
     RefPtr<CSSMutableStyleDeclaration> style = new CSSMutableStyleDeclaration;
     style->setProperty(propertyID, propertyValue);
@@ -158,26 +158,26 @@ bool execStyleChange(Frame *frame, int propertyID, const String &propertyValue)
     return true;
 }
 
-bool execStyleChange(Frame *frame, int propertyID, const char *propertyValue)
+bool execStyleChange(Frame* frame, int propertyID, const char* propertyValue)
 {
-    return execStyleChange(frame,  propertyID, String(propertyValue));
+    return execStyleChange(frame, propertyID, String(propertyValue));
 }
 
-Frame::TriState stateStyle(Frame *frame, int propertyID, const char *desiredValue)
+Frame::TriState stateStyle(Frame* frame, int propertyID, const char* desiredValue)
 {
     RefPtr<CSSMutableStyleDeclaration> style = new CSSMutableStyleDeclaration;
     style->setProperty(propertyID, desiredValue);
     return frame->selectionHasStyle(style.get());
 }
 
-bool selectionStartHasStyle(Frame *frame, int propertyID, const char *desiredValue)
+bool selectionStartHasStyle(Frame* frame, int propertyID, const char* desiredValue)
 {
     RefPtr<CSSMutableStyleDeclaration> style = new CSSMutableStyleDeclaration;
     style->setProperty(propertyID, desiredValue);
     return frame->selectionStartHasStyle(style.get());
 }
 
-String valueStyle(Frame *frame, int propertyID)
+String valueStyle(Frameframe, int propertyID)
 {
     return frame->selectionStartStylePropertyValue(propertyID);
 }
@@ -187,18 +187,18 @@ String valueStyle(Frame *frame, int propertyID)
 // execCommand implementations
 //
 
-bool execBackColor(Frame *frame, bool userInterface, const String &value)
+bool execBackColor(Frame* frame, bool, const String& value)
 {
     return execStyleChange(frame, CSS_PROP_BACKGROUND_COLOR, value);
 }
 
-bool execBold(Frame *frame, bool userInterface, const String &value)
+bool execBold(Frame* frame, bool, const String&)
 {
-    bool isBold = selectionStartHasStyle(frame,  CSS_PROP_FONT_WEIGHT, "bold");
-    return execStyleChange(frame,  CSS_PROP_FONT_WEIGHT, isBold ? "normal" : "bold");
+    bool isBold = selectionStartHasStyle(frame, CSS_PROP_FONT_WEIGHT, "bold");
+    return execStyleChange(frame, CSS_PROP_FONT_WEIGHT, isBold ? "normal" : "bold");
 }
 
-bool execCopy(Frame *frame, bool userInterface, const String &value)
+bool execCopy(Frame* frame, bool, const String&)
 {
     frame->copyToPasteboard();
     return true;
@@ -213,63 +213,62 @@ bool execCreateLink(Frame* frame, bool userInterface, const String& value)
     if (value.isEmpty())
         return false;
     
-    EditCommandPtr(new CreateLinkCommand(frame->document(), value)).apply();
+    applyCommand(new CreateLinkCommand(frame->document(), value));
     return true;
 }
 
-bool execCut(Frame *frame, bool userInterface, const String &value)
+bool execCut(Frame* frame, bool, const String&)
 {
     frame->cutToPasteboard();
     return true;
 }
 
-bool execDelete(Frame *frame, bool userInterface, const String &value)
+bool execDelete(Frame* frame, bool, const String&)
 {
     TypingCommand::deleteKeyPressed(frame->document(), frame->selectionGranularity() == WordGranularity);
     return true;
 }
 
 // FIXME: Come up with a way to send more parameters to execCommand so that we can support all of the features of Frame::findString.
-bool execFindString(Frame *frame, bool userInterface, const String &value)
+bool execFindString(Frame* frame, bool, const String& value)
 {
     return frame->findString(value, true, false, true);
 }
 
-bool execForwardDelete(Frame *frame, bool userInterface, const String &value)
+bool execForwardDelete(Frame* frame, bool, const String&)
 {
     TypingCommand::forwardDeleteKeyPressed(frame->document());
     return true;
 }
 
-bool execFontName(Frame *frame, bool userInterface, const String &value)
+bool execFontName(Frame* frame, bool, const String& value)
 {
-    return execStyleChange(frame,  CSS_PROP_FONT_FAMILY, value);
+    return execStyleChange(frame, CSS_PROP_FONT_FAMILY, value);
 }
 
-bool execFontSize(Frame *frame, bool userInterface, const String &value)
+bool execFontSize(Frame* frame, bool, const String& value)
 {
-    return execStyleChange(frame,  CSS_PROP_FONT_SIZE, value);
+    return execStyleChange(frame, CSS_PROP_FONT_SIZE, value);
 }
 
-bool execFontSizeDelta(Frame *frame, bool userInterface, const String &value)
+bool execFontSizeDelta(Frame* frame, bool, const String& value)
 {
-    return execStyleChange(frame,  CSS_PROP__WEBKIT_FONT_SIZE_DELTA, value);
+    return execStyleChange(frame, CSS_PROP__WEBKIT_FONT_SIZE_DELTA, value);
 }
 
-bool execForeColor(Frame *frame, bool userInterface, const String &value)
+bool execForeColor(Frame* frame, bool, const String& value)
 {
     return execStyleChange(frame, CSS_PROP_COLOR, value);
 }
 
-bool execFormatBlock(Frame *frame, bool userInterface, const String &value)
+bool execFormatBlock(Frame* frame, bool, const String& value)
 {
     String tagName = value.lower();
     if (tagName[0] == '<' && tagName[tagName.length() - 1] == '>')
         tagName = tagName.substring(1, tagName.length() - 2);
     if (!validBlockTag(tagName))
         return false;
-
-    EditCommandPtr(new FormatBlockCommand(frame->document(), tagName)).apply();
+    applyCommand(new FormatBlockCommand(frame->document(), tagName));
     return true;
 }
 
@@ -283,17 +282,15 @@ bool execInsertHorizontalRule(Frame* frame, bool userInterface, const String& va
     if (ec)
         return false;
     
-    EditCommandPtr(new ReplaceSelectionCommand(frame->document(), fragment.get(), false, false, false, true, EditActionUnspecified)).apply();
+    applyCommand(new ReplaceSelectionCommand(frame->document(), fragment.release(),
+        false, false, false, true, EditActionUnspecified));
     return true;
 }
 
 bool execInsertHTML(Frame* frame, bool userInterface, const String& value)
 {
-    DeprecatedString baseURL = "";
-    bool selectReplacement = false;
-    RefPtr<DocumentFragment> fragment = createFragmentFromMarkup(frame->document(), value.deprecatedString(), baseURL);
-    EditCommandPtr cmd(new ReplaceSelectionCommand(frame->document(), fragment.get(), selectReplacement));
-    cmd.apply();
+    Document* document = frame->document();
+    applyCommand(new ReplaceSelectionCommand(frame->document(), createFragmentFromMarkup(document, value, ""), false));
     return true;
 }
 
@@ -311,103 +308,103 @@ bool execInsertImage(Frame* frame, bool userInterface, const String& value)
     if (ec)
         return false;
     
-    EditCommandPtr(new ReplaceSelectionCommand(frame->document(), fragment.get(), false)).apply();
+    applyCommand(new ReplaceSelectionCommand(frame->document(), fragment.release(), false));
     return true;
 }
 
-bool execIndent(Frame *frame, bool userInterface, const String &value)
+bool execIndent(Frame* frame, bool, const String&)
 {
-    EditCommandPtr(new IndentOutdentCommand(frame->document(), IndentOutdentCommand::Indent)).apply();
+    applyCommand(new IndentOutdentCommand(frame->document(), IndentOutdentCommand::Indent));
     return true;
 }
 
-bool execInsertLineBreak(Frame *frame, bool userInterface, const String &value)
+bool execInsertLineBreak(Frame* frame, bool, const String&)
 {
     TypingCommand::insertLineBreak(frame->document());
     return true;
 }
 
-bool execInsertParagraph(Frame *frame, bool userInterface, const String &value)
+bool execInsertParagraph(Frame* frame, bool, const String&)
 {
     TypingCommand::insertParagraphSeparator(frame->document());
     return true;
 }
 
-bool execInsertNewlineInQuotedContent(Frame *frame, bool userInterface, const String &value)
+bool execInsertNewlineInQuotedContent(Frame* frame, bool, const String&)
 {
     TypingCommand::insertParagraphSeparatorInQuotedContent(frame->document());
     return true;
 }
 
-bool execInsertText(Frame *frame, bool userInterface, const String &value)
+bool execInsertText(Frame* frame, bool, const String& value)
 {
     TypingCommand::insertText(frame->document(), value);
     return true;
 }
 
-bool execInsertUnorderedList(Frame *frame, bool userInterface, const String &value)
+bool execInsertUnorderedList(Frame* frame, bool, const String& value)
 {
-    EditCommandPtr(new InsertListCommand(frame->document(), InsertListCommand::UnorderedListType, value)).apply();
+    applyCommand(new InsertListCommand(frame->document(), InsertListCommand::UnorderedList, value));
     return true;
 }
 
-bool execInsertOrderedList(Frame *frame, bool userInterface, const String &value)
+bool execInsertOrderedList(Frame* frame, bool, const String& value)
 {
-    EditCommandPtr(new InsertListCommand(frame->document(), InsertListCommand::OrderedListType, value)).apply();
+    applyCommand(new InsertListCommand(frame->document(), InsertListCommand::OrderedList, value));
     return true;
 }
 
-bool execItalic(Frame *frame, bool userInterface, const String &value)
+bool execItalic(Frame* frame, bool, const String&)
 {
-    bool isItalic = selectionStartHasStyle(frame,  CSS_PROP_FONT_STYLE, "italic");
-    return execStyleChange(frame,  CSS_PROP_FONT_STYLE, isItalic ? "normal" : "italic");
+    bool isItalic = selectionStartHasStyle(frame, CSS_PROP_FONT_STYLE, "italic");
+    return execStyleChange(frame, CSS_PROP_FONT_STYLE, isItalic ? "normal" : "italic");
 }
 
-bool execJustifyCenter(Frame *frame, bool userInterface, const String &value)
+bool execJustifyCenter(Frame* frame, bool, const String&)
 {
-    return execStyleChange(frame,  CSS_PROP_TEXT_ALIGN, "center");
+    return execStyleChange(frame, CSS_PROP_TEXT_ALIGN, "center");
 }
 
-bool execJustifyFull(Frame *frame, bool userInterface, const String &value)
+bool execJustifyFull(Frame* frame, bool, const String&)
 {
-    return execStyleChange(frame,  CSS_PROP_TEXT_ALIGN, "justify");
+    return execStyleChange(frame, CSS_PROP_TEXT_ALIGN, "justify");
 }
 
-bool execJustifyLeft(Frame *frame, bool userInterface, const String &value)
+bool execJustifyLeft(Frame* frame, bool, const String&)
 {
-    return execStyleChange(frame,  CSS_PROP_TEXT_ALIGN, "left");
+    return execStyleChange(frame, CSS_PROP_TEXT_ALIGN, "left");
 }
 
-bool execJustifyRight(Frame *frame, bool userInterface, const String &value)
+bool execJustifyRight(Frame* frame, bool, const String&)
 {
-    return execStyleChange(frame,  CSS_PROP_TEXT_ALIGN, "right");
+    return execStyleChange(frame, CSS_PROP_TEXT_ALIGN, "right");
 }
 
-bool execOutdent(Frame *frame, bool userInterface, const String &value)
+bool execOutdent(Frame* frame, bool, const String&)
 {
-    EditCommandPtr(new IndentOutdentCommand(frame->document(), IndentOutdentCommand::Outdent)).apply();
+    applyCommand(new IndentOutdentCommand(frame->document(), IndentOutdentCommand::Outdent));
     return true;
 }
 
-bool execPaste(Frame *frame, bool userInterface, const String &value)
+bool execPaste(Frame* frame, bool, const String&)
 {
     frame->pasteFromPasteboard();
     return true;
 }
 
-bool execPasteAndMatchStyle(Frame *frame, bool userInterface, const String &value)
+bool execPasteAndMatchStyle(Frame* frame, bool, const String&)
 {
     frame->pasteAndMatchStyle();
     return true;
 }
 
-bool execPrint(Frame *frame, bool userInterface, const String &value)
+bool execPrint(Frame* frame, bool, const String&)
 {
     frame->print();
     return true;
 }
 
-bool execRedo(Frame *frame, bool userInterface, const String &value)
+bool execRedo(Frame* frame, bool, const String&)
 {
     frame->redo();
     return true;
@@ -415,58 +412,59 @@ bool execRedo(Frame *frame, bool userInterface, const String &value)
 
 bool execRemoveFormat(Frame* frame, bool userInterface, const String& value)
 {
-    RefPtr<DocumentFragment> fragment = createFragmentFromText(frame->selection().toRange().get(), frame->selection().toString());
-    EditCommandPtr(new ReplaceSelectionCommand(frame->document(), fragment.get(), false, false, false, true, EditActionUnspecified)).apply();
+    applyCommand(new ReplaceSelectionCommand(frame->document(),
+        createFragmentFromText(frame->selection().toRange().get(), frame->selection().toString()),
+        false, false, false, true, EditActionUnspecified));
     return true;
 }
 
-bool execSelectAll(Frame *frame, bool userInterface, const String &value)
+bool execSelectAll(Frame* frame, bool, const String&)
 {
     frame->selectAll();
     return true;
 }
 
-bool execStrikethrough(Frame *frame, bool userInterface, const String &value)
+bool execStrikethrough(Frame* frame, bool, const String&)
 {
     bool isStrikethrough = selectionStartHasStyle(frame,  CSS_PROP__WEBKIT_TEXT_DECORATIONS_IN_EFFECT, "line-through");
-    return execStyleChange(frame,  CSS_PROP__WEBKIT_TEXT_DECORATIONS_IN_EFFECT, isStrikethrough ? "none" : "line-through");
+    return execStyleChange(frame, CSS_PROP__WEBKIT_TEXT_DECORATIONS_IN_EFFECT, isStrikethrough ? "none" : "line-through");
 }
 
-bool execSubscript(Frame *frame, bool userInterface, const String &value)
+bool execSubscript(Frame* frame, bool, const String&)
 {
     return execStyleChange(frame,  CSS_PROP_VERTICAL_ALIGN, "sub");
 }
 
-bool execSuperscript(Frame *frame, bool userInterface, const String &value)
+bool execSuperscript(Frame* frame, bool, const String&)
 {
     return execStyleChange(frame,  CSS_PROP_VERTICAL_ALIGN, "super");
 }
 
-bool execTranspose(Frame *frame, bool userInterface, const String &value)
+bool execTranspose(Frame* frame, bool, const String&)
 {
     frame->transpose();
     return true;
 }
 
-bool execUnderline(Frame *frame, bool userInterface, const String &value)
+bool execUnderline(Frame* frame, bool, const String&)
 {
     bool isUnderlined = selectionStartHasStyle(frame,  CSS_PROP__WEBKIT_TEXT_DECORATIONS_IN_EFFECT, "underline");
     return execStyleChange(frame,  CSS_PROP__WEBKIT_TEXT_DECORATIONS_IN_EFFECT, isUnderlined ? "none" : "underline");
 }
 
-bool execUndo(Frame *frame, bool userInterface, const String &value)
+bool execUndo(Frame* frame, bool, const String&)
 {
     frame->undo();
     return true;
 }
 
-bool execUnlink(Frame *frame, bool userInterface, const String &value)
+bool execUnlink(Frame* frame, bool, const String&)
 {
-    EditCommandPtr(new UnlinkCommand(frame->document())).apply();
+    applyCommand(new UnlinkCommand(frame->document()));
     return true;
 }
 
-bool execUnselect(Frame *frame, bool userInterface, const String &value)
+bool execUnselect(Frame* frame, bool, const String&)
 {
     // FIXME: 6498 Should just be able to call m_frame->selection().clear()
     frame->setSelection(SelectionController());
@@ -483,62 +481,62 @@ bool execUnselect(Frame *frame, bool userInterface, const String &value)
 //     Supported = The command is supported by this object.
 //     Enabled =   The command is available and enabled.
 
-bool enabled(Frame *frame)
+bool enabled(Frame*)
 {
     return true;
 }
 
-bool enabledAnyCaret(Frame *frame)
+bool enabledAnyCaret(Frameframe)
 {
     return frame->selection().isCaret() && frame->selection().isContentEditable();
 }
 
-bool enabledAnySelection(Frame *frame)
+bool enabledAnySelection(Frameframe)
 {
     return frame->selection().isCaretOrRange();
 }
 
-bool enabledAnyEditableSelection(Frame *frame)
+bool enabledAnyEditableSelection(Frameframe)
 {
     return frame->selection().isCaretOrRange() && frame->selection().isContentEditable();
 }
 
-bool enabledAnyRichlyEditableSelection(Frame *frame)
+bool enabledAnyRichlyEditableSelection(Frameframe)
 {
     return frame->selection().isCaretOrRange() && frame->selection().isContentRichlyEditable();
 }
 
-bool enabledPaste(Frame *frame)
+bool enabledPaste(Frameframe)
 {
     return supportsPasteCommand && frame->canPaste();
 }
 
-bool enabledPasteAndMatchStyle(Frame *frame)
+bool enabledPasteAndMatchStyle(Frameframe)
 {
     return supportsPasteCommand && frame->canPaste();
 }
 
-bool enabledAnyRangeSelection(Frame *frame)
+bool enabledAnyRangeSelection(Frameframe)
 {
     return frame->selection().isRange();
 }
 
-bool enabledAnyEditableRangeSelection(Frame *frame)
+bool enabledAnyEditableRangeSelection(Frameframe)
 {
     return frame->selection().isRange() && frame->selection().isContentEditable();
 }
 
-bool enabledAnyRichlyEditableRangeSelection(Frame *frame)
+bool enabledAnyRichlyEditableRangeSelection(Frameframe)
 {
     return frame->selection().isRange() && frame->selection().isContentRichlyEditable();
 }
 
-bool enabledRedo(Frame *frame)
+bool enabledRedo(Frameframe)
 {
     return frame->canRedo();
 }
 
-bool enabledUndo(Frame *frame)
+bool enabledUndo(Frameframe)
 {
     return frame->canUndo();
 }
@@ -560,44 +558,44 @@ bool enabledUndo(Frame *frame)
 // Then, queryCommandIndeterm should return "no" in the case where
 // all the text is either all bold or not-bold and and "yes" for partially-bold text.
 
-Frame::TriState stateNone(Frame *frame)
+Frame::TriState stateNone(Frame*)
 {
     return Frame::falseTriState;
 }
 
-Frame::TriState stateBold(Frame *frame)
+Frame::TriState stateBold(Frameframe)
 {
-    return stateStyle(frame,  CSS_PROP_FONT_WEIGHT, "bold");
+    return stateStyle(frame, CSS_PROP_FONT_WEIGHT, "bold");
 }
 
-Frame::TriState stateItalic(Frame *frame)
+Frame::TriState stateItalic(Frameframe)
 {
-    return stateStyle(frame,  CSS_PROP_FONT_STYLE, "italic");
+    return stateStyle(frame, CSS_PROP_FONT_STYLE, "italic");
 }
 
-Frame::TriState stateList(Frame *frame)
+Frame::TriState stateList(Frameframe)
 {
     return frame->selectionListState();
 }
 
-Frame::TriState stateStrikethrough(Frame *frame)
+Frame::TriState stateStrikethrough(Frameframe)
 {
-    return stateStyle(frame,  CSS_PROP_TEXT_DECORATION, "line-through");
+    return stateStyle(frame, CSS_PROP_TEXT_DECORATION, "line-through");
 }
 
-Frame::TriState stateSubscript(Frame *frame)
+Frame::TriState stateSubscript(Frameframe)
 {
-    return stateStyle(frame,  CSS_PROP_VERTICAL_ALIGN, "sub");
+    return stateStyle(frame, CSS_PROP_VERTICAL_ALIGN, "sub");
 }
 
-Frame::TriState stateSuperscript(Frame *frame)
+Frame::TriState stateSuperscript(Frameframe)
 {
-    return stateStyle(frame,  CSS_PROP_VERTICAL_ALIGN, "super");
+    return stateStyle(frame, CSS_PROP_VERTICAL_ALIGN, "super");
 }
 
-Frame::TriState stateUnderline(Frame *frame)
+Frame::TriState stateUnderline(Frameframe)
 {
-    return stateStyle(frame,  CSS_PROP_TEXT_DECORATION, "underline");
+    return stateStyle(frame, CSS_PROP_TEXT_DECORATION, "underline");
 }
 
 // =============================================================================================
@@ -605,41 +603,41 @@ Frame::TriState stateUnderline(Frame *frame)
 // queryCommandValue implementations
 //
 
-String valueNull(Frame *frame)
+String valueNull(Frame*)
 {
     return String();
 }
 
-String valueBackColor(Frame *frame)
+String valueBackColor(Frameframe)
 {
-    return valueStyle(frame,  CSS_PROP_BACKGROUND_COLOR);
+    return valueStyle(frame, CSS_PROP_BACKGROUND_COLOR);
 }
 
-String valueFontName(Frame *frame)
+String valueFontName(Frameframe)
 {
-    return valueStyle(frame,  CSS_PROP_FONT_FAMILY);
+    return valueStyle(frame, CSS_PROP_FONT_FAMILY);
 }
 
-String valueFontSize(Frame *frame)
+String valueFontSize(Frameframe)
 {
-    return valueStyle(frame,  CSS_PROP_FONT_SIZE);
+    return valueStyle(frame, CSS_PROP_FONT_SIZE);
 }
 
-String valueFontSizeDelta(Frame *frame)
+String valueFontSizeDelta(Frameframe)
 {
-    return valueStyle(frame,  CSS_PROP__WEBKIT_FONT_SIZE_DELTA);
+    return valueStyle(frame, CSS_PROP__WEBKIT_FONT_SIZE_DELTA);
 }
 
-String valueForeColor(Frame *frame)
+String valueForeColor(Frameframe)
 {
-    return valueStyle(frame,  CSS_PROP_COLOR);
+    return valueStyle(frame, CSS_PROP_COLOR);
 }
 
 // =============================================================================================
 
-CommandMap *createCommandDictionary()
+CommandMapcreateCommandDictionary()
 {
-    struct EditorCommand { const char *name; CommandImp imp; };
+    struct EditorCommand { const charname; CommandImp imp; };
 
     static const EditorCommand commands[] = {
 
@@ -739,7 +737,7 @@ CommandMap *createCommandDictionary()
         // Unbookmark (not supported)
     };
 
-    CommandMap *commandMap = new CommandMap;
+    CommandMapcommandMap = new CommandMap;
 
     const int numCommands = sizeof(commands) / sizeof(commands[0]);
     for (int i = 0; i < numCommands; ++i) {
index 0ebf94c32056eef14f9b271f409ca77ed3423161..76e9eb8237297fdb798f7c769ce9e4d337a80848 100644 (file)
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
 
-#ifndef jsediting_h__
-#define jsediting_h__
+#ifndef JSEditor_h
+#define JSEditor_h
 
-#include "PlatformString.h"
+#include <wtf/Noncopyable.h>
 
 namespace WebCore {
 
-class DeprecatedString;
 class Document;
+class String;
 
-class JSEditor {
-
+class JSEditor : Noncopyable {
 public:
-    JSEditor(Document *doc) : m_doc(doc) { }
+    JSEditor(Document* document) : m_document(document) { }
 
-    bool execCommand(const String &command, bool userInterface, const String &value);
-    bool queryCommandEnabled(const String &command);
-    bool queryCommandIndeterm(const String &command);
-    bool queryCommandState(const String &command);
-    bool queryCommandSupported(const String &command);
-    String queryCommandValue(const String &command);
+    bool execCommand(const String& command, bool userInterface, const String& parameter);
+    bool queryCommandEnabled(const Stringcommand);
+    bool queryCommandIndeterm(const Stringcommand);
+    bool queryCommandState(const Stringcommand);
+    bool queryCommandSupported(const Stringcommand);
+    String queryCommandValue(const Stringcommand);
 
-    static void setSupportsPasteCommand(bool flag=true);
+    static void setSupportsPasteCommand(bool flag = true);
 
 private:
-    JSEditor(const JSEditor &);
-    JSEditor &operator=(const JSEditor &);
-
-    Document *m_doc;
+    Document* m_document;
 };
 
 } // end namespace WebCore
index 45e33639f2baca5b42472ea1e83a1b9e24e1dc9f..9d5104361f58ab2de7513a728ccab171b6748d55 100644 (file)
@@ -30,8 +30,8 @@
 
 namespace WebCore {
 
-JoinTextNodesCommand::JoinTextNodesCommand(Document *document, Text *text1, Text *text2)
-    : EditCommand(document), m_text1(text1), m_text2(text2)
+JoinTextNodesCommand::JoinTextNodesCommand(Text *text1, Text *text2)
+    : EditCommand(text1->document()), m_text1(text1), m_text2(text2)
 {
     ASSERT(m_text1);
     ASSERT(m_text2);
index b918a9f8c748f9404b07c573de75eaea5e7e3f56..80ca801189c70a7b4624fce65b541de88050086a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005 Apple Computer, Inc.  All rights reserved.
+ * Copyright (C) 2005, 2006 Apple Computer, Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
 
-#ifndef __join_text_nodes_command_h__
-#define __join_text_nodes_command_h__
+#ifndef join_text_nodes_command_h__
+#define join_text_nodes_command_h__
 
 #include "EditCommand.h"
 
 namespace WebCore {
-    class Text;
-}
 
-namespace WebCore {
+class Text;
 
 class JoinTextNodesCommand : public EditCommand
 {
 public:
-    JoinTextNodesCommand(Document *, Text *, Text *);
-    virtual ~JoinTextNodesCommand() { }
+    JoinTextNodesCommand(Text*, Text*);
 
     virtual void doApply();
     virtual void doUnapply();
 
-    Text *firstNode() const { return m_text1.get(); }
-    Text *secondNode() const { return m_text2.get(); }
+    TextfirstNode() const { return m_text1.get(); }
+    TextsecondNode() const { return m_text2.get(); }
 
 private:
     RefPtr<Text> m_text1;
@@ -54,4 +51,4 @@ private:
 
 } // namespace WebCore
 
-#endif // __join_text_nodes_command_h__
+#endif // join_text_nodes_command_h__
index 3aefa874daec03fbdae13495b5939193974cd65c..0b9b019811850123025b0e50f2dc0b1cdf6c1a25 100644 (file)
@@ -30,8 +30,8 @@
 
 namespace WebCore {
 
-MergeIdenticalElementsCommand::MergeIdenticalElementsCommand(Document *document, Element *first, Element *second)
-    : EditCommand(document), m_element1(first), m_element2(second)
+MergeIdenticalElementsCommand::MergeIdenticalElementsCommand(Element* first, Element* second)
+    : EditCommand(first->document()), m_element1(first), m_element2(second)
 {
     ASSERT(m_element1);
     ASSERT(m_element2);
index 415914ff43c2a5c4ee77845d67c461eb4b3a8686..7ada87463cbe5170d65163266e723edfb696a33b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005 Apple Computer, Inc.  All rights reserved.
+ * Copyright (C) 2005, 2006 Apple Computer, Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
 
-#ifndef __merge_identical_elements_command_h__
-#define __merge_identical_elements_command_h__
+#ifndef merge_identical_elements_command_h__
+#define merge_identical_elements_command_h__
 
 #include "EditCommand.h"
 
 namespace WebCore {
 
-class MergeIdenticalElementsCommand : public EditCommand
-{
+class MergeIdenticalElementsCommand : public EditCommand {
 public:
-    MergeIdenticalElementsCommand(Document *, Element *first, Element *second);
-    virtual ~MergeIdenticalElementsCommand() { }
+    MergeIdenticalElementsCommand(Element*, Element*);
 
     virtual void doApply();
     virtual void doUnapply();
@@ -47,4 +45,4 @@ private:
 
 } // namespace WebCore
 
-#endif // __merge_identical_elements_command_h__
+#endif // merge_identical_elements_command_h__
index 5fdbdd78fe1cdfc2fc8681dac7d479fd912b5330..68ec9128c33af811a1942f8921403f99652a4165 100644 (file)
@@ -46,7 +46,7 @@ bool ModifySelectionListLevelCommand::preservesTypingStyle() const
 }
 
 // This needs to be static so it can be called by canIncreaseSelectionListLevel and canDecreaseSelectionListLevel
-static bool getStartEndListChildren(const Selection& selection, Node** start, Node** end)
+static bool getStartEndListChildren(const Selection& selection, Node*& start, Node*& end)
 {
     if (selection.isNone())
         return false;
@@ -83,8 +83,8 @@ static bool getStartEndListChildren(const Selection& selection, Node** start, No
             endListChild = r->element();
     }
 
-    *start = startListChild;
-    *end = endListChild;
+    start = startListChild;
+    end = endListChild;
     return true;
 }
 
@@ -134,27 +134,21 @@ void ModifySelectionListLevelCommand::appendSiblingNodeRange(Node* startNode, No
     }
 }
 
-IncreaseSelectionListLevelCommand::IncreaseSelectionListLevelCommand(Document* document, EListType listType)
+IncreaseSelectionListLevelCommand::IncreaseSelectionListLevelCommand(Document* document, Type listType)
     : ModifySelectionListLevelCommand(document)
+    , m_listType(listType)
 {
-    m_listType = listType;
-    m_listElement = 0;
-}
-
-Node* IncreaseSelectionListLevelCommand::listElement()
-{
-    return m_listElement;
 }
 
 // This needs to be static so it can be called by canIncreaseSelectionListLevel
-static bool canIncreaseListLevel(const Selection& selection, Node** start, Node** end)
+static bool canIncreaseListLevel(const Selection& selection, Node*& start, Node*& end)
 {
     if (!getStartEndListChildren(selection, start, end))
         return false;
         
     // start must not be the first child (because you need a prior one
     // to increase relative to)
-    if (!(*start)->renderer()->previousSibling())
+    if (!start->renderer()->previousSibling())
         return false;
     
     return true;
@@ -178,7 +172,7 @@ void IncreaseSelectionListLevelCommand::doApply()
 {
     Node* startListChild;
     Node* endListChild;
-    if (!canIncreaseListLevel(endingSelection(), &startListChild, &endListChild))
+    if (!canIncreaseListLevel(endingSelection(), startListChild, endListChild))
         return;
 
     Node* previousItem = startListChild->renderer()->previousSibling()->element();
@@ -210,29 +204,30 @@ bool IncreaseSelectionListLevelCommand::canIncreaseSelectionListLevel(Document*
 {
     Node* startListChild;
     Node* endListChild;
-    
-    return canIncreaseListLevel(document->frame()->selection().selection(), &startListChild, &endListChild);
+    return canIncreaseListLevel(document->frame()->selection().selection(), startListChild, endListChild);
 }
 
-static Node* increaseSelectionListLevelWithType(Document* document, EListType listType)
+Node* IncreaseSelectionListLevelCommand::increaseSelectionListLevelWithType(Document* document, Type listType)
 {
     ASSERT(document);
     ASSERT(document->frame());
-    IncreaseSelectionListLevelCommand* modCommand = new IncreaseSelectionListLevelCommand(document, listType);
-    EditCommandPtr cmd(modCommand);
-    cmd.apply();
-    return modCommand->listElement();
+    RefPtr<IncreaseSelectionListLevelCommand> modCommand = new IncreaseSelectionListLevelCommand(document, listType);
+    modCommand->apply();
+    return modCommand->m_listElement.get();
 }
 
-Node* IncreaseSelectionListLevelCommand::increaseSelectionListLevel(Document* document) {
+Node* IncreaseSelectionListLevelCommand::increaseSelectionListLevel(Document* document)
+{
     return increaseSelectionListLevelWithType(document, InheritedListType);
 }
 
-Node* IncreaseSelectionListLevelCommand::increaseSelectionListLevelOrdered(Document* document) {
+Node* IncreaseSelectionListLevelCommand::increaseSelectionListLevelOrdered(Document* document)
+{
     return increaseSelectionListLevelWithType(document, OrderedList);
 }
 
-Node* IncreaseSelectionListLevelCommand::increaseSelectionListLevelUnordered(Document* document) {
+Node* IncreaseSelectionListLevelCommand::increaseSelectionListLevelUnordered(Document* document)
+{
     return increaseSelectionListLevelWithType(document, UnorderedList);
 }
 
@@ -242,13 +237,13 @@ DecreaseSelectionListLevelCommand::DecreaseSelectionListLevelCommand(Document* d
 }
 
 // This needs to be static so it can be called by canDecreaseSelectionListLevel
-static bool canDecreaseListLevel(const Selection& selection, Node** start, Node** end)
+static bool canDecreaseListLevel(const Selection& selection, Node*& start, Node*& end)
 {
     if (!getStartEndListChildren(selection, start, end))
         return false;
     
     // there must be a destination list to move the items to
-    if (!isListElement((*start)->parentNode()->parentNode()))
+    if (!isListElement(start->parentNode()->parentNode()))
         return false;
         
     return true;
@@ -258,7 +253,7 @@ void DecreaseSelectionListLevelCommand::doApply()
 {
     Node* startListChild;
     Node* endListChild;
-    if (!canDecreaseListLevel(endingSelection(), &startListChild, &endListChild))
+    if (!canDecreaseListLevel(endingSelection(), startListChild, endListChild))
         return;
 
     Node* previousItem = startListChild->renderer()->previousSibling() ? startListChild->renderer()->previousSibling()->element() : 0;
@@ -285,17 +280,14 @@ bool DecreaseSelectionListLevelCommand::canDecreaseSelectionListLevel(Document*
 {
     Node* startListChild;
     Node* endListChild;
-    
-    return canDecreaseListLevel(document->frame()->selection().selection(), &startListChild, &endListChild);
+    return canDecreaseListLevel(document->frame()->selection().selection(), startListChild, endListChild);
 }
 
 void DecreaseSelectionListLevelCommand::decreaseSelectionListLevel(Document* document)
 {
     ASSERT(document);
     ASSERT(document->frame());
-    DecreaseSelectionListLevelCommand* modCommand = new DecreaseSelectionListLevelCommand(document);
-    EditCommandPtr cmd(modCommand);
-    cmd.apply();
+    applyCommand(new DecreaseSelectionListLevelCommand(document));
 }
 
 }
index c52163895a1c3fc9694bb7d9ac7f23c2949537df..ae172863f646255ea7cc377f9d7e95dde1553feb 100644 (file)
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
 
-#ifndef __modify_selection_list_level_h__
-#define __modify_selection_list_level_h__
+#ifndef modify_selection_list_level_h__
+#define modify_selection_list_level_h__
 
 #include "CompositeEditCommand.h"
 
 namespace WebCore {
 
-// ModifySelectionListLevelCommand provides functions useful for both increasing and decreasing the list
-// level.  So, it is the base class of IncreaseSelectionListLevelCommand and DecreaseSelectionListLevelCommand.
+// ModifySelectionListLevelCommand provides functions useful for both increasing and decreasing the list level.
+// It is the base class of IncreaseSelectionListLevelCommand and DecreaseSelectionListLevelCommand.
 // It is not used on its own.
-class ModifySelectionListLevelCommand : public CompositeEditCommand
-{
-public:
-    ModifySelectionListLevelCommand(Document* document);
-    
-private:
-    virtual bool preservesTypingStyle() const;
-    
+class ModifySelectionListLevelCommand : public CompositeEditCommand {
 protected:
+    ModifySelectionListLevelCommand(Document*);
+    
     void appendSiblingNodeRange(Node* startNode, Node* endNode, Node* newParent);
     void insertSiblingNodeRangeBefore(Node* startNode, Node* endNode, Node* refNode);
     void insertSiblingNodeRangeAfter(Node* startNode, Node* endNode, Node* refNode);
-};
 
-// IncreaseSelectionListLevelCommand moves the selected list items one level deeper
-typedef enum EListType { InheritedListType, OrderedList, UnorderedList };
+private:
+    virtual bool preservesTypingStyle() const;    
+};
 
-class IncreaseSelectionListLevelCommand : public ModifySelectionListLevelCommand
-{
+// IncreaseSelectionListLevelCommand moves the selected list items one level deeper.
+class IncreaseSelectionListLevelCommand : public ModifySelectionListLevelCommand {
 public:
     static bool canIncreaseSelectionListLevel(Document*);
     static Node* increaseSelectionListLevel(Document*);
     static Node* increaseSelectionListLevelOrdered(Document*);
     static Node* increaseSelectionListLevelUnordered(Document*);
 
-    IncreaseSelectionListLevelCommand(Document* document, EListType);
-    Node*       listElement();
+private:
+    enum Type { InheritedListType, OrderedList, UnorderedList };
+    static Node* increaseSelectionListLevelWithType(Document*, Type listType);
+
+    IncreaseSelectionListLevelCommand(Document*, Type);
     virtual void doApply();
 
-private:
-    EListType   m_listType;
-    Node*       m_listElement;
+    Type m_listType;
+    RefPtr<Node> m_listElement;
 };
 
-// DecreaseSelectionListLevelCommand moves the selected list items one level shallower
-class DecreaseSelectionListLevelCommand : public ModifySelectionListLevelCommand
-{
+// DecreaseSelectionListLevelCommand moves the selected list items one level shallower.
+class DecreaseSelectionListLevelCommand : public ModifySelectionListLevelCommand {
 public:
     static bool canDecreaseSelectionListLevel(Document*);
     static void decreaseSelectionListLevel(Document*);
 
-    DecreaseSelectionListLevelCommand(Document* document);
-
+private:
+    DecreaseSelectionListLevelCommand(Document*);
     virtual void doApply();
 };
 
 } // namespace WebCore
 
-#endif // __modify_selection_list_level_h__
+#endif // modify_selection_list_level_h__
index 2b0ba925933766f644533c41f24800869420ec3b..e2809ed0a51c2ebf5ea010aeb6effe21a180c84a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005 Apple Computer, Inc.  All rights reserved.
+ * Copyright (C) 2005, 2006 Apple Computer, Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -31,8 +31,8 @@
 
 namespace WebCore {
 
-MoveSelectionCommand::MoveSelectionCommand(Document *document, DocumentFragment *fragment, Position &position, bool smartMove) 
-    : CompositeEditCommand(document), m_fragment(fragment), m_position(position), m_smartMove(smartMove)
+MoveSelectionCommand::MoveSelectionCommand(PassRefPtr<DocumentFragment> fragment, const Position& position, bool smartMove) 
+    : CompositeEditCommand(fragment->document()), m_fragment(fragment), m_position(position), m_smartMove(smartMove)
 {
     ASSERT(m_fragment);
 }
@@ -73,9 +73,8 @@ void MoveSelectionCommand::doApply()
     if (!pos.node()->inDocument())
         pos = endingSelection().start();
 
-    setEndingSelection(pos, endingSelection().affinity());
-    EditCommandPtr cmd(new ReplaceSelectionCommand(document(), m_fragment.get(), true, m_smartMove));
-    applyCommandToComposite(cmd);
+    setEndingSelection(Selection(pos, endingSelection().affinity()));
+    applyCommandToComposite(new ReplaceSelectionCommand(positionNode->document(), m_fragment.get(), true, m_smartMove));
 }
 
 EditAction MoveSelectionCommand::editingAction() const
index 44c0941d22e6ef8d6705f9e6f27eca9c793140e6..027a377a4969aac3e1a3a7aff04b7b2d8d5c599c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005 Apple Computer, Inc.  All rights reserved.
+ * Copyright (C) 2005, 2006 Apple Computer, Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -23,8 +23,8 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
 
-#ifndef __move_selection_command_h__
-#define __move_selection_command_h__
+#ifndef move_selection_command_h__
+#define move_selection_command_h__
 
 #include "CompositeEditCommand.h"
 
@@ -32,10 +32,9 @@ namespace WebCore {
 
 class DocumentFragment;
 
-class MoveSelectionCommand : public CompositeEditCommand
-{
+class MoveSelectionCommand : public CompositeEditCommand {
 public:
-    MoveSelectionCommand(Document *document, DocumentFragment *fragment, Position &position, bool smartMove=false);
+    MoveSelectionCommand(PassRefPtr<DocumentFragment>, const Position&, bool smartMove = false);
     virtual ~MoveSelectionCommand();
     
     virtual void doApply();
index 2f76465d7088c89238c62a322d2f904bdda31093..448f2ebdcf55115af2c904e300ec4905bfd281ea 100644 (file)
@@ -33,8 +33,8 @@
 
 namespace WebCore {
 
-RebalanceWhitespaceCommand::RebalanceWhitespaceCommand(Document *document, const Position &pos)
-    : EditCommand(document), m_position(pos), m_upstreamOffset(InvalidOffset)
+RebalanceWhitespaceCommand::RebalanceWhitespaceCommand(const Position& pos)
+    : EditCommand(pos.node()->document()), m_position(pos), m_upstreamOffset(InvalidOffset)
 {
 }
 
@@ -47,7 +47,7 @@ static inline bool isWhitespace(UChar c)
 // FIXME: This turns preserved newlines into nbsps.
 void RebalanceWhitespaceCommand::doApply()
 {
-    if (m_position.isNull() || !m_position.node()->isTextNode())
+    if (!m_position.node()->isTextNode())
         return;
 
     Text* textNode = static_cast<Text*>(m_position.node());
index ecc3ce193b00b7b3a04bb0487e15f3a29ff0a1b8..2a6808295c8589bd6293d44e983696fe374d5efe 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005 Apple Computer, Inc.  All rights reserved.
+ * Copyright (C) 2005, 2006 Apple Computer, Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 
 namespace WebCore {
 
-class RebalanceWhitespaceCommand : public EditCommand
-{
+class RebalanceWhitespaceCommand : public EditCommand {
 public:
-    RebalanceWhitespaceCommand(Document *, const Position &);
-    virtual ~RebalanceWhitespaceCommand() { }
+    RebalanceWhitespaceCommand(const Position&);
 
     virtual void doApply();
     virtual void doUnapply();
@@ -53,4 +51,4 @@ private:
 
 } // namespace WebCore
 
-#endif // __rebalance_whitespace_command_h__
+#endif // rebalance_whitespace_command_h__
index 27e6bb259056c473a0dafa9c38aaf51143e73787..4082da378a2628227810f9764b3a495864494e67 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005 Apple Computer, Inc.  All rights reserved.
+ * Copyright (C) 2005, 2006 Apple Computer, Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -32,8 +32,7 @@ namespace WebCore {
 
 class CSSStyleDeclaration;
 
-class RemoveCSSPropertyCommand : public EditCommand
-{
+class RemoveCSSPropertyCommand : public EditCommand {
 public:
     RemoveCSSPropertyCommand(Document*, CSSStyleDeclaration*, int property);
     virtual ~RemoveCSSPropertyCommand();
index af7a72fd96eb0feda6dabcde3a0e5ba05e95fda0..ab3d4bd5f85e5a3419b11b8fa9bb5959ab3aef98 100644 (file)
@@ -31,8 +31,8 @@
 
 namespace WebCore {
 
-RemoveNodeAttributeCommand::RemoveNodeAttributeCommand(Document *document, Element *element, const QualifiedName& attribute)
-    : EditCommand(document), m_element(element), m_attribute(attribute)
+RemoveNodeAttributeCommand::RemoveNodeAttributeCommand(Element* element, const QualifiedName& attribute)
+    : EditCommand(element->document()), m_element(element), m_attribute(attribute)
 {
     ASSERT(m_element);
 }
index 3cd4cf1d913a91252fc049756c4c08ae37c97228..2a1df522d0f7c8861b60a986166729695888f5ad 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005 Apple Computer, Inc.  All rights reserved.
+ * Copyright (C) 2005, 2006 Apple Computer, Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
 
-#ifndef __remove_node_attribute_command_h__
-#define __remove_node_attribute_command_h__
+#ifndef remove_node_attribute_command_h__
+#define remove_node_attribute_command_h__
 
 #include "EditCommand.h"
-
 #include "QualifiedName.h"
 
 namespace WebCore {
 
-class RemoveNodeAttributeCommand : public EditCommand
-{
+class RemoveNodeAttributeCommand : public EditCommand {
 public:
-    RemoveNodeAttributeCommand(Document *, Element *, const QualifiedName& attribute);
-    virtual ~RemoveNodeAttributeCommand() { }
+    RemoveNodeAttributeCommand(Element*, const QualifiedName& attribute);
 
     virtual void doApply();
     virtual void doUnapply();
 
-    Element *element() const { return m_element.get(); }
+    Elementelement() const { return m_element.get(); }
     const QualifiedName& attribute() const { return m_attribute; }
     
 private:
@@ -52,4 +49,4 @@ private:
 
 } // namespace WebCore
 
-#endif // __remove_node_attribute_command_h__
+#endif // remove_node_attribute_command_h__
index 53f08aa2afe58f6a2e851d8891db741bb5b388af..6daedd53ed5d7a84bdb6411526203164cc464eda 100644 (file)
 
 namespace WebCore {
 
-RemoveNodeCommand::RemoveNodeCommand(Document *document, Node *removeChild)
-    : EditCommand(document), m_removeChild(removeChild), m_parent(m_removeChild->parentNode()), m_refChild(m_removeChild->nextSibling())
+RemoveNodeCommand::RemoveNodeCommand(Node* removeChild)
+    : EditCommand(removeChild->document())
+    , m_removeChild(removeChild)
+    , m_parent(m_removeChild->parentNode())
+    , m_refChild(m_removeChild->nextSibling())
 {
     ASSERT(m_parent);
 }
index 2657fa8bdfb1573cf01ca2eb1443c599eb8fee68..eec71fab4593c77e49824f6b74c352e7106dbda5 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005 Apple Computer, Inc.  All rights reserved.
+ * Copyright (C) 2005, 2006 Apple Computer, Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
 
-#ifndef __remove_node_command_h__
-#define __remove_node_command_h__
+#ifndef remove_node_command_h__
+#define remove_node_command_h__
 
 #include "EditCommand.h"
 
 namespace WebCore {
 
-class RemoveNodeCommand : public EditCommand
-{
+class RemoveNodeCommand : public EditCommand {
 public:
-    RemoveNodeCommand(Document *, Node *);
-    virtual ~RemoveNodeCommand() { }
+    RemoveNodeCommand(Node*);
 
     virtual void doApply();
     virtual void doUnapply();
 
-    Node *node() const { return m_removeChild.get(); }
+    Nodenode() const { return m_removeChild.get(); }
 
 private:
     RefPtr<Node> m_removeChild;
@@ -49,4 +47,4 @@ private:
 
 } // namespace WebCore
 
-#endif // __remove_node_command_h__
+#endif // remove_node_command_h__
index 10d1d6950c48b94a882d7f66be16d1a5f85e770b..6695a019bb9ea460e1db2f0c19549e5bd80a10b1 100644 (file)
@@ -31,8 +31,8 @@
 
 namespace WebCore {
 
-RemoveNodePreservingChildrenCommand::RemoveNodePreservingChildrenCommand(Document *document, Node *node)
-    : CompositeEditCommand(document), m_node(node)
+RemoveNodePreservingChildrenCommand::RemoveNodePreservingChildrenCommand(Node* node)
+    : CompositeEditCommand(node->document()), m_node(node)
 {
     ASSERT(m_node);
 }
index 8bc383b89dec1eef0308a81ceaffccbfc643b16e..c1deec4314fcda2914a0545fe67b37f39e98a44a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005 Apple Computer, Inc.  All rights reserved.
+ * Copyright (C) 2005, 2006 Apple Computer, Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
 
-#ifndef __remove_node_preserving_children_command_h__
-#define __remove_node_preserving_children_command_h__
+#ifndef remove_node_preserving_children_command_h__
+#define remove_node_preserving_children_command_h__
 
 #include "CompositeEditCommand.h"
 
 namespace WebCore {
 
-class RemoveNodePreservingChildrenCommand : public CompositeEditCommand
-{
+class RemoveNodePreservingChildrenCommand : public CompositeEditCommand {
 public:
-    RemoveNodePreservingChildrenCommand(Document *, Node *);
-    virtual ~RemoveNodePreservingChildrenCommand() { }
+    RemoveNodePreservingChildrenCommand(Node*);
 
     virtual void doApply();
 
-    Node *node() const { return m_node.get(); }
+    Nodenode() const { return m_node.get(); }
 
 private:
     RefPtr<Node> m_node;
@@ -46,4 +44,4 @@ private:
 
 } // namespace WebCore
 
-#endif // __remove_node_preserving_children_command_h__
+#endif // remove_node_preserving_children_command_h__
index 16f141a3192d4880a7e2c8c285cb2baae9b7c3ab..2f154bd224ce5cae0746b15d310497017008d777 100644 (file)
@@ -255,7 +255,9 @@ void ReplacementFragment::removeUnrenderedNodes(Node *holder)
         removeNode(it.current());
 }
 
-ReplaceSelectionCommand::ReplaceSelectionCommand(Document* document, DocumentFragment* fragment, bool selectReplacement, bool smartReplace, bool matchStyle, bool preventNesting, EditAction editAction) 
+ReplaceSelectionCommand::ReplaceSelectionCommand(Document* document, PassRefPtr<DocumentFragment> fragment,
+        bool selectReplacement, bool smartReplace, bool matchStyle, bool preventNesting,
+        EditAction editAction) 
     : CompositeEditCommand(document),
       m_selectReplacement(selectReplacement), 
       m_smartReplace(smartReplace),
@@ -710,7 +712,7 @@ void ReplaceSelectionCommand::completeHTMLReplacement(const Position &lastPositi
     if (m_selectReplacement)
         setEndingSelection(Selection(start, end, SEL_DEFAULT_AFFINITY));
     else
-        setEndingSelection(end, SEL_DEFAULT_AFFINITY);
+        setEndingSelection(Selection(end, SEL_DEFAULT_AFFINITY));
 }
 
 EditAction ReplaceSelectionCommand::editingAction() const
index b5fa7a4d0164782af0b65011a612d2038f2e1458..2f9ef9fafa27f70e4e0ef77c6a2deeb768a6b8a8 100644 (file)
@@ -38,8 +38,7 @@ enum EFragmentType { EmptyFragment, SingleTextNodeFragment, TreeFragment };
 
 // --- ReplacementFragment helper class
 
-class ReplacementFragment : Noncopyable
-{
+class ReplacementFragment : Noncopyable {
 public:
     ReplacementFragment(Document*, DocumentFragment*, bool matchStyle, const Selection&);
 
@@ -68,20 +67,21 @@ private:
     bool m_hasInterchangeNewlineAtEnd;
 };
 
-class ReplaceSelectionCommand : public CompositeEditCommand
-{
+class ReplaceSelectionCommand : public CompositeEditCommand {
 public:
-    ReplaceSelectionCommand(Document*, DocumentFragment*, bool selectReplacement=true, bool smartReplace=false, bool matchStyle=false, bool preventNesting=true, EditAction action=EditActionPaste);
+    ReplaceSelectionCommand(Document*, PassRefPtr<DocumentFragment>,
+        bool selectReplacement = true, bool smartReplace = false, bool matchStyle = false, bool preventNesting = true,
+        EditAction = EditActionPaste);
     
     virtual void doApply();
     virtual EditAction editingAction() const;
 
 private:
-    void completeHTMLReplacement(const Position &lastPositionToSelect);
+    void completeHTMLReplacement(const PositionlastPositionToSelect);
 
-    void insertNodeAfterAndUpdateNodesInserted(Node *insertChild, Node *refChild);
-    void insertNodeAtAndUpdateNodesInserted(Node *insertChild, Node *refChild, int offset);
-    void insertNodeBeforeAndUpdateNodesInserted(Node *insertChild, Node *refChild);
+    void insertNodeAfterAndUpdateNodesInserted(Node* insertChild, Node* refChild);
+    void insertNodeAtAndUpdateNodesInserted(Node* insertChild, Node* refChild, int offset);
+    void insertNodeBeforeAndUpdateNodesInserted(Node* insertChild, Node* refChild);
 
     void updateNodesInserted(Node*);
     bool shouldRemoveEndBR(Node*);
@@ -105,4 +105,4 @@ private:
 
 } // namespace WebCore
 
-#endif // __replace_selection_command_h__
+#endif // replace_selection_command_h__
index fc401444af70d56a69e64a3e55f489f7ddbd6976..1dd3a079d6241016b51933a2673e76388e564ae1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2004 Apple Computer, Inc.  All rights reserved.
+ * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -44,32 +44,47 @@ Selection::Selection()
 {
 }
 
-Selection::Selection(const Position &pos, EAffinity affinity)
-    : m_base(pos), m_extent(pos)
+Selection::Selection(const Position& pos, EAffinity affinity)
+    : m_base(pos)
+    , m_extent(pos)
     , m_affinity(affinity)
     , m_granularity(CharacterGranularity)
-    , m_state(NONE)
-    , m_baseIsFirst(true)
 {
     validate();
 }
 
-Selection::Selection(const Position &base, const Position &extent, EAffinity affinity)
-    : m_base(base), m_extent(extent)
+Selection::Selection(const Position& base, const Position& extent, EAffinity affinity)
+    : m_base(base)
+    , m_extent(extent)
     , m_affinity(affinity)
     , m_granularity(CharacterGranularity)
-    , m_state(NONE)
-    , m_baseIsFirst(true)
 {
     validate();
 }
 
-Selection::Selection(const Range *range, EAffinity affinity)
-    : m_base(range->startPosition()), m_extent(range->endPosition())
+Selection::Selection(const VisiblePosition& pos)
+    : m_base(pos.deepEquivalent())
+    , m_extent(pos.deepEquivalent())
+    , m_affinity(pos.affinity())
+    , m_granularity(CharacterGranularity)
+{
+    validate();
+}
+
+Selection::Selection(const VisiblePosition& base, const VisiblePosition& extent)
+    : m_base(base.deepEquivalent())
+    , m_extent(extent.deepEquivalent())
+    , m_affinity(base.affinity())
+    , m_granularity(CharacterGranularity)
+{
+    validate();
+}
+
+Selection::Selection(const Range* range, EAffinity affinity)
+    : m_base(range->startPosition())
+    , m_extent(range->endPosition())
     , m_affinity(affinity)
     , m_granularity(CharacterGranularity)
-    , m_state(NONE)
-    , m_baseIsFirst(true)
 {
     validate();
 }
@@ -299,9 +314,9 @@ void Selection::adjustForEditableContent()
     if (m_base.isNull() || m_start.isNull() || m_end.isNull())
         return;
 
-    Node *baseRoot = m_base.node()->rootEditableElement();
-    Node *startRoot = m_start.node()->rootEditableElement();
-    Node *endRoot = m_end.node()->rootEditableElement();
+    NodebaseRoot = m_base.node()->rootEditableElement();
+    NodestartRoot = m_start.node()->rootEditableElement();
+    NodeendRoot = m_end.node()->rootEditableElement();
     
     Node* baseEditableAncestor = lowestEditableAncestor(m_base.node());
     
index ebd310b0acabb3a8313abc6da17d987be0622b0c..ae0098ca5bab361f1a3093cd7637bc2f0cd82b7d 100644 (file)
 #ifndef Selection_h
 #define Selection_h
 
-#include "Position.h"
-#include "VisiblePosition.h"
 #include "TextGranularity.h"
+#include "VisiblePosition.h"
 
 namespace WebCore {
 
 class Position;
 
-class Selection
-{
+const EAffinity SEL_DEFAULT_AFFINITY = DOWNSTREAM;
+
+class Selection {
 public:
     enum EState { NONE, CARET, RANGE };
     enum EDirection { FORWARD, BACKWARD, RIGHT, LEFT };
-#define SEL_DEFAULT_AFFINITY DOWNSTREAM
 
     Selection();
-    Selection(const Position &, EAffinity);
-    Selection(const Position &, const Position &, EAffinity);
-    Selection(const Range *, EAffinity = DOWNSTREAM);
+
+    Selection(const Position&, EAffinity);
+    Selection(const Position&, const Position&, EAffinity);
+
+    Selection(const Range*, EAffinity = SEL_DEFAULT_AFFINITY);
     
+    Selection(const VisiblePosition&);
+    Selection(const VisiblePosition&, const VisiblePosition&);
+
     static Selection selectionFromContentsOfNode(Node*);
 
     EState state() const { return m_state; }
@@ -53,8 +57,8 @@ public:
     void setAffinity(EAffinity affinity) { m_affinity = affinity; }
     EAffinity affinity() const { return m_affinity; }
 
-    void setBase(Position base) { m_base = base; }
-    void setExtent(Position extent) { m_extent = extent; }
+    void setBase(const Position& base) { m_base = base; }
+    void setExtent(const Position& extent) { m_extent = extent; }
     Position base() const { return m_base; }
     Position extent() const { return m_extent; }
     Position start() const { return m_start; }
@@ -103,12 +107,12 @@ private:
     bool m_baseIsFirst;               // true if base is before the extent
 };
 
-inline bool operator==(const Selection &a, const Selection &b)
+inline bool operator==(const Selection& a, const Selection& b)
 {
     return a.start() == b.start() && a.end() == b.end() && a.affinity() == b.affinity() && a.granularity() == b.granularity();
 }
 
-inline bool operator!=(const Selection &a, const Selection &b)
+inline bool operator!=(const Selection& a, const Selection& b)
 {
     return !(a == b);
 }
index 59b25aaccc6cdf775bc97320b01190032c7c167a..faa8e5d04f4edf3972707b32761700f8cec9ba34 100644 (file)
@@ -31,9 +31,9 @@
 
 namespace WebCore {
 
-SetNodeAttributeCommand::SetNodeAttributeCommand(Document *document, Element *element, 
+SetNodeAttributeCommand::SetNodeAttributeCommand(Element* element, 
                                                  const QualifiedName& attribute, const String &value)
-    : EditCommand(document), m_element(element), m_attribute(attribute), m_value(value)
+    : EditCommand(element->document()), m_element(element), m_attribute(attribute), m_value(value)
 {
     ASSERT(m_element);
     ASSERT(!m_value.isNull());
index a3486bdc0fdd03203b75f54c3009d35fc1acdb25..b9b8e93f992a0288c1e30275a630097dd3558d44 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005 Apple Computer, Inc.  All rights reserved.
+ * Copyright (C) 2005, 2006 Apple Computer, Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
 
-#ifndef __set_node_attribute_command_h__
-#define __set_node_attribute_command_h__
+#ifndef set_node_attribute_command_h__
+#define set_node_attribute_command_h__
 
 #include "EditCommand.h"
-
 #include "QualifiedName.h"
 
 namespace WebCore {
 
-class SetNodeAttributeCommand : public EditCommand
-{
+class SetNodeAttributeCommand : public EditCommand {
 public:
-    SetNodeAttributeCommand(Document *, Element *, const QualifiedName& attribute, const String &value);
-    virtual ~SetNodeAttributeCommand() { }
+    SetNodeAttributeCommand(Element*, const QualifiedName& attribute, const String &value);
 
     virtual void doApply();
     virtual void doUnapply();
 
-    Element *element() const { return m_element.get(); }
+    Elementelement() const { return m_element.get(); }
     const QualifiedName& attribute() const { return m_attribute; }
     String value() const { return m_value; }
     
@@ -54,4 +51,4 @@ private:
 
 } // namespace WebCore
 
-#endif // __set_node_attribute_command_h__
+#endif // set_node_attribute_command_h__
index 4c983346569169d753fbdac5a4228d66b1cf859e..f6060c74e642a006f679c1421f34fec8f2230842 100644 (file)
@@ -31,8 +31,8 @@
 
 namespace WebCore {
 
-SplitElementCommand::SplitElementCommand(Document *document, Element *element, Node *atChild)
-    : EditCommand(document), m_element2(element), m_atChild(atChild)
+SplitElementCommand::SplitElementCommand(Element* element, Node* atChild)
+    : EditCommand(element->document()), m_element2(element), m_atChild(atChild)
 {
     ASSERT(m_element2);
     ASSERT(m_atChild);
index a3a70fb36f0510ec18f0985056db2ecd0b18236a..d6a925f7375651b876ec788123e3255b533003ba 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005 Apple Computer, Inc.  All rights reserved.
+ * Copyright (C) 2005, 2006 Apple Computer, Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
 
-#ifndef __split_element_command_h__
-#define __split_element_command_h__
+#ifndef split_element_command_h__
+#define split_element_command_h__
 
 #include "EditCommand.h"
 
 namespace WebCore {
 
-class SplitElementCommand : public EditCommand
-{
+class SplitElementCommand : public EditCommand {
 public:
-    SplitElementCommand(Document *, Element *element, Node *atChild);
-    virtual ~SplitElementCommand() { }
+    SplitElementCommand(Element*, Node* splitPointChild);
 
     virtual void doApply();
     virtual void doUnapply();
@@ -47,4 +45,4 @@ private:
 
 } // namespace WebCore
 
-#endif // __split_element_command_h__
+#endif // split_element_command_h__
index fb642156ef56ac1ab693b5771edab881ecf994e7..157e2ba5bdf20257aba20c76c12f31aa670712ab 100644 (file)
@@ -33,8 +33,8 @@
 
 namespace WebCore {
 
-SplitTextNodeCommand::SplitTextNodeCommand(Document *document, Text *text, int offset)
-    : EditCommand(document), m_text2(text), m_offset(offset)
+SplitTextNodeCommand::SplitTextNodeCommand(Text* text, int offset)
+    : EditCommand(text->document()), m_text2(text), m_offset(offset)
 {
     ASSERT(m_text2);
     ASSERT(m_text2->length() > 0);
index 422ec2bfa1102f4cc4c1294307b96a54fd1893e2..d0d2916708731dc22b0bf9a44143bb51d3756e3b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005 Apple Computer, Inc.  All rights reserved.
+ * Copyright (C) 2005, 2006 Apple Computer, Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
 
-#ifndef __split_text_node_command_h__
-#define __split_text_node_command_h__
+#ifndef split_text_node_command_h__
+#define split_text_node_command_h__
 
 #include "EditCommand.h"
 
 namespace WebCore {
-    class Text;
-}
 
-namespace WebCore {
+class Text;
 
-class SplitTextNodeCommand : public EditCommand
-{
+class SplitTextNodeCommand : public EditCommand {
 public:
-    SplitTextNodeCommand(Document *, Text *, int);
+    SplitTextNodeCommand(Text*, int offset);
     virtual ~SplitTextNodeCommand() { }
 
     virtual void doApply();
     virtual void doUnapply();
 
-    Text *node() const { return m_text2.get(); }
+    Textnode() const { return m_text2.get(); }
     int offset() const { return m_offset; }
 
 private:
@@ -54,4 +51,4 @@ private:
 
 } // namespace WebCore
 
-#endif // __split_text_node_command_h__
+#endif // split_text_node_command_h__
index fe0f4db53fd098f2ef7f7193951e6fba23b92b08..eb1b3e1a028e076ef4b285e4ba27f4860e2d2098 100644 (file)
@@ -33,8 +33,8 @@
 
 namespace WebCore {
 
-SplitTextNodeContainingElementCommand::SplitTextNodeContainingElementCommand(Document *document, Text *text, int offset)
-    : CompositeEditCommand(document), m_text(text), m_offset(offset)
+SplitTextNodeContainingElementCommand::SplitTextNodeContainingElementCommand(Text* text, int offset)
+    : CompositeEditCommand(text->document()), m_text(text), m_offset(offset)
 {
     ASSERT(m_text);
     ASSERT(m_text->length() > 0);
index 3d72f87dfa4411a21d63ba51bc424944caec1d17..08d3983dbe86f085fb91cda05296717c0e368254 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005 Apple Computer, Inc.  All rights reserved.
+ * Copyright (C) 2005, 2006 Apple Computer, Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
 
-#ifndef __split_text_node_containing_element_command_h__
-#define __split_text_node_containing_element_command_h__
+#ifndef split_text_node_containing_element_command_h__
+#define split_text_node_containing_element_command_h__
 
 #include "CompositeEditCommand.h"
 
 namespace WebCore {
 
-class SplitTextNodeContainingElementCommand : public CompositeEditCommand
-{
+class SplitTextNodeContainingElementCommand : public CompositeEditCommand {
 public:
-    SplitTextNodeContainingElementCommand(Document *, Text *, int);
-    virtual ~SplitTextNodeContainingElementCommand() { }
+    SplitTextNodeContainingElementCommand(Text*, int offset);
 
     virtual void doApply();
 
@@ -45,4 +43,4 @@ private:
 
 } // namespace WebCore
 
-#endif // __split_text_node_containing_element_command_h__
+#endif // split_text_node_containing_element_command_h__
index efead0f5f4a1a54544cf6d5cb5a2bb24bd87728a..ee6d0d4b81450684cffd3c7ccb10a89ccd7eedae 100644 (file)
@@ -61,16 +61,15 @@ void TypingCommand::deleteKeyPressed(Document *document, bool smartDelete, TextG
     Frame *frame = document->frame();
     ASSERT(frame);
     
-    EditCommandPtr lastEditCommand = frame->lastEditCommand();
+    EditCommand* lastEditCommand = frame->lastEditCommand();
     if (isOpenForMoreTypingCommand(lastEditCommand)) {
-        static_cast<TypingCommand *>(lastEditCommand.get())->deleteKeyPressed(granularity);
+        static_cast<TypingCommand*>(lastEditCommand)->deleteKeyPressed(granularity);
         return;
     }
     
-    TypingCommand *typingCommand = new TypingCommand(document, DeleteKey, "", false, granularity);
+    RefPtr<TypingCommand> typingCommand = new TypingCommand(document, DeleteKey, "", false, granularity);
     typingCommand->setSmartDelete(smartDelete);
-    EditCommandPtr cmd(typingCommand);
-    cmd.apply();
+    typingCommand->apply();
 }
 
 void TypingCommand::forwardDeleteKeyPressed(Document *document, bool smartDelete, TextGranularity granularity)
@@ -80,16 +79,15 @@ void TypingCommand::forwardDeleteKeyPressed(Document *document, bool smartDelete
     Frame *frame = document->frame();
     ASSERT(frame);
     
-    EditCommandPtr lastEditCommand = frame->lastEditCommand();
+    EditCommand* lastEditCommand = frame->lastEditCommand();
     if (isOpenForMoreTypingCommand(lastEditCommand)) {
-        static_cast<TypingCommand *>(lastEditCommand.get())->forwardDeleteKeyPressed(granularity);
+        static_cast<TypingCommand*>(lastEditCommand)->forwardDeleteKeyPressed(granularity);
         return;
     }
 
-    TypingCommand *typingCommand = new TypingCommand(document, ForwardDeleteKey, "", false, granularity);
+    RefPtr<TypingCommand> typingCommand = new TypingCommand(document, ForwardDeleteKey, "", false, granularity);
     typingCommand->setSmartDelete(smartDelete);
-    EditCommandPtr cmd(typingCommand);
-    cmd.apply();
+    typingCommand->apply();
 }
 
 void TypingCommand::insertText(Document *document, const String &text, bool selectInsertedText)
@@ -113,14 +111,13 @@ void TypingCommand::insertText(Document *document, const String &text, bool sele
     if (newText.isEmpty())
         return;
     
-    EditCommandPtr lastEditCommand = frame->lastEditCommand();
+    EditCommand* lastEditCommand = frame->lastEditCommand();
     if (isOpenForMoreTypingCommand(lastEditCommand)) {
-        static_cast<TypingCommand *>(lastEditCommand.get())->insertText(newText, selectInsertedText);
+        static_cast<TypingCommand*>(lastEditCommand)->insertText(newText, selectInsertedText);
         return;
     }
 
-    EditCommandPtr cmd(new TypingCommand(document, InsertText, newText, selectInsertedText));
-    cmd.apply();
+    applyCommand(new TypingCommand(document, InsertText, newText, selectInsertedText));
 }
 
 void TypingCommand::insertLineBreak(Document *document)
@@ -130,14 +127,13 @@ void TypingCommand::insertLineBreak(Document *document)
     Frame *frame = document->frame();
     ASSERT(frame);
     
-    EditCommandPtr lastEditCommand = frame->lastEditCommand();
+    EditCommand* lastEditCommand = frame->lastEditCommand();
     if (isOpenForMoreTypingCommand(lastEditCommand)) {
-        static_cast<TypingCommand *>(lastEditCommand.get())->insertLineBreak();
+        static_cast<TypingCommand*>(lastEditCommand)->insertLineBreak();
         return;
     }
 
-    EditCommandPtr cmd(new TypingCommand(document, InsertLineBreak));
-    cmd.apply();
+    applyCommand(new TypingCommand(document, InsertLineBreak));
 }
 
 void TypingCommand::insertParagraphSeparatorInQuotedContent(Document *document)
@@ -147,14 +143,13 @@ void TypingCommand::insertParagraphSeparatorInQuotedContent(Document *document)
     Frame *frame = document->frame();
     ASSERT(frame);
     
-    EditCommandPtr lastEditCommand = frame->lastEditCommand();
+    EditCommand* lastEditCommand = frame->lastEditCommand();
     if (isOpenForMoreTypingCommand(lastEditCommand)) {
-        static_cast<TypingCommand *>(lastEditCommand.get())->insertParagraphSeparatorInQuotedContent();
+        static_cast<TypingCommand*>(lastEditCommand)->insertParagraphSeparatorInQuotedContent();
         return;
     }
 
-    EditCommandPtr cmd(new TypingCommand(document, InsertParagraphSeparatorInQuotedContent));
-    cmd.apply();
+    applyCommand(new TypingCommand(document, InsertParagraphSeparatorInQuotedContent));
 }
 
 void TypingCommand::insertParagraphSeparator(Document *document)
@@ -164,26 +159,24 @@ void TypingCommand::insertParagraphSeparator(Document *document)
     Frame *frame = document->frame();
     ASSERT(frame);
     
-    EditCommandPtr lastEditCommand = frame->lastEditCommand();
+    EditCommand* lastEditCommand = frame->lastEditCommand();
     if (isOpenForMoreTypingCommand(lastEditCommand)) {
-        static_cast<TypingCommand *>(lastEditCommand.get())->insertParagraphSeparator();
+        static_cast<TypingCommand*>(lastEditCommand)->insertParagraphSeparator();
         return;
     }
 
-    EditCommandPtr cmd(new TypingCommand(document, InsertParagraphSeparator));
-    cmd.apply();
+    applyCommand(new TypingCommand(document, InsertParagraphSeparator));
 }
 
-bool TypingCommand::isOpenForMoreTypingCommand(const EditCommandPtr &cmd)
+bool TypingCommand::isOpenForMoreTypingCommand(const EditCommandcmd)
 {
-    return cmd.isTypingCommand() &&
-        static_cast<const TypingCommand *>(cmd.get())->openForMoreTyping();
+    return cmd && cmd->isTypingCommand() && static_cast<const TypingCommand*>(cmd)->isOpenForMoreTyping();
 }
 
-void TypingCommand::closeTyping(const EditCommandPtr &cmd)
+void TypingCommand::closeTyping(EditCommand* cmd)
 {
     if (isOpenForMoreTypingCommand(cmd))
-        static_cast<TypingCommand *>(cmd.get())->closeTyping();
+        static_cast<TypingCommand*>(cmd)->closeTyping();
 }
 
 void TypingCommand::doApply()
@@ -243,10 +236,8 @@ void TypingCommand::typingAddedToOpenCommand()
     // The frame will get told in the same way as all other commands.
     // But since this command stays open and is used for additional typing, 
     // we need to tell the frame here as other commands are added.
-    if (m_applyEditing) {
-        EditCommandPtr cmd(this);
-        document()->frame()->appliedEditing(cmd);
-    }
+    if (m_applyEditing)
+        document()->frame()->appliedEditing(this);
     m_applyEditing = true;
 }
 
@@ -277,46 +268,35 @@ void TypingCommand::insertText(const String &text, bool selectInsertedText)
 
 void TypingCommand::insertTextRunWithoutNewlines(const String &text, bool selectInsertedText)
 {
-    // FIXME: Improve typing style.
-    // See this bug: <rdar://problem/3769899> Implementation of typing style needs improvement
-    if (document()->frame()->typingStyle() || m_cmds.count() == 0) {
-        InsertTextCommand *impl = new InsertTextCommand(document());
-        EditCommandPtr cmd(impl);
-        applyCommandToComposite(cmd);
-        impl->input(text, selectInsertedText);
-    } else {
-        EditCommandPtr lastCommand = m_cmds.last();
-        if (lastCommand.isInsertTextCommand()) {
-            InsertTextCommand *impl = static_cast<InsertTextCommand *>(lastCommand.get());
-            impl->input(text, selectInsertedText);
-        } else {
-            InsertTextCommand *impl = new InsertTextCommand(document());
-            EditCommandPtr cmd(impl);
-            applyCommandToComposite(cmd);
-            impl->input(text, selectInsertedText);
-        }
+    RefPtr<InsertTextCommand> command;
+    if (!document()->frame()->typingStyle() && !m_commands.isEmpty()) {
+        EditCommand* lastCommand = m_commands.last().get();
+        if (lastCommand->isInsertTextCommand())
+            command = static_cast<InsertTextCommand*>(lastCommand);
+    }
+    if (!command) {
+        command = new InsertTextCommand(document());
+        applyCommandToComposite(command);
     }
+    command->input(text, selectInsertedText);
     typingAddedToOpenCommand();
 }
 
 void TypingCommand::insertLineBreak()
 {
-    EditCommandPtr cmd(new InsertLineBreakCommand(document()));
-    applyCommandToComposite(cmd);
+    applyCommandToComposite(new InsertLineBreakCommand(document()));
     typingAddedToOpenCommand();
 }
 
 void TypingCommand::insertParagraphSeparator()
 {
-    EditCommandPtr cmd(new InsertParagraphSeparatorCommand(document()));
-    applyCommandToComposite(cmd);
+    applyCommandToComposite(new InsertParagraphSeparatorCommand(document()));
     typingAddedToOpenCommand();
 }
 
 void TypingCommand::insertParagraphSeparatorInQuotedContent()
 {
-    EditCommandPtr cmd(new BreakBlockquoteCommand(document()));
-    applyCommandToComposite(cmd);
+    applyCommandToComposite(new BreakBlockquoteCommand(document()));
     typingAddedToOpenCommand();
 }
 
index a34fe7d19e34f7ba0db0238d8666e11bc5294d82..37c8ad0f72fc29e23c92054f9f03d636e1241be7 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005 Apple Computer, Inc.  All rights reserved.
+ * Copyright (C) 2005, 2006 Apple Computer, Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -41,21 +41,21 @@ public:
         InsertParagraphSeparatorInQuotedContent
     };
 
-    TypingCommand(Document *document, ETypingCommand, const String &text = "", bool selectInsertedText = false, TextGranularity granularity = CharacterGranularity);
+    TypingCommand(Document*, ETypingCommand, const String& text = "", bool selectInsertedText = false, TextGranularity = CharacterGranularity);
 
-    static void deleteKeyPressed(Document *, bool smartDelete = false, TextGranularity granularity = CharacterGranularity);
-    static void forwardDeleteKeyPressed(Document *, bool smartDelete = false, TextGranularity granularity = CharacterGranularity);
-    static void insertText(Document *, const String &, bool selectInsertedText = false);
-    static void insertLineBreak(Document *);
-    static void insertParagraphSeparator(Document *);
-    static void insertParagraphSeparatorInQuotedContent(Document *);
-    static bool isOpenForMoreTypingCommand(const EditCommandPtr &);
-    static void closeTyping(const EditCommandPtr &);
+    static void deleteKeyPressed(Document*, bool smartDelete = false, TextGranularity = CharacterGranularity);
+    static void forwardDeleteKeyPressed(Document*, bool smartDelete = false, TextGranularity = CharacterGranularity);
+    static void insertText(Document*, const String&, bool selectInsertedText = false);
+    static void insertLineBreak(Document*);
+    static void insertParagraphSeparator(Document*);
+    static void insertParagraphSeparatorInQuotedContent(Document*);
+    static bool isOpenForMoreTypingCommand(const EditCommand*);
+    static void closeTyping(EditCommand*);
     
     virtual void doApply();
     virtual EditAction editingAction() const;
 
-    bool openForMoreTyping() const { return m_openForMoreTyping; }
+    bool isOpenForMoreTyping() const { return m_openForMoreTyping; }
     void closeTyping() { m_openForMoreTyping = false; }
 
     void insertText(const String &text, bool selectInsertedText);
@@ -87,4 +87,4 @@ private:
 
 } // namespace WebCore
 
-#endif // __typing_command_h__
+#endif // typing_command_h__
index f2b4f554d8455db10a4ac741d65dc7aa2ea90d15..89be9a4cb7e585e095cfd2725f945bfa8f2a7e6c 100644 (file)
@@ -31,8 +31,8 @@
 
 namespace WebCore {
 
-WrapContentsInDummySpanCommand::WrapContentsInDummySpanCommand(Document *document, Element *element)
-    : EditCommand(document), m_element(element)
+WrapContentsInDummySpanCommand::WrapContentsInDummySpanCommand(Element* element)
+    : EditCommand(element->document()), m_element(element)
 {
     ASSERT(m_element);
 }
index 941656056a399ffdf909ada5d6c20e84f87bf447..024986c41005bcc7178f15354d1f108a36c20fcc 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005 Apple Computer, Inc.  All rights reserved.
+ * Copyright (C) 2005, 2006 Apple Computer, Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
 
-#ifndef __wrap_contents_in_dummy_span_command_h__
-#define __wrap_contents_in_dummy_span_command_h__
+#ifndef wrap_contents_in_dummy_span_command_h__
+#define wrap_contents_in_dummy_span_command_h__
 
 #include "EditCommand.h"
 
 namespace WebCore {
 
-class WrapContentsInDummySpanCommand : public EditCommand
-{
+class WrapContentsInDummySpanCommand : public EditCommand {
 public:
-    WrapContentsInDummySpanCommand(Document *, Element *);
-    virtual ~WrapContentsInDummySpanCommand() { }
+    WrapContentsInDummySpanCommand(Element*);
 
     virtual void doApply();
     virtual void doUnapply();
@@ -46,4 +44,4 @@ private:
 
 } // namespace WebCore
 
-#endif // __wrap_contents_in_dummy_span_command_h__
+#endif // wrap_contents_in_dummy_span_command_h__
index 45760a1823b62ed9eeee280f77af96504f6b281f..76d07a1dfc0d233b35be66cccd4879334e73705c 100644 (file)
@@ -38,7 +38,7 @@ class Position;
 class String;
 class VisiblePosition;
 
-const unsigned short NON_BREAKING_SPACE = 0xa0;
+const UChar NON_BREAKING_SPACE = 0xa0;
 
 Position rangeCompliantEquivalent(const Position&);
 Position rangeCompliantEquivalent(const VisiblePosition&);
index 22c8d4c8226967b61e4ea74b47133dfd07efb558..4c037977d9c48b5d3c2c998510b69689dfe78bbc 100644 (file)
@@ -234,7 +234,7 @@ bool Frame::didOpenURL(const KURL& url)
   cancelRedirection();
   
   // clear last edit command
-  d->m_lastEditCommand = EditCommandPtr();
+  d->m_lastEditCommand = 0;
   
   closeURL();
 
@@ -1267,9 +1267,7 @@ void Frame::setFocusNodeIfNeeded()
     if (!document() || d->m_selection.isNone() || !d->m_isActive)
         return;
 
-    Node *startNode = d->m_selection.start().node();
-    Node *target = startNode ? startNode->rootEditableElement() : 0;
-    
+    Node* target = d->m_selection.rootEditableElement();
     if (target) {
         RenderObject* renderer = target->renderer();
 
@@ -1959,9 +1957,7 @@ void Frame::selectAll()
     if (!d->m_doc)
         return;
     
-    Node *startNode = d->m_selection.start().node();
-    Node *root = startNode && startNode->isContentEditable() ? startNode->rootEditableElement() : d->m_doc->documentElement();
-    
+    Node* root = d->m_selection.isContentEditable() ? d->m_selection.rootEditableElement() : d->m_doc->documentElement();
     selectContentsOfNode(root);
     selectFrameElementInParentIfFullySelected();
     notifyRendererOfSelectionChange(true);
@@ -2029,76 +2025,77 @@ void Frame::textDidChangeInTextArea(Element* input)
 {
 }
 
-EditCommandPtr Frame::lastEditCommand()
+EditCommand* Frame::lastEditCommand()
 {
-    return d->m_lastEditCommand;
+    return d->m_lastEditCommand.get();
 }
 
-void dispatchEditableContentChangedEvent(Node* root)
+static void dispatchEditableContentChangedEvents(const EditCommand& command)
 {
-    if (!root)
-        return;
-        
-    ExceptionCode ec = 0;
-    EventTargetNodeCast(root)->dispatchEvent(new Event(khtmlEditableContentChangedEvent, false, false), ec, true);
+     Element* startRoot = command.startingRootEditableElement();
+     Element* endRoot = command.endingRootEditableElement();
+     ExceptionCode ec;
+     if (startRoot)
+         startRoot->dispatchEvent(new Event(khtmlEditableContentChangedEvent, false, false), ec, true);
+     if (endRoot && endRoot != startRoot)
+         endRoot->dispatchEvent(new Event(khtmlEditableContentChangedEvent, false, false), ec, true);
 }
 
-void Frame::appliedEditing(EditCommandPtr& cmd)
+void Frame::appliedEditing(PassRefPtr<EditCommand> cmd)
 {
-    SelectionController sel(cmd.endingSelection());
+    dispatchEditableContentChangedEvents(*cmd);
+    SelectionController sel(cmd->endingSelection());
     if (shouldChangeSelection(sel))
         setSelection(sel, false);
     
-    dispatchEditableContentChangedEvent(!selection().isNone() ? selection().start().node()->rootEditableElement() : 0);
-
     // Now set the typing style from the command. Clear it when done.
     // This helps make the case work where you completely delete a piece
     // of styled text and then type a character immediately after.
     // That new character needs to take on the style of the just-deleted text.
     // FIXME: Improve typing style.
     // See this bug: <rdar://problem/3769899> Implementation of typing style needs improvement
-    if (cmd.typingStyle()) {
-        setTypingStyle(cmd.typingStyle());
-        cmd.setTypingStyle(0);
+    if (cmd->typingStyle()) {
+        setTypingStyle(cmd->typingStyle());
+        cmd->setTypingStyle(0);
     }
 
     // Command will be equal to last edit command only in the case of typing
-    if (d->m_lastEditCommand == cmd) {
-        assert(cmd.isTypingCommand());
-    }
+    if (d->m_lastEditCommand == cmd)
+        assert(cmd->isTypingCommand());
     else {
         // Only register a new undo command if the command passed in is
         // different from the last command
+        d->m_lastEditCommand = cmd.get();
         registerCommandForUndo(cmd);
-        d->m_lastEditCommand = cmd;
     }
     respondToChangedContents();
 }
 
-void Frame::unappliedEditing(EditCommandPtr& cmd)
+void Frame::unappliedEditing(PassRefPtr<EditCommand> cmd)
 {
-    SelectionController sel(cmd.startingSelection());
+    dispatchEditableContentChangedEvents(*cmd);
+
+    SelectionController sel(cmd->startingSelection());
     if (shouldChangeSelection(sel))
         setSelection(sel, true);
-    
-    dispatchEditableContentChangedEvent(!selection().isNone() ? selection().start().node()->rootEditableElement() : 0);
         
+    d->m_lastEditCommand = 0;
     registerCommandForRedo(cmd);
     respondToChangedContents();
-    d->m_lastEditCommand = EditCommandPtr::emptyCommand();
 }
 
-void Frame::reappliedEditing(EditCommandPtr& cmd)
+void Frame::reappliedEditing(PassRefPtr<EditCommand> cmd)
 {
-    SelectionController sel(cmd.endingSelection());
+    dispatchEditableContentChangedEvents(*cmd);
+
+    SelectionController sel(cmd->startingSelection());
     if (shouldChangeSelection(sel))
         setSelection(sel, true);
-    
-    dispatchEditableContentChangedEvent(!selection().isNone() ? selection().start().node()->rootEditableElement() : 0);
         
+    d->m_lastEditCommand = 0;
     registerCommandForUndo(cmd);
     respondToChangedContents();
-    d->m_lastEditCommand = EditCommandPtr::emptyCommand();
 }
 
 CSSMutableStyleDeclaration *Frame::typingStyle() const
@@ -2220,10 +2217,8 @@ void Frame::computeAndSetTypingStyle(CSSStyleDeclaration *style, EditAction edit
     // Handle block styles, substracting these from the typing style.
     RefPtr<CSSMutableStyleDeclaration> blockStyle = mutableStyle->copyBlockProperties();
     blockStyle->diff(mutableStyle.get());
-    if (document() && blockStyle->length() > 0) {
-        EditCommandPtr cmd(new ApplyStyleCommand(document(), blockStyle.get(), editingAction));
-        cmd.apply();
-    }
+    if (document() && blockStyle->length() > 0)
+        applyCommand(new ApplyStyleCommand(document(), blockStyle.get(), editingAction));
     
     // Set the remaining style as the typing style.
     d->m_typingStyle = mutableStyle.release();
@@ -2240,10 +2235,8 @@ void Frame::applyStyle(CSSStyleDeclaration *style, EditAction editingAction)
             break;
         }
         case Selection::RANGE:
-            if (document() && style) {
-                EditCommandPtr cmd(new ApplyStyleCommand(document(), style, editingAction));
-                cmd.apply();
-            }
+            if (document() && style)
+                applyCommand(new ApplyStyleCommand(document(), style, editingAction));
             break;
     }
 }
@@ -2256,10 +2249,8 @@ void Frame::applyParagraphStyle(CSSStyleDeclaration *style, EditAction editingAc
             break;
         case Selection::CARET:
         case Selection::RANGE:
-            if (document() && style) {
-                EditCommandPtr cmd(new ApplyStyleCommand(document(), style, editingAction, ApplyStyleCommand::ForceBlockProperties));
-                cmd.apply();
-            }
+            if (document() && style)
+                applyCommand(new ApplyStyleCommand(document(), style, editingAction, ApplyStyleCommand::ForceBlockProperties));
             break;
     }
 }
index 1f2dd31c0d987a9286e9b8f7001830da58dd5758..4e9f46f367991c52514230648cbd975d384e85f7 100644 (file)
@@ -58,7 +58,7 @@ class CSSMutableStyleDeclaration;
 class CSSStyleDeclaration;
 class DrawContentsEvent;
 class DOMWindow;
-class EditCommandPtr;
+class EditCommand;
 class FramePrivate;
 class FrameTree;
 class KJSProxy;
@@ -420,22 +420,22 @@ public:
   /**
    * Returns the most recent edit command applied.
    */
-  EditCommandPtr lastEditCommand();
+  EditCommand* lastEditCommand();
 
   /**
    * Called when editing has been applied.
    */
-  void appliedEditing(EditCommandPtr&);
+  void appliedEditing(PassRefPtr<EditCommand>);
 
   /**
    * Called when editing has been unapplied.
    */
-  void unappliedEditing(EditCommandPtr&);
+  void unappliedEditing(PassRefPtr<EditCommand>);
 
   /**
    * Called when editing has been reapplied.
    */
-  void reappliedEditing(EditCommandPtr&);
+  void reappliedEditing(PassRefPtr<EditCommand>);
 
   /**
    * Returns the typing style for the document.
@@ -552,8 +552,8 @@ public:
   virtual void unfocusWindow() = 0;
   virtual void createEmptyDocument() = 0;
   virtual Range* markedTextRange() const = 0;
-  virtual void registerCommandForUndo(const EditCommandPtr&) = 0;
-  virtual void registerCommandForRedo(const EditCommandPtr&) = 0;
+  virtual void registerCommandForUndo(PassRefPtr<EditCommand>) = 0;
+  virtual void registerCommandForRedo(PassRefPtr<EditCommand>) = 0;
   virtual void clearUndoRedoOperations() = 0;
   virtual void issueUndoCommand() = 0;
   virtual void issueRedoCommand() = 0;
index 586dcf21b8f5e7966b13a894b4d781c65e420a91..ee1dc0176375dd9396b985be12123115b9c82ba4 100644 (file)
@@ -195,7 +195,7 @@ namespace WebCore {
         bool m_bCleared : 1;
         bool m_isActive : 1;
 
-        EditCommandPtr m_lastEditCommand;
+        RefPtr<EditCommand> m_lastEditCommand;
         int m_xPosForVerticalArrowNavigation;
         RefPtr<CSSMutableStyleDeclaration> m_typingStyle;
 
index 7d2226fbdec0dfca60a5643e78b77ba6b3b9697a..534a88f306636681b10d5042234350aa0670ffc6 100644 (file)
@@ -100,8 +100,8 @@ public:
     virtual KJS::Bindings::Instance* getObjectInstanceForWidget(Widget*);
     virtual KJS::Bindings::Instance* getAppletInstanceForWidget(Widget*);
 
-    virtual void registerCommandForUndo(const EditCommandPtr&);
-    virtual void registerCommandForRedo(const EditCommandPtr&);
+    virtual void registerCommandForUndo(PassRefPtr<EditCommand>);
+    virtual void registerCommandForRedo(PassRefPtr<EditCommand>);
     virtual void clearUndoRedoOperations();
     virtual void issueUndoCommand();
     virtual void issueRedoCommand();
index 5da72f8b98c665b88926d90afc5ba007717f619c..2057d7699292dbe4e4ecba208b04ad998085e89e 100644 (file)
@@ -178,7 +178,7 @@ KJS::Bindings::Instance* FrameGdk::getObjectInstanceForWidget(Widget *) { notImp
 KJS::Bindings::Instance* FrameGdk::getEmbedInstanceForWidget(Widget *) { notImplemented(); return 0; }
 bool FrameGdk::canRedo() const { notImplemented(); return 0; }
 bool FrameGdk::canUndo() const { notImplemented(); return 0; }
-void FrameGdk::registerCommandForRedo(WebCore::EditCommandPtr const&) { notImplemented(); }
+void FrameGdk::registerCommandForRedo(PassRefPtr<WebCore::EditCommand>) { notImplemented(); }
 bool FrameGdk::runJavaScriptPrompt(String const&, String const&, String &) { notImplemented(); return 0; }
 bool FrameGdk::shouldInterruptJavaScript() { notImplemented(); return false; }
 void FrameGdk::print() { notImplemented(); }
@@ -251,7 +251,7 @@ void FrameGdk::respondToChangedSelection(WebCore::SelectionController const&, bo
 Frame* FrameGdk::createFrame(const KURL& url, const String& name, Element* ownerElement, const String& referrer) { return 0; }
 
 void FrameGdk::saveDocumentState() { }
-void FrameGdk::registerCommandForUndo(WebCore::EditCommandPtr const&) { }
+void FrameGdk::registerCommandForUndo(PassRefPtr<WebCore::EditCommand>) { }
 void FrameGdk::clearUndoRedoOperations(void) { }
 String FrameGdk::incomingReferrer() const { return String(); }
 void FrameGdk::markMisspellingsInAdjacentWords(WebCore::VisiblePosition const&) { }
index 4501c67acc8916bcaa20ec2b25ba051db3924c5d..a827be6f84921bb6fb6c825acc149dd203e7ea00 100644 (file)
@@ -176,7 +176,7 @@ KJS::Bindings::Instance* FrameWin::getObjectInstanceForWidget(Widget *) { notImp
 KJS::Bindings::Instance* FrameWin::getEmbedInstanceForWidget(Widget *) { notImplemented(); return 0; }
 bool FrameWin::canRedo() const { notImplemented(); return 0; }
 bool FrameWin::canUndo() const { notImplemented(); return 0; }
-void FrameWin::registerCommandForRedo(WebCore::EditCommandPtr const&) { notImplemented(); }
+void FrameWin::registerCommandForRedo(PassRefPtr<WebCore::EditCommand>) { notImplemented(); }
 bool FrameWin::runJavaScriptPrompt(String const&,String const&,String &) { notImplemented(); return 0; }
 bool FrameWin::shouldInterruptJavaScript() { notImplemented(); return false; }
 bool FrameWin::openURL(KURL const&) { notImplemented(); return 0; }
@@ -256,7 +256,7 @@ void FrameWin::respondToChangedSelection(WebCore::SelectionController const&,boo
 static int frameNumber = 0;
 Frame* FrameWin::createFrame(KURL const&,String const&,Element*,String const&) { return 0; }
 void FrameWin::saveDocumentState() { }
-void FrameWin::registerCommandForUndo(WebCore::EditCommandPtr const&) { }
+void FrameWin::registerCommandForUndo(PassRefPtr<WebCore::EditCommand>) { }
 void FrameWin::clearUndoRedoOperations(void) { }
 String FrameWin::incomingReferrer() const { return String(); }
 void FrameWin::markMisspellingsInAdjacentWords(WebCore::VisiblePosition const&) { }