mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 23:13:18 +00:00
b91a6a24cc
- Bug 1001637 - Make math tables implement the nsIAccessibleTable interface. r=surkov (ebbb4325d6) - Bug 1149118 - Expose radio group with the correct role on OS X, r=surkov (4d4a95735c) - Bug 1113153 - use 'paragraph' role for paragraphs only, introduce 'text' role for small text containers, r=marcoz (14c4fa5881) - Bug 1175164 - Do not expose MathML semantics element in the accessibility tree. r=surkov (3945ae0367) - Bug 930843 part.1 Add test for checking isTrust attribute value of DOMActivate event r=smaug (14a49dd447) - Bug 930843 part.2 NS_UI_ACTIVATE event should be trusted event even if it's caused by an untrusted event r=smaug (e0af6165b5) - Bug 1156315 - Call DispatchInputEvent in more places on OS X. r=dvander (e24f42c09f) - Bug 1186015 part.1 Rename nsIMEContext to mozilla::widget::IMEContext r=jimm (077bf6e772) - Bug 1186015 part.2 Rename nsIMM32Handler to mozilla::widget::IMMHandler r=jimm+m_kato (a2098e33b5) - Bug 1184533 Rewrite range check in aOffset of nsIMM32Handler::GetCharacterRectOfSelectedTextAt() r=emk (fb68bc3c56) - Bug 555642 part.1 nsCaret should have a way to override the caret visible state for hiding caret temporarily and nsEditor should hide caret if composition string doesn't have caret information r=roc (9de4aa366c) - Bug 1171847 Remove unnecessary ',' in logging code in nsTextStore::Initialize() r=m_kato (78d0d43625) - Bug 1181714 nsTextStore should store previous focused document manager until new document manager actually gets focus r=m_kato (fd7e820af2) - Bug 1176950 nsTextStore should keep storing locked content until NOTIFY_IME_OF_COMPOSITION_UPDATE is notified r=emk (0a12349575) - Bug 1137539 part.1 Implement TSFStaticSink::IsGoogleJapaneseInputActive() r=emk (68d1f9a0ec) - Bug 1137539 part.2 Implement TSFStaticSink::IsATOKActive() r=emk (51a4208bfa) - Bug 1137539 part.3 Implement TSFStaticSink::IsFreeChangJieActive() r=emk (affbb81b96) - Bug 1137539 part.4 Implement TSFStaticSink::IsEasyChangjeiActive() r=emk (abd3e674b6) - Bug 1186014 Rename nsTextStore to mozilla::widget::TSFTextStore r=jimm+m_kato (ca63351f94) - Bug 1187351 TSFTextStore should forget modified range at notifying TSF of layout change since GetTextExt() shouldn't return TS_E_NOLAYOUT after that r=emk (48878793e0) - Bg 1187367 TSFTextStore shouldn't destroy native caret for ATOK until notifying TSF of layout change r=emk (a2a4022d15) - Bug 1187566 TSFTextStore::Content should compute mMinTextModified Offset only with the latest composition string and original composition string, and also the hack should be enabled on Win10 r=emk (1368885efe) - Bug 1050644 part.1 Add methods to check whether the active TIP is Chinese TIP which deosn't show candidate window in e10s mode r=emk (1b783e682e) - Bug 1050644 part.2 Hack ITextStoreACP::GetTextExt()'s offset for some Chinese TIPs of MS r=emk (c05cec10ce) - Bug 1187579 Enable TSF in e10s mode r=m_kato (1ae106231a) - Bug 555642 part.2 IME handlers on Windows shouldn't append caret range if the caret is in the target clause which doesn't have specific style r=m_kato (88bae2c8da) - Bug 1196124 Fix mismatch of printf style string and following arguments of MOZ_LOG() in IMMHandler::GetCharacterRectOfSelectedTextAt() r=m_kato (0f6debd0d3) - Bug 90712 Cancel composition when Enter key message isn't consumed by IME r=m_kato (0febdb1fd9) - pointer style (6c984274cd) - Bug 1177268 - implement aria-rowcount/index and aria-colcount/index, r=marcoz (92ac300374) - Bug 1153135 - Return possibility PEN working while APZC is enabled. r=jimm (8bc77ff84f) - Bug 1171073 - Suppress content scrolling issue on 64-bit platforms. r=kats (62db0dead3) - Bug 1121946, Implement e10 cursor drag feedback on Windows, r=jmathies (6e8218d202) - Bug 1144650 - Don't dispatch touch-based mouse events when APZ is handling touch. r=jimm (53ebea0d90) - Bug 1163056 - InkCollector activation at first PEN event. r=jimm (b28e0ee58b) - Bug 895274 part.3 Make the enum of event messages a named enum IGNORE IDL r=smaug (32e04a4e90) - spacing (b9249221dc) - Bug 1182966 - Part 3: Add some final annotations to DomainSet. r=mrbkap (3455822e89) - Bug 1050122 - Part 1: Enable Nuwa on debug builds, and kill it if the preference is false. r=khuey (46685a7bf3) - Bug 1146229: Remove calling convention modifier from local variable. r=surkov (e5f4b6e5d5) - bug 1168932 - Implement ProxyCreated and ProxyDestroyed to update mozAccessibles r=tbsaunde (77a007fa21) - Bug 1169701 - Fire native OS X accessibility events for proxied accessibles r=tbsaunde (c4847135a8) - bug 1172523 - fire useful text change events for proxies r=lsock (85b7f995b8) - remove spurious file (229c787360) - bug 1171117 - Fix cairo to build on iOS. r=jrmuizel (45709c8fe3) - Bug 963738 - Annotate XPCNativeMember, r=terrence (d1afdde52b) - Bug 1148383 - Add testcase for previously fixed object metadata issue r=terrence (2c1b762cba) - Bug 1149797 - Update browser jstests to treat ecma_6/extensions tests as 1.8, so that let is interpreted as a statement and not as an expression. r=bustage in a CLOSED TREE (ac6127d6bc) - Bug 1150858 - Unwrap the correct object in ArrayBuffer.transfer (r=sfink) (cf67906802) - Bug 1150380 - IonMonkey: MIPS: Fix JitRuntime::generateProfilerExitFrameTailStub. r=rankov (eeac49ddce) - use RootedValue for POW as in 1135708 (34c1c3d191) - Bug 1196648: IonMonkey - Don't run the lazy link stub for asmjs to jit fastpath, r=nbp (686d495371) - Bug 1121947, Implement e10 cursor drag feedback on Mac, r=smaug (f48df2d1) - and sync widget/TextEvents.h and TextRange.h with AF.
387 lines
11 KiB
C++
387 lines
11 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/BasicEvents.h"
|
|
#include "mozilla/EventDispatcher.h"
|
|
#include "mozilla/EventStates.h"
|
|
#include "mozilla/dom/HTMLFieldSetElement.h"
|
|
#include "mozilla/dom/HTMLFieldSetElementBinding.h"
|
|
#include "nsContentList.h"
|
|
#include "nsQueryObject.h"
|
|
|
|
NS_IMPL_NS_NEW_HTML_ELEMENT(FieldSet)
|
|
|
|
namespace mozilla {
|
|
namespace dom {
|
|
|
|
HTMLFieldSetElement::HTMLFieldSetElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
|
|
: nsGenericHTMLFormElement(aNodeInfo)
|
|
, mElements(nullptr)
|
|
, mFirstLegend(nullptr)
|
|
, mInvalidElementsCount(0)
|
|
{
|
|
// <fieldset> is always barred from constraint validation.
|
|
SetBarredFromConstraintValidation(true);
|
|
|
|
// We start out enabled and valid.
|
|
AddStatesSilently(NS_EVENT_STATE_ENABLED | NS_EVENT_STATE_VALID);
|
|
}
|
|
|
|
HTMLFieldSetElement::~HTMLFieldSetElement()
|
|
{
|
|
uint32_t length = mDependentElements.Length();
|
|
for (uint32_t i = 0; i < length; ++i) {
|
|
mDependentElements[i]->ForgetFieldSet(this);
|
|
}
|
|
}
|
|
|
|
// nsISupports
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_INHERITED(HTMLFieldSetElement, nsGenericHTMLFormElement,
|
|
mValidity, mElements)
|
|
|
|
NS_IMPL_ADDREF_INHERITED(HTMLFieldSetElement, Element)
|
|
NS_IMPL_RELEASE_INHERITED(HTMLFieldSetElement, Element)
|
|
|
|
// QueryInterface implementation for HTMLFieldSetElement
|
|
NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(HTMLFieldSetElement)
|
|
NS_INTERFACE_TABLE_INHERITED(HTMLFieldSetElement,
|
|
nsIDOMHTMLFieldSetElement,
|
|
nsIConstraintValidation)
|
|
NS_INTERFACE_TABLE_TAIL_INHERITING(nsGenericHTMLFormElement)
|
|
|
|
NS_IMPL_ELEMENT_CLONE(HTMLFieldSetElement)
|
|
|
|
|
|
NS_IMPL_BOOL_ATTR(HTMLFieldSetElement, Disabled, disabled)
|
|
NS_IMPL_STRING_ATTR(HTMLFieldSetElement, Name, name)
|
|
|
|
// nsIConstraintValidation
|
|
NS_IMPL_NSICONSTRAINTVALIDATION(HTMLFieldSetElement)
|
|
|
|
bool
|
|
HTMLFieldSetElement::IsDisabledForEvents(EventMessage aMessage)
|
|
{
|
|
return IsElementDisabledForEvents(aMessage, nullptr);
|
|
}
|
|
|
|
// nsIContent
|
|
nsresult
|
|
HTMLFieldSetElement::PreHandleEvent(EventChainPreVisitor& aVisitor)
|
|
{
|
|
// Do not process any DOM events if the element is disabled.
|
|
aVisitor.mCanHandle = false;
|
|
if (IsDisabledForEvents(aVisitor.mEvent->mMessage)) {
|
|
return NS_OK;
|
|
}
|
|
|
|
return nsGenericHTMLFormElement::PreHandleEvent(aVisitor);
|
|
}
|
|
|
|
nsresult
|
|
HTMLFieldSetElement::AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
|
|
const nsAttrValue* aValue, bool aNotify)
|
|
{
|
|
if (aNameSpaceID == kNameSpaceID_None && aName == nsGkAtoms::disabled) {
|
|
// This *has* to be called *before* calling FieldSetDisabledChanged on our
|
|
// controls, as they may depend on our disabled state.
|
|
UpdateDisabledState(aNotify);
|
|
|
|
if (nsINode::GetFirstChild()) {
|
|
if (!mElements) {
|
|
mElements = new nsContentList(this, MatchListedElements, nullptr, nullptr,
|
|
true);
|
|
}
|
|
|
|
uint32_t length = mElements->Length(true);
|
|
for (uint32_t i=0; i<length; ++i) {
|
|
static_cast<nsGenericHTMLFormElement*>(mElements->Item(i))
|
|
->FieldSetDisabledChanged(aNotify);
|
|
}
|
|
}
|
|
}
|
|
|
|
return nsGenericHTMLFormElement::AfterSetAttr(aNameSpaceID, aName,
|
|
aValue, aNotify);
|
|
}
|
|
|
|
// nsIDOMHTMLFieldSetElement
|
|
|
|
NS_IMETHODIMP
|
|
HTMLFieldSetElement::GetForm(nsIDOMHTMLFormElement** aForm)
|
|
{
|
|
return nsGenericHTMLFormElement::GetForm(aForm);
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
HTMLFieldSetElement::GetType(nsAString& aType)
|
|
{
|
|
aType.AssignLiteral("fieldset");
|
|
return NS_OK;
|
|
}
|
|
|
|
/* static */
|
|
bool
|
|
HTMLFieldSetElement::MatchListedElements(nsIContent* aContent, int32_t aNamespaceID,
|
|
nsIAtom* aAtom, void* aData)
|
|
{
|
|
nsCOMPtr<nsIFormControl> formControl = do_QueryInterface(aContent);
|
|
return formControl && formControl->GetType() != NS_FORM_LABEL;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
HTMLFieldSetElement::GetElements(nsIDOMHTMLCollection** aElements)
|
|
{
|
|
NS_ADDREF(*aElements = Elements());
|
|
return NS_OK;
|
|
}
|
|
|
|
nsIHTMLCollection*
|
|
HTMLFieldSetElement::Elements()
|
|
{
|
|
if (!mElements) {
|
|
mElements = new nsContentList(this, MatchListedElements, nullptr, nullptr,
|
|
true);
|
|
}
|
|
|
|
return mElements;
|
|
}
|
|
|
|
// nsIFormControl
|
|
|
|
nsresult
|
|
HTMLFieldSetElement::Reset()
|
|
{
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
HTMLFieldSetElement::SubmitNamesValues(nsFormSubmission* aFormSubmission)
|
|
{
|
|
return NS_OK;
|
|
}
|
|
|
|
nsresult
|
|
HTMLFieldSetElement::InsertChildAt(nsIContent* aChild, uint32_t aIndex,
|
|
bool aNotify)
|
|
{
|
|
bool firstLegendHasChanged = false;
|
|
|
|
if (aChild->IsHTMLElement(nsGkAtoms::legend)) {
|
|
if (!mFirstLegend) {
|
|
mFirstLegend = aChild;
|
|
// We do not want to notify the first time mFirstElement is set.
|
|
} else {
|
|
// If mFirstLegend is before aIndex, we do not change it.
|
|
// Otherwise, mFirstLegend is now aChild.
|
|
if (int32_t(aIndex) <= IndexOf(mFirstLegend)) {
|
|
mFirstLegend = aChild;
|
|
firstLegendHasChanged = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
nsresult rv = nsGenericHTMLFormElement::InsertChildAt(aChild, aIndex, aNotify);
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
if (firstLegendHasChanged) {
|
|
NotifyElementsForFirstLegendChange(aNotify);
|
|
}
|
|
|
|
return rv;
|
|
}
|
|
|
|
void
|
|
HTMLFieldSetElement::RemoveChildAt(uint32_t aIndex, bool aNotify)
|
|
{
|
|
bool firstLegendHasChanged = false;
|
|
|
|
if (mFirstLegend && (GetChildAt(aIndex) == mFirstLegend)) {
|
|
// If we are removing the first legend we have to found another one.
|
|
nsIContent* child = mFirstLegend->GetNextSibling();
|
|
mFirstLegend = nullptr;
|
|
firstLegendHasChanged = true;
|
|
|
|
for (; child; child = child->GetNextSibling()) {
|
|
if (child->IsHTMLElement(nsGkAtoms::legend)) {
|
|
mFirstLegend = child;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
nsGenericHTMLFormElement::RemoveChildAt(aIndex, aNotify);
|
|
|
|
if (firstLegendHasChanged) {
|
|
NotifyElementsForFirstLegendChange(aNotify);
|
|
}
|
|
}
|
|
|
|
void
|
|
HTMLFieldSetElement::AddElement(nsGenericHTMLFormElement* aElement)
|
|
{
|
|
mDependentElements.AppendElement(aElement);
|
|
|
|
// If the element that we are adding aElement is a fieldset, then all the
|
|
// invalid elements in aElement are also invalid elements of this.
|
|
HTMLFieldSetElement* fieldSet = FromContent(aElement);
|
|
if (fieldSet) {
|
|
if (fieldSet->mInvalidElementsCount > 0) {
|
|
// The order we call UpdateValidity and adjust mInvalidElementsCount is
|
|
// important. We need to first call UpdateValidity in case
|
|
// mInvalidElementsCount was 0 before the call and will be incremented to
|
|
// 1 and so we need to change state to invalid. After that is done, we
|
|
// are free to increment mInvalidElementsCount to the correct amount.
|
|
UpdateValidity(false);
|
|
mInvalidElementsCount += fieldSet->mInvalidElementsCount - 1;
|
|
}
|
|
return;
|
|
}
|
|
|
|
// We need to update the validity of the fieldset.
|
|
nsCOMPtr<nsIConstraintValidation> cvElmt = do_QueryObject(aElement);
|
|
if (cvElmt &&
|
|
cvElmt->IsCandidateForConstraintValidation() && !cvElmt->IsValid()) {
|
|
UpdateValidity(false);
|
|
}
|
|
|
|
#if DEBUG
|
|
int32_t debugInvalidElementsCount = 0;
|
|
for (uint32_t i = 0; i < mDependentElements.Length(); i++) {
|
|
HTMLFieldSetElement* fieldSet = FromContent(mDependentElements[i]);
|
|
if (fieldSet) {
|
|
debugInvalidElementsCount += fieldSet->mInvalidElementsCount;
|
|
continue;
|
|
}
|
|
nsCOMPtr<nsIConstraintValidation>
|
|
cvElmt = do_QueryObject(mDependentElements[i]);
|
|
if (cvElmt &&
|
|
cvElmt->IsCandidateForConstraintValidation() &&
|
|
!(cvElmt->IsValid())) {
|
|
debugInvalidElementsCount += 1;
|
|
}
|
|
}
|
|
MOZ_ASSERT(debugInvalidElementsCount == mInvalidElementsCount);
|
|
#endif
|
|
}
|
|
|
|
void
|
|
HTMLFieldSetElement::RemoveElement(nsGenericHTMLFormElement* aElement)
|
|
{
|
|
mDependentElements.RemoveElement(aElement);
|
|
|
|
// If the element that we are removing aElement is a fieldset, then all the
|
|
// invalid elements in aElement are also removed from this.
|
|
HTMLFieldSetElement* fieldSet = FromContent(aElement);
|
|
if (fieldSet) {
|
|
if (fieldSet->mInvalidElementsCount > 0) {
|
|
// The order we update mInvalidElementsCount and call UpdateValidity is
|
|
// important. We need to first decrement mInvalidElementsCount and then
|
|
// call UpdateValidity, in case mInvalidElementsCount hits 0 in the call
|
|
// of UpdateValidity and we have to change state to valid.
|
|
mInvalidElementsCount -= fieldSet->mInvalidElementsCount - 1;
|
|
UpdateValidity(true);
|
|
}
|
|
return;
|
|
}
|
|
|
|
// We need to update the validity of the fieldset.
|
|
nsCOMPtr<nsIConstraintValidation> cvElmt = do_QueryObject(aElement);
|
|
if (cvElmt &&
|
|
cvElmt->IsCandidateForConstraintValidation() && !cvElmt->IsValid()) {
|
|
UpdateValidity(true);
|
|
}
|
|
|
|
#if DEBUG
|
|
int32_t debugInvalidElementsCount = 0;
|
|
for (uint32_t i = 0; i < mDependentElements.Length(); i++) {
|
|
HTMLFieldSetElement* fieldSet = FromContent(mDependentElements[i]);
|
|
if (fieldSet) {
|
|
debugInvalidElementsCount += fieldSet->mInvalidElementsCount;
|
|
continue;
|
|
}
|
|
nsCOMPtr<nsIConstraintValidation>
|
|
cvElmt = do_QueryObject(mDependentElements[i]);
|
|
if (cvElmt &&
|
|
cvElmt->IsCandidateForConstraintValidation() &&
|
|
!(cvElmt->IsValid())) {
|
|
debugInvalidElementsCount += 1;
|
|
}
|
|
}
|
|
MOZ_ASSERT(debugInvalidElementsCount == mInvalidElementsCount);
|
|
#endif
|
|
}
|
|
|
|
void
|
|
HTMLFieldSetElement::NotifyElementsForFirstLegendChange(bool aNotify)
|
|
{
|
|
/**
|
|
* NOTE: this could be optimized if only call when the fieldset is currently
|
|
* disabled.
|
|
* This should also make sure that mElements is set when we happen to be here.
|
|
* However, this method shouldn't be called very often in normal use cases.
|
|
*/
|
|
if (!mElements) {
|
|
mElements = new nsContentList(this, MatchListedElements, nullptr, nullptr,
|
|
true);
|
|
}
|
|
|
|
uint32_t length = mElements->Length(true);
|
|
for (uint32_t i = 0; i < length; ++i) {
|
|
static_cast<nsGenericHTMLFormElement*>(mElements->Item(i))
|
|
->FieldSetFirstLegendChanged(aNotify);
|
|
}
|
|
}
|
|
|
|
void
|
|
HTMLFieldSetElement::UpdateValidity(bool aElementValidity)
|
|
{
|
|
if (aElementValidity) {
|
|
--mInvalidElementsCount;
|
|
} else {
|
|
++mInvalidElementsCount;
|
|
}
|
|
|
|
MOZ_ASSERT(mInvalidElementsCount >= 0);
|
|
|
|
// The fieldset validity has just changed if:
|
|
// - there are no more invalid elements ;
|
|
// - or there is one invalid elmement and an element just became invalid.
|
|
if (!mInvalidElementsCount || (mInvalidElementsCount == 1 && !aElementValidity)) {
|
|
UpdateState(true);
|
|
}
|
|
|
|
// We should propagate the change to the fieldset parent chain.
|
|
if (mFieldSet) {
|
|
mFieldSet->UpdateValidity(aElementValidity);
|
|
}
|
|
|
|
return;
|
|
}
|
|
|
|
EventStates
|
|
HTMLFieldSetElement::IntrinsicState() const
|
|
{
|
|
EventStates state = nsGenericHTMLFormElement::IntrinsicState();
|
|
|
|
if (mInvalidElementsCount) {
|
|
state |= NS_EVENT_STATE_INVALID;
|
|
} else {
|
|
state |= NS_EVENT_STATE_VALID;
|
|
}
|
|
|
|
return state;
|
|
}
|
|
|
|
JSObject*
|
|
HTMLFieldSetElement::WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
|
{
|
|
return HTMLFieldSetElementBinding::Wrap(aCx, this, aGivenProto);
|
|
}
|
|
|
|
} // namespace dom
|
|
} // namespace mozilla
|