Changeset 279661 in webkit
- Timestamp:
- Jul 7, 2021, 12:57:03 PM (5 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 edited
-
ChangeLog (modified) (1 diff)
-
page/DOMWindow.cpp (modified) (73 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r279659 r279661 1 2021-07-07 Ryosuke Niwa <rniwa@webkit.org> 2 3 Deploy smart pointers in DOMWindow 4 https://bugs.webkit.org/show_bug.cgi?id=227584 5 6 Reviewed by David Kilzer. 7 8 Deployed Ref/RefPtr in more places in DOMWindow. 9 10 * page/DOMWindow.cpp: 11 (WebCore::DOMWindow::performance const): 12 (WebCore::DOMWindow::shouldHaveWebKitNamespaceForWorld): 13 (WebCore::DOMWindow::postMessage): 14 (WebCore::DOMWindow::frameElement const): 15 (WebCore::DOMWindow::focus): 16 (WebCore::DOMWindow::blur): 17 (WebCore::DOMWindow::close): 18 (WebCore::DOMWindow::print): 19 (WebCore::DOMWindow::stop): 20 (WebCore::DOMWindow::alert): 21 (WebCore::DOMWindow::confirmForBindings): 22 (WebCore::DOMWindow::prompt): 23 (WebCore::DOMWindow::outerHeight const): 24 (WebCore::DOMWindow::outerWidth const): 25 (WebCore::DOMWindow::innerHeight const): 26 (WebCore::DOMWindow::innerWidth const): 27 (WebCore::DOMWindow::screenX const): 28 (WebCore::DOMWindow::screenY const): 29 (WebCore::DOMWindow::scrollX const): 30 (WebCore::DOMWindow::scrollY const): 31 (WebCore::DOMWindow::closed const): 32 (WebCore::DOMWindow::name const): 33 (WebCore::DOMWindow::setName): 34 (WebCore::DOMWindow::setStatus): 35 (WebCore::DOMWindow::setDefaultStatus): 36 (WebCore::DOMWindow::opener const): 37 (WebCore::DOMWindow::disownOpener): 38 (WebCore::DOMWindow::parent const): 39 (WebCore::DOMWindow::top const): 40 (WebCore::DOMWindow::consumeTransientActivation): 41 (WebCore::DOMWindow::notifyActivated): 42 (WebCore::DOMWindow::getMatchedCSSRules const): 43 (WebCore::DOMWindow::scrollBy const): 44 (WebCore::DOMWindow::allowedToChangeWindowGeometry const): 45 (WebCore::DOMWindow::setTimeout): 46 (WebCore::DOMWindow::clearTimeout): 47 (WebCore::DOMWindow::setInterval): 48 (WebCore::DOMWindow::requestAnimationFrame): 49 (WebCore::DOMWindow::cancelAnimationFrame): 50 (WebCore::DOMWindow::createImageBitmap): 51 (WebCore::DOMWindow::isSecureContext const): 52 (WebCore::DOMWindow::addEventListener): 53 (WebCore::DOMWindow::startListeningForDeviceOrientationIfNecessary): 54 (WebCore::DOMWindow::startListeningForDeviceMotionIfNecessary): 55 (WebCore::DOMWindow::incrementScrollEventListenersCount): 56 (WebCore::DOMWindow::removeEventListener): 57 (WebCore::DOMWindow::dispatchLoadEvent): 58 (WebCore::DOMWindow::removeAllEventListeners): 59 (WebCore::DOMWindow::setLocation): 60 (WebCore::DOMWindow::createWindow): 61 (WebCore::DOMWindow::open): 62 (WebCore::DOMWindow::showModalDialog): 63 1 64 2021-07-07 Aditya Keerthi <akeerthi@apple.com> 2 65 -
trunk/Source/WebCore/page/DOMWindow.cpp
r278391 r279661 579 579 return Exception { NotSupportedError }; 580 580 581 Document*document = frame->document();581 RefPtr document = frame->document(); 582 582 if (!document) 583 583 return Exception { NotSupportedError }; … … 730 730 { 731 731 if (!m_performance) { 732 auto*documentLoader = document() ? document()->loader() : nullptr;732 RefPtr documentLoader = document() ? document()->loader() : nullptr; 733 733 auto timeOrigin = documentLoader ? documentLoader->timing().timeOrigin() : MonotonicTime::now(); 734 734 m_performance = Performance::create(document(), timeOrigin); … … 776 776 bool DOMWindow::shouldHaveWebKitNamespaceForWorld(DOMWrapperWorld& world) 777 777 { 778 auto*frame = this->frame();778 RefPtr frame = this->frame(); 779 779 if (!frame) 780 780 return false; … … 814 814 return nullptr; 815 815 816 auto*document = this->document();816 RefPtr document = this->document(); 817 817 if (!document) 818 818 return nullptr; … … 838 838 return nullptr; 839 839 840 auto*document = this->document();840 RefPtr document = this->document(); 841 841 if (!document) 842 842 return nullptr; … … 872 872 return { }; 873 873 874 Document*sourceDocument = incumbentWindow.document();874 RefPtr sourceDocument = incumbentWindow.document(); 875 875 876 876 // Compute the target origin. We need to do this synchronously in order … … 906 906 // Capture stack trace only when inspector front-end is loaded as it may be time consuming. 907 907 RefPtr<ScriptCallStack> stackTrace; 908 if (InspectorInstrumentation::consoleAgentEnabled(sourceDocument ))908 if (InspectorInstrumentation::consoleAgentEnabled(sourceDocument.get())) 909 909 stackTrace = createScriptCallStack(JSExecState::currentState()); 910 910 … … 921 921 return; 922 922 923 Ref <Frame>frame = *this->frame();923 Ref frame = *this->frame(); 924 924 if (targetOrigin) { 925 925 // Check target origin now since the target document may have changed since the timer was scheduled. … … 963 963 Element* DOMWindow::frameElement() const 964 964 { 965 auto*frame = this->frame();965 RefPtr frame = this->frame(); 966 966 if (!frame) 967 967 return nullptr; … … 972 972 void DOMWindow::focus(DOMWindow& incumbentWindow) 973 973 { 974 auto*frame = this->frame();975 auto*openerFrame = frame ? frame->loader().opener() : nullptr;974 RefPtr frame = this->frame(); 975 RefPtr openerFrame = frame ? frame->loader().opener() : nullptr; 976 976 focus(openerFrame && openerFrame != frame && incumbentWindow.frame() == openerFrame); 977 977 } … … 979 979 void DOMWindow::focus(bool allowFocus) 980 980 { 981 if (!frame()) 982 return; 983 984 auto protectedFrame = makeRefPtr(frame()); 985 986 Page* page = protectedFrame->page(); 987 if (!page) 988 return; 989 990 allowFocus = allowFocus || WindowFocusAllowedIndicator::windowFocusAllowed() || !protectedFrame->settings().windowFocusRestricted(); 991 992 // If we're a top level window, bring the window to the front. 993 if (protectedFrame->isMainFrame() && allowFocus) 994 page->chrome().focus(); 995 996 if (!protectedFrame->hasHadUserInteraction() && !isSameSecurityOriginAsMainFrame()) 997 return; 998 999 // Clear the current frame's focused node if a new frame is about to be focused. 1000 auto focusedFrame = makeRefPtr(page->focusController().focusedFrame()); 1001 if (focusedFrame && focusedFrame != protectedFrame) 1002 focusedFrame->document()->setFocusedElement(nullptr); 1003 1004 protectedFrame->eventHandler().focusDocumentView(); 1005 } 1006 1007 void DOMWindow::blur() 1008 { 1009 auto* frame = this->frame(); 981 RefPtr frame = this->frame(); 1010 982 if (!frame) 1011 983 return; … … 1015 987 return; 1016 988 1017 if (frame->settings().windowFocusRestricted()) 1018 return; 1019 1020 if (!frame->isMainFrame()) 1021 return; 1022 1023 page->chrome().unfocus(); 1024 } 1025 1026 void DOMWindow::close(Document& document) 1027 { 1028 if (!document.canNavigate(frame())) 1029 return; 1030 close(); 1031 } 1032 1033 void DOMWindow::close() 1034 { 1035 auto* frame = this->frame(); 989 allowFocus = allowFocus || WindowFocusAllowedIndicator::windowFocusAllowed() || !frame->settings().windowFocusRestricted(); 990 991 // If we're a top level window, bring the window to the front. 992 if (frame->isMainFrame() && allowFocus) 993 page->chrome().focus(); 994 995 if (!frame->hasHadUserInteraction() && !isSameSecurityOriginAsMainFrame()) 996 return; 997 998 // Clear the current frame's focused node if a new frame is about to be focused. 999 RefPtr focusedFrame = page->focusController().focusedFrame(); 1000 if (focusedFrame && focusedFrame != frame) 1001 focusedFrame->document()->setFocusedElement(nullptr); 1002 1003 frame->eventHandler().focusDocumentView(); 1004 } 1005 1006 void DOMWindow::blur() 1007 { 1008 RefPtr frame = this->frame(); 1036 1009 if (!frame) 1037 1010 return; … … 1041 1014 return; 1042 1015 1016 if (frame->settings().windowFocusRestricted()) 1017 return; 1018 1019 if (!frame->isMainFrame()) 1020 return; 1021 1022 page->chrome().unfocus(); 1023 } 1024 1025 void DOMWindow::close(Document& document) 1026 { 1027 if (!document.canNavigate(frame())) 1028 return; 1029 close(); 1030 } 1031 1032 void DOMWindow::close() 1033 { 1034 RefPtr frame = this->frame(); 1035 if (!frame) 1036 return; 1037 1038 Page* page = frame->page(); 1039 if (!page) 1040 return; 1041 1043 1042 if (!frame->isMainFrame()) 1044 1043 return; … … 1060 1059 void DOMWindow::print() 1061 1060 { 1062 auto*frame = this->frame();1061 RefPtr frame = this->frame(); 1063 1062 if (!frame) 1064 1063 return; … … 1086 1085 void DOMWindow::stop() 1087 1086 { 1088 auto*frame = this->frame();1087 RefPtr frame = this->frame(); 1089 1088 if (!frame) 1090 1089 return; … … 1097 1096 void DOMWindow::alert(const String& message) 1098 1097 { 1099 auto* frame = this->frame(); 1100 if (!frame) 1101 return; 1102 1103 if (document()->isSandboxed(SandboxModals)) { 1098 RefPtr frame = this->frame(); 1099 if (!frame) 1100 return; 1101 1102 RefPtr document = this->document(); 1103 if (document->isSandboxed(SandboxModals)) { 1104 1104 printErrorMessage("Use of window.alert is not allowed in a sandboxed frame when the allow-modals flag is not set."); 1105 1105 return; … … 1115 1115 } 1116 1116 1117 if (!document ()->securityOrigin().isSameOriginDomain(document()->topDocument().securityOrigin())) {1117 if (!document->securityOrigin().isSameOriginDomain(document->topDocument().securityOrigin())) { 1118 1118 printErrorMessage("Use of window.alert is not allowed in different origin-domain iframes."); 1119 1119 return; 1120 1120 } 1121 1121 1122 frame->document()->updateStyleIfNeeded();1122 document->updateStyleIfNeeded(); 1123 1123 #if ENABLE(POINTER_LOCK) 1124 1124 page->pointerLockController().requestPointerUnlock(); … … 1130 1130 bool DOMWindow::confirmForBindings(const String& message) 1131 1131 { 1132 auto*frame = this->frame();1132 RefPtr frame = this->frame(); 1133 1133 if (!frame) 1134 1134 return false; 1135 1136 if (document()->isSandboxed(SandboxModals)) { 1135 1136 RefPtr document = this->document(); 1137 if (document->isSandboxed(SandboxModals)) { 1137 1138 printErrorMessage("Use of window.confirm is not allowed in a sandboxed frame when the allow-modals flag is not set."); 1138 1139 return false; … … 1148 1149 } 1149 1150 1150 if (!document ()->securityOrigin().isSameOriginDomain(document()->topDocument().securityOrigin())) {1151 if (!document->securityOrigin().isSameOriginDomain(document->topDocument().securityOrigin())) { 1151 1152 printErrorMessage("Use of window.confirm is not allowed in different origin-domain iframes."); 1152 1153 return false; 1153 1154 } 1154 1155 1155 frame->document()->updateStyleIfNeeded();1156 document->updateStyleIfNeeded(); 1156 1157 #if ENABLE(POINTER_LOCK) 1157 1158 page->pointerLockController().requestPointerUnlock(); … … 1163 1164 String DOMWindow::prompt(const String& message, const String& defaultValue) 1164 1165 { 1165 auto*frame = this->frame();1166 RefPtr frame = this->frame(); 1166 1167 if (!frame) 1167 1168 return String(); 1168 1169 1169 if (document()->isSandboxed(SandboxModals)) { 1170 RefPtr document = this->document(); 1171 if (document->isSandboxed(SandboxModals)) { 1170 1172 printErrorMessage("Use of window.prompt is not allowed in a sandboxed frame when the allow-modals flag is not set."); 1171 1173 return String(); … … 1181 1183 } 1182 1184 1183 if (!document ()->securityOrigin().isSameOriginDomain(document()->topDocument().securityOrigin())) {1185 if (!document->securityOrigin().isSameOriginDomain(document->topDocument().securityOrigin())) { 1184 1186 printErrorMessage("Use of window.prompt is not allowed in different origin-domain iframes."); 1185 1187 return String(); 1186 1188 } 1187 1189 1188 frame->document()->updateStyleIfNeeded();1190 document->updateStyleIfNeeded(); 1189 1191 #if ENABLE(POINTER_LOCK) 1190 1192 page->pointerLockController().requestPointerUnlock(); … … 1228 1230 return 0; 1229 1231 1230 auto*view = frame()->isMainFrame() ? frame()->view() : frame()->mainFrame().view();1232 RefPtr view = frame()->isMainFrame() ? frame()->view() : frame()->mainFrame().view(); 1231 1233 if (!view) 1232 1234 return 0; … … 1234 1236 return view->frameRect().height(); 1235 1237 #else 1236 auto*frame = this->frame();1238 RefPtr frame = this->frame(); 1237 1239 if (!frame) 1238 1240 return 0; … … 1252 1254 return 0; 1253 1255 1254 auto*view = frame()->isMainFrame() ? frame()->view() : frame()->mainFrame().view();1256 RefPtr view = frame()->isMainFrame() ? frame()->view() : frame()->mainFrame().view(); 1255 1257 if (!view) 1256 1258 return 0; … … 1258 1260 return view->frameRect().width(); 1259 1261 #else 1260 auto*frame = this->frame();1262 RefPtr frame = this->frame(); 1261 1263 if (!frame) 1262 1264 return 0; … … 1276 1278 1277 1279 // Force enough layout in the parent document to ensure that the FrameView has been resized. 1278 if ( auto ownerElement = makeRefPtr(frameElement()))1280 if (RefPtr ownerElement = frameElement()) 1279 1281 ownerElement->document().updateLayoutIfDimensionsOutOfDate(*ownerElement, HeightDimensionsCheck); 1280 1282 1281 auto frame = makeRefPtr(this->frame());1283 RefPtr frame = this->frame(); 1282 1284 if (!frame) 1283 1285 return 0; 1284 1286 1285 auto view = makeRefPtr(frame->view());1287 RefPtr view = frame->view(); 1286 1288 if (!view) 1287 1289 return 0; … … 1299 1301 ownerElement->document().updateLayoutIfDimensionsOutOfDate(*ownerElement, WidthDimensionsCheck); 1300 1302 1301 auto frame = makeRefPtr(this->frame());1302 if (!frame) 1303 return 0; 1304 1305 auto view = makeRefPtr(frame->view());1303 RefPtr frame = this->frame(); 1304 if (!frame) 1305 return 0; 1306 1307 RefPtr view = frame->view(); 1306 1308 if (!view) 1307 1309 return 0; … … 1312 1314 int DOMWindow::screenX() const 1313 1315 { 1314 auto frame = makeRefPtr(this->frame());1316 RefPtr frame = this->frame(); 1315 1317 if (!frame) 1316 1318 return 0; … … 1325 1327 int DOMWindow::screenY() const 1326 1328 { 1327 auto frame = makeRefPtr(this->frame());1329 RefPtr frame = this->frame(); 1328 1330 if (!frame) 1329 1331 return 0; … … 1338 1340 int DOMWindow::scrollX() const 1339 1341 { 1340 auto frame = makeRefPtr(this->frame());1341 if (!frame) 1342 return 0; 1343 1344 auto view = makeRefPtr(frame->view());1342 RefPtr frame = this->frame(); 1343 if (!frame) 1344 return 0; 1345 1346 RefPtr view = frame->view(); 1345 1347 if (!view) 1346 1348 return 0; … … 1353 1355 1354 1356 // Layout may have affected the current frame: 1355 auto frameAfterLayout = makeRefPtr(this->frame());1357 RefPtr frameAfterLayout = this->frame(); 1356 1358 if (!frameAfterLayout) 1357 1359 return 0; 1358 1360 1359 auto viewAfterLayout = makeRefPtr(frameAfterLayout->view());1361 RefPtr viewAfterLayout = frameAfterLayout->view(); 1360 1362 if (!viewAfterLayout) 1361 1363 return 0; … … 1366 1368 int DOMWindow::scrollY() const 1367 1369 { 1368 auto frame = makeRefPtr(this->frame());1369 if (!frame) 1370 return 0; 1371 1372 auto view = makeRefPtr(frame->view());1370 RefPtr frame = this->frame(); 1371 if (!frame) 1372 return 0; 1373 1374 RefPtr view = frame->view(); 1373 1375 if (!view) 1374 1376 return 0; … … 1381 1383 1382 1384 // Layout may have affected the current frame: 1383 auto frameAfterLayout = makeRefPtr(this->frame());1385 RefPtr frameAfterLayout = this->frame(); 1384 1386 if (!frameAfterLayout) 1385 1387 return 0; 1386 1388 1387 auto viewAfterLayout = makeRefPtr(frameAfterLayout->view());1389 RefPtr viewAfterLayout = frameAfterLayout->view(); 1388 1390 if (!viewAfterLayout) 1389 1391 return 0; … … 1394 1396 bool DOMWindow::closed() const 1395 1397 { 1396 auto*frame = this->frame();1398 RefPtr frame = this->frame(); 1397 1399 if (!frame) 1398 1400 return true; … … 1412 1414 String DOMWindow::name() const 1413 1415 { 1414 auto*frame = this->frame();1416 RefPtr frame = this->frame(); 1415 1417 if (!frame) 1416 1418 return String(); … … 1421 1423 void DOMWindow::setName(const String& string) 1422 1424 { 1423 auto*frame = this->frame();1425 RefPtr frame = this->frame(); 1424 1426 if (!frame) 1425 1427 return; … … 1432 1434 m_status = string; 1433 1435 1434 auto*frame = this->frame();1436 RefPtr frame = this->frame(); 1435 1437 if (!frame) 1436 1438 return; … … 1448 1450 m_defaultStatus = string; 1449 1451 1450 auto*frame = this->frame();1452 RefPtr frame = this->frame(); 1451 1453 if (!frame) 1452 1454 return; … … 1462 1464 WindowProxy* DOMWindow::opener() const 1463 1465 { 1464 auto*frame = this->frame();1466 RefPtr frame = this->frame(); 1465 1467 if (!frame) 1466 1468 return nullptr; 1467 1469 1468 auto*openerFrame = frame->loader().opener();1470 RefPtr openerFrame = frame->loader().opener(); 1469 1471 if (!openerFrame) 1470 1472 return nullptr; … … 1475 1477 void DOMWindow::disownOpener() 1476 1478 { 1477 if ( auto*frame = this->frame())1479 if (RefPtr frame = this->frame()) 1478 1480 frame->loader().setOpener(nullptr); 1479 1481 } … … 1481 1483 WindowProxy* DOMWindow::parent() const 1482 1484 { 1483 auto*frame = this->frame();1485 RefPtr frame = this->frame(); 1484 1486 if (!frame) 1485 1487 return nullptr; 1486 1488 1487 auto*parentFrame = frame->tree().parent();1489 RefPtr parentFrame = frame->tree().parent(); 1488 1490 if (parentFrame) 1489 1491 return &parentFrame->windowProxy(); … … 1494 1496 WindowProxy* DOMWindow::top() const 1495 1497 { 1496 auto*frame = this->frame();1498 RefPtr frame = this->frame(); 1497 1499 if (!frame) 1498 1500 return nullptr; … … 1541 1543 return false; 1542 1544 1543 for ( Frame*frame = this->frame() ? &this->frame()->tree().top() : nullptr; frame; frame = frame->tree().traverseNext()) {1545 for (RefPtr frame = this->frame() ? &this->frame()->tree().top() : nullptr; frame; frame = frame->tree().traverseNext()) { 1544 1546 auto* window = frame->window(); 1545 1547 if (!window || window->lastActivationTimestamp() != MonotonicTime::infinity()) … … 1557 1559 return; 1558 1560 1559 for ( Frame*ancestor = frame() ? frame()->tree().parent() : nullptr; ancestor; ancestor = ancestor->tree().parent()) {1561 for (RefPtr ancestor = frame() ? frame()->tree().parent() : nullptr; ancestor; ancestor = ancestor->tree().parent()) { 1560 1562 if (auto* window = ancestor->window()) 1561 1563 window->setLastActivationTimestamp(activationTime); 1562 1564 } 1563 1565 1564 auto*securityOrigin = this->securityOrigin();1566 RefPtr securityOrigin = this->securityOrigin(); 1565 1567 if (!securityOrigin) 1566 1568 return; 1567 1569 1568 auto*descendant = frame();1570 RefPtr descendant = frame(); 1569 1571 while ((descendant = descendant->tree().traverseNext(frame()))) { 1570 1572 auto* descendantWindow = descendant->window(); … … 1572 1574 continue; 1573 1575 1574 auto*descendantSecurityOrigin = descendantWindow->securityOrigin();1576 RefPtr descendantSecurityOrigin = descendantWindow->securityOrigin(); 1575 1577 if (!descendantSecurityOrigin || !descendantSecurityOrigin->isSameOriginAs(*securityOrigin)) 1576 1578 continue; … … 1602 1604 return nullptr; 1603 1605 1604 auto*frame = this->frame();1606 RefPtr frame = this->frame(); 1605 1607 frame->document()->styleScope().flushPendingUpdate(); 1606 1608 … … 1685 1687 document()->updateLayoutIgnorePendingStylesheets(); 1686 1688 1687 auto*frame = this->frame();1688 if (!frame) 1689 return; 1690 1691 auto view = makeRefPtr(frame->view());1689 RefPtr frame = this->frame(); 1690 if (!frame) 1691 return; 1692 1693 RefPtr view = frame->view(); 1692 1694 if (!view) 1693 1695 return; … … 1735 1737 bool DOMWindow::allowedToChangeWindowGeometry() const 1736 1738 { 1737 auto*frame = this->frame();1739 RefPtr frame = this->frame(); 1738 1740 if (!frame) 1739 1741 return false; … … 1800 1802 ExceptionOr<int> DOMWindow::setTimeout(JSC::JSGlobalObject& state, std::unique_ptr<ScheduledAction> action, int timeout, Vector<JSC::Strong<JSC::Unknown>>&& arguments) 1801 1803 { 1802 auto*context = scriptExecutionContext();1804 RefPtr context = scriptExecutionContext(); 1803 1805 if (!context) 1804 1806 return Exception { InvalidAccessError }; … … 1817 1819 void DOMWindow::clearTimeout(int timeoutId) 1818 1820 { 1819 ScriptExecutionContext*context = scriptExecutionContext();1821 RefPtr context = scriptExecutionContext(); 1820 1822 if (!context) 1821 1823 return; … … 1825 1827 ExceptionOr<int> DOMWindow::setInterval(JSC::JSGlobalObject& state, std::unique_ptr<ScheduledAction> action, int timeout, Vector<JSC::Strong<JSC::Unknown>>&& arguments) 1826 1828 { 1827 auto*context = scriptExecutionContext();1829 RefPtr context = scriptExecutionContext(); 1828 1830 if (!context) 1829 1831 return Exception { InvalidAccessError }; … … 1850 1852 int DOMWindow::requestAnimationFrame(Ref<RequestAnimationFrameCallback>&& callback) 1851 1853 { 1852 auto*document = this->document();1854 RefPtr document = this->document(); 1853 1855 if (!document) 1854 1856 return 0; … … 1868 1870 void DOMWindow::cancelAnimationFrame(int id) 1869 1871 { 1870 auto*document = this->document();1872 RefPtr document = this->document(); 1871 1873 if (!document) 1872 1874 return; … … 1892 1894 void DOMWindow::createImageBitmap(ImageBitmap::Source&& source, ImageBitmapOptions&& options, ImageBitmap::Promise&& promise) 1893 1895 { 1894 auto*document = this->document();1896 RefPtr document = this->document(); 1895 1897 if (!document) { 1896 1898 promise.reject(InvalidStateError); … … 1902 1904 void DOMWindow::createImageBitmap(ImageBitmap::Source&& source, int sx, int sy, int sw, int sh, ImageBitmapOptions&& options, ImageBitmap::Promise&& promise) 1903 1905 { 1904 auto*document = this->document();1906 RefPtr document = this->document(); 1905 1907 if (!document) { 1906 1908 promise.reject(InvalidStateError); … … 1912 1914 bool DOMWindow::isSecureContext() const 1913 1915 { 1914 auto*document = this->document();1916 RefPtr document = this->document(); 1915 1917 if (!document) 1916 1918 return false; … … 1950 1952 return false; 1951 1953 1952 auto*document = this->document();1954 RefPtr document = this->document(); 1953 1955 if (document) { 1954 1956 document->addListenerTypeIfNeeded(eventType); … … 2089 2091 String innerMessage; 2090 2092 if (!isAllowedToUseDeviceOrientation(innerMessage) || !hasPermissionToReceiveDeviceMotionOrOrientationEvents(innerMessage)) { 2091 if ( auto*document = this->document())2093 if (RefPtr document = this->document()) 2092 2094 document->addConsoleMessage(MessageSource::JS, MessageLevel::Warning, makeString("No device orientation events will be fired, reason: ", innerMessage, ".")); 2093 2095 return; … … 2118 2120 if (!isAllowedToUseDeviceMotion(innerMessage) || !hasPermissionToReceiveDeviceMotionOrOrientationEvents(innerMessage)) { 2119 2121 failedToRegisterDeviceMotionEventListener(); 2120 if ( auto*document = this->document())2122 if (RefPtr document = this->document()) 2121 2123 document->addConsoleMessage(MessageSource::JS, MessageLevel::Warning, makeString("No device motion events will be fired, reason: ", innerMessage, ".")); 2122 2124 return; … … 2160 2162 void DOMWindow::incrementScrollEventListenersCount() 2161 2163 { 2162 Document*document = this->document();2164 RefPtr document = this->document(); 2163 2165 if (++m_scrollEventListenerCount == 1 && document == &document->topDocument()) { 2164 Frame* frame = this->frame(); 2165 if (frame && frame->page()) 2166 if (RefPtr frame = this->frame(); frame && frame->page()) 2166 2167 frame->page()->chrome().client().setNeedsScrollNotifications(*frame, true); 2167 2168 } … … 2194 2195 return false; 2195 2196 2196 auto*document = this->document();2197 RefPtr document = this->document(); 2197 2198 if (document) { 2198 2199 if (eventNames().isWheelEventType(eventType)) … … 2260 2261 2261 2262 // Send a separate load event to the element that owns this frame. 2262 if ( frame()) {2263 if ( auto* owner = frame()->ownerElement())2263 if (RefPtr ownerFrame = frame()) { 2264 if (RefPtr owner = ownerFrame->ownerElement()) 2264 2265 owner->dispatchEvent(Event::create(eventNames().loadEvent, Event::CanBubble::No, Event::IsCancelable::No)); 2265 2266 } … … 2343 2344 2344 2345 #if ENABLE(TOUCH_EVENTS) 2345 if ( Document*document = this->document())2346 if (RefPtr document = this->document()) 2346 2347 document->didRemoveEventTargetNode(*document); 2347 2348 #endif … … 2380 2381 return; 2381 2382 2382 Document*activeDocument = activeWindow.document();2383 RefPtr activeDocument = activeWindow.document(); 2383 2384 if (!activeDocument) 2384 2385 return; 2385 2386 2386 auto*frame = this->frame();2387 if (!activeDocument->canNavigate(frame , completedURL))2387 RefPtr frame = this->frame(); 2388 if (!activeDocument->canNavigate(frame.get(), completedURL)) 2388 2389 return; 2389 2390 … … 2486 2487 ExceptionOr<RefPtr<Frame>> DOMWindow::createWindow(const String& urlString, const AtomString& frameName, const WindowFeatures& windowFeatures, DOMWindow& activeWindow, Frame& firstFrame, Frame& openerFrame, const WTF::Function<void(DOMWindow&)>& prepareDialogFunction) 2487 2488 { 2488 Frame*activeFrame = activeWindow.frame();2489 RefPtr activeFrame = activeWindow.frame(); 2489 2490 if (!activeFrame) 2490 2491 return RefPtr<Frame> { nullptr }; 2491 2492 2492 Document*activeDocument = activeWindow.document();2493 RefPtr activeDocument = activeWindow.document(); 2493 2494 if (!activeDocument) 2494 2495 return RefPtr<Frame> { nullptr }; … … 2547 2548 { 2548 2549 #if ENABLE(RESOURCE_LOAD_STATISTICS) 2549 if ( auto*document = this->document()) {2550 if (RefPtr document = this->document()) { 2550 2551 if (document->settings().needsSiteSpecificQuirks() && urlStringToOpen == Quirks::BBCRadioPlayerURLString()) { 2551 2552 auto radioPlayerDomain = RegistrableDomain(URL(URL(), Quirks::staticRadioPlayerURLString())); … … 2560 2561 return RefPtr<WindowProxy> { nullptr }; 2561 2562 2562 auto*activeDocument = activeWindow.document();2563 RefPtr activeDocument = activeWindow.document(); 2563 2564 if (!activeDocument) 2564 2565 return RefPtr<WindowProxy> { nullptr }; 2565 2566 2566 auto*firstFrame = firstWindow.frame();2567 RefPtr firstFrame = firstWindow.frame(); 2567 2568 if (!firstFrame) 2568 2569 return RefPtr<WindowProxy> { nullptr }; … … 2574 2575 #if ENABLE(CONTENT_EXTENSIONS) 2575 2576 auto* page = firstFrame->page(); 2576 auto*firstFrameDocument = firstFrame->document();2577 auto*mainFrameDocument = firstFrame->mainFrame().document();2578 auto*mainFrameDocumentLoader = mainFrameDocument ? mainFrameDocument->loader() : nullptr;2577 RefPtr firstFrameDocument = firstFrame->document(); 2578 RefPtr mainFrameDocument = firstFrame->mainFrame().document(); 2579 RefPtr mainFrameDocumentLoader = mainFrameDocument ? mainFrameDocument->loader() : nullptr; 2579 2580 if (firstFrameDocument && page && mainFrameDocumentLoader) { 2580 2581 auto results = page->userContentProvider().processContentRuleListsForLoad(*page, firstFrameDocument->completeURL(urlString), ContentExtensions::ResourceType::Popup, *mainFrameDocumentLoader); … … 2584 2585 #endif 2585 2586 2586 auto*frame = this->frame();2587 RefPtr frame = this->frame(); 2587 2588 if (!frame) 2588 2589 return RefPtr<WindowProxy> { nullptr }; … … 2591 2592 // Because FrameTree::findFrameForNavigation() returns true for empty strings, we must check for empty frame names. 2592 2593 // Otherwise, illegitimate window.open() calls with no name will pass right through the popup blocker. 2593 if (frameName.isEmpty() || !frame->loader().findFrameForNavigation(frameName, activeDocument ))2594 if (frameName.isEmpty() || !frame->loader().findFrameForNavigation(frameName, activeDocument.get())) 2594 2595 return RefPtr<WindowProxy> { nullptr }; 2595 2596 } … … 2597 2598 // Get the target frame for the special cases of _top and _parent. 2598 2599 // In those cases, we schedule a location change right now and return early. 2599 Frame* targetFrame = nullptr;2600 RefPtr<Frame> targetFrame; 2600 2601 if (equalIgnoringASCIICase(frameName, "_top")) 2601 2602 targetFrame = &frame->tree().top(); 2602 2603 else if (equalIgnoringASCIICase(frameName, "_parent")) { 2603 if ( Frame*parent = frame->tree().parent())2604 if (RefPtr parent = frame->tree().parent()) 2604 2605 targetFrame = parent; 2605 2606 else … … 2607 2608 } 2608 2609 if (targetFrame) { 2609 if (!activeDocument->canNavigate(targetFrame ))2610 if (!activeDocument->canNavigate(targetFrame.get())) 2610 2611 return RefPtr<WindowProxy> { nullptr }; 2611 2612 … … 2640 2641 if (!activeWindow.frame()) 2641 2642 return; 2642 Frame*firstFrame = firstWindow.frame();2643 RefPtr firstFrame = firstWindow.frame(); 2643 2644 if (!firstFrame) 2644 2645 return; 2645 2646 2646 auto*frame = this->frame();2647 RefPtr frame = this->frame(); 2647 2648 auto* page = frame->page(); 2648 2649 if (!page)
Note:
See TracChangeset
for help on using the changeset viewer.