summaryrefslogtreecommitdiffstats
path: root/WebKit
diff options
context:
space:
mode:
Diffstat (limited to 'WebKit')
-rw-r--r--WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp6
-rw-r--r--WebKit/android/WebCoreSupport/MemoryUsage.cpp2
-rw-r--r--WebKit/android/WebCoreSupport/MemoryUsage.h3
-rw-r--r--WebKit/android/WebCoreSupport/PlatformBridge.cpp5
-rw-r--r--WebKit/android/jni/WebSettings.cpp5
-rw-r--r--WebKit/android/jni/WebViewCore.cpp74
-rw-r--r--WebKit/android/jni/WebViewCore.h4
-rw-r--r--WebKit/android/nav/WebView.cpp73
8 files changed, 145 insertions, 27 deletions
diff --git a/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp b/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp
index 20ad5b9..cb1efe1 100644
--- a/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp
+++ b/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp
@@ -145,7 +145,11 @@ void ChromeClientAndroid::unfocus() { notImplemented(); }
bool ChromeClientAndroid::canTakeFocus(FocusDirection) { notImplemented(); return false; }
void ChromeClientAndroid::takeFocus(FocusDirection) { notImplemented(); }
-void ChromeClientAndroid::focusedNodeChanged(Node*) { notImplemented(); }
+void ChromeClientAndroid::focusedNodeChanged(Node* node)
+{
+ android::WebViewCore::getWebViewCore(m_webFrame->page()->mainFrame()->view())->focusNodeChanged(node);
+}
+
void ChromeClientAndroid::focusedFrameChanged(Frame*) { notImplemented(); }
Page* ChromeClientAndroid::createWindow(Frame* frame, const FrameLoadRequest&,
diff --git a/WebKit/android/WebCoreSupport/MemoryUsage.cpp b/WebKit/android/WebCoreSupport/MemoryUsage.cpp
index f799a18..32cdebf 100644
--- a/WebKit/android/WebCoreSupport/MemoryUsage.cpp
+++ b/WebKit/android/WebCoreSupport/MemoryUsage.cpp
@@ -78,4 +78,4 @@ int MemoryUsage::memoryUsageMb(bool forceFresh)
int MemoryUsage::m_lowMemoryUsageMb = 0;
int MemoryUsage::m_highMemoryUsageMb = 0;
-
+int MemoryUsage::m_highUsageDeltaMb = 0;
diff --git a/WebKit/android/WebCoreSupport/MemoryUsage.h b/WebKit/android/WebCoreSupport/MemoryUsage.h
index 899fd08..2a3d7ed 100644
--- a/WebKit/android/WebCoreSupport/MemoryUsage.h
+++ b/WebKit/android/WebCoreSupport/MemoryUsage.h
@@ -31,12 +31,15 @@ public:
static int memoryUsageMb(bool forceFresh);
static int lowMemoryUsageMb() { return m_lowMemoryUsageMb; }
static int highMemoryUsageMb() { return m_highMemoryUsageMb; }
+ static int highUsageDeltaMb() { return m_highUsageDeltaMb; }
static void setHighMemoryUsageMb(int highMemoryUsageMb) { m_highMemoryUsageMb = highMemoryUsageMb; }
static void setLowMemoryUsageMb(int lowMemoryUsageMb) { m_lowMemoryUsageMb = lowMemoryUsageMb; }
+ static void setHighUsageDeltaMb(int highUsageDeltaMb) { m_highUsageDeltaMb = highUsageDeltaMb; }
private:
static int m_lowMemoryUsageMb;
static int m_highMemoryUsageMb;
+ static int m_highUsageDeltaMb;
};
#endif
diff --git a/WebKit/android/WebCoreSupport/PlatformBridge.cpp b/WebKit/android/WebCoreSupport/PlatformBridge.cpp
index baeddb2..0bc2e3c 100644
--- a/WebKit/android/WebCoreSupport/PlatformBridge.cpp
+++ b/WebKit/android/WebCoreSupport/PlatformBridge.cpp
@@ -201,6 +201,11 @@ int PlatformBridge::highMemoryUsageMB()
return MemoryUsage::highMemoryUsageMb();
}
+int PlatformBridge::highUsageDeltaMB()
+{
+ return MemoryUsage::highUsageDeltaMb();
+}
+
int PlatformBridge::memoryUsageMB()
{
return MemoryUsage::memoryUsageMb(false);
diff --git a/WebKit/android/jni/WebSettings.cpp b/WebKit/android/jni/WebSettings.cpp
index 3712135..4dd183b 100644
--- a/WebKit/android/jni/WebSettings.cpp
+++ b/WebKit/android/jni/WebSettings.cpp
@@ -509,6 +509,11 @@ public:
if (str) {
WTF::String localStorageDatabasePath = jstringToWtfString(env,str);
if (localStorageDatabasePath.length()) {
+ localStorageDatabasePath = WebCore::pathByAppendingComponent(
+ localStorageDatabasePath, "localstorage");
+ // We need 770 for folders
+ mkdir(localStorageDatabasePath.utf8().data(),
+ permissionFlags660 | S_IXUSR | S_IXGRP);
s->setLocalStorageDatabasePath(localStorageDatabasePath);
}
}
diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp
index 6fd7b9c..39f6f2d 100644
--- a/WebKit/android/jni/WebViewCore.cpp
+++ b/WebKit/android/jni/WebViewCore.cpp
@@ -240,6 +240,7 @@ struct WebViewCoreFields {
jfieldID m_drawIsPaused;
jfieldID m_lowMemoryUsageMb;
jfieldID m_highMemoryUsageMb;
+ jfieldID m_highUsageDeltaMb;
} gWebViewCoreFields;
// ----------------------------------------------------------------------------
@@ -400,6 +401,7 @@ WebViewCore::WebViewCore(JNIEnv* env, jobject javaWebViewCore, WebCore::Frame* m
MemoryUsage::setLowMemoryUsageMb(env->GetIntField(javaWebViewCore, gWebViewCoreFields.m_lowMemoryUsageMb));
MemoryUsage::setHighMemoryUsageMb(env->GetIntField(javaWebViewCore, gWebViewCoreFields.m_highMemoryUsageMb));
+ MemoryUsage::setHighUsageDeltaMb(env->GetIntField(javaWebViewCore, gWebViewCoreFields.m_highUsageDeltaMb));
WebViewCore::addInstance(this);
@@ -457,6 +459,7 @@ void WebViewCore::reset(bool fromConstructor)
}
m_lastFocused = 0;
+ m_blurringNodePointer = 0;
m_lastFocusedBounds = WebCore::IntRect(0,0,0,0);
m_focusBoundsChanged = false;
m_lastFocusedSelStart = 0;
@@ -1192,6 +1195,7 @@ void WebViewCore::setSizeScreenWidthAndScale(int width, int height,
int osw = m_screenWidth;
int osh = m_screenHeight;
int otw = m_textWrapWidth;
+ float oldScale = m_scale;
DBG_NAV_LOGD("old:(w=%d,h=%d,sw=%d,scale=%g) new:(w=%d,h=%d,sw=%d,scale=%g)",
ow, oh, osw, m_scale, width, height, screenWidth, scale);
m_screenWidth = screenWidth;
@@ -1296,7 +1300,9 @@ void WebViewCore::setSizeScreenWidthAndScale(int width, int height,
// If this was in response to touching a textfield and showing the IME,
// the IME may now cover textfield. Bring it back into view.
- revealSelection();
+ // If the scale changed, however, this was the result of a zoom.
+ if (oldScale == m_scale)
+ revealSelection();
// update the currently visible screen as perceived by the plugin
sendPluginVisibleScreen();
}
@@ -1429,20 +1435,29 @@ WTF::String WebViewCore::requestLabel(WebCore::Frame* frame,
return WTF::String();
}
-static bool isContentEditable(WebCore::Node* node)
+static bool isContentEditable(const WebCore::Node* node)
{
if (!node) return false;
return node->document()->frame()->selection()->isContentEditable();
}
+// Returns true if the node is a textfield, textarea, or contentEditable
+static bool isTextInput(const WebCore::Node* node)
+{
+ if (isContentEditable(node))
+ return true;
+ if (!node)
+ return false;
+ WebCore::RenderObject* renderer = node->renderer();
+ return renderer && (renderer->isTextField() || renderer->isTextArea());
+}
+
void WebViewCore::revealSelection()
{
WebCore::Node* focus = currentFocus();
if (!focus)
return;
- WebCore::RenderObject* renderer = focus->renderer();
- if ((!renderer || (!renderer->isTextField() && !renderer->isTextArea()))
- && !isContentEditable(focus))
+ if (!isTextInput(focus))
return;
WebCore::Frame* focusedFrame = focus->document()->frame();
if (!focusedFrame->page()->focusController()->isActive())
@@ -2970,7 +2985,6 @@ static void scrollLayer(WebCore::RenderObject* renderer, WebCore::IntPoint* pos)
// in which case, 'fake' is set to true
bool WebViewCore::handleMouseClick(WebCore::Frame* framePtr, WebCore::Node* nodePtr, bool fake, int scrollY)
{
- m_lastClickWasOnTextInput = false;
bool valid = framePtr == NULL
|| CacheBuilder::validNode(m_mainFrame, framePtr, nodePtr);
WebFrame* webFrame = WebFrame::getWebFrame(m_mainFrame);
@@ -3028,12 +3042,6 @@ bool WebViewCore::handleMouseClick(WebCore::Frame* framePtr, WebCore::Node* node
static_cast<RenderTextControl*>(renderer)->setScrollTop(scrollY);
else
scrollLayer(renderer, &m_mousePos);
- if (isContentEditable(nodePtr) || (renderer
- && (renderer->isTextArea() || renderer->isTextField()))) {
- // The user clicked on a text input field. If this causes a blur event
- // on a different text input, do not hide the keyboard in formDidBlur
- m_lastClickWasOnTextInput = true;
- }
}
if (!valid || !framePtr)
framePtr = m_mainFrame;
@@ -3049,8 +3057,6 @@ bool WebViewCore::handleMouseClick(WebCore::Frame* framePtr, WebCore::Node* node
bool handled = framePtr->eventHandler()->handleMouseReleaseEvent(mouseUp);
webFrame->setUserInitiatedAction(false);
- m_lastClickWasOnTextInput = false;
-
// If the user clicked on a textfield, make the focusController active
// so we show the blinking cursor.
WebCore::Node* focusNode = currentFocus();
@@ -3115,14 +3121,24 @@ void WebViewCore::popupReply(const int* array, int count)
void WebViewCore::formDidBlur(const WebCore::Node* node)
{
- // This blur is the result of clicking on a different input. Do not hide
- // the keyboard, since it will just be opened again.
- if (m_lastClickWasOnTextInput) return;
+ // If the blur is on a text input, keep track of the node so we can
+ // hide the soft keyboard when the new focus is set, if it is not a
+ // text input.
+ if (isTextInput(node))
+ m_blurringNodePointer = reinterpret_cast<int>(node);
+}
- JNIEnv* env = JSC::Bindings::getJNIEnv();
- env->CallVoidMethod(m_javaGlue->object(env).get(),
- m_javaGlue->m_formDidBlur, reinterpret_cast<int>(node));
- checkException(env);
+void WebViewCore::focusNodeChanged(const WebCore::Node* newFocus)
+{
+ if (!m_blurringNodePointer)
+ return;
+ if (!isTextInput(newFocus)) {
+ JNIEnv* env = JSC::Bindings::getJNIEnv();
+ env->CallVoidMethod(m_javaGlue->object(env).get(),
+ m_javaGlue->m_formDidBlur, m_blurringNodePointer);
+ checkException(env);
+ }
+ m_blurringNodePointer = 0;
}
void WebViewCore::addMessageToConsole(const WTF::String& message, unsigned int lineNumber, const WTF::String& sourceID, int msgLevel) {
@@ -3493,12 +3509,19 @@ bool WebViewCore::drawIsPaused() const
#if USE(CHROME_NETWORK_STACK)
void WebViewCore::setWebRequestContextUserAgent()
{
- webRequestContext()->setUserAgent(WebFrame::getWebFrame(m_mainFrame)->userAgentForURL(0)); // URL not used
+ // We cannot create a WebRequestContext, because we might not know it this is a private tab or not yet
+ if (m_webRequestContext)
+ m_webRequestContext->setUserAgent(WebFrame::getWebFrame(m_mainFrame)->userAgentForURL(0)); // URL not used
}
-void WebViewCore::setWebRequestContextCacheMode(int mode)
+void WebViewCore::setWebRequestContextCacheMode(int cacheMode)
{
- webRequestContext()->setCacheMode(mode);
+ m_cacheMode = cacheMode;
+ // We cannot create a WebRequestContext, because we might not know it this is a private tab or not yet
+ if (!m_webRequestContext)
+ return;
+
+ m_webRequestContext->setCacheMode(cacheMode);
}
WebRequestContext* WebViewCore::webRequestContext()
@@ -3506,6 +3529,8 @@ WebRequestContext* WebViewCore::webRequestContext()
if (!m_webRequestContext) {
Settings* settings = mainFrame()->settings();
m_webRequestContext = new WebRequestContext(settings && settings->privateBrowsingEnabled());
+ setWebRequestContextUserAgent();
+ setWebRequestContextCacheMode(m_cacheMode);
}
return m_webRequestContext.get();
}
@@ -4361,6 +4386,7 @@ int registerWebViewCore(JNIEnv* env)
"Unable to find android/webkit/WebViewCore.mDrawIsPaused");
gWebViewCoreFields.m_lowMemoryUsageMb = env->GetFieldID(widget, "mLowMemoryUsageThresholdMb", "I");
gWebViewCoreFields.m_highMemoryUsageMb = env->GetFieldID(widget, "mHighMemoryUsageThresholdMb", "I");
+ gWebViewCoreFields.m_highUsageDeltaMb = env->GetFieldID(widget, "mHighUsageDeltaMb", "I");
gWebViewCoreStaticMethods.m_isSupportedMediaMimeType =
env->GetStaticMethodID(widget, "isSupportedMediaMimeType", "(Ljava/lang/String;)Z");
diff --git a/WebKit/android/jni/WebViewCore.h b/WebKit/android/jni/WebViewCore.h
index 0338104..611ee59 100644
--- a/WebKit/android/jni/WebViewCore.h
+++ b/WebKit/android/jni/WebViewCore.h
@@ -136,6 +136,7 @@ namespace android {
* @param Node The Node that blurred.
*/
void formDidBlur(const WebCore::Node*);
+ void focusNodeChanged(const WebCore::Node*);
/**
* Scroll to an absolute position.
@@ -601,7 +602,7 @@ namespace android {
WebCoreReply* m_popupReply;
WebCore::Node* m_lastFocused;
WebCore::IntRect m_lastFocusedBounds;
- bool m_lastClickWasOnTextInput;
+ int m_blurringNodePointer;
int m_lastFocusedSelStart;
int m_lastFocusedSelEnd;
PictureSet m_content; // the set of pictures to draw
@@ -635,6 +636,7 @@ namespace android {
bool m_check_domtree_version;
PageGroup* m_groupForVisitedLinks;
bool m_isPaused;
+ int m_cacheMode;
SkTDArray<PluginWidgetAndroid*> m_plugins;
WebCore::Timer<WebViewCore> m_pluginInvalTimer;
diff --git a/WebKit/android/nav/WebView.cpp b/WebKit/android/nav/WebView.cpp
index a9835bd..683c2a3 100644
--- a/WebKit/android/nav/WebView.cpp
+++ b/WebKit/android/nav/WebView.cpp
@@ -42,6 +42,7 @@
#include "IntRect.h"
#include "LayerAndroid.h"
#include "Node.h"
+#include "utils/Functor.h"
#include "PlatformGraphicsContext.h"
#include "PlatformString.h"
#include "ScrollableLayerAndroid.h"
@@ -187,6 +188,7 @@ WebView(JNIEnv* env, jobject javaWebView, int viewImpl) :
m_lastDxTime = 0;
m_ringAnimationEnd = 0;
m_baseLayer = 0;
+ m_glDrawFunctor = 0;
#if USE(ACCELERATED_COMPOSITING)
m_glWebViewState = 0;
#endif
@@ -209,6 +211,7 @@ WebView(JNIEnv* env, jobject javaWebView, int viewImpl) :
delete m_frameCacheUI;
delete m_navPictureUI;
m_baseLayer->safeUnref();
+ delete m_glDrawFunctor;
}
WebViewCore* getWebViewCore() const {
@@ -1424,6 +1427,15 @@ bool hasContent() {
return !m_baseLayer->content()->isEmpty();
}
+void setFunctor(Functor* functor) {
+ delete m_glDrawFunctor;
+ m_glDrawFunctor = functor;
+}
+
+Functor* getFunctor() {
+ return m_glDrawFunctor;
+}
+
private: // local state for WebView
// private to getFrameCache(); other functions operate in a different thread
CachedRoot* m_frameCacheUI; // navigation data ready for use
@@ -1439,11 +1451,47 @@ private: // local state for WebView
FindOnPage m_findOnPage;
CursorRing m_ring;
BaseLayerAndroid* m_baseLayer;
+ Functor* m_glDrawFunctor;
#if USE(ACCELERATED_COMPOSITING)
GLWebViewState* m_glWebViewState;
#endif
}; // end of WebView class
+
+/**
+ * This class holds a function pointer and parameters for calling drawGL into a specific
+ * viewport. The pointer to the Functor will be put on a framework display list to be called
+ * when the display list is replayed.
+ */
+class GLDrawFunctor : Functor {
+ public:
+ GLDrawFunctor(WebView* _wvInstance,
+ bool(WebView::*_funcPtr)(WebCore::IntRect&, jfloat, jint),
+ WebCore::IntRect _viewRect, float _scale, int _extras) {
+ wvInstance = _wvInstance;
+ funcPtr = _funcPtr;
+ viewRect = _viewRect;
+ scale = _scale;
+ extras = _extras;
+ };
+ status_t operator()() {
+ bool retVal = (*wvInstance.*funcPtr)(viewRect, scale, extras);
+ // return 1 if invalidation needed, 0 otherwise
+ return retVal ? 1 : 0;
+ }
+ void updateRect(WebCore::IntRect& _viewRect) {
+ viewRect = _viewRect;
+ }
+ private:
+ WebView* wvInstance;
+ bool (WebView::*funcPtr)(WebCore::IntRect&, float, int);
+ WebCore::IntRect viewRect;
+ jfloat scale;
+ jint extras;
+};
+
+
+
/*
* Native JNI methods
*/
@@ -1668,6 +1716,27 @@ static jint nativeDraw(JNIEnv *env, jobject obj, jobject canv, jint color,
return reinterpret_cast<jint>(GET_NATIVE_VIEW(env, obj)->draw(canvas, color, extras, split));
}
+static jint nativeGetDrawGLFunction(JNIEnv *env, jobject obj, jobject jrect,
+ jfloat scale, jint extras) {
+ WebCore::IntRect viewRect = jrect_to_webrect(env, jrect);
+ WebView *wvInstance = GET_NATIVE_VIEW(env, obj);
+ GLDrawFunctor* functor = new GLDrawFunctor(wvInstance, &android::WebView::drawGL,
+ viewRect, scale, extras);
+ wvInstance->setFunctor((Functor*) functor);
+ return (jint)functor;
+}
+
+static void nativeUpdateDrawGLFunction(JNIEnv *env, jobject obj, jobject jrect) {
+ WebView *wvInstance = GET_NATIVE_VIEW(env, obj);
+ if (wvInstance != NULL) {
+ GLDrawFunctor* functor = (GLDrawFunctor*) wvInstance->getFunctor();
+ if (functor != NULL) {
+ WebCore::IntRect viewRect = jrect_to_webrect(env, jrect);
+ functor->updateRect(viewRect);
+ }
+ }
+}
+
static bool nativeDrawGL(JNIEnv *env, jobject obj, jobject jrect,
jfloat scale, jint extras)
{
@@ -2353,6 +2422,10 @@ static JNINativeMethod gJavaWebViewMethods[] = {
(void*) nativeDestroy },
{ "nativeDraw", "(Landroid/graphics/Canvas;IIZ)I",
(void*) nativeDraw },
+ { "nativeGetDrawGLFunction", "(Landroid/graphics/Rect;FI)I",
+ (void*) nativeGetDrawGLFunction },
+ { "nativeUpdateDrawGLFunction", "(Landroid/graphics/Rect;)V",
+ (void*) nativeUpdateDrawGLFunction },
{ "nativeDrawGL", "(Landroid/graphics/Rect;FI)Z",
(void*) nativeDrawGL },
{ "nativeDumpDisplayTree", "(Ljava/lang/String;)V",