зеркало из https://github.com/mozilla/gecko-dev.git
bug 783372 - use HyperTextAccessible directly in nsMaiInterface{,Editable}Text r=surkov
This commit is contained in:
Родитель
52c1f879a1
Коммит
b7e8f47b30
|
@ -12,28 +12,6 @@
|
||||||
#include "nsString.h"
|
#include "nsString.h"
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
||||||
static gboolean
|
|
||||||
setRunAttributesCB(AtkEditableText *aText, AtkAttributeSet *aAttribSet,
|
|
||||||
gint aStartOffset, gint aEndOffset)
|
|
||||||
{
|
|
||||||
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
|
|
||||||
if (!accWrap)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
nsCOMPtr<nsIAccessibleEditableText> accText;
|
|
||||||
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleEditableText),
|
|
||||||
getter_AddRefs(accText));
|
|
||||||
NS_ENSURE_TRUE(accText, FALSE);
|
|
||||||
|
|
||||||
nsCOMPtr<nsISupports> attrSet;
|
|
||||||
/* how to insert attributes into nsISupports ??? */
|
|
||||||
|
|
||||||
nsresult rv = accText->SetAttributes(aStartOffset, aEndOffset,
|
|
||||||
attrSet);
|
|
||||||
return NS_FAILED(rv) ? FALSE : TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
setTextContentsCB(AtkEditableText *aText, const gchar *aString)
|
setTextContentsCB(AtkEditableText *aText, const gchar *aString)
|
||||||
{
|
{
|
||||||
|
@ -41,16 +19,14 @@ setTextContentsCB(AtkEditableText *aText, const gchar *aString)
|
||||||
if (!accWrap)
|
if (!accWrap)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
nsCOMPtr<nsIAccessibleEditableText> accText;
|
HyperTextAccessible* text = accWrap->AsHyperText();
|
||||||
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleEditableText),
|
if (!text || !text->IsTextRole())
|
||||||
getter_AddRefs(accText));
|
return;
|
||||||
if (!accText)
|
|
||||||
return;
|
|
||||||
|
|
||||||
MAI_LOG_DEBUG(("EditableText: setTextContentsCB, aString=%s", aString));
|
MAI_LOG_DEBUG(("EditableText: setTextContentsCB, aString=%s", aString));
|
||||||
|
|
||||||
NS_ConvertUTF8toUTF16 strContent(aString);
|
NS_ConvertUTF8toUTF16 strContent(aString);
|
||||||
accText->SetTextContents(strContent);
|
text->SetTextContents(strContent);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -61,24 +37,15 @@ insertTextCB(AtkEditableText *aText,
|
||||||
if (!accWrap)
|
if (!accWrap)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
nsCOMPtr<nsIAccessibleEditableText> accText;
|
HyperTextAccessible* text = accWrap->AsHyperText();
|
||||||
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleEditableText),
|
if (!text || !text->IsTextRole())
|
||||||
getter_AddRefs(accText));
|
return;
|
||||||
if (!accText)
|
|
||||||
return;
|
|
||||||
|
|
||||||
NS_ConvertUTF8toUTF16 strContent(aString, aLength);
|
NS_ConvertUTF8toUTF16 strContent(aString, aLength);
|
||||||
|
text->InsertText(strContent, *aPosition);
|
||||||
|
|
||||||
// interface changed in nsIAccessibleEditableText.idl ???
|
MAI_LOG_DEBUG(("EditableText: insert aString=%s, aLength=%d, aPosition=%d",
|
||||||
//
|
aString, aLength, *aPosition));
|
||||||
// int32_t pos = *aPosition;
|
|
||||||
// nsresult rv = accText->InsertText(strContent, aLength, &pos);
|
|
||||||
// *aPosition = pos;
|
|
||||||
|
|
||||||
accText->InsertText(strContent, *aPosition);
|
|
||||||
|
|
||||||
MAI_LOG_DEBUG(("EditableText: insert aString=%s, aLength=%d, aPosition=%d",
|
|
||||||
aString, aLength, *aPosition));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -88,15 +55,13 @@ copyTextCB(AtkEditableText *aText, gint aStartPos, gint aEndPos)
|
||||||
if (!accWrap)
|
if (!accWrap)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
nsCOMPtr<nsIAccessibleEditableText> accText;
|
HyperTextAccessible* text = accWrap->AsHyperText();
|
||||||
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleEditableText),
|
if (!text || !text->IsTextRole())
|
||||||
getter_AddRefs(accText));
|
return;
|
||||||
if (!accText)
|
|
||||||
return;
|
|
||||||
|
|
||||||
MAI_LOG_DEBUG(("EditableText: copyTextCB, aStartPos=%d, aEndPos=%d",
|
MAI_LOG_DEBUG(("EditableText: copyTextCB, aStartPos=%d, aEndPos=%d",
|
||||||
aStartPos, aEndPos));
|
aStartPos, aEndPos));
|
||||||
accText->CopyText(aStartPos, aEndPos);
|
text->CopyText(aStartPos, aEndPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -106,14 +71,13 @@ cutTextCB(AtkEditableText *aText, gint aStartPos, gint aEndPos)
|
||||||
if (!accWrap)
|
if (!accWrap)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
nsCOMPtr<nsIAccessibleEditableText> accText;
|
HyperTextAccessible* text = accWrap->AsHyperText();
|
||||||
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleEditableText),
|
if (!text || !text->IsTextRole())
|
||||||
getter_AddRefs(accText));
|
return;
|
||||||
if (!accText)
|
|
||||||
return;
|
MAI_LOG_DEBUG(("EditableText: cutTextCB, aStartPos=%d, aEndPos=%d",
|
||||||
MAI_LOG_DEBUG(("EditableText: cutTextCB, aStartPos=%d, aEndPos=%d",
|
aStartPos, aEndPos));
|
||||||
aStartPos, aEndPos));
|
text->CutText(aStartPos, aEndPos);
|
||||||
accText->CutText(aStartPos, aEndPos);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -123,15 +87,13 @@ deleteTextCB(AtkEditableText *aText, gint aStartPos, gint aEndPos)
|
||||||
if (!accWrap)
|
if (!accWrap)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
nsCOMPtr<nsIAccessibleEditableText> accText;
|
HyperTextAccessible* text = accWrap->AsHyperText();
|
||||||
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleEditableText),
|
if (!text || !text->IsTextRole())
|
||||||
getter_AddRefs(accText));
|
return;
|
||||||
if (!accText)
|
|
||||||
return;
|
|
||||||
|
|
||||||
MAI_LOG_DEBUG(("EditableText: deleteTextCB, aStartPos=%d, aEndPos=%d",
|
MAI_LOG_DEBUG(("EditableText: deleteTextCB, aStartPos=%d, aEndPos=%d",
|
||||||
aStartPos, aEndPos));
|
aStartPos, aEndPos));
|
||||||
accText->DeleteText(aStartPos, aEndPos);
|
text->DeleteText(aStartPos, aEndPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -141,14 +103,12 @@ pasteTextCB(AtkEditableText *aText, gint aPosition)
|
||||||
if (!accWrap)
|
if (!accWrap)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
nsCOMPtr<nsIAccessibleEditableText> accText;
|
HyperTextAccessible* text = accWrap->AsHyperText();
|
||||||
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleEditableText),
|
if (!text || !text->IsTextRole())
|
||||||
getter_AddRefs(accText));
|
return;
|
||||||
if (!accText)
|
|
||||||
return;
|
|
||||||
|
|
||||||
MAI_LOG_DEBUG(("EditableText: pasteTextCB, aPosition=%d", aPosition));
|
MAI_LOG_DEBUG(("EditableText: pasteTextCB, aPosition=%d", aPosition));
|
||||||
accText->PasteText(aPosition);
|
text->PasteText(aPosition);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,7 +119,6 @@ editableTextInterfaceInitCB(AtkEditableTextIface* aIface)
|
||||||
if (NS_UNLIKELY(!aIface))
|
if (NS_UNLIKELY(!aIface))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
aIface->set_run_attributes = setRunAttributesCB;
|
|
||||||
aIface->set_text_contents = setTextContentsCB;
|
aIface->set_text_contents = setTextContentsCB;
|
||||||
aIface->insert_text = insertTextCB;
|
aIface->insert_text = insertTextCB;
|
||||||
aIface->copy_text = copyTextCB;
|
aIface->copy_text = copyTextCB;
|
||||||
|
|
|
@ -34,13 +34,12 @@ getTextCB(AtkText *aText, gint aStartOffset, gint aEndOffset)
|
||||||
if (!accWrap)
|
if (!accWrap)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
nsCOMPtr<nsIAccessibleText> accText;
|
HyperTextAccessible* text = accWrap->AsHyperText();
|
||||||
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
|
if (!text || !text->IsTextRole())
|
||||||
getter_AddRefs(accText));
|
return nullptr;
|
||||||
NS_ENSURE_TRUE(accText, nullptr);
|
|
||||||
|
|
||||||
nsAutoString autoStr;
|
nsAutoString autoStr;
|
||||||
nsresult rv = accText->GetText(aStartOffset, aEndOffset, autoStr);
|
nsresult rv = text->GetText(aStartOffset, aEndOffset, autoStr);
|
||||||
NS_ENSURE_SUCCESS(rv, nullptr);
|
NS_ENSURE_SUCCESS(rv, nullptr);
|
||||||
|
|
||||||
ConvertTexttoAsterisks(accWrap, autoStr);
|
ConvertTexttoAsterisks(accWrap, autoStr);
|
||||||
|
@ -59,20 +58,20 @@ getTextAfterOffsetCB(AtkText *aText, gint aOffset,
|
||||||
if (!accWrap)
|
if (!accWrap)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
nsCOMPtr<nsIAccessibleText> accText;
|
HyperTextAccessible* text = accWrap->AsHyperText();
|
||||||
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
|
if (!text || !text->IsTextRole())
|
||||||
getter_AddRefs(accText));
|
return nullptr;
|
||||||
NS_ENSURE_TRUE(accText, nullptr);
|
|
||||||
|
|
||||||
nsAutoString autoStr;
|
nsAutoString autoStr;
|
||||||
int32_t startOffset = 0, endOffset = 0;
|
int32_t startOffset = 0, endOffset = 0;
|
||||||
nsresult rv =
|
nsresult rv =
|
||||||
accText->GetTextAfterOffset(aOffset, aBoundaryType,
|
text->GetTextAfterOffset(aOffset, aBoundaryType,
|
||||||
&startOffset, &endOffset, autoStr);
|
&startOffset, &endOffset, autoStr);
|
||||||
*aStartOffset = startOffset;
|
|
||||||
*aEndOffset = endOffset;
|
|
||||||
|
|
||||||
NS_ENSURE_SUCCESS(rv, nullptr);
|
*aStartOffset = startOffset;
|
||||||
|
*aEndOffset = endOffset;
|
||||||
|
|
||||||
|
NS_ENSURE_SUCCESS(rv, nullptr);
|
||||||
|
|
||||||
ConvertTexttoAsterisks(accWrap, autoStr);
|
ConvertTexttoAsterisks(accWrap, autoStr);
|
||||||
NS_ConvertUTF16toUTF8 cautoStr(autoStr);
|
NS_ConvertUTF16toUTF8 cautoStr(autoStr);
|
||||||
|
@ -88,16 +87,15 @@ getTextAtOffsetCB(AtkText *aText, gint aOffset,
|
||||||
if (!accWrap)
|
if (!accWrap)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
nsCOMPtr<nsIAccessibleText> accText;
|
HyperTextAccessible* text = accWrap->AsHyperText();
|
||||||
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
|
if (!text || !text->IsTextRole())
|
||||||
getter_AddRefs(accText));
|
return nullptr;
|
||||||
NS_ENSURE_TRUE(accText, nullptr);
|
|
||||||
|
|
||||||
nsAutoString autoStr;
|
nsAutoString autoStr;
|
||||||
int32_t startOffset = 0, endOffset = 0;
|
int32_t startOffset = 0, endOffset = 0;
|
||||||
nsresult rv =
|
nsresult rv =
|
||||||
accText->GetTextAtOffset(aOffset, aBoundaryType,
|
text->GetTextAtOffset(aOffset, aBoundaryType,
|
||||||
&startOffset, &endOffset, autoStr);
|
&startOffset, &endOffset, autoStr);
|
||||||
*aStartOffset = startOffset;
|
*aStartOffset = startOffset;
|
||||||
*aEndOffset = endOffset;
|
*aEndOffset = endOffset;
|
||||||
|
|
||||||
|
@ -115,15 +113,14 @@ getCharacterAtOffsetCB(AtkText* aText, gint aOffset)
|
||||||
if (!accWrap)
|
if (!accWrap)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
nsCOMPtr<nsIAccessibleText> accText;
|
HyperTextAccessible* text = accWrap->AsHyperText();
|
||||||
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
|
if (!text || !text->IsTextRole())
|
||||||
getter_AddRefs(accText));
|
return 0;
|
||||||
NS_ENSURE_TRUE(accText, 0);
|
|
||||||
|
|
||||||
// PRUnichar is unsigned short in Mozilla
|
// PRUnichar is unsigned short in Mozilla
|
||||||
// gnuichar is guint32 in glib
|
// gnuichar is guint32 in glib
|
||||||
PRUnichar uniChar = 0;
|
PRUnichar uniChar = 0;
|
||||||
nsresult rv = accText->GetCharacterAtOffset(aOffset, &uniChar);
|
nsresult rv = text->GetCharacterAtOffset(aOffset, &uniChar);
|
||||||
if (NS_FAILED(rv))
|
if (NS_FAILED(rv))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -143,16 +140,15 @@ getTextBeforeOffsetCB(AtkText *aText, gint aOffset,
|
||||||
if (!accWrap)
|
if (!accWrap)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
nsCOMPtr<nsIAccessibleText> accText;
|
HyperTextAccessible* text = accWrap->AsHyperText();
|
||||||
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
|
if (!text || !text->IsTextRole())
|
||||||
getter_AddRefs(accText));
|
return nullptr;
|
||||||
NS_ENSURE_TRUE(accText, nullptr);
|
|
||||||
|
|
||||||
nsAutoString autoStr;
|
nsAutoString autoStr;
|
||||||
int32_t startOffset = 0, endOffset = 0;
|
int32_t startOffset = 0, endOffset = 0;
|
||||||
nsresult rv =
|
nsresult rv =
|
||||||
accText->GetTextBeforeOffset(aOffset, aBoundaryType,
|
text->GetTextBeforeOffset(aOffset, aBoundaryType,
|
||||||
&startOffset, &endOffset, autoStr);
|
&startOffset, &endOffset, autoStr);
|
||||||
*aStartOffset = startOffset;
|
*aStartOffset = startOffset;
|
||||||
*aEndOffset = endOffset;
|
*aEndOffset = endOffset;
|
||||||
|
|
||||||
|
@ -170,13 +166,12 @@ getCaretOffsetCB(AtkText *aText)
|
||||||
if (!accWrap)
|
if (!accWrap)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
nsCOMPtr<nsIAccessibleText> accText;
|
HyperTextAccessible* text = accWrap->AsHyperText();
|
||||||
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
|
if (!text || !text->IsTextRole())
|
||||||
getter_AddRefs(accText));
|
return 0;
|
||||||
NS_ENSURE_TRUE(accText, 0);
|
|
||||||
|
|
||||||
int32_t offset;
|
int32_t offset;
|
||||||
nsresult rv = accText->GetCaretOffset(&offset);
|
nsresult rv = text->GetCaretOffset(&offset);
|
||||||
return (NS_FAILED(rv)) ? 0 : static_cast<gint>(offset);
|
return (NS_FAILED(rv)) ? 0 : static_cast<gint>(offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,16 +187,15 @@ getRunAttributesCB(AtkText *aText, gint aOffset,
|
||||||
if (!accWrap)
|
if (!accWrap)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
nsCOMPtr<nsIAccessibleText> accText;
|
HyperTextAccessible* text = accWrap->AsHyperText();
|
||||||
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
|
if (!text || !text->IsTextRole())
|
||||||
getter_AddRefs(accText));
|
return nullptr;
|
||||||
NS_ENSURE_TRUE(accText, nullptr);
|
|
||||||
|
|
||||||
nsCOMPtr<nsIPersistentProperties> attributes;
|
nsCOMPtr<nsIPersistentProperties> attributes;
|
||||||
int32_t startOffset = 0, endOffset = 0;
|
int32_t startOffset = 0, endOffset = 0;
|
||||||
nsresult rv = accText->GetTextAttributes(false, aOffset,
|
nsresult rv = text->GetTextAttributes(false, aOffset,
|
||||||
&startOffset, &endOffset,
|
&startOffset, &endOffset,
|
||||||
getter_AddRefs(attributes));
|
getter_AddRefs(attributes));
|
||||||
NS_ENSURE_SUCCESS(rv, nullptr);
|
NS_ENSURE_SUCCESS(rv, nullptr);
|
||||||
|
|
||||||
*aStartOffset = startOffset;
|
*aStartOffset = startOffset;
|
||||||
|
@ -217,13 +211,12 @@ getDefaultAttributesCB(AtkText *aText)
|
||||||
if (!accWrap)
|
if (!accWrap)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
nsCOMPtr<nsIAccessibleText> accText;
|
HyperTextAccessible* text = accWrap->AsHyperText();
|
||||||
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
|
if (!text || !text->IsTextRole())
|
||||||
getter_AddRefs(accText));
|
return nullptr;
|
||||||
NS_ENSURE_TRUE(accText, nullptr);
|
|
||||||
|
|
||||||
nsCOMPtr<nsIPersistentProperties> attributes;
|
nsCOMPtr<nsIPersistentProperties> attributes;
|
||||||
nsresult rv = accText->GetDefaultTextAttributes(getter_AddRefs(attributes));
|
nsresult rv = text->GetDefaultTextAttributes(getter_AddRefs(attributes));
|
||||||
if (NS_FAILED(rv))
|
if (NS_FAILED(rv))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
|
@ -240,11 +233,9 @@ getCharacterExtentsCB(AtkText *aText, gint aOffset,
|
||||||
if(!accWrap || !aX || !aY || !aWidth || !aHeight)
|
if(!accWrap || !aX || !aY || !aWidth || !aHeight)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
nsCOMPtr<nsIAccessibleText> accText;
|
HyperTextAccessible* text = accWrap->AsHyperText();
|
||||||
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
|
if (!text || !text->IsTextRole())
|
||||||
getter_AddRefs(accText));
|
return;
|
||||||
if (!accText)
|
|
||||||
return;
|
|
||||||
|
|
||||||
int32_t extY = 0, extX = 0;
|
int32_t extY = 0, extX = 0;
|
||||||
int32_t extWidth = 0, extHeight = 0;
|
int32_t extWidth = 0, extHeight = 0;
|
||||||
|
@ -258,9 +249,9 @@ getCharacterExtentsCB(AtkText *aText, gint aOffset,
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
nsresult rv =
|
nsresult rv =
|
||||||
#endif
|
#endif
|
||||||
accText->GetCharacterExtents(aOffset, &extX, &extY,
|
text->GetCharacterExtents(aOffset, &extX, &extY,
|
||||||
&extWidth, &extHeight,
|
&extWidth, &extHeight,
|
||||||
geckoCoordType);
|
geckoCoordType);
|
||||||
*aX = extX;
|
*aX = extX;
|
||||||
*aY = extY;
|
*aY = extY;
|
||||||
*aWidth = extWidth;
|
*aWidth = extWidth;
|
||||||
|
@ -277,11 +268,9 @@ getRangeExtentsCB(AtkText *aText, gint aStartOffset, gint aEndOffset,
|
||||||
if(!accWrap || !aRect)
|
if(!accWrap || !aRect)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
nsCOMPtr<nsIAccessibleText> accText;
|
HyperTextAccessible* text = accWrap->AsHyperText();
|
||||||
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
|
if (!text || !text->IsTextRole())
|
||||||
getter_AddRefs(accText));
|
return;
|
||||||
if (!accText)
|
|
||||||
return;
|
|
||||||
|
|
||||||
int32_t extY = 0, extX = 0;
|
int32_t extY = 0, extX = 0;
|
||||||
int32_t extWidth = 0, extHeight = 0;
|
int32_t extWidth = 0, extHeight = 0;
|
||||||
|
@ -295,10 +284,10 @@ getRangeExtentsCB(AtkText *aText, gint aStartOffset, gint aEndOffset,
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
nsresult rv =
|
nsresult rv =
|
||||||
#endif
|
#endif
|
||||||
accText->GetRangeExtents(aStartOffset, aEndOffset,
|
text->GetRangeExtents(aStartOffset, aEndOffset,
|
||||||
&extX, &extY,
|
&extX, &extY,
|
||||||
&extWidth, &extHeight,
|
&extWidth, &extHeight,
|
||||||
geckoCoordType);
|
geckoCoordType);
|
||||||
aRect->x = extX;
|
aRect->x = extX;
|
||||||
aRect->y = extY;
|
aRect->y = extY;
|
||||||
aRect->width = extWidth;
|
aRect->width = extWidth;
|
||||||
|
@ -328,10 +317,9 @@ getOffsetAtPointCB(AtkText *aText,
|
||||||
if (!accWrap)
|
if (!accWrap)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
nsCOMPtr<nsIAccessibleText> accText;
|
HyperTextAccessible* text = accWrap->AsHyperText();
|
||||||
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
|
if (!text || !text->IsTextRole())
|
||||||
getter_AddRefs(accText));
|
return -1;
|
||||||
NS_ENSURE_TRUE(accText, -1);
|
|
||||||
|
|
||||||
int32_t offset = 0;
|
int32_t offset = 0;
|
||||||
uint32_t geckoCoordType;
|
uint32_t geckoCoordType;
|
||||||
|
@ -340,7 +328,7 @@ getOffsetAtPointCB(AtkText *aText,
|
||||||
else
|
else
|
||||||
geckoCoordType = nsIAccessibleCoordinateType::COORDTYPE_WINDOW_RELATIVE;
|
geckoCoordType = nsIAccessibleCoordinateType::COORDTYPE_WINDOW_RELATIVE;
|
||||||
|
|
||||||
accText->GetOffsetAtPoint(aX, aY, geckoCoordType, &offset);
|
text->GetOffsetAtPoint(aX, aY, geckoCoordType, &offset);
|
||||||
return static_cast<gint>(offset);
|
return static_cast<gint>(offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -351,13 +339,12 @@ getTextSelectionCountCB(AtkText *aText)
|
||||||
if (!accWrap)
|
if (!accWrap)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
nsCOMPtr<nsIAccessibleText> accText;
|
HyperTextAccessible* text = accWrap->AsHyperText();
|
||||||
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
|
if (!text || !text->IsTextRole())
|
||||||
getter_AddRefs(accText));
|
return 0;
|
||||||
NS_ENSURE_TRUE(accText, 0);
|
|
||||||
|
|
||||||
int32_t selectionCount;
|
int32_t selectionCount;
|
||||||
nsresult rv = accText->GetSelectionCount(&selectionCount);
|
nsresult rv = text->GetSelectionCount(&selectionCount);
|
||||||
|
|
||||||
return NS_FAILED(rv) ? 0 : selectionCount;
|
return NS_FAILED(rv) ? 0 : selectionCount;
|
||||||
}
|
}
|
||||||
|
@ -370,14 +357,13 @@ getTextSelectionCB(AtkText *aText, gint aSelectionNum,
|
||||||
if (!accWrap)
|
if (!accWrap)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
nsCOMPtr<nsIAccessibleText> accText;
|
HyperTextAccessible* text = accWrap->AsHyperText();
|
||||||
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
|
if (!text || !text->IsTextRole())
|
||||||
getter_AddRefs(accText));
|
return nullptr;
|
||||||
NS_ENSURE_TRUE(accText, nullptr);
|
|
||||||
|
|
||||||
int32_t startOffset = 0, endOffset = 0;
|
int32_t startOffset = 0, endOffset = 0;
|
||||||
nsresult rv = accText->GetSelectionBounds(aSelectionNum,
|
nsresult rv = text->GetSelectionBounds(aSelectionNum,
|
||||||
&startOffset, &endOffset);
|
&startOffset, &endOffset);
|
||||||
|
|
||||||
*aStartOffset = startOffset;
|
*aStartOffset = startOffset;
|
||||||
*aEndOffset = endOffset;
|
*aEndOffset = endOffset;
|
||||||
|
@ -397,12 +383,11 @@ addTextSelectionCB(AtkText *aText,
|
||||||
if (!accWrap)
|
if (!accWrap)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
nsCOMPtr<nsIAccessibleText> accText;
|
HyperTextAccessible* text = accWrap->AsHyperText();
|
||||||
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
|
if (!text || !text->IsTextRole())
|
||||||
getter_AddRefs(accText));
|
return false;
|
||||||
NS_ENSURE_TRUE(accText, FALSE);
|
|
||||||
|
|
||||||
nsresult rv = accText->AddSelection(aStartOffset, aEndOffset);
|
nsresult rv = text->AddSelection(aStartOffset, aEndOffset);
|
||||||
|
|
||||||
return NS_SUCCEEDED(rv) ? TRUE : FALSE;
|
return NS_SUCCEEDED(rv) ? TRUE : FALSE;
|
||||||
}
|
}
|
||||||
|
@ -415,12 +400,11 @@ removeTextSelectionCB(AtkText *aText,
|
||||||
if (!accWrap)
|
if (!accWrap)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
nsCOMPtr<nsIAccessibleText> accText;
|
HyperTextAccessible* text = accWrap->AsHyperText();
|
||||||
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
|
if (!text || !text->IsTextRole())
|
||||||
getter_AddRefs(accText));
|
return false;
|
||||||
NS_ENSURE_TRUE(accText, FALSE);
|
|
||||||
|
|
||||||
nsresult rv = accText->RemoveSelection(aSelectionNum);
|
nsresult rv = text->RemoveSelection(aSelectionNum);
|
||||||
|
|
||||||
return NS_SUCCEEDED(rv) ? TRUE : FALSE;
|
return NS_SUCCEEDED(rv) ? TRUE : FALSE;
|
||||||
}
|
}
|
||||||
|
@ -433,13 +417,12 @@ setTextSelectionCB(AtkText *aText, gint aSelectionNum,
|
||||||
if (!accWrap)
|
if (!accWrap)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
nsCOMPtr<nsIAccessibleText> accText;
|
HyperTextAccessible* text = accWrap->AsHyperText();
|
||||||
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
|
if (!text || !text->IsTextRole())
|
||||||
getter_AddRefs(accText));
|
return false;
|
||||||
NS_ENSURE_TRUE(accText, FALSE);
|
|
||||||
|
|
||||||
nsresult rv = accText->SetSelectionBounds(aSelectionNum,
|
nsresult rv = text->SetSelectionBounds(aSelectionNum,
|
||||||
aStartOffset, aEndOffset);
|
aStartOffset, aEndOffset);
|
||||||
return NS_SUCCEEDED(rv) ? TRUE : FALSE;
|
return NS_SUCCEEDED(rv) ? TRUE : FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -450,12 +433,11 @@ setCaretOffsetCB(AtkText *aText, gint aOffset)
|
||||||
if (!accWrap)
|
if (!accWrap)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
nsCOMPtr<nsIAccessibleText> accText;
|
HyperTextAccessible* text = accWrap->AsHyperText();
|
||||||
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
|
if (!text || !text->IsTextRole())
|
||||||
getter_AddRefs(accText));
|
return false;
|
||||||
NS_ENSURE_TRUE(accText, FALSE);
|
|
||||||
|
|
||||||
nsresult rv = accText->SetCaretOffset(aOffset);
|
nsresult rv = text->SetCaretOffset(aOffset);
|
||||||
return NS_SUCCEEDED(rv) ? TRUE : FALSE;
|
return NS_SUCCEEDED(rv) ? TRUE : FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче