Bug 160793. Active Accessibility: support broken images. r=kyle, sr=hewitt

This commit is contained in:
aaronl%netscape.com 2002-08-10 07:59:44 +00:00
parent 322da773fb
commit c8215a38ee
5 changed files with 79 additions and 1 deletions

View File

@ -1335,7 +1335,7 @@ NS_IMETHODIMP nsAccessible::AppendFlatStringFromContentNode(nsIContent *aContent
elt->GetAttribute(NS_LITERAL_STRING("alt"), textEquivalent);
if (textEquivalent.IsEmpty())
elt->GetAttribute(NS_LITERAL_STRING("title"), textEquivalent);
if (imageContent) {
if (textEquivalent.IsEmpty() && imageContent) {
nsCOMPtr<nsIPresShell> presShell(do_QueryReferent(mPresShell));
nsCOMPtr<nsIDOMNode> imageNode(do_QueryInterface(aContent));
if (imageNode && presShell)

View File

@ -46,6 +46,10 @@
#include "nsAbsoluteContainingBlock.h"
#include "nsLayoutAtoms.h"
#include "nsReflowPath.h"
#ifdef ACCESSIBILITY
#include "nsIServiceManager.h"
#include "nsIAccessibilityService.h"
#endif
#ifdef DEBUG
#undef NOISY_PUSHING
@ -878,6 +882,29 @@ nsInlineFrame::GetSkipSides() const
return skip;
}
#ifdef ACCESSIBILITY
NS_IMETHODIMP nsInlineFrame::GetAccessible(nsIAccessible** aAccessible)
{
// Broken image accessibles are created here, because layout
// replaces the image or image control frame with an inline frame
*aAccessible = nsnull;
nsCOMPtr<nsIAtom> tagAtom;
mContent->GetTag(*getter_AddRefs(tagAtom));
if (tagAtom == nsHTMLAtoms::img || tagAtom == nsHTMLAtoms::input) {
// Only get accessibility service if we're going to use it
nsCOMPtr<nsIAccessibilityService> accService(do_GetService("@mozilla.org/accessibilityService;1"));
if (!accService)
return NS_ERROR_FAILURE;
if (tagAtom == nsHTMLAtoms::input) // Broken <input type=image ... />
return accService->CreateHTML4ButtonAccessible(NS_STATIC_CAST(nsIFrame*, this), aAccessible);
// Create accessible for broken <img>
return accService->CreateHTMLImageAccessible(NS_STATIC_CAST(nsIFrame*, this), aAccessible);
}
return NS_ERROR_FAILURE;
}
#endif
//////////////////////////////////////////////////////////////////////
// nsLineFrame implementation

View File

@ -50,6 +50,14 @@ class nsAnonymousBlockFrame;
#define NS_INLINE_FRAME_CONTAINS_PERCENT_AWARE_CHILD 0x00100000
// NS_INLINE_FRAME_HARD_TEXT_OFFSETS is used for access keys, where what
// would normally be 1 text frame is split into 3 sets of an inline parent
// and text child (the pre access key text, the underlined key text, and
// the post access key text). The offsets of the 3 text frame children
// are set in nsCSSFrameConstructor
#define NS_INLINE_FRAME_HARD_TEXT_OFFSETS 0x00200000
/**
* Inline frame class.
*
@ -85,6 +93,10 @@ public:
nsIFrame* aNewFrame);
NS_IMETHOD ReflowDirtyChild(nsIPresShell* aPresShell, nsIFrame* aChild);
#ifdef ACCESSIBILITY
NS_IMETHODIMP GetAccessible(nsIAccessible** aAccessible);
#endif
#ifdef DEBUG
NS_IMETHOD GetFrameName(nsAString& aResult) const;
#endif

View File

@ -46,6 +46,10 @@
#include "nsAbsoluteContainingBlock.h"
#include "nsLayoutAtoms.h"
#include "nsReflowPath.h"
#ifdef ACCESSIBILITY
#include "nsIServiceManager.h"
#include "nsIAccessibilityService.h"
#endif
#ifdef DEBUG
#undef NOISY_PUSHING
@ -878,6 +882,29 @@ nsInlineFrame::GetSkipSides() const
return skip;
}
#ifdef ACCESSIBILITY
NS_IMETHODIMP nsInlineFrame::GetAccessible(nsIAccessible** aAccessible)
{
// Broken image accessibles are created here, because layout
// replaces the image or image control frame with an inline frame
*aAccessible = nsnull;
nsCOMPtr<nsIAtom> tagAtom;
mContent->GetTag(*getter_AddRefs(tagAtom));
if (tagAtom == nsHTMLAtoms::img || tagAtom == nsHTMLAtoms::input) {
// Only get accessibility service if we're going to use it
nsCOMPtr<nsIAccessibilityService> accService(do_GetService("@mozilla.org/accessibilityService;1"));
if (!accService)
return NS_ERROR_FAILURE;
if (tagAtom == nsHTMLAtoms::input) // Broken <input type=image ... />
return accService->CreateHTML4ButtonAccessible(NS_STATIC_CAST(nsIFrame*, this), aAccessible);
// Create accessible for broken <img>
return accService->CreateHTMLImageAccessible(NS_STATIC_CAST(nsIFrame*, this), aAccessible);
}
return NS_ERROR_FAILURE;
}
#endif
//////////////////////////////////////////////////////////////////////
// nsLineFrame implementation

View File

@ -50,6 +50,14 @@ class nsAnonymousBlockFrame;
#define NS_INLINE_FRAME_CONTAINS_PERCENT_AWARE_CHILD 0x00100000
// NS_INLINE_FRAME_HARD_TEXT_OFFSETS is used for access keys, where what
// would normally be 1 text frame is split into 3 sets of an inline parent
// and text child (the pre access key text, the underlined key text, and
// the post access key text). The offsets of the 3 text frame children
// are set in nsCSSFrameConstructor
#define NS_INLINE_FRAME_HARD_TEXT_OFFSETS 0x00200000
/**
* Inline frame class.
*
@ -85,6 +93,10 @@ public:
nsIFrame* aNewFrame);
NS_IMETHOD ReflowDirtyChild(nsIPresShell* aPresShell, nsIFrame* aChild);
#ifdef ACCESSIBILITY
NS_IMETHODIMP GetAccessible(nsIAccessible** aAccessible);
#endif
#ifdef DEBUG
NS_IMETHOD GetFrameName(nsAString& aResult) const;
#endif