WebKit Bugzilla
Attachment 359834 Details for
Bug 193111
: [Cocoa] Allow the page to add to the platform undo stack via UndoManager.addItem()
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Part 2 (fix GTK/WPE builds)
bug-193111-20190122185344.patch (text/plain), 13.55 KB, created by
Wenson Hsieh
on 2019-01-22 18:53:45 PST
(
hide
)
Description:
Part 2 (fix GTK/WPE builds)
Filename:
MIME Type:
Creator:
Wenson Hsieh
Created:
2019-01-22 18:53:45 PST
Size:
13.55 KB
patch
obsolete
>Subversion Revision: 240313 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 9aaabb0b04663b6bf0adf22ebab3dfef36aaaec6..77775d53ace625457a35c82f7dbba6c0a687a9bb 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,44 @@ >+2019-01-19 Wenson Hsieh <wenson_hsieh@apple.com> >+ >+ Introduce CustomUndoStep.h and CustomUndoStep.cpp >+ https://bugs.webkit.org/show_bug.cgi?id=193111 >+ <rdar://problem/44807048> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ This patch is more work in progress towards supporting `UndoManager.addItem()`. Here, we introduce a helper >+ class, CustomUndoStep, that holds a weak reference to a script-defined UndoItem. See below for more details. >+ >+ No change in behavior. >+ >+ * Sources.txt: >+ * WebCore.xcodeproj/project.pbxproj: >+ * editing/CompositeEditCommand.h: >+ * editing/CustomUndoStep.cpp: >+ >+ Subclass UndoStep. >+ >+ (WebCore::CustomUndoStep::CustomUndoStep): >+ (WebCore::CustomUndoStep::unapply): >+ (WebCore::CustomUndoStep::reapply): >+ >+ If possible, invoke the UndoItem's undo and redo handlers. >+ >+ (WebCore::CustomUndoStep::isValid const): >+ (WebCore::CustomUndoStep::customUndoLabel const): >+ >+ The undo/redo action label used to represent this in platform UI. >+ >+ * editing/CustomUndoStep.h: >+ * editing/EditingStyle.cpp: >+ * editing/InsertEditableImageCommand.cpp: >+ (WebCore::InsertEditableImageCommand::doApply): >+ >+ Unified build fixes. >+ >+ * editing/UndoStep.h: >+ * page/UndoItem.h: >+ > 2019-01-22 Wenson Hsieh <wenson_hsieh@apple.com> > > Add some bindings-related bookkeeping to UndoManager and UndoItem >diff --git a/Source/WebCore/Sources.txt b/Source/WebCore/Sources.txt >index 7c484448f4d3a65960cca946d74649805cf08040..d2adb0e5409f18999c4876c3dd920bf9d3805e5f 100644 >--- a/Source/WebCore/Sources.txt >+++ b/Source/WebCore/Sources.txt >@@ -952,6 +952,7 @@ editing/BreakBlockquoteCommand.cpp > editing/ChangeListTypeCommand.cpp > editing/CompositeEditCommand.cpp > editing/CreateLinkCommand.cpp >+editing/CustomUndoStep.cpp > editing/DeleteFromTextNodeCommand.cpp > editing/DeleteSelectionCommand.cpp > editing/DictationAlternative.cpp >diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >index d1851ebddf0fbd815177ce4ddf937e4ebe4962c7..dab4df504e26433cde0d1c144d46b53c5ca9e928 100644 >--- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj >+++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >@@ -15131,6 +15131,8 @@ > F4D9817E2195FBF6008230FC /* ChangeListTypeCommand.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ChangeListTypeCommand.cpp; sourceTree = "<group>"; }; > F4E1965A21F2395000285078 /* JSUndoItemCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSUndoItemCustom.cpp; sourceTree = "<group>"; }; > F4E1965F21F26E4E00285078 /* UndoItem.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = UndoItem.cpp; sourceTree = "<group>"; }; >+ F4E1966121F27D3C00285078 /* CustomUndoStep.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CustomUndoStep.h; sourceTree = "<group>"; }; >+ F4E1966221F27D3D00285078 /* CustomUndoStep.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CustomUndoStep.cpp; sourceTree = "<group>"; }; > F4E57EDA213F3F5F004EA98E /* FontAttributeChanges.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FontAttributeChanges.h; sourceTree = "<group>"; }; > F4E57EDF213F434A004EA98E /* WebCoreNSFontManagerExtras.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebCoreNSFontManagerExtras.h; sourceTree = "<group>"; }; > F4E57EE0213F434A004EA98E /* WebCoreNSFontManagerExtras.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WebCoreNSFontManagerExtras.mm; sourceTree = "<group>"; }; >@@ -21107,6 +21109,8 @@ > 2DD5A7261EBEE47D009BA597 /* CompositionUnderline.h */, > D0B0556709C6700100307E43 /* CreateLinkCommand.cpp */, > D0B0556609C6700100307E43 /* CreateLinkCommand.h */, >+ F4E1966221F27D3D00285078 /* CustomUndoStep.cpp */, >+ F4E1966121F27D3C00285078 /* CustomUndoStep.h */, > 93309D8F099E64910056E581 /* DeleteFromTextNodeCommand.cpp */, > 93309D90099E64910056E581 /* DeleteFromTextNodeCommand.h */, > 93309D91099E64910056E581 /* DeleteSelectionCommand.cpp */, >diff --git a/Source/WebCore/editing/CompositeEditCommand.h b/Source/WebCore/editing/CompositeEditCommand.h >index 2da520fdc4649292dc7bfca20b7d11b118c5da1c..b2fa5d019a463fc6b250a484a2b43967fe2d61f2 100644 >--- a/Source/WebCore/editing/CompositeEditCommand.h >+++ b/Source/WebCore/editing/CompositeEditCommand.h >@@ -88,6 +88,8 @@ public: > private: > EditCommandComposition(Document&, const VisibleSelection& startingSelection, const VisibleSelection& endingSelection, EditAction); > >+ const String& customUndoLabel() const final { return emptyString(); } >+ > RefPtr<Document> m_document; > VisibleSelection m_startingSelection; > VisibleSelection m_endingSelection; >diff --git a/Source/WebCore/editing/CustomUndoStep.cpp b/Source/WebCore/editing/CustomUndoStep.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..ed8e028b7ca793e57abf957e93f5c9f69a5b22a0 >--- /dev/null >+++ b/Source/WebCore/editing/CustomUndoStep.cpp >@@ -0,0 +1,77 @@ >+/* >+ * 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 "CustomUndoStep.h" >+ >+#include "Document.h" >+#include "UndoItem.h" >+#include "UndoManager.h" >+#include "VoidCallback.h" >+ >+namespace WebCore { >+ >+CustomUndoStep::CustomUndoStep(UndoItem& item) >+ : m_undoItem(makeWeakPtr(item)) >+{ >+} >+ >+void CustomUndoStep::unapply() >+{ >+ if (!isValid()) >+ return; >+ >+ // FIXME: It's currently unclear how input events should be dispatched when unapplying or reapplying custom >+ // edit commands. Should the page be allowed to specify a target in the DOM for undo and redo? >+ Ref<UndoItem> protectedUndoItem(*m_undoItem); >+ protectedUndoItem->document()->updateLayoutIgnorePendingStylesheets(); >+ protectedUndoItem->undoHandler().handleEvent(); >+} >+ >+void CustomUndoStep::reapply() >+{ >+ if (!isValid()) >+ return; >+ >+ Ref<UndoItem> protectedUndoItem(*m_undoItem); >+ protectedUndoItem->document()->updateLayoutIgnorePendingStylesheets(); >+ protectedUndoItem->redoHandler().handleEvent(); >+} >+ >+bool CustomUndoStep::isValid() const >+{ >+ return m_undoItem && m_undoItem->isValid(); >+} >+ >+const String& CustomUndoStep::customUndoLabel() const >+{ >+ if (!isValid()) { >+ ASSERT_NOT_REACHED(); >+ return emptyString(); >+ } >+ return m_undoItem->label(); >+} >+ >+} // namespace WebCore >diff --git a/Source/WebCore/editing/CustomUndoStep.h b/Source/WebCore/editing/CustomUndoStep.h >new file mode 100644 >index 0000000000000000000000000000000000000000..1b6d906b9b8f63af91272f04decf4b19d977c419 >--- /dev/null >+++ b/Source/WebCore/editing/CustomUndoStep.h >@@ -0,0 +1,57 @@ >+/* >+ * 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. >+ */ >+ >+#pragma once >+ >+#include "UndoStep.h" >+#include <wtf/Ref.h> >+#include <wtf/WeakPtr.h> >+ >+namespace WebCore { >+ >+class Document; >+class UndoItem; >+ >+class CustomUndoStep final : public UndoStep { >+public: >+ static Ref<CustomUndoStep> create(UndoItem& item) >+ { >+ return adoptRef(*new CustomUndoStep(item)); >+ } >+ >+private: >+ CustomUndoStep(UndoItem&); >+ >+ void unapply() final; >+ void reapply() final; >+ EditAction editingAction() const final { return EditAction::Unspecified; } >+ const String& customUndoLabel() const final; >+ >+ bool isValid() const; >+ >+ WeakPtr<UndoItem> m_undoItem; >+}; >+ >+} // namespace WebCore >diff --git a/Source/WebCore/editing/EditingStyle.cpp b/Source/WebCore/editing/EditingStyle.cpp >index b38c1509ee979be9e40fe3bad290d4742660006c..6bbf014304b48c7751ec98ccb262b8a9a3070c01 100644 >--- a/Source/WebCore/editing/EditingStyle.cpp >+++ b/Source/WebCore/editing/EditingStyle.cpp >@@ -45,6 +45,7 @@ > #include "Node.h" > #include "NodeTraversal.h" > #include "QualifiedName.h" >+#include "RenderElement.h" > #include "RenderStyle.h" > #include "StyleFontSizeFunctions.h" > #include "StyleProperties.h" >diff --git a/Source/WebCore/editing/InsertEditableImageCommand.cpp b/Source/WebCore/editing/InsertEditableImageCommand.cpp >index 55d1184c7807c7e09a4c5f66e56792ec18a36a26..d9afa56e6cccaf092bb3da52286fade192b69bf0 100644 >--- a/Source/WebCore/editing/InsertEditableImageCommand.cpp >+++ b/Source/WebCore/editing/InsertEditableImageCommand.cpp >@@ -49,10 +49,10 @@ void InsertEditableImageCommand::doApply() > return; > > m_imageElement = HTMLImageElement::create(document()); >- m_imageElement->setAttributeWithoutSynchronization(x_apple_editable_imageAttr, emptyAtom()); >- m_imageElement->setAttributeWithoutSynchronization(widthAttr, AtomicString("100%", AtomicString::ConstructFromLiteral)); >- m_imageElement->setAttributeWithoutSynchronization(heightAttr, AtomicString("300px", AtomicString::ConstructFromLiteral)); >- m_imageElement->setAttributeWithoutSynchronization(styleAttr, AtomicString("display: block", AtomicString::ConstructFromLiteral)); >+ m_imageElement->setAttributeWithoutSynchronization(HTMLNames::x_apple_editable_imageAttr, emptyAtom()); >+ m_imageElement->setAttributeWithoutSynchronization(HTMLNames::widthAttr, AtomicString("100%", AtomicString::ConstructFromLiteral)); >+ m_imageElement->setAttributeWithoutSynchronization(HTMLNames::heightAttr, AtomicString("300px", AtomicString::ConstructFromLiteral)); >+ m_imageElement->setAttributeWithoutSynchronization(HTMLNames::styleAttr, AtomicString("display: block", AtomicString::ConstructFromLiteral)); > > insertNodeAt(*m_imageElement, endingSelection().start()); > setEndingSelection(visiblePositionAfterNode(*m_imageElement)); >diff --git a/Source/WebCore/editing/UndoStep.h b/Source/WebCore/editing/UndoStep.h >index 00c1700107b2cc79cc132679d898d705ba787e78..3490fff898ba6358bb37a58acc26c34497b52411 100644 >--- a/Source/WebCore/editing/UndoStep.h >+++ b/Source/WebCore/editing/UndoStep.h >@@ -32,6 +32,7 @@ > > #include "EditAction.h" > #include <wtf/RefCounted.h> >+#include <wtf/text/WTFString.h> > > namespace WebCore { > >@@ -42,6 +43,7 @@ public: > virtual void unapply() = 0; > virtual void reapply() = 0; > virtual EditAction editingAction() const = 0; >+ virtual const String& customUndoLabel() const = 0; > }; > > } // namespace WebCore >diff --git a/Source/WebCore/page/UndoItem.h b/Source/WebCore/page/UndoItem.h >index 29c102d8ee8e2aa2865f5a8c238b8479909817bd..326284a59c7b5f21f0a0806eaea0000262e76bcc 100644 >--- a/Source/WebCore/page/UndoItem.h >+++ b/Source/WebCore/page/UndoItem.h >@@ -36,7 +36,7 @@ namespace WebCore { > class Document; > class UndoManager; > >-class UndoItem : public RefCounted<UndoItem> { >+class UndoItem : public RefCounted<UndoItem>, public CanMakeWeakPtr<UndoItem> { > WTF_MAKE_ISO_ALLOCATED(UndoItem); > public: > struct Init {
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 193111
:
358427
|
359498
|
359590
|
359591
|
359592
|
359593
|
359594
|
359631
|
359632
|
359819
|
359832
|
359834