WebKit Bugzilla
Attachment 359848 Details for
Bug 193704
: Introduce CustomUndoStep.h and CustomUndoStep.cpp
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch for landing
bug-193704-20190122213021.patch (text/plain), 13.33 KB, created by
Wenson Hsieh
on 2019-01-22 21:30:22 PST
(
hide
)
Description:
Patch for landing
Filename:
MIME Type:
Creator:
Wenson Hsieh
Created:
2019-01-22 21:30:22 PST
Size:
13.33 KB
patch
obsolete
>Subversion Revision: 240316 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 9aaabb0b04663b6bf0adf22ebab3dfef36aaaec6..72c1343b43432d4417541c030e62288a88a1f353 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,38 @@ >+2019-01-22 Wenson Hsieh <wenson_hsieh@apple.com> >+ >+ Introduce CustomUndoStep.h and CustomUndoStep.cpp >+ https://bugs.webkit.org/show_bug.cgi?id=193704 >+ <rdar://problem/44807048> >+ >+ Reviewed by Ryosuke Niwa. >+ >+ 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/CustomUndoStep.cpp: >+ (WebCore::CustomUndoStep::CustomUndoStep): >+ >+ Subclass UndoStep. >+ >+ (WebCore::CustomUndoStep::unapply): >+ (WebCore::CustomUndoStep::reapply): >+ >+ If possible, invoke the UndoItem's undo and redo handlers. >+ >+ (WebCore::CustomUndoStep::isValid const): >+ * editing/CustomUndoStep.h: >+ * editing/EditingStyle.cpp: >+ * editing/InsertEditableImageCommand.cpp: >+ (WebCore::InsertEditableImageCommand::doApply): >+ >+ Unified build fixes. >+ >+ * 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/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 18568f7c8ce086de26993876d634574b7a3e9187..756097fcf5a9281eec713724bac318e46bb56acd 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -251,19 +251,6 @@ > * WebProcess/WebProcess.h: > * WebProcess/WebProcess.messages.in: > >-2019-01-22 Per Arne Vollan <pvollan@apple.com> >- >- [macOS] Adjust logging policy in WebKit's sandbox >- https://bugs.webkit.org/show_bug.cgi?id=193454 >- >- Reviewed by Brent Fulgham. >- >- Add a rule to initially deny all calls, since the default is to allow every call. >- Later rules allow syscalls that we determined are needed for proper WebKit function. >- This reduces the API surface available to attackers. >- >- * WebProcess/com.apple.WebProcess.sb.in: >- > 2019-01-22 Daniel Bates <dabates@apple.com> > > [iOS] WebKit should handle shift state changes when using the software keyboard >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/CustomUndoStep.cpp b/Source/WebCore/editing/CustomUndoStep.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..917f2aab75a68f19c24dd8cc625a69ecf3b3fb6b >--- /dev/null >+++ b/Source/WebCore/editing/CustomUndoStep.cpp >@@ -0,0 +1,68 @@ >+/* >+ * 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(); >+} >+ >+} // namespace WebCore >diff --git a/Source/WebCore/editing/CustomUndoStep.h b/Source/WebCore/editing/CustomUndoStep.h >new file mode 100644 >index 0000000000000000000000000000000000000000..fbce4543623125acc5f8d79660c9ed71c67f8294 >--- /dev/null >+++ b/Source/WebCore/editing/CustomUndoStep.h >@@ -0,0 +1,56 @@ >+/* >+ * 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; } >+ >+ 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/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 { >diff --git a/Source/WebKit/WebProcess/com.apple.WebProcess.sb.in b/Source/WebKit/WebProcess/com.apple.WebProcess.sb.in >index cd9e2136be821dd07dfaae323cef1c4da7ce2a5a..ca74c71cebe952afcac42598a16827b0b17fb500 100644 >--- a/Source/WebKit/WebProcess/com.apple.WebProcess.sb.in >+++ b/Source/WebKit/WebProcess/com.apple.WebProcess.sb.in >@@ -825,7 +825,6 @@ > #endif // PLATFORM(MAC) > > (when (defined? 'syscall-unix) >- (deny syscall-unix (with termination)) > (allow syscall-unix > (syscall-number SYS_exit) > (syscall-number SYS_read)
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
Flags:
wenson_hsieh
:
commit-queue-
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 193704
:
359840
|
359848
|
359849