merge fx-team to mozilla-central

This commit is contained in:
Carsten "Tomcat" Book 2013-12-20 10:22:29 +01:00
Родитель 3fa148f89a 185ff9cb48
Коммит 76b3c9c6c0
11 изменённых файлов: 272 добавлений и 59 удалений

Просмотреть файл

@ -82,6 +82,18 @@ interface nsIMarkupDocumentViewer : nsISupports
*/
void changeMaxLineBoxWidth(in int32_t maxLineBoxWidth);
/**
* Instruct the refresh driver to discontinue painting until further
* notice.
*/
void pausePainting();
/**
* Instruct the refresh driver to resume painting after a previous call to
* pausePainting().
*/
void resumePainting();
/*
* Render the document as if being viewed on a device with the specified
* media type. This will cause a reflow.

Просмотреть файл

@ -1053,6 +1053,9 @@ xpc::CreateSandboxObject(JSContext *cx, MutableHandleValue vp, nsISupports *prin
compartmentOptions.setSameZoneAs(js::UncheckedUnwrap(options.sameZoneAs));
else
compartmentOptions.setZone(JS::SystemZone);
compartmentOptions.setInvisibleToDebugger(options.invisibleToDebugger);
RootedObject sandbox(cx, xpc::CreateGlobalObject(cx, &SandboxClass,
principal, compartmentOptions));
if (!sandbox)
@ -1486,6 +1489,7 @@ SandboxOptions::Parse()
ParseBoolean("wantExportHelpers", &wantExportHelpers) &&
ParseString("sandboxName", sandboxName) &&
ParseObject("sameZoneAs", &sameZoneAs) &&
ParseBoolean("invisibleToDebugger", &invisibleToDebugger) &&
ParseGlobalProperties() &&
ParseValue("metadata", &metadata);
}

Просмотреть файл

@ -3432,6 +3432,7 @@ public:
, wantExportHelpers(false)
, proto(cx)
, sameZoneAs(cx)
, invisibleToDebugger(false)
, metadata(cx)
{ }
@ -3443,6 +3444,7 @@ public:
JS::RootedObject proto;
nsCString sandboxName;
JS::RootedObject sameZoneAs;
bool invisibleToDebugger;
GlobalProperties globalProperties;
JS::RootedValue metadata;

Просмотреть файл

@ -150,5 +150,26 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=533596
catch (e) {
ok(false, "sameZoneAs works");
}
Cu.import("resource://gre/modules/jsdebugger.jsm");
addDebuggerToGlobal(this);
try {
let dbg = new Debugger();
let sandbox = new Cu.Sandbox(this, { invisibleToDebugger: false });
dbg.addDebuggee(sandbox);
ok(true, "debugger added visible value");
} catch(e) {
ok(false, "debugger could not add visible value");
}
try {
let dbg = new Debugger();
let sandbox = new Cu.Sandbox(this, { invisibleToDebugger: true });
dbg.addDebuggee(sandbox);
ok(false, "debugger added invisible value");
} catch(e) {
ok(true, "debugger did not add invisible value");
}
]]></script>
</window>

Просмотреть файл

@ -2700,6 +2700,17 @@ struct LineBoxInfo
nscoord mMaxLineBoxWidth;
};
static void
ChangeChildPaintingEnabled(nsIMarkupDocumentViewer* aChild, void* aClosure)
{
bool* enablePainting = (bool*) aClosure;
if (*enablePainting) {
aChild->ResumePainting();
} else {
aChild->PausePainting();
}
}
static void
ChangeChildMaxLineBoxWidth(nsIMarkupDocumentViewer* aChild, void* aClosure)
{
@ -3126,7 +3137,36 @@ NS_IMETHODIMP nsDocumentViewer::AppendSubtree(nsTArray<nsCOMPtr<nsIMarkupDocumen
return NS_OK;
}
NS_IMETHODIMP nsDocumentViewer::ChangeMaxLineBoxWidth(int32_t aMaxLineBoxWidth)
NS_IMETHODIMP
nsDocumentViewer::PausePainting()
{
bool enablePaint = false;
CallChildren(ChangeChildPaintingEnabled, &enablePaint);
nsIPresShell* presShell = GetPresShell();
if (presShell) {
presShell->PausePainting();
}
return NS_OK;
}
NS_IMETHODIMP
nsDocumentViewer::ResumePainting()
{
bool enablePaint = true;
CallChildren(ChangeChildPaintingEnabled, &enablePaint);
nsIPresShell* presShell = GetPresShell();
if (presShell) {
presShell->ResumePainting();
}
return NS_OK;
}
NS_IMETHODIMP
nsDocumentViewer::ChangeMaxLineBoxWidth(int32_t aMaxLineBoxWidth)
{
// Change the max line box width for all children.
struct LineBoxInfo lbi = { aMaxLineBoxWidth };

Просмотреть файл

@ -129,10 +129,10 @@ typedef struct CapturingContentInfo {
} CapturingContentInfo;
// f5b542a9-eaf0-4560-a656-37a9d379864c
// 0e4f2b36-7ab8-43c5-b912-5c311566297c
#define NS_IPRESSHELL_IID \
{ 0xf5b542a9, 0xeaf0, 0x4560, \
{ 0x37, 0xa9, 0xd3, 0x79, 0x86, 0x4c } }
{ 0xde498c49, 0xf83f, 0x47bf, \
{0x8c, 0xc6, 0x8f, 0xf8, 0x74, 0x62, 0x22, 0x23 } }
// debug VerifyReflow flags
#define VERIFY_REFLOW_ON 0x01
@ -836,6 +836,20 @@ public:
*/
bool IsPaintingSuppressed() const { return mPaintingSuppressed; }
/**
* Pause painting by freezing the refresh driver of this and all parent
* presentations. This may not have the desired effect if this pres shell
* has its own refresh driver.
*/
virtual void PausePainting() = 0;
/**
* Resume painting by thawing the refresh driver of this and all parent
* presentations. This may not have the desired effect if this pres shell
* has its own refresh driver.
*/
virtual void ResumePainting() = 0;
/**
* Unsuppress painting.
*/
@ -1601,6 +1615,7 @@ protected:
bool mFontSizeInflationForceEnabled;
bool mFontSizeInflationDisabledInMasterProcess;
bool mFontSizeInflationEnabled;
bool mPaintingIsFrozen;
// Dirty bit indicating that mFontSizeInflationEnabled needs to be recomputed.
bool mFontSizeInflationEnabledIsDirty;

