зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1835162 - Use new async clipboard IPC methods in Android. r=Jamie
Differential Revision: https://phabricator.services.mozilla.com/D179159
This commit is contained in:
Родитель
b8cb45e0e0
Коммит
893830a805
|
@ -384,52 +384,6 @@ void AccessibleWrap::NavigateText(int32_t aGranularity, int32_t aStartOffset,
|
|||
}
|
||||
}
|
||||
|
||||
void AccessibleWrap::SetSelection(int32_t aStart, int32_t aEnd) {
|
||||
if (HyperTextAccessible* textAcc = AsHyperText()) {
|
||||
if (aStart == aEnd) {
|
||||
textAcc->SetCaretOffset(aStart);
|
||||
} else {
|
||||
textAcc->SetSelectionBoundsAt(0, aStart, aEnd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AccessibleWrap::Cut() {
|
||||
if ((State() & states::EDITABLE) == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (HyperTextAccessible* textAcc = AsHyperText()) {
|
||||
int32_t startSel, endSel;
|
||||
GetSelectionOrCaret(&startSel, &endSel);
|
||||
textAcc->CutText(startSel, endSel);
|
||||
}
|
||||
}
|
||||
|
||||
void AccessibleWrap::Copy() {
|
||||
if (HyperTextAccessible* textAcc = AsHyperText()) {
|
||||
int32_t startSel, endSel;
|
||||
GetSelectionOrCaret(&startSel, &endSel);
|
||||
textAcc->CopyText(startSel, endSel);
|
||||
}
|
||||
}
|
||||
|
||||
void AccessibleWrap::Paste() {
|
||||
if ((State() & states::EDITABLE) == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsHyperText()) {
|
||||
RefPtr<HyperTextAccessible> textAcc = AsHyperText();
|
||||
int32_t startSel, endSel;
|
||||
GetSelectionOrCaret(&startSel, &endSel);
|
||||
if (startSel != endSel) {
|
||||
textAcc->DeleteText(startSel, endSel);
|
||||
}
|
||||
textAcc->PasteText(startSel);
|
||||
}
|
||||
}
|
||||
|
||||
void AccessibleWrap::GetSelectionOrCaret(int32_t* aStartOffset,
|
||||
int32_t* aEndOffset) {
|
||||
*aStartOffset = *aEndOffset = -1;
|
||||
|
|
|
@ -33,15 +33,6 @@ class AccessibleWrap : public LocalAccessible {
|
|||
virtual void NavigateText(int32_t aGranularity, int32_t aStartOffset,
|
||||
int32_t aEndOffset, bool aForward, bool aSelect);
|
||||
|
||||
virtual void SetSelection(int32_t aStart, int32_t aEnd);
|
||||
|
||||
virtual void Cut();
|
||||
|
||||
virtual void Copy();
|
||||
|
||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY
|
||||
virtual void Paste();
|
||||
|
||||
void ExploreByTouch(float aX, float aY);
|
||||
|
||||
static uint32_t GetFlags(role aRole, uint64_t aState, uint8_t aActionCount);
|
||||
|
|
|
@ -12,8 +12,6 @@
|
|||
#include "nsThreadUtils.h"
|
||||
#include "AccAttributes.h"
|
||||
#include "AccessibilityEvent.h"
|
||||
#include "HyperTextAccessible.h"
|
||||
#include "HyperTextAccessible-inl.h"
|
||||
#include "JavaBuiltins.h"
|
||||
#include "RootAccessibleWrap.h"
|
||||
#include "nsAccessibilityService.h"
|
||||
|
@ -29,6 +27,7 @@
|
|||
#include "mozilla/a11y/DocAccessibleParent.h"
|
||||
#include "mozilla/a11y/DocAccessiblePlatformExtParent.h"
|
||||
#include "mozilla/a11y/DocManager.h"
|
||||
#include "mozilla/a11y/HyperTextAccessibleBase.h"
|
||||
#include "mozilla/jni/GeckoBundleUtils.h"
|
||||
#include "mozilla/jni/NativesInlines.h"
|
||||
#include "mozilla/widget/GeckoViewSupport.h"
|
||||
|
@ -234,21 +233,58 @@ void SessionAccessibility::NavigateText(int32_t aID, int32_t aGranularity,
|
|||
aEndOffset, aForward, aSelect);
|
||||
}
|
||||
|
||||
static void GetSelectionOrCaret(HyperTextAccessibleBase* aHyperTextAcc,
|
||||
int32_t* aStartOffset, int32_t* aEndOffset) {
|
||||
if (!aHyperTextAcc->SelectionBoundsAt(0, aStartOffset, aEndOffset)) {
|
||||
*aStartOffset = *aEndOffset = aHyperTextAcc->CaretOffset();
|
||||
}
|
||||
}
|
||||
|
||||
void SessionAccessibility::SetSelection(int32_t aID, int32_t aStart,
|
||||
int32_t aEnd) {
|
||||
FORWARD_EXT_ACTION_TO_ACCESSIBLE(SetSelection, aStart, aEnd);
|
||||
if (Accessible* acc = GetAccessibleByID(aID)) {
|
||||
if (auto* textAcc = acc->AsHyperTextBase()) {
|
||||
if (aStart == aEnd) {
|
||||
textAcc->SetCaretOffset(aStart);
|
||||
} else {
|
||||
textAcc->SetSelectionBoundsAt(0, aStart, aEnd);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SessionAccessibility::Cut(int32_t aID) {
|
||||
FORWARD_EXT_ACTION_TO_ACCESSIBLE(Cut);
|
||||
if (Accessible* acc = GetAccessibleByID(aID)) {
|
||||
if (auto* textAcc = acc->AsHyperTextBase()) {
|
||||
int32_t startSel, endSel;
|
||||
if (textAcc->SelectionBoundsAt(0, &startSel, &endSel)) {
|
||||
textAcc->CutText(startSel, endSel);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SessionAccessibility::Copy(int32_t aID) {
|
||||
FORWARD_EXT_ACTION_TO_ACCESSIBLE(Copy);
|
||||
if (Accessible* acc = GetAccessibleByID(aID)) {
|
||||
if (auto* textAcc = acc->AsHyperTextBase()) {
|
||||
int32_t startSel, endSel;
|
||||
GetSelectionOrCaret(textAcc, &startSel, &endSel);
|
||||
textAcc->CopyText(startSel, endSel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SessionAccessibility::Paste(int32_t aID) {
|
||||
FORWARD_EXT_ACTION_TO_ACCESSIBLE(Paste);
|
||||
if (Accessible* acc = GetAccessibleByID(aID)) {
|
||||
if (auto* textAcc = acc->AsHyperTextBase()) {
|
||||
int32_t startSel, endSel;
|
||||
GetSelectionOrCaret(textAcc, &startSel, &endSel);
|
||||
if (startSel != endSel) {
|
||||
textAcc->DeleteText(startSel, endSel);
|
||||
}
|
||||
textAcc->PasteText(startSel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#undef FORWARD_ACTION_TO_ACCESSIBLE
|
||||
|
|
|
@ -62,7 +62,7 @@ class SessionAccessibility final
|
|||
void SetSelection(int32_t aID, int32_t aStart, int32_t aEnd);
|
||||
void Cut(int32_t aID);
|
||||
void Copy(int32_t aID);
|
||||
void Paste(int32_t aID);
|
||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY void Paste(int32_t aID);
|
||||
void StartNativeAccessibility();
|
||||
|
||||
// Event methods
|
||||
|
|
|
@ -12,15 +12,6 @@
|
|||
namespace mozilla {
|
||||
namespace a11y {
|
||||
|
||||
mozilla::ipc::IPCResult DocAccessiblePlatformExtChild::RecvPivotTo(
|
||||
uint64_t aID, int32_t aGranularity, bool aForward, bool aInclusive) {
|
||||
if (auto acc = IdToAccessibleWrap(aID)) {
|
||||
acc->PivotTo(aGranularity, aForward, aInclusive);
|
||||
}
|
||||
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult DocAccessiblePlatformExtChild::RecvNavigateText(
|
||||
uint64_t aID, int32_t aGranularity, int32_t aStartOffset,
|
||||
int32_t aEndOffset, bool aForward, bool aSelect) {
|
||||
|
@ -32,39 +23,6 @@ mozilla::ipc::IPCResult DocAccessiblePlatformExtChild::RecvNavigateText(
|
|||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult DocAccessiblePlatformExtChild::RecvSetSelection(
|
||||
uint64_t aID, int32_t aStart, int32_t aEnd) {
|
||||
if (auto acc = IdToAccessibleWrap(aID)) {
|
||||
acc->SetSelection(aStart, aEnd);
|
||||
}
|
||||
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult DocAccessiblePlatformExtChild::RecvCut(uint64_t aID) {
|
||||
if (auto acc = IdToAccessibleWrap(aID)) {
|
||||
acc->Cut();
|
||||
}
|
||||
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult DocAccessiblePlatformExtChild::RecvCopy(uint64_t aID) {
|
||||
if (auto acc = IdToAccessibleWrap(aID)) {
|
||||
acc->Copy();
|
||||
}
|
||||
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult DocAccessiblePlatformExtChild::RecvPaste(uint64_t aID) {
|
||||
if (auto acc = IdToAccessibleWrap(aID)) {
|
||||
acc->Paste();
|
||||
}
|
||||
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
AccessibleWrap* DocAccessiblePlatformExtChild::IdToAccessibleWrap(
|
||||
const uint64_t& aID) const {
|
||||
return static_cast<AccessibleWrap*>(
|
||||
|
|
|
@ -16,25 +16,11 @@ class DocAccessibleChild;
|
|||
|
||||
class DocAccessiblePlatformExtChild : public PDocAccessiblePlatformExtChild {
|
||||
public:
|
||||
mozilla::ipc::IPCResult RecvPivotTo(uint64_t aID, int32_t aGranularity,
|
||||
bool aForward, bool aInclusive);
|
||||
|
||||
mozilla::ipc::IPCResult RecvNavigateText(uint64_t aID, int32_t aGranularity,
|
||||
int32_t aStartOffset,
|
||||
int32_t aEndOffset, bool aForward,
|
||||
bool aSelect);
|
||||
|
||||
mozilla::ipc::IPCResult RecvSetSelection(uint64_t aID, int32_t aStart,
|
||||
int32_t aEnd);
|
||||
|
||||
mozilla::ipc::IPCResult RecvCut(uint64_t aID);
|
||||
|
||||
mozilla::ipc::IPCResult RecvCopy(uint64_t aID);
|
||||
|
||||
mozilla::ipc::IPCResult RecvPaste(uint64_t aID);
|
||||
|
||||
mozilla::ipc::IPCResult RecvExploreByTouch(uint64_t aID, float aX, float aY);
|
||||
|
||||
private:
|
||||
AccessibleWrap* IdToAccessibleWrap(const uint64_t& aID) const;
|
||||
};
|
||||
|
|
|
@ -17,14 +17,6 @@ child:
|
|||
async __delete__();
|
||||
|
||||
async NavigateText(uint64_t aID, int32_t aGranularity, int32_t aStartOffset, int32_t aEndOffset, bool aForward, bool aSelect);
|
||||
|
||||
async SetSelection(uint64_t aID, int32_t aStart, int32_t aEnd);
|
||||
|
||||
async Cut(uint64_t aID);
|
||||
|
||||
async Copy(uint64_t aID);
|
||||
|
||||
async Paste(uint64_t aID);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче