From 4fa84bff4220328e2a83e71b0361af77c4948221 Mon Sep 17 00:00:00 2001 From: "heikki%netscape.com" Date: Tue, 4 Jun 2002 20:24:37 +0000 Subject: [PATCH] Bug 132105, XLinks must pay attention to the popup prefs. r=harishd, sr=jst. git-svn-id: svn://10.0.0.236/trunk@122694 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/content/xml/content/src/Makefile.in | 1 + mozilla/content/xml/content/src/makefile.win | 1 + .../content/xml/content/src/nsXMLElement.cpp | 37 ++++++++++-- mozilla/content/xml/tests/load/loadauth.html | 57 +++++++++++++++++++ mozilla/content/xml/tests/xlink/manual.xml | 14 +++++ 5 files changed, 104 insertions(+), 6 deletions(-) create mode 100644 mozilla/content/xml/tests/load/loadauth.html create mode 100644 mozilla/content/xml/tests/xlink/manual.xml diff --git a/mozilla/content/xml/content/src/Makefile.in b/mozilla/content/xml/content/src/Makefile.in index df09128b5dc..40945f05062 100644 --- a/mozilla/content/xml/content/src/Makefile.in +++ b/mozilla/content/xml/content/src/Makefile.in @@ -42,6 +42,7 @@ REQUIRES = xpcom \ htmlparser \ xpconnect \ unicharutil \ + pref \ $(NULL) CPPSRCS = \ diff --git a/mozilla/content/xml/content/src/makefile.win b/mozilla/content/xml/content/src/makefile.win index dd63eeb6d2c..f99833b8dea 100644 --- a/mozilla/content/xml/content/src/makefile.win +++ b/mozilla/content/xml/content/src/makefile.win @@ -37,6 +37,7 @@ REQUIRES = xpcom \ layout \ gfx \ unicharutil \ + pref \ $(NULL) DEFINES=-D_IMPL_NS_HTML -DWIN32_LEAN_AND_MEAN diff --git a/mozilla/content/xml/content/src/nsXMLElement.cpp b/mozilla/content/xml/content/src/nsXMLElement.cpp index f6cecd5a1f6..1231e0010fb 100644 --- a/mozilla/content/xml/content/src/nsXMLElement.cpp +++ b/mozilla/content/xml/content/src/nsXMLElement.cpp @@ -59,13 +59,14 @@ #include "nsIPresShell.h" #include "nsGUIEvent.h" #include "nsIPresContext.h" - +#include "nsIPref.h" #include "nsIDOMCSSStyleDeclaration.h" #include "nsIDOMViewCSS.h" #include "nsIXBLService.h" #include "nsIXBLBinding.h" #include "nsIBindingManager.h" +static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID); nsresult NS_NewXMLElement(nsIContent** aInstancePtrResult, nsINodeInfo *aNodeInfo) @@ -357,6 +358,21 @@ static inline nsresult SpecialAutoLoadReturn(nsresult aRv, nsLinkVerb aVerb) return aRv; } +inline PRBool BlockNewWindow(nsIPref *aPref) +{ + PRBool blockNewWindow = PR_FALSE; + nsCOMPtr prefs; + if (aPref) { + prefs = dont_QueryInterface(aPref); + } else { + prefs = do_GetService(kPrefServiceCID); + } + if (prefs) { + prefs->GetBoolPref("browser.block.target_new_window", &blockNewWindow); + } + return blockNewWindow; +} + NS_IMETHODIMP nsXMLElement::MaybeTriggerAutoLink(nsIWebShell *aShell) { @@ -381,15 +397,22 @@ nsXMLElement::MaybeTriggerAutoLink(nsIWebShell *aShell) value.Equals(onloadString)) { // show= ? - nsLinkVerb verb = eLinkVerb_Undefined; + nsLinkVerb verb = eLinkVerb_Undefined; // basically means same as replace rv = nsGenericContainerElement::GetAttr(kNameSpaceID_XLink, kShowAtom, value); if (NS_FAILED(rv)) break; + nsCOMPtr prefs(do_GetService(kPrefServiceCID)); + PRBool disableNewDuringLoad = PR_FALSE; + if (prefs) { + prefs->GetBoolPref("dom.disable_open_during_load", &disableNewDuringLoad); + } // XXX Should probably do this using atoms - if (value.Equals(NS_LITERAL_STRING("new"))) { - verb = eLinkVerb_New; + if (!disableNewDuringLoad && value.Equals(NS_LITERAL_STRING("new"))) { + if (!BlockNewWindow(prefs)) { + verb = eLinkVerb_New; + } } else if (value.Equals(NS_LITERAL_STRING("replace"))) { // We want to actually stop processing the current document now. // We do this by returning the correct value so that the one @@ -469,7 +492,7 @@ nsXMLElement::HandleDOMEvent(nsIPresContext* aPresContext, } nsAutoString show, href, target; nsIURI* baseURL = nsnull; - nsLinkVerb verb = eLinkVerb_Undefined; + nsLinkVerb verb = eLinkVerb_Undefined; // basically means same as replace nsGenericContainerElement::GetAttr(kNameSpaceID_XLink, kHrefAtom, href); @@ -484,7 +507,9 @@ nsXMLElement::HandleDOMEvent(nsIPresContext* aPresContext, // XXX Should probably do this using atoms if (show.Equals(NS_LITERAL_STRING("new"))) { - verb = eLinkVerb_New; + if (!BlockNewWindow(nsnull)) { + verb = eLinkVerb_New; + } } else if (show.Equals(NS_LITERAL_STRING("replace"))) { verb = eLinkVerb_Replace; } else if (show.Equals(NS_LITERAL_STRING("embed"))) { diff --git a/mozilla/content/xml/tests/load/loadauth.html b/mozilla/content/xml/tests/load/loadauth.html new file mode 100644 index 00000000000..628cd27ff7a --- /dev/null +++ b/mozilla/content/xml/tests/load/loadauth.html @@ -0,0 +1,57 @@ + + +Synchronized document.load() test + + + + +

Synchronized document.load() test

+ +
XML document serialized +
@@No result@@
+
+
Event information +
@@No result@@
+
+ + + + diff --git a/mozilla/content/xml/tests/xlink/manual.xml b/mozilla/content/xml/tests/xlink/manual.xml new file mode 100644 index 00000000000..fd7d49fc177 --- /dev/null +++ b/mozilla/content/xml/tests/xlink/manual.xml @@ -0,0 +1,14 @@ + + + +

Testing manual simple XLinks.

+ +Must not open, illegal + +Must open in new window (www.mozilla.org) + +Must open in same window (www.mozillazine.org) + +Foo +
+