X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fthird_party%2FWebKit%2FSource%2Fcore%2Fframe%2FDOMWindow.cpp;h=9b23dc8fc0e198095f97c478de138abbeaf80fee;hb=004985e17e624662a4c85c76a7654039dc83f028;hp=05d1d218bd2fc9de8af4df4d5e498898b90b7531;hpb=2f108dbacb161091e42a3479f4e171339b7e7623;p=platform%2Fframework%2Fweb%2Fcrosswalk.git diff --git a/src/third_party/WebKit/Source/core/frame/DOMWindow.cpp b/src/third_party/WebKit/Source/core/frame/DOMWindow.cpp index 05d1d21..9b23dc8 100644 --- a/src/third_party/WebKit/Source/core/frame/DOMWindow.cpp +++ b/src/third_party/WebKit/Source/core/frame/DOMWindow.cpp @@ -59,17 +59,18 @@ #include "core/frame/Console.h" #include "core/frame/DOMPoint.h" #include "core/frame/DOMWindowLifecycleNotifier.h" +#include "core/frame/FrameConsole.h" #include "core/frame/FrameHost.h" #include "core/frame/FrameView.h" #include "core/frame/History.h" #include "core/frame/LocalFrame.h" #include "core/frame/Location.h" #include "core/frame/Navigator.h" -#include "core/frame/PageConsole.h" #include "core/frame/Screen.h" #include "core/frame/Settings.h" #include "core/html/HTMLFrameOwnerElement.h" #include "core/inspector/InspectorInstrumentation.h" +#include "core/inspector/InspectorTraceEvents.h" #include "core/inspector/ScriptCallStack.h" #include "core/loader/DocumentLoader.h" #include "core/loader/FrameLoadRequest.h" @@ -113,7 +114,7 @@ class PostMessageTimer FINAL : public SuspendableTimer { public: PostMessageTimer(DOMWindow& window, PassRefPtr message, const String& sourceOrigin, PassRefPtrWillBeRawPtr source, PassOwnPtr channels, SecurityOrigin* targetOrigin, PassRefPtr stackTrace, UserGestureToken* userGestureToken) : SuspendableTimer(window.document()) - , m_window(&window) + , m_window(window) , m_message(message) , m_origin(sourceOrigin) , m_source(source) @@ -124,7 +125,7 @@ public: { } - PassRefPtr event() + PassRefPtrWillBeRawPtr event() { return MessageEvent::create(m_channels.release(), m_message, m_origin, String(), m_source.get()); @@ -310,16 +311,6 @@ bool DOMWindow::allowPopUp() return m_frame && allowPopUp(*m_frame); } -bool DOMWindow::canShowModalDialog(const LocalFrame* frame) -{ - if (!frame) - return false; - FrameHost* host = frame->host(); - if (!host) - return false; - return host->chrome().canRunModal(); -} - bool DOMWindow::canShowModalDialogNow(const LocalFrame* frame) { if (!frame) @@ -333,6 +324,9 @@ bool DOMWindow::canShowModalDialogNow(const LocalFrame* frame) DOMWindow::DOMWindow(LocalFrame& frame) : FrameDestructionObserver(&frame) , m_shouldPrintWhenFinishedLoading(false) +#if ASSERT_ENABLED + , m_hasBeenReset(false) +#endif { ScriptWrappable::init(this); } @@ -422,7 +416,7 @@ EventQueue* DOMWindow::eventQueue() const return m_eventQueue.get(); } -void DOMWindow::enqueueWindowEvent(PassRefPtr event) +void DOMWindow::enqueueWindowEvent(PassRefPtrWillBeRawPtr event) { if (!m_eventQueue) return; @@ -430,7 +424,7 @@ void DOMWindow::enqueueWindowEvent(PassRefPtr event) m_eventQueue->enqueueEvent(event); } -void DOMWindow::enqueueDocumentEvent(PassRefPtr event) +void DOMWindow::enqueueDocumentEvent(PassRefPtrWillBeRawPtr event) { if (!m_eventQueue) return; @@ -487,28 +481,17 @@ void DOMWindow::statePopped(PassRefPtr stateObject) DOMWindow::~DOMWindow() { - ASSERT(!m_screen); - ASSERT(!m_history); - ASSERT(!m_locationbar); - ASSERT(!m_menubar); - ASSERT(!m_personalbar); - ASSERT(!m_scrollbars); - ASSERT(!m_statusbar); - ASSERT(!m_toolbar); - ASSERT(!m_console); - ASSERT(!m_navigator); - ASSERT(!m_performance); - ASSERT(!m_location); - ASSERT(!m_media); - ASSERT(!m_sessionStorage); - ASSERT(!m_localStorage); - ASSERT(!m_applicationCache); - + ASSERT(m_hasBeenReset); reset(); removeAllEventListeners(); +#if ENABLE(OILPAN) + ASSERT(m_document->isDisposed()); +#else ASSERT(m_document->isStopped()); +#endif + clearDocument(); } @@ -604,6 +587,9 @@ void DOMWindow::resetDOMWindowProperties() m_sessionStorage = nullptr; m_localStorage = nullptr; m_applicationCache = nullptr; +#if ASSERT_ENABLED + m_hasBeenReset = true; +#endif } bool DOMWindow::isCurrentlyDisplayedInFrame() const @@ -615,12 +601,16 @@ int DOMWindow::orientation() const { ASSERT(RuntimeEnabledFeatures::orientationEventEnabled()); - UseCounter::count(document(), UseCounter::WindowOrientation); - if (!m_frame) return 0; - return m_frame->orientation(); + int orientation = screenOrientationAngle(m_frame->view()); + // For backward compatibility, we want to return a value in the range of + // [-90; 180] instead of [0; 360[ because window.orientation used to behave + // like that in WebKit (this is a WebKit proprietary API). + if (orientation == 270) + return -90; + return orientation; } Screen& DOMWindow::screen() const @@ -639,7 +629,6 @@ History& DOMWindow::history() const BarProp& DOMWindow::locationbar() const { - UseCounter::count(document(), UseCounter::BarPropLocationbar); if (!m_locationbar) m_locationbar = BarProp::create(m_frame, BarProp::Locationbar); return *m_locationbar; @@ -647,7 +636,6 @@ BarProp& DOMWindow::locationbar() const BarProp& DOMWindow::menubar() const { - UseCounter::count(document(), UseCounter::BarPropMenubar); if (!m_menubar) m_menubar = BarProp::create(m_frame, BarProp::Menubar); return *m_menubar; @@ -655,7 +643,6 @@ BarProp& DOMWindow::menubar() const BarProp& DOMWindow::personalbar() const { - UseCounter::count(document(), UseCounter::BarPropPersonalbar); if (!m_personalbar) m_personalbar = BarProp::create(m_frame, BarProp::Personalbar); return *m_personalbar; @@ -663,7 +650,6 @@ BarProp& DOMWindow::personalbar() const BarProp& DOMWindow::scrollbars() const { - UseCounter::count(document(), UseCounter::BarPropScrollbars); if (!m_scrollbars) m_scrollbars = BarProp::create(m_frame, BarProp::Scrollbars); return *m_scrollbars; @@ -671,7 +657,6 @@ BarProp& DOMWindow::scrollbars() const BarProp& DOMWindow::statusbar() const { - UseCounter::count(document(), UseCounter::BarPropStatusbar); if (!m_statusbar) m_statusbar = BarProp::create(m_frame, BarProp::Statusbar); return *m_statusbar; @@ -679,7 +664,6 @@ BarProp& DOMWindow::statusbar() const BarProp& DOMWindow::toolbar() const { - UseCounter::count(document(), UseCounter::BarPropToolbar); if (!m_toolbar) m_toolbar = BarProp::create(m_frame, BarProp::Toolbar); return *m_toolbar; @@ -692,11 +676,11 @@ Console& DOMWindow::console() const return *m_console; } -PageConsole* DOMWindow::pageConsole() const +FrameConsole* DOMWindow::frameConsole() const { if (!isCurrentlyDisplayedInFrame()) return 0; - return m_frame->host() ? &m_frame->host()->console() : 0; + return &m_frame->console(); } ApplicationCache* DOMWindow::applicationCache() const @@ -866,7 +850,7 @@ void DOMWindow::postMessageTimerFired(PassOwnPtr t) if (!isCurrentlyDisplayedInFrame()) return; - RefPtr event = timer->event(); + RefPtrWillBeRawPtr event = timer->event(); // Give the embedder a chance to intercept this postMessage because this // DOMWindow might be a proxy for another in browsers that support @@ -880,13 +864,13 @@ void DOMWindow::postMessageTimerFired(PassOwnPtr t) dispatchMessageEventWithOriginCheck(timer->targetOrigin(), event, timer->stackTrace()); } -void DOMWindow::dispatchMessageEventWithOriginCheck(SecurityOrigin* intendedTargetOrigin, PassRefPtr event, PassRefPtr stackTrace) +void DOMWindow::dispatchMessageEventWithOriginCheck(SecurityOrigin* intendedTargetOrigin, PassRefPtrWillBeRawPtr event, PassRefPtr stackTrace) { if (intendedTargetOrigin) { // Check target origin now since the target document may have changed since the timer was scheduled. if (!intendedTargetOrigin->isSameSchemeHostPort(document()->securityOrigin())) { String message = ExceptionMessages::failedToExecute("postMessage", "DOMWindow", "The target origin provided ('" + intendedTargetOrigin->toString() + "') does not match the recipient window's origin ('" + document()->securityOrigin()->toString() + "')."); - pageConsole()->addMessage(SecurityMessageSource, ErrorMessageLevel, message, stackTrace); + frameConsole()->addMessage(SecurityMessageSource, ErrorMessageLevel, message, stackTrace); return; } } @@ -964,7 +948,7 @@ void DOMWindow::close(ExecutionContext* context) bool allowScriptsToCloseWindows = settings && settings->allowScriptsToCloseWindows(); if (!(page->openedByDOM() || page->backForward().backForwardListCount() <= 1 || allowScriptsToCloseWindows)) { - pageConsole()->addMessage(JSMessageSource, WarningMessageLevel, "Scripts may close only the windows that were opened by it."); + frameConsole()->addMessage(JSMessageSource, WarningMessageLevel, "Scripts may close only the windows that were opened by it."); return; } @@ -1295,7 +1279,7 @@ StyleMedia& DOMWindow::styleMedia() const return *m_media; } -PassRefPtr DOMWindow::getComputedStyle(Element* elt, const String& pseudoElt) const +PassRefPtrWillBeRawPtr DOMWindow::getComputedStyle(Element* elt, const String& pseudoElt) const { if (!elt) return nullptr; @@ -1305,7 +1289,6 @@ PassRefPtr DOMWindow::getComputedStyle(Element* elt, const PassRefPtrWillBeRawPtr DOMWindow::getMatchedCSSRules(Element* element, const String& pseudoElement) const { - UseCounter::count(document(), UseCounter::GetMatchedCSSRules); if (!element) return nullptr; @@ -1571,7 +1554,7 @@ bool DOMWindow::removeEventListener(const AtomicString& eventType, EventListener void DOMWindow::dispatchLoadEvent() { - RefPtr loadEvent(Event::create(EventTypeNames::load)); + RefPtrWillBeRawPtr loadEvent(Event::create(EventTypeNames::load)); if (m_frame && m_frame->loader().documentLoader() && !m_frame->loader().documentLoader()->timing()->loadEventStart()) { // The DocumentLoader (and thus its DocumentLoadTiming) might get destroyed while dispatching // the event, so protect it to prevent writing the end time into freed memory. @@ -1590,20 +1573,24 @@ void DOMWindow::dispatchLoadEvent() if (ownerElement) ownerElement->dispatchEvent(Event::create(EventTypeNames::load)); + TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "MarkLoad", "data", InspectorMarkLoadEvent::data(frame())); + // FIXME(361045): remove InspectorInstrumentation calls once DevTools Timeline migrates to tracing. InspectorInstrumentation::loadEventFired(frame()); } -bool DOMWindow::dispatchEvent(PassRefPtr prpEvent, PassRefPtr prpTarget) +bool DOMWindow::dispatchEvent(PassRefPtrWillBeRawPtr prpEvent, PassRefPtr prpTarget) { ASSERT(!NoEventDispatchAssertion::isEventDispatchForbidden()); RefPtr protect = this; - RefPtr event = prpEvent; + RefPtrWillBeRawPtr event = prpEvent; event->setTarget(prpTarget ? prpTarget : this); event->setCurrentTarget(this); event->setEventPhase(Event::AT_TARGET); + TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "EventDispatch", "type", event->type().ascii()); + // FIXME(361045): remove InspectorInstrumentation calls once DevTools Timeline migrates to tracing. InspectorInstrumentationCookie cookie = InspectorInstrumentation::willDispatchEventOnWindow(frame(), *event, this); bool result = fireEventListeners(event.get()); @@ -1669,7 +1656,7 @@ void DOMWindow::printErrorMessage(const String& message) if (message.isEmpty()) return; - pageConsole()->addMessage(JSMessageSource, ErrorMessageLevel, message); + frameConsole()->addMessage(JSMessageSource, ErrorMessageLevel, message); } // FIXME: Once we're throwing exceptions for cross-origin access violations, we will always sanitize the target @@ -1889,9 +1876,7 @@ void DOMWindow::trace(Visitor* visitor) visitor->trace(m_applicationCache); visitor->trace(m_performance); visitor->trace(m_css); -#if ENABLE(OILPAN) - HeapSupplementable::trace(visitor); -#endif + WillBeHeapSupplementable::trace(visitor); } } // namespace WebCore