OLD | NEW |
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 29 matching lines...) Expand all Loading... |
40 #include "core/dom/FrameRequestCallback.h" | 40 #include "core/dom/FrameRequestCallback.h" |
41 #include "core/dom/SandboxFlags.h" | 41 #include "core/dom/SandboxFlags.h" |
42 #include "core/dom/custom/CustomElementRegistry.h" | 42 #include "core/dom/custom/CustomElementRegistry.h" |
43 #include "core/editing/Editor.h" | 43 #include "core/editing/Editor.h" |
44 #include "core/events/DOMWindowEventQueue.h" | 44 #include "core/events/DOMWindowEventQueue.h" |
45 #include "core/events/HashChangeEvent.h" | 45 #include "core/events/HashChangeEvent.h" |
46 #include "core/events/MessageEvent.h" | 46 #include "core/events/MessageEvent.h" |
47 #include "core/events/PageTransitionEvent.h" | 47 #include "core/events/PageTransitionEvent.h" |
48 #include "core/events/PopStateEvent.h" | 48 #include "core/events/PopStateEvent.h" |
49 #include "core/events/ScopedEventQueue.h" | 49 #include "core/events/ScopedEventQueue.h" |
| 50 #include "core/fetch/ResourceFetcher.h" |
50 #include "core/frame/BarProp.h" | 51 #include "core/frame/BarProp.h" |
51 #include "core/frame/DOMVisualViewport.h" | 52 #include "core/frame/DOMVisualViewport.h" |
52 #include "core/frame/EventHandlerRegistry.h" | 53 #include "core/frame/EventHandlerRegistry.h" |
53 #include "core/frame/FrameConsole.h" | 54 #include "core/frame/FrameConsole.h" |
54 #include "core/frame/FrameView.h" | 55 #include "core/frame/FrameView.h" |
55 #include "core/frame/History.h" | 56 #include "core/frame/History.h" |
56 #include "core/frame/LocalFrame.h" | 57 #include "core/frame/LocalFrame.h" |
57 #include "core/frame/Navigator.h" | 58 #include "core/frame/Navigator.h" |
58 #include "core/frame/Screen.h" | 59 #include "core/frame/Screen.h" |
59 #include "core/frame/ScrollToOptions.h" | 60 #include "core/frame/ScrollToOptions.h" |
(...skipping 16 matching lines...) Expand all Loading... |
76 #include "platform/EventDispatchForbiddenScope.h" | 77 #include "platform/EventDispatchForbiddenScope.h" |
77 #include "platform/weborigin/SecurityOrigin.h" | 78 #include "platform/weborigin/SecurityOrigin.h" |
78 #include "platform/weborigin/Suborigin.h" | 79 #include "platform/weborigin/Suborigin.h" |
79 #include "public/platform/Platform.h" | 80 #include "public/platform/Platform.h" |
80 #include "public/platform/WebFrameScheduler.h" | 81 #include "public/platform/WebFrameScheduler.h" |
81 #include "public/platform/WebScreenInfo.h" | 82 #include "public/platform/WebScreenInfo.h" |
82 #include <memory> | 83 #include <memory> |
83 | 84 |
84 namespace blink { | 85 namespace blink { |
85 | 86 |
| 87 // Timeout for link preloads to be used after window.onload |
| 88 static const int unusedPreloadTimeoutInSeconds = 3; |
| 89 |
86 class PostMessageTimer final : public GarbageCollectedFinalized<PostMessageTimer
>, public SuspendableTimer { | 90 class PostMessageTimer final : public GarbageCollectedFinalized<PostMessageTimer
>, public SuspendableTimer { |
87 USING_GARBAGE_COLLECTED_MIXIN(PostMessageTimer); | 91 USING_GARBAGE_COLLECTED_MIXIN(PostMessageTimer); |
88 public: | 92 public: |
89 PostMessageTimer(LocalDOMWindow& window, MessageEvent* event, PassRefPtr<Sec
urityOrigin> targetOrigin, std::unique_ptr<SourceLocation> location, UserGesture
Token* userGestureToken) | 93 PostMessageTimer(LocalDOMWindow& window, MessageEvent* event, PassRefPtr<Sec
urityOrigin> targetOrigin, std::unique_ptr<SourceLocation> location, UserGesture
Token* userGestureToken) |
90 : SuspendableTimer(window.document()) | 94 : SuspendableTimer(window.document()) |
91 , m_event(event) | 95 , m_event(event) |
92 , m_window(&window) | 96 , m_window(&window) |
93 , m_targetOrigin(targetOrigin) | 97 , m_targetOrigin(targetOrigin) |
94 , m_location(std::move(location)) | 98 , m_location(std::move(location)) |
95 , m_userGestureToken(userGestureToken) | 99 , m_userGestureToken(userGestureToken) |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 } | 257 } |
254 | 258 |
255 bool LocalDOMWindow::allowPopUp() | 259 bool LocalDOMWindow::allowPopUp() |
256 { | 260 { |
257 return frame() && allowPopUp(*frame()); | 261 return frame() && allowPopUp(*frame()); |
258 } | 262 } |
259 | 263 |
260 LocalDOMWindow::LocalDOMWindow(LocalFrame& frame) | 264 LocalDOMWindow::LocalDOMWindow(LocalFrame& frame) |
261 : m_frame(&frame) | 265 : m_frame(&frame) |
262 , m_visualViewport(DOMVisualViewport::create(this)) | 266 , m_visualViewport(DOMVisualViewport::create(this)) |
| 267 , m_unusedPreloadsTimer(this, &LocalDOMWindow::warnUnusedPreloads) |
263 , m_shouldPrintWhenFinishedLoading(false) | 268 , m_shouldPrintWhenFinishedLoading(false) |
264 { | 269 { |
265 ThreadState::current()->registerPreFinalizer(this); | 270 ThreadState::current()->registerPreFinalizer(this); |
266 } | 271 } |
267 | 272 |
268 void LocalDOMWindow::clearDocument() | 273 void LocalDOMWindow::clearDocument() |
269 { | 274 { |
270 if (!m_document) | 275 if (!m_document) |
271 return; | 276 return; |
272 | 277 |
(...skipping 1056 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1329 it->didRemoveEventListener(this, eventType); | 1334 it->didRemoveEventListener(this, eventType); |
1330 } | 1335 } |
1331 | 1336 |
1332 if (eventType == EventTypeNames::unload) { | 1337 if (eventType == EventTypeNames::unload) { |
1333 removeUnloadEventListener(this); | 1338 removeUnloadEventListener(this); |
1334 } else if (eventType == EventTypeNames::beforeunload && allowsBeforeUnloadLi
steners(this)) { | 1339 } else if (eventType == EventTypeNames::beforeunload && allowsBeforeUnloadLi
steners(this)) { |
1335 removeBeforeUnloadEventListener(this); | 1340 removeBeforeUnloadEventListener(this); |
1336 } | 1341 } |
1337 } | 1342 } |
1338 | 1343 |
| 1344 void LocalDOMWindow::warnUnusedPreloads(TimerBase* base) |
| 1345 { |
| 1346 if (frame() && frame()->loader().documentLoader()) { |
| 1347 ResourceFetcher* fetcher = frame()->loader().documentLoader()->fetcher()
; |
| 1348 DCHECK(fetcher); |
| 1349 if (fetcher->isUnusedLinkPreloads()) |
| 1350 fetcher->warnUnusedPreloads(); |
| 1351 } |
| 1352 } |
| 1353 |
1339 void LocalDOMWindow::dispatchLoadEvent() | 1354 void LocalDOMWindow::dispatchLoadEvent() |
1340 { | 1355 { |
1341 Event* loadEvent(Event::create(EventTypeNames::load)); | 1356 Event* loadEvent(Event::create(EventTypeNames::load)); |
1342 if (frame() && frame()->loader().documentLoader() && !frame()->loader().docu
mentLoader()->timing().loadEventStart()) { | 1357 if (frame() && frame()->loader().documentLoader() && !frame()->loader().docu
mentLoader()->timing().loadEventStart()) { |
1343 DocumentLoader* documentLoader = frame()->loader().documentLoader(); | 1358 DocumentLoader* documentLoader = frame()->loader().documentLoader(); |
1344 DocumentLoadTiming& timing = documentLoader->timing(); | 1359 DocumentLoadTiming& timing = documentLoader->timing(); |
1345 timing.markLoadEventStart(); | 1360 timing.markLoadEventStart(); |
1346 dispatchEvent(loadEvent, document()); | 1361 dispatchEvent(loadEvent, document()); |
1347 timing.markLoadEventEnd(); | 1362 timing.markLoadEventEnd(); |
| 1363 DCHECK(documentLoader->fetcher()); |
| 1364 if (documentLoader->fetcher()->isUnusedLinkPreloads()) |
| 1365 m_unusedPreloadsTimer.startOneShot(unusedPreloadTimeoutInSeconds, BL
INK_FROM_HERE); |
1348 } else { | 1366 } else { |
1349 dispatchEvent(loadEvent, document()); | 1367 dispatchEvent(loadEvent, document()); |
1350 } | 1368 } |
1351 | 1369 |
1352 // For load events, send a separate load event to the enclosing frame only. | 1370 // For load events, send a separate load event to the enclosing frame only. |
1353 // This is a DOM extension and is independent of bubbling/capturing rules of | 1371 // This is a DOM extension and is independent of bubbling/capturing rules of |
1354 // the DOM. | 1372 // the DOM. |
1355 FrameOwner* owner = frame() ? frame()->owner() : nullptr; | 1373 FrameOwner* owner = frame() ? frame()->owner() : nullptr; |
1356 if (owner) | 1374 if (owner) |
1357 owner->dispatchLoad(); | 1375 owner->dispatchLoad(); |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1493 LocalFrame* LocalDOMWindow::frame() const | 1511 LocalFrame* LocalDOMWindow::frame() const |
1494 { | 1512 { |
1495 // If the LocalDOMWindow still has a frame reference, that frame must point | 1513 // If the LocalDOMWindow still has a frame reference, that frame must point |
1496 // back to this LocalDOMWindow: otherwise, it's easy to get into a situation | 1514 // back to this LocalDOMWindow: otherwise, it's easy to get into a situation |
1497 // where script execution leaks between different LocalDOMWindows. | 1515 // where script execution leaks between different LocalDOMWindows. |
1498 SECURITY_DCHECK(!m_frame || m_frame->domWindow() == this); | 1516 SECURITY_DCHECK(!m_frame || m_frame->domWindow() == this); |
1499 return m_frame; | 1517 return m_frame; |
1500 } | 1518 } |
1501 | 1519 |
1502 } // namespace blink | 1520 } // namespace blink |
OLD | NEW |