- Revision
- 151524
- Author
- [email protected]
- Date
- 2013-06-12 14:39:42 -0700 (Wed, 12 Jun 2013)
Log Message
[atk] Replace deprecated call to atk_document_get_locale() in DumpRenderTree
https://bugs.webkit.org/show_bug.cgi?id=115647
Patch by Eduardo Lima Mitev <[email protected]> on 2013-06-12
Reviewed by Martin Robinson.
Source/WebCore:
Override the get_object_locale() method of WebkitAccessibleWrapperAtk's internal
AtkObject, to include custom implementations for AtkDocument and AtkText objects,
taking the logic as-is from AtkDocument::get_document_locale() and DumpRenderTree's
AccessibilityUIElementAtk::language(), respectively.
Apart from improving encapsulation, this avoids calling deprecated get_document_locale()
method.
No new functionality, no new tests.
* accessibility/atk/WebKitAccessibleInterfaceDocument.cpp:
(webkitAccessibleDocumentInterfaceInit): Chains implementation of
AtkDocument::get_document_locale() to AtkObject::get_object_locale().
* accessibility/atk/WebKitAccessibleWrapperAtk.cpp:
(webkitAccessibleGetObjectLocale): Add implementation of locale resolution for
objects of type AtkDocument and AtkText.
(webkitAccessibleClassInit): Override AtkObject::get_object_locale() method.
Tools:
Locale resolution is moved to WebKitAccessibleWrapperAtk using
AtkObject::get_object_locale() API. Now, implementation of
AccessibilityUIElement::language() in both DumpRenderTree and WebKitTestRunner can
be leveraged to get_object_locale() of AtkObject.
Apart from improving encapsulation, this avoids calling deprecated get_document_locale()
method.
No new functionality, no new tests.
* DumpRenderTree/atk/AccessibilityUIElementAtk.cpp:
(AccessibilityUIElement::language): Leverage locale resolution to
AtkObject::get_object_locale().
* WebKitTestRunner/InjectedBundle/atk/AccessibilityUIElementAtk.cpp:
(WTR::AccessibilityUIElement::language): Leverage locale resolution to
AtkObject::get_object_locale().
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (151523 => 151524)
--- trunk/Source/WebCore/ChangeLog 2013-06-12 20:46:18 UTC (rev 151523)
+++ trunk/Source/WebCore/ChangeLog 2013-06-12 21:39:42 UTC (rev 151524)
@@ -1,3 +1,28 @@
+2013-06-12 Eduardo Lima Mitev <[email protected]>
+
+ [atk] Replace deprecated call to atk_document_get_locale() in DumpRenderTree
+ https://bugs.webkit.org/show_bug.cgi?id=115647
+
+ Reviewed by Martin Robinson.
+
+ Override the get_object_locale() method of WebkitAccessibleWrapperAtk's internal
+ AtkObject, to include custom implementations for AtkDocument and AtkText objects,
+ taking the logic as-is from AtkDocument::get_document_locale() and DumpRenderTree's
+ AccessibilityUIElementAtk::language(), respectively.
+
+ Apart from improving encapsulation, this avoids calling deprecated get_document_locale()
+ method.
+
+ No new functionality, no new tests.
+
+ * accessibility/atk/WebKitAccessibleInterfaceDocument.cpp:
+ (webkitAccessibleDocumentInterfaceInit): Chains implementation of
+ AtkDocument::get_document_locale() to AtkObject::get_object_locale().
+ * accessibility/atk/WebKitAccessibleWrapperAtk.cpp:
+ (webkitAccessibleGetObjectLocale): Add implementation of locale resolution for
+ objects of type AtkDocument and AtkText.
+ (webkitAccessibleClassInit): Override AtkObject::get_object_locale() method.
+
2013-06-12 Zan Dobersek <[email protected]>
[GTK] Move more build targets for source code that's free of layer violations into libPlatform
Modified: trunk/Source/WebCore/accessibility/atk/WebKitAccessibleInterfaceDocument.cpp (151523 => 151524)
--- trunk/Source/WebCore/accessibility/atk/WebKitAccessibleInterfaceDocument.cpp 2013-06-12 20:46:18 UTC (rev 151523)
+++ trunk/Source/WebCore/accessibility/atk/WebKitAccessibleInterfaceDocument.cpp 2013-06-12 21:39:42 UTC (rev 151524)
@@ -97,12 +97,12 @@
static const gchar* webkitAccessibleDocumentGetLocale(AtkDocument* document)
{
- // TODO: Should we fall back on lang xml:lang when the following comes up empty?
- String language = core(document)->language();
- if (!language.isEmpty())
- return cacheAndReturnAtkProperty(ATK_OBJECT(document), AtkCachedDocumentLocale, language);
-
- return 0;
+ // The logic to resolve locale has been moved to
+ // AtkObject::get_object_locale() virtual method. However, to avoid breaking
+ // clients expecting the deprecated AtkDocumentIface::get_document_locale()
+ // to be overriden, method is kept and chained up to
+ // AtkObject::get_object_locale(). <https://bugs.webkit.org/show_bug.cgi?id=115647>
+ return atk_object_get_object_locale(ATK_OBJECT(document));
}
void webkitAccessibleDocumentInterfaceInit(AtkDocumentIface* iface)
Modified: trunk/Source/WebCore/accessibility/atk/WebKitAccessibleWrapperAtk.cpp (151523 => 151524)
--- trunk/Source/WebCore/accessibility/atk/WebKitAccessibleWrapperAtk.cpp 2013-06-12 20:46:18 UTC (rev 151523)
+++ trunk/Source/WebCore/accessibility/atk/WebKitAccessibleWrapperAtk.cpp 2013-06-12 21:39:42 UTC (rev 151524)
@@ -792,6 +792,38 @@
accessible->priv = WEBKIT_ACCESSIBLE_GET_PRIVATE(accessible);
}
+static const gchar* webkitAccessibleGetObjectLocale(AtkObject* object)
+{
+ if (ATK_IS_DOCUMENT(object)) {
+ AccessibilityObject* coreObject = core(object);
+ if (!coreObject)
+ return 0;
+
+ // TODO: Should we fall back on lang xml:lang when the following comes up empty?
+ String language = coreObject->language();
+ if (!language.isEmpty())
+ return cacheAndReturnAtkProperty(object, AtkCachedDocumentLocale, language);
+
+ } else if (ATK_IS_TEXT(object)) {
+ const gchar* locale = 0;
+
+ AtkAttributeSet* textAttributes = atk_text_get_default_attributes(ATK_TEXT(object));
+ for (GSList* attributes = textAttributes; attributes; attributes = attributes->next) {
+ AtkAttribute* atkAttribute = static_cast<AtkAttribute*>(attributes->data);
+ if (!strcmp(atkAttribute->name, atk_text_attribute_get_name(ATK_TEXT_ATTR_LANGUAGE))) {
+ locale = cacheAndReturnAtkProperty(object, AtkCachedDocumentLocale, String::fromUTF8(atkAttribute->value));
+ break;
+ }
+ }
+
+ atk_attribute_set_free(textAttributes);
+
+ return locale;
+ }
+
+ return 0;
+}
+
static void webkitAccessibleFinalize(GObject* object)
{
G_OBJECT_CLASS(webkitAccessibleParentClass)->finalize(object);
@@ -816,6 +848,7 @@
klass->get_index_in_parent = webkitAccessibleGetIndexInParent;
klass->get_attributes = webkitAccessibleGetAttributes;
klass->ref_relation_set = webkitAccessibleRefRelationSet;
+ klass->get_object_locale = webkitAccessibleGetObjectLocale;
g_type_class_add_private(klass, sizeof(WebKitAccessiblePrivate));
}
Modified: trunk/Tools/ChangeLog (151523 => 151524)
--- trunk/Tools/ChangeLog 2013-06-12 20:46:18 UTC (rev 151523)
+++ trunk/Tools/ChangeLog 2013-06-12 21:39:42 UTC (rev 151524)
@@ -1,3 +1,27 @@
+2013-06-12 Eduardo Lima Mitev <[email protected]>
+
+ [atk] Replace deprecated call to atk_document_get_locale() in DumpRenderTree
+ https://bugs.webkit.org/show_bug.cgi?id=115647
+
+ Reviewed by Martin Robinson.
+
+ Locale resolution is moved to WebKitAccessibleWrapperAtk using
+ AtkObject::get_object_locale() API. Now, implementation of
+ AccessibilityUIElement::language() in both DumpRenderTree and WebKitTestRunner can
+ be leveraged to get_object_locale() of AtkObject.
+
+ Apart from improving encapsulation, this avoids calling deprecated get_document_locale()
+ method.
+
+ No new functionality, no new tests.
+
+ * DumpRenderTree/atk/AccessibilityUIElementAtk.cpp:
+ (AccessibilityUIElement::language): Leverage locale resolution to
+ AtkObject::get_object_locale().
+ * WebKitTestRunner/InjectedBundle/atk/AccessibilityUIElementAtk.cpp:
+ (WTR::AccessibilityUIElement::language): Leverage locale resolution to
+ AtkObject::get_object_locale().
+
2013-06-12 Hugo Parente Lima <[email protected]>
Remove last bits of GYP from build-webkit and update-webkit scripts
Modified: trunk/Tools/DumpRenderTree/atk/AccessibilityUIElementAtk.cpp (151523 => 151524)
--- trunk/Tools/DumpRenderTree/atk/AccessibilityUIElementAtk.cpp 2013-06-12 20:46:18 UTC (rev 151523)
+++ trunk/Tools/DumpRenderTree/atk/AccessibilityUIElementAtk.cpp 2013-06-12 21:39:42 UTC (rev 151524)
@@ -432,21 +432,11 @@
if (!m_element)
return JSStringCreateWithCharacters(0, 0);
- // In ATK, the document language is exposed as the document's locale.
- if (atk_object_get_role(ATK_OBJECT(m_element)) == ATK_ROLE_DOCUMENT_FRAME)
- return JSStringCreateWithUTF8CString(g_strdup_printf("AXLanguage: %s", atk_document_get_locale(ATK_DOCUMENT(m_element))));
-
- // For all other objects, the language is exposed as an AtkText attribute.
- if (!ATK_IS_TEXT(m_element))
+ const gchar* locale = atk_object_get_object_locale(ATK_OBJECT(m_element));
+ if (!locale)
return JSStringCreateWithCharacters(0, 0);
- for (GSList* textAttributes = atk_text_get_default_attributes(ATK_TEXT(m_element)); textAttributes; textAttributes = textAttributes->next) {
- AtkAttribute* atkAttribute = static_cast<AtkAttribute*>(textAttributes->data);
- if (!strcmp(atkAttribute->name, atk_text_attribute_get_name(ATK_TEXT_ATTR_LANGUAGE)))
- return JSStringCreateWithUTF8CString(g_strdup_printf("AXLanguage: %s", atkAttribute->value));
- }
-
- return JSStringCreateWithCharacters(0, 0);
+ return JSStringCreateWithUTF8CString(g_strdup_printf("AXLanguage: %s", locale));
}
double AccessibilityUIElement::x()
Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/atk/AccessibilityUIElementAtk.cpp (151523 => 151524)
--- trunk/Tools/WebKitTestRunner/InjectedBundle/atk/AccessibilityUIElementAtk.cpp 2013-06-12 20:46:18 UTC (rev 151523)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/atk/AccessibilityUIElementAtk.cpp 2013-06-12 21:39:42 UTC (rev 151524)
@@ -618,29 +618,11 @@
if (!m_element || !ATK_IS_OBJECT(m_element.get()))
return JSStringCreateWithCharacters(0, 0);
- GOwnPtr<gchar> language;
- // In ATK, the document language is exposed as the document's locale.
- if (atk_object_get_role(ATK_OBJECT(m_element.get())) == ATK_ROLE_DOCUMENT_FRAME) {
- language.set(g_strdup_printf("AXLanguage: %s", atk_document_get_locale(ATK_DOCUMENT(m_element.get()))));
- return JSStringCreateWithUTF8CString(language.get());
- }
-
- // For all other objects, the language is exposed as an AtkText attribute.
- if (!ATK_IS_TEXT(m_element.get()))
+ const gchar* locale = atk_object_get_object_locale(ATK_OBJECT(m_element.get()));
+ if (!locale)
return JSStringCreateWithCharacters(0, 0);
- GOwnPtr<GSList> textAttributes(atk_text_get_default_attributes(ATK_TEXT(m_element.get())));
- for (GSList* attributes = textAttributes.get(); attributes; attributes = attributes->next) {
- AtkAttribute* atkAttribute = static_cast<AtkAttribute*>(attributes->data);
- if (!strcmp(atkAttribute->name, atk_text_attribute_get_name(ATK_TEXT_ATTR_LANGUAGE))) {
- language.set(g_strdup_printf("AXLanguage: %s", atkAttribute->value));
- break;
- }
- }
-
- attributesClear(textAttributes.get());
-
- return JSStringCreateWithUTF8CString(language.get());
+ return JSStringCreateWithUTF8CString(g_strdup_printf("AXLanguage: %s", locale));
}
JSRetainPtr<JSStringRef> AccessibilityUIElement::helpText() const