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

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

Issue 2393313002: reflow comments in core/frame (Closed)
Patch Set: tweak Created 4 years, 2 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
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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 126
127 // Eager finalization is needed to promptly stop this timer object. 127 // Eager finalization is needed to promptly stop this timer object.
128 // (see DOMTimer comment for more.) 128 // (see DOMTimer comment for more.)
129 EAGERLY_FINALIZE(); 129 EAGERLY_FINALIZE();
130 DEFINE_INLINE_VIRTUAL_TRACE() { 130 DEFINE_INLINE_VIRTUAL_TRACE() {
131 visitor->trace(m_event); 131 visitor->trace(m_event);
132 visitor->trace(m_window); 132 visitor->trace(m_window);
133 SuspendableTimer::trace(visitor); 133 SuspendableTimer::trace(visitor);
134 } 134 }
135 135
136 // TODO(alexclarke): Override timerTaskRunner() to pass in a document specific default task runner. 136 // TODO(alexclarke): Override timerTaskRunner() to pass in a document specific
137 // default task runner.
137 138
138 private: 139 private:
139 void fired() override { 140 void fired() override {
140 InspectorInstrumentation::AsyncTask asyncTask(m_window->document(), this); 141 InspectorInstrumentation::AsyncTask asyncTask(m_window->document(), this);
141 m_disposalAllowed = false; 142 m_disposalAllowed = false;
142 m_window->postMessageTimerFired(this); 143 m_window->postMessageTimerFired(this);
143 dispose(); 144 dispose();
144 // Oilpan optimization: unregister as an observer right away. 145 // Oilpan optimization: unregister as an observer right away.
145 clearContext(); 146 clearContext();
146 } 147 }
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 m_navigator->setLanguagesChanged(); 299 m_navigator->setLanguagesChanged();
299 300
300 dispatchEvent(Event::create(EventTypeNames::languagechange)); 301 dispatchEvent(Event::create(EventTypeNames::languagechange));
301 } 302 }
302 303
303 Document* LocalDOMWindow::createDocument(const String& mimeType, 304 Document* LocalDOMWindow::createDocument(const String& mimeType,
304 const DocumentInit& init, 305 const DocumentInit& init,
305 bool forceXHTML) { 306 bool forceXHTML) {
306 Document* document = nullptr; 307 Document* document = nullptr;
307 if (forceXHTML) { 308 if (forceXHTML) {
308 // This is a hack for XSLTProcessor. See XSLTProcessor::createDocumentFromSo urce(). 309 // This is a hack for XSLTProcessor. See
310 // XSLTProcessor::createDocumentFromSource().
309 document = Document::create(init); 311 document = Document::create(init);
310 } else { 312 } else {
311 document = DOMImplementation::createDocument( 313 document = DOMImplementation::createDocument(
312 mimeType, init, 314 mimeType, init,
313 init.frame() ? init.frame()->inViewSourceMode() : false); 315 init.frame() ? init.frame()->inViewSourceMode() : false);
314 if (document->isPluginDocument() && document->isSandboxed(SandboxPlugins)) 316 if (document->isPluginDocument() && document->isSandboxed(SandboxPlugins))
315 document = SinkDocument::create(init); 317 document = SinkDocument::create(init);
316 } 318 }
317 319
318 return document; 320 return document;
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 } 386 }
385 387
386 void LocalDOMWindow::documentWasClosed() { 388 void LocalDOMWindow::documentWasClosed() {
387 dispatchWindowLoadEvent(); 389 dispatchWindowLoadEvent();
388 enqueuePageshowEvent(PageshowEventNotPersisted); 390 enqueuePageshowEvent(PageshowEventNotPersisted);
389 if (m_pendingStateObject) 391 if (m_pendingStateObject)
390 enqueuePopstateEvent(m_pendingStateObject.release()); 392 enqueuePopstateEvent(m_pendingStateObject.release());
391 } 393 }
392 394
393 void LocalDOMWindow::enqueuePageshowEvent(PageshowEventPersistence persisted) { 395 void LocalDOMWindow::enqueuePageshowEvent(PageshowEventPersistence persisted) {
394 // FIXME: https://bugs.webkit.org/show_bug.cgi?id=36334 Pageshow event needs t o fire asynchronously. 396 // FIXME: https://bugs.webkit.org/show_bug.cgi?id=36334 Pageshow event needs
395 // As per spec pageshow must be triggered asynchronously. 397 // to fire asynchronously. As per spec pageshow must be triggered
396 // However to be compatible with other browsers blink fires pageshow synchrono usly. 398 // asynchronously. However to be compatible with other browsers blink fires
399 // pageshow synchronously.
397 dispatchEvent( 400 dispatchEvent(
398 PageTransitionEvent::create(EventTypeNames::pageshow, persisted), 401 PageTransitionEvent::create(EventTypeNames::pageshow, persisted),
399 m_document.get()); 402 m_document.get());
400 } 403 }
401 404
402 void LocalDOMWindow::enqueueHashchangeEvent(const String& oldURL, 405 void LocalDOMWindow::enqueueHashchangeEvent(const String& oldURL,
403 const String& newURL) { 406 const String& newURL) {
404 enqueueWindowEvent(HashChangeEvent::create(oldURL, newURL)); 407 enqueueWindowEvent(HashChangeEvent::create(oldURL, newURL));
405 } 408 }
406 409
407 void LocalDOMWindow::enqueuePopstateEvent( 410 void LocalDOMWindow::enqueuePopstateEvent(
408 PassRefPtr<SerializedScriptValue> stateObject) { 411 PassRefPtr<SerializedScriptValue> stateObject) {
409 // FIXME: https://bugs.webkit.org/show_bug.cgi?id=36202 Popstate event needs t o fire asynchronously 412 // FIXME: https://bugs.webkit.org/show_bug.cgi?id=36202 Popstate event needs
413 // to fire asynchronously
410 dispatchEvent(PopStateEvent::create(std::move(stateObject), history())); 414 dispatchEvent(PopStateEvent::create(std::move(stateObject), history()));
411 } 415 }
412 416
413 void LocalDOMWindow::statePopped( 417 void LocalDOMWindow::statePopped(
414 PassRefPtr<SerializedScriptValue> stateObject) { 418 PassRefPtr<SerializedScriptValue> stateObject) {
415 if (!frame()) 419 if (!frame())
416 return; 420 return;
417 421
418 // Per step 11 of section 6.5.9 (history traversal) of the HTML5 spec, we 422 // Per step 11 of section 6.5.9 (history traversal) of the HTML5 spec, we
419 // defer firing of popstate until we're in the complete state. 423 // defer firing of popstate until we're in the complete state.
420 if (document()->isLoadCompleted()) 424 if (document()->isLoadCompleted())
421 enqueuePopstateEvent(std::move(stateObject)); 425 enqueuePopstateEvent(std::move(stateObject));
422 else 426 else
423 m_pendingStateObject = stateObject; 427 m_pendingStateObject = stateObject;
424 } 428 }
425 429
426 LocalDOMWindow::~LocalDOMWindow() { 430 LocalDOMWindow::~LocalDOMWindow() {
427 // Cleared when detaching document. 431 // Cleared when detaching document.
428 ASSERT(!m_eventQueue); 432 ASSERT(!m_eventQueue);
429 } 433 }
430 434
431 void LocalDOMWindow::dispose() { 435 void LocalDOMWindow::dispose() {
432 // Oilpan: should the LocalDOMWindow be GCed along with its LocalFrame without the 436 // Oilpan: should the LocalDOMWindow be GCed along with its LocalFrame without
433 // frame having first notified its observers of imminent destruction, the 437 // the frame having first notified its observers of imminent destruction, the
434 // LocalDOMWindow will not have had an opportunity to remove event listeners. 438 // LocalDOMWindow will not have had an opportunity to remove event listeners.
435 // 439 //
436 // Arrange for that removal to happen using a prefinalizer action. Making Loca lDOMWindow 440 // Arrange for that removal to happen using a prefinalizer action. Making
437 // eager finalizable is problematic as other eagerly finalized objects may wel l 441 // LocalDOMWindow eager finalizable is problematic as other eagerly finalized
438 // want to access their associated LocalDOMWindow from their destructors. 442 // objects may well want to access their associated LocalDOMWindow from their
443 // destructors.
439 if (!frame()) 444 if (!frame())
440 return; 445 return;
441 446
442 removeAllEventListeners(); 447 removeAllEventListeners();
443 } 448 }
444 449
445 ExecutionContext* LocalDOMWindow::getExecutionContext() const { 450 ExecutionContext* LocalDOMWindow::getExecutionContext() const {
446 return m_document.get(); 451 return m_document.get();
447 } 452 }
448 453
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 640
636 void LocalDOMWindow::removePostMessageTimer(PostMessageTimer* timer) { 641 void LocalDOMWindow::removePostMessageTimer(PostMessageTimer* timer) {
637 m_postMessageTimers.remove(timer); 642 m_postMessageTimers.remove(timer);
638 } 643 }
639 644
640 void LocalDOMWindow::dispatchMessageEventWithOriginCheck( 645 void LocalDOMWindow::dispatchMessageEventWithOriginCheck(
641 SecurityOrigin* intendedTargetOrigin, 646 SecurityOrigin* intendedTargetOrigin,
642 Event* event, 647 Event* event,
643 std::unique_ptr<SourceLocation> location) { 648 std::unique_ptr<SourceLocation> location) {
644 if (intendedTargetOrigin) { 649 if (intendedTargetOrigin) {
645 // Check target origin now since the target document may have changed since the timer was scheduled. 650 // Check target origin now since the target document may have changed since
651 // the timer was scheduled.
646 SecurityOrigin* securityOrigin = document()->getSecurityOrigin(); 652 SecurityOrigin* securityOrigin = document()->getSecurityOrigin();
647 bool validTarget = 653 bool validTarget =
648 intendedTargetOrigin->isSameSchemeHostPortAndSuborigin(securityOrigin); 654 intendedTargetOrigin->isSameSchemeHostPortAndSuborigin(securityOrigin);
649 if (securityOrigin->hasSuborigin() && 655 if (securityOrigin->hasSuborigin() &&
650 securityOrigin->suborigin()->policyContains( 656 securityOrigin->suborigin()->policyContains(
651 Suborigin::SuboriginPolicyOptions::UnsafePostMessageReceive)) 657 Suborigin::SuboriginPolicyOptions::UnsafePostMessageReceive))
652 validTarget = intendedTargetOrigin->isSameSchemeHostPort(securityOrigin); 658 validTarget = intendedTargetOrigin->isSameSchemeHostPort(securityOrigin);
653 659
654 if (!validTarget) { 660 if (!validTarget) {
655 String message = ExceptionMessages::failedToExecute( 661 String message = ExceptionMessages::failedToExecute(
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
821 bool LocalDOMWindow::find(const String& string, 827 bool LocalDOMWindow::find(const String& string,
822 bool caseSensitive, 828 bool caseSensitive,
823 bool backwards, 829 bool backwards,
824 bool wrap, 830 bool wrap,
825 bool wholeWord, 831 bool wholeWord,
826 bool /*searchInFrames*/, 832 bool /*searchInFrames*/,
827 bool /*showDialog*/) const { 833 bool /*showDialog*/) const {
828 if (!isCurrentlyDisplayedInFrame()) 834 if (!isCurrentlyDisplayedInFrame())
829 return false; 835 return false;
830 836
831 // Up-to-date, clean tree is required for finding text in page, since it relie s 837 // Up-to-date, clean tree is required for finding text in page, since it
832 // on TextIterator to look over the text. 838 // relies on TextIterator to look over the text.
833 document()->updateStyleAndLayoutIgnorePendingStylesheets(); 839 document()->updateStyleAndLayoutIgnorePendingStylesheets();
834 840
835 // FIXME (13016): Support searchInFrames and showDialog 841 // FIXME (13016): Support searchInFrames and showDialog
836 FindOptions options = 842 FindOptions options =
837 (backwards ? Backwards : 0) | (caseSensitive ? 0 : CaseInsensitive) | 843 (backwards ? Backwards : 0) | (caseSensitive ? 0 : CaseInsensitive) |
838 (wrap ? WrapAround : 0) | (wholeWord ? WholeWord | AtWordStarts : 0); 844 (wrap ? WrapAround : 0) | (wholeWord ? WholeWord | AtWordStarts : 0);
839 return frame()->editor().findString(string, options); 845 return frame()->editor().findString(string, options);
840 } 846 }
841 847
842 bool LocalDOMWindow::offscreenBuffering() const { 848 bool LocalDOMWindow::offscreenBuffering() const {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
887 if (!host) 893 if (!host)
888 return FloatSize(); 894 return FloatSize();
889 895
890 // The main frame's viewport size depends on the page scale. Since the 896 // The main frame's viewport size depends on the page scale. Since the
891 // initial page scale depends on the content width and is set after a 897 // initial page scale depends on the content width and is set after a
892 // layout, perform one now so queries during page load will use the up to 898 // layout, perform one now so queries during page load will use the up to
893 // date viewport. 899 // date viewport.
894 if (host->settings().viewportEnabled() && frame()->isMainFrame()) 900 if (host->settings().viewportEnabled() && frame()->isMainFrame())
895 document()->updateStyleAndLayoutIgnorePendingStylesheets(); 901 document()->updateStyleAndLayoutIgnorePendingStylesheets();
896 902
897 // FIXME: This is potentially too much work. We really only need to know the d imensions of the parent frame's layoutObject. 903 // FIXME: This is potentially too much work. We really only need to know the
904 // dimensions of the parent frame's layoutObject.
898 if (Frame* parent = frame()->tree().parent()) { 905 if (Frame* parent = frame()->tree().parent()) {
899 if (parent && parent->isLocalFrame()) 906 if (parent && parent->isLocalFrame())
900 toLocalFrame(parent) 907 toLocalFrame(parent)
901 ->document() 908 ->document()
902 ->updateStyleAndLayoutIgnorePendingStylesheets(); 909 ->updateStyleAndLayoutIgnorePendingStylesheets();
903 } 910 }
904 911
905 return frame()->isMainFrame() && !host->settings().inertVisualViewport() 912 return frame()->isMainFrame() && !host->settings().inertVisualViewport()
906 ? FloatSize(host->visualViewport().visibleRect().size()) 913 ? FloatSize(host->visualViewport().visibleRect().size())
907 : FloatSize(view->visibleContentRect(scrollbarInclusion).size()); 914 : FloatSize(view->visibleContentRect(scrollbarInclusion).size());
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
1142 if (!view) 1149 if (!view)
1143 return; 1150 return;
1144 1151
1145 FrameHost* host = frame()->host(); 1152 FrameHost* host = frame()->host();
1146 if (!host) 1153 if (!host)
1147 return; 1154 return;
1148 1155
1149 x = ScrollableArea::normalizeNonFiniteScroll(x); 1156 x = ScrollableArea::normalizeNonFiniteScroll(x);
1150 y = ScrollableArea::normalizeNonFiniteScroll(y); 1157 y = ScrollableArea::normalizeNonFiniteScroll(y);
1151 1158
1152 // It is only necessary to have an up-to-date layout if the position may be cl amped, 1159 // It is only necessary to have an up-to-date layout if the position may be
1153 // which is never the case for (0, 0). 1160 // clamped, which is never the case for (0, 0).
1154 if (x || y) 1161 if (x || y)
1155 document()->updateStyleAndLayoutIgnorePendingStylesheets(); 1162 document()->updateStyleAndLayoutIgnorePendingStylesheets();
1156 1163
1157 DoublePoint layoutPos(x * frame()->pageZoomFactor(), 1164 DoublePoint layoutPos(x * frame()->pageZoomFactor(),
1158 y * frame()->pageZoomFactor()); 1165 y * frame()->pageZoomFactor());
1159 ScrollableArea* viewport = host->settings().inertVisualViewport() 1166 ScrollableArea* viewport = host->settings().inertVisualViewport()
1160 ? view->layoutViewportScrollableArea() 1167 ? view->layoutViewportScrollableArea()
1161 : view->getScrollableArea(); 1168 : view->getScrollableArea();
1162 viewport->setScrollPosition(layoutPos, ProgrammaticScroll, 1169 viewport->setScrollPosition(layoutPos, ProgrammaticScroll,
1163 ScrollBehaviorAuto); 1170 ScrollBehaviorAuto);
1164 } 1171 }
1165 1172
1166 void LocalDOMWindow::scrollTo(const ScrollToOptions& scrollToOptions) const { 1173 void LocalDOMWindow::scrollTo(const ScrollToOptions& scrollToOptions) const {
1167 if (!isCurrentlyDisplayedInFrame()) 1174 if (!isCurrentlyDisplayedInFrame())
1168 return; 1175 return;
1169 1176
1170 FrameView* view = frame()->view(); 1177 FrameView* view = frame()->view();
1171 if (!view) 1178 if (!view)
1172 return; 1179 return;
1173 1180
1174 FrameHost* host = frame()->host(); 1181 FrameHost* host = frame()->host();
1175 if (!host) 1182 if (!host)
1176 return; 1183 return;
1177 1184
1178 // It is only necessary to have an up-to-date layout if the position may be cl amped, 1185 // It is only necessary to have an up-to-date layout if the position may be
1179 // which is never the case for (0, 0). 1186 // clamped, which is never the case for (0, 0).
1180 if (!scrollToOptions.hasLeft() || !scrollToOptions.hasTop() || 1187 if (!scrollToOptions.hasLeft() || !scrollToOptions.hasTop() ||
1181 scrollToOptions.left() || scrollToOptions.top()) { 1188 scrollToOptions.left() || scrollToOptions.top()) {
1182 document()->updateStyleAndLayoutIgnorePendingStylesheets(); 1189 document()->updateStyleAndLayoutIgnorePendingStylesheets();
1183 } 1190 }
1184 1191
1185 double scaledX = 0.0; 1192 double scaledX = 0.0;
1186 double scaledY = 0.0; 1193 double scaledY = 0.0;
1187 1194
1188 ScrollableArea* viewport = host->settings().inertVisualViewport() 1195 ScrollableArea* viewport = host->settings().inertVisualViewport()
1189 ? view->layoutViewportScrollableArea() 1196 ? view->layoutViewportScrollableArea()
(...skipping 22 matching lines...) Expand all
1212 void LocalDOMWindow::moveBy(int x, int y) const { 1219 void LocalDOMWindow::moveBy(int x, int y) const {
1213 if (!frame() || !frame()->isMainFrame()) 1220 if (!frame() || !frame()->isMainFrame())
1214 return; 1221 return;
1215 1222
1216 FrameHost* host = frame()->host(); 1223 FrameHost* host = frame()->host();
1217 if (!host) 1224 if (!host)
1218 return; 1225 return;
1219 1226
1220 IntRect windowRect = host->chromeClient().rootWindowRect(); 1227 IntRect windowRect = host->chromeClient().rootWindowRect();
1221 windowRect.saturatedMove(x, y); 1228 windowRect.saturatedMove(x, y);
1222 // Security check (the spec talks about UniversalBrowserWrite to disable this check...) 1229 // Security check (the spec talks about UniversalBrowserWrite to disable this
1230 // check...)
1223 host->chromeClient().setWindowRectWithAdjustment(windowRect, *frame()); 1231 host->chromeClient().setWindowRectWithAdjustment(windowRect, *frame());
1224 } 1232 }
1225 1233
1226 void LocalDOMWindow::moveTo(int x, int y) const { 1234 void LocalDOMWindow::moveTo(int x, int y) const {
1227 if (!frame() || !frame()->isMainFrame()) 1235 if (!frame() || !frame()->isMainFrame())
1228 return; 1236 return;
1229 1237
1230 FrameHost* host = frame()->host(); 1238 FrameHost* host = frame()->host();
1231 if (!host) 1239 if (!host)
1232 return; 1240 return;
1233 1241
1234 IntRect windowRect = host->chromeClient().rootWindowRect(); 1242 IntRect windowRect = host->chromeClient().rootWindowRect();
1235 windowRect.setLocation(IntPoint(x, y)); 1243 windowRect.setLocation(IntPoint(x, y));
1236 // Security check (the spec talks about UniversalBrowserWrite to disable this check...) 1244 // Security check (the spec talks about UniversalBrowserWrite to disable this
1245 // check...)
1237 host->chromeClient().setWindowRectWithAdjustment(windowRect, *frame()); 1246 host->chromeClient().setWindowRectWithAdjustment(windowRect, *frame());
1238 } 1247 }
1239 1248
1240 void LocalDOMWindow::resizeBy(int x, int y) const { 1249 void LocalDOMWindow::resizeBy(int x, int y) const {
1241 if (!frame() || !frame()->isMainFrame()) 1250 if (!frame() || !frame()->isMainFrame())
1242 return; 1251 return;
1243 1252
1244 FrameHost* host = frame()->host(); 1253 FrameHost* host = frame()->host();
1245 if (!host) 1254 if (!host)
1246 return; 1255 return;
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1328 for (auto& it : m_eventListenerObservers) { 1337 for (auto& it : m_eventListenerObservers) {
1329 it->didAddEventListener(this, eventType); 1338 it->didAddEventListener(this, eventType);
1330 } 1339 }
1331 1340
1332 if (eventType == EventTypeNames::unload) { 1341 if (eventType == EventTypeNames::unload) {
1333 UseCounter::count(document(), UseCounter::DocumentUnloadRegistered); 1342 UseCounter::count(document(), UseCounter::DocumentUnloadRegistered);
1334 addUnloadEventListener(this); 1343 addUnloadEventListener(this);
1335 } else if (eventType == EventTypeNames::beforeunload) { 1344 } else if (eventType == EventTypeNames::beforeunload) {
1336 UseCounter::count(document(), UseCounter::DocumentBeforeUnloadRegistered); 1345 UseCounter::count(document(), UseCounter::DocumentBeforeUnloadRegistered);
1337 if (allowsBeforeUnloadListeners(this)) { 1346 if (allowsBeforeUnloadListeners(this)) {
1338 // This is confusingly named. It doesn't actually add the listener. It jus t increments a count 1347 // This is confusingly named. It doesn't actually add the listener. It
1339 // so that we know we have listeners registered for the purposes of determ ining if we can 1348 // just increments a count so that we know we have listeners registered
1340 // fast terminate the renderer process. 1349 // for the purposes of determining if we can fast terminate the renderer
1350 // process.
1341 addBeforeUnloadEventListener(this); 1351 addBeforeUnloadEventListener(this);
1342 } else { 1352 } else {
1343 // Subframes return false from allowsBeforeUnloadListeners. 1353 // Subframes return false from allowsBeforeUnloadListeners.
1344 UseCounter::count(document(), UseCounter::SubFrameBeforeUnloadRegistered); 1354 UseCounter::count(document(), UseCounter::SubFrameBeforeUnloadRegistered);
1345 } 1355 }
1346 } 1356 }
1347 } 1357 }
1348 1358
1349 void LocalDOMWindow::removedEventListener( 1359 void LocalDOMWindow::removedEventListener(
1350 const AtomicString& eventType, 1360 const AtomicString& eventType,
(...skipping 27 matching lines...) Expand all
1378 void LocalDOMWindow::dispatchLoadEvent() { 1388 void LocalDOMWindow::dispatchLoadEvent() {
1379 Event* loadEvent(Event::create(EventTypeNames::load)); 1389 Event* loadEvent(Event::create(EventTypeNames::load));
1380 if (frame() && frame()->loader().documentLoader() && 1390 if (frame() && frame()->loader().documentLoader() &&
1381 !frame()->loader().documentLoader()->timing().loadEventStart()) { 1391 !frame()->loader().documentLoader()->timing().loadEventStart()) {
1382 DocumentLoader* documentLoader = frame()->loader().documentLoader(); 1392 DocumentLoader* documentLoader = frame()->loader().documentLoader();
1383 DocumentLoadTiming& timing = documentLoader->timing(); 1393 DocumentLoadTiming& timing = documentLoader->timing();
1384 timing.markLoadEventStart(); 1394 timing.markLoadEventStart();
1385 dispatchEvent(loadEvent, document()); 1395 dispatchEvent(loadEvent, document());
1386 timing.markLoadEventEnd(); 1396 timing.markLoadEventEnd();
1387 DCHECK(documentLoader->fetcher()); 1397 DCHECK(documentLoader->fetcher());
1388 // If fetcher->countPreloads() is not empty here, it's full of link preloads , 1398 // If fetcher->countPreloads() is not empty here, it's full of link
1389 // as speculatove preloads were cleared at DCL. 1399 // preloads, as speculatove preloads were cleared at DCL.
1390 if (frame() && documentLoader == frame()->loader().documentLoader() && 1400 if (frame() && documentLoader == frame()->loader().documentLoader() &&
1391 documentLoader->fetcher()->countPreloads()) 1401 documentLoader->fetcher()->countPreloads())
1392 m_unusedPreloadsTimer.startOneShot(unusedPreloadTimeoutInSeconds, 1402 m_unusedPreloadsTimer.startOneShot(unusedPreloadTimeoutInSeconds,
1393 BLINK_FROM_HERE); 1403 BLINK_FROM_HERE);
1394 } else { 1404 } else {
1395 dispatchEvent(loadEvent, document()); 1405 dispatchEvent(loadEvent, document());
1396 } 1406 }
1397 1407
1398 // For load events, send a separate load event to the enclosing frame only. 1408 // For load events, send a separate load event to the enclosing frame only.
1399 // This is a DOM extension and is independent of bubbling/capturing rules of 1409 // This is a DOM extension and is independent of bubbling/capturing rules of
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
1468 return nullptr; 1478 return nullptr;
1469 LocalFrame* firstFrame = enteredWindow->frame(); 1479 LocalFrame* firstFrame = enteredWindow->frame();
1470 if (!firstFrame) 1480 if (!firstFrame)
1471 return nullptr; 1481 return nullptr;
1472 1482
1473 UseCounter::count(*activeDocument, UseCounter::DOMWindowOpen); 1483 UseCounter::count(*activeDocument, UseCounter::DOMWindowOpen);
1474 if (!windowFeaturesString.isEmpty()) 1484 if (!windowFeaturesString.isEmpty())
1475 UseCounter::count(*activeDocument, UseCounter::DOMWindowOpenFeatures); 1485 UseCounter::count(*activeDocument, UseCounter::DOMWindowOpenFeatures);
1476 1486
1477 if (!enteredWindow->allowPopUp()) { 1487 if (!enteredWindow->allowPopUp()) {
1478 // Because FrameTree::find() returns true for empty strings, we must check f or empty frame names. 1488 // Because FrameTree::find() returns true for empty strings, we must check
1479 // Otherwise, illegitimate window.open() calls with no name will pass right through the popup blocker. 1489 // for empty frame names. Otherwise, illegitimate window.open() calls with
1490 // no name will pass right through the popup blocker.
1480 if (frameName.isEmpty() || !frame()->tree().find(frameName)) 1491 if (frameName.isEmpty() || !frame()->tree().find(frameName))
1481 return nullptr; 1492 return nullptr;
1482 } 1493 }
1483 1494
1484 // Get the target frame for the special cases of _top and _parent. 1495 // Get the target frame for the special cases of _top and _parent.
1485 // In those cases, we schedule a location change right now and return early. 1496 // In those cases, we schedule a location change right now and return early.
1486 Frame* targetFrame = nullptr; 1497 Frame* targetFrame = nullptr;
1487 if (frameName == "_top") { 1498 if (frameName == "_top") {
1488 targetFrame = frame()->tree().top(); 1499 targetFrame = frame()->tree().top();
1489 } else if (frameName == "_parent") { 1500 } else if (frameName == "_parent") {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1544 1555
1545 LocalFrame* LocalDOMWindow::frame() const { 1556 LocalFrame* LocalDOMWindow::frame() const {
1546 // If the LocalDOMWindow still has a frame reference, that frame must point 1557 // If the LocalDOMWindow still has a frame reference, that frame must point
1547 // back to this LocalDOMWindow: otherwise, it's easy to get into a situation 1558 // back to this LocalDOMWindow: otherwise, it's easy to get into a situation
1548 // where script execution leaks between different LocalDOMWindows. 1559 // where script execution leaks between different LocalDOMWindows.
1549 SECURITY_DCHECK(!m_frame || m_frame->domWindow() == this); 1560 SECURITY_DCHECK(!m_frame || m_frame->domWindow() == this);
1550 return m_frame; 1561 return m_frame;
1551 } 1562 }
1552 1563
1553 } // namespace blink 1564 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/frame/LocalDOMWindow.h ('k') | third_party/WebKit/Source/core/frame/LocalFrame.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698