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 unusedPreloadTimeout = 3; | |
Charlie Harrison
2016/09/14 12:34:58
Make it clear this is in seconds in the name or co
Yoav Weiss
2016/09/14 13:28:31
good call
| |
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 DCHECK(frame()->loader().documentLoader()->fetcher()); | |
1348 frame()->loader().documentLoader()->fetcher()->warnUnusedPreloads(); | |
1349 } | |
1350 } | |
1351 | |
1339 void LocalDOMWindow::dispatchLoadEvent() | 1352 void LocalDOMWindow::dispatchLoadEvent() |
1340 { | 1353 { |
1341 Event* loadEvent(Event::create(EventTypeNames::load)); | 1354 Event* loadEvent(Event::create(EventTypeNames::load)); |
1342 if (frame() && frame()->loader().documentLoader() && !frame()->loader().docu mentLoader()->timing().loadEventStart()) { | 1355 if (frame() && frame()->loader().documentLoader() && !frame()->loader().docu mentLoader()->timing().loadEventStart()) { |
1343 DocumentLoader* documentLoader = frame()->loader().documentLoader(); | 1356 DocumentLoader* documentLoader = frame()->loader().documentLoader(); |
1344 DocumentLoadTiming& timing = documentLoader->timing(); | 1357 DocumentLoadTiming& timing = documentLoader->timing(); |
1345 timing.markLoadEventStart(); | 1358 timing.markLoadEventStart(); |
1346 dispatchEvent(loadEvent, document()); | 1359 dispatchEvent(loadEvent, document()); |
1347 timing.markLoadEventEnd(); | 1360 timing.markLoadEventEnd(); |
1361 m_unusedPreloadsTimer.startOneShot(unusedPreloadTimeout, BLINK_FROM_HERE ); | |
Charlie Harrison
2016/09/14 12:34:58
I think it makes sense to only dispatch this timer
Yoav Weiss
2016/09/14 13:28:31
It makes sense, but I really don't want to iterate
Charlie Harrison
2016/09/14 13:32:59
That's a good point. A counter is not great but I
| |
1362 | |
1348 } else { | 1363 } else { |
Charlie Harrison
2016/09/14 12:34:58
Remove empty line.
Yoav Weiss
2016/09/14 13:28:31
sure
| |
1349 dispatchEvent(loadEvent, document()); | 1364 dispatchEvent(loadEvent, document()); |
1350 } | 1365 } |
1351 | 1366 |
1352 // For load events, send a separate load event to the enclosing frame only. | 1367 // 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 | 1368 // This is a DOM extension and is independent of bubbling/capturing rules of |
1354 // the DOM. | 1369 // the DOM. |
1355 FrameOwner* owner = frame() ? frame()->owner() : nullptr; | 1370 FrameOwner* owner = frame() ? frame()->owner() : nullptr; |
1356 if (owner) | 1371 if (owner) |
1357 owner->dispatchLoad(); | 1372 owner->dispatchLoad(); |
1358 | 1373 |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1493 LocalFrame* LocalDOMWindow::frame() const | 1508 LocalFrame* LocalDOMWindow::frame() const |
1494 { | 1509 { |
1495 // If the LocalDOMWindow still has a frame reference, that frame must point | 1510 // 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 | 1511 // back to this LocalDOMWindow: otherwise, it's easy to get into a situation |
1497 // where script execution leaks between different LocalDOMWindows. | 1512 // where script execution leaks between different LocalDOMWindows. |
1498 SECURITY_DCHECK(!m_frame || m_frame->domWindow() == this); | 1513 SECURITY_DCHECK(!m_frame || m_frame->domWindow() == this); |
1499 return m_frame; | 1514 return m_frame; |
1500 } | 1515 } |
1501 | 1516 |
1502 } // namespace blink | 1517 } // namespace blink |
OLD | NEW |