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 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 , m_writeRecursionIsTooDeep(false) | 445 , m_writeRecursionIsTooDeep(false) |
446 , m_writeRecursionDepth(0) | 446 , m_writeRecursionDepth(0) |
447 , m_taskRunner(MainThreadTaskRunner::create(this)) | 447 , m_taskRunner(MainThreadTaskRunner::create(this)) |
448 , m_registrationContext(initializer.registrationContext(this)) | 448 , m_registrationContext(initializer.registrationContext(this)) |
449 , m_elementDataCacheClearTimer(this, &Document::elementDataCacheClearTimerFi
red) | 449 , m_elementDataCacheClearTimer(this, &Document::elementDataCacheClearTimerFi
red) |
450 , m_timeline(AnimationTimeline::create(this)) | 450 , m_timeline(AnimationTimeline::create(this)) |
451 , m_templateDocumentHost(nullptr) | 451 , m_templateDocumentHost(nullptr) |
452 , m_didAssociateFormControlsTimer(this, &Document::didAssociateFormControlsT
imerFired) | 452 , m_didAssociateFormControlsTimer(this, &Document::didAssociateFormControlsT
imerFired) |
453 , m_timers(timerTaskRunner()->adoptClone()) | 453 , m_timers(timerTaskRunner()->adoptClone()) |
454 , m_hasViewportUnits(false) | 454 , m_hasViewportUnits(false) |
455 , m_styleRecalcElementCounter(0) | |
456 , m_parserSyncPolicy(AllowAsynchronousParsing) | 455 , m_parserSyncPolicy(AllowAsynchronousParsing) |
457 , m_nodeCount(0) | 456 , m_nodeCount(0) |
458 { | 457 { |
459 if (m_frame) { | 458 if (m_frame) { |
460 ASSERT(m_frame->page()); | 459 ASSERT(m_frame->page()); |
461 provideContextFeaturesToDocumentFrom(*this, *m_frame->page()); | 460 provideContextFeaturesToDocumentFrom(*this, *m_frame->page()); |
462 | 461 |
463 m_fetcher = m_frame->loader().documentLoader()->fetcher(); | 462 m_fetcher = m_frame->loader().documentLoader()->fetcher(); |
464 FrameFetchContext::provideDocumentToContext(m_fetcher->context(), this); | 463 FrameFetchContext::provideDocumentToContext(m_fetcher->context(), this); |
465 } else if (m_importsController) { | 464 } else if (m_importsController) { |
(...skipping 1302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1768 // Script can run below in WidgetUpdates, so protect the LocalFrame. | 1767 // Script can run below in WidgetUpdates, so protect the LocalFrame. |
1769 // TODO(esprehn): This should actually crash because of the ScriptForbiddenS
cope, | 1768 // TODO(esprehn): This should actually crash because of the ScriptForbiddenS
cope, |
1770 // for an example stack see crbug.com/536194, it seems like we should just u
se | 1769 // for an example stack see crbug.com/536194, it seems like we should just u
se |
1771 // a PluginScriptForbiddenScope to block all script from running inside here | 1770 // a PluginScriptForbiddenScope to block all script from running inside here |
1772 // to avoid the crash. | 1771 // to avoid the crash. |
1773 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get()); | 1772 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get()); |
1774 | 1773 |
1775 TRACE_EVENT_BEGIN1("blink,devtools.timeline", "UpdateLayoutTree", "beginData
", InspectorRecalculateStylesEvent::data(frame())); | 1774 TRACE_EVENT_BEGIN1("blink,devtools.timeline", "UpdateLayoutTree", "beginData
", InspectorRecalculateStylesEvent::data(frame())); |
1776 TRACE_EVENT_SCOPED_SAMPLING_STATE("blink", "UpdateLayoutTree"); | 1775 TRACE_EVENT_SCOPED_SAMPLING_STATE("blink", "UpdateLayoutTree"); |
1777 | 1776 |
1778 // FIXME: Remove m_styleRecalcElementCounter, we should just use the accessC
ount() on the resolver. | 1777 unsigned startElementCount = styleEngine().styleForElementCount(); |
1779 m_styleRecalcElementCounter = 0; | 1778 |
1780 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willRecalc
ulateStyle(this); | 1779 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willRecalc
ulateStyle(this); |
1781 | 1780 |
1782 DocumentAnimations::updateAnimationTimingIfNeeded(*this); | 1781 DocumentAnimations::updateAnimationTimingIfNeeded(*this); |
1783 evaluateMediaQueryListIfNeeded(); | 1782 evaluateMediaQueryListIfNeeded(); |
1784 updateUseShadowTreesIfNeeded(); | 1783 updateUseShadowTreesIfNeeded(); |
1785 updateDistribution(); | 1784 updateDistribution(); |
1786 updateStyleInvalidationIfNeeded(); | 1785 updateStyleInvalidationIfNeeded(); |
1787 | 1786 |
1788 // FIXME: We should update style on our ancestor chain before proceeding | 1787 // FIXME: We should update style on our ancestor chain before proceeding |
1789 // however doing so currently causes several tests to crash, as LocalFrame::
setDocument calls Document::attach | 1788 // however doing so currently causes several tests to crash, as LocalFrame::
setDocument calls Document::attach |
(...skipping 11 matching lines...) Expand all Loading... |
1801 // to check if any other elements ended up under the mouse pointer due to re
-layout. | 1800 // to check if any other elements ended up under the mouse pointer due to re
-layout. |
1802 if (hoverNode() && !hoverNode()->layoutObject() && frame()) | 1801 if (hoverNode() && !hoverNode()->layoutObject() && frame()) |
1803 frame()->eventHandler().dispatchFakeMouseMoveEventSoon(); | 1802 frame()->eventHandler().dispatchFakeMouseMoveEventSoon(); |
1804 | 1803 |
1805 if (m_focusedElement && !m_focusedElement->isFocusable()) | 1804 if (m_focusedElement && !m_focusedElement->isFocusable()) |
1806 clearFocusedElementSoon(); | 1805 clearFocusedElementSoon(); |
1807 layoutView()->clearHitTestCache(); | 1806 layoutView()->clearHitTestCache(); |
1808 | 1807 |
1809 ASSERT(!DocumentAnimations::needsAnimationTimingUpdate(*this)); | 1808 ASSERT(!DocumentAnimations::needsAnimationTimingUpdate(*this)); |
1810 | 1809 |
1811 TRACE_EVENT_END1("blink,devtools.timeline", "UpdateLayoutTree", "elementCoun
t", m_styleRecalcElementCounter); | 1810 unsigned elementCount = styleEngine().styleForElementCount() - startElementC
ount; |
1812 InspectorInstrumentation::didRecalculateStyle(cookie, m_styleRecalcElementCo
unter); | 1811 |
| 1812 TRACE_EVENT_END1("blink,devtools.timeline", "UpdateLayoutTree", "elementCoun
t", elementCount); |
| 1813 InspectorInstrumentation::didRecalculateStyle(cookie, elementCount); |
1813 | 1814 |
1814 #if ENABLE(ASSERT) | 1815 #if ENABLE(ASSERT) |
1815 assertLayoutTreeUpdated(*this); | 1816 assertLayoutTreeUpdated(*this); |
1816 #endif | 1817 #endif |
1817 } | 1818 } |
1818 | 1819 |
1819 void Document::updateStyle(StyleRecalcChange change) | 1820 void Document::updateStyle(StyleRecalcChange change) |
1820 { | 1821 { |
1821 if (view()->shouldThrottleRendering()) | 1822 if (view()->shouldThrottleRendering()) |
1822 return; | 1823 return; |
1823 | 1824 |
1824 TRACE_EVENT_BEGIN0("blink,blink_style", "Document::updateStyle"); | 1825 TRACE_EVENT_BEGIN0("blink,blink_style", "Document::updateStyle"); |
1825 unsigned initialResolverAccessCount = styleEngine().resolverAccessCount(); | 1826 unsigned initialElementCount = styleEngine().styleForElementCount(); |
1826 | 1827 |
1827 HTMLFrameOwnerElement::UpdateSuspendScope suspendWidgetHierarchyUpdates; | 1828 HTMLFrameOwnerElement::UpdateSuspendScope suspendWidgetHierarchyUpdates; |
1828 m_lifecycle.advanceTo(DocumentLifecycle::InStyleRecalc); | 1829 m_lifecycle.advanceTo(DocumentLifecycle::InStyleRecalc); |
1829 | 1830 |
1830 NthIndexCache nthIndexCache(*this); | 1831 NthIndexCache nthIndexCache(*this); |
1831 | 1832 |
1832 if (styleChangeType() >= SubtreeStyleChange) | 1833 if (styleChangeType() >= SubtreeStyleChange) |
1833 change = Force; | 1834 change = Force; |
1834 | 1835 |
1835 // FIXME: Cannot access the ensureStyleResolver() before calling styleForDoc
ument below because | 1836 // FIXME: Cannot access the ensureStyleResolver() before calling styleForDoc
ument below because |
1836 // apparently the StyleResolver's constructor has side effects. We should fi
x it. | 1837 // apparently the StyleResolver's constructor has side effects. We should fi
x it. |
1837 // See printing/setPrinting.html, printing/width-overflow.html though they o
nly fail on | 1838 // See printing/setPrinting.html, printing/width-overflow.html though they o
nly fail on |
1838 // mac when accessing the resolver by what appears to be a viewport size dif
ference. | 1839 // mac when accessing the resolver by what appears to be a viewport size dif
ference. |
1839 | 1840 |
1840 if (change == Force) { | 1841 if (change == Force) { |
1841 m_hasNodesWithPlaceholderStyle = false; | 1842 m_hasNodesWithPlaceholderStyle = false; |
1842 RefPtr<ComputedStyle> documentStyle = StyleResolver::styleForDocument(*t
his); | 1843 RefPtr<ComputedStyle> documentStyle = StyleResolver::styleForDocument(*t
his); |
1843 StyleRecalcChange localChange = ComputedStyle::stylePropagationDiff(docu
mentStyle.get(), layoutView()->style()); | 1844 StyleRecalcChange localChange = ComputedStyle::stylePropagationDiff(docu
mentStyle.get(), layoutView()->style()); |
1844 if (localChange != NoChange) | 1845 if (localChange != NoChange) |
1845 layoutView()->setStyle(documentStyle.release()); | 1846 layoutView()->setStyle(documentStyle.release()); |
1846 } | 1847 } |
1847 | 1848 |
1848 clearNeedsStyleRecalc(); | 1849 clearNeedsStyleRecalc(); |
1849 | 1850 |
1850 StyleResolver& resolver = ensureStyleResolver(); | 1851 StyleResolver& resolver = ensureStyleResolver(); |
1851 | 1852 |
1852 bool shouldRecordStats; | 1853 bool shouldRecordStats; |
1853 TRACE_EVENT_CATEGORY_GROUP_ENABLED("blink,blink_style", &shouldRecordStats); | 1854 TRACE_EVENT_CATEGORY_GROUP_ENABLED("blink,blink_style", &shouldRecordStats); |
1854 resolver.setStatsEnabled(shouldRecordStats); | 1855 styleEngine().setStatsEnabled(shouldRecordStats); |
1855 | 1856 |
1856 if (Element* documentElement = this->documentElement()) { | 1857 if (Element* documentElement = this->documentElement()) { |
1857 inheritHtmlAndBodyElementStyles(change); | 1858 inheritHtmlAndBodyElementStyles(change); |
1858 dirtyElementsForLayerUpdate(); | 1859 dirtyElementsForLayerUpdate(); |
1859 if (documentElement->shouldCallRecalcStyle(change)) | 1860 if (documentElement->shouldCallRecalcStyle(change)) |
1860 documentElement->recalcStyle(change); | 1861 documentElement->recalcStyle(change); |
1861 while (dirtyElementsForLayerUpdate()) | 1862 while (dirtyElementsForLayerUpdate()) |
1862 documentElement->recalcStyle(NoChange); | 1863 documentElement->recalcStyle(NoChange); |
1863 } | 1864 } |
1864 | 1865 |
1865 view()->recalcOverflowAfterStyleChange(); | 1866 view()->recalcOverflowAfterStyleChange(); |
1866 view()->setFrameTimingRequestsDirty(true); | 1867 view()->setFrameTimingRequestsDirty(true); |
1867 | 1868 |
1868 clearChildNeedsStyleRecalc(); | 1869 clearChildNeedsStyleRecalc(); |
1869 | 1870 |
1870 // Pseudo element removal and similar may only work with these flags still s
et. Reset them after the style recalc. | 1871 // Pseudo element removal and similar may only work with these flags still s
et. Reset them after the style recalc. |
1871 styleEngine().resetCSSFeatureFlags(resolver.ensureUpdatedRuleFeatureSet()); | 1872 styleEngine().resetCSSFeatureFlags(resolver.ensureUpdatedRuleFeatureSet()); |
1872 resolver.clearStyleSharingList(); | 1873 resolver.clearStyleSharingList(); |
1873 | 1874 |
1874 m_wasPrinting = m_printing; | 1875 m_wasPrinting = m_printing; |
1875 | 1876 |
1876 ASSERT(!needsStyleRecalc()); | 1877 ASSERT(!needsStyleRecalc()); |
1877 ASSERT(!childNeedsStyleRecalc()); | 1878 ASSERT(!childNeedsStyleRecalc()); |
1878 ASSERT(inStyleRecalc()); | 1879 ASSERT(inStyleRecalc()); |
1879 ASSERT(styleResolver() == &resolver); | 1880 ASSERT(styleResolver() == &resolver); |
1880 m_lifecycle.advanceTo(DocumentLifecycle::StyleClean); | 1881 m_lifecycle.advanceTo(DocumentLifecycle::StyleClean); |
1881 if (shouldRecordStats) { | 1882 if (shouldRecordStats) { |
1882 TRACE_EVENT_END2("blink,blink_style", "Document::updateStyle", | 1883 TRACE_EVENT_END2("blink,blink_style", "Document::updateStyle", |
1883 "resolverAccessCount", styleEngine().resolverAccessCount() - initial
ResolverAccessCount, | 1884 "resolverAccessCount", styleEngine().styleForElementCount() - initia
lElementCount, |
1884 "counters", resolver.stats()->toTracedValue()); | 1885 "counters", styleEngine().stats()->toTracedValue()); |
1885 } else { | 1886 } else { |
1886 TRACE_EVENT_END1("blink,blink_style", "Document::updateStyle", | 1887 TRACE_EVENT_END1("blink,blink_style", "Document::updateStyle", |
1887 "resolverAccessCount", styleEngine().resolverAccessCount() - initial
ResolverAccessCount); | 1888 "resolverAccessCount", styleEngine().styleForElementCount() - initia
lElementCount); |
1888 } | 1889 } |
1889 } | 1890 } |
1890 | 1891 |
1891 void Document::notifyLayoutTreeOfSubtreeChanges() | 1892 void Document::notifyLayoutTreeOfSubtreeChanges() |
1892 { | 1893 { |
1893 if (!layoutView()->wasNotifiedOfSubtreeChange()) | 1894 if (!layoutView()->wasNotifiedOfSubtreeChange()) |
1894 return; | 1895 return; |
1895 | 1896 |
1896 m_lifecycle.advanceTo(DocumentLifecycle::InLayoutSubtreeChange); | 1897 m_lifecycle.advanceTo(DocumentLifecycle::InLayoutSubtreeChange); |
1897 | 1898 |
(...skipping 4026 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5924 #ifndef NDEBUG | 5925 #ifndef NDEBUG |
5925 using namespace blink; | 5926 using namespace blink; |
5926 void showLiveDocumentInstances() | 5927 void showLiveDocumentInstances() |
5927 { | 5928 { |
5928 Document::WeakDocumentSet& set = Document::liveDocumentSet(); | 5929 Document::WeakDocumentSet& set = Document::liveDocumentSet(); |
5929 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); | 5930 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); |
5930 for (Document* document : set) | 5931 for (Document* document : set) |
5931 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str
ing().utf8().data()); | 5932 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str
ing().utf8().data()); |
5932 } | 5933 } |
5933 #endif | 5934 #endif |
OLD | NEW |