Fix for bug 836809 (Convert XMLStyleSheetProcessingInstruction to WebIDL). r=bz.
authorPeter Van der Beken <peterv@propagandism.org>
Fri, 01 Feb 2013 13:28:37 +0100
changeset 131321 a2c01ef72e26d8d2adb9f6d59cd067505a751484
parent 131320 94dc3dd5174a1740a50f42f7675d67ef7d80c4fc
child 131322 13654177590abae26b328c9d2e0356a3e235423c
push id317
push userbbajaj@mozilla.com
push dateTue, 07 May 2013 01:20:33 +0000
treeherdermozilla-release@159a10910249 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs836809
milestone21.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
Fix for bug 836809 (Convert XMLStyleSheetProcessingInstruction to WebIDL). r=bz.
content/xml/content/src/XMLStylesheetProcessingInstruction.cpp
content/xml/content/src/XMLStylesheetProcessingInstruction.h
dom/bindings/Bindings.conf
dom/tests/mochitest/general/Makefile.in
dom/tests/mochitest/general/test_stylesheetPI.html
dom/webidl/WebIDL.mk
dom/webidl/XMLStylesheetProcessingInstruction.webidl
--- a/content/xml/content/src/XMLStylesheetProcessingInstruction.cpp
+++ b/content/xml/content/src/XMLStylesheetProcessingInstruction.cpp
@@ -1,14 +1,15 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* 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 "XMLStylesheetProcessingInstruction.h"
+#include "mozilla/dom/XMLStylesheetProcessingInstructionBinding.h"
 #include "nsNetUtil.h"
 
 DOMCI_NODE_DATA(XMLStylesheetProcessingInstruction,
                 mozilla::dom::XMLStylesheetProcessingInstruction)
 
 namespace mozilla {
 namespace dom {
 
@@ -35,16 +36,24 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_IN
   tmp->nsStyleLinkElement::Unlink();
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END
 
 
 XMLStylesheetProcessingInstruction::~XMLStylesheetProcessingInstruction()
 {
 }
 
+JSObject*
+XMLStylesheetProcessingInstruction::WrapNode(JSContext *aCx, JSObject *aScope,
+                                             bool *aTriedToWrap)
+{
+  return XMLStylesheetProcessingInstructionBinding::Wrap(aCx, aScope, this,
+                                                         aTriedToWrap);
+}
+
 // nsIContent
 
 nsresult
 XMLStylesheetProcessingInstruction::BindToTree(nsIDocument* aDocument,
                                                nsIContent* aParent,
                                                nsIContent* aBindingParent,
                                                bool aCompileEventHandlers)
 {
--- a/content/xml/content/src/XMLStylesheetProcessingInstruction.h
+++ b/content/xml/content/src/XMLStylesheetProcessingInstruction.h
@@ -18,23 +18,32 @@ class XMLStylesheetProcessingInstruction
 public:
   XMLStylesheetProcessingInstruction(already_AddRefed<nsINodeInfo> aNodeInfo,
                                      const nsAString& aData)
     : ProcessingInstruction(aNodeInfo, aData)
   {
   }
   virtual ~XMLStylesheetProcessingInstruction();
 
+  virtual JSObject* WrapNode(JSContext *aCx, JSObject *aScope,
+                             bool *aTriedToWrap);
+
   // nsISupports
   NS_DECL_ISUPPORTS_INHERITED
 
   // CC
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(XMLStylesheetProcessingInstruction,
                                            ProcessingInstruction)
 
+  using nsStyleLinkElement::GetSheet;
+  nsIStyleSheet* GetSheet()
+  {
+    return GetStyleSheet();
+  }
+
   // nsIDOMNode
   virtual void SetNodeValueInternal(const nsAString& aNodeValue,
                                     mozilla::ErrorResult& aError);
 
   // nsIContent
   virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
                               nsIContent* aBindingParent,
                               bool aCompileEventHandlers);
@@ -43,16 +52,17 @@ public:
 
   // nsIStyleSheetLinkingElement
   virtual void OverrideBaseURI(nsIURI* aNewBaseURI);
 
   // nsStyleLinkElement
   NS_IMETHOD GetCharset(nsAString& aCharset);
 
   virtual nsXPCClassInfo* GetClassInfo();
+
 protected:
   nsCOMPtr<nsIURI> mOverriddenBaseURI;
 
   already_AddRefed<nsIURI> GetStyleSheetURL(bool* aIsInline);
   void GetStyleSheetInfo(nsAString& aTitle,
                          nsAString& aType,
                          nsAString& aMedia,
                          bool* aIsScoped,
--- a/dom/bindings/Bindings.conf
+++ b/dom/bindings/Bindings.conf
@@ -992,16 +992,20 @@ DOMInterfaces = {
 {
     'workers': True,
 }],
 
 'XMLSerializer': {
     'nativeType': 'nsDOMSerializer',
 },
 
+'XMLStylesheetProcessingInstruction': {
+    'resultNotAddRefed': [ 'sheet' ]
+},
+
 'XPathEvaluator': {
     'nativeType': 'nsXPathEvaluator',
     'headerFile': 'nsXPathEvaluator.h',
     'wrapperCache': False
 },
 
 'XULElement': {
     'nativeType': 'nsXULElement',
@@ -1224,16 +1228,17 @@ addExternalIface('NodeIterator')
 addExternalIface('nsIStreamListener', nativeType='nsIStreamListener', notflattened=True)
 addExternalIface('nsISupports', nativeType='nsISupports')
 addExternalIface('OutputStream', nativeType='nsIOutputStream',
                  notflattened=True)
 addExternalIface('Principal', nativeType='nsIPrincipal',
                  headerFile='nsIPrincipal.h', notflattened=True)
 addExternalIface('Range', nativeType='nsRange')
 addExternalIface('Selection', nativeType='nsISelection')
+addExternalIface('StyleSheet', nativeType='nsIStyleSheet')
 addExternalIface('StyleSheetList')
 addExternalIface('SVGAnimatedEnumeration', headerFile='nsIDOMSVGAnimatedEnum.h')
 addExternalIface('SVGAnimatedNumber')
 addExternalIface('SVGAnimatedString')
 addExternalIface('SVGLength')
 addExternalIface('SVGNumber')
 addExternalIface('TextMetrics', headerFile='nsIDOMCanvasRenderingContext2D.h')
 addExternalIface('TreeWalker')
--- a/dom/tests/mochitest/general/Makefile.in
+++ b/dom/tests/mochitest/general/Makefile.in
@@ -42,16 +42,17 @@ MOCHITEST_FILES = \
 		test_vibrator.html \
 		test_for_of.html \
 		test_focus_legend_noparent.html \
 		file_clonewrapper.html \
 		file_moving_nodeList.html \
 		test_performance_now.html \
 		test_interfaces.html \
 		test_idleapi_permissions.html \
+		test_stylesheetPI.html \
 		$(NULL)
 
 # Disable this test until bug 795711 is fixed.
 #		test_network_events.html \
 
 MOCHITEST_CHROME_FILES = \
 		test_innerScreen.xul \
 		test_offsets.xul \
new file mode 100644
--- /dev/null
+++ b/dom/tests/mochitest/general/test_stylesheetPI.html
@@ -0,0 +1,37 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=836809
+-->
+<head>
+  <meta charset="utf-8">
+  <title>Test for Bug 836809</title>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+  <script type="application/javascript">
+
+  /** Test for Bug 836809 **/
+
+  var pi = document.createProcessingInstruction('xml-stylesheet', 'href="/tests/SimpleTest/test.css" type="text/css"');
+
+  function checkSheet(e)
+  {
+    ok("sheet" in pi, "XMLStyleSheetProcessingInstruction should have a sheet property");
+    ok(pi.sheet, "XMLStyleSheetProcessingInstruction should have a sheet property");
+  }
+
+  pi.addEventListener("load", checkSheet);
+  document.insertBefore(pi, document.documentElement);
+
+  </script>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=836809">Mozilla Bug 836809</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+</pre>
+</body>
+</html>
--- a/dom/webidl/WebIDL.mk
+++ b/dom/webidl/WebIDL.mk
@@ -177,16 +177,17 @@ webidl_files = \
   ValidityState.webidl \
   WebSocket.webidl \
   UndoManager.webidl \
   USSDReceivedEvent.webidl \
   XMLHttpRequest.webidl \
   XMLHttpRequestEventTarget.webidl \
   XMLHttpRequestUpload.webidl \
   XMLSerializer.webidl \
+  XMLStylesheetProcessingInstruction.webidl \
   XPathEvaluator.webidl \
   XULElement.webidl \
   $(NULL)
 
 ifdef MOZ_WEBGL
 webidl_files += \
   WebGLRenderingContext.webidl \
   $(NULL)
new file mode 100644
--- /dev/null
+++ b/dom/webidl/XMLStylesheetProcessingInstruction.webidl
@@ -0,0 +1,11 @@
+/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* 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/.
+ */
+
+interface StyleSheet;
+
+interface XMLStylesheetProcessingInstruction : ProcessingInstruction {
+  readonly attribute StyleSheet? sheet;
+};