Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Side by Side Diff: Source/core/dom/Element.cpp

Issue 24773003: Rename Node::attached() to confusingAndOftenMisusedAttached() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/dom/Document.cpp ('k') | Source/core/dom/ElementRareData.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 899 matching lines...) Expand 10 before | Expand all | Expand 10 after
910 if (ElementShadow* parentElementShadow = shadowOfParentForDistribution(this) ) { 910 if (ElementShadow* parentElementShadow = shadowOfParentForDistribution(this) ) {
911 if (shouldInvalidateDistributionWhenAttributeChanged(parentElementShadow , name, newValue)) 911 if (shouldInvalidateDistributionWhenAttributeChanged(parentElementShadow , name, newValue))
912 parentElementShadow->setNeedsDistributionRecalc(); 912 parentElementShadow->setNeedsDistributionRecalc();
913 } 913 }
914 914
915 parseAttribute(name, newValue); 915 parseAttribute(name, newValue);
916 916
917 document().incDOMTreeVersion(); 917 document().incDOMTreeVersion();
918 918
919 StyleResolver* styleResolver = document().styleResolverIfExists(); 919 StyleResolver* styleResolver = document().styleResolverIfExists();
920 bool testShouldInvalidateStyle = attached() && styleResolver && styleChangeT ype() < SubtreeStyleChange; 920 bool testShouldInvalidateStyle = confusingAndOftenMisusedAttached() && style Resolver && styleChangeType() < SubtreeStyleChange;
921 bool shouldInvalidateStyle = false; 921 bool shouldInvalidateStyle = false;
922 922
923 if (isStyledElement() && name == styleAttr) { 923 if (isStyledElement() && name == styleAttr) {
924 styleAttributeChanged(newValue, reason); 924 styleAttributeChanged(newValue, reason);
925 } else if (isStyledElement() && isPresentationAttribute(name)) { 925 } else if (isStyledElement() && isPresentationAttribute(name)) {
926 elementData()->m_presentationAttributeStyleIsDirty = true; 926 elementData()->m_presentationAttributeStyleIsDirty = true;
927 setNeedsStyleRecalc(LocalStyleChange); 927 setNeedsStyleRecalc(LocalStyleChange);
928 } 928 }
929 929
930 if (isIdAttributeName(name)) { 930 if (isIdAttributeName(name)) {
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
1025 continue; 1025 continue;
1026 if (checker.hasSelectorForClass(oldClasses[i])) 1026 if (checker.hasSelectorForClass(oldClasses[i]))
1027 return true; 1027 return true;
1028 } 1028 }
1029 return false; 1029 return false;
1030 } 1030 }
1031 1031
1032 void Element::classAttributeChanged(const AtomicString& newClassString) 1032 void Element::classAttributeChanged(const AtomicString& newClassString)
1033 { 1033 {
1034 StyleResolver* styleResolver = document().styleResolverIfExists(); 1034 StyleResolver* styleResolver = document().styleResolverIfExists();
1035 bool testShouldInvalidateStyle = attached() && styleResolver && styleChangeT ype() < SubtreeStyleChange; 1035 bool testShouldInvalidateStyle = confusingAndOftenMisusedAttached() && style Resolver && styleChangeType() < SubtreeStyleChange;
1036 bool shouldInvalidateStyle = false; 1036 bool shouldInvalidateStyle = false;
1037 1037
1038 if (classStringHasClassName(newClassString)) { 1038 if (classStringHasClassName(newClassString)) {
1039 const bool shouldFoldCase = document().inQuirksMode(); 1039 const bool shouldFoldCase = document().inQuirksMode();
1040 const SpaceSplitString oldClasses = elementData()->classNames(); 1040 const SpaceSplitString oldClasses = elementData()->classNames();
1041 elementData()->setClass(newClassString, shouldFoldCase); 1041 elementData()->setClass(newClassString, shouldFoldCase);
1042 const SpaceSplitString& newClasses = elementData()->classNames(); 1042 const SpaceSplitString& newClasses = elementData()->classNames();
1043 shouldInvalidateStyle = testShouldInvalidateStyle && checkSelectorForCla ssChange(oldClasses, newClasses, styleResolver->ruleFeatureSet()); 1043 shouldInvalidateStyle = testShouldInvalidateStyle && checkSelectorForCla ssChange(oldClasses, newClasses, styleResolver->ruleFeatureSet());
1044 } else { 1044 } else {
1045 const SpaceSplitString& oldClasses = elementData()->classNames(); 1045 const SpaceSplitString& oldClasses = elementData()->classNames();
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after
1668 if (!style && !element->styleAffectedByEmpty()) 1668 if (!style && !element->styleAffectedByEmpty())
1669 return; 1669 return;
1670 1670
1671 if (!style || (element->styleAffectedByEmpty() && (!style->emptyState() || e lement->hasChildNodes()))) 1671 if (!style || (element->styleAffectedByEmpty() && (!style->emptyState() || e lement->hasChildNodes())))
1672 element->setNeedsStyleRecalc(); 1672 element->setNeedsStyleRecalc();
1673 } 1673 }
1674 1674
1675 static void checkForSiblingStyleChanges(Element* e, RenderStyle* style, bool fin ishedParsingCallback, 1675 static void checkForSiblingStyleChanges(Element* e, RenderStyle* style, bool fin ishedParsingCallback,
1676 Node* beforeChange, Node* afterChange, i nt childCountDelta) 1676 Node* beforeChange, Node* afterChange, i nt childCountDelta)
1677 { 1677 {
1678 if (!e->attached() || e->document().hasPendingForcedStyleRecalc() || e->styl eChangeType() >= SubtreeStyleChange) 1678 if (!e->confusingAndOftenMisusedAttached() || e->document().hasPendingForced StyleRecalc() || e->styleChangeType() >= SubtreeStyleChange)
1679 return; 1679 return;
1680 1680
1681 // :empty selector. 1681 // :empty selector.
1682 checkForEmptyStyleChange(e, style); 1682 checkForEmptyStyleChange(e, style);
1683 1683
1684 if (!style || (e->needsStyleRecalc() && e->childrenAffectedByPositionalRules ())) 1684 if (!style || (e->needsStyleRecalc() && e->childrenAffectedByPositionalRules ()))
1685 return; 1685 return;
1686 1686
1687 // Forward positional selectors include the ~ selector, nth-child, nth-of-ty pe, first-of-type and only-of-type. 1687 // Forward positional selectors include the ~ selector, nth-child, nth-of-ty pe, first-of-type and only-of-type.
1688 // Backward positional selectors include nth-last-child, nth-last-of-type, l ast-of-type and only-of-type. 1688 // Backward positional selectors include nth-last-child, nth-last-of-type, l ast-of-type and only-of-type.
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after
2215 // properties, which are only known by the renderer because it did the layou t, will be correct and so that the 2215 // properties, which are only known by the renderer because it did the layou t, will be correct and so that the
2216 // values returned for the ":selection" pseudo-element will be correct. 2216 // values returned for the ":selection" pseudo-element will be correct.
2217 if (RenderStyle* usedStyle = renderStyle()) { 2217 if (RenderStyle* usedStyle = renderStyle()) {
2218 if (pseudoElementSpecifier) { 2218 if (pseudoElementSpecifier) {
2219 RenderStyle* cachedPseudoStyle = usedStyle->getCachedPseudoStyle(pse udoElementSpecifier); 2219 RenderStyle* cachedPseudoStyle = usedStyle->getCachedPseudoStyle(pse udoElementSpecifier);
2220 return cachedPseudoStyle ? cachedPseudoStyle : usedStyle; 2220 return cachedPseudoStyle ? cachedPseudoStyle : usedStyle;
2221 } else 2221 } else
2222 return usedStyle; 2222 return usedStyle;
2223 } 2223 }
2224 2224
2225 if (!attached()) 2225 if (!confusingAndOftenMisusedAttached())
2226 // FIXME: Try to do better than this. Ensure that styleForElement() work s for elements that are not in the 2226 // FIXME: Try to do better than this. Ensure that styleForElement() work s for elements that are not in the
2227 // document tree and figure out when to destroy the computed style for s uch elements. 2227 // document tree and figure out when to destroy the computed style for s uch elements.
2228 return 0; 2228 return 0;
2229 2229
2230 ElementRareData* data = ensureElementRareData(); 2230 ElementRareData* data = ensureElementRareData();
2231 if (!data->computedStyle()) 2231 if (!data->computedStyle())
2232 data->setComputedStyle(document().styleForElementIgnoringPendingStyleshe ets(this)); 2232 data->setComputedStyle(document().styleForElementIgnoringPendingStyleshe ets(this));
2233 return pseudoElementSpecifier ? data->computedStyle()->getCachedPseudoStyle( pseudoElementSpecifier) : data->computedStyle(); 2233 return pseudoElementSpecifier ? data->computedStyle()->getCachedPseudoStyle( pseudoElementSpecifier) : data->computedStyle();
2234 } 2234 }
2235 2235
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after
2824 updateId(oldValue, newValue); 2824 updateId(oldValue, newValue);
2825 else if (name == HTMLNames::nameAttr) 2825 else if (name == HTMLNames::nameAttr)
2826 updateName(oldValue, newValue); 2826 updateName(oldValue, newValue);
2827 else if (name == HTMLNames::forAttr && hasTagName(labelTag)) { 2827 else if (name == HTMLNames::forAttr && hasTagName(labelTag)) {
2828 TreeScope& scope = treeScope(); 2828 TreeScope& scope = treeScope();
2829 if (scope.shouldCacheLabelsByForAttribute()) 2829 if (scope.shouldCacheLabelsByForAttribute())
2830 updateLabel(scope, oldValue, newValue); 2830 updateLabel(scope, oldValue, newValue);
2831 } 2831 }
2832 2832
2833 if (oldValue != newValue) { 2833 if (oldValue != newValue) {
2834 if (attached() && hasSelectorForAttribute(&document(), name.localName()) ) 2834 if (confusingAndOftenMisusedAttached() && hasSelectorForAttribute(&docum ent(), name.localName()))
2835 setNeedsStyleRecalc(); 2835 setNeedsStyleRecalc();
2836 2836
2837 if (isUpgradedCustomElement()) 2837 if (isUpgradedCustomElement())
2838 CustomElement::attributeDidChange(this, name.localName(), oldValue, newValue); 2838 CustomElement::attributeDidChange(this, name.localName(), oldValue, newValue);
2839 } 2839 }
2840 2840
2841 if (OwnPtr<MutationObserverInterestGroup> recipients = MutationObserverInter estGroup::createForAttributesMutation(this, name)) 2841 if (OwnPtr<MutationObserverInterestGroup> recipients = MutationObserverInter estGroup::createForAttributesMutation(this, name))
2842 recipients->enqueueMutationRecord(MutationRecord::createAttributes(this, name, oldValue)); 2842 recipients->enqueueMutationRecord(MutationRecord::createAttributes(this, name, oldValue));
2843 2843
2844 InspectorInstrumentation::willModifyDOMAttr(&document(), this, oldValue, new Value); 2844 InspectorInstrumentation::willModifyDOMAttr(&document(), this, oldValue, new Value);
(...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after
3642 return 0; 3642 return 0;
3643 } 3643 }
3644 3644
3645 Attribute* UniqueElementData::attributeItem(unsigned index) 3645 Attribute* UniqueElementData::attributeItem(unsigned index)
3646 { 3646 {
3647 ASSERT_WITH_SECURITY_IMPLICATION(index < length()); 3647 ASSERT_WITH_SECURITY_IMPLICATION(index < length());
3648 return &m_attributeVector.at(index); 3648 return &m_attributeVector.at(index);
3649 } 3649 }
3650 3650
3651 } // namespace WebCore 3651 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/dom/Document.cpp ('k') | Source/core/dom/ElementRareData.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698