Bug 799905 - .URL and .compatMode should be defined on Document, not HTMLDocument; r=bz
authorAryeh Gregor <ayg@aryeh.name>
Thu, 11 Oct 2012 14:48:31 +0200
changeset 118154 eaa7aff9f43c4d065c47f99dacbe30d8a0accdc4
parent 118153 796eea064cd4dd0d71b80880ca095d5f563c5a2e
child 118155 ba1ece534b748b22e68597b7ef4ba237ba17b143
push id1997
push userakeybl@mozilla.com
push dateMon, 07 Jan 2013 21:25:26 +0000
treeherdermozilla-beta@4baf45cdcf21 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs799905
milestone19.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 799905 - .URL and .compatMode should be defined on Document, not HTMLDocument; r=bz
content/base/src/nsDocument.cpp
content/html/document/src/nsHTMLDocument.cpp
content/svg/document/src/nsSVGDocument.cpp
dom/imptests/failures/webapps/DOMCore/tests/approved/test_interfaces.html.json
dom/interfaces/core/nsIDOMDocument.idl
dom/interfaces/html/nsIDOMHTMLDocument.idl
dom/interfaces/svg/nsIDOMSVGDocument.idl
js/xpconnect/src/dom_quickstubs.qsconf
--- a/content/base/src/nsDocument.cpp
+++ b/content/base/src/nsDocument.cpp
@@ -6068,17 +6068,45 @@ nsDocument::GetMozSyntheticDocument(bool
 NS_IMETHODIMP
 nsDocument::GetDocumentURI(nsAString& aDocumentURI)
 {
   if (mDocumentURI) {
     nsAutoCString uri;
     mDocumentURI->GetSpec(uri);
     CopyUTF8toUTF16(uri, aDocumentURI);
   } else {
-    SetDOMStringToNull(aDocumentURI);
+    aDocumentURI.Truncate();
+  }
+
+  return NS_OK;
+}
+
+// Alias of above
+NS_IMETHODIMP
+nsDocument::GetURL(nsAString& aURL)
+{
+  return GetDocumentURI(aURL);
+}
+
+// readonly attribute DOMString compatMode;
+// Returns "BackCompat" if we are in quirks mode, "CSS1Compat" if we are
+// in almost standards or full standards mode. See bug 105640.  This was
+// implemented to match MSIE's compatMode property.
+NS_IMETHODIMP
+nsDocument::GetCompatMode(nsAString& aCompatMode)
+{
+  NS_ASSERTION(mCompatMode == eCompatibility_NavQuirks ||
+               mCompatMode == eCompatibility_AlmostStandards ||
+               mCompatMode == eCompatibility_FullStandards,
+               "mCompatMode is neither quirks nor strict for this document");
+
+  if (mCompatMode == eCompatibility_NavQuirks) {
+    aCompatMode.AssignLiteral("BackCompat");
+  } else {
+    aCompatMode.AssignLiteral("CSS1Compat");
   }
 
   return NS_OK;
 }
 
 static void BlastSubtreeToPieces(nsINode *aNode);
 
 PLDHashOperator
--- a/content/html/document/src/nsHTMLDocument.cpp
+++ b/content/html/document/src/nsHTMLDocument.cpp
@@ -997,30 +997,16 @@ nsHTMLDocument::SetDomain(const nsAStrin
   if (!ok) {
     // Error: illegal domain
     return NS_ERROR_DOM_BAD_DOCUMENT_DOMAIN;
   }
 
   return NodePrincipal()->SetDomain(newURI);
 }
 
-NS_IMETHODIMP
-nsHTMLDocument::GetURL(nsAString& aURL)
-{
-  nsAutoCString str;
-
-  if (mDocumentURI) {
-    mDocumentURI->GetSpec(str);
-  }
-
-  CopyUTF8toUTF16(str, aURL);
-
-  return NS_OK;
-}
-
 nsIContent*
 nsHTMLDocument::GetBody()
 {
   Element* body = GetBodyElement();
 
   if (body) {
     // There is a body element, return that as the body.
     return body;
@@ -2041,37 +2027,16 @@ nsHTMLDocument::ReleaseEvents(int32_t aE
 
 NS_IMETHODIMP
 nsHTMLDocument::RouteEvent(nsIDOMEvent* aEvt)
 {
   ReportUseOfDeprecatedMethod(this, "UseOfRouteEventWarning");
   return NS_OK;
 }
 
-// readonly attribute DOMString compatMode;
-// Returns "BackCompat" if we are in quirks mode, "CSS1Compat" if we are
-// in almost standards or full standards mode. See bug 105640.  This was
-// implemented to match MSIE's compatMode property
-NS_IMETHODIMP
-nsHTMLDocument::GetCompatMode(nsAString& aCompatMode)
-{
-  NS_ASSERTION(mCompatMode == eCompatibility_NavQuirks ||
-               mCompatMode == eCompatibility_AlmostStandards ||
-               mCompatMode == eCompatibility_FullStandards,
-               "mCompatMode is neither quirks nor strict for this document");
-
-  if (mCompatMode == eCompatibility_NavQuirks) {
-    aCompatMode.AssignLiteral("BackCompat");
-  } else {
-    aCompatMode.AssignLiteral("CSS1Compat");
-  }
-
-  return NS_OK;
-}
-
 // Mapped to document.embeds for NS4 compatibility
 NS_IMETHODIMP
 nsHTMLDocument::GetPlugins(nsIDOMHTMLCollection** aPlugins)
 {
   *aPlugins = nullptr;
 
   return GetEmbeds(aPlugins);
 }
--- a/content/svg/document/src/nsSVGDocument.cpp
+++ b/content/svg/document/src/nsSVGDocument.cpp
@@ -53,33 +53,16 @@ nsSVGDocument::GetDomain(nsAString& aDom
     if (domain.IsEmpty() || NS_FAILED(rv))
       return rv;
     CopyUTF8toUTF16(domain, aDomain);
   }
 
   return NS_OK;
 }
 
-/* readonly attribute DOMString URL; */
-NS_IMETHODIMP
-nsSVGDocument::GetURL(nsAString& aURL)
-{
-  SetDOMStringToNull(aURL);
-
-  if (mDocumentURI) {
-    nsAutoCString url;
-    nsresult rv = mDocumentURI->GetSpec(url);
-    if (url.IsEmpty() || NS_FAILED(rv))
-      return rv;
-    CopyUTF8toUTF16(url, aURL);
-  }
-
-  return NS_OK;
-}
-
 /* readonly attribute SVGSVGElement rootElement; */
 NS_IMETHODIMP
 nsSVGDocument::GetRootElement(nsIDOMSVGSVGElement** aRootElement)
 {
   *aRootElement = nullptr;
   Element* root = nsDocument::GetRootElement();
 
   return root ? CallQueryInterface(root, aRootElement) : NS_OK;
--- a/dom/imptests/failures/webapps/DOMCore/tests/approved/test_interfaces.html.json
+++ b/dom/imptests/failures/webapps/DOMCore/tests/approved/test_interfaces.html.json
@@ -156,18 +156,16 @@
   "Document interface: operation createEvent(DOMString)": true,
   "Document interface: operation createRange()": true,
   "Document interface: operation createNodeIterator(Node,unsigned long,NodeFilter)": true,
   "Document interface: operation createTreeWalker(Node,unsigned long,NodeFilter)": true,
   "XMLDocument interface: existence and properties of interface object": true,
   "XMLDocument interface: existence and properties of interface prototype object": true,
   "XMLDocument interface: existence and properties of interface prototype object's \"constructor\" property": true,
   "Stringification of xmlDoc": "debug",
-  "Document interface: xmlDoc must inherit property \"URL\" with the proper type (1)": true,
-  "Document interface: xmlDoc must inherit property \"compatMode\" with the proper type (3)": true,
   "Document interface: calling getElementsByTagName(DOMString) on xmlDoc with too few arguments must throw TypeError": true,
   "Document interface: calling getElementsByTagNameNS(DOMString,DOMString) on xmlDoc with too few arguments must throw TypeError": true,
   "Document interface: calling getElementsByClassName(DOMString) on xmlDoc with too few arguments must throw TypeError": true,
   "Document interface: calling getElementById(DOMString) on xmlDoc with too few arguments must throw TypeError": true,
   "Document interface: calling createElement(DOMString) on xmlDoc with too few arguments must throw TypeError": true,
   "Document interface: calling createElementNS(DOMString,DOMString) on xmlDoc with too few arguments must throw TypeError": true,
   "Document interface: calling createTextNode(DOMString) on xmlDoc with too few arguments must throw TypeError": true,
   "Document interface: calling createComment(DOMString) on xmlDoc with too few arguments must throw TypeError": true,
--- a/dom/interfaces/core/nsIDOMDocument.idl
+++ b/dom/interfaces/core/nsIDOMDocument.idl
@@ -22,17 +22,17 @@ interface nsIDOMLocation;
  * cannot exist outside the context of a Document, the nsIDOMDocument 
  * interface also contains the factory methods needed to create these 
  * objects.
  *
  * For more information on this interface please see 
  * http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html
  */
 
-[scriptable, uuid(FDB92F4F-C6B4-4509-A29D-A309981E28AC)]
+[scriptable, uuid(22af46a3-64ac-430a-bcc7-d0a9aefe474f)]
 interface nsIDOMDocument : nsIDOMNode
 {
   readonly attribute nsIDOMDocumentType         doctype;
   readonly attribute nsIDOMDOMImplementation    implementation;
   readonly attribute nsIDOMElement              documentElement;
   nsIDOMElement                 createElement(in DOMString tagName)
                                   raises(DOMException);
   nsIDOMDocumentFragment        createDocumentFragment();
@@ -63,16 +63,18 @@ interface nsIDOMDocument : nsIDOMNode
   nsIDOMNodeList                getElementsByTagNameNS(in DOMString namespaceURI,
                                                        in DOMString localName);
   // Introduced in DOM Level 2:
   nsIDOMElement                 getElementById(in DOMString elementId);
   // Introduced in DOM Level 3:
   readonly attribute DOMString       inputEncoding;
   // Introduced in DOM Level 3:
   readonly attribute DOMString       documentURI;
+  // Alias introduced for all documents in recent DOM standards
+  readonly attribute DOMString       URL;
   // Introduced in DOM Level 3:
   nsIDOMNode         adoptNode(in nsIDOMNode source)
                                         raises(DOMException);
 
   /**
    * Create a range
    *
    * @see http://html5.org/specs/dom-range.html#dom-document-createrange
@@ -380,9 +382,15 @@ interface nsIDOMDocument : nsIDOMNode
   [implicit_jscontext] attribute jsval onmouseenter;
   [implicit_jscontext] attribute jsval onmouseleave;
 
   /**
    * Visibility API implementation.
    */
   readonly attribute boolean mozHidden;
   readonly attribute DOMString mozVisibilityState;
+
+  /**
+   * Returns "BackCompat" if we're in quirks mode or "CSS1Compat" if we're in
+   * strict mode.  (XML documents are always in strict mode.)
+   */
+  readonly attribute DOMString compatMode;
 };
--- a/dom/interfaces/html/nsIDOMHTMLDocument.idl
+++ b/dom/interfaces/html/nsIDOMHTMLDocument.idl
@@ -8,25 +8,21 @@
 /**
  * The nsIDOMHTMLDocument interface is the interface to a [X]HTML
  * document object.
  *
  * @see <http://www.whatwg.org/html/>
  */
 interface nsISelection;
 
-[scriptable, uuid(ecae54c6-2ab9-4167-b0ef-61960aadbb68)]
+[scriptable, uuid(3f8666a9-76f0-4733-ae11-4aea8753062d)]
 interface nsIDOMHTMLDocument : nsIDOMDocument
 {
-  readonly attribute DOMString            URL;
            attribute DOMString            domain;
            attribute DOMString            cookie;
-  // returns "BackCompat" if we're in quirks mode,
-  // or "CSS1Compat" if we're in strict mode
-  readonly attribute DOMString            compatMode;
 
   readonly attribute nsIDOMHTMLHeadElement head;
            attribute nsIDOMHTMLElement    body;
 
   readonly attribute nsIDOMHTMLCollection images;
   readonly attribute nsIDOMHTMLCollection embeds;
   // mapped to attribute embeds for NS4 compat
   readonly attribute nsIDOMHTMLCollection plugins;
--- a/dom/interfaces/svg/nsIDOMSVGDocument.idl
+++ b/dom/interfaces/svg/nsIDOMSVGDocument.idl
@@ -2,15 +2,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsIDOMDocument.idl"
 
 interface nsIDOMSVGSVGElement;
 
-[scriptable, uuid(4AEBF9E7-F275-4147-AA90-601626476132)]
+[scriptable, uuid(8fe506e4-5563-4b16-9228-182071e3f8f8)]
 interface nsIDOMSVGDocument : nsIDOMDocument
 {
   readonly attribute DOMString domain;
-  readonly attribute DOMString URL;
   readonly attribute nsIDOMSVGSVGElement rootElement;
 };
--- a/js/xpconnect/src/dom_quickstubs.qsconf
+++ b/js/xpconnect/src/dom_quickstubs.qsconf
@@ -90,16 +90,17 @@ members = [
     # would shadow any quick stub.  Also, document.location is a special
     # case for security.
     #'nsIDOMDocument.location',
     'nsIDOMDocument.elementFromPoint',
     'nsIDOMDocument.activeElement',
     'nsIDOMDocument.onreadystatechange',
     'nsIDOMDocument.onmouseenter',
     'nsIDOMDocument.onmouseleave',
+    'nsIDOMDocument.URL',
     'nsIDOMElement.removeAttributeNS',
     'nsIDOMElement.removeAttribute',
     'nsIDOMElement.getAttribute',
     'nsIDOMElement.getElementsByTagName',
     'nsIDOMElement.setAttribute',
     'nsIDOMElement.getElementsByTagNameNS',
     'nsIDOMElement.hasAttributeNS',
     'nsIDOMElement.tagName',
@@ -202,17 +203,16 @@ members = [
     'nsIDOMHTMLButtonElement.form',
     'nsIDOMHTMLButtonElement.value',
     'nsIDOMHTMLButtonElement.disabled',
     'nsIDOMHTMLCommandElement.*',
     'nsIDOMHTMLDocument.body',
     'nsIDOMHTMLDocument.getElementsByName',
     'nsIDOMHTMLDocument.anchors',
     'nsIDOMHTMLDocument.links',
-    'nsIDOMHTMLDocument.URL',
     'nsIDOMHTMLDocument.forms',
     'nsIDOMHTMLDocument.cookie',
     'nsIDOMHTMLDocument.images',
     'nsIDOMHTMLDocument.write',
     'nsIDOMHTMLDocument.writeln',
     'nsIDOMHTMLDocument.domain',
     'nsIDOMHTMLDocument.getSelection',
     'nsIDOMHTMLDocument.designMode',