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"
|
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
|
|
|
|
2020-02-20 19:19:15 +03:00
|
|
|
HTMLLegendElement::~HTMLLegendElement() = default;
|
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
|
|
|
|
2014-10-31 00:38:48 +03:00
|
|
|
nsIContent* 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
|
|
|
}
|
|
|
|
|
2013-02-15 20:55:53 +04:00
|
|
|
bool HTMLLegendElement::ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute,
|
|
|
|
const nsAString& aValue,
|
2017-11-02 06:35:52 +03:00
|
|
|
nsIPrincipal* aMaybeScriptedPrincipal,
|
2013-02-15 20:55:53 +04:00
|
|
|
nsAttrValue& aResult) {
|
2013-11-19 23:21:29 +04:00
|
|
|
// this contains center, because IE4 does
|
|
|
|
static const nsAttrValue::EnumTable kAlignTable[] = {
|
2020-01-23 06:10:03 +03:00
|
|
|
{"left", LegendAlignValue::Left},
|
|
|
|
{"right", LegendAlignValue::Right},
|
|
|
|
{"center", LegendAlignValue::Center},
|
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,
|
2017-11-02 06:35:52 +03:00
|
|
|
aMaybeScriptedPrincipal, aResult);
|
1998-09-03 05:03:33 +04:00
|
|
|
}
|
|
|
|
|
2017-10-03 01:05:19 +03:00
|
|
|
nsChangeHint HTMLLegendElement::GetAttributeChangeHint(const nsAtom* aAttribute,
|
2013-02-15 20:55:53 +04:00
|
|
|
int32_t aModType) const {
|
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
|
|
|
}
|
|
|
|
|
Bug 1555216 - Change the signature of BindToTree to be (BindContext&, nsINode& aParentNode). r=bzbarsky
BindContext was going to have way more information at first, but then I realized
that most of the things I wanted to know were basically a flag away using the
parent node.
Still I think it's worth it, now experimenting with BindToTree will only mean
adding a field to a struct that's included from a couple cpp files, instead of a
massive pain.
I also think this is clearer, and doing this highlights quite a few
inconsistencies in our code which I've left untouched, but commented with
FIXMEs.
Steps are:
$ for file in $(rg 'nsresult BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#nsresult BindToTree(Document\* aDocument, nsIContent\* aParent,#nsresult BindToTree(BindContext\&, nsINode\& aParent)#g' $file; done
$ for file in $(rg 'nsresult BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's# nsIContent\* aBindingParent) override#override#g' $file; done
$ for file in $(rg '::BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#::BindToTree(Document\* aDocument, nsIContent\* aParent,#::BindToTree(BindContext\& aContext, nsINode\& aParent)#g' $file; done
$ for file in $(rg '::BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#nsIContent\* aBindingParent)##g' $file; done
$ for file in $(rg '::BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#::BindToTree(aDocument, aParent, aBindingParent)#::BindToTree(aContext, aParent)#g' $file; done
$ ./mach clang-format
Then manual fixups.
Depends on D32948
Differential Revision: https://phabricator.services.mozilla.com/D32949
2019-05-29 07:27:04 +03:00
|
|
|
nsresult HTMLLegendElement::BindToTree(BindContext& aContext,
|
|
|
|
nsINode& aParent) {
|
|
|
|
return nsGenericHTMLElement::BindToTree(aContext, aParent);
|
2005-04-06 03:54:35 +04:00
|
|
|
}
|
2005-01-16 19:39:35 +03:00
|
|
|
|
2019-05-29 01:47:08 +03:00
|
|
|
void HTMLLegendElement::UnbindFromTree(bool aNullParent) {
|
|
|
|
nsGenericHTMLElement::UnbindFromTree(aNullParent);
|
2005-01-16 19:39:35 +03:00
|
|
|
}
|
|
|
|
|
2019-04-12 11:16:47 +03:00
|
|
|
void HTMLLegendElement::Focus(const FocusOptions& aOptions,
|
2020-01-16 17:38:40 +03:00
|
|
|
const mozilla::dom::CallerType aCallerType,
|
2019-04-12 11:16:47 +03:00
|
|
|
ErrorResult& aError) {
|
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)) {
|
2020-01-16 17:38:40 +03:00
|
|
|
nsGenericHTMLElement::Focus(aOptions, aCallerType, aError);
|
2012-10-06 11:19:52 +04:00
|
|
|
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
|
|
|
|
2018-04-26 17:37:47 +03:00
|
|
|
RefPtr<Element> result;
|
2019-04-12 11:16:47 +03:00
|
|
|
aError = fm->MoveFocus(
|
|
|
|
nullptr, this, nsIFocusManager::MOVEFOCUS_FORWARD,
|
|
|
|
nsIFocusManager::FLAG_NOPARENTFRAME |
|
|
|
|
nsFocusManager::FocusOptionsToFocusManagerFlags(aOptions),
|
|
|
|
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
|
|
|
|
2013-02-15 20:55:53 +04:00
|
|
|
bool HTMLLegendElement::PerformAccesskey(bool aKeyCausesActivation,
|
|
|
|
bool aIsTrustedEvent) {
|
2019-04-12 11:16:47 +03:00
|
|
|
FocusOptions options;
|
2013-02-15 20:55:53 +04:00
|
|
|
ErrorResult rv;
|
2019-04-12 11:16:47 +03:00
|
|
|
|
2020-01-16 17:38:40 +03:00
|
|
|
Focus(options, CallerType::System, 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> HTMLLegendElement::GetForm() {
|
2013-02-15 20:55:53 +04:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
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
|
|
|
JSObject* HTMLLegendElement::WrapNode(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aGivenProto) {
|
2018-06-26 00:20:54 +03:00
|
|
|
return HTMLLegendElement_Binding::Wrap(aCx, this, aGivenProto);
|
2013-02-15 20:55:53 +04:00
|
|
|
}
|
|
|
|
|
2013-02-15 20:55:53 +04:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|