| 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.
All rights reserved. | 7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc.
All rights reserved. |
| 8 * (C) 2007 Eric Seidel (eric@webkit.org) | 8 * (C) 2007 Eric Seidel (eric@webkit.org) |
| 9 * | 9 * |
| 10 * This library is free software; you can redistribute it and/or | 10 * This library is free software; you can redistribute it and/or |
| (...skipping 987 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 998 } else if (name == HTMLNames::nameAttr) { | 998 } else if (name == HTMLNames::nameAttr) { |
| 999 setHasName(!newValue.isNull()); | 999 setHasName(!newValue.isNull()); |
| 1000 } | 1000 } |
| 1001 | 1001 |
| 1002 invalidateNodeListCachesInAncestors(&name, this); | 1002 invalidateNodeListCachesInAncestors(&name, this); |
| 1003 | 1003 |
| 1004 // If there is currently no StyleResolver, we can't be sure that this attrib
ute change won't affect style. | 1004 // If there is currently no StyleResolver, we can't be sure that this attrib
ute change won't affect style. |
| 1005 shouldInvalidateStyle |= !styleResolver; | 1005 shouldInvalidateStyle |= !styleResolver; |
| 1006 | 1006 |
| 1007 if (shouldInvalidateStyle) | 1007 if (shouldInvalidateStyle) |
| 1008 setNeedsStyleRecalc(); | 1008 setNeedsStyleRecalc(SubtreeStyleChange); |
| 1009 | 1009 |
| 1010 if (AXObjectCache* cache = document().existingAXObjectCache()) | 1010 if (AXObjectCache* cache = document().existingAXObjectCache()) |
| 1011 cache->handleAttributeChanged(name, this); | 1011 cache->handleAttributeChanged(name, this); |
| 1012 } | 1012 } |
| 1013 | 1013 |
| 1014 inline void Element::attributeChangedFromParserOrByCloning(const QualifiedName&
name, const AtomicString& newValue, AttributeModificationReason reason) | 1014 inline void Element::attributeChangedFromParserOrByCloning(const QualifiedName&
name, const AtomicString& newValue, AttributeModificationReason reason) |
| 1015 { | 1015 { |
| 1016 if (name == isAttr) | 1016 if (name == isAttr) |
| 1017 CustomElementRegistrationContext::setTypeExtension(this, newValue); | 1017 CustomElementRegistrationContext::setTypeExtension(this, newValue); |
| 1018 attributeChanged(name, newValue, reason); | 1018 attributeChanged(name, newValue, reason); |
| (...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1660 unsigned forceCheckOfNextElementCount = 0; | 1660 unsigned forceCheckOfNextElementCount = 0; |
| 1661 bool forceCheckOfAnyElementSibling = false; | 1661 bool forceCheckOfAnyElementSibling = false; |
| 1662 | 1662 |
| 1663 for (Node* child = firstChild(); child; child = child->nextSibling()) { | 1663 for (Node* child = firstChild(); child; child = child->nextSibling()) { |
| 1664 if (!child->isElementNode()) | 1664 if (!child->isElementNode()) |
| 1665 continue; | 1665 continue; |
| 1666 Element* element = toElement(child); | 1666 Element* element = toElement(child); |
| 1667 bool childRulesChanged = element->needsStyleRecalc() && element->styleCh
angeType() >= SubtreeStyleChange; | 1667 bool childRulesChanged = element->needsStyleRecalc() && element->styleCh
angeType() >= SubtreeStyleChange; |
| 1668 | 1668 |
| 1669 if (forceCheckOfNextElementCount || forceCheckOfAnyElementSibling) | 1669 if (forceCheckOfNextElementCount || forceCheckOfAnyElementSibling) |
| 1670 element->setNeedsStyleRecalc(); | 1670 element->setNeedsStyleRecalc(SubtreeStyleChange); |
| 1671 | 1671 |
| 1672 if (forceCheckOfNextElementCount) | 1672 if (forceCheckOfNextElementCount) |
| 1673 forceCheckOfNextElementCount--; | 1673 forceCheckOfNextElementCount--; |
| 1674 | 1674 |
| 1675 if (childRulesChanged && hasDirectAdjacentRules) | 1675 if (childRulesChanged && hasDirectAdjacentRules) |
| 1676 forceCheckOfNextElementCount = document().styleEngine()->maxDirectAd
jacentSelectors(); | 1676 forceCheckOfNextElementCount = document().styleEngine()->maxDirectAd
jacentSelectors(); |
| 1677 | 1677 |
| 1678 forceCheckOfAnyElementSibling = forceCheckOfAnyElementSibling || (childR
ulesChanged && hasIndirectAdjacentRules); | 1678 forceCheckOfAnyElementSibling = forceCheckOfAnyElementSibling || (childR
ulesChanged && hasIndirectAdjacentRules); |
| 1679 } | 1679 } |
| 1680 } | 1680 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1705 return hasRareData() ? elementRareData()->shadow() : 0; | 1705 return hasRareData() ? elementRareData()->shadow() : 0; |
| 1706 } | 1706 } |
| 1707 | 1707 |
| 1708 ElementShadow& Element::ensureShadow() | 1708 ElementShadow& Element::ensureShadow() |
| 1709 { | 1709 { |
| 1710 return ensureElementRareData().ensureShadow(); | 1710 return ensureElementRareData().ensureShadow(); |
| 1711 } | 1711 } |
| 1712 | 1712 |
| 1713 void Element::didAffectSelector(AffectedSelectorMask mask) | 1713 void Element::didAffectSelector(AffectedSelectorMask mask) |
| 1714 { | 1714 { |
| 1715 setNeedsStyleRecalc(); | 1715 setNeedsStyleRecalc(SubtreeStyleChange); |
| 1716 if (ElementShadow* elementShadow = shadowWhereNodeCanBeDistributed(*this)) | 1716 if (ElementShadow* elementShadow = shadowWhereNodeCanBeDistributed(*this)) |
| 1717 elementShadow->didAffectSelector(mask); | 1717 elementShadow->didAffectSelector(mask); |
| 1718 } | 1718 } |
| 1719 | 1719 |
| 1720 void Element::setAnimationStyleChange(bool animationStyleChange) | 1720 void Element::setAnimationStyleChange(bool animationStyleChange) |
| 1721 { | 1721 { |
| 1722 if (ActiveAnimations* activeAnimations = elementRareData()->activeAnimations
()) | 1722 if (ActiveAnimations* activeAnimations = elementRareData()->activeAnimations
()) |
| 1723 activeAnimations->setAnimationStyleChange(animationStyleChange); | 1723 activeAnimations->setAnimationStyleChange(animationStyleChange); |
| 1724 } | 1724 } |
| 1725 | 1725 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1798 } | 1798 } |
| 1799 return false; | 1799 return false; |
| 1800 } | 1800 } |
| 1801 | 1801 |
| 1802 void Element::checkForEmptyStyleChange(RenderStyle* style) | 1802 void Element::checkForEmptyStyleChange(RenderStyle* style) |
| 1803 { | 1803 { |
| 1804 if (!style && !styleAffectedByEmpty()) | 1804 if (!style && !styleAffectedByEmpty()) |
| 1805 return; | 1805 return; |
| 1806 | 1806 |
| 1807 if (!style || (styleAffectedByEmpty() && (!style->emptyState() || hasChildNo
des()))) | 1807 if (!style || (styleAffectedByEmpty() && (!style->emptyState() || hasChildNo
des()))) |
| 1808 setNeedsStyleRecalc(); | 1808 setNeedsStyleRecalc(SubtreeStyleChange); |
| 1809 } | 1809 } |
| 1810 | 1810 |
| 1811 void Element::checkForSiblingStyleChanges(bool finishedParsingCallback, Node* be
foreChange, Node* afterChange, int childCountDelta) | 1811 void Element::checkForSiblingStyleChanges(bool finishedParsingCallback, Node* be
foreChange, Node* afterChange, int childCountDelta) |
| 1812 { | 1812 { |
| 1813 if (!inActiveDocument() || document().hasPendingForcedStyleRecalc() || style
ChangeType() >= SubtreeStyleChange) | 1813 if (!inActiveDocument() || document().hasPendingForcedStyleRecalc() || style
ChangeType() >= SubtreeStyleChange) |
| 1814 return; | 1814 return; |
| 1815 | 1815 |
| 1816 RenderStyle* style = renderStyle(); | 1816 RenderStyle* style = renderStyle(); |
| 1817 | 1817 |
| 1818 // :empty selector. | 1818 // :empty selector. |
| 1819 checkForEmptyStyleChange(style); | 1819 checkForEmptyStyleChange(style); |
| 1820 | 1820 |
| 1821 if (!style || (needsStyleRecalc() && childrenAffectedByPositionalRules())) | 1821 if (!style || (needsStyleRecalc() && childrenAffectedByPositionalRules())) |
| 1822 return; | 1822 return; |
| 1823 | 1823 |
| 1824 // Forward positional selectors include the ~ selector, nth-child, nth-of-ty
pe, first-of-type and only-of-type. | 1824 // Forward positional selectors include the ~ selector, nth-child, nth-of-ty
pe, first-of-type and only-of-type. |
| 1825 // Backward positional selectors include nth-last-child, nth-last-of-type, l
ast-of-type and only-of-type. | 1825 // Backward positional selectors include nth-last-child, nth-last-of-type, l
ast-of-type and only-of-type. |
| 1826 // We have to invalidate everything following the insertion point in the for
ward case, and everything before the insertion point in the | 1826 // We have to invalidate everything following the insertion point in the for
ward case, and everything before the insertion point in the |
| 1827 // backward case. | 1827 // backward case. |
| 1828 // |afterChange| is 0 in the parser callback case, so we won't do any work f
or the forward case if we don't have to. | 1828 // |afterChange| is 0 in the parser callback case, so we won't do any work f
or the forward case if we don't have to. |
| 1829 // For performance reasons we just mark the parent node as changed, since we
don't want to make childrenChanged O(n^2) by crawling all our kids | 1829 // For performance reasons we just mark the parent node as changed, since we
don't want to make childrenChanged O(n^2) by crawling all our kids |
| 1830 // here. recalcStyle will then force a walk of the children when it sees tha
t this has happened. | 1830 // here. recalcStyle will then force a walk of the children when it sees tha
t this has happened. |
| 1831 if ((childrenAffectedByForwardPositionalRules() && afterChange) || (children
AffectedByBackwardPositionalRules() && beforeChange)) { | 1831 if ((childrenAffectedByForwardPositionalRules() && afterChange) || (children
AffectedByBackwardPositionalRules() && beforeChange)) { |
| 1832 setNeedsStyleRecalc(); | 1832 setNeedsStyleRecalc(SubtreeStyleChange); |
| 1833 return; | 1833 return; |
| 1834 } | 1834 } |
| 1835 | 1835 |
| 1836 // :first-child. In the parser callback case, we don't have to check anythi
ng, since we were right the first time. | 1836 // :first-child. In the parser callback case, we don't have to check anythi
ng, since we were right the first time. |
| 1837 // In the DOM case, we only need to do something if |afterChange| is not 0. | 1837 // In the DOM case, we only need to do something if |afterChange| is not 0. |
| 1838 // |afterChange| is 0 in the parser case, so it works out that we'll skip th
is block. | 1838 // |afterChange| is 0 in the parser case, so it works out that we'll skip th
is block. |
| 1839 if (childrenAffectedByFirstChildRules() && afterChange) { | 1839 if (childrenAffectedByFirstChildRules() && afterChange) { |
| 1840 // Find our new first child. | 1840 // Find our new first child. |
| 1841 Node* newFirstChild = firstElementChild(); | 1841 Node* newFirstChild = firstElementChild(); |
| 1842 RenderStyle* newFirstChildStyle = newFirstChild ? newFirstChild->renderS
tyle() : 0; | 1842 RenderStyle* newFirstChildStyle = newFirstChild ? newFirstChild->renderS
tyle() : 0; |
| 1843 | 1843 |
| 1844 // Find the first element node following |afterChange| | 1844 // Find the first element node following |afterChange| |
| 1845 Node* firstElementAfterInsertion = afterChange->isElementNode() ? afterC
hange : afterChange->nextElementSibling(); | 1845 Node* firstElementAfterInsertion = afterChange->isElementNode() ? afterC
hange : afterChange->nextElementSibling(); |
| 1846 RenderStyle* firstElementAfterInsertionStyle = firstElementAfterInsertio
n ? firstElementAfterInsertion->renderStyle() : 0; | 1846 RenderStyle* firstElementAfterInsertionStyle = firstElementAfterInsertio
n ? firstElementAfterInsertion->renderStyle() : 0; |
| 1847 | 1847 |
| 1848 // This is the insert/append case. | 1848 // This is the insert/append case. |
| 1849 if (newFirstChild != firstElementAfterInsertion && firstElementAfterInse
rtionStyle && firstElementAfterInsertionStyle->firstChildState()) | 1849 if (newFirstChild != firstElementAfterInsertion && firstElementAfterInse
rtionStyle && firstElementAfterInsertionStyle->firstChildState()) |
| 1850 firstElementAfterInsertion->setNeedsStyleRecalc(); | 1850 firstElementAfterInsertion->setNeedsStyleRecalc(SubtreeStyleChange); |
| 1851 | 1851 |
| 1852 // We also have to handle node removal. | 1852 // We also have to handle node removal. |
| 1853 if (childCountDelta < 0 && newFirstChild == firstElementAfterInsertion &
& newFirstChild && (!newFirstChildStyle || !newFirstChildStyle->firstChildState(
))) | 1853 if (childCountDelta < 0 && newFirstChild == firstElementAfterInsertion &
& newFirstChild && (!newFirstChildStyle || !newFirstChildStyle->firstChildState(
))) |
| 1854 newFirstChild->setNeedsStyleRecalc(); | 1854 newFirstChild->setNeedsStyleRecalc(SubtreeStyleChange); |
| 1855 } | 1855 } |
| 1856 | 1856 |
| 1857 // :last-child. In the parser callback case, we don't have to check anythin
g, since we were right the first time. | 1857 // :last-child. In the parser callback case, we don't have to check anythin
g, since we were right the first time. |
| 1858 // In the DOM case, we only need to do something if |afterChange| is not 0. | 1858 // In the DOM case, we only need to do something if |afterChange| is not 0. |
| 1859 if (childrenAffectedByLastChildRules() && beforeChange) { | 1859 if (childrenAffectedByLastChildRules() && beforeChange) { |
| 1860 // Find our new last child. | 1860 // Find our new last child. |
| 1861 Node* newLastChild = lastElementChild(); | 1861 Node* newLastChild = lastElementChild(); |
| 1862 RenderStyle* newLastChildStyle = newLastChild ? newLastChild->renderStyl
e() : 0; | 1862 RenderStyle* newLastChildStyle = newLastChild ? newLastChild->renderStyl
e() : 0; |
| 1863 | 1863 |
| 1864 // Find the last element node going backwards from |beforeChange| | 1864 // Find the last element node going backwards from |beforeChange| |
| 1865 Node* lastElementBeforeInsertion = beforeChange->isElementNode() ? befor
eChange : beforeChange->previousElementSibling(); | 1865 Node* lastElementBeforeInsertion = beforeChange->isElementNode() ? befor
eChange : beforeChange->previousElementSibling(); |
| 1866 RenderStyle* lastElementBeforeInsertionStyle = lastElementBeforeInsertio
n ? lastElementBeforeInsertion->renderStyle() : 0; | 1866 RenderStyle* lastElementBeforeInsertionStyle = lastElementBeforeInsertio
n ? lastElementBeforeInsertion->renderStyle() : 0; |
| 1867 | 1867 |
| 1868 if (newLastChild != lastElementBeforeInsertion && lastElementBeforeInser
tionStyle && lastElementBeforeInsertionStyle->lastChildState()) | 1868 if (newLastChild != lastElementBeforeInsertion && lastElementBeforeInser
tionStyle && lastElementBeforeInsertionStyle->lastChildState()) |
| 1869 lastElementBeforeInsertion->setNeedsStyleRecalc(); | 1869 lastElementBeforeInsertion->setNeedsStyleRecalc(SubtreeStyleChange); |
| 1870 | 1870 |
| 1871 // We also have to handle node removal. The parser callback case is sim
ilar to node removal as well in that we need to change the last child | 1871 // We also have to handle node removal. The parser callback case is sim
ilar to node removal as well in that we need to change the last child |
| 1872 // to match now. | 1872 // to match now. |
| 1873 if ((childCountDelta < 0 || finishedParsingCallback) && newLastChild ==
lastElementBeforeInsertion && newLastChild && (!newLastChildStyle || !newLastChi
ldStyle->lastChildState())) | 1873 if ((childCountDelta < 0 || finishedParsingCallback) && newLastChild ==
lastElementBeforeInsertion && newLastChild && (!newLastChildStyle || !newLastChi
ldStyle->lastChildState())) |
| 1874 newLastChild->setNeedsStyleRecalc(); | 1874 newLastChild->setNeedsStyleRecalc(SubtreeStyleChange); |
| 1875 } | 1875 } |
| 1876 | 1876 |
| 1877 // The + selector. We need to invalidate the first element following the in
sertion point. It is the only possible element | 1877 // The + selector. We need to invalidate the first element following the in
sertion point. It is the only possible element |
| 1878 // that could be affected by this DOM change. | 1878 // that could be affected by this DOM change. |
| 1879 if (childrenAffectedByDirectAdjacentRules() && afterChange) { | 1879 if (childrenAffectedByDirectAdjacentRules() && afterChange) { |
| 1880 if (Node* firstElementAfterInsertion = afterChange->isElementNode() ? af
terChange : afterChange->nextElementSibling()) | 1880 if (Node* firstElementAfterInsertion = afterChange->isElementNode() ? af
terChange : afterChange->nextElementSibling()) |
| 1881 firstElementAfterInsertion->setNeedsStyleRecalc(); | 1881 firstElementAfterInsertion->setNeedsStyleRecalc(SubtreeStyleChange); |
| 1882 } | 1882 } |
| 1883 } | 1883 } |
| 1884 | 1884 |
| 1885 void Element::childrenChanged(bool changedByParser, Node* beforeChange, Node* af
terChange, int childCountDelta) | 1885 void Element::childrenChanged(bool changedByParser, Node* beforeChange, Node* af
terChange, int childCountDelta) |
| 1886 { | 1886 { |
| 1887 ContainerNode::childrenChanged(changedByParser, beforeChange, afterChange, c
hildCountDelta); | 1887 ContainerNode::childrenChanged(changedByParser, beforeChange, afterChange, c
hildCountDelta); |
| 1888 if (changedByParser) | 1888 if (changedByParser) |
| 1889 checkForEmptyStyleChange(renderStyle()); | 1889 checkForEmptyStyleChange(renderStyle()); |
| 1890 else | 1890 else |
| 1891 checkForSiblingStyleChanges(false, beforeChange, afterChange, childCount
Delta); | 1891 checkForSiblingStyleChanges(false, beforeChange, afterChange, childCount
Delta); |
| (...skipping 1183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3075 else if (name == HTMLNames::nameAttr) | 3075 else if (name == HTMLNames::nameAttr) |
| 3076 updateName(oldValue, newValue); | 3076 updateName(oldValue, newValue); |
| 3077 else if (name == HTMLNames::forAttr && hasTagName(labelTag)) { | 3077 else if (name == HTMLNames::forAttr && hasTagName(labelTag)) { |
| 3078 TreeScope& scope = treeScope(); | 3078 TreeScope& scope = treeScope(); |
| 3079 if (scope.shouldCacheLabelsByForAttribute()) | 3079 if (scope.shouldCacheLabelsByForAttribute()) |
| 3080 updateLabel(scope, oldValue, newValue); | 3080 updateLabel(scope, oldValue, newValue); |
| 3081 } | 3081 } |
| 3082 | 3082 |
| 3083 if (oldValue != newValue) { | 3083 if (oldValue != newValue) { |
| 3084 if (inActiveDocument() && hasSelectorForAttribute(&document(), name.loca
lName())) | 3084 if (inActiveDocument() && hasSelectorForAttribute(&document(), name.loca
lName())) |
| 3085 setNeedsStyleRecalc(); | 3085 setNeedsStyleRecalc(SubtreeStyleChange); |
| 3086 | 3086 |
| 3087 if (isUpgradedCustomElement()) | 3087 if (isUpgradedCustomElement()) |
| 3088 CustomElement::attributeDidChange(this, name.localName(), oldValue,
newValue); | 3088 CustomElement::attributeDidChange(this, name.localName(), oldValue,
newValue); |
| 3089 } | 3089 } |
| 3090 | 3090 |
| 3091 if (OwnPtr<MutationObserverInterestGroup> recipients = MutationObserverInter
estGroup::createForAttributesMutation(*this, name)) | 3091 if (OwnPtr<MutationObserverInterestGroup> recipients = MutationObserverInter
estGroup::createForAttributesMutation(*this, name)) |
| 3092 recipients->enqueueMutationRecord(MutationRecord::createAttributes(this,
name, oldValue)); | 3092 recipients->enqueueMutationRecord(MutationRecord::createAttributes(this,
name, oldValue)); |
| 3093 | 3093 |
| 3094 InspectorInstrumentation::willModifyDOMAttr(this, oldValue, newValue); | 3094 InspectorInstrumentation::willModifyDOMAttr(this, oldValue, newValue); |
| 3095 } | 3095 } |
| (...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3571 // Before doing so, we need to resolve issues in HTMLSelectElement::recalcLi
stItems | 3571 // Before doing so, we need to resolve issues in HTMLSelectElement::recalcLi
stItems |
| 3572 // and RenderMenuList::setText. See also https://bugs.webkit.org/show_bug.cg
i?id=88405 | 3572 // and RenderMenuList::setText. See also https://bugs.webkit.org/show_bug.cg
i?id=88405 |
| 3573 if (hasTagName(optionTag) || hasTagName(optgroupTag)) | 3573 if (hasTagName(optionTag) || hasTagName(optgroupTag)) |
| 3574 return false; | 3574 return false; |
| 3575 if (FullscreenElementStack::isActiveFullScreenElement(this)) | 3575 if (FullscreenElementStack::isActiveFullScreenElement(this)) |
| 3576 return false; | 3576 return false; |
| 3577 return true; | 3577 return true; |
| 3578 } | 3578 } |
| 3579 | 3579 |
| 3580 } // namespace WebCore | 3580 } // namespace WebCore |
| OLD | NEW |