diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2012-09-24 13:09:44 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@digia.com> | 2012-09-24 13:09:44 +0200 |
commit | dc6262b587c71c14e30d93e57ed812e36a79a33e (patch) | |
tree | 03ff986e7aa38bba0c0ef374f44fda52aff93f01 /Tools/DumpRenderTree | |
parent | 02e1fbbefd49229b102ef107bd70ce974a2d85fb (diff) | |
download | qtwebkit-dc6262b587c71c14e30d93e57ed812e36a79a33e.tar.gz |
Imported WebKit commit 6339232fec7f5d9984a33388aecfd2cbc7832053 (http://svn.webkit.org/repository/webkit/trunk@129343)
New snapshot with build fixes for latest qtbase
Diffstat (limited to 'Tools/DumpRenderTree')
15 files changed, 248 insertions, 46 deletions
diff --git a/Tools/DumpRenderTree/AccessibilityController.cpp b/Tools/DumpRenderTree/AccessibilityController.cpp index b367d5c46..49d453a84 100644 --- a/Tools/DumpRenderTree/AccessibilityController.cpp +++ b/Tools/DumpRenderTree/AccessibilityController.cpp @@ -97,6 +97,18 @@ static JSValueRef getElementAtPointCallback(JSContextRef context, JSObjectRef fu return AccessibilityUIElement::makeJSAccessibilityUIElement(context, controller->elementAtPoint(x, y)); } +static JSValueRef getAccessibleElementByIdCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +{ + JSStringRef idAttribute = 0; + if (argumentCount == 1) + idAttribute = JSValueToStringCopy(context, arguments[0], exception); + AccessibilityController* controller = static_cast<AccessibilityController*>(JSObjectGetPrivate(thisObject)); + JSValueRef result = AccessibilityUIElement::makeJSAccessibilityUIElement(context, controller->accessibleElementById(idAttribute)); + if (idAttribute) + JSStringRelease(idAttribute); + return result; +} + static JSValueRef addNotificationListenerCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { if (argumentCount != 1) @@ -123,6 +135,7 @@ JSClassRef AccessibilityController::getJSClass() { "logScrollingStartEvents", logScrollingStartEventsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "logAccessibilityEvents", logAccessibilityEventsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "elementAtPoint", getElementAtPointCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, + { "accessibleElementById", getAccessibleElementByIdCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "addNotificationListener", addNotificationListenerCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "removeNotificationListener", removeNotificationListenerCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { 0, 0, 0 } diff --git a/Tools/DumpRenderTree/AccessibilityController.h b/Tools/DumpRenderTree/AccessibilityController.h index 1d52353cd..a6cdc4686 100644 --- a/Tools/DumpRenderTree/AccessibilityController.h +++ b/Tools/DumpRenderTree/AccessibilityController.h @@ -46,6 +46,7 @@ public: AccessibilityUIElement rootElement(); AccessibilityUIElement focusedElement(); AccessibilityUIElement elementAtPoint(int x, int y); + AccessibilityUIElement accessibleElementById(JSStringRef id); void setLogFocusEvents(bool); void setLogValueChangeEvents(bool); diff --git a/Tools/DumpRenderTree/DumpRenderTree.gyp/DumpRenderTree.gyp b/Tools/DumpRenderTree/DumpRenderTree.gyp/DumpRenderTree.gyp index 131d40f02..982c767fd 100644 --- a/Tools/DumpRenderTree/DumpRenderTree.gyp/DumpRenderTree.gyp +++ b/Tools/DumpRenderTree/DumpRenderTree.gyp/DumpRenderTree.gyp @@ -285,21 +285,12 @@ '<(chromium_src_dir)/testing/android/native_test.gyp:native_test_native_code', '<(chromium_src_dir)/tools/android/forwarder/forwarder.gyp:forwarder', '<(chromium_src_dir)/tools/android/md5sum/md5sum.gyp:md5sum', - '<(source_dir)/WebKit/chromium/WebKitUnitTests.gyp:io_stream_forwarder_android', ], 'dependencies!': [ 'ImageDiff', 'copy_TestNetscapePlugIn', '<(chromium_src_dir)/third_party/mesa/mesa.gyp:osmesa', ], - # FIXME: Remove when the io_stream_forwarder_android target is deprecated. - 'conditions': [ - ['inside_chromium_build==1', { - 'include_dirs': [ - '<(source_dir)/WebKit/chromium/', - ], - }], - ], 'copies': [{ 'destination': '<(PRODUCT_DIR)', 'files': [ @@ -528,5 +519,14 @@ }], }], }], + ['clang==1', { + 'target_defaults': { + # FIXME: Add -Wglobal-constructors after fixing existing bugs. + 'cflags': ['-Wunused-parameter'], + 'xcode_settings': { + 'WARNING_CFLAGS': ['-Wunused-parameter'], + }, + }, + }], ], # conditions } diff --git a/Tools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj b/Tools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj index 55b6ef290..0c6b8049e 100644 --- a/Tools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj +++ b/Tools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj @@ -116,6 +116,8 @@ BC0E24E00E2D9451001B6BC2 /* AccessibilityUIElement.h in Headers */ = {isa = PBXBuildFile; fileRef = BC0E24DE0E2D9451001B6BC2 /* AccessibilityUIElement.h */; }; BC0E24E10E2D9451001B6BC2 /* AccessibilityUIElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC0E24DF0E2D9451001B6BC2 /* AccessibilityUIElement.cpp */; }; BC0E26150E2DA4C6001B6BC2 /* AccessibilityUIElementMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC0E26140E2DA4C6001B6BC2 /* AccessibilityUIElementMac.mm */; }; + BC0E24E00E2D9451001B6BC3 /* AccessibilityCommonMac.h in Headers */ = {isa = PBXBuildFile; fileRef = BC0E24DE0E2D9451001B6BC3 /* AccessibilityCommonMac.h */; }; + BC0E26150E2DA4C6001B6BC3 /* AccessibilityCommonMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC0E26140E2DA4C6001B6BC3 /* AccessibilityCommonMac.mm */; }; BC47412A0D038A4C0072B006 /* JavaScriptThreading.h in Headers */ = {isa = PBXBuildFile; fileRef = BC4741290D038A4C0072B006 /* JavaScriptThreading.h */; }; BC4741410D038A570072B006 /* JavaScriptThreadingPthreads.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC4741400D038A570072B006 /* JavaScriptThreadingPthreads.cpp */; }; BC9D90240C97472E0099A4A3 /* WorkQueue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC9D90210C97472D0099A4A3 /* WorkQueue.cpp */; }; @@ -323,8 +325,10 @@ BC0131D80C9772010087317D /* TestRunner.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = TestRunner.cpp; sourceTree = "<group>"; }; BC0131D90C9772010087317D /* TestRunner.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = TestRunner.h; sourceTree = "<group>"; }; BC0E24DE0E2D9451001B6BC2 /* AccessibilityUIElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AccessibilityUIElement.h; sourceTree = "<group>"; }; + BC0E24DE0E2D9451001B6BC3 /* AccessibilityCommonMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mac/AccessibilityCommonMac.h; sourceTree = "<group>"; }; BC0E24DF0E2D9451001B6BC2 /* AccessibilityUIElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AccessibilityUIElement.cpp; sourceTree = "<group>"; }; BC0E26140E2DA4C6001B6BC2 /* AccessibilityUIElementMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = AccessibilityUIElementMac.mm; path = mac/AccessibilityUIElementMac.mm; sourceTree = "<group>"; }; + BC0E26140E2DA4C6001B6BC3 /* AccessibilityCommonMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = AccessibilityCommonMac.mm; path = mac/AccessibilityCommonMac.mm; sourceTree = "<group>"; }; BC4741290D038A4C0072B006 /* JavaScriptThreading.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JavaScriptThreading.h; sourceTree = "<group>"; }; BC4741400D038A570072B006 /* JavaScriptThreadingPthreads.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = JavaScriptThreadingPthreads.cpp; path = pthreads/JavaScriptThreadingPthreads.cpp; sourceTree = "<group>"; }; BC646A4B136905DE00B35DED /* CompilerVersion.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = CompilerVersion.xcconfig; path = mac/Configurations/CompilerVersion.xcconfig; sourceTree = "<group>"; }; @@ -503,6 +507,8 @@ BC0E24DF0E2D9451001B6BC2 /* AccessibilityUIElement.cpp */, BC0E24DE0E2D9451001B6BC2 /* AccessibilityUIElement.h */, BC0E26140E2DA4C6001B6BC2 /* AccessibilityUIElementMac.mm */, + BC0E26140E2DA4C6001B6BC3 /* AccessibilityCommonMac.h */, + BC0E26140E2DA4C6001B6BC3 /* AccessibilityCommonMac.mm */, BCA18B360C9B021900114369 /* AppleScriptController.h */, BCA18B370C9B021900114369 /* AppleScriptController.m */, BCA18B6B0C9B08DB00114369 /* EventSendingController.h */, @@ -948,6 +954,7 @@ BCD08B710E1059D200A7D0C1 /* AccessibilityControllerMac.mm in Sources */, BC0E24E10E2D9451001B6BC2 /* AccessibilityUIElement.cpp in Sources */, BC0E26150E2DA4C6001B6BC2 /* AccessibilityUIElementMac.mm in Sources */, + BC0E26150E2DA4C6001B6BC3 /* AccessibilityCommonMac.mm in Sources */, BCA18B390C9B021900114369 /* AppleScriptController.m in Sources */, A8B91BFD0CF522B4008F91FF /* CheckedMalloc.cpp in Sources */, 53CBB832134E42F3001CE6A4 /* CyclicRedundancyCheck.cpp in Sources */, diff --git a/Tools/DumpRenderTree/chromium/TestRunner/AccessibilityControllerChromium.cpp b/Tools/DumpRenderTree/chromium/TestRunner/AccessibilityControllerChromium.cpp index b1d2948ae..89d5d5877 100644 --- a/Tools/DumpRenderTree/chromium/TestRunner/AccessibilityControllerChromium.cpp +++ b/Tools/DumpRenderTree/chromium/TestRunner/AccessibilityControllerChromium.cpp @@ -32,9 +32,11 @@ #include "AccessibilityControllerChromium.h" #include "WebAccessibilityObject.h" +#include "WebElement.h" #include "WebFrame.h" +#include "WebNode.h" #include "WebView.h" -#include "platform/WebString.h" +#include "platform/WebCString.h" using namespace WebKit; @@ -49,6 +51,8 @@ AccessibilityController::AccessibilityController() bindProperty("focusedElement", &AccessibilityController::focusedElementGetterCallback); bindProperty("rootElement", &AccessibilityController::rootElementGetterCallback); + bindMethod("accessibleElementById", &AccessibilityController::accessibleElementByIdGetterCallback); + bindFallbackMethod(&AccessibilityController::fallbackCallback); } @@ -86,6 +90,36 @@ AccessibilityUIElement* AccessibilityController::getRootElement() return m_elements.createRoot(m_rootElement); } +AccessibilityUIElement* AccessibilityController::findAccessibleElementByIdRecursive(const WebAccessibilityObject& obj, const WebString& id) +{ + if (obj.isNull() || obj.isDetached()) + return 0; + + WebNode node = obj.node(); + if (!node.isNull() && node.isElementNode()) { + WebElement element = node.to<WebElement>(); + element.getAttribute("id"); + if (element.getAttribute("id") == id) + return m_elements.getOrCreate(obj); + } + + unsigned childCount = obj.childCount(); + for (unsigned i = 0; i < childCount; i++) { + if (AccessibilityUIElement* result = findAccessibleElementByIdRecursive(obj.childAt(i), id)) + return result; + } + + return 0; +} + +AccessibilityUIElement* AccessibilityController::getAccessibleElementById(const std::string& id) +{ + if (m_rootElement.isNull()) + m_rootElement = m_webView->accessibilityObject(); + + return findAccessibleElementByIdRecursive(m_rootElement, WebString::fromUTF8(id.c_str())); +} + bool AccessibilityController::shouldLogAccessibilityEvents() { return m_logAccessibilityEvents; @@ -141,6 +175,21 @@ void AccessibilityController::rootElementGetterCallback(CppVariant* result) result->set(*(getRootElement()->getAsCppVariant())); } +void AccessibilityController::accessibleElementByIdGetterCallback(const CppArgumentList& arguments, CppVariant* result) +{ + result->setNull(); + + if (arguments.size() < 1 || !arguments[0].isString()) + return; + + std::string id = arguments[0].toString(); + AccessibilityUIElement* foundElement = getAccessibleElementById(id); + if (!foundElement) + return; + + result->set(*(foundElement->getAsCppVariant())); +} + void AccessibilityController::fallbackCallback(const CppArgumentList&, CppVariant* result) { printf("CONSOLE MESSAGE: JavaScript ERROR: unknown method called on " diff --git a/Tools/DumpRenderTree/chromium/TestRunner/AccessibilityControllerChromium.h b/Tools/DumpRenderTree/chromium/TestRunner/AccessibilityControllerChromium.h index 11c082b3e..f0f5dee85 100644 --- a/Tools/DumpRenderTree/chromium/TestRunner/AccessibilityControllerChromium.h +++ b/Tools/DumpRenderTree/chromium/TestRunner/AccessibilityControllerChromium.h @@ -51,6 +51,7 @@ public: void setFocusedElement(const WebKit::WebAccessibilityObject&); AccessibilityUIElement* getFocusedElement(); AccessibilityUIElement* getRootElement(); + AccessibilityUIElement* getAccessibleElementById(const std::string& id); bool shouldLogAccessibilityEvents(); @@ -70,6 +71,9 @@ private: void focusedElementGetterCallback(CppVariant*); void rootElementGetterCallback(CppVariant*); + void accessibleElementByIdGetterCallback(const CppArgumentList&, CppVariant*); + + AccessibilityUIElement* findAccessibleElementByIdRecursive(const WebKit::WebAccessibilityObject&, const WebKit::WebString& id); WebKit::WebAccessibilityObject m_focusedElement; WebKit::WebAccessibilityObject m_rootElement; diff --git a/Tools/DumpRenderTree/chromium/TestShellAndroid.cpp b/Tools/DumpRenderTree/chromium/TestShellAndroid.cpp index 8f8eedc3d..1a327bb85 100644 --- a/Tools/DumpRenderTree/chromium/TestShellAndroid.cpp +++ b/Tools/DumpRenderTree/chromium/TestShellAndroid.cpp @@ -32,7 +32,6 @@ #include "TestShell.h" #include "linux/WebFontRendering.h" -#include "tests/ForwardIOStreamsAndroid.h" #include "third_party/skia/include/ports/SkTypeface_android.h" namespace { @@ -51,9 +50,6 @@ void platformInit(int* argc, char*** argv) // Initialize skia with customized font config files. SkUseTestFontConfigFile(fontMainConfigFile, fontFallbackConfigFile, fontsDir); - // Set up IO stream forwarding if necessary. - WebKit::maybeInitIOStreamForwardingForAndroid(argc, argv); - // Disable auto hint and use normal hinting in layout test mode to produce the same font metrics as chromium-linux. WebKit::WebFontRendering::setAutoHint(false); WebKit::WebFontRendering::setHinting(SkPaint::kNormal_Hinting); diff --git a/Tools/DumpRenderTree/efl/EventSender.cpp b/Tools/DumpRenderTree/efl/EventSender.cpp index b09031c0e..78d2dbcf3 100644 --- a/Tools/DumpRenderTree/efl/EventSender.cpp +++ b/Tools/DumpRenderTree/efl/EventSender.cpp @@ -529,9 +529,24 @@ static void sendKeyDown(Evas* evas, KeyEventInfo* keyEventInfo) DumpRenderTreeSupportEfl::layoutFrame(browser->mainFrame()); ASSERT(evas); + + int eventIndex = 0; + // Mimic the emacs ctrl-o binding by inserting a paragraph + // separator and then putting the cursor back to its original + // position. Allows us to pass emacs-ctrl-o.html + if ((modifiers & EvasKeyModifierControl) && !strcmp(keyName, "o")) { + setEvasModifiers(evas, EvasKeyModifierNone); + evas_event_feed_key_down(evas, "Return", "Return", "\r", 0, eventIndex++, 0); + evas_event_feed_key_up(evas, "Return", "Return", "\r", 0, eventIndex++, 0); + + modifiers = EvasKeyModifierNone; + keyName = "Left"; + keyString = 0; + } + setEvasModifiers(evas, modifiers); - evas_event_feed_key_down(evas, keyName, keyName, keyString, 0, 0, 0); - evas_event_feed_key_up(evas, keyName, keyName, keyString, 0, 1, 0); + evas_event_feed_key_down(evas, keyName, keyName, keyString, 0, eventIndex++, 0); + evas_event_feed_key_up(evas, keyName, keyName, keyString, 0, eventIndex++, 0); setEvasModifiers(evas, EvasKeyModifierNone); DumpRenderTreeSupportEfl::deliverAllMutationsIfNecessary(); diff --git a/Tools/DumpRenderTree/gtk/AccessibilityControllerGtk.cpp b/Tools/DumpRenderTree/gtk/AccessibilityControllerGtk.cpp index ceeb8dfcb..466182bb3 100644 --- a/Tools/DumpRenderTree/gtk/AccessibilityControllerGtk.cpp +++ b/Tools/DumpRenderTree/gtk/AccessibilityControllerGtk.cpp @@ -70,6 +70,12 @@ AccessibilityUIElement AccessibilityController::rootElement() return AccessibilityUIElement(accessible); } +AccessibilityUIElement AccessibilityController::accessibleElementById(JSStringRef id) +{ + // FIXME: implement + return 0; +} + void AccessibilityController::setLogFocusEvents(bool) { } diff --git a/Tools/DumpRenderTree/gtk/AccessibilityUIElementGtk.cpp b/Tools/DumpRenderTree/gtk/AccessibilityUIElementGtk.cpp index d2b4e8b4b..6b9edc94b 100644 --- a/Tools/DumpRenderTree/gtk/AccessibilityUIElementGtk.cpp +++ b/Tools/DumpRenderTree/gtk/AccessibilityUIElementGtk.cpp @@ -409,7 +409,8 @@ double AccessibilityUIElement::maxValue() JSStringRef AccessibilityUIElement::valueDescription() { - // FIXME: implement + // FIXME: implement after it has been implemented in ATK. + // See: https://bugzilla.gnome.org/show_bug.cgi?id=684576 return JSStringCreateWithCharacters(0, 0); } diff --git a/Tools/DumpRenderTree/mac/AccessibilityCommonMac.h b/Tools/DumpRenderTree/mac/AccessibilityCommonMac.h new file mode 100644 index 000000000..c8b91257f --- /dev/null +++ b/Tools/DumpRenderTree/mac/AccessibilityCommonMac.h @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2012 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef AccessibilityCommonMac_h +#define AccessibilityCommonMac_h + +#import <JavaScriptCore/JSStringRef.h> + +// If an unsupported attribute is passed in, it will raise an accessibility exception. These are usually caught by the Accessibility Runtime to inform +// the AX client app of the error. However, DRT is the AX client app, so it must catch these exceptions. +#define BEGIN_AX_OBJC_EXCEPTIONS @try { +#define END_AX_OBJC_EXCEPTIONS } @catch(NSException *e) { if (![[e name] isEqualToString:NSAccessibilityException]) @throw; } + + +@interface NSString (JSStringRefAdditions) ++ (NSString *)stringWithJSStringRef:(JSStringRef)jsStringRef; +- (JSStringRef)createJSStringRef; +@end + +#endif // AccessibilityCommonMac_h diff --git a/Tools/DumpRenderTree/mac/AccessibilityCommonMac.mm b/Tools/DumpRenderTree/mac/AccessibilityCommonMac.mm new file mode 100644 index 000000000..082c0f0cc --- /dev/null +++ b/Tools/DumpRenderTree/mac/AccessibilityCommonMac.mm @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2012 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#import "config.h" +#import "AccessibilityCommonMac.h" + +#import <JavaScriptCore/JSStringRefCF.h> + +@implementation NSString (JSStringRefAdditions) + ++ (NSString *)stringWithJSStringRef:(JSStringRef)jsStringRef +{ + if (!jsStringRef) + return nil; + + CFStringRef cfString = JSStringCopyCFString(kCFAllocatorDefault, jsStringRef); + return [(NSString *)cfString autorelease]; +} + +- (JSStringRef)createJSStringRef +{ + return JSStringCreateWithCFString((CFStringRef)self); +} + +@end diff --git a/Tools/DumpRenderTree/mac/AccessibilityControllerMac.mm b/Tools/DumpRenderTree/mac/AccessibilityControllerMac.mm index 6fc0dd056..6e0213241 100644 --- a/Tools/DumpRenderTree/mac/AccessibilityControllerMac.mm +++ b/Tools/DumpRenderTree/mac/AccessibilityControllerMac.mm @@ -27,10 +27,13 @@ #import "DumpRenderTree.h" #import "AccessibilityController.h" +#import "AccessibilityCommonMac.h" #import "AccessibilityNotificationHandler.h" #import "AccessibilityUIElement.h" #import <AppKit/NSColor.h> #import <Foundation/Foundation.h> +#import <JavaScriptCore/JSStringRef.h> +#import <JavaScriptCore/JSStringRefCF.h> #import <WebKit/WebFrame.h> #import <WebKit/WebFramePrivate.h> #import <WebKit/WebHTMLView.h> @@ -68,6 +71,36 @@ AccessibilityUIElement AccessibilityController::rootElement() return AccessibilityUIElement(accessibilityObject); } +static id findAccessibleObjectById(id obj, NSString *idAttribute) +{ + BEGIN_AX_OBJC_EXCEPTIONS + id objIdAttribute = [obj accessibilityAttributeValue:@"AXDRTElementIdAttribute"]; + if ([objIdAttribute isKindOfClass:[NSString class]] && [objIdAttribute isEqualToString:idAttribute]) + return obj; + END_AX_OBJC_EXCEPTIONS + + NSArray *children = [obj accessibilityAttributeValue:NSAccessibilityChildrenAttribute]; + NSUInteger childrenCount = [children count]; + for (NSUInteger i = 0; i < childrenCount; ++i) { + id result = findAccessibleObjectById([children objectAtIndex:i], idAttribute); + if (result) + return result; + } + + return 0; +} + +AccessibilityUIElement AccessibilityController::accessibleElementById(JSStringRef idAttributeRef) +{ + NSString *idAttribute = [NSString stringWithJSStringRef:idAttributeRef]; + id root = [[mainFrame accessibilityRoot] accessibilityAttributeValue:NSAccessibilityParentAttribute]; + id result = findAccessibleObjectById(root, idAttribute); + if (result) + return AccessibilityUIElement(result); + + return 0; +} + void AccessibilityController::setLogFocusEvents(bool) { } diff --git a/Tools/DumpRenderTree/mac/AccessibilityUIElementMac.mm b/Tools/DumpRenderTree/mac/AccessibilityUIElementMac.mm index 5abd52700..cd1c92d12 100644 --- a/Tools/DumpRenderTree/mac/AccessibilityUIElementMac.mm +++ b/Tools/DumpRenderTree/mac/AccessibilityUIElementMac.mm @@ -25,6 +25,7 @@ #import "config.h" #import "DumpRenderTree.h" +#import "AccessibilityCommonMac.h" #import "AccessibilityNotificationHandler.h" #import "AccessibilityUIElement.h" @@ -51,12 +52,6 @@ #define NSAccessibilityDropEffectsAttribute @"AXDropEffects" #endif -// If an unsupported attribute is passed in, it will raise an accessibility exception. These are usually caught by the Accessibility Runtime to inform -// the AX client app of the error. However, DRT is the AX client app, so it must catch these exceptions. -#define BEGIN_AX_OBJC_EXCEPTIONS @try { -#define END_AX_OBJC_EXCEPTIONS } @catch(NSException *e) { if (![[e name] isEqualToString:NSAccessibilityException]) @throw; } - - typedef void (*AXPostedNotificationCallback)(id element, NSString* notification, void* context); @interface NSObject (WebKitAccessibilityAdditions) @@ -65,29 +60,6 @@ typedef void (*AXPostedNotificationCallback)(id element, NSString* notification, - (NSUInteger)accessibilityArrayAttributeCount:(NSString *)attribute; @end -@interface NSString (JSStringRefAdditions) -+ (NSString *)stringWithJSStringRef:(JSStringRef)jsStringRef; -- (JSStringRef)createJSStringRef; -@end - -@implementation NSString (JSStringRefAdditions) - -+ (NSString *)stringWithJSStringRef:(JSStringRef)jsStringRef -{ - if (!jsStringRef) - return NULL; - - CFStringRef cfString = JSStringCopyCFString(kCFAllocatorDefault, jsStringRef); - return [(NSString *)cfString autorelease]; -} - -- (JSStringRef)createJSStringRef -{ - return JSStringCreateWithCFString((CFStringRef)self); -} - -@end - AccessibilityUIElement::AccessibilityUIElement(PlatformUIElement element) : m_element(element) , m_notificationHandler(0) diff --git a/Tools/DumpRenderTree/win/AccessibilityControllerWin.cpp b/Tools/DumpRenderTree/win/AccessibilityControllerWin.cpp index 7f9aa6cc2..9e76c8dda 100644 --- a/Tools/DumpRenderTree/win/AccessibilityControllerWin.cpp +++ b/Tools/DumpRenderTree/win/AccessibilityControllerWin.cpp @@ -67,6 +67,12 @@ AccessibilityUIElement AccessibilityController::elementAtPoint(int x, int y) return 0; } +AccessibilityUIElement AccessibilityController::accessibleElementById(JSStringRef id) +{ + // FIXME: implement + return 0; +} + AccessibilityUIElement AccessibilityController::focusedElement() { COMPtr<IAccessible> rootAccessible = rootElement().platformUIElement(); |