WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
193111
[Cocoa] Allow the page to add to the platform undo stack via UndoManager.addItem()
https://bugs.webkit.org/show_bug.cgi?id=193111
Summary
[Cocoa] Allow the page to add to the platform undo stack via UndoManager.addI...
Wenson Hsieh
Reported
2019-01-03 10:23:29 PST
<
rdar://problem/44807048
>
Attachments
WIP (with tests)
(62.94 KB, patch)
2019-01-04 20:45 PST
,
Wenson Hsieh
no flags
Details
Formatted Diff
Diff
Part 1
(22.68 KB, patch)
2019-01-18 09:34 PST
,
Wenson Hsieh
no flags
Details
Formatted Diff
Diff
Patch
(32.88 KB, patch)
2019-01-18 23:43 PST
,
Wenson Hsieh
no flags
Details
Formatted Diff
Diff
Part 1
(18.17 KB, patch)
2019-01-18 23:52 PST
,
Wenson Hsieh
no flags
Details
Formatted Diff
Diff
Part 1 (w/ unified build fix)
(18.71 KB, patch)
2019-01-19 00:15 PST
,
Wenson Hsieh
no flags
Details
Formatted Diff
Diff
Part 1 (fix typo in title)
(18.70 KB, patch)
2019-01-19 00:29 PST
,
Wenson Hsieh
rniwa
: review+
Details
Formatted Diff
Diff
Part 2 (CustomUndoStep)
(13.25 KB, patch)
2019-01-19 00:34 PST
,
Wenson Hsieh
no flags
Details
Formatted Diff
Diff
Part 3
(56.45 KB, patch)
2019-01-19 20:41 PST
,
Wenson Hsieh
no flags
Details
Formatted Diff
Diff
Part 3
(56.39 KB, patch)
2019-01-19 20:54 PST
,
Wenson Hsieh
no flags
Details
Formatted Diff
Diff
Patch for landing
(18.77 KB, patch)
2019-01-22 17:30 PST
,
Wenson Hsieh
no flags
Details
Formatted Diff
Diff
Part 2 (rebase on trunk)
(13.42 KB, patch)
2019-01-22 18:38 PST
,
Wenson Hsieh
no flags
Details
Formatted Diff
Diff
Part 2 (fix GTK/WPE builds)
(13.55 KB, patch)
2019-01-22 18:53 PST
,
Wenson Hsieh
no flags
Details
Formatted Diff
Diff
Show Obsolete
(12)
View All
Add attachment
proposed patch, testcase, etc.
Wenson Hsieh
Comment 1
2019-01-04 20:45:23 PST
Comment hidden (obsolete)
Created
attachment 358427
[details]
WIP (with tests)
Wenson Hsieh
Comment 2
2019-01-18 09:34:59 PST
Comment hidden (obsolete)
Created
attachment 359498
[details]
Part 1
Wenson Hsieh
Comment 3
2019-01-18 23:43:24 PST
Comment hidden (obsolete)
Created
attachment 359590
[details]
Patch
Wenson Hsieh
Comment 4
2019-01-18 23:52:05 PST
Comment hidden (obsolete)
Created
attachment 359591
[details]
Part 1
Wenson Hsieh
Comment 5
2019-01-19 00:15:42 PST
Comment hidden (obsolete)
Created
attachment 359592
[details]
Part 1 (w/ unified build fix)
Wenson Hsieh
Comment 6
2019-01-19 00:29:10 PST
Created
attachment 359593
[details]
Part 1 (fix typo in title)
Wenson Hsieh
Comment 7
2019-01-19 00:34:29 PST
Created
attachment 359594
[details]
Part 2 (CustomUndoStep)
Wenson Hsieh
Comment 8
2019-01-19 20:41:14 PST
Comment hidden (obsolete)
Created
attachment 359631
[details]
Part 3
Wenson Hsieh
Comment 9
2019-01-19 20:54:05 PST
Created
attachment 359632
[details]
Part 3
Ryosuke Niwa
Comment 10
2019-01-22 14:32:08 PST
Comment on
attachment 359593
[details]
Part 1 (fix typo in title) View in context:
https://bugs.webkit.org/attachment.cgi?id=359593&action=review
> Source/WebCore/bindings/js/JSUndoItemCustom.cpp:47 > + if (UNLIKELY(reason)) > + *reason = "Document is an opaque root.";
You can always set the reason even if you were to return false. So the idiomatic way of writing isReachableFromOpaqueRoots is to put this code at the beginning of the function.
> Source/WebCore/page/UndoItem.cpp:55 > + return isValid() ? &m_undoManager->document() : nullptr;
I'd prefer clearing m_undoManager in invalidate() instead. That way, UndoItem would be destructed even after it had been removed from UndoManager e.g. via some kind of clear() operation in the future.
> Source/WebCore/page/UndoManager.cpp:59 > + auto items = std::exchange(m_items, { });
I think you can just iterate over m_items and call clear at the end. There is no reentrancy concern here.
Wenson Hsieh
Comment 11
2019-01-22 16:12:06 PST
Comment on
attachment 359593
[details]
Part 1 (fix typo in title) View in context:
https://bugs.webkit.org/attachment.cgi?id=359593&action=review
>> Source/WebCore/bindings/js/JSUndoItemCustom.cpp:47 >> + *reason = "Document is an opaque root."; > > You can always set the reason even if you were to return false. > So the idiomatic way of writing isReachableFromOpaqueRoots is to put this code at the beginning of the function.
Ah, I see! Fixed.
>> Source/WebCore/page/UndoItem.cpp:55 >> + return isValid() ? &m_undoManager->document() : nullptr; > > I'd prefer clearing m_undoManager in invalidate() instead. > That way, UndoItem would be destructed even after it had been removed from UndoManager > e.g. via some kind of clear() operation in the future.
So in my patch, UndoItem::invalidate() already does null out m_undoManager by using std::exchange(m_undoManager, nullptr). But maybe this was too subtle :/ I'll change this to set m_undoManager to nullptr instead, to make it more obvious...
>> Source/WebCore/page/UndoManager.cpp:59 >> + auto items = std::exchange(m_items, { }); > > I think you can just iterate over m_items and call clear at the end. > There is no reentrancy concern here.
The reason I used std::exchange here is that UndoItem::invalidate calls back into UndoManager::removeItem to actually remove the UndoItem from the UndoManager, and so iterating over m_items while invalidating each item is going to cause m_items to mutate during iteration. On second thought, this code is unnecessarily convoluted; I'll refactor this...
Wenson Hsieh
Comment 12
2019-01-22 17:30:04 PST
Created
attachment 359819
[details]
Patch for landing
WebKit Commit Bot
Comment 13
2019-01-22 18:06:58 PST
Comment on
attachment 359819
[details]
Patch for landing Clearing flags on attachment: 359819 Committed
r240315
: <
https://trac.webkit.org/changeset/240315
>
WebKit Commit Bot
Comment 14
2019-01-22 18:07:00 PST
All reviewed patches have been landed. Closing bug.
Wenson Hsieh
Comment 15
2019-01-22 18:38:00 PST
Reopening to attach new patch.
Wenson Hsieh
Comment 16
2019-01-22 18:38:01 PST
Created
attachment 359832
[details]
Part 2 (rebase on trunk)
Wenson Hsieh
Comment 17
2019-01-22 18:53:45 PST
Created
attachment 359834
[details]
Part 2 (fix GTK/WPE builds)
Ryosuke Niwa
Comment 18
2019-01-22 19:42:13 PST
Can we file a separate bug for part 2? It's confusing to post multiple patches per Bugzilla bug like this.
Wenson Hsieh
Comment 19
2019-01-22 19:43:59 PST
(In reply to Ryosuke Niwa from
comment #18
)
> Can we file a separate bug for part 2? It's confusing to post multiple > patches per Bugzilla bug like this.
Sure thing — filed <
https://bugs.webkit.org/show_bug.cgi?id=193704
>.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug