Backed out bug 709492 due to breakage with external urls. r=backout

This commit is contained in:
Patrick Walton 2011-12-30 18:47:06 -05:00
parent 6690bd6752
commit d075492ab2
9 changed files with 28 additions and 142 deletions

View File

@ -194,8 +194,6 @@ static const char sPrintOptionsContractID[] = "@mozilla.org/gfx/printset
//switch to page layout
#include "nsGfxCIID.h"
#include "nsObserverService.h"
#include "mozilla/dom/Element.h"
using namespace mozilla;
@ -511,18 +509,6 @@ public:
nsCOMPtr<nsIDocument> mTop;
};
class nsDocumentShownDispatcher : public nsRunnable
{
public:
nsDocumentShownDispatcher(nsIDocument *aDocument)
: mDocument(aDocument) {}
NS_IMETHOD Run();
private:
nsCOMPtr<nsIDocument> mDocument;
};
//------------------------------------------------------------------
// DocumentViewerImpl
@ -2053,10 +2039,6 @@ DocumentViewerImpl::Show(void)
}
}
// Notify observers that a new page has been shown. (But not right now;
// running JS at this time is not safe.)
NS_DispatchToMainThread(new nsDocumentShownDispatcher(mDocument));
return NS_OK;
}
@ -4389,17 +4371,3 @@ DocumentViewerImpl::SetPrintPreviewPresentation(nsIViewManager* aViewManager,
mPresContext = aPresContext;
mPresShell = aPresShell;
}
// Fires the "document-shown" event so that interested parties (right now, the
// mobile browser) are aware of it.
NS_IMETHODIMP
nsDocumentShownDispatcher::Run()
{
nsCOMPtr<nsIObserverService> observerService =
mozilla::services::GetObserverService();
if (observerService) {
observerService->NotifyObservers(mDocument, "document-shown", NULL);
}
return NS_OK;
}

View File

@ -615,11 +615,8 @@ abstract public class GeckoApp
if (mLastUri == lastHistoryEntry.mUri &&
mLastTitle == lastHistoryEntry.mTitle)
return;
ViewportMetrics viewportMetrics = mSoftwareLayerClient.getGeckoViewportMetrics();
if (viewportMetrics != null)
mLastViewport = viewportMetrics.toJSON();
mLastViewport = mSoftwareLayerClient.getGeckoViewportMetrics().toJSON();
mLastUri = lastHistoryEntry.mUri;
mLastTitle = lastHistoryEntry.mTitle;
Bitmap bitmap = mSoftwareLayerClient.getBitmap();

View File

@ -78,7 +78,6 @@ public class GeckoEvent {
public static final int ACTIVITY_START = 17;
public static final int BROADCAST = 19;
public static final int VIEWPORT = 20;
public static final int EXPOSE = 21;
public static final int IME_COMPOSITION_END = 0;
public static final int IME_COMPOSITION_BEGIN = 1;

View File

@ -140,8 +140,7 @@ public class GeckoSoftwareLayerClient extends LayerClient implements GeckoEventL
layerController.setViewportMetrics(mGeckoViewport);
}
GeckoAppShell.registerGeckoEventListener("Viewport:Expose", this);
GeckoAppShell.registerGeckoEventListener("Viewport:UpdateAndDraw", this);
GeckoAppShell.registerGeckoEventListener("Viewport:Update", this);
GeckoAppShell.registerGeckoEventListener("Viewport:UpdateLater", this);
}
@ -341,15 +340,19 @@ public class GeckoSoftwareLayerClient extends LayerClient implements GeckoEventL
}
public void handleMessage(String event, JSONObject message) {
if ("Viewport:Expose".equals(event)) {
GeckoAppShell.sendEventToGecko(new GeckoEvent(GeckoEvent.EXPOSE));
} else if ("Viewport:UpdateAndDraw".equals(event)) {
mUpdateViewportOnEndDraw = true;
// Redraw everything.
Rect rect = new Rect(0, 0, mBufferSize.width, mBufferSize.height);
GeckoAppShell.sendEventToGecko(new GeckoEvent(GeckoEvent.DRAW, rect));
if ("Viewport:Update".equals(event)) {
beginTransaction(mTileLayer);
try {
updateViewport(message.getString("viewport"), false);
} catch (JSONException e) {
Log.e(LOGTAG, "Unable to update viewport", e);
} finally {
endTransaction(mTileLayer);
}
} else if ("Viewport:UpdateLater".equals(event)) {
if (!mTileLayer.inTransaction()) {
Log.e(LOGTAG, "Viewport:UpdateLater called while not in transaction. You should be using Viewport:Update instead!");
}
mUpdateViewportOnEndDraw = true;
}
}

View File

@ -264,10 +264,7 @@ public class PanZoomController
// the screen orientation changed) so abort it and start a new one to
// ensure the viewport doesn't contain out-of-bounds areas
case NOTHING:
// Don't do animations here; they're distracting and can cause flashes on page
// transitions.
mController.setViewportMetrics(getValidViewportMetrics());
mController.notifyLayerClientOfGeometryChange();
bounce();
break;
}
}

