Bug 1523118 atk: Implement scrollsubstringto ATK API. r=surkov
authorSamuel Thibault <samuel.thibault@ens-lyon.org>
Sat, 26 Jan 2019 20:38:53 +0100
changeset 515589 80254b1b3aa1e1a5dece34a9c966ed8ebdb13e8f
parent 515588 47aa4d0b53749a04760a41213d88c2cfed80a870
child 515590 06e3993985b77e62c9b6ee1f9dba87da407eb6d1
child 516521 558f79de8945ab95ded723604575252b18521967
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssurkov
bugs1523118
milestone66.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1523118 atk: Implement scrollsubstringto ATK API. r=surkov
accessible/atk/nsMaiInterfaceText.cpp
other-licenses/atk-1.0/atk/atktext.h
--- a/accessible/atk/nsMaiInterfaceText.cpp
+++ b/accessible/atk/nsMaiInterfaceText.cpp
@@ -585,16 +585,65 @@ static gboolean setCaretOffsetCB(AtkText
 
   if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aText))) {
     proxy->SetCaretOffset(aOffset);
     return TRUE;
   }
 
   return FALSE;
 }
+
+static gboolean scrollSubstringToCB(AtkText* aText,
+                                    gint aStartOffset, gint aEndOffset,
+                                    AtkScrollType aType) {
+  AtkObject* atkObject = ATK_OBJECT(aText);
+  AccessibleWrap* accWrap = GetAccessibleWrap(atkObject);
+  if (accWrap) {
+    HyperTextAccessible* text = accWrap->AsHyperText();
+    if (!text || !text->IsTextRole() ||
+        !text->IsValidRange(aStartOffset, aEndOffset)) {
+      return FALSE;
+    }
+    text->ScrollSubstringTo(aStartOffset, aEndOffset, aType);
+    return TRUE;
+  }
+
+  ProxyAccessible* proxy = GetProxy(atkObject);
+  if (proxy) {
+    proxy->ScrollSubstringTo(aStartOffset, aEndOffset, aType);
+    return TRUE;
+  }
+
+  return FALSE;
+}
+
+static gboolean scrollSubstringToPointCB(AtkText* aText,
+                                         gint aStartOffset, gint aEndOffset,
+                                         AtkCoordType aCoords,
+                                         gint aX, gint aY) {
+  AtkObject* atkObject = ATK_OBJECT(aText);
+  AccessibleWrap* accWrap = GetAccessibleWrap(atkObject);
+  if (accWrap) {
+    HyperTextAccessible* text = accWrap->AsHyperText();
+    if (!text || !text->IsTextRole() ||
+        !text->IsValidRange(aStartOffset, aEndOffset)) {
+      return FALSE;
+    }
+    text->ScrollSubstringToPoint(aStartOffset, aEndOffset, aCoords, aX, aY);
+    return TRUE;
+  }
+
+  ProxyAccessible* proxy = GetProxy(atkObject);
+  if (proxy) {
+    proxy->ScrollSubstringToPoint(aStartOffset, aEndOffset, aCoords, aX, aY);
+    return TRUE;
+  }
+
+  return FALSE;
+}
 }
 
 void textInterfaceInitCB(AtkTextIface* aIface) {
   NS_ASSERTION(aIface, "Invalid aIface");
   if (MOZ_UNLIKELY(!aIface)) return;
 
   aIface->get_text = getTextCB;
   aIface->get_text_after_offset = getTextAfterOffsetCB;
@@ -612,13 +661,18 @@ void textInterfaceInitCB(AtkTextIface* a
   aIface->get_selection = getTextSelectionCB;
 
   // set methods
   aIface->add_selection = addTextSelectionCB;
   aIface->remove_selection = removeTextSelectionCB;
   aIface->set_selection = setTextSelectionCB;
   aIface->set_caret_offset = setCaretOffsetCB;
 
+  if (IsAtkVersionAtLeast(2, 32)) {
+    aIface->scroll_substring_to = scrollSubstringToCB;
+    aIface->scroll_substring_to_point = scrollSubstringToPointCB;
+  }
+
   // Cache the string values of the atk text attribute names.
   for (uint32_t i = 0; i < ArrayLength(sAtkTextAttrNames); i++)
     sAtkTextAttrNames[i] =
         atk_text_attribute_get_name(static_cast<AtkTextAttribute>(i));
 }
--- a/other-licenses/atk-1.0/atk/atktext.h
+++ b/other-licenses/atk-1.0/atk/atktext.h
@@ -132,16 +132,44 @@ typedef enum {
   ATK_TEXT_BOUNDARY_WORD_END,
   ATK_TEXT_BOUNDARY_SENTENCE_START,
   ATK_TEXT_BOUNDARY_SENTENCE_END,
   ATK_TEXT_BOUNDARY_LINE_START,
   ATK_TEXT_BOUNDARY_LINE_END
 } AtkTextBoundary;
 
 /**
+ *AtkTextGranularity:
+ *@ATK_TEXT_GRANULARITY_CHAR: Granularity is defined by the boundaries between characters
+ * (including non-printing characters)
+ *@ATK_TEXT_GRANULARITY_WORD: Granularity is defined by the boundaries of a word,
+ * starting at the beginning of the current word and finishing at the beginning of
+ * the following one, if present.
+ *@ATK_TEXT_GRANULARITY_SENTENCE: Granularity is defined by the boundaries of a sentence,
+ * starting at the beginning of the current sentence and finishing at the beginning of
+ * the following one, if present.
+ *@ATK_TEXT_GRANULARITY_LINE: Granularity is defined by the boundaries of a line,
+ * starting at the beginning of the current line and finishing at the beginning of
+ * the following one, if present.
+ *@ATK_TEXT_GRANULARITY_PARAGRAPH: Granularity is defined by the boundaries of a paragraph,
+ * starting at the beginning of the current paragraph and finishing at the beginning of
+ * the following one, if present.
+ *
+ * Text granularity types used for specifying the granularity of the region of
+ * text we are interested in.
+ **/
+typedef enum {
+  ATK_TEXT_GRANULARITY_CHAR,
+  ATK_TEXT_GRANULARITY_WORD,
+  ATK_TEXT_GRANULARITY_SENTENCE,
+  ATK_TEXT_GRANULARITY_LINE,
+  ATK_TEXT_GRANULARITY_PARAGRAPH
+} AtkTextGranularity;
+
+/**
  * AtkTextRectangle:
  * @x: The horizontal coordinate of a rectangle
  * @y: The vertical coordinate of a rectangle
  * @width: The width of a rectangle
  * @height: The height of a rectangle
  *
  * A structure used to store a rectangle used by AtkText.
  **/
@@ -267,19 +295,43 @@ struct _AtkTextIface
                                                    AtkCoordType     coord_type,
                                                    AtkTextRectangle *rect);
 
   AtkTextRange** (* get_bounded_ranges)           (AtkText          *text,
                                                    AtkTextRectangle *rect,
                                                    AtkCoordType     coord_type,
                                                    AtkTextClipType  x_clip_type,
                                                    AtkTextClipType  y_clip_type);
