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 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
609 { | 609 { |
610 if (!m_selectorQueryCache) | 610 if (!m_selectorQueryCache) |
611 m_selectorQueryCache = adoptPtr(new SelectorQueryCache()); | 611 m_selectorQueryCache = adoptPtr(new SelectorQueryCache()); |
612 return *m_selectorQueryCache; | 612 return *m_selectorQueryCache; |
613 } | 613 } |
614 | 614 |
615 MediaQueryMatcher& Document::mediaQueryMatcher() | 615 MediaQueryMatcher& Document::mediaQueryMatcher() |
616 { | 616 { |
617 if (!m_mediaQueryMatcher) | 617 if (!m_mediaQueryMatcher) |
618 m_mediaQueryMatcher = MediaQueryMatcher::create(this); | 618 m_mediaQueryMatcher = MediaQueryMatcher::create(this); |
| 619 appendPendingStyleSheetsIfNeeded(m_styleResolver.get()); |
619 return *m_mediaQueryMatcher; | 620 return *m_mediaQueryMatcher; |
620 } | 621 } |
621 | 622 |
622 void Document::setCompatibilityMode(CompatibilityMode mode) | 623 void Document::setCompatibilityMode(CompatibilityMode mode) |
623 { | 624 { |
624 if (m_compatibilityModeLocked || mode == m_compatibilityMode) | 625 if (m_compatibilityModeLocked || mode == m_compatibilityMode) |
625 return; | 626 return; |
626 bool wasInQuirksMode = inQuirksMode(); | 627 bool wasInQuirksMode = inQuirksMode(); |
627 m_compatibilityMode = mode; | 628 m_compatibilityMode = mode; |
628 selectorQueryCache().invalidate(); | 629 selectorQueryCache().invalidate(); |
(...skipping 1068 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1697 // resolves style (here) and then when we resolve style on the parent chain,
we may end up | 1698 // resolves style (here) and then when we resolve style on the parent chain,
we may end up |
1698 // re-attaching our containing iframe, which when asked HTMLFrameElementBase
::isURLAllowed | 1699 // re-attaching our containing iframe, which when asked HTMLFrameElementBase
::isURLAllowed |
1699 // hits a null-dereference due to security code always assuming the document
has a SecurityOrigin. | 1700 // hits a null-dereference due to security code always assuming the document
has a SecurityOrigin. |
1700 | 1701 |
1701 if (m_styleEngine->needsUpdateActiveStylesheetsOnStyleRecalc()) | 1702 if (m_styleEngine->needsUpdateActiveStylesheetsOnStyleRecalc()) |
1702 m_styleEngine->updateActiveStyleSheets(FullStyleUpdate); | 1703 m_styleEngine->updateActiveStyleSheets(FullStyleUpdate); |
1703 | 1704 |
1704 if (m_elemSheet && m_elemSheet->contents()->usesRemUnits()) | 1705 if (m_elemSheet && m_elemSheet->contents()->usesRemUnits()) |
1705 m_styleEngine->setUsesRemUnit(true); | 1706 m_styleEngine->setUsesRemUnit(true); |
1706 | 1707 |
| 1708 appendPendingStyleSheetsIfNeeded(m_styleResolver.get()); |
| 1709 |
1707 { | 1710 { |
1708 PostAttachCallbacks::SuspendScope suspendPostAttachCallbacks; | 1711 PostAttachCallbacks::SuspendScope suspendPostAttachCallbacks; |
1709 RenderWidget::UpdateSuspendScope suspendWidgetHierarchyUpdates; | 1712 RenderWidget::UpdateSuspendScope suspendWidgetHierarchyUpdates; |
1710 FrameView::DeferredRepaintScope deferRepaints(*view()); | 1713 FrameView::DeferredRepaintScope deferRepaints(*view()); |
1711 TemporaryChange<bool> changeInStyleRecalc(m_inStyleRecalc, true); | 1714 TemporaryChange<bool> changeInStyleRecalc(m_inStyleRecalc, true); |
1712 | 1715 |
1713 if (styleChangeType() >= SubtreeStyleChange) | 1716 if (styleChangeType() >= SubtreeStyleChange) |
1714 change = Force; | 1717 change = Force; |
1715 | 1718 |
1716 // FIXME: Cannot access the styleResolver() before calling styleForDocum
ent below because | 1719 // FIXME: Cannot access the styleResolver() before calling styleForDocum
ent below because |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1750 clearChildNeedsStyleRecalc(); | 1753 clearChildNeedsStyleRecalc(); |
1751 unscheduleStyleRecalc(); | 1754 unscheduleStyleRecalc(); |
1752 | 1755 |
1753 // FIXME: SVG <use> element can schedule a recalc in the middle of an al
ready running one. | 1756 // FIXME: SVG <use> element can schedule a recalc in the middle of an al
ready running one. |
1754 // See StyleEngine::updateActiveStyleSheets. | 1757 // See StyleEngine::updateActiveStyleSheets. |
1755 if (m_styleEngine->needsUpdateActiveStylesheetsOnStyleRecalc()) | 1758 if (m_styleEngine->needsUpdateActiveStylesheetsOnStyleRecalc()) |
1756 setNeedsStyleRecalc(); | 1759 setNeedsStyleRecalc(); |
1757 | 1760 |
1758 if (m_styleResolver) { | 1761 if (m_styleResolver) { |
1759 // Pseudo element removal and similar may only work with these flags
still set. Reset them after the style recalc. | 1762 // Pseudo element removal and similar may only work with these flags
still set. Reset them after the style recalc. |
1760 m_styleEngine->resetCSSFeatureFlags(m_styleResolver->ruleFeatureSet(
)); | 1763 m_styleEngine->resetCSSFeatureFlags(m_styleResolver->ensureRuleFeatu
reSet()); |
1761 m_styleResolver->clearStyleSharingList(); | 1764 m_styleResolver->clearStyleSharingList(); |
1762 } | 1765 } |
1763 } | 1766 } |
1764 | 1767 |
1765 InspectorInstrumentation::didRecalculateStyle(cookie); | 1768 InspectorInstrumentation::didRecalculateStyle(cookie); |
1766 | 1769 |
1767 // As a result of the style recalculation, the currently hovered element mig
ht have been | 1770 // As a result of the style recalculation, the currently hovered element mig
ht have been |
1768 // detached (for example, by setting display:none in the :hover style), sche
dule another mouseMove event | 1771 // detached (for example, by setting display:none in the :hover style), sche
dule another mouseMove event |
1769 // to check if any other elements ended up under the mouse pointer due to re
-layout. | 1772 // to check if any other elements ended up under the mouse pointer due to re
-layout. |
1770 if (hoverNode() && !hoverNode()->renderer() && frame()) | 1773 if (hoverNode() && !hoverNode()->renderer() && frame()) |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1897 updateLayout(); | 1900 updateLayout(); |
1898 | 1901 |
1899 if (view()) | 1902 if (view()) |
1900 view()->partialLayout().reset(); | 1903 view()->partialLayout().reset(); |
1901 } | 1904 } |
1902 | 1905 |
1903 PassRefPtr<RenderStyle> Document::styleForElementIgnoringPendingStylesheets(Elem
ent* element) | 1906 PassRefPtr<RenderStyle> Document::styleForElementIgnoringPendingStylesheets(Elem
ent* element) |
1904 { | 1907 { |
1905 ASSERT_ARG(element, element->document() == this); | 1908 ASSERT_ARG(element, element->document() == this); |
1906 TemporaryChange<bool> ignoreStyleSheets(m_ignorePendingStylesheets, true); | 1909 TemporaryChange<bool> ignoreStyleSheets(m_ignorePendingStylesheets, true); |
1907 return styleResolver()->styleForElement(element, element->parentNode() ? ele
ment->parentNode()->computedStyle() : 0); | 1910 StyleResolver* resolver = styleResolver(); |
| 1911 appendPendingStyleSheetsIfNeeded(resolver); |
| 1912 return resolver->styleForElement(element, element->parentNode() ? element->p
arentNode()->computedStyle() : 0); |
1908 } | 1913 } |
1909 | 1914 |
1910 PassRefPtr<RenderStyle> Document::styleForPage(int pageIndex) | 1915 PassRefPtr<RenderStyle> Document::styleForPage(int pageIndex) |
1911 { | 1916 { |
1912 return styleResolver()->styleForPage(pageIndex); | 1917 StyleResolver* resolver = styleResolver(); |
| 1918 appendPendingStyleSheetsIfNeeded(resolver); |
| 1919 return resolver->styleForPage(pageIndex); |
1913 } | 1920 } |
1914 | 1921 |
1915 bool Document::isPageBoxVisible(int pageIndex) | 1922 bool Document::isPageBoxVisible(int pageIndex) |
1916 { | 1923 { |
1917 return styleForPage(pageIndex)->visibility() != HIDDEN; // display property
doesn't apply to @page. | 1924 return styleForPage(pageIndex)->visibility() != HIDDEN; // display property
doesn't apply to @page. |
1918 } | 1925 } |
1919 | 1926 |
1920 void Document::pageSizeAndMarginsInPixels(int pageIndex, IntSize& pageSize, int&
marginTop, int& marginRight, int& marginBottom, int& marginLeft) | 1927 void Document::pageSizeAndMarginsInPixels(int pageIndex, IntSize& pageSize, int&
marginTop, int& marginRight, int& marginBottom, int& marginLeft) |
1921 { | 1928 { |
1922 RefPtr<RenderStyle> style = styleForPage(pageIndex); | 1929 RefPtr<RenderStyle> style = styleForPage(pageIndex); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1967 } | 1974 } |
1968 | 1975 |
1969 void Document::createStyleResolver() | 1976 void Document::createStyleResolver() |
1970 { | 1977 { |
1971 // It is a programming error to attempt to resolve style on a Document | 1978 // It is a programming error to attempt to resolve style on a Document |
1972 // which is not in a frame. Code which hits this should have checked | 1979 // which is not in a frame. Code which hits this should have checked |
1973 // Document::isActive() before calling into code which could get here. | 1980 // Document::isActive() before calling into code which could get here. |
1974 ASSERT(frame()); | 1981 ASSERT(frame()); |
1975 | 1982 |
1976 m_styleResolver = adoptPtr(new StyleResolver(*this)); | 1983 m_styleResolver = adoptPtr(new StyleResolver(*this)); |
1977 m_styleEngine->combineCSSFeatureFlags(m_styleResolver->ruleFeatureSet()); | 1984 m_styleEngine->combineCSSFeatureFlags(m_styleResolver->ensureRuleFeatureSet(
)); |
1978 } | 1985 } |
1979 | 1986 |
1980 void Document::clearStyleResolver() | 1987 void Document::clearStyleResolver() |
1981 { | 1988 { |
1982 m_styleResolver.clear(); | 1989 m_styleResolver.clear(); |
1983 } | 1990 } |
1984 | 1991 |
1985 void Document::attach(const AttachContext& context) | 1992 void Document::attach(const AttachContext& context) |
1986 { | 1993 { |
1987 ASSERT(m_lifecyle.state() == DocumentLifecycle::Inactive); | 1994 ASSERT(m_lifecyle.state() == DocumentLifecycle::Inactive); |
(...skipping 3235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5223 void Document::modifiedStyleSheet(StyleSheet* sheet, RecalcStyleTime when, Style
ResolverUpdateMode updateMode) | 5230 void Document::modifiedStyleSheet(StyleSheet* sheet, RecalcStyleTime when, Style
ResolverUpdateMode updateMode) |
5224 { | 5231 { |
5225 if (!isActive()) | 5232 if (!isActive()) |
5226 return; | 5233 return; |
5227 | 5234 |
5228 styleEngine()->modifiedStyleSheet(sheet); | 5235 styleEngine()->modifiedStyleSheet(sheet); |
5229 styleResolverChanged(when, updateMode); | 5236 styleResolverChanged(when, updateMode); |
5230 } | 5237 } |
5231 | 5238 |
5232 } // namespace WebCore | 5239 } // namespace WebCore |
OLD | NEW |