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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 #include "core/page/MouseEventWithHitTestResults.h" | 146 #include "core/page/MouseEventWithHitTestResults.h" |
147 #include "core/page/Page.h" | 147 #include "core/page/Page.h" |
148 #include "core/page/PageConsole.h" | 148 #include "core/page/PageConsole.h" |
149 #include "core/page/PointerLockController.h" | 149 #include "core/page/PointerLockController.h" |
150 #include "core/page/Settings.h" | 150 #include "core/page/Settings.h" |
151 #include "core/page/animation/AnimationController.h" | 151 #include "core/page/animation/AnimationController.h" |
152 #include "core/page/scrolling/ScrollingCoordinator.h" | 152 #include "core/page/scrolling/ScrollingCoordinator.h" |
153 #include "core/platform/DateComponents.h" | 153 #include "core/platform/DateComponents.h" |
154 #include "core/platform/HistogramSupport.h" | 154 #include "core/platform/HistogramSupport.h" |
155 #include "core/platform/Language.h" | 155 #include "core/platform/Language.h" |
| 156 #include "core/platform/ScrollbarTheme.h" |
156 #include "core/platform/Timer.h" | 157 #include "core/platform/Timer.h" |
157 #include "core/platform/chromium/TraceEvent.h" | 158 #include "core/platform/chromium/TraceEvent.h" |
158 #include "core/platform/network/HTTPParsers.h" | 159 #include "core/platform/network/HTTPParsers.h" |
159 #include "core/platform/text/PlatformLocale.h" | 160 #include "core/platform/text/PlatformLocale.h" |
160 #include "core/platform/text/SegmentedString.h" | 161 #include "core/platform/text/SegmentedString.h" |
161 #include "core/rendering/HitTestRequest.h" | 162 #include "core/rendering/HitTestRequest.h" |
162 #include "core/rendering/HitTestResult.h" | 163 #include "core/rendering/HitTestResult.h" |
163 #include "core/rendering/RenderView.h" | 164 #include "core/rendering/RenderView.h" |
164 #include "core/rendering/RenderWidget.h" | 165 #include "core/rendering/RenderWidget.h" |
165 #include "core/rendering/TextAutosizer.h" | 166 #include "core/rendering/TextAutosizer.h" |
(...skipping 1576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1742 | 1743 |
1743 if (Element* oe = ownerElement()) | 1744 if (Element* oe = ownerElement()) |
1744 oe->document().updateLayout(); | 1745 oe->document().updateLayout(); |
1745 | 1746 |
1746 updateStyleIfNeeded(); | 1747 updateStyleIfNeeded(); |
1747 | 1748 |
1748 // Only do a layout if changes have occurred that make it necessary. | 1749 // Only do a layout if changes have occurred that make it necessary. |
1749 if (frameView && renderer() && (frameView->layoutPending() || renderer()->ne
edsLayout())) | 1750 if (frameView && renderer() && (frameView->layoutPending() || renderer()->ne
edsLayout())) |
1750 frameView->layout(); | 1751 frameView->layout(); |
1751 | 1752 |
| 1753 if (frameView) |
| 1754 frameView->partialLayout().reset(); |
| 1755 |
1752 setNeedsFocusedElementCheck(); | 1756 setNeedsFocusedElementCheck(); |
1753 } | 1757 } |
1754 | 1758 |
1755 void Document::setNeedsFocusedElementCheck() | 1759 void Document::setNeedsFocusedElementCheck() |
1756 { | 1760 { |
1757 // FIXME: Using a Task doesn't look a good idea. | 1761 // FIXME: Using a Task doesn't look a good idea. |
1758 if (!m_focusedElement || m_didPostCheckFocusedElementTask) | 1762 if (!m_focusedElement || m_didPostCheckFocusedElementTask) |
1759 return; | 1763 return; |
1760 postTask(CheckFocusedElementTask::create()); | 1764 postTask(CheckFocusedElementTask::create()); |
1761 m_didPostCheckFocusedElementTask = true; | 1765 m_didPostCheckFocusedElementTask = true; |
1762 } | 1766 } |
1763 | 1767 |
| 1768 void Document::recalcStyleForLayoutIgnoringPendingStylesheets() |
| 1769 { |
| 1770 TemporaryChange<bool> ignorePendingStylesheets(m_ignorePendingStylesheets, m
_ignorePendingStylesheets); |
| 1771 if (!haveStylesheetsLoaded()) { |
| 1772 m_ignorePendingStylesheets = true; |
| 1773 // FIXME: We are willing to attempt to suppress painting with outdated s
tyle info only once. |
| 1774 // Our assumption is that it would be dangerous to try to stop it a seco
nd time, after page |
| 1775 // content has already been loaded and displayed with accurate style inf
ormation. (Our |
| 1776 // suppression involves blanking the whole page at the moment. If it wer
e more refined, we |
| 1777 // might be able to do something better.) It's worth noting though that
this entire method |
| 1778 // is a hack, since what we really want to do is suspend JS instead of d
oing a layout with |
| 1779 // inaccurate information. |
| 1780 HTMLElement* bodyElement = body(); |
| 1781 if (bodyElement && !bodyElement->renderer() && m_pendingSheetLayout == N
oLayoutWithPendingSheets) { |
| 1782 m_pendingSheetLayout = DidLayoutWithPendingSheets; |
| 1783 styleResolverChanged(RecalcStyleImmediately); |
| 1784 } else if (m_hasNodesWithPlaceholderStyle) { |
| 1785 // If new nodes have been added or style recalc has been done with s
tyle sheets still |
| 1786 // pending, some nodes may not have had their real style calculated
yet. Normally this |
| 1787 // gets cleaned when style sheets arrive but here we need up-to-date
style immediately. |
| 1788 recalcStyle(Force); |
| 1789 } |
| 1790 } |
| 1791 } |
| 1792 |
1764 // FIXME: This is a bad idea and needs to be removed eventually. | 1793 // FIXME: This is a bad idea and needs to be removed eventually. |
1765 // Other browsers load stylesheets before they continue parsing the web page. | 1794 // Other browsers load stylesheets before they continue parsing the web page. |
1766 // Since we don't, we can run JavaScript code that needs answers before the | 1795 // Since we don't, we can run JavaScript code that needs answers before the |
1767 // stylesheets are loaded. Doing a layout ignoring the pending stylesheets | 1796 // stylesheets are loaded. Doing a layout ignoring the pending stylesheets |
1768 // lets us get reasonable answers. The long term solution to this problem is | 1797 // lets us get reasonable answers. The long term solution to this problem is |
1769 // to instead suspend JavaScript execution. | 1798 // to instead suspend JavaScript execution. |
1770 void Document::updateLayoutIgnorePendingStylesheets() | 1799 void Document::updateLayoutIgnorePendingStylesheets() |
1771 { | 1800 { |
1772 bool oldIgnore = m_ignorePendingStylesheets; | 1801 recalcStyleForLayoutIgnoringPendingStylesheets(); |
| 1802 updateLayout(); |
| 1803 } |
1773 | 1804 |
1774 if (!haveStylesheetsLoaded()) { | 1805 void Document::partialUpdateLayoutIgnorePendingStylesheets(Node* stopLayoutAtNod
e) |
1775 m_ignorePendingStylesheets = true; | 1806 { |
1776 // FIXME: We are willing to attempt to suppress painting with outdated s
tyle info only once. Our assumption is that it would be | 1807 // Non-overlay scrollbars can cause a second layout that is dependent |
1777 // dangerous to try to stop it a second time, after page content has alr
eady been loaded and displayed | 1808 // on a first layout. This is disabled for partial layout for now. |
1778 // with accurate style information. (Our suppression involves blanking
the whole page at the | 1809 if (!RuntimeEnabledFeatures::partialLayoutEnabled() || !ScrollbarTheme::them
e()->usesOverlayScrollbars()) { |
1779 // moment. If it were more refined, we might be able to do something be
tter.) | 1810 updateLayoutIgnorePendingStylesheets(); |
1780 // It's worth noting though that this entire method is a hack, since wha
t we really want to do is | 1811 return; |
1781 // suspend JS instead of doing a layout with inaccurate information. | 1812 } |
1782 HTMLElement* bodyElement = body(); | 1813 |
1783 if (bodyElement && !bodyElement->renderer() && m_pendingSheetLayout == N
oLayoutWithPendingSheets) { | 1814 TemporaryChange<bool> ignorePendingStylesheets(m_ignorePendingStylesheets, m
_ignorePendingStylesheets); |
1784 m_pendingSheetLayout = DidLayoutWithPendingSheets; | 1815 recalcStyleForLayoutIgnoringPendingStylesheets(); |
1785 styleResolverChanged(RecalcStyleImmediately); | 1816 |
1786 } else if (m_hasNodesWithPlaceholderStyle) | 1817 if (stopLayoutAtNode) { |
1787 // If new nodes have been added or style recalc has been done with s
tyle sheets still pending, some nodes | 1818 RenderObject* renderer = stopLayoutAtNode->renderer(); |
1788 // may not have had their real style calculated yet. Normally this g
ets cleaned when style sheets arrive | 1819 bool canPartialLayout = renderer; |
1789 // but here we need up-to-date style immediately. | 1820 while (renderer) { |
1790 recalcStyle(Force); | 1821 if (!renderer->supportsPartialLayout()) { |
| 1822 canPartialLayout = false; |
| 1823 break; |
| 1824 } |
| 1825 renderer = renderer->parent(); |
| 1826 } |
| 1827 if (canPartialLayout && view()) |
| 1828 view()->partialLayout().setStopAtRenderer(stopLayoutAtNode->renderer
()); |
1791 } | 1829 } |
1792 | 1830 |
1793 updateLayout(); | 1831 updateLayout(); |
1794 | 1832 |
1795 m_ignorePendingStylesheets = oldIgnore; | 1833 if (view()) |
| 1834 view()->partialLayout().reset(); |
1796 } | 1835 } |
1797 | 1836 |
1798 PassRefPtr<RenderStyle> Document::styleForElementIgnoringPendingStylesheets(Elem
ent* element) | 1837 PassRefPtr<RenderStyle> Document::styleForElementIgnoringPendingStylesheets(Elem
ent* element) |
1799 { | 1838 { |
1800 ASSERT_ARG(element, &element->document() == this); | 1839 ASSERT_ARG(element, &element->document() == this); |
1801 TemporaryChange<bool> ignoreStyleSheets(m_ignorePendingStylesheets, true); | 1840 TemporaryChange<bool> ignoreStyleSheets(m_ignorePendingStylesheets, true); |
1802 return styleResolver()->styleForElement(element, element->parentNode() ? ele
ment->parentNode()->computedStyle() : 0); | 1841 return styleResolver()->styleForElement(element, element->parentNode() ? ele
ment->parentNode()->computedStyle() : 0); |
1803 } | 1842 } |
1804 | 1843 |
1805 PassRefPtr<RenderStyle> Document::styleForPage(int pageIndex) | 1844 PassRefPtr<RenderStyle> Document::styleForPage(int pageIndex) |
(...skipping 3519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5325 { | 5364 { |
5326 return DocumentLifecycleNotifier::create(this); | 5365 return DocumentLifecycleNotifier::create(this); |
5327 } | 5366 } |
5328 | 5367 |
5329 DocumentLifecycleNotifier* Document::lifecycleNotifier() | 5368 DocumentLifecycleNotifier* Document::lifecycleNotifier() |
5330 { | 5369 { |
5331 return static_cast<DocumentLifecycleNotifier*>(ScriptExecutionContext::lifec
ycleNotifier()); | 5370 return static_cast<DocumentLifecycleNotifier*>(ScriptExecutionContext::lifec
ycleNotifier()); |
5332 } | 5371 } |
5333 | 5372 |
5334 } // namespace WebCore | 5373 } // namespace WebCore |
OLD | NEW |