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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
145 #include "core/page/MouseEventWithHitTestResults.h" | 145 #include "core/page/MouseEventWithHitTestResults.h" |
146 #include "core/page/Page.h" | 146 #include "core/page/Page.h" |
147 #include "core/page/PageConsole.h" | 147 #include "core/page/PageConsole.h" |
148 #include "core/page/PointerLockController.h" | 148 #include "core/page/PointerLockController.h" |
149 #include "core/page/Settings.h" | 149 #include "core/page/Settings.h" |
150 #include "core/page/animation/AnimationController.h" | 150 #include "core/page/animation/AnimationController.h" |
151 #include "core/page/scrolling/ScrollingCoordinator.h" | 151 #include "core/page/scrolling/ScrollingCoordinator.h" |
152 #include "core/platform/DateComponents.h" | 152 #include "core/platform/DateComponents.h" |
153 #include "core/platform/HistogramSupport.h" | 153 #include "core/platform/HistogramSupport.h" |
154 #include "core/platform/Language.h" | 154 #include "core/platform/Language.h" |
155 #include "core/platform/ScrollbarTheme.h" | |
155 #include "core/platform/Timer.h" | 156 #include "core/platform/Timer.h" |
156 #include "core/platform/chromium/TraceEvent.h" | 157 #include "core/platform/chromium/TraceEvent.h" |
157 #include "core/platform/network/HTTPParsers.h" | 158 #include "core/platform/network/HTTPParsers.h" |
158 #include "core/platform/text/PlatformLocale.h" | 159 #include "core/platform/text/PlatformLocale.h" |
159 #include "core/platform/text/SegmentedString.h" | 160 #include "core/platform/text/SegmentedString.h" |
160 #include "core/rendering/HitTestRequest.h" | 161 #include "core/rendering/HitTestRequest.h" |
161 #include "core/rendering/HitTestResult.h" | 162 #include "core/rendering/HitTestResult.h" |
162 #include "core/rendering/RenderView.h" | 163 #include "core/rendering/RenderView.h" |
163 #include "core/rendering/RenderWidget.h" | 164 #include "core/rendering/RenderWidget.h" |
164 #include "core/rendering/TextAutosizer.h" | 165 #include "core/rendering/TextAutosizer.h" |
(...skipping 1575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1740 oe->document()->updateLayout(); | 1741 oe->document()->updateLayout(); |
1741 | 1742 |
1742 updateStyleIfNeeded(); | 1743 updateStyleIfNeeded(); |
1743 | 1744 |
1744 StackStats::LayoutCheckPoint layoutCheckPoint; | 1745 StackStats::LayoutCheckPoint layoutCheckPoint; |
1745 | 1746 |
1746 // Only do a layout if changes have occurred that make it necessary. | 1747 // Only do a layout if changes have occurred that make it necessary. |
1747 if (frameView && renderer() && (frameView->layoutPending() || renderer()->ne edsLayout())) | 1748 if (frameView && renderer() && (frameView->layoutPending() || renderer()->ne edsLayout())) |
1748 frameView->layout(); | 1749 frameView->layout(); |
1749 | 1750 |
1751 if (frameView) | |
1752 frameView->resetPartialLayoutState(); | |
1753 | |
1750 setNeedsFocusedElementCheck(); | 1754 setNeedsFocusedElementCheck(); |
1751 } | 1755 } |
1752 | 1756 |
1753 void Document::setNeedsFocusedElementCheck() | 1757 void Document::setNeedsFocusedElementCheck() |
1754 { | 1758 { |
1755 // FIXME: Using a Task doesn't look a good idea. | 1759 // FIXME: Using a Task doesn't look a good idea. |
1756 if (!m_focusedElement || m_didPostCheckFocusedElementTask) | 1760 if (!m_focusedElement || m_didPostCheckFocusedElementTask) |
1757 return; | 1761 return; |
1758 postTask(CheckFocusedElementTask::create()); | 1762 postTask(CheckFocusedElementTask::create()); |
1759 m_didPostCheckFocusedElementTask = true; | 1763 m_didPostCheckFocusedElementTask = true; |
1760 } | 1764 } |
1761 | 1765 |
1766 void Document::recalcStyleForLayoutIgnoringPendingStylesheets() | |
1767 { | |
1768 if (!haveStylesheetsLoaded()) { | |
1769 m_ignorePendingStylesheets = true; | |
1770 // FIXME: We are willing to attempt to suppress painting with outdated s tyle info only once. | |
1771 // Our assumption is that it would be dangerous to try to stop it a seco nd time, after page | |
1772 // content has already been loaded and displayed with accurate style inf ormation. (Our | |
1773 // suppression involves blanking the whole page at the moment. If it wer e more refined, we | |
1774 // might be able to do something better.) It's worth noting though that this entire method | |
1775 // is a hack, since what we really want to do is suspend JS instead of d oing a layout with | |
1776 // inaccurate information. | |
1777 HTMLElement* bodyElement = body(); | |
1778 if (bodyElement && !bodyElement->renderer() && m_pendingSheetLayout == N oLayoutWithPendingSheets) { | |
1779 m_pendingSheetLayout = DidLayoutWithPendingSheets; | |
1780 styleResolverChanged(RecalcStyleImmediately); | |
1781 } else if (m_hasNodesWithPlaceholderStyle) | |
1782 // If new nodes have been added or style recalc has been done with s tyle sheets still | |
1783 // pending, some nodes may not have had their real style calculated yet. Normally this | |
1784 // gets cleaned when style sheets arrive but here we need up-to-date style immediately. | |
1785 recalcStyle(Force); | |
1786 } | |
1787 } | |
1788 | |
1762 // FIXME: This is a bad idea and needs to be removed eventually. | 1789 // FIXME: This is a bad idea and needs to be removed eventually. |
1763 // Other browsers load stylesheets before they continue parsing the web page. | 1790 // Other browsers load stylesheets before they continue parsing the web page. |
1764 // Since we don't, we can run JavaScript code that needs answers before the | 1791 // Since we don't, we can run JavaScript code that needs answers before the |
1765 // stylesheets are loaded. Doing a layout ignoring the pending stylesheets | 1792 // stylesheets are loaded. Doing a layout ignoring the pending stylesheets |
1766 // lets us get reasonable answers. The long term solution to this problem is | 1793 // lets us get reasonable answers. The long term solution to this problem is |
1767 // to instead suspend JavaScript execution. | 1794 // to instead suspend JavaScript execution. |
1768 void Document::updateLayoutIgnorePendingStylesheets() | 1795 void Document::updateLayoutIgnorePendingStylesheets() |
1769 { | 1796 { |
1770 bool oldIgnore = m_ignorePendingStylesheets; | 1797 bool oldIgnore = m_ignorePendingStylesheets; |
esprehn
2013/08/23 20:47:27
You should switch this to a TemporaryChange<bool>
pdr.
2013/08/26 05:50:40
Done
| |
1798 recalcStyleForLayoutIgnoringPendingStylesheets(); | |
1799 updateLayout(); | |
1800 m_ignorePendingStylesheets = oldIgnore; | |
1801 } | |
1771 | 1802 |
1772 if (!haveStylesheetsLoaded()) { | 1803 void Document::partialUpdateLayoutIgnorePendingStylesheets(Node* stopLayoutAtNod e) |
1773 m_ignorePendingStylesheets = true; | 1804 { |
1774 // FIXME: We are willing to attempt to suppress painting with outdated s tyle info only once. Our assumption is that it would be | 1805 bool oldIgnore = m_ignorePendingStylesheets; |
esprehn
2013/08/23 20:47:27
Ditto
pdr.
2013/08/26 05:50:40
Done.
| |
1775 // dangerous to try to stop it a second time, after page content has alr eady been loaded and displayed | 1806 recalcStyleForLayoutIgnoringPendingStylesheets(); |
1776 // with accurate style information. (Our suppression involves blanking the whole page at the | 1807 |
1777 // moment. If it were more refined, we might be able to do something be tter.) | 1808 if (stopLayoutAtNode) { |
1778 // It's worth noting though that this entire method is a hack, since wha t we really want to do is | 1809 // Non-overlay scrollbars can cause layout during layout. |
1779 // suspend JS instead of doing a layout with inaccurate information. | 1810 // FIXME: REMOVE THIS 'true' BEFORE LANDING. This allows linux to run pa rtiallayout |
1780 HTMLElement* bodyElement = body(); | 1811 // performance tests, even though it's only valid for OSX and And roid. |
1781 if (bodyElement && !bodyElement->renderer() && m_pendingSheetLayout == N oLayoutWithPendingSheets) { | 1812 if (true || ScrollbarTheme::theme()->usesOverlayScrollbars()) { |
1782 m_pendingSheetLayout = DidLayoutWithPendingSheets; | 1813 // FIXME: Text autosizing will not work with partial layout. |
1783 styleResolverChanged(RecalcStyleImmediately); | 1814 bool canPartialLayout = true; |
1784 } else if (m_hasNodesWithPlaceholderStyle) | 1815 RenderObject* renderer = stopLayoutAtNode->renderer(); |
1785 // If new nodes have been added or style recalc has been done with s tyle sheets still pending, some nodes | 1816 while (renderer) { |
1786 // may not have had their real style calculated yet. Normally this g ets cleaned when style sheets arrive | 1817 if (!renderer->supportsPartialLayout()) { |
1787 // but here we need up-to-date style immediately. | 1818 canPartialLayout = false; |
1788 recalcStyle(Force); | 1819 break; |
1820 } | |
1821 renderer = renderer->parent(); | |
1822 } | |
1823 if (canPartialLayout) | |
1824 view()->setStopLayoutAtRenderer(stopLayoutAtNode->renderer()); | |
1825 } | |
1789 } | 1826 } |
1790 | 1827 |
1791 updateLayout(); | 1828 updateLayout(); |
1792 | |
1793 m_ignorePendingStylesheets = oldIgnore; | 1829 m_ignorePendingStylesheets = oldIgnore; |
1794 } | 1830 } |
1795 | 1831 |
1796 PassRefPtr<RenderStyle> Document::styleForElementIgnoringPendingStylesheets(Elem ent* element) | 1832 PassRefPtr<RenderStyle> Document::styleForElementIgnoringPendingStylesheets(Elem ent* element) |
1797 { | 1833 { |
1798 ASSERT_ARG(element, element->document() == this); | 1834 ASSERT_ARG(element, element->document() == this); |
1799 TemporaryChange<bool> ignoreStyleSheets(m_ignorePendingStylesheets, true); | 1835 TemporaryChange<bool> ignoreStyleSheets(m_ignorePendingStylesheets, true); |
1800 return styleResolver()->styleForElement(element, element->parentNode() ? ele ment->parentNode()->computedStyle() : 0); | 1836 return styleResolver()->styleForElement(element, element->parentNode() ? ele ment->parentNode()->computedStyle() : 0); |
1801 } | 1837 } |
1802 | 1838 |
(...skipping 3401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5204 { | 5240 { |
5205 return DocumentLifecycleNotifier::create(this); | 5241 return DocumentLifecycleNotifier::create(this); |
5206 } | 5242 } |
5207 | 5243 |
5208 DocumentLifecycleNotifier* Document::lifecycleNotifier() | 5244 DocumentLifecycleNotifier* Document::lifecycleNotifier() |
5209 { | 5245 { |
5210 return static_cast<DocumentLifecycleNotifier*>(ScriptExecutionContext::lifec ycleNotifier()); | 5246 return static_cast<DocumentLifecycleNotifier*>(ScriptExecutionContext::lifec ycleNotifier()); |
5211 } | 5247 } |
5212 | 5248 |
5213 } // namespace WebCore | 5249 } // namespace WebCore |
OLD | NEW |