Skip to content

Commit

Permalink
Merge r155520 - [GTK] Get rid of Pango/Gail dependencies in accessibi…
Browse files Browse the repository at this point in the history
…lity for ATK

https://bugs.webkit.org/show_bug.cgi?id=114867

Reviewed by Martin Robinson.

Removed all trace of Gail and Pango specific code from the AtkText
implementation, now everything has been reimplemented.

* accessibility/atk/WebKitAccessibleInterfaceText.cpp:
(webkitAccessibleTextGetTextForOffset): Removed fallback code
relying in Gail/Pango, now all the related code has been
removed. Also, replaced the collection of if statements with a
switch, for better readability of the code.
  • Loading branch information
mariospr authored and carlosgcampos committed Sep 16, 2013
1 parent 308b28a commit cab733a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 67 deletions.
16 changes: 16 additions & 0 deletions Source/WebCore/ChangeLog
@@ -1,3 +1,19 @@
2013-09-11 Mario Sanchez Prada <mario.prada@samsung.com>

[GTK] Get rid of Pango/Gail dependencies in accessibility for ATK
https://bugs.webkit.org/show_bug.cgi?id=114867

Reviewed by Martin Robinson.

Removed all trace of Gail and Pango specific code from the AtkText
implementation, now everything has been reimplemented.

* accessibility/atk/WebKitAccessibleInterfaceText.cpp:
(webkitAccessibleTextGetTextForOffset): Removed fallback code
relying in Gail/Pango, now all the related code has been
removed. Also, replaced the collection of if statements with a
switch, for better readability of the code.

2013-09-10 Mario Sanchez Prada <mario.prada@samsung.com>

[GTK] Reimplement atk_text_get_text_*_offset for LINE boundaries
Expand Down
79 changes: 12 additions & 67 deletions Source/WebCore/accessibility/atk/WebKitAccessibleInterfaceText.cpp
Expand Up @@ -55,11 +55,6 @@
#include <wtf/gobject/GOwnPtr.h>
#include <wtf/text/CString.h>

#if PLATFORM(GTK)
#include <libgail-util/gail-util.h>
#include <pango/pango.h>
#endif

using namespace WebCore;

static AccessibilityObject* core(AtkText* text)
Expand Down Expand Up @@ -165,39 +160,6 @@ static gchar* textForObject(const AccessibilityObject* coreObject)
return g_string_free(str, FALSE);
}

static gchar* webkitAccessibleTextGetText(AtkText*, gint startOffset, gint endOffset);

#if PLATFORM(GTK)
static GailTextUtil* getGailTextUtilForAtk(AtkText* textObject)
{
GailTextUtil* gailTextUtil = gail_text_util_new();
GOwnPtr<char> text(webkitAccessibleTextGetText(textObject, 0, -1));
gail_text_util_text_setup(gailTextUtil, text.get());
return gailTextUtil;
}

static PangoLayout* getPangoLayoutForAtk(AtkText* textObject)
{
AccessibilityObject* coreObject = core(textObject);

Document* document = coreObject->document();
if (!document)
return 0;

HostWindow* hostWindow = document->view()->hostWindow();
if (!hostWindow)
return 0;
PlatformPageClient webView = hostWindow->platformPageClient();
if (!webView)
return 0;

// Create a string with the layout as it appears on the screen
GOwnPtr<char> objectText(textForObject(coreObject));
PangoLayout* layout = gtk_widget_create_pango_layout(static_cast<GtkWidget*>(webView), objectText.get());
return layout;
}
#endif

static int baselinePositionForRenderObject(RenderObject* renderObject)
{
// FIXME: This implementation of baselinePosition originates from RenderObject.cpp and was
Expand Down Expand Up @@ -369,6 +331,8 @@ static AtkAttributeSet* attributeSetDifference(AtkAttributeSet* attributeSet1, A
return attributeSet1;
}

static gchar* webkitAccessibleTextGetText(AtkText*, gint startOffset, gint endOffset);

static guint accessibilityObjectLength(const AccessibilityObject* object)
{
// Non render objects are not taken into account
Expand Down Expand Up @@ -1079,46 +1043,27 @@ static gchar* webkitAccessibleTextGetTextForOffset(AtkText* text, gint offset, A
if (!coreObject || !coreObject->isAccessibilityRenderObject())
return emptyTextSelectionAtOffset(0, startOffset, endOffset);

if (boundaryType == ATK_TEXT_BOUNDARY_CHAR)
switch (boundaryType) {
case ATK_TEXT_BOUNDARY_CHAR:
return webkitAccessibleTextGetChar(text, offset, textPosition, startOffset, endOffset);

if (boundaryType == ATK_TEXT_BOUNDARY_WORD_START || boundaryType == ATK_TEXT_BOUNDARY_WORD_END)
case ATK_TEXT_BOUNDARY_WORD_START:
case ATK_TEXT_BOUNDARY_WORD_END:
return webkitAccessibleTextWordForBoundary(text, offset, boundaryType, textPosition, startOffset, endOffset);

if (boundaryType == ATK_TEXT_BOUNDARY_SENTENCE_START || boundaryType == ATK_TEXT_BOUNDARY_SENTENCE_END)
return webkitAccessibleTextSentenceForBoundary(text, offset, boundaryType, textPosition, startOffset, endOffset);

if (boundaryType == ATK_TEXT_BOUNDARY_LINE_START || boundaryType == ATK_TEXT_BOUNDARY_LINE_END)
case ATK_TEXT_BOUNDARY_LINE_START:
case ATK_TEXT_BOUNDARY_LINE_END:
return webkitAccessibleTextLineForBoundary(text, offset, boundaryType, textPosition, startOffset, endOffset);

#if PLATFORM(GTK)
// FIXME: Get rid of the code below once every single part above
// has been properly implemented without using Pango/Cairo.
GailOffsetType offsetType = GAIL_AT_OFFSET;
switch (textPosition) {
case GetTextPositionBefore:
offsetType = GAIL_BEFORE_OFFSET;
break;

case GetTextPositionAt:
break;

case GetTextPositionAfter:
offsetType = GAIL_AFTER_OFFSET;
break;
case ATK_TEXT_BOUNDARY_SENTENCE_START:
case ATK_TEXT_BOUNDARY_SENTENCE_END:
return webkitAccessibleTextSentenceForBoundary(text, offset, boundaryType, textPosition, startOffset, endOffset);

default:
ASSERT_NOT_REACHED();
}

// Make sure we always return valid valid values for offsets.
*startOffset = 0;
*endOffset = 0;

return gail_text_util_get_text(getGailTextUtilForAtk(text), getPangoLayoutForAtk(text), offsetType, boundaryType, offset, startOffset, endOffset);
#endif

notImplemented();
// This should never be reached.
return 0;
}

Expand Down

0 comments on commit cab733a

Please sign in to comment.