2001-09-25 05:32:19 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04: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 20:55:53 +04:00
|
|
|
|
|
|
|
#include "mozilla/dom/HTMLLegendElement.h"
|
2013-02-15 20:55:53 +04:00
|
|
|
#include "mozilla/dom/HTMLLegendElementBinding.h"
|
1998-09-30 03:22:42 +04: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 22:00:39 +04:00
|
|
|
#include "nsFocusManager.h"
|
|
|
|
#include "nsIFrame.h"
|
1998-09-03 05:03:33 +04:00
|
|
|
|
2004-05-19 00:58:12 +04:00
|
|
|
NS_IMPL_NS_NEW_HTML_ELEMENT(Legend)
|
2013-02-15 20:55:53 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
1998-09-03 05:03:33 +04:00
|
|
|
|
1999-10-07 04:35:04 +04:00
|
|
|
|
2013-02-15 20:55:53 +04:00
|
|
|
HTMLLegendElement::~HTMLLegendElement()
|
1998-09-03 05:03:33 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-02-15 20:55:53 +04:00
|
|
|
NS_IMPL_ELEMENT_CLONE(HTMLLegendElement)
|
2000-06-23 18:12:24 +04:00
|
|
|
|
2010-05-12 23:01:25 +04:00
|
|
|
nsIContent*
|
2014-10-31 00:38:48 +03:00
|
|
|
HTMLLegendElement::GetFieldSet() const
|
2010-05-12 23:01:25 +04:00
|
|
|
{
|
|
|
|
nsIContent* parent = GetParent();
|
|
|
|
|
2011-11-16 11:50:19 +04:00
|
|
|
if (parent && parent->IsHTML(nsGkAtoms::fieldset)) {
|
2010-05-12 23:01:25 +04:00
|
|
|
return parent;
|
|
|
|
}
|
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2010-05-12 23:01:25 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2013-02-15 20:55:53 +04:00
|
|
|
HTMLLegendElement::ParseAttribute(int32_t aNamespaceID,
|
|
|
|
nsIAtom* aAttribute,
|
|
|
|
const nsAString& aValue,
|
|
|
|
nsAttrValue& aResult)
|
1998-09-03 05:03:33 +04:00
|
|
|
{
|
2013-11-19 23:21:29 +04: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 }
|
|
|
|
};
|
|
|
|
|
2006-12-26 20:47:52 +03:00
|
|
|
if (aAttribute == nsGkAtoms::align && aNamespaceID == kNameSpaceID_None) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return aResult.ParseEnumValue(aValue, kAlignTable, false);
|
1998-09-30 03:22:42 +04:00
|
|
|
}
|
2000-12-23 13:56:31 +03:00
|
|
|
|
2005-11-29 19:37:15 +03:00
|
|
|
return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
|
|
|
|
aResult);
|
1998-09-03 05:03:33 +04:00
|
|
|
}
|
|
|
|
|
2004-10-24 21:10:32 +04:00
|
|
|
nsChangeHint
|
2013-02-15 20:55:53 +04:00
|
|
|
HTMLLegendElement::GetAttributeChangeHint(const nsIAtom* aAttribute,
|
|
|
|
int32_t aModType) const
|
2004-01-06 03:01:54 +03:00
|
|
|
{
|
2004-10-24 21:10:32 +04:00
|
|
|
nsChangeHint retval =
|
2010-05-20 00:33:00 +04:00
|
|
|
nsGenericHTMLElement::GetAttributeChangeHint(aAttribute, aModType);
|
2006-12-26 20:47:52 +03:00
|
|
|
if (aAttribute == nsGkAtoms::align) {
|
2004-10-24 21:10:32 +04:00
|
|
|
NS_UpdateHint(retval, NS_STYLE_HINT_REFLOW);
|
2004-01-06 03:01:54 +03:00
|
|
|
}
|
2004-10-24 21:10:32 +04:00
|
|
|
return retval;
|
2004-01-06 03:01:54 +03:00
|
|
|
}
|
|
|
|
|
2011-10-17 22:52:12 +04:00
|
|
|
nsresult
|
2013-02-15 20:55:53 +04:00
|
|
|
HTMLLegendElement::SetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute,
|
|
|
|
nsIAtom* aPrefix, const nsAString& aValue,
|
|
|
|
bool aNotify)
|
2011-10-17 22:52:12 +04:00
|
|
|
{
|
|
|
|
return nsGenericHTMLElement::SetAttr(aNameSpaceID, aAttribute,
|
|
|
|
aPrefix, aValue, aNotify);
|
|
|
|
}
|
|
|
|
nsresult
|
2013-02-15 20:55:53 +04:00
|
|
|
HTMLLegendElement::UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute,
|
|
|
|
bool aNotify)
|
2011-10-17 22:52:12 +04:00
|
|
|
{
|
|
|
|
return nsGenericHTMLElement::UnsetAttr(aNameSpaceID, aAttribute, aNotify);
|
|
|
|
}
|
2001-11-02 10:40:01 +03:00
|
|
|
|
2005-04-06 03:54:35 +04:00
|
|
|
nsresult
|
2013-02-15 20:55:53 +04:00
|
|
|
HTMLLegendElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
|
|
|
nsIContent* aBindingParent,
|
|
|
|
bool aCompileEventHandlers)
|
2005-01-16 19:39:35 +03:00
|
|
|
{
|
2011-04-11 20:56:37 +04:00
|
|
|
return nsGenericHTMLElement::BindToTree(aDocument, aParent,
|
|
|
|
aBindingParent,
|
|
|
|
aCompileEventHandlers);
|
2005-04-06 03:54:35 +04:00
|
|
|
}
|
2005-01-16 19:39:35 +03:00
|
|
|
|
2005-04-06 03:54:35 +04:00
|
|
|
void
|
2013-02-15 20:55:53 +04:00
|
|
|
HTMLLegendElement::UnbindFromTree(bool aDeep, bool aNullParent)
|
2005-04-06 03:54:35 +04:00
|
|
|
{
|
2010-05-20 00:33:00 +04:00
|
|
|
nsGenericHTMLElement::UnbindFromTree(aDeep, aNullParent);
|
2005-01-16 19:39:35 +03:00
|
|
|
}
|
|
|
|
|
2012-10-06 11:19:52 +04:00
|
|
|
void
|
2013-02-15 20:55:53 +04:00
|
|
|
HTMLLegendElement::Focus(ErrorResult& aError)
|
2005-01-16 19:39:35 +03: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 22:00:39 +04:00
|
|
|
nsIFrame* frame = GetPrimaryFrame();
|
2012-10-06 11:19:52 +04: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 22:00:39 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t tabIndex;
|
2012-10-06 11:19:52 +04: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 22:00:39 +04:00
|
|
|
|
|
|
|
// If the legend isn't focusable, focus whatever is focusable following
|
|
|
|
// the legend instead, bug 81481.
|
|
|
|
nsIFocusManager* fm = nsFocusManager::GetFocusManager();
|
2012-10-06 11:19:52 +04: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 22:00:39 +04:00
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMElement> result;
|
2012-10-06 11:19:52 +04: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 22:00:39 +04:00
|
|
|
}
|
2005-01-16 19:39:35 +03: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 22:00:39 +04:00
|
|
|
void
|
2013-02-15 20:55:53 +04: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 22:00:39 +04:00
|
|
|
{
|
|
|
|
// just use the same behaviour as the focus method
|
2013-02-15 20:55:53 +04:00
|
|
|
ErrorResult rv;
|
2012-10-06 11:19:52 +04:00
|
|
|
Focus(rv);
|
2005-01-16 19:39:35 +03:00
|
|
|
}
|
|
|
|
|
2013-06-19 18:24:37 +04:00
|
|
|
already_AddRefed<HTMLFormElement>
|
2013-02-15 20:55:53 +04:00
|
|
|
HTMLLegendElement::GetForm()
|
|
|
|
{
|
|
|
|
Element* form = GetFormElement();
|
|
|
|
MOZ_ASSERT_IF(form, form->IsHTML(nsGkAtoms::form));
|
2013-06-19 18:24:37 +04:00
|
|
|
nsRefPtr<HTMLFormElement> ret = static_cast<HTMLFormElement*>(form);
|
2013-02-15 20:55:53 +04:00
|
|
|
return ret.forget();
|
|
|
|
}
|
|
|
|
|
|
|
|
JSObject*
|
2014-04-09 02:27:17 +04:00
|
|
|
HTMLLegendElement::WrapNode(JSContext* aCx)
|
2013-02-15 20:55:53 +04: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-09 02:27:17 +04:00
|
|
|
return HTMLLegendElementBinding::Wrap(aCx, this);
|
2013-02-15 20:55:53 +04:00
|
|
|
}
|
|
|
|
|
2013-02-15 20:55:53 +04:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|