зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1773070 - While at it rename ContentStateChanged to ElementStateChanged, and make it take elements. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D148553
This commit is contained in:
Родитель
47afabb81a
Коммит
12bd84f0c5
|
@ -863,16 +863,16 @@ void DocAccessible::ContentAppended(nsIContent* aFirstNewContent) {
|
|||
MaybeHandleChangeToHiddenNameOrDescription(aFirstNewContent);
|
||||
}
|
||||
|
||||
void DocAccessible::ContentStateChanged(dom::Document* aDocument,
|
||||
nsIContent* aContent,
|
||||
void DocAccessible::ElementStateChanged(dom::Document* aDocument,
|
||||
dom::Element* aElement,
|
||||
dom::ElementState aStateMask) {
|
||||
if (aStateMask.HasState(dom::ElementState::READWRITE) &&
|
||||
aContent == mDocumentNode->GetRootElement()) {
|
||||
aElement == mDocumentNode->GetRootElement()) {
|
||||
// This handles changes to designMode. contentEditable is handled by
|
||||
// LocalAccessible::AttributeChangesState and
|
||||
// LocalAccessible::DOMAttributeChanged.
|
||||
const bool isEditable =
|
||||
aContent->AsElement()->State().HasState(dom::ElementState::READWRITE);
|
||||
aElement->State().HasState(dom::ElementState::READWRITE);
|
||||
RefPtr<AccEvent> event =
|
||||
new AccStateChangeEvent(this, states::EDITABLE, isEditable);
|
||||
FireDelayedEvent(event);
|
||||
|
@ -880,14 +880,14 @@ void DocAccessible::ContentStateChanged(dom::Document* aDocument,
|
|||
FireDelayedEvent(event);
|
||||
}
|
||||
|
||||
LocalAccessible* accessible = GetAccessible(aContent);
|
||||
LocalAccessible* accessible = GetAccessible(aElement);
|
||||
if (!accessible) return;
|
||||
|
||||
if (aStateMask.HasState(dom::ElementState::CHECKED)) {
|
||||
LocalAccessible* widget = accessible->ContainerWidget();
|
||||
if (widget && widget->IsSelect()) {
|
||||
AccSelChangeEvent::SelChangeType selChangeType =
|
||||
aContent->AsElement()->State().HasState(dom::ElementState::CHECKED)
|
||||
aElement->State().HasState(dom::ElementState::CHECKED)
|
||||
? AccSelChangeEvent::eSelectionAdd
|
||||
: AccSelChangeEvent::eSelectionRemove;
|
||||
RefPtr<AccEvent> event =
|
||||
|
@ -898,7 +898,7 @@ void DocAccessible::ContentStateChanged(dom::Document* aDocument,
|
|||
|
||||
RefPtr<AccEvent> event = new AccStateChangeEvent(
|
||||
accessible, states::CHECKED,
|
||||
aContent->AsElement()->State().HasState(dom::ElementState::CHECKED));
|
||||
aElement->State().HasState(dom::ElementState::CHECKED));
|
||||
FireDelayedEvent(event);
|
||||
}
|
||||
|
||||
|
|
|
@ -701,7 +701,7 @@ class LocalAccessible : public nsISupports, public Accessible {
|
|||
* Return true if the accessible state change is processed by handling proper
|
||||
* DOM UI event, if otherwise then false. For example, CheckboxAccessible
|
||||
* created for HTML:input@type="checkbox" will process
|
||||
* nsIDocumentObserver::ContentStateChanged instead of 'CheckboxStateChange'
|
||||
* nsIDocumentObserver::ElementStateChanged instead of 'CheckboxStateChange'
|
||||
* event.
|
||||
*/
|
||||
bool NeedsDOMUIEvent() const { return !(mStateFlags & eIgnoreDOMUIEvent); }
|
||||
|
|
|
@ -8235,12 +8235,11 @@ void Document::UnblockDOMContentLoaded() {
|
|||
}
|
||||
}
|
||||
|
||||
void Document::ContentStateChanged(nsIContent* aContent,
|
||||
ElementState aStateMask) {
|
||||
void Document::ElementStateChanged(Element* aElement, ElementState aStateMask) {
|
||||
MOZ_ASSERT(!nsContentUtils::IsSafeToRunScript(),
|
||||
"Someone forgot a scriptblocker");
|
||||
NS_DOCUMENT_NOTIFY_OBSERVERS(ContentStateChanged,
|
||||
(this, aContent, aStateMask));
|
||||
NS_DOCUMENT_NOTIFY_OBSERVERS(ElementStateChanged,
|
||||
(this, aElement, aStateMask));
|
||||
}
|
||||
|
||||
void Document::RuleChanged(StyleSheet& aSheet, css::Rule*,
|
||||
|
|
|
@ -2059,9 +2059,9 @@ class Document : public nsINode,
|
|||
|
||||
void NotifyAbortedLoad();
|
||||
|
||||
// notify that a content node changed state. This must happen under
|
||||
// a scriptblocker but NOT within a begin/end update.
|
||||
void ContentStateChanged(nsIContent* aContent, ElementState aStateMask);
|
||||
// Notify that an element changed state. This must happen under a
|
||||
// scriptblocker but NOT within a begin/end update.
|
||||
void ElementStateChanged(Element*, ElementState);
|
||||
|
||||
// Update a set of document states that may have changed.
|
||||
// This should only be called by callers whose state is also reflected in the
|
||||
|
|
|
@ -353,7 +353,7 @@ void Element::NotifyStateChange(ElementState aStates) {
|
|||
|
||||
if (Document* doc = GetComposedDoc()) {
|
||||
nsAutoScriptBlocker scriptBlocker;
|
||||
doc->ContentStateChanged(this, aStates);
|
||||
doc->ElementStateChanged(this, aStates);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -373,7 +373,7 @@ void Element::UpdateState(bool aNotify) {
|
|||
Document* doc = GetComposedDoc();
|
||||
if (doc) {
|
||||
nsAutoScriptBlocker scriptBlocker;
|
||||
doc->ContentStateChanged(this, changedStates);
|
||||
doc->ElementStateChanged(this, changedStates);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -525,12 +525,10 @@ Element::StyleStateLocks Element::LockedStyleStates() const {
|
|||
}
|
||||
|
||||
void Element::NotifyStyleStateChange(ElementState aStates) {
|
||||
Document* doc = GetComposedDoc();
|
||||
if (doc) {
|
||||
RefPtr<PresShell> presShell = doc->GetPresShell();
|
||||
if (presShell) {
|
||||
if (RefPtr<Document> doc = GetComposedDoc()) {
|
||||
if (RefPtr<PresShell> presShell = doc->GetPresShell()) {
|
||||
nsAutoScriptBlocker scriptBlocker;
|
||||
presShell->ContentStateChanged(doc, this, aStates);
|
||||
presShell->ElementStateChanged(doc, this, aStates);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,12 +10,12 @@
|
|||
#include "nsIMutationObserver.h"
|
||||
#include "mozilla/dom/RustTypes.h"
|
||||
|
||||
class nsIContent;
|
||||
namespace mozilla {
|
||||
|
||||
namespace dom {
|
||||
class Document;
|
||||
}
|
||||
class Element;
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#define NS_IDOCUMENT_OBSERVER_IID \
|
||||
|
@ -55,24 +55,22 @@ class nsIDocumentObserver : public nsIMutationObserver {
|
|||
virtual void EndLoad(mozilla::dom::Document*) = 0;
|
||||
|
||||
/**
|
||||
* Notification that the state of a content node has changed.
|
||||
* (ie: gained or lost focus, became active or hovered over)
|
||||
* This method is called automatically by content objects
|
||||
* when their state is changed (therefore there is normally
|
||||
* no need to invoke this method directly). The notification
|
||||
* is passed to any IDocumentObservers. The notification is
|
||||
* passed on to all of the document observers. <p>
|
||||
* Notification that the state of an element has changed. (ie: gained or lost
|
||||
* focus, became active or hovered over)
|
||||
*
|
||||
* This notification is not sent when a piece of content is
|
||||
* added/removed from the document or the content itself changed
|
||||
* (the other notifications are used for that).
|
||||
* This method is called automatically by elements when their state is changed
|
||||
* (therefore there is normally no need to invoke this method directly).
|
||||
*
|
||||
* @param aDocument The document being observed
|
||||
* @param aContent the piece of content that changed
|
||||
* This notification is not sent when elements are added/removed from the
|
||||
* document (the other notifications are used for that).
|
||||
*
|
||||
* @param Document The document being observed
|
||||
* @param Element the piece of content that changed
|
||||
* @param ElementState the element states that changed
|
||||
*/
|
||||
virtual void ContentStateChanged(mozilla::dom::Document*,
|
||||
nsIContent* aContent,
|
||||
mozilla::dom::ElementState aStateMask) = 0;
|
||||
virtual void ElementStateChanged(mozilla::dom::Document*,
|
||||
mozilla::dom::Element*,
|
||||
mozilla::dom::ElementState) = 0;
|
||||
};
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(nsIDocumentObserver, NS_IDOCUMENT_OBSERVER_IID)
|
||||
|
@ -89,10 +87,10 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsIDocumentObserver, NS_IDOCUMENT_OBSERVER_IID)
|
|||
#define NS_DECL_NSIDOCUMENTOBSERVER_ENDLOAD \
|
||||
virtual void EndLoad(mozilla::dom::Document*) override;
|
||||
|
||||
#define NS_DECL_NSIDOCUMENTOBSERVER_CONTENTSTATECHANGED \
|
||||
virtual void ContentStateChanged( \
|
||||
mozilla::dom::Document*, nsIContent* aContent, \
|
||||
mozilla::dom::ElementState aStateMask) override;
|
||||
#define NS_DECL_NSIDOCUMENTOBSERVER_CONTENTSTATECHANGED \
|
||||
virtual void ElementStateChanged(mozilla::dom::Document*, \
|
||||
mozilla::dom::Element*, \
|
||||
mozilla::dom::ElementState) override;
|
||||
|
||||
#define NS_DECL_NSIDOCUMENTOBSERVER \
|
||||
NS_DECL_NSIDOCUMENTOBSERVER_BEGINUPDATE \
|
||||
|
@ -112,9 +110,9 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsIDocumentObserver, NS_IDOCUMENT_OBSERVER_IID)
|
|||
void _class::EndLoad(mozilla::dom::Document*) {}
|
||||
|
||||
#define NS_IMPL_NSIDOCUMENTOBSERVER_STATE_STUB(_class) \
|
||||
void _class::ContentStateChanged(mozilla::dom::Document*, \
|
||||
nsIContent* aContent, \
|
||||
mozilla::dom::ElementState aStateMask) {}
|
||||
void _class::ElementStateChanged(mozilla::dom::Document*, \
|
||||
mozilla::dom::Element*, \
|
||||
mozilla::dom::ElementState) {}
|
||||
|
||||
#define NS_IMPL_NSIDOCUMENTOBSERVER_CONTENT(_class) \
|
||||
NS_IMPL_NSIMUTATIONOBSERVER_CONTENT(_class)
|
||||
|
|
|
@ -6545,7 +6545,7 @@ void HTMLInputElement::UpdateValueMissingValidityStateForRadio(
|
|||
|
||||
SetValidityState(VALIDITY_STATE_VALUE_MISSING, valueMissing);
|
||||
|
||||
// nsRadioSetValueMissingState will call ContentStateChanged while visiting.
|
||||
// nsRadioSetValueMissingState will call ElementStateChanged while visiting.
|
||||
nsAutoScriptBlocker scriptBlocker;
|
||||
nsCOMPtr<nsIRadioVisitor> visitor =
|
||||
new nsRadioSetValueMissingState(this, valueMissing);
|
||||
|
|
|
@ -2331,7 +2331,7 @@ bool nsGenericHTMLElement::IsEditableRoot() const {
|
|||
static void MakeContentDescendantsEditable(nsIContent* aContent) {
|
||||
// If aContent is not an element, we just need to update its
|
||||
// internal editable state and don't need to notify anyone about
|
||||
// that. For elements, we need to send a ContentStateChanged
|
||||
// that. For elements, we need to send a ElementStateChanged
|
||||
// notification.
|
||||
if (!aContent->IsElement()) {
|
||||
aContent->UpdateEditableState(false);
|
||||
|
@ -2364,7 +2364,7 @@ void nsGenericHTMLElement::ChangeEditableState(int32_t aChange) {
|
|||
previousEditingState = document->GetEditingState();
|
||||
}
|
||||
|
||||
// MakeContentDescendantsEditable is going to call ContentStateChanged for
|
||||
// MakeContentDescendantsEditable is going to call ElementStateChanged for
|
||||
// this element and all descendants if editable state has changed.
|
||||
// We might as well wrap it all in one script blocker.
|
||||
nsAutoScriptBlocker scriptBlocker;
|
||||
|
|
|
@ -4427,15 +4427,15 @@ MOZ_CAN_RUN_SCRIPT_BOUNDARY void PresShell::CharacterDataChanged(
|
|||
mFrameConstructor->CharacterDataChanged(aContent, aInfo);
|
||||
}
|
||||
|
||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY void PresShell::ContentStateChanged(
|
||||
Document* aDocument, nsIContent* aContent, ElementState aStateMask) {
|
||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY void PresShell::ElementStateChanged(
|
||||
Document* aDocument, Element* aElement, ElementState aStateMask) {
|
||||
MOZ_ASSERT(!nsContentUtils::IsSafeToRunScript());
|
||||
MOZ_ASSERT(!mIsDocumentGone, "Unexpected ContentStateChanged");
|
||||
MOZ_ASSERT(aDocument == mDocument, "Unexpected aDocument");
|
||||
|
||||
if (mDidInitialize) {
|
||||
nsAutoCauseReflowNotifier crNotifier(this);
|
||||
mPresContext->RestyleManager()->ContentStateChanged(aContent, aStateMask);
|
||||
mPresContext->RestyleManager()->ElementStateChanged(aElement, aStateMask);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -525,7 +525,7 @@ static nsChangeHint ChangeForContentStateChange(const Element& aElement,
|
|||
}
|
||||
}
|
||||
}
|
||||
primaryFrame->ContentStatesChanged(aStateMask);
|
||||
primaryFrame->ElementStateChanged(aStateMask);
|
||||
}
|
||||
|
||||
if (aStateMask.HasState(ElementState::VISITED)) {
|
||||
|
@ -3220,16 +3220,10 @@ void RestyleManager::UpdateOnlyAnimationStyles() {
|
|||
DoProcessPendingRestyles(ServoTraversalFlags::FlushThrottledAnimations);
|
||||
}
|
||||
|
||||
void RestyleManager::ContentStateChanged(nsIContent* aContent,
|
||||
void RestyleManager::ElementStateChanged(Element* aElement,
|
||||
ElementState aChangedBits) {
|
||||
MOZ_DIAGNOSTIC_ASSERT(!mInStyleRefresh);
|
||||
|
||||
if (!aContent->IsElement()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Element& element = *aContent->AsElement();
|
||||
|
||||
const ElementState kVisitedAndUnvisited =
|
||||
ElementState::VISITED | ElementState::UNVISITED;
|
||||
|
||||
|
@ -3245,7 +3239,7 @@ void RestyleManager::ContentStateChanged(nsIContent* aContent,
|
|||
// changes to unvisited or vice-versa, but not when we start or stop being a
|
||||
// link itself.
|
||||
if (aChangedBits.HasAllStates(kVisitedAndUnvisited)) {
|
||||
if (!Gecko_VisitedStylesEnabled(element.OwnerDoc()) ||
|
||||
if (!Gecko_VisitedStylesEnabled(aElement->OwnerDoc()) ||
|
||||
StaticPrefs::layout_css_always_repaint_on_unvisited()) {
|
||||
aChangedBits &= ~kVisitedAndUnvisited;
|
||||
if (aChangedBits.IsEmpty()) {
|
||||
|
@ -3254,8 +3248,8 @@ void RestyleManager::ContentStateChanged(nsIContent* aContent,
|
|||
}
|
||||
}
|
||||
|
||||
if (auto changeHint = ChangeForContentStateChange(element, aChangedBits)) {
|
||||
Servo_NoteExplicitHints(&element, RestyleHint{0}, changeHint);
|
||||
if (auto changeHint = ChangeForContentStateChange(*aElement, aChangedBits)) {
|
||||
Servo_NoteExplicitHints(aElement, RestyleHint{0}, changeHint);
|
||||
}
|
||||
|
||||
// Don't bother taking a snapshot if no rules depend on these state bits.
|
||||
|
@ -3264,7 +3258,7 @@ void RestyleManager::ContentStateChanged(nsIContent* aContent,
|
|||
// track those bits in the same way, and we know that :dir() rules are always
|
||||
// present in UA style sheets.
|
||||
if (!aChangedBits.HasAtLeastOneOfStates(ElementState::DIR_STATES) &&
|
||||
!StyleSet()->HasStateDependency(element, aChangedBits)) {
|
||||
!StyleSet()->HasStateDependency(*aElement, aChangedBits)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -3272,12 +3266,12 @@ void RestyleManager::ContentStateChanged(nsIContent* aContent,
|
|||
// undisplayed elements, since we don't know if it is needed.
|
||||
IncrementUndisplayedRestyleGeneration();
|
||||
|
||||
if (!element.HasServoData()) {
|
||||
if (!aElement->HasServoData()) {
|
||||
return;
|
||||
}
|
||||
|
||||
ServoElementSnapshot& snapshot = SnapshotFor(element);
|
||||
ElementState previousState = element.StyleState() ^ aChangedBits;
|
||||
ServoElementSnapshot& snapshot = SnapshotFor(*aElement);
|
||||
ElementState previousState = aElement->StyleState() ^ aChangedBits;
|
||||
snapshot.AddState(previousState);
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
|
||||
class nsAttrValue;
|
||||
class nsAtom;
|
||||
class nsIContent;
|
||||
class nsIFrame;
|
||||
class nsStyleChangeList;
|
||||
class nsStyleChangeList;
|
||||
|
@ -360,7 +359,7 @@ class RestyleManager {
|
|||
void ProcessPendingRestyles();
|
||||
void ProcessAllPendingAttributeAndStateInvalidations();
|
||||
|
||||
void ContentStateChanged(nsIContent* aContent, dom::ElementState aStateMask);
|
||||
void ElementStateChanged(Element*, dom::ElementState);
|
||||
void AttributeWillChange(Element* aElement, int32_t aNameSpaceID,
|
||||
nsAtom* aAttribute, int32_t aModType);
|
||||
void ClassAttributeWillBeChangedBySMIL(dom::Element* aElement);
|
||||
|
|
|
@ -540,7 +540,7 @@ void nsFileControlFrame::SyncDisabledState() {
|
|||
}
|
||||
}
|
||||
|
||||
void nsFileControlFrame::ContentStatesChanged(ElementState aStates) {
|
||||
void nsFileControlFrame::ElementStateChanged(ElementState aStates) {
|
||||
if (aStates.HasState(ElementState::DISABLED)) {
|
||||
nsContentUtils::AddScriptRunner(new SyncDisabledStateEvent(this));
|
||||
}
|
||||
|
|
|
@ -59,8 +59,7 @@ class nsFileControlFrame final : public nsBlockFrame,
|
|||
virtual nsresult GetFrameName(nsAString& aResult) const override;
|
||||
#endif
|
||||
|
||||
virtual void ContentStatesChanged(
|
||||
mozilla::dom::ElementState aStates) override;
|
||||
void ElementStateChanged(mozilla::dom::ElementState aStates) override;
|
||||
|
||||
// nsIAnonymousContentCreator
|
||||
virtual nsresult CreateAnonymousContent(
|
||||
|
|
|
@ -443,7 +443,7 @@ void nsIFrame::FindCloserFrameForSelection(
|
|||
}
|
||||
}
|
||||
|
||||
void nsIFrame::ContentStatesChanged(mozilla::dom::ElementState aStates) {}
|
||||
void nsIFrame::ElementStateChanged(mozilla::dom::ElementState aStates) {}
|
||||
|
||||
void WeakFrame::Clear(mozilla::PresShell* aPresShell) {
|
||||
if (aPresShell) {
|
||||
|
|
|
@ -2354,12 +2354,12 @@ class nsIFrame : public nsQueryFrame {
|
|||
int32_t aModType);
|
||||
|
||||
/**
|
||||
* When the content states of a content object change, this method is invoked
|
||||
* on the primary frame of that content object.
|
||||
* When the element states of mContent change, this method is invoked on the
|
||||
* primary frame of that element.
|
||||
*
|
||||
* @param aStates the changed states
|
||||
*/
|
||||
virtual void ContentStatesChanged(mozilla::dom::ElementState aStates);
|
||||
virtual void ElementStateChanged(mozilla::dom::ElementState aStates);
|
||||
|
||||
/**
|
||||
* Continuation member functions
|
||||
|
|
Загрузка…
Ссылка в новой задаче