Bug 824823 part 4. WebIDL binding for HTML list elements. r=peterv

Note that I had to create the separate subclasses because we can't map
different WebIDL interfaces to the same concrete type: it causes the
PrototypeIDMap templates to completely fail to deal.
This commit is contained in:
Boris Zbarsky 2013-01-04 12:02:14 -05:00
Родитель c09af46f0f
Коммит 12ee90cc51
7 изменённых файлов: 175 добавлений и 0 удалений

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

@ -4,6 +4,9 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/dom/HTMLSharedListElement.h"
#include "mozilla/dom/HTMLDListElementBinding.h"
#include "mozilla/dom/HTMLOListElementBinding.h"
#include "mozilla/dom/HTMLUListElementBinding.h"
#include "nsIDOMEventTarget.h"
#include "nsGenericHTMLElement.h"
@ -166,5 +169,23 @@ HTMLSharedListElement::GetAttributeMappingFunction() const
return nsGenericHTMLElement::GetAttributeMappingFunction();
}
JSObject*
HTMLDListElement::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap)
{
return HTMLDListElementBinding::Wrap(aCx, aScope, this, aTriedToWrap);
}
JSObject*
HTMLOListElement::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap)
{
return HTMLOListElementBinding::Wrap(aCx, aScope, this, aTriedToWrap);
}
JSObject*
HTMLUListElement::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap)
{
return HTMLUListElementBinding::Wrap(aCx, aScope, this, aTriedToWrap);
}
} // namespace dom
} // namespace mozilla

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

@ -24,6 +24,7 @@ public:
HTMLSharedListElement(already_AddRefed<nsINodeInfo> aNodeInfo)
: nsGenericHTMLElement(aNodeInfo)
{
SetIsDOMBinding();
}
virtual ~HTMLSharedListElement();
@ -65,6 +66,60 @@ public:
{
return static_cast<nsIDOMHTMLOListElement*>(this);
}
bool Reversed() const
{
return GetBoolAttr(nsGkAtoms::reversed);
}
void SetReversed(bool aReversed, mozilla::ErrorResult& rv)
{
SetHTMLBoolAttr(nsGkAtoms::reversed, aReversed, rv);
}
int32_t Start() const
{
return GetIntAttr(nsGkAtoms::start, 1);
}
void SetStart(int32_t aStart, mozilla::ErrorResult& rv)
{
SetHTMLIntAttr(nsGkAtoms::start, aStart, rv);
}
void GetType(nsString& aType)
{
GetHTMLAttr(nsGkAtoms::type, aType);
}
void SetType(const nsAString& aType, mozilla::ErrorResult& rv)
{
SetHTMLAttr(nsGkAtoms::type, aType, rv);
}
bool Compact() const
{
return GetBoolAttr(nsGkAtoms::compact);
}
void SetCompact(bool aCompact, mozilla::ErrorResult& rv)
{
SetHTMLBoolAttr(nsGkAtoms::compact, aCompact, rv);
}
};
class HTMLDListElement MOZ_FINAL : public HTMLSharedListElement
{
protected:
virtual JSObject* WrapNode(JSContext *aCx, JSObject *aScope,
bool *aTriedToWrap) MOZ_OVERRIDE;
};
class HTMLOListElement MOZ_FINAL : public HTMLSharedListElement
{
protected:
virtual JSObject* WrapNode(JSContext *aCx, JSObject *aScope,
bool *aTriedToWrap) MOZ_OVERRIDE;
};
class HTMLUListElement MOZ_FINAL : public HTMLSharedListElement
{
protected:
virtual JSObject* WrapNode(JSContext *aCx, JSObject *aScope,
bool *aTriedToWrap) MOZ_OVERRIDE;
};
} // namespace dom

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

@ -323,6 +323,10 @@ DOMInterfaces = {
'hasInstanceInterface': 'nsIDOMHTMLDivElement',
},
'HTMLDListElement': {
'headerFile' : 'mozilla/dom/HTMLSharedListElement.h'
},
'HTMLDocument': {
'nativeType': 'nsHTMLDocument',
'register': False,
@ -362,6 +366,11 @@ DOMInterfaces = {
'hasInstanceInterface': 'nsIDOMHTMLLabelElement',
},
'HTMLOListElement': {
'headerFile' : 'mozilla/dom/HTMLSharedListElement.h',
'hasInstanceInterface': 'nsIDOMHTMLOListElement'
},
'HTMLOptionsCollection': {
'nativeType': 'nsHTMLOptionCollection',
'headerFile': 'nsHTMLSelectElement.h',
@ -376,6 +385,10 @@ DOMInterfaces = {
'resultNotAddRefed': [ 'item', 'namedItem', 'names' ]
},
'HTMLUListElement': {
'headerFile' : 'mozilla/dom/HTMLSharedListElement.h'
},
'IID': [
{
'nativeType': 'nsIJSID',

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

@ -0,0 +1,25 @@
/* -*- 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-dl-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-dl-element
interface HTMLDListElement : HTMLElement {
/*
};
// http://www.whatwg.org/specs/web-apps/current-work/#other-elements,-attributes-and-apis
partial interface HTMLDListElement {
*/
[SetterThrows]
attribute boolean compact;
};

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

@ -0,0 +1,31 @@
/* -*- 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-ol-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-ol-element
interface HTMLOListElement : HTMLElement {
[SetterThrows]
attribute boolean reversed;
[SetterThrows]
attribute long start;
[SetterThrows]
attribute DOMString type;
/*
};
// http://www.whatwg.org/specs/web-apps/current-work/#other-elements,-attributes-and-apis
partial interface HTMLOListElement {
*/
[SetterThrows]
attribute boolean compact;
};

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

@ -0,0 +1,27 @@
/* -*- 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-ul-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-ul-element
interface HTMLUListElement : HTMLElement {
/*
};
// http://www.whatwg.org/specs/web-apps/current-work/#other-elements,-attributes-and-apis
partial interface HTMLUListElement {
*/
[SetterThrows]
attribute boolean compact;
[SetterThrows]
attribute DOMString type;
};

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

@ -54,6 +54,7 @@ webidl_files = \
HTMLCollection.webidl \
HTMLDataListElement.webidl \
HTMLDivElement.webidl \
HTMLDListElement.webidl \
HTMLDocument.webidl \
HTMLElement.webidl \
HTMLFontElement.webidl \
@ -61,9 +62,11 @@ webidl_files = \
HTMLHeadingElement.webidl \
HTMLImageElement.webidl \
HTMLLabelElement.webidl \
HTMLOListElement.webidl \
HTMLOptionsCollection.webidl \
HTMLPropertiesCollection.webidl \
HTMLTitleElement.webidl \
HTMLUListElement.webidl \
ImageData.webidl \
Location.webidl \
MutationObserver.webidl \