[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

darin at apple.com darin at apple.com
Wed Dec 22 11:28:57 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 33d3ec1e5689449bf71512dfa9c72b36bdf8cc65
Author: darin at apple.com <darin at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Jul 27 01:17:48 2010 +0000

    WebKitTestRunner needs to support layoutTestController.counterValueForElementById
    https://bugs.webkit.org/show_bug.cgi?id=42537
    
    Reviewed by Sam Weinig.
    
    WebKitTestRunner needs layoutTestController.markerTextForListItem
    https://bugs.webkit.org/show_bug.cgi?id=42549
    
    WebKit2:
    
    * UIProcess/API/C/WKString.cpp:
    (WKStringIsEmpty): Added.
    * UIProcess/API/C/WKString.h: Added WKStringIsEmpty.
    
    * WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp:
    (copiedString): Added. Helper for functions that return a
    WKStringRef that follows the copy rule.
    (WKBundleFrameCopyName): Use copiedString.
    (WKBundleFrameCopyCounterValue): Added. Calls counterValue.
    (WKBundleFrameCopyMarkerText): Added. Calls markerText.
    * WebProcess/InjectedBundle/API/c/WKBundleFramePrivate.h:
    Added WKBundleFrameCopyCounterValue and WKBundleFrameCopyMarkerText.
    
    * WebProcess/WebPage/WebFrame.cpp:
    (WebKit::WebFrame::computedStyleIncludingVisitedInfo):
    Renamed argument to streamline function a bit.
    (WebKit::WebFrame::counterValue): Added.
    (WebKit::WebFrame::markerText): Added.
    * WebProcess/WebPage/WebFrame.h: Added counterValue and markerText.
    
    WebKitTools:
    
    * WebKitTestRunner/InjectedBundle/Bindings/CodeGeneratorTestRunner.pm:
    Fixed _paramterExpression typo. Improved support for string type as a
    return value, so we don't try to include DOMString.h and we can convert
    the string to a JSValue by calling JSValueMakeStringOrNull.
    
    * WebKitTestRunner/InjectedBundle/Bindings/JSWrappable.h:
    Added JSValueMakeStringOrNull, used by the code generator.
    
    * WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl:
    Added counterValueForElementById and markerTextForListItem.
    
    * WebKitTestRunner/InjectedBundle/LayoutTestController.cpp:
    Moved constant to the top of the file.
    (WTR::toCF): Added. Converts strings to CFStringRef.
    (WTR::toWK): Added. Converts strings to WKStringRef.
    (WTR::toJS): Added. Converts strings to JSStringRef.
    (WTR::setProperty): Moved this function to the top of the file
    rather than having it down where it's used inside the class. Also
    renamed it so it's a separate function rather than an overload of
    JSObjectSetProperty.
    (WTR::propertyValue): Copied this here from InjectedBundlePage.cpp.
    Should move it somewhere we can share it.
    (WTR::propertyObject): Ditto.
    (WTR::getElementById): Added. Calls getElementById through the magic
    of JavaScript.
    (WTR::LayoutTestController::pauseAnimationAtTimeOnElementWithId):
    Chagned to use toWK instead of four local variables.
    (WTR::LayoutTestController::counterValueForElementById): Added.
    Calls WKBundleFrameCopyCounterValue.
    (WTR::LayoutTestController::markerTextForListItem): Added.
    Calls WKBundleFrameCopyMarkerText.
    
    * WebKitTestRunner/InjectedBundle/LayoutTestController.h:
    Added counterValueForElementById and markerTextForListItem.
    
    LayoutTests:
    
    * platform/mac-wk2/Skipped: Removed tests that were failing due to one of the above.
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@64096 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 844d023..22fca2d 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,15 @@
+2010-07-26  Darin Adler  <darin at apple.com>
+
+        Reviewed by Sam Weinig.
+
+        WebKitTestRunner needs to support layoutTestController.counterValueForElementById
+        https://bugs.webkit.org/show_bug.cgi?id=42537
+
+        WebKitTestRunner needs layoutTestController.markerTextForListItem
+        https://bugs.webkit.org/show_bug.cgi?id=42549
+
+        * platform/mac-wk2/Skipped: Removed tests that were failing due to one of the above.
+
 2010-07-26  Simon Fraser  <simon.fraser at apple.com>
 
         Reviewed by Dan Bernstein.
diff --git a/LayoutTests/platform/mac-wk2/Skipped b/LayoutTests/platform/mac-wk2/Skipped
index 42f5b26..e43069d 100644
--- a/LayoutTests/platform/mac-wk2/Skipped
+++ b/LayoutTests/platform/mac-wk2/Skipped
@@ -1968,19 +1968,6 @@ fast/frames/flattening/iframe-flattening-fixed-width.html
 fast/frames/flattening/iframe-flattening-offscreen.html
 fast/frames/flattening/iframe-flattening-simple.html
 
-# WebKitTestRunner needs to support layoutTestController.counterValueForElementById
-# <https://bugs.webkit.org/show_bug.cgi?id=42537>
-fast/css/counters/adding-nodes.html
-fast/css/counters/counter-reset-001.html
-fast/css/counters/counter-increment-000.html
-fast/css/counters/counter-reset-002.html
-fast/css/counters/counter-increment-001.html
-fast/css/counters/counterValueForElementById.html
-fast/css/counters/counter-increment-002.html
-fast/css/counters/invalidate-cached-counter-node.html
-fast/css/counters/counter-reset-000.html
-fast/css/counters/nesting.html
-
 # WebKitTestRunner needs to support layoutTestController.execCommand
 # <https://bugs.webkit.org/show_bug.cgi?id=42538>
 editing/deleting/5300379.html
@@ -2095,15 +2082,6 @@ svg/custom/manually-parsed-embedded-svg-disallowed-in-dashboard.html
 svg/custom/manually-parsed-svg-disallowed-in-dashboard.html
 svg/custom/svg-disallowed-in-dashboard-object.html
 
-# WebKitTestRunner needs layoutTestController.markerTextForListItem
-# <https://bugs.webkit.org/show_bug.cgi?id=42549>
-fast/lists/ol-nested-items.html
-fast/lists/ol-nested-items-dynamic-insert.html
-fast/lists/ol-nested-items-dynamic-remove.html
-fast/lists/ol-nested-list.html
-fast/lists/ol-nested-list-dynamic-insert.html
-fast/lists/ol-nested-list-dynamic-remove.html
-
 # WebKitTestRunner needs layoutTestController.pauseTransitionAtTimeOnElementWithId
 # <https://bugs.webkit.org/show_bug.cgi?id=42550>
 transitions/transition-drt-api-delay.html
diff --git a/WebKit2/ChangeLog b/WebKit2/ChangeLog
index f3b38e0..f2db396 100644
--- a/WebKit2/ChangeLog
+++ b/WebKit2/ChangeLog
@@ -1,3 +1,33 @@
+2010-07-26  Darin Adler  <darin at apple.com>
+
+        Reviewed by Sam Weinig.
+
+        WebKitTestRunner needs to support layoutTestController.counterValueForElementById
+        https://bugs.webkit.org/show_bug.cgi?id=42537
+
+        WebKitTestRunner needs layoutTestController.markerTextForListItem
+        https://bugs.webkit.org/show_bug.cgi?id=42549
+
+        * UIProcess/API/C/WKString.cpp:
+        (WKStringIsEmpty): Added.
+        * UIProcess/API/C/WKString.h: Added WKStringIsEmpty.
+
+        * WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp:
+        (copiedString): Added. Helper for functions that return a
+        WKStringRef that follows the copy rule.
+        (WKBundleFrameCopyName): Use copiedString.
+        (WKBundleFrameCopyCounterValue): Added. Calls counterValue.
+        (WKBundleFrameCopyMarkerText): Added. Calls markerText.
+        * WebProcess/InjectedBundle/API/c/WKBundleFramePrivate.h:
+        Added WKBundleFrameCopyCounterValue and WKBundleFrameCopyMarkerText.
+
+        * WebProcess/WebPage/WebFrame.cpp:
+        (WebKit::WebFrame::computedStyleIncludingVisitedInfo):
+        Renamed argument to streamline function a bit.
+        (WebKit::WebFrame::counterValue): Added.
+        (WebKit::WebFrame::markerText): Added.
+        * WebProcess/WebPage/WebFrame.h: Added counterValue and markerText.
+
 2010-07-26  Sam Weinig  <sam at webkit.org>
 
         Reviewed by Anders Carlsson.
diff --git a/WebKit2/UIProcess/API/C/WKString.cpp b/WebKit2/UIProcess/API/C/WKString.cpp
index a1d4cd8..b12021c 100644
--- a/WebKit2/UIProcess/API/C/WKString.cpp
+++ b/WebKit2/UIProcess/API/C/WKString.cpp
@@ -38,3 +38,8 @@ void WKStringRelease(WKStringRef stringRef)
 {
     toWK(stringRef)->deref();
 }
+
+bool WKStringIsEmpty(WKStringRef stringRef)
+{
+    return !toWK(stringRef)->length();
+}
diff --git a/WebKit2/UIProcess/API/C/WKString.h b/WebKit2/UIProcess/API/C/WKString.h
index 2d9e021..89511bc 100644
--- a/WebKit2/UIProcess/API/C/WKString.h
+++ b/WebKit2/UIProcess/API/C/WKString.h
@@ -28,6 +28,10 @@
 
 #include <WebKit2/WKBase.h>
 
+#ifndef __cplusplus
+#include <stdbool.h>
+#endif
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -35,6 +39,8 @@ extern "C" {
 WK_EXPORT WKStringRef WKStringRetain(WKStringRef string);
 WK_EXPORT void WKStringRelease(WKStringRef string);
 
+WK_EXPORT bool WKStringIsEmpty(WKStringRef string);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp b/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp
index 67ee541..5d46bdb 100644
--- a/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp
+++ b/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp
@@ -34,6 +34,13 @@
 using namespace WebCore;
 using namespace WebKit;
 
+static WKStringRef copiedString(const WebCore::String& string)
+{
+    StringImpl* impl = string.impl() ? string.impl() : StringImpl::empty();
+    impl->ref();
+    return toRef(impl);
+}
+
 bool WKBundleFrameIsMainFrame(WKBundleFrameRef frameRef)
 {
     return toWK(frameRef)->isMainFrame();
@@ -66,12 +73,20 @@ JSGlobalContextRef WKBundleFrameGetJavaScriptContext(WKBundleFrameRef frameRef)
 
 WKStringRef WKBundleFrameCopyName(WKBundleFrameRef frameRef)
 {
-    WebCore::String string = toWK(frameRef)->name();
-    string.impl()->ref();
-    return toRef(string.impl());
+    return copiedString(toWK(frameRef)->name());
 }
 
 JSValueRef WKBundleFrameGetComputedStyleIncludingVisitedInfo(WKBundleFrameRef frameRef, JSObjectRef element)
 {
     return toWK(frameRef)->computedStyleIncludingVisitedInfo(element);
 }
+
+WKStringRef WKBundleFrameCopyCounterValue(WKBundleFrameRef frameRef, JSObjectRef element)
+{
+    return copiedString(toWK(frameRef)->counterValue(element));
+}
+
+WKStringRef WKBundleFrameCopyMarkerText(WKBundleFrameRef frameRef, JSObjectRef element)
+{
+    return copiedString(toWK(frameRef)->markerText(element));
+}
diff --git a/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFramePrivate.h b/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFramePrivate.h
index fb88171..3a6ed44 100644
--- a/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFramePrivate.h
+++ b/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFramePrivate.h
@@ -38,6 +38,8 @@
 extern "C" {
 #endif
 
+WK_EXPORT WKStringRef WKBundleFrameCopyCounterValue(WKBundleFrameRef frame, JSObjectRef element);
+WK_EXPORT WKStringRef WKBundleFrameCopyMarkerText(WKBundleFrameRef frame, JSObjectRef element);
 WK_EXPORT JSValueRef WKBundleFrameGetComputedStyleIncludingVisitedInfo(WKBundleFrameRef frame, JSObjectRef element);
 WK_EXPORT unsigned WKBundleFrameGetNumberOfActiveAnimations(WKBundleFrameRef frame);
 WK_EXPORT bool WKBundleFramePauseAnimationOnElementWithId(WKBundleFrameRef frame, WKStringRef name, WKStringRef elementID, double time);
diff --git a/WebKit2/WebProcess/WebPage/WebFrame.cpp b/WebKit2/WebProcess/WebPage/WebFrame.cpp
index c5d6046..3ae6335 100644
--- a/WebKit2/WebProcess/WebPage/WebFrame.cpp
+++ b/WebKit2/WebProcess/WebPage/WebFrame.cpp
@@ -34,7 +34,7 @@
 #include <WebCore/HTMLFrameOwnerElement.h>
 #include <WebCore/JSCSSStyleDeclaration.h>
 #include <WebCore/JSElement.h>
-#include <WebCore/PlatformString.h>
+#include <WebCore/RenderTreeAsText.h>
 
 #ifndef NDEBUG
 #include <wtf/RefCountedLeakCounter.h>
@@ -257,7 +257,7 @@ JSGlobalContextRef WebFrame::jsContext()
     return const_cast<JSGlobalContextRef>(toRef(m_coreFrame->script()->globalObject(mainThreadNormalWorld())->globalExec()));
 }
 
-JSValueRef WebFrame::computedStyleIncludingVisitedInfo(JSObjectRef elementJSObject)
+JSValueRef WebFrame::computedStyleIncludingVisitedInfo(JSObjectRef element)
 {
     if (!m_coreFrame)
         return 0;
@@ -265,13 +265,29 @@ JSValueRef WebFrame::computedStyleIncludingVisitedInfo(JSObjectRef elementJSObje
     JSDOMWindow* globalObject = m_coreFrame->script()->globalObject(mainThreadNormalWorld());
     ExecState* exec = globalObject->globalExec();
 
-    if (!toJS(elementJSObject)->inherits(&JSElement::s_info))
+    if (!toJS(element)->inherits(&JSElement::s_info))
         return JSValueMakeUndefined(toRef(exec));
 
-    RefPtr<CSSComputedStyleDeclaration> style = computedStyle(static_cast<JSElement*>(toJS(elementJSObject))->impl(), true);
+    RefPtr<CSSComputedStyleDeclaration> style = computedStyle(static_cast<JSElement*>(toJS(element))->impl(), true);
 
     JSLock lock(SilenceAssertionsOnly);
     return toRef(exec, toJS(exec, globalObject, style.get()));
 }
 
+String WebFrame::counterValue(JSObjectRef element)
+{
+    if (!toJS(element)->inherits(&JSElement::s_info))
+        return String();
+
+    return counterValueForElement(static_cast<JSElement*>(toJS(element))->impl());
+}
+
+String WebFrame::markerText(JSObjectRef element)
+{
+    if (!toJS(element)->inherits(&JSElement::s_info))
+        return String();
+
+    return markerTextForListItem(static_cast<JSElement*>(toJS(element))->impl());
+}
+
 } // namespace WebKit
diff --git a/WebKit2/WebProcess/WebPage/WebFrame.h b/WebKit2/WebProcess/WebPage/WebFrame.h
index 3c035f9..f3f3a7b 100644
--- a/WebKit2/WebProcess/WebPage/WebFrame.h
+++ b/WebKit2/WebProcess/WebPage/WebFrame.h
@@ -64,13 +64,15 @@ public:
     void invalidatePolicyListener();
     void didReceivePolicyDecision(uint64_t listenerID, WebCore::PolicyAction);
 
-    // WKBundleFrame API functions
+    // WKBundleFrame API and SPI functions
     bool isMainFrame() const;
     WebCore::String name() const;
     WebCore::String url() const;
     PassRefPtr<ImmutableArray> childFrames();
     JSValueRef computedStyleIncludingVisitedInfo(JSObjectRef element);
     JSGlobalContextRef jsContext();
+    static WebCore::String counterValue(JSObjectRef element);
+    static WebCore::String markerText(JSObjectRef element);
 
     unsigned numberOfActiveAnimations();
     bool pauseAnimationOnElementWithId(const WebCore::String& animationName, const WebCore::String& elementID, double time);
diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index 2c06677..eb75ca5 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,3 +1,48 @@
+2010-07-26  Darin Adler  <darin at apple.com>
+
+        Reviewed by Sam Weinig.
+
+        WebKitTestRunner needs to support layoutTestController.counterValueForElementById
+        https://bugs.webkit.org/show_bug.cgi?id=42537
+
+        WebKitTestRunner needs layoutTestController.markerTextForListItem
+        https://bugs.webkit.org/show_bug.cgi?id=42549
+
+        * WebKitTestRunner/InjectedBundle/Bindings/CodeGeneratorTestRunner.pm:
+        Fixed _paramterExpression typo. Improved support for string type as a
+        return value, so we don't try to include DOMString.h and we can convert
+        the string to a JSValue by calling JSValueMakeStringOrNull.
+
+        * WebKitTestRunner/InjectedBundle/Bindings/JSWrappable.h:
+        Added JSValueMakeStringOrNull, used by the code generator.
+
+        * WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl:
+        Added counterValueForElementById and markerTextForListItem.
+
+        * WebKitTestRunner/InjectedBundle/LayoutTestController.cpp:
+        Moved constant to the top of the file.
+        (WTR::toCF): Added. Converts strings to CFStringRef.
+        (WTR::toWK): Added. Converts strings to WKStringRef.
+        (WTR::toJS): Added. Converts strings to JSStringRef.
+        (WTR::setProperty): Moved this function to the top of the file
+        rather than having it down where it's used inside the class. Also
+        renamed it so it's a separate function rather than an overload of
+        JSObjectSetProperty.
+        (WTR::propertyValue): Copied this here from InjectedBundlePage.cpp.
+        Should move it somewhere we can share it.
+        (WTR::propertyObject): Ditto.
+        (WTR::getElementById): Added. Calls getElementById through the magic
+        of JavaScript.
+        (WTR::LayoutTestController::pauseAnimationAtTimeOnElementWithId):
+        Chagned to use toWK instead of four local variables.
+        (WTR::LayoutTestController::counterValueForElementById): Added.
+        Calls WKBundleFrameCopyCounterValue.
+        (WTR::LayoutTestController::markerTextForListItem): Added.
+        Calls WKBundleFrameCopyMarkerText.
+
+        * WebKitTestRunner/InjectedBundle/LayoutTestController.h:
+        Added counterValueForElementById and markerTextForListItem.
+
 2010-07-26  Martin Robinson  <mrobinson at igalia.com>
 
         Reviewed by Gustavo Noronha Silva.
diff --git a/WebKitTools/WebKitTestRunner/InjectedBundle/Bindings/CodeGeneratorTestRunner.pm b/WebKitTools/WebKitTestRunner/InjectedBundle/Bindings/CodeGeneratorTestRunner.pm
index 75d7ec7..fa47143 100644
--- a/WebKitTools/WebKitTestRunner/InjectedBundle/Bindings/CodeGeneratorTestRunner.pm
+++ b/WebKitTools/WebKitTestRunner/InjectedBundle/Bindings/CodeGeneratorTestRunner.pm
@@ -260,7 +260,7 @@ EOF
 
                 push(@contents, "    " . $self->_platformTypeVariableDeclaration($parameter, $parameter->name, "arguments[$i]", "argumentCount > $i") . "\n");
                 
-                push(@parameters, $self->_paramterExpression($parameter));
+                push(@parameters, $self->_parameterExpression($parameter));
             }
 
             my $isVoidReturn = $function->signature->type eq "void";
@@ -346,6 +346,7 @@ sub _includeHeaders
     return if $idlType eq "boolean";
     return if $idlType eq "object";
     return if $$self{codeGenerator}->IsNonPointerType($idlType);
+    return if $$self{codeGenerator}->IsStringType($idlType);
 
     $$headers{_className($idlType) . ".h"} = 1;
     $$headers{_implementationClassName($idlType) . ".h"} = 1;
@@ -434,20 +435,17 @@ sub _returnExpression
 {
     my ($self, $signature, $expression) = @_;
 
-    my $convertNullStringAttribute = $signature->extendedAttributes->{"ConvertNullStringTo"};
-    my $nullOrEmptyString = "NullStringAsEmptyString";
-    $nullOrEmptyString = "NullStringAsNull" if defined $convertNullStringAttribute && $convertNullStringAttribute eq "Null";
-
     my $returnIDLType = $signature->type;
 
     return "JSValueMakeUndefined(context)" if $returnIDLType eq "void";
     return "JSValueMakeBoolean(context, ${expression})" if $returnIDLType eq "boolean";
     return "${expression}" if $returnIDLType eq "object";
     return "JSValueMakeNumber(context, ${expression})" if $$self{codeGenerator}->IsNonPointerType($returnIDLType);
+    return "JSValueMakeStringOrNull(context, ${expression}.get())" if $$self{codeGenerator}->IsStringType($returnIDLType);
     return "toJS(context, WTF::getPtr(${expression}))";
 }
 
-sub _paramterExpression
+sub _parameterExpression
 {
     my ($self, $parameter) = @_;
 
diff --git a/WebKitTools/WebKitTestRunner/InjectedBundle/Bindings/JSWrappable.h b/WebKitTools/WebKitTestRunner/InjectedBundle/Bindings/JSWrappable.h
index cf56c5d..9cb97af 100644
--- a/WebKitTools/WebKitTestRunner/InjectedBundle/Bindings/JSWrappable.h
+++ b/WebKitTools/WebKitTestRunner/InjectedBundle/Bindings/JSWrappable.h
@@ -37,6 +37,11 @@ public:
     virtual JSClassRef wrapperClass() = 0;
 };
 
+inline JSValueRef JSValueMakeStringOrNull(JSContextRef context, JSStringRef stringOrNull)
+{
+    return stringOrNull ? JSValueMakeString(context, stringOrNull) : JSValueMakeNull(context);
+}
+
 } // namespace WTR
 
 #endif // JSWrappable_h
diff --git a/WebKitTools/WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl b/WebKitTools/WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl
index 08e93b6..6d4fd65 100644
--- a/WebKitTools/WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl
+++ b/WebKitTools/WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl
@@ -44,6 +44,8 @@ module WTR {
 
         // Special DOM functions.
         object computedStyleIncludingVisitedInfo(in object element);
+        DOMString counterValueForElementById(in DOMString elementId);
+        DOMString markerTextForListItem(in object element);
 
         // Repaint testing.
         void testRepaint();
diff --git a/WebKitTools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp b/WebKitTools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp
index 0268256..e760fe8 100644
--- a/WebKitTools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp
+++ b/WebKitTools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp
@@ -37,6 +37,75 @@
 
 namespace WTR {
 
+// This is lower than DumpRenderTree's timeout, to make it easier to work through the failures
+// Eventually it should be changed to match.
+static const CFTimeInterval waitToDumpWatchdogInterval = 6.0;
+
+static RetainPtr<CFStringRef> toCF(JSStringRef string)
+{
+    return RetainPtr<CFStringRef>(AdoptCF, JSStringCopyCFString(0, string));
+}
+
+static RetainPtr<CFStringRef> toCF(WKStringRef string)
+{
+    return RetainPtr<CFStringRef>(AdoptCF, WKStringCopyCFString(0, string));
+}
+
+static WKRetainPtr<WKStringRef> toWK(JSStringRef string)
+{
+    return WKRetainPtr<WKStringRef>(AdoptWK, WKStringCreateWithCFString(toCF(string).get()));
+}
+
+static JSRetainPtr<JSStringRef> toJS(WKStringRef string)
+{
+    return JSRetainPtr<JSStringRef>(Adopt, JSStringCreateWithCFString(toCF(string).get()));
+}
+
+static JSRetainPtr<JSStringRef> toJS(const WKRetainPtr<WKStringRef>& string)
+{
+    return toJS(string.get());
+}
+
+static void setProperty(JSContextRef context, JSObjectRef object, const char* propertyName, JSWrappable* value, JSPropertyAttributes attributes, JSValueRef* exception)
+{
+    JSRetainPtr<JSStringRef> propertyNameString(Adopt, JSStringCreateWithUTF8CString(propertyName));
+    JSObjectSetProperty(context, object, propertyNameString.get(), JSWrapper::wrap(context, value), attributes, exception);
+}
+
+static JSValueRef propertyValue(JSContextRef context, JSObjectRef object, const char* propertyName)
+{
+    if (!object)
+        return 0;
+    JSRetainPtr<JSStringRef> propertyNameString(Adopt, JSStringCreateWithUTF8CString(propertyName));
+    JSValueRef exception;
+    return JSObjectGetProperty(context, object, propertyNameString.get(), &exception);
+}
+
+static JSObjectRef propertyObject(JSContextRef context, JSObjectRef object, const char* propertyName)
+{
+    JSValueRef value = propertyValue(context, object, propertyName);
+    if (!value || !JSValueIsObject(context, value))
+        return 0;
+    return const_cast<JSObjectRef>(value);
+}
+
+static JSObjectRef getElementById(WKBundleFrameRef frame, JSStringRef elementId)
+{
+    JSContextRef context = WKBundleFrameGetJavaScriptContext(frame);
+    JSObjectRef document = propertyObject(context, JSContextGetGlobalObject(context), "document");
+    if (!document)
+        return 0;
+    JSValueRef getElementById = propertyObject(context, document, "getElementById");
+    if (!getElementById || !JSValueIsObject(context, getElementById))
+        return 0;
+    JSValueRef elementIdValue = JSValueMakeString(context, elementId);
+    JSValueRef exception;
+    JSValueRef element = JSObjectCallAsFunction(context, const_cast<JSObjectRef>(getElementById), document, 1, &elementIdValue, &exception);
+    if (!element || !JSValueIsObject(context, element))
+        return 0;
+    return const_cast<JSObjectRef>(element);
+}
+
 PassRefPtr<LayoutTestController> LayoutTestController::create()
 {
     return adoptRef(new LayoutTestController);
@@ -63,10 +132,6 @@ JSClassRef LayoutTestController::wrapperClass()
     return JSLayoutTestController::layoutTestControllerClass();
 }
 
-// This is lower than DumpRenderTree's timeout, to make it easier to work through the failures
-// Eventually it should be changed to match.
-static const CFTimeInterval waitToDumpWatchdogInterval = 6.0;
-
 void LayoutTestController::display()
 {
     // FIXME: actually implement, once we want pixel tests
@@ -122,14 +187,8 @@ bool LayoutTestController::pauseAnimationAtTimeOnElementWithId(JSStringRef anima
 {
     // FIXME: Is it OK this works only for the main frame?
     // FIXME: If this is needed only for the main frame, then why is the function on WKBundleFrame instead of WKBundlePage?
-
-    RetainPtr<CFStringRef> idCF(AdoptCF, JSStringCopyCFString(kCFAllocatorDefault, elementId));
-    WKRetainPtr<WKStringRef> idWK(AdoptWK, WKStringCreateWithCFString(idCF.get()));
-    RetainPtr<CFStringRef> nameCF(AdoptCF, JSStringCopyCFString(kCFAllocatorDefault, animationName));
-    WKRetainPtr<WKStringRef> nameWK(AdoptWK, WKStringCreateWithCFString(nameCF.get()));
-
     WKBundleFrameRef mainFrame = WKBundlePageGetMainFrame(InjectedBundle::shared().page()->page());
-    return WKBundleFramePauseAnimationOnElementWithId(mainFrame, nameWK.get(), idWK.get(), time);
+    return WKBundleFramePauseAnimationOnElementWithId(mainFrame, toWK(animationName).get(), toWK(elementId).get(), time);
 }
 
 void LayoutTestController::keepWebHistory()
@@ -150,17 +209,33 @@ JSValueRef LayoutTestController::computedStyleIncludingVisitedInfo(JSValueRef el
     return value;
 }
 
-// Object Creation
+JSRetainPtr<JSStringRef> LayoutTestController::counterValueForElementById(JSStringRef elementId)
+{
+    WKBundleFrameRef mainFrame = WKBundlePageGetMainFrame(InjectedBundle::shared().page()->page());
+    JSObjectRef element = getElementById(mainFrame, elementId);
+    if (!element)
+        return 0;
+    WKRetainPtr<WKStringRef> value(AdoptWK, WKBundleFrameCopyCounterValue(mainFrame, const_cast<JSObjectRef>(element)));
+    return toJS(value);
+}
 
-static void JSObjectSetProperty(JSContextRef context, JSObjectRef object, const char* propertyName, JSWrappable* value, JSPropertyAttributes attributes, JSValueRef* exception)
+JSRetainPtr<JSStringRef> LayoutTestController::markerTextForListItem(JSValueRef element)
 {
-    JSRetainPtr<JSStringRef> propertyNameString(Adopt, JSStringCreateWithUTF8CString(propertyName));
-    JSObjectSetProperty(context, object, propertyNameString.get(), JSWrapper::wrap(context, value), attributes, exception);
+    WKBundleFrameRef mainFrame = WKBundlePageGetMainFrame(InjectedBundle::shared().page()->page());
+    JSContextRef context = WKBundleFrameGetJavaScriptContext(mainFrame);
+    if (!element || !JSValueIsObject(context, element))
+        return 0;
+    WKRetainPtr<WKStringRef> text(AdoptWK, WKBundleFrameCopyMarkerText(mainFrame, const_cast<JSObjectRef>(element)));
+    if (WKStringIsEmpty(text.get()))
+        return 0;
+    return toJS(text);
 }
 
+// Object Creation
+
 void LayoutTestController::makeWindowObject(JSContextRef context, JSObjectRef windowObject, JSValueRef* exception)
 {
-    JSObjectSetProperty(context, windowObject, "layoutTestController", this, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete, exception);
+    setProperty(context, windowObject, "layoutTestController", this, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete, exception);
 }
 
 } // namespace WTR
diff --git a/WebKitTools/WebKitTestRunner/InjectedBundle/LayoutTestController.h b/WebKitTools/WebKitTestRunner/InjectedBundle/LayoutTestController.h
index 3f24064..3a10854 100644
--- a/WebKitTools/WebKitTestRunner/InjectedBundle/LayoutTestController.h
+++ b/WebKitTools/WebKitTestRunner/InjectedBundle/LayoutTestController.h
@@ -28,6 +28,7 @@
 
 #include "JSWrappable.h"
 #include <JavaScriptCore/JavaScriptCore.h>
+#include <JavaScriptCore/JSRetainPtr.h>
 #include <wtf/PassRefPtr.h>
 #include <wtf/RetainPtr.h>
 #include <string>
@@ -61,7 +62,9 @@ public:
     void setAcceptsEditing(bool value) { m_shouldAllowEditing = value; }
 
     // Special DOM functions.
-    JSValueRef computedStyleIncludingVisitedInfo(JSValueRef);
+    JSValueRef computedStyleIncludingVisitedInfo(JSValueRef element);
+    JSRetainPtr<JSStringRef> counterValueForElementById(JSStringRef elementId);
+    JSRetainPtr<JSStringRef> markerTextForListItem(JSValueRef element);
 
     // Repaint testing.
     void testRepaint() { m_testRepaint = true; }

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list