Flush view manager's delayed resize when flushing layout. (Bug 453896) r+sr=bzbarsky

This commit is contained in:
L. David Baron 2008-09-09 06:43:10 -07:00
Родитель 9d07b6f6d9
Коммит ee127333fd
8 изменённых файлов: 164 добавлений и 6 удалений

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

@ -4581,6 +4581,7 @@ PresShell::DoFlushPendingNotifications(mozFlushType aType,
if (aType >= Flush_Layout && !mIsDestroying) {
mFrameConstructor->RecalcQuotesAndCounters();
mViewManager->FlushDelayedResize();
ProcessReflowCommands(aInterruptibleReflow);
}

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

@ -95,6 +95,7 @@ _TEST_FILES = test_acid3_test46.html \
test_bug405818.html \
test_bug412901.html \
test_bug437915.html \
test_bug453896_deck.html \
test_cascade.html \
test_compute_data_with_start_struct.html \
test_css_eof_handling.html \
@ -136,8 +137,17 @@ _TEST_FILES = test_acid3_test46.html \
media_queries_dynamic_xbl_binding.xml \
media_queries_dynamic_xbl_iframe.html \
media_queries_dynamic_xbl_style.css \
bug453896_iframe.html \
$(NULL)
_BROWSER_FILES = \
browser_bug453896.js \
bug453896_iframe.html \
media_queries_iframe.html \
$(NULL)
libs:: $(_TEST_FILES)
$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)
libs:: $(_BROWSER_FILES)
$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/browser/$(relativesrcdir)

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

@ -0,0 +1,24 @@
var listener = {
handleEvent : function(e) {
if (e.target == theBrowser.contentDocument)
doTest();
}
}
var theTab;
var theBrowser;
function test() {
waitForExplicitFinish();
theTab = gBrowser.addTab();
theBrowser = gBrowser.getBrowserForTab(theTab);
theBrowser.addEventListener("load", listener, true);
theBrowser.contentWindow.location = "chrome://mochikit/content/browser/layout/style/test/bug453896_iframe.html";
}
function doTest() {
var fake_window = { ok: ok, SimpleTest: { finish: finish } };
theBrowser.contentWindow.wrappedJSObject.run(fake_window);
gBrowser.removeTab(theTab);
}

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

@ -0,0 +1,68 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en-US">
<head>
<title>Bug 453896 Test middle frame</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<script type="application/javascript; version=1.7">
function run(test_window)
{
var subdoc = document.getElementById("subdoc").contentDocument;
var subwin = document.getElementById("subdoc").contentWindow;
var style = subdoc.getElementById("style");
var iframe_style = document.getElementById("subdoc").style;
var body_cs = subdoc.defaultView.getComputedStyle(subdoc.body, "");
function query_applies(q) {
style.setAttribute("media", q);
return body_cs.getPropertyValue("text-decoration") == "underline";
}
function should_apply(q) {
test_window.ok(query_applies(q), q + " should apply");
}
function should_not_apply(q) {
test_window.ok(!query_applies(q), q + " should not apply");
}
// in this test, assume the common underlying implementation is correct
let width_val = 157; // pick two not-too-round numbers
let height_val = 182;
iframe_style.width = width_val + "px";
iframe_style.height = height_val + "px";
for (let [feature, value] in
Iterator({ "width": width_val, "height": height_val })) {
should_apply("all and (" + feature + ": " + value + "px)");
should_not_apply("all and (" + feature + ": " + (value + 1) + "px)");
should_not_apply("all and (" + feature + ": " + (value - 1) + "px)");
}
iframe_style.width = "0";
should_apply("all and (height)");
should_not_apply("all and (width)");
iframe_style.height = "0";
should_not_apply("all and (height)");
should_not_apply("all and (width)");
should_apply("all and (device-height)");
should_apply("all and (device-width)");
iframe_style.width = width_val + "px";
should_not_apply("all and (height)");
should_apply("all and (width)");
iframe_style.height = height_val + "px";
should_apply("all and (height)");
should_apply("all and (width)");
test_window.SimpleTest.finish();
}
</script>
</head>
<body>
<iframe id="subdoc" src="media_queries_iframe.html"></iframe>
</body>
</html>

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

@ -0,0 +1,42 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=453896
-->
<head>
<title>Test for Bug 453896</title>
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body onload="run()">
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=453896">Mozilla Bug 453896</a>
<div id="display">
<div style="display:-moz-deck; height: 300px; width: 300px;">
<iframe src="about:blank"></iframe>
<iframe id="subdoc" src="bug453896_iframe.html"></iframe>
<iframe src="about:blank"></iframe>
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
/** Test for Bug 453896 **/
function run()
{
var iframe = document.getElementById("subdoc");
var subdoc = iframe.contentDocument;
var subwin = iframe.contentWindow;
subwin.run(window);
}
SimpleTest.waitForExplicitFinish();
</script>
</pre>
</body>
</html>

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

@ -60,10 +60,10 @@ enum nsRectVisibility {
nsRectVisibility_kZeroAreaRect
};
// 855e75b8-32cf-4e16-bc50-4e04c53f6cbc
// 7eae119d-9fc8-482d-92ec-145eef228a4a
#define NS_IVIEWMANAGER_IID \
{ 0x855e75b8, 0x32cf, 0x4e16, \
{ 0xbc, 0x50, 0x4e, 0x04, 0xc5, 0x3f, 0x6c, 0xbc } }
{ 0x7eae119d, 0x9fc8, 0x482d, \
{ 0x92, 0xec, 0x14, 0x5e, 0xef, 0x22, 0x8a, 0x4a } }
class nsIViewManager : public nsISupports
{
@ -138,6 +138,11 @@ public:
*/
NS_IMETHOD SetWindowDimensions(nscoord aWidth, nscoord aHeight) = 0;
/**
* Do any resizes that are pending.
*/
NS_IMETHOD FlushDelayedResize() = 0;
/**
* Called to force a redrawing of any dirty areas.
*/

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

@ -378,6 +378,15 @@ NS_IMETHODIMP nsViewManager::SetWindowDimensions(nscoord aWidth, nscoord aHeight
return NS_OK;
}
NS_IMETHODIMP nsViewManager::FlushDelayedResize()
{
if (mDelayedResize != nsSize(NSCOORD_NONE, NSCOORD_NONE)) {
DoSetWindowDimensions(mDelayedResize.width, mDelayedResize.height);
mDelayedResize.SizeTo(NSCOORD_NONE, NSCOORD_NONE);
}
return NS_OK;
}
static void ConvertNativeRegionToAppRegion(nsIRegion* aIn, nsRegion* aOut,
nsIDeviceContext* context)
{
@ -1073,9 +1082,7 @@ NS_IMETHODIMP nsViewManager::DispatchEvent(nsGUIEvent *aEvent, nsEventStatus *aS
: nsnull) {
if (vm->mDelayedResize != nsSize(NSCOORD_NONE, NSCOORD_NONE) &&
IsViewVisible(vm->mRootView)) {
vm->DoSetWindowDimensions(vm->mDelayedResize.width,
vm->mDelayedResize.height);
vm->mDelayedResize.SizeTo(NSCOORD_NONE, NSCOORD_NONE);
vm->FlushDelayedResize();
// Paint later.
vm->UpdateView(vm->mRootView, NS_VMREFRESH_NO_SYNC);

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

@ -123,6 +123,7 @@ public:
NS_IMETHOD GetWindowDimensions(nscoord *width, nscoord *height);
NS_IMETHOD SetWindowDimensions(nscoord width, nscoord height);
NS_IMETHOD FlushDelayedResize();
NS_IMETHOD Composite(void);