| 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 bool Element::pseudoStyleCacheIsInvalid(const ComputedStyle* currentStyle, | 1811 void Element::pseudoStyleCacheIsInvalid(const ComputedStyle* currentStyle, |
| 1812 ComputedStyle* newStyle) { | 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. |
| 1813 DCHECK_EQ(currentStyle, computedStyle()); | 1817 DCHECK_EQ(currentStyle, computedStyle()); |
| 1814 DCHECK(layoutObject()); | 1818 DCHECK(layoutObject()); |
| 1815 | 1819 |
| 1816 if (!currentStyle) | 1820 if (!currentStyle) |
| 1817 return false; | 1821 return; |
| 1818 | 1822 |
| 1819 const PseudoStyleCache* pseudoStyleCache = currentStyle->cachedPseudoStyles(); | 1823 const PseudoStyleCache* pseudoStyleCache = currentStyle->cachedPseudoStyles(); |
| 1820 if (!pseudoStyleCache) | 1824 if (!pseudoStyleCache) |
| 1821 return false; | 1825 return; |
| 1822 | 1826 |
| 1823 size_t cacheSize = pseudoStyleCache->size(); | 1827 size_t cacheSize = pseudoStyleCache->size(); |
| 1824 for (size_t i = 0; i < cacheSize; ++i) { | 1828 for (size_t i = 0; i < cacheSize; ++i) { |
| 1825 RefPtr<ComputedStyle> newPseudoStyle; | 1829 RefPtr<ComputedStyle> newPseudoStyle; |
| 1826 RefPtr<ComputedStyle> oldPseudoStyle = pseudoStyleCache->at(i); | 1830 RefPtr<ComputedStyle> oldPseudoStyle = pseudoStyleCache->at(i); |
| 1827 PseudoId pseudoId = oldPseudoStyle->styleType(); | 1831 PseudoId pseudoId = oldPseudoStyle->styleType(); |
| 1828 if (pseudoId == PseudoIdFirstLine || pseudoId == PseudoIdFirstLineInherited) | 1832 if (pseudoId != PseudoIdFirstLine && pseudoId != PseudoIdFirstLineInherited) |
| 1829 newPseudoStyle = layoutObject()->uncachedFirstLineStyle(newStyle); | 1833 continue; |
| 1830 else | 1834 newPseudoStyle = layoutObject()->uncachedFirstLineStyle(newStyle); |
| 1831 newPseudoStyle = layoutObject()->getUncachedPseudoStyle( | |
| 1832 PseudoStyleRequest(pseudoId), newStyle, newStyle); | |
| 1833 if (!newPseudoStyle) | 1835 if (!newPseudoStyle) |
| 1834 return true; | 1836 continue; |
| 1835 if (*oldPseudoStyle != *newPseudoStyle || | 1837 if (*oldPseudoStyle != *newPseudoStyle || |
| 1836 oldPseudoStyle->font().loadingCustomFonts() != | 1838 oldPseudoStyle->font().loadingCustomFonts() != |
| 1837 newPseudoStyle->font().loadingCustomFonts()) { | 1839 newPseudoStyle->font().loadingCustomFonts()) { |
| 1838 if (pseudoId < FirstInternalPseudoId) | 1840 if (pseudoId < FirstInternalPseudoId) |
| 1839 newStyle->setHasPseudoStyle(pseudoId); | 1841 newStyle->setHasPseudoStyle(pseudoId); |
| 1840 newStyle->addCachedPseudoStyle(newPseudoStyle); | 1842 newStyle->addCachedPseudoStyle(newPseudoStyle); |
| 1841 if (pseudoId == PseudoIdFirstLine || | 1843 if (pseudoId == PseudoIdFirstLine || |
| 1842 pseudoId == PseudoIdFirstLineInherited) | 1844 pseudoId == PseudoIdFirstLineInherited) { |
| 1843 layoutObject()->firstLineStyleDidChange(*oldPseudoStyle, | 1845 layoutObject()->firstLineStyleDidChange(*oldPseudoStyle, |
| 1844 *newPseudoStyle); | 1846 *newPseudoStyle); |
| 1845 return true; | 1847 } |
| 1846 } | 1848 } |
| 1847 } | 1849 } |
| 1848 return false; | |
| 1849 } | 1850 } |
| 1850 | 1851 |
| 1851 PassRefPtr<ComputedStyle> Element::styleForLayoutObject() { | 1852 PassRefPtr<ComputedStyle> Element::styleForLayoutObject() { |
| 1852 DCHECK(document().inStyleRecalc()); | 1853 DCHECK(document().inStyleRecalc()); |
| 1853 | 1854 |
| 1854 RefPtr<ComputedStyle> style; | 1855 RefPtr<ComputedStyle> style; |
| 1855 | 1856 |
| 1856 // FIXME: Instead of clearing updates that may have been added from calls to | 1857 // FIXME: Instead of clearing updates that may have been added from calls to |
| 1857 // styleForElement outside recalcStyle, we should just never set them if we're | 1858 // styleForElement outside recalcStyle, we should just never set them if we're |
| 1858 // not inside recalcStyle. | 1859 // not inside recalcStyle. |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2025 setNeedsReattachLayoutTree(); | 2026 setNeedsReattachLayoutTree(); |
| 2026 return rebuildLayoutTree(); | 2027 return rebuildLayoutTree(); |
| 2027 } | 2028 } |
| 2028 | 2029 |
| 2029 DCHECK(oldStyle); | 2030 DCHECK(oldStyle); |
| 2030 | 2031 |
| 2031 if (localChange != NoChange) | 2032 if (localChange != NoChange) |
| 2032 updateCallbackSelectors(oldStyle.get(), newStyle.get()); | 2033 updateCallbackSelectors(oldStyle.get(), newStyle.get()); |
| 2033 | 2034 |
| 2034 if (LayoutObject* layoutObject = this->layoutObject()) { | 2035 if (LayoutObject* layoutObject = this->layoutObject()) { |
| 2035 if (localChange != NoChange || | 2036 if (localChange != NoChange) { |
| 2036 pseudoStyleCacheIsInvalid(oldStyle.get(), newStyle.get())) { | 2037 pseudoStyleCacheIsInvalid(oldStyle.get(), newStyle.get()); |
| 2037 layoutObject->setStyle(newStyle.get()); | 2038 layoutObject->setStyle(newStyle.get()); |
| 2038 } else { | 2039 } else { |
| 2039 // Although no change occurred, we use the new style so that the cousin | 2040 // Although no change occurred, we use the new style so that the cousin |
| 2040 // style sharing code won't get fooled into believing this style is the | 2041 // style sharing code won't get fooled into believing this style is the |
| 2041 // same. | 2042 // same. |
| 2042 // FIXME: We may be able to remove this hack, see discussion in | 2043 // FIXME: We may be able to remove this hack, see discussion in |
| 2043 // https://codereview.chromium.org/30453002/ | 2044 // https://codereview.chromium.org/30453002/ |
| 2044 layoutObject->setStyleInternal(newStyle.get()); | 2045 layoutObject->setStyleInternal(newStyle.get()); |
| 2045 } | 2046 } |
| 2046 } else if (localChange != NoChange && | 2047 } else if (localChange != NoChange && |
| (...skipping 2154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4201 } | 4202 } |
| 4202 | 4203 |
| 4203 DEFINE_TRACE_WRAPPERS(Element) { | 4204 DEFINE_TRACE_WRAPPERS(Element) { |
| 4204 if (hasRareData()) { | 4205 if (hasRareData()) { |
| 4205 visitor->traceWrappers(elementRareData()); | 4206 visitor->traceWrappers(elementRareData()); |
| 4206 } | 4207 } |
| 4207 ContainerNode::traceWrappers(visitor); | 4208 ContainerNode::traceWrappers(visitor); |
| 4208 } | 4209 } |
| 4209 | 4210 |
| 4210 } // namespace blink | 4211 } // namespace blink |
| OLD | NEW |