Bug 354745. Show/hide events not fired for layout changes in a changelist. r+sr=bz

git-svn-id: svn://10.0.0.236/trunk@213170 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
aaronleventhal%moonset.net 2006-10-05 13:35:23 +00:00
parent f5f80d9ee3
commit 06a68f0229
3 changed files with 47 additions and 68 deletions

View File

@ -10419,46 +10419,6 @@ nsCSSFrameConstructor::CharacterDataChanged(nsIContent* aContent,
return rv;
}
#ifdef ACCESSIBILITY
nsIAtom*
nsCSSFrameConstructor::GetRenderedFrameType(nsIFrame *aFrame)
{
if (aFrame) {
const nsStyleVisibility* vis = aFrame->GetStyleVisibility();
if (vis->IsVisible()) {
return aFrame->GetType();
}
}
return nsnull;
}
void
nsCSSFrameConstructor::NotifyAccessibleChange(nsIAtom *aPreviousFrameType,
nsIAtom *aFrameType,
nsIContent *aContent)
{
if (aFrameType == aPreviousFrameType) {
return;
}
PRUint32 event = nsIAccessibleEvent::EVENT_REORDER;
if (!aPreviousFrameType) {
event = nsIAccessibleEvent::EVENT_SHOW;
}
else if (!aFrameType) {
event = nsIAccessibleEvent::EVENT_HIDE;
}
// A significant enough change occured that this part
// of the accessible tree is no longer valid.
nsCOMPtr<nsIAccessibilityService> accService =
do_GetService("@mozilla.org/accessibilityService;1");
if (accService) {
accService->InvalidateSubtreeFor(mPresShell, aContent, event);
}
}
#endif
nsresult
nsCSSFrameConstructor::ProcessRestyledFrames(nsStyleChangeList& aChangeList)
{
@ -10550,12 +10510,6 @@ nsCSSFrameConstructor::RestyleElement(nsIContent *aContent,
nsIFrame *aPrimaryFrame,
nsChangeHint aMinHint)
{
#ifdef ACCESSIBILITY
nsIAtom *prevRenderedFrameType = nsnull;
if (mPresShell->IsAccessibilityActive()) {
prevRenderedFrameType = GetRenderedFrameType(aPrimaryFrame);
}
#endif
if (aMinHint & nsChangeHint_ReconstructFrame) {
RecreateFramesForContent(aContent);
} else if (aPrimaryFrame) {
@ -10576,14 +10530,6 @@ nsCSSFrameConstructor::RestyleElement(nsIContent *aContent,
// no frames, reconstruct for content
MaybeRecreateFramesForContent(aContent);
}
#ifdef ACCESSIBILITY
if (mPresShell->IsAccessibilityActive()) {
nsIFrame *frame = mPresShell->GetPrimaryFrameFor(aContent);
NotifyAccessibleChange(prevRenderedFrameType,
GetRenderedFrameType(frame),
aContent);
}
#endif
}
void
@ -11723,6 +11669,27 @@ nsCSSFrameConstructor::RecreateFramesForContent(nsIContent* aContent)
ReconstructDocElementHierarchy();
}
#ifdef ACCESSIBILITY
if (mPresShell->IsAccessibilityActive()) {
PRUint32 event;
if (frame) {
nsIFrame *newFrame = mPresShell->GetPrimaryFrameFor(aContent);
event = newFrame ? nsIAccessibleEvent::EVENT_REORDER : nsIAccessibleEvent::EVENT_HIDE;
}
else {
event = nsIAccessibleEvent::EVENT_SHOW;
}
// A significant enough change occured that this part
// of the accessible tree is no longer valid.
nsCOMPtr<nsIAccessibilityService> accService =
do_GetService("@mozilla.org/accessibilityService;1");
if (accService) {
accService->InvalidateSubtreeFor(mPresShell, aContent, event);
}
}
#endif
return rv;
}

View File

@ -1026,20 +1026,6 @@ public:
friend class nsFrameConstructorState;
private:
#ifdef ACCESSIBILITY
// If the frame is visible, return the frame type
// If the frame is invisible, return nsnull
nsIAtom *GetRenderedFrameType(nsIFrame *aFrame);
// Using the rendered frame type from GetRenderedFrameType(), which is nsnull
// for invisible frames, compare the previous rendering and new rendering, to
// determine if the tree of accessibility objects may change. If it might,
// notify the accessibility module of the change, and whether it is a generic
// change, something is being made visible or something is being made hidden.
void NotifyAccessibleChange(nsIAtom *aPreviousFrameType, nsIAtom *aFrameType,
nsIContent *aContent);
#endif
nsIDocument* mDocument; // Weak ref
nsIPresShell* mPresShell; // Weak ref

View File

@ -93,6 +93,10 @@
#include "imgIRequest.h"
#include "nsFrameManager.h"
#ifdef ACCESSIBILITY
#include "nsIAccessibilityService.h"
#include "nsIAccessibleEvent.h"
#endif
#ifdef DEBUG
//#define NOISY_DEBUG
@ -1016,6 +1020,13 @@ nsFrameManager::ReResolveStyleContext(nsPresContext *aPresContext,
nsChangeHint assumeDifferenceHint = NS_STYLE_HINT_NONE;
nsStyleContext* oldContext = aFrame->GetStyleContext();
nsStyleSet* styleSet = aPresContext->StyleSet();
#ifdef ACCESSIBILITY
PRBool isAccessibilityActive = mPresShell->IsAccessibilityActive();
PRBool isVisible;
if (isAccessibilityActive) {
isVisible = aFrame->GetStyleVisibility()->IsVisible();
}
#endif
if (oldContext) {
oldContext->AddRef();
@ -1335,6 +1346,21 @@ nsFrameManager::ReResolveStyleContext(nsPresContext *aPresContext,
newContext->Release();
}
if (isAccessibilityActive &&
aFrame->GetStyleVisibility()->IsVisible() != isVisible) {
// XXX Visibility does not affect descendents with visibility set
// Work on a separate, accurate mechanism for dealing with visibility changes.
// A significant enough change occured that this part
// of the accessible tree is no longer valid.
nsCOMPtr<nsIAccessibilityService> accService =
do_GetService("@mozilla.org/accessibilityService;1");
if (accService) {
accService->InvalidateSubtreeFor(mPresShell, aFrame->GetContent(),
isVisible ? nsIAccessibleEvent::EVENT_HIDE :
nsIAccessibleEvent::EVENT_SHOW);
}
}
return aMinChange;
}