Bug 1288834 - Remove ZOOMEDVIEW event from GeckoEvent; r=snorp

Remove the now-obsolete ZOOMEDVIEW event from GeckoEvent, and the
associated code in nsAppShell and AndroidBridge.
This commit is contained in:
Jim Chen 2016-08-04 09:15:17 -04:00
parent a0e70ac337
commit 580a7782fe
6 changed files with 1 additions and 142 deletions

View File

@ -75,8 +75,7 @@ public class GeckoEvent {
TELEMETRY_UI_EVENT(44),
GAMEPAD_ADDREMOVE(45),
GAMEPAD_DATA(46),
LONG_PRESS(47),
ZOOMEDVIEW(48);
LONG_PRESS(47);
public final int value;
@ -118,8 +117,6 @@ public class GeckoEvent {
private String mCharactersExtra;
private String mData;
private ByteBuffer mBuffer;
private int mWidth;
private int mHeight;
@ -332,17 +329,6 @@ public class GeckoEvent {
return event;
}
public static GeckoEvent createZoomedViewEvent(int tabId, int x, int y, int bufw, int bufh, float scaleFactor, ByteBuffer buffer) {
GeckoEvent event = GeckoEvent.get(NativeGeckoEvent.ZOOMEDVIEW);
event.mPoints = new Point[2];
event.mPoints[0] = new Point(x, y);
event.mPoints[1] = new Point(bufw, bufh);
event.mX = (double) scaleFactor;
event.mMetaState = tabId;
event.mBuffer = buffer;
return event;
}
public static GeckoEvent createCallObserverEvent(String observerKey, String topic, String data) {
GeckoEvent event = GeckoEvent.get(NativeGeckoEvent.CALL_OBSERVER);
event.mCharacters = observerKey;

View File

@ -1660,90 +1660,6 @@ AndroidBridge::GetFrameNameJavaProfiling(uint32_t aThreadId, uint32_t aSampleId,
return true;
}
static float
GetScaleFactor(nsPresContext* aPresContext) {
nsIPresShell* presShell = aPresContext->PresShell();
LayoutDeviceToLayerScale cumulativeResolution(presShell->GetCumulativeResolution());
return cumulativeResolution.scale;
}
nsresult
AndroidBridge::CaptureZoomedView(mozIDOMWindowProxy *window, nsIntRect zoomedViewRect, ByteBuffer::Param buffer,
float zoomFactor) {
nsresult rv;
if (!buffer)
return NS_ERROR_FAILURE;
nsCOMPtr <nsIDOMWindowUtils> utils = do_GetInterface(window);
if (!utils)
return NS_ERROR_FAILURE;
JNIEnv* const env = jni::GetGeckoThreadEnv();
AutoLocalJNIFrame jniFrame(env, 0);
if (!window) {
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsPIDOMWindowOuter> win = nsPIDOMWindowOuter::From(window);
RefPtr<nsPresContext> presContext;
nsIDocShell* docshell = win->GetDocShell();
if (docshell) {
docshell->GetPresContext(getter_AddRefs(presContext));
}
if (!presContext) {
return NS_ERROR_FAILURE;
}
nsCOMPtr <nsIPresShell> presShell = presContext->PresShell();
float scaleFactor = GetScaleFactor(presContext) ;
nscolor bgColor = NS_RGB(255, 255, 255);
uint32_t renderDocFlags = (nsIPresShell::RENDER_IGNORE_VIEWPORT_SCROLLING | nsIPresShell::RENDER_DOCUMENT_RELATIVE);
nsRect r(presContext->DevPixelsToAppUnits(zoomedViewRect.x / scaleFactor),
presContext->DevPixelsToAppUnits(zoomedViewRect.y / scaleFactor ),
presContext->DevPixelsToAppUnits(zoomedViewRect.width / scaleFactor ),
presContext->DevPixelsToAppUnits(zoomedViewRect.height / scaleFactor ));
bool is24bit = (GetScreenDepth() == 24);
SurfaceFormat format = is24bit ? SurfaceFormat::B8G8R8X8 : SurfaceFormat::R5G6B5_UINT16;
gfxImageFormat iFormat = gfx::SurfaceFormatToImageFormat(format);
uint32_t stride = gfxASurface::FormatStrideForWidth(iFormat, zoomedViewRect.width);
uint8_t* data = static_cast<uint8_t*>(buffer->Address());
if (!data) {
return NS_ERROR_FAILURE;
}
MOZ_ASSERT (gfxPlatform::GetPlatform()->SupportsAzureContentForType(BackendType::CAIRO),
"Need BackendType::CAIRO support");
RefPtr < DrawTarget > dt = Factory::CreateDrawTargetForData(
BackendType::CAIRO, data, IntSize(zoomedViewRect.width, zoomedViewRect.height), stride,
format);
if (!dt || !dt->IsValid()) {
ALOG_BRIDGE("Error creating DrawTarget");
return NS_ERROR_FAILURE;
}
RefPtr<gfxContext> context = gfxContext::CreateOrNull(dt);
MOZ_ASSERT(context); // already checked the draw target above
context->SetMatrix(context->CurrentMatrix().Scale(zoomFactor, zoomFactor));
rv = presShell->RenderDocument(r, renderDocFlags, bgColor, context);
if (is24bit) {
gfxUtils::ConvertBGRAtoRGBA(data, stride * zoomedViewRect.height);
}
LayerView::UpdateZoomedView(buffer);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
}
void
AndroidBridge::GetDisplayPort(bool aPageSizeUpdate, bool aIsBrowserContentDisplayed, int32_t tabId, nsIAndroidViewport* metrics, nsIAndroidDisplayport** displayPort)
{

View File

@ -147,7 +147,6 @@ public:
bool GetThreadNameJavaProfiling(uint32_t aThreadId, nsCString & aResult);
bool GetFrameNameJavaProfiling(uint32_t aThreadId, uint32_t aSampleId, uint32_t aFrameId, nsCString & aResult);
nsresult CaptureZoomedView(mozIDOMWindowProxy *window, nsIntRect zoomedViewRect, jni::ByteBuffer::Param buffer, float zoomFactor);
void GetDisplayPort(bool aPageSizeUpdate, bool aIsBrowserContentDisplayed, int32_t tabId, nsIAndroidViewport* metrics, nsIAndroidDisplayport** displayPort);
void ContentDocumentChanged();
bool IsContentDocumentDisplayed();

View File

@ -39,7 +39,6 @@ jfieldID AndroidGeckoEvent::jMetaStateField = 0;
jfieldID AndroidGeckoEvent::jFlagsField = 0;
jfieldID AndroidGeckoEvent::jCountField = 0;
jfieldID AndroidGeckoEvent::jPointerIndexField = 0;
jfieldID AndroidGeckoEvent::jByteBufferField = 0;
jfieldID AndroidGeckoEvent::jWidthField = 0;
jfieldID AndroidGeckoEvent::jHeightField = 0;
jfieldID AndroidGeckoEvent::jIDField = 0;
@ -107,7 +106,6 @@ AndroidGeckoEvent::InitGeckoEventClass(JNIEnv *jEnv)
jFlagsField = geckoEvent.getField("mFlags", "I");
jCountField = geckoEvent.getField("mCount", "I");
jPointerIndexField = geckoEvent.getField("mPointerIndex", "I");
jByteBufferField = geckoEvent.getField("mBuffer", "Ljava/nio/ByteBuffer;");
jWidthField = geckoEvent.getField("mWidth", "I");
jHeightField = geckoEvent.getField("mHeight", "I");
jIDField = geckoEvent.getField("mID", "I");
@ -310,14 +308,6 @@ AndroidGeckoEvent::Init(JNIEnv *jenv, jobject jobj)
break;
}
case ZOOMEDVIEW: {
mX = jenv->GetDoubleField(jobj, jXField);
mMetaState = jenv->GetIntField(jobj, jMetaStateField);
ReadPointArray(mPoints, jenv, jPoints, 2);
mByteBuffer = new RefCountedJavaObject(jenv, jenv->GetObjectField(jobj, jByteBufferField));
break;
}
case CALL_OBSERVER: {
ReadCharactersField(jenv);
ReadCharactersExtraField(jenv);

View File

@ -473,7 +473,6 @@ public:
int Flags() { return mFlags; }
int Count() { return mCount; }
int PointerIndex() { return mPointerIndex; }
RefCountedJavaObject* ByteBuffer() { return mByteBuffer; }
int Width() { return mWidth; }
int Height() { return mHeight; }
int ID() { return mID; }
@ -508,7 +507,6 @@ protected:
double mX, mY, mZ, mW;
int mPointerIndex;
nsString mCharacters, mCharactersExtra, mData;
RefPtr<RefCountedJavaObject> mByteBuffer;
int mWidth, mHeight;
int mID;
int mGamepadButton;
@ -567,8 +565,6 @@ protected:
static jfieldID jCountField;
static jfieldID jPointerIndexField;
static jfieldID jByteBufferField;
static jfieldID jWidthField;
static jfieldID jHeightField;
@ -595,7 +591,6 @@ public:
GAMEPAD_ADDREMOVE = 45,
GAMEPAD_DATA = 46,
LONG_PRESS = 47,
ZOOMEDVIEW = 48,
dummy_java_enum_list_end
};

View File

@ -656,33 +656,6 @@ nsAppShell::LegacyGeckoEvent::Run()
EVLOG("nsAppShell: event %p %d", (void*)curEvent.get(), curEvent->Type());
switch (curEvent->Type()) {
case AndroidGeckoEvent::ZOOMEDVIEW: {
if (!nsAppShell::Get()->mBrowserApp)
break;
int32_t tabId = curEvent->MetaState();
const nsTArray<nsIntPoint>& points = curEvent->Points();
float scaleFactor = (float) curEvent->X();
RefPtr<RefCountedJavaObject> javaBuffer = curEvent->ByteBuffer();
const auto& mBuffer = jni::ByteBuffer::Ref::From(javaBuffer->GetObject());
nsCOMPtr<mozIDOMWindowProxy> domWindow;
nsCOMPtr<nsIBrowserTab> tab;
nsAppShell::Get()->mBrowserApp->GetBrowserTab(tabId, getter_AddRefs(tab));
if (!tab) {
NS_ERROR("Can't find tab!");
break;
}
tab->GetWindow(getter_AddRefs(domWindow));
if (!domWindow) {
NS_ERROR("Can't find dom window!");
break;
}
NS_ASSERTION(points.Length() == 2, "ZoomedView event does not have enough coordinates");
nsIntRect r(points[0].x, points[0].y, points[1].x, points[1].y);
AndroidBridge::Bridge()->CaptureZoomedView(domWindow, r, mBuffer, scaleFactor);
break;
}
case AndroidGeckoEvent::VIEWPORT: {
if (curEvent->Characters().Length() == 0)
break;