- 
 
-  AtkFunction    pad4;
+  gchar*         (* get_string_at_offset)         (AtkText            *text,
+                                                   gint               offset,
+                                                   AtkTextGranularity granularity,
+                                                   gint               *start_offset,
+                                                   gint               *end_offset);
+  /*
+   * Scrolls this text range so it becomes visible on the screen.
+   *
+   * scroll_substring_to lets the implementation compute an appropriate target
+   * position on the screen, with type used as a positioning hint.
+   *
+   * scroll_substring_to_point lets the client specify a precise target position
+   * on the screen.
+   *
+   * Since ATK 2.32
+   */
+  gboolean       (* scroll_substring_to)          (AtkText          *text,
+                                                   gint             start_offset,
+                                                   gint             end_offset,
+                                                   AtkScrollType    type);
+  gboolean       (* scroll_substring_to_point)    (AtkText          *text,
+                                                   gint             start_offset,
+                                                   gint             end_offset,
+                                                   AtkCoordType     coords,
+                                                   gint             x,
+                                                   gint             y);
 };
 
 GType            atk_text_get_type (void);
 
 
 /*
  * Additional AtkObject properties used by AtkText:
  *    "accessible_text" (accessible text has changed)
@@ -302,16 +354,21 @@ gchar*        atk_text_get_text_at_offse
                                                            AtkTextBoundary  boundary_type,
 							   gint             *start_offset,
 							   gint             *end_offset);
 gchar*        atk_text_get_text_before_offset             (AtkText          *text,
                                                            gint             offset,
                                                            AtkTextBoundary  boundary_type,
 							   gint             *start_offset,
 							   gint	            *end_offset);
+gchar*        atk_text_get_string_at_offset               (AtkText            *text,
+                                                           gint               offset,
+                                                           AtkTextGranularity granularity,
+                                                           gint               *start_offset,
+                                                           gint               *end_offset);
 gint          atk_text_get_caret_offset                   (AtkText          *text);
 void          atk_text_get_character_extents              (AtkText          *text,
                                                            gint             offset,
                                                            gint             *x,
                                                            gint             *y,
                                                            gint             *width,
                                                            gint             *height,
                                                            AtkCoordType	    coords);
@@ -354,14 +411,26 @@ AtkTextRange**  atk_text_get_bounded_ran
                                                            AtkTextClipType  y_clip_type);
 void          atk_text_free_ranges                        (AtkTextRange     **ranges);
 void 	      atk_attribute_set_free                      (AtkAttributeSet  *attrib_set);
 G_CONST_RETURN gchar*  atk_text_attribute_get_name        (AtkTextAttribute attr);
 AtkTextAttribute       atk_text_attribute_for_name        (const gchar      *name);
 G_CONST_RETURN gchar*  atk_text_attribute_get_value       (AtkTextAttribute attr,
                                                            gint             index_);
 
+gboolean      atk_text_scroll_substring_to                (AtkText          *text,
+                                                           gint             start_offset,
+                                                           gint             end_offset,
+                                                           AtkScrollType    type);
+
+gboolean      atk_text_scroll_substring_to_point          (AtkText          *text,
+                                                           gint             start_offset,
+                                                           gint             end_offset,
+                                                           AtkCoordType     coords,
+                                                           gint             x,
+                                                           gint             y);
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
 
 
 #endif /* __ATK_TEXT_H__ */