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 Peter Kelly (pmk@post.com) | 4 * (C) 2001 Peter Kelly (pmk@post.com) |
5 * (C) 2001 Dirk Mueller (mueller@kde.org) | 5 * (C) 2001 Dirk Mueller (mueller@kde.org) |
6 * (C) 2007 David Smith (catfish.man@gmail.com) | 6 * (C) 2007 David Smith (catfish.man@gmail.com) |
7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. | 7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. |
8 * All rights reserved. | 8 * All rights reserved. |
9 * (C) 2007 Eric Seidel (eric@webkit.org) | 9 * (C) 2007 Eric Seidel (eric@webkit.org) |
10 * | 10 * |
(...skipping 1790 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1801 } | 1801 } |
1802 | 1802 |
1803 if (context.clearInvalidation) | 1803 if (context.clearInvalidation) |
1804 document().styleEngine().styleInvalidator().clearInvalidation(*this); | 1804 document().styleEngine().styleInvalidator().clearInvalidation(*this); |
1805 | 1805 |
1806 setNeedsResizeObserverUpdate(); | 1806 setNeedsResizeObserverUpdate(); |
1807 | 1807 |
1808 DCHECK(needsAttach()); | 1808 DCHECK(needsAttach()); |
1809 } | 1809 } |
1810 | 1810 |
1811 void Element::pseudoStyleCacheIsInvalid(const ComputedStyle* currentStyle, | |
1812 ComputedStyle* newStyle) { | |
1813 // TODO(rune@opera.com): This method does not take into account pseudo style | |
1814 // which is only present for the newStyle. Also the first-line part should | |
1815 // probably be moved to where we handle visual invalidation diff for setStyle. | |
1816 // setHasPseudoStyle() calls are probably unnecessary. | |
1817 DCHECK_EQ(currentStyle, computedStyle()); | |
1818 DCHECK(layoutObject()); | |
1819 | |
1820 if (!currentStyle) | |
1821 return; | |
1822 | |
1823 const PseudoStyleCache* pseudoStyleCache = currentStyle->cachedPseudoStyles(); | |
1824 if (!pseudoStyleCache) | |
1825 return; | |
1826 | |
1827 size_t cacheSize = pseudoStyleCache->size(); | |
1828 for (size_t i = 0; i < cacheSize; ++i) { | |
1829 RefPtr<ComputedStyle> newPseudoStyle; | |
1830 RefPtr<ComputedStyle> oldPseudoStyle = pseudoStyleCache->at(i); | |
1831 PseudoId pseudoId = oldPseudoStyle->styleType(); | |
1832 if (pseudoId != PseudoIdFirstLine && pseudoId != PseudoIdFirstLineInherited) | |
1833 continue; | |
1834 newPseudoStyle = layoutObject()->uncachedFirstLineStyle(newStyle); | |
1835 if (!newPseudoStyle) | |
1836 continue; | |
1837 if (*oldPseudoStyle != *newPseudoStyle || | |
1838 oldPseudoStyle->font().loadingCustomFonts() != | |
1839 newPseudoStyle->font().loadingCustomFonts()) { | |
1840 if (pseudoId < FirstInternalPseudoId) | |
1841 newStyle->setHasPseudoStyle(pseudoId); | |
1842 newStyle->addCachedPseudoStyle(newPseudoStyle); | |
1843 if (pseudoId == PseudoIdFirstLine || | |
1844 pseudoId == PseudoIdFirstLineInherited) { | |
1845 layoutObject()->firstLineStyleDidChange(*oldPseudoStyle, | |
1846 *newPseudoStyle); | |
1847 } | |
1848 } | |
1849 } | |
1850 } | |
1851 | |
1852 PassRefPtr<ComputedStyle> Element::styleForLayoutObject() { | 1811 PassRefPtr<ComputedStyle> Element::styleForLayoutObject() { |
1853 DCHECK(document().inStyleRecalc()); | 1812 DCHECK(document().inStyleRecalc()); |
1854 | 1813 |
1855 RefPtr<ComputedStyle> style; | 1814 RefPtr<ComputedStyle> style; |
1856 | 1815 |
1857 // FIXME: Instead of clearing updates that may have been added from calls to | 1816 // FIXME: Instead of clearing updates that may have been added from calls to |
1858 // styleForElement outside recalcStyle, we should just never set them if we're | 1817 // styleForElement outside recalcStyle, we should just never set them if we're |
1859 // not inside recalcStyle. | 1818 // not inside recalcStyle. |
1860 if (ElementAnimations* elementAnimations = this->elementAnimations()) | 1819 if (ElementAnimations* elementAnimations = this->elementAnimations()) |
1861 elementAnimations->cssAnimations().clearPendingUpdate(); | 1820 elementAnimations->cssAnimations().clearPendingUpdate(); |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2029 return Reattach; | 1988 return Reattach; |
2030 } | 1989 } |
2031 | 1990 |
2032 DCHECK(oldStyle); | 1991 DCHECK(oldStyle); |
2033 | 1992 |
2034 if (localChange != NoChange) | 1993 if (localChange != NoChange) |
2035 updateCallbackSelectors(oldStyle.get(), newStyle.get()); | 1994 updateCallbackSelectors(oldStyle.get(), newStyle.get()); |
2036 | 1995 |
2037 if (LayoutObject* layoutObject = this->layoutObject()) { | 1996 if (LayoutObject* layoutObject = this->layoutObject()) { |
2038 if (localChange != NoChange) { | 1997 if (localChange != NoChange) { |
2039 pseudoStyleCacheIsInvalid(oldStyle.get(), newStyle.get()); | |
2040 layoutObject->setStyle(newStyle.get()); | 1998 layoutObject->setStyle(newStyle.get()); |
2041 } else { | 1999 } else { |
2042 // Although no change occurred, we use the new style so that the cousin | 2000 // Although no change occurred, we use the new style so that the cousin |
2043 // style sharing code won't get fooled into believing this style is the | 2001 // style sharing code won't get fooled into believing this style is the |
2044 // same. | 2002 // same. |
2045 // FIXME: We may be able to remove this hack, see discussion in | 2003 // FIXME: We may be able to remove this hack, see discussion in |
2046 // https://codereview.chromium.org/30453002/ | 2004 // https://codereview.chromium.org/30453002/ |
2047 layoutObject->setStyleInternal(newStyle.get()); | 2005 layoutObject->setStyleInternal(newStyle.get()); |
2048 } | 2006 } |
2049 } else if (localChange != NoChange && | 2007 } else if (localChange != NoChange && |
(...skipping 2177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4227 } | 4185 } |
4228 | 4186 |
4229 DEFINE_TRACE_WRAPPERS(Element) { | 4187 DEFINE_TRACE_WRAPPERS(Element) { |
4230 if (hasRareData()) { | 4188 if (hasRareData()) { |
4231 visitor->traceWrappers(elementRareData()); | 4189 visitor->traceWrappers(elementRareData()); |
4232 } | 4190 } |
4233 ContainerNode::traceWrappers(visitor); | 4191 ContainerNode::traceWrappers(visitor); |
4234 } | 4192 } |
4235 | 4193 |
4236 } // namespace blink | 4194 } // namespace blink |
OLD | NEW |