summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--WebCore/plugins/PluginView.cpp4
-rw-r--r--WebCore/plugins/PluginView.h1
-rw-r--r--WebCore/plugins/android/PluginViewAndroid.cpp18
-rw-r--r--WebCore/rendering/RenderPartObject.cpp3
-rw-r--r--WebKit/android/jni/WebSettings.cpp3
-rw-r--r--WebKit/android/jni/WebViewCore.cpp118
-rw-r--r--WebKit/android/jni/WebViewCore.h8
-rw-r--r--WebKit/android/nav/WebView.cpp174
8 files changed, 119 insertions, 210 deletions
diff --git a/WebCore/plugins/PluginView.cpp b/WebCore/plugins/PluginView.cpp
index 811f6be..13d8511 100644
--- a/WebCore/plugins/PluginView.cpp
+++ b/WebCore/plugins/PluginView.cpp
@@ -165,6 +165,10 @@ void PluginView::handleEvent(Event* event)
#if defined(ANDROID_PLUGINS)
else if (event->isTouchEvent())
handleTouchEvent(static_cast<TouchEvent*>(event));
+ else if (event->type() == eventNames().DOMFocusOutEvent)
+ handleFocusEvent(false);
+ else if (event->type() == eventNames().DOMFocusInEvent)
+ handleFocusEvent(true);
#endif
#if defined(Q_WS_X11)
else if (event->type() == eventNames().DOMFocusOutEvent)
diff --git a/WebCore/plugins/PluginView.h b/WebCore/plugins/PluginView.h
index 0fd0d4f..b385d41 100644
--- a/WebCore/plugins/PluginView.h
+++ b/WebCore/plugins/PluginView.h
@@ -289,6 +289,7 @@ namespace WebCore {
#endif
#ifdef ANDROID_PLUGINS
+ void handleFocusEvent(bool hasFocus);
void handleTouchEvent(TouchEvent*);
// called at the end of the base constructor
void platformInit();
diff --git a/WebCore/plugins/android/PluginViewAndroid.cpp b/WebCore/plugins/android/PluginViewAndroid.cpp
index 0c69cfd..529458b 100644
--- a/WebCore/plugins/android/PluginViewAndroid.cpp
+++ b/WebCore/plugins/android/PluginViewAndroid.cpp
@@ -258,6 +258,20 @@ static ANPKeyModifier make_modifiers(bool shift, bool alt) {
return mod;
}
+void PluginView::handleFocusEvent(bool hasFocus)
+{
+ ANPEvent evt;
+ SkANP::InitEvent(&evt, kLifecycle_ANPEventType);
+ evt.data.lifecycle.action = hasFocus ? kGainFocus_ANPLifecycleAction :
+ kLoseFocus_ANPLifecycleAction;
+ m_window->sendEvent(evt);
+
+ // redraw the plugin which subsequently invalidates the nav cache
+ IntRect rect = IntRect(m_npWindow.x, m_npWindow.y,
+ m_npWindow.width, m_npWindow.height);
+ m_window->webViewCore()->contentInvalidate(rect);
+}
+
void PluginView::handleKeyboardEvent(KeyboardEvent* event)
{
if (!m_window->isAcceptingEvent(kKey_ANPEventFlag))
@@ -319,6 +333,9 @@ void PluginView::handleKeyboardEvent(KeyboardEvent* event)
if (m_plugin->pluginFuncs()->event(m_instance, &evt)) {
event->setDefaultHandled();
+ } else {
+ // remove the plugin from the document's focus
+ m_parentFrame->document()->focusedNodeRemoved();
}
}
@@ -498,7 +515,6 @@ void PluginView::invalidateRect(NPRect* rect)
}
m_window->inval(r, true);
-// android::WebViewCore::getWebViewCore(parent())->contentInvalidate(r);
}
void PluginView::invalidateRegion(NPRegion region)
diff --git a/WebCore/rendering/RenderPartObject.cpp b/WebCore/rendering/RenderPartObject.cpp
index 3867581..f864c00 100644
--- a/WebCore/rendering/RenderPartObject.cpp
+++ b/WebCore/rendering/RenderPartObject.cpp
@@ -386,9 +386,6 @@ void RenderPartObject::layout()
ASSERT(!c->needsLayout());
c = c->nextInPreOrder();
}
- Node* body = document()->body();
- if (body)
- ASSERT(!body->renderer()->needsLayout());
#endif
}
}
diff --git a/WebKit/android/jni/WebSettings.cpp b/WebKit/android/jni/WebSettings.cpp
index 4240dd5..e5532c3 100644
--- a/WebKit/android/jni/WebSettings.cpp
+++ b/WebKit/android/jni/WebSettings.cpp
@@ -342,7 +342,8 @@ public:
flag = env->GetBooleanField(obj, gFieldIds->mDatabaseEnabled);
s->setDatabasesEnabled(flag);
str = (jstring)env->GetObjectField(obj, gFieldIds->mDatabasePath);
- WebCore::DatabaseTracker::tracker().setDatabaseDirectoryPath(to_string(env, str));
+ if (str && WebCore::DatabaseTracker::tracker().databaseDirectoryPath().isNull())
+ WebCore::DatabaseTracker::tracker().setDatabaseDirectoryPath(to_string(env, str));
#endif
#if ENABLE(DOM_STORAGE)
flag = env->GetBooleanField(obj, gFieldIds->mDomStorageEnabled);
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",
diff --git a/WebKit/android/jni/WebViewCore.h b/WebKit/android/jni/WebViewCore.h
index 88031d0..a7855b8 100644
--- a/WebKit/android/jni/WebViewCore.h
+++ b/WebKit/android/jni/WebViewCore.h
@@ -63,11 +63,6 @@ class SkIRect;
namespace android {
- enum PluginState {
- kGainFocus_PluginState = 0,
- kLoseFocus_PluginState = 1,
- };
-
class CachedRoot;
class ListBoxReply;
@@ -366,9 +361,6 @@ namespace android {
// return the cursorNode if it is a plugin
Node* cursorNodeIsPlugin();
- // notify the plugin of an update in state
- void updatePluginState(Frame* frame, Node* node, PluginState state);
-
// Notify the Java side whether it needs to pass down the touch events
void needTouchEvents(bool);
diff --git a/WebKit/android/nav/WebView.cpp b/WebKit/android/nav/WebView.cpp
index 8fff1b9..cc90396 100644
--- a/WebKit/android/nav/WebView.cpp
+++ b/WebKit/android/nav/WebView.cpp
@@ -98,7 +98,6 @@ struct JavaGlue {
jobject m_obj;
jmethodID m_clearTextEntry;
jmethodID m_overrideLoading;
- jmethodID m_sendPluginState;
jmethodID m_scrollBy;
jmethodID m_sendMoveMouse;
jmethodID m_sendMoveMouseIfLatest;
@@ -107,6 +106,7 @@ struct JavaGlue {
jmethodID m_getScaledMaxYScroll;
jmethodID m_getVisibleRect;
jmethodID m_rebuildWebTextView;
+ jmethodID m_setOkayToNotMatch;
jmethodID m_displaySoftKeyboard;
jmethodID m_viewInvalidate;
jmethodID m_viewInvalidateRect;
@@ -128,7 +128,6 @@ WebView(JNIEnv* env, jobject javaWebView, int viewImpl)
m_javaGlue.m_scrollBy = GetJMethod(env, clazz, "setContentScrollBy", "(IIZ)Z");
m_javaGlue.m_clearTextEntry = GetJMethod(env, clazz, "clearTextEntry", "()V");
m_javaGlue.m_overrideLoading = GetJMethod(env, clazz, "overrideLoading", "(Ljava/lang/String;)V");
- m_javaGlue.m_sendPluginState = GetJMethod(env, clazz, "sendPluginState", "(I)V");
m_javaGlue.m_sendMoveMouse = GetJMethod(env, clazz, "sendMoveMouse", "(IIII)V");
m_javaGlue.m_sendMoveMouseIfLatest = GetJMethod(env, clazz, "sendMoveMouseIfLatest", "(Z)V");
m_javaGlue.m_sendMotionUp = GetJMethod(env, clazz, "sendMotionUp", "(IIIII)V");
@@ -136,6 +135,7 @@ WebView(JNIEnv* env, jobject javaWebView, int viewImpl)
m_javaGlue.m_getScaledMaxYScroll = GetJMethod(env, clazz, "getScaledMaxYScroll", "()I");
m_javaGlue.m_getVisibleRect = GetJMethod(env, clazz, "sendOurVisibleRect", "()Landroid/graphics/Rect;");
m_javaGlue.m_rebuildWebTextView = GetJMethod(env, clazz, "rebuildWebTextView", "()V");
+ m_javaGlue.m_setOkayToNotMatch = GetJMethod(env, clazz, "setOkayNotToMatch", "()V");
m_javaGlue.m_displaySoftKeyboard = GetJMethod(env, clazz, "displaySoftKeyboard", "(Z)V");
m_javaGlue.m_viewInvalidate = GetJMethod(env, clazz, "viewInvalidate", "()V");
m_javaGlue.m_viewInvalidateRect = GetJMethod(env, clazz, "viewInvalidate", "(IIII)V");
@@ -163,10 +163,6 @@ WebView(JNIEnv* env, jobject javaWebView, int viewImpl)
m_matches = 0;
m_hasCurrentLocation = false;
m_isFindPaintSetUp = false;
- m_pluginReceivesEvents = false; // initialization is the only time this
- // variable should be set directly, all
- // other changes should be made through
- // setPluginReceivesEvents(bool)
}
~WebView()
@@ -483,10 +479,9 @@ void drawCursorRing(SkCanvas* canvas)
" bounds=(%d,%d,w=%d,h=%d)", node->index(), node->nodePointer(),
bounds.x(), bounds.y(), bounds.width(), bounds.height());
m_followedLink = false;
- setPluginReceivesEvents(false);
return;
}
- if (!node->hasCursorRing() || (m_pluginReceivesEvents && node->isPlugin()))
+ if (!node->hasCursorRing() || (node->isPlugin() && node->isFocus()))
return;
CursorRing::Flavor flavor = CursorRing::NORMAL_FLAVOR;
if (!isButton) {
@@ -499,13 +494,12 @@ void drawCursorRing(SkCanvas* canvas)
#if DEBUG_NAV_UI
const WebCore::IntRect& ring = (*rings)[0];
DBG_NAV_LOGD("cursorNode=%d (nodePointer=%p) flavor=%s rings=%d"
- " (%d, %d, %d, %d) pluginReceivesEvents=%s isPlugin=%s",
+ " (%d, %d, %d, %d) isPlugin=%s",
node->index(), node->nodePointer(),
flavor == CursorRing::FAKE_FLAVOR ? "FAKE_FLAVOR" :
flavor == CursorRing::NORMAL_ANIMATING ? "NORMAL_ANIMATING" :
flavor == CursorRing::FAKE_ANIMATING ? "FAKE_ANIMATING" : "NORMAL_FLAVOR",
rings->size(), ring.x(), ring.y(), ring.width(), ring.height(),
- m_pluginReceivesEvents ? "true" : "false",
node->isPlugin() ? "true" : "false");
#endif
}
@@ -756,7 +750,6 @@ void updateCursorBounds(const CachedRoot* root, const CachedFrame* cachedFrame,
/* returns true if the key had no effect (neither scrolled nor changed cursor) */
bool moveCursor(int keyCode, int count, bool ignoreScroll)
{
- setPluginReceivesEvents(false);
CachedRoot* root = getFrameCache(AllowNewer);
if (!root) {
DBG_NAV_LOG("!root");
@@ -841,25 +834,10 @@ bool moveCursor(int keyCode, int count, bool ignoreScroll)
return result;
}
-bool pluginEatsNavKey()
-{
- CachedRoot* root = getFrameCache(DontAllowNewer);
- if (!root) {
- DBG_NAV_LOG("!root");
- return false;
- }
- const CachedNode* cursor = root->currentCursor();
- DBG_NAV_LOGD("cursor=%p isPlugin=%s pluginReceivesEvents=%s",
- cursor, cursor && cursor->isPlugin() ? "true" : "false",
- m_pluginReceivesEvents ? "true" : "false");
- // FIXME: check to see if plugin wants keys
- return cursor && cursor->isPlugin() && m_pluginReceivesEvents;
-}
-
void notifyProgressFinished()
{
DBG_NAV_LOGD("cursorIsTextInput=%d", cursorIsTextInput(DontAllowNewer));
- rebuildWebTextView();
+ rebuildWebTextView(false);
#if DEBUG_NAV_UI
if (m_frameCacheUI) {
const CachedNode* focus = m_frameCacheUI->currentFocus();
@@ -975,7 +953,6 @@ bool motionUp(int x, int y, int slop)
0, x, y);
viewInvalidate();
clearTextEntry();
- setPluginReceivesEvents(false);
return pageScrolled;
}
DBG_NAV_LOGD("CachedNode:%p (%d) x=%d y=%d rx=%d ry=%d", result,
@@ -984,7 +961,6 @@ bool motionUp(int x, int y, int slop)
updateCursorBounds(root, frame, result);
root->setCursor(const_cast<CachedFrame*>(frame),
const_cast<CachedNode*>(result));
- updatePluginReceivesEvents();
CachedNodeType type = result->type();
if (type == NORMAL_CACHEDNODETYPE) {
sendMotionUp(
@@ -993,7 +969,7 @@ bool motionUp(int x, int y, int slop)
}
viewInvalidate();
if (result->isTextField() || result->isTextArea()) {
- rebuildWebTextView();
+ rebuildWebTextView(true);
if (!result->isReadOnly()) {
displaySoftKeyboard(true);
}
@@ -1034,35 +1010,6 @@ void setFindIsUp(bool up)
m_hasCurrentLocation = false;
}
-void setPluginReceivesEvents(bool value)
-{
- if (value == m_pluginReceivesEvents)
- return;
-
- //send message to plugin in webkit
- JNIEnv* env = JSC::Bindings::getJNIEnv();
- AutoJObject obj = m_javaGlue.object(env);
- // if it is called during or after DESTROY is handled, the real object of
- // WebView can be gone. Check before using it.
- if (!obj.get())
- return;
- env->CallVoidMethod(obj.get(), m_javaGlue.m_sendPluginState,
- value ? kGainFocus_PluginState : kLoseFocus_PluginState);
- checkException(env);
- m_pluginReceivesEvents = value;
-}
-
-void updatePluginReceivesEvents()
-{
- CachedRoot* root = getFrameCache(DontAllowNewer);
- if (!root)
- return;
- const CachedNode* cursor = root->currentCursor();
- setPluginReceivesEvents(cursor && cursor->isPlugin());
- DBG_NAV_LOGD("m_pluginReceivesEvents=%s cursor=%p", m_pluginReceivesEvents
- ? "true" : "false", cursor);
-}
-
void setFollowedLink(bool followed)
{
if ((m_followedLink = followed) != false) {
@@ -1104,17 +1051,6 @@ const SkRegion& getSelection()
return m_selRegion;
}
-void drawSelection(SkCanvas* canvas, float scale, int offset, int x, int y,
- bool extendSelection)
-{
- if (!extendSelection) {
- drawSelectionArrow(canvas, scale, x, y - offset);
- } else {
- drawSelectionRegion(canvas);
- drawSelectionPointer(canvas, scale, offset, x, y, false);
- }
-}
-
void drawSelectionRegion(SkCanvas* canvas)
{
CachedRoot* root = getFrameCache(DontAllowNewer);
@@ -1134,46 +1070,31 @@ void drawSelectionRegion(SkCanvas* canvas)
canvas->drawPath(path, paint);
}
-void drawSelectionPointer(SkCanvas* canvas, float scale, int offset,
- int x, int y, bool gridded)
+void drawSelectionPointer(SkCanvas* canvas, float scale, int x, int y, bool ex)
{
SkPath path;
- getSelectionCaret(&path);
+ if (ex)
+ getSelectionCaret(&path);
+ else
+ getSelectionArrow(&path);
SkPaint paint;
paint.setAntiAlias(true);
paint.setStyle(SkPaint::kStroke_Style);
paint.setColor(SK_ColorBLACK);
SkPixelXorXfermode xorMode(SK_ColorWHITE);
- paint.setXfermode(&xorMode);
- int sc = canvas->save();
- canvas->scale(scale, scale);
- canvas->translate(0, -SkIntToScalar(offset));
- if (gridded) {
- bool useLeft = x <= (m_selStart.fLeft + m_selStart.fRight) >> 1;
- canvas->translate(SkIntToScalar(useLeft ? m_selStart.fLeft :
- m_selStart.fRight), SkIntToScalar(m_selStart.fTop));
- } else
- canvas->translate(SkIntToScalar(x), SkIntToScalar(y));
- canvas->drawPath(path, paint);
- canvas->restoreToCount(sc);
-}
-
-void drawSelectionArrow(SkCanvas* canvas, float scale, int x, int y)
-{
- SkPath path;
- getSelectionArrow(&path);
- SkPaint paint;
- paint.setAntiAlias(true);
- paint.setStyle(SkPaint::kStroke_Style);
- paint.setColor(SK_ColorBLACK);
- paint.setStrokeWidth(SK_Scalar1 * 2);
+ if (ex)
+ paint.setXfermode(&xorMode);
+ else
+ paint.setStrokeWidth(SK_Scalar1 * 2);
int sc = canvas->save();
canvas->scale(scale, scale);
canvas->translate(SkIntToScalar(x), SkIntToScalar(y));
canvas->drawPath(path, paint);
- paint.setStyle(SkPaint::kFill_Style);
- paint.setColor(SK_ColorWHITE);
- canvas->drawPath(path, paint);
+ if (!ex) {
+ paint.setStyle(SkPaint::kFill_Style);
+ paint.setColor(SK_ColorWHITE);
+ canvas->drawPath(path, paint);
+ }
canvas->restoreToCount(sc);
}
@@ -1191,14 +1112,13 @@ void getSelectionCaret(SkPath* path)
{
SkScalar height = SkIntToScalar(m_selStart.fBottom - m_selStart.fTop);
SkScalar dist = height / 4;
- path->lineTo(0, height);
- SkScalar bottom = height + dist;
- path->lineTo(-dist, bottom);
- SkScalar edge = bottom - SK_Scalar1/2;
- path->moveTo(-dist, edge);
- path->lineTo(dist, edge);
- path->moveTo(dist, bottom);
- path->lineTo(0, height);
+ path->moveTo(0, -height / 2);
+ path->rLineTo(0, height);
+ path->rLineTo(-dist, dist);
+ path->rMoveTo(0, -SK_Scalar1/2);
+ path->rLineTo(dist * 2, 0);
+ path->rMoveTo(0, SK_Scalar1/2);
+ path->rLineTo(-dist, -dist);
}
void sendMoveMouse(WebCore::Frame* framePtr, WebCore::Node* nodePtr, int x, int y)
@@ -1349,7 +1269,7 @@ bool hasFocusNode()
return focusNode;
}
-void rebuildWebTextView()
+void rebuildWebTextView(bool needNotMatchFocus)
{
JNIEnv* env = JSC::Bindings::getJNIEnv();
AutoJObject obj = m_javaGlue.object(env);
@@ -1359,6 +1279,10 @@ void rebuildWebTextView()
return;
env->CallVoidMethod(obj.get(), m_javaGlue.m_rebuildWebTextView);
checkException(env);
+ if (needNotMatchFocus) {
+ env->CallVoidMethod(obj.get(), m_javaGlue.m_setOkayToNotMatch);
+ checkException(env);
+ }
}
void displaySoftKeyboard(bool isTextView)
@@ -1423,7 +1347,6 @@ private: // local state for WebView
int m_generation; // associate unique ID with sent kit focus to match with ui
SkPicture* m_navPictureUI;
bool m_followedLink;
- bool m_pluginReceivesEvents;
SkMSec m_ringAnimationEnd;
// Corresponds to the same-named boolean on the java side.
bool m_heightCanMeasure;
@@ -1626,8 +1549,8 @@ static void nativeDrawCursorRing(JNIEnv *env, jobject obj, jobject canv)
view->drawCursorRing(canvas);
}
-static void nativeDrawSelection(JNIEnv *env, jobject obj,
- jobject canv, jfloat scale, jint offset, jint x, jint y, bool ex)
+static void nativeDrawSelectionPointer(JNIEnv *env, jobject obj,
+ jobject canv, jfloat scale, jint x, jint y, bool ex)
{
SkCanvas* canvas = GraphicsJNI::getNativeCanvas(env, canv);
if (!canv) {
@@ -1639,7 +1562,7 @@ static void nativeDrawSelection(JNIEnv *env, jobject obj,
DBG_NAV_LOG("!view");
return;
}
- view->drawSelection(canvas, scale, offset, x, y, ex);
+ view->drawSelectionPointer(canvas, scale, x, y, ex);
}
static void nativeDrawSelectionRegion(JNIEnv *env, jobject obj, jobject canv)
@@ -1763,6 +1686,12 @@ static bool nativeFocusCandidateIsPlugin(JNIEnv *env, jobject obj)
return node ? node->isPlugin() : false;
}
+static bool nativeFocusIsPlugin(JNIEnv *env, jobject obj)
+{
+ const CachedNode* node = getFocusNode(env, obj);
+ return node ? node->isPlugin() : false;
+}
+
static jint nativeFocusNodePointer(JNIEnv *env, jobject obj)
{
const CachedNode* node = getFocusNode(env, obj);
@@ -1852,11 +1781,6 @@ static void nativeSetFindIsDown(JNIEnv *env, jobject obj)
view->setFindIsUp(false);
}
-static void nativeUpdatePluginReceivesEvents(JNIEnv *env, jobject obj)
-{
- GET_NATIVE_VIEW(env, obj)->updatePluginReceivesEvents();
-}
-
static void nativeSetFollowedLink(JNIEnv *env, jobject obj, bool followed)
{
WebView* view = GET_NATIVE_VIEW(env, obj);
@@ -2009,6 +1933,7 @@ static void nativeMoveCursorToNextTextInput(JNIEnv *env, jobject obj)
static_cast<WebCore::Node*>(next->nodePointer()), pos.x(), pos.y());
view->scrollRectOnScreen(bounds.x(), bounds.y(), bounds.right(),
bounds.bottom());
+ view->getWebViewCore()->m_moveGeneration++;
}
static jint nativeTextFieldAction(JNIEnv *env, jobject obj)
@@ -2035,11 +1960,6 @@ static void nativeMoveSelection(JNIEnv *env, jobject obj, int x, int y, bool ex)
view->moveSelection(x, y, ex);
}
-static bool nativePluginEatsNavKey(JNIEnv *env, jobject obj)
-{
- return GET_NATIVE_VIEW(env, obj)->pluginEatsNavKey();
-}
-
static jobject nativeGetSelection(JNIEnv *env, jobject obj)
{
WebView* view = GET_NATIVE_VIEW(env, obj);
@@ -2122,8 +2042,8 @@ static JNINativeMethod gJavaWebViewMethods[] = {
(void*) nativeDrawCursorRing },
{ "nativeDrawMatches", "(Landroid/graphics/Canvas;)V",
(void*) nativeDrawMatches },
- { "nativeDrawSelection", "(Landroid/graphics/Canvas;FIIIZ)V",
- (void*) nativeDrawSelection },
+ { "nativeDrawSelectionPointer", "(Landroid/graphics/Canvas;FIIZ)V",
+ (void*) nativeDrawSelectionPointer },
{ "nativeDrawSelectionRegion", "(Landroid/graphics/Canvas;)V",
(void*) nativeDrawSelectionRegion },
{ "nativeDumpDisplayTree", "(Ljava/lang/String;)V",
@@ -2156,6 +2076,8 @@ static JNINativeMethod gJavaWebViewMethods[] = {
(void*) nativeFocusCandidateText },
{ "nativeFocusCandidateTextSize", "()I",
(void*) nativeFocusCandidateTextSize },
+ { "nativeFocusIsPlugin", "()Z",
+ (void*) nativeFocusIsPlugin },
{ "nativeFocusNodePointer", "()I",
(void*) nativeFocusNodePointer },
{ "nativeGetCursorRingBounds", "()Landroid/graphics/Rect;",
@@ -2184,8 +2106,6 @@ static JNINativeMethod gJavaWebViewMethods[] = {
(void*) nativeMoveGeneration },
{ "nativeMoveSelection", "(IIZ)V",
(void*) nativeMoveSelection },
- { "nativePluginEatsNavKey", "()Z",
- (void*) nativePluginEatsNavKey },
{ "nativeRecordButtons", "(ZZZ)V",
(void*) nativeRecordButtons },
{ "nativeSelectBestAt", "(Landroid/graphics/Rect;)V",
@@ -2204,8 +2124,6 @@ static JNINativeMethod gJavaWebViewMethods[] = {
(void*) nativeUpdateCachedTextfield },
{ "nativeGetBlockLeftEdge", "(IIF)I",
(void*) nativeGetBlockLeftEdge },
- { "nativeUpdatePluginReceivesEvents", "()V",
- (void*) nativeUpdatePluginReceivesEvents }
};
int register_webview(JNIEnv* env)