Bug 838532 - Convert HTMLLegendElement to WebIDL. r=Ms2ger

This commit is contained in:
Andrea Marchesini 2013-02-15 11:55:53 -05:00
parent 76260f9192
commit c6c00b063d
4 changed files with 64 additions and 0 deletions

View File

@ -4,6 +4,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/dom/HTMLLegendElement.h"
#include "mozilla/dom/HTMLLegendElementBinding.h"
#include "nsIDOMHTMLFormElement.h"
#include "nsFocusManager.h"
#include "nsIFrame.h"
@ -170,5 +171,21 @@ HTMLLegendElement::PerformAccesskey(bool aKeyCausesActivation,
Focus(rv);
}
already_AddRefed<nsHTMLFormElement>
HTMLLegendElement::GetForm()
{
Element* form = GetFormElement();
MOZ_ASSERT_IF(form, form->IsHTML(nsGkAtoms::form));
nsRefPtr<nsHTMLFormElement> ret = static_cast<nsHTMLFormElement*>(form);
return ret.forget();
}
JSObject*
HTMLLegendElement::WrapNode(JSContext* aCx, JSObject* aScope,
bool* aTriedToWrap)
{
return HTMLLegendElementBinding::Wrap(aCx, aScope, this, aTriedToWrap);
}
} // namespace dom
} // namespace mozilla

View File

@ -8,6 +8,7 @@
#include "nsIDOMHTMLLegendElement.h"
#include "nsGenericHTMLElement.h"
#include "nsHTMLFormElement.h"
namespace mozilla {
namespace dom {
@ -76,7 +77,29 @@ public:
virtual nsXPCClassInfo* GetClassInfo();
virtual nsIDOMNode* AsDOMNode() { return this; }
/**
* WebIDL Interface
*/
already_AddRefed<nsHTMLFormElement> GetForm();
// The XPCOM GetAlign is OK for us
void SetAlign(const nsAString& aAlign, ErrorResult& aError)
{
SetHTMLAttr(nsGkAtoms::align, aAlign, aError);
}
nsINode* GetParentObject() {
Element* form = GetFormElement();
return form ? static_cast<nsINode*>(form)
: nsGenericHTMLElement::GetParentObject();
}
protected:
virtual JSObject* WrapNode(JSContext* aCx, JSObject* aScope,
bool* aTriedToWrap) MOZ_OVERRIDE;
/**
* Get the fieldset content element that contains this legend.
* Returns null if there is no fieldset containing this legend.

View File

@ -0,0 +1,23 @@
/* -*- 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-legend-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-legend-element
interface HTMLLegendElement : HTMLElement {
readonly attribute HTMLFormElement? form;
};
// http://www.whatwg.org/specs/web-apps/current-work/#other-elements,-attributes-and-apis
partial interface HTMLLegendElement {
attribute DOMString align;
};

View File

@ -78,6 +78,7 @@ webidl_files = \
HTMLHtmlElement.webidl \
HTMLImageElement.webidl \
HTMLLabelElement.webidl \
HTMLLegendElement.webidl \
HTMLLIElement.webidl \
HTMLLinkElement.webidl \
HTMLMapElement.webidl \