Closed Bug 83612 Opened 23 years ago Closed 23 years ago

Correct/cleanup style loading code in content

Categories

(Core :: XML, defect, P1)

defect

Tracking

()

VERIFIED FIXED
mozilla0.9.2

People

(Reporter: rbs, Assigned: peterv)

References

Details

Attachments

(5 files)

Compilation gives a warning that a 'namespaceID' variable is being used without being initialized on line 1098 in nsXMLContentSink.cpp. Not sure how serious this is. But I thought I will file this bug since namespace issues are sensitive. nsXMLContentSink.cpp(1098) : warning C4700: local variable 'namespaceID' used without having been initialized
The relevant part of my patch for bug 7515 (which changed this code) is this: nsAutoString title; nsAutoString type; nsAutoString media; + nsCOMPtr<nsIAtom> name, prefix; + PRInt32 namespaceID; + + if (NS_FAILED(mStyleElement->GetAttribute(namespaceID, *getter_AddRefs(name),src))) + return rv; + src.StripWhitespace(); + for (i = 0; i < count; i++) { - PRInt32 namespaceID; - nsCOMPtr<nsIAtom> name, prefix; mStyleElement->GetAttributeNameAt(i,namespaceID,*getter_AddRefs(name),*getter_AddRefs(prefix)); - if (name.get() == nsHTMLAtoms::src) { - mStyleElement->GetAttribute(namespaceID,name,src); - src.StripWhitespace(); - } - else if (name.get() == nsHTMLAtoms::title) { + if (name.get() == nsHTMLAtoms::title) { mStyleElement->GetAttribute(namespaceID,name,title); title.CompressWhitespace(); } I think we should set namespaceID to kNameSpaceID_None, as that is what GetAttributeNameAt does, and that's what initialized namespaceID in the old code (see http://lxr.mozilla.org/seamonkey/source/content/html/content/src/nsGenericHTMLElement.cpp#1866). I'll attach a patch.
Status: NEW → ASSIGNED
OS: Windows 2000 → All
Priority: -- → P4
Hardware: PC → All
Target Milestone: --- → mozilla0.9.2
I'll use this bug to do some cleanup and corrections for the style-loading code. First patch coming up, one or two more will follow.
Priority: P4 → P3
Summary: 'namespaceID' used without having been initialized → Correct/cleanup style loading code in content
*** Bug 83744 has been marked as a duplicate of this bug. ***
I now always set the mParser (in nsStyleLinkElement) to nsnull when setting mDontLoadStyle to PR_TRUE. This ensures that we don't leak the parser when not loading stylesheets. Looking for an r and sr.
sr=jst
Um, near the end of the last patch we bail out if there is a src attribute. I think we should just ignore the src attribute and not bail out if it exists (so you can also avoid GetAttribute for src). This is of course only for XHTML.
We could do that, it does make some sense. Note that we didn't support that before. Is the patch ok otherwise?
Blocks: 83989
Priority: P3 → P1
a= asa@mozilla.org for checkin to the trunk. (on behalf of drivers)
Checked in.
Status: ASSIGNED → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
Marking verified per last comments.
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: