Fix for bug 824007 (Convert HTMLBodyElement, HTMLDataListElement, HTMLFontElement, HTMLFrameSetElement and HTMLLabelElement to new DOM bindings). r=bz.

--HG--
rename : content/html/content/src/nsHTMLBodyElement.cpp => content/html/content/src/HTMLBodyElement.cpp
rename : content/html/content/src/nsHTMLDataListElement.cpp => content/html/content/src/HTMLDataListElement.cpp
rename : content/html/content/src/nsHTMLFontElement.cpp => content/html/content/src/HTMLFontElement.cpp
rename : content/html/content/src/nsHTMLFrameSetElement.cpp => content/html/content/src/HTMLFrameSetElement.cpp
rename : content/html/content/src/nsHTMLFrameSetElement.h => content/html/content/src/HTMLFrameSetElement.h
rename : content/html/content/src/nsHTMLLabelElement.cpp => content/html/content/src/HTMLLabelElement.cpp
rename : content/html/content/src/nsHTMLLabelElement.h => content/html/content/src/HTMLLabelElement.h
extra : rebase_source : f287e7530fa829a6159537476dc1418bbc9f40e5
This commit is contained in:
Peter Van der Beken 2012-12-21 15:07:28 +01:00
Родитель d837e37c50
Коммит c466c4597c
20 изменённых файлов: 655 добавлений и 71 удалений

Просмотреть файл

@ -6,6 +6,7 @@
#include "mozilla/Util.h"
#include "HTMLBodyElement.h"
#include "mozilla/dom/HTMLBodyElementBinding.h"
#include "nsAttrValueInlines.h"
#include "nsGkAtoms.h"
#include "nsStyleConsts.h"
@ -19,7 +20,7 @@
#include "nsIDocShell.h"
#include "nsIEditorDocShell.h"
#include "nsRuleWalker.h"
#include "mozilla/dom/EventHandlerBinding.h"
#include "nsGlobalWindow.h"
NS_IMPL_NS_NEW_HTML_ELEMENT(Body)
DOMCI_NODE_DATA(HTMLBodyElement, mozilla::dom::HTMLBodyElement)
@ -190,10 +191,14 @@ HTMLBodyElement::~HTMLBodyElement()
{
if (mContentStyleRule) {
mContentStyleRule->mPart = nullptr;
NS_RELEASE(mContentStyleRule);
}
}
JSObject*
HTMLBodyElement::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap)
{
return HTMLBodyElementBinding::Wrap(aCx, aScope, this, aTriedToWrap);
}
NS_IMPL_ADDREF_INHERITED(HTMLBodyElement, Element)
NS_IMPL_RELEASE_INHERITED(HTMLBodyElement, Element)
@ -207,13 +212,107 @@ NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLBodyElement)
NS_IMPL_ELEMENT_CLONE(HTMLBodyElement)
NS_IMETHODIMP
HTMLBodyElement::SetBackground(const nsAString& aBackground)
{
ErrorResult rv;
SetBackground(aBackground, rv);
return rv.ErrorCode();
}
NS_IMPL_STRING_ATTR(HTMLBodyElement, Background, background)
NS_IMPL_STRING_ATTR(HTMLBodyElement, VLink, vlink)
NS_IMPL_STRING_ATTR(HTMLBodyElement, ALink, alink)
NS_IMPL_STRING_ATTR(HTMLBodyElement, Link, link)
NS_IMPL_STRING_ATTR(HTMLBodyElement, Text, text)
NS_IMPL_STRING_ATTR(HTMLBodyElement, BgColor, bgcolor)
NS_IMETHODIMP
HTMLBodyElement::GetBackground(nsAString& aBackground)
{
nsString background;
GetBackground(background);
aBackground = background;
return NS_OK;
}
NS_IMETHODIMP
HTMLBodyElement::SetVLink(const nsAString& aVLink)
{
ErrorResult rv;
SetVLink(aVLink, rv);
return rv.ErrorCode();
}
NS_IMETHODIMP
HTMLBodyElement::GetVLink(nsAString& aVLink)
{
nsString vLink;
GetVLink(vLink);
aVLink = vLink;
return NS_OK;
}
NS_IMETHODIMP
HTMLBodyElement::SetALink(const nsAString& aALink)
{
ErrorResult rv;
SetALink(aALink, rv);
return rv.ErrorCode();
}
NS_IMETHODIMP
HTMLBodyElement::GetALink(nsAString& aALink)
{
nsString aLink;
GetALink(aLink);
aALink = aLink;
return NS_OK;
}
NS_IMETHODIMP
HTMLBodyElement::SetLink(const nsAString& aLink)
{
ErrorResult rv;
SetLink(aLink, rv);
return rv.ErrorCode();
}
NS_IMETHODIMP
HTMLBodyElement::GetLink(nsAString& aLink)
{
nsString link;
GetLink(link);
aLink = link;
return NS_OK;
}
NS_IMETHODIMP
HTMLBodyElement::SetText(const nsAString& aText)
{
ErrorResult rv;
SetText(aText, rv);
return rv.ErrorCode();
}
NS_IMETHODIMP
HTMLBodyElement::GetText(nsAString& aText)
{
nsString text;
GetText(text);
aText = text;
return NS_OK;
}
NS_IMETHODIMP
HTMLBodyElement::SetBgColor(const nsAString& aBgColor)
{
ErrorResult rv;
SetBgColor(aBgColor, rv);
return rv.ErrorCode();
}
NS_IMETHODIMP
HTMLBodyElement::GetBgColor(nsAString& aBgColor)
{
nsString bgColor;
GetBgColor(bgColor);
aBgColor = bgColor;
return NS_OK;
}
bool
HTMLBodyElement::ParseAttribute(int32_t aNamespaceID,
@ -389,11 +488,11 @@ HTMLBodyElement::GetAssociatedEditor()
// nsGenericHTMLElement::GetOnError returns
// already_AddRefed<EventHandlerNonNull> while other getters return
// EventHandlerNonNull*, so allow passing in the type to use here.
#define FORWARDED_EVENT_HELPER(name_, getter_type_) \
#define FORWARDED_EVENT_HELPER(name_, forwardto_, type_, getter_type_) \
NS_IMETHODIMP \
HTMLBodyElement::GetOn##name_(JSContext *cx, jsval *vp) \
{ \
getter_type_ h = nsGenericHTMLElement::GetOn##name_(); \
getter_type_ h = forwardto_::GetOn##name_(); \
vp->setObjectOrNull(h ? h->Callable() : nullptr); \
return NS_OK; \
} \
@ -405,46 +504,59 @@ HTMLBodyElement::GetAssociatedEditor()
/* Just silently do nothing */ \
return NS_OK; \
} \
nsRefPtr<EventHandlerNonNull> handler; \
nsRefPtr<type_> handler; \
JSObject *callable; \
if (v.isObject() && \
JS_ObjectIsCallable(cx, callable = &v.toObject())) { \
bool ok; \
handler = new EventHandlerNonNull(cx, obj, callable, &ok); \
handler = new type_(cx, obj, callable, &ok); \
if (!ok) { \
return NS_ERROR_OUT_OF_MEMORY; \
} \
} \
ErrorResult rv; \
nsGenericHTMLElement::SetOn##name_(handler, rv); \
forwardto_::SetOn##name_(handler, rv); \
return rv.ErrorCode(); \
}
#define FORWARDED_EVENT(name_, id_, type_, struct_) \
FORWARDED_EVENT_HELPER(name_, EventHandlerNonNull*)
FORWARDED_EVENT_HELPER(name_, nsGenericHTMLElement, EventHandlerNonNull, \
EventHandlerNonNull*)
#define ERROR_EVENT(name_, id_, type_, struct_) \
FORWARDED_EVENT_HELPER(name_, nsCOMPtr<EventHandlerNonNull>)
#define WINDOW_EVENT(name_, id_, type_, struct_) \
NS_IMETHODIMP \
HTMLBodyElement::GetOn##name_(JSContext *cx, jsval *vp) \
FORWARDED_EVENT_HELPER(name_, nsGenericHTMLElement, \
EventHandlerNonNull, nsCOMPtr<EventHandlerNonNull>)
#define WINDOW_EVENT_HELPER(name_, type_) \
type_* \
HTMLBodyElement::GetOn##name_() \
{ \
nsPIDOMWindow* win = OwnerDoc()->GetInnerWindow(); \
if (win && win->IsInnerWindow()) { \
return win->GetOn##name_(cx, vp); \
nsCOMPtr<nsISupports> supports = do_QueryInterface(win); \
nsGlobalWindow* globalWin = nsGlobalWindow::FromSupports(supports); \
return globalWin->GetOn##name_(); \
} \
*vp = JSVAL_NULL; \
return NS_OK; \
return nullptr; \
} \
NS_IMETHODIMP \
HTMLBodyElement::SetOn##name_(JSContext *cx, const jsval &v) \
void \
HTMLBodyElement::SetOn##name_(type_* handler, ErrorResult& error) \
{ \
nsPIDOMWindow* win = OwnerDoc()->GetInnerWindow(); \
if (win && win->IsInnerWindow()) { \
return win->SetOn##name_(cx, v); \
if (!win || !win->IsInnerWindow()) { \
return; \
} \
return NS_OK; \
}
\
nsCOMPtr<nsISupports> supports = do_QueryInterface(win); \
nsGlobalWindow* globalWin = nsGlobalWindow::FromSupports(supports); \
return globalWin->SetOn##name_(handler, error); \
} \
FORWARDED_EVENT_HELPER(name_, HTMLBodyElement, type_, type_*)
#define WINDOW_EVENT(name_, id_, type_, struct_) \
WINDOW_EVENT_HELPER(name_, EventHandlerNonNull)
#define BEFOREUNLOAD_EVENT(name_, id_, type_, struct_) \
WINDOW_EVENT_HELPER(name_, BeforeUnloadEventHandlerNonNull)
#include "nsEventNameList.h"
#undef BEFOREUNLOAD_EVENT
#undef WINDOW_EVENT
#undef WINDOW_EVENT_HELPER
#undef ERROR_EVENT
#undef FORWARDED_EVENT
#undef FORWARDED_EVENT_HELPER

Просмотреть файл

@ -40,9 +40,9 @@ public:
using Element::SetText;
HTMLBodyElement(already_AddRefed<nsINodeInfo> aNodeInfo)
: nsGenericHTMLElement(aNodeInfo),
mContentStyleRule(nullptr)
: nsGenericHTMLElement(aNodeInfo)
{
SetIsDOMBinding();
}
virtual ~HTMLBodyElement();
@ -67,10 +67,69 @@ public:
#define FORWARDED_EVENT(name_, id_, type_, struct_) \
NS_IMETHOD GetOn##name_(JSContext *cx, jsval *vp); \
NS_IMETHOD SetOn##name_(JSContext *cx, const jsval &v);
#define WINDOW_EVENT_HELPER(name_, type_) \
type_* GetOn##name_(); \
void SetOn##name_(type_* handler, ErrorResult& error);
#define WINDOW_EVENT(name_, id_, type_, struct_) \
WINDOW_EVENT_HELPER(name_, EventHandlerNonNull)
#define BEFOREUNLOAD_EVENT(name_, id_, type_, struct_) \
WINDOW_EVENT_HELPER(name_, BeforeUnloadEventHandlerNonNull)
#include "nsEventNameList.h"
#undef BEFOREUNLOAD_EVENT
#undef WINDOW_EVENT
#undef WINDOW_EVENT_HELPER
#undef FORWARDED_EVENT
#undef EVENT
void GetText(nsString& aText)
{
GetHTMLAttr(nsGkAtoms::text, aText);
}
void SetText(const nsAString& aText, ErrorResult& aError)
{
SetHTMLAttr(nsGkAtoms::text, aText, aError);
}
void GetLink(nsString& aLink)
{
GetHTMLAttr(nsGkAtoms::link, aLink);
}
void SetLink(const nsAString& aLink, ErrorResult& aError)
{
SetHTMLAttr(nsGkAtoms::link, aLink, aError);
}
void GetVLink(nsString& aVLink)
{
GetHTMLAttr(nsGkAtoms::vlink, aVLink);
}
void SetVLink(const nsAString& aVLink, ErrorResult& aError)
{
SetHTMLAttr(nsGkAtoms::vlink, aVLink, aError);
}
void GetALink(nsString& aALink)
{
GetHTMLAttr(nsGkAtoms::alink, aALink);
}
void SetALink(const nsAString& aALink, ErrorResult& aError)
{
SetHTMLAttr(nsGkAtoms::alink, aALink, aError);
}
void GetBgColor(nsString& aBgColor)
{
GetHTMLAttr(nsGkAtoms::bgcolor, aBgColor);
}
void SetBgColor(const nsAString& aBgColor, ErrorResult& aError)
{
SetHTMLAttr(nsGkAtoms::bgcolor, aBgColor, aError);
}
void GetBackground(nsString& aBackground)
{
GetHTMLAttr(nsGkAtoms::background, aBackground);
}
void SetBackground(const nsAString& aBackground, ErrorResult& aError)
{
SetHTMLAttr(nsGkAtoms::background, aBackground, aError);
}
virtual bool ParseAttribute(int32_t aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
@ -88,7 +147,10 @@ private:
nsresult GetColorHelper(nsIAtom* aAtom, nsAString& aColor);
protected:
BodyRule* mContentStyleRule;
virtual JSObject* WrapNode(JSContext *aCx, JSObject *aScope,
bool *aTriedToWrap) MOZ_OVERRIDE;
nsRefPtr<BodyRule> mContentStyleRule;
};
} // namespace dom

Просмотреть файл

@ -4,6 +4,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "HTMLDataListElement.h"
#include "mozilla/dom/HTMLDataListElementBinding.h"
NS_IMPL_NS_NEW_HTML_ELEMENT(DataList)
DOMCI_NODE_DATA(HTMLDataListElement, mozilla::dom::HTMLDataListElement)
@ -15,6 +16,12 @@ HTMLDataListElement::~HTMLDataListElement()
{
}
JSObject*
HTMLDataListElement::WrapNode(JSContext *aCx, JSObject *aScope,
bool *aTriedToWrap)
{
return HTMLDataListElementBinding::Wrap(aCx, aScope, this, aTriedToWrap);
}
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(HTMLDataListElement,
nsGenericHTMLElement)
@ -51,11 +58,7 @@ HTMLDataListElement::MatchOptions(nsIContent* aContent, int32_t aNamespaceID,
NS_IMETHODIMP
HTMLDataListElement::GetOptions(nsIDOMHTMLCollection** aOptions)
{
if (!mOptions) {
mOptions = new nsContentList(this, MatchOptions, nullptr, nullptr, true);
}
NS_ADDREF(*aOptions = mOptions);
NS_ADDREF(*aOptions = Options());
return NS_OK;
}

Просмотреть файл

@ -19,6 +19,7 @@ public:
HTMLDataListElement(already_AddRefed<nsINodeInfo> aNodeInfo)
: nsGenericHTMLElement(aNodeInfo)
{
SetIsDOMBinding();
}
virtual ~HTMLDataListElement();
@ -37,6 +38,16 @@ public:
// nsIDOMHTMLDataListElement
NS_DECL_NSIDOMHTMLDATALISTELEMENT
nsContentList* Options()
{
if (!mOptions) {
mOptions = new nsContentList(this, MatchOptions, nullptr, nullptr, true);
}
return mOptions;
}
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
// This function is used to generate the nsContentList (option elements).
@ -49,6 +60,8 @@ public:
virtual nsXPCClassInfo* GetClassInfo();
virtual nsIDOMNode* AsDOMNode() { return this; }
protected:
virtual JSObject* WrapNode(JSContext *aCx, JSObject *aScope,
bool *aTriedToWrap) MOZ_OVERRIDE;
// <option>'s list inside the datalist element.
nsRefPtr<nsContentList> mOptions;

Просмотреть файл

@ -6,6 +6,7 @@
#include "mozilla/Util.h"
#include "HTMLFontElement.h"
#include "mozilla/dom/HTMLFontElementBinding.h"
#include "nsAttrValueInlines.h"
#include "nsMappedAttributes.h"
#include "nsRuleData.h"
@ -20,6 +21,12 @@ HTMLFontElement::~HTMLFontElement()
{
}
JSObject*
HTMLFontElement::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap)
{
return HTMLFontElementBinding::Wrap(aCx, aScope, this, aTriedToWrap);
}
NS_IMPL_ADDREF_INHERITED(HTMLFontElement, Element)
NS_IMPL_RELEASE_INHERITED(HTMLFontElement, Element)
@ -33,11 +40,56 @@ NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLFontElement)
NS_IMPL_ELEMENT_CLONE(HTMLFontElement)
NS_IMETHODIMP
HTMLFontElement::GetColor(nsAString& aColor)
{
nsString color;
GetColor(color);
aColor = color;
return NS_OK;
}
NS_IMPL_STRING_ATTR(HTMLFontElement, Color, color)
NS_IMPL_STRING_ATTR(HTMLFontElement, Face, face)
NS_IMPL_STRING_ATTR(HTMLFontElement, Size, size)
NS_IMETHODIMP
HTMLFontElement::SetColor(const nsAString& aColor)
{
ErrorResult rv;
SetColor(aColor, rv);
return rv.ErrorCode();
}
NS_IMETHODIMP
HTMLFontElement::GetFace(nsAString& aFace)
{
nsString face;
GetFace(face);
aFace = face;
return NS_OK;
}
NS_IMETHODIMP
HTMLFontElement::SetFace(const nsAString& aFace)
{
ErrorResult rv;
SetFace(aFace, rv);
return rv.ErrorCode();
}
NS_IMETHODIMP
HTMLFontElement::GetSize(nsAString& aSize)
{
nsString size;
GetSize(size);
aSize = size;
return NS_OK;
}
NS_IMETHODIMP
HTMLFontElement::SetSize(const nsAString& aSize)
{
ErrorResult rv;
SetSize(aSize, rv);
return rv.ErrorCode();
}
bool
HTMLFontElement::ParseAttribute(int32_t aNamespaceID,

Просмотреть файл

@ -18,6 +18,7 @@ public:
HTMLFontElement(already_AddRefed<nsINodeInfo> aNodeInfo)
: nsGenericHTMLElement(aNodeInfo)
{
SetIsDOMBinding();
}
virtual ~HTMLFontElement();
@ -36,6 +37,31 @@ public:
// nsIDOMHTMLFontElement
NS_DECL_NSIDOMHTMLFONTELEMENT
void GetColor(nsString& aColor)
{
GetHTMLAttr(nsGkAtoms::color, aColor);
}
void SetColor(const nsAString& aColor, ErrorResult& aError)
{
SetHTMLAttr(nsGkAtoms::color, aColor, aError);
}
void GetFace(nsString& aFace)
{
GetHTMLAttr(nsGkAtoms::face, aFace);
}
void SetFace(const nsAString& aFace, ErrorResult& aError)
{
SetHTMLAttr(nsGkAtoms::face, aFace, aError);
}
void GetSize(nsString& aSize)
{
GetHTMLAttr(nsGkAtoms::size, aSize);
}
void SetSize(const nsAString& aSize, ErrorResult& aError)
{
SetHTMLAttr(nsGkAtoms::size, aSize, aError);
}
virtual bool ParseAttribute(int32_t aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
@ -45,6 +71,10 @@ public:
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
virtual nsXPCClassInfo* GetClassInfo();
virtual nsIDOMNode* AsDOMNode() { return this; }
protected:
virtual JSObject* WrapNode(JSContext *aCx, JSObject *aScope,
bool *aTriedToWrap) MOZ_OVERRIDE;
};
} // namespace dom

Просмотреть файл

@ -4,7 +4,9 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "HTMLFrameSetElement.h"
#include "mozilla/dom/HTMLFrameSetElementBinding.h"
#include "mozilla/dom/EventHandlerBinding.h"
#include "nsGlobalWindow.h"
NS_IMPL_NS_NEW_HTML_ELEMENT(FrameSet)
DOMCI_NODE_DATA(HTMLFrameSetElement, mozilla::dom::HTMLFrameSetElement)
@ -16,6 +18,12 @@ HTMLFrameSetElement::~HTMLFrameSetElement()
{
}
JSObject*
HTMLFrameSetElement::WrapNode(JSContext *aCx, JSObject *aScope,
bool *aTriedToWrap)
{
return HTMLFrameSetElementBinding::Wrap(aCx, aScope, this, aTriedToWrap);
}
NS_IMPL_ADDREF_INHERITED(HTMLFrameSetElement, Element)
NS_IMPL_RELEASE_INHERITED(HTMLFrameSetElement, Element)
@ -31,9 +39,39 @@ NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLFrameSetElement)
NS_IMPL_ELEMENT_CLONE(HTMLFrameSetElement)
NS_IMETHODIMP
HTMLFrameSetElement::SetCols(const nsAString& aCols)
{
ErrorResult rv;
SetCols(aCols, rv);
return rv.ErrorCode();
}
NS_IMPL_STRING_ATTR(HTMLFrameSetElement, Cols, cols)
NS_IMPL_STRING_ATTR(HTMLFrameSetElement, Rows, rows)
NS_IMETHODIMP
HTMLFrameSetElement::GetCols(nsAString& aCols)
{
nsString cols;
GetCols(cols);
aCols = cols;
return NS_OK;
}
NS_IMETHODIMP
HTMLFrameSetElement::SetRows(const nsAString& aRows)
{
ErrorResult rv;
SetRows(aRows, rv);
return rv.ErrorCode();
}
NS_IMETHODIMP
HTMLFrameSetElement::GetRows(nsAString& aRows)
{
nsString rows;
GetRows(rows);
aRows = rows;
return NS_OK;
}
nsresult
HTMLFrameSetElement::SetAttr(int32_t aNameSpaceID,
@ -315,11 +353,11 @@ HTMLFrameSetElement::ParseRowCol(const nsAString & aValue,
// nsGenericHTMLElement::GetOnError returns
// already_AddRefed<EventHandlerNonNull> while other getters return
// EventHandlerNonNull*, so allow passing in the type to use here.
#define FORWARDED_EVENT_HELPER(name_, getter_type_) \
#define FORWARDED_EVENT_HELPER(name_, forwardto_, type_, getter_type_) \
NS_IMETHODIMP \
HTMLFrameSetElement::GetOn##name_(JSContext *cx, jsval *vp) \
{ \
getter_type_ h = nsGenericHTMLElement::GetOn##name_(); \
getter_type_ h = forwardto_::GetOn##name_(); \
vp->setObjectOrNull(h ? h->Callable() : nullptr); \
return NS_OK; \
} \
@ -331,47 +369,59 @@ HTMLFrameSetElement::ParseRowCol(const nsAString & aValue,
/* Just silently do nothing */ \
return NS_OK; \
} \
nsRefPtr<EventHandlerNonNull> handler; \
nsRefPtr<type_> handler; \
JSObject *callable; \
if (v.isObject() && \
JS_ObjectIsCallable(cx, callable = &v.toObject())) { \
bool ok; \
handler = new EventHandlerNonNull(cx, obj, callable, &ok); \
handler = new type_(cx, obj, callable, &ok); \
if (!ok) { \
return NS_ERROR_OUT_OF_MEMORY; \
} \
} \
ErrorResult rv; \
nsGenericHTMLElement::SetOn##name_(handler, rv); \
forwardto_::SetOn##name_(handler, rv); \
return rv.ErrorCode(); \
}
#define FORWARDED_EVENT(name_, id_, type_, struct_) \
FORWARDED_EVENT_HELPER(name_, EventHandlerNonNull*)
FORWARDED_EVENT_HELPER(name_, nsGenericHTMLElement, EventHandlerNonNull, \
EventHandlerNonNull*)
#define ERROR_EVENT(name_, id_, type_, struct_) \
FORWARDED_EVENT_HELPER(name_, nsCOMPtr<EventHandlerNonNull>)
#define WINDOW_EVENT(name_, id_, type_, struct_) \
NS_IMETHODIMP \
HTMLFrameSetElement::GetOn##name_(JSContext *cx, jsval *vp) \
FORWARDED_EVENT_HELPER(name_, nsGenericHTMLElement, \
EventHandlerNonNull, nsCOMPtr<EventHandlerNonNull>)
#define WINDOW_EVENT_HELPER(name_, type_) \
type_* \
HTMLFrameSetElement::GetOn##name_() \
{ \
/* XXXbz note to self: add tests for this! */ \
nsPIDOMWindow* win = OwnerDoc()->GetInnerWindow(); \
if (win && win->IsInnerWindow()) { \
return win->GetOn##name_(cx, vp); \
nsCOMPtr<nsISupports> supports = do_QueryInterface(win); \
nsGlobalWindow* globalWin = nsGlobalWindow::FromSupports(supports); \
return globalWin->GetOn##name_(); \
} \
*vp = JSVAL_NULL; \
return NS_OK; \
return nullptr; \
} \
NS_IMETHODIMP \
HTMLFrameSetElement::SetOn##name_(JSContext *cx, const jsval &v) \
void \
HTMLFrameSetElement::SetOn##name_(type_* handler, ErrorResult& error) \
{ \
nsPIDOMWindow* win = OwnerDoc()->GetInnerWindow(); \
if (win && win->IsInnerWindow()) { \
return win->SetOn##name_(cx, v); \
if (!win || !win->IsInnerWindow()) { \
return; \
} \
return NS_OK; \
}
\
nsCOMPtr<nsISupports> supports = do_QueryInterface(win); \
nsGlobalWindow* globalWin = nsGlobalWindow::FromSupports(supports); \
return globalWin->SetOn##name_(handler, error); \
} \
FORWARDED_EVENT_HELPER(name_, HTMLFrameSetElement, type_, type_*)
#define WINDOW_EVENT(name_, id_, type_, struct_) \
WINDOW_EVENT_HELPER(name_, EventHandlerNonNull)
#define BEFOREUNLOAD_EVENT(name_, id_, type_, struct_) \
WINDOW_EVENT_HELPER(name_, BeforeUnloadEventHandlerNonNull)
#include "nsEventNameList.h"
#undef BEFOREUNLOAD_EVENT
#undef WINDOW_EVENT
#undef WINDOW_EVENT_HELPER
#undef ERROR_EVENT
#undef FORWARDED_EVENT
#undef FORWARDED_EVENT_HELPER

Просмотреть файл

@ -39,6 +39,8 @@ struct nsFramesetSpec {
namespace mozilla {
namespace dom {
class BeforeUnloadEventHandlerNonNull;
class HTMLFrameSetElement : public nsGenericHTMLElement,
public nsIDOMHTMLFrameSetElement
{
@ -49,6 +51,7 @@ public:
mNumCols(0),
mCurrentRowColHint(NS_STYLE_HINT_REFLOW)
{
SetIsDOMBinding();
}
virtual ~HTMLFrameSetElement();
@ -69,13 +72,40 @@ public:
// nsIDOMHTMLFrameSetElement
NS_DECL_NSIDOMHTMLFRAMESETELEMENT
void GetCols(nsString& aCols)
{
GetHTMLAttr(nsGkAtoms::cols, aCols);
}
void SetCols(const nsAString& aCols, ErrorResult& aError)
{
SetHTMLAttr(nsGkAtoms::cols, aCols, aError);
}
void GetRows(nsString& aRows)
{
GetHTMLAttr(nsGkAtoms::rows, aRows);
}
void SetRows(const nsAString& aRows, ErrorResult& aError)
{
SetHTMLAttr(nsGkAtoms::rows, aRows, aError);
}
// Event listener stuff; we need to declare only the ones we need to
// forward to window that don't come from nsIDOMHTMLFrameSetElement.
#define EVENT(name_, id_, type_, struct_) /* nothing; handled by the superclass */
#define FORWARDED_EVENT(name_, id_, type_, struct_) \
NS_IMETHOD GetOn##name_(JSContext *cx, jsval *vp); \
NS_IMETHOD SetOn##name_(JSContext *cx, const jsval &v);
#define WINDOW_EVENT_HELPER(name_, type_) \
type_* GetOn##name_(); \
void SetOn##name_(type_* handler, ErrorResult& error);
#define WINDOW_EVENT(name_, id_, type_, struct_) \
WINDOW_EVENT_HELPER(name_, EventHandlerNonNull)
#define BEFOREUNLOAD_EVENT(name_, id_, type_, struct_) \
WINDOW_EVENT_HELPER(name_, BeforeUnloadEventHandlerNonNull)
#include "nsEventNameList.h"
#undef BEFOREUNLOAD_EVENT
#undef WINDOW_EVENT
#undef WINDOW_EVENT_HELPER
#undef FORWARDED_EVENT
#undef EVENT
@ -119,6 +149,10 @@ public:
virtual nsXPCClassInfo* GetClassInfo();
virtual nsIDOMNode* AsDOMNode() { return this; }
protected:
virtual JSObject* WrapNode(JSContext *aCx, JSObject *aScope,
bool *aTriedToWrap) MOZ_OVERRIDE;
private:
nsresult ParseRowCol(const nsAString& aValue,
int32_t& aNumSpecs,

Просмотреть файл

@ -7,6 +7,7 @@
* Implementation of HTML <label> elements.
*/
#include "HTMLLabelElement.h"
#include "mozilla/dom/HTMLLabelElementBinding.h"
#include "nsEventDispatcher.h"
#include "nsFocusManager.h"
@ -22,6 +23,12 @@ HTMLLabelElement::~HTMLLabelElement()
{
}
JSObject*
HTMLLabelElement::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap)
{
return HTMLLabelElementBinding::Wrap(aCx, aScope, this, aTriedToWrap);
}
// nsISupports
@ -55,8 +62,22 @@ HTMLLabelElement::GetControl(nsIDOMHTMLElement** aElement)
return NS_OK;
}
NS_IMETHODIMP
HTMLLabelElement::SetHtmlFor(const nsAString& aHtmlFor)
{
ErrorResult rv;
SetHtmlFor(aHtmlFor, rv);
return rv.ErrorCode();
}
NS_IMPL_STRING_ATTR(HTMLLabelElement, HtmlFor, _for)
NS_IMETHODIMP
HTMLLabelElement::GetHtmlFor(nsAString& aHtmlFor)
{
nsString htmlFor;
GetHtmlFor(htmlFor);
aHtmlFor = htmlFor;
return NS_OK;
}
void
HTMLLabelElement::Focus(ErrorResult& aError)
@ -236,8 +257,8 @@ HTMLLabelElement::PerformAccesskey(bool aKeyCausesActivation,
}
}
Element*
HTMLLabelElement::GetLabeledElement()
nsGenericHTMLElement*
HTMLLabelElement::GetLabeledElement() const
{
nsAutoString elementId;
@ -256,20 +277,20 @@ HTMLLabelElement::GetLabeledElement()
Element* element = doc->GetElementById(elementId);
if (element && element->IsLabelable()) {
return element;
return static_cast<nsGenericHTMLElement*>(element);
}
return nullptr;
}
Element*
HTMLLabelElement::GetFirstLabelableDescendant()
nsGenericHTMLElement*
HTMLLabelElement::GetFirstLabelableDescendant() const
{
for (nsIContent* cur = nsINode::GetFirstChild(); cur;
cur = cur->GetNextNode(this)) {
Element* element = cur->IsElement() ? cur->AsElement() : nullptr;
if (element && element->IsLabelable()) {
return element;
return static_cast<nsGenericHTMLElement*>(element);
}
}

Просмотреть файл

@ -23,6 +23,7 @@ public:
: nsGenericHTMLFormElement(aNodeInfo),
mHandlingEvent(false)
{
SetIsDOMBinding();
}
virtual ~HTMLLabelElement();
@ -43,6 +44,20 @@ public:
// nsIDOMHTMLElement
NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC
using nsGenericHTMLFormElement::GetForm;
void GetHtmlFor(nsString& aHtmlFor)
{
GetHTMLAttr(nsGkAtoms::_for, aHtmlFor);
}
void SetHtmlFor(const nsAString& aHtmlFor, ErrorResult& aError)
{
SetHTMLAttr(nsGkAtoms::_for, aHtmlFor, aError);
}
nsGenericHTMLElement* GetControl() const
{
return GetLabeledElement();
}
virtual void Focus(mozilla::ErrorResult& aError) MOZ_OVERRIDE;
// nsIFormControl
@ -62,9 +77,12 @@ public:
virtual nsIDOMNode* AsDOMNode() { return this; }
mozilla::dom::Element* GetLabeledElement();
nsGenericHTMLElement* GetLabeledElement() const;
protected:
mozilla::dom::Element* GetFirstLabelableDescendant();
virtual JSObject* WrapNode(JSContext *aCx, JSObject *aScope,
bool *aTriedToWrap) MOZ_OVERRIDE;
nsGenericHTMLElement* GetFirstLabelableDescendant() const;
// XXX It would be nice if we could use an event flag instead.
bool mHandlingEvent;

Просмотреть файл

@ -1084,6 +1084,10 @@ public:
// nsIFormControl
virtual mozilla::dom::Element* GetFormElement();
nsHTMLFormElement* GetForm() const
{
return mForm;
}
virtual void SetForm(nsIDOMHTMLFormElement* aForm);
virtual void ClearForm(bool aRemoveFromForm);

Просмотреть файл

@ -21,7 +21,7 @@ function a(s) {
var r;
try { r = frames[0].document.body; }
catch (e) { r = e; }
is(r instanceof HTMLBodyElement, true,
is(r instanceof frames[0].HTMLBodyElement, true,
"Can't get body" + s);
}
var p = 0;

Просмотреть файл

@ -284,6 +284,12 @@ DOMInterfaces = {
'resultNotAddRefed': [ 'item' ]
},
'HTMLDataListElement': {
'resultNotAddRefed': [
'options'
]
},
'HTMLElement': {
'nativeType': 'nsGenericHTMLElement',
'hasXPConnectImpls': True,
@ -294,6 +300,12 @@ DOMInterfaces = {
]
},
'HTMLLabelElement': {
'resultNotAddRefed': [
'form', 'control'
]
},
'HTMLOptionsCollection': {
'nativeType': 'nsHTMLOptionCollection',
'headerFile': 'nsHTMLSelectElement.h',

Просмотреть файл

@ -41,7 +41,7 @@ function runTest() {
t.step(fails ? function() {
assert_equals(ifr.document.body, null, ifr.name + " should NOT load.");
} : function() {
assert_true(ifr.document.body instanceof HTMLBodyElement, ifr.name + " should load.");
assert_true(ifr.document.body instanceof ifr.HTMLBodyElement, ifr.name + " should load.");
});
t.done();
};

Просмотреть файл

@ -0,0 +1,62 @@
/* -*- 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/
*
* © 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.
*/
interface HTMLBodyElement : HTMLElement {
[SetterThrows]
attribute EventHandler onafterprint;
[SetterThrows]
attribute EventHandler onbeforeprint;
[SetterThrows]
attribute BeforeUnloadEventHandler onbeforeunload;
//[SetterThrows]
//attribute EventHandler onblur;
//[SetterThrows]
//attribute OnErrorEventHandler onerror;
//[SetterThrows]
//attribute EventHandler onfocus;
[SetterThrows]
attribute EventHandler onhashchange;
//[SetterThrows]
//attribute EventHandler onload;
[SetterThrows]
attribute EventHandler onmessage;
[SetterThrows]
attribute EventHandler onoffline;
[SetterThrows]
attribute EventHandler ononline;
[SetterThrows]
attribute EventHandler onpopstate;
[SetterThrows]
attribute EventHandler onpagehide;
[SetterThrows]
attribute EventHandler onpageshow;
[SetterThrows]
attribute EventHandler onresize;
//[SetterThrows]
//attribute EventHandler onscroll;
//[SetterThrows]
//attribute EventHandler onstorage;
[SetterThrows]
attribute EventHandler onunload;
/*
};
partial interface HTMLBodyElement {
*/
[TreatNullAs=EmptyString, SetterThrows] attribute DOMString text;
[TreatNullAs=EmptyString, SetterThrows] attribute DOMString link;
[TreatNullAs=EmptyString, SetterThrows] attribute DOMString vLink;
[TreatNullAs=EmptyString, SetterThrows] attribute DOMString aLink;
[TreatNullAs=EmptyString, SetterThrows] attribute DOMString bgColor;
[SetterThrows] attribute DOMString background;
};

Просмотреть файл

@ -0,0 +1,16 @@
/* -*- 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/
*
* © 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.
*/
interface HTMLDataListElement : HTMLElement {
readonly attribute HTMLCollection options;
};

Просмотреть файл

@ -0,0 +1,18 @@
/* -*- 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/
*
* © 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.
*/
interface HTMLFontElement : HTMLElement {
[TreatNullAs=EmptyString, SetterThrows] attribute DOMString color;
[SetterThrows] attribute DOMString face;
[SetterThrows] attribute DOMString size;
};

Просмотреть файл

@ -0,0 +1,54 @@
/* -*- 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/
*
* © 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.
*/
interface HTMLFrameSetElement : HTMLElement {
[SetterThrows]
attribute DOMString cols;
[SetterThrows]
attribute DOMString rows;
[SetterThrows]
attribute EventHandler onafterprint;
[SetterThrows]
attribute EventHandler onbeforeprint;
[SetterThrows]
attribute BeforeUnloadEventHandler onbeforeunload;
//[SetterThrows]
//attribute EventHandler onblur;
//[SetterThrows]
//attribute EventHandler onerror;
//[SetterThrows]
//attribute EventHandler onfocus;
[SetterThrows]
attribute EventHandler onhashchange;
//attribute EventHandler onload;
[SetterThrows]
attribute EventHandler onmessage;
[SetterThrows]
attribute EventHandler onoffline;
[SetterThrows]
attribute EventHandler ononline;
[SetterThrows]
attribute EventHandler onpagehide;
[SetterThrows]
attribute EventHandler onpageshow;
[SetterThrows]
attribute EventHandler onpopstate;
[SetterThrows]
attribute EventHandler onresize;
//[SetterThrows]
//attribute EventHandler onscroll;
//[SetterThrows]
//attribute EventHandler onstorage;
[SetterThrows]
attribute EventHandler onunload;
};

Просмотреть файл

@ -0,0 +1,18 @@
/* -*- 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/
*
* © 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.
*/
interface HTMLLabelElement : HTMLElement {
readonly attribute HTMLFormElement? form;
attribute DOMString htmlFor;
readonly attribute HTMLElement? control;
};

Просмотреть файл

@ -44,9 +44,14 @@ webidl_files = \
FormData.webidl \
Function.webidl \
GainNode.webidl \
HTMLBodyElement.webidl \
HTMLCollection.webidl \
HTMLDataListElement.webidl \
HTMLDivElement.webidl \
HTMLElement.webidl \
HTMLFontElement.webidl \
HTMLFrameSetElement.webidl \
HTMLLabelElement.webidl \
HTMLOptionsCollection.webidl \
HTMLPropertiesCollection.webidl \
ImageData.webidl \