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

Side by Side Diff: Source/core/frame/DOMWindow.cpp

Issue 216523002: Oilpan: Replace most of RefPtrs for Event objects with oilpan's transition types (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 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 | Annotate | Revision Log
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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 , m_message(message) 117 , m_message(message)
118 , m_origin(sourceOrigin) 118 , m_origin(sourceOrigin)
119 , m_source(source) 119 , m_source(source)
120 , m_channels(channels) 120 , m_channels(channels)
121 , m_targetOrigin(targetOrigin) 121 , m_targetOrigin(targetOrigin)
122 , m_stackTrace(stackTrace) 122 , m_stackTrace(stackTrace)
123 , m_userGestureToken(userGestureToken) 123 , m_userGestureToken(userGestureToken)
124 { 124 {
125 } 125 }
126 126
127 PassRefPtr<MessageEvent> event() 127 PassRefPtrWillBeRawPtr<MessageEvent> event()
128 { 128 {
129 return MessageEvent::create(m_channels.release(), m_message, m_origin, S tring(), m_source.get()); 129 return MessageEvent::create(m_channels.release(), m_message, m_origin, S tring(), m_source.get());
130 130
131 } 131 }
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 135
136 private: 136 private:
137 virtual void fired() OVERRIDE 137 virtual void fired() OVERRIDE
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 } 415 }
416 416
417 return m_document; 417 return m_document;
418 } 418 }
419 419
420 EventQueue* DOMWindow::eventQueue() const 420 EventQueue* DOMWindow::eventQueue() const
421 { 421 {
422 return m_eventQueue.get(); 422 return m_eventQueue.get();
423 } 423 }
424 424
425 void DOMWindow::enqueueWindowEvent(PassRefPtr<Event> event) 425 void DOMWindow::enqueueWindowEvent(PassRefPtrWillBeRawPtr<Event> event)
426 { 426 {
427 if (!m_eventQueue) 427 if (!m_eventQueue)
428 return; 428 return;
429 event->setTarget(this); 429 event->setTarget(this);
430 m_eventQueue->enqueueEvent(event); 430 m_eventQueue->enqueueEvent(event);
431 } 431 }
432 432
433 void DOMWindow::enqueueDocumentEvent(PassRefPtr<Event> event) 433 void DOMWindow::enqueueDocumentEvent(PassRefPtrWillBeRawPtr<Event> event)
434 { 434 {
435 if (!m_eventQueue) 435 if (!m_eventQueue)
436 return; 436 return;
437 event->setTarget(m_document); 437 event->setTarget(m_document);
438 m_eventQueue->enqueueEvent(event); 438 m_eventQueue->enqueueEvent(event);
439 } 439 }
440 440
441 void DOMWindow::dispatchWindowLoadEvent() 441 void DOMWindow::dispatchWindowLoadEvent()
442 { 442 {
443 ASSERT(!NoEventDispatchAssertion::isEventDispatchForbidden()); 443 ASSERT(!NoEventDispatchAssertion::isEventDispatchForbidden());
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
859 timer->suspendIfNeeded(); 859 timer->suspendIfNeeded();
860 } 860 }
861 861
862 void DOMWindow::postMessageTimerFired(PassOwnPtr<PostMessageTimer> t) 862 void DOMWindow::postMessageTimerFired(PassOwnPtr<PostMessageTimer> t)
863 { 863 {
864 OwnPtr<PostMessageTimer> timer(t); 864 OwnPtr<PostMessageTimer> timer(t);
865 865
866 if (!isCurrentlyDisplayedInFrame()) 866 if (!isCurrentlyDisplayedInFrame())
867 return; 867 return;
868 868
869 RefPtr<MessageEvent> event = timer->event(); 869 RefPtrWillBeRawPtr<MessageEvent> event = timer->event();
870 870
871 // Give the embedder a chance to intercept this postMessage because this 871 // Give the embedder a chance to intercept this postMessage because this
872 // DOMWindow might be a proxy for another in browsers that support 872 // DOMWindow might be a proxy for another in browsers that support
873 // postMessage calls across WebKit instances. 873 // postMessage calls across WebKit instances.
874 if (m_frame->loader().client()->willCheckAndDispatchMessageEvent(timer->targ etOrigin(), event.get())) 874 if (m_frame->loader().client()->willCheckAndDispatchMessageEvent(timer->targ etOrigin(), event.get()))
875 return; 875 return;
876 876
877 UserGestureIndicator gestureIndicator(timer->userGestureToken()); 877 UserGestureIndicator gestureIndicator(timer->userGestureToken());
878 878
879 event->entangleMessagePorts(document()); 879 event->entangleMessagePorts(document());
880 dispatchMessageEventWithOriginCheck(timer->targetOrigin(), event, timer->sta ckTrace()); 880 dispatchMessageEventWithOriginCheck(timer->targetOrigin(), event, timer->sta ckTrace());
881 } 881 }
882 882
883 void DOMWindow::dispatchMessageEventWithOriginCheck(SecurityOrigin* intendedTarg etOrigin, PassRefPtr<Event> event, PassRefPtr<ScriptCallStack> stackTrace) 883 void DOMWindow::dispatchMessageEventWithOriginCheck(SecurityOrigin* intendedTarg etOrigin, PassRefPtrWillBeRawPtr<Event> event, PassRefPtr<ScriptCallStack> stack Trace)
884 { 884 {
885 if (intendedTargetOrigin) { 885 if (intendedTargetOrigin) {
886 // Check target origin now since the target document may have changed si nce the timer was scheduled. 886 // Check target origin now since the target document may have changed si nce the timer was scheduled.
887 if (!intendedTargetOrigin->isSameSchemeHostPort(document()->securityOrig in())) { 887 if (!intendedTargetOrigin->isSameSchemeHostPort(document()->securityOrig in())) {
888 String message = ExceptionMessages::failedToExecute("postMessage", " DOMWindow", "The target origin provided ('" + intendedTargetOrigin->toString() + "') does not match the recipient window's origin ('" + document()->securityOrig in()->toString() + "')."); 888 String message = ExceptionMessages::failedToExecute("postMessage", " DOMWindow", "The target origin provided ('" + intendedTargetOrigin->toString() + "') does not match the recipient window's origin ('" + document()->securityOrig in()->toString() + "').");
889 pageConsole()->addMessage(SecurityMessageSource, ErrorMessageLevel, message, stackTrace); 889 pageConsole()->addMessage(SecurityMessageSource, ErrorMessageLevel, message, stackTrace);
890 return; 890 return;
891 } 891 }
892 } 892 }
893 893
(...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after
1564 removeUnloadEventListener(this); 1564 removeUnloadEventListener(this);
1565 } else if (eventType == EventTypeNames::beforeunload && allowsBeforeUnloadLi steners(this)) { 1565 } else if (eventType == EventTypeNames::beforeunload && allowsBeforeUnloadLi steners(this)) {
1566 removeBeforeUnloadEventListener(this); 1566 removeBeforeUnloadEventListener(this);
1567 } 1567 }
1568 1568
1569 return true; 1569 return true;
1570 } 1570 }
1571 1571
1572 void DOMWindow::dispatchLoadEvent() 1572 void DOMWindow::dispatchLoadEvent()
1573 { 1573 {
1574 RefPtr<Event> loadEvent(Event::create(EventTypeNames::load)); 1574 RefPtrWillBeRawPtr<Event> loadEvent(Event::create(EventTypeNames::load));
1575 if (m_frame && m_frame->loader().documentLoader() && !m_frame->loader().docu mentLoader()->timing()->loadEventStart()) { 1575 if (m_frame && m_frame->loader().documentLoader() && !m_frame->loader().docu mentLoader()->timing()->loadEventStart()) {
1576 // The DocumentLoader (and thus its DocumentLoadTiming) might get destro yed while dispatching 1576 // The DocumentLoader (and thus its DocumentLoadTiming) might get destro yed while dispatching
1577 // the event, so protect it to prevent writing the end time into freed m emory. 1577 // the event, so protect it to prevent writing the end time into freed m emory.
1578 RefPtr<DocumentLoader> documentLoader = m_frame->loader().documentLoader (); 1578 RefPtr<DocumentLoader> documentLoader = m_frame->loader().documentLoader ();
1579 DocumentLoadTiming* timing = documentLoader->timing(); 1579 DocumentLoadTiming* timing = documentLoader->timing();
1580 timing->markLoadEventStart(); 1580 timing->markLoadEventStart();
1581 dispatchEvent(loadEvent, document()); 1581 dispatchEvent(loadEvent, document());
1582 timing->markLoadEventEnd(); 1582 timing->markLoadEventEnd();
1583 } else 1583 } else
1584 dispatchEvent(loadEvent, document()); 1584 dispatchEvent(loadEvent, document());
1585 1585
1586 // For load events, send a separate load event to the enclosing frame only. 1586 // For load events, send a separate load event to the enclosing frame only.
1587 // This is a DOM extension and is independent of bubbling/capturing rules of 1587 // This is a DOM extension and is independent of bubbling/capturing rules of
1588 // the DOM. 1588 // the DOM.
1589 Element* ownerElement = m_frame ? m_frame->ownerElement() : 0; 1589 Element* ownerElement = m_frame ? m_frame->ownerElement() : 0;
1590 if (ownerElement) 1590 if (ownerElement)
1591 ownerElement->dispatchEvent(Event::create(EventTypeNames::load)); 1591 ownerElement->dispatchEvent(Event::create(EventTypeNames::load));
1592 1592
1593 InspectorInstrumentation::loadEventFired(frame()); 1593 InspectorInstrumentation::loadEventFired(frame());
1594 } 1594 }
1595 1595
1596 bool DOMWindow::dispatchEvent(PassRefPtr<Event> prpEvent, PassRefPtr<EventTarget > prpTarget) 1596 bool DOMWindow::dispatchEvent(PassRefPtrWillBeRawPtr<Event> prpEvent, PassRefPtr <EventTarget> prpTarget)
1597 { 1597 {
1598 ASSERT(!NoEventDispatchAssertion::isEventDispatchForbidden()); 1598 ASSERT(!NoEventDispatchAssertion::isEventDispatchForbidden());
1599 1599
1600 RefPtr<EventTarget> protect = this; 1600 RefPtr<EventTarget> protect = this;
1601 RefPtr<Event> event = prpEvent; 1601 RefPtrWillBeRawPtr<Event> event = prpEvent;
1602 1602
1603 event->setTarget(prpTarget ? prpTarget : this); 1603 event->setTarget(prpTarget ? prpTarget : this);
1604 event->setCurrentTarget(this); 1604 event->setCurrentTarget(this);
1605 event->setEventPhase(Event::AT_TARGET); 1605 event->setEventPhase(Event::AT_TARGET);
1606 1606
1607 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willDispat chEventOnWindow(frame(), *event, this); 1607 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willDispat chEventOnWindow(frame(), *event, this);
1608 1608
1609 bool result = fireEventListeners(event.get()); 1609 bool result = fireEventListeners(event.get());
1610 1610
1611 InspectorInstrumentation::didDispatchEventOnWindow(cookie); 1611 InspectorInstrumentation::didDispatchEventOnWindow(cookie);
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
1888 visitor->trace(m_localStorage); 1888 visitor->trace(m_localStorage);
1889 visitor->trace(m_applicationCache); 1889 visitor->trace(m_applicationCache);
1890 visitor->trace(m_performance); 1890 visitor->trace(m_performance);
1891 visitor->trace(m_css); 1891 visitor->trace(m_css);
1892 #if ENABLE(OILPAN) 1892 #if ENABLE(OILPAN)
1893 HeapSupplementable<DOMWindow>::trace(visitor); 1893 HeapSupplementable<DOMWindow>::trace(visitor);
1894 #endif 1894 #endif
1895 } 1895 }
1896 1896
1897 } // namespace WebCore 1897 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698