summaryrefslogtreecommitdiffstats
path: root/WebKit/android/jni/WebViewCore.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'WebKit/android/jni/WebViewCore.cpp')
-rw-r--r--WebKit/android/jni/WebViewCore.cpp118
1 files changed, 49 insertions, 69 deletions
diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp
index 6ca1e4b..c574d5a 100644
--- a/WebKit/android/jni/WebViewCore.cpp
+++ b/WebKit/android/jni/WebViewCore.cpp
@@ -1400,33 +1400,6 @@ Node* WebViewCore::cursorNodeIsPlugin() {
return 0;
}
-
-void WebViewCore::updatePluginState(Frame* frame, Node* node, PluginState state) {
-
- // check that the node and frame pointers are (still) valid
- if (!frame || !node || !CacheBuilder::validNode(m_mainFrame, frame, node))
- return;
-
- // check that the node is a plugin view
- PluginView* pluginView = nodeIsPlugin(node);
- if (!pluginView)
- return;
-
- // create the event
- ANPEvent event;
- SkANP::InitEvent(&event, kLifecycle_ANPEventType);
-
- if (state == kLoseFocus_PluginState)
- event.data.lifecycle.action = kLoseFocus_ANPLifecycleAction;
- else if (state == kGainFocus_PluginState)
- event.data.lifecycle.action = kGainFocus_ANPLifecycleAction;
- else
- return;
-
- // send the event
- pluginView->platformPluginWidget()->sendEvent(event);
-}
-
///////////////////////////////////////////////////////////////////////////////
void WebViewCore::moveMouseIfLatest(int moveGeneration,
WebCore::Frame* frame, int x, int y)
@@ -1481,19 +1454,25 @@ static int findTextBoxIndex(WebCore::Node* node, const WebCore::IntPoint& pt)
do {
int textBoxStart = textBox->start();
int textBoxEnd = textBoxStart + textBox->len();
- if (textBoxEnd <= textBoxStart)
+ if (textBoxEnd <= textBoxStart) {
+ DBG_NAV_LOGD("textBoxStart=%d <= textBoxEnd=%d", textBoxStart,
+ textBoxEnd);
continue;
+ }
WebCore::IntRect bounds = textBox->selectionRect(absPt.x(), absPt.y(),
textBoxStart, textBoxEnd);
- if (!bounds.contains(x, y))
+ if (!bounds.contains(x, y)) {
+ DBG_NAV_LOGD("[absPt=(%g,%g) textBoxStart=%d textBoxEnd=%d]"
+ " !contains (x=%d, y=%d)",
+ absPt.x(), absPt.y(), textBoxStart, textBoxEnd, x, y);
continue;
+ }
int offset = textBox->offsetForPosition(x - absPt.x());
#if DEBUG_NAV_UI
int prior = offset > 0 ? textBox->positionForOffset(offset - 1) : -1;
int current = textBox->positionForOffset(offset);
int next = textBox->positionForOffset(offset + 1);
- DBG_NAV_LOGD(
- "offset=%d pt.x=%d globalX=%d renderX=%d x=%d "
+ DBG_NAV_LOGD("offset=%d pt.x=%d globalX=%d renderX=%g x=%d "
"textBox->x()=%d textBox->start()=%d prior=%d current=%d next=%d",
offset, pt.x(), globalX, absPt.x(), x,
textBox->x(), textBox->start(), prior, current, next
@@ -1527,6 +1506,38 @@ static int centerY(const SkIRect& rect)
return (rect.fTop + rect.fBottom) >> 1;
}
+static void ShowNode(Node* node)
+{
+#if DEBUG_NAV_UI
+ WebCore::Node* match = node->document();
+ int index = 1;
+ while (match != node && (match = match->traverseNextNode()))
+ index++;
+ if (match != node)
+ index = -1;
+ const char* name = "text";
+ WebCore::CString cstr;
+ if (!node->isTextNode()) {
+ cstr = node->localName().string().utf8();
+ name = cstr.data();
+ }
+ node->getRect();
+ const WebCore::IntRect& b = node->getRect();
+ DBG_NAV_LOGD("%s %p (%d) (%d,%d,w=%d,h=%d)", name, node, index,
+ b.x(), b.y(), b.width(), b.height());
+#endif
+}
+
+static WebCore::Node* ChildIsTextNode(WebCore::Node* node)
+{
+ WebCore::Node* child = node;
+ while (child && !child->isTextNode()) {
+ ShowNode(child);
+ child = child->traverseNextNode(node);
+ }
+ return child;
+}
+
WebCore::String WebViewCore::getSelection(SkRegion* selRgn)
{
SkRegion::Iterator iter(*selRgn);
@@ -1542,14 +1553,14 @@ WebCore::String WebViewCore::getSelection(SkRegion* selRgn)
int cy = centerY(rect);
WebCore::IntPoint startPt, endPt;
WebCore::Node* node, * endNode;
- for (int top = rect.fTop + 1; top != cy; top = cy) {
+ for (int top = rect.fTop + 2; top != cy; top = cy) {
startPt = WebCore::IntPoint(rect.fLeft + 1, top);
WebCore::HitTestResult hitTestResult = m_mainFrame->eventHandler()->
hitTestResultAtPoint(startPt, false);
- node = hitTestResult.innerNode();
+ node = ChildIsTextNode(hitTestResult.innerNode());
if (node)
break;
- DBG_NAV_LOGD("!node (%s)", top != cy ? "top+1" : "cy");
+ DBG_NAV_LOGD("node=%p (%s)", node, top != cy ? "top+1" : "cy");
}
if (!node) {
DBG_NAV_LOG("!node");
@@ -1560,10 +1571,10 @@ WebCore::String WebViewCore::getSelection(SkRegion* selRgn)
endPt = WebCore::IntPoint(right, bottom);
WebCore::HitTestResult hitTestResult = m_mainFrame->
eventHandler()->hitTestResultAtPoint(endPt, false);
- endNode = hitTestResult.innerNode();
+ endNode = ChildIsTextNode(hitTestResult.innerNode());
if (endNode)
break;
- DBG_NAV_LOGD("!endNode (%s) (right-%d)",
+ DBG_NAV_LOGD("!endNode=%p (%s) (right-%d)", node,
bottom != cy ? "bottom-1" : "cy", rect.fRight - right);
}
}
@@ -2012,35 +2023,16 @@ void WebViewCore::touchUp(int touchGeneration,
" x=%d y=%d", m_touchGeneration, touchGeneration, x, y);
return; // short circuit if a newer touch has been generated
}
+ // This moves m_mousePos to the correct place, and handleMouseClick uses
+ // m_mousePos to determine where the click happens.
moveMouse(frame, x, y);
m_lastGeneration = touchGeneration;
if (frame && CacheBuilder::validNode(m_mainFrame, frame, 0)) {
frame->loader()->resetMultipleFormSubmissionProtection();
}
- // If the click is on an unselected textfield/area we do not want to allow
- // the click to change the selection, because we will set it ourselves
- // elsewhere - beginning for textareas, end for textfields
- bool needToIgnoreChangesToSelectedRange = true;
- WebCore::Node* focusNode = currentFocus();
- if (focusNode) {
- WebCore::RenderObject* renderer = focusNode->renderer();
- if (renderer && (renderer->isTextField() || renderer->isTextArea())) {
- // Now check to see if the click is inside the focused textfield
- if (focusNode->getRect().contains(x, y))
- needToIgnoreChangesToSelectedRange = false;
- }
- }
- EditorClientAndroid* client = 0;
- if (needToIgnoreChangesToSelectedRange) {
- client = static_cast<EditorClientAndroid*>(
- m_mainFrame->editor()->client());
- client->setShouldChangeSelectedRange(false);
- }
DBG_NAV_LOGD("touchGeneration=%d handleMouseClick frame=%p node=%p"
" x=%d y=%d", touchGeneration, frame, node, x, y);
handleMouseClick(frame, node);
- if (needToIgnoreChangesToSelectedRange)
- client->setShouldChangeSelectedRange(true);
}
// Common code for both clicking with the trackball and touchUp
@@ -2962,17 +2954,6 @@ static bool PictureReady(JNIEnv* env, jobject obj)
return GET_NATIVE_VIEW(env, obj)->pictureReady();
}
-static void UpdatePluginState(JNIEnv* env, jobject obj, jint framePtr, jint nodePtr, jint state)
-{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::WebViewCoreTimeCounter);
-#endif
- WebViewCore* viewImpl = GET_NATIVE_VIEW(env, obj);
- LOG_ASSERT(viewImpl, "viewImpl not set in nativeUpdatePluginState");
- viewImpl->updatePluginState((WebCore::Frame*) framePtr, (WebCore::Node*) nodePtr,
- (PluginState) state);
-}
-
static void Pause(JNIEnv* env, jobject obj)
{
// This is called for the foreground tab when the browser is put to the
@@ -3111,7 +3092,6 @@ static JNINativeMethod gJavaWebViewCoreMethods[] = {
{ "nativeResume", "()V", (void*) Resume },
{ "nativeFreeMemory", "()V", (void*) FreeMemory },
{ "nativeSetJsFlags", "(Ljava/lang/String;)V", (void*) SetJsFlags },
- { "nativeUpdatePluginState", "(III)V", (void*) UpdatePluginState },
{ "nativeUpdateFrameCacheIfLoading", "()V",
(void*) UpdateFrameCacheIfLoading },
{ "nativeProvideVisitedHistory", "([Ljava/lang/String;)V",