[ATK] accessibility/aria-sort.html is failing after r156409
https://bugs.webkit.org/show_bug.cgi?id=121947

Reviewed by Chris Fleizach.

Source/WebCore:

The WAI-ARIA spec says to translate the value as is from the
attribute, so do just that instead of mapping values from the
AccessibilitySortDirection enumeration into strings.
http://www.w3.org/TR/wai-aria-implementation/#mapping_state-property

* accessibility/atk/WebKitAccessibleWrapperAtk.cpp:
(webkitAccessibleGetAttributes): Do the right mapping for aria-sort.

Tools:

Implement AccessibilityUIElement::isSupported for the ATK
platforms, just by checking whether we have an associated object
attribute exposed for the wrapper object matching the required
attribute in the layout test (e.g "AXSortDirection" -> "sort").

* DumpRenderTree/atk/AccessibilityUIElementAtk.cpp:
(AccessibilityUIElement::isAttributeSupported): Implemented.
* WebKitTestRunner/InjectedBundle/atk/AccessibilityUIElementAtk.cpp:
(WTR::AccessibilityUIElement::isAttributeSupported): Implemented.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@156530 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[ATK] Normalize checks in entry points for DRT and WKTR
https://bugs.webkit.org/show_bug.cgi?id=121959

Reviewed by Chris Fleizach.

Always check if we have a proper instance of AtkObject,
implementing the interfaces that we might need for each case, at
the entry point of every method of AccessibilityUIElement for ATK,
and do those checks in an uniform way across DRT and WKTR, to
avoid confusion and issues when modifying these files in the future.

* DumpRenderTree/atk/AccessibilityUIElementAtk.cpp:
(AccessibilityUIElement::getChildren): Use normalized checks.
(AccessibilityUIElement::getChildrenWithRange): Ditto.
(AccessibilityUIElement::rowCount): Ditto.
(AccessibilityUIElement::columnCount): Ditto.
(AccessibilityUIElement::childrenCount): Ditto.
(AccessibilityUIElement::elementAtPoint): Ditto.
(AccessibilityUIElement::getChildAtIndex): Ditto.
(AccessibilityUIElement::allAttributes): Ditto.
(AccessibilityUIElement::titleUIElement): Ditto.
(AccessibilityUIElement::parentElement): Ditto.
(AccessibilityUIElement::attributesOfChildren): Ditto.
(AccessibilityUIElement::role): Ditto.
(AccessibilityUIElement::title): Ditto.
(AccessibilityUIElement::description): Ditto.
(AccessibilityUIElement::stringValue): Ditto.
(AccessibilityUIElement::language): Ditto.
(AccessibilityUIElement::x): Ditto.
(AccessibilityUIElement::y): Ditto.
(AccessibilityUIElement::width): Ditto.
(AccessibilityUIElement::height): Ditto.
(AccessibilityUIElement::orientation): Ditto.
(AccessibilityUIElement::intValue): Ditto.
(AccessibilityUIElement::minValue): Ditto.
(AccessibilityUIElement::maxValue): Ditto.
(indexRangeInTable): Ditto.
(AccessibilityUIElement::cellForColumnAndRow): Ditto.
(AccessibilityUIElement::stringAttributeValue): Ditto.
(alterCurrentValue): Ditto.
(AccessibilityUIElement::press): Ditto.
(AccessibilityUIElement::documentEncoding): Ditto.
(AccessibilityUIElement::documentURI): Ditto.
(AccessibilityUIElement::hasPopup): Ditto.