Просмотреть файл

@ -724,6 +724,8 @@ PresShell::PresShell()
"layout.reflow.synthMouseMove", true);
addedSynthMouseMove = true;
}
mPaintingIsFrozen = false;
}
NS_IMPL_ISUPPORTS7(PresShell, nsIPresShell, nsIDocumentObserver,
@ -744,6 +746,13 @@ PresShell::~PresShell()
mLastCallbackEventRequest == nullptr,
"post-reflow queues not empty. This means we're leaking");
// Verify that if painting was frozen, but we're being removed from the tree,
// that we now re-enable painting on our refresh driver, since it may need to
// be re-used by another presentation.
if (mPaintingIsFrozen) {
mPresContext->RefreshDriver()->Thaw();
}
#ifdef DEBUG
MOZ_ASSERT(mPresArenaAllocCount == 0,
"Some pres arena objects were not freed");
@ -9931,3 +9940,23 @@ nsIPresShell::SetMaxLineBoxWidth(nscoord aMaxLineBoxWidth)
FrameNeedsReflow(GetRootFrame(), eResize, NS_FRAME_HAS_DIRTY_CHILDREN);
}
}
void
PresShell::PausePainting()
{
if (GetPresContext()->RefreshDriver()->PresContext() != GetPresContext())
return;
mPaintingIsFrozen = true;
GetPresContext()->RefreshDriver()->Freeze();
}
void
PresShell::ResumePainting()
{
if (GetPresContext()->RefreshDriver()->PresContext() != GetPresContext())
return;
mPaintingIsFrozen = false;
GetPresContext()->RefreshDriver()->Thaw();
}

Просмотреть файл

@ -689,6 +689,9 @@ protected:
virtual void ThemeChanged() MOZ_OVERRIDE { mPresContext->ThemeChanged(); }
virtual void BackingScaleFactorChanged() MOZ_OVERRIDE { mPresContext->UIResolutionChanged(); }
virtual void PausePainting() MOZ_OVERRIDE;
virtual void ResumePainting() MOZ_OVERRIDE;
void UpdateImageVisibility();
nsRevocableEventPtr<nsRunnableMethod<PresShell> > mUpdateImageVisibilityEvent;

Просмотреть файл

