Bug 707353 - Implement ANPWindow::showKeyboard() for Android plugins. r=snorp a=blocking-fennec

--HG--
extra : rebase_source : ca2da8fe9689fa702444cd6da7b4841d9ef12ec4
This commit is contained in:
James Willcox 2012-04-20 09:49:50 -07:00
parent 82c7940be5
commit 4e5222e0f7
5 changed files with 28 additions and 10 deletions

View File

@ -43,11 +43,13 @@
#include "nsNPAPIPluginInstance.h"
#include "nsIPluginInstanceOwner.h"
#include "nsPluginInstanceOwner.h"
#include "nsWindow.h"
#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "GeckoPlugins" , ## args)
#define ASSIGN(obj, name) (obj)->name = anp_window_##name
using namespace mozilla;
using namespace mozilla::widget;
void
anp_window_setVisibleRects(NPP instance, const ANPRectI rects[], int32_t count)
@ -64,7 +66,22 @@ anp_window_clearVisibleRects(NPP instance)
void
anp_window_showKeyboard(NPP instance, bool value)
{
NOT_IMPLEMENTED();
InputContext context;
context.mIMEState.mEnabled = IMEState::PLUGIN;
context.mIMEState.mOpen = value ? IMEState::OPEN : IMEState::CLOSED;
context.mActionHint.Assign(EmptyString());
InputContextAction action;
action.mCause = InputContextAction::CAUSE_UNKNOWN;
action.mFocusChange = InputContextAction::FOCUS_NOT_CHANGED;
nsWindow* window = nsWindow::TopWindow();
if (!window) {
LOG("Couldn't get top window?");
return;
}
window->SetInputContext(context, action);
}
void

View File

@ -72,6 +72,7 @@ CPPSRCS += ANPAudio.cpp \
LOCAL_INCLUDES += \
-I$(topsrcdir)/widget/android \
-I$(topsrcdir)/widget/xpwidgets \
-I$(topsrcdir)/dom/plugins/base \
-I$(topsrcdir)/dom/plugins/base/android/include \
-I$(topsrcdir)/gfx/gl \

View File

@ -1041,8 +1041,7 @@ public class GeckoInputConnection
if (!mEnable)
return;
if (mIMEState != IME_STATE_DISABLED &&
mIMEState != IME_STATE_PLUGIN)
if (mIMEState != IME_STATE_DISABLED)
imm.showSoftInput(v, 0);
else
imm.hideSoftInputFromWindow(v.getWindowToken(), 0);

View File

@ -153,8 +153,8 @@ static void *sNativeWindow = nsnull;
static const double SWIPE_MAX_PINCH_DELTA_INCHES = 0.4;
static const double SWIPE_MIN_DISTANCE_INCHES = 0.6;
static nsWindow*
TopWindow()
nsWindow*
nsWindow::TopWindow()
{
if (!gTopLevelWindows.IsEmpty())
return gTopLevelWindows[0];
@ -334,7 +334,7 @@ nsWindow::SetParent(nsIWidget *aNewParent)
mParent->mChildren.AppendElement(this);
// if we are now in the toplevel window's hierarchy, schedule a redraw
if (FindTopLevel() == TopWindow())
if (FindTopLevel() == nsWindow::TopWindow())
RedrawAll();
return NS_OK;
@ -390,7 +390,7 @@ nsWindow::Show(bool aState)
// and bring it to the front.
Resize(0, 0, gAndroidBounds.width, gAndroidBounds.height, false);
BringToFront();
} else if (TopWindow() == this) {
} else if (nsWindow::TopWindow() == this) {
// find the next visible window to show
unsigned int i;
for (i = 1; i < gTopLevelWindows.Length(); i++) {
@ -402,7 +402,7 @@ nsWindow::Show(bool aState)
break;
}
}
} else if (FindTopLevel() == TopWindow()) {
} else if (FindTopLevel() == nsWindow::TopWindow()) {
RedrawAll();
}
@ -490,7 +490,7 @@ nsWindow::Resize(PRInt32 aX,
OnSizeChanged(gfxIntSize(aWidth, aHeight));
// Should we skip honoring aRepaint here?
if (aRepaint && FindTopLevel() == TopWindow())
if (aRepaint && FindTopLevel() == nsWindow::TopWindow())
RedrawAll();
return NS_OK;
@ -589,7 +589,7 @@ nsWindow::BringToFront()
nsCOMPtr<nsIFocusManager> fm = do_GetService(FOCUSMANAGER_CONTRACTID);
nsCOMPtr<nsIDOMWindow> existingTopWindow;
fm->GetActiveWindow(getter_AddRefs(existingTopWindow));
if (existingTopWindow && FindTopLevel() == TopWindow())
if (existingTopWindow && FindTopLevel() == nsWindow::TopWindow())
return;
if (!IsTopLevel()) {

View File

@ -76,6 +76,7 @@ public:
static void OnGlobalAndroidEvent(mozilla::AndroidGeckoEvent *ae);
static gfxIntSize GetAndroidScreenBounds();
static nsWindow* TopWindow();
nsWindow* FindWindowForPoint(const nsIntPoint& pt);