Closed Bug 81989 Opened 24 years ago Closed 24 years ago

STYLE tags can cause multiple copies of stylesheet to be loaded

Categories

(Core :: Layout, defect, P1)

defect

Tracking

()

VERIFIED FIXED
mozilla0.9.1

People

(Reporter: peterv, Assigned: peterv)

Details

(Keywords: perf, regression, Whiteboard: [fixinhand])

Attachments

(6 files)

I was going to keep this clean-up to the HTML content sink for later, but I've discovered that without it we load multiple copies of stylesheets specified through a <style src=...> tag. This is very bad, I think we should try to get this in before tree closure.
Severity: normal → major
Status: NEW → ASSIGNED
Priority: -- → P1
Target Milestone: --- → mozilla0.9.1
Attached patch Diff -w -uSplinter Review
The changes look good to me, one additional change that could be made here: for (i = 0; i < count; i++) { nsAutoString key(aNode.GetKeyAt(i)); - if (key.EqualsIgnoreCase("src")) { - GetAttributeValueAt(aNode, i, src); - src.StripWhitespace(); - } - else if (key.EqualsIgnoreCase("title")) { + if (key.EqualsIgnoreCase("title")) { is to change the 'key' variable to be a const nsAReadableString& here which would avoid a string copy per attribute, if this change is made the the EqualsIgnoreCase() calls need to be changed to Compare() calls to get case insensitive compare. Either way, sr=jst
Or even better, use element->GetAttribute() to get the value of all those attributes as you do for getting the src attribute. But again, that's not required...
This looks ok to me too, r=heikki.
My sr=jst still applies...
I think this should go in for 0.9.1. I have a fix and it is low-risk. Trying to load the same styleheet multiple times (though it is only specified once) is a performance hit, and the document ends up with a style model which is wrong.
Whiteboard: [fixinhand]
Uhhhh... - if(mCurrentContext!=nsnull) { + if (!mCurrentContext) { parent=mCurrentContext->mStack[mCurrentContext->mStackPos-1].mContent; } Same again, later on. Use 'if (p)' rather than 'if (p != nsnull)', and 'if (!p)' rather than 'if (p == nsnull)' -- and try spaces around operators, my eyes thank you! /be
Was the patch really tested? Need a new patch, review and super-review before we can go for approval in 0.9.1. /be
Fixed the gross errors. Fixed what I think Brendan meant with "try spaces around operators" (in one line). Tested with the actual patch I attached, only one stylesheet is loaded and shows up when doing "dump stylesheets". Re-applying for r and sr.
Once again, r=heikki. I seem to have a habit of thinking some of those boolean logic changes are wrong when they are correct, and correct when they are wrong :/ All bow to Brendan :)
Oh geez, I can't believe I didn't see that, now I'm embarrassed. Thanks for catching that, Brendan.
+ nsIDOMText* tc; + rv = text->QueryInterface(NS_GET_IID(nsIDOMText), (void**)&tc); [...] + tc->SetData(content); + NS_RELEASE(tc); any reason why you aren't using nsCOMPtr<> there? Same with the nsIContent *text above and below. other than that, sr=blizzard
oh, and a=blizzard for 0.9.1 when you respond to my one comment.
Is this fixed now, peterv? Looks like it went in last night...
Note that the variable `i' is now unused... c:\seamonkey\mozilla\content\html\document\src\nsHTMLContentSink.cpp(4663) : warning C4101: 'i' : unreferenced local variable
Memory leaks went up pretty steep after this fix went in...
Bug 83093 deals with the leaks.
Status: ASSIGNED → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
This is actually an HTML element bug, not a CSS bug (the CSS part was working fine, it was just being called twice). Sending to HTML Element for verification.
Component: Style System → HTML Element
QA Contact: ian → bsharma
Verified on: build: 2001-07-02-04-Trunk platform: WinNT Below is the test case that I used to verify this bug. The test case loads fine. <HTML> <body> <P STYLE="color: red; font-family: 'New Century Schoolbook', serif src:..."> This paragraph is styled in red with the New Century Schoolbook font, if available.</P> </BODY> </HTML>
Status: RESOLVED → VERIFIED
SPAM. HTML Element component deprecated, changing component to Layout. See bug 88132 for details.
Component: HTML Element → Layout
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: