Patch for https://bugs.webkit.org/show_bug.cgi?id=43305
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 31 Jul 2010 22:37:35 +0000 (22:37 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 31 Jul 2010 22:37:35 +0000 (22:37 +0000)
Add back WKBundleFrameCopyInnerText to fix ~50 test failures
due to SVGElements not having the innerText function.

Reviewed by Dan Bernstein.

WebKit2:

* WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp:
(WKBundleFrameCopyInnerText):
* WebProcess/InjectedBundle/API/c/WKBundleFramePrivate.h:
* WebProcess/WebPage/WebFrame.cpp:
(WebKit::WebFrame::innerText):
* WebProcess/WebPage/WebFrame.h:

WebKitTools:

* WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:
(WTR::dumpFrameText):

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

WebKit2/ChangeLog
WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp
WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFramePrivate.h
WebKit2/WebProcess/WebPage/WebFrame.cpp
WebKit2/WebProcess/WebPage/WebFrame.h
WebKitTools/ChangeLog
WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp

index 2e02226..f086d4d 100644 (file)
@@ -1,3 +1,18 @@
+2010-07-31  Sam Weinig  <sam@webkit.org>
+
+        Reviewed by Dan Bernstein.
+
+        Patch for https://bugs.webkit.org/show_bug.cgi?id=43305
+        Add back WKBundleFrameCopyInnerText to fix ~50 test failures
+        due to SVGElements not having the innerText function.
+
+        * WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp:
+        (WKBundleFrameCopyInnerText):
+        * WebProcess/InjectedBundle/API/c/WKBundleFramePrivate.h:
+        * WebProcess/WebPage/WebFrame.cpp:
+        (WebKit::WebFrame::innerText):
+        * WebProcess/WebPage/WebFrame.h:
+
 2010-07-27  Luiz Agostini  <luiz.agostini@openbossa.org>
 
         Reviewed by Darin Fisher.
index 5da8bae..707a249 100644 (file)
@@ -88,3 +88,8 @@ WKStringRef WKBundleFrameCopyMarkerText(WKBundleFrameRef frameRef, JSObjectRef e
 {
     return toCopiedRef(toWK(frameRef)->markerText(element));
 }
+
+WKStringRef WKBundleFrameCopyInnerText(WKBundleFrameRef frameRef)
+{
+    return toCopiedRef(toWK(frameRef)->innerText());
+}
index 3a6ed44..055e7cd 100644 (file)
@@ -38,6 +38,7 @@
 extern "C" {
 #endif
 
+WK_EXPORT WKStringRef WKBundleFrameCopyInnerText(WKBundleFrameRef frame);
 WK_EXPORT WKStringRef WKBundleFrameCopyCounterValue(WKBundleFrameRef frame, JSObjectRef element);
 WK_EXPORT WKStringRef WKBundleFrameCopyMarkerText(WKBundleFrameRef frame, JSObjectRef element);
 WK_EXPORT JSValueRef WKBundleFrameGetComputedStyleIncludingVisitedInfo(WKBundleFrameRef frame, JSObjectRef element);
index 7d82a19..6b3b221 100644 (file)
@@ -185,6 +185,14 @@ String WebFrame::url() const
     return m_coreFrame->loader()->url().string();
 }
 
+String WebFrame::innerText() const
+{
+    if (!m_coreFrame)
+        return String();
+
+    return m_coreFrame->document()->documentElement()->innerText();
+}
+
 PassRefPtr<ImmutableArray> WebFrame::childFrames()
 {
     if (!m_coreFrame)
index 419bd73..6a018ee 100644 (file)
@@ -70,6 +70,7 @@ public:
     bool isMainFrame() const;
     WebCore::String name() const;
     WebCore::String url() const;
+    WebCore::String innerText() const;
     PassRefPtr<ImmutableArray> childFrames();
     JSValueRef computedStyleIncludingVisitedInfo(JSObjectRef element);
     JSGlobalContextRef jsContext();
index 48773fd..47f9d9e 100644 (file)
@@ -1,3 +1,14 @@
+2010-07-31  Sam Weinig  <sam@webkit.org>
+
+        Reviewed by Dan Bernstein.
+
+        Patch for https://bugs.webkit.org/show_bug.cgi?id=43305
+        Add back WKBundleFrameCopyInnerText to fix ~50 test failures
+        due to SVGElements not having the innerText function.
+
+        * WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:
+        (WTR::dumpFrameText):
+
 2010-07-30  Sam Weinig  <sam@webkit.org>
 
         Reviewed by Maciej Stachowiak.
index ca01c14..f5570f6 100644 (file)
@@ -29,6 +29,7 @@
 #include <JavaScriptCore/JSRetainPtr.h>
 #include <WebKit2/WKArray.h>
 #include <WebKit2/WKBundleFrame.h>
+#include <WebKit2/WKBundleFramePrivate.h>
 #include <WebKit2/WKBundleNode.h>
 #include <WebKit2/WKBundlePagePrivate.h>
 #include <WebKit2/WKRetainPtr.h>
@@ -72,21 +73,6 @@ static ostream& operator<<(ostream& out, const WKRetainPtr<WKStringRef>& stringR
     return out << stringRef.get();
 }
 
-static ostream& operator<<(ostream& out, JSStringRef stringRef)
-{
-    if (!stringRef)
-        return out;
-    CFIndex bufferLength = JSStringGetMaximumUTF8CStringSize(stringRef) + 1;
-    Vector<char> buffer(bufferLength);
-    JSStringGetUTF8CString(stringRef, buffer.data(), bufferLength);
-    return out << buffer.data();
-}
-
-static ostream& operator<<(ostream& out, const JSRetainPtr<JSStringRef>& stringRef)
-{
-    return out << stringRef.get();
-}
-
 static string dumpPath(WKBundleNodeRef node)
 {
     if (!node)
@@ -238,23 +224,6 @@ static JSValueRef propertyValue(JSContextRef context, JSObjectRef object, const
     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 JSRetainPtr<JSStringRef> propertyString(JSContextRef context, JSObjectRef object, const char* propertyName)
-{
-    JSValueRef value = propertyValue(context, object, propertyName);
-    if (!value)
-        return 0;
-    JSValueRef exception;
-    return JSRetainPtr<JSStringRef>(Adopt, JSValueToStringCopy(context, value, &exception));
-}
-
 static double numericWindowPropertyValue(WKBundleFrameRef frame, const char* propertyName)
 {
     JSGlobalContextRef context = WKBundleFrameGetJavaScriptContext(frame);
@@ -300,10 +269,8 @@ void InjectedBundlePage::dumpAllFrameScrollPositions()
 
 static void dumpFrameText(WKBundleFrameRef frame)
 {
-    JSGlobalContextRef context = WKBundleFrameGetJavaScriptContext(frame);
-    JSObjectRef document = propertyObject(context, JSContextGetGlobalObject(context), "document");
-    JSObjectRef documentElement = propertyObject(context, document, "documentElement");
-    InjectedBundle::shared().os() << propertyString(context, documentElement, "innerText") << "\n";
+    WKRetainPtr<WKStringRef> text(AdoptWK, WKBundleFrameCopyInnerText(frame));
+    InjectedBundle::shared().os() << text << "\n";
 }
 
 static void dumpDescendantFramesText(WKBundleFrameRef frame)