| 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 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 631 if (ownerElement()) | 631 if (ownerElement()) |
| 632 return documentElement(); | 632 return documentElement(); |
| 633 | 633 |
| 634 FrameHost* host = frameHost(); | 634 FrameHost* host = frameHost(); |
| 635 if (!host) | 635 if (!host) |
| 636 return nullptr; | 636 return nullptr; |
| 637 | 637 |
| 638 RootScroller* rootScroller = host->rootScroller(); | 638 RootScroller* rootScroller = host->rootScroller(); |
| 639 DCHECK(rootScroller); | 639 DCHECK(rootScroller); |
| 640 | 640 |
| 641 updateLayoutIgnorePendingStylesheets(); | 641 updateStyleAndLayoutIgnorePendingStylesheets(); |
| 642 | 642 |
| 643 return rootScroller->get(); | 643 return rootScroller->get(); |
| 644 } | 644 } |
| 645 | 645 |
| 646 AtomicString Document::convertLocalName(const AtomicString& name) | 646 AtomicString Document::convertLocalName(const AtomicString& name) |
| 647 { | 647 { |
| 648 return isHTMLDocument() ? name.lower() : name; | 648 return isHTMLDocument() ? name.lower() : name; |
| 649 } | 649 } |
| 650 | 650 |
| 651 Element* Document::createElement(const AtomicString& name, ExceptionState& excep
tionState) | 651 Element* Document::createElement(const AtomicString& name, ExceptionState& excep
tionState) |
| (...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1151 return nullptr; | 1151 return nullptr; |
| 1152 | 1152 |
| 1153 Position rangeCompliantPosition = positionWithAffinity.position().parentAnch
oredEquivalent(); | 1153 Position rangeCompliantPosition = positionWithAffinity.position().parentAnch
oredEquivalent(); |
| 1154 return Range::createAdjustedToTreeScope(*this, rangeCompliantPosition); | 1154 return Range::createAdjustedToTreeScope(*this, rangeCompliantPosition); |
| 1155 } | 1155 } |
| 1156 | 1156 |
| 1157 Element* Document::scrollingElement() | 1157 Element* Document::scrollingElement() |
| 1158 { | 1158 { |
| 1159 if (RuntimeEnabledFeatures::scrollTopLeftInteropEnabled()) { | 1159 if (RuntimeEnabledFeatures::scrollTopLeftInteropEnabled()) { |
| 1160 if (inQuirksMode()) { | 1160 if (inQuirksMode()) { |
| 1161 updateLayoutTree(); | 1161 updateStyleAndLayoutTree(); |
| 1162 HTMLBodyElement* body = firstBodyElement(); | 1162 HTMLBodyElement* body = firstBodyElement(); |
| 1163 if (body && body->layoutObject() && body->layoutObject()->hasOverflo
wClip()) | 1163 if (body && body->layoutObject() && body->layoutObject()->hasOverflo
wClip()) |
| 1164 return nullptr; | 1164 return nullptr; |
| 1165 | 1165 |
| 1166 return body; | 1166 return body; |
| 1167 } | 1167 } |
| 1168 | 1168 |
| 1169 return documentElement(); | 1169 return documentElement(); |
| 1170 } | 1170 } |
| 1171 | 1171 |
| (...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1687 DCHECK(!node.childNeedsStyleRecalc()); | 1687 DCHECK(!node.childNeedsStyleRecalc()); |
| 1688 DCHECK(!node.childNeedsDistributionRecalc()); | 1688 DCHECK(!node.childNeedsDistributionRecalc()); |
| 1689 DCHECK(!node.needsStyleInvalidation()); | 1689 DCHECK(!node.needsStyleInvalidation()); |
| 1690 DCHECK(!node.childNeedsStyleInvalidation()); | 1690 DCHECK(!node.childNeedsStyleInvalidation()); |
| 1691 for (ShadowRoot* shadowRoot = node.youngestShadowRoot(); shadowRoot; sha
dowRoot = shadowRoot->olderShadowRoot()) | 1691 for (ShadowRoot* shadowRoot = node.youngestShadowRoot(); shadowRoot; sha
dowRoot = shadowRoot->olderShadowRoot()) |
| 1692 assertLayoutTreeUpdated(*shadowRoot); | 1692 assertLayoutTreeUpdated(*shadowRoot); |
| 1693 } | 1693 } |
| 1694 } | 1694 } |
| 1695 #endif | 1695 #endif |
| 1696 | 1696 |
| 1697 void Document::updateLayoutTree() | 1697 void Document::updateStyleAndLayoutTree() |
| 1698 { | 1698 { |
| 1699 DCHECK(isMainThread()); | 1699 DCHECK(isMainThread()); |
| 1700 | 1700 |
| 1701 ScriptForbiddenScope forbidScript; | 1701 ScriptForbiddenScope forbidScript; |
| 1702 // We should forbid script execution for plugins here because update while l
ayout is changing, | 1702 // We should forbid script execution for plugins here because update while l
ayout is changing, |
| 1703 // HTMLPlugin element can be reattached and plugin can be destroyed. Plugin
can execute scripts | 1703 // HTMLPlugin element can be reattached and plugin can be destroyed. Plugin
can execute scripts |
| 1704 // on destroy. It produces crash without PluginScriptForbiddenScope: crbug.c
om/550427. | 1704 // on destroy. It produces crash without PluginScriptForbiddenScope: crbug.c
om/550427. |
| 1705 PluginScriptForbiddenScope pluginForbidScript; | 1705 PluginScriptForbiddenScope pluginForbidScript; |
| 1706 | 1706 |
| 1707 if (!view() || !isActive()) | 1707 if (!view() || !isActive()) |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1722 } | 1722 } |
| 1723 | 1723 |
| 1724 if (inStyleRecalc()) | 1724 if (inStyleRecalc()) |
| 1725 return; | 1725 return; |
| 1726 | 1726 |
| 1727 // Entering here from inside layout, paint etc. would be catastrophic since
recalcStyle can | 1727 // Entering here from inside layout, paint etc. would be catastrophic since
recalcStyle can |
| 1728 // tear down the layout tree or (unfortunately) run script. Kill the whole l
ayoutObject if | 1728 // tear down the layout tree or (unfortunately) run script. Kill the whole l
ayoutObject if |
| 1729 // someone managed to get into here in states not allowing tree mutations. | 1729 // someone managed to get into here in states not allowing tree mutations. |
| 1730 RELEASE_ASSERT(lifecycle().stateAllowsTreeMutations()); | 1730 RELEASE_ASSERT(lifecycle().stateAllowsTreeMutations()); |
| 1731 | 1731 |
| 1732 TRACE_EVENT_BEGIN1("blink,devtools.timeline", "UpdateLayoutTree", "beginData
", InspectorRecalculateStylesEvent::data(frame())); | 1732 TRACE_EVENT_BEGIN1("blink,devtools.timeline", "UpdateStyleAndLayoutTree", "b
eginData", InspectorRecalculateStylesEvent::data(frame())); |
| 1733 TRACE_EVENT_SCOPED_SAMPLING_STATE("blink", "UpdateLayoutTree"); | 1733 TRACE_EVENT_SCOPED_SAMPLING_STATE("blink", "UpdateStyleAndLayoutTree"); |
| 1734 | 1734 |
| 1735 unsigned startElementCount = styleEngine().styleForElementCount(); | 1735 unsigned startElementCount = styleEngine().styleForElementCount(); |
| 1736 | 1736 |
| 1737 InspectorInstrumentation::StyleRecalc instrumentation(this); | 1737 InspectorInstrumentation::StyleRecalc instrumentation(this); |
| 1738 | 1738 |
| 1739 DocumentAnimations::updateAnimationTimingIfNeeded(*this); | 1739 DocumentAnimations::updateAnimationTimingIfNeeded(*this); |
| 1740 evaluateMediaQueryListIfNeeded(); | 1740 evaluateMediaQueryListIfNeeded(); |
| 1741 updateUseShadowTreesIfNeeded(); | 1741 updateUseShadowTreesIfNeeded(); |
| 1742 updateDistribution(); | 1742 updateDistribution(); |
| 1743 updateStyleInvalidationIfNeeded(); | 1743 updateStyleInvalidationIfNeeded(); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1760 frame()->eventHandler().dispatchFakeMouseMoveEventSoon(); | 1760 frame()->eventHandler().dispatchFakeMouseMoveEventSoon(); |
| 1761 | 1761 |
| 1762 if (m_focusedElement && !m_focusedElement->isFocusable()) | 1762 if (m_focusedElement && !m_focusedElement->isFocusable()) |
| 1763 clearFocusedElementSoon(); | 1763 clearFocusedElementSoon(); |
| 1764 layoutView()->clearHitTestCache(); | 1764 layoutView()->clearHitTestCache(); |
| 1765 | 1765 |
| 1766 DCHECK(!DocumentAnimations::needsAnimationTimingUpdate(*this)); | 1766 DCHECK(!DocumentAnimations::needsAnimationTimingUpdate(*this)); |
| 1767 | 1767 |
| 1768 unsigned elementCount = styleEngine().styleForElementCount() - startElementC
ount; | 1768 unsigned elementCount = styleEngine().styleForElementCount() - startElementC
ount; |
| 1769 | 1769 |
| 1770 TRACE_EVENT_END1("blink,devtools.timeline", "UpdateLayoutTree", "elementCoun
t", elementCount); | 1770 TRACE_EVENT_END1("blink,devtools.timeline", "UpdateStyleAndLayoutTree", "ele
mentCount", elementCount); |
| 1771 | 1771 |
| 1772 #if DCHECK_IS_ON() | 1772 #if DCHECK_IS_ON() |
| 1773 assertLayoutTreeUpdated(*this); | 1773 assertLayoutTreeUpdated(*this); |
| 1774 #endif | 1774 #endif |
| 1775 } | 1775 } |
| 1776 | 1776 |
| 1777 void Document::updateStyle() | 1777 void Document::updateStyle() |
| 1778 { | 1778 { |
| 1779 DCHECK(!view()->shouldThrottleRendering()); | 1779 DCHECK(!view()->shouldThrottleRendering()); |
| 1780 TRACE_EVENT_BEGIN0("blink,blink_style", "Document::updateStyle"); | 1780 TRACE_EVENT_BEGIN0("blink,blink_style", "Document::updateStyle"); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1866 | 1866 |
| 1867 if (needsFullLayoutTreeUpdate() || node.needsStyleRecalc() || node.needsStyl
eInvalidation()) | 1867 if (needsFullLayoutTreeUpdate() || node.needsStyleRecalc() || node.needsStyl
eInvalidation()) |
| 1868 return true; | 1868 return true; |
| 1869 for (const ContainerNode* ancestor = LayoutTreeBuilderTraversal::parent(node
); ancestor; ancestor = LayoutTreeBuilderTraversal::parent(*ancestor)) { | 1869 for (const ContainerNode* ancestor = LayoutTreeBuilderTraversal::parent(node
); ancestor; ancestor = LayoutTreeBuilderTraversal::parent(*ancestor)) { |
| 1870 if (ancestor->needsStyleRecalc() || ancestor->needsStyleInvalidation() |
| ancestor->needsAdjacentStyleRecalc()) | 1870 if (ancestor->needsStyleRecalc() || ancestor->needsStyleInvalidation() |
| ancestor->needsAdjacentStyleRecalc()) |
| 1871 return true; | 1871 return true; |
| 1872 } | 1872 } |
| 1873 return false; | 1873 return false; |
| 1874 } | 1874 } |
| 1875 | 1875 |
| 1876 void Document::updateLayoutTreeForNode(const Node* node) | 1876 void Document::updateStyleAndLayoutTreeForNode(const Node* node) |
| 1877 { | 1877 { |
| 1878 DCHECK(node); | 1878 DCHECK(node); |
| 1879 if (!needsLayoutTreeUpdateForNode(*node)) | 1879 if (!needsLayoutTreeUpdateForNode(*node)) |
| 1880 return; | 1880 return; |
| 1881 updateLayoutTree(); | 1881 updateStyleAndLayoutTree(); |
| 1882 } | 1882 } |
| 1883 | 1883 |
| 1884 void Document::updateLayoutIgnorePendingStylesheetsForNode(Node* node) | 1884 void Document::updateStyleAndLayoutIgnorePendingStylesheetsForNode(Node* node) |
| 1885 { | 1885 { |
| 1886 DCHECK(node); | 1886 DCHECK(node); |
| 1887 if (!node->inActiveDocument()) | 1887 if (!node->inActiveDocument()) |
| 1888 return; | 1888 return; |
| 1889 updateLayoutIgnorePendingStylesheets(); | 1889 updateStyleAndLayoutIgnorePendingStylesheets(); |
| 1890 } | 1890 } |
| 1891 | 1891 |
| 1892 void Document::updateLayout() | 1892 void Document::updateStyleAndLayout() |
| 1893 { | 1893 { |
| 1894 DCHECK(isMainThread()); | 1894 DCHECK(isMainThread()); |
| 1895 | 1895 |
| 1896 ScriptForbiddenScope forbidScript; | 1896 ScriptForbiddenScope forbidScript; |
| 1897 | 1897 |
| 1898 FrameView* frameView = view(); | 1898 FrameView* frameView = view(); |
| 1899 if (frameView && frameView->isInPerformLayout()) { | 1899 if (frameView && frameView->isInPerformLayout()) { |
| 1900 // View layout should not be re-entrant. | 1900 // View layout should not be re-entrant. |
| 1901 ASSERT_NOT_REACHED(); | 1901 ASSERT_NOT_REACHED(); |
| 1902 return; | 1902 return; |
| 1903 } | 1903 } |
| 1904 | 1904 |
| 1905 if (HTMLFrameOwnerElement* owner = ownerElement()) | 1905 if (HTMLFrameOwnerElement* owner = ownerElement()) |
| 1906 owner->document().updateLayout(); | 1906 owner->document().updateStyleAndLayout(); |
| 1907 | 1907 |
| 1908 updateLayoutTree(); | 1908 updateStyleAndLayoutTree(); |
| 1909 | 1909 |
| 1910 if (!isActive()) | 1910 if (!isActive()) |
| 1911 return; | 1911 return; |
| 1912 | 1912 |
| 1913 if (frameView->needsLayout()) | 1913 if (frameView->needsLayout()) |
| 1914 frameView->layout(); | 1914 frameView->layout(); |
| 1915 | 1915 |
| 1916 if (lifecycle().state() < DocumentLifecycle::LayoutClean) | 1916 if (lifecycle().state() < DocumentLifecycle::LayoutClean) |
| 1917 lifecycle().advanceTo(DocumentLifecycle::LayoutClean); | 1917 lifecycle().advanceTo(DocumentLifecycle::LayoutClean); |
| 1918 } | 1918 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1952 } | 1952 } |
| 1953 | 1953 |
| 1954 void Document::clearFocusedElementSoon() | 1954 void Document::clearFocusedElementSoon() |
| 1955 { | 1955 { |
| 1956 if (!m_clearFocusedElementTimer.isActive()) | 1956 if (!m_clearFocusedElementTimer.isActive()) |
| 1957 m_clearFocusedElementTimer.startOneShot(0, BLINK_FROM_HERE); | 1957 m_clearFocusedElementTimer.startOneShot(0, BLINK_FROM_HERE); |
| 1958 } | 1958 } |
| 1959 | 1959 |
| 1960 void Document::clearFocusedElementTimerFired(Timer<Document>*) | 1960 void Document::clearFocusedElementTimerFired(Timer<Document>*) |
| 1961 { | 1961 { |
| 1962 updateLayoutTree(); | 1962 updateStyleAndLayoutTree(); |
| 1963 m_clearFocusedElementTimer.stop(); | 1963 m_clearFocusedElementTimer.stop(); |
| 1964 | 1964 |
| 1965 if (m_focusedElement && !m_focusedElement->isFocusable()) | 1965 if (m_focusedElement && !m_focusedElement->isFocusable()) |
| 1966 m_focusedElement->blur(); | 1966 m_focusedElement->blur(); |
| 1967 } | 1967 } |
| 1968 | 1968 |
| 1969 // FIXME: This is a bad idea and needs to be removed eventually. | 1969 // FIXME: This is a bad idea and needs to be removed eventually. |
| 1970 // Other browsers load stylesheets before they continue parsing the web page. | 1970 // Other browsers load stylesheets before they continue parsing the web page. |
| 1971 // Since we don't, we can run JavaScript code that needs answers before the | 1971 // Since we don't, we can run JavaScript code that needs answers before the |
| 1972 // stylesheets are loaded. Doing a layout ignoring the pending stylesheets | 1972 // stylesheets are loaded. Doing a layout ignoring the pending stylesheets |
| 1973 // lets us get reasonable answers. The long term solution to this problem is | 1973 // lets us get reasonable answers. The long term solution to this problem is |
| 1974 // to instead suspend JavaScript execution. | 1974 // to instead suspend JavaScript execution. |
| 1975 void Document::updateLayoutTreeIgnorePendingStylesheets() | 1975 void Document::updateStyleAndLayoutTreeIgnorePendingStylesheets() |
| 1976 { | 1976 { |
| 1977 StyleEngine::IgnoringPendingStylesheet ignoring(styleEngine()); | 1977 StyleEngine::IgnoringPendingStylesheet ignoring(styleEngine()); |
| 1978 | 1978 |
| 1979 if (styleEngine().hasPendingSheets()) { | 1979 if (styleEngine().hasPendingSheets()) { |
| 1980 // FIXME: We are willing to attempt to suppress painting with outdated s
tyle info only once. | 1980 // FIXME: We are willing to attempt to suppress painting with outdated s
tyle info only once. |
| 1981 // Our assumption is that it would be dangerous to try to stop it a seco
nd time, after page | 1981 // Our assumption is that it would be dangerous to try to stop it a seco
nd time, after page |
| 1982 // content has already been loaded and displayed with accurate style inf
ormation. (Our | 1982 // content has already been loaded and displayed with accurate style inf
ormation. (Our |
| 1983 // suppression involves blanking the whole page at the moment. If it wer
e more refined, we | 1983 // suppression involves blanking the whole page at the moment. If it wer
e more refined, we |
| 1984 // might be able to do something better.) It's worth noting though that
this entire method | 1984 // might be able to do something better.) It's worth noting though that
this entire method |
| 1985 // is a hack, since what we really want to do is suspend JS instead of d
oing a layout with | 1985 // is a hack, since what we really want to do is suspend JS instead of d
oing a layout with |
| 1986 // inaccurate information. | 1986 // inaccurate information. |
| 1987 HTMLElement* bodyElement = body(); | 1987 HTMLElement* bodyElement = body(); |
| 1988 if (bodyElement && !bodyElement->layoutObject() && m_pendingSheetLayout
== NoLayoutWithPendingSheets) { | 1988 if (bodyElement && !bodyElement->layoutObject() && m_pendingSheetLayout
== NoLayoutWithPendingSheets) { |
| 1989 m_pendingSheetLayout = DidLayoutWithPendingSheets; | 1989 m_pendingSheetLayout = DidLayoutWithPendingSheets; |
| 1990 styleEngine().resolverChanged(FullStyleUpdate); | 1990 styleEngine().resolverChanged(FullStyleUpdate); |
| 1991 } else if (m_hasNodesWithPlaceholderStyle) { | 1991 } else if (m_hasNodesWithPlaceholderStyle) { |
| 1992 // If new nodes have been added or style recalc has been done with s
tyle sheets still | 1992 // If new nodes have been added or style recalc has been done with s
tyle sheets still |
| 1993 // pending, some nodes may not have had their real style calculated
yet. Normally this | 1993 // pending, some nodes may not have had their real style calculated
yet. Normally this |
| 1994 // gets cleaned when style sheets arrive but here we need up-to-date
style immediately. | 1994 // gets cleaned when style sheets arrive but here we need up-to-date
style immediately. |
| 1995 setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing:
:create(StyleChangeReason::CleanupPlaceholderStyles)); | 1995 setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing:
:create(StyleChangeReason::CleanupPlaceholderStyles)); |
| 1996 } | 1996 } |
| 1997 } | 1997 } |
| 1998 updateLayoutTree(); | 1998 updateStyleAndLayoutTree(); |
| 1999 } | 1999 } |
| 2000 | 2000 |
| 2001 void Document::updateLayoutIgnorePendingStylesheets(Document::RunPostLayoutTasks
runPostLayoutTasks) | 2001 void Document::updateStyleAndLayoutIgnorePendingStylesheets(Document::RunPostLay
outTasks runPostLayoutTasks) |
| 2002 { | 2002 { |
| 2003 updateLayoutTreeIgnorePendingStylesheets(); | 2003 updateStyleAndLayoutTreeIgnorePendingStylesheets(); |
| 2004 updateLayout(); | 2004 updateStyleAndLayout(); |
| 2005 | 2005 |
| 2006 if (runPostLayoutTasks == RunPostLayoutTasksSynchronously && view()) | 2006 if (runPostLayoutTasks == RunPostLayoutTasksSynchronously && view()) |
| 2007 view()->flushAnyPendingPostLayoutTasks(); | 2007 view()->flushAnyPendingPostLayoutTasks(); |
| 2008 } | 2008 } |
| 2009 | 2009 |
| 2010 PassRefPtr<ComputedStyle> Document::styleForElementIgnoringPendingStylesheets(El
ement* element) | 2010 PassRefPtr<ComputedStyle> Document::styleForElementIgnoringPendingStylesheets(El
ement* element) |
| 2011 { | 2011 { |
| 2012 DCHECK_EQ(element->document(), this); | 2012 DCHECK_EQ(element->document(), this); |
| 2013 StyleEngine::IgnoringPendingStylesheet ignoring(styleEngine()); | 2013 StyleEngine::IgnoringPendingStylesheet ignoring(styleEngine()); |
| 2014 return ensureStyleResolver().styleForElement(element, element->parentNode()
? element->parentNode()->ensureComputedStyle() : 0); | 2014 return ensureStyleResolver().styleForElement(element, element->parentNode()
? element->parentNode()->ensureComputedStyle() : 0); |
| (...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2663 // Just bail out. Before or during the onload we were shifted to another
page. | 2663 // Just bail out. Before or during the onload we were shifted to another
page. |
| 2664 // The old i-Bench suite does this. When this happens don't bother paint
ing or laying out. | 2664 // The old i-Bench suite does this. When this happens don't bother paint
ing or laying out. |
| 2665 m_loadEventProgress = LoadEventCompleted; | 2665 m_loadEventProgress = LoadEventCompleted; |
| 2666 return; | 2666 return; |
| 2667 } | 2667 } |
| 2668 | 2668 |
| 2669 // We used to force a synchronous display and flush here. This really isn't | 2669 // We used to force a synchronous display and flush here. This really isn't |
| 2670 // necessary and can in fact be actively harmful if pages are loading at a r
ate of > 60fps | 2670 // necessary and can in fact be actively harmful if pages are loading at a r
ate of > 60fps |
| 2671 // (if your platform is syncing flushes and limiting them to 60fps). | 2671 // (if your platform is syncing flushes and limiting them to 60fps). |
| 2672 if (!ownerElement() || (ownerElement()->layoutObject() && !ownerElement()->l
ayoutObject()->needsLayout())) { | 2672 if (!ownerElement() || (ownerElement()->layoutObject() && !ownerElement()->l
ayoutObject()->needsLayout())) { |
| 2673 updateLayoutTree(); | 2673 updateStyleAndLayoutTree(); |
| 2674 | 2674 |
| 2675 // Always do a layout after loading if needed. | 2675 // Always do a layout after loading if needed. |
| 2676 if (view() && layoutView() && (!layoutView()->firstChild() || layoutView
()->needsLayout())) | 2676 if (view() && layoutView() && (!layoutView()->firstChild() || layoutView
()->needsLayout())) |
| 2677 view()->layout(); | 2677 view()->layout(); |
| 2678 } | 2678 } |
| 2679 | 2679 |
| 2680 m_loadEventProgress = LoadEventCompleted; | 2680 m_loadEventProgress = LoadEventCompleted; |
| 2681 | 2681 |
| 2682 if (frame() && layoutView() && settings()->accessibilityEnabled()) { | 2682 if (frame() && layoutView() && settings()->accessibilityEnabled()) { |
| 2683 if (AXObjectCache* cache = axObjectCache()) { | 2683 if (AXObjectCache* cache = axObjectCache()) { |
| (...skipping 915 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3599 if (view()) { | 3599 if (view()) { |
| 3600 Widget* oldWidget = widgetForElement(*oldFocusedElement); | 3600 Widget* oldWidget = widgetForElement(*oldFocusedElement); |
| 3601 if (oldWidget) | 3601 if (oldWidget) |
| 3602 oldWidget->setFocus(false, params.type); | 3602 oldWidget->setFocus(false, params.type); |
| 3603 else | 3603 else |
| 3604 view()->setFocus(false, params.type); | 3604 view()->setFocus(false, params.type); |
| 3605 } | 3605 } |
| 3606 } | 3606 } |
| 3607 | 3607 |
| 3608 if (newFocusedElement) | 3608 if (newFocusedElement) |
| 3609 updateLayoutTreeForNode(newFocusedElement); | 3609 updateStyleAndLayoutTreeForNode(newFocusedElement); |
| 3610 if (newFocusedElement && newFocusedElement->isFocusable()) { | 3610 if (newFocusedElement && newFocusedElement->isFocusable()) { |
| 3611 if (newFocusedElement->isRootEditableElement() && !acceptsEditingFocus(*
newFocusedElement)) { | 3611 if (newFocusedElement->isRootEditableElement() && !acceptsEditingFocus(*
newFocusedElement)) { |
| 3612 // delegate blocks focus change | 3612 // delegate blocks focus change |
| 3613 focusChangeBlocked = true; | 3613 focusChangeBlocked = true; |
| 3614 goto SetFocusedElementDone; | 3614 goto SetFocusedElementDone; |
| 3615 } | 3615 } |
| 3616 // Set focus on the new node | 3616 // Set focus on the new node |
| 3617 m_focusedElement = newFocusedElement; | 3617 m_focusedElement = newFocusedElement; |
| 3618 setSequentialFocusNavigationStartingPoint(m_focusedElement.get()); | 3618 setSequentialFocusNavigationStartingPoint(m_focusedElement.get()); |
| 3619 | 3619 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3660 frame()->spellChecker().didBeginEditing(m_focusedElement.get()); | 3660 frame()->spellChecker().didBeginEditing(m_focusedElement.get()); |
| 3661 | 3661 |
| 3662 // eww, I suck. set the qt focus correctly | 3662 // eww, I suck. set the qt focus correctly |
| 3663 // ### find a better place in the code for this | 3663 // ### find a better place in the code for this |
| 3664 if (view()) { | 3664 if (view()) { |
| 3665 Widget* focusWidget = widgetForElement(*m_focusedElement); | 3665 Widget* focusWidget = widgetForElement(*m_focusedElement); |
| 3666 if (focusWidget) { | 3666 if (focusWidget) { |
| 3667 // Make sure a widget has the right size before giving it focus. | 3667 // Make sure a widget has the right size before giving it focus. |
| 3668 // Otherwise, we are testing edge cases of the Widget code. | 3668 // Otherwise, we are testing edge cases of the Widget code. |
| 3669 // Specifically, in WebCore this does not work well for text fie
lds. | 3669 // Specifically, in WebCore this does not work well for text fie
lds. |
| 3670 updateLayout(); | 3670 updateStyleAndLayout(); |
| 3671 // Re-get the widget in case updating the layout changed things. | 3671 // Re-get the widget in case updating the layout changed things. |
| 3672 focusWidget = widgetForElement(*m_focusedElement); | 3672 focusWidget = widgetForElement(*m_focusedElement); |
| 3673 } | 3673 } |
| 3674 if (focusWidget) | 3674 if (focusWidget) |
| 3675 focusWidget->setFocus(true, params.type); | 3675 focusWidget->setFocus(true, params.type); |
| 3676 else | 3676 else |
| 3677 view()->setFocus(true, params.type); | 3677 view()->setFocus(true, params.type); |
| 3678 } | 3678 } |
| 3679 } | 3679 } |
| 3680 | 3680 |
| 3681 if (!focusChangeBlocked && m_focusedElement) { | 3681 if (!focusChangeBlocked && m_focusedElement) { |
| 3682 // Create the AXObject cache in a focus change because Chromium relies o
n it. | 3682 // Create the AXObject cache in a focus change because Chromium relies o
n it. |
| 3683 if (AXObjectCache* cache = axObjectCache()) | 3683 if (AXObjectCache* cache = axObjectCache()) |
| 3684 cache->handleFocusedUIElementChanged(oldFocusedElement, newFocusedEl
ement); | 3684 cache->handleFocusedUIElementChanged(oldFocusedElement, newFocusedEl
ement); |
| 3685 } | 3685 } |
| 3686 | 3686 |
| 3687 if (!focusChangeBlocked && frameHost()) | 3687 if (!focusChangeBlocked && frameHost()) |
| 3688 frameHost()->chromeClient().focusedNodeChanged(oldFocusedElement, m_focu
sedElement.get()); | 3688 frameHost()->chromeClient().focusedNodeChanged(oldFocusedElement, m_focu
sedElement.get()); |
| 3689 | 3689 |
| 3690 SetFocusedElementDone: | 3690 SetFocusedElementDone: |
| 3691 updateLayoutTree(); | 3691 updateStyleAndLayoutTree(); |
| 3692 if (LocalFrame* frame = this->frame()) | 3692 if (LocalFrame* frame = this->frame()) |
| 3693 frame->selection().didChangeFocus(); | 3693 frame->selection().didChangeFocus(); |
| 3694 return !focusChangeBlocked; | 3694 return !focusChangeBlocked; |
| 3695 } | 3695 } |
| 3696 | 3696 |
| 3697 void Document::clearFocusedElement() | 3697 void Document::clearFocusedElement() |
| 3698 { | 3698 { |
| 3699 setFocusedElement(nullptr, FocusParams(SelectionBehaviorOnFocus::None, WebFo
cusTypeNone, nullptr)); | 3699 setFocusedElement(nullptr, FocusParams(SelectionBehaviorOnFocus::None, WebFo
cusTypeNone, nullptr)); |
| 3700 } | 3700 } |
| 3701 | 3701 |
| (...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4468 } | 4468 } |
| 4469 | 4469 |
| 4470 // Support for Javascript execCommand, and related methods | 4470 // Support for Javascript execCommand, and related methods |
| 4471 | 4471 |
| 4472 static Editor::Command command(Document* document, const String& commandName) | 4472 static Editor::Command command(Document* document, const String& commandName) |
| 4473 { | 4473 { |
| 4474 LocalFrame* frame = document->frame(); | 4474 LocalFrame* frame = document->frame(); |
| 4475 if (!frame || frame->document() != document) | 4475 if (!frame || frame->document() != document) |
| 4476 return Editor::Command(); | 4476 return Editor::Command(); |
| 4477 | 4477 |
| 4478 document->updateLayoutTree(); | 4478 document->updateStyleAndLayoutTree(); |
| 4479 return frame->editor().createCommand(commandName, CommandFromDOM); | 4479 return frame->editor().createCommand(commandName, CommandFromDOM); |
| 4480 } | 4480 } |
| 4481 | 4481 |
| 4482 bool Document::execCommand(const String& commandName, bool, const String& value,
ExceptionState& exceptionState) | 4482 bool Document::execCommand(const String& commandName, bool, const String& value,
ExceptionState& exceptionState) |
| 4483 { | 4483 { |
| 4484 if (!isHTMLDocument() && !isXHTMLDocument()) { | 4484 if (!isHTMLDocument() && !isXHTMLDocument()) { |
| 4485 exceptionState.throwDOMException(InvalidStateError, "execCommand is only
supported on HTML documents."); | 4485 exceptionState.throwDOMException(InvalidStateError, "execCommand is only
supported on HTML documents."); |
| 4486 return false; | 4486 return false; |
| 4487 } | 4487 } |
| 4488 if (focusedElement() && isHTMLTextFormControlElement(*focusedElement())) | 4488 if (focusedElement() && isHTMLTextFormControlElement(*focusedElement())) |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4787 const bool mainResourceWasAlreadyRequested = frame->loader().stateMachin
e()->committedFirstRealDocumentLoad(); | 4787 const bool mainResourceWasAlreadyRequested = frame->loader().stateMachin
e()->committedFirstRealDocumentLoad(); |
| 4788 | 4788 |
| 4789 // FrameLoader::finishedParsing() might end up calling Document::implici
tClose() if all | 4789 // FrameLoader::finishedParsing() might end up calling Document::implici
tClose() if all |
| 4790 // resource loads are complete. HTMLObjectElements can start loading the
ir resources from | 4790 // resource loads are complete. HTMLObjectElements can start loading the
ir resources from |
| 4791 // post attach callbacks triggered by recalcStyle(). This means if we p
arse out an <object> | 4791 // post attach callbacks triggered by recalcStyle(). This means if we p
arse out an <object> |
| 4792 // tag and then reach the end of the document without updating styles, w
e might not have yet | 4792 // tag and then reach the end of the document without updating styles, w
e might not have yet |
| 4793 // started the resource load and might fire the window load event too ea
rly. To avoid this | 4793 // started the resource load and might fire the window load event too ea
rly. To avoid this |
| 4794 // we force the styles to be up to date before calling FrameLoader::fini
shedParsing(). | 4794 // we force the styles to be up to date before calling FrameLoader::fini
shedParsing(). |
| 4795 // See https://bugs.webkit.org/show_bug.cgi?id=36864 starting around com
ment 35. | 4795 // See https://bugs.webkit.org/show_bug.cgi?id=36864 starting around com
ment 35. |
| 4796 if (mainResourceWasAlreadyRequested) | 4796 if (mainResourceWasAlreadyRequested) |
| 4797 updateLayoutTree(); | 4797 updateStyleAndLayoutTree(); |
| 4798 | 4798 |
| 4799 beginLifecycleUpdatesIfRenderingReady(); | 4799 beginLifecycleUpdatesIfRenderingReady(); |
| 4800 | 4800 |
| 4801 frame->loader().finishedParsing(); | 4801 frame->loader().finishedParsing(); |
| 4802 | 4802 |
| 4803 TRACE_EVENT_INSTANT1("devtools.timeline", "MarkDOMContent", TRACE_EVENT_
SCOPE_THREAD, "data", InspectorMarkLoadEvent::data(frame)); | 4803 TRACE_EVENT_INSTANT1("devtools.timeline", "MarkDOMContent", TRACE_EVENT_
SCOPE_THREAD, "data", InspectorMarkLoadEvent::data(frame)); |
| 4804 InspectorInstrumentation::domContentLoadedEventFired(frame); | 4804 InspectorInstrumentation::domContentLoadedEventFired(frame); |
| 4805 } | 4805 } |
| 4806 | 4806 |
| 4807 // Schedule dropping of the ElementDataCache. We keep it alive for a while a
fter parsing finishes | 4807 // Schedule dropping of the ElementDataCache. We keep it alive for a while a
fter parsing finishes |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5118 void Document::cancelFocusAppearanceUpdate() | 5118 void Document::cancelFocusAppearanceUpdate() |
| 5119 { | 5119 { |
| 5120 m_updateFocusAppearanceTimer.stop(); | 5120 m_updateFocusAppearanceTimer.stop(); |
| 5121 } | 5121 } |
| 5122 | 5122 |
| 5123 void Document::updateFocusAppearanceTimerFired(Timer<Document>*) | 5123 void Document::updateFocusAppearanceTimerFired(Timer<Document>*) |
| 5124 { | 5124 { |
| 5125 Element* element = focusedElement(); | 5125 Element* element = focusedElement(); |
| 5126 if (!element) | 5126 if (!element) |
| 5127 return; | 5127 return; |
| 5128 updateLayout(); | 5128 updateStyleAndLayout(); |
| 5129 if (element->isFocusable()) | 5129 if (element->isFocusable()) |
| 5130 element->updateFocusAppearance(m_updateFocusAppearanceSelectionBahavior)
; | 5130 element->updateFocusAppearance(m_updateFocusAppearanceSelectionBahavior)
; |
| 5131 } | 5131 } |
| 5132 | 5132 |
| 5133 void Document::attachRange(Range* range) | 5133 void Document::attachRange(Range* range) |
| 5134 { | 5134 { |
| 5135 DCHECK(!m_ranges.contains(range)); | 5135 DCHECK(!m_ranges.contains(range)); |
| 5136 m_ranges.add(range); | 5136 m_ranges.add(range); |
| 5137 } | 5137 } |
| 5138 | 5138 |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5367 | 5367 |
| 5368 void Document::loadPluginsSoon() | 5368 void Document::loadPluginsSoon() |
| 5369 { | 5369 { |
| 5370 // FIXME: Remove this timer once we don't need to compute layout to load plu
gins. | 5370 // FIXME: Remove this timer once we don't need to compute layout to load plu
gins. |
| 5371 if (!m_pluginLoadingTimer.isActive()) | 5371 if (!m_pluginLoadingTimer.isActive()) |
| 5372 m_pluginLoadingTimer.startOneShot(0, BLINK_FROM_HERE); | 5372 m_pluginLoadingTimer.startOneShot(0, BLINK_FROM_HERE); |
| 5373 } | 5373 } |
| 5374 | 5374 |
| 5375 void Document::pluginLoadingTimerFired(Timer<Document>*) | 5375 void Document::pluginLoadingTimerFired(Timer<Document>*) |
| 5376 { | 5376 { |
| 5377 updateLayout(); | 5377 updateStyleAndLayout(); |
| 5378 } | 5378 } |
| 5379 | 5379 |
| 5380 ScriptedAnimationController& Document::ensureScriptedAnimationController() | 5380 ScriptedAnimationController& Document::ensureScriptedAnimationController() |
| 5381 { | 5381 { |
| 5382 if (!m_scriptedAnimationController) { | 5382 if (!m_scriptedAnimationController) { |
| 5383 m_scriptedAnimationController = ScriptedAnimationController::create(this
); | 5383 m_scriptedAnimationController = ScriptedAnimationController::create(this
); |
| 5384 // We need to make sure that we don't start up the animation controller
on a background tab, for example. | 5384 // We need to make sure that we don't start up the animation controller
on a background tab, for example. |
| 5385 if (!page()) | 5385 if (!page()) |
| 5386 m_scriptedAnimationController->suspend(); | 5386 m_scriptedAnimationController->suspend(); |
| 5387 } | 5387 } |
| (...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5979 #ifndef NDEBUG | 5979 #ifndef NDEBUG |
| 5980 using namespace blink; | 5980 using namespace blink; |
| 5981 void showLiveDocumentInstances() | 5981 void showLiveDocumentInstances() |
| 5982 { | 5982 { |
| 5983 Document::WeakDocumentSet& set = Document::liveDocumentSet(); | 5983 Document::WeakDocumentSet& set = Document::liveDocumentSet(); |
| 5984 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); | 5984 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); |
| 5985 for (Document* document : set) | 5985 for (Document* document : set) |
| 5986 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().get
String().utf8().data()); | 5986 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().get
String().utf8().data()); |
| 5987 } | 5987 } |
| 5988 #endif | 5988 #endif |
| OLD | NEW |