2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* 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/. */
|
2013-02-15 08:55:53 -08:00
|
|
|
|
|
|
|
#include "mozilla/dom/HTMLLegendElement.h"
|
2013-02-15 08:55:53 -08:00
|
|
|
#include "mozilla/dom/HTMLLegendElementBinding.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIDOMHTMLFormElement.h"
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 11:00:39 -07:00
|
|
|
#include "nsFocusManager.h"
|
|
|
|
#include "nsIFrame.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
NS_IMPL_NS_NEW_HTML_ELEMENT(Legend)
|
2013-02-15 08:55:53 -08:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
|
2013-02-15 08:55:53 -08:00
|
|
|
HTMLLegendElement::~HTMLLegendElement()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-02-15 08:55:53 -08:00
|
|
|
NS_IMPL_ELEMENT_CLONE(HTMLLegendElement)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-05-12 12:01:25 -07:00
|
|
|
nsIContent*
|
2013-02-15 08:55:53 -08:00
|
|
|
HTMLLegendElement::GetFieldSet()
|
2010-05-12 12:01:25 -07:00
|
|
|
{
|
|
|
|
nsIContent* parent = GetParent();
|
|
|
|
|
2011-11-15 23:50:19 -08:00
|
|
|
if (parent && parent->IsHTML(nsGkAtoms::fieldset)) {
|
2010-05-12 12:01:25 -07:00
|
|
|
return parent;
|
|
|
|
}
|
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2010-05-12 12:01:25 -07:00
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2013-02-15 08:55:53 -08:00
|
|
|
HTMLLegendElement::ParseAttribute(int32_t aNamespaceID,
|
|
|
|
nsIAtom* aAttribute,
|
|
|
|
const nsAString& aValue,
|
|
|
|
nsAttrValue& aResult)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2013-11-19 11:21:29 -08:00
|
|
|
// this contains center, because IE4 does
|
|
|
|
static const nsAttrValue::EnumTable kAlignTable[] = {
|
|
|
|
{ "left", NS_STYLE_TEXT_ALIGN_LEFT },
|
|
|
|
{ "right", NS_STYLE_TEXT_ALIGN_RIGHT },
|
|
|
|
{ "center", NS_STYLE_TEXT_ALIGN_CENTER },
|
|
|
|
{ "bottom", NS_STYLE_VERTICAL_ALIGN_BOTTOM },
|
|
|
|
{ "top", NS_STYLE_VERTICAL_ALIGN_TOP },
|
|
|
|
{ 0 }
|
|
|
|
};
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
if (aAttribute == nsGkAtoms::align && aNamespaceID == kNameSpaceID_None) {
|
2011-10-17 07:59:28 -07:00
|
|
|
return aResult.ParseEnumValue(aValue, kAlignTable, false);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
|
|
|
|
aResult);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsChangeHint
|
2013-02-15 08:55:53 -08:00
|
|
|
HTMLLegendElement::GetAttributeChangeHint(const nsIAtom* aAttribute,
|
|
|
|
int32_t aModType) const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
nsChangeHint retval =
|
2010-05-19 13:33:00 -07:00
|
|
|
nsGenericHTMLElement::GetAttributeChangeHint(aAttribute, aModType);
|
2007-03-22 10:30:00 -07:00
|
|
|
if (aAttribute == nsGkAtoms::align) {
|
|
|
|
NS_UpdateHint(retval, NS_STYLE_HINT_REFLOW);
|
|
|
|
}
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2011-10-17 11:52:12 -07:00
|
|
|
nsresult
|
2013-02-15 08:55:53 -08:00
|
|
|
HTMLLegendElement::SetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute,
|
|
|
|
nsIAtom* aPrefix, const nsAString& aValue,
|
|
|
|
bool aNotify)
|
2011-10-17 11:52:12 -07:00
|
|
|
{
|
|
|
|
return nsGenericHTMLElement::SetAttr(aNameSpaceID, aAttribute,
|
|
|
|
aPrefix, aValue, aNotify);
|
|
|
|
}
|
|
|
|
nsresult
|
2013-02-15 08:55:53 -08:00
|
|
|
HTMLLegendElement::UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute,
|
|
|
|
bool aNotify)
|
2011-10-17 11:52:12 -07:00
|
|
|
{
|
|
|
|
return nsGenericHTMLElement::UnsetAttr(aNameSpaceID, aAttribute, aNotify);
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
nsresult
|
2013-02-15 08:55:53 -08:00
|
|
|
HTMLLegendElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
|
|
|
nsIContent* aBindingParent,
|
|
|
|
bool aCompileEventHandlers)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2011-04-11 09:56:37 -07:00
|
|
|
return nsGenericHTMLElement::BindToTree(aDocument, aParent,
|
|
|
|
aBindingParent,
|
|
|
|
aCompileEventHandlers);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-02-15 08:55:53 -08:00
|
|
|
HTMLLegendElement::UnbindFromTree(bool aDeep, bool aNullParent)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2010-05-19 13:33:00 -07:00
|
|
|
nsGenericHTMLElement::UnbindFromTree(aDeep, aNullParent);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-10-06 00:19:52 -07:00
|
|
|
void
|
2013-02-15 08:55:53 -08:00
|
|
|
HTMLLegendElement::Focus(ErrorResult& aError)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 11:00:39 -07:00
|
|
|
nsIFrame* frame = GetPrimaryFrame();
|
2012-10-06 00:19:52 -07:00
|
|
|
if (!frame) {
|
|
|
|
return;
|
|
|
|
}
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 11:00:39 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t tabIndex;
|
2012-10-06 00:19:52 -07:00
|
|
|
if (frame->IsFocusable(&tabIndex, false)) {
|
|
|
|
nsGenericHTMLElement::Focus(aError);
|
|
|
|
return;
|
|
|
|
}
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 11:00:39 -07:00
|
|
|
|
|
|
|
// If the legend isn't focusable, focus whatever is focusable following
|
|
|
|
// the legend instead, bug 81481.
|
|
|
|
nsIFocusManager* fm = nsFocusManager::GetFocusManager();
|
2012-10-06 00:19:52 -07:00
|
|
|
if (!fm) {
|
|
|
|
return;
|
|
|
|
}
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 11:00:39 -07:00
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMElement> result;
|
2012-10-06 00:19:52 -07:00
|
|
|
aError = fm->MoveFocus(nullptr, this, nsIFocusManager::MOVEFOCUS_FORWARD,
|
|
|
|
nsIFocusManager::FLAG_NOPARENTFRAME,
|
|
|
|
getter_AddRefs(result));
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 11:00:39 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 11:00:39 -07:00
|
|
|
void
|
2013-02-15 08:55:53 -08:00
|
|
|
HTMLLegendElement::PerformAccesskey(bool aKeyCausesActivation,
|
|
|
|
bool aIsTrustedEvent)
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 11:00:39 -07:00
|
|
|
{
|
|
|
|
// just use the same behaviour as the focus method
|
2013-02-15 08:55:53 -08:00
|
|
|
ErrorResult rv;
|
2012-10-06 00:19:52 -07:00
|
|
|
Focus(rv);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-06-19 07:24:37 -07:00
|
|
|
already_AddRefed<HTMLFormElement>
|
2013-02-15 08:55:53 -08:00
|
|
|
HTMLLegendElement::GetForm()
|
|
|
|
{
|
|
|
|
Element* form = GetFormElement();
|
|
|
|
MOZ_ASSERT_IF(form, form->IsHTML(nsGkAtoms::form));
|
2013-06-19 07:24:37 -07:00
|
|
|
nsRefPtr<HTMLFormElement> ret = static_cast<HTMLFormElement*>(form);
|
2013-02-15 08:55:53 -08:00
|
|
|
return ret.forget();
|
|
|
|
}
|
|
|
|
|
|
|
|
JSObject*
|
2014-04-08 15:27:17 -07:00
|
|
|
HTMLLegendElement::WrapNode(JSContext* aCx)
|
2013-02-15 08:55:53 -08:00
|
|
|
{
|
Bug 991742 part 6. Remove the "aScope" argument of binding Wrap() methods. r=bholley
This patch was mostly generated with this command:
find . -name "*.h" -o -name "*.cpp" | xargs sed -e 's/Binding::Wrap(aCx, aScope, this/Binding::Wrap(aCx, this/' -e 's/Binding_workers::Wrap(aCx, aScope, this/Binding_workers::Wrap(aCx, this/' -e 's/Binding::Wrap(cx, scope, this/Binding::Wrap(cx, this/' -i ""
plus a few manual fixes to dom/bindings/Codegen.py, js/xpconnect/src/event_impl_gen.py, and a few C++ files that were not caught in the search-and-replace above.
2014-04-08 15:27:17 -07:00
|
|
|
return HTMLLegendElementBinding::Wrap(aCx, this);
|
2013-02-15 08:55:53 -08:00
|
|
|
}
|
|
|
|
|
2013-02-15 08:55:53 -08:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|