Closed Bug 112008 Opened 23 years ago Closed 23 years ago

implement modification count in Composer code (not nsIDiskDocument)

Categories

(SeaMonkey :: Composer, defect)

defect
Not set
normal

Tracking

(Not tracked)

VERIFIED FIXED
mozilla0.9.7

People

(Reporter: Brade, Assigned: Brade)

References

Details

Attachments

(1 file, 1 obsolete file)

implement dirty flag in Composer code (not nsIDiskDocument).
Note that this needs to be more than a dirty flag; it has to be a counter, so that Undo can make the document non-dirty.
Blocks: 102033
sorry; in my haste to file the bug, I mistyped: should be modCount (not dirtyFlag)
Status: NEW → ASSIGNED
Summary: implement dirty flag in Composer code (not nsIDiskDocument) → implement modification count in Composer code (not nsIDiskDocument)
Target Milestone: --- → mozilla0.9.7
This patch includes a little more than it needs to for this particular bug. It also includes some #include cleanup (to be tested on other platforms tomorrow) and the use of nsIWebBrowserPersist for saving. Sorry for the compound fix! Feedback please!
Comments: +NS_IMETHODIMP nsEditor::IncrementModificationCount(PRInt32 inNumMods) { ... + mModCount += inNumMods; NotifyDocumentListeners(eDocumentStateChanged); I think we only really want to send out a 'eDocumentStateChanged' when the document changes state from clean to dirty, or vice versa (i.e. the mod count changes from 0 to something, or something to 0). +NS_IMETHODIMP nsEditor::ResetModificationCount() { ... + mModCount = 0; NotifyDocumentListeners(eDocumentStateChanged); Ditto here. Only call NotifyDocumentListeners() if the mod count was not 0 before. (Ignoring ComposerCommands.js changes). I assume that there are diffs to nsIDiskDocument/nsDocument that remove the mod count APIs there?
This updated patch has been built on Linux and Mac. It fixes the modCount notification to happen less often (per sfraser above). I am still building on Windows. When that finishes, I'll remove the commented out #includes. Akkana--please r= Simon--please sr=
Attachment #59403 - Attachment is obsolete: true
cc akkana for her r= also note: this patch is waiting for Adam's patch
Depends on: 110135
+ PRBool doNotify = (mModCount == 0) && (inNumMods > 0); The inNumMods can actually be negative (for undo), so the code should read: PRBool oldModCount = mModCount; mModCount += inNumMods; if ((oldModCount == 0 && mModCount != 0) || (oldModCount != 0 && mModCount == 0)) NotifyDocumentListeners(eDocumentStateChanged); There's probably a cleaner way, but that's the gist.
Comment on attachment 59583 [details] [diff] [review] updated patch to address sfraser's comments Looks good to me (modulo Simon's comments). Might be better to remove the commented-out headers in nsEditor.cpp. Kathy says she's already removed the gEditorOutputProgressListener dump()s. The changes in nsEditorUtils.cpp and nsTextEditRules.cpp point out that nsEditor.h is included in those classes' .h files, and shouldn't be (there's no reason for it, and it slows down the build) -- that's not related to this change but we should fix it at some point.
Attachment #59583 - Flags: review+
sr=sfraser on all changes, given my and akkana's comments.
fixes checked in Sujay--to verify this, you can just ensure that undo/redo work properly.
Status: ASSIGNED → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
brade, please verify....thanks..
v
Status: RESOLVED → VERIFIED
Product: Browser → Seamonkey
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: