Log Message
Clean up use of adjustWindowRect https://bugs.webkit.org/show_bug.cgi?id=102072
Reviewed by Alexis Menard.
Source/WebCore:
Tested by fast/dom/Window/open-window-min-size.html
* loader/FrameLoader.cpp:
(WebCore::createWindow):
Validate the window size here so that it is not just done for
.open, but also for .showModalDialog. This is compatible with
other browsers such as IE and Firefox (though IE > 6, enforces
a minimum width of 250 instead of 100 as Firefox and us.)
* page/DOMWindow.cpp:
(WebCore):
(WebCore::DOMWindow::adjustWindowRect):
Make it a static method which only takes page. It was never
called from anywhere without a valid page, so the page check
has been turned into an assert, and two of the arguments have
been removed as they can be accessed via the page.
(WebCore::DOMWindow::moveBy):
(WebCore::DOMWindow::moveTo):
(WebCore::DOMWindow::resizeBy):
(WebCore::DOMWindow::resizeTo):
Update use of adjustWindowRect.
(WebCore::DOMWindow::open):
Avoid modifying the WindowFeatures as the WebCore::createWindow
validates and adjusts the arguments.
* page/DOMWindow.h:
(DOMWindow):
LayoutTests:
Test that minimum sizes are honored.
* fast/dom/Window/open-window-min-size.html: Added.
* fast/dom/Window/open-window-min-size-expected.txt: Added.
* fast/dom/Window/resources/print-close.html: Added.
Modified Paths
- trunk/LayoutTests/ChangeLog
- trunk/Source/WebCore/ChangeLog
- trunk/Source/WebCore/loader/FrameLoader.cpp
- trunk/Source/WebCore/page/DOMWindow.cpp
- trunk/Source/WebCore/page/DOMWindow.h
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (134433 => 134434)
--- trunk/LayoutTests/ChangeLog 2012-11-13 17:53:31 UTC (rev 134433)
+++ trunk/LayoutTests/ChangeLog 2012-11-13 17:59:14 UTC (rev 134434)
@@ -1,3 +1,16 @@
+2012-11-13 Kenneth Rohde Christiansen <[email protected]>
+
+ Clean up use of adjustWindowRect
+ https://bugs.webkit.org/show_bug.cgi?id=102072
+
+ Reviewed by Alexis Menard.
+
+ Test that minimum sizes are honored.
+
+ * fast/dom/Window/open-window-min-size.html: Added.
+ * fast/dom/Window/open-window-min-size-expected.txt: Added.
+ * fast/dom/Window/resources/print-close.html: Added.
+
2012-11-13 Bem Jones-Bey <[email protected]>
[CSS Exclusions] Update wrap-margin/padding to shape-margin/padding
Added: trunk/LayoutTests/fast/dom/Window/open-window-min-size-expected.txt (0 => 134434)
--- trunk/LayoutTests/fast/dom/Window/open-window-min-size-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/dom/Window/open-window-min-size-expected.txt 2012-11-13 17:59:14 UTC (rev 134434)
@@ -0,0 +1,8 @@
+PASS successfullyParsed is true
+
+TEST COMPLETE
+PASS 100 is >= 100
+PASS 100 is >= 100
+PASS 100 is >= 100
+PASS 100 is >= 100
+
Added: trunk/LayoutTests/fast/dom/Window/open-window-min-size.html (0 => 134434)
--- trunk/LayoutTests/fast/dom/Window/open-window-min-size.html (rev 0)
+++ trunk/LayoutTests/fast/dom/Window/open-window-min-size.html 2012-11-13 17:59:14 UTC (rev 134434)
@@ -0,0 +1,32 @@
+<html>
+<head>
+<script src=""
+<script>
+function test() {
+ var expectedMsgs = 2;
+ var msgsReceived = 0;
+ window.addEventListener('message', function(e) {
+ msgsReceived++;
+ shouldBeGreaterThanOrEqual(e.data["width"].toString(), "100");
+ shouldBeGreaterThanOrEqual(e.data["height"].toString(), "100");
+ if (msgsReceived === expectedMsgs)
+ testRunner.notifyDone();
+ }, false);
+
+ window.open("resources/print-close.html", "", "width=10, height=10");
+ window.showModalDialog("resources/print-close.html", "", "dialogWidth:10; dialogHeight:10");
+}
+
+if (window.testRunner) {
+ testRunner.dumpAsText();
+ testRunner.waitUntilDone();
+ testRunner.setCanOpenWindows();
+ testRunner.setCloseRemainingWindowsWhenComplete(true);
+}
+
+</script>
+</head>
+<body _onload_="test()">
+<script src=""
+</body>
+</html>
Added: trunk/LayoutTests/fast/dom/Window/resources/print-close.html (0 => 134434)
--- trunk/LayoutTests/fast/dom/Window/resources/print-close.html (rev 0)
+++ trunk/LayoutTests/fast/dom/Window/resources/print-close.html 2012-11-13 17:59:14 UTC (rev 134434)
@@ -0,0 +1,9 @@
+<body _onload_="loaded()">
+<script>
+function loaded() {
+ var msg = { "width": window.outerWidth, "height": window.outerHeight };
+ window.opener.postMessage(msg, '*');
+ window.close();
+}
+</script>
+</body
Modified: trunk/Source/WebCore/ChangeLog (134433 => 134434)
--- trunk/Source/WebCore/ChangeLog 2012-11-13 17:53:31 UTC (rev 134433)
+++ trunk/Source/WebCore/ChangeLog 2012-11-13 17:59:14 UTC (rev 134434)
@@ -1,3 +1,44 @@
+2012-11-13 Kenneth Rohde Christiansen <[email protected]>
+
+ Clean up use of adjustWindowRect
+ https://bugs.webkit.org/show_bug.cgi?id=102072
+
+ Reviewed by Alexis Menard.
+
+ Tested by fast/dom/Window/open-window-min-size.html
+
+ * loader/FrameLoader.cpp:
+ (WebCore::createWindow):
+
+ Validate the window size here so that it is not just done for
+ .open, but also for .showModalDialog. This is compatible with
+ other browsers such as IE and Firefox (though IE > 6, enforces
+ a minimum width of 250 instead of 100 as Firefox and us.)
+
+ * page/DOMWindow.cpp:
+ (WebCore):
+ (WebCore::DOMWindow::adjustWindowRect):
+
+ Make it a static method which only takes page. It was never
+ called from anywhere without a valid page, so the page check
+ has been turned into an assert, and two of the arguments have
+ been removed as they can be accessed via the page.
+
+ (WebCore::DOMWindow::moveBy):
+ (WebCore::DOMWindow::moveTo):
+ (WebCore::DOMWindow::resizeBy):
+ (WebCore::DOMWindow::resizeTo):
+
+ Update use of adjustWindowRect.
+
+ (WebCore::DOMWindow::open):
+
+ Avoid modifying the WindowFeatures as the WebCore::createWindow
+ validates and adjusts the arguments.
+
+ * page/DOMWindow.h:
+ (DOMWindow):
+
2012-11-13 Bem Jones-Bey <[email protected]>
[CSS Exclusions] Update wrap-margin/padding to shape-margin/padding
Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (134433 => 134434)
--- trunk/Source/WebCore/loader/FrameLoader.cpp 2012-11-13 17:53:31 UTC (rev 134433)
+++ trunk/Source/WebCore/loader/FrameLoader.cpp 2012-11-13 17:59:14 UTC (rev 134434)
@@ -3321,21 +3321,25 @@
page->chrome()->setResizable(features.resizable);
// 'x' and 'y' specify the location of the window, while 'width' and 'height'
- // specify the size of the page. We can only resize the window, so
- // adjust for the difference between the window size and the page size.
+ // specify the size of the viewport. We can only resize the window, so adjust
+ // for the difference between the window size and the viewport size.
FloatRect windowRect = page->chrome()->windowRect();
- FloatSize pageSize = page->chrome()->pageRect().size();
+ FloatSize viewportSize = page->chrome()->pageRect().size();
+
if (features.xSet)
windowRect.setX(features.x);
if (features.ySet)
windowRect.setY(features.y);
if (features.widthSet)
- windowRect.setWidth(features.width + (windowRect.width() - pageSize.width()));
+ windowRect.setWidth(features.width + (windowRect.width() - viewportSize.width()));
if (features.heightSet)
- windowRect.setHeight(features.height + (windowRect.height() - pageSize.height()));
- page->chrome()->setWindowRect(windowRect);
+ windowRect.setHeight(features.height + (windowRect.height() - viewportSize.height()));
+ // Ensure non-NaN values, minimum size as well as being within valid screen area.
+ FloatRect newWindowRect = DOMWindow::adjustWindowRect(page, windowRect);
+
+ page->chrome()->setWindowRect(newWindowRect);
page->chrome()->show();
created = true;
Modified: trunk/Source/WebCore/page/DOMWindow.cpp (134433 => 134434)
--- trunk/Source/WebCore/page/DOMWindow.cpp 2012-11-13 17:53:31 UTC (rev 134433)
+++ trunk/Source/WebCore/page/DOMWindow.cpp 2012-11-13 17:59:14 UTC (rev 134434)
@@ -308,16 +308,18 @@
}
// This function:
-// 1) Validates the pending changes are not changing to NaN
-// 2) Constrains the window rect to the minimum window size and no bigger than
-// the the float rect's dimensions.
-// 3) Constrain window rect to within the top and left boundaries of the screen rect
-// 4) Constraint the window rect to within the bottom and right boundaries of the
-// screen rect.
-// 5) Translate the window rect coordinates to be within the coordinate space of
-// the screen rect.
-void DOMWindow::adjustWindowRect(const FloatRect& screen, FloatRect& window, const FloatRect& pendingChanges) const
+// 1) Validates the pending changes are not changing any value to NaN; in that case keep original value.
+// 2) Constrains the window rect to the minimum window size and no bigger than the float rect's dimensions.
+// 3) Constrains the window rect to within the top and left boundaries of the available screen rect.
+// 4) Constrains the window rect to within the bottom and right boundaries of the available screen rect.
+// 5) Translate the window rect coordinates to be within the coordinate space of the screen.
+FloatRect DOMWindow::adjustWindowRect(Page* page, const FloatRect& pendingChanges)
{
+ ASSERT(page);
+
+ FloatRect screen = screenAvailableRect(page->mainFrame()->view());
+ FloatRect window = page->chrome()->windowRect();
+
// Make sure we're in a valid state before adjusting dimensions.
ASSERT(isfinite(screen.x()));
ASSERT(isfinite(screen.y()));
@@ -327,7 +329,7 @@
ASSERT(isfinite(window.y()));
ASSERT(isfinite(window.width()));
ASSERT(isfinite(window.height()));
-
+
// Update window values if new requested values are not NaN.
if (!isnan(pendingChanges.x()))
window.setX(pendingChanges.x());
@@ -338,15 +340,15 @@
if (!isnan(pendingChanges.height()))
window.setHeight(pendingChanges.height());
- ASSERT(m_frame);
- Page* page = m_frame->page();
- FloatSize minimumSize = page ? m_frame->page()->chrome()->client()->minimumWindowSize() : FloatSize(100, 100);
+ FloatSize minimumSize = page->chrome()->client()->minimumWindowSize();
window.setWidth(min(max(minimumSize.width(), window.width()), screen.width()));
window.setHeight(min(max(minimumSize.height(), window.height()), screen.height()));
- // Constrain the window position to the screen.
+ // Constrain the window position within the valid screen area.
window.setX(max(screen.x(), min(window.x(), screen.maxX() - window.width())));
window.setY(max(screen.y(), min(window.y(), screen.maxY() - window.height())));
+
+ return window;
}
// FIXME: We can remove this function once V8 showModalDialog is changed to use DOMWindow.
@@ -1450,8 +1452,7 @@
FloatRect update = fr;
update.move(x, y);
// Security check (the spec talks about UniversalBrowserWrite to disable this check...)
- adjustWindowRect(screenAvailableRect(page->mainFrame()->view()), fr, update);
- page->chrome()->setWindowRect(fr);
+ page->chrome()->setWindowRect(adjustWindowRect(page, update));
}
void DOMWindow::moveTo(float x, float y) const
@@ -1470,10 +1471,9 @@
FloatRect sr = screenAvailableRect(page->mainFrame()->view());
fr.setLocation(sr.location());
FloatRect update = fr;
- update.move(x, y);
+ update.move(x, y);
// Security check (the spec talks about UniversalBrowserWrite to disable this check...)
- adjustWindowRect(sr, fr, update);
- page->chrome()->setWindowRect(fr);
+ page->chrome()->setWindowRect(adjustWindowRect(page, update));
}
void DOMWindow::resizeBy(float x, float y) const
@@ -1491,8 +1491,7 @@
FloatRect fr = page->chrome()->windowRect();
FloatSize dest = fr.size() + FloatSize(x, y);
FloatRect update(fr.location(), dest);
- adjustWindowRect(screenAvailableRect(page->mainFrame()->view()), fr, update);
- page->chrome()->setWindowRect(fr);
+ page->chrome()->setWindowRect(adjustWindowRect(page, update));
}
void DOMWindow::resizeTo(float width, float height) const
@@ -1510,8 +1509,7 @@
FloatRect fr = page->chrome()->windowRect();
FloatSize dest = FloatSize(width, height);
FloatRect update(fr.location(), dest);
- adjustWindowRect(screenAvailableRect(page->mainFrame()->view()), fr, update);
- page->chrome()->setWindowRect(fr);
+ page->chrome()->setWindowRect(adjustWindowRect(page, update));
}
int DOMWindow::setTimeout(PassOwnPtr<ScheduledAction> action, int timeout, ExceptionCode& ec)
@@ -1930,15 +1928,6 @@
}
WindowFeatures windowFeatures(windowFeaturesString);
- FloatRect windowRect(windowFeatures.xSet ? windowFeatures.x : 0, windowFeatures.ySet ? windowFeatures.y : 0,
- windowFeatures.widthSet ? windowFeatures.width : 0, windowFeatures.heightSet ? windowFeatures.height : 0);
- Page* page = m_frame->page();
- DOMWindow::adjustWindowRect(screenAvailableRect(page ? page->mainFrame()->view() : 0), windowRect, windowRect);
- windowFeatures.x = windowRect.x();
- windowFeatures.y = windowRect.y();
- windowFeatures.height = windowRect.height();
- windowFeatures.width = windowRect.width();
-
Frame* result = createWindow(urlString, frameName, windowFeatures, activeWindow, firstFrame, m_frame);
return result ? result->document()->domWindow() : 0;
}
@@ -1958,7 +1947,8 @@
if (!canShowModalDialogNow(m_frame) || !firstWindow->allowPopUp())
return;
- Frame* dialogFrame = createWindow(urlString, emptyAtom, WindowFeatures(dialogFeaturesString, screenAvailableRect(m_frame->view())),
+ WindowFeatures windowFeatures(dialogFeaturesString, screenAvailableRect(m_frame->view()));
+ Frame* dialogFrame = createWindow(urlString, emptyAtom, windowFeatures,
activeWindow, firstFrame, m_frame, function, functionContext);
if (!dialogFrame)
return;
Modified: trunk/Source/WebCore/page/DOMWindow.h (134433 => 134434)
--- trunk/Source/WebCore/page/DOMWindow.h 2012-11-13 17:53:31 UTC (rev 134433)
+++ trunk/Source/WebCore/page/DOMWindow.h 2012-11-13 17:59:14 UTC (rev 134434)
@@ -120,7 +120,7 @@
static bool dispatchAllPendingBeforeUnloadEvents();
static void dispatchAllPendingUnloadEvents();
- void adjustWindowRect(const FloatRect& screen, FloatRect& window, const FloatRect& pendingChanges) const;
+ static FloatRect adjustWindowRect(Page*, const FloatRect& pendingChanges);
// FIXME: We can remove this function once V8 showModalDialog is changed to use DOMWindow.
static void parseModalDialogFeatures(const String&, HashMap<String, String>&);
_______________________________________________ webkit-changes mailing list [email protected] http://lists.webkit.org/mailman/listinfo/webkit-changes
