WebCore:
authorsullivan <sullivan@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 15 Dec 2004 19:13:48 +0000 (19:13 +0000)
committersullivan <sullivan@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 15 Dec 2004 19:13:48 +0000 (19:13 +0000)
        Reviewed by Ken.

        - rest of WebCore fix for <rdar://problem/3790011> undoable operations all say "Undo"
        in the menu, no specific action names

        * khtml/editing/edit_actions.h: new header, contains EditAction enum
        (renamed from HTMLEditAction, formerly in htmlediting.h)

        * ForwardingHeaders/editing/edit_actions.h: new forwarding header

        * khtml/editing/htmlediting.h:
        removed HTMLEditAction enum in favor of including edit_actions.h; added khtml::
        namespace to EditAction usages; added m_editingAction ivar to ApplyStyleCommand

        * khtml/editing/htmlediting.cpp:
        (khtml::EditCommandPtr::editingAction):
        update for enum name change
        (khtml::EditCommand::editingAction):
        ditto
        (khtml::ApplyStyleCommand::ApplyStyleCommand):
        added editingAction parameter to this constructor
        (khtml::ApplyStyleCommand::editingAction):
        return new ivar
        (khtml::DeleteSelectionCommand::editingAction):
        update for enum name change
        (khtml::MoveSelectionCommand::editingAction):
        ditto
        (khtml::TypingCommand::editingAction):
        ditto
        (khtml::ReplaceSelectionCommand::editingAction):
        ditto

        * khtml/khtml_part.h:
        added EditAction parameter to applyStyle and computeAndSetTypingStyle
        * khtml/khtml_part.cpp:
        (KHTMLPart::computeAndSetTypingStyle):
        added EditAction parameter
        (KHTMLPart::applyStyle):
        ditto

        * kwq/KWQKHTMLPart.mm:
        (KWQKHTMLPart::registerCommandForUndoOrRedo):
        do the cast from EditAction to WebUndoAction a different way to match other code

        * kwq/WebCoreBridge.h:
        * kwq/WebCoreBridge.mm:
        (-[WebCoreBridge setTypingStyle:withUndoAction:]):
        added WebUndoAction parameter, passed into ApplyStyleCommand constructor
        (-[WebCoreBridge applyStyle:withUndoAction:]):
        ditto

        * WebCore.pbproj/project.pbxproj:
        updated for new files

WebKit:

        Reviewed by Ken.

        - rest of WebKit fix for <rdar://problem/3790011> undoable operations all say "Undo"
        in the menu, no specific action names

        I only know of one loose end currently, which I wrote up as <rdar://problem/3920971> Edit menu
        says "Undo Change Attributes" when it should say "Undo Set Color", from font panel

        * WebView.subproj/WebHTMLView.m:
        (-[WebHTMLView concludeDragForDraggingInfo:actionMask:]):
        use WebUndoActionSetColor when dragging color swatch
        (-[WebHTMLView _applyStyleToSelection:withUndoAction:]):
        new WebUndoAction parameter, passed across bridge
        (-[WebHTMLView _toggleBold]):
        use WebUndoActionSetFont
        (-[WebHTMLView _toggleItalic]):
        use WebUndoActionSetFont
        (-[WebHTMLView pasteFont:]):
        use WebUndoActionPasteFont
        (-[WebHTMLView changeFont:]):
        use WebUndoActionSetFont
        (-[WebHTMLView changeAttributes:]):
        use WebUndoActionChangeAttributes
        (-[WebHTMLView _undoActionFromColorPanelWithSelector:]):
        new method, returns WebUndoActionSetBackgroundColor or WebUndoActionSetColor
        (-[WebHTMLView _changeCSSColorUsingSelector:inRange:]):
        now calls _undoActionFromColorPanelWithSelector
        (-[WebHTMLView changeColor:]):
        use WebUndoActionSetColor
        (-[WebHTMLView _alignSelectionUsingCSSValue:withUndoAction:]):
        new WebUndoAction parameter, passed through
        (-[WebHTMLView alignCenter:]):
        use WebUndoActionCenter
        (-[WebHTMLView alignJustified:]):
        use WebUndoActionJustify
        (-[WebHTMLView alignLeft:]):
        use WebUndoActionAlignLeft
        (-[WebHTMLView alignRight:]):
        use WebUndoActionAlignRight
        (-[WebHTMLView subscript:]):
        use WebUndoActionAlignSubscript
        (-[WebHTMLView superscript:]):
        use WebUndoActionAlignSuperscript
        (-[WebHTMLView unscript:]):
        use WebUndoActionAlignUnscript
        (-[WebHTMLView underline:]):
        use WebUndoActionAlignUnderline

        * WebView.subproj/WebView.m:
        (-[WebView setTypingStyle:]):
        pass WebUndoActionUnspecified through as new parameter since we don't have any more specific info
        (-[WebView applyStyle:]):
        ditto

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

14 files changed:
WebCore/ChangeLog-2005-08-23
WebCore/ForwardingHeaders/editing/edit_actions.h [new file with mode: 0644]
WebCore/WebCore.pbproj/project.pbxproj
WebCore/khtml/editing/edit_actions.h [new file with mode: 0644]
WebCore/khtml/editing/htmlediting.cpp
WebCore/khtml/editing/htmlediting.h
WebCore/khtml/khtml_part.cpp
WebCore/khtml/khtml_part.h
WebCore/kwq/KWQKHTMLPart.mm
WebCore/kwq/WebCoreBridge.h
WebCore/kwq/WebCoreBridge.mm
WebKit/ChangeLog
WebKit/WebView.subproj/WebHTMLView.m
WebKit/WebView.subproj/WebView.m

index 9ae3a13..612df3b 100644 (file)
@@ -1,3 +1,59 @@
+2004-12-14  John Sullivan  <sullivan@apple.com>
+
+        Reviewed by Ken.
+        
+        - rest of WebCore fix for <rdar://problem/3790011> undoable operations all say "Undo" 
+        in the menu, no specific action names
+
+        * khtml/editing/edit_actions.h: new header, contains EditAction enum
+        (renamed from HTMLEditAction, formerly in htmlediting.h)
+
+        * ForwardingHeaders/editing/edit_actions.h: new forwarding header
+        
+        * khtml/editing/htmlediting.h:
+        removed HTMLEditAction enum in favor of including edit_actions.h; added khtml::
+        namespace to EditAction usages; added m_editingAction ivar to ApplyStyleCommand
+
+        * khtml/editing/htmlediting.cpp:
+        (khtml::EditCommandPtr::editingAction):
+        update for enum name change
+        (khtml::EditCommand::editingAction):
+        ditto
+        (khtml::ApplyStyleCommand::ApplyStyleCommand):
+        added editingAction parameter to this constructor
+        (khtml::ApplyStyleCommand::editingAction):
+        return new ivar
+        (khtml::DeleteSelectionCommand::editingAction):
+        update for enum name change
+        (khtml::MoveSelectionCommand::editingAction):
+        ditto
+        (khtml::TypingCommand::editingAction):
+        ditto
+        (khtml::ReplaceSelectionCommand::editingAction):
+        ditto
+        
+        * khtml/khtml_part.h:
+        added EditAction parameter to applyStyle and computeAndSetTypingStyle
+        * khtml/khtml_part.cpp:
+        (KHTMLPart::computeAndSetTypingStyle):
+        added EditAction parameter
+        (KHTMLPart::applyStyle):
+        ditto
+
+        * kwq/KWQKHTMLPart.mm:
+        (KWQKHTMLPart::registerCommandForUndoOrRedo):
+        do the cast from EditAction to WebUndoAction a different way to match other code
+        
+        * kwq/WebCoreBridge.h:
+        * kwq/WebCoreBridge.mm:
+        (-[WebCoreBridge setTypingStyle:withUndoAction:]):
+        added WebUndoAction parameter, passed into ApplyStyleCommand constructor
+        (-[WebCoreBridge applyStyle:withUndoAction:]):
+        ditto
+
+        * WebCore.pbproj/project.pbxproj:
+        updated for new files
+
 2004-12-14  David Hyatt  <hyatt@apple.com>
 
        Fix for 3562458, rowspan and colspan converted to ints so that large values will work for them.  Remove
diff --git a/WebCore/ForwardingHeaders/editing/edit_actions.h b/WebCore/ForwardingHeaders/editing/edit_actions.h
new file mode 100644 (file)
index 0000000..6b0d7e9
--- /dev/null
@@ -0,0 +1 @@
+#import <edit_actions.h>
index ab0842b..748aa32 100644 (file)
                                BECE67BE07087B250007C14B,
                                BEA5E01E075CEDAC0098A432,
                                9378D9FC07640A46004B97BF,
+                               EDA4AC98076FB89100DD23EC,
                        );
                        isa = PBXHeadersBuildPhase;
                        runOnlyForDeploymentPostprocessing = 0;
                };
                BEB1DD0805C197DF00DD1F43 = {
                        children = (
+                               EDA4AC97076FB89100DD23EC,
                                BE9185DD05EE59B80081354D,
                                BE9185E005EE59B80081354D,
                                BEA5DBDA075CEDA00098A432,
 //BE2
 //BE3
 //BE4
+//ED0
+//ED1
+//ED2
+//ED3
+//ED4
+               EDA4AC97076FB89100DD23EC = {
+                       fileEncoding = 4;
+                       isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
+                       name = edit_actions.h;
+                       path = editing/edit_actions.h;
+                       refType = 4;
+                       sourceTree = "<group>";
+               };
+               EDA4AC98076FB89100DD23EC = {
+                       fileRef = EDA4AC97076FB89100DD23EC;
+                       isa = PBXBuildFile;
+                       settings = {
+                       };
+               };
+//ED0
+//ED1
+//ED2
+//ED3
+//ED4
 //F50
 //F51
 //F52
diff --git a/WebCore/khtml/editing/edit_actions.h b/WebCore/khtml/editing/edit_actions.h
new file mode 100644 (file)
index 0000000..d321584
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2004 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
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef KHTML_EDITING_EDIT_ACTIONS_H
+#define KHTML_EDITING_EDIT_ACTIONS_H
+
+namespace khtml {
+    typedef enum {
+        EditActionUnspecified,
+        EditActionSetColor,
+        EditActionSetBackgroundColor,
+        EditActionTurnOffKerning,
+        EditActionTightenKerning,
+        EditActionLoosenKerning,
+        EditActionUseStandardKerning,
+        EditActionTurnOffLigatures,
+        EditActionUseStandardLigatures,
+        EditActionUseAllLigatures,
+        EditActionRaiseBaseline,
+        EditActionLowerBaseline,
+        EditActionSetTraditionalCharacterShape,
+        EditActionSetFont,
+        EditActionChangeAttributes,
+        EditActionAlignLeft,
+        EditActionAlignRight,
+        EditActionCenter,
+        EditActionJustify,
+        EditActionSetWritingDirection,
+        EditActionSubscript,
+        EditActionSuperscript,
+        EditActionUnderline,
+        EditActionOutline,
+        EditActionUnscript,
+        EditActionDrag,
+        EditActionCut,
+        EditActionPaste,
+        EditActionPasteFont,
+        EditActionPasteRuler,
+        EditActionTyping,
+    } EditAction;    
+}
+
+#endif
index 6bb3f69..10a0cf7 100644 (file)
@@ -266,9 +266,9 @@ void EditCommandPtr::reapply() const
     get()->reapply();
 }
 
-HTMLEditAction EditCommandPtr::editingAction() const
+EditAction EditCommandPtr::editingAction() const
 {
-    IF_IMPL_NULL_RETURN_ARG(HTMLEditActionUnspecified);
+    IF_IMPL_NULL_RETURN_ARG(EditActionUnspecified);
     return get()->editingAction();
 }
 
@@ -521,9 +521,9 @@ void EditCommand::doReapply()
     doApply();
 }
 
