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

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

Issue 209323003: Merge recalcStyleForLayoutIgnoringPendingStylesheets into updateLayoutIgnorePendingStylesheets (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 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') | no next file » | 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 1869 matching lines...) Expand 10 before | Expand all | Expand 10 after
1880 1880
1881 void Document::clearFocusedElementTimerFired(Timer<Document>*) 1881 void Document::clearFocusedElementTimerFired(Timer<Document>*)
1882 { 1882 {
1883 updateStyleIfNeeded(); 1883 updateStyleIfNeeded();
1884 m_clearFocusedElementTimer.stop(); 1884 m_clearFocusedElementTimer.stop();
1885 1885
1886 if (m_focusedElement && !m_focusedElement->isFocusable()) 1886 if (m_focusedElement && !m_focusedElement->isFocusable())
1887 setFocusedElement(nullptr); 1887 setFocusedElement(nullptr);
1888 } 1888 }
1889 1889
1890 void Document::recalcStyleForLayoutIgnoringPendingStylesheets()
1891 {
1892 ASSERT(m_styleEngine->ignoringPendingStylesheets());
1893
1894 if (!m_styleEngine->hasPendingSheets())
1895 return;
1896
1897 // FIXME: We are willing to attempt to suppress painting with outdated style info only once.
1898 // Our assumption is that it would be dangerous to try to stop it a second t ime, after page
1899 // content has already been loaded and displayed with accurate style informa tion. (Our
1900 // suppression involves blanking the whole page at the moment. If it were mo re refined, we
1901 // might be able to do something better.) It's worth noting though that this entire method
1902 // is a hack, since what we really want to do is suspend JS instead of doing a layout with
1903 // inaccurate information.
1904 HTMLElement* bodyElement = body();
1905 if (bodyElement && !bodyElement->renderer() && m_pendingSheetLayout == NoLay outWithPendingSheets) {
1906 m_pendingSheetLayout = DidLayoutWithPendingSheets;
1907 styleResolverChanged(RecalcStyleImmediately);
1908 } else if (m_hasNodesWithPlaceholderStyle) {
1909 // If new nodes have been added or style recalc has been done with style sheets still
1910 // pending, some nodes may not have had their real style calculated yet. Normally this
1911 // gets cleaned when style sheets arrive but here we need up-to-date sty le immediately.
1912 updateStyle(Force);
1913 }
1914 }
1915
1916 // FIXME: This is a bad idea and needs to be removed eventually. 1890 // FIXME: This is a bad idea and needs to be removed eventually.
1917 // Other browsers load stylesheets before they continue parsing the web page. 1891 // Other browsers load stylesheets before they continue parsing the web page.
1918 // Since we don't, we can run JavaScript code that needs answers before the 1892 // Since we don't, we can run JavaScript code that needs answers before the
1919 // stylesheets are loaded. Doing a layout ignoring the pending stylesheets 1893 // stylesheets are loaded. Doing a layout ignoring the pending stylesheets
1920 // lets us get reasonable answers. The long term solution to this problem is 1894 // lets us get reasonable answers. The long term solution to this problem is
1921 // to instead suspend JavaScript execution. 1895 // to instead suspend JavaScript execution.
1922 void Document::updateLayoutIgnorePendingStylesheets(Document::RunPostLayoutTasks runPostLayoutTasks) 1896 void Document::updateLayoutIgnorePendingStylesheets(Document::RunPostLayoutTasks runPostLayoutTasks)
1923 { 1897 {
1924 StyleEngine::IgnoringPendingStylesheet ignoring(m_styleEngine.get()); 1898 StyleEngine::IgnoringPendingStylesheet ignoring(m_styleEngine.get());
1925 recalcStyleForLayoutIgnoringPendingStylesheets(); 1899
1900 if (m_styleEngine->hasPendingSheets()) {
1901 // FIXME: We are willing to attempt to suppress painting with outdated s tyle info only once.
1902 // Our assumption is that it would be dangerous to try to stop it a seco nd time, after page
1903 // content has already been loaded and displayed with accurate style inf ormation. (Our
1904 // suppression involves blanking the whole page at the moment. If it wer e more refined, we
1905 // might be able to do something better.) It's worth noting though that this entire method
1906 // is a hack, since what we really want to do is suspend JS instead of d oing a layout with
1907 // inaccurate information.
1908 HTMLElement* bodyElement = body();
1909 if (bodyElement && !bodyElement->renderer() && m_pendingSheetLayout == N oLayoutWithPendingSheets) {
1910 m_pendingSheetLayout = DidLayoutWithPendingSheets;
1911 styleResolverChanged(RecalcStyleImmediately);
1912 } else if (m_hasNodesWithPlaceholderStyle) {
1913 // If new nodes have been added or style recalc has been done with s tyle sheets still
1914 // pending, some nodes may not have had their real style calculated yet. Normally this
1915 // gets cleaned when style sheets arrive but here we need up-to-date style immediately.
1916 updateStyle(Force);
1917 }
1918 }
1919
1926 updateLayout(); 1920 updateLayout();
1921
1927 if (runPostLayoutTasks == RunPostLayoutTasksSynchronously && view()) 1922 if (runPostLayoutTasks == RunPostLayoutTasksSynchronously && view())
1928 view()->flushAnyPendingPostLayoutTasks(); 1923 view()->flushAnyPendingPostLayoutTasks();
1929 } 1924 }
1930 1925
1931 PassRefPtr<RenderStyle> Document::styleForElementIgnoringPendingStylesheets(Elem ent* element) 1926 PassRefPtr<RenderStyle> Document::styleForElementIgnoringPendingStylesheets(Elem ent* element)
1932 { 1927 {
1933 ASSERT_ARG(element, element->document() == this); 1928 ASSERT_ARG(element, element->document() == this);
1934 StyleEngine::IgnoringPendingStylesheet ignoring(m_styleEngine.get()); 1929 StyleEngine::IgnoringPendingStylesheet ignoring(m_styleEngine.get());
1935 return ensureStyleResolver().styleForElement(element, element->parentNode() ? element->parentNode()->computedStyle() : 0); 1930 return ensureStyleResolver().styleForElement(element, element->parentNode() ? element->parentNode()->computedStyle() : 0);
1936 } 1931 }
(...skipping 3532 matching lines...) Expand 10 before | Expand all | Expand 10 after
5469 } 5464 }
5470 5465
5471 void Document::invalidateNodeListCaches(const QualifiedName* attrName) 5466 void Document::invalidateNodeListCaches(const QualifiedName* attrName)
5472 { 5467 {
5473 HashSet<LiveNodeListBase*>::iterator end = m_listsInvalidatedAtDocument.end( ); 5468 HashSet<LiveNodeListBase*>::iterator end = m_listsInvalidatedAtDocument.end( );
5474 for (HashSet<LiveNodeListBase*>::iterator it = m_listsInvalidatedAtDocument. begin(); it != end; ++it) 5469 for (HashSet<LiveNodeListBase*>::iterator it = m_listsInvalidatedAtDocument. begin(); it != end; ++it)
5475 (*it)->invalidateCache(attrName); 5470 (*it)->invalidateCache(attrName);
5476 } 5471 }
5477 5472
5478 } // namespace WebCore 5473 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/dom/Document.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698