2015-05-03 19:32:37 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 11:12:37 +00: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 16:55:53 +00:00
|
|
|
|
|
|
|
#include "mozilla/dom/HTMLLegendElement.h"
|
2013-02-15 16:55:53 +00:00
|
|
|
#include "mozilla/dom/HTMLLegendElementBinding.h"
|
1998-09-29 23:22:42 +00: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 18:00:39 +00:00
|
|
|
#include "nsFocusManager.h"
|
|
|
|
#include "nsIFrame.h"
|
1998-09-03 01:03:33 +00:00
|
|
|
|
2004-05-18 20:58:12 +00:00
|
|
|
NS_IMPL_NS_NEW_HTML_ELEMENT(Legend)
|
2013-02-15 16:55:53 +00:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
1998-09-03 01:03:33 +00:00
|
|
|
|
1999-10-07 00:35:04 +00:00
|
|
|
|
2013-02-15 16:55:53 +00:00
|
|
|
HTMLLegendElement::~HTMLLegendElement()
|
1998-09-03 01:03:33 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-02-15 16:55:53 +00:00
|
|
|
NS_IMPL_ELEMENT_CLONE(HTMLLegendElement)
|
2000-06-23 14:12:24 +00:00
|
|
|
|
2010-05-12 19:01:25 +00:00
|
|
|
nsIContent*
|
2014-10-30 21:38:48 +00:00
|
|
|
HTMLLegendElement::GetFieldSet() const
|
2010-05-12 19:01:25 +00:00
|
|
|
{
|
|
|
|
nsIContent* parent = GetParent();
|
|
|
|
|
2015-03-03 11:08:59 +00:00
|
|
|
if (parent && parent->IsHTMLElement(nsGkAtoms::fieldset)) {
|
2010-05-12 19:01:25 +00:00
|
|
|
return parent;
|
|
|
|
}
|
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2010-05-12 19:01:25 +00:00
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
2013-02-15 16:55:53 +00:00
|
|
|
HTMLLegendElement::ParseAttribute(int32_t aNamespaceID,
|
|
|
|
nsIAtom* aAttribute,
|
|
|
|
const nsAString& aValue,
|
|
|
|
nsAttrValue& aResult)
|
1998-09-03 01:03:33 +00:00
|
|
|
{
|
2013-11-19 19:21:29 +00: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 17:47:52 +00:00
|
|
|
if (aAttribute == nsGkAtoms::align && aNamespaceID == kNameSpaceID_None) {
|
2011-10-17 14:59:28 +00:00
|
|
|
return aResult.ParseEnumValue(aValue, kAlignTable, false);
|
1998-09-29 23:22:42 +00:00
|
|
|
}
|
2000-12-23 10:56:31 +00:00
|
|
|
|
2005-11-29 16:37:15 +00:00
|
|
|
return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
|
|
|
|
aResult);
|
1998-09-03 01:03:33 +00:00
|
|
|
}
|
|
|
|
|
2004-10-24 17:10:32 +00:00
|
|
|
nsChangeHint
|
2013-02-15 16:55:53 +00:00
|
|
|
HTMLLegendElement::GetAttributeChangeHint(const nsIAtom* aAttribute,
|
|
|
|
int32_t aModType) const
|
2004-01-06 00:01:54 +00:00
|
|
|
{
|
2004-10-24 17:10:32 +00:00
|
|
|
nsChangeHint retval =
|
2010-05-19 20:33:00 +00:00
|
|
|
nsGenericHTMLElement::GetAttributeChangeHint(aAttribute, aModType);
|
2006-12-26 17:47:52 +00:00
|
|
|
if (aAttribute == nsGkAtoms::align) {
|
2004-10-24 17:10:32 +00:00
|
|
|
NS_UpdateHint(retval, NS_STYLE_HINT_REFLOW);
|
2004-01-06 00:01:54 +00:00
|
|
|
}
|
2004-10-24 17:10:32 +00:00
|
|
|
return retval;
|
2004-01-06 00:01:54 +00:00
|
|
|
}
|
|
|
|
|
2011-10-17 18:52:12 +00:00
|
|
|
nsresult
|
2013-02-15 16:55:53 +00:00
|
|
|
HTMLLegendElement::SetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute,
|
|
|
|
nsIAtom* aPrefix, const nsAString& aValue,
|
|
|
|
bool aNotify)
|
2011-10-17 18:52:12 +00:00
|
|
|
{
|
|
|
|
return nsGenericHTMLElement::SetAttr(aNameSpaceID, aAttribute,
|
|
|
|
aPrefix, aValue, aNotify);
|
|
|
|
}
|
|
|
|
nsresult
|
2013-02-15 16:55:53 +00:00
|
|
|
HTMLLegendElement::UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute,
|
|
|
|
bool aNotify)
|
2011-10-17 18:52:12 +00:00
|
|
|
{
|
|
|
|
return nsGenericHTMLElement::UnsetAttr(aNameSpaceID, aAttribute, aNotify);
|
|
|
|
}
|
2001-11-02 07:40:01 +00:00
|
|
|
|
2005-04-05 23:54:35 +00:00
|
|
|
nsresult
|
2013-02-15 16:55:53 +00:00
|
|
|
HTMLLegendElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
|
|
|
nsIContent* aBindingParent,
|
|
|
|
bool aCompileEventHandlers)
|
2005-01-16 16:39:35 +00:00
|
|
|
{
|
2011-04-11 16:56:37 +00:00
|
|
|
return nsGenericHTMLElement::BindToTree(aDocument, aParent,
|
|
|
|
aBindingParent,
|
|
|
|
aCompileEventHandlers);
|
2005-04-05 23:54:35 +00:00
|
|
|
}
|
2005-01-16 16:39:35 +00:00
|
|
|
|
2005-04-05 23:54:35 +00:00
|
|
|
void
|
2013-02-15 16:55:53 +00:00
|
|
|
HTMLLegendElement::UnbindFromTree(bool aDeep, bool aNullParent)
|
2005-04-05 23:54:35 +00:00
|
|
|
{
|
2010-05-19 20:33:00 +00:00
|
|
|
nsGenericHTMLElement::UnbindFromTree(aDeep, aNullParent);
|
2005-01-16 16:39:35 +00:00
|
|
|
}
|
|
|
|
|
2012-10-06 07:19:52 +00:00
|
|
|
void
|
2013-02-15 16:55:53 +00:00
|
|
|
HTMLLegendElement::Focus(ErrorResult& aError)
|
2005-01-16 16:39:35 +00: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 18:00:39 +00:00
|
|
|
nsIFrame* frame = GetPrimaryFrame();
|
2012-10-06 07:19:52 +00: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 18:00:39 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t tabIndex;
|
2012-10-06 07:19:52 +00: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 18:00:39 +00:00
|
|
|
|
|
|
|
// If the legend isn't focusable, focus whatever is focusable following
|
|
|
|
// the legend instead, bug 81481.
|
|
|
|
nsIFocusManager* fm = nsFocusManager::GetFocusManager();
|
2012-10-06 07:19:52 +00: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 18:00:39 +00:00
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMElement> result;
|
2012-10-06 07:19:52 +00: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 18:00:39 +00:00
|
|
|
}
|
2005-01-16 16:39:35 +00: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 18:00:39 +00:00
|
|
|
void
|
2013-02-15 16:55:53 +00: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 18:00:39 +00:00
|
|
|
{
|
|
|
|
// just use the same behaviour as the focus method
|
2013-02-15 16:55:53 +00:00
|
|
|
ErrorResult rv;
|
2012-10-06 07:19:52 +00:00
|
|
|
Focus(rv);
|
2005-01-16 16:39:35 +00:00
|
|
|
}
|
|
|
|
|
2013-06-19 14:24:37 +00:00
|
|
|
already_AddRefed<HTMLFormElement>
|
2013-02-15 16:55:53 +00:00
|
|
|
HTMLLegendElement::GetForm()
|
|
|
|
{
|
|
|
|
Element* form = GetFormElement();
|
2015-03-03 11:08:59 +00:00
|
|
|
MOZ_ASSERT_IF(form, form->IsHTMLElement(nsGkAtoms::form));
|
2013-06-19 14:24:37 +00:00
|
|
|
nsRefPtr<HTMLFormElement> ret = static_cast<HTMLFormElement*>(form);
|
2013-02-15 16:55:53 +00:00
|
|
|
return ret.forget();
|
|
|
|
}
|
|
|
|
|
|
|
|
JSObject*
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 14:13:33 +00:00
|
|
|
HTMLLegendElement::WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
2013-02-15 16:55:53 +00:00
|
|
|
{
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 14:13:33 +00:00
|
|
|
return HTMLLegendElementBinding::Wrap(aCx, this, aGivenProto);
|
2013-02-15 16:55:53 +00:00
|
|
|
}
|
|
|
|
|
2013-02-15 16:55:53 +00:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|