2015-05-03 22:32:37 +03: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 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();
|
|
|
|
|
2015-03-03 14:08:59 +03:00
|
|
|
if (parent && parent->IsHTMLElement(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 },
|
2016-09-07 05:20:17 +03:00
|
|
|
{ nullptr, 0 }
|
2013-11-19 23:21:29 +04:00
|
|
|
};
|
|
|
|
|
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) {
|
2016-05-23 06:26:03 +03:00
|
|
|
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
|
|
|
|
2015-09-18 15:18:42 +03:00
|
|
|
bool
|
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);
|
2015-09-18 15:18:42 +03:00
|
|
|
return NS_SUCCEEDED(rv.StealNSResult());
|
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();
|
2015-03-03 14:08:59 +03:00
|
|
|
MOZ_ASSERT_IF(form, form->IsHTMLElement(nsGkAtoms::form));
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<HTMLFormElement> ret = static_cast<HTMLFormElement*>(form);
|
2013-02-15 20:55:53 +04: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 17:13:33 +03:00
|
|
|
HTMLLegendElement::WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
2013-02-15 20:55:53 +04: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 17:13:33 +03:00
|
|
|
return HTMLLegendElementBinding::Wrap(aCx, this, aGivenProto);
|
2013-02-15 20:55:53 +04:00
|
|
|
}
|
|
|
|
|
2013-02-15 20:55:53 +04:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|