mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-08 12:37:37 +00:00
01583602a9
The bulk of this commit was generated with a script, executed at the top level of a typical source code checkout. The only non-machine-generated part was modifying MFBT's moz.build to reflect the new naming. CLOSED TREE makes big refactorings like this a piece of cake. # The main substitution. find . -name '*.cpp' -o -name '*.cc' -o -name '*.h' -o -name '*.mm' -o -name '*.idl'| \ xargs perl -p -i -e ' s/nsRefPtr\.h/RefPtr\.h/g; # handle includes s/nsRefPtr ?</RefPtr</g; # handle declarations and variables ' # Handle a special friend declaration in gfx/layers/AtomicRefCountedWithFinalize.h. perl -p -i -e 's/::nsRefPtr;/::RefPtr;/' gfx/layers/AtomicRefCountedWithFinalize.h # Handle nsRefPtr.h itself, a couple places that define constructors # from nsRefPtr, and code generators specially. We do this here, rather # than indiscriminantly s/nsRefPtr/RefPtr/, because that would rename # things like nsRefPtrHashtable. perl -p -i -e 's/nsRefPtr/RefPtr/g' \ mfbt/nsRefPtr.h \ xpcom/glue/nsCOMPtr.h \ xpcom/base/OwningNonNull.h \ ipc/ipdl/ipdl/lower.py \ ipc/ipdl/ipdl/builtin.py \ dom/bindings/Codegen.py \ python/lldbutils/lldbutils/utils.py # In our indiscriminate substitution above, we renamed # nsRefPtrGetterAddRefs, the class behind getter_AddRefs. Fix that up. find . -name '*.cpp' -o -name '*.h' -o -name '*.idl' | \ xargs perl -p -i -e 's/nsRefPtrGetterAddRefs/RefPtrGetterAddRefs/g' if [ -d .git ]; then git mv mfbt/nsRefPtr.h mfbt/RefPtr.h else hg mv mfbt/nsRefPtr.h mfbt/RefPtr.h fi --HG-- rename : mfbt/nsRefPtr.h => mfbt/RefPtr.h
166 lines
4.3 KiB
C++
166 lines
4.3 KiB
C++
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
#include "base/basictypes.h"
|
|
#include "assert.h"
|
|
#include "ANPBase.h"
|
|
#include <android/log.h>
|
|
#include "AndroidBridge.h"
|
|
#include "nsNPAPIPluginInstance.h"
|
|
#include "nsPluginInstanceOwner.h"
|
|
#include "nsWindow.h"
|
|
#include "mozilla/dom/ScreenOrientation.h"
|
|
|
|
#undef LOG
|
|
#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;
|
|
using namespace mozilla::dom;
|
|
|
|
void
|
|
anp_window_setVisibleRects(NPP instance, const ANPRectI rects[], int32_t count)
|
|
{
|
|
NOT_IMPLEMENTED();
|
|
}
|
|
|
|
void
|
|
anp_window_clearVisibleRects(NPP instance)
|
|
{
|
|
NOT_IMPLEMENTED();
|
|
}
|
|
|
|
void
|
|
anp_window_showKeyboard(NPP instance, bool value)
|
|
{
|
|
InputContext context;
|
|
context.mIMEState.mEnabled = value ? IMEState::PLUGIN : IMEState::DISABLED;
|
|
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
|
|
anp_window_requestFullScreen(NPP instance)
|
|
{
|
|
nsNPAPIPluginInstance* inst = static_cast<nsNPAPIPluginInstance*>(instance->ndata);
|
|
|
|
RefPtr<nsPluginInstanceOwner> owner = inst->GetOwner();
|
|
if (!owner) {
|
|
return;
|
|
}
|
|
|
|
owner->RequestFullScreen();
|
|
}
|
|
|
|
void
|
|
anp_window_exitFullScreen(NPP instance)
|
|
{
|
|
nsNPAPIPluginInstance* inst = static_cast<nsNPAPIPluginInstance*>(instance->ndata);
|
|
|
|
RefPtr<nsPluginInstanceOwner> owner = inst->GetOwner();
|
|
if (!owner) {
|
|
return;
|
|
}
|
|
|
|
owner->ExitFullScreen();
|
|
}
|
|
|
|
void
|
|
anp_window_requestCenterFitZoom(NPP instance)
|
|
{
|
|
NOT_IMPLEMENTED();
|
|
}
|
|
|
|
ANPRectI
|
|
anp_window_visibleRect(NPP instance)
|
|
{
|
|
ANPRectI rect = { 0, 0, 0, 0 };
|
|
|
|
nsNPAPIPluginInstance* pinst = static_cast<nsNPAPIPluginInstance*>(instance->ndata);
|
|
|
|
nsIntSize currentSize = pinst->CurrentSize();
|
|
rect.left = rect.top = 0;
|
|
rect.right = currentSize.width;
|
|
rect.bottom = currentSize.height;
|
|
|
|
return rect;
|
|
}
|
|
|
|
void anp_window_requestFullScreenOrientation(NPP instance, ANPScreenOrientation orientation)
|
|
{
|
|
short newOrientation;
|
|
|
|
// Convert to the ActivityInfo equivalent
|
|
switch (orientation) {
|
|
case kFixedLandscape_ANPScreenOrientation:
|
|
newOrientation = eScreenOrientation_LandscapePrimary;
|
|
break;
|
|
case kFixedPortrait_ANPScreenOrientation:
|
|
newOrientation = eScreenOrientation_PortraitPrimary;
|
|
break;
|
|
case kLandscape_ANPScreenOrientation:
|
|
newOrientation = eScreenOrientation_LandscapePrimary |
|
|
eScreenOrientation_LandscapeSecondary;
|
|
break;
|
|
case kPortrait_ANPScreenOrientation:
|
|
newOrientation = eScreenOrientation_PortraitPrimary |
|
|
eScreenOrientation_PortraitSecondary;
|
|
break;
|
|
default:
|
|
newOrientation = eScreenOrientation_None;
|
|
break;
|
|
}
|
|
|
|
nsNPAPIPluginInstance* pinst = static_cast<nsNPAPIPluginInstance*>(instance->ndata);
|
|
pinst->SetFullScreenOrientation(newOrientation);
|
|
}
|
|
|
|
void InitWindowInterface(ANPWindowInterfaceV0 *i) {
|
|
_assert(i->inSize == sizeof(*i));
|
|
ASSIGN(i, setVisibleRects);
|
|
ASSIGN(i, clearVisibleRects);
|
|
ASSIGN(i, showKeyboard);
|
|
ASSIGN(i, requestFullScreen);
|
|
ASSIGN(i, exitFullScreen);
|
|
ASSIGN(i, requestCenterFitZoom);
|
|
}
|
|
|
|
void InitWindowInterfaceV1(ANPWindowInterfaceV1 *i) {
|
|
_assert(i->inSize == sizeof(*i));
|
|
ASSIGN(i, setVisibleRects);
|
|
ASSIGN(i, clearVisibleRects);
|
|
ASSIGN(i, showKeyboard);
|
|
ASSIGN(i, requestFullScreen);
|
|
ASSIGN(i, exitFullScreen);
|
|
ASSIGN(i, requestCenterFitZoom);
|
|
ASSIGN(i, visibleRect);
|
|
}
|
|
|
|
void InitWindowInterfaceV2(ANPWindowInterfaceV2 *i) {
|
|
_assert(i->inSize == sizeof(*i));
|
|
ASSIGN(i, setVisibleRects);
|
|
ASSIGN(i, clearVisibleRects);
|
|
ASSIGN(i, showKeyboard);
|
|
ASSIGN(i, requestFullScreen);
|
|
ASSIGN(i, exitFullScreen);
|
|
ASSIGN(i, requestCenterFitZoom);
|
|
ASSIGN(i, visibleRect);
|
|
ASSIGN(i, requestFullScreenOrientation);
|
|
}
|
|
|