| 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 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 635 if (!isInMainFrame()) | 635 if (!isInMainFrame()) |
| 636 return documentElement(); | 636 return documentElement(); |
| 637 | 637 |
| 638 FrameHost* host = frameHost(); | 638 FrameHost* host = frameHost(); |
| 639 if (!host) | 639 if (!host) |
| 640 return nullptr; | 640 return nullptr; |
| 641 | 641 |
| 642 RootScroller* rootScroller = host->rootScroller(); | 642 RootScroller* rootScroller = host->rootScroller(); |
| 643 DCHECK(rootScroller); | 643 DCHECK(rootScroller); |
| 644 | 644 |
| 645 updateLayoutIgnorePendingStylesheets(); | 645 updateStyleAndLayoutIgnorePendingStylesheets(); |
| 646 | 646 |
| 647 return rootScroller->get(); | 647 return rootScroller->get(); |
| 648 } | 648 } |
| 649 | 649 |
| 650 bool Document::isInMainFrame() const | 650 bool Document::isInMainFrame() const |
| 651 { | 651 { |
| 652 return frame() && frame()->isMainFrame(); | 652 return frame() && frame()->isMainFrame(); |
| 653 } | 653 } |
| 654 | 654 |
| 655 AtomicString Document::convertLocalName(const AtomicString& name) | 655 AtomicString Document::convertLocalName(const AtomicString& name) |
| (...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1160 return nullptr; | 1160 return nullptr; |
| 1161 | 1161 |
| 1162 Position rangeCompliantPosition = positionWithAffinity.position().parentAnch
oredEquivalent(); | 1162 Position rangeCompliantPosition = positionWithAffinity.position().parentAnch
oredEquivalent(); |
| 1163 return Range::createAdjustedToTreeScope(*this, rangeCompliantPosition); | 1163 return Range::createAdjustedToTreeScope(*this, rangeCompliantPosition); |
| 1164 } | 1164 } |
| 1165 | 1165 |
| 1166 Element* Document::scrollingElement() | 1166 Element* Document::scrollingElement() |
| 1167 { | 1167 { |
| 1168 if (RuntimeEnabledFeatures::scrollTopLeftInteropEnabled()) { | 1168 if (RuntimeEnabledFeatures::scrollTopLeftInteropEnabled()) { |
| 1169 if (inQuirksMode()) { | 1169 if (inQuirksMode()) { |
| 1170 updateLayoutTree(); | 1170 updateStyleAndLayoutTree(); |
| 1171 HTMLBodyElement* body = firstBodyElement(); | 1171 HTMLBodyElement* body = firstBodyElement(); |
| 1172 if (body && body->layoutObject() && body->layoutObject()->hasOverflo
wClip()) | 1172 if (body && body->layoutObject() && body->layoutObject()->hasOverflo
wClip()) |
| 1173 return nullptr; | 1173 return nullptr; |
| 1174 | 1174 |
| 1175 return body; | 1175 return body; |
| 1176 } | 1176 } |
| 1177 | 1177 |
| 1178 return documentElement(); | 1178 return documentElement(); |
| 1179 } | 1179 } |
| 1180 | 1180 |
| (...skipping 506 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 158 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 = localOwner()) | 1905 if (HTMLFrameOwnerElement* owner = localOwner()) |
| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1953 } | 1953 } |
| 1954 | 1954 |
| 1955 void Document::clearFocusedElementSoon() | 1955 void Document::clearFocusedElementSoon() |
| 1956 { | 1956 { |
| 1957 if (!m_clearFocusedElementTimer.isActive()) | 1957 if (!m_clearFocusedElementTimer.isActive()) |
| 1958 m_clearFocusedElementTimer.startOneShot(0, BLINK_FROM_HERE); | 1958 m_clearFocusedElementTimer.startOneShot(0, BLINK_FROM_HERE); |
| 1959 } | 1959 } |
| 1960 | 1960 |
| 1961 void Document::clearFocusedElementTimerFired(Timer<Document>*) | 1961 void Document::clearFocusedElementTimerFired(Timer<Document>*) |
| 1962 { | 1962 { |
| 1963 updateLayoutTree(); | 1963 updateStyleAndLayoutTree(); |
| 1964 m_clearFocusedElementTimer.stop(); | 1964 m_clearFocusedElementTimer.stop(); |
| 1965 | 1965 |
| 1966 if (m_focusedElement && !m_focusedElement->isFocusable()) | 1966 if (m_focusedElement && !m_focusedElement->isFocusable()) |
| 1967 m_focusedElement->blur(); | 1967 m_focusedElement->blur(); |
| 1968 } | 1968 } |
| 1969 | 1969 |
| 1970 // FIXME: This is a bad idea and needs to be removed eventually. | 1970 // FIXME: This is a bad idea and needs to be removed eventually. |
| 1971 // Other browsers load stylesheets before they continue parsing the web page. | 1971 // Other browsers load stylesheets before they continue parsing the web page. |
| 1972 // Since we don't, we can run JavaScript code that needs answers before the | 1972 // Since we don't, we can run JavaScript code that needs answers before the |
| 1973 // stylesheets are loaded. Doing a layout ignoring the pending stylesheets | 1973 // stylesheets are loaded. Doing a layout ignoring the pending stylesheets |
| 1974 // lets us get reasonable answers. The long term solution to this problem is | 1974 // lets us get reasonable answers. The long term solution to this problem is |
| 1975 // to instead suspend JavaScript execution. | 1975 // to instead suspend JavaScript execution. |
| 1976 void Document::updateLayoutTreeIgnorePendingStylesheets() | 1976 void Document::updateStyleAndLayoutTreeIgnorePendingStylesheets() |
| 1977 { | 1977 { |
| 1978 StyleEngine::IgnoringPendingStylesheet ignoring(styleEngine()); | 1978 StyleEngine::IgnoringPendingStylesheet ignoring(styleEngine()); |
| 1979 | 1979 |
| 1980 if (styleEngine().hasPendingScriptBlockingSheets()) { | 1980 if (styleEngine().hasPendingScriptBlockingSheets()) { |
| 1981 // FIXME: We are willing to attempt to suppress painting with outdated s
tyle info only once. | 1981 // FIXME: We are willing to attempt to suppress painting with outdated s
tyle info only once. |
| 1982 // Our assumption is that it would be dangerous to try to stop it a seco
nd time, after page | 1982 // Our assumption is that it would be dangerous to try to stop it a seco
nd time, after page |
| 1983 // content has already been loaded and displayed with accurate style inf
ormation. (Our | 1983 // content has already been loaded and displayed with accurate style inf
ormation. (Our |
| 1984 // suppression involves blanking the whole page at the moment. If it wer
e more refined, we | 1984 // suppression involves blanking the whole page at the moment. If it wer
e more refined, we |
| 1985 // might be able to do something better.) It's worth noting though that
this entire method | 1985 // might be able to do something better.) It's worth noting though that
this entire method |
| 1986 // is a hack, since what we really want to do is suspend JS instead of d
oing a layout with | 1986 // is a hack, since what we really want to do is suspend JS instead of d
oing a layout with |
| 1987 // inaccurate information. | 1987 // inaccurate information. |
| 1988 HTMLElement* bodyElement = body(); | 1988 HTMLElement* bodyElement = body(); |
| 1989 if (bodyElement && !bodyElement->layoutObject() && m_pendingSheetLayout
== NoLayoutWithPendingSheets) { | 1989 if (bodyElement && !bodyElement->layoutObject() && m_pendingSheetLayout
== NoLayoutWithPendingSheets) { |
| 1990 m_pendingSheetLayout = DidLayoutWithPendingSheets; | 1990 m_pendingSheetLayout = DidLayoutWithPendingSheets; |
| 1991 styleEngine().resolverChanged(FullStyleUpdate); | 1991 styleEngine().resolverChanged(FullStyleUpdate); |
| 1992 } else if (m_hasNodesWithPlaceholderStyle) { | 1992 } else if (m_hasNodesWithPlaceholderStyle) { |
| 1993 // If new nodes have been added or style recalc has been done with s
tyle sheets still | 1993 // If new nodes have been added or style recalc has been done with s
tyle sheets still |
| 1994 // pending, some nodes may not have had their real style calculated
yet. Normally this | 1994 // pending, some nodes may not have had their real style calculated
yet. Normally this |
| 1995 // gets cleaned when style sheets arrive but here we need up-to-date
style immediately. | 1995 // gets cleaned when style sheets arrive but here we need up-to-date
style immediately. |
| 1996 setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing:
:create(StyleChangeReason::CleanupPlaceholderStyles)); | 1996 setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing:
:create(StyleChangeReason::CleanupPlaceholderStyles)); |
| 1997 } | 1997 } |
| 1998 } | 1998 } |
| 1999 updateLayoutTree(); | 1999 updateStyleAndLayoutTree(); |
| 2000 } | 2000 } |
| 2001 | 2001 |
| 2002 void Document::updateLayoutIgnorePendingStylesheets(Document::RunPostLayoutTasks
runPostLayoutTasks) | 2002 void Document::updateStyleAndLayoutIgnorePendingStylesheets(Document::RunPostLay
outTasks runPostLayoutTasks) |
| 2003 { | 2003 { |
| 2004 updateLayoutTreeIgnorePendingStylesheets(); | 2004 updateStyleAndLayoutTreeIgnorePendingStylesheets(); |
| 2005 updateLayout(); | 2005 updateStyleAndLayout(); |
| 2006 | 2006 |
| 2007 if (runPostLayoutTasks == RunPostLayoutTasksSynchronously && view()) | 2007 if (runPostLayoutTasks == RunPostLayoutTasksSynchronously && view()) |
| 2008 view()->flushAnyPendingPostLayoutTasks(); | 2008 view()->flushAnyPendingPostLayoutTasks(); |
| 2009 } | 2009 } |
| 2010 | 2010 |
| 2011 PassRefPtr<ComputedStyle> Document::styleForElementIgnoringPendingStylesheets(El
ement* element) | 2011 PassRefPtr<ComputedStyle> Document::styleForElementIgnoringPendingStylesheets(El
ement* element) |
| 2012 { | 2012 { |
| 2013 DCHECK_EQ(element->document(), this); | 2013 DCHECK_EQ(element->document(), this); |
| 2014 StyleEngine::IgnoringPendingStylesheet ignoring(styleEngine()); | 2014 StyleEngine::IgnoringPendingStylesheet ignoring(styleEngine()); |
| 2015 return ensureStyleResolver().styleForElement(element, element->parentNode()
? element->parentNode()->ensureComputedStyle() : 0); | 2015 return ensureStyleResolver().styleForElement(element, element->parentNode()
? element->parentNode()->ensureComputedStyle() : 0); |
| (...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2658 // Just bail out. Before or during the onload we were shifted to another
page. | 2658 // Just bail out. Before or during the onload we were shifted to another
page. |
| 2659 // The old i-Bench suite does this. When this happens don't bother paint
ing or laying out. | 2659 // The old i-Bench suite does this. When this happens don't bother paint
ing or laying out. |
| 2660 m_loadEventProgress = LoadEventCompleted; | 2660 m_loadEventProgress = LoadEventCompleted; |
| 2661 return; | 2661 return; |
| 2662 } | 2662 } |
| 2663 | 2663 |
| 2664 // We used to force a synchronous display and flush here. This really isn't | 2664 // We used to force a synchronous display and flush here. This really isn't |
| 2665 // necessary and can in fact be actively harmful if pages are loading at a r
ate of > 60fps | 2665 // necessary and can in fact be actively harmful if pages are loading at a r
ate of > 60fps |
| 2666 // (if your platform is syncing flushes and limiting them to 60fps). | 2666 // (if your platform is syncing flushes and limiting them to 60fps). |
| 2667 if (!localOwner() || (localOwner()->layoutObject() && !localOwner()->layoutO
bject()->needsLayout())) { | 2667 if (!localOwner() || (localOwner()->layoutObject() && !localOwner()->layoutO
bject()->needsLayout())) { |
| 2668 updateLayoutTree(); | 2668 updateStyleAndLayoutTree(); |
| 2669 | 2669 |
| 2670 // Always do a layout after loading if needed. | 2670 // Always do a layout after loading if needed. |
| 2671 if (view() && layoutView() && (!layoutView()->firstChild() || layoutView
()->needsLayout())) | 2671 if (view() && layoutView() && (!layoutView()->firstChild() || layoutView
()->needsLayout())) |
| 2672 view()->layout(); | 2672 view()->layout(); |
| 2673 } | 2673 } |
| 2674 | 2674 |
| 2675 m_loadEventProgress = LoadEventCompleted; | 2675 m_loadEventProgress = LoadEventCompleted; |
| 2676 | 2676 |
| 2677 if (frame() && layoutView() && settings()->accessibilityEnabled()) { | 2677 if (frame() && layoutView() && settings()->accessibilityEnabled()) { |
| 2678 if (AXObjectCache* cache = axObjectCache()) { | 2678 if (AXObjectCache* cache = axObjectCache()) { |
| (...skipping 914 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3593 if (view()) { | 3593 if (view()) { |
| 3594 Widget* oldWidget = widgetForElement(*oldFocusedElement); | 3594 Widget* oldWidget = widgetForElement(*oldFocusedElement); |
| 3595 if (oldWidget) | 3595 if (oldWidget) |
| 3596 oldWidget->setFocus(false, params.type); | 3596 oldWidget->setFocus(false, params.type); |
| 3597 else | 3597 else |
| 3598 view()->setFocus(false, params.type); | 3598 view()->setFocus(false, params.type); |
| 3599 } | 3599 } |
| 3600 } | 3600 } |
| 3601 | 3601 |
| 3602 if (newFocusedElement) | 3602 if (newFocusedElement) |
| 3603 updateLayoutTreeForNode(newFocusedElement); | 3603 updateStyleAndLayoutTreeForNode(newFocusedElement); |
| 3604 if (newFocusedElement && newFocusedElement->isFocusable()) { | 3604 if (newFocusedElement && newFocusedElement->isFocusable()) { |
| 3605 if (newFocusedElement->isRootEditableElement() && !acceptsEditingFocus(*
newFocusedElement)) { | 3605 if (newFocusedElement->isRootEditableElement() && !acceptsEditingFocus(*
newFocusedElement)) { |
| 3606 // delegate blocks focus change | 3606 // delegate blocks focus change |
| 3607 focusChangeBlocked = true; | 3607 focusChangeBlocked = true; |
| 3608 goto SetFocusedElementDone; | 3608 goto SetFocusedElementDone; |
| 3609 } | 3609 } |
| 3610 // Set focus on the new node | 3610 // Set focus on the new node |
| 3611 m_focusedElement = newFocusedElement; | 3611 m_focusedElement = newFocusedElement; |
| 3612 setSequentialFocusNavigationStartingPoint(m_focusedElement.get()); | 3612 setSequentialFocusNavigationStartingPoint(m_focusedElement.get()); |
| 3613 | 3613 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3654 frame()->spellChecker().didBeginEditing(m_focusedElement.get()); | 3654 frame()->spellChecker().didBeginEditing(m_focusedElement.get()); |
| 3655 | 3655 |
| 3656 // eww, I suck. set the qt focus correctly | 3656 // eww, I suck. set the qt focus correctly |
| 3657 // ### find a better place in the code for this | 3657 // ### find a better place in the code for this |
| 3658 if (view()) { | 3658 if (view()) { |
| 3659 Widget* focusWidget = widgetForElement(*m_focusedElement); | 3659 Widget* focusWidget = widgetForElement(*m_focusedElement); |
| 3660 if (focusWidget) { | 3660 if (focusWidget) { |
| 3661 // Make sure a widget has the right size before giving it focus. | 3661 // Make sure a widget has the right size before giving it focus. |
| 3662 // Otherwise, we are testing edge cases of the Widget code. | 3662 // Otherwise, we are testing edge cases of the Widget code. |
| 3663 // Specifically, in WebCore this does not work well for text fie
lds. | 3663 // Specifically, in WebCore this does not work well for text fie
lds. |
| 3664 updateLayout(); | 3664 updateStyleAndLayout(); |
| 3665 // Re-get the widget in case updating the layout changed things. | 3665 // Re-get the widget in case updating the layout changed things. |
| 3666 focusWidget = widgetForElement(*m_focusedElement); | 3666 focusWidget = widgetForElement(*m_focusedElement); |
| 3667 } | 3667 } |
| 3668 if (focusWidget) | 3668 if (focusWidget) |
| 3669 focusWidget->setFocus(true, params.type); | 3669 focusWidget->setFocus(true, params.type); |
| 3670 else | 3670 else |
| 3671 view()->setFocus(true, params.type); | 3671 view()->setFocus(true, params.type); |
| 3672 } | 3672 } |
| 3673 } | 3673 } |
| 3674 | 3674 |
| 3675 if (!focusChangeBlocked && m_focusedElement) { | 3675 if (!focusChangeBlocked && m_focusedElement) { |
| 3676 // Create the AXObject cache in a focus change because Chromium relies o
n it. | 3676 // Create the AXObject cache in a focus change because Chromium relies o
n it. |
| 3677 if (AXObjectCache* cache = axObjectCache()) | 3677 if (AXObjectCache* cache = axObjectCache()) |
| 3678 cache->handleFocusedUIElementChanged(oldFocusedElement, newFocusedEl
ement); | 3678 cache->handleFocusedUIElementChanged(oldFocusedElement, newFocusedEl
ement); |
| 3679 } | 3679 } |
| 3680 | 3680 |
| 3681 if (!focusChangeBlocked && frameHost()) | 3681 if (!focusChangeBlocked && frameHost()) |
| 3682 frameHost()->chromeClient().focusedNodeChanged(oldFocusedElement, m_focu
sedElement.get()); | 3682 frameHost()->chromeClient().focusedNodeChanged(oldFocusedElement, m_focu
sedElement.get()); |
| 3683 | 3683 |
| 3684 SetFocusedElementDone: | 3684 SetFocusedElementDone: |
| 3685 updateLayoutTree(); | 3685 updateStyleAndLayoutTree(); |
| 3686 if (LocalFrame* frame = this->frame()) | 3686 if (LocalFrame* frame = this->frame()) |
| 3687 frame->selection().didChangeFocus(); | 3687 frame->selection().didChangeFocus(); |
| 3688 return !focusChangeBlocked; | 3688 return !focusChangeBlocked; |
| 3689 } | 3689 } |
| 3690 | 3690 |
| 3691 void Document::clearFocusedElement() | 3691 void Document::clearFocusedElement() |
| 3692 { | 3692 { |
| 3693 setFocusedElement(nullptr, FocusParams(SelectionBehaviorOnFocus::None, WebFo
cusTypeNone, nullptr)); | 3693 setFocusedElement(nullptr, FocusParams(SelectionBehaviorOnFocus::None, WebFo
cusTypeNone, nullptr)); |
| 3694 } | 3694 } |
| 3695 | 3695 |
| (...skipping 767 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4463 } | 4463 } |
| 4464 | 4464 |
| 4465 // Support for Javascript execCommand, and related methods | 4465 // Support for Javascript execCommand, and related methods |
| 4466 | 4466 |
| 4467 static Editor::Command command(Document* document, const String& commandName) | 4467 static Editor::Command command(Document* document, const String& commandName) |
| 4468 { | 4468 { |
| 4469 LocalFrame* frame = document->frame(); | 4469 LocalFrame* frame = document->frame(); |
| 4470 if (!frame || frame->document() != document) | 4470 if (!frame || frame->document() != document) |
| 4471 return Editor::Command(); | 4471 return Editor::Command(); |
| 4472 | 4472 |
| 4473 document->updateLayoutTree(); | 4473 document->updateStyleAndLayoutTree(); |
| 4474 return frame->editor().createCommand(commandName, CommandFromDOM); | 4474 return frame->editor().createCommand(commandName, CommandFromDOM); |
| 4475 } | 4475 } |
| 4476 | 4476 |
| 4477 bool Document::execCommand(const String& commandName, bool, const String& value,
ExceptionState& exceptionState) | 4477 bool Document::execCommand(const String& commandName, bool, const String& value,
ExceptionState& exceptionState) |
| 4478 { | 4478 { |
| 4479 if (!isHTMLDocument() && !isXHTMLDocument()) { | 4479 if (!isHTMLDocument() && !isXHTMLDocument()) { |
| 4480 exceptionState.throwDOMException(InvalidStateError, "execCommand is only
supported on HTML documents."); | 4480 exceptionState.throwDOMException(InvalidStateError, "execCommand is only
supported on HTML documents."); |
| 4481 return false; | 4481 return false; |
| 4482 } | 4482 } |
| 4483 if (focusedElement() && isHTMLTextFormControlElement(*focusedElement())) | 4483 if (focusedElement() && isHTMLTextFormControlElement(*focusedElement())) |
| (...skipping 303 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 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5124 void Document::cancelFocusAppearanceUpdate() | 5124 void Document::cancelFocusAppearanceUpdate() |
| 5125 { | 5125 { |
| 5126 m_updateFocusAppearanceTimer.stop(); | 5126 m_updateFocusAppearanceTimer.stop(); |
| 5127 } | 5127 } |
| 5128 | 5128 |
| 5129 void Document::updateFocusAppearanceTimerFired(Timer<Document>*) | 5129 void Document::updateFocusAppearanceTimerFired(Timer<Document>*) |
| 5130 { | 5130 { |
| 5131 Element* element = focusedElement(); | 5131 Element* element = focusedElement(); |
| 5132 if (!element) | 5132 if (!element) |
| 5133 return; | 5133 return; |
| 5134 updateLayout(); | 5134 updateStyleAndLayout(); |
| 5135 if (element->isFocusable()) | 5135 if (element->isFocusable()) |
| 5136 element->updateFocusAppearance(m_updateFocusAppearanceSelectionBahavior)
; | 5136 element->updateFocusAppearance(m_updateFocusAppearanceSelectionBahavior)
; |
| 5137 } | 5137 } |
| 5138 | 5138 |
| 5139 void Document::attachRange(Range* range) | 5139 void Document::attachRange(Range* range) |
| 5140 { | 5140 { |
| 5141 DCHECK(!m_ranges.contains(range)); | 5141 DCHECK(!m_ranges.contains(range)); |
| 5142 m_ranges.add(range); | 5142 m_ranges.add(range); |
| 5143 } | 5143 } |
| 5144 | 5144 |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5373 | 5373 |
| 5374 void Document::loadPluginsSoon() | 5374 void Document::loadPluginsSoon() |
| 5375 { | 5375 { |
| 5376 // FIXME: Remove this timer once we don't need to compute layout to load plu
gins. | 5376 // FIXME: Remove this timer once we don't need to compute layout to load plu
gins. |
| 5377 if (!m_pluginLoadingTimer.isActive()) | 5377 if (!m_pluginLoadingTimer.isActive()) |
| 5378 m_pluginLoadingTimer.startOneShot(0, BLINK_FROM_HERE); | 5378 m_pluginLoadingTimer.startOneShot(0, BLINK_FROM_HERE); |
| 5379 } | 5379 } |
| 5380 | 5380 |
| 5381 void Document::pluginLoadingTimerFired(Timer<Document>*) | 5381 void Document::pluginLoadingTimerFired(Timer<Document>*) |
| 5382 { | 5382 { |
| 5383 updateLayout(); | 5383 updateStyleAndLayout(); |
| 5384 } | 5384 } |
| 5385 | 5385 |
| 5386 ScriptedAnimationController& Document::ensureScriptedAnimationController() | 5386 ScriptedAnimationController& Document::ensureScriptedAnimationController() |
| 5387 { | 5387 { |
| 5388 if (!m_scriptedAnimationController) { | 5388 if (!m_scriptedAnimationController) { |
| 5389 m_scriptedAnimationController = ScriptedAnimationController::create(this
); | 5389 m_scriptedAnimationController = ScriptedAnimationController::create(this
); |
| 5390 // We need to make sure that we don't start up the animation controller
on a background tab, for example. | 5390 // We need to make sure that we don't start up the animation controller
on a background tab, for example. |
| 5391 if (!page()) | 5391 if (!page()) |
| 5392 m_scriptedAnimationController->suspend(); | 5392 m_scriptedAnimationController->suspend(); |
| 5393 } | 5393 } |
| (...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6016 #ifndef NDEBUG | 6016 #ifndef NDEBUG |
| 6017 using namespace blink; | 6017 using namespace blink; |
| 6018 void showLiveDocumentInstances() | 6018 void showLiveDocumentInstances() |
| 6019 { | 6019 { |
| 6020 Document::WeakDocumentSet& set = Document::liveDocumentSet(); | 6020 Document::WeakDocumentSet& set = Document::liveDocumentSet(); |
| 6021 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); | 6021 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); |
| 6022 for (Document* document : set) | 6022 for (Document* document : set) |
| 6023 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().get
String().utf8().data()); | 6023 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().get
String().utf8().data()); |
| 6024 } | 6024 } |
| 6025 #endif | 6025 #endif |
| OLD | NEW |