@ -245,12 +245,16 @@ class JavaPanZoomController
final RectF zoomRect = new RectF(x, y,
x + (float)message.getDouble("w"),
y + (float)message.getDouble("h"));
mTarget.post(new Runnable() {
@Override
public void run() {
animatedZoomTo(zoomRect);
}
});
if (message.optBoolean("animate", true)) {
mTarget.post(new Runnable() {
@Override
public void run() {
animatedZoomTo(zoomRect);
}
});
} else {
mTarget.setViewportMetrics(getMetricsToZoomTo(zoomRect));
}
} else if (MESSAGE_ZOOM_PAGE.equals(event)) {
ImmutableViewportMetrics metrics = getMetrics();
RectF cssPageRect = metrics.getCssPageRect();
@ -264,12 +268,16 @@ class JavaPanZoomController
y + dh/2,
cssPageRect.width(),
y + dh/2 + newHeight);
mTarget.post(new Runnable() {
@Override
public void run() {
animatedZoomTo(r);
}
});
if (message.optBoolean("animate", true)) {
mTarget.post(new Runnable() {
@Override
public void run() {
animatedZoomTo(r);
}
});
} else {
mTarget.setViewportMetrics(getMetricsToZoomTo(r));
}
} else if (MESSAGE_TOUCH_LISTENER.equals(event)) {
int tabId = message.getInt("tabID");
final Tab tab = Tabs.getInstance().getTab(tabId);
@ -1399,7 +1407,7 @@ class JavaPanZoomController
* While we usually use device pixels, @zoomToRect must be specified in CSS
* pixels.
*/
private boolean animatedZoomTo(RectF zoomToRect) {
private ImmutableViewportMetrics getMetricsToZoomTo(RectF zoomToRect) {
final float startZoom = getMetrics().zoomFactor;
RectF viewport = getMetrics().getViewport();
@ -1434,8 +1442,11 @@ class JavaPanZoomController
// 2. now run getValidViewportMetrics on it, so that the target viewport is
// clamped down to prevent overscroll, over-zoom, and other bad conditions.
finalMetrics = getValidViewportMetrics(finalMetrics);
return finalMetrics;
}
bounce(finalMetrics, PanZoomState.ANIMATED_ZOOM);
private boolean animatedZoomTo(RectF zoomToRect) {
bounce(getMetricsToZoomTo(zoomToRect), PanZoomState.ANIMATED_ZOOM);
return true;
}

Просмотреть файл

@ -15,6 +15,8 @@ import org.mozilla.gecko.tests.UITestContext.ComponentType;
import com.jayway.android.robotium.solo.Condition;
import com.jayway.android.robotium.solo.Solo;
import java.util.regex.Pattern;
/**
* Provides functionality related to waiting on certain events to happen.
*/
@ -131,7 +133,7 @@ public final class WaitHelper {
ToolbarTitleTextChangeVerifier.class.getSimpleName() + ": ";
// A regex that matches the page title that shows up while the page is loading.
private static final String LOADING_REGEX = "^[A-Za-z]{3,9}://";
private static final Pattern LOADING_PREFIX = Pattern.compile("[A-Za-z]{3,9}://");
private CharSequence mOldTitleText;
@ -157,7 +159,7 @@ public final class WaitHelper {
// (e.g. the page title). However, the title is set to the URL before the title is
// loaded from the server and set as the final page title; we ignore the
// intermediate URL loading state here.
final boolean isLoading = title.toString().matches(LOADING_REGEX);
final boolean isLoading = LOADING_PREFIX.matcher(title).lookingAt();
final boolean hasStateChanged = !isLoading && !mOldTitleText.equals(title);
if (hasStateChanged) {

Просмотреть файл

@ -178,10 +178,20 @@ function doChangeMaxLineBoxWidth(aWidth) {
range = BrowserApp.selectedTab._mReflozPoint.range;
}
docViewer.changeMaxLineBoxWidth(aWidth);
try {
docViewer.pausePainting();
docViewer.changeMaxLineBoxWidth(aWidth);
if (range) {
BrowserEventHandler._zoomInAndSnapToRange(range);
if (range) {
BrowserEventHandler._zoomInAndSnapToRange(range);
} else {
// In this case, we actually didn't zoom into a specific range. It
// probably happened from a page load reflow-on-zoom event, so we
// need to make sure painting is re-enabled.
BrowserApp.selectedTab.clearReflowOnZoomPendingActions();
}
} finally {
docViewer.resumePainting();
}
}
@ -2744,6 +2754,7 @@ Tab.prototype = {
this.browser.addEventListener("MozApplicationManifest", this, true);
Services.obs.addObserver(this, "before-first-paint", false);
Services.obs.addObserver(this, "after-viewport-change", false);
Services.prefs.addObserver("browser.ui.zoom.force-user-scalable", this, false);
if (aParams.delayLoad) {
@ -2803,21 +2814,58 @@ Tab.prototype = {
return minFontSize / this.getInflatedFontSizeFor(aElement);
},
clearReflowOnZoomPendingActions: function() {
// Reflow was completed, so now re-enable painting.
let webNav = BrowserApp.selectedTab.window.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebNavigation);
let docShell = webNav.QueryInterface(Ci.nsIDocShell);
let docViewer = docShell.contentViewer.QueryInterface(Ci.nsIMarkupDocumentViewer);
docViewer.resumePainting();
BrowserApp.selectedTab._mReflozPositioned = false;
},
/**
* Reflow on zoom consists of a few different sub-operations:
*
* 1. When a double-tap event is seen, we verify that the correct preferences
* are enabled and perform the pre-position handling calculation. We also
* signal that reflow-on-zoom should be performed at this time, and pause
* painting.
* 2. During the next call to setViewport(), which is in the Tab prototype,
* we detect that a call to changeMaxLineBoxWidth should be performed. If
* we're zooming out, then the max line box width should be reset at this
* time. Otherwise, we call performReflowOnZoom.
* 2a. PerformReflowOnZoom() and resetMaxLineBoxWidth() schedule a call to
* doChangeMaxLineBoxWidth, based on a timeout specified in preferences.
* 3. doChangeMaxLineBoxWidth changes the line box width (which also
* schedules a reflow event), and then calls _zoomInAndSnapToRange.
* 4. _zoomInAndSnapToRange performs the positioning of reflow-on-zoom and
* then re-enables painting.
*
* Some of the events happen synchronously, while others happen asynchronously.
* The following is a rough sketch of the progression of events:
*
* double tap event seen -> onDoubleTap() -> ... asynchronous ...
* -> setViewport() -> performReflowOnZoom() -> ... asynchronous ...
* -> doChangeMaxLineBoxWidth() -> _zoomInAndSnapToRange()
* -> ... asynchronous ... -> setViewport() -> Observe('after-viewport-change')
* -> resumePainting()
*/
performReflowOnZoom: function(aViewport) {
let zoom = this._drawZoom ? this._drawZoom : aViewport.zoom;
let zoom = this._drawZoom ? this._drawZoom : aViewport.zoom;
let viewportWidth = gScreenWidth / zoom;
let reflozTimeout = Services.prefs.getIntPref("browser.zoom.reflowZoom.reflowTimeout");
let viewportWidth = gScreenWidth / zoom;
let reflozTimeout = Services.prefs.getIntPref("browser.zoom.reflowZoom.reflowTimeout");
if (gReflowPending) {
clearTimeout(gReflowPending);
}
if (gReflowPending) {
clearTimeout(gReflowPending);
}
// We add in a bit of fudge just so that the end characters
// don't accidentally get clipped. 15px is an arbitrary choice.
gReflowPending = setTimeout(doChangeMaxLineBoxWidth,
reflozTimeout,
viewportWidth - 15);
// We add in a bit of fudge just so that the end characters
// don't accidentally get clipped. 15px is an arbitrary choice.
gReflowPending = setTimeout(doChangeMaxLineBoxWidth,
reflozTimeout,
viewportWidth - 15);
},
/**
@ -2889,6 +2937,7 @@ Tab.prototype = {
this.browser.removeEventListener("MozApplicationManifest", this, true);
Services.obs.removeObserver(this, "before-first-paint");
Services.obs.removeObserver(this, "after-viewport-change");
Services.prefs.removeObserver("browser.ui.zoom.force-user-scalable", this);
// Make sure the previously selected panel remains selected. The selected panel of a deck is
@ -3175,13 +3224,21 @@ Tab.prototype = {
// In this case, the user pinch-zoomed in, so we don't want to
// preserve position as we would with reflow-on-zoom.
BrowserApp.selectedTab.probablyNeedRefloz = false;
BrowserApp.selectedTab.clearReflowOnZoomPendingActions();
BrowserApp.selectedTab._mReflozPoint = null;
}
let docViewer = null;
if (isZooming &&
BrowserEventHandler.mReflozPref &&
BrowserApp.selectedTab._mReflozPoint &&
BrowserApp.selectedTab.probablyNeedRefloz) {
let webNav = BrowserApp.selectedTab.window.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebNavigation);
let docShell = webNav.QueryInterface(Ci.nsIDocShell);
docViewer = docShell.contentViewer.QueryInterface(Ci.nsIMarkupDocumentViewer);
docViewer.pausePainting();
BrowserApp.selectedTab.performReflowOnZoom(aViewport);
BrowserApp.selectedTab.probablyNeedRefloz = false;
}
@ -3210,6 +3267,9 @@ Tab.prototype = {
aViewport.fixedMarginLeft / aViewport.zoom);
Services.obs.notifyObservers(null, "after-viewport-change", "");
if (docViewer) {
docViewer.resumePainting();
}
},
setResolution: function(aZoom, aForce) {
@ -4166,6 +4226,11 @@ Tab.prototype = {
BrowserApp.selectedTab.performReflowOnZoom(vp);
}
break;
case "after-viewport-change":
if (BrowserApp.selectedTab._mReflozPositioned) {
BrowserApp.selectedTab.clearReflowOnZoomPendingActions();
}
break;
case "nsPref:changed":
if (aData == "browser.ui.zoom.force-user-scalable")
ViewportHandler.updateMetadata(this, false);
@ -4484,13 +4549,23 @@ var BrowserEventHandler = {
if (BrowserEventHandler.mReflozPref &&
!BrowserApp.selectedTab._mReflozPoint &&
!this._shouldSuppressReflowOnZoom(element)) {
let data = JSON.parse(aData);
let zoomPointX = data.x;
let zoomPointY = data.y;
BrowserApp.selectedTab._mReflozPoint = { x: zoomPointX, y: zoomPointY,
range: BrowserApp.selectedBrowser.contentDocument.caretPositionFromPoint(zoomPointX, zoomPointY) };
BrowserApp.selectedTab.probablyNeedRefloz = true;
// See comment above performReflowOnZoom() for a detailed description of
// the events happening in the reflow-on-zoom operation.
let data = JSON.parse(aData);
let zoomPointX = data.x;
let zoomPointY = data.y;
BrowserApp.selectedTab._mReflozPoint = { x: zoomPointX, y: zoomPointY,
range: BrowserApp.selectedBrowser.contentDocument.caretPositionFromPoint(zoomPointX, zoomPointY) };
// Before we perform a reflow on zoom, let's disable painting.
let webNav = BrowserApp.selectedTab.window.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebNavigation);
let docShell = webNav.QueryInterface(Ci.nsIDocShell);
let docViewer = docShell.contentViewer.QueryInterface(Ci.nsIMarkupDocumentViewer);
docViewer.pausePainting();
BrowserApp.selectedTab.probablyNeedRefloz = true;
}
if (!element) {
@ -4590,11 +4665,7 @@ var BrowserEventHandler = {
},
_zoomInAndSnapToRange: function(aRange) {
if (!aRange) {
Cu.reportError("aRange is null in zoomInAndSnapToRange. Unable to maintain position.");
return;
}
// aRange is always non-null here, since a check happened previously.
let viewport = BrowserApp.selectedTab.getViewport();
let fudge = 15; // Add a bit of fudge.
let boundingElement = aRange.offsetNode;
@ -4617,30 +4688,33 @@ var BrowserEventHandler = {
let leftAdjustment = parseInt(boundingStyle.paddingLeft) +
parseInt(boundingStyle.borderLeftWidth);
BrowserApp.selectedTab._mReflozPositioned = true;
rect.type = "Browser:ZoomToRect";
rect.x = Math.max(viewport.cssPageLeft, rect.x - fudge + leftAdjustment);
rect.y = Math.max(topPos, viewport.cssPageTop);
rect.w = viewport.cssWidth;
rect.h = viewport.cssHeight;
rect.animate = false;
sendMessageToJava(rect);
BrowserApp.selectedTab._mReflozPoint = null;
},
},
onPinchFinish: function(aData) {
let data = {};
try {
data = JSON.parse(aData);
} catch(ex) {
console.log(ex);
return;
}
onPinchFinish: function(aData) {
let data = {};
try {
data = JSON.parse(aData);
} catch(ex) {
console.log(ex);
return;
}
if (BrowserEventHandler.mReflozPref &&
data.zoomDelta < 0.0) {
BrowserEventHandler.resetMaxLineBoxWidth();
}
},
if (BrowserEventHandler.mReflozPref &&
data.zoomDelta < 0.0) {
BrowserEventHandler.resetMaxLineBoxWidth();
}
},
_shouldZoomToElement: function(aElement) {
let win = aElement.ownerDocument.defaultView;