* WebKitTestRunner/InjectedBundle/atk/AccessibilityUIElementAtk.cpp:
(WTR::indexRangeInTable): Use normalized checks.
(WTR::alterCurrentValue): Ditto.
(WTR::AccessibilityUIElement::getChildren): Ditto.
(WTR::AccessibilityUIElement::getChildrenWithRange): Ditto.
(WTR::AccessibilityUIElement::childrenCount): Ditto.
(WTR::AccessibilityUIElement::elementAtPoint): Ditto.
(WTR::AccessibilityUIElement::indexOfChild): Ditto.
(WTR::AccessibilityUIElement::childAtIndex): Ditto.
(WTR::AccessibilityUIElement::titleUIElement): Ditto.
(WTR::AccessibilityUIElement::parentElement): Ditto.
(WTR::AccessibilityUIElement::attributesOfChildren): Ditto.
(WTR::AccessibilityUIElement::allAttributes): Ditto.
(WTR::AccessibilityUIElement::stringAttributeValue): Ditto.
(WTR::AccessibilityUIElement::role): Ditto.
(WTR::AccessibilityUIElement::title): Ditto.
(WTR::AccessibilityUIElement::description): Ditto.
(WTR::AccessibilityUIElement::orientation): Ditto.
(WTR::AccessibilityUIElement::stringValue): Ditto.
(WTR::AccessibilityUIElement::language): Ditto.
(WTR::AccessibilityUIElement::x): Ditto.
(WTR::AccessibilityUIElement::y): Ditto.
(WTR::AccessibilityUIElement::width): Ditto.
(WTR::AccessibilityUIElement::height): Ditto.
(WTR::AccessibilityUIElement::intValue): Ditto.
(WTR::AccessibilityUIElement::minValue): Ditto.
(WTR::AccessibilityUIElement::maxValue): Ditto.
(WTR::AccessibilityUIElement::rowCount): Ditto.
(WTR::AccessibilityUIElement::columnCount): Ditto.
(WTR::AccessibilityUIElement::cellForColumnAndRow): Ditto.
(WTR::AccessibilityUIElement::press): Ditto.
(WTR::AccessibilityUIElement::documentEncoding): Ditto.
(WTR::AccessibilityUIElement::documentURI): Ditto.
(WTR::AccessibilityUIElement::hasPopup): Ditto.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@156531 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[ATK] Protect entry points in the ATK wrapper against outdated render trees
https://bugs.webkit.org/show_bug.cgi?id=121558

Reviewed by Chris Fleizach.

Source/WebCore:

Make sure that we protect every entry point in the ATK wrapper
against outdated render trees, before using the WebCore's
accessibility API, since that might lead to problems (and crashes)
if the render and accessibility trees are not stable.

Thus, call AccessibilityObject::updateBackingStore() in those
entry points and check whether the ATK wrapper is detached or not
after that, to decide whether to continue or not.

Besides providing a new test to check that it WebKit does not
crash in a given scenario (which actually triggered the
investigation here), solving this situation also fixes other tests
that were previously failing (aria-used-on-image-maps.html) or
that were printing wrong results, not detected until now due to
wrong platform specific expectations (file-upload-button-stringvalue
and deleting-iframe-destroys-axcache).

Test: accessibility/heading-crash-after-hidden.html

* accessibility/atk/WebKitAccessibleUtil.h: Added two new macros
to inject the needed code at the beginning of each entry point to
allow gracefully exit those functions when the render tree is
unstable. Inspired by g_return_if_fail and g_return_val_if_fail, we
called them returnIfWebKitAccessibleIsInvalid and returnValIfWebKitAccessibleIsInvalid.

* accessibility/atk/WebKitAccessibleHyperlink.cpp:
(webkitAccessibleHyperlinkActionDoAction): Protect entry point.
(webkitAccessibleHyperlinkActionGetNActions): Ditto.
(webkitAccessibleHyperlinkActionGetDescription): Ditto.
(webkitAccessibleHyperlinkActionGetKeybinding): Ditto.
(webkitAccessibleHyperlinkActionGetName): Ditto.
(webkitAccessibleHyperlinkGetURI): Ditto.
(webkitAccessibleHyperlinkGetObject): Ditto.
(webkitAccessibleHyperlinkGetStartIndex): Ditto.
(webkitAccessibleHyperlinkGetEndIndex): Ditto.
(webkitAccessibleHyperlinkIsValid): Ditto.
(webkitAccessibleHyperlinkGetNAnchors): Ditto.
(webkitAccessibleHyperlinkIsSelectedLink): Ditto.
* accessibility/atk/WebKitAccessibleInterfaceAction.cpp:
(webkitAccessibleActionDoAction): Ditto.
(webkitAccessibleActionGetNActions): Ditto.
(webkitAccessibleActionGetDescription): Ditto.
(webkitAccessibleActionGetKeybinding): Ditto.
(webkitAccessibleActionGetName): Ditto.
* accessibility/atk/WebKitAccessibleInterfaceComponent.cpp:
(webkitAccessibleComponentRefAccessibleAtPoint): Ditto.
(webkitAccessibleComponentGetExtents): Ditto.
(webkitAccessibleComponentGrabFocus): Ditto.
* accessibility/atk/WebKitAccessibleInterfaceDocument.cpp:
(webkitAccessibleDocumentGetAttributeValue): Ditto.
(webkitAccessibleDocumentGetAttributes): Ditto.
(webkitAccessibleDocumentGetLocale): Ditto.
* accessibility/atk/WebKitAccessibleInterfaceEditableText.cpp:
(webkitAccessibleEditableTextSetRunAttributes): Ditto.
(webkitAccessibleEditableTextSetTextContents): Ditto.
(webkitAccessibleEditableTextInsertText): Ditto.
(webkitAccessibleEditableTextCopyText): Ditto.
(webkitAccessibleEditableTextCutText): Ditto.
(webkitAccessibleEditableTextDeleteText): Ditto.
(webkitAccessibleEditableTextPasteText): Ditto.
* accessibility/atk/WebKitAccessibleInterfaceHypertext.cpp:
(webkitAccessibleHypertextGetLink): Ditto.
(webkitAccessibleHypertextGetNLinks): Ditto.
(webkitAccessibleHypertextGetLinkIndex): Ditto.
* accessibility/atk/WebKitAccessibleInterfaceImage.cpp:
(webkitAccessibleImageGetImagePosition): Ditto.
(webkitAccessibleImageGetImageDescription): Ditto.
(webkitAccessibleImageGetImageSize): Ditto.
* accessibility/atk/WebKitAccessibleInterfaceSelection.cpp:
(webkitAccessibleSelectionAddSelection): Ditto.
(webkitAccessibleSelectionClearSelection): Ditto.
(webkitAccessibleSelectionRefSelection): Ditto.
(webkitAccessibleSelectionGetSelectionCount): Ditto.
(webkitAccessibleSelectionIsChildSelected): Ditto.
(webkitAccessibleSelectionRemoveSelection): Ditto.
(webkitAccessibleSelectionSelectAllSelection): Ditto.
* accessibility/atk/WebKitAccessibleInterfaceTable.cpp:
(webkitAccessibleTableRefAt): Ditto.
(webkitAccessibleTableGetIndexAt): Ditto.
(webkitAccessibleTableGetColumnAtIndex): Ditto.
(webkitAccessibleTableGetRowAtIndex): Ditto.
(webkitAccessibleTableGetNColumns): Ditto.
(webkitAccessibleTableGetNRows): Ditto.
(webkitAccessibleTableGetColumnExtentAt): Ditto.
(webkitAccessibleTableGetRowExtentAt): Ditto.
(webkitAccessibleTableGetColumnHeader): Ditto.
(webkitAccessibleTableGetRowHeader): Ditto.
(webkitAccessibleTableGetCaption): Ditto.
(webkitAccessibleTableGetColumnDescription): Ditto.
(webkitAccessibleTableGetRowDescription): Ditto.
* accessibility/atk/WebKitAccessibleInterfaceText.cpp:
(webkitAccessibleTextGetText): Ditto.
(webkitAccessibleTextGetTextAfterOffset): Ditto.
(webkitAccessibleTextGetTextAtOffset): Ditto.
(webkitAccessibleTextGetTextBeforeOffset): Ditto.
(webkitAccessibleTextGetCharacterAtOffset): Ditto.
(webkitAccessibleTextGetCaretOffset): Ditto.
(webkitAccessibleTextGetRunAttributes): Ditto.
(webkitAccessibleTextGetDefaultAttributes): Ditto.
(webkitAccessibleTextGetCharacterExtents): Ditto.
(webkitAccessibleTextGetRangeExtents): Ditto.
(webkitAccessibleTextGetCharacterCount): Ditto.
(webkitAccessibleTextGetOffsetAtPoint): Ditto.
(webkitAccessibleTextGetNSelections): Ditto.
(webkitAccessibleTextGetSelection): Ditto.
(webkitAccessibleTextAddSelection): Ditto.
(webkitAccessibleTextSetSelection): Ditto.
(webkitAccessibleTextRemoveSelection): Ditto.
(webkitAccessibleTextSetCaretOffset): Ditto.
* accessibility/atk/WebKitAccessibleInterfaceValue.cpp:
(webkitAccessibleValueGetCurrentValue): Ditto.
(webkitAccessibleValueGetMaximumValue): Ditto.
(webkitAccessibleValueGetMinimumValue): Ditto.
(webkitAccessibleValueSetCurrentValue): Ditto.
(webkitAccessibleValueGetMinimumIncrement): Ditto.
* accessibility/atk/WebKitAccessibleWrapperAtk.cpp:
(core): Removed, as it's not actually needed.
(webkitAccessibleGetName):  Protect entry point.
(webkitAccessibleGetDescription): Ditto.
(webkitAccessibleGetParent): Ditto.
(webkitAccessibleGetNChildren): Ditto.
(webkitAccessibleRefChild): Ditto.
(webkitAccessibleGetIndexInParent): Ditto.
(webkitAccessibleGetAttributes): Ditto.
(webkitAccessibleGetRole): Ditto.
(webkitAccessibleRefStateSet): Ditto.
(webkitAccessibleRefRelationSet): Ditto.
(webkitAccessibleGetObjectLocale): Ditto.
(webkitAccessibleDetach): Ditto.
(webkitAccessibleIsDetached): New helper function, to be used from
the newly added macros. We need to check whether the wrapper is
detached and not just the wrapper AccessibilityObject since once
the detachment happens we can't trust anything but the AtkObject
from the wrapper (the AccessibilityObject might be invalid).
* accessibility/atk/WebKitAccessibleWrapperAtk.h:

Assert that the render tree is neither being updated nor in need
of being updated before trying to compute the text under a given
element, since that might lead to crashes due to the constructor
of TextIterator calling updateLayoutIgnorePendingStylesheets().

* accessibility/AccessibilityNodeObject.cpp:
(WebCore::AccessibilityNodeObject::textUnderElement): Assert that
the render tree is neither being updated nor needing updating.

LayoutTests:

Added a new test to check that we do not crash in certain
scenarios when hiding objects and retriving accessibility
information about it.

* accessibility/heading-crash-after-hidden-expected.txt: Added.
* accessibility/heading-crash-after-hidden.html: Added.

Rebaselined expectations that were wrong before, since they were
not returning the actual value that they should be returning when
called AccessibilityUIElement::stringValue().

* platform/efl-wk1/accessibility/file-upload-button-stringvalue-expected.txt:
Updated, since the actual text being returned should be the actual
value of the file chooser (e.g. "(None)") and not the text in the
upload botton (e.g. "Choose files").
* platform/efl-wk2/accessibility/file-upload-button-stringvalue-expected.txt: Ditto.
* platform/gtk-wk2/accessibility/file-upload-button-stringvalue-expected.txt: Ditto..
* platform/gtk/accessibility/file-upload-button-stringvalue-expected.txt: Ditto.

* platform/gtk/accessibility/deleting-iframe-destroys-axcache-expected.txt:
Updated, since the iframe should be exposed at all after deleting it.

Removed accesibility test now passing after fixing this issue.

* platform/gtk/TestExpectations: Removed accessibility/aria-used-on-image-maps.html.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@156532 268f45cc-cd09-0410-ab3c-d52691b4dbfc