View File

@ -155,16 +155,6 @@ var Strings = {};
});
});
var MetadataProvider = {
getDrawMetadata: function getDrawMetadata() {
return BrowserApp.getDrawMetadata();
},
drawingAllowed: function drawingAllowed() {
return !BrowserApp.selectedTab.suppressDrawing;
}
};
var BrowserApp = {
_tabs: [],
_selectedTab: null,
@ -179,7 +169,7 @@ var BrowserApp = {
BrowserEventHandler.init();
ViewportHandler.init();
getBridge().setDrawMetadataProvider(MetadataProvider);
getBridge().setDrawMetadataProvider(this.getDrawMetadata.bind(this));
Services.obs.addObserver(this, "Tab:Add", false);
Services.obs.addObserver(this, "Tab:Load", false);
@ -200,7 +190,6 @@ var BrowserApp = {
Services.obs.addObserver(this, "Viewport:Change", false);
Services.obs.addObserver(this, "AgentMode:Change", false);
Services.obs.addObserver(this, "SearchEngines:Get", false);
Services.obs.addObserver(this, "document-shown", false);
function showFullScreenWarning() {
NativeWindow.toast.show(Strings.browser.GetStringFromName("alertFullScreenToast"), "short");
@ -772,19 +761,6 @@ var BrowserApp = {
ViewportHandler.onResize();
} else if (aTopic == "SearchEngines:Get") {
this.getSearchEngines();
} else if (aTopic == "document-shown") {
let tab = BrowserApp.getTabForBrowser(BrowserApp.getBrowserForDocument(aSubject));
if (!tab)
return;
ViewportHandler.resetMetadata(tab);
// Unsuppress drawing unless the page was being thawed from the bfcache (which is an atomic
// operation, so there is no drawing to suppress).
if (tab.suppressDrawing) {
tab.sendExposeEvent();
tab.suppressDrawing = false;
}
}
},
@ -792,7 +768,7 @@ var BrowserApp = {
delete this.defaultBrowserWidth;
let width = Services.prefs.getIntPref("browser.viewport.desktopWidth");
return this.defaultBrowserWidth = width;
}
}
};
var NativeWindow = {
@ -1265,12 +1241,6 @@ Tab.prototype = {
this.browser.addEventListener("PluginClickToPlay", this, true);
this.browser.addEventListener("pagehide", this, true);
let chromeEventHandler = this.browser.contentWindow.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsIDocShell)
.chromeEventHandler;
chromeEventHandler.addEventListener("DOMWindowCreated", this, false);
Services.obs.addObserver(this, "http-on-modify-request", false);
if (!aParams.delayLoad) {
@ -1483,7 +1453,8 @@ Tab.prototype = {
return;
sendMessageToJava({
gecko: {
type: "Viewport:UpdateAndDraw"
type: "Viewport:Update",
viewport: JSON.stringify(this.viewport)
}
});
},
@ -1644,18 +1615,6 @@ Tab.prototype = {
}
break;
}
case "DOMWindowCreated": {
// Conveniently, this call to getBrowserForDocument() will return null if the document is
// not the top-level content document of the browser.
let browser = BrowserApp.getBrowserForDocument(aEvent.originalTarget);
if (!browser)
break;
let tab = BrowserApp.getTabForBrowser(browser);
tab.suppressDrawing = true;
break;
}
}
},
@ -1915,16 +1874,6 @@ Tab.prototype = {
}
},
sendExposeEvent: function() {
// Now that the document is actually on the screen, send an expose event.
this._timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
sendMessageToJava({
gecko: {
type: "Viewport:Expose"
}
});
},
QueryInterface: XPCOMUtils.generateQI([
Ci.nsIWebProgressListener,
Ci.nsISHistoryListener,

View File

@ -532,7 +532,6 @@ public:
ACTIVITY_START = 17,
BROADCAST = 19,
VIEWPORT = 20,
EXPOSE = 21,
dummy_java_enum_list_end
};

View File

@ -1,14 +1,8 @@
#include "nsISupports.idl"
[scriptable, uuid(c60bf6cf-5e31-4bf8-a1f0-a82c061d65a8)]
[scriptable, function, uuid(9feed1e5-bb90-4663-b70a-e03cb27a9e8b)]
interface nsIAndroidDrawMetadataProvider : nsISupports {
AString getDrawMetadata();
/*
* Returns true if drawing should be allowed or false if it should be suppressed (during page
* transitions).
*/
boolean drawingAllowed();
};
[scriptable, uuid(7dd8441a-4f38-49b2-bd90-da69d02a96cf)]

View File

@ -978,7 +978,6 @@ nsWindow::OnGlobalAndroidEvent(AndroidGeckoEvent *ae)
break;
case AndroidGeckoEvent::DRAW:
case AndroidGeckoEvent::EXPOSE:
win->OnDraw(ae);
break;
@ -1169,32 +1168,10 @@ nsWindow::OnDraw(AndroidGeckoEvent *ae)
if (gAndroidBounds.width <= 0 || gAndroidBounds.height <= 0)
return;
nsCOMPtr<nsIAndroidDrawMetadataProvider> metadataProvider =
AndroidBridge::Bridge()->GetDrawMetadataProvider();
/*
* If this is a DRAW event (not an EXPOSE event), check to see whether browser.js wants us to
* draw. This will be false during page transitions, in which case we immediately bail out.
*/
bool shouldDraw = true;
if (metadataProvider && ae->Type() == AndroidGeckoEvent::DRAW) {
metadataProvider->DrawingAllowed(&shouldDraw);
}
if (!shouldDraw) {
return;
}
AndroidGeckoSoftwareLayerClient &client =
AndroidBridge::Bridge()->GetSoftwareLayerClient();
client.BeginDrawing(gAndroidBounds.width, gAndroidBounds.height);
// Redraw the entire tile on an EXPOSE event. Otherwise (on a DRAW event), redraw only the
// portion specified by the event.
nsIntRect rect(0, 0, gAndroidBounds.width, gAndroidBounds.height);
if (ae->Type() == AndroidGeckoEvent::DRAW)
rect = ae->Rect();
nsAutoString metadata;
unsigned char *bits = NULL;
if (sHasDirectTexture) {
@ -1227,11 +1204,14 @@ nsWindow::OnDraw(AndroidGeckoEvent *ae)
// XXX: lock only the dirty rect above and pass it in here
DrawTo(targetSurface);
} else {
DrawTo(targetSurface, rect);
DrawTo(targetSurface, ae->Rect());
}
if (metadataProvider) {
metadataProvider->GetDrawMetadata(metadata);
{
nsCOMPtr<nsIAndroidDrawMetadataProvider> metadataProvider =
AndroidBridge::Bridge()->GetDrawMetadataProvider();
if (metadataProvider)
metadataProvider->GetDrawMetadata(metadata);
}
}
if (sHasDirectTexture) {
@ -1240,7 +1220,7 @@ nsWindow::OnDraw(AndroidGeckoEvent *ae)
client.UnlockBuffer();
}
}
client.EndDrawing(rect, metadata);
client.EndDrawing(ae->Rect(), metadata);
return;
#endif