Bug 12461 - Need API to clear WebView's undo actions from undo manager
Summary: Need API to clear WebView's undo actions from undo manager
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit API (show other bugs)
Version: 420+
Hardware: Mac OS X 10.5
: P2 Enhancement
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-01-29 11:01 PST by Jim Correia
Modified: 2007-01-29 13:00 PST (History)
0 users

See Also:


Attachments
Test case described in bug body. (26.29 KB, application/zip)
2007-01-29 11:02 PST, Jim Correia
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jim Correia 2007-01-29 11:01:13 PST
Please provide a public API on WebView which let's me clear all undo actions associated with the web view.

Consider this usage model:

A view controller (not NSViewController based since this code targets 10.4) inserts a web view into a window. The web view shares the undo manager with other views in the window (via -windowWillReturnUndoManager:) and is not being used in bindings mode.

After some user edits, a) the data is committed back to the model object and b) the view is removed from the window.

After (a) it is desirable to remove the web view's undo actions from the undo manager.

After (b) it is required that I remove the actions. If I don't, you'll crash later on when choosing undo. You can reproduce this in the attached sample:

Build/Run.
Type in the web view.
Click "Remove Web View".
Choose "Undo" from the edit menu.

Note: it appears that loading a new string/request into the web view clears the undo actions today. But The action gets cleared when the load is complete (on a runloop callback) and by that time it is too late, since I've already removed the view from the window, and therefore it can no longer locate its undo manager.
Comment 1 Jim Correia 2007-01-29 11:02:13 PST
Created attachment 12746 [details]
Test case described in bug body.
Comment 2 David Kilzer (:ddkilzer) 2007-01-29 12:09:57 PST
This is a dumb question, but can't you just create a new undo manager to "clear" the undo history?

How is this bug related to Bug 12462?

Comment 3 Jim Correia 2007-01-29 12:24:41 PST
(In reply to comment #2)
> This is a dumb question, but can't you just create a new undo manager to
> "clear" the undo history?
> 
> How is this bug related to Bug 12462?

The bug isn't related to 12462 as they solve different problems. (I answered in more detail there.)

I can't just create a new undo manager to clear the history because the undo manager is associated with the window, and other views and model objects may have registered actions with the undo manager which need to persist.

This is not unlike NSTextView when used as a field editor or in bindings mode. (Though it does this through an SPI, which presents a similar problem, but that one is logged in radar.)
Comment 4 David Kilzer (:ddkilzer) 2007-01-29 12:38:46 PST
(In reply to comment #3)
> This is not unlike NSTextView when used as a field editor or in bindings mode.
> (Though it does this through an SPI, which presents a similar problem, but that
> one is logged in radar.)

Please note the Radar bug number here (in the form <rdar://problem/NNNNNNN>) in case an Apple engineer wants to review it in conjunction with this bug.
Comment 5 Jim Correia 2007-01-29 13:00:17 PST
(In reply to comment #4)
> Please note the Radar bug number here (in the form <rdar://problem/NNNNNNN>) in
> case an Apple engineer wants to review it in conjunction with this bug.

rdar://problem/4961133

It is a similar API request for NSTextView