-HTMLEditAction EditCommand::editingAction() const
+EditAction EditCommand::editingAction() const
 {
-    return HTMLEditActionUnspecified;
+    return EditActionUnspecified;
 }
 
 void EditCommand::setStartingSelection(const Selection &s)
@@ -1021,8 +1021,8 @@ void AppendNodeCommand::doUnapply()
 //------------------------------------------------------------------------------------------
 // ApplyStyleCommand
 
-ApplyStyleCommand::ApplyStyleCommand(DocumentImpl *document, CSSStyleDeclarationImpl *style)
-    : CompositeEditCommand(document), m_style(style->makeMutable())
+ApplyStyleCommand::ApplyStyleCommand(DocumentImpl *document, CSSStyleDeclarationImpl *style, EditAction editingAction)
+    : CompositeEditCommand(document), m_style(style->makeMutable()), m_editingAction(editingAction)
 {   
     ASSERT(m_style);
     m_style->ref();
@@ -1056,6 +1056,11 @@ void ApplyStyleCommand::doApply()
     setEndingSelectionNeedsLayout();
 }
 
+EditAction ApplyStyleCommand::editingAction() const
+{
+    return m_editingAction;
+}
+
 void ApplyStyleCommand::applyBlockStyle(CSSMutableStyleDeclarationImpl *style)
 {
     // update document layout once before removing styles
@@ -1940,12 +1945,12 @@ void DeleteSelectionCommand::doApply()
     rebalanceWhitespace();
 }
 
-HTMLEditAction DeleteSelectionCommand::editingAction() const
+EditAction DeleteSelectionCommand::editingAction() const
 {
     // Note that DeleteSelectionCommand is also used when the user presses the Delete key,
     // but in that case there's a TypingCommand that supplies the editingAction(), so
     // the Undo menu correctly shows "Undo Typing"
-    return HTMLEditActionCut;
+    return EditActionCut;
 }
 
 bool DeleteSelectionCommand::preservesTypingStyle() const
@@ -2794,9 +2799,9 @@ void MoveSelectionCommand::doApply()
     applyCommandToComposite(cmd);
 }
 
-HTMLEditAction MoveSelectionCommand::editingAction() const
+EditAction MoveSelectionCommand::editingAction() const
 {
-    return HTMLEditActionDrag;
+    return EditActionDrag;
 }
 
 //------------------------------------------------------------------------------------------
@@ -3802,9 +3807,9 @@ void TypingCommand::doApply()
     ASSERT_NOT_REACHED();
 }
 
-HTMLEditAction TypingCommand::editingAction() const
+EditAction TypingCommand::editingAction() const
 {
-    return HTMLEditActionTyping;
+    return EditActionTyping;
 }
 
 void TypingCommand::markMisspellingsAfterTyping()
@@ -3963,9 +3968,9 @@ void TypingCommand::removeCommand(const EditCommandPtr &cmd)
         setEndingSelection(m_cmds.last().endingSelection());
 }
 
-HTMLEditAction ReplaceSelectionCommand::editingAction() const
+EditAction ReplaceSelectionCommand::editingAction() const
 {
-    return HTMLEditActionPaste;
+    return EditActionPaste;
 }
 
 bool TypingCommand::preservesTypingStyle() const
index e767961..0ee3597 100644 (file)
@@ -27,6 +27,7 @@
 #define __htmlediting_h__
 
 #include "dom_nodeimpl.h"
+#include "editing/edit_actions.h"
 #include "qptrlist.h"
 #include "qvaluelist.h"
 #include "selection.h"
@@ -41,40 +42,6 @@ namespace DOM {
     class TextImpl;
 }
 
-typedef enum {
-    HTMLEditActionUnspecified,
-    HTMLEditActionSetColor,
-    HTMLEditActionSetBackgroundColor,
-    HTMLEditActionTurnOffKerning,
-    HTMLEditActionTightenKerning,
-    HTMLEditActionLoosenKerning,
-    HTMLEditActionUseStandardKerning,
-    HTMLEditActionTurnOffLigatures,
-    HTMLEditActionUseStandardLigatures,
-    HTMLEditActionUseAllLigatures,
-    HTMLEditActionRaiseBaseline,
-    HTMLEditActionLowerBaseline,
-    HTMLEditActionSetTraditionalCharacterShape,
-    HTMLEditActionSetFont,
-    HTMLEditActionChangeAttributes,
-    HTMLEditActionAlignLeft,
-    HTMLEditActionAlignRight,
-    HTMLEditActionCenter,
-    HTMLEditActionJustify,
-    HTMLEditActionSetWritingDirection,
-    HTMLEditActionSubscript,
-    HTMLEditActionSuperscript,
-    HTMLEditActionUnderline,
-    HTMLEditActionOutline,
-    HTMLEditActionUnscript,
-    HTMLEditActionDrag,
-    HTMLEditActionCut,
-    HTMLEditActionPaste,
-    HTMLEditActionPasteFont,
-    HTMLEditActionPasteRuler,
-    HTMLEditActionTyping,
-} HTMLEditAction;
-
 namespace khtml {
 
 class EditCommand;
@@ -100,15 +67,15 @@ public:
     void unapply() const;
     void reapply() const;
 
-    HTMLEditAction editingAction() const;
+    EditAction editingAction() const;
 
     DOM::DocumentImpl * const document() const;
 
-    khtml::Selection startingSelection() const;
-    khtml::Selection endingSelection() const;
+    Selection startingSelection() const;
+    Selection endingSelection() const;
 
-    void setStartingSelection(const khtml::Selection &s) const;
-    void setEndingSelection(const khtml::Selection &s) const;
+    void setStartingSelection(const Selection &s) const;
+    void setEndingSelection(const Selection &s) const;
 
     DOM::CSSMutableStyleDeclarationImpl *typingStyle() const;
     void setTypingStyle(DOM::CSSMutableStyleDeclarationImpl *) const;
@@ -172,20 +139,20 @@ public:
     virtual void doUnapply() = 0;
     virtual void doReapply();  // calls doApply()
 
-    virtual HTMLEditAction editingAction() const;
+    virtual EditAction editingAction() const;
 
     virtual DOM::DocumentImpl * const document() const { return m_document; }
 
-    khtml::Selection startingSelection() const { return m_startingSelection; }
-    khtml::Selection endingSelection() const { return m_endingSelection; }
+    Selection startingSelection() const { return m_startingSelection; }
+    Selection endingSelection() const { return m_endingSelection; }
 
     void setEndingSelectionNeedsLayout(bool flag=true) { m_endingSelection.setNeedsLayout(flag); }
         
     ECommandState state() const { return m_state; }
     void setState(ECommandState state) { m_state = state; }
 
-    void setStartingSelection(const khtml::Selection &s);
-    void setEndingSelection(const khtml::Selection &s);
+    void setStartingSelection(const Selection &s);
+    void setEndingSelection(const Selection &s);
 
     DOM::CSSMutableStyleDeclarationImpl *typingStyle() const { return m_typingStyle; };
     void setTypingStyle(DOM::CSSMutableStyleDeclarationImpl *);
@@ -200,8 +167,8 @@ private:
 
     DOM::DocumentImpl *m_document;
     ECommandState m_state;
-    khtml::Selection m_startingSelection;
-    khtml::Selection m_endingSelection;
+    Selection m_startingSelection;
+    Selection m_endingSelection;
     DOM::CSSMutableStyleDeclarationImpl *m_typingStyle;
     EditCommand *m_parent;
 };
@@ -225,7 +192,7 @@ protected:
     void applyCommandToComposite(EditCommandPtr &);
     void deleteKeyPressed();
     void deleteSelection(bool smartDelete=false, bool mergeBlocksAfterDelete=true);
-    void deleteSelection(const khtml::Selection &selection, bool smartDelete=false, bool mergeBlocksAfterDelete=true);
+    void deleteSelection(const Selection &selection, bool smartDelete=false, bool mergeBlocksAfterDelete=true);
     void deleteTextFromNode(DOM::TextImpl *node, long offset, long count);
     void inputText(const DOM::DOMString &text, bool selectInsertedText = false);
     void insertNodeAfter(DOM::NodeImpl *insertChild, DOM::NodeImpl *refChild);
@@ -284,10 +251,11 @@ private:
 class ApplyStyleCommand : public CompositeEditCommand
 {
 public:
-    ApplyStyleCommand(DOM::DocumentImpl *, DOM::CSSStyleDeclarationImpl *style);
+    ApplyStyleCommand(DOM::DocumentImpl *, DOM::CSSStyleDeclarationImpl *style, EditAction editingAction=EditActionChangeAttributes);
     virtual ~ApplyStyleCommand();
        
     virtual void doApply();
+    virtual EditAction editingAction() const;
 
     DOM::CSSMutableStyleDeclarationImpl *style() const { return m_style; }
 
@@ -311,6 +279,7 @@ private:
     DOM::Position positionInsertionPoint(DOM::Position);
     
     DOM::CSSMutableStyleDeclarationImpl *m_style;
+    EditAction m_editingAction;
 };
 
 //------------------------------------------------------------------------------------------
@@ -343,10 +312,10 @@ class DeleteSelectionCommand : public CompositeEditCommand
 { 
 public:
     DeleteSelectionCommand(DOM::DocumentImpl *document, bool smartDelete=false, bool mergeBlocksAfterDelete=true);
-    DeleteSelectionCommand(DOM::DocumentImpl *document, const khtml::Selection &selection, bool smartDelete=false, bool mergeBlocksAfterDelete=true);
+    DeleteSelectionCommand(DOM::DocumentImpl *document, const Selection &selection, bool smartDelete=false, bool mergeBlocksAfterDelete=true);
        
     virtual void doApply();
-    virtual HTMLEditAction editingAction() const;
+    virtual EditAction editingAction() const;
     
 private:
     virtual bool preservesTypingStyle() const;
@@ -368,7 +337,7 @@ private:
     bool m_trailingWhitespaceValid;
 
     // This data is transient and should be cleared at the end of the doApply function.
-    khtml::Selection m_selectionToDelete;
+    Selection m_selectionToDelete;
     DOM::Position m_upstreamStart;
     DOM::Position m_downstreamStart;
     DOM::Position m_upstreamEnd;
@@ -531,7 +500,7 @@ public:
     virtual ~MoveSelectionCommand();
     
     virtual void doApply();
-    virtual HTMLEditAction editingAction() const;
+    virtual EditAction editingAction() const;
     
 private:
     DOM::DocumentFragmentImpl *m_fragment;
@@ -702,7 +671,7 @@ public:
     virtual ~ReplaceSelectionCommand();
     
     virtual void doApply();
-    virtual HTMLEditAction editingAction() const;
+    virtual EditAction editingAction() const;
 
 private:
     void completeHTMLReplacement(const DOM::Position &, const DOM::Position &);
@@ -782,7 +751,7 @@ public:
     static void closeTyping(const EditCommandPtr &);
     
     virtual void doApply();
-    virtual HTMLEditAction editingAction() const;
+    virtual EditAction editingAction() const;
 
     bool openForMoreTyping() const { return m_openForMoreTyping; }
     void closeTyping() { m_openForMoreTyping = false; }
index ccf337b..0ef6b73 100644 (file)
@@ -112,6 +112,7 @@ using khtml::CHARACTER;
 using khtml::ChildFrame;
 using khtml::Decoder;
 using khtml::EAffinity;
+using khtml::EditAction;
 using khtml::EditCommandPtr;
 using khtml::ETextGranularity;
 using khtml::FormData;
@@ -5359,7 +5360,7 @@ bool KHTMLPart::canUndo() const
 
 #endif
 
-void KHTMLPart::computeAndSetTypingStyle(CSSStyleDeclarationImpl *style)
+void KHTMLPart::computeAndSetTypingStyle(CSSStyleDeclarationImpl *style, EditAction editingAction)
 {
     if (!style || style->length() == 0) {
         clearTypingStyle();
@@ -5385,7 +5386,7 @@ void KHTMLPart::computeAndSetTypingStyle(CSSStyleDeclarationImpl *style)
     blockStyle->ref();
     blockStyle->diff(mutableStyle);
     if (xmlDocImpl() && blockStyle->length() > 0) {
-        EditCommandPtr cmd(new ApplyStyleCommand(xmlDocImpl(), blockStyle));
+        EditCommandPtr cmd(new ApplyStyleCommand(xmlDocImpl(), blockStyle, editingAction));
         cmd.apply();
     }
     blockStyle->deref();
@@ -5395,19 +5396,19 @@ void KHTMLPart::computeAndSetTypingStyle(CSSStyleDeclarationImpl *style)
     mutableStyle->deref();
 }
 
-void KHTMLPart::applyStyle(CSSStyleDeclarationImpl *style)
+void KHTMLPart::applyStyle(CSSStyleDeclarationImpl *style, EditAction editingAction)
 {
     switch (selection().state()) {
         case Selection::NONE:
             // do nothing
             break;
         case Selection::CARET: {
-            computeAndSetTypingStyle(style);
+            computeAndSetTypingStyle(style, editingAction);
             break;
         }
         case Selection::RANGE:
             if (xmlDocImpl() && style) {
-                EditCommandPtr cmd(new ApplyStyleCommand(xmlDocImpl(), style));
+                EditCommandPtr cmd(new ApplyStyleCommand(xmlDocImpl(), style, editingAction));
                 cmd.apply();
             }
             break;
index 0f8c6fc..beb6bff 100644 (file)
@@ -28,6 +28,7 @@
 #define __khtml_part_h__
 
 #include "editing/text_granularity.h"
+#include "editing/edit_actions.h"
 
 #include <kparts/part.h>
 #include <kparts/browserextension.h>
@@ -888,8 +889,8 @@ public:
   void undo();
   bool canRedo() const;
   bool canUndo() const;
-  void computeAndSetTypingStyle(DOM::CSSStyleDeclarationImpl *);
-  void applyStyle(DOM::CSSStyleDeclarationImpl *);
+  void computeAndSetTypingStyle(DOM::CSSStyleDeclarationImpl *, khtml::EditAction editingAction=khtml::EditActionUnspecified);
+  void applyStyle(DOM::CSSStyleDeclarationImpl *, khtml::EditAction editingAction=khtml::EditActionUnspecified);
   TriState selectionHasStyle(DOM::CSSStyleDeclarationImpl *) const;
   bool selectionStartHasStyle(DOM::CSSStyleDeclarationImpl *) const;
   DOM::DOMString selectionStartStylePropertyValue(int stylePropertyID) const;
index 8182ae6..1584dc4 100644 (file)
@@ -3828,7 +3828,7 @@ void KWQKHTMLPart::registerCommandForUndoOrRedo(const EditCommandPtr &cmd, bool
     KWQEditCommand *kwq = [KWQEditCommand commandWithEditCommand:cmd.get()];
     NSUndoManager *undoManager = [_bridge undoManager];
     [undoManager registerUndoWithTarget:_bridge selector:(isRedo ? @selector(redoEditing:) : @selector(undoEditing:)) object:kwq];
-    NSString *actionName = [_bridge nameForUndoAction:(WebUndoAction)cmd.editingAction()];
+    NSString *actionName = [_bridge nameForUndoAction:static_cast<WebUndoAction>(cmd.editingAction())];
     if (actionName != nil) {
         [undoManager setActionName:actionName];
     }
index d600c4b..8d01f71 100644 (file)
@@ -385,8 +385,8 @@ typedef enum {
 - (void)deleteKeyPressed;
 
 - (DOMCSSStyleDeclaration *)typingStyle;
-- (void)setTypingStyle:(DOMCSSStyleDeclaration *)style;
-- (void)applyStyle:(DOMCSSStyleDeclaration *)style;
+- (void)setTypingStyle:(DOMCSSStyleDeclaration *)style withUndoAction:(WebUndoAction)undoAction;
+- (void)applyStyle:(DOMCSSStyleDeclaration *)style withUndoAction:(WebUndoAction)undoAction;
 - (BOOL)selectionStartHasStyle:(DOMCSSStyleDeclaration *)style;
 - (void)applyEditingStyleToBodyElement;
 - (void)removeEditingStyleFromBodyElement;
index 2a5027e..05c1727 100644 (file)
@@ -108,6 +108,7 @@ using khtml::createMarkup;
 using khtml::Decoder;
 using khtml::DeleteSelectionCommand;
 using khtml::EAffinity;
+using khtml::EditAction;
 using khtml::EditCommandPtr;
 using khtml::ETextGranularity;
 using khtml::IncludeNode;
@@ -1706,18 +1707,18 @@ static HTMLFormElementImpl *formElementFromDOMElement(DOMElement *element)
     return [DOMCSSStyleDeclaration _styleDeclarationWithImpl:_part->typingStyle()];
 }
 
-- (void)setTypingStyle:(DOMCSSStyleDeclaration *)style
+- (void)setTypingStyle:(DOMCSSStyleDeclaration *)style withUndoAction:(WebUndoAction)undoAction
 {
     if (!_part)
         return;
-    _part->computeAndSetTypingStyle([style _styleDeclarationImpl]);
+    _part->computeAndSetTypingStyle([style _styleDeclarationImpl], static_cast<EditAction>(undoAction));
 }
 
-- (void)applyStyle:(DOMCSSStyleDeclaration *)style
+- (void)applyStyle:(DOMCSSStyleDeclaration *)style withUndoAction:(WebUndoAction)undoAction
 {
     if (!_part)
         return;
-    _part->applyStyle([style _styleDeclarationImpl]);
+    _part->applyStyle([style _styleDeclarationImpl], static_cast<EditAction>(undoAction));
 }
 
 - (BOOL)selectionStartHasStyle:(DOMCSSStyleDeclaration *)style
index 4df941d..b9c3174 100644 (file)
@@ -1,3 +1,59 @@
+2004-12-14  John Sullivan  <sullivan@apple.com>
+
+        Reviewed by Ken.
+        
+        - rest of WebKit fix for <rdar://problem/3790011> undoable operations all say "Undo" 
+        in the menu, no specific action names
+        
+        I only know of one loose end currently, which I wrote up as <rdar://problem/3920971> Edit menu 
+        says "Undo Change Attributes" when it should say "Undo Set Color", from font panel
+
+        * WebView.subproj/WebHTMLView.m:
+        (-[WebHTMLView concludeDragForDraggingInfo:actionMask:]):
+        use WebUndoActionSetColor when dragging color swatch
+        (-[WebHTMLView _applyStyleToSelection:withUndoAction:]):
+        new WebUndoAction parameter, passed across bridge
+        (-[WebHTMLView _toggleBold]):
+        use WebUndoActionSetFont
+        (-[WebHTMLView _toggleItalic]):
+        use WebUndoActionSetFont
+        (-[WebHTMLView pasteFont:]):
+        use WebUndoActionPasteFont
+        (-[WebHTMLView changeFont:]):
+        use WebUndoActionSetFont
+        (-[WebHTMLView changeAttributes:]):
+        use WebUndoActionChangeAttributes
+        (-[WebHTMLView _undoActionFromColorPanelWithSelector:]):
+        new method, returns WebUndoActionSetBackgroundColor or WebUndoActionSetColor
+        (-[WebHTMLView _changeCSSColorUsingSelector:inRange:]):
+        now calls _undoActionFromColorPanelWithSelector
+        (-[WebHTMLView changeColor:]):
+        use WebUndoActionSetColor
+        (-[WebHTMLView _alignSelectionUsingCSSValue:withUndoAction:]):
+        new WebUndoAction parameter, passed through
+        (-[WebHTMLView alignCenter:]):
+        use WebUndoActionCenter
+        (-[WebHTMLView alignJustified:]):
+        use WebUndoActionJustify
+        (-[WebHTMLView alignLeft:]):
+        use WebUndoActionAlignLeft
+        (-[WebHTMLView alignRight:]):
+        use WebUndoActionAlignRight
+        (-[WebHTMLView subscript:]):
+        use WebUndoActionAlignSubscript
+        (-[WebHTMLView superscript:]):
+        use WebUndoActionAlignSuperscript
+        (-[WebHTMLView unscript:]):
+        use WebUndoActionAlignUnscript
+        (-[WebHTMLView underline:]):
+        use WebUndoActionAlignUnderline
+        
+        * WebView.subproj/WebView.m:
+        (-[WebView setTypingStyle:]):
+        pass WebUndoActionUnspecified through as new parameter since we don't have any more specific info
+        (-[WebView applyStyle:]):
+        ditto
+
 2004-12-14  Richard Williamson   <rjw@apple.com>
 
        Helper method to get URL of plugin view.
@@ -30,7 +86,7 @@
 
         Reviewed by Ken.
 
-        - WebKit part of fix for <rdar://problem/3790011> undoable operations all say "Undo" in the menu, 
+        - WebKit part of plumbing of fix for <rdar://problem/3790011> undoable operations all say "Undo" in the menu, 
         no specific action names
 
         * WebCoreSupport.subproj/WebBridge.m:
index 9292180..c830502 100644 (file)
@@ -2415,7 +2415,7 @@ static WebHTMLView *lastHitView = nil;
             [style setProperty:@"color" :[self _colorAsString:color] :@""];
             if ([[webView _editingDelegateForwarder] webView:webView shouldApplyStyle:style toElementsInDOMRange:[bridge selectedDOMRange]]) {
                 [[webView _UIDelegateForwarder] webView:webView willPerformDragDestinationAction:WebDragDestinationActionEdit forDraggingInfo:draggingInfo];
-                [bridge applyStyle:style];
+                [bridge applyStyle:style withUndoAction:WebUndoActionSetColor];
                 return YES;
             }
             return NO;
@@ -3237,14 +3237,14 @@ static WebHTMLView *lastHitView = nil;
     return style;
 }
 
-- (void)_applyStyleToSelection:(DOMCSSStyleDeclaration *)style
+- (void)_applyStyleToSelection:(DOMCSSStyleDeclaration *)style withUndoAction:(WebUndoAction)undoAction
 {
     if (style == nil || [style length] == 0 || ![self _canEdit])
         return;
     WebView *webView = [self _webView];
     WebBridge *bridge = [self _bridge];
     if ([[webView _editingDelegateForwarder] webView:webView shouldApplyStyle:style toElementsInDOMRange:[self _selectedRange]]) {
-        [bridge applyStyle:style];
+        [bridge applyStyle:style withUndoAction:undoAction];
     }
 }
 
@@ -3254,7 +3254,7 @@ static WebHTMLView *lastHitView = nil;
     [style setFontWeight:@"bold"];
     if ([[self _bridge] selectionStartHasStyle:style])
         [style setFontWeight:@"normal"];
-    [self _applyStyleToSelection:style];
+    [self _applyStyleToSelection:style withUndoAction:WebUndoActionSetFont];
 }
 
 - (void)_toggleItalic
@@ -3263,7 +3263,7 @@ static WebHTMLView *lastHitView = nil;
     [style setFontStyle:@"italic"];
     if ([[self _bridge] selectionStartHasStyle:style])
         [style setFontStyle:@"normal"];
-    [self _applyStyleToSelection:style];
+    [self _applyStyleToSelection:style withUndoAction:WebUndoActionSetFont];
 }
 
 - (BOOL)_handleStyleKeyEquivalent:(NSEvent *)event
@@ -3318,7 +3318,7 @@ static WebHTMLView *lastHitView = nil;
 {
     // Read RTF with font attributes from the pasteboard.
     // Maybe later we should add a pasteboard type that contains CSS text for "native" copy and paste font.
-    [self _applyStyleToSelection:[self _styleFromFontAttributes:[self _fontAttributesFromFontPasteboard]]];
+    [self _applyStyleToSelection:[self _styleFromFontAttributes:[self _fontAttributesFromFontPasteboard]] withUndoAction:WebUndoActionPasteFont];
 }
 
 - (void)pasteAsPlainText:(id)sender
@@ -3413,7 +3413,7 @@ static WebHTMLView *lastHitView = nil;
 
 - (void)changeFont:(id)sender
 {
-    [self _applyStyleToSelection:[self _styleFromFontManagerOperation]];
+    [self _applyStyleToSelection:[self _styleFromFontManagerOperation] withUndoAction:WebUndoActionSetFont];
 }
 
 - (DOMCSSStyleDeclaration *)_styleForAttributeChange:(id)sender
@@ -3519,7 +3519,7 @@ NSStrokeColorAttributeName        /* NSColor, default nil: same as foreground co
 
 - (void)changeAttributes:(id)sender
 {
-    [self _applyStyleToSelection:[self _styleForAttributeChange:sender]];
+    [self _applyStyleToSelection:[self _styleForAttributeChange:sender] withUndoAction:WebUndoActionChangeAttributes];
 }
 
 - (DOMCSSStyleDeclaration *)_styleFromColorPanelWithSelector:(SEL)selector
@@ -3532,12 +3532,21 @@ NSStrokeColorAttributeName        /* NSColor, default nil: same as foreground co
     return style;
 }
 
+- (WebUndoAction)_undoActionFromColorPanelWithSelector:(SEL)selector
+{
+    if (selector == @selector(setBackgroundColor:)) {
+        return WebUndoActionSetBackgroundColor;
+    }
+    
+    return WebUndoActionSetColor;
+}
+
 - (void)_changeCSSColorUsingSelector:(SEL)selector inRange:(DOMRange *)range
 {
     DOMCSSStyleDeclaration *style = [self _styleFromColorPanelWithSelector:selector];
     WebView *webView = [self _webView];
     if ([[webView _editingDelegateForwarder] webView:webView shouldApplyStyle:style toElementsInDOMRange:range]) {
-        [[self _bridge] applyStyle:style];
+        [[self _bridge] applyStyle:style withUndoAction:[self _undoActionFromColorPanelWithSelector:selector]];
     }
 }
 
@@ -3564,10 +3573,11 @@ NSStrokeColorAttributeName        /* NSColor, default nil: same as foreground co
     // AppKit will have to be revised to allow this to work with anything that isn't an 
     // NSTextView. However, this might not be required for Tiger, since the background-color 
     // changing box in the font panel doesn't work in Mail (3674481), though it does in TextEdit.
-    [self _applyStyleToSelection:[self _styleFromColorPanelWithSelector:@selector(setColor:)]];
+    [self _applyStyleToSelection:[self _styleFromColorPanelWithSelector:@selector(setColor:)] 
+                  withUndoAction:WebUndoActionSetColor];
 }
 
-- (void)_alignSelectionUsingCSSValue:(NSString *)CSSAlignmentValue
+- (void)_alignSelectionUsingCSSValue:(NSString *)CSSAlignmentValue withUndoAction:(WebUndoAction)undoAction
 {
     if (![self _canEdit])
         return;
@@ -3576,27 +3586,27 @@ NSStrokeColorAttributeName        /* NSColor, default nil: same as foreground co
     // just applyStyle: needs to be called for block-level attributes like this.
     DOMCSSStyleDeclaration *style = [self _emptyStyle];
     [style setTextAlign:CSSAlignmentValue];
-    [self _applyStyleToSelection:style];
+    [self _applyStyleToSelection:style withUndoAction:undoAction];
 }
 
 - (void)alignCenter:(id)sender
 {
-    [self _alignSelectionUsingCSSValue:@"center"];
+    [self _alignSelectionUsingCSSValue:@"center" withUndoAction:WebUndoActionCenter];
 }
 
 - (void)alignJustified:(id)sender
 {
-    [self _alignSelectionUsingCSSValue:@"justify"];
+    [self _alignSelectionUsingCSSValue:@"justify" withUndoAction:WebUndoActionJustify];
 }
 
 - (void)alignLeft:(id)sender
 {
-    [self _alignSelectionUsingCSSValue:@"left"];
+    [self _alignSelectionUsingCSSValue:@"left" withUndoAction:WebUndoActionAlignLeft];
 }
 
 - (void)alignRight:(id)sender
 {
-    [self _alignSelectionUsingCSSValue:@"right"];
+    [self _alignSelectionUsingCSSValue:@"right" withUndoAction:WebUndoActionAlignRight];
 }
 
 - (void)insertTab:(id)sender
@@ -3885,21 +3895,21 @@ NSStrokeColorAttributeName        /* NSColor, default nil: same as foreground co
 {
     DOMCSSStyleDeclaration *style = [self _emptyStyle];
     [style setVerticalAlign:@"sub"];
-    [self _applyStyleToSelection:style];
+    [self _applyStyleToSelection:style withUndoAction:WebUndoActionSubscript];
 }
 
 - (void)superscript:(id)sender
 {
     DOMCSSStyleDeclaration *style = [self _emptyStyle];
     [style setVerticalAlign:@"super"];
-    [self _applyStyleToSelection:style];
+    [self _applyStyleToSelection:style withUndoAction:WebUndoActionSuperscript];
 }
 
 - (void)unscript:(id)sender
 {
     DOMCSSStyleDeclaration *style = [self _emptyStyle];
     [style setVerticalAlign:@"baseline"];
-    [self _applyStyleToSelection:style];
+    [self _applyStyleToSelection:style withUndoAction:WebUndoActionUnscript];
 }
 
 - (void)underline:(id)sender
@@ -3910,7 +3920,7 @@ NSStrokeColorAttributeName        /* NSColor, default nil: same as foreground co
     [style setTextDecoration:@"underline"];
     if ([[self _bridge] selectionStartHasStyle:style])
         [style setTextDecoration:@"none"];
-    [self _applyStyleToSelection:style];
+    [self _applyStyleToSelection:style withUndoAction:WebUndoActionUnderline];
 }
 
 - (void)yank:(id)sender
index 60ec43c..fc7c13b 100644 (file)
@@ -2565,7 +2565,9 @@ static WebFrame *incrementFrame(WebFrame *curr, BOOL forward, BOOL wrapFlag)
 
 - (void)setTypingStyle:(DOMCSSStyleDeclaration *)style
 {
-    [[self _bridgeForCurrentSelection] setTypingStyle:style];
+    // We don't know enough at thls level to pass in a relevant WebUndoAction; we'd have to
+    // change the API to allow this.
+    [[self _bridgeForCurrentSelection] setTypingStyle:style withUndoAction:WebUndoActionUnspecified];
 }
 
 - (DOMCSSStyleDeclaration *)typingStyle
@@ -2694,7 +2696,9 @@ static WebFrame *incrementFrame(WebFrame *curr, BOOL forward, BOOL wrapFlag)
     
 - (void)applyStyle:(DOMCSSStyleDeclaration *)style
 {
-    [[self _bridgeForCurrentSelection] applyStyle:style];
+    // We don't know enough at thls level to pass in a relevant WebUndoAction; we'd have to
+    // change the API to allow this.
+    [[self _bridgeForCurrentSelection] applyStyle:style withUndoAction:WebUndoActionUnspecified];
 }
 
 @end