Changeset 236965 in webkit
- Timestamp:
- Oct 9, 2018, 10:15:21 AM (8 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 5 edited
-
ChangeLog (modified) (1 diff)
-
dom/Document.cpp (modified) (2 diffs)
-
dom/Document.h (modified) (1 diff)
-
page/DOMWindow.cpp (modified) (69 diffs)
-
page/DOMWindow.h (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r236964 r236965 1 2018-10-09 Chris Dumez <cdumez@apple.com> 2 3 Have DOMWindow get its frame from its document 4 https://bugs.webkit.org/show_bug.cgi?id=190389 5 6 Reviewed by Geoff Garen. 7 8 Have DOMWindow get its frame from its document instead of having its own m_frame which can potentially 9 be out-of-sync. 10 11 * dom/Document.cpp: 12 (WebCore::Document::frameDestroyed): 13 (WebCore::Document::willDetachPage): 14 (WebCore::Document::attachToCachedFrame): 15 * dom/Document.h: 16 * page/DOMWindow.cpp: 17 (WebCore::DOMWindow::allowPopUp): 18 (WebCore::ContextDestructionObserver): 19 (WebCore::DOMWindow::didSecureTransitionTo): 20 (WebCore::DOMWindow::frameDestroyed): 21 (WebCore::DOMWindow::willDetachDocumentFromFrame): 22 (WebCore::DOMWindow::reconnectDOMWindowProperties): 23 (WebCore::DOMWindow::isCurrentlyDisplayedInFrame const): 24 (WebCore::DOMWindow::collectMatchingElementsInFlatTree): 25 (WebCore::DOMWindow::matchingElementInFlatTree): 26 (WebCore::DOMWindow::orientation const): 27 (WebCore::DOMWindow::console const): 28 (WebCore::DOMWindow::shouldHaveWebKitNamespaceForWorld): 29 (WebCore::DOMWindow::webkitNamespace): 30 (WebCore::DOMWindow::postMessage): 31 (WebCore::DOMWindow::postMessageTimerFired): 32 (WebCore::DOMWindow::frameElement const): 33 (WebCore::DOMWindow::focus): 34 (WebCore::DOMWindow::blur): 35 (WebCore::DOMWindow::close): 36 (WebCore::DOMWindow::print): 37 (WebCore::DOMWindow::stop): 38 (WebCore::DOMWindow::alert): 39 (WebCore::DOMWindow::confirm): 40 (WebCore::DOMWindow::prompt): 41 (WebCore::DOMWindow::find const): 42 (WebCore::DOMWindow::outerHeight const): 43 (WebCore::DOMWindow::outerWidth const): 44 (WebCore::DOMWindow::innerHeight const): 45 (WebCore::DOMWindow::innerWidth const): 46 (WebCore::DOMWindow::screenX const): 47 (WebCore::DOMWindow::screenY const): 48 (WebCore::DOMWindow::scrollX const): 49 (WebCore::DOMWindow::scrollY const): 50 (WebCore::DOMWindow::closed const): 51 (WebCore::DOMWindow::length const): 52 (WebCore::DOMWindow::name const): 53 (WebCore::DOMWindow::setName): 54 (WebCore::DOMWindow::setStatus): 55 (WebCore::DOMWindow::setDefaultStatus): 56 (WebCore::DOMWindow::self const): 57 (WebCore::DOMWindow::opener const): 58 (WebCore::DOMWindow::disownOpener): 59 (WebCore::DOMWindow::parent const): 60 (WebCore::DOMWindow::top const): 61 (WebCore::DOMWindow::getMatchedCSSRules const): 62 (WebCore::DOMWindow::devicePixelRatio const): 63 (WebCore::DOMWindow::scrollBy const): 64 (WebCore::DOMWindow::scrollTo const): 65 (WebCore::DOMWindow::allowedToChangeWindowGeometry const): 66 (WebCore::DOMWindow::moveBy const): 67 (WebCore::DOMWindow::moveTo const): 68 (WebCore::DOMWindow::resizeBy const): 69 (WebCore::DOMWindow::resizeTo const): 70 (WebCore::DOMWindow::clearTimeout): 71 (WebCore::DOMWindow::isSameSecurityOriginAsMainFrame const): 72 (WebCore::DOMWindow::finishedLoading): 73 (WebCore::DOMWindow::setLocation): 74 (WebCore::DOMWindow::open): 75 (WebCore::DOMWindow::showModalDialog): 76 (WebCore::DOMWindow::frame const): 77 (WebCore::FrameDestructionObserver): Deleted. 78 (WebCore::DOMWindow::willDetachPage): Deleted. 79 (WebCore::DOMWindow::detachFromFrame): Deleted. 80 (WebCore::DOMWindow::attachToFrame): Deleted. 81 * page/DOMWindow.h: 82 1 83 2018-10-09 Jer Noble <jer.noble@apple.com> 2 84 -
trunk/Source/WebCore/dom/Document.cpp
r236954 r236965 2333 2333 // detachFromFrame() must be called before destroying the Frame. 2334 2334 RELEASE_ASSERT(!m_frame); 2335 2336 if (auto* window = domWindow()) 2337 window->frameDestroyed(); 2338 2335 2339 FrameDestructionObserver::frameDestroyed(); 2340 } 2341 2342 void Document::willDetachPage() 2343 { 2344 FrameDestructionObserver::willDetachPage(); 2345 2346 if (domWindow() && frame()) 2347 InspectorInstrumentation::frameWindowDiscarded(*frame(), domWindow()); 2336 2348 } 2337 2349 … … 2342 2354 ASSERT(m_pageCacheState == Document::InPageCache); 2343 2355 observeFrame(&cachedFrame.view()->frame()); 2344 if (auto* window = domWindow())2345 window->attachToFrame(cachedFrame.view()->frame());2346 2356 } 2347 2357 -
trunk/Source/WebCore/dom/Document.h
r236954 r236965 1526 1526 1527 1527 void updateTitleElement(Element& changingTitleElement); 1528 void willDetachPage() final; 1528 1529 void frameDestroyed() final; 1529 1530 -
trunk/Source/WebCore/page/DOMWindow.cpp
r236917 r236965 376 376 bool DOMWindow::allowPopUp() 377 377 { 378 return m_frame && allowPopUp(*m_frame); 378 auto* frame = this->frame(); 379 return frame && allowPopUp(*frame); 379 380 } 380 381 … … 406 407 : AbstractDOMWindow(GlobalWindowIdentifier { Process::identifier(), generateObjectIdentifier<WindowIdentifierType>() }) 407 408 , ContextDestructionObserver(&document) 408 , FrameDestructionObserver(document.frame())409 409 { 410 410 ASSERT(frame()); … … 415 415 { 416 416 observeContext(&document); 417 observeFrame(document.frame());418 417 } 419 418 … … 477 476 478 477 willDestroyDocumentInFrame(); 479 FrameDestructionObserver::frameDestroyed();480 478 resetDOMWindowProperties(); 481 479 JSDOMWindowBase::fireFrameClearedWatchpointsForWindow(this); 482 }483 484 void DOMWindow::willDetachPage()485 {486 if (m_frame)487 InspectorInstrumentation::frameWindowDiscarded(*m_frame, this);488 480 } 489 481 … … 516 508 if (m_performance) 517 509 m_performance->clearResourceTimings(); 518 519 detachFromFrame();520 510 } 521 511 … … 582 572 // unregister themselves from the DOMWindow as a result of the call to reconnectFromPageCache. 583 573 for (auto& property : copyToVector(m_properties)) 584 property->reconnectFrameFromDocumentSuspension( m_frame);574 property->reconnectFrameFromDocumentSuspension(frame()); 585 575 } 586 576 … … 611 601 bool DOMWindow::isCurrentlyDisplayedInFrame() const 612 602 { 613 return m_frame && m_frame->document()->domWindow() == this; 603 auto* frame = this->frame(); 604 return frame && frame->document()->domWindow() == this; 614 605 } 615 606 … … 635 626 ExceptionOr<Ref<NodeList>> DOMWindow::collectMatchingElementsInFlatTree(Node& scope, const String& selectors) 636 627 { 637 auto queryOrException = selectorQueryInFrame( m_frame, selectors);628 auto queryOrException = selectorQueryInFrame(frame(), selectors); 638 629 if (queryOrException.hasException()) 639 630 return queryOrException.releaseException(); … … 655 646 ExceptionOr<RefPtr<Element>> DOMWindow::matchingElementInFlatTree(Node& scope, const String& selectors) 656 647 { 657 auto queryOrException = selectorQueryInFrame( m_frame, selectors);648 auto queryOrException = selectorQueryInFrame(frame(), selectors); 658 649 if (queryOrException.hasException()) 659 650 return queryOrException.releaseException(); … … 676 667 int DOMWindow::orientation() const 677 668 { 678 if (!m_frame) 669 auto* frame = this->frame(); 670 if (!frame) 679 671 return 0; 680 672 681 return m_frame->orientation();673 return frame->orientation(); 682 674 } 683 675 … … 770 762 if (!isCurrentlyDisplayedInFrame()) 771 763 return nullptr; 772 return m_frame->page() ? &m_frame->page()->console() : nullptr; 764 auto* frame = this->frame(); 765 return frame->page() ? &frame->page()->console() : nullptr; 773 766 } 774 767 … … 833 826 bool DOMWindow::shouldHaveWebKitNamespaceForWorld(DOMWrapperWorld& world) 834 827 { 835 if (!m_frame) 828 auto* frame = this->frame(); 829 if (!frame) 836 830 return false; 837 831 838 auto* page = m_frame->page();832 auto* page = frame->page(); 839 833 if (!page) 840 834 return false; … … 855 849 if (!isCurrentlyDisplayedInFrame()) 856 850 return nullptr; 857 auto* page = m_frame->page();851 auto* page = frame()->page(); 858 852 if (!page) 859 853 return nullptr; … … 972 966 timer->startOneShot(0_s); 973 967 974 InspectorInstrumentation::didPostMessage(* m_frame, *timer, state);968 InspectorInstrumentation::didPostMessage(*frame(), *timer, state); 975 969 976 970 return { }; … … 982 976 return; 983 977 978 auto* frame = this->frame(); 984 979 if (auto* intendedTargetOrigin = timer.targetOrigin()) { 985 980 // Check target origin now since the target document may have changed since the timer was scheduled. … … 993 988 } 994 989 995 InspectorInstrumentation::didFailPostMessage(* m_frame, timer);990 InspectorInstrumentation::didFailPostMessage(*frame, timer); 996 991 return; 997 992 } 998 993 } 999 994 1000 InspectorInstrumentation::willDispatchPostMessage(* m_frame, timer);995 InspectorInstrumentation::willDispatchPostMessage(*frame, timer); 1001 996 1002 997 dispatchEvent(timer.event(*document())); 1003 998 1004 InspectorInstrumentation::didDispatchPostMessage(* m_frame, timer);999 InspectorInstrumentation::didDispatchPostMessage(*frame, timer); 1005 1000 } 1006 1001 … … 1016 1011 Element* DOMWindow::frameElement() const 1017 1012 { 1018 if (!m_frame) 1019 return nullptr; 1020 1021 return m_frame->ownerElement(); 1013 auto* frame = this->frame(); 1014 if (!frame) 1015 return nullptr; 1016 1017 return frame->ownerElement(); 1022 1018 } 1023 1019 … … 1030 1026 void DOMWindow::focus(bool allowFocus) 1031 1027 { 1032 if (! m_frame)1033 return; 1034 1035 Page* page = m_frame->page();1028 if (!frame()) 1029 return; 1030 1031 Page* page = frame()->page(); 1036 1032 if (!page) 1037 1033 return; 1038 1034 1039 allowFocus = allowFocus || WindowFocusAllowedIndicator::windowFocusAllowed() || ! m_frame->settings().windowFocusRestricted();1035 allowFocus = allowFocus || WindowFocusAllowedIndicator::windowFocusAllowed() || !frame()->settings().windowFocusRestricted(); 1040 1036 1041 1037 // If we're a top level window, bring the window to the front. 1042 if ( m_frame->isMainFrame() && allowFocus)1038 if (frame()->isMainFrame() && allowFocus) 1043 1039 page->chrome().focus(); 1044 1040 1045 if (! m_frame)1041 if (!frame()) 1046 1042 return; 1047 1043 1048 1044 // Clear the current frame's focused node if a new frame is about to be focused. 1049 1045 Frame* focusedFrame = page->focusController().focusedFrame(); 1050 if (focusedFrame && focusedFrame != m_frame)1046 if (focusedFrame && focusedFrame != frame()) 1051 1047 focusedFrame->document()->setFocusedElement(nullptr); 1052 1048 1053 // setFocusedElement may clear m_frame, so recheck before using it.1054 if ( m_frame)1055 m_frame->eventHandler().focusDocumentView();1049 // setFocusedElement may clear frame(), so recheck before using it. 1050 if (auto* frame = this->frame()) 1051 frame->eventHandler().focusDocumentView(); 1056 1052 } 1057 1053 1058 1054 void DOMWindow::blur() 1059 1055 { 1060 if (!m_frame) 1061 return; 1062 1063 Page* page = m_frame->page(); 1056 auto* frame = this->frame(); 1057 if (!frame) 1058 return; 1059 1060 Page* page = frame->page(); 1064 1061 if (!page) 1065 1062 return; 1066 1063 1067 if ( m_frame->settings().windowFocusRestricted())1068 return; 1069 1070 if (! m_frame->isMainFrame())1064 if (frame->settings().windowFocusRestricted()) 1065 return; 1066 1067 if (!frame->isMainFrame()) 1071 1068 return; 1072 1069 … … 1076 1073 void DOMWindow::close(Document& document) 1077 1074 { 1078 if (!document.canNavigate( m_frame))1075 if (!document.canNavigate(frame())) 1079 1076 return; 1080 1077 close(); … … 1083 1080 void DOMWindow::close() 1084 1081 { 1085 if (!m_frame) 1086 return; 1087 1088 Page* page = m_frame->page(); 1082 auto* frame = this->frame(); 1083 if (!frame) 1084 return; 1085 1086 Page* page = frame->page(); 1089 1087 if (!page) 1090 1088 return; 1091 1089 1092 if (! m_frame->isMainFrame())1090 if (!frame->isMainFrame()) 1093 1091 return; 1094 1092 … … 1098 1096 } 1099 1097 1100 if (! m_frame->loader().shouldClose())1098 if (!frame->loader().shouldClose()) 1101 1099 return; 1102 1100 … … 1107 1105 void DOMWindow::print() 1108 1106 { 1109 if (!m_frame) 1110 return; 1111 1112 auto* page = m_frame->page(); 1107 auto* frame = this->frame(); 1108 if (!frame) 1109 return; 1110 1111 auto* page = frame->page(); 1113 1112 if (!page) 1114 1113 return; … … 1119 1118 } 1120 1119 1121 if ( m_frame->loader().activeDocumentLoader()->isLoading()) {1120 if (frame->loader().activeDocumentLoader()->isLoading()) { 1122 1121 m_shouldPrintWhenFinishedLoading = true; 1123 1122 return; 1124 1123 } 1125 1124 m_shouldPrintWhenFinishedLoading = false; 1126 page->chrome().print(* m_frame);1125 page->chrome().print(*frame); 1127 1126 } 1128 1127 1129 1128 void DOMWindow::stop() 1130 1129 { 1131 if (!m_frame) 1130 auto* frame = this->frame(); 1131 if (!frame) 1132 1132 return; 1133 1133 1134 1134 // We must check whether the load is complete asynchronously, because we might still be parsing 1135 1135 // the document until the callstack unwinds. 1136 m_frame->loader().stopForUserCancel(true);1136 frame->loader().stopForUserCancel(true); 1137 1137 } 1138 1138 1139 1139 void DOMWindow::alert(const String& message) 1140 1140 { 1141 if (!m_frame) 1141 auto* frame = this->frame(); 1142 if (!frame) 1142 1143 return; 1143 1144 … … 1147 1148 } 1148 1149 1149 auto* page = m_frame->page();1150 auto* page = frame->page(); 1150 1151 if (!page) 1151 1152 return; … … 1156 1157 } 1157 1158 1158 m_frame->document()->updateStyleIfNeeded();1159 frame->document()->updateStyleIfNeeded(); 1159 1160 #if ENABLE(POINTER_LOCK) 1160 1161 page->pointerLockController().requestPointerUnlock(); 1161 1162 #endif 1162 1163 1163 page->chrome().runJavaScriptAlert(* m_frame, message);1164 page->chrome().runJavaScriptAlert(*frame, message); 1164 1165 } 1165 1166 1166 1167 bool DOMWindow::confirm(const String& message) 1167 1168 { 1168 if (!m_frame) 1169 auto* frame = this->frame(); 1170 if (!frame) 1169 1171 return false; 1170 1172 … … 1174 1176 } 1175 1177 1176 auto* page = m_frame->page();1178 auto* page = frame->page(); 1177 1179 if (!page) 1178 1180 return false; … … 1183 1185 } 1184 1186 1185 m_frame->document()->updateStyleIfNeeded();1187 frame->document()->updateStyleIfNeeded(); 1186 1188 #if ENABLE(POINTER_LOCK) 1187 1189 page->pointerLockController().requestPointerUnlock(); 1188 1190 #endif 1189 1191 1190 return page->chrome().runJavaScriptConfirm(* m_frame, message);1192 return page->chrome().runJavaScriptConfirm(*frame, message); 1191 1193 } 1192 1194 1193 1195 String DOMWindow::prompt(const String& message, const String& defaultValue) 1194 1196 { 1195 if (!m_frame) 1197 auto* frame = this->frame(); 1198 if (!frame) 1196 1199 return String(); 1197 1200 … … 1201 1204 } 1202 1205 1203 auto* page = m_frame->page();1206 auto* page = frame->page(); 1204 1207 if (!page) 1205 1208 return String(); … … 1210 1213 } 1211 1214 1212 m_frame->document()->updateStyleIfNeeded();1215 frame->document()->updateStyleIfNeeded(); 1213 1216 #if ENABLE(POINTER_LOCK) 1214 1217 page->pointerLockController().requestPointerUnlock(); … … 1216 1219 1217 1220 String returnValue; 1218 if (page->chrome().runJavaScriptPrompt(* m_frame, message, defaultValue, returnValue))1221 if (page->chrome().runJavaScriptPrompt(*frame, message, defaultValue, returnValue)) 1219 1222 return returnValue; 1220 1223 … … 1235 1238 if (wrap) 1236 1239 options.add(WrapAround); 1237 return m_frame->editor().findString(string, options);1240 return frame()->editor().findString(string, options); 1238 1241 } 1239 1242 … … 1248 1251 return 0; 1249 1252 #else 1250 if (!m_frame) 1253 auto* frame = this->frame(); 1254 if (!frame) 1251 1255 return 0; 1252 1256 1253 Page* page = m_frame->page();1257 Page* page = frame->page(); 1254 1258 if (!page) 1255 1259 return 0; … … 1264 1268 return 0; 1265 1269 #else 1266 if (!m_frame) 1270 auto* frame = this->frame(); 1271 if (!frame) 1267 1272 return 0; 1268 1273 1269 Page* page = m_frame->page();1274 Page* page = frame->page(); 1270 1275 if (!page) 1271 1276 return 0; … … 1277 1282 int DOMWindow::innerHeight() const 1278 1283 { 1279 if (!m_frame) 1284 auto* frame = this->frame(); 1285 if (!frame) 1280 1286 return 0; 1281 1287 … … 1284 1290 frameElement->document().updateLayoutIfDimensionsOutOfDate(*frameElement, HeightDimensionsCheck); 1285 1291 1286 FrameView* view = m_frame->view();1292 FrameView* view = frame->view(); 1287 1293 if (!view) 1288 1294 return 0; … … 1293 1299 int DOMWindow::innerWidth() const 1294 1300 { 1295 if (!m_frame) 1301 auto* frame = this->frame(); 1302 if (!frame) 1296 1303 return 0; 1297 1304 … … 1300 1307 frameElement->document().updateLayoutIfDimensionsOutOfDate(*frameElement, WidthDimensionsCheck); 1301 1308 1302 FrameView* view = m_frame->view();1309 FrameView* view = frame->view(); 1303 1310 if (!view) 1304 1311 return 0; … … 1309 1316 int DOMWindow::screenX() const 1310 1317 { 1311 if (!m_frame) 1318 auto* frame = this->frame(); 1319 if (!frame) 1312 1320 return 0; 1313 1321 1314 Page* page = m_frame->page();1322 Page* page = frame->page(); 1315 1323 if (!page) 1316 1324 return 0; … … 1321 1329 int DOMWindow::screenY() const 1322 1330 { 1323 if (!m_frame) 1331 auto* frame = this->frame(); 1332 if (!frame) 1324 1333 return 0; 1325 1334 1326 Page* page = m_frame->page();1335 Page* page = frame->page(); 1327 1336 if (!page) 1328 1337 return 0; … … 1333 1342 int DOMWindow::scrollX() const 1334 1343 { 1335 if (!m_frame) 1344 auto* frame = this->frame(); 1345 if (!frame) 1336 1346 return 0; 1337 1347 1338 FrameView* view = m_frame->view();1348 FrameView* view = frame->view(); 1339 1349 if (!view) 1340 1350 return 0; … … 1344 1354 return 0; 1345 1355 1346 m_frame->document()->updateLayoutIgnorePendingStylesheets();1356 frame->document()->updateLayoutIgnorePendingStylesheets(); 1347 1357 1348 1358 return view->mapFromLayoutToCSSUnits(view->contentsScrollPosition().x()); … … 1351 1361 int DOMWindow::scrollY() const 1352 1362 { 1353 if (!m_frame) 1363 auto* frame = this->frame(); 1364 if (!frame) 1354 1365 return 0; 1355 1366 1356 FrameView* view = m_frame->view();1367 FrameView* view = frame->view(); 1357 1368 if (!view) 1358 1369 return 0; … … 1362 1373 return 0; 1363 1374 1364 m_frame->document()->updateLayoutIgnorePendingStylesheets();1375 frame->document()->updateLayoutIgnorePendingStylesheets(); 1365 1376 1366 1377 return view->mapFromLayoutToCSSUnits(view->contentsScrollPosition().y()); … … 1369 1380 bool DOMWindow::closed() const 1370 1381 { 1371 return ! m_frame;1382 return !frame(); 1372 1383 } 1373 1384 … … 1377 1388 return 0; 1378 1389 1379 return m_frame->tree().scopedChildCount();1390 return frame()->tree().scopedChildCount(); 1380 1391 } 1381 1392 1382 1393 String DOMWindow::name() const 1383 1394 { 1384 if (!m_frame) 1395 auto* frame = this->frame(); 1396 if (!frame) 1385 1397 return String(); 1386 1398 1387 return m_frame->tree().name();1399 return frame->tree().name(); 1388 1400 } 1389 1401 1390 1402 void DOMWindow::setName(const String& string) 1391 1403 { 1392 if (!m_frame) 1393 return; 1394 1395 m_frame->tree().setName(string); 1404 auto* frame = this->frame(); 1405 if (!frame) 1406 return; 1407 1408 frame->tree().setName(string); 1396 1409 } 1397 1410 … … 1400 1413 m_status = string; 1401 1414 1402 if (!m_frame) 1403 return; 1404 1405 Page* page = m_frame->page(); 1415 auto* frame = this->frame(); 1416 if (!frame) 1417 return; 1418 1419 Page* page = frame->page(); 1406 1420 if (!page) 1407 1421 return; 1408 1422 1409 ASSERT(m_frame->document()); // Client calls shouldn't be made when the frame is in inconsistent state. 1410 page->chrome().setStatusbarText(*m_frame, m_status); 1411 } 1412 1413 void DOMWindow::detachFromFrame() 1414 { 1415 observeFrame(nullptr); 1416 } 1417 1418 void DOMWindow::attachToFrame(Frame& frame) 1419 { 1420 observeFrame(&frame); 1421 } 1422 1423 ASSERT(frame->document()); // Client calls shouldn't be made when the frame is in inconsistent state. 1424 page->chrome().setStatusbarText(*frame, m_status); 1425 } 1426 1423 1427 void DOMWindow::setDefaultStatus(const String& string) 1424 1428 { 1425 1429 m_defaultStatus = string; 1426 1430 1427 if (!m_frame) 1428 return; 1429 1430 Page* page = m_frame->page(); 1431 auto* frame = this->frame(); 1432 if (!frame) 1433 return; 1434 1435 Page* page = frame->page(); 1431 1436 if (!page) 1432 1437 return; 1433 1438 1434 ASSERT( m_frame->document()); // Client calls shouldn't be made when the frame is in inconsistent state.1435 page->chrome().setStatusbarText(* m_frame, m_defaultStatus);1439 ASSERT(frame->document()); // Client calls shouldn't be made when the frame is in inconsistent state. 1440 page->chrome().setStatusbarText(*frame, m_defaultStatus); 1436 1441 } 1437 1442 1438 1443 WindowProxy* DOMWindow::self() const 1439 1444 { 1440 if (!m_frame) 1441 return nullptr; 1442 1443 return &m_frame->windowProxy(); 1445 auto* frame = this->frame(); 1446 if (!frame) 1447 return nullptr; 1448 1449 return &frame->windowProxy(); 1444 1450 } 1445 1451 1446 1452 WindowProxy* DOMWindow::opener() const 1447 1453 { 1448 if (!m_frame) 1449 return nullptr; 1450 1451 auto* openerFrame = m_frame->loader().opener(); 1454 auto* frame = this->frame(); 1455 if (!frame) 1456 return nullptr; 1457 1458 auto* openerFrame = frame->loader().opener(); 1452 1459 if (!openerFrame) 1453 1460 return nullptr; … … 1458 1465 void DOMWindow::disownOpener() 1459 1466 { 1460 if ( m_frame)1461 m_frame->loader().setOpener(nullptr);1467 if (auto* frame = this->frame()) 1468 frame->loader().setOpener(nullptr); 1462 1469 } 1463 1470 1464 1471 WindowProxy* DOMWindow::parent() const 1465 1472 { 1466 if (!m_frame) 1467 return nullptr; 1468 1469 auto* parentFrame = m_frame->tree().parent(); 1473 auto* frame = this->frame(); 1474 if (!frame) 1475 return nullptr; 1476 1477 auto* parentFrame = frame->tree().parent(); 1470 1478 if (parentFrame) 1471 1479 return &parentFrame->windowProxy(); 1472 1480 1473 return & m_frame->windowProxy();1481 return &frame->windowProxy(); 1474 1482 } 1475 1483 1476 1484 WindowProxy* DOMWindow::top() const 1477 1485 { 1478 if (!m_frame) 1479 return nullptr; 1480 1481 if (!m_frame->page()) 1482 return nullptr; 1483 1484 return &m_frame->tree().top().windowProxy(); 1486 auto* frame = this->frame(); 1487 if (!frame) 1488 return nullptr; 1489 1490 if (!frame->page()) 1491 return nullptr; 1492 1493 return &frame->tree().top().windowProxy(); 1485 1494 } 1486 1495 … … 1520 1529 return nullptr; 1521 1530 1522 m_frame->document()->styleScope().flushPendingUpdate(); 1531 auto* frame = this->frame(); 1532 frame->document()->styleScope().flushPendingUpdate(); 1523 1533 1524 1534 unsigned rulesToInclude = StyleResolver::AuthorCSSRules; … … 1528 1538 PseudoId pseudoId = CSSSelector::pseudoId(pseudoType); 1529 1539 1530 auto matchedRules = m_frame->document()->styleScope().resolver().pseudoStyleRulesForElement(element, pseudoId, rulesToInclude);1540 auto matchedRules = frame->document()->styleScope().resolver().pseudoStyleRulesForElement(element, pseudoId, rulesToInclude); 1531 1541 if (matchedRules.isEmpty()) 1532 1542 return nullptr; 1533 1543 1534 bool allowCrossOrigin = m_frame->settings().crossOriginCheckInGetMatchedCSSRulesDisabled();1544 bool allowCrossOrigin = frame->settings().crossOriginCheckInGetMatchedCSSRulesDisabled(); 1535 1545 1536 1546 RefPtr<StaticCSSRuleList> ruleList = StaticCSSRuleList::create(); … … 1579 1589 double DOMWindow::devicePixelRatio() const 1580 1590 { 1581 if (!m_frame) 1591 auto* frame = this->frame(); 1592 if (!frame) 1582 1593 return 0.0; 1583 1594 1584 Page* page = m_frame->page();1595 Page* page = frame->page(); 1585 1596 if (!page) 1586 1597 return 0.0; … … 1601 1612 document()->updateLayoutIgnorePendingStylesheets(); 1602 1613 1603 FrameView* view = m_frame->view();1614 FrameView* view = frame()->view(); 1604 1615 if (!view) 1605 1616 return; … … 1621 1632 return; 1622 1633 1623 RefPtr<FrameView> view = m_frame->view();1634 RefPtr<FrameView> view = frame()->view(); 1624 1635 if (!view) 1625 1636 return; … … 1640 1651 bool DOMWindow::allowedToChangeWindowGeometry() const 1641 1652 { 1642 if (!m_frame) 1653 auto* frame = this->frame(); 1654 if (!frame) 1643 1655 return false; 1644 if (! m_frame->page())1656 if (!frame->page()) 1645 1657 return false; 1646 if (! m_frame->isMainFrame())1658 if (!frame->isMainFrame()) 1647 1659 return false; 1648 1660 // Prevent web content from tricking the user into initiating a drag. 1649 if ( m_frame->eventHandler().mousePressed())1661 if (frame->eventHandler().mousePressed()) 1650 1662 return false; 1651 1663 return true; … … 1657 1669 return; 1658 1670 1659 Page* page = m_frame->page();1671 auto* page = frame()->page(); 1660 1672 FloatRect fr = page->chrome().windowRect(); 1661 1673 FloatRect update = fr; … … 1669 1681 return; 1670 1682 1671 Page* page = m_frame->page();1683 auto* page = frame()->page(); 1672 1684 FloatRect fr = page->chrome().windowRect(); 1673 1685 FloatRect sr = screenAvailableRect(page->mainFrame().view()); … … 1683 1695 return; 1684 1696 1685 Page* page = m_frame->page();1697 auto* page = frame()->page(); 1686 1698 FloatRect fr = page->chrome().windowRect(); 1687 1699 FloatSize dest = fr.size() + FloatSize(x, y); … … 1695 1707 return; 1696 1708 1697 Page* page = m_frame->page();1709 auto* page = frame()->page(); 1698 1710 FloatRect fr = page->chrome().windowRect(); 1699 1711 FloatSize dest = FloatSize(width, height); … … 1722 1734 { 1723 1735 #if PLATFORM(IOS) 1724 if ( m_frame) {1725 Document* document = m_frame->document();1736 if (auto* frame = this->frame()) { 1737 Document* document = frame->document(); 1726 1738 if (timeoutId > 0 && document) { 1727 1739 DOMTimer* timer = document->findTimeout(timeoutId); … … 1730 1742 1731 1743 if (!WebThreadCountOfObservedContentModifiers()) { 1732 if (Page* page = m_frame->page())1733 page->chrome().client().observedContentChange(* m_frame);1744 if (Page* page = frame->page()) 1745 page->chrome().client().observedContentChange(*frame); 1734 1746 } 1735 1747 } … … 1834 1846 bool DOMWindow::isSameSecurityOriginAsMainFrame() const 1835 1847 { 1836 if (!m_frame || !m_frame->page() || !document()) 1848 auto* frame = this->frame(); 1849 if (!frame || !frame->page() || !document()) 1837 1850 return false; 1838 1851 1839 if ( m_frame->isMainFrame())1852 if (frame->isMainFrame()) 1840 1853 return true; 1841 1854 1842 Document* mainFrameDocument = m_frame->mainFrame().document();1855 Document* mainFrameDocument = frame->mainFrame().document(); 1843 1856 1844 1857 if (mainFrameDocument && document()->securityOrigin().canAccess(mainFrameDocument->securityOrigin())) … … 2133 2146 if (m_shouldPrintWhenFinishedLoading) { 2134 2147 m_shouldPrintWhenFinishedLoading = false; 2135 if ( m_frame->loader().activeDocumentLoader()->mainDocumentError().isNull())2148 if (frame()->loader().activeDocumentLoader()->mainDocumentError().isNull()) 2136 2149 print(); 2137 2150 } … … 2147 2160 return; 2148 2161 2149 if (!activeDocument->canNavigate(m_frame)) 2162 auto* frame = this->frame(); 2163 if (!activeDocument->canNavigate(frame)) 2150 2164 return; 2151 2165 … … 2164 2178 LockHistory lockHistory = (locking != LockHistoryBasedOnGestureState || !UserGestureIndicator::processingUserGesture()) ? LockHistory::Yes : LockHistory::No; 2165 2179 LockBackForwardList lockBackForwardList = (locking != LockHistoryBasedOnGestureState) ? LockBackForwardList::Yes : LockBackForwardList::No; 2166 m_frame->navigationScheduler().scheduleLocationChange(*activeDocument, activeDocument->securityOrigin(),2180 frame->navigationScheduler().scheduleLocationChange(*activeDocument, activeDocument->securityOrigin(), 2167 2181 // FIXME: What if activeDocument()->frame() is 0? 2168 2182 completedURL, activeDocument->frame()->loader().outgoingReferrer(), … … 2338 2352 #endif 2339 2353 2354 auto* frame = this->frame(); 2340 2355 if (!firstWindow.allowPopUp()) { 2341 2356 // Because FrameTree::findFrameForNavigation() returns true for empty strings, we must check for empty frame names. 2342 2357 // Otherwise, illegitimate window.open() calls with no name will pass right through the popup blocker. 2343 if (frameName.isEmpty() || ! m_frame->loader().findFrameForNavigation(frameName, activeDocument))2358 if (frameName.isEmpty() || !frame->loader().findFrameForNavigation(frameName, activeDocument)) 2344 2359 return RefPtr<WindowProxy> { nullptr }; 2345 2360 } … … 2349 2364 Frame* targetFrame = nullptr; 2350 2365 if (equalIgnoringASCIICase(frameName, "_top")) 2351 targetFrame = & m_frame->tree().top();2366 targetFrame = &frame->tree().top(); 2352 2367 else if (equalIgnoringASCIICase(frameName, "_parent")) { 2353 if (Frame* parent = m_frame->tree().parent())2368 if (Frame* parent = frame->tree().parent()) 2354 2369 targetFrame = parent; 2355 2370 else 2356 targetFrame = m_frame;2371 targetFrame = frame; 2357 2372 } 2358 2373 if (targetFrame) { … … 2376 2391 } 2377 2392 2378 auto newFrameOrException = createWindow(urlString, frameName, parseWindowFeatures(windowFeaturesString), activeWindow, *firstFrame, * m_frame);2393 auto newFrameOrException = createWindow(urlString, frameName, parseWindowFeatures(windowFeaturesString), activeWindow, *firstFrame, *frame); 2379 2394 if (newFrameOrException.hasException()) 2380 2395 return newFrameOrException.releaseException(); … … 2394 2409 return; 2395 2410 2396 auto* page = m_frame->page(); 2411 auto* frame = this->frame(); 2412 auto* page = frame->page(); 2397 2413 if (!page) 2398 2414 return; … … 2403 2419 } 2404 2420 2405 if (!canShowModalDialog(* m_frame) || !firstWindow.allowPopUp())2406 return; 2407 2408 auto dialogFrameOrException = createWindow(urlString, emptyAtom(), parseDialogFeatures(dialogFeaturesString, screenAvailableRect( m_frame->view())), activeWindow, *firstFrame, *m_frame, prepareDialogFunction);2421 if (!canShowModalDialog(*frame) || !firstWindow.allowPopUp()) 2422 return; 2423 2424 auto dialogFrameOrException = createWindow(urlString, emptyAtom(), parseDialogFeatures(dialogFeaturesString, screenAvailableRect(frame->view())), activeWindow, *firstFrame, *frame, prepareDialogFunction); 2409 2425 if (dialogFrameOrException.hasException()) 2410 2426 return; … … 2427 2443 } 2428 2444 2445 Frame* DOMWindow::frame() const 2446 { 2447 auto* document = this->document(); 2448 return document ? document->frame() : nullptr; 2449 } 2450 2429 2451 } // namespace WebCore -
trunk/Source/WebCore/page/DOMWindow.h
r236917 r236965 89 89 enum class IncludeTargetOrigin { No, Yes }; 90 90 91 // FIXME: DOMWindow shouldn't subclass FrameDestructionObserver and instead should get to Frame via its Document.92 91 // FIXME: Rename DOMWindow to LocalWindow and AbstractDOMWindow to DOMWindow. 93 92 class DOMWindow final … … 95 94 , public CanMakeWeakPtr<DOMWindow> 96 95 , public ContextDestructionObserver 97 , public FrameDestructionObserver98 96 , public Base64Utilities 99 97 , public Supplementable<DOMWindow> { … … 117 115 void suspendForDocumentSuspension(); 118 116 void resumeFromDocumentSuspension(); 117 118 WEBCORE_EXPORT Frame* frame() const final; 119 119 120 120 RefPtr<MediaQueryList> matchMedia(const String&); … … 202 202 WindowProxy* top() const; 203 203 204 Frame* frame() const final { return FrameDestructionObserver::frame(); }205 206 204 String origin() const; 207 205 … … 334 332 void willDestroyCachedFrame(); 335 333 336 void attachToFrame(Frame&);337 void detachFromFrame();338 339 334 void enableSuddenTermination(); 340 335 void disableSuddenTermination(); 341 336 337 void frameDestroyed(); 338 342 339 private: 343 340 explicit DOMWindow(Document&); … … 350 347 Page* page(); 351 348 bool allowedToChangeWindowGeometry() const; 352 353 void frameDestroyed() final;354 void willDetachPage() final;355 349 356 350 static ExceptionOr<RefPtr<Frame>> createWindow(const String& urlString, const AtomicString& frameName, const WindowFeatures&, DOMWindow& activeWindow, Frame& firstFrame, Frame& openerFrame, const WTF::Function<void(DOMWindow&)>& prepareDialogFunction = nullptr);
Note:
See TracChangeset
for help on using the changeset viewer.