Bug 313351. ContentStatesChanged should take only one argument. r=dbaron

This commit is contained in:
Boris Zbarsky 2011-03-28 23:32:11 -04:00
parent f096ca3c02
commit c634f43209
28 changed files with 174 additions and 200 deletions

View File

@ -1231,19 +1231,17 @@ void nsDocAccessible::ContentAppended(nsIDocument *aDocument,
{
}
void nsDocAccessible::ContentStatesChanged(nsIDocument* aDocument,
nsIContent* aContent1,
nsIContent* aContent2,
nsEventStates aStateMask)
void nsDocAccessible::ContentStateChanged(nsIDocument* aDocument,
nsIContent* aContent,
nsEventStates aStateMask)
{
if (aStateMask.HasState(NS_EVENT_STATE_CHECKED)) {
nsHTMLSelectOptionAccessible::SelectionChangedIfOption(aContent1);
nsHTMLSelectOptionAccessible::SelectionChangedIfOption(aContent2);
nsHTMLSelectOptionAccessible::SelectionChangedIfOption(aContent);
}
if (aStateMask.HasState(NS_EVENT_STATE_INVALID)) {
nsRefPtr<AccEvent> event =
new AccStateChangeEvent(aContent1, nsIAccessibleStates::STATE_INVALID,
new AccStateChangeEvent(aContent, nsIAccessibleStates::STATE_INVALID,
PR_FALSE, PR_TRUE);
FireDelayedAccessibleEvent(event);
}

View File

@ -123,8 +123,8 @@ class Element;
#define NS_IDOCUMENT_IID \
{ 0xc38a7935, 0xc854, 0x4df7, \
{ 0x8f, 0xd4, 0xa2, 0x6f, 0x0d, 0x27, 0x9f, 0x31 } }
{ 0x2c6ad63f, 0xb7b9, 0x42f8, \
{ 0xbd, 0xde, 0x76, 0x0a, 0x83, 0xe3, 0xb0, 0x49 } }
// Flag for AddStyleSheet().
#define NS_STYLESHEET_FROM_CATALOG (1 << 0)
@ -757,11 +757,9 @@ public:
virtual void SetReadyStateInternal(ReadyState rs) = 0;
virtual ReadyState GetReadyStateEnum() = 0;
// notify that one or two content nodes changed state
// either may be nsnull, but not both
virtual void ContentStatesChanged(nsIContent* aContent1,
nsIContent* aContent2,
nsEventStates aStateMask) = 0;
// notify that a content node changed state
virtual void ContentStateChanged(nsIContent* aContent,
nsEventStates aStateMask) = 0;
// Notify that a document state has changed.
// This should only be called by callers whose state is also reflected in the

View File

@ -49,8 +49,8 @@ class nsString;
class nsIDocument;
#define NS_IDOCUMENT_OBSERVER_IID \
{ 0x3d005225, 0x210f, 0x4b07, \
{ 0xb1, 0xd9, 0x96, 0x02, 0x05, 0x74, 0xc4, 0x37 } }
{ 0x900bc4bc, 0x8b6c, 0x4cba, \
{ 0x82, 0xfa, 0x56, 0x8a, 0x80, 0xff, 0xfd, 0x3e } }
typedef PRUint32 nsUpdateType;
@ -103,20 +103,12 @@ public:
* added/removed from the document or the content itself changed
* (the other notifications are used for that).
*
* The optional second content node is to allow optimization
* of the case where state moves from one node to another
* (as is likely for :focus and :hover)
*
* Either content node may be nsnull, but not both
*
* @param aDocument The document being observed
* @param aContent1 the piece of content that changed
* @param aContent2 optional second piece of content that changed
* @param aContent the piece of content that changed
*/
virtual void ContentStatesChanged(nsIDocument* aDocument,
nsIContent* aContent1,
nsIContent* aContent2,
nsEventStates aStateMask) = 0;
virtual void ContentStateChanged(nsIDocument* aDocument,
nsIContent* aContent,
nsEventStates aStateMask) = 0;
/**
* Notification that the state of the document has changed.
@ -247,11 +239,10 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsIDocumentObserver, NS_IDOCUMENT_OBSERVER_IID)
#define NS_DECL_NSIDOCUMENTOBSERVER_ENDLOAD \
virtual void EndLoad(nsIDocument* aDocument);
#define NS_DECL_NSIDOCUMENTOBSERVER_CONTENTSTATESCHANGED \
virtual void ContentStatesChanged(nsIDocument* aDocument, \
nsIContent* aContent1, \
nsIContent* aContent2, \
nsEventStates aStateMask);
#define NS_DECL_NSIDOCUMENTOBSERVER_CONTENTSTATECHANGED \
virtual void ContentStateChanged(nsIDocument* aDocument, \
nsIContent* aContent, \
nsEventStates aStateMask);
#define NS_DECL_NSIDOCUMENTOBSERVER_DOCUMENTSTATESCHANGED \
virtual void DocumentStatesChanged(nsIDocument* aDocument, \
@ -293,7 +284,7 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsIDocumentObserver, NS_IDOCUMENT_OBSERVER_IID)
NS_DECL_NSIDOCUMENTOBSERVER_ENDUPDATE \
NS_DECL_NSIDOCUMENTOBSERVER_BEGINLOAD \
NS_DECL_NSIDOCUMENTOBSERVER_ENDLOAD \
NS_DECL_NSIDOCUMENTOBSERVER_CONTENTSTATESCHANGED \
NS_DECL_NSIDOCUMENTOBSERVER_CONTENTSTATECHANGED \
NS_DECL_NSIDOCUMENTOBSERVER_DOCUMENTSTATESCHANGED \
NS_DECL_NSIDOCUMENTOBSERVER_STYLESHEETADDED \
NS_DECL_NSIDOCUMENTOBSERVER_STYLESHEETREMOVED \
@ -327,9 +318,8 @@ _class::EndLoad(nsIDocument* aDocument) \
#define NS_IMPL_NSIDOCUMENTOBSERVER_STATE_STUB(_class) \
void \
_class::ContentStatesChanged(nsIDocument* aDocument, \
nsIContent* aContent1, \
nsIContent* aContent2, \
_class::ContentStateChanged(nsIDocument* aDocument, \
nsIContent* aContent, \
nsEventStates aStateMask) \
{ \
} \

View File

@ -102,7 +102,7 @@ Link::SetLinkState(nsLinkState aState)
newLinkState == NS_EVENT_STATE_UNVISITED,
"Unexpected state obtained from LinkState()!");
mozAutoDocUpdate update(doc, UPDATE_CONTENT_STATE, PR_TRUE);
doc->ContentStatesChanged(content, nsnull, oldLinkState ^ newLinkState);
doc->ContentStateChanged(content, oldLinkState ^ newLinkState);
}
nsEventStates
@ -493,7 +493,7 @@ Link::ResetLinkState(bool aNotify)
if (aNotify && doc) {
nsEventStates changedState = NS_EVENT_STATE_VISITED ^ NS_EVENT_STATE_UNVISITED;
MOZ_AUTO_DOC_UPDATE(doc, UPDATE_STYLE, aNotify);
doc->ContentStatesChanged(content, nsnull, changedState);
doc->ContentStateChanged(content, changedState);
}
}

View File

@ -4266,11 +4266,10 @@ nsDocument::EndLoad()
}
void
nsDocument::ContentStatesChanged(nsIContent* aContent1, nsIContent* aContent2,
nsEventStates aStateMask)
nsDocument::ContentStateChanged(nsIContent* aContent, nsEventStates aStateMask)
{
NS_DOCUMENT_NOTIFY_OBSERVERS(ContentStatesChanged,
(this, aContent1, aContent2, aStateMask));
NS_DOCUMENT_NOTIFY_OBSERVERS(ContentStateChanged,
(this, aContent, aStateMask));
}
void

View File

@ -706,9 +706,8 @@ public:
virtual void SetReadyStateInternal(ReadyState rs);
virtual ReadyState GetReadyStateEnum();
virtual void ContentStatesChanged(nsIContent* aContent1,
nsIContent* aContent2,
nsEventStates aStateMask);
virtual void ContentStateChanged(nsIContent* aContent,
nsEventStates aStateMask);
virtual void DocumentStatesChanged(nsEventStates aStateMask);
virtual void StyleRuleChanged(nsIStyleSheet* aStyleSheet,

View File

@ -4766,7 +4766,7 @@ nsGenericElement::SetAttrAndNotify(PRInt32 aNamespaceID,
stateMask ^= IntrinsicState();
if (document && !stateMask.IsEmpty()) {
MOZ_AUTO_DOC_UPDATE(document, UPDATE_CONTENT_STATE, aNotify);
document->ContentStatesChanged(this, nsnull, stateMask);
document->ContentStateChanged(this, stateMask);
}
nsNodeUtils::AttributeChanged(this, aNamespaceID, aName, aModType);
}
@ -5013,7 +5013,7 @@ nsGenericElement::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
stateMask ^= IntrinsicState();
if (document && !stateMask.IsEmpty()) {
MOZ_AUTO_DOC_UPDATE(document, UPDATE_CONTENT_STATE, aNotify);
document->ContentStatesChanged(this, nsnull, stateMask);
document->ContentStateChanged(this, stateMask);
}
nsNodeUtils::AttributeChanged(this, aNameSpaceID, aName,
nsIDOMMutationEvent::REMOVAL);

View File

@ -829,7 +829,7 @@ nsImageLoadingContent::UpdateImageState(PRBool aNotify)
nsEventStates changedBits = oldState ^ ImageState();
if (!changedBits.IsEmpty()) {
mozAutoDocUpdate upd(doc, UPDATE_CONTENT_STATE, PR_TRUE);
doc->ContentStatesChanged(thisContent, nsnull, changedBits);
doc->ContentStateChanged(thisContent, changedBits);
}
}
}

View File

@ -1657,7 +1657,7 @@ nsObjectLoadingContent::NotifyStateChanged(ObjectType aOldType,
{
mozAutoDocUpdate upd(doc, UPDATE_CONTENT_STATE, PR_TRUE);
doc->ContentStatesChanged(thisContent, nsnull, changedBits);
doc->ContentStateChanged(thisContent, changedBits);
}
if (aSync) {
// Make sure that frames are actually constructed, and do it after

View File

@ -4305,10 +4305,10 @@ NotifyAncestors(nsIDocument* aDocument, nsIContent* aStartNode,
nsIContent* aStopBefore, nsEventStates aState)
{
while (aStartNode && aStartNode != aStopBefore) {
aDocument->ContentStatesChanged(aStartNode, nsnull, aState);
aDocument->ContentStateChanged(aStartNode, aState);
nsCOMPtr<nsIContent> labelTarget = GetLabelTarget(aStartNode);
if (labelTarget) {
aDocument->ContentStatesChanged(labelTarget, nsnull, aState);
aDocument->ContentStateChanged(labelTarget, aState);
}
aStartNode = aStartNode->GetParent();
}
@ -4467,20 +4467,19 @@ nsEventStateManager::SetContentState(nsIContent *aContent, nsEventStates aState)
NotifyAncestors(doc1, oldHover, commonHoverAncestor, NS_EVENT_STATE_HOVER);
if (notifyContent[0]) {
doc1->ContentStatesChanged(notifyContent[0], notifyContent[1],
simpleStates);
doc1->ContentStateChanged(notifyContent[0], simpleStates);
if (notifyContent[1]) {
doc1->ContentStateChanged(notifyContent[1], simpleStates);
}
if (notifyContent[2]) {
// more that two notifications are needed (should be rare)
// XXX a further optimization here would be to group the
// notification pairs together by parent/child, only needed if
// more than two content changed (ie: if [0] and [2] are
// parent/child, then notify (0,2) (1,3))
doc1->ContentStatesChanged(notifyContent[2], notifyContent[3],
simpleStates);
doc1->ContentStateChanged(notifyContent[2], simpleStates);
if (notifyContent[3]) {
doc1->ContentStateChanged(notifyContent[3], simpleStates);
}
if (notifyContent[4]) {
// more that four notifications are needed (should be rare)
doc1->ContentStatesChanged(notifyContent[4], nsnull,
simpleStates);
doc1->ContentStateChanged(notifyContent[4], simpleStates);
}
}
}
@ -4488,11 +4487,16 @@ nsEventStateManager::SetContentState(nsIContent *aContent, nsEventStates aState)
if (doc2) {
doc2->BeginUpdate(UPDATE_CONTENT_STATE);
doc2->ContentStatesChanged(notifyContent[1], notifyContent[2],
simpleStates);
doc2->ContentStateChanged(notifyContent[1], simpleStates);
if (notifyContent[2]) {
doc2->ContentStateChanged(notifyContent[2], simpleStates);
}
if (notifyContent[3]) {
doc1->ContentStatesChanged(notifyContent[3], notifyContent[4],
simpleStates);
// XXXbz shouldn't this notify doc2????
doc1->ContentStateChanged(notifyContent[3], simpleStates);
if (notifyContent[4]) {
doc1->ContentStateChanged(notifyContent[4], simpleStates);
}
}
doc2->EndUpdate(UPDATE_CONTENT_STATE);
}

View File

@ -2624,7 +2624,7 @@ nsGenericHTMLFormElement::BeforeSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
// AfterSetAttr.
if (doc && aNotify) {
MOZ_AUTO_DOC_UPDATE(doc, UPDATE_CONTENT_STATE, PR_TRUE);
doc->ContentStatesChanged(this, nsnull, NS_EVENT_STATE_DEFAULT);
doc->ContentStateChanged(this, NS_EVENT_STATE_DEFAULT);
}
}
@ -2682,7 +2682,7 @@ nsGenericHTMLFormElement::AfterSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
// changes can't affect that.
if (doc && aNotify) {
MOZ_AUTO_DOC_UPDATE(doc, UPDATE_CONTENT_STATE, PR_TRUE);
doc->ContentStatesChanged(this, nsnull, NS_EVENT_STATE_DEFAULT);
doc->ContentStateChanged(this, NS_EVENT_STATE_DEFAULT);
}
}
@ -2998,7 +2998,7 @@ nsGenericHTMLFormElement::FieldSetDisabledChanged(nsEventStates aStates, PRBool
nsIDocument* doc = GetCurrentDoc();
if (doc) {
MOZ_AUTO_DOC_UPDATE(doc, UPDATE_CONTENT_STATE, PR_TRUE);
doc->ContentStatesChanged(this, nsnull, aStates);
doc->ContentStateChanged(this, aStates);
}
}
@ -3496,9 +3496,9 @@ MakeContentDescendantsEditable(nsIContent *aContent, nsIDocument *aDocument)
aContent->UpdateEditableState();
if (aDocument && stateBefore != aContent->IntrinsicState()) {
aDocument->ContentStatesChanged(aContent, nsnull,
NS_EVENT_STATE_MOZ_READONLY |
NS_EVENT_STATE_MOZ_READWRITE);
aDocument->ContentStateChanged(aContent,
NS_EVENT_STATE_MOZ_READONLY |
NS_EVENT_STATE_MOZ_READWRITE);
}
PRUint32 i, n = aContent->GetChildCount();
@ -3530,7 +3530,7 @@ nsGenericHTMLElement::ChangeEditableState(PRInt32 aChange)
document = nsnull;
}
// MakeContentDescendantsEditable is going to call ContentStatesChanged for
// MakeContentDescendantsEditable is going to call ContentStateChanged for
// this element and all descendants if editable state has changed.
// We have to create a document update batch now so it's created once.
MOZ_AUTO_DOC_UPDATE(document, UPDATE_CONTENT_STATE, PR_TRUE);

View File

@ -632,7 +632,7 @@ nsHTMLButtonElement::AfterSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
nsIDocument* doc = GetCurrentDoc();
if (doc) {
MOZ_AUTO_DOC_UPDATE(doc, UPDATE_CONTENT_STATE, PR_TRUE);
doc->ContentStatesChanged(this, nsnull, states);
doc->ContentStateChanged(this, states);
}
}
}

View File

@ -394,16 +394,16 @@ nsHTMLFormElement::AfterSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
for (PRUint32 i = 0, length = mControls->mElements.Length();
i < length; ++i) {
doc->ContentStatesChanged(mControls->mElements[i], nsnull,
NS_EVENT_STATE_MOZ_UI_VALID |
NS_EVENT_STATE_MOZ_UI_INVALID);
doc->ContentStateChanged(mControls->mElements[i],
NS_EVENT_STATE_MOZ_UI_VALID |
NS_EVENT_STATE_MOZ_UI_INVALID);
}
for (PRUint32 i = 0, length = mControls->mNotInElements.Length();
i < length; ++i) {
doc->ContentStatesChanged(mControls->mNotInElements[i], nsnull,
NS_EVENT_STATE_MOZ_UI_VALID |
NS_EVENT_STATE_MOZ_UI_INVALID);
doc->ContentStateChanged(mControls->mNotInElements[i],
NS_EVENT_STATE_MOZ_UI_VALID |
NS_EVENT_STATE_MOZ_UI_INVALID);
}
}
}
@ -547,7 +547,7 @@ CollectOrphans(nsINode* aRemovalRoot, nsTArray<nsGenericHTMLFormElement*> aArray
}
if (doc) {
doc->ContentStatesChanged(node, nsnull, states);
doc->ContentStateChanged(node, states);
}
#ifdef DEBUG
removed = PR_TRUE;
@ -1234,7 +1234,7 @@ nsHTMLFormElement::AddElement(nsGenericHTMLFormElement* aChild,
// Notify that the state of the previous default submit element has changed
// if the element which is the default submit element has changed. The new
// default submit element is responsible for its own ContentStatesChanged
// default submit element is responsible for its own ContentStateChanged
// call.
if (aNotify && oldDefaultSubmit &&
oldDefaultSubmit != mDefaultSubmitElement) {
@ -1242,8 +1242,7 @@ nsHTMLFormElement::AddElement(nsGenericHTMLFormElement* aChild,
if (document) {
MOZ_AUTO_DOC_UPDATE(document, UPDATE_CONTENT_STATE, PR_TRUE);
nsCOMPtr<nsIContent> oldElement(do_QueryInterface(oldDefaultSubmit));
document->ContentStatesChanged(oldElement, nsnull,
NS_EVENT_STATE_DEFAULT);
document->ContentStateChanged(oldElement, NS_EVENT_STATE_DEFAULT);
}
}
}
@ -1380,8 +1379,8 @@ nsHTMLFormElement::HandleDefaultSubmitRemoval()
nsIDocument* document = GetCurrentDoc();
if (document) {
MOZ_AUTO_DOC_UPDATE(document, UPDATE_CONTENT_STATE, PR_TRUE);
document->ContentStatesChanged(mDefaultSubmitElement, nsnull,
NS_EVENT_STATE_DEFAULT);
document->ContentStateChanged(mDefaultSubmitElement,
NS_EVENT_STATE_DEFAULT);
}
}
}
@ -1754,7 +1753,7 @@ nsHTMLFormElement::CheckValidFormSubmission()
nsIDocument* doc = GetCurrentDoc();
if (doc) {
/*
* We are going to call ContentStatesChanged assuming elements want to
* We are going to call ContentStateChanged assuming elements want to
* be notified because we can't know.
* Submissions shouldn't happen during parsing so it _should_ be safe.
*/
@ -1771,9 +1770,9 @@ nsHTMLFormElement::CheckValidFormSubmission()
->UpdateValidityUIBits(true);
}
doc->ContentStatesChanged(mControls->mElements[i], nsnull,
NS_EVENT_STATE_MOZ_UI_VALID |
NS_EVENT_STATE_MOZ_UI_INVALID);
doc->ContentStateChanged(mControls->mElements[i],
NS_EVENT_STATE_MOZ_UI_VALID |
NS_EVENT_STATE_MOZ_UI_INVALID);
}
// Because of backward compatibility, <input type='image'> is not in
@ -1781,9 +1780,9 @@ nsHTMLFormElement::CheckValidFormSubmission()
// TODO: should probably be removed when bug 606491 will be fixed.
for (PRUint32 i = 0, length = mControls->mNotInElements.Length();
i < length; ++i) {
doc->ContentStatesChanged(mControls->mNotInElements[i], nsnull,
NS_EVENT_STATE_MOZ_UI_VALID |
NS_EVENT_STATE_MOZ_UI_INVALID);
doc->ContentStateChanged(mControls->mNotInElements[i],
NS_EVENT_STATE_MOZ_UI_VALID |
NS_EVENT_STATE_MOZ_UI_INVALID);
}
}
}
@ -1838,7 +1837,7 @@ nsHTMLFormElement::UpdateValidity(PRBool aElementValidity)
}
/*
* We are going to call ContentStatesChanged assuming submit controls want to
* We are going to call ContentStateChanged assuming submit controls want to
* be notified because we can't know.
* UpdateValidity shouldn't be called so much during parsing so it _should_
* be safe.
@ -1850,8 +1849,8 @@ nsHTMLFormElement::UpdateValidity(PRBool aElementValidity)
for (PRUint32 i = 0, length = mControls->mElements.Length();
i < length; ++i) {
if (mControls->mElements[i]->IsSubmitControl()) {
doc->ContentStatesChanged(mControls->mElements[i], nsnull,
NS_EVENT_STATE_MOZ_SUBMITINVALID);
doc->ContentStateChanged(mControls->mElements[i],
NS_EVENT_STATE_MOZ_SUBMITINVALID);
}
}
@ -1860,8 +1859,8 @@ nsHTMLFormElement::UpdateValidity(PRBool aElementValidity)
PRUint32 length = mControls->mNotInElements.Length();
for (PRUint32 i = 0; i < length; ++i) {
if (mControls->mNotInElements[i]->IsSubmitControl()) {
doc->ContentStatesChanged(mControls->mNotInElements[i], nsnull,
NS_EVENT_STATE_MOZ_SUBMITINVALID);
doc->ContentStateChanged(mControls->mNotInElements[i],
NS_EVENT_STATE_MOZ_SUBMITINVALID);
}
}
}

View File

@ -799,7 +799,7 @@ nsHTMLInputElement::AfterSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
const nsAString* aValue,
PRBool aNotify)
{
// States changes that have to be passed to ContentStatesChanged().
// States changes that have to be passed to ContentStateChanged().
nsEventStates states;
if (aNameSpaceID == kNameSpaceID_None) {
@ -953,7 +953,7 @@ nsHTMLInputElement::AfterSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
if (doc && !states.IsEmpty()) {
MOZ_AUTO_DOC_UPDATE(doc, UPDATE_CONTENT_STATE, PR_TRUE);
doc->ContentStatesChanged(this, nsnull, states);
doc->ContentStateChanged(this, states);
}
}
}
@ -1027,7 +1027,7 @@ nsHTMLInputElement::SetIndeterminateInternal(PRBool aValue,
nsIDocument* document = GetCurrentDoc();
if (document) {
mozAutoDocUpdate upd(document, UPDATE_CONTENT_STATE, PR_TRUE);
document->ContentStatesChanged(this, nsnull, NS_EVENT_STATE_INDETERMINATE);
document->ContentStateChanged(this, NS_EVENT_STATE_INDETERMINATE);
}
return NS_OK;
@ -1444,7 +1444,7 @@ nsHTMLInputElement::SetValueInternal(const nsAString& aValue,
nsIDocument* doc = GetCurrentDoc();
if (doc) {
mozAutoDocUpdate upd(doc, UPDATE_CONTENT_STATE, PR_TRUE);
doc->ContentStatesChanged(this, nsnull, NS_EVENT_STATE_MOZ_PLACEHOLDER);
doc->ContentStateChanged(this, NS_EVENT_STATE_MOZ_PLACEHOLDER);
}
}
@ -1483,8 +1483,8 @@ nsHTMLInputElement::SetValueChanged(PRBool aValueChanged)
nsIDocument* doc = GetCurrentDoc();
if (doc) {
mozAutoDocUpdate upd(doc, UPDATE_CONTENT_STATE, PR_TRUE);
doc->ContentStatesChanged(this, nsnull, NS_EVENT_STATE_MOZ_UI_VALID |
NS_EVENT_STATE_MOZ_UI_INVALID);
doc->ContentStateChanged(this, NS_EVENT_STATE_MOZ_UI_VALID |
NS_EVENT_STATE_MOZ_UI_INVALID);
}
}
@ -1533,9 +1533,9 @@ nsHTMLInputElement::SetCheckedChangedInternal(PRBool aCheckedChanged)
nsIDocument* document = GetCurrentDoc();
if (document) {
mozAutoDocUpdate upd(document, UPDATE_CONTENT_STATE, PR_TRUE);
document->ContentStatesChanged(this, nsnull,
NS_EVENT_STATE_MOZ_UI_VALID |
NS_EVENT_STATE_MOZ_UI_INVALID);
document->ContentStateChanged(this,
NS_EVENT_STATE_MOZ_UI_VALID |
NS_EVENT_STATE_MOZ_UI_INVALID);
}
}
}
@ -1733,7 +1733,7 @@ nsHTMLInputElement::SetCheckedInternal(PRBool aChecked, PRBool aNotify)
nsIDocument* document = GetCurrentDoc();
if (document) {
mozAutoDocUpdate upd(document, UPDATE_CONTENT_STATE, aNotify);
document->ContentStatesChanged(this, nsnull, NS_EVENT_STATE_CHECKED);
document->ContentStateChanged(this, NS_EVENT_STATE_CHECKED);
}
}
@ -2147,7 +2147,7 @@ nsHTMLInputElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor)
nsIDocument* doc = GetCurrentDoc();
if (doc) {
MOZ_AUTO_DOC_UPDATE(doc, UPDATE_CONTENT_STATE, PR_TRUE);
doc->ContentStatesChanged(this, nsnull, states);
doc->ContentStateChanged(this, states);
}
}
@ -3784,10 +3784,10 @@ nsHTMLInputElement::SetCustomValidity(const nsAString& aError)
nsIDocument* doc = GetCurrentDoc();
if (doc) {
MOZ_AUTO_DOC_UPDATE(doc, UPDATE_CONTENT_STATE, PR_TRUE);
doc->ContentStatesChanged(this, nsnull, NS_EVENT_STATE_INVALID |
NS_EVENT_STATE_VALID |
NS_EVENT_STATE_MOZ_UI_INVALID |
NS_EVENT_STATE_MOZ_UI_VALID);
doc->ContentStateChanged(this, NS_EVENT_STATE_INVALID |
NS_EVENT_STATE_VALID |
NS_EVENT_STATE_MOZ_UI_INVALID |
NS_EVENT_STATE_MOZ_UI_VALID);
}
return NS_OK;
@ -4000,9 +4000,10 @@ nsHTMLInputElement::UpdateAllValidityStates(PRBool aNotify)
nsIDocument* doc = GetCurrentDoc();
if (doc) {
MOZ_AUTO_DOC_UPDATE(doc, UPDATE_CONTENT_STATE, PR_TRUE);
doc->ContentStatesChanged(this, nsnull,
NS_EVENT_STATE_VALID | NS_EVENT_STATE_INVALID |
NS_EVENT_STATE_MOZ_UI_VALID | NS_EVENT_STATE_MOZ_UI_INVALID);
doc->ContentStateChanged(this,
NS_EVENT_STATE_VALID | NS_EVENT_STATE_INVALID |
NS_EVENT_STATE_MOZ_UI_VALID |
NS_EVENT_STATE_MOZ_UI_INVALID);
}
}
}
@ -4322,11 +4323,11 @@ public:
mValidity);
if (mNotify && mDocument) {
mDocument->ContentStatesChanged(input, nsnull,
NS_EVENT_STATE_VALID |
NS_EVENT_STATE_INVALID |
NS_EVENT_STATE_MOZ_UI_VALID |
NS_EVENT_STATE_MOZ_UI_INVALID);
mDocument->ContentStateChanged(input,
NS_EVENT_STATE_VALID |
NS_EVENT_STATE_INVALID |
NS_EVENT_STATE_MOZ_UI_VALID |
NS_EVENT_STATE_MOZ_UI_INVALID);
}
return NS_OK;
@ -4542,7 +4543,7 @@ nsHTMLInputElement::OnValueChanged(PRBool aNotify)
nsIDocument* doc = GetCurrentDoc();
if (doc) {
MOZ_AUTO_DOC_UPDATE(doc, UPDATE_CONTENT_STATE, PR_TRUE);
doc->ContentStatesChanged(this, nsnull, NS_EVENT_STATE_MOZ_PLACEHOLDER);
doc->ContentStateChanged(this, NS_EVENT_STATE_MOZ_PLACEHOLDER);
}
}
}

View File

@ -157,7 +157,7 @@ nsHTMLOptionElement::SetSelectedInternal(PRBool aValue, PRBool aNotify)
nsIDocument* document = GetCurrentDoc();
if (document) {
mozAutoDocUpdate upd(document, UPDATE_CONTENT_STATE, aNotify);
document->ContentStatesChanged(this, nsnull, NS_EVENT_STATE_CHECKED);
document->ContentStateChanged(this, NS_EVENT_STATE_CHECKED);
}
}
}

View File

@ -160,10 +160,10 @@ nsHTMLOutputElement::SetCustomValidity(const nsAString& aError)
nsIDocument* doc = GetCurrentDoc();
if (doc) {
MOZ_AUTO_DOC_UPDATE(doc, UPDATE_CONTENT_STATE, PR_TRUE);
doc->ContentStatesChanged(this, nsnull, NS_EVENT_STATE_INVALID |
NS_EVENT_STATE_VALID |
NS_EVENT_STATE_MOZ_UI_INVALID |
NS_EVENT_STATE_MOZ_UI_VALID);
doc->ContentStateChanged(this, NS_EVENT_STATE_INVALID |
NS_EVENT_STATE_VALID |
NS_EVENT_STATE_MOZ_UI_INVALID |
NS_EVENT_STATE_MOZ_UI_VALID);
}
return NS_OK;

View File

@ -212,10 +212,10 @@ nsHTMLSelectElement::SetCustomValidity(const nsAString& aError)
nsIDocument* doc = GetCurrentDoc();
if (doc) {
MOZ_AUTO_DOC_UPDATE(doc, UPDATE_CONTENT_STATE, PR_TRUE);
doc->ContentStatesChanged(this, nsnull, NS_EVENT_STATE_INVALID |
NS_EVENT_STATE_VALID |
NS_EVENT_STATE_MOZ_UI_INVALID |
NS_EVENT_STATE_MOZ_UI_VALID);
doc->ContentStateChanged(this, NS_EVENT_STATE_INVALID |
NS_EVENT_STATE_VALID |
NS_EVENT_STATE_MOZ_UI_INVALID |
NS_EVENT_STATE_MOZ_UI_VALID);
}
return NS_OK;
@ -366,10 +366,10 @@ nsHTMLSelectElement::RemoveOptionsFromList(nsIContent* aOptions,
nsIDocument* doc = GetCurrentDoc();
if (doc) {
MOZ_AUTO_DOC_UPDATE(doc, UPDATE_CONTENT_STATE, PR_TRUE);
doc->ContentStatesChanged(this, nsnull, NS_EVENT_STATE_VALID |
NS_EVENT_STATE_INVALID |
NS_EVENT_STATE_MOZ_UI_INVALID |
NS_EVENT_STATE_MOZ_UI_VALID);
doc->ContentStateChanged(this, NS_EVENT_STATE_VALID |
NS_EVENT_STATE_INVALID |
NS_EVENT_STATE_MOZ_UI_INVALID |
NS_EVENT_STATE_MOZ_UI_VALID);
}
}
}
@ -899,10 +899,10 @@ nsHTMLSelectElement::OnOptionSelected(nsISelectControlFrame* aSelectFrame,
nsIDocument* doc = GetCurrentDoc();
if (doc) {
MOZ_AUTO_DOC_UPDATE(doc, UPDATE_CONTENT_STATE, PR_TRUE);
doc->ContentStatesChanged(this, nsnull, NS_EVENT_STATE_VALID |
NS_EVENT_STATE_INVALID |
NS_EVENT_STATE_MOZ_UI_INVALID |
NS_EVENT_STATE_MOZ_UI_VALID);
doc->ContentStateChanged(this, NS_EVENT_STATE_VALID |
NS_EVENT_STATE_INVALID |
NS_EVENT_STATE_MOZ_UI_INVALID |
NS_EVENT_STATE_MOZ_UI_VALID);
}
}
}
@ -1344,10 +1344,10 @@ nsHTMLSelectElement::SelectSomething(PRBool aNotify)
nsIDocument* doc = GetCurrentDoc();
if (doc) {
MOZ_AUTO_DOC_UPDATE(doc, UPDATE_CONTENT_STATE, PR_TRUE);
doc->ContentStatesChanged(this, nsnull, NS_EVENT_STATE_VALID |
NS_EVENT_STATE_INVALID |
NS_EVENT_STATE_MOZ_UI_INVALID |
NS_EVENT_STATE_MOZ_UI_VALID);
doc->ContentStateChanged(this, NS_EVENT_STATE_VALID |
NS_EVENT_STATE_INVALID |
NS_EVENT_STATE_MOZ_UI_INVALID |
NS_EVENT_STATE_MOZ_UI_VALID);
}
}
@ -1410,7 +1410,7 @@ nsHTMLSelectElement::AfterSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
nsIDocument* doc = GetCurrentDoc();
if (doc) {
MOZ_AUTO_DOC_UPDATE(doc, UPDATE_CONTENT_STATE, PR_TRUE);
doc->ContentStatesChanged(this, nsnull, states);
doc->ContentStateChanged(this, states);
}
}
@ -1586,8 +1586,8 @@ nsHTMLSelectElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor)
nsIDocument* doc = GetCurrentDoc();
if (doc) {
MOZ_AUTO_DOC_UPDATE(doc, UPDATE_CONTENT_STATE, PR_TRUE);
doc->ContentStatesChanged(this, nsnull, NS_EVENT_STATE_MOZ_UI_VALID |
NS_EVENT_STATE_MOZ_UI_INVALID);
doc->ContentStateChanged(this, NS_EVENT_STATE_MOZ_UI_VALID |
NS_EVENT_STATE_MOZ_UI_INVALID);
}
}
@ -2328,8 +2328,8 @@ nsHTMLSelectElement::SetSelectionChanged(PRBool aValue, PRBool aNotify)
nsIDocument* doc = GetCurrentDoc();
if (doc) {
MOZ_AUTO_DOC_UPDATE(doc, UPDATE_CONTENT_STATE, PR_TRUE);
doc->ContentStatesChanged(this, nsnull, NS_EVENT_STATE_MOZ_UI_INVALID |
NS_EVENT_STATE_MOZ_UI_VALID);
doc->ContentStateChanged(this, NS_EVENT_STATE_MOZ_UI_INVALID |
NS_EVENT_STATE_MOZ_UI_VALID);
}
}
}

View File

@ -603,7 +603,7 @@ nsHTMLTextAreaElement::SetValueChanged(PRBool aValueChanged)
nsIDocument* doc = GetCurrentDoc();
if (doc) {
mozAutoDocUpdate upd(doc, UPDATE_CONTENT_STATE, PR_TRUE);
doc->ContentStatesChanged(this, nsnull, states);
doc->ContentStateChanged(this, states);
}
}
@ -781,7 +781,7 @@ nsHTMLTextAreaElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor)
nsIDocument* doc = GetCurrentDoc();
if (doc) {
MOZ_AUTO_DOC_UPDATE(doc, UPDATE_CONTENT_STATE, PR_TRUE);
doc->ContentStatesChanged(this, nsnull, states);
doc->ContentStateChanged(this, states);
}
}
@ -1234,7 +1234,7 @@ nsHTMLTextAreaElement::AfterSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
if (doc && !states.IsEmpty()) {
MOZ_AUTO_DOC_UPDATE(doc, UPDATE_CONTENT_STATE, PR_TRUE);
doc->ContentStatesChanged(this, nsnull, states);
doc->ContentStateChanged(this, states);
}
}
}
@ -1273,10 +1273,10 @@ nsHTMLTextAreaElement::SetCustomValidity(const nsAString& aError)
nsIDocument* doc = GetCurrentDoc();
if (doc) {
MOZ_AUTO_DOC_UPDATE(doc, UPDATE_CONTENT_STATE, PR_TRUE);
doc->ContentStatesChanged(this, nsnull, NS_EVENT_STATE_INVALID |
NS_EVENT_STATE_VALID |
NS_EVENT_STATE_MOZ_UI_INVALID |
NS_EVENT_STATE_MOZ_UI_VALID);
doc->ContentStateChanged(this, NS_EVENT_STATE_INVALID |
NS_EVENT_STATE_VALID |
NS_EVENT_STATE_MOZ_UI_INVALID |
NS_EVENT_STATE_MOZ_UI_VALID);
}
return NS_OK;
@ -1507,7 +1507,7 @@ nsHTMLTextAreaElement::OnValueChanged(PRBool aNotify)
nsIDocument* doc = GetCurrentDoc();
if (doc) {
MOZ_AUTO_DOC_UPDATE(doc, UPDATE_CONTENT_STATE, PR_TRUE);
doc->ContentStatesChanged(this, nsnull, states);
doc->ContentStateChanged(this, states);
}
}
}

View File

@ -3145,9 +3145,9 @@ NotifyEditableStateChange(nsINode *aNode, nsIDocument *aDocument,
for (i = 0; i < n; ++i) {
nsIContent *child = aNode->GetChildAt(i);
if (child->HasFlag(NODE_IS_EDITABLE) != aEditable) {
aDocument->ContentStatesChanged(child, nsnull,
NS_EVENT_STATE_MOZ_READONLY |
NS_EVENT_STATE_MOZ_READWRITE);
aDocument->ContentStateChanged(child,
NS_EVENT_STATE_MOZ_READONLY |
NS_EVENT_STATE_MOZ_READWRITE);
}
NotifyEditableStateChange(child, aDocument, aEditable);
}

View File

@ -468,6 +468,5 @@ nsMathMLElement::SetIncrementScriptLevel(PRBool aIncrementScriptLevel,
return;
mozAutoDocUpdate upd(doc, UPDATE_CONTENT_STATE, PR_TRUE);
doc->ContentStatesChanged(this, nsnull,
NS_EVENT_STATE_INCREMENT_SCRIPT_LEVEL);
doc->ContentStateChanged(this, NS_EVENT_STATE_INCREMENT_SCRIPT_LEVEL);
}

View File

@ -916,7 +916,7 @@ nsXTFElementWrapper::SetIntrinsicState(nsEventStates::InternalType aNewState)
mIntrinsicState = newStates;
mozAutoDocUpdate upd(doc, UPDATE_CONTENT_STATE, PR_TRUE);
doc->ContentStatesChanged(this, nsnull, bits);
doc->ContentStateChanged(this, bits);
return NS_OK;
}

View File

@ -1473,7 +1473,7 @@ nsXULElement::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, PRBool aNotify)
stateMask ^= IntrinsicState();
if (doc && !stateMask.IsEmpty()) {
MOZ_AUTO_DOC_UPDATE(doc, UPDATE_CONTENT_STATE, aNotify);
doc->ContentStatesChanged(this, nsnull, stateMask);
doc->ContentStateChanged(this, stateMask);
}
nsNodeUtils::AttributeChanged(this, aNameSpaceID, aName,
nsIDOMMutationEvent::REMOVAL);

View File

@ -8092,25 +8092,17 @@ nsCSSFrameConstructor::RestyleElement(Element *aElement,
}
nsresult
nsCSSFrameConstructor::ContentStatesChanged(nsIContent* aContent1,
nsIContent* aContent2,
nsEventStates aStateMask)
nsCSSFrameConstructor::ContentStateChanged(nsIContent* aContent,
nsEventStates aStateMask)
{
// XXXbz it would be good if this function only took Elements, but
// we'd have to make ESM guarantee that usefully.
if (NS_LIKELY(aContent1 && aContent1->IsElement())) {
DoContentStateChanged(aContent1->AsElement(), aStateMask);
if (!aContent->IsElement()) {
return NS_OK;
}
if (aContent2 && aContent2->IsElement()) {
DoContentStateChanged(aContent2->AsElement(), aStateMask);
}
return NS_OK;
}
void
nsCSSFrameConstructor::DoContentStateChanged(Element* aElement,
nsEventStates aStateMask)
{
Element* aElement = aContent->AsElement();
nsStyleSet *styleSet = mPresShell->StyleSet();
nsPresContext *presContext = mPresShell->GetPresContext();
NS_ASSERTION(styleSet, "couldn't get style set");
@ -8164,6 +8156,7 @@ nsCSSFrameConstructor::DoContentStateChanged(Element* aElement,
}
PostRestyleEvent(aElement, rshint, hint);
return NS_OK;
}
void

View File

@ -235,9 +235,8 @@ public:
nsresult CharacterDataChanged(nsIContent* aContent,
CharacterDataChangeInfo* aInfo);
nsresult ContentStatesChanged(nsIContent* aContent1,
nsIContent* aContent2,
nsEventStates aStateMask);
nsresult ContentStateChanged(nsIContent* aContent,
nsEventStates aStateMask);
// generate the child frames and process bindings
nsresult GenerateChildFrames(nsIFrame* aFrame);
@ -415,9 +414,6 @@ private:
nsIFrame*& aPageFrame,
nsIFrame*& aCanvasFrame);
void DoContentStateChanged(Element* aElement,
nsEventStates aStateMask);
/* aMinHint is the minimal change that should be made to the element */
// XXXbz do we really need the aPrimaryFrame argument here?
void RestyleElement(Element* aElement,

View File

@ -907,7 +907,7 @@ public:
NS_DECL_NSIDOCUMENTOBSERVER_ENDUPDATE
NS_DECL_NSIDOCUMENTOBSERVER_BEGINLOAD
NS_DECL_NSIDOCUMENTOBSERVER_ENDLOAD
NS_DECL_NSIDOCUMENTOBSERVER_CONTENTSTATESCHANGED
NS_DECL_NSIDOCUMENTOBSERVER_CONTENTSTATECHANGED
NS_DECL_NSIDOCUMENTOBSERVER_DOCUMENTSTATESCHANGED
NS_DECL_NSIDOCUMENTOBSERVER_STYLESHEETADDED
NS_DECL_NSIDOCUMENTOBSERVER_STYLESHEETREMOVED
@ -4903,17 +4903,16 @@ PresShell::CharacterDataChanged(nsIDocument *aDocument,
}
void
PresShell::ContentStatesChanged(nsIDocument* aDocument,
nsIContent* aContent1,
nsIContent* aContent2,
nsEventStates aStateMask)
PresShell::ContentStateChanged(nsIDocument* aDocument,
nsIContent* aContent,
nsEventStates aStateMask)
{
NS_PRECONDITION(!mIsDocumentGone, "Unexpected ContentStatesChanged");
NS_PRECONDITION(!mIsDocumentGone, "Unexpected ContentStateChanged");
NS_PRECONDITION(aDocument == mDocument, "Unexpected aDocument");
if (mDidInitialReflow) {
nsAutoCauseReflowNotifier crNotifier(this);
mFrameConstructor->ContentStatesChanged(aContent1, aContent2, aStateMask);
mFrameConstructor->ContentStateChanged(aContent, aStateMask);
VERIFY_STYLE_TREE;
}
}

View File

@ -820,19 +820,18 @@ nsTreeContentView::GetIndexOfItem(nsIDOMElement* aItem, PRInt32* _retval)
}
void
nsTreeContentView::ContentStatesChanged(nsIDocument* aDocument,
nsIContent* aContent1,
nsIContent* aContent2,
nsEventStates aStateMask)
nsTreeContentView::ContentStateChanged(nsIDocument* aDocument,
nsIContent* aContent,
nsEventStates aStateMask)
{
if (!aContent1 || !mSelection ||
!aContent1->IsHTML() ||
if (!mSelection ||
!aContent->IsHTML() ||
!aStateMask.HasState(NS_EVENT_STATE_CHECKED))
return;
if (aContent1->Tag() == nsGkAtoms::option) {
if (aContent->Tag() == nsGkAtoms::option) {
// update the selected state for this node
PRInt32 index = FindContent(aContent1);
PRInt32 index = FindContent(aContent);
if (index >= 0)
mSelection->ToggleSelect(index);
}

View File

@ -72,7 +72,7 @@ class nsTreeContentView : public nsINativeTreeView,
NS_DECL_NSITREECONTENTVIEW
// nsIDocumentObserver
NS_DECL_NSIDOCUMENTOBSERVER_CONTENTSTATESCHANGED
NS_DECL_NSIDOCUMENTOBSERVER_CONTENTSTATECHANGED
NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED
NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED
NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED

View File

@ -385,7 +385,7 @@ nsHtml5TreeOperation::Perform(nsHtml5TreeOpExecutor* aBuilder,
stateMask ^= node->IntrinsicState();
if (!stateMask.IsEmpty() && document) {
MOZ_AUTO_DOC_UPDATE(document, UPDATE_CONTENT_STATE, PR_TRUE);
document->ContentStatesChanged(node, nsnull, stateMask);
document->ContentStateChanged(node, stateMask);
}
nsNodeUtils::AttributeChanged(node,
nsuri,