Closed
Bug 211376
Opened 22 years ago
Closed 21 years ago
XUL style attributes should use recycled CSS parsers
Categories
(Core :: XUL, defect)
Core
XUL
Tracking
()
RESOLVED
FIXED
People
(Reporter: bzbarsky, Assigned: bzbarsky)
References
Details
Attachments
(2 files, 3 obsolete files)
81.00 KB,
patch
|
Details | Diff | Splinter Review | |
1.54 KB,
patch
|
Details | Diff | Splinter Review |
This is not a huge deal, since fastloaded XUL is a little smarter.. but still.
Attaching partial patch; I'd like to move over the GetCSSLoader stuff to
nsIDocument (and maybe put it in nsDocument).
![]() |
Assignee | |
Comment 1•22 years ago
|
||
![]() |
Assignee | |
Comment 2•21 years ago
|
||
So.. every single one of our document classes implements
nsIHTMLContentContainer. Is there any objection to just putting those methods
on nsIDocument and killing off the mis-named nsIHTMLContentContainer interface?
Comment 3•21 years ago
|
||
No, none, what so ever. Kill it, and let it RIP.
Comment 4•21 years ago
|
||
Oh, and deCOMtaminate it while you're at it, where possible.
![]() |
Assignee | |
Comment 5•21 years ago
|
||
Attachment #126890 -
Attachment is obsolete: true
![]() |
Assignee | |
Comment 6•21 years ago
|
||
![]() |
Assignee | |
Comment 7•21 years ago
|
||
Comment on attachment 138957 [details] [diff] [review]
Same with -w; may be easier to review
jst, would you do the honors?
Attachment #138957 -
Flags: superreview?(jst)
Attachment #138957 -
Flags: review?(jst)
Comment 8•21 years ago
|
||
Comment on attachment 138957 [details] [diff] [review]
Same with -w; may be easier to review
- In nsIDocument.h:
+ // Strong refs; these are not nsCOMPtr to avoid header hell
+ nsIHTMLStyleSheet* mAttrStyleSheet;
+ nsIHTMLCSSStyleSheet* mStyleAttrStyleSheet;
I doubt the inlining of the getters for these has any noticeable perf or code
size impact, so I think I'd rather see the getters be virtual and these members
as nsCOMPtr's in nsDocument, in stead of here. Done this way, you're now in
theory (though not in our case) forcing implementations of this interface to
release (and do the proper cleanup) of these members, even though they're
members of the interface.
- In nsXULDocument::PrepareStyleSheets():
+ // XXXbz this is similar to code in nsHTMLDocument and
+ // nsXMLDocument; move up to nsDocument?
IMO yes, wanna do that here, or file a separate bug?
- In XULContentSinkImpl::Init():
// Get the CSS loader from the document so we can load
- // stylesheets.
- nsCOMPtr<nsIHTMLContentContainer> htmlContainer =
do_QueryInterface(aDocument);
- NS_ASSERTION(htmlContainer != nsnull, "not an HTML container");
- if (! htmlContainer)
- return NS_ERROR_UNEXPECTED;
-
- rv = htmlContainer->GetCSSLoader(*getter_AddRefs(mCSSLoader));
- if (NS_FAILED(rv)) return rv;
+ mCSSLoader = aDocument->GetCSSLoader();
+ NS_ENSURE_TRUE(mCSSLoader, NS_ERROR_OUT_OF_MEMORY);
Little to trigger happy with the delete key here? Leave the last line of that
comment :-)
- In nsXULElement.h:
static nsICSSParser* GetCSSParser()
{
- if (!sCSSParser)
+ if (!sCSSParser) {
CallCreateInstance(kCSSParserCID, &sCSSParser);
+ if (sCSSParser) {
+ sCSSParser->SetCaseSensitive(PR_TRUE);
+ sCSSParser->SetQuirkMode(PR_FALSE);
Aren't both of the above the defaults? If so, why bother re-setting them?
- In nsXULAttributes::UpdateStyleRule():
+ // XXX GetOwnerDocument
+ nsIDocument* doc = mContent->GetDocument();
+ if (!doc) {
+ nsCOMPtr<nsINodeInfo> nodeInfo = mContent->GetNodeInfo();
+ if (nodeInfo) {
+ doc = nodeInfo->GetDocument();
+ }
+ }
Unless performance here is so critical that saving a virtual call in the
common-case is worth the added code, you could simply do:
+ nsIDocument* doc = mContent->GetNodeInfo()->GetDocument();
You know mContent is an element, so it will have nodeinfo, so no need for any
null checks here either.
r+sr=jst with those changes as you see fit.
Attachment #138957 -
Flags: superreview?(jst)
Attachment #138957 -
Flags: superreview+
Attachment #138957 -
Flags: review?(jst)
Attachment #138957 -
Flags: review+
Comment 9•21 years ago
|
||
>forcing implementations of this interface to
>release (and do the proper cleanup) of these members, even though they're
>members of the interface.
alternatively, the destructor could be made virtual, though that may not be what
you want either...
![]() |
Assignee | |
Comment 10•21 years ago
|
||
> so I think I'd rather see the getters be virtual and these members
> as nsCOMPtr's in nsDocument
Fair enough. Will do.
> IMO yes, wanna do that here, or file a separate bug?
This patch is already big. I'll file a separate bug.
> Little to trigger happy with the delete key here?
Yes. It just felt so nice, y'know. ;)
> Aren't both of the above the defaults?
One is, one is not. The point is, we shouldn't need to worry in this code about
what the defaults are. This is a class static, so the extra code only happens
once per life of mozilla, and it's not much code (one function call).
> + nsIDocument* doc = mContent->GetNodeInfo()->GetDocument();
Done.
I'll rediff once I make sure my changes compile. ;)
![]() |
Assignee | |
Comment 11•21 years ago
|
||
Attachment #138955 -
Attachment is obsolete: true
Attachment #138957 -
Attachment is obsolete: true
![]() |
Assignee | |
Comment 12•21 years ago
|
||
![]() |
Assignee | |
Comment 13•21 years ago
|
||
Checked in. Wins about 2k space and 10ms pageload time. ;)
Status: NEW → RESOLVED
Closed: 21 years ago
Resolution: --- → FIXED
![]() |
Assignee | |
Comment 14•21 years ago
|
||
Filed bug 230947 on moving the attr and inline sheet handling to nsDocument.
Component: XP Toolkit/Widgets: XUL → XUL
QA Contact: shrir → xptoolkit.widgets
You need to log in
before you can comment on or make changes to this bug.
Description
•