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
+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
--- /dev/null
+#import <edit_actions.h>
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
--- /dev/null
+/*
+ * 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
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();
}
doApply();
}
-HTMLEditAction EditCommand::editingAction() const
+EditAction EditCommand::editingAction() const
{
- return HTMLEditActionUnspecified;
+ return EditActionUnspecified;
}
void EditCommand::setStartingSelection(const Selection &s)
//------------------------------------------------------------------------------------------
// 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();
setEndingSelectionNeedsLayout();
}
+EditAction ApplyStyleCommand::editingAction() const
+{
+ return m_editingAction;
+}
+
void ApplyStyleCommand::applyBlockStyle(CSSMutableStyleDeclarationImpl *style)
{
// update document layout once before removing styles
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
applyCommandToComposite(cmd);
}
-HTMLEditAction MoveSelectionCommand::editingAction() const
+EditAction MoveSelectionCommand::editingAction() const
{
- return HTMLEditActionDrag;
+ return EditActionDrag;
}
//------------------------------------------------------------------------------------------
ASSERT_NOT_REACHED();
}
-HTMLEditAction TypingCommand::editingAction() const
+EditAction TypingCommand::editingAction() const
{
- return HTMLEditActionTyping;
+ return EditActionTyping;
}
void TypingCommand::markMisspellingsAfterTyping()
setEndingSelection(m_cmds.last().endingSelection());
}
-HTMLEditAction ReplaceSelectionCommand::editingAction() const
+EditAction ReplaceSelectionCommand::editingAction() const
{
- return HTMLEditActionPaste;
+ return EditActionPaste;
}
bool TypingCommand::preservesTypingStyle() const
#define __htmlediting_h__
#include "dom_nodeimpl.h"
+#include "editing/edit_actions.h"
#include "qptrlist.h"
#include "qvaluelist.h"
#include "selection.h"
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;
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;
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 *);
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;
};
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);
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; }
DOM::Position positionInsertionPoint(DOM::Position);
DOM::CSSMutableStyleDeclarationImpl *m_style;
+ EditAction m_editingAction;
};
//------------------------------------------------------------------------------------------
{
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;
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;
virtual ~MoveSelectionCommand();
virtual void doApply();
- virtual HTMLEditAction editingAction() const;
+ virtual EditAction editingAction() const;
private:
DOM::DocumentFragmentImpl *m_fragment;
virtual ~ReplaceSelectionCommand();
virtual void doApply();
- virtual HTMLEditAction editingAction() const;
+ virtual EditAction editingAction() const;
private:
void completeHTMLReplacement(const DOM::Position &, const DOM::Position &);
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; }
using khtml::ChildFrame;
using khtml::Decoder;
using khtml::EAffinity;
+using khtml::EditAction;
using khtml::EditCommandPtr;
using khtml::ETextGranularity;
using khtml::FormData;
#endif
-void KHTMLPart::computeAndSetTypingStyle(CSSStyleDeclarationImpl *style)
+void KHTMLPart::computeAndSetTypingStyle(CSSStyleDeclarationImpl *style, EditAction editingAction)
{
if (!style || style->length() == 0) {
clearTypingStyle();
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();
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;
#define __khtml_part_h__
#include "editing/text_granularity.h"
+#include "editing/edit_actions.h"
#include <kparts/part.h>
#include <kparts/browserextension.h>
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;
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];
}
- (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;
using khtml::Decoder;
using khtml::DeleteSelectionCommand;
using khtml::EAffinity;
+using khtml::EditAction;
using khtml::EditCommandPtr;
using khtml::ETextGranularity;
using khtml::IncludeNode;
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
+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.
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:
[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;
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];
}
}
[style setFontWeight:@"bold"];
if ([[self _bridge] selectionStartHasStyle:style])
[style setFontWeight:@"normal"];
- [self _applyStyleToSelection:style];
+ [self _applyStyleToSelection:style withUndoAction:WebUndoActionSetFont];
}
- (void)_toggleItalic
[style setFontStyle:@"italic"];
if ([[self _bridge] selectionStartHasStyle:style])
[style setFontStyle:@"normal"];
- [self _applyStyleToSelection:style];
+ [self _applyStyleToSelection:style withUndoAction:WebUndoActionSetFont];
}
- (BOOL)_handleStyleKeyEquivalent:(NSEvent *)event
{
// 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
- (void)changeFont:(id)sender
{
- [self _applyStyleToSelection:[self _styleFromFontManagerOperation]];
+ [self _applyStyleToSelection:[self _styleFromFontManagerOperation] withUndoAction:WebUndoActionSetFont];
}
- (DOMCSSStyleDeclaration *)_styleForAttributeChange:(id)sender
- (void)changeAttributes:(id)sender
{
- [self _applyStyleToSelection:[self _styleForAttributeChange:sender]];
+ [self _applyStyleToSelection:[self _styleForAttributeChange:sender] withUndoAction:WebUndoActionChangeAttributes];
}
- (DOMCSSStyleDeclaration *)_styleFromColorPanelWithSelector:(SEL)selector
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]];
}
}
// 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;
// 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
{
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
[style setTextDecoration:@"underline"];
if ([[self _bridge] selectionStartHasStyle:style])
[style setTextDecoration:@"none"];
- [self _applyStyleToSelection:style];
+ [self _applyStyleToSelection:style withUndoAction:WebUndoActionUnderline];
}
- (void)yank:(id)sender
- (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
- (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