Title: [148749] trunk/Source/WebCore
Revision
148749
Author
[email protected]
Date
2013-04-19 09:03:46 -0700 (Fri, 19 Apr 2013)

Log Message

[GTK] Minimize calls to GailTextUtil in AtkText implementation
https://bugs.webkit.org/show_bug.cgi?id=114868

Patch by Mario Sanchez Prada <[email protected]> on 2013-04-19
Reviewed by Martin Robinson.

Create a new helper function to concentrate inside of it the calls to
gail_text_util_get_text(), so we can get rid of it later more easily.

* accessibility/atk/WebKitAccessibleInterfaceText.cpp:
(webkitAccessibleTextGetTextForOffset): New helper function.
(webkitAccessibleTextGetTextAfterOffset): Rely on the new function.
(webkitAccessibleTextGetTextAtOffset): Ditto.
(webkitAccessibleTextGetTextBeforeOffset): Ditto.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (148748 => 148749)


--- trunk/Source/WebCore/ChangeLog	2013-04-19 16:01:25 UTC (rev 148748)
+++ trunk/Source/WebCore/ChangeLog	2013-04-19 16:03:46 UTC (rev 148749)
@@ -1,3 +1,19 @@
+2013-04-19  Mario Sanchez Prada  <[email protected]>
+
+        [GTK] Minimize calls to GailTextUtil in AtkText implementation
+        https://bugs.webkit.org/show_bug.cgi?id=114868
+
+        Reviewed by Martin Robinson.
+
+        Create a new helper function to concentrate inside of it the calls to
+        gail_text_util_get_text(), so we can get rid of it later more easily.
+
+        * accessibility/atk/WebKitAccessibleInterfaceText.cpp:
+        (webkitAccessibleTextGetTextForOffset): New helper function.
+        (webkitAccessibleTextGetTextAfterOffset): Rely on the new function.
+        (webkitAccessibleTextGetTextAtOffset): Ditto.
+        (webkitAccessibleTextGetTextBeforeOffset): Ditto.
+
 2013-04-19  Noam Rosenthal  <[email protected]>
 
         [Texmap] Implementation for pattern compositing

Modified: trunk/Source/WebCore/accessibility/atk/WebKitAccessibleInterfaceText.cpp (148748 => 148749)


--- trunk/Source/WebCore/accessibility/atk/WebKitAccessibleInterfaceText.cpp	2013-04-19 16:01:25 UTC (rev 148748)
+++ trunk/Source/WebCore/accessibility/atk/WebKitAccessibleInterfaceText.cpp	2013-04-19 16:03:46 UTC (rev 148749)
@@ -567,11 +567,38 @@
     return g_strdup(ret.utf8().data());
 }
 
-static gchar* webkitAccessibleTextGetTextAfterOffset(AtkText* text, gint offset, AtkTextBoundary boundaryType, gint* startOffset, gint* endOffset)
+enum GetTextRelativePosition {
+    GetTextPositionAt,
+    GetTextPositionBefore,
+    GetTextPositionAfter
+};
+
+static gchar* webkitAccessibleTextGetTextForOffset(AtkText* text, gint offset, AtkTextBoundary boundaryType, GetTextRelativePosition textPosition, gint* startOffset, gint* endOffset)
 {
 #if PLATFORM(GTK)
-    return gail_text_util_get_text(getGailTextUtilForAtk(text), getPangoLayoutForAtk(text), GAIL_AFTER_OFFSET, boundaryType, offset, startOffset, endOffset);
-#else
+    // FIXME: Get rid of the code below once every single get_text_*_offset
+    // function has been properly implemented without using Pango/Cairo.
+    GailOffsetType offsetType;
+    switch (textPosition) {
+    case GetTextPositionBefore:
+        offsetType = GAIL_BEFORE_OFFSET;
+        break;
+
+    case GetTextPositionAt:
+        offsetType = GAIL_AT_OFFSET;
+        break;
+
+    case GetTextPositionAfter:
+        offsetType = GAIL_AFTER_OFFSET;
+        break;
+
+    default:
+        ASSERT_NOT_REACHED();
+    }
+
+    return gail_text_util_get_text(getGailTextUtilForAtk(text), getPangoLayoutForAtk(text), offsetType, boundaryType, offset, startOffset, endOffset);
+#endif
+
     UNUSED_PARAM(text);
     UNUSED_PARAM(offset);
     UNUSED_PARAM(boundaryType);
@@ -580,39 +607,21 @@
 
     notImplemented();
     return 0;
-#endif
 }
 
+static gchar* webkitAccessibleTextGetTextAfterOffset(AtkText* text, gint offset, AtkTextBoundary boundaryType, gint* startOffset, gint* endOffset)
+{
+    return webkitAccessibleTextGetTextForOffset(text, offset, boundaryType, GetTextPositionAfter, startOffset, endOffset);
+}
+
 static gchar* webkitAccessibleTextGetTextAtOffset(AtkText* text, gint offset, AtkTextBoundary boundaryType, gint* startOffset, gint* endOffset)
 {
-#if PLATFORM(GTK)
-    return gail_text_util_get_text(getGailTextUtilForAtk(text), getPangoLayoutForAtk(text), GAIL_AT_OFFSET, boundaryType, offset, startOffset, endOffset);
-#else
-    UNUSED_PARAM(text);
-    UNUSED_PARAM(offset);
-    UNUSED_PARAM(boundaryType);
-    UNUSED_PARAM(startOffset);
-    UNUSED_PARAM(endOffset);
-
-    notImplemented();
-    return 0;
-#endif
+    return webkitAccessibleTextGetTextForOffset(text, offset, boundaryType, GetTextPositionAt, startOffset, endOffset);
 }
 
 static gchar* webkitAccessibleTextGetTextBeforeOffset(AtkText* text, gint offset, AtkTextBoundary boundaryType, gint* startOffset, gint* endOffset)
 {
-#if PLATFORM(GTK)
-    return gail_text_util_get_text(getGailTextUtilForAtk(text), getPangoLayoutForAtk(text), GAIL_BEFORE_OFFSET, boundaryType, offset, startOffset, endOffset);
-#else
-    UNUSED_PARAM(text);
-    UNUSED_PARAM(offset);
-    UNUSED_PARAM(boundaryType);
-    UNUSED_PARAM(startOffset);
-    UNUSED_PARAM(endOffset);
-
-    notImplemented();
-    return 0;
-#endif
+    return webkitAccessibleTextGetTextForOffset(text, offset, boundaryType, GetTextPositionBefore, startOffset, endOffset);
 }
 
 static gunichar webkitAccessibleTextGetCharacterAtOffset(AtkText*, gint)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to