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

Side by Side Diff: Source/core/dom/Document.cpp

Issue 367863002: Add ScriptForbiddenScopes to style and layout. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Blanket allow inspector scripts. Created 6 years, 5 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
« no previous file with comments | « no previous file | Source/core/frame/FrameView.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1737 matching lines...) Expand 10 before | Expand all | Expand 10 after
1748 if (RenderStyle* style = documentElement()->renderStyle()) { 1748 if (RenderStyle* style = documentElement()->renderStyle()) {
1749 if (style->direction() != rootDirection || style->writingMode() != rootW ritingMode) 1749 if (style->direction() != rootDirection || style->writingMode() != rootW ritingMode)
1750 documentElement()->setNeedsStyleRecalc(SubtreeStyleChange); 1750 documentElement()->setNeedsStyleRecalc(SubtreeStyleChange);
1751 } 1751 }
1752 } 1752 }
1753 1753
1754 void Document::updateRenderTree(StyleRecalcChange change) 1754 void Document::updateRenderTree(StyleRecalcChange change)
1755 { 1755 {
1756 ASSERT(isMainThread()); 1756 ASSERT(isMainThread());
1757 1757
1758 ScriptForbiddenScope forbidScript;
1759
1758 if (change != Force && !needsRenderTreeUpdate()) 1760 if (change != Force && !needsRenderTreeUpdate())
1759 return; 1761 return;
1760 1762
1761 if (inStyleRecalc()) 1763 if (inStyleRecalc())
1762 return; 1764 return;
1763 1765
1764 // Entering here from inside layout or paint would be catastrophic since rec alcStyle can 1766 // Entering here from inside layout or paint would be catastrophic since rec alcStyle can
1765 // tear down the render tree or (unfortunately) run script. Kill the whole r enderer if 1767 // tear down the render tree or (unfortunately) run script. Kill the whole r enderer if
1766 // someone managed to get into here from inside layout or paint. 1768 // someone managed to get into here from inside layout or paint.
1767 RELEASE_ASSERT(!view()->isInPerformLayout()); 1769 RELEASE_ASSERT(!view()->isInPerformLayout());
1768 RELEASE_ASSERT(!view()->isPainting()); 1770 RELEASE_ASSERT(!view()->isPainting());
1769 1771
1770 // Script can run below in WidgetUpdates, so protect the LocalFrame. 1772 // Script can run below in WidgetUpdates, so protect the LocalFrame.
1773 // FIXME: Can this still happen? How does script run inside
1774 // UpdateSuspendScope::performDeferredWidgetTreeOperations() ?
1771 RefPtr<LocalFrame> protect(m_frame); 1775 RefPtr<LocalFrame> protect(m_frame);
1772 1776
1773 TRACE_EVENT0("blink", "Document::updateRenderTree"); 1777 TRACE_EVENT0("blink", "Document::updateRenderTree");
1774 TRACE_EVENT_SCOPED_SAMPLING_STATE("blink", "UpdateRenderTree"); 1778 TRACE_EVENT_SCOPED_SAMPLING_STATE("blink", "UpdateRenderTree");
1775 1779
1776 m_styleRecalcElementCounter = 0; 1780 m_styleRecalcElementCounter = 0;
1777 TRACE_EVENT_BEGIN1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Recalcul ateStyles", "frame", frame()); 1781 TRACE_EVENT_BEGIN1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Recalcul ateStyles", "frame", frame());
1778 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline.stack"), " CallStack", "stack", InspectorCallStackEvent::currentCallStack()); 1782 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline.stack"), " CallStack", "stack", InspectorCallStackEvent::currentCallStack());
1779 // FIXME(361045): remove InspectorInstrumentation calls once DevTools Timeli ne migrates to tracing. 1783 // FIXME(361045): remove InspectorInstrumentation calls once DevTools Timeli ne migrates to tracing.
1780 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willRecalc ulateStyle(this); 1784 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willRecalc ulateStyle(this);
1781 1785
1782 DocumentAnimations::updateOutdatedAnimationPlayersIfNeeded(*this); 1786 DocumentAnimations::updateOutdatedAnimationPlayersIfNeeded(*this);
1783
1784 // FIXME: This executes media query listeners which runs script, instead the script
1785 // should run at raf timing in ScriptedAnimationController just like resize events.
1786 evaluateMediaQueryListIfNeeded(); 1787 evaluateMediaQueryListIfNeeded();
1787
1788 updateUseShadowTreesIfNeeded(); 1788 updateUseShadowTreesIfNeeded();
1789 updateDistributionIfNeeded(); 1789 updateDistributionIfNeeded();
1790 updateStyleInvalidationIfNeeded(); 1790 updateStyleInvalidationIfNeeded();
1791 1791
1792 // FIXME: We should update style on our ancestor chain before proceeding 1792 // FIXME: We should update style on our ancestor chain before proceeding
1793 // however doing so currently causes several tests to crash, as LocalFrame:: setDocument calls Document::attach 1793 // however doing so currently causes several tests to crash, as LocalFrame:: setDocument calls Document::attach
1794 // before setting the LocalDOMWindow on the LocalFrame, or the SecurityOrigi n on the document. The attach, in turn 1794 // before setting the LocalDOMWindow on the LocalFrame, or the SecurityOrigi n on the document. The attach, in turn
1795 // resolves style (here) and then when we resolve style on the parent chain, we may end up 1795 // resolves style (here) and then when we resolve style on the parent chain, we may end up
1796 // re-attaching our containing iframe, which when asked HTMLFrameElementBase ::isURLAllowed 1796 // re-attaching our containing iframe, which when asked HTMLFrameElementBase ::isURLAllowed
1797 // hits a null-dereference due to security code always assuming the document has a SecurityOrigin. 1797 // hits a null-dereference due to security code always assuming the document has a SecurityOrigin.
(...skipping 21 matching lines...) Expand all
1819 1819
1820 TRACE_EVENT_END1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Recalculat eStyles", "elementCount", m_styleRecalcElementCounter); 1820 TRACE_EVENT_END1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Recalculat eStyles", "elementCount", m_styleRecalcElementCounter);
1821 // 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.
1822 InspectorInstrumentation::didRecalculateStyle(cookie, m_styleRecalcElementCo unter); 1822 InspectorInstrumentation::didRecalculateStyle(cookie, m_styleRecalcElementCo unter);
1823 } 1823 }
1824 1824
1825 void Document::updateStyle(StyleRecalcChange change) 1825 void Document::updateStyle(StyleRecalcChange change)
1826 { 1826 {
1827 TRACE_EVENT0("blink", "Document::updateStyle"); 1827 TRACE_EVENT0("blink", "Document::updateStyle");
1828 1828
1829 ScriptForbiddenScope forbidScript;
1830 HTMLFrameOwnerElement::UpdateSuspendScope suspendWidgetHierarchyUpdates; 1829 HTMLFrameOwnerElement::UpdateSuspendScope suspendWidgetHierarchyUpdates;
1831 m_lifecycle.advanceTo(DocumentLifecycle::InStyleRecalc); 1830 m_lifecycle.advanceTo(DocumentLifecycle::InStyleRecalc);
1832 1831
1833 if (styleChangeType() >= SubtreeStyleChange) 1832 if (styleChangeType() >= SubtreeStyleChange)
1834 change = Force; 1833 change = Force;
1835 1834
1836 // FIXME: Cannot access the ensureStyleResolver() before calling styleForDoc ument below because 1835 // FIXME: Cannot access the ensureStyleResolver() before calling styleForDoc ument below because
1837 // apparently the StyleResolver's constructor has side effects. We should fi x it. 1836 // apparently the StyleResolver's constructor has side effects. We should fi x it.
1838 // See printing/setPrinting.html, printing/width-overflow.html though they o nly fail on 1837 // See printing/setPrinting.html, printing/width-overflow.html though they o nly fail on
1839 // mac when accessing the resolver by what appears to be a viewport size dif ference. 1838 // mac when accessing the resolver by what appears to be a viewport size dif ference.
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1893 needsRecalc = ancestor->needsStyleRecalc() || ancestor->needsStyleInvali dation(); 1892 needsRecalc = ancestor->needsStyleRecalc() || ancestor->needsStyleInvali dation();
1894 1893
1895 if (needsRecalc) 1894 if (needsRecalc)
1896 updateRenderTreeIfNeeded(); 1895 updateRenderTreeIfNeeded();
1897 } 1896 }
1898 1897
1899 void Document::updateLayout() 1898 void Document::updateLayout()
1900 { 1899 {
1901 ASSERT(isMainThread()); 1900 ASSERT(isMainThread());
1902 1901
1902 ScriptForbiddenScope forbidScript;
1903
1903 RefPtr<FrameView> frameView = view(); 1904 RefPtr<FrameView> frameView = view();
1904 if (frameView && frameView->isInPerformLayout()) { 1905 if (frameView && frameView->isInPerformLayout()) {
1905 // View layout should not be re-entrant. 1906 // View layout should not be re-entrant.
1906 ASSERT_NOT_REACHED(); 1907 ASSERT_NOT_REACHED();
1907 return; 1908 return;
1908 } 1909 }
1909 1910
1910 if (Element* oe = ownerElement()) 1911 if (Element* oe = ownerElement())
1911 oe->document().updateLayout(); 1912 oe->document().updateLayout();
1912 1913
(...skipping 3904 matching lines...) Expand 10 before | Expand all | Expand 10 after
5817 visitor->trace(m_compositorPendingAnimations); 5818 visitor->trace(m_compositorPendingAnimations);
5818 visitor->trace(m_contextDocument); 5819 visitor->trace(m_contextDocument);
5819 visitor->registerWeakMembers<Document, &Document::clearWeakMembers>(this); 5820 visitor->registerWeakMembers<Document, &Document::clearWeakMembers>(this);
5820 DocumentSupplementable::trace(visitor); 5821 DocumentSupplementable::trace(visitor);
5821 TreeScope::trace(visitor); 5822 TreeScope::trace(visitor);
5822 ContainerNode::trace(visitor); 5823 ContainerNode::trace(visitor);
5823 ExecutionContext::trace(visitor); 5824 ExecutionContext::trace(visitor);
5824 } 5825 }
5825 5826
5826 } // namespace WebCore 5827 } // namespace WebCore
OLDNEW
« no previous file with comments | « no previous file | Source/core/frame/FrameView.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698