Closed Bug 123343 Opened 23 years ago Closed 22 years ago

XML output handler needs to handle base-tags

Categories

(Core :: XSLT, defect, P3)

defect

Tracking

()

VERIFIED FIXED
mozilla1.0

People

(Reporter: sicking, Assigned: sicking)

References

()

Details

Attachments

(1 file, 6 obsolete files)

We need to do what the xml contentsink does and special-handle <base> tags
and here is a piece of spec:
http://www.w3.org/TR/html4/struct/links.html#h-12.4
Attached patch patch v1 (obsolete) — Splinter Review
this adds a bunch of html-handling to the output handler. I desided to break
out the handling from ::closePrevious and ::startElement since with the new
code i needed to add it just became too messy IMHO.

So now we have ::startHTMLElement which is called right after the element is
created, and ::endHTMLElement which is called when the the element is closed.
::startHTMLElement returns a boolean which indicates if the element is to be
inserted in the tree or if that should be held off until the elements children
are processed (for <script>).

The patch fixes:
 * support <base>
 * support <meta http-equiv="...">
 * keep track of stylesheets and specify stylesheetindex to speed up (and
   correct) cascading order
my patch, my bug
Assignee: peterv → sicking
Priority: -- → P3
Target Milestone: --- → mozilla1.0
I just noted that this patch also fixes the fact that all stylesheets in the
result document gets doubled.
Comment on attachment 71100 [details] [diff] [review]
patch v1 -w

