Files
palemoon27/dom/html/HTMLLegendElement.cpp
T
roytam1 343d0fbef3 import changes from `dev' branch of rmottola/Arctic-Fox:
- non-android part of Bug 1159371 - Make --disable-compile-environment work with --enable-application=mobile/android. r=glandium (489eef9b71)
- Bug 1159371 - Allow compiling sub-directories with --disable-compile-environment. r=glandium (5994752e02)
- Bug 1191819 - part 1 - substitute MOZ_BZ2_CFLAGS as a list; r=mshal (71cc3c5600)
- Bug 973933 - New updater-xpcshell binary for updater tests. r=rstrong (231074b8dd)
- Bug 973933 - Fix mochitest chrome updater tests. r=rstrong (30fbbcb6fc)
- Bug 973933 - Fix Nightly builds failing on updater-xpcshell. r=rstrong (8321af1395)
- Bug 1151827 - Fix re-building toolkit/mozapps/update on Windows. r=rstrong (ebc315c842)
- missing bit of Bug 1043692 - Add a DIST_INSTALL variable to moz.build, and replace NO_DIST_INSTALL with it. r=gps (cd79d1609d)
- Bug 1165061 - Fix Intermittent test_0102_background_restartNotification_staging.xul by not copying app files when staging for tests and enable the tests for Linux and Mac. r=spohl (918995f426)
- Bug 1191819 - part 2 - move updater's CXXFLAGS munging to moz.build; r=mshal (1e671a9838)
- Bug 1168042, return a bool from PerformAccessKey indicating if focus was changed, r=masayuki (2077cb0763)
- Bug 895274 part.36 Rename NS_MOUSEENTER to eMouseEnter r=smaug (fa49e67e92)
- Bug 895274 part.37 Rename NS_MOUSELEAVE to eMouseLeave r=smaug (1cc67b7bf5)
- Bug 895274 part.38 Rename NS_MOUSE_MOZLONGTAP to eMouseLongTap r=smaug (57b23d9678)
- Bug 1188234, part 1 - Initialize |number|. r=smaug (65734ffddd)
- Bug 1188234, part 2 - Add bounds checking in nsXULPrototypeElement::Deserialize(). r=smaug (c60e5e2eb0)
- Bug 1188234, part 3 - Make allocation of nsXULPrototypeAttribute fallible in nsXULPrototypeElement::Deserialize(). r=smaug (8ce4fe9925)
- Bug 1188234, part 4 - Don't append null to mChildren. r=smaug (2ec23c1c28)
- Bug 1190608, part 4 - Brace a few ifs in nsXULElement.cpp. r=poiru (1186ad8a86)
- Bug 1190608, part 3 - Remove some infallible new checks in nsXULElement.cpp. r=poiru (b2cf9b38b9)
- part of Bug 1190608, part 2 - Tuck elses in nsXULElement.cpp. r=poiru (98e6b93cdd)
- Bug 1190608, part 1 - Delete trailing whitespace in nsXULElement.cpp and nsXULPrototypeCache.cpp. r=poiru (3e80527246)
- Bug 1190608, part 5 - Sink the declaration of i in nsXULElement.cpp. r=poiru (d6917f5d96)
- Bug 1193572, part 1 - Don't use return values of failing calls in XUL deserialize methods. r=baku (8410bb3954)
- Bug 1193572, part 2 - nsXULPrototypeElement::Deserialize should use fallible SetCapacity. r=baku (15bf7ba655)
- Bug 1193572, part 3 - Don't re-initialize mType for XUL proto elements. r=baku (bdddcc6b0e)
- Bug 1193572, part 4 - Make script element ownership more direct. r=baku (7729aba5b3)
-  Bug 95274 part.39 Rename NS_POINTER_EVENT_START to ePointerEventFirst and add ePointerEventLast r=smaug (12289fc024)
- Bug 895274 part.40 Rename NS_POINTER_LOST_CAPTURE to ePointerLostCapture r=smaug (8cf49e2dce)
- Bug 895274 part.41 Rename NS_POINTER_GOT_CAPTURE to ePointerGotCapture r=smaug (11e1d37261)
- Bug 895274 part.42 Rename NS_POINTER_CANCEL to ePointerCancel r=smaug (ffe18b2169)
- Bug 1162990 - Add POINTER_LEAVE on captured element on e10s. r=smaug (98430e3bdc)
- Bug 895274 part.43 Rename NS_POINTER_LEAVE to ePointerLeave r=smaug (635c331338)
2022-04-22 14:33:40 +08:00

158 lines
4.4 KiB
C++

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */
#include "mozilla/dom/HTMLLegendElement.h"
#include "mozilla/dom/HTMLLegendElementBinding.h"
#include "nsIDOMHTMLFormElement.h"
#include "nsFocusManager.h"
#include "nsIFrame.h"
NS_IMPL_NS_NEW_HTML_ELEMENT(Legend)
namespace mozilla {
namespace dom {
HTMLLegendElement::~HTMLLegendElement()
{
}
NS_IMPL_ELEMENT_CLONE(HTMLLegendElement)
nsIContent*
HTMLLegendElement::GetFieldSet() const
{
nsIContent* parent = GetParent();
if (parent && parent->IsHTMLElement(nsGkAtoms::fieldset)) {
return parent;
}
return nullptr;
}
bool
HTMLLegendElement::ParseAttribute(int32_t aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult)
{
// 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 }
};
if (aAttribute == nsGkAtoms::align && aNamespaceID == kNameSpaceID_None) {
return aResult.ParseEnumValue(aValue, kAlignTable, false);
}
return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
aResult);
}
nsChangeHint
HTMLLegendElement::GetAttributeChangeHint(const nsIAtom* aAttribute,
int32_t aModType) const
{
nsChangeHint retval =
nsGenericHTMLElement::GetAttributeChangeHint(aAttribute, aModType);
if (aAttribute == nsGkAtoms::align) {
NS_UpdateHint(retval, NS_STYLE_HINT_REFLOW);
}
return retval;
}
nsresult
HTMLLegendElement::SetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute,
nsIAtom* aPrefix, const nsAString& aValue,
bool aNotify)
{
return nsGenericHTMLElement::SetAttr(aNameSpaceID, aAttribute,
aPrefix, aValue, aNotify);
}
nsresult
HTMLLegendElement::UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute,
bool aNotify)
{
return nsGenericHTMLElement::UnsetAttr(aNameSpaceID, aAttribute, aNotify);
}
nsresult
HTMLLegendElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
nsIContent* aBindingParent,
bool aCompileEventHandlers)
{
return nsGenericHTMLElement::BindToTree(aDocument, aParent,
aBindingParent,
aCompileEventHandlers);
}
void
HTMLLegendElement::UnbindFromTree(bool aDeep, bool aNullParent)
{
nsGenericHTMLElement::UnbindFromTree(aDeep, aNullParent);
}
void
HTMLLegendElement::Focus(ErrorResult& aError)
{
nsIFrame* frame = GetPrimaryFrame();
if (!frame) {
return;
}
int32_t tabIndex;
if (frame->IsFocusable(&tabIndex, false)) {
nsGenericHTMLElement::Focus(aError);
return;
}
// If the legend isn't focusable, focus whatever is focusable following
// the legend instead, bug 81481.
nsIFocusManager* fm = nsFocusManager::GetFocusManager();
if (!fm) {
return;
}
nsCOMPtr<nsIDOMElement> result;
aError = fm->MoveFocus(nullptr, this, nsIFocusManager::MOVEFOCUS_FORWARD,
nsIFocusManager::FLAG_NOPARENTFRAME,
getter_AddRefs(result));
}
bool
HTMLLegendElement::PerformAccesskey(bool aKeyCausesActivation,
bool aIsTrustedEvent)
{
// just use the same behaviour as the focus method
ErrorResult rv;
Focus(rv);
return NS_SUCCEEDED(rv.StealNSResult());
}
already_AddRefed<HTMLFormElement>
HTMLLegendElement::GetForm()
{
Element* form = GetFormElement();
MOZ_ASSERT_IF(form, form->IsHTMLElement(nsGkAtoms::form));
nsRefPtr<HTMLFormElement> ret = static_cast<HTMLFormElement*>(form);
return ret.forget();
}
JSObject*
HTMLLegendElement::WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
{
return HTMLLegendElementBinding::Wrap(aCx, this, aGivenProto);
}
} // namespace dom
} // namespace mozilla