Closed Bug 398399 Opened 18 years ago Closed 18 years ago

make DOMLinkHandler implement nsIDOMEventListener

Categories

(Firefox :: General, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
Firefox 3 beta1

People

(Reporter: dao, Assigned: dao)

References

Details

Attachments

(1 file, 2 obsolete files)

Spin-off from bug 396203. See bug 396203 comment 9 for details.
Blocks: 396203
Attached patch patch (obsolete) — Splinter Review
this also contains drive-by cleanup for onLinkAdded
Assignee: nobody → dao
Status: NEW → ASSIGNED
Attachment #283350 - Flags: review?(mconnor)
Attached patch patch v1.00001 (obsolete) — Splinter Review
Attachment #283350 - Attachment is obsolete: true
Attachment #283351 - Flags: review?(mconnor)
Attachment #283350 - Flags: review?(mconnor)
Comment on attachment 283351 [details] [diff] [review] patch v1.00001 >- // Verify that the load of this icon is legal. >- // error pages can load their favicon, to be on the safe side, >- // only allow chrome:// favicons >- const aboutNeterr = "about:neterror?"; >- if (targetDoc.documentURI.substr(0, aboutNeterr.length) != aboutNeterr || >- !uri.schemeIs("chrome")) { >+ // Verify that the load of this icon is legal. >+ // error pages can load their favicon, to be on the safe side, >+ // only allow chrome:// favicons >+ if (!/^about:neterror\?/.test(targetDoc.documentURI) || >+ !uri.schemeIs("chrome")) { what's the point of this change? I'm pretty sure its marginally slower. substr or indexOf are about the same speed, regex for straight strings is overkill.
I think ideally the regex would be compiled once and could be even faster then. But I don't really care either way, I just thought it was cleaner (more compact).
An indexOf check is as compact as a regexp test and shouldn't be slower than the current code.
Yeah, my first thought was to use indexOf, but then I realized that scanning the entire string is waste -- we don't want to know the index but if the strings starts with "about:neterror?". So substr makes a little bit more sense, as well as the regex.
Attached patch patch v2Splinter Review
Attachment #283351 - Attachment is obsolete: true
Attachment #283368 - Flags: review?(mconnor)
Attachment #283351 - Flags: review?(mconnor)
Attachment #283368 - Flags: review?(mconnor)
Attachment #283368 - Flags: review+
Attachment #283368 - Flags: approval1.9+
Keywords: checkin-needed
Checking in browser/base/content/browser.js; /cvsroot/mozilla/browser/base/content/browser.js,v <-- browser.js new revision: 1.862; previous revision: 1.861 done
Status: ASSIGNED → RESOLVED
Closed: 18 years ago
Keywords: checkin-needed
Resolution: --- → FIXED
Target Milestone: --- → Firefox 3 M9
(In reply to comment #6) > Yeah, my first thought was to use indexOf, but then I realized that scanning > the entire string is waste -- we don't want to know the index but if the > strings starts with "about:neterror?". So substr makes a little bit more sense, > as well as the regex. I doubt we are talking significant (if any) savings here but I tend to program this as targetDoc.documentURI.lastIndexOf(aboutNeterr, 0) != 0
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: