Bug 1832353 - P3: Make editable text methods async and return void. r=Jamie,ipc-reviewers,mccr8

Depends on D178715

Differential Revision: https://phabricator.services.mozilla.com/D178724
This commit is contained in:
Eitan Isaacson 2023-05-26 22:17:12 +00:00
Родитель 832b5bfb9a
Коммит dbdf01888d
21 изменённых файлов: 296 добавлений и 388 удалений

Просмотреть файл

@ -17,92 +17,72 @@ using namespace mozilla::a11y;
extern "C" {
static void setTextContentsCB(AtkEditableText* aText, const gchar* aString) {
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
if (accWrap) {
HyperTextAccessible* text = accWrap->AsHyperText();
if (!text || !text->IsTextRole()) {
if (Accessible* acc = GetInternalObj(ATK_OBJECT(aText))) {
if (acc->IsTextRole()) {
return;
}
NS_ConvertUTF8toUTF16 strContent(aString);
text->ReplaceText(strContent);
} else if (RemoteAccessible* proxy = GetProxy(ATK_OBJECT(aText))) {
NS_ConvertUTF8toUTF16 strContent(aString);
proxy->ReplaceText(strContent);
if (HyperTextAccessibleBase* text = acc->AsHyperTextBase()) {
NS_ConvertUTF8toUTF16 strContent(aString);
text->ReplaceText(strContent);
}
}
}
static void insertTextCB(AtkEditableText* aText, const gchar* aString,
gint aLength, gint* aPosition) {
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
if (accWrap) {
HyperTextAccessible* text = accWrap->AsHyperText();
if (!text || !text->IsTextRole()) {
if (Accessible* acc = GetInternalObj(ATK_OBJECT(aText))) {
if (acc->IsTextRole()) {
return;
}
NS_ConvertUTF8toUTF16 strContent(aString);
text->InsertText(strContent, *aPosition);
} else if (RemoteAccessible* proxy = GetProxy(ATK_OBJECT(aText))) {
NS_ConvertUTF8toUTF16 strContent(aString);
proxy->InsertText(strContent, *aPosition);
if (HyperTextAccessibleBase* text = acc->AsHyperTextBase()) {
NS_ConvertUTF8toUTF16 strContent(aString);
text->InsertText(strContent, *aPosition);
}
}
}
static void copyTextCB(AtkEditableText* aText, gint aStartPos, gint aEndPos) {
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
if (accWrap) {
HyperTextAccessible* text = accWrap->AsHyperText();
if (!text || !text->IsTextRole()) {
if (Accessible* acc = GetInternalObj(ATK_OBJECT(aText))) {
if (acc->IsTextRole()) {
return;
}
text->CopyText(aStartPos, aEndPos);
} else if (RemoteAccessible* proxy = GetProxy(ATK_OBJECT(aText))) {
proxy->CopyText(aStartPos, aEndPos);
if (HyperTextAccessibleBase* text = acc->AsHyperTextBase()) {
text->CopyText(aStartPos, aEndPos);
}
}
}
static void cutTextCB(AtkEditableText* aText, gint aStartPos, gint aEndPos) {
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
if (accWrap) {
HyperTextAccessible* text = accWrap->AsHyperText();
if (!text || !text->IsTextRole()) {
if (Accessible* acc = GetInternalObj(ATK_OBJECT(aText))) {
if (acc->IsTextRole()) {
return;
}
text->CutText(aStartPos, aEndPos);
} else if (RemoteAccessible* proxy = GetProxy(ATK_OBJECT(aText))) {
proxy->CutText(aStartPos, aEndPos);
if (HyperTextAccessibleBase* text = acc->AsHyperTextBase()) {
text->CutText(aStartPos, aEndPos);
}
}
}
static void deleteTextCB(AtkEditableText* aText, gint aStartPos, gint aEndPos) {
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
if (accWrap) {
HyperTextAccessible* text = accWrap->AsHyperText();
if (!text || !text->IsTextRole()) {
if (Accessible* acc = GetInternalObj(ATK_OBJECT(aText))) {
if (acc->IsTextRole()) {
return;
}
text->DeleteText(aStartPos, aEndPos);
} else if (RemoteAccessible* proxy = GetProxy(ATK_OBJECT(aText))) {
proxy->DeleteText(aStartPos, aEndPos);
if (HyperTextAccessibleBase* text = acc->AsHyperTextBase()) {
text->DeleteText(aStartPos, aEndPos);
}
}
}
MOZ_CAN_RUN_SCRIPT_BOUNDARY
static void pasteTextCB(AtkEditableText* aText, gint aPosition) {
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
if (accWrap) {
RefPtr<HyperTextAccessible> text = accWrap->AsHyperText();
if (!text || !text->IsTextRole()) {
if (Accessible* acc = GetInternalObj(ATK_OBJECT(aText))) {
if (acc->IsTextRole()) {
return;
}
text->PasteText(aPosition);
} else if (RemoteAccessible* proxy = GetProxy(ATK_OBJECT(aText))) {
proxy->PasteText(aPosition);
if (HyperTextAccessibleBase* text = acc->AsHyperTextBase()) {
text->PasteText(aPosition);
}
}
}
}

Просмотреть файл

@ -245,6 +245,21 @@ class HyperTextAccessibleBase {
int32_t aEndOffset,
uint32_t aScrollType);
//////////////////////////////////////////////////////////////////////////////
// EditableTextAccessible
MOZ_CAN_RUN_SCRIPT_BOUNDARY virtual void ReplaceText(
const nsAString& aText) = 0;
MOZ_CAN_RUN_SCRIPT_BOUNDARY virtual void InsertText(const nsAString& aText,
int32_t aPosition) = 0;
MOZ_CAN_RUN_SCRIPT_BOUNDARY virtual void CopyText(int32_t aStartPos,
int32_t aEndPos) = 0;
MOZ_CAN_RUN_SCRIPT_BOUNDARY virtual void CutText(int32_t aStartPos,
int32_t aEndPos) = 0;
MOZ_CAN_RUN_SCRIPT_BOUNDARY virtual void DeleteText(int32_t aStartPos,
int32_t aEndPos) = 0;
MOZ_CAN_RUN_SCRIPT virtual void PasteText(int32_t aPosition) = 0;
protected:
virtual const Accessible* Acc() const = 0;
Accessible* Acc() {

Просмотреть файл

@ -25,70 +25,6 @@ inline void HyperTextAccessible::SetCaretOffset(int32_t aOffset) {
SelectionMgr()->UpdateCaretOffset(this, aOffset);
}
inline void HyperTextAccessible::ReplaceText(const nsAString& aText) {
if (aText.Length() == 0) {
DeleteText(0, CharacterCount());
return;
}
SetSelectionRange(0, CharacterCount());
RefPtr<EditorBase> editorBase = GetEditor();
if (!editorBase) {
return;
}
DebugOnly<nsresult> rv = editorBase->InsertTextAsAction(aText);
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "Failed to insert the new text");
}
inline void HyperTextAccessible::InsertText(const nsAString& aText,
int32_t aPosition) {
RefPtr<EditorBase> editorBase = GetEditor();
if (editorBase) {
SetSelectionRange(aPosition, aPosition);
DebugOnly<nsresult> rv = editorBase->InsertTextAsAction(aText);
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "Failed to insert the text");
}
}
inline void HyperTextAccessible::CopyText(int32_t aStartPos, int32_t aEndPos) {
RefPtr<EditorBase> editorBase = GetEditor();
if (editorBase) {
SetSelectionRange(aStartPos, aEndPos);
editorBase->Copy();
}
}
inline void HyperTextAccessible::CutText(int32_t aStartPos, int32_t aEndPos) {
RefPtr<EditorBase> editorBase = GetEditor();
if (editorBase) {
SetSelectionRange(aStartPos, aEndPos);
editorBase->Cut();
}
}
inline void HyperTextAccessible::DeleteText(int32_t aStartPos,
int32_t aEndPos) {
RefPtr<EditorBase> editorBase = GetEditor();
if (!editorBase) {
return;
}
SetSelectionRange(aStartPos, aEndPos);
DebugOnly<nsresult> rv =
editorBase->DeleteSelectionAsAction(nsIEditor::eNone, nsIEditor::eStrip);
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "Failed to delete text");
}
inline void HyperTextAccessible::PasteText(int32_t aPosition) {
RefPtr<EditorBase> editorBase = GetEditor();
if (editorBase) {
SetSelectionRange(aPosition, aPosition);
editorBase->PasteAsAction(nsIClipboard::kGlobalClipboard,
EditorBase::DispatchPasteEvent::Yes);
}
}
inline bool HyperTextAccessible::IsCaretAtEndOfLine() const {
RefPtr<nsFrameSelection> frameSelection = FrameSelection();
return frameSelection && frameSelection->GetHint() == CARET_ASSOCIATE_BEFORE;

Просмотреть файл

@ -997,6 +997,69 @@ void HyperTextAccessible::RangeAtPoint(int32_t aX, int32_t aY,
}
}
void HyperTextAccessible::ReplaceText(const nsAString& aText) {
if (aText.Length() == 0) {
DeleteText(0, CharacterCount());
return;
}
SetSelectionRange(0, CharacterCount());
RefPtr<EditorBase> editorBase = GetEditor();
if (!editorBase) {
return;
}
DebugOnly<nsresult> rv = editorBase->InsertTextAsAction(aText);
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "Failed to insert the new text");
}
void HyperTextAccessible::InsertText(const nsAString& aText,
int32_t aPosition) {
RefPtr<EditorBase> editorBase = GetEditor();
if (editorBase) {
SetSelectionRange(aPosition, aPosition);
DebugOnly<nsresult> rv = editorBase->InsertTextAsAction(aText);
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "Failed to insert the text");
}
}
void HyperTextAccessible::CopyText(int32_t aStartPos, int32_t aEndPos) {
RefPtr<EditorBase> editorBase = GetEditor();
if (editorBase) {
SetSelectionRange(aStartPos, aEndPos);
editorBase->Copy();
}
}
void HyperTextAccessible::CutText(int32_t aStartPos, int32_t aEndPos) {
RefPtr<EditorBase> editorBase = GetEditor();
if (editorBase) {
SetSelectionRange(aStartPos, aEndPos);
editorBase->Cut();
}
}
void HyperTextAccessible::DeleteText(int32_t aStartPos, int32_t aEndPos) {
RefPtr<EditorBase> editorBase = GetEditor();
if (!editorBase) {
return;
}
SetSelectionRange(aStartPos, aEndPos);
DebugOnly<nsresult> rv =
editorBase->DeleteSelectionAsAction(nsIEditor::eNone, nsIEditor::eStrip);
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "Failed to delete text");
}
void HyperTextAccessible::PasteText(int32_t aPosition) {
RefPtr<EditorBase> editorBase = GetEditor();
if (editorBase) {
SetSelectionRange(aPosition, aPosition);
editorBase->PasteAsAction(nsIClipboard::kGlobalClipboard,
EditorBase::DispatchPasteEvent::Yes);
}
}
////////////////////////////////////////////////////////////////////////////////
// LocalAccessible public

Просмотреть файл

@ -200,15 +200,17 @@ class HyperTextAccessible : public AccessibleWrap,
//////////////////////////////////////////////////////////////////////////////
// EditableTextAccessible
MOZ_CAN_RUN_SCRIPT_BOUNDARY void ReplaceText(const nsAString& aText);
MOZ_CAN_RUN_SCRIPT_BOUNDARY void InsertText(const nsAString& aText,
int32_t aPosition);
MOZ_CAN_RUN_SCRIPT_BOUNDARY void CopyText(int32_t aStartPos, int32_t aEndPos);
MOZ_CAN_RUN_SCRIPT_BOUNDARY void CutText(int32_t aStartPos, int32_t aEndPos);
MOZ_CAN_RUN_SCRIPT_BOUNDARY void DeleteText(int32_t aStartPos,
int32_t aEndPos);
MOZ_CAN_RUN_SCRIPT
void PasteText(int32_t aPosition);
MOZ_CAN_RUN_SCRIPT_BOUNDARY virtual void ReplaceText(
const nsAString& aText) override;
MOZ_CAN_RUN_SCRIPT_BOUNDARY virtual void InsertText(
const nsAString& aText, int32_t aPosition) override;
MOZ_CAN_RUN_SCRIPT_BOUNDARY virtual void CopyText(int32_t aStartPos,
int32_t aEndPos) override;
MOZ_CAN_RUN_SCRIPT_BOUNDARY virtual void CutText(int32_t aStartPos,
int32_t aEndPos) override;
MOZ_CAN_RUN_SCRIPT_BOUNDARY virtual void DeleteText(int32_t aStartPos,
int32_t aEndPos) override;
MOZ_CAN_RUN_SCRIPT virtual void PasteText(int32_t aPosition) override;
/**
* Return the editor associated with the accessible.

Просмотреть файл

@ -265,6 +265,66 @@ mozilla::ipc::IPCResult DocAccessibleChildBase::RecvSetCurValue(
return IPC_OK();
}
mozilla::ipc::IPCResult DocAccessibleChildBase::RecvReplaceText(
const uint64_t& aID, const nsAString& aText) {
HyperTextAccessible* acc = IdToHyperTextAccessible(aID);
if (acc && acc->IsTextRole()) {
acc->ReplaceText(aText);
}
return IPC_OK();
}
mozilla::ipc::IPCResult DocAccessibleChildBase::RecvInsertText(
const uint64_t& aID, const nsAString& aText, const int32_t& aPosition) {
HyperTextAccessible* acc = IdToHyperTextAccessible(aID);
if (acc && acc->IsTextRole()) {
acc->InsertText(aText, aPosition);
}
return IPC_OK();
}
mozilla::ipc::IPCResult DocAccessibleChildBase::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 IPC_OK();
}
mozilla::ipc::IPCResult DocAccessibleChildBase::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 IPC_OK();
}
mozilla::ipc::IPCResult DocAccessibleChildBase::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 IPC_OK();
}
mozilla::ipc::IPCResult DocAccessibleChildBase::RecvPasteText(
const uint64_t& aID, const int32_t& aPosition) {
RefPtr<HyperTextAccessible> acc = IdToHyperTextAccessible(aID);
if (acc && acc->IsTextRole()) {
acc->PasteText(aPosition);
}
return IPC_OK();
}
LocalAccessible* DocAccessibleChildBase::IdToAccessible(
const uint64_t& aID) const {
if (!aID) return mDoc;

Просмотреть файл

@ -95,6 +95,29 @@ class DocAccessibleChildBase : public PDocAccessibleChild {
virtual mozilla::ipc::IPCResult RecvSetCurValue(
const uint64_t& aID, const double& aValue) override;
virtual mozilla::ipc::IPCResult RecvReplaceText(
const uint64_t& aID, const nsAString& aText) override;
virtual mozilla::ipc::IPCResult RecvInsertText(
const uint64_t& aID, const nsAString& aText,
const int32_t& aPosition) override;
virtual mozilla::ipc::IPCResult RecvCopyText(const uint64_t& aID,
const int32_t& aStartPos,
const int32_t& aEndPos) override;
virtual mozilla::ipc::IPCResult RecvCutText(const uint64_t& aID,
const int32_t& aStartPos,
const int32_t& aEndPos) override;
virtual mozilla::ipc::IPCResult RecvDeleteText(
const uint64_t& aID, const int32_t& aStartPos,
const int32_t& aEndPos) override;
MOZ_CAN_RUN_SCRIPT_BOUNDARY
virtual mozilla::ipc::IPCResult RecvPasteText(
const uint64_t& aID, const int32_t& aPosition) override;
protected:
static void FlattenTree(LocalAccessible* aRoot,
nsTArray<LocalAccessible*>& aTree);

Просмотреть файл

@ -1958,6 +1958,40 @@ void RemoteAccessibleBase<Derived>::Language(nsAString& aLocale) {
}
}
template <class Derived>
void RemoteAccessibleBase<Derived>::ReplaceText(const nsAString& aText) {
Unused << mDoc->SendReplaceText(mID, aText);
}
template <class Derived>
void RemoteAccessibleBase<Derived>::InsertText(const nsAString& aText,
int32_t aPosition) {
Unused << mDoc->SendInsertText(mID, aText, aPosition);
}
template <class Derived>
void RemoteAccessibleBase<Derived>::CopyText(int32_t aStartPos,
int32_t aEndPos) {
Unused << mDoc->SendCopyText(mID, aStartPos, aEndPos);
}
template <class Derived>
void RemoteAccessibleBase<Derived>::CutText(int32_t aStartPos,
int32_t aEndPos) {
Unused << mDoc->SendCutText(mID, aStartPos, aEndPos);
}
template <class Derived>
void RemoteAccessibleBase<Derived>::DeleteText(int32_t aStartPos,
int32_t aEndPos) {
Unused << mDoc->SendDeleteText(mID, aStartPos, aEndPos);
}
template <class Derived>
void RemoteAccessibleBase<Derived>::PasteText(int32_t aPosition) {
Unused << mDoc->SendPasteText(mID, aPosition);
}
template <class Derived>
size_t RemoteAccessibleBase<Derived>::SizeOfIncludingThis(
MallocSizeOf aMallocSizeOf) {

Просмотреть файл

@ -225,6 +225,21 @@ class RemoteAccessibleBase : public Accessible, public HyperTextAccessibleBase {
virtual void Language(nsAString& aLocale) override;
//////////////////////////////////////////////////////////////////////////////
// EditableTextAccessible
MOZ_CAN_RUN_SCRIPT_BOUNDARY virtual void ReplaceText(
const nsAString& aText) override;
MOZ_CAN_RUN_SCRIPT_BOUNDARY virtual void InsertText(
const nsAString& aText, int32_t aPosition) override;
MOZ_CAN_RUN_SCRIPT_BOUNDARY virtual void CopyText(int32_t aStartPos,
int32_t aEndPos) override;
MOZ_CAN_RUN_SCRIPT_BOUNDARY virtual void CutText(int32_t aStartPos,
int32_t aEndPos) override;
MOZ_CAN_RUN_SCRIPT_BOUNDARY virtual void DeleteText(int32_t aStartPos,
int32_t aEndPos) override;
MOZ_CAN_RUN_SCRIPT virtual void PasteText(int32_t aPosition) override;
//////////////////////////////////////////////////////////////////////////////
// SelectAccessible

Просмотреть файл

@ -19,18 +19,6 @@ void Announce(const nsString& aAnnouncement, uint16_t aPriority);
void ScrollSubstringToPoint(int32_t aStartOffset, int32_t aEndOffset,
uint32_t aCoordinateType, int32_t aX, int32_t aY);
void ReplaceText(const nsString& aText);
bool InsertText(const nsString& aText, int32_t aPosition);
bool CopyText(int32_t aStartPos, int32_t aEndPos);
bool CutText(int32_t aStartPos, int32_t aEndPos);
bool DeleteText(int32_t aStartPos, int32_t aEndPos);
bool PasteText(int32_t aPosition);
void DocType(nsString& aType);
void MimeType(nsString aMime);
void URLDocTypeMimeType(nsString& aURL, nsString& aDocType,

Просмотреть файл

@ -60,74 +60,6 @@ mozilla::ipc::IPCResult DocAccessibleChild::RecvScrollSubstringToPoint(
return IPC_OK();
}
mozilla::ipc::IPCResult DocAccessibleChild::RecvReplaceText(
const uint64_t& aID, const nsAString& aText) {
HyperTextAccessible* acc = IdToHyperTextAccessible(aID);
if (acc && acc->IsTextRole()) {
acc->ReplaceText(aText);
}
return IPC_OK();
}
mozilla::ipc::IPCResult DocAccessibleChild::RecvInsertText(
const uint64_t& aID, const nsAString& aText, const int32_t& aPosition,
bool* aValid) {
HyperTextAccessible* acc = IdToHyperTextAccessible(aID);
if (acc && acc->IsTextRole()) {
*aValid = acc->IsValidOffset(aPosition);
acc->InsertText(aText, aPosition);
}
return IPC_OK();
}
mozilla::ipc::IPCResult DocAccessibleChild::RecvCopyText(
const uint64_t& aID, const int32_t& aStartPos, const int32_t& aEndPos,
bool* aValid) {
HyperTextAccessible* acc = IdToHyperTextAccessible(aID);
if (acc && acc->IsTextRole()) {
acc->CopyText(aStartPos, aEndPos);
}
return IPC_OK();
}
mozilla::ipc::IPCResult DocAccessibleChild::RecvCutText(
const uint64_t& aID, const int32_t& aStartPos, const int32_t& aEndPos,
bool* aValid) {
HyperTextAccessible* acc = IdToHyperTextAccessible(aID);
if (acc && acc->IsTextRole()) {
*aValid = acc->IsValidRange(aStartPos, aEndPos);
acc->CutText(aStartPos, aEndPos);
}
return IPC_OK();
}
mozilla::ipc::IPCResult DocAccessibleChild::RecvDeleteText(
const uint64_t& aID, const int32_t& aStartPos, const int32_t& aEndPos,
bool* aValid) {
HyperTextAccessible* acc = IdToHyperTextAccessible(aID);
if (acc && acc->IsTextRole()) {
*aValid = acc->IsValidRange(aStartPos, aEndPos);
acc->DeleteText(aStartPos, aEndPos);
}
return IPC_OK();
}
mozilla::ipc::IPCResult DocAccessibleChild::RecvPasteText(
const uint64_t& aID, const int32_t& aPosition, bool* aValid) {
RefPtr<HyperTextAccessible> acc = IdToHyperTextAccessible(aID);
if (acc && acc->IsTextRole()) {
*aValid = acc->IsValidOffset(aPosition);
acc->PasteText(aPosition);
}
return IPC_OK();
}
mozilla::ipc::IPCResult DocAccessibleChild::RecvDocType(const uint64_t& aID,
nsString* aType) {
LocalAccessible* acc = IdToAccessible(aID);

Просмотреть файл

@ -53,34 +53,6 @@ class DocAccessibleChild : public DocAccessibleChildBase {
const int32_t& aEndOffset, const uint32_t& aCoordinateType,
const int32_t& aX, const int32_t& aY) override;
virtual mozilla::ipc::IPCResult RecvReplaceText(
const uint64_t& aID, const nsAString& aText) override;
virtual mozilla::ipc::IPCResult RecvInsertText(const uint64_t& aID,
const nsAString& aText,
const int32_t& aPosition,
bool* aValid) override;
virtual mozilla::ipc::IPCResult RecvCopyText(const uint64_t& aID,
const int32_t& aStartPos,
const int32_t& aEndPos,
bool* aValid) override;
virtual mozilla::ipc::IPCResult RecvCutText(const uint64_t& aID,
const int32_t& aStartPos,
const int32_t& aEndPos,
bool* aValid) override;
virtual mozilla::ipc::IPCResult RecvDeleteText(const uint64_t& aID,
const int32_t& aStartPos,
const int32_t& aEndPos,
bool* aValid) override;
MOZ_CAN_RUN_SCRIPT_BOUNDARY
virtual mozilla::ipc::IPCResult RecvPasteText(const uint64_t& aID,
const int32_t& aPosition,
bool* aValid) override;
virtual mozilla::ipc::IPCResult RecvDocType(const uint64_t& aID,
nsString* aType) override;
virtual mozilla::ipc::IPCResult RecvMimeType(const uint64_t& aID,

Просмотреть файл

@ -164,17 +164,12 @@ child:
uint32_t aCoordinateType,
int32_t aX, int32_t aY);
[Nested=inside_sync] sync ReplaceText(uint64_t aID, nsString aText);
[Nested=inside_sync] sync InsertText(uint64_t aID, nsString aText, int32_t aPosition)
returns(bool aValid);
[Nested=inside_sync] sync CopyText(uint64_t aID, int32_t aStartPos, int32_t aEndPos)
returns(bool aValid);
[Nested=inside_sync] sync CutText(uint64_t aID, int32_t aStartPos, int32_t aEndPos)
returns(bool aValid);
[Nested=inside_sync] sync DeleteText(uint64_t aID, int32_t aStartPos, int32_t aEndPos)
returns(bool aValid);
[Nested=inside_sync] sync PasteText(uint64_t aID, int32_t aPosition)
returns(bool aValid);
async ReplaceText(uint64_t aID, nsString aText);
async InsertText(uint64_t aID, nsString aText, int32_t aPosition);
async CopyText(uint64_t aID, int32_t aStartPos, int32_t aEndPos);
async CutText(uint64_t aID, int32_t aStartPos, int32_t aEndPos);
async DeleteText(uint64_t aID, int32_t aStartPos, int32_t aEndPos);
async PasteText(uint64_t aID, int32_t aPosition);
async TakeSelection(uint64_t aID);
async SetSelected(uint64_t aID, bool aSelected);

Просмотреть файл

@ -39,40 +39,6 @@ void RemoteAccessible::ScrollSubstringToPoint(int32_t aStartOffset,
aCoordinateType, aX, aY);
}
void RemoteAccessible::ReplaceText(const nsString& aText) {
Unused << mDoc->SendReplaceText(mID, aText);
}
bool RemoteAccessible::InsertText(const nsString& aText, int32_t aPosition) {
bool valid;
Unused << mDoc->SendInsertText(mID, aText, aPosition, &valid);
return valid;
}
bool RemoteAccessible::CopyText(int32_t aStartPos, int32_t aEndPos) {
bool valid;
Unused << mDoc->SendCopyText(mID, aStartPos, aEndPos, &valid);
return valid;
}
bool RemoteAccessible::CutText(int32_t aStartPos, int32_t aEndPos) {
bool valid;
Unused << mDoc->SendCutText(mID, aStartPos, aEndPos, &valid);
return valid;
}
bool RemoteAccessible::DeleteText(int32_t aStartPos, int32_t aEndPos) {
bool valid;
Unused << mDoc->SendDeleteText(mID, aStartPos, aEndPos, &valid);
return valid;
}
bool RemoteAccessible::PasteText(int32_t aPosition) {
bool valid;
Unused << mDoc->SendPasteText(mID, aPosition, &valid);
return valid;
}
void RemoteAccessible::DocType(nsString& aType) {
Unused << mDoc->SendDocType(mID, &aType);
}

Просмотреть файл

@ -130,6 +130,13 @@ child:
uint64_t aEndID, int32_t aEndOffset,
uint32_t aScrollType);
async ReplaceText(uint64_t aID, nsString aText);
async InsertText(uint64_t aID, nsString aText, int32_t aPosition);
async CopyText(uint64_t aID, int32_t aStartPos, int32_t aEndPos);
async CutText(uint64_t aID, int32_t aStartPos, int32_t aEndPos);
async DeleteText(uint64_t aID, int32_t aStartPos, int32_t aEndPos);
async PasteText(uint64_t aID, int32_t aPosition);
/*
* Verify the cache. Used for testing purposes.
*/

Просмотреть файл

@ -172,13 +172,8 @@ inline NSString* ToNSString(id aValue) {
nsString text;
nsCocoaUtils::GetStringForNSString(value, text);
if (mGeckoAccessible->IsLocal()) {
if (HyperTextAccessible* textAcc =
mGeckoAccessible->AsLocal()->AsHyperText()) {
textAcc->ReplaceText(text);
}
} else {
mGeckoAccessible->AsRemote()->ReplaceText(text);
if (HyperTextAccessibleBase* textAcc = mGeckoAccessible->AsHyperTextBase()) {
textAcc->ReplaceText(text);
}
}
@ -198,17 +193,9 @@ inline NSString* ToNSString(id aValue) {
textAcc->SelectionBoundsAt(0, &start, &end);
nsString text;
nsCocoaUtils::GetStringForNSString(stringValue, text);
if (LocalAccessible* localAcc = mGeckoAccessible->AsLocal()) {
HyperTextAccessible* localTextAcc = localAcc->AsHyperText();
MOZ_ASSERT(localTextAcc);
localTextAcc->DeleteText(start, end - start);
localTextAcc->InsertText(text, start);
} else {
RemoteAccessible* proxy = mGeckoAccessible->AsRemote();
proxy->DeleteText(start, end - start);
nsCocoaUtils::GetStringForNSString(stringValue, text);
proxy->InsertText(text, start);
}
textAcc->SelectionBoundsAt(0, &start, &end);
textAcc->DeleteText(start, end - start);
textAcc->InsertText(text, start);
}
- (void)moxSetSelectedTextRange:(NSValue*)selectedTextRange {

Просмотреть файл

@ -9,25 +9,24 @@
#include "ia2AccessibleHypertext.h"
#include "AccessibleEditableText_i.c"
#include "HyperTextAccessible-inl.h"
#include "HyperTextAccessibleWrap.h"
#include "mozilla/a11y/HyperTextAccessibleBase.h"
#include "nsCOMPtr.h"
#include "nsString.h"
using namespace mozilla::a11y;
HyperTextAccessibleWrap* ia2AccessibleEditableText::TextAcc() {
HyperTextAccessibleBase* ia2AccessibleEditableText::TextAcc() {
auto hyp = static_cast<ia2AccessibleHypertext*>(this);
AccessibleWrap* acc = static_cast<MsaaAccessible*>(hyp)->LocalAcc();
return static_cast<HyperTextAccessibleWrap*>(acc);
Accessible* acc = hyp->Acc();
return acc ? acc->AsHyperTextBase() : nullptr;
}
// IAccessibleEditableText
STDMETHODIMP
ia2AccessibleEditableText::copyText(long aStartOffset, long aEndOffset) {
HyperTextAccessible* textAcc = TextAcc();
HyperTextAccessibleBase* textAcc = TextAcc();
if (!textAcc) return CO_E_OBJNOTCONNECTED;
if (!textAcc->IsValidRange(aStartOffset, aEndOffset)) return E_INVALIDARG;
@ -38,7 +37,7 @@ ia2AccessibleEditableText::copyText(long aStartOffset, long aEndOffset) {
STDMETHODIMP
ia2AccessibleEditableText::deleteText(long aStartOffset, long aEndOffset) {
HyperTextAccessible* textAcc = TextAcc();
HyperTextAccessibleBase* textAcc = TextAcc();
if (!textAcc) return CO_E_OBJNOTCONNECTED;
if (!textAcc->IsValidRange(aStartOffset, aEndOffset)) return E_INVALIDARG;
@ -52,7 +51,7 @@ ia2AccessibleEditableText::insertText(long aOffset, BSTR* aText) {
uint32_t length = ::SysStringLen(*aText);
nsAutoString text(*aText, length);
HyperTextAccessible* textAcc = TextAcc();
HyperTextAccessibleBase* textAcc = TextAcc();
if (!textAcc) return CO_E_OBJNOTCONNECTED;
if (!textAcc->IsValidOffset(aOffset)) return E_INVALIDARG;
@ -63,7 +62,7 @@ ia2AccessibleEditableText::insertText(long aOffset, BSTR* aText) {
STDMETHODIMP
ia2AccessibleEditableText::cutText(long aStartOffset, long aEndOffset) {
HyperTextAccessible* textAcc = TextAcc();
HyperTextAccessibleBase* textAcc = TextAcc();
if (!textAcc) return CO_E_OBJNOTCONNECTED;
if (!textAcc->IsValidRange(aStartOffset, aEndOffset)) return E_INVALIDARG;
@ -74,7 +73,7 @@ ia2AccessibleEditableText::cutText(long aStartOffset, long aEndOffset) {
STDMETHODIMP
ia2AccessibleEditableText::pasteText(long aOffset) {
RefPtr<HyperTextAccessible> textAcc = TextAcc();
HyperTextAccessibleBase* textAcc = TextAcc();
if (!textAcc) return CO_E_OBJNOTCONNECTED;
if (!textAcc->IsValidOffset(aOffset)) return E_INVALIDARG;
@ -86,7 +85,7 @@ ia2AccessibleEditableText::pasteText(long aOffset) {
STDMETHODIMP
ia2AccessibleEditableText::replaceText(long aStartOffset, long aEndOffset,
BSTR* aText) {
HyperTextAccessible* textAcc = TextAcc();
HyperTextAccessibleBase* textAcc = TextAcc();
if (!textAcc) return CO_E_OBJNOTCONNECTED;
if (!textAcc->IsValidRange(aStartOffset, aEndOffset)) return E_INVALIDARG;

Просмотреть файл

@ -14,7 +14,7 @@
namespace mozilla {
namespace a11y {
class HyperTextAccessibleWrap;
class HyperTextAccessibleBase;
class ia2AccessibleEditableText : public IAccessibleEditableText {
public:
@ -50,7 +50,7 @@ class ia2AccessibleEditableText : public IAccessibleEditableText {
/* [in] */ BSTR* attributes);
private:
HyperTextAccessibleWrap* TextAcc();
HyperTextAccessibleBase* TextAcc();
};
} // namespace a11y

Просмотреть файл

@ -1334,11 +1334,8 @@ MsaaAccessible::put_accValue(
if (accessible) {
return accessible->put_accValue(kVarChildIdSelf, szValue);
}
if (mAcc->IsRemote()) {
return E_NOTIMPL; // XXX Not supported for RemoteAccessible yet.
}
HyperTextAccessible* ht = LocalAcc()->AsHyperText();
HyperTextAccessibleBase* ht = mAcc->AsHyperTextBase();
if (!ht) {
return E_NOTIMPL;
}

Просмотреть файл

@ -444,16 +444,8 @@ NS_IMETHODIMP
xpcAccessibleHyperText::SetTextContents(const nsAString& aText) {
if (!mIntl) return NS_ERROR_FAILURE;
if (mIntl->IsLocal()) {
IntlLocal()->ReplaceText(aText);
} else {
#if defined(XP_WIN)
return NS_ERROR_NOT_IMPLEMENTED;
#else
nsString text(aText);
mIntl->AsRemote()->ReplaceText(text);
#endif
}
Intl()->ReplaceText(aText);
return NS_OK;
}
@ -461,16 +453,8 @@ NS_IMETHODIMP
xpcAccessibleHyperText::InsertText(const nsAString& aText, int32_t aOffset) {
if (!mIntl) return NS_ERROR_FAILURE;
if (mIntl->IsLocal()) {
IntlLocal()->InsertText(aText, aOffset);
} else {
#if defined(XP_WIN)
return NS_ERROR_NOT_IMPLEMENTED;
#else
nsString text(aText);
mIntl->AsRemote()->InsertText(text, aOffset);
#endif
}
Intl()->InsertText(aText, aOffset);
return NS_OK;
}
@ -478,15 +462,8 @@ NS_IMETHODIMP
xpcAccessibleHyperText::CopyText(int32_t aStartOffset, int32_t aEndOffset) {
if (!mIntl) return NS_ERROR_FAILURE;
if (mIntl->IsLocal()) {
IntlLocal()->CopyText(aStartOffset, aEndOffset);
} else {
#if defined(XP_WIN)
return NS_ERROR_NOT_IMPLEMENTED;
#else
mIntl->AsRemote()->CopyText(aStartOffset, aEndOffset);
#endif
}
Intl()->CopyText(aStartOffset, aEndOffset);
return NS_OK;
}
@ -494,15 +471,8 @@ NS_IMETHODIMP
xpcAccessibleHyperText::CutText(int32_t aStartOffset, int32_t aEndOffset) {
if (!mIntl) return NS_ERROR_FAILURE;
if (mIntl->IsLocal()) {
IntlLocal()->CutText(aStartOffset, aEndOffset);
} else {
#if defined(XP_WIN)
return NS_ERROR_NOT_IMPLEMENTED;
#else
mIntl->AsRemote()->CutText(aStartOffset, aEndOffset);
#endif
}
Intl()->CutText(aStartOffset, aEndOffset);
return NS_OK;
}
@ -510,15 +480,8 @@ NS_IMETHODIMP
xpcAccessibleHyperText::DeleteText(int32_t aStartOffset, int32_t aEndOffset) {
if (!mIntl) return NS_ERROR_FAILURE;
if (mIntl->IsLocal()) {
IntlLocal()->DeleteText(aStartOffset, aEndOffset);
} else {
#if defined(XP_WIN)
return NS_ERROR_NOT_IMPLEMENTED;
#else
mIntl->AsRemote()->DeleteText(aStartOffset, aEndOffset);
#endif
}
Intl()->DeleteText(aStartOffset, aEndOffset);
return NS_OK;
}
@ -526,16 +489,8 @@ NS_IMETHODIMP
xpcAccessibleHyperText::PasteText(int32_t aOffset) {
if (!mIntl) return NS_ERROR_FAILURE;
if (mIntl->IsLocal()) {
RefPtr<HyperTextAccessible> acc = IntlLocal();
acc->PasteText(aOffset);
} else {
#if defined(XP_WIN)
return NS_ERROR_NOT_IMPLEMENTED;
#else
mIntl->AsRemote()->PasteText(aOffset);
#endif
}
Intl()->PasteText(aOffset);
return NS_OK;
}

Просмотреть файл

@ -23,24 +23,6 @@ description = Only used by gtests
[PDocAccessible::AddToSelection]
description = Legacy a11y IPC
platform = notwin
[PDocAccessible::ReplaceText]
description = Legacy a11y IPC
platform = notwin
[PDocAccessible::InsertText]
description = Legacy a11y IPC
platform = notwin
[PDocAccessible::CopyText]
description = Legacy a11y IPC
platform = notwin
[PDocAccessible::CutText]
description = Legacy a11y IPC
platform = notwin
[PDocAccessible::DeleteText]
description = Legacy a11y IPC
platform = notwin
[PDocAccessible::PasteText]
description = Legacy a11y IPC
platform = notwin
[PDocAccessible::DocType]
description = Legacy a11y IPC
platform = notwin