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

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

Issue 1854543002: Oilpan: Remove WillBe types (part 7) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 #include "public/platform/WebScreenInfo.h" 78 #include "public/platform/WebScreenInfo.h"
79 79
80 namespace blink { 80 namespace blink {
81 81
82 LocalDOMWindow::WindowFrameObserver::WindowFrameObserver(LocalDOMWindow* window, LocalFrame& frame) 82 LocalDOMWindow::WindowFrameObserver::WindowFrameObserver(LocalDOMWindow* window, LocalFrame& frame)
83 : LocalFrameLifecycleObserver(&frame) 83 : LocalFrameLifecycleObserver(&frame)
84 , m_window(window) 84 , m_window(window)
85 { 85 {
86 } 86 }
87 87
88 PassOwnPtrWillBeRawPtr<LocalDOMWindow::WindowFrameObserver> LocalDOMWindow::Wind owFrameObserver::create(LocalDOMWindow* window, LocalFrame& frame) 88 RawPtr<LocalDOMWindow::WindowFrameObserver> LocalDOMWindow::WindowFrameObserver: :create(LocalDOMWindow* window, LocalFrame& frame)
89 { 89 {
90 return adoptPtrWillBeNoop(new WindowFrameObserver(window, frame)); 90 return new WindowFrameObserver(window, frame);
91 } 91 }
92 92
93 #if !ENABLE(OILPAN) 93 #if !ENABLE(OILPAN)
94 LocalDOMWindow::WindowFrameObserver::~WindowFrameObserver() 94 LocalDOMWindow::WindowFrameObserver::~WindowFrameObserver()
95 { 95 {
96 } 96 }
97 #endif 97 #endif
98 98
99 DEFINE_TRACE(LocalDOMWindow::WindowFrameObserver) 99 DEFINE_TRACE(LocalDOMWindow::WindowFrameObserver)
100 { 100 {
101 visitor->trace(m_window); 101 visitor->trace(m_window);
102 LocalFrameLifecycleObserver::trace(visitor); 102 LocalFrameLifecycleObserver::trace(visitor);
103 } 103 }
104 104
105 void LocalDOMWindow::WindowFrameObserver::willDetachFrameHost() 105 void LocalDOMWindow::WindowFrameObserver::willDetachFrameHost()
106 { 106 {
107 m_window->willDetachFrameHost(); 107 m_window->willDetachFrameHost();
108 } 108 }
109 109
110 void LocalDOMWindow::WindowFrameObserver::contextDestroyed() 110 void LocalDOMWindow::WindowFrameObserver::contextDestroyed()
111 { 111 {
112 m_window->frameDestroyed(); 112 m_window->frameDestroyed();
113 LocalFrameLifecycleObserver::contextDestroyed(); 113 LocalFrameLifecycleObserver::contextDestroyed();
114 } 114 }
115 115
116 class PostMessageTimer final : public NoBaseWillBeGarbageCollectedFinalized<Post MessageTimer>, public SuspendableTimer { 116 class PostMessageTimer final : public GarbageCollectedFinalized<PostMessageTimer >, public SuspendableTimer {
117 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(PostMessageTimer); 117 USING_GARBAGE_COLLECTED_MIXIN(PostMessageTimer);
118 public: 118 public:
119 PostMessageTimer(LocalDOMWindow& window, PassRefPtrWillBeRawPtr<MessageEvent > event, SecurityOrigin* targetOrigin, PassRefPtr<ScriptCallStack> stackTrace, U serGestureToken* userGestureToken) 119 PostMessageTimer(LocalDOMWindow& window, RawPtr<MessageEvent> event, Securit yOrigin* targetOrigin, PassRefPtr<ScriptCallStack> stackTrace, UserGestureToken* userGestureToken)
120 : SuspendableTimer(window.document()) 120 : SuspendableTimer(window.document())
121 , m_event(event) 121 , m_event(event)
122 , m_window(&window) 122 , m_window(&window)
123 , m_targetOrigin(targetOrigin) 123 , m_targetOrigin(targetOrigin)
124 , m_stackTrace(stackTrace) 124 , m_stackTrace(stackTrace)
125 , m_userGestureToken(userGestureToken) 125 , m_userGestureToken(userGestureToken)
126 , m_disposalAllowed(true) 126 , m_disposalAllowed(true)
127 { 127 {
128 m_asyncOperationId = InspectorInstrumentation::traceAsyncOperationStarti ng(getExecutionContext(), "postMessage"); 128 m_asyncOperationId = InspectorInstrumentation::traceAsyncOperationStarti ng(getExecutionContext(), "postMessage");
129 } 129 }
130 130
131 PassRefPtrWillBeRawPtr<MessageEvent> event() const { return m_event.get(); } 131 RawPtr<MessageEvent> event() const { return m_event.get(); }
132 SecurityOrigin* targetOrigin() const { return m_targetOrigin.get(); } 132 SecurityOrigin* targetOrigin() const { return m_targetOrigin.get(); }
133 ScriptCallStack* stackTrace() const { return m_stackTrace.get(); } 133 ScriptCallStack* stackTrace() const { return m_stackTrace.get(); }
134 UserGestureToken* userGestureToken() const { return m_userGestureToken.get() ; } 134 UserGestureToken* userGestureToken() const { return m_userGestureToken.get() ; }
135 void stop() override 135 void stop() override
136 { 136 {
137 SuspendableTimer::stop(); 137 SuspendableTimer::stop();
138 138
139 if (m_disposalAllowed) 139 if (m_disposalAllowed)
140 dispose(); 140 dispose();
141 } 141 }
(...skipping 22 matching lines...) Expand all
164 164
165 void dispose() 165 void dispose()
166 { 166 {
167 // Oilpan optimization: unregister as an observer right away. 167 // Oilpan optimization: unregister as an observer right away.
168 clearContext(); 168 clearContext();
169 // Will destroy this object, now or after the next GC depending 169 // Will destroy this object, now or after the next GC depending
170 // on whether Oilpan is disabled or not. 170 // on whether Oilpan is disabled or not.
171 m_window->removePostMessageTimer(this); 171 m_window->removePostMessageTimer(this);
172 } 172 }
173 173
174 RefPtrWillBeMember<MessageEvent> m_event; 174 Member<MessageEvent> m_event;
175 RawPtrWillBeMember<LocalDOMWindow> m_window; 175 Member<LocalDOMWindow> m_window;
176 RefPtr<SecurityOrigin> m_targetOrigin; 176 RefPtr<SecurityOrigin> m_targetOrigin;
177 RefPtr<ScriptCallStack> m_stackTrace; 177 RefPtr<ScriptCallStack> m_stackTrace;
178 RefPtr<UserGestureToken> m_userGestureToken; 178 RefPtr<UserGestureToken> m_userGestureToken;
179 int m_asyncOperationId; 179 int m_asyncOperationId;
180 bool m_disposalAllowed; 180 bool m_disposalAllowed;
181 }; 181 };
182 182
183 static void updateSuddenTerminationStatus(LocalDOMWindow* domWindow, bool addedL istener, FrameLoaderClient::SuddenTerminationDisablerType disablerType) 183 static void updateSuddenTerminationStatus(LocalDOMWindow* domWindow, bool addedL istener, FrameLoaderClient::SuddenTerminationDisablerType disablerType)
184 { 184 {
185 Platform::current()->suddenTerminationChanged(!addedListener); 185 Platform::current()->suddenTerminationChanged(!addedListener);
186 if (domWindow->frame() && domWindow->frame()->loader().client()) 186 if (domWindow->frame() && domWindow->frame()->loader().client())
187 domWindow->frame()->loader().client()->suddenTerminationDisablerChanged( addedListener, disablerType); 187 domWindow->frame()->loader().client()->suddenTerminationDisablerChanged( addedListener, disablerType);
188 } 188 }
189 189
190 using DOMWindowSet = WillBePersistentHeapHashCountedSet<RawPtrWillBeWeakMember<L ocalDOMWindow>>; 190 using DOMWindowSet = PersistentHeapHashCountedSet<WeakMember<LocalDOMWindow>>;
191 191
192 static DOMWindowSet& windowsWithUnloadEventListeners() 192 static DOMWindowSet& windowsWithUnloadEventListeners()
193 { 193 {
194 DEFINE_STATIC_LOCAL(DOMWindowSet, windowsWithUnloadEventListeners, ()); 194 DEFINE_STATIC_LOCAL(DOMWindowSet, windowsWithUnloadEventListeners, ());
195 return windowsWithUnloadEventListeners; 195 return windowsWithUnloadEventListeners;
196 } 196 }
197 197
198 static DOMWindowSet& windowsWithBeforeUnloadEventListeners() 198 static DOMWindowSet& windowsWithBeforeUnloadEventListeners()
199 { 199 {
200 DEFINE_STATIC_LOCAL(DOMWindowSet, windowsWithBeforeUnloadEventListeners, ()) ; 200 DEFINE_STATIC_LOCAL(DOMWindowSet, windowsWithBeforeUnloadEventListeners, ()) ;
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 } 326 }
327 327
328 void LocalDOMWindow::acceptLanguagesChanged() 328 void LocalDOMWindow::acceptLanguagesChanged()
329 { 329 {
330 if (m_navigator) 330 if (m_navigator)
331 m_navigator->setLanguagesChanged(); 331 m_navigator->setLanguagesChanged();
332 332
333 dispatchEvent(Event::create(EventTypeNames::languagechange)); 333 dispatchEvent(Event::create(EventTypeNames::languagechange));
334 } 334 }
335 335
336 PassRefPtrWillBeRawPtr<Document> LocalDOMWindow::createDocument(const String& mi meType, const DocumentInit& init, bool forceXHTML) 336 RawPtr<Document> LocalDOMWindow::createDocument(const String& mimeType, const Do cumentInit& init, bool forceXHTML)
337 { 337 {
338 RefPtrWillBeRawPtr<Document> document = nullptr; 338 RawPtr<Document> document = nullptr;
339 if (forceXHTML) { 339 if (forceXHTML) {
340 // This is a hack for XSLTProcessor. See XSLTProcessor::createDocumentFr omSource(). 340 // This is a hack for XSLTProcessor. See XSLTProcessor::createDocumentFr omSource().
341 document = Document::create(init); 341 document = Document::create(init);
342 } else { 342 } else {
343 document = DOMImplementation::createDocument(mimeType, init, init.frame( ) ? init.frame()->inViewSourceMode() : false); 343 document = DOMImplementation::createDocument(mimeType, init, init.frame( ) ? init.frame()->inViewSourceMode() : false);
344 if (document->isPluginDocument() && document->isSandboxed(SandboxPlugins )) 344 if (document->isPluginDocument() && document->isSandboxed(SandboxPlugins ))
345 document = SinkDocument::create(init); 345 document = SinkDocument::create(init);
346 } 346 }
347 347
348 return document.release(); 348 return document.release();
349 } 349 }
350 350
351 PassRefPtrWillBeRawPtr<Document> LocalDOMWindow::installNewDocument(const String & mimeType, const DocumentInit& init, bool forceXHTML) 351 RawPtr<Document> LocalDOMWindow::installNewDocument(const String& mimeType, cons t DocumentInit& init, bool forceXHTML)
352 { 352 {
353 ASSERT(init.frame() == frame()); 353 ASSERT(init.frame() == frame());
354 354
355 clearDocument(); 355 clearDocument();
356 356
357 m_document = createDocument(mimeType, init, forceXHTML); 357 m_document = createDocument(mimeType, init, forceXHTML);
358 m_eventQueue = DOMWindowEventQueue::create(m_document.get()); 358 m_eventQueue = DOMWindowEventQueue::create(m_document.get());
359 m_document->attach(); 359 m_document->attach();
360 360
361 if (!frame()) 361 if (!frame())
(...skipping 12 matching lines...) Expand all
374 374
375 frame()->selection().updateSecureKeyboardEntryIfActive(); 375 frame()->selection().updateSecureKeyboardEntryIfActive();
376 return m_document; 376 return m_document;
377 } 377 }
378 378
379 EventQueue* LocalDOMWindow::getEventQueue() const 379 EventQueue* LocalDOMWindow::getEventQueue() const
380 { 380 {
381 return m_eventQueue.get(); 381 return m_eventQueue.get();
382 } 382 }
383 383
384 void LocalDOMWindow::enqueueWindowEvent(PassRefPtrWillBeRawPtr<Event> event) 384 void LocalDOMWindow::enqueueWindowEvent(RawPtr<Event> event)
385 { 385 {
386 if (!m_eventQueue) 386 if (!m_eventQueue)
387 return; 387 return;
388 event->setTarget(this); 388 event->setTarget(this);
389 m_eventQueue->enqueueEvent(event); 389 m_eventQueue->enqueueEvent(event);
390 } 390 }
391 391
392 void LocalDOMWindow::enqueueDocumentEvent(PassRefPtrWillBeRawPtr<Event> event) 392 void LocalDOMWindow::enqueueDocumentEvent(RawPtr<Event> event)
393 { 393 {
394 if (!m_eventQueue) 394 if (!m_eventQueue)
395 return; 395 return;
396 event->setTarget(m_document.get()); 396 event->setTarget(m_document.get());
397 m_eventQueue->enqueueEvent(event); 397 m_eventQueue->enqueueEvent(event);
398 } 398 }
399 399
400 void LocalDOMWindow::dispatchWindowLoadEvent() 400 void LocalDOMWindow::dispatchWindowLoadEvent()
401 { 401 {
402 ASSERT(!EventDispatchForbiddenScope::isEventDispatchForbidden()); 402 ASSERT(!EventDispatchForbiddenScope::isEventDispatchForbidden());
403 // Delay 'load' event if we are in EventQueueScope. This is a short-term 403 // Delay 'load' event if we are in EventQueueScope. This is a short-term
404 // workaround to avoid Editing code crashes. We should always dispatch 404 // workaround to avoid Editing code crashes. We should always dispatch
405 // 'load' event asynchronously. crbug.com/569511. 405 // 'load' event asynchronously. crbug.com/569511.
406 if (ScopedEventQueue::instance()->shouldQueueEvents() && m_document) { 406 if (ScopedEventQueue::instance()->shouldQueueEvents() && m_document) {
407 m_document->postTask(BLINK_FROM_HERE, createSameThreadTask(&LocalDOMWind ow::dispatchLoadEvent, PassRefPtrWillBeRawPtr<LocalDOMWindow>(this))); 407 m_document->postTask(BLINK_FROM_HERE, createSameThreadTask(&LocalDOMWind ow::dispatchLoadEvent, RawPtr<LocalDOMWindow>(this)));
408 return; 408 return;
409 } 409 }
410 dispatchLoadEvent(); 410 dispatchLoadEvent();
411 } 411 }
412 412
413 void LocalDOMWindow::documentWasClosed() 413 void LocalDOMWindow::documentWasClosed()
414 { 414 {
415 dispatchWindowLoadEvent(); 415 dispatchWindowLoadEvent();
416 enqueuePageshowEvent(PageshowEventNotPersisted); 416 enqueuePageshowEvent(PageshowEventNotPersisted);
417 if (m_pendingStateObject) 417 if (m_pendingStateObject)
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 const LocalDOMWindow* LocalDOMWindow::toDOMWindow() const 488 const LocalDOMWindow* LocalDOMWindow::toDOMWindow() const
489 { 489 {
490 return this; 490 return this;
491 } 491 }
492 492
493 LocalDOMWindow* LocalDOMWindow::toDOMWindow() 493 LocalDOMWindow* LocalDOMWindow::toDOMWindow()
494 { 494 {
495 return this; 495 return this;
496 } 496 }
497 497
498 PassRefPtrWillBeRawPtr<MediaQueryList> LocalDOMWindow::matchMedia(const String& media) 498 RawPtr<MediaQueryList> LocalDOMWindow::matchMedia(const String& media)
499 { 499 {
500 return document() ? document()->mediaQueryMatcher().matchMedia(media) : null ptr; 500 return document() ? document()->mediaQueryMatcher().matchMedia(media) : null ptr;
501 } 501 }
502 502
503 void LocalDOMWindow::willDetachFrameHost() 503 void LocalDOMWindow::willDetachFrameHost()
504 { 504 {
505 frame()->host()->eventHandlerRegistry().didRemoveAllEventHandlers(*this); 505 frame()->host()->eventHandlerRegistry().didRemoveAllEventHandlers(*this);
506 frame()->host()->consoleMessageStorage().frameWindowDiscarded(this); 506 frame()->host()->consoleMessageStorage().frameWindowDiscarded(this);
507 LocalDOMWindow::notifyContextDestroyed(); 507 LocalDOMWindow::notifyContextDestroyed();
508 } 508 }
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 } 561 }
562 562
563 void LocalDOMWindow::sendOrientationChangeEvent() 563 void LocalDOMWindow::sendOrientationChangeEvent()
564 { 564 {
565 ASSERT(RuntimeEnabledFeatures::orientationEventEnabled()); 565 ASSERT(RuntimeEnabledFeatures::orientationEventEnabled());
566 ASSERT(frame()->isMainFrame()); 566 ASSERT(frame()->isMainFrame());
567 567
568 // Before dispatching the event, build a list of all frames in the page 568 // Before dispatching the event, build a list of all frames in the page
569 // to send the event to, to mitigate side effects from event handlers 569 // to send the event to, to mitigate side effects from event handlers
570 // potentially interfering with others. 570 // potentially interfering with others.
571 WillBeHeapVector<RefPtrWillBeMember<Frame>> frames; 571 HeapVector<Member<Frame>> frames;
572 for (Frame* f = frame(); f; f = f->tree().traverseNext()) 572 for (Frame* f = frame(); f; f = f->tree().traverseNext())
573 frames.append(f); 573 frames.append(f);
574 574
575 for (size_t i = 0; i < frames.size(); ++i) { 575 for (size_t i = 0; i < frames.size(); ++i) {
576 if (!frames[i]->isLocalFrame()) 576 if (!frames[i]->isLocalFrame())
577 continue; 577 continue;
578 toLocalFrame(frames[i].get())->localDOMWindow()->dispatchEvent(Event::cr eate(EventTypeNames::orientationchange)); 578 toLocalFrame(frames[i].get())->localDOMWindow()->dispatchEvent(Event::cr eate(EventTypeNames::orientationchange));
579 } 579 }
580 } 580 }
581 581
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 return m_applicationCache.get(); 674 return m_applicationCache.get();
675 } 675 }
676 676
677 Navigator* LocalDOMWindow::navigator() const 677 Navigator* LocalDOMWindow::navigator() const
678 { 678 {
679 if (!m_navigator) 679 if (!m_navigator)
680 m_navigator = Navigator::create(frame()); 680 m_navigator = Navigator::create(frame());
681 return m_navigator.get(); 681 return m_navigator.get();
682 } 682 }
683 683
684 void LocalDOMWindow::schedulePostMessage(PassRefPtrWillBeRawPtr<MessageEvent> ev ent, SecurityOrigin* target, PassRefPtr<ScriptCallStack> stackTrace) 684 void LocalDOMWindow::schedulePostMessage(RawPtr<MessageEvent> event, SecurityOri gin* target, PassRefPtr<ScriptCallStack> stackTrace)
685 { 685 {
686 // Allowing unbounded amounts of messages to build up for a suspended contex t 686 // Allowing unbounded amounts of messages to build up for a suspended contex t
687 // is problematic; consider imposing a limit or other restriction if this 687 // is problematic; consider imposing a limit or other restriction if this
688 // surfaces often as a problem (see crbug.com/587012). 688 // surfaces often as a problem (see crbug.com/587012).
689 689
690 // Schedule the message. 690 // Schedule the message.
691 OwnPtrWillBeRawPtr<PostMessageTimer> timer = adoptPtrWillBeNoop(new PostMess ageTimer(*this, event, target, stackTrace, UserGestureIndicator::currentToken()) ); 691 RawPtr<PostMessageTimer> timer = new PostMessageTimer(*this, event, target, stackTrace, UserGestureIndicator::currentToken());
692 timer->startOneShot(0, BLINK_FROM_HERE); 692 timer->startOneShot(0, BLINK_FROM_HERE);
693 timer->suspendIfNeeded(); 693 timer->suspendIfNeeded();
694 m_postMessageTimers.add(timer.release()); 694 m_postMessageTimers.add(timer.release());
695 } 695 }
696 696
697 void LocalDOMWindow::postMessageTimerFired(PostMessageTimer* timer) 697 void LocalDOMWindow::postMessageTimerFired(PostMessageTimer* timer)
698 { 698 {
699 if (!isCurrentlyDisplayedInFrame()) 699 if (!isCurrentlyDisplayedInFrame())
700 return; 700 return;
701 701
702 RefPtrWillBeRawPtr<MessageEvent> event = timer->event(); 702 RawPtr<MessageEvent> event = timer->event();
703 703
704 UserGestureIndicator gestureIndicator(timer->userGestureToken()); 704 UserGestureIndicator gestureIndicator(timer->userGestureToken());
705 705
706 event->entangleMessagePorts(document()); 706 event->entangleMessagePorts(document());
707 dispatchMessageEventWithOriginCheck(timer->targetOrigin(), event, timer->sta ckTrace()); 707 dispatchMessageEventWithOriginCheck(timer->targetOrigin(), event, timer->sta ckTrace());
708 } 708 }
709 709
710 void LocalDOMWindow::removePostMessageTimer(PostMessageTimer* timer) 710 void LocalDOMWindow::removePostMessageTimer(PostMessageTimer* timer)
711 { 711 {
712 m_postMessageTimers.remove(timer); 712 m_postMessageTimers.remove(timer);
713 } 713 }
714 714
715 void LocalDOMWindow::dispatchMessageEventWithOriginCheck(SecurityOrigin* intende dTargetOrigin, PassRefPtrWillBeRawPtr<Event> event, PassRefPtr<ScriptCallStack> stackTrace) 715 void LocalDOMWindow::dispatchMessageEventWithOriginCheck(SecurityOrigin* intende dTargetOrigin, RawPtr<Event> event, PassRefPtr<ScriptCallStack> stackTrace)
716 { 716 {
717 if (intendedTargetOrigin) { 717 if (intendedTargetOrigin) {
718 // Check target origin now since the target document may have changed si nce the timer was scheduled. 718 // Check target origin now since the target document may have changed si nce the timer was scheduled.
719 SecurityOrigin* securityOrigin = document()->getSecurityOrigin(); 719 SecurityOrigin* securityOrigin = document()->getSecurityOrigin();
720 bool validTarget = intendedTargetOrigin->isSameSchemeHostPortAndSuborigi n(securityOrigin); 720 bool validTarget = intendedTargetOrigin->isSameSchemeHostPortAndSuborigi n(securityOrigin);
721 if (securityOrigin->hasSuborigin() && securityOrigin->suborigin()->polic yContains(Suborigin::SuboriginPolicyOptions::UnsafePostMessageReceive)) 721 if (securityOrigin->hasSuborigin() && securityOrigin->suborigin()->polic yContains(Suborigin::SuboriginPolicyOptions::UnsafePostMessageReceive))
722 validTarget = intendedTargetOrigin->isSameSchemeHostPort(securityOri gin); 722 validTarget = intendedTargetOrigin->isSameSchemeHostPort(securityOri gin);
723 723
724 if (!validTarget) { 724 if (!validTarget) {
725 String message = ExceptionMessages::failedToExecute("postMessage", " DOMWindow", "The target origin provided ('" + intendedTargetOrigin->toString() + "') does not match the recipient window's origin ('" + document()->getSecurityO rigin()->toString() + "')."); 725 String message = ExceptionMessages::failedToExecute("postMessage", " DOMWindow", "The target origin provided ('" + intendedTargetOrigin->toString() + "') does not match the recipient window's origin ('" + document()->getSecurityO rigin()->toString() + "').");
726 RefPtrWillBeRawPtr<ConsoleMessage> consoleMessage = ConsoleMessage:: create(SecurityMessageSource, ErrorMessageLevel, message); 726 RawPtr<ConsoleMessage> consoleMessage = ConsoleMessage::create(Secur ityMessageSource, ErrorMessageLevel, message);
727 consoleMessage->setCallStack(stackTrace); 727 consoleMessage->setCallStack(stackTrace);
728 frameConsole()->addMessage(consoleMessage.release()); 728 frameConsole()->addMessage(consoleMessage.release());
729 return; 729 return;
730 } 730 }
731 } 731 }
732 732
733 dispatchEvent(event); 733 dispatchEvent(event);
734 } 734 }
735 735
736 DOMSelection* LocalDOMWindow::getSelection() 736 DOMSelection* LocalDOMWindow::getSelection()
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
855 return String(); 855 return String();
856 } 856 }
857 857
858 bool LocalDOMWindow::find(const String& string, bool caseSensitive, bool backwar ds, bool wrap, bool wholeWord, bool /*searchInFrames*/, bool /*showDialog*/) con st 858 bool LocalDOMWindow::find(const String& string, bool caseSensitive, bool backwar ds, bool wrap, bool wholeWord, bool /*searchInFrames*/, bool /*showDialog*/) con st
859 { 859 {
860 if (!isCurrentlyDisplayedInFrame()) 860 if (!isCurrentlyDisplayedInFrame())
861 return false; 861 return false;
862 862
863 // |frame()| can be destructed during |Editor::findString()| via 863 // |frame()| can be destructed during |Editor::findString()| via
864 // |Document::updateLayout()|, e.g. event handler removes a frame. 864 // |Document::updateLayout()|, e.g. event handler removes a frame.
865 RefPtrWillBeRawPtr<LocalFrame> protectFrame(frame()); 865 RawPtr<LocalFrame> protectFrame(frame());
866 866
867 // FIXME (13016): Support searchInFrames and showDialog 867 // FIXME (13016): Support searchInFrames and showDialog
868 FindOptions options = (backwards ? Backwards : 0) | (caseSensitive ? 0 : Cas eInsensitive) | (wrap ? WrapAround : 0) | (wholeWord ? WholeWord | AtWordStarts : 0); 868 FindOptions options = (backwards ? Backwards : 0) | (caseSensitive ? 0 : Cas eInsensitive) | (wrap ? WrapAround : 0) | (wholeWord ? WholeWord | AtWordStarts : 0);
869 return frame()->editor().findString(string, options); 869 return frame()->editor().findString(string, options);
870 } 870 }
871 871
872 bool LocalDOMWindow::offscreenBuffering() const 872 bool LocalDOMWindow::offscreenBuffering() const
873 { 873 {
874 return true; 874 return true;
875 } 875 }
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
1069 return m_document.get(); 1069 return m_document.get();
1070 } 1070 }
1071 1071
1072 StyleMedia* LocalDOMWindow::styleMedia() const 1072 StyleMedia* LocalDOMWindow::styleMedia() const
1073 { 1073 {
1074 if (!m_media) 1074 if (!m_media)
1075 m_media = StyleMedia::create(frame()); 1075 m_media = StyleMedia::create(frame());
1076 return m_media.get(); 1076 return m_media.get();
1077 } 1077 }
1078 1078
1079 PassRefPtrWillBeRawPtr<CSSStyleDeclaration> LocalDOMWindow::getComputedStyle(Ele ment* elt, const String& pseudoElt) const 1079 RawPtr<CSSStyleDeclaration> LocalDOMWindow::getComputedStyle(Element* elt, const String& pseudoElt) const
1080 { 1080 {
1081 ASSERT(elt); 1081 ASSERT(elt);
1082 return CSSComputedStyleDeclaration::create(elt, false, pseudoElt); 1082 return CSSComputedStyleDeclaration::create(elt, false, pseudoElt);
1083 } 1083 }
1084 1084
1085 PassRefPtrWillBeRawPtr<CSSRuleList> LocalDOMWindow::getMatchedCSSRules(Element* element, const String& pseudoElement) const 1085 RawPtr<CSSRuleList> LocalDOMWindow::getMatchedCSSRules(Element* element, const S tring& pseudoElement) const
1086 { 1086 {
1087 if (!element) 1087 if (!element)
1088 return nullptr; 1088 return nullptr;
1089 1089
1090 if (!isCurrentlyDisplayedInFrame()) 1090 if (!isCurrentlyDisplayedInFrame())
1091 return nullptr; 1091 return nullptr;
1092 1092
1093 unsigned colonStart = pseudoElement[0] == ':' ? (pseudoElement[1] == ':' ? 2 : 1) : 0; 1093 unsigned colonStart = pseudoElement[0] == ':' ? (pseudoElement[1] == ':' ? 2 : 1) : 0;
1094 CSSSelector::PseudoType pseudoType = CSSSelector::parsePseudoType(AtomicStri ng(pseudoElement.substring(colonStart)), false); 1094 CSSSelector::PseudoType pseudoType = CSSSelector::parsePseudoType(AtomicStri ng(pseudoElement.substring(colonStart)), false);
1095 if (pseudoType == CSSSelector::PseudoUnknown && !pseudoElement.isEmpty()) 1095 if (pseudoType == CSSSelector::PseudoUnknown && !pseudoElement.isEmpty())
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
1305 return document->requestIdleCallback(callback, options); 1305 return document->requestIdleCallback(callback, options);
1306 return 0; 1306 return 0;
1307 } 1307 }
1308 1308
1309 void LocalDOMWindow::cancelIdleCallback(int id) 1309 void LocalDOMWindow::cancelIdleCallback(int id)
1310 { 1310 {
1311 if (Document* document = this->document()) 1311 if (Document* document = this->document())
1312 document->cancelIdleCallback(id); 1312 document->cancelIdleCallback(id);
1313 } 1313 }
1314 1314
1315 bool LocalDOMWindow::addEventListenerInternal(const AtomicString& eventType, Pas sRefPtrWillBeRawPtr<EventListener> prpListener, const EventListenerOptions& opti ons) 1315 bool LocalDOMWindow::addEventListenerInternal(const AtomicString& eventType, Raw Ptr<EventListener> prpListener, const EventListenerOptions& options)
1316 { 1316 {
1317 RefPtrWillBeRawPtr<EventListener> listener = prpListener; 1317 RawPtr<EventListener> listener = prpListener;
1318 if (!EventTarget::addEventListenerInternal(eventType, listener, options)) 1318 if (!EventTarget::addEventListenerInternal(eventType, listener, options))
1319 return false; 1319 return false;
1320 1320
1321 if (frame() && frame()->host()) 1321 if (frame() && frame()->host())
1322 frame()->host()->eventHandlerRegistry().didAddEventHandler(*this, eventT ype, options); 1322 frame()->host()->eventHandlerRegistry().didAddEventHandler(*this, eventT ype, options);
1323 1323
1324 if (Document* document = this->document()) { 1324 if (Document* document = this->document()) {
1325 document->addListenerTypeIfNeeded(eventType); 1325 document->addListenerTypeIfNeeded(eventType);
1326 } 1326 }
1327 1327
(...skipping 11 matching lines...) Expand all
1339 addBeforeUnloadEventListener(this); 1339 addBeforeUnloadEventListener(this);
1340 } else { 1340 } else {
1341 // Subframes return false from allowsBeforeUnloadListeners. 1341 // Subframes return false from allowsBeforeUnloadListeners.
1342 UseCounter::count(document(), UseCounter::SubFrameBeforeUnloadRegist ered); 1342 UseCounter::count(document(), UseCounter::SubFrameBeforeUnloadRegist ered);
1343 } 1343 }
1344 } 1344 }
1345 1345
1346 return true; 1346 return true;
1347 } 1347 }
1348 1348
1349 bool LocalDOMWindow::removeEventListenerInternal(const AtomicString& eventType, PassRefPtrWillBeRawPtr<EventListener> listener, const EventListenerOptions& opti ons) 1349 bool LocalDOMWindow::removeEventListenerInternal(const AtomicString& eventType, RawPtr<EventListener> listener, const EventListenerOptions& options)
1350 { 1350 {
1351 if (!EventTarget::removeEventListenerInternal(eventType, listener, options)) 1351 if (!EventTarget::removeEventListenerInternal(eventType, listener, options))
1352 return false; 1352 return false;
1353 1353
1354 if (frame() && frame()->host()) 1354 if (frame() && frame()->host())
1355 frame()->host()->eventHandlerRegistry().didRemoveEventHandler(*this, eve ntType, options); 1355 frame()->host()->eventHandlerRegistry().didRemoveEventHandler(*this, eve ntType, options);
1356 1356
1357 notifyRemoveEventListener(this, eventType); 1357 notifyRemoveEventListener(this, eventType);
1358 1358
1359 if (eventType == EventTypeNames::unload) { 1359 if (eventType == EventTypeNames::unload) {
1360 removeUnloadEventListener(this); 1360 removeUnloadEventListener(this);
1361 } else if (eventType == EventTypeNames::beforeunload && allowsBeforeUnloadLi steners(this)) { 1361 } else if (eventType == EventTypeNames::beforeunload && allowsBeforeUnloadLi steners(this)) {
1362 removeBeforeUnloadEventListener(this); 1362 removeBeforeUnloadEventListener(this);
1363 } 1363 }
1364 1364
1365 return true; 1365 return true;
1366 } 1366 }
1367 1367
1368 void LocalDOMWindow::dispatchLoadEvent() 1368 void LocalDOMWindow::dispatchLoadEvent()
1369 { 1369 {
1370 RefPtrWillBeRawPtr<Event> loadEvent(Event::create(EventTypeNames::load)); 1370 RawPtr<Event> loadEvent(Event::create(EventTypeNames::load));
1371 if (frame() && frame()->loader().documentLoader() && !frame()->loader().docu mentLoader()->timing().loadEventStart()) { 1371 if (frame() && frame()->loader().documentLoader() && !frame()->loader().docu mentLoader()->timing().loadEventStart()) {
1372 // The DocumentLoader (and thus its DocumentLoadTiming) might get destro yed while dispatching 1372 // The DocumentLoader (and thus its DocumentLoadTiming) might get destro yed while dispatching
1373 // the event, so protect it to prevent writing the end time into freed m emory. 1373 // the event, so protect it to prevent writing the end time into freed m emory.
1374 RefPtrWillBeRawPtr<DocumentLoader> documentLoader = frame()->loader().do cumentLoader(); 1374 RawPtr<DocumentLoader> documentLoader = frame()->loader().documentLoader ();
1375 DocumentLoadTiming& timing = documentLoader->timing(); 1375 DocumentLoadTiming& timing = documentLoader->timing();
1376 timing.markLoadEventStart(); 1376 timing.markLoadEventStart();
1377 dispatchEvent(loadEvent, document()); 1377 dispatchEvent(loadEvent, document());
1378 timing.markLoadEventEnd(); 1378 timing.markLoadEventEnd();
1379 } else { 1379 } else {
1380 dispatchEvent(loadEvent, document()); 1380 dispatchEvent(loadEvent, document());
1381 } 1381 }
1382 1382
1383 // For load events, send a separate load event to the enclosing frame only. 1383 // For load events, send a separate load event to the enclosing frame only.
1384 // This is a DOM extension and is independent of bubbling/capturing rules of 1384 // This is a DOM extension and is independent of bubbling/capturing rules of
1385 // the DOM. 1385 // the DOM.
1386 FrameOwner* owner = frame() ? frame()->owner() : nullptr; 1386 FrameOwner* owner = frame() ? frame()->owner() : nullptr;
1387 if (owner) 1387 if (owner)
1388 owner->dispatchLoad(); 1388 owner->dispatchLoad();
1389 1389
1390 TRACE_EVENT_INSTANT1("devtools.timeline", "MarkLoad", TRACE_EVENT_SCOPE_THRE AD, "data", InspectorMarkLoadEvent::data(frame())); 1390 TRACE_EVENT_INSTANT1("devtools.timeline", "MarkLoad", TRACE_EVENT_SCOPE_THRE AD, "data", InspectorMarkLoadEvent::data(frame()));
1391 InspectorInstrumentation::loadEventFired(frame()); 1391 InspectorInstrumentation::loadEventFired(frame());
1392 } 1392 }
1393 1393
1394 DispatchEventResult LocalDOMWindow::dispatchEvent(PassRefPtrWillBeRawPtr<Event> prpEvent, PassRefPtrWillBeRawPtr<EventTarget> prpTarget) 1394 DispatchEventResult LocalDOMWindow::dispatchEvent(RawPtr<Event> prpEvent, RawPtr <EventTarget> prpTarget)
1395 { 1395 {
1396 ASSERT(!EventDispatchForbiddenScope::isEventDispatchForbidden()); 1396 ASSERT(!EventDispatchForbiddenScope::isEventDispatchForbidden());
1397 1397
1398 RefPtrWillBeRawPtr<EventTarget> protect(this); 1398 RawPtr<EventTarget> protect(this);
1399 RefPtrWillBeRawPtr<Event> event = prpEvent; 1399 RawPtr<Event> event = prpEvent;
1400 1400
1401 event->setTrusted(true); 1401 event->setTrusted(true);
1402 event->setTarget(prpTarget ? prpTarget : this); 1402 event->setTarget(prpTarget ? prpTarget : this);
1403 event->setCurrentTarget(this); 1403 event->setCurrentTarget(this);
1404 event->setEventPhase(Event::AT_TARGET); 1404 event->setEventPhase(Event::AT_TARGET);
1405 1405
1406 TRACE_EVENT1("devtools.timeline", "EventDispatch", "data", InspectorEventDis patchEvent::data(*event)); 1406 TRACE_EVENT1("devtools.timeline", "EventDispatch", "data", InspectorEventDis patchEvent::data(*event));
1407 return fireEventListeners(event.get()); 1407 return fireEventListeners(event.get());
1408 } 1408 }
1409 1409
(...skipping 21 matching lines...) Expand all
1431 { 1431 {
1432 if (!isCurrentlyDisplayedInFrame()) 1432 if (!isCurrentlyDisplayedInFrame())
1433 return; 1433 return;
1434 1434
1435 if (message.isEmpty()) 1435 if (message.isEmpty())
1436 return; 1436 return;
1437 1437
1438 frameConsole()->addMessage(ConsoleMessage::create(JSMessageSource, ErrorMess ageLevel, message)); 1438 frameConsole()->addMessage(ConsoleMessage::create(JSMessageSource, ErrorMess ageLevel, message));
1439 } 1439 }
1440 1440
1441 PassRefPtrWillBeRawPtr<DOMWindow> LocalDOMWindow::open(const String& urlString, const AtomicString& frameName, const String& windowFeaturesString, 1441 RawPtr<DOMWindow> LocalDOMWindow::open(const String& urlString, const AtomicStri ng& frameName, const String& windowFeaturesString,
1442 LocalDOMWindow* callingWindow, LocalDOMWindow* enteredWindow) 1442 LocalDOMWindow* callingWindow, LocalDOMWindow* enteredWindow)
1443 { 1443 {
1444 if (!isCurrentlyDisplayedInFrame()) 1444 if (!isCurrentlyDisplayedInFrame())
1445 return nullptr; 1445 return nullptr;
1446 if (!callingWindow->frame()) 1446 if (!callingWindow->frame())
1447 return nullptr; 1447 return nullptr;
1448 Document* activeDocument = callingWindow->document(); 1448 Document* activeDocument = callingWindow->document();
1449 if (!activeDocument) 1449 if (!activeDocument)
1450 return nullptr; 1450 return nullptr;
1451 LocalFrame* firstFrame = enteredWindow->frame(); 1451 LocalFrame* firstFrame = enteredWindow->frame();
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1485 return targetFrame->domWindow(); 1485 return targetFrame->domWindow();
1486 1486
1487 if (urlString.isEmpty()) 1487 if (urlString.isEmpty())
1488 return targetFrame->domWindow(); 1488 return targetFrame->domWindow();
1489 1489
1490 targetFrame->navigate(*activeDocument, completedURL, false, UserGestureS tatus::None); 1490 targetFrame->navigate(*activeDocument, completedURL, false, UserGestureS tatus::None);
1491 return targetFrame->domWindow(); 1491 return targetFrame->domWindow();
1492 } 1492 }
1493 1493
1494 WindowFeatures features(windowFeaturesString); 1494 WindowFeatures features(windowFeaturesString);
1495 RefPtrWillBeRawPtr<DOMWindow> newWindow = createWindow(urlString, frameName, features, *callingWindow, *firstFrame, *frame()); 1495 RawPtr<DOMWindow> newWindow = createWindow(urlString, frameName, features, * callingWindow, *firstFrame, *frame());
1496 return features.noopener ? nullptr : newWindow; 1496 return features.noopener ? nullptr : newWindow;
1497 } 1497 }
1498 1498
1499 DEFINE_TRACE(LocalDOMWindow) 1499 DEFINE_TRACE(LocalDOMWindow)
1500 { 1500 {
1501 #if ENABLE(OILPAN) 1501 #if ENABLE(OILPAN)
1502 visitor->trace(m_frameObserver); 1502 visitor->trace(m_frameObserver);
1503 visitor->trace(m_document); 1503 visitor->trace(m_document);
1504 visitor->trace(m_properties); 1504 visitor->trace(m_properties);
1505 visitor->trace(m_screen); 1505 visitor->trace(m_screen);
(...skipping 20 matching lines...) Expand all
1526 { 1526 {
1527 // If the LocalDOMWindow still has a frame reference, that frame must point 1527 // If the LocalDOMWindow still has a frame reference, that frame must point
1528 // back to this LocalDOMWindow: otherwise, it's easy to get into a situation 1528 // back to this LocalDOMWindow: otherwise, it's easy to get into a situation
1529 // where script execution leaks between different LocalDOMWindows. 1529 // where script execution leaks between different LocalDOMWindows.
1530 if (m_frameObserver->frame()) 1530 if (m_frameObserver->frame())
1531 ASSERT_WITH_SECURITY_IMPLICATION(m_frameObserver->frame()->domWindow() = = this); 1531 ASSERT_WITH_SECURITY_IMPLICATION(m_frameObserver->frame()->domWindow() = = this);
1532 return m_frameObserver->frame(); 1532 return m_frameObserver->frame();
1533 } 1533 }
1534 1534
1535 } // namespace blink 1535 } // 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