diff --git a/accessible/atk/nsMaiInterfaceEditableText.cpp b/accessible/atk/nsMaiInterfaceEditableText.cpp index 6f76940a4efc..18a1b6f42293 100644 --- a/accessible/atk/nsMaiInterfaceEditableText.cpp +++ b/accessible/atk/nsMaiInterfaceEditableText.cpp @@ -9,7 +9,7 @@ #include "Accessible-inl.h" #include "HyperTextAccessible-inl.h" #include "nsMai.h" - +#include "ProxyAccessible.h" #include "nsString.h" #include "mozilla/Likely.h" @@ -20,15 +20,18 @@ static void setTextContentsCB(AtkEditableText *aText, const gchar *aString) { AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText)); - if (!accWrap) - return; + if (accWrap) { + HyperTextAccessible* text = accWrap->AsHyperText(); + if (!text || !text->IsTextRole()) { + return; + } - HyperTextAccessible* text = accWrap->AsHyperText(); - if (!text || !text->IsTextRole()) - return; - - NS_ConvertUTF8toUTF16 strContent(aString); - text->ReplaceText(strContent); + NS_ConvertUTF8toUTF16 strContent(aString); + text->ReplaceText(strContent); + } else if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aText))) { + NS_ConvertUTF8toUTF16 strContent(aString); + proxy->ReplaceText(strContent); + } } static void @@ -36,71 +39,82 @@ insertTextCB(AtkEditableText *aText, const gchar *aString, gint aLength, gint *aPosition) { AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText)); - if (!accWrap) - return; + if (accWrap) { + HyperTextAccessible* text = accWrap->AsHyperText(); + if (!text || !text->IsTextRole()) { + return; + } - HyperTextAccessible* text = accWrap->AsHyperText(); - if (!text || !text->IsTextRole()) - return; - - NS_ConvertUTF8toUTF16 strContent(aString, aLength); - text->InsertText(strContent, *aPosition); + NS_ConvertUTF8toUTF16 strContent(aString); + text->InsertText(strContent, *aPosition); + } else if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aText))) { + NS_ConvertUTF8toUTF16 strContent(aString); + proxy->InsertText(strContent, *aPosition); + } } static void copyTextCB(AtkEditableText *aText, gint aStartPos, gint aEndPos) { AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText)); - if (!accWrap) - return; + if (accWrap) { + HyperTextAccessible* text = accWrap->AsHyperText(); + if (!text || !text->IsTextRole()) { + return; + } - HyperTextAccessible* text = accWrap->AsHyperText(); - if (!text || !text->IsTextRole()) - return; - - text->CopyText(aStartPos, aEndPos); + text->CopyText(aStartPos, aEndPos); + } else if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aText))) { + proxy->CopyText(aStartPos, aEndPos); + } } static void cutTextCB(AtkEditableText *aText, gint aStartPos, gint aEndPos) { AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText)); - if (!accWrap) - return; + if (accWrap) { + HyperTextAccessible* text = accWrap->AsHyperText(); + if (!text || !text->IsTextRole()) { + return; + } - HyperTextAccessible* text = accWrap->AsHyperText(); - if (!text || !text->IsTextRole()) - return; - - text->CutText(aStartPos, aEndPos); + text->CutText(aStartPos, aEndPos); + } else if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aText))) { + proxy->CutText(aStartPos, aEndPos); + } } static void deleteTextCB(AtkEditableText *aText, gint aStartPos, gint aEndPos) { AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText)); - if (!accWrap) - return; + if (accWrap) { + HyperTextAccessible* text = accWrap->AsHyperText(); + if (!text || !text->IsTextRole()) { + return; + } - HyperTextAccessible* text = accWrap->AsHyperText(); - if (!text || !text->IsTextRole()) - return; - - text->DeleteText(aStartPos, aEndPos); + text->DeleteText(aStartPos, aEndPos); + } else if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aText))) { + proxy->DeleteText(aStartPos, aEndPos); + } } static void pasteTextCB(AtkEditableText *aText, gint aPosition) { AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText)); - if (!accWrap) - return; + if (accWrap) { + HyperTextAccessible* text = accWrap->AsHyperText(); + if (!text || !text->IsTextRole()) { + return; + } - HyperTextAccessible* text = accWrap->AsHyperText(); - if (!text || !text->IsTextRole()) - return; - - text->PasteText(aPosition); + text->PasteText(aPosition); + } else if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aText))) { + proxy->PasteText(aPosition); + } } } diff --git a/accessible/ipc/DocAccessibleChild.cpp b/accessible/ipc/DocAccessibleChild.cpp index 0d6f4ea58587..949d9b7be67c 100644 --- a/accessible/ipc/DocAccessibleChild.cpp +++ b/accessible/ipc/DocAccessibleChild.cpp @@ -508,5 +508,81 @@ DocAccessibleChild::RecvScrollSubstringToPoint(const uint64_t& aID, } +bool +DocAccessibleChild::RecvReplaceText(const uint64_t& aID, + const nsString& aText) +{ + HyperTextAccessible* acc = IdToHyperTextAccessible(aID); + if (acc && acc->IsTextRole()) { + acc->ReplaceText(aText); + } + + return true; +} + +bool +DocAccessibleChild::RecvInsertText(const uint64_t& aID, + const nsString& aText, + const int32_t& aPosition) +{ + HyperTextAccessible* acc = IdToHyperTextAccessible(aID); + if (acc && acc->IsTextRole()) { + acc->InsertText(aText, aPosition); + } + + return true; +} + +bool +DocAccessibleChild::RecvCopyText(const uint64_t& aID, + const int32_t& aStartPos, + const int32_t& aEndPos) +{ + HyperTextAccessible* acc = IdToHyperTextAccessible(aID); + if (acc && acc->IsTextRole()) { + acc->CopyText(aStartPos, aEndPos); + } + + return true; +} + +bool +DocAccessibleChild::RecvCutText(const uint64_t& aID, + const int32_t& aStartPos, + const int32_t& aEndPos) +{ + HyperTextAccessible* acc = IdToHyperTextAccessible(aID); + if (acc && acc->IsTextRole()) { + acc->CutText(aStartPos, aEndPos); + } + + return true; +} + +bool +DocAccessibleChild::RecvDeleteText(const uint64_t& aID, + const int32_t& aStartPos, + const int32_t& aEndPos) +{ + HyperTextAccessible* acc = IdToHyperTextAccessible(aID); + if (acc && acc->IsTextRole()) { + acc->DeleteText(aStartPos, aEndPos); + } + + return true; +} + +bool +DocAccessibleChild::RecvPasteText(const uint64_t& aID, + const int32_t& aPosition) +{ + HyperTextAccessible* acc = IdToHyperTextAccessible(aID); + if (acc && acc->IsTextRole()) { + acc->PasteText(aPosition); + } + + return true; +} + } } diff --git a/accessible/ipc/DocAccessibleChild.h b/accessible/ipc/DocAccessibleChild.h index dc6c3a1df6fa..a27c9ca9a700 100644 --- a/accessible/ipc/DocAccessibleChild.h +++ b/accessible/ipc/DocAccessibleChild.h @@ -162,6 +162,28 @@ public: const int32_t& aX, const int32_t& aY) MOZ_OVERRIDE; + virtual bool RecvReplaceText(const uint64_t& aID, + const nsString& aText); + + virtual bool RecvInsertText(const uint64_t& aID, + const nsString& aText, + const int32_t& aPosition); + + virtual bool RecvCopyText(const uint64_t& aID, + const int32_t& aStartPos, + const int32_t& aEndPos); + + virtual bool RecvCutText(const uint64_t& aID, + const int32_t& aStartPos, + const int32_t& aEndPos); + + virtual bool RecvDeleteText(const uint64_t& aID, + const int32_t& aStartPos, + const int32_t& aEndPos); + + virtual bool RecvPasteText(const uint64_t& aID, + const int32_t& aPosition); + private: bool PersistentPropertiesToArray(nsIPersistentProperties* aProps, nsTArray* aAttributes); diff --git a/accessible/ipc/PDocAccessible.ipdl b/accessible/ipc/PDocAccessible.ipdl index 3bf0c1cf9a44..1237b10ecf53 100644 --- a/accessible/ipc/PDocAccessible.ipdl +++ b/accessible/ipc/PDocAccessible.ipdl @@ -114,6 +114,13 @@ child: int32_t aEndOffset, uint32_t aCoordinateType, int32_t aX, int32_t aY); + + prio(high) sync ReplaceText(uint64_t aID, nsString aText); + prio(high) sync InsertText(uint64_t aID, nsString aText, int32_t aPosition); + prio(high) sync CopyText(uint64_t aID, int32_t aStartPos, int32_t aEndPos); + prio(high) sync CutText(uint64_t aID, int32_t aStartPos, int32_t aEndPos); + prio(high) sync DeleteText(uint64_t aID, int32_t aStartPos, int32_t aEndPos); + prio(high) sync PasteText(uint64_t aID, int32_t aPosition); }; } diff --git a/accessible/ipc/ProxyAccessible.cpp b/accessible/ipc/ProxyAccessible.cpp index 259eafe55d1c..2190a0e79499 100644 --- a/accessible/ipc/ProxyAccessible.cpp +++ b/accessible/ipc/ProxyAccessible.cpp @@ -327,5 +327,41 @@ ProxyAccessible::ScrollSubstringToPoint(int32_t aStartOffset, aCoordinateType, aX, aY); } +void +ProxyAccessible::ReplaceText(const nsString& aText) +{ + unused << mDoc->SendReplaceText(mID, aText); +} + +void +ProxyAccessible::InsertText(const nsString& aText, int32_t aPosition) +{ + unused << mDoc->SendInsertText(mID, aText, aPosition); +} + +void +ProxyAccessible::CopyText(int32_t aStartPos, int32_t aEndPos) +{ + unused << mDoc->SendCopyText(mID, aStartPos, aEndPos); +} + +void +ProxyAccessible::CutText(int32_t aStartPos, int32_t aEndPos) +{ + unused << mDoc->SendCutText(mID, aStartPos, aEndPos); +} + +void +ProxyAccessible::DeleteText(int32_t aStartPos, int32_t aEndPos) +{ + unused << mDoc->SendDeleteText(mID, aStartPos, aEndPos); +} + +void +ProxyAccessible::PasteText(int32_t aPosition) +{ + unused << mDoc->SendPasteText(mID, aPosition); +} + } } diff --git a/accessible/ipc/ProxyAccessible.h b/accessible/ipc/ProxyAccessible.h index fa4e39014316..294922e84bf0 100644 --- a/accessible/ipc/ProxyAccessible.h +++ b/accessible/ipc/ProxyAccessible.h @@ -162,6 +162,18 @@ public: uint32_t aCoordinateType, int32_t aX, int32_t aY); + void ReplaceText(const nsString& aText); + + void InsertText(const nsString& aText, int32_t aPosition); + + void CopyText(int32_t aStartPos, int32_t aEndPos); + + void CutText(int32_t aStartPos, int32_t aEndPos); + + void DeleteText(int32_t aStartPos, int32_t aEndPos); + + void PasteText(int32_t aPosition); + /** * Allow the platform to store a pointers worth of data on us. */