mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 03:15:11 +00:00
Bug 379366 - reimplement IAccessibleText::newText/oldText, r=aaronlev, bent.mozilla, sr=neil
This commit is contained in:
parent
01725954b0
commit
12a7e11ca9
@ -65,6 +65,8 @@ LPFNGETGUITHREADINFO nsAccessNodeWrap::gmGetGUIThreadInfo = nsnull;
|
||||
|
||||
PRBool nsAccessNodeWrap::gIsEnumVariantSupportDisabled = 0;
|
||||
|
||||
nsIAccessibleTextChangeEvent *nsAccessNodeWrap::gTextEvent = nsnull;
|
||||
|
||||
/* For documentation of the accessibility architecture,
|
||||
* see http://lxr.mozilla.org/seamonkey/source/accessible/accessible-docs.html
|
||||
*/
|
||||
@ -539,6 +541,8 @@ void nsAccessNodeWrap::InitAccessibility()
|
||||
|
||||
void nsAccessNodeWrap::ShutdownAccessibility()
|
||||
{
|
||||
NS_IF_RELEASE(gTextEvent);
|
||||
|
||||
if (!gIsAccessibilityActive) {
|
||||
return;
|
||||
}
|
||||
|
@ -45,6 +45,7 @@
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIAccessible.h"
|
||||
#include "nsIAccessibleEvent.h"
|
||||
#include "nsIWinAccessNode.h"
|
||||
#include "ISimpleDOMNode.h"
|
||||
#include "nsIDOMElement.h"
|
||||
@ -143,6 +144,12 @@ class nsAccessNodeWrap : public nsAccessNode,
|
||||
ISimpleDOMNode* MakeAccessNode(nsIDOMNode *node);
|
||||
|
||||
static PRBool gIsEnumVariantSupportDisabled;
|
||||
|
||||
/**
|
||||
* It is used in nsHyperTextAccessibleWrap for IA2::newText/oldText
|
||||
* implementation.
|
||||
*/
|
||||
static nsIAccessibleTextChangeEvent *gTextEvent;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -40,11 +40,6 @@
|
||||
|
||||
#include "nsHyperTextAccessibleWrap.h"
|
||||
|
||||
nsString nsHyperTextAccessibleWrap::sText;
|
||||
PRInt32 nsHyperTextAccessibleWrap::sOffset = 0;
|
||||
PRUint32 nsHyperTextAccessibleWrap::sLength = 0;
|
||||
PRBool nsHyperTextAccessibleWrap::sIsInserted = PR_FALSE;
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED0(nsHyperTextAccessibleWrap,
|
||||
nsHyperTextAccessible)
|
||||
|
||||
@ -60,14 +55,22 @@ nsHyperTextAccessibleWrap::FireAccessibleEvent(nsIAccessibleEvent *aEvent)
|
||||
aEvent->GetEventType(&eventType);
|
||||
|
||||
if (eventType == nsIAccessibleEvent::EVENT_TEXT_CHANGED) {
|
||||
nsCOMPtr<nsIAccessibleTextChangeEvent> textEvent(do_QueryInterface(aEvent));
|
||||
NS_ENSURE_STATE(textEvent);
|
||||
nsCOMPtr<nsIAccessible> accessible;
|
||||
aEvent->GetAccessible(getter_AddRefs(accessible));
|
||||
if (accessible) {
|
||||
nsCOMPtr<nsIWinAccessNode> winAccessNode(do_QueryInterface(accessible));
|
||||
if (winAccessNode) {
|
||||
void *instancePtr = NULL;
|
||||
nsresult rv = winAccessNode->QueryNativeInterface(IID_IAccessibleText,
|
||||
&instancePtr);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
NS_IF_RELEASE(gTextEvent);
|
||||
|
||||
textEvent->GetStart(&sOffset);
|
||||
textEvent->GetLength(&sLength);
|
||||
textEvent->IsInserted(&sIsInserted);
|
||||
|
||||
GetText(sOffset, sOffset + sLength, sText);
|
||||
CallQueryInterface(aEvent, &gTextEvent);
|
||||
(NS_STATIC_CAST(IUnknown*, instancePtr))->Release();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nsHyperTextAccessible::FireAccessibleEvent(aEvent);
|
||||
@ -79,15 +82,33 @@ nsHyperTextAccessibleWrap::GetModifiedText(PRBool aGetInsertedText,
|
||||
PRUint32 *aStartOffset,
|
||||
PRUint32 *aEndOffset)
|
||||
{
|
||||
if ((aGetInsertedText && sIsInserted) || (!aGetInsertedText && !sIsInserted)) {
|
||||
aText.Assign(sText);
|
||||
*aStartOffset = sOffset;
|
||||
*aEndOffset = sOffset + sLength;
|
||||
} else {
|
||||
aText.Truncate();
|
||||
*aStartOffset = 0;
|
||||
*aEndOffset = 0;
|
||||
}
|
||||
aText.Truncate();
|
||||
*aStartOffset = 0;
|
||||
*aEndOffset = 0;
|
||||
|
||||
if (!gTextEvent)
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsIAccessible> targetAcc;
|
||||
gTextEvent->GetAccessible(getter_AddRefs(targetAcc));
|
||||
if (targetAcc != this)
|
||||
return NS_OK;
|
||||
|
||||
PRBool isInserted;
|
||||
gTextEvent->IsInserted(&isInserted);
|
||||
|
||||
if (aGetInsertedText != isInserted)
|
||||
return NS_OK;
|
||||
|
||||
nsAutoString text;
|
||||
PRInt32 offset;
|
||||
PRUint32 length;
|
||||
|
||||
gTextEvent->GetStart(&offset);
|
||||
gTextEvent->GetLength(&length);
|
||||
GetText(offset, offset + length, aText);
|
||||
*aStartOffset = offset;
|
||||
*aEndOffset = offset + length;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -62,17 +62,10 @@ public:
|
||||
|
||||
// nsIAccessible
|
||||
NS_IMETHOD FireAccessibleEvent(nsIAccessibleEvent *aEvent);
|
||||
|
||||
protected:
|
||||
virtual nsresult GetModifiedText(PRBool aGetInsertedText, nsAString& aText,
|
||||
PRUint32 *aStartOffset,
|
||||
PRUint32 *aEndOffset);
|
||||
|
||||
private:
|
||||
static nsString sText;
|
||||
static PRInt32 sOffset;
|
||||
static PRUint32 sLength;
|
||||
static PRBool sIsInserted;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user