Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(224)

Side by Side Diff: Source/core/frame/LocalDOMWindow.cpp

Issue 1135633004: Revert of Make createWindow (mostly) work with OOPIF (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/frame/LocalDOMWindow.h ('k') | Source/core/frame/Screen.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved.
3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 #include "core/page/Chrome.h" 64 #include "core/page/Chrome.h"
65 #include "core/page/ChromeClient.h" 65 #include "core/page/ChromeClient.h"
66 #include "core/page/CreateWindow.h" 66 #include "core/page/CreateWindow.h"
67 #include "core/page/EventHandler.h" 67 #include "core/page/EventHandler.h"
68 #include "core/page/Page.h" 68 #include "core/page/Page.h"
69 #include "core/page/WindowFeatures.h" 69 #include "core/page/WindowFeatures.h"
70 #include "core/page/scrolling/ScrollingCoordinator.h" 70 #include "core/page/scrolling/ScrollingCoordinator.h"
71 #include "platform/EventDispatchForbiddenScope.h" 71 #include "platform/EventDispatchForbiddenScope.h"
72 #include "platform/PlatformScreen.h" 72 #include "platform/PlatformScreen.h"
73 #include "public/platform/Platform.h" 73 #include "public/platform/Platform.h"
74 #include <algorithm>
75
76 using std::min;
77 using std::max;
74 78
75 namespace blink { 79 namespace blink {
76 80
77 LocalDOMWindow::WindowFrameObserver::WindowFrameObserver(LocalDOMWindow* window, LocalFrame& frame) 81 LocalDOMWindow::WindowFrameObserver::WindowFrameObserver(LocalDOMWindow* window, LocalFrame& frame)
78 : LocalFrameLifecycleObserver(&frame) 82 : LocalFrameLifecycleObserver(&frame)
79 , m_window(window) 83 , m_window(window)
80 { 84 {
81 } 85 }
82 86
83 PassOwnPtrWillBeRawPtr<LocalDOMWindow::WindowFrameObserver> LocalDOMWindow::Wind owFrameObserver::create(LocalDOMWindow* window, LocalFrame& frame) 87 PassOwnPtrWillBeRawPtr<LocalDOMWindow::WindowFrameObserver> LocalDOMWindow::Wind owFrameObserver::create(LocalDOMWindow* window, LocalFrame& frame)
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 if (!frame) 246 if (!frame)
243 return false; 247 return false;
244 return frame->isMainFrame(); 248 return frame->isMainFrame();
245 } 249 }
246 250
247 unsigned LocalDOMWindow::pendingUnloadEventListeners() const 251 unsigned LocalDOMWindow::pendingUnloadEventListeners() const
248 { 252 {
249 return windowsWithUnloadEventListeners().count(const_cast<LocalDOMWindow*>(t his)); 253 return windowsWithUnloadEventListeners().count(const_cast<LocalDOMWindow*>(t his));
250 } 254 }
251 255
256 // This function:
257 // 1) Constrains the window rect to the minimum window size and no bigger than t he int rect's dimensions.
258 // 2) Constrains the window rect to within the top and left boundaries of the av ailable screen rect.
259 // 3) Constrains the window rect to within the bottom and right boundaries of th e available screen rect.
260 // 4) Translate the window rect coordinates to be within the coordinate space of the screen.
261 IntRect LocalDOMWindow::adjustWindowRect(LocalFrame& frame, const IntRect& pendi ngChanges)
262 {
263 FrameHost* host = frame.host();
264 ASSERT(host);
265
266 IntRect screen = screenAvailableRect(frame.view());
267 IntRect window = pendingChanges;
268
269 IntSize minimumSize = host->chrome().client().minimumWindowSize();
270 // Let size 0 pass through, since that indicates default size, not minimum s ize.
271 if (window.width())
272 window.setWidth(min(max(minimumSize.width(), window.width()), screen.wid th()));
273 if (window.height())
274 window.setHeight(min(max(minimumSize.height(), window.height()), screen. height()));
275
276 // Constrain the window position within the valid screen area.
277 window.setX(max(screen.x(), min(window.x(), screen.maxX() - window.width())) );
278 window.setY(max(screen.y(), min(window.y(), screen.maxY() - window.height()) ));
279
280 return window;
281 }
282
252 bool LocalDOMWindow::allowPopUp(LocalFrame& firstFrame) 283 bool LocalDOMWindow::allowPopUp(LocalFrame& firstFrame)
253 { 284 {
254 if (UserGestureIndicator::processingUserGesture()) 285 if (UserGestureIndicator::processingUserGesture())
255 return true; 286 return true;
256 287
257 Settings* settings = firstFrame.settings(); 288 Settings* settings = firstFrame.settings();
258 return settings && settings->javaScriptCanOpenWindowsAutomatically(); 289 return settings && settings->javaScriptCanOpenWindowsAutomatically();
259 } 290 }
260 291
261 bool LocalDOMWindow::allowPopUp() 292 bool LocalDOMWindow::allowPopUp()
(...skipping 990 matching lines...) Expand 10 before | Expand all | Expand 10 after
1252 if (!frame() || !frame()->isMainFrame()) 1283 if (!frame() || !frame()->isMainFrame())
1253 return; 1284 return;
1254 1285
1255 FrameHost* host = frame()->host(); 1286 FrameHost* host = frame()->host();
1256 if (!host) 1287 if (!host)
1257 return; 1288 return;
1258 1289
1259 IntRect windowRect = host->chrome().windowRect(); 1290 IntRect windowRect = host->chrome().windowRect();
1260 windowRect.move(x, y); 1291 windowRect.move(x, y);
1261 // Security check (the spec talks about UniversalBrowserWrite to disable thi s check...) 1292 // Security check (the spec talks about UniversalBrowserWrite to disable thi s check...)
1262 host->chrome().setWindowRect(windowRect); 1293 host->chrome().setWindowRect(adjustWindowRect(*frame(), windowRect));
1263 } 1294 }
1264 1295
1265 void LocalDOMWindow::moveTo(int x, int y, bool hasX, bool hasY) const 1296 void LocalDOMWindow::moveTo(int x, int y, bool hasX, bool hasY) const
1266 { 1297 {
1267 if (!hasX || !hasY) 1298 if (!hasX || !hasY)
1268 UseCounter::count(document(), UseCounter::WindowMoveResizeMissingArgumen ts); 1299 UseCounter::count(document(), UseCounter::WindowMoveResizeMissingArgumen ts);
1269 1300
1270 if (!frame() || !frame()->isMainFrame()) 1301 if (!frame() || !frame()->isMainFrame())
1271 return; 1302 return;
1272 1303
1273 FrameHost* host = frame()->host(); 1304 FrameHost* host = frame()->host();
1274 if (!host) 1305 if (!host)
1275 return; 1306 return;
1276 1307
1277 IntRect windowRect = host->chrome().windowRect(); 1308 IntRect windowRect = host->chrome().windowRect();
1278 windowRect.setLocation(IntPoint(hasX ? x : windowRect.x(), hasY ? y : window Rect.y())); 1309 windowRect.setLocation(IntPoint(hasX ? x : windowRect.x(), hasY ? y : window Rect.y()));
1279 // Security check (the spec talks about UniversalBrowserWrite to disable thi s check...) 1310 // Security check (the spec talks about UniversalBrowserWrite to disable thi s check...)
1280 host->chrome().setWindowRect(windowRect); 1311 host->chrome().setWindowRect(adjustWindowRect(*frame(), windowRect));
1281 } 1312 }
1282 1313
1283 void LocalDOMWindow::resizeBy(int x, int y, bool hasX, bool hasY) const 1314 void LocalDOMWindow::resizeBy(int x, int y, bool hasX, bool hasY) const
1284 { 1315 {
1285 if (!hasX || !hasY) 1316 if (!hasX || !hasY)
1286 UseCounter::count(document(), UseCounter::WindowMoveResizeMissingArgumen ts); 1317 UseCounter::count(document(), UseCounter::WindowMoveResizeMissingArgumen ts);
1287 1318
1288 if (!frame() || !frame()->isMainFrame()) 1319 if (!frame() || !frame()->isMainFrame())
1289 return; 1320 return;
1290 1321
1291 FrameHost* host = frame()->host(); 1322 FrameHost* host = frame()->host();
1292 if (!host) 1323 if (!host)
1293 return; 1324 return;
1294 1325
1295 IntRect fr = host->chrome().windowRect(); 1326 IntRect fr = host->chrome().windowRect();
1296 IntSize dest = fr.size() + IntSize(x, y); 1327 IntSize dest = fr.size() + IntSize(x, y);
1297 IntRect update(fr.location(), dest); 1328 IntRect update(fr.location(), dest);
1298 host->chrome().setWindowRect(update); 1329 host->chrome().setWindowRect(adjustWindowRect(*frame(), update));
1299 } 1330 }
1300 1331
1301 void LocalDOMWindow::resizeTo(int width, int height, bool hasWidth, bool hasHeig ht) const 1332 void LocalDOMWindow::resizeTo(int width, int height, bool hasWidth, bool hasHeig ht) const
1302 { 1333 {
1303 if (!hasWidth || !hasHeight) 1334 if (!hasWidth || !hasHeight)
1304 UseCounter::count(document(), UseCounter::WindowMoveResizeMissingArgumen ts); 1335 UseCounter::count(document(), UseCounter::WindowMoveResizeMissingArgumen ts);
1305 1336
1306 if (!frame() || !frame()->isMainFrame()) 1337 if (!frame() || !frame()->isMainFrame())
1307 return; 1338 return;
1308 1339
1309 FrameHost* host = frame()->host(); 1340 FrameHost* host = frame()->host();
1310 if (!host) 1341 if (!host)
1311 return; 1342 return;
1312 1343
1313 IntRect fr = host->chrome().windowRect(); 1344 IntRect fr = host->chrome().windowRect();
1314 IntSize dest = IntSize(hasWidth ? width : fr.width(), hasHeight ? height : f r.height()); 1345 IntSize dest = IntSize(hasWidth ? width : fr.width(), hasHeight ? height : f r.height());
1315 IntRect update(fr.location(), dest); 1346 IntRect update(fr.location(), dest);
1316 host->chrome().setWindowRect(update); 1347 host->chrome().setWindowRect(adjustWindowRect(*frame(), update));
1317 } 1348 }
1318 1349
1319 int LocalDOMWindow::requestAnimationFrame(FrameRequestCallback* callback) 1350 int LocalDOMWindow::requestAnimationFrame(FrameRequestCallback* callback)
1320 { 1351 {
1321 callback->m_useLegacyTimeBase = false; 1352 callback->m_useLegacyTimeBase = false;
1322 if (Document* d = document()) 1353 if (Document* d = document())
1323 return d->requestAnimationFrame(callback); 1354 return d->requestAnimationFrame(callback);
1324 return 0; 1355 return 0;
1325 } 1356 }
1326 1357
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
1514 return targetFrame->domWindow(); 1545 return targetFrame->domWindow();
1515 1546
1516 if (urlString.isEmpty()) 1547 if (urlString.isEmpty())
1517 return targetFrame->domWindow(); 1548 return targetFrame->domWindow();
1518 1549
1519 targetFrame->navigate(*activeDocument, completedURL, false); 1550 targetFrame->navigate(*activeDocument, completedURL, false);
1520 return targetFrame->domWindow(); 1551 return targetFrame->domWindow();
1521 } 1552 }
1522 1553
1523 WindowFeatures windowFeatures(windowFeaturesString); 1554 WindowFeatures windowFeatures(windowFeaturesString);
1524 Frame* result = createWindow(urlString, frameName, windowFeatures, *callingW indow, *firstFrame, *frame()); 1555 LocalFrame* result = createWindow(urlString, frameName, windowFeatures, *cal lingWindow, *firstFrame, *frame());
1525 return result ? result->domWindow() : nullptr; 1556 return result ? result->domWindow() : nullptr;
1526 } 1557 }
1527 1558
1528 DEFINE_TRACE(LocalDOMWindow) 1559 DEFINE_TRACE(LocalDOMWindow)
1529 { 1560 {
1530 #if ENABLE(OILPAN) 1561 #if ENABLE(OILPAN)
1531 visitor->trace(m_frameObserver); 1562 visitor->trace(m_frameObserver);
1532 visitor->trace(m_document); 1563 visitor->trace(m_document);
1533 visitor->trace(m_properties); 1564 visitor->trace(m_properties);
1534 visitor->trace(m_screen); 1565 visitor->trace(m_screen);
(...skipping 16 matching lines...) Expand all
1551 DOMWindow::trace(visitor); 1582 DOMWindow::trace(visitor);
1552 DOMWindowLifecycleNotifier::trace(visitor); 1583 DOMWindowLifecycleNotifier::trace(visitor);
1553 } 1584 }
1554 1585
1555 LocalFrame* LocalDOMWindow::frame() const 1586 LocalFrame* LocalDOMWindow::frame() const
1556 { 1587 {
1557 return m_frameObserver->frame(); 1588 return m_frameObserver->frame();
1558 } 1589 }
1559 1590
1560 } // namespace blink 1591 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/frame/LocalDOMWindow.h ('k') | Source/core/frame/Screen.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698