From 1776beab14aa3061bb3b67fc2a88743a52f9d228 Mon Sep 17 00:00:00 2001 From: Trevor Saunders Date: Tue, 25 Dec 2012 18:47:17 -0500 Subject: [PATCH] bug 824940 - convert HTMLTitleElement to webidl r=bz --- content/html/content/src/HTMLTitleElement.cpp | 9 +++++++++ content/html/content/src/HTMLTitleElement.h | 16 ++++++++++++++++ dom/webidl/HTMLTitleElement.webidl | 13 +++++++++++++ dom/webidl/WebIDL.mk | 1 + 4 files changed, 39 insertions(+) create mode 100644 dom/webidl/HTMLTitleElement.webidl diff --git a/content/html/content/src/HTMLTitleElement.cpp b/content/html/content/src/HTMLTitleElement.cpp index a99e5ba8b10f..ed587acefdfc 100644 --- a/content/html/content/src/HTMLTitleElement.cpp +++ b/content/html/content/src/HTMLTitleElement.cpp @@ -5,6 +5,8 @@ #include "mozilla/dom/HTMLTitleElement.h" +#include "mozilla/dom/HTMLTitleElementBinding.h" +#include "mozilla/ErrorResult.h" #include "nsStyleConsts.h" #include "nsIDocument.h" #include "nsContentUtils.h" @@ -18,6 +20,7 @@ namespace dom { HTMLTitleElement::HTMLTitleElement(already_AddRefed aNodeInfo) : nsGenericHTMLElement(aNodeInfo) { + SetIsDOMBinding(); AddMutationObserver(this); } @@ -49,6 +52,12 @@ NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLTitleElement) NS_IMPL_ELEMENT_CLONE(HTMLTitleElement) +JSObject* +HTMLTitleElement::WrapNode(JSContext* cx, JSObject* scope, bool* triedToWrap) +{ + return HTMLTitleElementBinding::Wrap(cx, scope, this, triedToWrap); +} + NS_IMETHODIMP HTMLTitleElement::GetText(nsAString& aTitle) diff --git a/content/html/content/src/HTMLTitleElement.h b/content/html/content/src/HTMLTitleElement.h index 554bde9ca6c1..0ee48c6b275c 100644 --- a/content/html/content/src/HTMLTitleElement.h +++ b/content/html/content/src/HTMLTitleElement.h @@ -6,11 +6,14 @@ #ifndef mozilla_dom_HTMLTITLEElement_h_ #define mozilla_dom_HTMLTITLEElement_h_ +#include "mozilla/Attributes.h" #include "nsIDOMHTMLTitleElement.h" #include "nsGenericHTMLElement.h" #include "nsStubMutationObserver.h" namespace mozilla { +class ErrorResult; + namespace dom { class HTMLTitleElement : public nsGenericHTMLElement, @@ -39,6 +42,13 @@ public: // nsIDOMHTMLTitleElement NS_DECL_NSIDOMHTMLTITLEELEMENT + //HTMLTitleElement + //The xpcom GetTextContent() never fails so we just use that. + void SetText(const nsAString& aText, ErrorResult& aError) + { + aError = SetText(aText); + } + // nsIMutationObserver NS_DECL_NSIMUTATIONOBSERVER_CHARACTERDATACHANGED NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED @@ -59,6 +69,12 @@ public: virtual nsXPCClassInfo* GetClassInfo(); virtual nsIDOMNode* AsDOMNode() { return this; } + +protected: + + virtual JSObject* WrapNode(JSContext* cx, JSObject* scope, bool* triedToWrap) + MOZ_OVERRIDE MOZ_FINAL; + private: void SendTitleChangeEvent(bool aBound); }; diff --git a/dom/webidl/HTMLTitleElement.webidl b/dom/webidl/HTMLTitleElement.webidl new file mode 100644 index 000000000000..e695d8421a52 --- /dev/null +++ b/dom/webidl/HTMLTitleElement.webidl @@ -0,0 +1,13 @@ +/* -*- 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-title-element + */ + +interface HTMLTitleElement : HTMLElement { + [SetterThrows] + attribute DOMString text; +}; diff --git a/dom/webidl/WebIDL.mk b/dom/webidl/WebIDL.mk index 9a4e6e4292b2..87eeafb9bbe2 100644 --- a/dom/webidl/WebIDL.mk +++ b/dom/webidl/WebIDL.mk @@ -61,6 +61,7 @@ webidl_files = \ HTMLLabelElement.webidl \ HTMLOptionsCollection.webidl \ HTMLPropertiesCollection.webidl \ + HTMLTitleElement.webidl \ ImageData.webidl \ Location.webidl \ MutationObserver.webidl \