Diff
Modified: trunk/Source/WebKit/ChangeLog (239588 => 239589)
--- trunk/Source/WebKit/ChangeLog 2019-01-03 07:18:32 UTC (rev 239588)
+++ trunk/Source/WebKit/ChangeLog 2019-01-03 15:34:34 UTC (rev 239589)
@@ -1,3 +1,49 @@
+2019-01-03 Wenson Hsieh <[email protected]>
+
+ WebUndoStep's monotonically increasing identifier should be a WebUndoStepID instead of uint64_t
+ https://bugs.webkit.org/show_bug.cgi?id=193100
+
+ Reviewed by Simon Fraser.
+
+ Add a type alias, WebUndoStepID, to represent the monotonically increasing undo step ID for each undoable
+ editing command, and use this type alias in lieu of `uint64_t`. No change in behavior.
+
+ * UIProcess/WebEditCommandProxy.cpp:
+ (WebKit::WebEditCommandProxy::WebEditCommandProxy):
+ * UIProcess/WebEditCommandProxy.h:
+ (WebKit::WebEditCommandProxy::create):
+ (WebKit::WebEditCommandProxy::commandID const):
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::registerEditCommandForUndo):
+ * UIProcess/WebPageProxy.h:
+ * WebKit.xcodeproj/project.pbxproj:
+ * WebProcess/WebCoreSupport/WebEditorClient.cpp:
+ (WebKit::WebEditorClient::registerUndoStep):
+
+ Store the step ID in a temporary variable, since `webUndoStep` is now moved when calling `addWebUndoStep`.
+
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::webUndoStep):
+ (WebKit::WebPage::addWebUndoStep):
+
+ Make this take a `Ref<WebUndoStep>&&` instead of a `WebUndoStep*`, and use move semantics to transfer the
+ given `Ref` to the table.
+
+ (WebKit::WebPage::removeWebEditCommand):
+ (WebKit::WebPage::unapplyEditCommand):
+ (WebKit::WebPage::reapplyEditCommand):
+
+ Use `auto*` in a couple of places.
+
+ (WebKit::WebPage::didRemoveEditCommand):
+ * WebProcess/WebPage/WebPage.h:
+ * WebProcess/WebPage/WebUndoStep.cpp:
+ (WebKit::generateUndoStep):
+ * WebProcess/WebPage/WebUndoStep.h:
+ (WebKit::WebUndoStep::stepID const):
+ (WebKit::WebUndoStep::WebUndoStep):
+ * WebProcess/WebPage/WebUndoStepID.h: Copied from Source/WebKit/WebProcess/WebPage/WebUndoStep.cpp.
+
2019-01-02 Wenson Hsieh <[email protected]>
Add support for using the current text selection as the find string on iOS
Modified: trunk/Source/WebKit/UIProcess/WebEditCommandProxy.cpp (239588 => 239589)
--- trunk/Source/WebKit/UIProcess/WebEditCommandProxy.cpp 2019-01-03 07:18:32 UTC (rev 239588)
+++ trunk/Source/WebKit/UIProcess/WebEditCommandProxy.cpp 2019-01-03 15:34:34 UTC (rev 239589)
@@ -36,7 +36,7 @@
namespace WebKit {
using namespace WebCore;
-WebEditCommandProxy::WebEditCommandProxy(uint64_t commandID, WebCore::EditAction editAction, WebPageProxy* page)
+WebEditCommandProxy::WebEditCommandProxy(WebUndoStepID commandID, WebCore::EditAction editAction, WebPageProxy* page)
: m_commandID(commandID)
, m_editAction(editAction)
, m_page(page)
Modified: trunk/Source/WebKit/UIProcess/WebEditCommandProxy.h (239588 => 239589)
--- trunk/Source/WebKit/UIProcess/WebEditCommandProxy.h 2019-01-03 07:18:32 UTC (rev 239588)
+++ trunk/Source/WebKit/UIProcess/WebEditCommandProxy.h 2019-01-03 15:34:34 UTC (rev 239589)
@@ -26,6 +26,7 @@
#pragma once
#include "APIObject.h"
+#include "WebUndoStepID.h"
#include <WebCore/EditAction.h>
#include <wtf/Forward.h>
#include <wtf/RefCounted.h>
@@ -37,13 +38,13 @@
class WebEditCommandProxy : public API::ObjectImpl<API::Object::Type::EditCommandProxy> {
public:
- static Ref<WebEditCommandProxy> create(uint64_t commandID, WebCore::EditAction editAction, WebPageProxy* page)
+ static Ref<WebEditCommandProxy> create(WebUndoStepID commandID, WebCore::EditAction editAction, WebPageProxy* page)
{
return adoptRef(*new WebEditCommandProxy(commandID, editAction, page));
}
~WebEditCommandProxy();
- uint64_t commandID() const { return m_commandID; }
+ WebUndoStepID commandID() const { return m_commandID; }
WebCore::EditAction editAction() const { return m_editAction; }
void invalidate() { m_page = 0; }
@@ -54,9 +55,9 @@
static String nameForEditAction(WebCore::EditAction);
private:
- WebEditCommandProxy(uint64_t commandID, WebCore::EditAction, WebPageProxy*);
+ WebEditCommandProxy(WebUndoStepID commandID, WebCore::EditAction, WebPageProxy*);
- uint64_t m_commandID;
+ WebUndoStepID m_commandID;
WebCore::EditAction m_editAction;
WebPageProxy* m_page;
};
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (239588 => 239589)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2019-01-03 07:18:32 UTC (rev 239588)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2019-01-03 15:34:34 UTC (rev 239589)
@@ -5340,7 +5340,7 @@
// Undo management
-void WebPageProxy::registerEditCommandForUndo(uint64_t commandID, uint32_t editAction)
+void WebPageProxy::registerEditCommandForUndo(WebUndoStepID commandID, uint32_t editAction)
{
registerEditCommand(WebEditCommandProxy::create(commandID, static_cast<EditAction>(editAction), this), UndoOrRedo::Undo);
}
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (239588 => 239589)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.h 2019-01-03 07:18:32 UTC (rev 239588)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h 2019-01-03 15:34:34 UTC (rev 239589)
@@ -65,6 +65,7 @@
#include "WebPageProxyMessages.h"
#include "WebPopupMenuProxy.h"
#include "WebProcessLifetimeTracker.h"
+#include "WebUndoStepID.h"
#include "WebsitePoliciesData.h"
#include <WebCore/ActivityState.h>
#include <WebCore/AutoplayEvent.h>
@@ -1615,7 +1616,7 @@
void backForwardClear();
// Undo management
- void registerEditCommandForUndo(uint64_t commandID, uint32_t editAction);
+ void registerEditCommandForUndo(WebUndoStepID commandID, uint32_t editAction);
void registerInsertionUndoGrouping();
void clearAllEditCommands();
void canUndoRedo(UndoOrRedo, bool& result);
Modified: trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj (239588 => 239589)
--- trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj 2019-01-03 07:18:32 UTC (rev 239588)
+++ trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj 2019-01-03 15:34:34 UTC (rev 239589)
@@ -4511,6 +4511,7 @@
F48D2A8421583A0200C6752B /* AppKitSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppKitSPI.h; sourceTree = "<group>"; };
F496A42F1F58A272004C1757 /* DragDropInteractionState.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = DragDropInteractionState.h; path = ios/DragDropInteractionState.h; sourceTree = "<group>"; };
F496A4301F58A272004C1757 /* DragDropInteractionState.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = DragDropInteractionState.mm; path = ios/DragDropInteractionState.mm; sourceTree = "<group>"; };
+ F4B378D021DDBBAB0095A378 /* WebUndoStepID.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebUndoStepID.h; sourceTree = "<group>"; };
F4D5F519206087A00038BBA8 /* WKTextInputListViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WKTextInputListViewController.h; path = ios/forms/WKTextInputListViewController.h; sourceTree = "<group>"; };
F4D5F51A206087A10038BBA8 /* WKTextInputListViewController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WKTextInputListViewController.mm; path = ios/forms/WKTextInputListViewController.mm; sourceTree = "<group>"; };
F4D5F51B206087A10038BBA8 /* WKQuickboardListViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WKQuickboardListViewController.h; path = ios/forms/WKQuickboardListViewController.h; sourceTree = "<group>"; };
@@ -7268,6 +7269,7 @@
2D5C9D0419C81D8F00B3C5C1 /* WebPageOverlay.h */,
BCA0EF7E12331E78007D3CFB /* WebUndoStep.cpp */,
BCA0EF7D12331E78007D3CFB /* WebUndoStep.h */,
+ F4B378D021DDBBAB0095A378 /* WebUndoStepID.h */,
51D1242A1E6D41BC002B2820 /* WebURLSchemeHandlerProxy.cpp */,
51D1242B1E6D41BC002B2820 /* WebURLSchemeHandlerProxy.h */,
51D124211E6D349A002B2820 /* WebURLSchemeTaskProxy.cpp */,
Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebEditorClient.cpp (239588 => 239589)
--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebEditorClient.cpp 2019-01-03 07:18:32 UTC (rev 239588)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebEditorClient.cpp 2019-01-03 15:34:34 UTC (rev 239589)
@@ -310,10 +310,11 @@
return;
auto webStep = WebUndoStep::create(step);
+ auto stepID = webStep->stepID();
auto editAction = static_cast<uint32_t>(webStep->step().editingAction());
- m_page->addWebUndoStep(webStep->stepID(), webStep.ptr());
- m_page->send(Messages::WebPageProxy::RegisterEditCommandForUndo(webStep->stepID(), editAction), m_page->pageID(), IPC::SendOption::DispatchMessageEvenWhenWaitingForSyncReply);
+ m_page->addWebUndoStep(stepID, WTFMove(webStep));
+ m_page->send(Messages::WebPageProxy::RegisterEditCommandForUndo(stepID, editAction), m_page->pageID(), IPC::SendOption::DispatchMessageEvenWhenWaitingForSyncReply);
}
void WebEditorClient::registerRedoStep(UndoStep&)
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (239588 => 239589)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2019-01-03 07:18:32 UTC (rev 239588)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2019-01-03 15:34:34 UTC (rev 239589)
@@ -3765,17 +3765,17 @@
#endif // ENABLE(DRAG_SUPPORT)
-WebUndoStep* WebPage::webUndoStep(uint64_t stepID)
+WebUndoStep* WebPage::webUndoStep(WebUndoStepID stepID)
{
return m_undoStepMap.get(stepID);
}
-void WebPage::addWebUndoStep(uint64_t stepID, WebUndoStep* entry)
+void WebPage::addWebUndoStep(WebUndoStepID stepID, Ref<WebUndoStep>&& entry)
{
- m_undoStepMap.set(stepID, entry);
+ m_undoStepMap.set(stepID, WTFMove(entry));
}
-void WebPage::removeWebEditCommand(uint64_t stepID)
+void WebPage::removeWebEditCommand(WebUndoStepID stepID)
{
m_undoStepMap.remove(stepID);
}
@@ -3785,9 +3785,9 @@
return corePage() && corePage()->isAlwaysOnLoggingAllowed();
}
-void WebPage::unapplyEditCommand(uint64_t stepID)
+void WebPage::unapplyEditCommand(WebUndoStepID stepID)
{
- WebUndoStep* step = webUndoStep(stepID);
+ auto* step = webUndoStep(stepID);
if (!step)
return;
@@ -3794,9 +3794,9 @@
step->step().unapply();
}
-void WebPage::reapplyEditCommand(uint64_t stepID)
+void WebPage::reapplyEditCommand(WebUndoStepID stepID)
{
- WebUndoStep* step = webUndoStep(stepID);
+ auto* step = webUndoStep(stepID);
if (!step)
return;
@@ -3805,7 +3805,7 @@
m_isInRedo = false;
}
-void WebPage::didRemoveEditCommand(uint64_t commandID)
+void WebPage::didRemoveEditCommand(WebUndoStepID commandID)
{
removeWebEditCommand(commandID);
}
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.h (239588 => 239589)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.h 2019-01-03 07:18:32 UTC (rev 239588)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.h 2019-01-03 15:34:34 UTC (rev 239589)
@@ -50,6 +50,7 @@
#include "UserData.h"
#include "WebBackForwardListProxy.h"
#include "WebURLSchemeHandler.h"
+#include "WebUndoStepID.h"
#include "WebUserContentController.h"
#include "WebsitePoliciesData.h"
#include <_javascript_Core/InspectorFrontendChannel.h>
@@ -355,9 +356,9 @@
const String& overrideContentSecurityPolicy() const { return m_overrideContentSecurityPolicy; }
- WebUndoStep* webUndoStep(uint64_t);
- void addWebUndoStep(uint64_t, WebUndoStep*);
- void removeWebEditCommand(uint64_t);
+ WebUndoStep* webUndoStep(WebUndoStepID);
+ void addWebUndoStep(WebUndoStepID, Ref<WebUndoStep>&&);
+ void removeWebEditCommand(WebUndoStepID);
bool isInRedo() const { return m_isInRedo; }
bool isAlwaysOnLoggingAllowed() const;
@@ -1324,9 +1325,9 @@
void setMainFrameIsScrollable(bool);
- void unapplyEditCommand(uint64_t commandID);
- void reapplyEditCommand(uint64_t commandID);
- void didRemoveEditCommand(uint64_t commandID);
+ void unapplyEditCommand(WebUndoStepID commandID);
+ void reapplyEditCommand(WebUndoStepID commandID);
+ void didRemoveEditCommand(WebUndoStepID commandID);
void findString(const String&, uint32_t findOptions, uint32_t maxMatchCount);
void findStringMatches(const String&, uint32_t findOptions, uint32_t maxMatchCount);
@@ -1574,7 +1575,7 @@
RunLoop::Timer<WebPage> m_setCanStartMediaTimer;
bool m_mayStartMediaWhenInWindow { false };
- HashMap<uint64_t, RefPtr<WebUndoStep>> m_undoStepMap;
+ HashMap<WebUndoStepID, RefPtr<WebUndoStep>> m_undoStepMap;
#if ENABLE(CONTEXT_MENUS)
std::unique_ptr<API::InjectedBundle::PageContextMenuClient> m_contextMenuClient;
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebUndoStep.cpp (239588 => 239589)
--- trunk/Source/WebKit/WebProcess/WebPage/WebUndoStep.cpp 2019-01-03 07:18:32 UTC (rev 239588)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebUndoStep.cpp 2019-01-03 15:34:34 UTC (rev 239589)
@@ -28,9 +28,9 @@
namespace WebKit {
-static uint64_t generateUndoStep()
+static WebUndoStepID generateUndoStep()
{
- static uint64_t uniqueEntryID = 1;
+ static WebUndoStepID uniqueEntryID = 1;
return uniqueEntryID++;
}
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebUndoStep.h (239588 => 239589)
--- trunk/Source/WebKit/WebProcess/WebPage/WebUndoStep.h 2019-01-03 07:18:32 UTC (rev 239588)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebUndoStep.h 2019-01-03 15:34:34 UTC (rev 239589)
@@ -25,6 +25,7 @@
#pragma once
+#include "WebUndoStepID.h"
#include <WebCore/UndoStep.h>
#include <wtf/Ref.h>
@@ -36,10 +37,10 @@
~WebUndoStep();
WebCore::UndoStep& step() const { return m_step.get(); }
- uint64_t stepID() const { return m_stepID; }
+ WebUndoStepID stepID() const { return m_stepID; }
private:
- WebUndoStep(Ref<WebCore::UndoStep>&& step, uint64_t stepID)
+ WebUndoStep(Ref<WebCore::UndoStep>&& step, WebUndoStepID stepID)
: m_step(WTFMove(step))
, m_stepID(stepID)
{
@@ -46,7 +47,7 @@
}
Ref<WebCore::UndoStep> m_step;
- uint64_t m_stepID;
+ WebUndoStepID m_stepID;
};
} // namespace WebKit
Copied: trunk/Source/WebKit/WebProcess/WebPage/WebUndoStepID.h (from rev 239588, trunk/Source/WebKit/WebProcess/WebPage/WebUndoStep.cpp) (0 => 239589)
--- trunk/Source/WebKit/WebProcess/WebPage/WebUndoStepID.h (rev 0)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebUndoStepID.h 2019-01-03 15:34:34 UTC (rev 239589)
@@ -0,0 +1,28 @@
+/*
+ * 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
+
+using WebUndoStepID = uint64_t;