Bug 839053 - Part b: Move HTMLLinkElement to Paris bindings; r=bz
authorMs2ger <ms2ger@gmail.com>
Fri, 08 Feb 2013 13:50:30 +0100
changeset 131165 494e348aa8bb03ced4696db7284876abad2c61b3
parent 131164 a5df70a08031de1d6c84645ed40736dd3fe492cc
child 131166 fcbfbf396e1ff7b1302318ac8adcffcbeeed3ff2
push id2323
push userbbajaj@mozilla.com
push dateMon, 01 Apr 2013 19:47:02 +0000
treeherdermozilla-beta@7712be144d91 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs839053
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
Bug 839053 - Part b: Move HTMLLinkElement to Paris bindings; r=bz
content/html/content/src/HTMLLinkElement.cpp
content/html/content/src/HTMLLinkElement.h
dom/bindings/Bindings.conf
dom/webidl/HTMLLinkElement.webidl
dom/webidl/WebIDL.mk
--- a/content/html/content/src/HTMLLinkElement.cpp
+++ b/content/html/content/src/HTMLLinkElement.cpp
@@ -1,15 +1,16 @@
 /* -*- 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 "mozilla/dom/HTMLLinkElement.h"
 
+#include "mozilla/dom/HTMLLinkElementBinding.h"
 #include "nsGenericHTMLElement.h"
 #include "nsILink.h"
 #include "nsGkAtoms.h"
 #include "nsStyleConsts.h"
 #include "nsIDOMStyleSheet.h"
 #include "nsIStyleSheet.h"
 #include "nsIStyleSheetLinkingElement.h"
 #include "nsReadableUtils.h"
@@ -28,16 +29,17 @@ DOMCI_NODE_DATA(HTMLLinkElement, mozilla
 
 namespace mozilla {
 namespace dom {
 
 HTMLLinkElement::HTMLLinkElement(already_AddRefed<nsINodeInfo> aNodeInfo)
   : nsGenericHTMLElement(aNodeInfo),
     Link(this)
 {
+  SetIsDOMBinding();
 }
 
 HTMLLinkElement::~HTMLLinkElement()
 {
 }
 
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(HTMLLinkElement,
                                                   nsGenericHTMLElement)
@@ -62,43 +64,54 @@ NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION
                                    Link)
   NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(HTMLLinkElement,
                                                nsGenericHTMLElement)
 NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLLinkElement)
 
 
 NS_IMPL_ELEMENT_CLONE(HTMLLinkElement)
 
+bool
+HTMLLinkElement::GetDisabled(ErrorResult& aRv)
+{
+  nsCOMPtr<nsIDOMStyleSheet> ss = do_QueryInterface(GetSheet());
+  if (!ss) {
+    return false;
+  }
+
+  bool disabled = false;
+  aRv = ss->GetDisabled(&disabled);
+  return disabled;
+}
 
 NS_IMETHODIMP
 HTMLLinkElement::GetDisabled(bool* aDisabled)
 {
-  nsCOMPtr<nsIDOMStyleSheet> ss = do_QueryInterface(GetSheet());
-  nsresult result = NS_OK;
-
-  if (ss) {
-    result = ss->GetDisabled(aDisabled);
-  } else {
-    *aDisabled = false;
-  }
-
-  return result;
+  ErrorResult rv;
+  *aDisabled = GetDisabled(rv);
+  return rv.ErrorCode();
 }
 
-NS_IMETHODIMP 
-HTMLLinkElement::SetDisabled(bool aDisabled)
+void
+HTMLLinkElement::SetDisabled(bool aDisabled, ErrorResult& aRv)
 {
   nsCOMPtr<nsIDOMStyleSheet> ss = do_QueryInterface(GetSheet());
-  nsresult result = NS_OK;
-
-  if (ss) {
-    result = ss->SetDisabled(aDisabled);
+  if (!ss) {
+    return;
   }
 
-  return result;
+  aRv = ss->SetDisabled(aDisabled);
+}
+
+NS_IMETHODIMP
+HTMLLinkElement::SetDisabled(bool aDisabled)
+{
+  ErrorResult rv;
+  SetDisabled(aDisabled, rv);
+  return rv.ErrorCode();
 }
 
 
 NS_IMPL_STRING_ATTR(HTMLLinkElement, Charset, charset)
 NS_IMPL_URI_ATTR(HTMLLinkElement, Href, href)
 NS_IMPL_STRING_ATTR(HTMLLinkElement, Hreflang, hreflang)
 NS_IMPL_STRING_ATTR(HTMLLinkElement, Media, media)
 NS_IMPL_STRING_ATTR(HTMLLinkElement, Rel, rel)
@@ -408,10 +421,16 @@ HTMLLinkElement::IntrinsicState() const
 
 size_t
 HTMLLinkElement::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const
 {
   return nsGenericHTMLElement::SizeOfExcludingThis(aMallocSizeOf) +
          Link::SizeOfExcludingThis(aMallocSizeOf);
 }
 
+JSObject*
+HTMLLinkElement::WrapNode(JSContext* aCx, JSObject* aScope, bool* aTriedToWrap)
+{
+  return HTMLLinkElementBinding::Wrap(aCx, aScope, this, aTriedToWrap);
+}
+
 } // namespace dom
 } // namespace mozilla
--- a/content/html/content/src/HTMLLinkElement.h
+++ b/content/html/content/src/HTMLLinkElement.h
@@ -54,16 +54,18 @@ public:
   // nsIDOMEventTarget
   virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor);
   virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor);
 
   // nsINode
   virtual nsresult Clone(nsINodeInfo* aNodeInfo, nsINode** aResult) const;
   virtual nsXPCClassInfo* GetClassInfo();
   virtual nsIDOMNode* AsDOMNode() { return this; }
+  virtual JSObject*
+  WrapNode(JSContext* aCx, JSObject* aScope, bool* aTriedToWrap) MOZ_OVERRIDE;
 
   // nsIContent
   virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
                               nsIContent* aBindingParent,
                               bool aCompileEventHandlers);
   virtual void UnbindFromTree(bool aDeep = true,
                               bool aNullParent = true);
   nsresult SetAttr(int32_t aNameSpaceID, nsIAtom* aName,
@@ -85,16 +87,65 @@ public:
                               nsIAtom* aAttribute,
                               const nsAString& aValue,
                               nsAttrValue& aResult);
   virtual void GetLinkTarget(nsAString& aTarget);
   virtual nsEventStates IntrinsicState() const;
 
   void CreateAndDispatchEvent(nsIDocument* aDoc, const nsAString& aEventName);
 
+  // WebIDL
+  bool GetDisabled(ErrorResult& aRv);
+  void SetDisabled(bool aDisabled, ErrorResult& aRv);
+  // XPCOM GetHref is fine.
+  void SetHref(const nsAString& aHref, ErrorResult& aRv)
+  {
+    SetHTMLAttr(nsGkAtoms::href, aHref, aRv);
+  }
+  // XPCOM GetCrossOrigin is fine.
+  void SetCrossOrigin(const nsAString& aCrossOrigin, ErrorResult& aRv)
+  {
+    SetHTMLAttr(nsGkAtoms::crossorigin, aCrossOrigin, aRv);
+  }
+  // XPCOM GetRel is fine.
+  void SetRel(const nsAString& aRel, ErrorResult& aRv)
+  {
+    SetHTMLAttr(nsGkAtoms::rel, aRel, aRv);
+  }
+  // XPCOM GetMedia is fine.
+  void SetMedia(const nsAString& aMedia, ErrorResult& aRv)
+  {
+    SetHTMLAttr(nsGkAtoms::media, aMedia, aRv);
+  }
+  // XPCOM GetHreflang is fine.
+  void SetHreflang(const nsAString& aHreflang, ErrorResult& aRv)
+  {
+    SetHTMLAttr(nsGkAtoms::hreflang, aHreflang, aRv);
+  }
+  // XPCOM GetType is fine.
+  void SetType(const nsAString& aType, ErrorResult& aRv)
+  {
+    SetHTMLAttr(nsGkAtoms::type, aType, aRv);
+  }
+  // XPCOM GetCharset is fine.
+  void SetCharset(const nsAString& aCharset, ErrorResult& aRv)
+  {
+    SetHTMLAttr(nsGkAtoms::charset, aCharset, aRv);
+  }
+  // XPCOM GetRev is fine.
+  void SetRev(const nsAString& aRev, ErrorResult& aRv)
+  {
+    SetHTMLAttr(nsGkAtoms::rev, aRev, aRv);
+  }
+  // XPCOM GetTarget is fine.
+  void SetTarget(const nsAString& aTarget, ErrorResult& aRv)
+  {
+    SetHTMLAttr(nsGkAtoms::target, aTarget, aRv);
+  }
+
 protected:
   // nsStyleLinkElement
   virtual already_AddRefed<nsIURI> GetStyleSheetURL(bool* aIsInline);
   virtual void GetStyleSheetInfo(nsAString& aTitle,
                                  nsAString& aType,
                                  nsAString& aMedia,
                                  bool* aIsScoped,
                                  bool* aIsAlternate);
--- a/dom/bindings/Bindings.conf
+++ b/dom/bindings/Bindings.conf
@@ -434,16 +434,20 @@ DOMInterfaces = {
     ],
     'hasInstanceInterface': 'nsIDOMHTMLLabelElement',
 },
 
 'HTMLLIElement': {
     'hasInstanceInterface': 'nsIDOMHTMLLIElement',
 },
 
+'HTMLLinkElement': {
+    'hasInstanceInterface': 'nsIDOMHTMLLinkElement',
+},
+
 'HTMLMapElement': {
     'hasInstanceInterface': 'nsIDOMHTMLMapElement',
 },
 
 'HTMLMetaElement': {
     'hasInstanceInterface': 'nsIDOMHTMLMetaElement',
 },
 
new file mode 100644
--- /dev/null
+++ b/dom/webidl/HTMLLinkElement.webidl
@@ -0,0 +1,45 @@
+/* -*- 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/.
+ *
+ * The origin of this IDL file is
+ * http://www.whatwg.org/specs/web-apps/current-work/#the-link-element
+ * http://www.whatwg.org/specs/web-apps/current-work/#other-elements,-attributes-and-apis
+ * © Copyright 2004-2011 Apple Computer, Inc., Mozilla Foundation, and
+ * Opera Software ASA. You are granted a license to use, reproduce
+ * and create derivative works of this document.
+ */
+
+// http://www.whatwg.org/specs/web-apps/current-work/#the-link-element
+interface HTMLLinkElement : HTMLElement {
+  [Throws]
+           attribute boolean disabled;
+  [SetterThrows, Pure]
+           attribute DOMString href;
+  [SetterThrows, Pure]
+           attribute DOMString crossOrigin;
+  [SetterThrows, Pure]
+           attribute DOMString rel;
+// Not supported yet:
+//  readonly attribute DOMTokenList relList;
+  [SetterThrows, Pure]
+           attribute DOMString media;
+  [SetterThrows, Pure]
+           attribute DOMString hreflang;
+  [SetterThrows, Pure]
+           attribute DOMString type;
+// Not supported yet:
+//  [PutForwards=value] readonly attribute DOMSettableTokenList sizes;
+};
+HTMLLinkElement implements LinkStyle;
+
+// http://www.whatwg.org/specs/web-apps/current-work/#other-elements,-attributes-and-apis
+partial interface HTMLLinkElement {
+  [SetterThrows, Pure]
+           attribute DOMString charset;
+  [SetterThrows, Pure]
+           attribute DOMString rev;
+  [SetterThrows, Pure]
+           attribute DOMString target;
+};
--- a/dom/webidl/WebIDL.mk
+++ b/dom/webidl/WebIDL.mk
@@ -71,16 +71,17 @@ webidl_files = \
   HTMLFrameSetElement.webidl \
   HTMLHeadElement.webidl \
   HTMLHeadingElement.webidl \
   HTMLHRElement.webidl \
   HTMLHtmlElement.webidl \
   HTMLImageElement.webidl \
   HTMLLabelElement.webidl \
   HTMLLIElement.webidl \
+  HTMLLinkElement.webidl \
   HTMLMapElement.webidl \
   HTMLMetaElement.webidl \
   HTMLMeterElement.webidl \
   HTMLModElement.webidl \
   HTMLOListElement.webidl \
   HTMLOptionsCollection.webidl \
   HTMLParagraphElement.webidl \
   HTMLParamElement.webidl \