Skip to content

Commit

Permalink
Backed out 6 changesets (bug 1832353, bug 1821965) for causing build …
Browse files Browse the repository at this point in the history
…bustages in GeckoTextMarker.mm

Backed out changeset 6df0877f288a (bug 1821965)
Backed out changeset e663ccc0334e (bug 1821965)
Backed out changeset 36b250225e50 (bug 1821965)
Backed out changeset 6df5d07bf19f (bug 1832353)
Backed out changeset 409966c76f0f (bug 1832353)
Backed out changeset 3be446e44436 (bug 1832353)
  • Loading branch information
nerli1 committed May 25, 2023
1 parent df8401c commit b18a751
Show file tree
Hide file tree
Showing 54 changed files with 3,695 additions and 1,056 deletions.
84 changes: 52 additions & 32 deletions accessible/atk/nsMaiInterfaceEditableText.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,72 +17,92 @@ using namespace mozilla::a11y;

extern "C" {
static void setTextContentsCB(AtkEditableText* aText, const gchar* aString) {
if (Accessible* acc = GetInternalObj(ATK_OBJECT(aText))) {
if (acc->IsTextRole()) {
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
if (accWrap) {
HyperTextAccessible* text = accWrap->AsHyperText();
if (!text || !text->IsTextRole()) {
return;
}
if (HyperTextAccessibleBase* text = acc->AsHyperTextBase()) {
NS_ConvertUTF8toUTF16 strContent(aString);
text->ReplaceText(strContent);
}

NS_ConvertUTF8toUTF16 strContent(aString);
text->ReplaceText(strContent);
} else if (RemoteAccessible* proxy = GetProxy(ATK_OBJECT(aText))) {
NS_ConvertUTF8toUTF16 strContent(aString);
proxy->ReplaceText(strContent);
}
}

static void insertTextCB(AtkEditableText* aText, const gchar* aString,
gint aLength, gint* aPosition) {
if (Accessible* acc = GetInternalObj(ATK_OBJECT(aText))) {
if (acc->IsTextRole()) {
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
if (accWrap) {
HyperTextAccessible* text = accWrap->AsHyperText();
if (!text || !text->IsTextRole()) {
return;
}
if (HyperTextAccessibleBase* text = acc->AsHyperTextBase()) {
NS_ConvertUTF8toUTF16 strContent(aString);
text->InsertText(strContent, *aPosition);
}

NS_ConvertUTF8toUTF16 strContent(aString);
text->InsertText(strContent, *aPosition);
} else if (RemoteAccessible* proxy = GetProxy(ATK_OBJECT(aText))) {
NS_ConvertUTF8toUTF16 strContent(aString);
proxy->InsertText(strContent, *aPosition);
}
}

static void copyTextCB(AtkEditableText* aText, gint aStartPos, gint aEndPos) {
if (Accessible* acc = GetInternalObj(ATK_OBJECT(aText))) {
if (acc->IsTextRole()) {
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
if (accWrap) {
HyperTextAccessible* text = accWrap->AsHyperText();
if (!text || !text->IsTextRole()) {
return;
}
if (HyperTextAccessibleBase* text = acc->AsHyperTextBase()) {
text->CopyText(aStartPos, aEndPos);
}

text->CopyText(aStartPos, aEndPos);
} else if (RemoteAccessible* proxy = GetProxy(ATK_OBJECT(aText))) {
proxy->CopyText(aStartPos, aEndPos);
}
}

static void cutTextCB(AtkEditableText* aText, gint aStartPos, gint aEndPos) {
if (Accessible* acc = GetInternalObj(ATK_OBJECT(aText))) {
if (acc->IsTextRole()) {
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
if (accWrap) {
HyperTextAccessible* text = accWrap->AsHyperText();
if (!text || !text->IsTextRole()) {
return;
}
if (HyperTextAccessibleBase* text = acc->AsHyperTextBase()) {
text->CutText(aStartPos, aEndPos);
}

text->CutText(aStartPos, aEndPos);
} else if (RemoteAccessible* proxy = GetProxy(ATK_OBJECT(aText))) {
proxy->CutText(aStartPos, aEndPos);
}
}

static void deleteTextCB(AtkEditableText* aText, gint aStartPos, gint aEndPos) {
if (Accessible* acc = GetInternalObj(ATK_OBJECT(aText))) {
if (acc->IsTextRole()) {
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
if (accWrap) {
HyperTextAccessible* text = accWrap->AsHyperText();
if (!text || !text->IsTextRole()) {
return;
}
if (HyperTextAccessibleBase* text = acc->AsHyperTextBase()) {
text->DeleteText(aStartPos, aEndPos);
}

text->DeleteText(aStartPos, aEndPos);
} else if (RemoteAccessible* proxy = GetProxy(ATK_OBJECT(aText))) {
proxy->DeleteText(aStartPos, aEndPos);
}
}

MOZ_CAN_RUN_SCRIPT_BOUNDARY
static void pasteTextCB(AtkEditableText* aText, gint aPosition) {
if (Accessible* acc = GetInternalObj(ATK_OBJECT(aText))) {
if (acc->IsTextRole()) {
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
if (accWrap) {
RefPtr<HyperTextAccessible> text = accWrap->AsHyperText();
if (!text || !text->IsTextRole()) {
return;
}
if (HyperTextAccessibleBase* text = acc->AsHyperTextBase()) {
text->PasteText(aPosition);
}

text->PasteText(aPosition);
} else if (RemoteAccessible* proxy = GetProxy(ATK_OBJECT(aText))) {
proxy->PasteText(aPosition);
}
}
}
Expand Down
15 changes: 0 additions & 15 deletions accessible/basetypes/HyperTextAccessibleBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,21 +245,6 @@ 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() {
Expand Down
64 changes: 64 additions & 0 deletions accessible/generic/HyperTextAccessible-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,70 @@ 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;
Expand Down
63 changes: 0 additions & 63 deletions accessible/generic/HyperTextAccessible.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -997,69 +997,6 @@ 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

Expand Down
20 changes: 9 additions & 11 deletions accessible/generic/HyperTextAccessible.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,17 +200,15 @@ class HyperTextAccessible : public AccessibleWrap,
//////////////////////////////////////////////////////////////////////////////
// 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;
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);

/**
* Return the editor associated with the accessible.
Expand Down
60 changes: 0 additions & 60 deletions accessible/ipc/DocAccessibleChildBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,66 +265,6 @@ 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;
Expand Down
Loading

0 comments on commit b18a751

Please sign in to comment.