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 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
562 #if !ENABLE(OILPAN) | 562 #if !ENABLE(OILPAN) |
563 if (m_styleSheetList) | 563 if (m_styleSheetList) |
564 m_styleSheetList->detachFromDocument(); | 564 m_styleSheetList->detachFromDocument(); |
565 | 565 |
566 if (m_importsController) | 566 if (m_importsController) |
567 HTMLImportsController::removeFrom(*this); | 567 HTMLImportsController::removeFrom(*this); |
568 | 568 |
569 m_timeline->detachFromDocument(); | 569 m_timeline->detachFromDocument(); |
570 | 570 |
571 // We need to destroy CSSFontSelector before destroying m_fetcher. | 571 // We need to destroy CSSFontSelector before destroying m_fetcher. |
572 if (m_styleEngine) | 572 m_styleEngine->detachFromDocument(); |
573 m_styleEngine->detachFromDocument(); | |
574 | 573 |
575 if (m_elemSheet) | 574 if (m_elemSheet) |
576 m_elemSheet->clearOwnerNode(); | 575 m_elemSheet->clearOwnerNode(); |
577 | 576 |
578 // It's possible for multiple Documents to end up referencing the same Resou
rceFetcher (e.g., SVGImages | 577 // It's possible for multiple Documents to end up referencing the same Resou
rceFetcher (e.g., SVGImages |
579 // load the initial empty document and the SVGDocument with the same Documen
tLoader). | 578 // load the initial empty document and the SVGDocument with the same Documen
tLoader). |
580 FrameFetchContext& context = static_cast<FrameFetchContext&>(m_fetcher->cont
ext()); | 579 FrameFetchContext& context = static_cast<FrameFetchContext&>(m_fetcher->cont
ext()); |
581 if (context.document() == this) | 580 if (context.document() == this) |
582 context.setDocument(nullptr); | 581 context.setDocument(nullptr); |
583 m_fetcher.clear(); | 582 m_fetcher.clear(); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
660 MediaQueryMatcher& Document::mediaQueryMatcher() | 659 MediaQueryMatcher& Document::mediaQueryMatcher() |
661 { | 660 { |
662 if (!m_mediaQueryMatcher) | 661 if (!m_mediaQueryMatcher) |
663 m_mediaQueryMatcher = MediaQueryMatcher::create(*this); | 662 m_mediaQueryMatcher = MediaQueryMatcher::create(*this); |
664 return *m_mediaQueryMatcher; | 663 return *m_mediaQueryMatcher; |
665 } | 664 } |
666 | 665 |
667 void Document::mediaQueryAffectingValueChanged() | 666 void Document::mediaQueryAffectingValueChanged() |
668 { | 667 { |
669 m_evaluateMediaQueriesOnStyleRecalc = true; | 668 m_evaluateMediaQueriesOnStyleRecalc = true; |
670 styleEngine()->clearMediaQueryRuleSetStyleSheets(); | 669 styleEngine().clearMediaQueryRuleSetStyleSheets(); |
671 InspectorInstrumentation::mediaQueryResultChanged(this); | 670 InspectorInstrumentation::mediaQueryResultChanged(this); |
672 } | 671 } |
673 | 672 |
674 void Document::setCompatibilityMode(CompatibilityMode mode) | 673 void Document::setCompatibilityMode(CompatibilityMode mode) |
675 { | 674 { |
676 if (m_compatibilityModeLocked || mode == m_compatibilityMode) | 675 if (m_compatibilityModeLocked || mode == m_compatibilityMode) |
677 return; | 676 return; |
678 bool wasInQuirksMode = inQuirksMode(); | 677 bool wasInQuirksMode = inQuirksMode(); |
679 m_compatibilityMode = mode; | 678 m_compatibilityMode = mode; |
680 selectorQueryCache().invalidate(); | 679 selectorQueryCache().invalidate(); |
(...skipping 12 matching lines...) Expand all Loading... |
693 { | 692 { |
694 // This should never be called more than once. | 693 // This should never be called more than once. |
695 ASSERT(!m_docType || !docType); | 694 ASSERT(!m_docType || !docType); |
696 m_docType = docType; | 695 m_docType = docType; |
697 if (m_docType) { | 696 if (m_docType) { |
698 this->adoptIfNeeded(*m_docType); | 697 this->adoptIfNeeded(*m_docType); |
699 if (m_docType->publicId().startsWith("-//wapforum//dtd xhtml mobile 1.",
/* caseSensitive */ false)) | 698 if (m_docType->publicId().startsWith("-//wapforum//dtd xhtml mobile 1.",
/* caseSensitive */ false)) |
700 m_isMobileDocument = true; | 699 m_isMobileDocument = true; |
701 } | 700 } |
702 // Doctype affects the interpretation of the stylesheets. | 701 // Doctype affects the interpretation of the stylesheets. |
703 clearStyleResolver(); | 702 styleEngine().clearResolver(); |
704 } | 703 } |
705 | 704 |
706 DOMImplementation& Document::implementation() | 705 DOMImplementation& Document::implementation() |
707 { | 706 { |
708 if (!m_implementation) | 707 if (!m_implementation) |
709 m_implementation = DOMImplementation::create(*this); | 708 m_implementation = DOMImplementation::create(*this); |
710 return *m_implementation; | 709 return *m_implementation; |
711 } | 710 } |
712 | 711 |
713 bool Document::hasAppCacheManifest() const | 712 bool Document::hasAppCacheManifest() const |
(...skipping 882 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1596 return; | 1595 return; |
1597 TRACE_EVENT0("blink", "Document::updateStyleInvalidationIfNeeded"); | 1596 TRACE_EVENT0("blink", "Document::updateStyleInvalidationIfNeeded"); |
1598 ASSERT(styleResolver()); | 1597 ASSERT(styleResolver()); |
1599 | 1598 |
1600 styleResolver()->ruleFeatureSet().styleInvalidator().invalidate(*this); | 1599 styleResolver()->ruleFeatureSet().styleInvalidator().invalidate(*this); |
1601 } | 1600 } |
1602 | 1601 |
1603 void Document::setupFontBuilder(LayoutStyle& documentStyle) | 1602 void Document::setupFontBuilder(LayoutStyle& documentStyle) |
1604 { | 1603 { |
1605 FontBuilder fontBuilder(*this); | 1604 FontBuilder fontBuilder(*this); |
1606 RefPtrWillBeRawPtr<CSSFontSelector> selector = m_styleEngine->fontSelector()
; | 1605 RefPtrWillBeRawPtr<CSSFontSelector> selector = styleEngine().fontSelector(); |
1607 fontBuilder.createFontForDocument(selector, documentStyle); | 1606 fontBuilder.createFontForDocument(selector, documentStyle); |
1608 } | 1607 } |
1609 | 1608 |
1610 void Document::inheritHtmlAndBodyElementStyles(StyleRecalcChange change) | 1609 void Document::inheritHtmlAndBodyElementStyles(StyleRecalcChange change) |
1611 { | 1610 { |
1612 ASSERT(inStyleRecalc()); | 1611 ASSERT(inStyleRecalc()); |
1613 ASSERT(documentElement()); | 1612 ASSERT(documentElement()); |
1614 | 1613 |
1615 RefPtr<LayoutStyle> documentElementStyle = documentElement()->layoutStyle(); | 1614 RefPtr<LayoutStyle> documentElementStyle = documentElement()->layoutStyle(); |
1616 if (!documentElementStyle || documentElement()->needsStyleRecalc() || change
== Force) | 1615 if (!documentElementStyle || documentElement()->needsStyleRecalc() || change
== Force) |
(...skipping 22 matching lines...) Expand all Loading... |
1639 } | 1638 } |
1640 } | 1639 } |
1641 | 1640 |
1642 // Resolved rem units are stored in the matched properties cache so we need
to make sure to | 1641 // Resolved rem units are stored in the matched properties cache so we need
to make sure to |
1643 // invalidate the cache if the documentElement needed to reattach or the fon
t size changed | 1642 // invalidate the cache if the documentElement needed to reattach or the fon
t size changed |
1644 // and then trigger a full document recalc. We also need to clear it here si
nce the | 1643 // and then trigger a full document recalc. We also need to clear it here si
nce the |
1645 // call to styleForElement on the body above can cache bad values for rem un
its if the | 1644 // call to styleForElement on the body above can cache bad values for rem un
its if the |
1646 // documentElement's style was dirty. We could keep track of which elements
depend on | 1645 // documentElement's style was dirty. We could keep track of which elements
depend on |
1647 // rem units like we do for viewport styles, but we assume root font size ch
anges are | 1646 // rem units like we do for viewport styles, but we assume root font size ch
anges are |
1648 // rare and just invalidate the cache for now. | 1647 // rare and just invalidate the cache for now. |
1649 if (styleEngine()->usesRemUnits() && (documentElement()->needsAttach() || do
cumentElement()->computedStyle()->fontSize() != documentElementStyle->fontSize()
)) { | 1648 if (styleEngine().usesRemUnits() && (documentElement()->needsAttach() || doc
umentElement()->computedStyle()->fontSize() != documentElementStyle->fontSize())
) { |
1650 ensureStyleResolver().invalidateMatchedPropertiesCache(); | 1649 ensureStyleResolver().invalidateMatchedPropertiesCache(); |
1651 documentElement()->setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeRe
asonForTracing::create(StyleChangeReason::FontSizeChange)); | 1650 documentElement()->setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeRe
asonForTracing::create(StyleChangeReason::FontSizeChange)); |
1652 } | 1651 } |
1653 | 1652 |
1654 EOverflow overflowX = OAUTO; | 1653 EOverflow overflowX = OAUTO; |
1655 EOverflow overflowY = OAUTO; | 1654 EOverflow overflowY = OAUTO; |
1656 float columnGap = 0; | 1655 float columnGap = 0; |
1657 if (overflowStyle) { | 1656 if (overflowStyle) { |
1658 overflowX = overflowStyle->overflowX(); | 1657 overflowX = overflowStyle->overflowX(); |
1659 overflowY = overflowStyle->overflowY(); | 1658 overflowY = overflowStyle->overflowY(); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1741 updateStyleInvalidationIfNeeded(); | 1740 updateStyleInvalidationIfNeeded(); |
1742 | 1741 |
1743 // FIXME: We should update style on our ancestor chain before proceeding | 1742 // FIXME: We should update style on our ancestor chain before proceeding |
1744 // however doing so currently causes several tests to crash, as LocalFrame::
setDocument calls Document::attach | 1743 // however doing so currently causes several tests to crash, as LocalFrame::
setDocument calls Document::attach |
1745 // before setting the LocalDOMWindow on the LocalFrame, or the SecurityOrigi
n on the document. The attach, in turn | 1744 // before setting the LocalDOMWindow on the LocalFrame, or the SecurityOrigi
n on the document. The attach, in turn |
1746 // resolves style (here) and then when we resolve style on the parent chain,
we may end up | 1745 // resolves style (here) and then when we resolve style on the parent chain,
we may end up |
1747 // re-attaching our containing iframe, which when asked HTMLFrameElementBase
::isURLAllowed | 1746 // re-attaching our containing iframe, which when asked HTMLFrameElementBase
::isURLAllowed |
1748 // hits a null-dereference due to security code always assuming the document
has a SecurityOrigin. | 1747 // hits a null-dereference due to security code always assuming the document
has a SecurityOrigin. |
1749 | 1748 |
1750 if (m_elemSheet && m_elemSheet->contents()->usesRemUnits()) | 1749 if (m_elemSheet && m_elemSheet->contents()->usesRemUnits()) |
1751 m_styleEngine->setUsesRemUnit(true); | 1750 styleEngine().setUsesRemUnit(true); |
1752 | 1751 |
1753 updateStyle(change); | 1752 updateStyle(change); |
1754 | 1753 |
1755 // As a result of the style recalculation, the currently hovered element mig
ht have been | 1754 // As a result of the style recalculation, the currently hovered element mig
ht have been |
1756 // detached (for example, by setting display:none in the :hover style), sche
dule another mouseMove event | 1755 // detached (for example, by setting display:none in the :hover style), sche
dule another mouseMove event |
1757 // to check if any other elements ended up under the mouse pointer due to re
-layout. | 1756 // to check if any other elements ended up under the mouse pointer due to re
-layout. |
1758 if (hoverNode() && !hoverNode()->renderer() && frame()) | 1757 if (hoverNode() && !hoverNode()->renderer() && frame()) |
1759 frame()->eventHandler().dispatchFakeMouseMoveEventSoon(); | 1758 frame()->eventHandler().dispatchFakeMouseMoveEventSoon(); |
1760 | 1759 |
1761 if (m_focusedElement && !m_focusedElement->isFocusable()) | 1760 if (m_focusedElement && !m_focusedElement->isFocusable()) |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1810 while (dirtyElementsForLayerUpdate()) | 1809 while (dirtyElementsForLayerUpdate()) |
1811 documentElement->recalcStyle(NoChange); | 1810 documentElement->recalcStyle(NoChange); |
1812 } | 1811 } |
1813 | 1812 |
1814 ensureStyleResolver().printStats(); | 1813 ensureStyleResolver().printStats(); |
1815 | 1814 |
1816 view()->recalcOverflowAfterStyleChange(); | 1815 view()->recalcOverflowAfterStyleChange(); |
1817 | 1816 |
1818 clearChildNeedsStyleRecalc(); | 1817 clearChildNeedsStyleRecalc(); |
1819 | 1818 |
1820 if (m_styleEngine->hasResolver()) { | 1819 if (styleEngine().hasResolver()) { |
1821 // Pseudo element removal and similar may only work with these flags sti
ll set. Reset them after the style recalc. | 1820 // Pseudo element removal and similar may only work with these flags sti
ll set. Reset them after the style recalc. |
1822 StyleResolver& resolver = m_styleEngine->ensureResolver(); | 1821 StyleResolver& resolver = styleEngine().ensureResolver(); |
1823 m_styleEngine->resetCSSFeatureFlags(resolver.ensureUpdatedRuleFeatureSet
()); | 1822 styleEngine().resetCSSFeatureFlags(resolver.ensureUpdatedRuleFeatureSet(
)); |
1824 resolver.clearStyleSharingList(); | 1823 resolver.clearStyleSharingList(); |
1825 } | 1824 } |
1826 | 1825 |
1827 ASSERT(!needsStyleRecalc()); | 1826 ASSERT(!needsStyleRecalc()); |
1828 ASSERT(!childNeedsStyleRecalc()); | 1827 ASSERT(!childNeedsStyleRecalc()); |
1829 ASSERT(inStyleRecalc()); | 1828 ASSERT(inStyleRecalc()); |
1830 m_lifecycle.advanceTo(DocumentLifecycle::StyleClean); | 1829 m_lifecycle.advanceTo(DocumentLifecycle::StyleClean); |
1831 } | 1830 } |
1832 | 1831 |
1833 void Document::updateRenderTreeForNodeIfNeeded(Node* node) | 1832 void Document::updateRenderTreeForNodeIfNeeded(Node* node) |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1898 } | 1897 } |
1899 | 1898 |
1900 // FIXME: This is a bad idea and needs to be removed eventually. | 1899 // FIXME: This is a bad idea and needs to be removed eventually. |
1901 // Other browsers load stylesheets before they continue parsing the web page. | 1900 // Other browsers load stylesheets before they continue parsing the web page. |
1902 // Since we don't, we can run JavaScript code that needs answers before the | 1901 // Since we don't, we can run JavaScript code that needs answers before the |
1903 // stylesheets are loaded. Doing a layout ignoring the pending stylesheets | 1902 // stylesheets are loaded. Doing a layout ignoring the pending stylesheets |
1904 // lets us get reasonable answers. The long term solution to this problem is | 1903 // lets us get reasonable answers. The long term solution to this problem is |
1905 // to instead suspend JavaScript execution. | 1904 // to instead suspend JavaScript execution. |
1906 void Document::updateLayoutIgnorePendingStylesheets(Document::RunPostLayoutTasks
runPostLayoutTasks) | 1905 void Document::updateLayoutIgnorePendingStylesheets(Document::RunPostLayoutTasks
runPostLayoutTasks) |
1907 { | 1906 { |
1908 StyleEngine::IgnoringPendingStylesheet ignoring(m_styleEngine.get()); | 1907 StyleEngine::IgnoringPendingStylesheet ignoring(styleEngine()); |
1909 | 1908 |
1910 if (m_styleEngine->hasPendingSheets()) { | 1909 if (styleEngine().hasPendingSheets()) { |
1911 // FIXME: We are willing to attempt to suppress painting with outdated s
tyle info only once. | 1910 // FIXME: We are willing to attempt to suppress painting with outdated s
tyle info only once. |
1912 // Our assumption is that it would be dangerous to try to stop it a seco
nd time, after page | 1911 // Our assumption is that it would be dangerous to try to stop it a seco
nd time, after page |
1913 // content has already been loaded and displayed with accurate style inf
ormation. (Our | 1912 // content has already been loaded and displayed with accurate style inf
ormation. (Our |
1914 // suppression involves blanking the whole page at the moment. If it wer
e more refined, we | 1913 // suppression involves blanking the whole page at the moment. If it wer
e more refined, we |
1915 // might be able to do something better.) It's worth noting though that
this entire method | 1914 // might be able to do something better.) It's worth noting though that
this entire method |
1916 // is a hack, since what we really want to do is suspend JS instead of d
oing a layout with | 1915 // is a hack, since what we really want to do is suspend JS instead of d
oing a layout with |
1917 // inaccurate information. | 1916 // inaccurate information. |
1918 HTMLElement* bodyElement = body(); | 1917 HTMLElement* bodyElement = body(); |
1919 if (bodyElement && !bodyElement->renderer() && m_pendingSheetLayout == N
oLayoutWithPendingSheets) { | 1918 if (bodyElement && !bodyElement->renderer() && m_pendingSheetLayout == N
oLayoutWithPendingSheets) { |
1920 m_pendingSheetLayout = DidLayoutWithPendingSheets; | 1919 m_pendingSheetLayout = DidLayoutWithPendingSheets; |
1921 styleResolverChanged(); | 1920 styleResolverChanged(); |
1922 } else if (m_hasNodesWithPlaceholderStyle) { | 1921 } else if (m_hasNodesWithPlaceholderStyle) { |
1923 // If new nodes have been added or style recalc has been done with s
tyle sheets still | 1922 // If new nodes have been added or style recalc has been done with s
tyle sheets still |
1924 // pending, some nodes may not have had their real style calculated
yet. Normally this | 1923 // pending, some nodes may not have had their real style calculated
yet. Normally this |
1925 // gets cleaned when style sheets arrive but here we need up-to-date
style immediately. | 1924 // gets cleaned when style sheets arrive but here we need up-to-date
style immediately. |
1926 updateRenderTree(Force); | 1925 updateRenderTree(Force); |
1927 } | 1926 } |
1928 } | 1927 } |
1929 | 1928 |
1930 updateLayout(); | 1929 updateLayout(); |
1931 | 1930 |
1932 if (runPostLayoutTasks == RunPostLayoutTasksSynchronously && view()) | 1931 if (runPostLayoutTasks == RunPostLayoutTasksSynchronously && view()) |
1933 view()->flushAnyPendingPostLayoutTasks(); | 1932 view()->flushAnyPendingPostLayoutTasks(); |
1934 } | 1933 } |
1935 | 1934 |
1936 PassRefPtr<LayoutStyle> Document::styleForElementIgnoringPendingStylesheets(Elem
ent* element) | 1935 PassRefPtr<LayoutStyle> Document::styleForElementIgnoringPendingStylesheets(Elem
ent* element) |
1937 { | 1936 { |
1938 ASSERT_ARG(element, element->document() == this); | 1937 ASSERT_ARG(element, element->document() == this); |
1939 StyleEngine::IgnoringPendingStylesheet ignoring(m_styleEngine.get()); | 1938 StyleEngine::IgnoringPendingStylesheet ignoring(styleEngine()); |
1940 return ensureStyleResolver().styleForElement(element, element->parentNode()
? element->parentNode()->computedStyle() : 0); | 1939 return ensureStyleResolver().styleForElement(element, element->parentNode()
? element->parentNode()->computedStyle() : 0); |
1941 } | 1940 } |
1942 | 1941 |
1943 PassRefPtr<LayoutStyle> Document::styleForPage(int pageIndex) | 1942 PassRefPtr<LayoutStyle> Document::styleForPage(int pageIndex) |
1944 { | 1943 { |
1945 updateDistribution(); | 1944 updateDistribution(); |
1946 return ensureStyleResolver().styleForPage(pageIndex); | 1945 return ensureStyleResolver().styleForPage(pageIndex); |
1947 } | 1946 } |
1948 | 1947 |
1949 bool Document::isPageBoxVisible(int pageIndex) | 1948 bool Document::isPageBoxVisible(int pageIndex) |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2054 StyleResolver* Document::styleResolver() const | 2053 StyleResolver* Document::styleResolver() const |
2055 { | 2054 { |
2056 return m_styleEngine->resolver(); | 2055 return m_styleEngine->resolver(); |
2057 } | 2056 } |
2058 | 2057 |
2059 StyleResolver& Document::ensureStyleResolver() const | 2058 StyleResolver& Document::ensureStyleResolver() const |
2060 { | 2059 { |
2061 return m_styleEngine->ensureResolver(); | 2060 return m_styleEngine->ensureResolver(); |
2062 } | 2061 } |
2063 | 2062 |
2064 void Document::clearStyleResolver() | |
2065 { | |
2066 m_styleEngine->clearResolver(); | |
2067 } | |
2068 | |
2069 void Document::attach(const AttachContext& context) | 2063 void Document::attach(const AttachContext& context) |
2070 { | 2064 { |
2071 ASSERT(m_lifecycle.state() == DocumentLifecycle::Inactive); | 2065 ASSERT(m_lifecycle.state() == DocumentLifecycle::Inactive); |
2072 ASSERT(!m_axObjectCache || this != &axObjectCacheOwner()); | 2066 ASSERT(!m_axObjectCache || this != &axObjectCacheOwner()); |
2073 | 2067 |
2074 m_layoutView = new LayoutView(this); | 2068 m_layoutView = new LayoutView(this); |
2075 setRenderer(m_layoutView); | 2069 setRenderer(m_layoutView); |
2076 | 2070 |
2077 m_layoutView->setIsInWindow(true); | 2071 m_layoutView->setIsInWindow(true); |
2078 m_layoutView->setStyle(StyleResolver::styleForDocument(*this)); | 2072 m_layoutView->setStyle(StyleResolver::styleForDocument(*this)); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2136 RefPtrWillBeRawPtr<Element> oldFocusedElement = m_focusedElement; | 2130 RefPtrWillBeRawPtr<Element> oldFocusedElement = m_focusedElement; |
2137 m_focusedElement = nullptr; | 2131 m_focusedElement = nullptr; |
2138 if (frameHost()) | 2132 if (frameHost()) |
2139 frameHost()->chrome().focusedNodeChanged(oldFocusedElement.get(), nu
llptr); | 2133 frameHost()->chrome().focusedNodeChanged(oldFocusedElement.get(), nu
llptr); |
2140 | 2134 |
2141 } | 2135 } |
2142 | 2136 |
2143 m_layoutView = 0; | 2137 m_layoutView = 0; |
2144 ContainerNode::detach(context); | 2138 ContainerNode::detach(context); |
2145 | 2139 |
2146 m_styleEngine->didDetach(); | 2140 styleEngine().didDetach(); |
2147 | 2141 |
2148 frameHost()->eventHandlerRegistry().documentDetached(*this); | 2142 frameHost()->eventHandlerRegistry().documentDetached(*this); |
2149 | 2143 |
2150 // This is required, as our LocalFrame might delete itself as soon as it det
aches | 2144 // This is required, as our LocalFrame might delete itself as soon as it det
aches |
2151 // us. However, this violates Node::detach() semantics, as it's never | 2145 // us. However, this violates Node::detach() semantics, as it's never |
2152 // possible to re-attach. Eventually Document::detach() should be renamed, | 2146 // possible to re-attach. Eventually Document::detach() should be renamed, |
2153 // or this setting of the frame to 0 could be made explicit in each of the | 2147 // or this setting of the frame to 0 could be made explicit in each of the |
2154 // callers of Document::detach(). | 2148 // callers of Document::detach(). |
2155 m_frame = nullptr; | 2149 m_frame = nullptr; |
2156 | 2150 |
(...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2933 } | 2927 } |
2934 | 2928 |
2935 void Document::processHttpEquivDefaultStyle(const AtomicString& content) | 2929 void Document::processHttpEquivDefaultStyle(const AtomicString& content) |
2936 { | 2930 { |
2937 // The preferred style set has been overridden as per section | 2931 // The preferred style set has been overridden as per section |
2938 // 14.3.2 of the HTML4.0 specification. We need to update the | 2932 // 14.3.2 of the HTML4.0 specification. We need to update the |
2939 // sheet used variable and then update our style selector. | 2933 // sheet used variable and then update our style selector. |
2940 // For more info, see the test at: | 2934 // For more info, see the test at: |
2941 // http://www.hixie.ch/tests/evil/css/import/main/preferred.html | 2935 // http://www.hixie.ch/tests/evil/css/import/main/preferred.html |
2942 // -dwh | 2936 // -dwh |
2943 m_styleEngine->setSelectedStylesheetSetName(content); | 2937 styleEngine().setSelectedStylesheetSetName(content); |
2944 m_styleEngine->setPreferredStylesheetSetName(content); | 2938 styleEngine().setPreferredStylesheetSetName(content); |
2945 styleResolverChanged(); | 2939 styleResolverChanged(); |
2946 } | 2940 } |
2947 | 2941 |
2948 void Document::processHttpEquivRefresh(const AtomicString& content) | 2942 void Document::processHttpEquivRefresh(const AtomicString& content) |
2949 { | 2943 { |
2950 maybeHandleHttpRefresh(content, HttpRefreshFromMetaTag); | 2944 maybeHandleHttpRefresh(content, HttpRefreshFromMetaTag); |
2951 } | 2945 } |
2952 | 2946 |
2953 void Document::maybeHandleHttpRefresh(const String& content, HttpRefreshType htt
pRefreshType) | 2947 void Document::maybeHandleHttpRefresh(const String& content, HttpRefreshType htt
pRefreshType) |
2954 { | 2948 { |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3272 return m_styleEngine->preferredStylesheetSetName(); | 3266 return m_styleEngine->preferredStylesheetSetName(); |
3273 } | 3267 } |
3274 | 3268 |
3275 String Document::selectedStylesheetSet() const | 3269 String Document::selectedStylesheetSet() const |
3276 { | 3270 { |
3277 return m_styleEngine->selectedStylesheetSetName(); | 3271 return m_styleEngine->selectedStylesheetSetName(); |
3278 } | 3272 } |
3279 | 3273 |
3280 void Document::setSelectedStylesheetSet(const String& aString) | 3274 void Document::setSelectedStylesheetSet(const String& aString) |
3281 { | 3275 { |
3282 m_styleEngine->setSelectedStylesheetSetName(aString); | 3276 styleEngine().setSelectedStylesheetSetName(aString); |
3283 styleResolverChanged(); | 3277 styleResolverChanged(); |
3284 } | 3278 } |
3285 | 3279 |
3286 void Document::evaluateMediaQueryListIfNeeded() | 3280 void Document::evaluateMediaQueryListIfNeeded() |
3287 { | 3281 { |
3288 if (!m_evaluateMediaQueriesOnStyleRecalc) | 3282 if (!m_evaluateMediaQueriesOnStyleRecalc) |
3289 return; | 3283 return; |
3290 evaluateMediaQueryList(); | 3284 evaluateMediaQueryList(); |
3291 m_evaluateMediaQueriesOnStyleRecalc = false; | 3285 m_evaluateMediaQueriesOnStyleRecalc = false; |
3292 } | 3286 } |
3293 | 3287 |
3294 void Document::evaluateMediaQueryList() | 3288 void Document::evaluateMediaQueryList() |
3295 { | 3289 { |
3296 if (m_mediaQueryMatcher) | 3290 if (m_mediaQueryMatcher) |
3297 m_mediaQueryMatcher->mediaFeaturesChanged(); | 3291 m_mediaQueryMatcher->mediaFeaturesChanged(); |
3298 } | 3292 } |
3299 | 3293 |
3300 void Document::notifyResizeForViewportUnits() | 3294 void Document::notifyResizeForViewportUnits() |
3301 { | 3295 { |
3302 if (m_mediaQueryMatcher) | 3296 if (m_mediaQueryMatcher) |
3303 m_mediaQueryMatcher->viewportChanged(); | 3297 m_mediaQueryMatcher->viewportChanged(); |
3304 if (!hasViewportUnits()) | 3298 if (!hasViewportUnits()) |
3305 return; | 3299 return; |
3306 ensureStyleResolver().notifyResizeForViewportUnits(); | 3300 ensureStyleResolver().notifyResizeForViewportUnits(); |
3307 setNeedsStyleRecalcForViewportUnits(); | 3301 setNeedsStyleRecalcForViewportUnits(); |
3308 } | 3302 } |
3309 | 3303 |
3310 void Document::styleResolverChanged(StyleResolverUpdateMode updateMode) | 3304 void Document::styleResolverChanged(StyleResolverUpdateMode updateMode) |
3311 { | 3305 { |
3312 // styleResolverChanged() can be invoked during Document destruction. | 3306 styleEngine().resolverChanged(updateMode); |
3313 // We just skip that case. | |
3314 if (!m_styleEngine) | |
3315 return; | |
3316 | 3307 |
3317 m_styleEngine->resolverChanged(updateMode); | 3308 if (didLayoutWithPendingStylesheets() && !styleEngine().hasPendingSheets())
{ |
3318 | |
3319 if (didLayoutWithPendingStylesheets() && !m_styleEngine->hasPendingSheets())
{ | |
3320 // We need to manually repaint because we avoid doing all repaints in la
yout or style | 3309 // We need to manually repaint because we avoid doing all repaints in la
yout or style |
3321 // recalc while sheets are still loading to avoid FOUC. | 3310 // recalc while sheets are still loading to avoid FOUC. |
3322 m_pendingSheetLayout = IgnoreLayoutWithPendingSheets; | 3311 m_pendingSheetLayout = IgnoreLayoutWithPendingSheets; |
3323 | 3312 |
3324 ASSERT(layoutView() || importsController()); | 3313 ASSERT(layoutView() || importsController()); |
3325 if (layoutView()) | 3314 if (layoutView()) |
3326 layoutView()->invalidatePaintForViewAndCompositedLayers(); | 3315 layoutView()->invalidatePaintForViewAndCompositedLayers(); |
3327 } | 3316 } |
3328 } | 3317 } |
3329 | 3318 |
(...skipping 2098 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5428 { | 5417 { |
5429 return m_frame ? m_frame->devicePixelRatio() : 1.0; | 5418 return m_frame ? m_frame->devicePixelRatio() : 1.0; |
5430 } | 5419 } |
5431 | 5420 |
5432 void Document::removedStyleSheet(StyleSheet* sheet, StyleResolverUpdateMode upda
teMode) | 5421 void Document::removedStyleSheet(StyleSheet* sheet, StyleResolverUpdateMode upda
teMode) |
5433 { | 5422 { |
5434 // If we're in document teardown, then we don't need this notification of ou
r sheet's removal. | 5423 // If we're in document teardown, then we don't need this notification of ou
r sheet's removal. |
5435 // styleResolverChanged() is needed even when the document is inactive so th
at | 5424 // styleResolverChanged() is needed even when the document is inactive so th
at |
5436 // imported docuements (which is inactive) notifies the change to the master
document. | 5425 // imported docuements (which is inactive) notifies the change to the master
document. |
5437 if (isActive()) | 5426 if (isActive()) |
5438 styleEngine()->modifiedStyleSheet(sheet); | 5427 styleEngine().modifiedStyleSheet(sheet); |
5439 styleResolverChanged(updateMode); | 5428 styleResolverChanged(updateMode); |
5440 } | 5429 } |
5441 | 5430 |
5442 void Document::modifiedStyleSheet(StyleSheet* sheet, StyleResolverUpdateMode upd
ateMode) | 5431 void Document::modifiedStyleSheet(StyleSheet* sheet, StyleResolverUpdateMode upd
ateMode) |
5443 { | 5432 { |
5444 // If we're in document teardown, then we don't need this notification of ou
r sheet's removal. | 5433 // If we're in document teardown, then we don't need this notification of ou
r sheet's removal. |
5445 // styleResolverChanged() is needed even when the document is inactive so th
at | 5434 // styleResolverChanged() is needed even when the document is inactive so th
at |
5446 // imported docuements (which is inactive) notifies the change to the master
document. | 5435 // imported docuements (which is inactive) notifies the change to the master
document. |
5447 if (isActive()) | 5436 if (isActive()) |
5448 styleEngine()->modifiedStyleSheet(sheet); | 5437 styleEngine().modifiedStyleSheet(sheet); |
5449 styleResolverChanged(updateMode); | 5438 styleResolverChanged(updateMode); |
5450 } | 5439 } |
5451 | 5440 |
5452 TextAutosizer* Document::textAutosizer() | 5441 TextAutosizer* Document::textAutosizer() |
5453 { | 5442 { |
5454 if (!m_textAutosizer) | 5443 if (!m_textAutosizer) |
5455 m_textAutosizer = TextAutosizer::create(this); | 5444 m_textAutosizer = TextAutosizer::create(this); |
5456 return m_textAutosizer.get(); | 5445 return m_textAutosizer.get(); |
5457 } | 5446 } |
5458 | 5447 |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5617 { | 5606 { |
5618 for (const LiveNodeListBase* list : m_listsInvalidatedAtDocument) | 5607 for (const LiveNodeListBase* list : m_listsInvalidatedAtDocument) |
5619 list->invalidateCacheForAttribute(attrName); | 5608 list->invalidateCacheForAttribute(attrName); |
5620 } | 5609 } |
5621 | 5610 |
5622 void Document::platformColorsChanged() | 5611 void Document::platformColorsChanged() |
5623 { | 5612 { |
5624 if (!isActive()) | 5613 if (!isActive()) |
5625 return; | 5614 return; |
5626 | 5615 |
5627 styleEngine()->platformColorsChanged(); | 5616 styleEngine().platformColorsChanged(); |
5628 } | 5617 } |
5629 | 5618 |
5630 void Document::clearWeakMembers(Visitor* visitor) | 5619 void Document::clearWeakMembers(Visitor* visitor) |
5631 { | 5620 { |
5632 if (m_axObjectCache) | 5621 if (m_axObjectCache) |
5633 m_axObjectCache->clearWeakMembers(visitor); | 5622 m_axObjectCache->clearWeakMembers(visitor); |
5634 } | 5623 } |
5635 | 5624 |
5636 v8::Handle<v8::Object> Document::wrap(v8::Handle<v8::Object> creationContext, v8
::Isolate* isolate) | 5625 v8::Handle<v8::Object> Document::wrap(v8::Handle<v8::Object> creationContext, v8
::Isolate* isolate) |
5637 { | 5626 { |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5733 #ifndef NDEBUG | 5722 #ifndef NDEBUG |
5734 using namespace blink; | 5723 using namespace blink; |
5735 void showLiveDocumentInstances() | 5724 void showLiveDocumentInstances() |
5736 { | 5725 { |
5737 WeakDocumentSet& set = liveDocumentSet(); | 5726 WeakDocumentSet& set = liveDocumentSet(); |
5738 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); | 5727 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); |
5739 for (Document* document : set) | 5728 for (Document* document : set) |
5740 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str
ing().utf8().data()); | 5729 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str
ing().utf8().data()); |
5741 } | 5730 } |
5742 #endif | 5731 #endif |
OLD | NEW |