summaryrefslogtreecommitdiffstats
path: root/WebKit
diff options
context:
space:
mode:
authorShimeng (Simon) Wang <swang@google.com>2010-06-17 09:26:44 -0700
committerShimeng (Simon) Wang <swang@google.com>2010-06-21 09:54:53 -0700
commitbd9835293313631ebfffd6bdbeb2686bdf624dfe (patch)
tree2920bff3c62b4aa55fb7206e4ac1313bfe4ab417 /WebKit
parente9b72f76a65930718d3b83de2ae52e2104e813c7 (diff)
downloadexternal_webkit-bd9835293313631ebfffd6bdbeb2686bdf624dfe.zip
external_webkit-bd9835293313631ebfffd6bdbeb2686bdf624dfe.tar.gz
external_webkit-bd9835293313631ebfffd6bdbeb2686bdf624dfe.tar.bz2
Dump child frames data according to Mac/Qt implementation for layout tests.
Change-Id: I79bf09b1064d0d21540f492070f9b8a1ded83907
Diffstat (limited to 'WebKit')
-rw-r--r--WebKit/android/jni/WebCoreFrameBridge.cpp48
1 files changed, 44 insertions, 4 deletions
diff --git a/WebKit/android/jni/WebCoreFrameBridge.cpp b/WebKit/android/jni/WebCoreFrameBridge.cpp
index 24f27b1..e375e46 100644
--- a/WebKit/android/jni/WebCoreFrameBridge.cpp
+++ b/WebKit/android/jni/WebCoreFrameBridge.cpp
@@ -73,6 +73,7 @@
#include "SecurityOrigin.h"
#include "SelectionController.h"
#include "Settings.h"
+#include "StringBuilder.h"
#include "SubstituteData.h"
#include "WebCoreJni.h"
#include "WebCoreResourceLoader.h"
@@ -1110,6 +1111,28 @@ static jstring ExternalRepresentation(JNIEnv *env, jobject obj)
return env->NewString(renderDump.characters(), len);
}
+static WebCore::StringBuilder FrameAsText(WebCore::Frame *pFrame, jboolean dumpChildFrames) {
+ WebCore::StringBuilder renderDump;
+ if (!pFrame)
+ return renderDump;
+ WebCore::Element *documentElement = pFrame->document()->documentElement();
+ if (!documentElement)
+ return renderDump;
+ if (pFrame->tree()->parent()) {
+ renderDump.append("\n--------\nFrame: '");
+ renderDump.append(pFrame->tree()->name());
+ renderDump.append("'\n--------\n");
+ }
+ renderDump.append(((WebCore::HTMLElement*)documentElement)->innerText());
+ renderDump.append("\n");
+ if (dumpChildFrames) {
+ for (unsigned i = 0; i < pFrame->tree()->childCount(); ++i) {
+ renderDump.append(FrameAsText(pFrame->tree()->child(i), dumpChildFrames).toString());
+ }
+ }
+ return renderDump;
+}
+
static jstring DocumentAsText(JNIEnv *env, jobject obj)
{
#ifdef ANDROID_INSTRUMENT
@@ -1118,11 +1141,26 @@ static jstring DocumentAsText(JNIEnv *env, jobject obj)
WebCore::Frame* pFrame = GET_NATIVE_FRAME(env, obj);
LOG_ASSERT(pFrame, "android_webcore_nativeDocumentAsText must take a valid frame pointer!");
- WebCore::Element *documentElement = pFrame->document()->documentElement();
- if (!documentElement)
+ WebCore::String renderDump = FrameAsText(pFrame, false /* dumpChildFrames */).toString();
+ unsigned len = renderDump.length();
+ if (!len)
return NULL;
- WebCore::String renderDump = ((WebCore::HTMLElement*)documentElement)->innerText();
- renderDump.append("\n");
+ return env->NewString((unsigned short*)renderDump.characters(), len);
+}
+
+static jstring ChildFramesAsText(JNIEnv *env, jobject obj)
+{
+#ifdef ANDROID_INSTRUMENT
+ TimeCounterAuto counter(TimeCounter::NativeCallbackTimeCounter);
+#endif
+ WebCore::Frame* pFrame = GET_NATIVE_FRAME(env, obj);
+ LOG_ASSERT(pFrame, "android_webcore_nativeDocumentAsText must take a valid frame pointer!");
+
+ WebCore::StringBuilder renderDumpBuilder;
+ for (unsigned i = 0; i < pFrame->tree()->childCount(); ++i) {
+ renderDumpBuilder.append(FrameAsText(pFrame->tree()->child(i), true /* dumpChildFrames */).toString());
+ }
+ WebCore::String renderDump = renderDumpBuilder.toString();
unsigned len = renderDump.length();
if (!len)
return NULL;
@@ -1606,6 +1644,8 @@ static JNINativeMethod gBrowserFrameNativeMethods[] = {
(void*) ExternalRepresentation },
{ "documentAsText", "()Ljava/lang/String;",
(void*) DocumentAsText },
+ { "childFramesAsText", "()Ljava/lang/String;",
+ (void*) ChildFramesAsText },
{ "reload", "(Z)V",
(void*) Reload },
{ "nativeGoBackOrForward", "(I)V",