mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 19:04:45 +00:00
Bug 602962 - Undo close tab thumbnail disappears when rotating screen orientation [r=smaug r=roc a=blocking-fennecb3]
This commit is contained in:
parent
fe3717a7aa
commit
584b8d9e8a
@ -592,6 +592,7 @@ nsContentUtils::InitializeEventTable() {
|
||||
|
||||
{ nsGkAtoms::onpageshow, NS_PAGE_SHOW, EventNameType_HTML, NS_EVENT },
|
||||
{ nsGkAtoms::onpagehide, NS_PAGE_HIDE, EventNameType_HTML, NS_EVENT },
|
||||
{ nsGkAtoms::onMozBeforeResize, NS_BEFORERESIZE_EVENT, EventNameType_None, NS_EVENT },
|
||||
{ nsGkAtoms::onresize, NS_RESIZE_EVENT,
|
||||
(EventNameType_HTMLXUL | EventNameType_SVGSVG), NS_EVENT },
|
||||
{ nsGkAtoms::onscroll, NS_SCROLL_EVENT,
|
||||
|
@ -709,6 +709,7 @@ GK_ATOM(onpopupshown, "onpopupshown")
|
||||
GK_ATOM(onreadystatechange, "onreadystatechange")
|
||||
GK_ATOM(onRequest, "onRequest")
|
||||
GK_ATOM(onreset, "onreset")
|
||||
GK_ATOM(onMozBeforeResize, "onMozBeforeResize")
|
||||
GK_ATOM(onresize, "onresize")
|
||||
GK_ATOM(onscroll, "onscroll")
|
||||
GK_ATOM(onselect, "onselect")
|
||||
|
@ -93,6 +93,7 @@ static const char* const sEventNames[] = {
|
||||
#endif // MOZ_MEDIA
|
||||
"MozAfterPaint",
|
||||
"MozBeforePaint",
|
||||
"MozBeforeResize",
|
||||
"MozSwipeGesture",
|
||||
"MozMagnifyGestureStart",
|
||||
"MozMagnifyGestureUpdate",
|
||||
@ -1316,6 +1317,8 @@ const char* nsDOMEvent::GetEventName(PRUint32 aEventType)
|
||||
return sEventNames[eDOMEvents_afterpaint];
|
||||
case NS_BEFOREPAINT:
|
||||
return sEventNames[eDOMEvents_beforepaint];
|
||||
case NS_BEFORERESIZE_EVENT:
|
||||
return sEventNames[eDOMEvents_beforeresize];
|
||||
case NS_SIMPLE_GESTURE_SWIPE:
|
||||
return sEventNames[eDOMEvents_MozSwipeGesture];
|
||||
case NS_SIMPLE_GESTURE_MAGNIFY_START:
|
||||
|
@ -175,6 +175,7 @@ public:
|
||||
#endif
|
||||
eDOMEvents_afterpaint,
|
||||
eDOMEvents_beforepaint,
|
||||
eDOMEvents_beforeresize,
|
||||
eDOMEvents_MozSwipeGesture,
|
||||
eDOMEvents_MozMagnifyGestureStart,
|
||||
eDOMEvents_MozMagnifyGestureUpdate,
|
||||
|
@ -110,6 +110,8 @@ _CHROME_FILES = \
|
||||
test_bug415498.xul \
|
||||
bug415498-doc1.html \
|
||||
bug415498-doc2.html \
|
||||
bug602962.xul \
|
||||
test_bug602962.xul \
|
||||
$(NULL)
|
||||
|
||||
libs:: $(_TEST_FILES)
|
||||
|
8
content/events/test/bug602962.xul
Normal file
8
content/events/test/bug602962.xul
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
||||
|
||||
<window onload="window.opener.doTest()" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
<scrollbox id="page-scrollbox" style="border: 1px solid red; background-color: black;overflow: auto" flex="1">
|
||||
<box id="page-box" style="border: 1px solid green;"/>
|
||||
</scrollbox>
|
||||
</window>
|
94
content/events/test/test_bug602962.xul
Normal file
94
content/events/test/test_bug602962.xul
Normal file
@ -0,0 +1,94 @@
|
||||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
||||
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=602962
|
||||
-->
|
||||
<window title="Mozilla Bug 602962" onload="openWindow()"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
|
||||
<title>Test for Bug 602962</title>
|
||||
<script type="application/javascript" src="chrome://mochikit/content/MochiKit/packed.js"/>
|
||||
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
|
||||
|
||||
<body xmlns="http://www.w3.org/1999/xhtml">
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=602962">Mozilla Bug 602962</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
</div>
|
||||
</body>
|
||||
|
||||
<script class="testbody" type="application/javascript;version=1.8"><![CDATA[
|
||||
/** Test for Bug 602962 **/
|
||||
var scrollbox, sbo, content;
|
||||
var scrollX = 0, scrollY = 0;
|
||||
|
||||
var mozBeforeResizeHasFired = false;
|
||||
var oldWidth = 0, oldHeight = 0;
|
||||
var win = null;
|
||||
|
||||
function openWindow() {
|
||||
win = window.open("chrome://mochitests/content/chrome/content/events/test/bug602962.xul", "_blank", "width=600,height=600");
|
||||
}
|
||||
|
||||
function doTest() {
|
||||
scrollbox = win.document.getElementById("page-scrollbox");
|
||||
sbo = scrollbox.boxObject.QueryInterface(Components.interfaces.nsIScrollBoxObject);
|
||||
content = win.document.getElementById("page-box");
|
||||
content.style.width = 400 + "px";
|
||||
|
||||
win.addEventListener("resize", function() {
|
||||
win.removeEventListener("resize", arguments.callee, false);
|
||||
|
||||
sbo.scrollBy(200, 0);
|
||||
setTimeout(function() { resize(); }, 0);
|
||||
}, false);
|
||||
|
||||
oldWidth = win.outerWidth;
|
||||
oldHeight = win.outerHeight;
|
||||
win.resizeTo(200, 400);
|
||||
}
|
||||
|
||||
function resize() {
|
||||
win.addEventListener("MozBeforeResize", function() {
|
||||
win.removeEventListener("MozBeforeResize", arguments.callee, false);
|
||||
mozBeforeResizeHasFired = true;
|
||||
|
||||
let x = {}, y = {};
|
||||
sbo.getPosition(x, y);
|
||||
scrollX = x.value, scrollY = y.value;
|
||||
is(scrollX, 200, "Scroll X should not have changed yet");
|
||||
is(scrollY, 0, "Scroll Y should not have changed yet");
|
||||
}, false);
|
||||
|
||||
win.addEventListener("resize", function() {
|
||||
content.style.width = (oldWidth + 400) + "px";
|
||||
win.removeEventListener("resize", arguments.callee, true);
|
||||
|
||||
setTimeout(function() {
|
||||
finish();
|
||||
}, 0);
|
||||
}, true);
|
||||
|
||||
win.resizeTo(oldWidth, oldHeight);
|
||||
}
|
||||
|
||||
function finish() {
|
||||
is(mozBeforeResizeHasFired, true, "The MozBeforeResize event should already have fired");
|
||||
sbo.scrollBy(scrollX, scrollY);
|
||||
|
||||
let x = {}, y = {};
|
||||
sbo.getPosition(x, y);
|
||||
is(x.value, 200, "Scroll X should have been restored to the value before the resize");
|
||||
is(y.value, 0, "Scroll Y should have been restored to the value before the resize");
|
||||
|
||||
is(win.outerWidth, oldWidth, "Width should be resized");
|
||||
is(win.outerHeight, oldHeight, "Height should be resized");
|
||||
win.close();
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
]]></script>
|
||||
|
||||
</window>
|
@ -1355,6 +1355,7 @@ private:
|
||||
nsIWidget *aRootWidget);
|
||||
|
||||
void FireResizeEvent();
|
||||
void FireBeforeResizeEvent();
|
||||
static void AsyncResizeEventCallback(nsITimer* aTimer, void* aPresShell);
|
||||
nsRevocableEventPtr<nsRunnableMethod<PresShell> > mResizeEvent;
|
||||
nsCOMPtr<nsITimer> mAsyncResizeEventTimer;
|
||||
@ -2830,6 +2831,11 @@ PresShell::ResizeReflowIgnoreOverride(nscoord aWidth, nscoord aHeight)
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
if (!mIsDestroying && !mResizeEvent.IsPending() &&
|
||||
!mAsyncResizeTimerIsActive) {
|
||||
FireBeforeResizeEvent();
|
||||
}
|
||||
|
||||
mPresContext->SetVisibleArea(nsRect(0, 0, aWidth, aHeight));
|
||||
|
||||
// There isn't anything useful we can do if the initial reflow hasn't happened
|
||||
@ -2905,6 +2911,22 @@ PresShell::ResizeReflowIgnoreOverride(nscoord aWidth, nscoord aHeight)
|
||||
return NS_OK; //XXX this needs to be real. MMP
|
||||
}
|
||||
|
||||
void
|
||||
PresShell::FireBeforeResizeEvent()
|
||||
{
|
||||
if (mIsDocumentGone)
|
||||
return;
|
||||
|
||||
// Send beforeresize event from here.
|
||||
nsEvent event(PR_TRUE, NS_BEFORERESIZE_EVENT);
|
||||
|
||||
nsPIDOMWindow *window = mDocument->GetWindow();
|
||||
if (window) {
|
||||
nsCOMPtr<nsIPresShell> kungFuDeathGrip(this);
|
||||
nsEventDispatcher::Dispatch(window, mPresContext, &event);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
PresShell::FireResizeEvent()
|
||||
{
|
||||
|
@ -236,6 +236,9 @@ class nsHashKey;
|
||||
#define NS_OFFLINE (NS_WINDOW_START + 64)
|
||||
#define NS_ONLINE (NS_WINDOW_START + 65)
|
||||
|
||||
// Indicates a resize will occur
|
||||
#define NS_BEFORERESIZE_EVENT (NS_WINDOW_START + 66)
|
||||
|
||||
#define NS_MOUSE_MESSAGE_START 300
|
||||
#define NS_MOUSE_MOVE (NS_MOUSE_MESSAGE_START)
|
||||
#define NS_MOUSE_BUTTON_UP (NS_MOUSE_MESSAGE_START + 1)
|
||||
|
Loading…
Reference in New Issue
Block a user