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

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

Issue 18601002: Add infrastructure for partial layouts (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: define RenderObject::frameView in the header Created 7 years, 3 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 | « Source/core/dom/Document.h ('k') | Source/core/dom/Element.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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 #include "core/page/MouseEventWithHitTestResults.h" 149 #include "core/page/MouseEventWithHitTestResults.h"
150 #include "core/page/Page.h" 150 #include "core/page/Page.h"
151 #include "core/page/PageConsole.h" 151 #include "core/page/PageConsole.h"
152 #include "core/page/PointerLockController.h" 152 #include "core/page/PointerLockController.h"
153 #include "core/page/Settings.h" 153 #include "core/page/Settings.h"
154 #include "core/page/animation/AnimationController.h" 154 #include "core/page/animation/AnimationController.h"
155 #include "core/page/scrolling/ScrollingCoordinator.h" 155 #include "core/page/scrolling/ScrollingCoordinator.h"
156 #include "core/platform/DateComponents.h" 156 #include "core/platform/DateComponents.h"
157 #include "core/platform/HistogramSupport.h" 157 #include "core/platform/HistogramSupport.h"
158 #include "core/platform/Language.h" 158 #include "core/platform/Language.h"
159 #include "core/platform/ScrollbarTheme.h"
159 #include "core/platform/Timer.h" 160 #include "core/platform/Timer.h"
160 #include "core/platform/chromium/TraceEvent.h" 161 #include "core/platform/chromium/TraceEvent.h"
161 #include "core/platform/network/HTTPParsers.h" 162 #include "core/platform/network/HTTPParsers.h"
162 #include "core/platform/text/PlatformLocale.h" 163 #include "core/platform/text/PlatformLocale.h"
163 #include "core/platform/text/SegmentedString.h" 164 #include "core/platform/text/SegmentedString.h"
164 #include "core/rendering/HitTestRequest.h" 165 #include "core/rendering/HitTestRequest.h"
165 #include "core/rendering/HitTestResult.h" 166 #include "core/rendering/HitTestResult.h"
166 #include "core/rendering/RenderView.h" 167 #include "core/rendering/RenderView.h"
167 #include "core/rendering/RenderWidget.h" 168 #include "core/rendering/RenderWidget.h"
168 #include "core/rendering/TextAutosizer.h" 169 #include "core/rendering/TextAutosizer.h"
(...skipping 1647 matching lines...) Expand 10 before | Expand all | Expand 10 after
1816 1817
1817 if (Element* oe = ownerElement()) 1818 if (Element* oe = ownerElement())
1818 oe->document().updateLayout(); 1819 oe->document().updateLayout();
1819 1820
1820 updateStyleIfNeeded(); 1821 updateStyleIfNeeded();
1821 1822
1822 // Only do a layout if changes have occurred that make it necessary. 1823 // Only do a layout if changes have occurred that make it necessary.
1823 if (frameView && renderer() && (frameView->layoutPending() || renderer()->ne edsLayout())) 1824 if (frameView && renderer() && (frameView->layoutPending() || renderer()->ne edsLayout()))
1824 frameView->layout(); 1825 frameView->layout();
1825 1826
1827 if (frameView)
1828 frameView->partialLayout().reset();
1829
1826 setNeedsFocusedElementCheck(); 1830 setNeedsFocusedElementCheck();
1827 } 1831 }
1828 1832
1829 void Document::setNeedsFocusedElementCheck() 1833 void Document::setNeedsFocusedElementCheck()
1830 { 1834 {
1831 // FIXME: Using a Task doesn't look a good idea. 1835 // FIXME: Using a Task doesn't look a good idea.
1832 if (!m_focusedElement || m_didPostCheckFocusedElementTask) 1836 if (!m_focusedElement || m_didPostCheckFocusedElementTask)
1833 return; 1837 return;
1834 postTask(CheckFocusedElementTask::create()); 1838 postTask(CheckFocusedElementTask::create());
1835 m_didPostCheckFocusedElementTask = true; 1839 m_didPostCheckFocusedElementTask = true;
1836 } 1840 }
1837 1841
1842 void Document::recalcStyleForLayoutIgnoringPendingStylesheets()
1843 {
1844 TemporaryChange<bool> ignorePendingStylesheets(m_ignorePendingStylesheets, m _ignorePendingStylesheets);
1845 if (!haveStylesheetsLoaded()) {
1846 m_ignorePendingStylesheets = true;
1847 // FIXME: We are willing to attempt to suppress painting with outdated s tyle info only once.
1848 // Our assumption is that it would be dangerous to try to stop it a seco nd time, after page
1849 // content has already been loaded and displayed with accurate style inf ormation. (Our
1850 // suppression involves blanking the whole page at the moment. If it wer e more refined, we
1851 // might be able to do something better.) It's worth noting though that this entire method
1852 // is a hack, since what we really want to do is suspend JS instead of d oing a layout with
1853 // inaccurate information.
1854 HTMLElement* bodyElement = body();
1855 if (bodyElement && !bodyElement->renderer() && m_pendingSheetLayout == N oLayoutWithPendingSheets) {
1856 m_pendingSheetLayout = DidLayoutWithPendingSheets;
1857 styleResolverChanged(RecalcStyleImmediately);
1858 } else if (m_hasNodesWithPlaceholderStyle) {
1859 // If new nodes have been added or style recalc has been done with s tyle sheets still
1860 // pending, some nodes may not have had their real style calculated yet. Normally this
1861 // gets cleaned when style sheets arrive but here we need up-to-date style immediately.
1862 recalcStyle(Force);
1863 }
1864 }
1865 }
1866
1838 // FIXME: This is a bad idea and needs to be removed eventually. 1867 // FIXME: This is a bad idea and needs to be removed eventually.
1839 // Other browsers load stylesheets before they continue parsing the web page. 1868 // Other browsers load stylesheets before they continue parsing the web page.
1840 // Since we don't, we can run JavaScript code that needs answers before the 1869 // Since we don't, we can run JavaScript code that needs answers before the
1841 // stylesheets are loaded. Doing a layout ignoring the pending stylesheets 1870 // stylesheets are loaded. Doing a layout ignoring the pending stylesheets
1842 // lets us get reasonable answers. The long term solution to this problem is 1871 // lets us get reasonable answers. The long term solution to this problem is
1843 // to instead suspend JavaScript execution. 1872 // to instead suspend JavaScript execution.
1844 void Document::updateLayoutIgnorePendingStylesheets() 1873 void Document::updateLayoutIgnorePendingStylesheets()
1845 { 1874 {
1846 bool oldIgnore = m_ignorePendingStylesheets; 1875 recalcStyleForLayoutIgnoringPendingStylesheets();
1876 updateLayout();
1877 }
1847 1878
1848 if (!haveStylesheetsLoaded()) { 1879 void Document::partialUpdateLayoutIgnorePendingStylesheets(Node* stopLayoutAtNod e)
1849 m_ignorePendingStylesheets = true; 1880 {
1850 // FIXME: We are willing to attempt to suppress painting with outdated s tyle info only once. Our assumption is that it would be 1881 // Non-overlay scrollbars can cause a second layout that is dependent
1851 // dangerous to try to stop it a second time, after page content has alr eady been loaded and displayed 1882 // on a first layout. This is disabled for partial layout for now.
1852 // with accurate style information. (Our suppression involves blanking the whole page at the 1883 if (!RuntimeEnabledFeatures::partialLayoutEnabled() || !ScrollbarTheme::them e()->usesOverlayScrollbars()) {
1853 // moment. If it were more refined, we might be able to do something be tter.) 1884 updateLayoutIgnorePendingStylesheets();
1854 // It's worth noting though that this entire method is a hack, since wha t we really want to do is 1885 return;
1855 // suspend JS instead of doing a layout with inaccurate information. 1886 }
1856 HTMLElement* bodyElement = body(); 1887
1857 if (bodyElement && !bodyElement->renderer() && m_pendingSheetLayout == N oLayoutWithPendingSheets) { 1888 TemporaryChange<bool> ignorePendingStylesheets(m_ignorePendingStylesheets, m _ignorePendingStylesheets);
1858 m_pendingSheetLayout = DidLayoutWithPendingSheets; 1889 recalcStyleForLayoutIgnoringPendingStylesheets();
1859 styleResolverChanged(RecalcStyleImmediately); 1890
1860 } else if (m_hasNodesWithPlaceholderStyle) 1891 if (stopLayoutAtNode) {
1861 // If new nodes have been added or style recalc has been done with s tyle sheets still pending, some nodes 1892 RenderObject* renderer = stopLayoutAtNode->renderer();
1862 // may not have had their real style calculated yet. Normally this g ets cleaned when style sheets arrive 1893 bool canPartialLayout = renderer;
1863 // but here we need up-to-date style immediately. 1894 while (renderer) {
1864 recalcStyle(Force); 1895 if (!renderer->supportsPartialLayout()) {
1896 canPartialLayout = false;
1897 break;
1898 }
1899 renderer = renderer->parent();
1900 }
1901 if (canPartialLayout && view())
1902 view()->partialLayout().setStopAtRenderer(stopLayoutAtNode->renderer ());
1865 } 1903 }
1866 1904
1867 updateLayout(); 1905 updateLayout();
1868 1906
1869 m_ignorePendingStylesheets = oldIgnore; 1907 if (view())
1908 view()->partialLayout().reset();
1870 } 1909 }
1871 1910
1872 PassRefPtr<RenderStyle> Document::styleForElementIgnoringPendingStylesheets(Elem ent* element) 1911 PassRefPtr<RenderStyle> Document::styleForElementIgnoringPendingStylesheets(Elem ent* element)
1873 { 1912 {
1874 ASSERT_ARG(element, &element->document() == this); 1913 ASSERT_ARG(element, &element->document() == this);
1875 TemporaryChange<bool> ignoreStyleSheets(m_ignorePendingStylesheets, true); 1914 TemporaryChange<bool> ignoreStyleSheets(m_ignorePendingStylesheets, true);
1876 return styleResolver()->styleForElement(element, element->parentNode() ? ele ment->parentNode()->computedStyle() : 0); 1915 return styleResolver()->styleForElement(element, element->parentNode() ? ele ment->parentNode()->computedStyle() : 0);
1877 } 1916 }
1878 1917
1879 PassRefPtr<RenderStyle> Document::styleForPage(int pageIndex) 1918 PassRefPtr<RenderStyle> Document::styleForPage(int pageIndex)
(...skipping 3519 matching lines...) Expand 10 before | Expand all | Expand 10 after
5399 { 5438 {
5400 return DocumentLifecycleNotifier::create(this); 5439 return DocumentLifecycleNotifier::create(this);
5401 } 5440 }
5402 5441
5403 DocumentLifecycleNotifier* Document::lifecycleNotifier() 5442 DocumentLifecycleNotifier* Document::lifecycleNotifier()
5404 { 5443 {
5405 return static_cast<DocumentLifecycleNotifier*>(ScriptExecutionContext::lifec ycleNotifier()); 5444 return static_cast<DocumentLifecycleNotifier*>(ScriptExecutionContext::lifec ycleNotifier());
5406 } 5445 }
5407 5446
5408 } // namespace WebCore 5447 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/dom/Document.h ('k') | Source/core/dom/Element.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698