OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) | 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) |
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r
ights reserved. | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r
ights reserved. |
7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) | 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) |
8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. | 8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. |
9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) | 9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) |
10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. | 10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 #include "core/events/Event.h" | 108 #include "core/events/Event.h" |
109 #include "core/events/EventFactory.h" | 109 #include "core/events/EventFactory.h" |
110 #include "core/events/EventListener.h" | 110 #include "core/events/EventListener.h" |
111 #include "core/events/HashChangeEvent.h" | 111 #include "core/events/HashChangeEvent.h" |
112 #include "core/events/PageTransitionEvent.h" | 112 #include "core/events/PageTransitionEvent.h" |
113 #include "core/events/ScopedEventQueue.h" | 113 #include "core/events/ScopedEventQueue.h" |
114 #include "core/fetch/ResourceFetcher.h" | 114 #include "core/fetch/ResourceFetcher.h" |
115 #include "core/frame/EventHandlerRegistry.h" | 115 #include "core/frame/EventHandlerRegistry.h" |
116 #include "core/frame/FrameConsole.h" | 116 #include "core/frame/FrameConsole.h" |
117 #include "core/frame/FrameHost.h" | 117 #include "core/frame/FrameHost.h" |
| 118 #include "core/frame/FrameProtector.h" |
118 #include "core/frame/FrameView.h" | 119 #include "core/frame/FrameView.h" |
119 #include "core/frame/History.h" | 120 #include "core/frame/History.h" |
120 #include "core/frame/LocalDOMWindow.h" | 121 #include "core/frame/LocalDOMWindow.h" |
121 #include "core/frame/LocalFrame.h" | 122 #include "core/frame/LocalFrame.h" |
122 #include "core/frame/Settings.h" | 123 #include "core/frame/Settings.h" |
123 #include "core/frame/csp/ContentSecurityPolicy.h" | 124 #include "core/frame/csp/ContentSecurityPolicy.h" |
124 #include "core/html/DocumentNameCollection.h" | 125 #include "core/html/DocumentNameCollection.h" |
125 #include "core/html/HTMLAllCollection.h" | 126 #include "core/html/HTMLAllCollection.h" |
126 #include "core/html/HTMLAnchorElement.h" | 127 #include "core/html/HTMLAnchorElement.h" |
127 #include "core/html/HTMLBaseElement.h" | 128 #include "core/html/HTMLBaseElement.h" |
(...skipping 1673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1801 | 1802 |
1802 // Entering here from inside layout or paint would be catastrophic since rec
alcStyle can | 1803 // Entering here from inside layout or paint would be catastrophic since rec
alcStyle can |
1803 // tear down the render tree or (unfortunately) run script. Kill the whole r
enderer if | 1804 // tear down the render tree or (unfortunately) run script. Kill the whole r
enderer if |
1804 // someone managed to get into here from inside layout or paint. | 1805 // someone managed to get into here from inside layout or paint. |
1805 RELEASE_ASSERT(!view()->isInPerformLayout()); | 1806 RELEASE_ASSERT(!view()->isInPerformLayout()); |
1806 RELEASE_ASSERT(!view()->isPainting()); | 1807 RELEASE_ASSERT(!view()->isPainting()); |
1807 | 1808 |
1808 // Script can run below in WidgetUpdates, so protect the LocalFrame. | 1809 // Script can run below in WidgetUpdates, so protect the LocalFrame. |
1809 // FIXME: Can this still happen? How does script run inside | 1810 // FIXME: Can this still happen? How does script run inside |
1810 // UpdateSuspendScope::performDeferredWidgetTreeOperations() ? | 1811 // UpdateSuspendScope::performDeferredWidgetTreeOperations() ? |
1811 RefPtr<LocalFrame> protect(m_frame); | 1812 FrameProtector protect(m_frame); |
1812 | 1813 |
1813 TRACE_EVENT_BEGIN0("blink", "Document::updateRenderTree"); | 1814 TRACE_EVENT_BEGIN0("blink", "Document::updateRenderTree"); |
1814 TRACE_EVENT_SCOPED_SAMPLING_STATE("blink", "UpdateRenderTree"); | 1815 TRACE_EVENT_SCOPED_SAMPLING_STATE("blink", "UpdateRenderTree"); |
1815 | 1816 |
1816 // FIXME: Remove m_styleRecalcElementCounter, we should just use the accessC
ount() on the resolver. | 1817 // FIXME: Remove m_styleRecalcElementCounter, we should just use the accessC
ount() on the resolver. |
1817 m_styleRecalcElementCounter = 0; | 1818 m_styleRecalcElementCounter = 0; |
1818 TRACE_EVENT_BEGIN1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Recalcul
ateStyles", "frame", frame()); | 1819 TRACE_EVENT_BEGIN1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Recalcul
ateStyles", "frame", frame()); |
1819 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline.stack"), "
CallStack", "stack", InspectorCallStackEvent::currentCallStack()); | 1820 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline.stack"), "
CallStack", "stack", InspectorCallStackEvent::currentCallStack()); |
1820 // FIXME(361045): remove InspectorInstrumentation calls once DevTools Timeli
ne migrates to tracing. | 1821 // FIXME(361045): remove InspectorInstrumentation calls once DevTools Timeli
ne migrates to tracing. |
1821 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willRecalc
ulateStyle(this); | 1822 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willRecalc
ulateStyle(this); |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1932 if (needsRecalc) | 1933 if (needsRecalc) |
1933 updateRenderTreeIfNeeded(); | 1934 updateRenderTreeIfNeeded(); |
1934 } | 1935 } |
1935 | 1936 |
1936 void Document::updateLayout() | 1937 void Document::updateLayout() |
1937 { | 1938 { |
1938 ASSERT(isMainThread()); | 1939 ASSERT(isMainThread()); |
1939 | 1940 |
1940 ScriptForbiddenScope forbidScript; | 1941 ScriptForbiddenScope forbidScript; |
1941 | 1942 |
1942 RefPtr<FrameView> frameView = view(); | 1943 FrameView* frameView = view(); |
| 1944 FrameViewProtector protect(frameView); |
1943 if (frameView && frameView->isInPerformLayout()) { | 1945 if (frameView && frameView->isInPerformLayout()) { |
1944 // View layout should not be re-entrant. | 1946 // View layout should not be re-entrant. |
1945 ASSERT_NOT_REACHED(); | 1947 ASSERT_NOT_REACHED(); |
1946 return; | 1948 return; |
1947 } | 1949 } |
1948 | 1950 |
1949 if (HTMLFrameOwnerElement* owner = ownerElement()) | 1951 if (HTMLFrameOwnerElement* owner = ownerElement()) |
1950 owner->document().updateLayout(); | 1952 owner->document().updateLayout(); |
1951 | 1953 |
1952 updateRenderTreeIfNeeded(); | 1954 updateRenderTreeIfNeeded(); |
(...skipping 2698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4651 m_documentTiming.domContentLoadedEventStart = monotonicallyIncreasingTim
e(); | 4653 m_documentTiming.domContentLoadedEventStart = monotonicallyIncreasingTim
e(); |
4652 dispatchEvent(Event::createBubble(EventTypeNames::DOMContentLoaded)); | 4654 dispatchEvent(Event::createBubble(EventTypeNames::DOMContentLoaded)); |
4653 if (!m_documentTiming.domContentLoadedEventEnd) | 4655 if (!m_documentTiming.domContentLoadedEventEnd) |
4654 m_documentTiming.domContentLoadedEventEnd = monotonicallyIncreasingTime(
); | 4656 m_documentTiming.domContentLoadedEventEnd = monotonicallyIncreasingTime(
); |
4655 | 4657 |
4656 // The loader's finishedParsing() method may invoke script that causes this
object to | 4658 // The loader's finishedParsing() method may invoke script that causes this
object to |
4657 // be dereferenced (when this document is in an iframe and the onload causes
the iframe's src to change). | 4659 // be dereferenced (when this document is in an iframe and the onload causes
the iframe's src to change). |
4658 // Keep it alive until we are done. | 4660 // Keep it alive until we are done. |
4659 RefPtrWillBeRawPtr<Document> protect(this); | 4661 RefPtrWillBeRawPtr<Document> protect(this); |
4660 | 4662 |
4661 if (RefPtr<LocalFrame> f = frame()) { | 4663 if (LocalFrame* frame = this->frame()) { |
| 4664 FrameProtector protect(frame); |
4662 // Don't update the render tree if we haven't requested the main resourc
e yet to avoid | 4665 // Don't update the render tree if we haven't requested the main resourc
e yet to avoid |
4663 // adding extra latency. Note that the first render tree update can be e
xpensive since it | 4666 // adding extra latency. Note that the first render tree update can be e
xpensive since it |
4664 // triggers the parsing of the default stylesheets which are compiled-in
. | 4667 // triggers the parsing of the default stylesheets which are compiled-in
. |
4665 const bool mainResourceWasAlreadyRequested = | 4668 const bool mainResourceWasAlreadyRequested = frame->loader().stateMachin
e()->committedFirstRealDocumentLoad(); |
4666 m_frame->loader().stateMachine()->committedFirstRealDocumentLoad(); | |
4667 | 4669 |
4668 // FrameLoader::finishedParsing() might end up calling Document::implici
tClose() if all | 4670 // FrameLoader::finishedParsing() might end up calling Document::implici
tClose() if all |
4669 // resource loads are complete. HTMLObjectElements can start loading the
ir resources from | 4671 // resource loads are complete. HTMLObjectElements can start loading the
ir resources from |
4670 // post attach callbacks triggered by recalcStyle(). This means if we p
arse out an <object> | 4672 // post attach callbacks triggered by recalcStyle(). This means if we p
arse out an <object> |
4671 // tag and then reach the end of the document without updating styles, w
e might not have yet | 4673 // tag and then reach the end of the document without updating styles, w
e might not have yet |
4672 // started the resource load and might fire the window load event too ea
rly. To avoid this | 4674 // started the resource load and might fire the window load event too ea
rly. To avoid this |
4673 // we force the styles to be up to date before calling FrameLoader::fini
shedParsing(). | 4675 // we force the styles to be up to date before calling FrameLoader::fini
shedParsing(). |
4674 // See https://bugs.webkit.org/show_bug.cgi?id=36864 starting around com
ment 35. | 4676 // See https://bugs.webkit.org/show_bug.cgi?id=36864 starting around com
ment 35. |
4675 if (mainResourceWasAlreadyRequested) | 4677 if (mainResourceWasAlreadyRequested) |
4676 updateRenderTreeIfNeeded(); | 4678 updateRenderTreeIfNeeded(); |
4677 | 4679 |
4678 f->loader().finishedParsing(); | 4680 frame->loader().finishedParsing(); |
4679 | 4681 |
4680 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Ma
rkDOMContent", "data", InspectorMarkLoadEvent::data(f.get())); | 4682 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Ma
rkDOMContent", "data", InspectorMarkLoadEvent::data(frame)); |
4681 // FIXME(361045): remove InspectorInstrumentation calls once DevTools Ti
meline migrates to tracing. | 4683 // FIXME(361045): remove InspectorInstrumentation calls once DevTools Ti
meline migrates to tracing. |
4682 InspectorInstrumentation::domContentLoadedEventFired(f.get()); | 4684 InspectorInstrumentation::domContentLoadedEventFired(frame); |
4683 } | 4685 } |
4684 | 4686 |
4685 // Schedule dropping of the ElementDataCache. We keep it alive for a while a
fter parsing finishes | 4687 // Schedule dropping of the ElementDataCache. We keep it alive for a while a
fter parsing finishes |
4686 // so that dynamically inserted content can also benefit from sharing optimi
zations. | 4688 // so that dynamically inserted content can also benefit from sharing optimi
zations. |
4687 // Note that we don't refresh the timer on cache access since that could lea
d to huge caches being kept | 4689 // Note that we don't refresh the timer on cache access since that could lea
d to huge caches being kept |
4688 // alive indefinitely by something innocuous like JS setting .innerHTML repe
atedly on a timer. | 4690 // alive indefinitely by something innocuous like JS setting .innerHTML repe
atedly on a timer. |
4689 m_elementDataCacheClearTimer.startOneShot(10, FROM_HERE); | 4691 m_elementDataCacheClearTimer.startOneShot(10, FROM_HERE); |
4690 | 4692 |
4691 // Parser should have picked up all preloads by now | 4693 // Parser should have picked up all preloads by now |
4692 m_fetcher->clearPreloads(); | 4694 m_fetcher->clearPreloads(); |
(...skipping 1158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5851 using namespace blink; | 5853 using namespace blink; |
5852 void showLiveDocumentInstances() | 5854 void showLiveDocumentInstances() |
5853 { | 5855 { |
5854 WeakDocumentSet& set = liveDocumentSet(); | 5856 WeakDocumentSet& set = liveDocumentSet(); |
5855 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); | 5857 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); |
5856 for (WeakDocumentSet::const_iterator it = set.begin(); it != set.end(); ++it
) { | 5858 for (WeakDocumentSet::const_iterator it = set.begin(); it != set.end(); ++it
) { |
5857 fprintf(stderr, "- Document %p URL: %s\n", *it, (*it)->url().string().ut
f8().data()); | 5859 fprintf(stderr, "- Document %p URL: %s\n", *it, (*it)->url().string().ut
f8().data()); |
5858 } | 5860 } |
5859 } | 5861 } |
5860 #endif | 5862 #endif |
OLD | NEW |