Backed out 6 changesets (bug 1439875) for failing mochitest clipboard at browser/components/customizableui/test/browser_editcontrols_update.js and mochitest headless at dom/events/test/pointerevents/test_bug1414336.html on a CLOSED TREE

Backed out changeset f21bdb9b67e8 (bug 1439875)
Backed out changeset bd81fafecd95 (bug 1439875)
Backed out changeset 3296aef96276 (bug 1439875)
Backed out changeset a1237d0711a2 (bug 1439875)
Backed out changeset fc25cbe8e22e (bug 1439875)
Backed out changeset 25e681a47121 (bug 1439875)
This commit is contained in:
Andreea Pavel 2018-03-13 18:37:16 +02:00
Родитель b68dfdbc2d
Коммит e74f76b184
11 изменённых файлов: 140 добавлений и 165 удалений

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

@ -1194,10 +1194,7 @@ function RedirectLoad({ target: browser, data }) {
} }
if (document.documentElement.getAttribute("windowtype") == "navigator:browser") { if (document.documentElement.getAttribute("windowtype") == "navigator:browser") {
document.addEventListener("MozBeforeInitialXULLayout", function() { addEventListener("DOMContentLoaded", function() {
gBrowserInit.onBeforeInitialXULLayout();
}, { once: true });
document.addEventListener("DOMContentLoaded", function() {
gBrowserInit.onDOMContentLoaded(); gBrowserInit.onDOMContentLoaded();
}, { once: true }); }, { once: true });
} }
@ -1210,27 +1207,6 @@ var delayedStartupPromise = new Promise(resolve => {
var gBrowserInit = { var gBrowserInit = {
delayedStartupFinished: false, delayedStartupFinished: false,
onBeforeInitialXULLayout() {
// Set a sane starting width/height for all resolutions on new profiles.
if (Services.prefs.getBoolPref("privacy.resistFingerprinting")) {
// When the fingerprinting resistance is enabled, making sure that we don't
// have a maximum window to interfere with generating rounded window dimensions.
document.documentElement.setAttribute("sizemode", "normal");
} else if (!document.documentElement.hasAttribute("width")) {
const TARGET_WIDTH = 1280;
const TARGET_HEIGHT = 1040;
let width = Math.min(screen.availWidth * .9, TARGET_WIDTH);
let height = Math.min(screen.availHeight * .9, TARGET_HEIGHT);
document.documentElement.setAttribute("width", width);
document.documentElement.setAttribute("height", height);
if (width < TARGET_WIDTH && height < TARGET_HEIGHT) {
document.documentElement.setAttribute("sizemode", "maximized");
}
}
},
onDOMContentLoaded() { onDOMContentLoaded() {
window.QueryInterface(Ci.nsIInterfaceRequestor) window.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(nsIWebNavigation) .getInterface(nsIWebNavigation)
@ -1270,6 +1246,25 @@ var gBrowserInit = {
initBrowser.removeAttribute("blank"); initBrowser.removeAttribute("blank");
} }
// Set a sane starting width/height for all resolutions on new profiles.
if (Services.prefs.getBoolPref("privacy.resistFingerprinting")) {
// When the fingerprinting resistance is enabled, making sure that we don't
// have a maximum window to interfere with generating rounded window dimensions.
document.documentElement.setAttribute("sizemode", "normal");
} else if (!document.documentElement.hasAttribute("width")) {
const TARGET_WIDTH = 1280;
const TARGET_HEIGHT = 1040;
let width = Math.min(screen.availWidth * .9, TARGET_WIDTH);
let height = Math.min(screen.availHeight * .9, TARGET_HEIGHT);
document.documentElement.setAttribute("width", width);
document.documentElement.setAttribute("height", height);
if (width < TARGET_WIDTH && height < TARGET_HEIGHT) {
document.documentElement.setAttribute("sizemode", "maximized");
}
}
gBrowser.updateBrowserRemoteness(initBrowser, isRemote, { gBrowser.updateBrowserRemoteness(initBrowser, isRemote, {
remoteType, sameProcessAsFrameLoader remoteType, sameProcessAsFrameLoader
}); });

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

@ -22,16 +22,16 @@ add_task(async function() {
let frame = frames[i], previousFrame = frames[i - 1]; let frame = frames[i], previousFrame = frames[i - 1];
let rects = compareFrames(frame, previousFrame); let rects = compareFrames(frame, previousFrame);
// The first screenshot we get in OSX / Windows shows an unfocused browser // The first screenshot we get shows an unfocused browser window for some
// window for some reason. See bug 1445161. // reason. This is likely due to the test harness, so we want to ignore it.
//
// We'll assume the changes we are seeing are due to this focus change if // We'll assume the changes we are seeing are due to this focus change if
// there are at least 5 areas that changed near the top of the screen, but // there are at least 5 areas that changed near the top of the screen, but
// will only ignore this once (hence the alreadyFocused variable). // will only ignore this once (hence the alreadyFocused variable).
if (!alreadyFocused && rects.length > 5 && rects.every(r => r.y2 < 100)) { if (!alreadyFocused && rects.length > 5 && rects.every(r => r.y2 < 100)) {
alreadyFocused = true; alreadyFocused = true;
// This is likely an issue caused by the test harness, but log it anyway.
todo(false, todo(false,
"bug 1445161 - the window should be focused at first paint, " + rects.toSource()); "the window should be focused at first paint, " + rects.toSource());
continue; continue;
} }

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

@ -61,7 +61,6 @@ const whitelist = [
{ {
file: "chrome://browser/skin/chevron.svg", file: "chrome://browser/skin/chevron.svg",
platforms: ["win", "linux", "macosx"], platforms: ["win", "linux", "macosx"],
intermittentShown: ["win"],
}, },
{ {

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

@ -71,25 +71,17 @@ add_task(async function() {
win.removeEventListener("MozAfterPaint", afterPaintListener); win.removeEventListener("MozAfterPaint", afterPaintListener);
let unexpectedRects = 0; let unexpectedRects = 0;
let alreadyFocused = false; let ignoreTinyPaint = true;
for (let i = 1; i < frames.length; ++i) { for (let i = 1; i < frames.length; ++i) {
let frame = frames[i], previousFrame = frames[i - 1]; let frame = frames[i], previousFrame = frames[i - 1];
let rects = compareFrames(frame, previousFrame); if (ignoreTinyPaint &&
previousFrame.width == 1 && previousFrame.height == 1) {
// The first screenshot we get in OSX / Windows shows an unfocused browser todo(false, "shouldn't initially paint a 1x1px window");
// window for some reason. See bug 1445161.
//
// We'll assume the changes we are seeing are due to this focus change if
// there are at least 5 areas that changed near the top of the screen, but
// will only ignore this once (hence the alreadyFocused variable).
if (!alreadyFocused && rects.length > 5 && rects.every(r => r.y2 < 100)) {
alreadyFocused = true;
todo(false,
"bug 1445161 - the window should be focused at first paint, " + rects.toSource());
continue; continue;
} }
rects = rects.filter(rect => { ignoreTinyPaint = false;
let rects = compareFrames(frame, previousFrame).filter(rect => {
let inRange = (val, min, max) => min <= val && val <= max; let inRange = (val, min, max) => min <= val && val <= max;
let width = frame.width; let width = frame.width;

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

@ -62,8 +62,12 @@ add_task(async function() {
let win = OpenBrowserWindow(); let win = OpenBrowserWindow();
await withReflowObserver(async function() { await withReflowObserver(async function() {
await TestUtils.topicObserved("browser-delayed-startup-finished", let resizeEvent = BrowserTestUtils.waitForEvent(win, "resize");
subject => subject == win); let delayedStartup =
TestUtils.topicObserved("browser-delayed-startup-finished",
subject => subject == win);
await resizeEvent;
await delayedStartup;
}, EXPECTED_REFLOWS, win); }, EXPECTED_REFLOWS, win);
await BrowserTestUtils.closeWindow(win); await BrowserTestUtils.closeWindow(win);

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

@ -180,10 +180,14 @@ this.windows = class extends ExtensionAPI {
return new Promise(resolve => { return new Promise(resolve => {
window.addEventListener("load", function() { window.addEventListener("load", function() {
if (["maximized", "normal"].includes(createData.state)) {
window.document.documentElement.setAttribute("sizemode", createData.state);
}
resolve(promiseObserved("browser-delayed-startup-finished", win => win == window)); resolve(promiseObserved("browser-delayed-startup-finished", win => win == window));
}, {once: true}); }, {once: true});
}).then(() => { }).then(() => {
if (["minimized", "fullscreen", "docked", "normal", "maximized"].includes(createData.state)) { // Some states only work after delayed-startup-finished
if (["minimized", "fullscreen", "docked"].includes(createData.state)) {
win.state = createData.state; win.state = createData.state;
} }
if (allowScriptsToClose) { if (allowScriptsToClose) {

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

@ -103,7 +103,7 @@ add_task(async function testWindowCreate() {
windowState = latestWindow.STATE_FULLSCREEN; windowState = latestWindow.STATE_FULLSCREEN;
} }
if (expected.state == "STATE_NORMAL") { if (expected.state == "STATE_NORMAL" && AppConstants.platform == "macosx") {
ok(windowState == window.STATE_NORMAL || windowState == window.STATE_MAXIMIZED, ok(windowState == window.STATE_NORMAL || windowState == window.STATE_MAXIMIZED,
`Expected windowState (currently ${windowState}) to be STATE_NORMAL but will accept STATE_MAXIMIZED`); `Expected windowState (currently ${windowState}) to be STATE_NORMAL but will accept STATE_MAXIMIZED`);
} else { } else {

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

@ -2662,29 +2662,30 @@ XULDocument::DoneWalking()
NotifyPossibleTitleChange(false); NotifyPossibleTitleChange(false);
nsContentUtils::DispatchTrustedEvent(
this,
static_cast<nsIDocument*>(this),
NS_LITERAL_STRING("MozBeforeInitialXULLayout"),
true,
false);
// Before starting layout, check whether we're a toplevel chrome // Before starting layout, check whether we're a toplevel chrome
// window. If we are, setup some state so that we don't have to restyle // window. If we are, set our chrome flags now, so that we don't have
// the whole tree after StartLayout. // to restyle the whole frame tree after StartLayout.
if (nsCOMPtr<nsIDocShellTreeItem> item = GetDocShell()) { nsCOMPtr<nsIDocShellTreeItem> item = GetDocShell();
if (item) {
nsCOMPtr<nsIDocShellTreeOwner> owner; nsCOMPtr<nsIDocShellTreeOwner> owner;
item->GetTreeOwner(getter_AddRefs(owner)); item->GetTreeOwner(getter_AddRefs(owner));
if (nsCOMPtr<nsIXULWindow> xulWin = do_GetInterface(owner)) { nsCOMPtr<nsIXULWindow> xulWin = do_GetInterface(owner);
if (xulWin) {
nsCOMPtr<nsIDocShell> xulWinShell; nsCOMPtr<nsIDocShell> xulWinShell;
xulWin->GetDocShell(getter_AddRefs(xulWinShell)); xulWin->GetDocShell(getter_AddRefs(xulWinShell));
if (SameCOMIdentity(xulWinShell, item)) { if (SameCOMIdentity(xulWinShell, item)) {
// We're the chrome document! // We're the chrome document! Apply our chrome flags now.
xulWin->BeforeStartLayout(); xulWin->ApplyChromeFlags();
} }
} }
} }
nsContentUtils::DispatchTrustedEvent(this,
static_cast<nsIDocument*>(this),
NS_LITERAL_STRING("MozBeforeInitialXULLayout"),
true,
false);
StartLayout(); StartLayout();
if (mIsWritingFastLoad && IsChromeURI(mDocumentURI)) if (mIsWritingFastLoad && IsChromeURI(mDocumentURI))

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

@ -128,14 +128,12 @@ interface nsIXULWindow : nsISupports
attribute nsIXULBrowserWindow XULBrowserWindow; attribute nsIXULBrowserWindow XULBrowserWindow;
/** /**
* Back-door method to make sure some stuff is done when the document is * Back-door method to force application of chrome flags at a particular
* ready for layout, that would cause expensive computation otherwise later. * time. Do NOT call this unless you know what you're doing! In particular,
*
* Do NOT call this unless you know what you're doing! In particular,
* calling this when this XUL window doesn't yet have a document in its * calling this when this XUL window doesn't yet have a document in its
* docshell could cause problems. * docshell could cause problems.
*/ */
[noscript] void beforeStartLayout(); [noscript] void applyChromeFlags();
/** /**
* Given the dimensions of some content area held within this * Given the dimensions of some content area held within this

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

@ -274,9 +274,8 @@ NS_IMETHODIMP nsXULWindow::SetChromeFlags(uint32_t aChromeFlags)
"SetChromeFlags() after AssumeChromeFlagsAreFrozen()!"); "SetChromeFlags() after AssumeChromeFlagsAreFrozen()!");
mChromeFlags = aChromeFlags; mChromeFlags = aChromeFlags;
if (mChromeLoaded) { if (mChromeLoaded)
ApplyChromeFlags(); NS_ENSURE_SUCCESS(ApplyChromeFlags(), NS_ERROR_FAILURE);
}
return NS_OK; return NS_OK;
} }
@ -1084,7 +1083,82 @@ void nsXULWindow::OnChromeLoaded()
mChromeLoaded = true; mChromeLoaded = true;
ApplyChromeFlags(); ApplyChromeFlags();
SyncAttributesToWidget(); SyncAttributesToWidget();
SizeShell();
int32_t specWidth = -1, specHeight = -1;
bool gotSize = false;
bool isContent = false;
GetHasPrimaryContent(&isContent);
CSSIntSize windowDiff = mWindow
? RoundedToInt(GetWindowOuterInnerDiff(mWindow) /
mWindow->GetDefaultScale())
: CSSIntSize();
// If this window has a primary content and fingerprinting resistance is
// enabled, we enforce this window to rounded dimensions.
if (isContent && nsContentUtils::ShouldResistFingerprinting()) {
ForceRoundedDimensions();
} else if (!mIgnoreXULSize) {
gotSize = LoadSizeFromXUL(specWidth, specHeight);
specWidth += windowDiff.width;
specHeight += windowDiff.height;
}
bool positionSet = !mIgnoreXULPosition;
nsCOMPtr<nsIXULWindow> parentWindow(do_QueryReferent(mParentWindow));
#if defined(XP_UNIX) && !defined(XP_MACOSX)
// don't override WM placement on unix for independent, top-level windows
// (however, we think the benefits of intelligent dependent window placement
// trump that override.)
if (!parentWindow)
positionSet = false;
#endif
if (positionSet) {
// We have to do this before sizing the window, because sizing depends
// on the resolution of the screen we're on. But positioning needs to
// know the size so that it can constrain to screen bounds.... as an
// initial guess here, we'll use the specified size (if any).
positionSet = LoadPositionFromXUL(specWidth, specHeight);
}
if (gotSize) {
SetSpecifiedSize(specWidth, specHeight);
}
if (mIntrinsicallySized) {
// (if LoadSizeFromXUL set the size, mIntrinsicallySized will be false)
nsCOMPtr<nsIContentViewer> cv;
mDocShell->GetContentViewer(getter_AddRefs(cv));
if (cv) {
nsCOMPtr<nsIDocShellTreeItem> docShellAsItem = do_QueryInterface(mDocShell);
nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
docShellAsItem->GetTreeOwner(getter_AddRefs(treeOwner));
if (treeOwner) {
// GetContentSize can fail, so initialise |width| and |height| to be
// on the safe side.
int32_t width = 0, height = 0;
if (NS_SUCCEEDED(cv->GetContentSize(&width, &height))) {
treeOwner->SizeShellTo(docShellAsItem, width, height);
// Update specified size for the final LoadPositionFromXUL call.
specWidth = width + windowDiff.width;
specHeight = height + windowDiff.height;
}
}
}
}
// Now that we have set the window's final size, we can re-do its
// positioning so that it is properly constrained to the screen.
if (positionSet) {
LoadPositionFromXUL(specWidth, specHeight);
}
LoadMiscPersistentAttributesFromXUL();
if (mCenterAfterLoad && !positionSet) {
Center(parentWindow, parentWindow ? false : true, false);
}
if (mShowAfterLoad) { if (mShowAfterLoad) {
SetVisibility(true); SetVisibility(true);
@ -2188,13 +2262,10 @@ void nsXULWindow::PersistentAttributesDirty(uint32_t aDirtyFlags)
mPersistentAttributesDirty |= aDirtyFlags & mPersistentAttributesMask; mPersistentAttributesDirty |= aDirtyFlags & mPersistentAttributesMask;
} }
void NS_IMETHODIMP nsXULWindow::ApplyChromeFlags()
nsXULWindow::ApplyChromeFlags()
{ {
nsCOMPtr<dom::Element> window = GetWindowDOMElement(); nsCOMPtr<dom::Element> window = GetWindowDOMElement();
if (!window) { NS_ENSURE_TRUE(window, NS_ERROR_FAILURE);
return;
}
if (mChromeLoaded) { if (mChromeLoaded) {
// The two calls in this block don't need to happen early because they // The two calls in this block don't need to happen early because they
@ -2233,99 +2304,12 @@ nsXULWindow::ApplyChromeFlags()
// Note that if we're not actually changing the value this will be a no-op, // Note that if we're not actually changing the value this will be a no-op,
// so no need to compare to the old value. // so no need to compare to the old value.
IgnoredErrorResult rv; ErrorResult rv;
window->SetAttribute(NS_LITERAL_STRING("chromehidden"), newvalue, rv); window->SetAttribute(NS_LITERAL_STRING("chromehidden"), newvalue, rv);
}
NS_IMETHODIMP
nsXULWindow::BeforeStartLayout()
{
ApplyChromeFlags();
SyncAttributesToWidget();
SizeShell();
return NS_OK; return NS_OK;
} }
void
nsXULWindow::SizeShell()
{
int32_t specWidth = -1, specHeight = -1;
bool gotSize = false;
bool isContent = false;
GetHasPrimaryContent(&isContent);
CSSIntSize windowDiff = mWindow
? RoundedToInt(GetWindowOuterInnerDiff(mWindow) /
mWindow->GetDefaultScale())
: CSSIntSize();
// If this window has a primary content and fingerprinting resistance is
// enabled, we enforce this window to rounded dimensions.
if (isContent && nsContentUtils::ShouldResistFingerprinting()) {
ForceRoundedDimensions();
} else if (!mIgnoreXULSize) {
gotSize = LoadSizeFromXUL(specWidth, specHeight);
specWidth += windowDiff.width;
specHeight += windowDiff.height;
}
bool positionSet = !mIgnoreXULPosition;
nsCOMPtr<nsIXULWindow> parentWindow(do_QueryReferent(mParentWindow));
#if defined(XP_UNIX) && !defined(XP_MACOSX)
// don't override WM placement on unix for independent, top-level windows
// (however, we think the benefits of intelligent dependent window placement
// trump that override.)
if (!parentWindow)
positionSet = false;
#endif
if (positionSet) {
// We have to do this before sizing the window, because sizing depends
// on the resolution of the screen we're on. But positioning needs to
// know the size so that it can constrain to screen bounds.... as an
// initial guess here, we'll use the specified size (if any).
positionSet = LoadPositionFromXUL(specWidth, specHeight);
}
if (gotSize) {
SetSpecifiedSize(specWidth, specHeight);
}
if (mIntrinsicallySized) {
// (if LoadSizeFromXUL set the size, mIntrinsicallySized will be false)
nsCOMPtr<nsIContentViewer> cv;
mDocShell->GetContentViewer(getter_AddRefs(cv));
if (cv) {
nsCOMPtr<nsIDocShellTreeItem> docShellAsItem = do_QueryInterface(mDocShell);
nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
docShellAsItem->GetTreeOwner(getter_AddRefs(treeOwner));
if (treeOwner) {
// GetContentSize can fail, so initialise |width| and |height| to be
// on the safe side.
int32_t width = 0, height = 0;
if (NS_SUCCEEDED(cv->GetContentSize(&width, &height))) {
treeOwner->SizeShellTo(docShellAsItem, width, height);
// Update specified size for the final LoadPositionFromXUL call.
specWidth = width + windowDiff.width;
specHeight = height + windowDiff.height;
}
}
}
}
// Now that we have set the window's final size, we can re-do its
// positioning so that it is properly constrained to the screen.
if (positionSet) {
LoadPositionFromXUL(specWidth, specHeight);
}
LoadMiscPersistentAttributesFromXUL();
if (mChromeLoaded && mCenterAfterLoad && !positionSet) {
Center(parentWindow, parentWindow ? false : true, false);
}
}
NS_IMETHODIMP nsXULWindow::GetXULBrowserWindow(nsIXULBrowserWindow * *aXULBrowserWindow) NS_IMETHODIMP nsXULWindow::GetXULBrowserWindow(nsIXULBrowserWindow * *aXULBrowserWindow)
{ {
NS_IF_ADDREF(*aXULBrowserWindow = mXULBrowserWindow); NS_IF_ADDREF(*aXULBrowserWindow = mXULBrowserWindow);

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

@ -93,8 +93,6 @@ protected:
NS_IMETHOD ForceRoundedDimensions(); NS_IMETHOD ForceRoundedDimensions();
NS_IMETHOD GetAvailScreenSize(int32_t* aAvailWidth, int32_t* aAvailHeight); NS_IMETHOD GetAvailScreenSize(int32_t* aAvailWidth, int32_t* aAvailHeight);
void ApplyChromeFlags();
void SizeShell();
void OnChromeLoaded(); void OnChromeLoaded();
void StaggerPosition(int32_t &aRequestedX, int32_t &aRequestedY, void StaggerPosition(int32_t &aRequestedX, int32_t &aRequestedY,
int32_t aSpecWidth, int32_t aSpecHeight); int32_t aSpecWidth, int32_t aSpecHeight);