Changeset 240342 in webkit
- Timestamp:
- Jan 23, 2019 9:30:05 AM (5 years ago)
- Location:
- trunk/Source
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r240340 r240342 1 2019-01-23 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 Introduce UndoStep::label() and adopt it in WebKitLegacy and WebKit 4 https://bugs.webkit.org/show_bug.cgi?id=193706 5 <rdar://problem/44807048> 6 7 Reviewed by Ryosuke Niwa. 8 9 Refactors some existing logic when registering undoable actions, such that we propagate the undoable action's 10 label string instead of the EditAction to the client layer. This will help make handling of CustomUndoStep's 11 undo/redo label simpler, as the client layer won't need to worry about managing an EditAction and undo/redo 12 label simultaneously. There should be no change in behavior. 13 14 * editing/CompositeEditCommand.cpp: 15 (WebCore::EditCommandComposition::label const): 16 * editing/CompositeEditCommand.h: 17 * editing/CustomUndoStep.cpp: 18 (WebCore::CustomUndoStep::label const): 19 * editing/CustomUndoStep.h: 20 * editing/EditAction.cpp: 21 (WebCore::undoRedoLabel): 22 (WebCore::nameForUndoRedo): Deleted. 23 * editing/EditAction.h: 24 25 Rename nameForUndoRedo to undoRedoLabel, and remove the WEBCORE_EXPORT since it's no longer needed in WebKit or 26 WebKitLegacy. 27 28 * editing/UndoStep.h: 29 30 Add UndoStep::label(). While EditCommandComposition implements this by mapping its EditAction to a 31 localized string, CustomUndoStep implements this by returning the undoable action label provided by script. 32 1 33 2019-01-23 Michael Catanzaro <mcatanzaro@igalia.com> 2 34 -
trunk/Source/WebCore/editing/CompositeEditCommand.cpp
r240237 r240342 303 303 #endif 304 304 305 String EditCommandComposition::label() const 306 { 307 return undoRedoLabel(m_editAction); 308 } 309 305 310 CompositeEditCommand::CompositeEditCommand(Document& document, EditAction editingAction) 306 311 : EditCommand(document, editingAction) -
trunk/Source/WebCore/editing/CompositeEditCommand.h
r239427 r240342 88 88 private: 89 89 EditCommandComposition(Document&, const VisibleSelection& startingSelection, const VisibleSelection& endingSelection, EditAction); 90 91 String label() const final; 90 92 91 93 RefPtr<Document> m_document; -
trunk/Source/WebCore/editing/CustomUndoStep.cpp
r240328 r240342 66 66 } 67 67 68 String CustomUndoStep::label() const 69 { 70 if (!isValid()) { 71 ASSERT_NOT_REACHED(); 72 return emptyString(); 73 } 74 return m_undoItem->label(); 75 } 76 68 77 } // namespace WebCore -
trunk/Source/WebCore/editing/CustomUndoStep.h
r240328 r240342 48 48 void reapply() final; 49 49 EditAction editingAction() const final { return EditAction::Unspecified; } 50 String label() const final; 50 51 51 52 bool isValid() const; -
trunk/Source/WebCore/editing/EditAction.cpp
r239627 r240342 31 31 namespace WebCore { 32 32 33 String nameForUndoRedo(EditAction editAction)33 String undoRedoLabel(EditAction editAction) 34 34 { 35 35 switch (editAction) { -
trunk/Source/WebCore/editing/EditAction.h
r239627 r240342 96 96 }; 97 97 98 W EBCORE_EXPORT WTF::String nameForUndoRedo(EditAction);98 WTF::String undoRedoLabel(EditAction); 99 99 100 100 } // namespace WebCore -
trunk/Source/WebCore/editing/UndoStep.h
r223728 r240342 33 33 #include "EditAction.h" 34 34 #include <wtf/RefCounted.h> 35 #include <wtf/text/WTFString.h> 35 36 36 37 namespace WebCore { … … 43 44 virtual void reapply() = 0; 44 45 virtual EditAction editingAction() const = 0; 46 virtual String label() const = 0; 45 47 }; 46 48 -
trunk/Source/WebKit/ChangeLog
r240341 r240342 1 2019-01-23 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 Introduce UndoStep::label() and adopt it in WebKitLegacy and WebKit 4 https://bugs.webkit.org/show_bug.cgi?id=193706 5 <rdar://problem/44807048> 6 7 Reviewed by Ryosuke Niwa. 8 9 * UIProcess/Cocoa/WebViewImpl.mm: 10 (WebKit::WebViewImpl::registerEditCommand): 11 * UIProcess/WebEditCommandProxy.cpp: 12 (WebKit::WebEditCommandProxy::WebEditCommandProxy): 13 * UIProcess/WebEditCommandProxy.h: 14 15 Drive-by tweak: make WebEditCommandProxy's backpointer to its WebPageProxy a WeakPtr instead of a raw pointer. 16 Additionally, call clear() instead of setting m_page to 0 upon invalidation. Also, turn the WebPageProxy* 17 argument into a WebPageProxy&, since the WebPageProxy must exist when it creates a new WebEditCommandProxy. 18 19 (WebKit::WebEditCommandProxy::create): 20 (WebKit::WebEditCommandProxy::label const): 21 (WebKit::WebEditCommandProxy::invalidate): 22 (WebKit::WebEditCommandProxy::editAction const): Deleted. 23 24 Adjust UI-side logic to just handle the undo/redo label, rather than map the edit action to a localized string. 25 26 * UIProcess/WebPageProxy.cpp: 27 (WebKit::WebPageProxy::registerEditCommandForUndo): 28 (WebKit::WebPageProxy::resetState): 29 30 Tweak this to use std::exchange instead of copying all the WebEditCommandProxy RefPtrs into a separate Vector 31 and then iterating over the Vector. 32 33 * UIProcess/WebPageProxy.h: 34 * UIProcess/WebPageProxy.messages.in: 35 36 Adjust this so that we only send the undo/redo label over IPC, rather than the edit action type. 37 38 * UIProcess/ios/PageClientImplIOS.mm: 39 (WebKit::PageClientImpl::registerEditCommand): 40 * WebProcess/WebCoreSupport/WebEditorClient.cpp: 41 (WebKit::WebEditorClient::registerUndoStep): 42 1 43 2019-01-23 Michael Catanzaro <mcatanzaro@igalia.com> 2 44 -
trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm
r240219 r240342 2693 2693 void WebViewImpl::registerEditCommand(Ref<WebEditCommandProxy>&& command, UndoOrRedo undoOrRedo) 2694 2694 { 2695 auto actionName = WebCore::nameForUndoRedo(command->editAction());2695 auto actionName = command->label(); 2696 2696 auto commandObjC = adoptNS([[WKEditCommand alloc] initWithWebEditCommandProxy:WTFMove(command)]); 2697 2697 -
trunk/Source/WebKit/UIProcess/WebEditCommandProxy.cpp
r239627 r240342 37 37 using namespace WebCore; 38 38 39 WebEditCommandProxy::WebEditCommandProxy(WebUndoStepID commandID, WebCore::EditAction editAction, WebPageProxy*page)39 WebEditCommandProxy::WebEditCommandProxy(WebUndoStepID commandID, const String& label, WebPageProxy& page) 40 40 : m_commandID(commandID) 41 , m_ editAction(editAction)42 , m_page( page)41 , m_label(label) 42 , m_page(makeWeakPtr(page)) 43 43 { 44 44 m_page->addEditCommand(*this); -
trunk/Source/WebKit/UIProcess/WebEditCommandProxy.h
r239627 r240342 32 32 #include <wtf/RefCounted.h> 33 33 #include <wtf/RefPtr.h> 34 #include <wtf/WeakPtr.h> 35 #include <wtf/text/WTFString.h> 34 36 35 37 namespace WebKit { … … 39 41 class WebEditCommandProxy : public API::ObjectImpl<API::Object::Type::EditCommandProxy> { 40 42 public: 41 static Ref<WebEditCommandProxy> create(WebUndoStepID commandID, WebCore::EditAction editAction, WebPageProxy*page)43 static Ref<WebEditCommandProxy> create(WebUndoStepID commandID, const String& label, WebPageProxy& page) 42 44 { 43 return adoptRef(*new WebEditCommandProxy(commandID, editAction, page));45 return adoptRef(*new WebEditCommandProxy(commandID, label, page)); 44 46 } 45 47 ~WebEditCommandProxy(); 46 48 47 49 WebUndoStepID commandID() const { return m_commandID; } 48 WebCore::EditAction editAction() const { return m_editAction; }50 String label() const { return m_label; } 49 51 50 void invalidate() { m_page = 0; }52 void invalidate() { m_page.clear(); } 51 53 52 54 void unapply(); … … 54 56 55 57 private: 56 WebEditCommandProxy(WebUndoStepID commandID, WebCore::EditAction, WebPageProxy*);58 WebEditCommandProxy(WebUndoStepID commandID, const String& label, WebPageProxy&); 57 59 58 60 WebUndoStepID m_commandID; 59 WebCore::EditAction m_editAction;60 We bPageProxy*m_page;61 String m_label; 62 WeakPtr<WebPageProxy> m_page; 61 63 }; 62 64 -
trunk/Source/WebKit/UIProcess/WebPageProxy.cpp
r240243 r240342 5440 5440 // Undo management 5441 5441 5442 void WebPageProxy::registerEditCommandForUndo(WebUndoStepID commandID, uint32_t editAction)5443 { 5444 registerEditCommand(WebEditCommandProxy::create(commandID, static_cast<EditAction>(editAction),this), UndoOrRedo::Undo);5442 void WebPageProxy::registerEditCommandForUndo(WebUndoStepID commandID, const String& label) 5443 { 5444 registerEditCommand(WebEditCommandProxy::create(commandID, label, *this), UndoOrRedo::Undo); 5445 5445 } 5446 5446 … … 6653 6653 m_loadDependentStringCallbackIDs.clear(); 6654 6654 6655 auto editCommandVector = copyToVector(m_editCommandSet); 6656 m_editCommandSet.clear(); 6657 6658 for (auto& editCommand : editCommandVector) 6655 for (auto& editCommand : std::exchange(m_editCommandSet, { })) 6659 6656 editCommand->invalidate(); 6660 6657 -
trunk/Source/WebKit/UIProcess/WebPageProxy.h
r240243 r240342 1645 1645 1646 1646 // Undo management 1647 void registerEditCommandForUndo(WebUndoStepID commandID, uint32_t editAction);1647 void registerEditCommandForUndo(WebUndoStepID commandID, const String& label); 1648 1648 void registerInsertionUndoGrouping(); 1649 1649 void clearAllEditCommands(); -
trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in
r240199 r240342 234 234 235 235 # Undo/Redo messages 236 RegisterEditCommandForUndo(uint64_t commandID, uint32_t editAction)236 RegisterEditCommandForUndo(uint64_t commandID, String label) 237 237 ClearAllEditCommands() 238 238 RegisterInsertionUndoGrouping() -
trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm
r240199 r240342 268 268 void PageClientImpl::registerEditCommand(Ref<WebEditCommandProxy>&& command, UndoOrRedo undoOrRedo) 269 269 { 270 auto actionName = WebCore::nameForUndoRedo(command->editAction());270 auto actionName = command->label(); 271 271 auto commandObjC = adoptNS([[WKEditCommand alloc] initWithWebEditCommandProxy:WTFMove(command)]); 272 272 -
trunk/Source/WebKit/WebProcess/WebCoreSupport/WebEditorClient.cpp
r239589 r240342 312 312 auto webStep = WebUndoStep::create(step); 313 313 auto stepID = webStep->stepID(); 314 auto editAction = static_cast<uint32_t>(webStep->step().editingAction());315 314 316 315 m_page->addWebUndoStep(stepID, WTFMove(webStep)); 317 m_page->send(Messages::WebPageProxy::RegisterEditCommandForUndo(stepID, editAction), m_page->pageID(), IPC::SendOption::DispatchMessageEvenWhenWaitingForSyncReply);316 m_page->send(Messages::WebPageProxy::RegisterEditCommandForUndo(stepID, step.label()), m_page->pageID(), IPC::SendOption::DispatchMessageEvenWhenWaitingForSyncReply); 318 317 } 319 318 -
trunk/Source/WebKitLegacy/mac/ChangeLog
r240292 r240342 1 2019-01-23 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 Introduce UndoStep::label() and adopt it in WebKitLegacy and WebKit 4 https://bugs.webkit.org/show_bug.cgi?id=193706 5 <rdar://problem/44807048> 6 7 Reviewed by Ryosuke Niwa. 8 9 Use UndoStep::label(). 10 11 * WebCoreSupport/WebEditorClient.h: 12 * WebCoreSupport/WebEditorClient.mm: 13 (-[WebUndoStep initWithUndoStep:]): 14 (+[WebUndoStep stepWithUndoStep:]): 15 (WebEditorClient::registerUndoOrRedoStep): 16 (WebEditorClient::registerUndoStep): 17 (WebEditorClient::registerRedoStep): 18 1 19 2019-01-22 Alex Christensen <achristensen@webkit.org> 2 20 -
trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebEditorClient.mm
r240181 r240342 126 126 } 127 127 128 + (WebUndoStep *)stepWithUndoStep:( UndoStep&)step;128 + (WebUndoStep *)stepWithUndoStep:(Ref<UndoStep>&&)step; 129 129 - (UndoStep&)step; 130 130 … … 142 142 } 143 143 144 - (id)initWithUndoStep:( UndoStep&)step144 - (id)initWithUndoStep:(Ref<UndoStep>&&)step 145 145 { 146 146 self = [super init]; 147 147 if (!self) 148 148 return nil; 149 m_step = &step;149 m_step = WTFMove(step); 150 150 return self; 151 151 } … … 159 159 } 160 160 161 + (WebUndoStep *)stepWithUndoStep:( UndoStep&)step162 { 163 return [[[WebUndoStep alloc] initWithUndoStep: step] autorelease];161 + (WebUndoStep *)stepWithUndoStep:(Ref<UndoStep>&&)step 162 { 163 return [[[WebUndoStep alloc] initWithUndoStep:WTFMove(step)] autorelease]; 164 164 } 165 165 … … 602 602 #endif 603 603 604 NSString *actionName = WebCore::nameForUndoRedo(step.editingAction()); 605 WebUndoStep *webEntry = [WebUndoStep stepWithUndoStep:step]; 606 [undoManager registerUndoWithTarget:m_undoTarget.get() selector:(isRedo ? @selector(redoEditing:) : @selector(undoEditing:)) object:webEntry]; 604 NSString *actionName = step.label(); 605 [undoManager registerUndoWithTarget:m_undoTarget.get() selector:(isRedo ? @selector(redoEditing:) : @selector(undoEditing:)) object:[WebUndoStep stepWithUndoStep:step]]; 607 606 if (actionName) 608 607 [undoManager setActionName:actionName]; … … 630 629 } 631 630 632 void WebEditorClient::registerUndoStep(UndoStep& c md)633 { 634 registerUndoOrRedoStep(c md, false);635 } 636 637 void WebEditorClient::registerRedoStep(UndoStep& c md)638 { 639 registerUndoOrRedoStep(c md, true);631 void WebEditorClient::registerUndoStep(UndoStep& command) 632 { 633 registerUndoOrRedoStep(command, false); 634 } 635 636 void WebEditorClient::registerRedoStep(UndoStep& command) 637 { 638 registerUndoOrRedoStep(command, true); 640 639 } 641 640
Note: See TracChangeset
for help on using the changeset viewer.