summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/WebCore/platform/android/RenderThemeAndroid.cpp24
-rw-r--r--Source/WebCore/platform/android/RenderThemeAndroid.h2
-rw-r--r--Source/WebCore/platform/graphics/android/BaseLayerAndroid.cpp2
-rw-r--r--Source/WebCore/platform/graphics/android/MediaTexture.cpp3
-rw-r--r--Source/WebCore/platform/graphics/android/TilesManager.cpp22
-rw-r--r--Source/WebCore/platform/network/android/ResourceHandleAndroid.cpp4
-rw-r--r--Source/WebCore/platform/network/android/ResourceLoaderAndroid.h1
-rw-r--r--Source/WebCore/rendering/RenderHTMLCanvas.cpp7
-rw-r--r--Source/WebCore/rendering/RenderLayerCompositor.cpp4
-rw-r--r--Source/WebKit/Android.mk3
-rw-r--r--Source/WebKit/android/benchmark/Android.mk41
-rw-r--r--Source/WebKit/android/benchmark/Intercept.cpp190
-rw-r--r--Source/WebKit/android/benchmark/Intercept.h82
-rw-r--r--Source/WebKit/android/benchmark/MyJavaVM.cpp130
-rw-r--r--Source/WebKit/android/benchmark/MyJavaVM.h34
-rw-r--r--Source/WebKit/android/benchmark/main.cpp65
-rw-r--r--Source/WebKit/android/jni/AndroidHitTestResult.cpp92
-rw-r--r--Source/WebKit/android/jni/AndroidHitTestResult.h4
-rw-r--r--Source/WebKit/android/jni/WebCoreFrameBridge.cpp14
-rw-r--r--Source/WebKit/android/jni/WebCoreJniOnLoad.cpp159
-rw-r--r--Source/WebKit/android/jni/WebViewCore.cpp82
-rw-r--r--Source/WebKit/android/jni/WebViewCore.h2
-rw-r--r--Source/WebKit/android/nav/WebView.cpp2
23 files changed, 116 insertions, 853 deletions
diff --git a/Source/WebCore/platform/android/RenderThemeAndroid.cpp b/Source/WebCore/platform/android/RenderThemeAndroid.cpp
index 97110ee..ee406c2 100644
--- a/Source/WebCore/platform/android/RenderThemeAndroid.cpp
+++ b/Source/WebCore/platform/android/RenderThemeAndroid.cpp
@@ -633,30 +633,16 @@ bool RenderThemeAndroid::paintMenuListButton(RenderObject* obj, const PaintInfo&
Color RenderThemeAndroid::platformFocusRingColor() const
{
- static Color focusRingColor(0x66, 0x33, 0xB5, 0xE5);
+ static Color focusRingColor(0x33, 0xB5, 0xE5, 0x66);
return focusRingColor;
}
bool RenderThemeAndroid::supportsFocusRing(const RenderStyle* style) const
{
- // TODO: Draw this on the UI side
- // For now, just return false to let WebKit draw the focus ring. We only
- // draw this ring when navigating via the keyboard, this does not affect
- // the touch ring
- return false;
- return style->opacity() > 0
- && style->hasAppearance()
- && style->appearance() != TextFieldPart
- && style->appearance() != SearchFieldPart
- && style->appearance() != TextAreaPart
- && style->appearance() != CheckboxPart
- && style->appearance() != RadioPart
- && style->appearance() != PushButtonPart
- && style->appearance() != SquareButtonPart
- && style->appearance() != ButtonPart
- && style->appearance() != ButtonBevelPart
- && style->appearance() != MenulistPart
- && style->appearance() != MenulistButtonPart;
+ // Draw the focus ring ourselves unless it is a text area (webkit does borders better)
+ if (!style || !style->hasAppearance())
+ return true;
+ return style->appearance() != TextFieldPart && style->appearance() != TextAreaPart;
}
} // namespace WebCore
diff --git a/Source/WebCore/platform/android/RenderThemeAndroid.h b/Source/WebCore/platform/android/RenderThemeAndroid.h
index 165abf8..ed4d07f 100644
--- a/Source/WebCore/platform/android/RenderThemeAndroid.h
+++ b/Source/WebCore/platform/android/RenderThemeAndroid.h
@@ -48,7 +48,7 @@ public:
~RenderThemeAndroid();
virtual bool stateChanged(RenderObject*, ControlState) const;
-
+
virtual bool supportsFocusRing(const RenderStyle*) const;
// A method asking if the theme's controls actually care about redrawing when hovered.
virtual bool supportsHover(const RenderStyle* style) const { return style->affectedByHoverRules(); }
diff --git a/Source/WebCore/platform/graphics/android/BaseLayerAndroid.cpp b/Source/WebCore/platform/graphics/android/BaseLayerAndroid.cpp
index 2d2867c..7208380 100644
--- a/Source/WebCore/platform/graphics/android/BaseLayerAndroid.cpp
+++ b/Source/WebCore/platform/graphics/android/BaseLayerAndroid.cpp
@@ -320,6 +320,8 @@ void BaseLayerAndroid::drawBasePictureInGL()
void BaseLayerAndroid::updateLayerPositions(SkRect& visibleRect)
{
LayerAndroid* compositedRoot = static_cast<LayerAndroid*>(getChild(0));
+ if (!compositedRoot)
+ return;
TransformationMatrix ident;
compositedRoot->updateFixedLayersPositions(visibleRect);
FloatRect clip(0, 0, content()->width(), content()->height());
diff --git a/Source/WebCore/platform/graphics/android/MediaTexture.cpp b/Source/WebCore/platform/graphics/android/MediaTexture.cpp
index f3d1756..2582a53 100644
--- a/Source/WebCore/platform/graphics/android/MediaTexture.cpp
+++ b/Source/WebCore/platform/graphics/android/MediaTexture.cpp
@@ -191,8 +191,7 @@ void MediaTexture::draw(const TransformationMatrix& contentMatrix,
bool forceAlphaBlending = !(
PIXEL_FORMAT_RGBX_8888 == f ||
PIXEL_FORMAT_RGB_888 == f ||
- PIXEL_FORMAT_RGB_565 == f ||
- PIXEL_FORMAT_RGB_332 == f);
+ PIXEL_FORMAT_RGB_565 == f);
TilesManager::instance()->shader()->drawLayerQuad(contentMatrix,
mediaBounds,
diff --git a/Source/WebCore/platform/graphics/android/TilesManager.cpp b/Source/WebCore/platform/graphics/android/TilesManager.cpp
index 7fe856b..184d80c 100644
--- a/Source/WebCore/platform/graphics/android/TilesManager.cpp
+++ b/Source/WebCore/platform/graphics/android/TilesManager.cpp
@@ -183,12 +183,14 @@ void TilesManager::discardTexturesVector(unsigned long long sparedDrawCount,
{
const unsigned int max = textures.size();
int dealloc = 0;
+ WTF::Vector<int> discardedIndex;
for (unsigned int i = 0; i < max; i++) {
TextureOwner* owner = textures[i]->owner();
if (!owner || owner->drawCount() < sparedDrawCount) {
if (deallocateGLTextures) {
// deallocate textures' gl memory
textures[i]->discardGLTexture();
+ discardedIndex.append(i);
} else if (owner) {
// simply detach textures from owner
static_cast<BaseTile*>(owner)->discardTextures();
@@ -196,9 +198,27 @@ void TilesManager::discardTexturesVector(unsigned long long sparedDrawCount,
dealloc++;
}
}
+
+ bool base = textures == m_textures;
+ // Clean up the vector of BaseTileTextures and reset the max texture count.
+ if (discardedIndex.size()) {
+ android::Mutex::Autolock lock(m_texturesLock);
+ for (int i = discardedIndex.size() - 1; i >= 0; i--)
+ textures.remove(discardedIndex[i]);
+
+ int remainedTextureNumber = textures.size();
+ int* countPtr = base ? &m_maxTextureCount : &m_maxLayerTextureCount;
+ if (remainedTextureNumber < *countPtr) {
+ XLOG("reset maxTextureCount for %s tiles from %d to %d",
+ base ? "base" : "layer", *countPtr, remainedTextureNumber);
+ *countPtr = remainedTextureNumber;
+ }
+
+ }
+
XLOG("Discarded %d %s textures (out of %d %s tiles)",
dealloc, (deallocateGLTextures ? "gl" : ""),
- max, (textures == m_textures) ? "base" : "layer");
+ max, base ? "base" : "layer");
}
void TilesManager::gatherTexturesNumbers(int* nbTextures, int* nbAllocatedTextures,
diff --git a/Source/WebCore/platform/network/android/ResourceHandleAndroid.cpp b/Source/WebCore/platform/network/android/ResourceHandleAndroid.cpp
index 13a26f0..4bc918b 100644
--- a/Source/WebCore/platform/network/android/ResourceHandleAndroid.cpp
+++ b/Source/WebCore/platform/network/android/ResourceHandleAndroid.cpp
@@ -96,9 +96,7 @@ void ResourceHandle::platformSetDefersLoading(bool)
}
// This static method is called to check to see if a POST response is in
-// the cache. The JNI call through to the HTTP cache stored on the Java
-// side may be slow, but is only used during a navigation to
-// a POST response.
+// the cache.
bool ResourceHandle::willLoadFromCache(ResourceRequest& request, Frame*)
{
// set the cache policy correctly, copied from
diff --git a/Source/WebCore/platform/network/android/ResourceLoaderAndroid.h b/Source/WebCore/platform/network/android/ResourceLoaderAndroid.h
index f627d62..5ff2322 100644
--- a/Source/WebCore/platform/network/android/ResourceLoaderAndroid.h
+++ b/Source/WebCore/platform/network/android/ResourceLoaderAndroid.h
@@ -46,7 +46,6 @@ public:
virtual void pauseLoad(bool) = 0;
// END ANDROID TODO
- // Call to java to find out if this URL is in the cache
static bool willLoadFromCache(const WebCore::KURL&, int64_t identifier);
protected:
ResourceLoaderAndroid() { }
diff --git a/Source/WebCore/rendering/RenderHTMLCanvas.cpp b/Source/WebCore/rendering/RenderHTMLCanvas.cpp
index de2a2c1..03b406b 100644
--- a/Source/WebCore/rendering/RenderHTMLCanvas.cpp
+++ b/Source/WebCore/rendering/RenderHTMLCanvas.cpp
@@ -47,6 +47,13 @@ RenderHTMLCanvas::RenderHTMLCanvas(HTMLCanvasElement* element)
bool RenderHTMLCanvas::requiresLayer() const
{
+#if PLATFORM(ANDROID)
+ // All Canvas are drawn on their own composited layer
+ // This improves performances a lot (as this simplify
+ // the repaint/inval chain dealing with the PictureSet)
+ return true;
+#endif
+
if (RenderReplaced::requiresLayer())
return true;
diff --git a/Source/WebCore/rendering/RenderLayerCompositor.cpp b/Source/WebCore/rendering/RenderLayerCompositor.cpp
index 03f1e41..25a08e7 100644
--- a/Source/WebCore/rendering/RenderLayerCompositor.cpp
+++ b/Source/WebCore/rendering/RenderLayerCompositor.cpp
@@ -1410,6 +1410,10 @@ bool RenderLayerCompositor::requiresCompositingForAndroidLayers(const RenderLaye
if (layer->isFixed())
return true;
#endif
+
+ if (layer->renderer()->isCanvas())
+ return true;
+
return false;
}
#endif
diff --git a/Source/WebKit/Android.mk b/Source/WebKit/Android.mk
index 68ba036..36664dd 100644
--- a/Source/WebKit/Android.mk
+++ b/Source/WebKit/Android.mk
@@ -52,9 +52,6 @@ LOCAL_SRC_FILES += \
android/RenderSkinMediaButton.cpp \
android/RenderSkinNinePatch.cpp \
\
- android/benchmark/Intercept.cpp \
- android/benchmark/MyJavaVM.cpp \
- \
android/icu/unicode/ucnv.cpp \
\
android/jni/AndroidHitTestResult.cpp \
diff --git a/Source/WebKit/android/benchmark/Android.mk b/Source/WebKit/android/benchmark/Android.mk
deleted file mode 100644
index 5b189e1..0000000
--- a/Source/WebKit/android/benchmark/Android.mk
+++ /dev/null
@@ -1,41 +0,0 @@
-##
-##
-## Copyright 2009, The Android Open Source Project
-##
-## 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.
-##
-## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``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 APPLE COMPUTER, INC. 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.
-##
-
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
- main.cpp
-
-# Pull the webkit definitions from the base webkit makefile.
-LOCAL_SHARED_LIBRARIES := libwebcore $(WEBKIT_SHARED_LIBRARIES)
-LOCAL_LDLIBS := $(WEBKIT_LDLIBS)
-
-LOCAL_MODULE := webcore_test
-
-LOCAL_MODULE_TAGS := optional
-
-include $(BUILD_EXECUTABLE)
diff --git a/Source/WebKit/android/benchmark/Intercept.cpp b/Source/WebKit/android/benchmark/Intercept.cpp
deleted file mode 100644
index 28ada5a..0000000
--- a/Source/WebKit/android/benchmark/Intercept.cpp
+++ /dev/null
@@ -1,190 +0,0 @@
-/*
- * Copyright 2009, The Android Open Source Project
- *
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``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 APPLE COMPUTER, INC. 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.
- */
-
-#define LOG_TAG "webcore_test"
-#include "config.h"
-
-#include "Base64.h"
-#include "HTTPParsers.h"
-#include "Intercept.h"
-#include "ResourceHandle.h"
-#include "ResourceHandleClient.h"
-#include "ResourceRequest.h"
-#include "ResourceResponse.h"
-#include "TextEncoding.h"
-
-#include <utils/Log.h>
-#include <wtf/HashMap.h>
-#include <wtf/text/CString.h>
-#include <wtf/text/StringHash.h>
-
-PassRefPtr<WebCore::ResourceLoaderAndroid> MyResourceLoader::create(
- ResourceHandle* handle, String url)
-{
- return adoptRef<WebCore::ResourceLoaderAndroid>(
- new MyResourceLoader(handle, url));
-}
-
-void MyResourceLoader::handleRequest()
-{
- if (protocolIs(m_url, "data"))
- loadData(m_url.substring(5)); // 5 for data:
- else if (protocolIs(m_url, "file"))
- loadFile(m_url.substring(7)); // 7 for file://
-}
-
-void MyResourceLoader::loadData(const String& data)
-{
- ALOGD("Loading data (%s) ...", data.latin1().data());
- ResourceHandleClient* client = m_handle->client();
- int index = data.find(',');
- if (index == -1) {
- client->cannotShowURL(m_handle);
- return;
- }
-
- String mediaType = data.substring(0, index);
- String base64 = data.substring(index + 1);
-
- bool decode = mediaType.endsWith(";base64", false);
- if (decode)
- mediaType = mediaType.left(mediaType.length() - 7); // 7 for base64;
-
- if (mediaType.isEmpty())
- mediaType = "text/plain;charset=US-ASCII";
-
- String mimeType = extractMIMETypeFromMediaType(mediaType);
- String charset = extractCharsetFromMediaType(mediaType);
-
- ResourceResponse response;
- response.setMimeType(mimeType);
-
- if (decode) {
- base64 = decodeURLEscapeSequences(base64);
- response.setTextEncodingName(charset);
- client->didReceiveResponse(m_handle, response);
-
- // FIXME: This is annoying. WebCore's Base64 decoder chokes on spaces.
- // That is correct with strict decoding but html authors (particularly
- // the acid3 authors) put spaces in the data which should be ignored.
- // Remove them here before sending to the decoder.
- Vector<char> in;
- CString str = base64.latin1();
- const char* chars = str.data();
- unsigned i = 0;
- while (i < str.length()) {
- char c = chars[i];
- // Don't send spaces or control characters.
- if (c != ' ' && c != '\n' && c != '\t' && c != '\b'
- && c != '\f' && c != '\r')
- in.append(chars[i]);
- i++;
- }
- Vector<char> out;
- if (base64Decode(in, out) && out.size() > 0)
- client->didReceiveData(m_handle, out.data(), out.size(), 0);
- } else {
- base64 = decodeURLEscapeSequences(base64, TextEncoding(charset));
- response.setTextEncodingName("UTF-16");
- client->didReceiveResponse(m_handle, response);
- if (base64.length() > 0)
- client->didReceiveData(m_handle, (const char*)base64.characters(),
- base64.length() * sizeof(UChar), 0);
- }
- client->didFinishLoading(m_handle, 0);
-}
-static String mimeTypeForExtension(const String& file)
-{
- static HashMap<String, String, CaseFoldingHash> extensionToMime;
- if (extensionToMime.isEmpty()) {
- extensionToMime.set("txt", "text/plain");
- extensionToMime.set("html", "text/html");
- extensionToMime.set("htm", "text/html");
- extensionToMime.set("png", "image/png");
- extensionToMime.set("jpeg", "image/jpeg");
- extensionToMime.set("jpg", "image/jpeg");
- extensionToMime.set("gif", "image/gif");
- extensionToMime.set("ico", "image/x-icon");
- extensionToMime.set("js", "text/javascript");
- }
- int dot = file.reverseFind('.');
- String mime("text/plain");
- if (dot != -1) {
- String ext = file.substring(dot + 1);
- if (extensionToMime.contains(ext))
- mime = extensionToMime.get(ext);
- }
- return mime;
-}
-
-void MyResourceLoader::loadFile(const String& file)
-{
- ALOGD("Loading file (%s) ...", file.latin1().data());
- FILE* f = fopen(file.latin1().data(), "r");
- ResourceHandleClient* client = m_handle->client();
- if (!f) {
- client->didFail(m_handle,
- ResourceError("", -14, file, "Could not open file"));
- } else {
- ResourceResponse response;
- response.setTextEncodingName("utf-8");
- response.setMimeType(mimeTypeForExtension(file));
- client->didReceiveResponse(m_handle, response);
- char buf[512];
- while (true) {
- int res = fread(buf, 1, sizeof(buf), f);
- if (res <= 0)
- break;
- client->didReceiveData(m_handle, buf, res, 0);
- }
- fclose(f);
- client->didFinishLoading(m_handle, 0);
- }
-}
-
-PassRefPtr<WebCore::ResourceLoaderAndroid> MyWebFrame::startLoadingResource(
- ResourceHandle* handle, const ResourceRequest& req, bool ignore,
- bool ignore2)
-{
- RefPtr<WebCore::ResourceLoaderAndroid> loader =
- MyResourceLoader::create(handle, req.url().string());
- m_requests.append(loader);
- if (!m_timer.isActive())
- m_timer.startOneShot(0);
- return loader.release();
-}
-
-void MyWebFrame::timerFired(Timer<MyWebFrame>*)
-{
- ALOGD("Handling requests...");
- Vector<RefPtr<WebCore::ResourceLoaderAndroid> > reqs;
- reqs.swap(m_requests);
- Vector<RefPtr<WebCore::ResourceLoaderAndroid> >::iterator i = reqs.begin();
- Vector<RefPtr<WebCore::ResourceLoaderAndroid> >::iterator end = reqs.end();
- for (; i != end; i++)
- static_cast<MyResourceLoader*>((*i).get())->handleRequest();
-
- ALOGD("...done");
-}
diff --git a/Source/WebKit/android/benchmark/Intercept.h b/Source/WebKit/android/benchmark/Intercept.h
deleted file mode 100644
index 6694dba..0000000
--- a/Source/WebKit/android/benchmark/Intercept.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright 2009, The Android Open Source Project
- *
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``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 APPLE COMPUTER, INC. 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 Intercept_h
-#define Intercept_h
-
-#include "MyJavaVM.h"
-#include "PlatformString.h"
-#include "Timer.h"
-#include "WebCoreFrameBridge.h"
-#include "WebCoreResourceLoader.h"
-#include <JNIUtility.h>
-#include <wtf/Vector.h>
-
-namespace WebCore {
- class Page;
- class ResourceHandle;
- class ResourceRequest;
-}
-
-using namespace android;
-using namespace WebCore;
-using namespace WTF;
-
-class MyResourceLoader : public WebCoreResourceLoader {
-public:
- static PassRefPtr<WebCore::ResourceLoaderAndroid> create(
- ResourceHandle* handle, String url);
- void handleRequest();
-
-private:
- MyResourceLoader(ResourceHandle* handle, String url)
- : WebCoreResourceLoader(JSC::Bindings::getJNIEnv(), MY_JOBJECT)
- , m_handle(handle)
- , m_url(url) {}
-
- void loadData(const String&);
- void loadFile(const String&);
- ResourceHandle* m_handle;
- String m_url;
-};
-
-class MyWebFrame : public WebFrame {
-public:
- MyWebFrame(Page* page)
- : WebFrame(JSC::Bindings::getJNIEnv(), MY_JOBJECT, MY_JOBJECT, page)
- , m_timer(this, &MyWebFrame::timerFired) {}
-
- virtual PassRefPtr<WebCore::ResourceLoaderAndroid> startLoadingResource(
- ResourceHandle* handle, const ResourceRequest& req, bool, bool);
-
- virtual bool canHandleRequest(const ResourceRequest&) { return true; }
-
-private:
- void timerFired(Timer<MyWebFrame>*);
- Vector<RefPtr<WebCore::ResourceLoaderAndroid> > m_requests;
- Timer<MyWebFrame> m_timer;
-};
-
-#endif
diff --git a/Source/WebKit/android/benchmark/MyJavaVM.cpp b/Source/WebKit/android/benchmark/MyJavaVM.cpp
deleted file mode 100644
index 574c745..0000000
--- a/Source/WebKit/android/benchmark/MyJavaVM.cpp
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright 2009, The Android Open Source Project
- *
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``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 APPLE COMPUTER, INC. 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.
- */
-
-#include "config.h"
-#include "MyJavaVM.h"
-
-#include <JNIUtility.h>
-#include <jni.h>
-
-static JNIEnv* s_env;
-static JavaVM* s_jvm;
-
-// JavaVM functions
-jint vm_attachCurrentThread(JavaVM*, JNIEnv** env, void*) {
- *env = s_env;
- return JNI_OK;
-}
-
-// JNIEnv functions
-jobject env_callObjectMethodV(JNIEnv*, jobject, jmethodID, va_list) {
- return MY_JOBJECT;
-}
-void env_callVoidMethodV(JNIEnv*, jobject, jmethodID, va_list) {}
-void env_deleteRef(JNIEnv*, jobject) {}
-jboolean env_exceptionCheck(JNIEnv*) {
- return false;
-}
-jclass env_findClass(JNIEnv*, const char*) {
- return (jclass) 1;
-}
-jbyte* env_getByteArrayElements(JNIEnv*, jbyteArray, jboolean*) {
- return NULL;
-}
-jmethodID env_getMethodID(JNIEnv*, jclass, const char*, const char*) {
- return (jmethodID) 1;
-}
-jclass env_getObjectClass(JNIEnv*, jobject) {
- return (jclass) 1;
-}
-static const char* s_fakeString = "Fake Java String";
-const jchar* env_getStringChars(JNIEnv*, jstring, jboolean* isCopy) {
- if (isCopy)
- *isCopy = false;
- return (const jchar*)s_fakeString;
-}
-jsize env_getStringLength(JNIEnv*, jstring) {
- return sizeof(s_fakeString) - 1;
-}
-jbyteArray env_newByteArray(JNIEnv*, jsize) {
- return (jbyteArray) 1;
-}
-jobject env_newRef(JNIEnv*, jobject obj) {
- return obj;
-}
-jobject env_newObjectV(JNIEnv*, jclass, jmethodID, va_list) {
- return MY_JOBJECT;
-}
-jstring env_newString(JNIEnv*, const jchar*, jsize) {
- return (jstring) 1;
-}
-void env_releaseByteArrayElements(JNIEnv*, jbyteArray, jbyte*, jint) {}
-void env_releaseStringChars(JNIEnv*, jstring, const jchar*) {}
-void env_setByteArrayRegion(JNIEnv*, jbyteArray, jsize, jsize, const jbyte*) {}
-void env_setIntField(JNIEnv*, jobject, jfieldID, jint) {}
-
-void InitializeJavaVM() {
- // First, create the fake vm
- s_jvm = new JavaVM;
- JNIInvokeInterface* i = new JNIInvokeInterface;
- memset(i, 0, sizeof(JNIInvokeInterface));
- s_jvm->functions = i;
-
- // Now, assign the functions of the vm to our fake ones.
- i->AttachCurrentThread = vm_attachCurrentThread;
-
- // Create the fake env next
- s_env = new JNIEnv;
- JNINativeInterface* n = new JNINativeInterface;
- memset(n, 0, sizeof(JNINativeInterface));
- s_env->functions = n;
-
- // Point the functions we care about to out fake ones.
- n->CallObjectMethodV = env_callObjectMethodV;
- n->CallVoidMethodV = env_callVoidMethodV;
- n->DeleteLocalRef = env_deleteRef;
- n->DeleteGlobalRef = env_deleteRef;
- n->DeleteWeakGlobalRef = env_deleteRef;
- n->ExceptionCheck = env_exceptionCheck;
- n->FindClass = env_findClass;
- n->GetByteArrayElements = env_getByteArrayElements;
- n->GetMethodID = env_getMethodID;
- n->GetObjectClass = env_getObjectClass;
- n->GetStringChars = env_getStringChars;
- n->GetStringLength = env_getStringLength;
- n->NewByteArray = env_newByteArray;
- n->NewLocalRef = env_newRef;
- n->NewGlobalRef = env_newRef;
- n->NewWeakGlobalRef = env_newRef;
- n->NewObjectV = env_newObjectV;
- n->NewString = env_newString;
- n->ReleaseByteArrayElements = env_releaseByteArrayElements;
- n->ReleaseStringChars = env_releaseStringChars;
- n->SetByteArrayRegion = env_setByteArrayRegion;
- n->SetIntField = env_setIntField;
-
- // Tell WebCore about the vm
- JSC::Bindings::setJavaVM(s_jvm);
-}
diff --git a/Source/WebKit/android/benchmark/MyJavaVM.h b/Source/WebKit/android/benchmark/MyJavaVM.h
deleted file mode 100644
index 3092161..0000000
--- a/Source/WebKit/android/benchmark/MyJavaVM.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright 2009, The Android Open Source Project
- *
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``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 APPLE COMPUTER, INC. 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 MyJavaVM_h
-#define MyJavaVM_h
-
-// Make it 1 just to appease any assertions or checks for valid objects
-#define MY_JOBJECT ((jobject) 1)
-
-void InitializeJavaVM();
-
-#endif
diff --git a/Source/WebKit/android/benchmark/main.cpp b/Source/WebKit/android/benchmark/main.cpp
deleted file mode 100644
index 0dcb80b..0000000
--- a/Source/WebKit/android/benchmark/main.cpp
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright 2009, The Android Open Source Project
- *
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``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 APPLE COMPUTER, INC. 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.
- */
-
-#define LOG_TAG "webcore_test"
-
-#include <stdlib.h>
-#include <string.h>
-#include <getopt.h>
-#include <utils/Log.h>
-
-namespace android {
-extern void benchmark(const char*, int, int ,int);
-}
-
-int main(int argc, char** argv) {
- int width = 800;
- int height = 600;
- int reloadCount = 0;
- while (true) {
- int c = getopt(argc, argv, "d:r:");
- if (c == -1)
- break;
- else if (c == 'd') {
- char* x = strchr(optarg, 'x');
- if (x) {
- width = atoi(optarg);
- height = atoi(x + 1);
- ALOGD("Rendering page at %dx%d", width, height);
- }
- } else if (c == 'r') {
- reloadCount = atoi(optarg);
- if (reloadCount < 0)
- reloadCount = 0;
- ALOGD("Reloading %d times", reloadCount);
- }
- }
- if (optind >= argc) {
- ALOGE("Please supply a file to read\n");
- return 1;
- }
-
- android::benchmark(argv[optind], reloadCount, width, height);
-}
diff --git a/Source/WebKit/android/jni/AndroidHitTestResult.cpp b/Source/WebKit/android/jni/AndroidHitTestResult.cpp
index 0a69007..6f94488 100644
--- a/Source/WebKit/android/jni/AndroidHitTestResult.cpp
+++ b/Source/WebKit/android/jni/AndroidHitTestResult.cpp
@@ -28,7 +28,9 @@
#include "config.h"
#include "AndroidHitTestResult.h"
+#include "Document.h"
#include "Element.h"
+#include "Frame.h"
#include "HitTestResult.h"
#include "KURL.h"
#include "LayerAndroid.h"
@@ -49,18 +51,19 @@ namespace android {
using namespace WebCore;
static bool gJniInitialized = false;
-static struct JavaGlue {
- jmethodID m_hitTestInit;
- jfieldID m_hitTestLinkUrl;
- jfieldID m_hitTestAnchorText;
- jfieldID m_hitTestImageUrl;
- jfieldID m_hitTestAltDisplayString;
- jfieldID m_hitTestTitle;
- jfieldID m_hitTestEditable;
- jfieldID m_hitTestTouchRects;
- jfieldID m_hitTestTapHighlightColor;
- jfieldID m_hitTestEnclosingParentRects;
-} gJavaGlue;
+static struct {
+ jmethodID m_Init;
+ jfieldID m_LinkUrl;
+ jfieldID m_AnchorText;
+ jfieldID m_ImageUrl;
+ jfieldID m_AltDisplayString;
+ jfieldID m_Title;
+ jfieldID m_Editable;
+ jfieldID m_TouchRects;
+ jfieldID m_TapHighlightColor;
+ jfieldID m_EnclosingParentRects;
+ jfieldID m_HasFocus;
+} gHitTestGlue;
struct field {
jclass m_class;
@@ -79,19 +82,20 @@ static void InitJni(JNIEnv* env)
jclass hitTestClass = env->FindClass("android/webkit/WebViewCore$WebKitHitTest");
ALOG_ASSERT(hitTestClass, "Could not find android/webkit/WebViewCore$WebKitHitTest");
- gJavaGlue.m_hitTestInit = env->GetMethodID(hitTestClass, "<init>", "()V");
- ALOG_ASSERT(gJavaGlue.m_hitTestInit, "Could not find init method on android/webkit/WebViewCore$WebKitHitTest");
+ gHitTestGlue.m_Init = env->GetMethodID(hitTestClass, "<init>", "()V");
+ ALOG_ASSERT(gHitTestGlue.m_Init, "Could not find init method on android/webkit/WebViewCore$WebKitHitTest");
field fields[] = {
- { hitTestClass, "mTouchRects", "[Landroid/graphics/Rect;", &gJavaGlue.m_hitTestTouchRects },
- { hitTestClass, "mEditable", "Z", &gJavaGlue.m_hitTestEditable },
- { hitTestClass, "mLinkUrl", "Ljava/lang/String;", &gJavaGlue.m_hitTestLinkUrl },
- { hitTestClass, "mAnchorText", "Ljava/lang/String;", &gJavaGlue.m_hitTestAnchorText },
- { hitTestClass, "mImageUrl", "Ljava/lang/String;", &gJavaGlue.m_hitTestImageUrl },
- { hitTestClass, "mAltDisplayString", "Ljava/lang/String;", &gJavaGlue.m_hitTestAltDisplayString },
- { hitTestClass, "mTitle", "Ljava/lang/String;", &gJavaGlue.m_hitTestTitle },
- { hitTestClass, "mTapHighlightColor", "I", &gJavaGlue.m_hitTestTapHighlightColor },
- { hitTestClass, "mEnclosingParentRects", "[Landroid/graphics/Rect;", &gJavaGlue.m_hitTestEnclosingParentRects },
+ { hitTestClass, "mTouchRects", "[Landroid/graphics/Rect;", &gHitTestGlue.m_TouchRects },
+ { hitTestClass, "mEditable", "Z", &gHitTestGlue.m_Editable },
+ { hitTestClass, "mLinkUrl", "Ljava/lang/String;", &gHitTestGlue.m_LinkUrl },
+ { hitTestClass, "mAnchorText", "Ljava/lang/String;", &gHitTestGlue.m_AnchorText },
+ { hitTestClass, "mImageUrl", "Ljava/lang/String;", &gHitTestGlue.m_ImageUrl },
+ { hitTestClass, "mAltDisplayString", "Ljava/lang/String;", &gHitTestGlue.m_AltDisplayString },
+ { hitTestClass, "mTitle", "Ljava/lang/String;", &gHitTestGlue.m_Title },
+ { hitTestClass, "mTapHighlightColor", "I", &gHitTestGlue.m_TapHighlightColor },
+ { hitTestClass, "mEnclosingParentRects", "[Landroid/graphics/Rect;", &gHitTestGlue.m_EnclosingParentRects },
+ { hitTestClass, "mHasFocus", "Z", &gHitTestGlue.m_HasFocus },
{0, 0, 0, 0},
};
@@ -109,6 +113,33 @@ AndroidHitTestResult::AndroidHitTestResult(WebViewCore* webViewCore, WebCore::Hi
: m_webViewCore(webViewCore)
, m_hitTestResult(hitTestResult)
{
+ buildHighlightRects();
+}
+
+void AndroidHitTestResult::setURLElement(Element* element)
+{
+ m_hitTestResult.setURLElement(element);
+ buildHighlightRects();
+}
+
+void AndroidHitTestResult::buildHighlightRects()
+{
+ m_highlightRects.clear();
+ Node* node = m_hitTestResult.URLElement();
+ if (!node || !node->renderer())
+ node = m_hitTestResult.innerNode();
+ if (!node || !node->renderer())
+ return;
+ Frame* frame = node->document()->frame();
+ IntPoint frameOffset = m_webViewCore->convertGlobalContentToFrameContent(IntPoint(), frame);
+ RenderObject* renderer = node->renderer();
+ Vector<FloatQuad> quads;
+ renderer->absoluteFocusRingQuads(quads);
+ for (int i = 0; i < quads.size(); i++) {
+ IntRect boundingBox = quads[i].enclosingBoundingBox();
+ boundingBox.move(-frameOffset.x(), -frameOffset.y());
+ m_highlightRects.append(boundingBox);
+ }
}
void setStringField(JNIEnv* env, jobject obj, jfieldID field, const String& str)
@@ -126,9 +157,9 @@ void setRectArray(JNIEnv* env, jobject obj, jfieldID field, Vector<IntRect> &rec
}
// Some helper macros specific to setting hitTest fields
-#define _SET(jtype, jfield, value) env->Set ## jtype ## Field(hitTest, gJavaGlue.m_hitTest ## jfield, value)
+#define _SET(jtype, jfield, value) env->Set ## jtype ## Field(hitTest, gHitTestGlue.m_ ## jfield, value)
#define SET_BOOL(jfield, value) _SET(Boolean, jfield, value)
-#define SET_STRING(jfield, value) setStringField(env, hitTest, gJavaGlue.m_hitTest ## jfield, value)
+#define SET_STRING(jfield, value) setStringField(env, hitTest, gHitTestGlue.m_ ## jfield, value)
#define SET_INT(jfield, value) _SET(Int, jfield, value)
jobject AndroidHitTestResult::createJavaObject(JNIEnv* env)
@@ -137,11 +168,11 @@ jobject AndroidHitTestResult::createJavaObject(JNIEnv* env)
jclass hitTestClass = env->FindClass("android/webkit/WebViewCore$WebKitHitTest");
ALOG_ASSERT(hitTestClass, "Could not find android/webkit/WebViewCore$WebKitHitTest");
- jobject hitTest = env->NewObject(hitTestClass, gJavaGlue.m_hitTestInit);
- setRectArray(env, hitTest, gJavaGlue.m_hitTestTouchRects, m_highlightRects);
+ jobject hitTest = env->NewObject(hitTestClass, gHitTestGlue.m_Init);
+ setRectArray(env, hitTest, gHitTestGlue.m_TouchRects, m_highlightRects);
Vector<IntRect> rects = enclosingParentRects(m_hitTestResult.innerNode());
- setRectArray(env, hitTest, gJavaGlue.m_hitTestEnclosingParentRects, rects);
+ setRectArray(env, hitTest, gHitTestGlue.m_EnclosingParentRects, rects);
SET_BOOL(Editable, m_hitTestResult.isContentEditable());
SET_STRING(LinkUrl, m_hitTestResult.absoluteLinkURL().string());
@@ -157,6 +188,11 @@ jobject AndroidHitTestResult::createJavaObject(JNIEnv* env)
urlElement->renderer()->style()->tapHighlightColor().rgb());
}
}
+ Node* focusedNode = m_webViewCore->focusedFrame()->document()->focusedNode();
+ SET_BOOL(HasFocus,
+ focusedNode == m_hitTestResult.URLElement()
+ || focusedNode == m_hitTestResult.innerNode()
+ || focusedNode == m_hitTestResult.innerNonSharedNode());
env->DeleteLocalRef(hitTestClass);
diff --git a/Source/WebKit/android/jni/AndroidHitTestResult.h b/Source/WebKit/android/jni/AndroidHitTestResult.h
index e4233fd..f9709ac 100644
--- a/Source/WebKit/android/jni/AndroidHitTestResult.h
+++ b/Source/WebKit/android/jni/AndroidHitTestResult.h
@@ -26,6 +26,7 @@
#ifndef AndroidHitTestResult_h
#define AndroidHitTestResult_h
+#include "Element.h"
#include "HitTestResult.h"
#include "IntRect.h"
#include "wtf/Vector.h"
@@ -45,6 +46,9 @@ public:
WebCore::HitTestResult& hitTestResult() { return m_hitTestResult; }
Vector<WebCore::IntRect>& highlightRects() { return m_highlightRects; }
+ void setURLElement(WebCore::Element* element);
+ void buildHighlightRects();
+
jobject createJavaObject(JNIEnv*);
private:
diff --git a/Source/WebKit/android/jni/WebCoreFrameBridge.cpp b/Source/WebKit/android/jni/WebCoreFrameBridge.cpp
index 50c1fb2..2724d6b 100644
--- a/Source/WebKit/android/jni/WebCoreFrameBridge.cpp
+++ b/Source/WebKit/android/jni/WebCoreFrameBridge.cpp
@@ -1703,16 +1703,6 @@ static void AddJavascriptInterface(JNIEnv *env, jobject obj, jint nativeFramePoi
}
}
-static void SetCacheDisabled(JNIEnv *env, jobject obj, jboolean disabled)
-{
- WebCore::memoryCache()->setDisabled(disabled);
-}
-
-static jboolean CacheDisabled(JNIEnv *env, jobject obj)
-{
- return WebCore::memoryCache()->disabled();
-}
-
static void ClearWebCoreCache()
{
if (!WebCore::memoryCache()->disabled()) {
@@ -2084,10 +2074,6 @@ static JNINativeMethod gBrowserFrameNativeMethods[] = {
{ "stringByEvaluatingJavaScriptFromString",
"(Ljava/lang/String;)Ljava/lang/String;",
(void*) StringByEvaluatingJavaScriptFromString },
- { "setCacheDisabled", "(Z)V",
- (void*) SetCacheDisabled },
- { "cacheDisabled", "()Z",
- (void*) CacheDisabled },
{ "clearCache", "()V",
(void*) ClearCache },
{ "documentHasImages", "()Z",
diff --git a/Source/WebKit/android/jni/WebCoreJniOnLoad.cpp b/Source/WebKit/android/jni/WebCoreJniOnLoad.cpp
index fb959ac..64aeb7e 100644
--- a/Source/WebKit/android/jni/WebCoreJniOnLoad.cpp
+++ b/Source/WebKit/android/jni/WebCoreJniOnLoad.cpp
@@ -62,8 +62,6 @@
#include "WebCoreViewBridge.h"
#include "WebFrameView.h"
#include "WebViewCore.h"
-#include "benchmark/Intercept.h"
-#include "benchmark/MyJavaVM.h"
#include <JNIUtility.h>
#include <jni.h>
@@ -162,160 +160,3 @@ EXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved)
return JNI_VERSION_1_4;
}
-
-class MyJavaSharedClient : public TimerClient, public CookieClient {
-public:
- MyJavaSharedClient() : m_hasTimer(false) {}
- virtual void setSharedTimer(long long timemillis) { m_hasTimer = true; }
- virtual void stopSharedTimer() { m_hasTimer = false; }
- virtual void setSharedTimerCallback(void (*f)()) { m_func = f; }
- virtual void signalServiceFuncPtrQueue() {}
-
- // Cookie methods that do nothing.
- virtual void setCookies(const KURL&, const String&) {}
- virtual String cookies(const KURL&) { return ""; }
- virtual bool cookiesEnabled() { return false; }
-
- bool m_hasTimer;
- void (*m_func)();
-};
-
-static void historyItemChanged(HistoryItem* i) {
- if (i->bridge())
- i->bridge()->updateHistoryItem(i);
-}
-
-namespace android {
-
-EXPORT void benchmark(const char* url, int reloadCount, int width, int height) {
- ScriptController::initializeThreading();
-
- // Setting this allows data: urls to load from a local file.
- SecurityOrigin::setLocalLoadPolicy(SecurityOrigin::AllowLocalLoadsForAll);
-
- // Create the fake JNIEnv and JavaVM
- InitializeJavaVM();
-
- // The real function is private to libwebcore but we know what it does.
- notifyHistoryItemChanged = historyItemChanged;
-
- // Implement the shared timer callback
- MyJavaSharedClient client;
- JavaSharedClient::SetTimerClient(&client);
- JavaSharedClient::SetCookieClient(&client);
-
- // Create the page with all the various clients
- ChromeClientAndroid* chrome = new ChromeClientAndroid;
- EditorClientAndroid* editor = new EditorClientAndroid;
- DeviceMotionClientAndroid* deviceMotion = new DeviceMotionClientAndroid;
- DeviceOrientationClientAndroid* deviceOrientation = new DeviceOrientationClientAndroid;
- WebCore::Page::PageClients pageClients;
- pageClients.chromeClient = chrome;
- pageClients.contextMenuClient = new ContextMenuClientAndroid;
- pageClients.editorClient = editor;
- pageClients.dragClient = new DragClientAndroid;
- pageClients.inspectorClient = new InspectorClientAndroid;
- pageClients.deviceMotionClient = deviceMotion;
- pageClients.deviceOrientationClient = deviceOrientation;
- WebCore::Page* page = new WebCore::Page(pageClients);
- editor->setPage(page);
-
- // Create MyWebFrame that intercepts network requests
- MyWebFrame* webFrame = new MyWebFrame(page);
- webFrame->setUserAgent("Performance testing"); // needs to be non-empty
- chrome->setWebFrame(webFrame);
- // ChromeClientAndroid maintains the reference.
- Release(webFrame);
-
- // Create the Frame and the FrameLoaderClient
- FrameLoaderClientAndroid* loader = new FrameLoaderClientAndroid(webFrame);
- RefPtr<Frame> frame = Frame::create(page, NULL, loader);
- loader->setFrame(frame.get());
-
- // Build our View system, resize it to the given dimensions and release our
- // references. Note: We keep a referenec to frameView so we can layout and
- // draw later without risk of it being deleted.
- WebViewCore* webViewCore = new WebViewCore(JSC::Bindings::getJNIEnv(),
- MY_JOBJECT, frame.get());
- RefPtr<FrameView> frameView = FrameView::create(frame.get());
- WebFrameView* webFrameView = new WebFrameView(frameView.get(), webViewCore);
- frame->setView(frameView);
- frameView->resize(width, height);
- Release(webViewCore);
- Release(webFrameView);
-
- // Initialize the frame and turn of low-bandwidth display (it fails an
- // assertion in the Cache code)
- frame->init();
- frame->selection()->setFocused(true);
- frame->page()->focusController()->setFocused(true);
-
- deviceMotion->setWebViewCore(webViewCore);
- deviceOrientation->setWebViewCore(webViewCore);
-
- // Set all the default settings the Browser normally uses.
- Settings* s = frame->settings();
-#ifdef ANDROID_LAYOUT
- s->setLayoutAlgorithm(Settings::kLayoutNormal); // Normal layout for now
-#endif
- s->setStandardFontFamily("sans-serif");
- s->setFixedFontFamily("monospace");
- s->setSansSerifFontFamily("sans-serif");
- s->setSerifFontFamily("serif");
- s->setCursiveFontFamily("cursive");
- s->setFantasyFontFamily("fantasy");
- s->setMinimumFontSize(8);
- s->setMinimumLogicalFontSize(8);
- s->setDefaultFontSize(16);
- s->setDefaultFixedFontSize(13);
- s->setLoadsImagesAutomatically(true);
- s->setJavaScriptEnabled(true);
- s->setDefaultTextEncodingName("latin1");
- s->setPluginsEnabled(false);
- s->setShrinksStandaloneImagesToFit(false);
-#ifdef ANDROID_LAYOUT
- s->setUseWideViewport(false);
-#endif
-
- // Finally, load the actual data
- ResourceRequest req(url);
- frame->loader()->load(req, false);
-
- do {
- // Layout the page and service the timer
- frame->view()->layout();
- while (client.m_hasTimer) {
- client.m_func();
- JavaSharedClient::ServiceFunctionPtrQueue();
- }
- JavaSharedClient::ServiceFunctionPtrQueue();
-
- // Layout more if needed.
- while (frame->view()->needsLayout())
- frame->view()->layout();
- JavaSharedClient::ServiceFunctionPtrQueue();
-
- if (reloadCount)
- frame->loader()->reload(true);
- } while (reloadCount--);
-
- // Draw into an offscreen bitmap
- SkBitmap bmp;
- bmp.setConfig(SkBitmap::kARGB_8888_Config, width, height);
- bmp.allocPixels();
- SkCanvas canvas(bmp);
- PlatformGraphicsContext ctx(&canvas);
- GraphicsContext gc(&ctx);
- frame->view()->paintContents(&gc, IntRect(0, 0, width, height));
-
- // Write the bitmap to the sdcard
- SkImageEncoder* enc = SkImageEncoder::Create(SkImageEncoder::kPNG_Type);
- enc->encodeFile("/sdcard/webcore_test.png", bmp, 100);
- delete enc;
-
- // Tear down the world.
- frame->loader()->detachFromParent();
- delete page;
-}
-
-} // namespace android
diff --git a/Source/WebKit/android/jni/WebViewCore.cpp b/Source/WebKit/android/jni/WebViewCore.cpp
index d1b1629..c53f3fb 100644
--- a/Source/WebKit/android/jni/WebViewCore.cpp
+++ b/Source/WebKit/android/jni/WebViewCore.cpp
@@ -1625,7 +1625,7 @@ static IntRect getAbsoluteBoundingBox(Node* node) {
rect = toRenderText(render)->linesBoundingBox();
else
ALOGE("getAbsoluteBoundingBox failed for node %p, name %s", node, render->renderName());
- FloatPoint absPos = render->localToAbsolute();
+ FloatPoint absPos = render->localToAbsolute(FloatPoint(), false, true);
rect.move(absPos.x(), absPos.y());
return rect;
}
@@ -2005,7 +2005,7 @@ AndroidHitTestResult WebViewCore::hitTestAtPoint(int x, int y, int slop, bool do
IntRect rect = n->mBounds;
rect.intersect(testRect);
int a = rect.width() * rect.height();
- if (a > area) {
+ if (a > area || !final.mUrlNode) {
final = *n;
area = a;
}
@@ -2014,9 +2014,9 @@ AndroidHitTestResult WebViewCore::hitTestAtPoint(int x, int y, int slop, bool do
if (final.mUrlNode) {
if (final.mUrlNode->isElementNode()) {
// We found a URL element. Update the hitTestResult
- androidHitResult.hitTestResult().setURLElement(static_cast<Element*>(final.mUrlNode));
+ androidHitResult.setURLElement(static_cast<Element*>(final.mUrlNode));
} else {
- androidHitResult.hitTestResult().setURLElement(0);
+ androidHitResult.setURLElement(0);
}
// Update innerNode and innerNonSharedNode
androidHitResult.hitTestResult().setInnerNode(final.mInnerNode);
@@ -2026,81 +2026,8 @@ AndroidHitTestResult WebViewCore::hitTestAtPoint(int x, int y, int slop, bool do
frameAdjust = frame->view()->contentsToWindow(IntPoint());
frameAdjust.move(m_scrollOffsetX, m_scrollOffsetY);
}
- Vector<IntRect>& rects = androidHitResult.highlightRects();
- if (final.mUrlNode->isLink() && final.mUrlNode->renderer()) {
- // most of the links are inline instead of box style. So the bounding box is not
- // a good representation for the highlights. Get the list of rectangles instead.
- RenderObject* render = final.mUrlNode->renderer();
- IntPoint offset = roundedIntPoint(render->localToAbsolute());
- render->absoluteRects(rects, offset.x() + frameAdjust.x(), offset.y() + frameAdjust.y());
- if (final.mInnerNode && final.mInnerNode->renderer()) {
- final.mInnerNode->renderer()->absoluteRects(rects,
- offset.x() + frameAdjust.x(), offset.y() + frameAdjust.y());
- }
- bool inside = false;
- int distance = INT_MAX;
- int newx = x, newy = y;
- int i = rects.size();
- while (i--) {
- if (rects[i].isEmpty()) {
- rects.remove(i);
- continue;
- }
- // check whether the point (x, y) is inside one of the rectangles.
- if (inside)
- continue;
- if (rects[i].contains(x, y)) {
- inside = true;
- continue;
- }
- if (x >= rects[i].x() && x < rects[i].maxX()) {
- if (y < rects[i].y()) {
- if (rects[i].y() - y < distance) {
- newx = x;
- newy = rects[i].y();
- distance = rects[i].y() - y;
- }
- } else if (y >= rects[i].maxY()) {
- if (y - rects[i].maxY() + 1 < distance) {
- newx = x;
- newy = rects[i].maxY() - 1;
- distance = y - rects[i].maxY() + 1;
- }
- }
- } else if (y >= rects[i].y() && y < rects[i].maxY()) {
- if (x < rects[i].x()) {
- if (rects[i].x() - x < distance) {
- newx = rects[i].x();
- newy = y;
- distance = rects[i].x() - x;
- }
- } else if (x >= rects[i].maxX()) {
- if (x - rects[i].maxX() + 1 < distance) {
- newx = rects[i].maxX() - 1;
- newy = y;
- distance = x - rects[i].maxX() + 1;
- }
- }
- }
- }
- if (!rects.isEmpty()) {
- if (!inside && doMoveMouse) {
- // if neither x nor y has overlap, just pick the top/left of the first rectangle
- if (newx == x && newy == y) {
- newx = rects[0].x();
- newy = rects[0].y();
- }
- moveMouse(m_mainFrame, newx, newy);
- DBG_NAV_LOGD("Move x/y from (%d, %d) to (%d, %d) scrollOffset is (%d, %d)",
- x, y, m_mousePos.x() + m_scrollOffsetX, m_mousePos.y() + m_scrollOffsetY,
- m_scrollOffsetX, m_scrollOffsetY);
- }
- return androidHitResult;
- }
- }
IntRect rect = final.mBounds;
rect.move(frameAdjust.x(), frameAdjust.y());
- rects.append(rect);
if (doMoveMouse) {
// adjust m_mousePos if it is not inside the returned highlight rectangle
testRect.move(frameAdjust.x(), frameAdjust.y());
@@ -3677,7 +3604,6 @@ void WebViewCore::focusNodeChanged(WebCore::Node* newFocus)
}
}
AndroidHitTestResult androidHitTest(this, focusHitResult);
- androidHitTest.highlightRects();
jobject jHitTestObj = androidHitTest.createJavaObject(env);
env->CallVoidMethod(javaObject.get(), m_javaGlue->m_focusNodeChanged, jHitTestObj);
env->DeleteLocalRef(jHitTestObj);
diff --git a/Source/WebKit/android/jni/WebViewCore.h b/Source/WebKit/android/jni/WebViewCore.h
index 41e681e..315b024 100644
--- a/Source/WebKit/android/jni/WebViewCore.h
+++ b/Source/WebKit/android/jni/WebViewCore.h
@@ -152,7 +152,7 @@ namespace android {
*
* This method calls Java to trigger a gradual scroll event.
*/
- void scrollTo(int x, int y, bool animate = false);
+ void scrollTo(int x, int y, bool animate = true);
/**
* Record the invalid rectangle
diff --git a/Source/WebKit/android/nav/WebView.cpp b/Source/WebKit/android/nav/WebView.cpp
index a63675c..2bd76f5 100644
--- a/Source/WebKit/android/nav/WebView.cpp
+++ b/Source/WebKit/android/nav/WebView.cpp
@@ -1301,7 +1301,7 @@ void setTextSelection(SelectText *selection) {
int getHandleLayerId(SelectText::HandleId handleId, SkIRect& cursorRect) {
SelectText* selectText = static_cast<SelectText*>(getDrawExtra(DrawExtrasSelection));
- if (!selectText)
+ if (!selectText || !m_baseLayer)
return -1;
int layerId = selectText->caretLayerId(handleId);
IntRect rect = selectText->caretRect(handleId);