From bca7e7be13533bdec9342b1f7f57f65eb7611029 Mon Sep 17 00:00:00 2001 From: Olli Pettay Date: Wed, 25 Feb 2015 14:18:17 +0200 Subject: [PATCH] Bug 1135908 - [E10s] Proxy for Character/SelectionCount(), r=tbsaunde --- accessible/atk/nsMaiInterfaceText.cpp | 33 ++++++++++++++++++--------- accessible/ipc/DocAccessibleChild.cpp | 16 +++++++++++++ accessible/ipc/DocAccessibleChild.h | 6 +++++ accessible/ipc/PDocAccessible.ipdl | 2 ++ accessible/ipc/ProxyAccessible.cpp | 16 +++++++++++++ accessible/ipc/ProxyAccessible.h | 3 +++ 6 files changed, 65 insertions(+), 11 deletions(-) diff --git a/accessible/atk/nsMaiInterfaceText.cpp b/accessible/atk/nsMaiInterfaceText.cpp index ee3f995018c..3468fc1ea1d 100644 --- a/accessible/atk/nsMaiInterfaceText.cpp +++ b/accessible/atk/nsMaiInterfaceText.cpp @@ -330,12 +330,17 @@ static gint getCharacterCountCB(AtkText *aText) { AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText)); - if (!accWrap) - return 0; + if (accWrap) { + HyperTextAccessible* textAcc = accWrap->AsHyperText(); + return + textAcc->IsDefunct() ? 0 : static_cast(textAcc->CharacterCount()); + } - HyperTextAccessible* textAcc = accWrap->AsHyperText(); - return textAcc->IsDefunct() ? - 0 : static_cast(textAcc->CharacterCount()); + if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aText))) { + return proxy->CharacterCount(); + } + + return 0; } static gint @@ -362,14 +367,20 @@ static gint getTextSelectionCountCB(AtkText *aText) { AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText)); - if (!accWrap) - return 0; + if (accWrap) { + HyperTextAccessible* text = accWrap->AsHyperText(); + if (!text || !text->IsTextRole()) { + return 0; + } - HyperTextAccessible* text = accWrap->AsHyperText(); - if (!text || !text->IsTextRole()) - return 0; + return text->SelectionCount(); + } - return text->SelectionCount(); + if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aText))) { + return proxy->SelectionCount(); + } + + return 0; } static gchar* diff --git a/accessible/ipc/DocAccessibleChild.cpp b/accessible/ipc/DocAccessibleChild.cpp index af0f890e3be..2d7b413c604 100644 --- a/accessible/ipc/DocAccessibleChild.cpp +++ b/accessible/ipc/DocAccessibleChild.cpp @@ -207,6 +207,22 @@ DocAccessibleChild::RecvRelations(const uint64_t& aID, return true; } +bool +DocAccessibleChild::RecvCharacterCount(const uint64_t& aID, int32_t* aCount) +{ + HyperTextAccessible* acc = IdToHyperTextAccessible(aID); + *aCount = acc ? acc->CharacterCount() : 0; + return true; +} + +bool +DocAccessibleChild::RecvSelectionCount(const uint64_t& aID, int32_t* aCount) +{ + HyperTextAccessible* acc = IdToHyperTextAccessible(aID); + *aCount = acc ? acc->SelectionCount() : 0; + return true; +} + bool DocAccessibleChild::RecvTextSubstring(const uint64_t& aID, const int32_t& aStartOffset, diff --git a/accessible/ipc/DocAccessibleChild.h b/accessible/ipc/DocAccessibleChild.h index a9626bbd504..3b798f69980 100644 --- a/accessible/ipc/DocAccessibleChild.h +++ b/accessible/ipc/DocAccessibleChild.h @@ -63,6 +63,12 @@ public: virtual bool RecvAttributes(const uint64_t& aID, nsTArray *aAttributes) MOZ_OVERRIDE; + + virtual bool RecvCharacterCount(const uint64_t& aID, int32_t* aCount) + MOZ_OVERRIDE; + virtual bool RecvSelectionCount(const uint64_t& aID, int32_t* aCount) + MOZ_OVERRIDE; + virtual bool RecvTextSubstring(const uint64_t& aID, const int32_t& aStartOffset, const int32_t& aEndOffset, nsString* aText) diff --git a/accessible/ipc/PDocAccessible.ipdl b/accessible/ipc/PDocAccessible.ipdl index 7464787cd25..21be62a0922 100644 --- a/accessible/ipc/PDocAccessible.ipdl +++ b/accessible/ipc/PDocAccessible.ipdl @@ -65,6 +65,8 @@ child: // AccessibleText // TextSubstring is getText in IDL. + prio(high) sync CharacterCount(uint64_t aID) returns(int32_t aCount); + prio(high) sync SelectionCount(uint64_t aID) returns(int32_t aCount); prio(high) sync TextSubstring(uint64_t aID, int32_t aStartOffset, int32_t aEndOffset) returns(nsString aText); prio(high) sync GetTextAfterOffset(uint64_t aID, int32_t aOffset, int32_t aBoundaryType) diff --git a/accessible/ipc/ProxyAccessible.cpp b/accessible/ipc/ProxyAccessible.cpp index 8dd034c5057..3ef225ff06c 100644 --- a/accessible/ipc/ProxyAccessible.cpp +++ b/accessible/ipc/ProxyAccessible.cpp @@ -149,6 +149,22 @@ ProxyAccessible::Relations(nsTArray* aTypes, } } +int32_t +ProxyAccessible::CharacterCount() +{ + int32_t count = 0; + unused << mDoc->SendCharacterCount(mID, &count); + return count; +} + +int32_t +ProxyAccessible::SelectionCount() +{ + int32_t count = 0; + unused << mDoc->SendSelectionCount(mID, &count); + return count; +} + void ProxyAccessible::TextSubstring(int32_t aStartOffset, int32_t aEndOfset, nsString& aText) const diff --git a/accessible/ipc/ProxyAccessible.h b/accessible/ipc/ProxyAccessible.h index 83fae3b8892..7c89f3dd852 100644 --- a/accessible/ipc/ProxyAccessible.h +++ b/accessible/ipc/ProxyAccessible.h @@ -99,6 +99,9 @@ public: void Relations(nsTArray* aTypes, nsTArray>* aTargetSets) const; + int32_t CharacterCount(); + int32_t SelectionCount(); + /** * Get the text between the given offsets. */