>+PRBool txMozillaXMLOutput::startHTMLElement(nsIDOMElement* aElement)
>+{
>+    PRBool dontAppendNode = PR_FALSE;
>             nsCOMPtr<nsIAtom> atom;
>-            currentContent->GetTag(*getter_AddRefs(atom));
>-            if ((atom == txHTMLAtoms::title) && mTitleElement) {
>+    nsCOMPtr<nsIContent> content = do_QueryInterface(aElement);
>+    content->GetTag(*getter_AddRefs(atom));
>+
>+    if (atom == txHTMLAtoms::script) {
>+        dontAppendNode = PR_TRUE;
>+    }
>+
>+    nsCOMPtr<nsIStyleSheetLinkingElement> ssle =
>+        do_QueryInterface(aElement);
>+    if (ssle) {
>+        // XXX Trick nsCSSLoader into blocking/notifying us?
>+        //     We would need to implement nsIParser and
>+        //     pass ourselves as first parameter to
>+        //     InitStyleLinkElement. We would then be notified
>+        //     of stylesheet loads/load failures.
>+        ssle->InitStyleLinkElement(nsnull, PR_FALSE);
>+        ssle->SetEnableUpdates(PR_FALSE);
>+    }
>+    
>+    return dontAppendNode;
>+}

I think you could just do mDontAddCurrent = (atom == txHTMLAtoms::script);

>Index: source/xslt/txMozillaXMLOutput.h
>===================================================================
>RCS file: /cvsroot/mozilla/extensions/transformiix/source/xslt/txMozillaXMLOutput.h,v
>retrieving revision 1.2
>diff -u -w -r1.2 txMozillaXMLOutput.h
>--- source/xslt/txMozillaXMLOutput.h	19 Feb 2002 22:48:07 -0000	1.2
>+++ source/xslt/txMozillaXMLOutput.h	23 Feb 2002 19:08:44 -0000
>@@ -160,7 +160,9 @@
> 
> private:
>     void closePrevious(PRInt8 aAction);
>-    void startHTMLElement(nsIDOMElement* aElement);
>+    PRBool startHTMLElement(nsIDOMElement* aElement);
>+    void endHTMLElement(nsIDOMElement* aElement, PRBool aXHTML);
>+    void ProcessHTTPEquiv(nsIAtom* aHeader, nsAReadableString& aValue);

processHTTPEquiv
Attached patch patch v2 (obsolete) — Splinter Review
addresses petervs comments and moves the set-refresh-timer code to endDocument
on Pikes request.
Attachment #71099 - Attachment is obsolete: true
Attachment #71100 - Attachment is obsolete: true
oops, the comment at the top of txMozillaXMLOutput::processHTTPEquiv is 
supposed to say

    // For now we only handle "refresh". There's a longer list in
    // HTMLContentSink::ProcessHeaderData

done locally
Status: NEW → ASSIGNED
Comment on attachment 72843 [details] [diff] [review]
patch v2

>+    if (!mRefreshString.IsEmpty()) {
>+        nsCOMPtr<nsIDocument> doc = do_QueryInterface(mDocument);
>+        nsCOMPtr<nsIScriptGlobalObject> sgo;
>+        doc->GetScriptGlobalObject(getter_AddRefs(sgo));
>+        if(!sgo)

Space after if

>+            return;
>+        nsCOMPtr<nsIDocShell> docShell;
>+        sgo->GetDocShell(getter_AddRefs(docShell));
>+        if(!docShell)

Ditto

>+            return;
>+        nsCOMPtr<nsIRefreshURI> refURI = do_QueryInterface(docShell);
>+        if(!refURI)

Ditto

>@@ -311,7 +307,7 @@
>     closePrevious(eCloseElement | eFlushText);
> 
>     nsresult rv;
>-
>+    

Don't add the extra spaces.

>+        nsCOMPtr<nsIDocument> doc = do_QueryInterface(mDocument);
>+        NS_ASSERTION(doc, "document doesn't implement nsIDocument");
>+        nsAutoString value;
>+        content->GetAttr(kNameSpaceID_HTML, txHTMLAtoms::target, value);
>+        doc->SetBaseTarget(value);

kNameSpaceID_None

>+
>+        content->GetAttr(kNameSpaceID_HTML, txHTMLAtoms::href, value);

Ditto.

r=peterv.
Attachment #72843 - Flags: review+
Attached patch patch v3 (obsolete) — Splinter Review
addresses all petervs comments
Attachment #72843 - Attachment is obsolete: true
Attached patch *this* is patch v3 (obsolete) — Splinter Review
oops
Attachment #73211 - Attachment is obsolete: true
Comment on attachment 73212 [details] [diff] [review]
*this* is patch v3

bringing over petervs r=
Attachment #73212 - Flags: review+
Comment on attachment 73212 [details] [diff] [review]
*this* is patch v3

>Index: source/xslt/txMozillaXMLOutput.cpp
[...]
> void txMozillaXMLOutput::endDocument()
[...]
>+        nsCOMPtr<nsIDocShell> docShell;
>+        sgo->GetDocShell(getter_AddRefs(docShell));
>+        if (!docShell)
>+            return;

The above null check is not needed, the do_QueryInterface() below will do the
null check for you.

>+        nsCOMPtr<nsIRefreshURI> refURI = do_QueryInterface(docShell);
>+        if (!refURI)
>+            return;
>+        

I don't like the early return here, what if someone adds code to the end of
this method, then it won't get executed if there's no docshell? I'd add an if
check and put the code inside it in stead of returning early in this case.

>+        if (!mScriptElements)
>+            NS_NewISupportsArray(getter_AddRefs(mScriptElements));
>+        NS_ASSERTION(mScriptElements, "Can't create array");
>+        if (mScriptElements)
>+            mScriptElements->AppendElement(scriptElement);

Don't you want to return NS_ERROR_OUT_OF_MEMORY in cases like this if we can't
create a new nsISupportsArray?

Other than that, sr=jst
Attachment #73212 - Flags: superreview+
Attached patch patch v4 (obsolete) — Splinter Review
addresses all jsts comments except the last since the function returns void.

Got ok over irc
Attachment #73212 - Attachment is obsolete: true
Comment on attachment 73612 [details] [diff] [review]
patch v4

bringing over reviews
Attachment #73612 - Flags: superreview+
Attachment #73612 - Flags: review+
i really must stop hacking at night. Saving before diffing makes so big
difference
Attachment #73612 - Attachment is obsolete: true
checked in
Status: ASSIGNED → RESOLVED
Closed: 22 years ago
Resolution: --- → FIXED
we didn't verify for a long time.
I really checked, so VERIFIED.
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: