summaryrefslogtreecommitdiffstats
path: root/Source/WebKit/android/jni/WebViewCore.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebKit/android/jni/WebViewCore.cpp')
-rw-r--r--Source/WebKit/android/jni/WebViewCore.cpp85
1 files changed, 35 insertions, 50 deletions
diff --git a/Source/WebKit/android/jni/WebViewCore.cpp b/Source/WebKit/android/jni/WebViewCore.cpp
index 724f84d..ec027cd 100644
--- a/Source/WebKit/android/jni/WebViewCore.cpp
+++ b/Source/WebKit/android/jni/WebViewCore.cpp
@@ -368,8 +368,6 @@ struct WebViewCore::JavaGlue {
jmethodID m_showRect;
jmethodID m_centerFitRect;
jmethodID m_setScrollbarModes;
- jmethodID m_setInstallableWebApp;
- jmethodID m_enterFullscreenForVideoLayer;
jmethodID m_exitFullscreenVideo;
jmethodID m_setWebTextViewAutoFillable;
jmethodID m_selectAt;
@@ -424,7 +422,6 @@ WebViewCore::WebViewCore(JNIEnv* env, jobject javaWebViewCore, WebCore::Frame* m
, m_mainFrame(mainframe)
, m_popupReply(0)
, m_blockTextfieldUpdates(false)
- , m_focusBoundsChanged(false)
, m_skipContentDraw(false)
, m_textGeneration(0)
, m_maxXScroll(320/4)
@@ -472,7 +469,7 @@ WebViewCore::WebViewCore(JNIEnv* env, jobject javaWebViewCore, WebCore::Frame* m
m_javaGlue->m_updateViewport = GetJMethod(env, clazz, "updateViewport", "()V");
m_javaGlue->m_sendNotifyProgressFinished = GetJMethod(env, clazz, "sendNotifyProgressFinished", "()V");
m_javaGlue->m_sendViewInvalidate = GetJMethod(env, clazz, "sendViewInvalidate", "(IIII)V");
- m_javaGlue->m_updateTextfield = GetJMethod(env, clazz, "updateTextfield", "(IZLjava/lang/String;I)V");
+ m_javaGlue->m_updateTextfield = GetJMethod(env, clazz, "updateTextfield", "(ILjava/lang/String;I)V");
m_javaGlue->m_updateTextSelection = GetJMethod(env, clazz, "updateTextSelection", "(IIIII)V");
m_javaGlue->m_updateTextSizeAndScroll = GetJMethod(env, clazz, "updateTextSizeAndScroll", "(IIIII)V");
m_javaGlue->m_clearTextEntry = GetJMethod(env, clazz, "clearTextEntry", "()V");
@@ -500,9 +497,7 @@ WebViewCore::WebViewCore(JNIEnv* env, jobject javaWebViewCore, WebCore::Frame* m
m_javaGlue->m_showRect = GetJMethod(env, clazz, "showRect", "(IIIIIIFFFF)V");
m_javaGlue->m_centerFitRect = GetJMethod(env, clazz, "centerFitRect", "(IIII)V");
m_javaGlue->m_setScrollbarModes = GetJMethod(env, clazz, "setScrollbarModes", "(II)V");
- m_javaGlue->m_setInstallableWebApp = GetJMethod(env, clazz, "setInstallableWebApp", "()V");
#if ENABLE(VIDEO)
- m_javaGlue->m_enterFullscreenForVideoLayer = GetJMethod(env, clazz, "enterFullscreenForVideoLayer", "(ILjava/lang/String;)V");
m_javaGlue->m_exitFullscreenVideo = GetJMethod(env, clazz, "exitFullscreenVideo", "()V");
#endif
m_javaGlue->m_setWebTextViewAutoFillable = GetJMethod(env, clazz, "setWebTextViewAutoFillable", "(ILjava/lang/String;)V");
@@ -729,13 +724,6 @@ void WebViewCore::clearContent()
updateLocale();
}
-bool WebViewCore::focusBoundsChanged()
-{
- bool result = m_focusBoundsChanged;
- m_focusBoundsChanged = false;
- return result;
-}
-
void WebViewCore::paintContents(WebCore::GraphicsContext* gc, WebCore::IntRect& dirty)
{
WebCore::FrameView* view = m_mainFrame->view();
@@ -1217,7 +1205,7 @@ void WebViewCore::setSizeScreenWidthAndScale(int width, int height,
m_mainFrame->view()->forceLayout();
// scroll to restore current screen center
- if (node) {
+ if (node && node->inDocument()) {
const WebCore::IntRect& newBounds = node->getRect();
if ((osw && osh && bounds.width() && bounds.height())
&& (bounds != newBounds)) {
@@ -1605,6 +1593,20 @@ bool WebViewCore::isLtr(const Position& position)
return isLtr;
}
+static Node* findInputParent(Node* node)
+{
+ Node* testNode = node;
+ while (testNode) {
+ RenderObject* renderer = testNode->renderer();
+ if (renderer
+ && (renderer->isTextArea() || renderer->isTextControl())) {
+ return testNode;
+ }
+ testNode = testNode->parentOrHostNode();
+ }
+ return node;
+}
+
SelectText* WebViewCore::createSelectText(const VisibleSelection& selection)
{
bool isCaret = selection.isCaret();
@@ -1649,6 +1651,18 @@ SelectText* WebViewCore::createSelectText(const VisibleSelection& selection)
? SelectText::RightHandle : SelectText::LeftHandle;
setSelectionCaretInfo(selectTextContainer, extent, frameOffset,
SelectText::ExtentHandle, extentHandleType, extentOffset, affinity);
+ IntRect clipRect;
+ if (selection.isContentEditable()) {
+ Node* editable = findInputParent(base.anchorNode());
+ RenderObject* render = editable->renderer();
+ if (render && render->isBox() && !render->isBody()) {
+ RenderBox* renderBox = toRenderBox(render);
+ clipRect = renderBox->clientBoxRect();
+ FloatPoint pos = renderBox->localToAbsolute(clipRect.location());
+ clipRect.setX(pos.x());
+ clipRect.setY(pos.y());
+ }
+ }
Node* stopNode = range->pastLastNode();
for (Node* node = range->firstNode(); node != stopNode; node = node->traverseNextNode()) {
@@ -1662,7 +1676,8 @@ SelectText* WebViewCore::createSelectText(const VisibleSelection& selection)
int layerId = platformLayerIdFromNode(node, &layer);
Vector<IntRect> rects;
renderText->absoluteRectsForRange(rects, startOffset, endOffset, true);
- selectTextContainer->addHighlightRegion(layer, rects, frameOffset);
+ selectTextContainer->addHighlightRegion(layer, rects, frameOffset,
+ clipRect);
}
}
selectTextContainer->setText(range->text());
@@ -2973,7 +2988,7 @@ void WebViewCore::passToJs(int generation, const WTF::String& current,
WTF::String test = getInputText(focus);
if (test != current) {
// If the text changed during the key event, update the UI text field.
- updateTextfield(focus, false, test);
+ updateTextfield(focus, test);
}
// Now that the selection has settled down, send it.
updateTextSelection();
@@ -3889,8 +3904,7 @@ void WebViewCore::updateTextSizeAndScroll(WebCore::Node* node)
checkException(env);
}
-void WebViewCore::updateTextfield(WebCore::Node* ptr, bool changeToPassword,
- const WTF::String& text)
+void WebViewCore::updateTextfield(WebCore::Node* ptr, const WTF::String& text)
{
JNIEnv* env = JSC::Bindings::getJNIEnv();
AutoJObject javaObject = m_javaGlue->object(env);
@@ -3898,15 +3912,9 @@ void WebViewCore::updateTextfield(WebCore::Node* ptr, bool changeToPassword,
return;
if (m_blockTextfieldUpdates)
return;
- if (changeToPassword) {
- env->CallVoidMethod(javaObject.get(), m_javaGlue->m_updateTextfield,
- (int) ptr, true, 0, m_textGeneration);
- checkException(env);
- return;
- }
jstring string = wtfStringToJstring(env, text);
env->CallVoidMethod(javaObject.get(), m_javaGlue->m_updateTextfield,
- (int) ptr, false, string, m_textGeneration);
+ (int) ptr, string, m_textGeneration);
env->DeleteLocalRef(string);
checkException(env);
}
@@ -4100,27 +4108,11 @@ void WebViewCore::setScrollbarModes(ScrollbarMode horizontalMode, ScrollbarMode
checkException(env);
}
-void WebViewCore::notifyWebAppCanBeInstalled()
-{
- JNIEnv* env = JSC::Bindings::getJNIEnv();
- AutoJObject javaObject = m_javaGlue->object(env);
- if (!javaObject.get())
- return;
- env->CallVoidMethod(javaObject.get(), m_javaGlue->m_setInstallableWebApp);
- checkException(env);
-}
-
#if ENABLE(VIDEO)
-void WebViewCore::enterFullscreenForVideoLayer(int layerId, const WTF::String& url)
+void WebViewCore::enterFullscreenForVideoLayer()
{
- JNIEnv* env = JSC::Bindings::getJNIEnv();
- AutoJObject javaObject = m_javaGlue->object(env);
- if (!javaObject.get())
- return;
- jstring jUrlStr = wtfStringToJstring(env, url);
- env->CallVoidMethod(javaObject.get(), m_javaGlue->m_enterFullscreenForVideoLayer, layerId, jUrlStr);
+ // Just need to update the video mode, to avoid multiple exit full screen.
m_fullscreenVideoMode = true;
- checkException(env);
}
void WebViewCore::exitFullscreenVideo()
@@ -4813,11 +4805,6 @@ static void RegisterURLSchemeAsLocal(JNIEnv* env, jobject obj, jint nativeClass,
WebCore::SchemeRegistry::registerURLSchemeAsLocal(jstringToWtfString(env, scheme));
}
-static bool FocusBoundsChanged(JNIEnv* env, jobject obj, jint nativeClass)
-{
- return reinterpret_cast<WebViewCore*>(nativeClass)->focusBoundsChanged();
-}
-
static void Pause(JNIEnv* env, jobject obj, jint nativeClass)
{
// This is called for the foreground tab when the browser is put to the
@@ -5019,8 +5006,6 @@ static int FindNext(JNIEnv* env, jobject obj, jint nativeClass,
static JNINativeMethod gJavaWebViewCoreMethods[] = {
{ "nativeClearContent", "(I)V",
(void*) ClearContent },
- { "nativeFocusBoundsChanged", "(I)Z",
- (void*) FocusBoundsChanged } ,
{ "nativeKey", "(IIIIZZZZ)Z",
(void*) Key },
{ "nativeContentInvalidateAll", "(I)V",