Closed Bug 87348 Opened 23 years ago Closed 23 years ago

Relying on cached text length too heavily

Categories

(Core :: DOM: Editor, defect, P3)

x86
Windows 2000
defect

Tracking

()

VERIFIED FIXED
mozilla0.9.3

People

(Reporter: bugzilla, Assigned: bugzilla)

References

Details

(Whiteboard: [PDT+])

Attachments

(4 files)

In nsGfxTextControlFrame2.cpp, ::GetTextLength: // We should probably invalidate the cached string on more // than just selection changes; maybe we should listen // for editor transactions etc. nsString *str = GetCachedString(); if (str) { *aTextLength = str->Length(); return NS_OK; } However, we need to retrieve the text length now for whenever the urlbar is focused, and thus even though the page/url may have changed, we're still relying on the cached value. Not sure how we'll get around this, but we need it for 37587, which is wanted for rtm.
Blocks: 37587
Simon/Mike, you guys touched this area frequently: is this a bad place to invalidate?
Assignee: beppe → mjudge
Priority: -- → P3
Target Milestone: --- → mozilla1.0
I'm not sure that this will be prime for 9.3, this may well be very significant change. asking smfr and kin for comment
? If my fix is okay, it's a one line change...
Your patch will not fix all cases ... we will still have the same problem if SetTextControlFrameState() is never called. (ie the value attribute is never set on the textarea, but the user types in the text widget. I think we should just remove GetCachedString() entirely and make GetTextLength() call GetTextControlFrameState(). If there is a cached string, GetTextControlFrameState() will return it, if we have an editor, then it will give the current value back.
Sounds good to me.
(By the way, it still seems to work fine if the user types the value...I won't bother investigating why, though)
Attached patch full patchSplinter Review
Actually, I suppose it's still necessary to free mCachedState, so...do we want to keep InvalidateCachedState?
Kin, can you take a look at these and pick one or provide your own? ;-) 37587 depends on this, and that's wanted on the branch.
sr=kin@netscape.com on the 06/25/01 20:06 patch. This *shouldn't* break restoration of form text widget values when going forward/backwards in the browser history, but I'm a paranoid kind of guy, so can you just make sure that stuff still works before checking in?
Restoration works fine for me. smfr, r=?
What performance implications does this have?
As far as I can tell, nothing. GetTextControlFrameState will still return the cached state when possible/necessary. kin, correct me if i'm wrong...
kin?
kin is on vacation
Argh. When will he be back? Anyways, I'm fairly confident this has little effect on performance...It does almostthe same thing. The difference is that we no longer call GetCachedString first, since GetTextControlFrameState will give us a cached string if one is available...
-> me
Assignee: mjudge → blake
Target Milestone: mozilla1.0 → mozilla0.9.3
I'll take your word for it. r=sfraser
adding PDT+, bug 37587 that depends on this bug is needed in the branch for accessibility purposes.
Keywords: vtrunk
Whiteboard: PDT+
paw/jrgm, do we have anything in the performance tests that could help answer sfraser's questions?
I don't know if we could get a meaningful measure of this. This is rarely called when running page loading tests (actually never) and rarely called when opening a new browser window (i.e., only when the focus is set in the Urlbar). Although I will make one correction to Blake's comments above (or at least this is what it looks like to me). GetTextControlFrameState would return the mCachedState if it is available except that it seems to always pass an earlier test and takes a different branch, so it never gets to the test for mCachedState.
Why would that be? The tests in GetCachedState and GetTextControlFrame seem to be the same... Is kin back yet?
This has been checked into the 0.9.2 branch on wed 4 july.
Updating status whiteboard to reflect that this bug is open for the trunk.
Keywords: vtrunkvbranch
Whiteboard: PDT+ → [PDT+] FIX ON BRANCH; BUG OPEN for TRUNK
Fixed everywhere
Status: NEW → RESOLVED
Closed: 23 years ago
Keywords: vbranch
Resolution: --- → FIXED
Whiteboard: [PDT+] FIX ON BRANCH; BUG OPEN for TRUNK → [PDT+]
Ok, I'm back from vacation ... I know this was checked in already, but just wanted to followup with some of the questions. John is correct, a call to GetTextControlFrameState() will always retrieve the value from the editor if an editor is available, even if mCachedState is not null. It looks like prior to blake's checkin, mCachedState was used for 2 purposes: 1. A temporary storage place for the text widget's value if SetTextControlFrameState() was ever called before an editor was available. This happens when going forward or back in the browser because the history mechanism restores widget values before the first reflow ever occurs for the page. 2. A quick way to cache the value for repeated calls to GetTextLength(). Blake removed #2 with his patch. For people who are concerned about the performance impact of this change, it should be noted that the only way to trigger a call to GetTextLength() is to use the textLength attribute on the nsIDOMNSHTMLInputElement interface, which no one seems to use except the urlbar code.
Blake, can you please verify this one and mark VERIFIED-FIXED? thanks.
Marking verified.
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: