Diff
Modified: trunk/Source/WebCore/ChangeLog (239626 => 239627)
--- trunk/Source/WebCore/ChangeLog 2019-01-04 19:52:26 UTC (rev 239626)
+++ trunk/Source/WebCore/ChangeLog 2019-01-04 19:56:51 UTC (rev 239627)
@@ -1,3 +1,19 @@
+2019-01-04 Wenson Hsieh <wenson_hs...@apple.com>
+
+ [Cocoa] Merge WebEditCommandProxy::nameForEditAction and undoNameForEditAction into a single function
+ https://bugs.webkit.org/show_bug.cgi?id=193129
+
+ Reviewed by Tim Horton.
+
+ Adds a new helper function that returns the undo/redo name for a given EditAction. No change in behavior.
+
+ * Sources.txt:
+ * WebCore.xcodeproj/project.pbxproj:
+ * editing/EditAction.cpp: Copied from Source/WebKit/UIProcess/WebEditCommandProxy.cpp.
+ (WebCore::nameForUndoRedo):
+ * editing/EditAction.h:
+ * editing/Editor.cpp:
+
2019-01-03 Matt Rajca <mra...@apple.com>
Make DidPlayMediaPreventedFromPlaying autoplay event more generic.
Modified: trunk/Source/WebCore/Sources.txt (239626 => 239627)
--- trunk/Source/WebCore/Sources.txt 2019-01-04 19:52:26 UTC (rev 239626)
+++ trunk/Source/WebCore/Sources.txt 2019-01-04 19:56:51 UTC (rev 239627)
@@ -913,6 +913,7 @@
editing/DeleteSelectionCommand.cpp
editing/DictationAlternative.cpp
editing/DictationCommand.cpp
+editing/EditAction.cpp
editing/EditCommand.cpp
editing/Editing.cpp
editing/EditingStyle.cpp
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (239626 => 239627)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2019-01-04 19:52:26 UTC (rev 239626)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2019-01-04 19:56:51 UTC (rev 239627)
@@ -14935,6 +14935,7 @@
F48D2AA32159740D00C6752B /* ColorCocoa.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ColorCocoa.h; sourceTree = "<group>"; };
F48D2AA42159740D00C6752B /* ColorCocoa.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = ColorCocoa.mm; sourceTree = "<group>"; };
F49786871FF45FA500E060AB /* PasteboardItemInfo.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PasteboardItemInfo.h; sourceTree = "<group>"; };
+ F49E98E421DEE6C1009AE55E /* EditAction.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = EditAction.cpp; sourceTree = "<group>"; };
F4D43D64218802E600ECECAC /* SerializedAttachmentData.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SerializedAttachmentData.h; sourceTree = "<group>"; };
F4D9817D2195FBF6008230FC /* ChangeListTypeCommand.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ChangeListTypeCommand.h; sourceTree = "<group>"; };
F4D9817E2195FBF6008230FC /* ChangeListTypeCommand.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ChangeListTypeCommand.cpp; sourceTree = "<group>"; };
@@ -20780,6 +20781,7 @@
CECADFC4153778FF00E37068 /* DictationCommand.cpp */,
CECADFC5153778FF00E37068 /* DictationCommand.h */,
2D5646AF1B8F8493003C4994 /* DictionaryPopupInfo.h */,
+ F49E98E421DEE6C1009AE55E /* EditAction.cpp */,
93309D93099E64910056E581 /* EditAction.h */,
93309D94099E64910056E581 /* EditCommand.cpp */,
93309D95099E64910056E581 /* EditCommand.h */,
Copied: trunk/Source/WebCore/editing/EditAction.cpp (from rev 239626, trunk/Source/WebKit/UIProcess/WebEditCommandProxy.cpp) (0 => 239627)
--- trunk/Source/WebCore/editing/EditAction.cpp (rev 0)
+++ trunk/Source/WebCore/editing/EditAction.cpp 2019-01-04 19:56:51 UTC (rev 239627)
@@ -0,0 +1,147 @@
+/*
+ * Copyright (C) 2019 Apple 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 INC. AND ITS CONTRIBUTORS ``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 INC. OR ITS 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.
+ */
+
+#include "config.h"
+#include "EditAction.h"
+
+#include "LocalizedStrings.h"
+
+namespace WebCore {
+
+String nameForUndoRedo(EditAction editAction)
+{
+ switch (editAction) {
+ case EditAction::Unspecified:
+ case EditAction::Insert:
+ case EditAction::InsertReplacement:
+ case EditAction::InsertFromDrop:
+ return { };
+ case EditAction::SetColor:
+ return WEB_UI_STRING_KEY("Set Color", "Set Color (Undo action name)", "Undo action name");
+ case EditAction::SetBackgroundColor:
+ return WEB_UI_STRING_KEY("Set Background Color", "Set Background Color (Undo action name)", "Undo action name");
+ case EditAction::TurnOffKerning:
+ return WEB_UI_STRING_KEY("Turn Off Kerning", "Turn Off Kerning (Undo action name)", "Undo action name");
+ case EditAction::TightenKerning:
+ return WEB_UI_STRING_KEY("Tighten Kerning", "Tighten Kerning (Undo action name)", "Undo action name");
+ case EditAction::LoosenKerning:
+ return WEB_UI_STRING_KEY("Loosen Kerning", "Loosen Kerning (Undo action name)", "Undo action name");
+ case EditAction::UseStandardKerning:
+ return WEB_UI_STRING_KEY("Use Standard Kerning", "Use Standard Kerning (Undo action name)", "Undo action name");
+ case EditAction::TurnOffLigatures:
+ return WEB_UI_STRING_KEY("Turn Off Ligatures", "Turn Off Ligatures (Undo action name)", "Undo action name");
+ case EditAction::UseStandardLigatures:
+ return WEB_UI_STRING_KEY("Use Standard Ligatures", "Use Standard Ligatures (Undo action name)", "Undo action name");
+ case EditAction::UseAllLigatures:
+ return WEB_UI_STRING_KEY("Use All Ligatures", "Use All Ligatures (Undo action name)", "Undo action name");
+ case EditAction::RaiseBaseline:
+ return WEB_UI_STRING_KEY("Raise Baseline", "Raise Baseline (Undo action name)", "Undo action name");
+ case EditAction::LowerBaseline:
+ return WEB_UI_STRING_KEY("Lower Baseline", "Lower Baseline (Undo action name)", "Undo action name");
+ case EditAction::SetTraditionalCharacterShape:
+ return WEB_UI_STRING_KEY("Set Traditional Character Shape", "Set Traditional Character Shape (Undo action name)", "Undo action name");
+ case EditAction::SetFont:
+ return WEB_UI_STRING_KEY("Set Font", "Set Font (Undo action name)", "Undo action name");
+ case EditAction::ChangeAttributes:
+ return WEB_UI_STRING_KEY("Change Attributes", "Change Attributes (Undo action name)", "Undo action name");
+ case EditAction::AlignLeft:
+ return WEB_UI_STRING_KEY("Align Left", "Align Left (Undo action name)", "Undo action name");
+ case EditAction::AlignRight:
+ return WEB_UI_STRING_KEY("Align Right", "Align Right (Undo action name)", "Undo action name");
+ case EditAction::Center:
+ return WEB_UI_STRING_KEY("Center", "Center (Undo action name)", "Undo action name");
+ case EditAction::Justify:
+ return WEB_UI_STRING_KEY("Justify", "Justify (Undo action name)", "Undo action name");
+ case EditAction::SetWritingDirection:
+ return WEB_UI_STRING_KEY("Set Writing Direction", "Set Writing Direction (Undo action name)", "Undo action name");
+ case EditAction::Subscript:
+ return WEB_UI_STRING_KEY("Subscript", "Subscript (Undo action name)", "Undo action name");
+ case EditAction::Superscript:
+ return WEB_UI_STRING_KEY("Superscript", "Superscript (Undo action name)", "Undo action name");
+ case EditAction::Underline:
+ return WEB_UI_STRING_KEY("Underline", "Underline (Undo action name)", "Undo action name");
+ case EditAction::Outline:
+ return WEB_UI_STRING_KEY("Outline", "Outline (Undo action name)", "Undo action name");
+ case EditAction::Unscript:
+ return WEB_UI_STRING_KEY("Unscript", "Unscript (Undo action name)", "Undo action name");
+ case EditAction::DeleteByDrag:
+ return WEB_UI_STRING_KEY("Drag", "Drag (Undo action name)", "Undo action name");
+ case EditAction::Cut:
+ return WEB_UI_STRING_KEY("Cut", "Cut (Undo action name)", "Undo action name");
+ case EditAction::Bold:
+ return WEB_UI_STRING_KEY("Bold", "Bold (Undo action name)", "Undo action name");
+ case EditAction::Italics:
+ return WEB_UI_STRING_KEY("Italics", "Italics (Undo action name)", "Undo action name");
+ case EditAction::Delete:
+ return WEB_UI_STRING_KEY("Delete", "Delete (Undo action name)", "Undo action name");
+ case EditAction::Dictation:
+ return WEB_UI_STRING_KEY("Dictation", "Dictation (Undo action name)", "Undo action name");
+ case EditAction::Paste:
+ return WEB_UI_STRING_KEY("Paste", "Paste (Undo action name)", "Undo action name");
+ case EditAction::PasteFont:
+ return WEB_UI_STRING_KEY("Paste Font", "Paste Font (Undo action name)", "Undo action name");
+ case EditAction::PasteRuler:
+ return WEB_UI_STRING_KEY("Paste Ruler", "Paste Ruler (Undo action name)", "Undo action name");
+ case EditAction::TypingDeleteSelection:
+ case EditAction::TypingDeleteBackward:
+ case EditAction::TypingDeleteForward:
+ case EditAction::TypingDeleteWordBackward:
+ case EditAction::TypingDeleteWordForward:
+ case EditAction::TypingDeleteLineBackward:
+ case EditAction::TypingDeleteLineForward:
+ case EditAction::TypingDeletePendingComposition:
+ case EditAction::TypingDeleteFinalComposition:
+ case EditAction::TypingInsertText:
+ case EditAction::TypingInsertLineBreak:
+ case EditAction::TypingInsertParagraph:
+ case EditAction::TypingInsertPendingComposition:
+ case EditAction::TypingInsertFinalComposition:
+ return WEB_UI_STRING_KEY("Typing", "Typing (Undo action name)", "Undo action name");
+ case EditAction::CreateLink:
+ return WEB_UI_STRING_KEY("Create Link", "Create Link (Undo action name)", "Undo action name");
+ case EditAction::Unlink:
+ return WEB_UI_STRING_KEY("Unlink", "Unlink (Undo action name)", "Undo action name");
+ case EditAction::InsertUnorderedList:
+ case EditAction::InsertOrderedList:
+ return WEB_UI_STRING_KEY("Insert List", "Insert List (Undo action name)", "Undo action name");
+ case EditAction::FormatBlock:
+ return WEB_UI_STRING_KEY("Formatting", "Format Block (Undo action name)", "Undo action name");
+ case EditAction::Indent:
+ return WEB_UI_STRING_KEY("Indent", "Indent (Undo action name)", "Undo action name");
+ case EditAction::Outdent:
+ return WEB_UI_STRING_KEY("Outdent", "Outdent (Undo action name)", "Undo action name");
+ // FIXME: We should give internal clients a way to override these undo names. For instance, Mail refers to ordered and unordered lists as "numbered" and "bulleted" lists, respectively,
+ // despite the fact that ordered and unordered lists are not necessarily displayed using bullets and numerals.
+ case EditAction::ConvertToOrderedList:
+ return WEB_UI_STRING_KEY("Convert to Ordered List", "Convert to Ordered List (Undo action name)", "Undo action name");
+ case EditAction::ConvertToUnorderedList:
+ return WEB_UI_STRING_KEY("Convert to Unordered List", "Convert to Unordered List (Undo action name)", "Undo action name");
+ case EditAction::InsertEditableImage:
+ return WEB_UI_STRING_KEY("Insert Drawing", "Insert Drawing (Undo action name)", "Undo action name");
+ }
+ return { };
+}
+
+} // namespace WebCore
Modified: trunk/Source/WebCore/editing/EditAction.h (239626 => 239627)
--- trunk/Source/WebCore/editing/EditAction.h 2019-01-04 19:52:26 UTC (rev 239626)
+++ trunk/Source/WebCore/editing/EditAction.h 2019-01-04 19:56:51 UTC (rev 239627)
@@ -25,6 +25,10 @@
#pragma once
+namespace WTF {
+class String;
+}
+
namespace WebCore {
enum class EditAction : uint8_t {
@@ -91,4 +95,6 @@
InsertEditableImage
};
+WEBCORE_EXPORT WTF::String nameForUndoRedo(EditAction);
+
} // namespace WebCore
Modified: trunk/Source/WebCore/editing/Editor.cpp (239626 => 239627)
--- trunk/Source/WebCore/editing/Editor.cpp 2019-01-04 19:52:26 UTC (rev 239626)
+++ trunk/Source/WebCore/editing/Editor.cpp 2019-01-04 19:56:51 UTC (rev 239627)
@@ -32,6 +32,8 @@
#include "ApplyStyleCommand.h"
#include "CSSComputedStyleDeclaration.h"
#include "CSSPropertyNames.h"
+#include "CSSValueList.h"
+#include "CSSValuePool.h"
#include "CachedResourceLoader.h"
#include "ChangeListTypeCommand.h"
#include "ClipboardEvent.h"
@@ -63,8 +65,10 @@
#include "HTMLImageElement.h"
#include "HTMLInputElement.h"
#include "HTMLNames.h"
+#include "HTMLOListElement.h"
#include "HTMLQuoteElement.h"
#include "HTMLSpanElement.h"
+#include "HTMLUListElement.h"
#include "HitTestResult.h"
#include "IndentOutdentCommand.h"
#include "InputEvent.h"
Modified: trunk/Source/WebKit/ChangeLog (239626 => 239627)
--- trunk/Source/WebKit/ChangeLog 2019-01-04 19:52:26 UTC (rev 239626)
+++ trunk/Source/WebKit/ChangeLog 2019-01-04 19:56:51 UTC (rev 239627)
@@ -1,3 +1,31 @@
+2019-01-04 Wenson Hsieh <wenson_hs...@apple.com>
+
+ [Cocoa] Merge WebEditCommandProxy::nameForEditAction and undoNameForEditAction into a single function
+ https://bugs.webkit.org/show_bug.cgi?id=193129
+
+ Reviewed by Tim Horton.
+
+ Remove WebEditCommandProxy::nameForEditAction and use WebCore::nameForUndoRedo instead.
+
+ * UIProcess/Cocoa/WebViewImpl.mm:
+ (WebKit::WebViewImpl::registerEditCommand):
+ * UIProcess/WebEditCommandProxy.cpp:
+ (WebKit::WebEditCommandProxy::WebEditCommandProxy):
+ (WebKit::WebEditCommandProxy::~WebEditCommandProxy):
+ (WebKit::WebEditCommandProxy::nameForEditAction): Deleted.
+ * UIProcess/WebEditCommandProxy.h:
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::addEditCommand):
+ (WebKit::WebPageProxy::removeEditCommand):
+ (WebKit::WebPageProxy::isValidEditCommand): Deleted.
+
+ Bit of drive-by refactoring: remove an unused function, and make addEditCommand and removeEditCommand take
+ references instead of pointers, since these are assumed to be nonnull.
+
+ * UIProcess/WebPageProxy.h:
+ * UIProcess/ios/PageClientImplIOS.mm:
+ (WebKit::PageClientImpl::registerEditCommand):
+
2019-01-03 Matt Rajca <mra...@apple.com>
Make DidPlayMediaPreventedFromPlaying autoplay event more generic.
Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm (239626 => 239627)
--- trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm 2019-01-04 19:52:26 UTC (rev 239626)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm 2019-01-04 19:56:51 UTC (rev 239627)
@@ -2677,7 +2677,7 @@
void WebViewImpl::registerEditCommand(Ref<WebEditCommandProxy>&& command, UndoOrRedo undoOrRedo)
{
- auto actionName = WebEditCommandProxy::nameForEditAction(command->editAction());
+ auto actionName = WebCore::nameForUndoRedo(command->editAction());
auto commandObjC = adoptNS([[WKEditCommand alloc] initWithWebEditCommandProxy:WTFMove(command)]);
NSUndoManager *undoManager = [m_view undoManager];
Modified: trunk/Source/WebKit/UIProcess/WebEditCommandProxy.cpp (239626 => 239627)
--- trunk/Source/WebKit/UIProcess/WebEditCommandProxy.cpp 2019-01-04 19:52:26 UTC (rev 239626)
+++ trunk/Source/WebKit/UIProcess/WebEditCommandProxy.cpp 2019-01-04 19:56:51 UTC (rev 239627)
@@ -41,13 +41,13 @@
, m_editAction(editAction)
, m_page(page)
{
- m_page->addEditCommand(this);
+ m_page->addEditCommand(*this);
}
WebEditCommandProxy::~WebEditCommandProxy()
{
if (m_page)
- m_page->removeEditCommand(this);
+ m_page->removeEditCommand(*this);
}
void WebEditCommandProxy::unapply()
@@ -68,119 +68,4 @@
m_page->registerEditCommand(*this, UndoOrRedo::Undo);
}
-String WebEditCommandProxy::nameForEditAction(EditAction editAction)
-{
- // FIXME: This is identical to code in WebKit's WebEditorClient class; would be nice to share the strings instead of having two copies.
- switch (editAction) {
- case EditAction::Unspecified:
- case EditAction::Insert:
- case EditAction::InsertReplacement:
- case EditAction::InsertFromDrop:
- return String();
- case EditAction::SetColor:
- return WEB_UI_STRING_KEY("Set Color", "Set Color (Undo action name)", "Undo action name");
- case EditAction::SetBackgroundColor:
- return WEB_UI_STRING_KEY("Set Background Color", "Set Background Color (Undo action name)", "Undo action name");
- case EditAction::TurnOffKerning:
- return WEB_UI_STRING_KEY("Turn Off Kerning", "Turn Off Kerning (Undo action name)", "Undo action name");
- case EditAction::TightenKerning:
- return WEB_UI_STRING_KEY("Tighten Kerning", "Tighten Kerning (Undo action name)", "Undo action name");
- case EditAction::LoosenKerning:
- return WEB_UI_STRING_KEY("Loosen Kerning", "Loosen Kerning (Undo action name)", "Undo action name");
- case EditAction::UseStandardKerning:
- return WEB_UI_STRING_KEY("Use Standard Kerning", "Use Standard Kerning (Undo action name)", "Undo action name");
- case EditAction::TurnOffLigatures:
- return WEB_UI_STRING_KEY("Turn Off Ligatures", "Turn Off Ligatures (Undo action name)", "Undo action name");
- case EditAction::UseStandardLigatures:
- return WEB_UI_STRING_KEY("Use Standard Ligatures", "Use Standard Ligatures (Undo action name)", "Undo action name");
- case EditAction::UseAllLigatures:
- return WEB_UI_STRING_KEY("Use All Ligatures", "Use All Ligatures (Undo action name)", "Undo action name");
- case EditAction::RaiseBaseline:
- return WEB_UI_STRING_KEY("Raise Baseline", "Raise Baseline (Undo action name)", "Undo action name");
- case EditAction::LowerBaseline:
- return WEB_UI_STRING_KEY("Lower Baseline", "Lower Baseline (Undo action name)", "Undo action name");
- case EditAction::SetTraditionalCharacterShape:
- return WEB_UI_STRING_KEY("Set Traditional Character Shape", "Set Traditional Character Shape (Undo action name)", "Undo action name");
- case EditAction::SetFont:
- return WEB_UI_STRING_KEY("Set Font", "Set Font (Undo action name)", "Undo action name");
- case EditAction::ChangeAttributes:
- return WEB_UI_STRING_KEY("Change Attributes", "Change Attributes (Undo action name)", "Undo action name");
- case EditAction::AlignLeft:
- return WEB_UI_STRING_KEY("Align Left", "Align Left (Undo action name)", "Undo action name");
- case EditAction::AlignRight:
- return WEB_UI_STRING_KEY("Align Right", "Align Right (Undo action name)", "Undo action name");
- case EditAction::Center:
- return WEB_UI_STRING_KEY("Center", "Center (Undo action name)", "Undo action name");
- case EditAction::Justify:
- return WEB_UI_STRING_KEY("Justify", "Justify (Undo action name)", "Undo action name");
- case EditAction::SetWritingDirection:
- return WEB_UI_STRING_KEY("Set Writing Direction", "Set Writing Direction (Undo action name)", "Undo action name");
- case EditAction::Subscript:
- return WEB_UI_STRING_KEY("Subscript", "Subscript (Undo action name)", "Undo action name");
- case EditAction::Superscript:
- return WEB_UI_STRING_KEY("Superscript", "Superscript (Undo action name)", "Undo action name");
- case EditAction::Underline:
- return WEB_UI_STRING_KEY("Underline", "Underline (Undo action name)", "Undo action name");
- case EditAction::Outline:
- return WEB_UI_STRING_KEY("Outline", "Outline (Undo action name)", "Undo action name");
- case EditAction::Unscript:
- return WEB_UI_STRING_KEY("Unscript", "Unscript (Undo action name)", "Undo action name");
- case EditAction::DeleteByDrag:
- return WEB_UI_STRING_KEY("Drag", "Drag (Undo action name)", "Undo action name");
- case EditAction::Cut:
- return WEB_UI_STRING_KEY("Cut", "Cut (Undo action name)", "Undo action name");
- case EditAction::Bold:
- return WEB_UI_STRING_KEY("Bold", "Bold (Undo action name)", "Undo action name");
- case EditAction::Italics:
- return WEB_UI_STRING_KEY("Italics", "Italics (Undo action name)", "Undo action name");
- case EditAction::Delete:
- return WEB_UI_STRING_KEY("Delete", "Delete (Undo action name)", "Undo action name");
- case EditAction::Dictation:
- return WEB_UI_STRING_KEY("Dictation", "Dictation (Undo action name)", "Undo action name");
- case EditAction::Paste:
- return WEB_UI_STRING_KEY("Paste", "Paste (Undo action name)", "Undo action name");
- case EditAction::PasteFont:
- return WEB_UI_STRING_KEY("Paste Font", "Paste Font (Undo action name)", "Undo action name");
- case EditAction::PasteRuler:
- return WEB_UI_STRING_KEY("Paste Ruler", "Paste Ruler (Undo action name)", "Undo action name");
- case EditAction::TypingDeleteSelection:
- case EditAction::TypingDeleteBackward:
- case EditAction::TypingDeleteForward:
- case EditAction::TypingDeleteWordBackward:
- case EditAction::TypingDeleteWordForward:
- case EditAction::TypingDeleteLineBackward:
- case EditAction::TypingDeleteLineForward:
- case EditAction::TypingDeletePendingComposition:
- case EditAction::TypingDeleteFinalComposition:
- case EditAction::TypingInsertText:
- case EditAction::TypingInsertLineBreak:
- case EditAction::TypingInsertParagraph:
- case EditAction::TypingInsertPendingComposition:
- case EditAction::TypingInsertFinalComposition:
- return WEB_UI_STRING_KEY("Typing", "Typing (Undo action name)", "Undo action name");
- case EditAction::CreateLink:
- return WEB_UI_STRING_KEY("Create Link", "Create Link (Undo action name)", "Undo action name");
- case EditAction::Unlink:
- return WEB_UI_STRING_KEY("Unlink", "Unlink (Undo action name)", "Undo action name");
- case EditAction::InsertUnorderedList:
- case EditAction::InsertOrderedList:
- return WEB_UI_STRING_KEY("Insert List", "Insert List (Undo action name)", "Undo action name");
- case EditAction::FormatBlock:
- return WEB_UI_STRING_KEY("Formatting", "Format Block (Undo action name)", "Undo action name");
- case EditAction::Indent:
- return WEB_UI_STRING_KEY("Indent", "Indent (Undo action name)", "Undo action name");
- case EditAction::Outdent:
- return WEB_UI_STRING_KEY("Outdent", "Outdent (Undo action name)", "Undo action name");
- // FIXME: We should give internal clients a way to override these undo names. For instance, Mail refers to ordered and unordered lists as "numbered" and "bulleted" lists, respectively,
- // despite the fact that ordered and unordered lists are not necessarily displayed using bullets and numerals.
- case EditAction::ConvertToOrderedList:
- return WEB_UI_STRING_KEY("Convert to Ordered List", "Convert to Ordered List (Undo action name)", "Undo action name");
- case EditAction::ConvertToUnorderedList:
- return WEB_UI_STRING_KEY("Convert to Unordered List", "Convert to Unordered List (Undo action name)", "Undo action name");
- case EditAction::InsertEditableImage:
- return WEB_UI_STRING_KEY("Insert Drawing", "Insert Drawing (Undo action name)", "Undo action name");
- }
- return String();
-}
-
} // namespace WebKit
Modified: trunk/Source/WebKit/UIProcess/WebEditCommandProxy.h (239626 => 239627)
--- trunk/Source/WebKit/UIProcess/WebEditCommandProxy.h 2019-01-04 19:52:26 UTC (rev 239626)
+++ trunk/Source/WebKit/UIProcess/WebEditCommandProxy.h 2019-01-04 19:56:51 UTC (rev 239627)
@@ -52,8 +52,6 @@
void unapply();
void reapply();
- static String nameForEditAction(WebCore::EditAction);
-
private:
WebEditCommandProxy(WebUndoStepID commandID, WebCore::EditAction, WebPageProxy*);
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (239626 => 239627)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2019-01-04 19:52:26 UTC (rev 239626)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2019-01-04 19:56:51 UTC (rev 239627)
@@ -5711,18 +5711,18 @@
pageClient().registerEditCommand(WTFMove(commandProxy), undoOrRedo);
}
-void WebPageProxy::addEditCommand(WebEditCommandProxy* command)
+void WebPageProxy::addEditCommand(WebEditCommandProxy& command)
{
- m_editCommandSet.add(command);
+ m_editCommandSet.add(&command);
}
-void WebPageProxy::removeEditCommand(WebEditCommandProxy* command)
+void WebPageProxy::removeEditCommand(WebEditCommandProxy& command)
{
- m_editCommandSet.remove(command);
+ m_editCommandSet.remove(&command);
if (!isValid())
return;
- m_process->send(Messages::WebPage::DidRemoveEditCommand(command->commandID()), m_pageID);
+ m_process->send(Messages::WebPage::DidRemoveEditCommand(command.commandID()), m_pageID);
}
bool WebPageProxy::canUndo()
@@ -5735,11 +5735,6 @@
return pageClient().canUndoRedo(UndoOrRedo::Redo);
}
-bool WebPageProxy::isValidEditCommand(WebEditCommandProxy* command)
-{
- return m_editCommandSet.find(command) != m_editCommandSet.end();
-}
-
SpellDocumentTag WebPageProxy::spellDocumentTag()
{
if (!m_spellDocumentTag)
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (239626 => 239627)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.h 2019-01-04 19:52:26 UTC (rev 239626)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h 2019-01-04 19:56:51 UTC (rev 239627)
@@ -1007,9 +1007,8 @@
virtual void exitAcceleratedCompositingMode();
virtual void updateAcceleratedCompositingMode(const LayerTreeContext&);
- void addEditCommand(WebEditCommandProxy*);
- void removeEditCommand(WebEditCommandProxy*);
- bool isValidEditCommand(WebEditCommandProxy*);
+ void addEditCommand(WebEditCommandProxy&);
+ void removeEditCommand(WebEditCommandProxy&);
void registerEditCommand(Ref<WebEditCommandProxy>&&, UndoOrRedo);
bool canUndo();
Modified: trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm (239626 => 239627)
--- trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm 2019-01-04 19:52:26 UTC (rev 239626)
+++ trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm 2019-01-04 19:56:51 UTC (rev 239627)
@@ -265,7 +265,7 @@
void PageClientImpl::registerEditCommand(Ref<WebEditCommandProxy>&& command, UndoOrRedo undoOrRedo)
{
- auto actionName = WebEditCommandProxy::nameForEditAction(command->editAction());
+ auto actionName = WebCore::nameForUndoRedo(command->editAction());
auto commandObjC = adoptNS([[WKEditCommand alloc] initWithWebEditCommandProxy:WTFMove(command)]);
NSUndoManager *undoManager = [m_contentView undoManager];
Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (239626 => 239627)
--- trunk/Source/WebKitLegacy/mac/ChangeLog 2019-01-04 19:52:26 UTC (rev 239626)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog 2019-01-04 19:56:51 UTC (rev 239627)
@@ -1,3 +1,16 @@
+2019-01-04 Wenson Hsieh <wenson_hs...@apple.com>
+
+ [Cocoa] Merge WebEditCommandProxy::nameForEditAction and undoNameForEditAction into a single function
+ https://bugs.webkit.org/show_bug.cgi?id=193129
+
+ Reviewed by Tim Horton.
+
+ Remove undoNameForEditAction and use WebCore::nameForUndoRedo instead.
+
+ * WebCoreSupport/WebEditorClient.mm:
+ (WebEditorClient::registerUndoOrRedoStep):
+ (undoNameForEditAction): Deleted.
+
2019-01-02 Wenson Hsieh <wenson_hs...@apple.com>
Add support for using the current text selection as the find string on iOS
Modified: trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebEditorClient.mm (239626 => 239627)
--- trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebEditorClient.mm 2019-01-04 19:52:26 UTC (rev 239626)
+++ trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebEditorClient.mm 2019-01-04 19:56:51 UTC (rev 239627)
@@ -589,77 +589,6 @@
return [[m_webView _editingDelegateForwarder] webView:m_webView shouldInsertNode:kit(node) replacingDOMRange:kit(replacingRange) givenAction:(WebViewInsertAction)givenAction];
}
-static NSString* undoNameForEditAction(EditAction editAction)
-{
- // FIXME: This is identical to code in WebKit2's WebEditCommandProxy class; would be nice to share the strings instead of having two copies.
- switch (editAction) {
- case EditAction::Unspecified: return nil;
- case EditAction::Insert: return nil;
- case EditAction::InsertReplacement: return nil;
- case EditAction::InsertFromDrop: return nil;
- case EditAction::SetColor: return UI_STRING_KEY_INTERNAL("Set Color", "Set Color (Undo action name)", "Undo action name");
- case EditAction::SetBackgroundColor: return UI_STRING_KEY_INTERNAL("Set Background Color", "Set Background Color (Undo action name)", "Undo action name");
- case EditAction::TurnOffKerning: return UI_STRING_KEY_INTERNAL("Turn Off Kerning", "Turn Off Kerning (Undo action name)", "Undo action name");
- case EditAction::TightenKerning: return UI_STRING_KEY_INTERNAL("Tighten Kerning", "Tighten Kerning (Undo action name)", "Undo action name");
- case EditAction::LoosenKerning: return UI_STRING_KEY_INTERNAL("Loosen Kerning", "Loosen Kerning (Undo action name)", "Undo action name");
- case EditAction::UseStandardKerning: return UI_STRING_KEY_INTERNAL("Use Standard Kerning", "Use Standard Kerning (Undo action name)", "Undo action name");
- case EditAction::TurnOffLigatures: return UI_STRING_KEY_INTERNAL("Turn Off Ligatures", "Turn Off Ligatures (Undo action name)", "Undo action name");
- case EditAction::UseStandardLigatures: return UI_STRING_KEY_INTERNAL("Use Standard Ligatures", "Use Standard Ligatures (Undo action name)", "Undo action name");
- case EditAction::UseAllLigatures: return UI_STRING_KEY_INTERNAL("Use All Ligatures", "Use All Ligatures (Undo action name)", "Undo action name");
- case EditAction::RaiseBaseline: return UI_STRING_KEY_INTERNAL("Raise Baseline", "Raise Baseline (Undo action name)", "Undo action name");
- case EditAction::LowerBaseline: return UI_STRING_KEY_INTERNAL("Lower Baseline", "Lower Baseline (Undo action name)", "Undo action name");
- case EditAction::SetTraditionalCharacterShape: return UI_STRING_KEY_INTERNAL("Set Traditional Character Shape", "Set Traditional Character Shape (Undo action name)", "Undo action name");
- case EditAction::SetFont: return UI_STRING_KEY_INTERNAL("Set Font", "Set Font (Undo action name)", "Undo action name");
- case EditAction::ChangeAttributes: return UI_STRING_KEY_INTERNAL("Change Attributes", "Change Attributes (Undo action name)", "Undo action name");
- case EditAction::AlignLeft: return UI_STRING_KEY_INTERNAL("Align Left", "Align Left (Undo action name)", "Undo action name");
- case EditAction::AlignRight: return UI_STRING_KEY_INTERNAL("Align Right", "Align Right (Undo action name)", "Undo action name");
- case EditAction::Center: return UI_STRING_KEY_INTERNAL("Center", "Center (Undo action name)", "Undo action name");
- case EditAction::Justify: return UI_STRING_KEY_INTERNAL("Justify", "Justify (Undo action name)", "Undo action name");
- case EditAction::SetWritingDirection: return UI_STRING_KEY_INTERNAL("Set Writing Direction", "Set Writing Direction (Undo action name)", "Undo action name");
- case EditAction::Subscript: return UI_STRING_KEY_INTERNAL("Subscript", "Subscript (Undo action name)", "Undo action name");
- case EditAction::Superscript: return UI_STRING_KEY_INTERNAL("Superscript", "Superscript (Undo action name)", "Undo action name");
- case EditAction::Underline: return UI_STRING_KEY_INTERNAL("Underline", "Underline (Undo action name)", "Undo action name");
- case EditAction::Outline: return UI_STRING_KEY_INTERNAL("Outline", "Outline (Undo action name)", "Undo action name");
- case EditAction::Unscript: return UI_STRING_KEY_INTERNAL("Unscript", "Unscript (Undo action name)", "Undo action name");
- case EditAction::DeleteByDrag: return UI_STRING_KEY_INTERNAL("Drag", "Drag (Undo action name)", "Undo action name");
- case EditAction::Cut: return UI_STRING_KEY_INTERNAL("Cut", "Cut (Undo action name)", "Undo action name");
- case EditAction::Paste: return UI_STRING_KEY_INTERNAL("Paste", "Paste (Undo action name)", "Undo action name");
- case EditAction::PasteFont: return UI_STRING_KEY_INTERNAL("Paste Font", "Paste Font (Undo action name)", "Undo action name");
- case EditAction::PasteRuler: return UI_STRING_KEY_INTERNAL("Paste Ruler", "Paste Ruler (Undo action name)", "Undo action name");
- case EditAction::TypingDeleteSelection:
- case EditAction::TypingDeleteBackward:
- case EditAction::TypingDeleteForward:
- case EditAction::TypingDeleteWordBackward:
- case EditAction::TypingDeleteWordForward:
- case EditAction::TypingDeleteLineBackward:
- case EditAction::TypingDeleteLineForward:
- case EditAction::TypingDeletePendingComposition:
- case EditAction::TypingDeleteFinalComposition:
- case EditAction::TypingInsertText:
- case EditAction::TypingInsertLineBreak:
- case EditAction::TypingInsertParagraph:
- case EditAction::TypingInsertPendingComposition:
- case EditAction::TypingInsertFinalComposition:
- return UI_STRING_KEY_INTERNAL("Typing", "Typing (Undo action name)", "Undo action name");
- case EditAction::CreateLink: return UI_STRING_KEY_INTERNAL("Create Link", "Create Link (Undo action name)", "Undo action name");
- case EditAction::Unlink: return UI_STRING_KEY_INTERNAL("Unlink", "Unlink (Undo action name)", "Undo action name");
- case EditAction::InsertOrderedList:
- case EditAction::InsertUnorderedList:
- return UI_STRING_KEY_INTERNAL("Insert List", "Insert List (Undo action name)", "Undo action name");
- case EditAction::FormatBlock: return UI_STRING_KEY_INTERNAL("Formatting", "Format Block (Undo action name)", "Undo action name");
- case EditAction::Indent: return UI_STRING_KEY_INTERNAL("Indent", "Indent (Undo action name)", "Undo action name");
- case EditAction::Outdent: return UI_STRING_KEY_INTERNAL("Outdent", "Outdent (Undo action name)", "Undo action name");
- case EditAction::Bold: return UI_STRING_KEY_INTERNAL("Bold", "Bold (Undo action name)", "Undo action name");
- case EditAction::Italics: return UI_STRING_KEY_INTERNAL("Italics", "Italics (Undo action name)", "Undo action name");
- case EditAction::Delete: return UI_STRING_KEY_INTERNAL("Delete", "Delete (Undo action name)", "Undo action name");
- case EditAction::Dictation: return UI_STRING_KEY_INTERNAL("Dictation", "Dictation (Undo action name)", "Undo action name");
- case EditAction::ConvertToOrderedList: return UI_STRING_KEY_INTERNAL("Convert to Ordered List", "Convert to Ordered List (Undo action name)", "Undo action name");
- case EditAction::ConvertToUnorderedList: return UI_STRING_KEY_INTERNAL("Convert to Unordered List", "Convert to Unordered List (Undo action name)", "Undo action name");
- case EditAction::InsertEditableImage: return UI_STRING_KEY_INTERNAL("Insert Drawing", "Insert Drawing (Undo action name)", "Undo action name");
- }
- return nil;
-}
-
void WebEditorClient::registerUndoOrRedoStep(UndoStep& step, bool isRedo)
{
NSUndoManager *undoManager = [m_webView undoManager];
@@ -672,7 +601,7 @@
return;
#endif
- NSString *actionName = undoNameForEditAction(step.editingAction());
+ NSString *actionName = WebCore::nameForUndoRedo(step.editingAction());
WebUndoStep *webEntry = [WebUndoStep stepWithUndoStep:step];
[undoManager registerUndoWithTarget:m_undoTarget.get() selector:(isRedo ? @selector(redoEditing:) : @selector(undoEditing:)) object:webEntry];
if (actionName)