Closed Bug 485553 Opened 16 years ago Closed 16 years ago

[FIX]Anchor-mutation functions should store the URI object, not the string

Categories

(Core :: DOM: Core & HTML, defect)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: bzbarsky, Assigned: bzbarsky)

Details

Attachments

(2 files, 1 obsolete file)

Now that bug 481335 is fixed, we should store the URI object, not the string in the anchor mutations functions.
Or rather, store both.
Attached patch Proposed fix (obsolete) — Splinter Review
The change this bug is about is the first part of the SetHrefToURI change. The nsHTMLAnchorElement change fixes a bug I found while looking at this code, and the test tests for that bug. In particular, since GetHref() uses the cached URI, and the mutators mutate it, we were getting equality when the attr set came from SetHrefToURI, even though the URI had changed. The right equality check is no check at all, I think; the chance that SetAttr is happening with the same value as we already had is low, and I have no problem dropping the URI cache in that case. That said, we don't get dropped from the link map correctly in that case, because that uses our cached URI (which has changed by then). The consequence is the node being kept alive too long, I think. So the other change is to drop us from the link map when getting ready to edit the URI. But since we might edit it in a way that doesn't actually call into the style system to reresolve (e.g. don't change the href), we need to manually readd in SetHrefToURI. The test covers the various correctness aspects of this (everything mentioned above except link map bloat and the caching we were not doing). Note that the caching call I'm adding doesn't affect the correctness bugs this patch fixes; those are present even without it. If we think that readding all links to the link map on anchor.* mutations is bad, we could alternately clone the URI in GetHrefURIForEditing. Then we could probably restore the equality check in SetAttr, as well as getting rid of the link map munging I added. That does involve a separate allocation, though. Not sure which is faster... Cloning is certainly cleaner. Thoughts?
Attachment #369725 - Flags: superreview?(jst)
Attachment #369725 - Flags: review?(jst)
Attached patch With cloningSplinter Review
I did some measurements, and this is no slower than the other patch. It _is_ simpler, though. About half the time, sadly, is spent doing the IsVisited() check when constructing the restyle data for checking whether we have attribute dependent style... There's also wasted time because said attribute dependent style check forces parsing of the URI, and happens before we've managed to set the new URI object on the nsAttrValue in a lot of cases. I can do a followup but to try to fix this, if you'd like.
Attachment #369725 - Attachment is obsolete: true
Attachment #369732 - Flags: superreview?(jst)
Attachment #369732 - Flags: review?(jst)
Attachment #369725 - Flags: superreview?(jst)
Attachment #369725 - Flags: review?(jst)
Come to think of which, we're atomically changing both the link state and the attr value; I bet we can write testcases for dynamic changes that fail to restyle correctly in this case...
Attached file microbenchmark I used
Comment on attachment 369732 [details] [diff] [review] With cloning From: Boris Zbarsky <bzbarsky@mit.edu> Bug 485553. Fix issue with mutating anchor uri properties and visited state, and cache the resulting URI when the URI is mutated instead of just reparsing it later. r+sr=sicking Did sicking already review this, or something? :) This patch looks good to me, the only thing that came to mind when reading through it was a naming thing... + // As above, but removes us from the link map using the URI before we edit it + void GetHrefURIForEditing(nsIURI** aURI); ... which was here. Would this be better named something like GetHrefURIToMutate(), or somesuch. At first glance I though editing had something to do with our editor, which is of course not the case. I don't care strongly here, just figured I'd throw it out there for you to consider as well. r+sr=jst
Attachment #369732 - Flags: superreview?(jst)
Attachment #369732 - Flags: superreview+
Attachment #369732 - Flags: review?(jst)
Attachment #369732 - Flags: review+
> Did sicking already review this, or something? :) Er, no. I originally planned to ask him for review, but then decided that he's lagging enough as it is. ;) > Would this be better named something like GetHrefURIToMutate() Yeah, makes sense. I'll do that.
Status: NEW → RESOLVED
Closed: 16 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: