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

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

Issue 26270004: Element should not use confusingAndOftenMisusedAttached (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase Created 7 years, 1 month 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 | « no previous file | Source/core/dom/Node.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 958 matching lines...) Expand 10 before | Expand all | Expand 10 after
969 if (ElementShadow* parentElementShadow = shadowOfParentForDistribution(this) ) { 969 if (ElementShadow* parentElementShadow = shadowOfParentForDistribution(this) ) {
970 if (shouldInvalidateDistributionWhenAttributeChanged(parentElementShadow , name, newValue)) 970 if (shouldInvalidateDistributionWhenAttributeChanged(parentElementShadow , name, newValue))
971 parentElementShadow->setNeedsDistributionRecalc(); 971 parentElementShadow->setNeedsDistributionRecalc();
972 } 972 }
973 973
974 parseAttribute(name, newValue); 974 parseAttribute(name, newValue);
975 975
976 document().incDOMTreeVersion(); 976 document().incDOMTreeVersion();
977 977
978 StyleResolver* styleResolver = document().styleResolverIfExists(); 978 StyleResolver* styleResolver = document().styleResolverIfExists();
979 bool testShouldInvalidateStyle = confusingAndOftenMisusedAttached() && style Resolver && styleChangeType() < SubtreeStyleChange; 979 bool testShouldInvalidateStyle = inActiveDocument() && styleResolver && styl eChangeType() < SubtreeStyleChange;
980 bool shouldInvalidateStyle = false; 980 bool shouldInvalidateStyle = false;
981 981
982 if (isStyledElement() && name == styleAttr) { 982 if (isStyledElement() && name == styleAttr) {
983 styleAttributeChanged(newValue, reason); 983 styleAttributeChanged(newValue, reason);
984 } else if (isStyledElement() && isPresentationAttribute(name)) { 984 } else if (isStyledElement() && isPresentationAttribute(name)) {
985 elementData()->m_presentationAttributeStyleIsDirty = true; 985 elementData()->m_presentationAttributeStyleIsDirty = true;
986 setNeedsStyleRecalc(LocalStyleChange); 986 setNeedsStyleRecalc(LocalStyleChange);
987 } 987 }
988 988
989 if (isIdAttributeName(name)) { 989 if (isIdAttributeName(name)) {
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
1084 continue; 1084 continue;
1085 if (checker.hasSelectorForClass(oldClasses[i])) 1085 if (checker.hasSelectorForClass(oldClasses[i]))
1086 return true; 1086 return true;
1087 } 1087 }
1088 return false; 1088 return false;
1089 } 1089 }
1090 1090
1091 void Element::classAttributeChanged(const AtomicString& newClassString) 1091 void Element::classAttributeChanged(const AtomicString& newClassString)
1092 { 1092 {
1093 StyleResolver* styleResolver = document().styleResolverIfExists(); 1093 StyleResolver* styleResolver = document().styleResolverIfExists();
1094 bool testShouldInvalidateStyle = confusingAndOftenMisusedAttached() && style Resolver && styleChangeType() < SubtreeStyleChange; 1094 bool testShouldInvalidateStyle = inActiveDocument() && styleResolver && styl eChangeType() < SubtreeStyleChange;
1095 bool shouldInvalidateStyle = false; 1095 bool shouldInvalidateStyle = false;
1096 1096
1097 if (classStringHasClassName(newClassString)) { 1097 if (classStringHasClassName(newClassString)) {
1098 const bool shouldFoldCase = document().inQuirksMode(); 1098 const bool shouldFoldCase = document().inQuirksMode();
1099 const SpaceSplitString oldClasses = elementData()->classNames(); 1099 const SpaceSplitString oldClasses = elementData()->classNames();
1100 elementData()->setClass(newClassString, shouldFoldCase); 1100 elementData()->setClass(newClassString, shouldFoldCase);
1101 const SpaceSplitString& newClasses = elementData()->classNames(); 1101 const SpaceSplitString& newClasses = elementData()->classNames();
1102 shouldInvalidateStyle = testShouldInvalidateStyle && checkSelectorForCla ssChange(oldClasses, newClasses, styleResolver->ruleFeatureSet()); 1102 shouldInvalidateStyle = testShouldInvalidateStyle && checkSelectorForCla ssChange(oldClasses, newClasses, styleResolver->ruleFeatureSet());
1103 } else { 1103 } else {
1104 const SpaceSplitString& oldClasses = elementData()->classNames(); 1104 const SpaceSplitString& oldClasses = elementData()->classNames();
(...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after
1762 if (!style && !element->styleAffectedByEmpty()) 1762 if (!style && !element->styleAffectedByEmpty())
1763 return; 1763 return;
1764 1764
1765 if (!style || (element->styleAffectedByEmpty() && (!style->emptyState() || e lement->hasChildNodes()))) 1765 if (!style || (element->styleAffectedByEmpty() && (!style->emptyState() || e lement->hasChildNodes())))
1766 element->setNeedsStyleRecalc(); 1766 element->setNeedsStyleRecalc();
1767 } 1767 }
1768 1768
1769 static void checkForSiblingStyleChanges(Element* e, RenderStyle* style, bool fin ishedParsingCallback, 1769 static void checkForSiblingStyleChanges(Element* e, RenderStyle* style, bool fin ishedParsingCallback,
1770 Node* beforeChange, Node* afterChange, i nt childCountDelta) 1770 Node* beforeChange, Node* afterChange, i nt childCountDelta)
1771 { 1771 {
1772 if (!e->confusingAndOftenMisusedAttached() || e->document().hasPendingForced StyleRecalc() || e->styleChangeType() >= SubtreeStyleChange) 1772 if (!e->inActiveDocument() || e->document().hasPendingForcedStyleRecalc() || e->styleChangeType() >= SubtreeStyleChange)
1773 return; 1773 return;
1774 1774
1775 // :empty selector. 1775 // :empty selector.
1776 checkForEmptyStyleChange(e, style); 1776 checkForEmptyStyleChange(e, style);
1777 1777
1778 if (!style || (e->needsStyleRecalc() && e->childrenAffectedByPositionalRules ())) 1778 if (!style || (e->needsStyleRecalc() && e->childrenAffectedByPositionalRules ()))
1779 return; 1779 return;
1780 1780
1781 // Forward positional selectors include the ~ selector, nth-child, nth-of-ty pe, first-of-type and only-of-type. 1781 // Forward positional selectors include the ~ selector, nth-child, nth-of-ty pe, first-of-type and only-of-type.
1782 // Backward positional selectors include nth-last-child, nth-last-of-type, l ast-of-type and only-of-type. 1782 // Backward positional selectors include nth-last-child, nth-last-of-type, l ast-of-type and only-of-type.
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after
2306 // properties, which are only known by the renderer because it did the layou t, will be correct and so that the 2306 // properties, which are only known by the renderer because it did the layou t, will be correct and so that the
2307 // values returned for the ":selection" pseudo-element will be correct. 2307 // values returned for the ":selection" pseudo-element will be correct.
2308 if (RenderStyle* usedStyle = renderStyle()) { 2308 if (RenderStyle* usedStyle = renderStyle()) {
2309 if (pseudoElementSpecifier) { 2309 if (pseudoElementSpecifier) {
2310 RenderStyle* cachedPseudoStyle = usedStyle->getCachedPseudoStyle(pse udoElementSpecifier); 2310 RenderStyle* cachedPseudoStyle = usedStyle->getCachedPseudoStyle(pse udoElementSpecifier);
2311 return cachedPseudoStyle ? cachedPseudoStyle : usedStyle; 2311 return cachedPseudoStyle ? cachedPseudoStyle : usedStyle;
2312 } else 2312 } else
2313 return usedStyle; 2313 return usedStyle;
2314 } 2314 }
2315 2315
2316 if (!confusingAndOftenMisusedAttached()) 2316 if (!inActiveDocument())
2317 // FIXME: Try to do better than this. Ensure that styleForElement() work s for elements that are not in the 2317 // FIXME: Try to do better than this. Ensure that styleForElement() work s for elements that are not in the
2318 // document tree and figure out when to destroy the computed style for s uch elements. 2318 // document tree and figure out when to destroy the computed style for s uch elements.
2319 return 0; 2319 return 0;
2320 2320
2321 ElementRareData& rareData = ensureElementRareData(); 2321 ElementRareData& rareData = ensureElementRareData();
2322 if (!rareData.computedStyle()) 2322 if (!rareData.computedStyle())
2323 rareData.setComputedStyle(document().styleForElementIgnoringPendingStyle sheets(this)); 2323 rareData.setComputedStyle(document().styleForElementIgnoringPendingStyle sheets(this));
2324 return pseudoElementSpecifier ? rareData.computedStyle()->getCachedPseudoSty le(pseudoElementSpecifier) : rareData.computedStyle(); 2324 return pseudoElementSpecifier ? rareData.computedStyle()->getCachedPseudoSty le(pseudoElementSpecifier) : rareData.computedStyle();
2325 } 2325 }
2326 2326
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after
2924 updateId(oldValue, newValue); 2924 updateId(oldValue, newValue);
2925 else if (name == HTMLNames::nameAttr) 2925 else if (name == HTMLNames::nameAttr)
2926 updateName(oldValue, newValue); 2926 updateName(oldValue, newValue);
2927 else if (name == HTMLNames::forAttr && hasTagName(labelTag)) { 2927 else if (name == HTMLNames::forAttr && hasTagName(labelTag)) {
2928 TreeScope& scope = treeScope(); 2928 TreeScope& scope = treeScope();
2929 if (scope.shouldCacheLabelsByForAttribute()) 2929 if (scope.shouldCacheLabelsByForAttribute())
2930 updateLabel(scope, oldValue, newValue); 2930 updateLabel(scope, oldValue, newValue);
2931 } 2931 }
2932 2932
2933 if (oldValue != newValue) { 2933 if (oldValue != newValue) {
2934 if (confusingAndOftenMisusedAttached() && hasSelectorForAttribute(&docum ent(), name.localName())) 2934 if (inActiveDocument() && hasSelectorForAttribute(&document(), name.loca lName()))
2935 setNeedsStyleRecalc(); 2935 setNeedsStyleRecalc();
2936 2936
2937 if (isUpgradedCustomElement()) 2937 if (isUpgradedCustomElement())
2938 CustomElement::attributeDidChange(this, name.localName(), oldValue, newValue); 2938 CustomElement::attributeDidChange(this, name.localName(), oldValue, newValue);
2939 } 2939 }
2940 2940
2941 if (OwnPtr<MutationObserverInterestGroup> recipients = MutationObserverInter estGroup::createForAttributesMutation(this, name)) 2941 if (OwnPtr<MutationObserverInterestGroup> recipients = MutationObserverInter estGroup::createForAttributesMutation(this, name))
2942 recipients->enqueueMutationRecord(MutationRecord::createAttributes(this, name, oldValue)); 2942 recipients->enqueueMutationRecord(MutationRecord::createAttributes(this, name, oldValue));
2943 2943
2944 InspectorInstrumentation::willModifyDOMAttr(this, oldValue, newValue); 2944 InspectorInstrumentation::willModifyDOMAttr(this, oldValue, newValue);
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after
3431 // Before doing so, we need to resolve issues in HTMLSelectElement::recalcLi stItems 3431 // Before doing so, we need to resolve issues in HTMLSelectElement::recalcLi stItems
3432 // and RenderMenuList::setText. See also https://bugs.webkit.org/show_bug.cg i?id=88405 3432 // and RenderMenuList::setText. See also https://bugs.webkit.org/show_bug.cg i?id=88405
3433 if (hasTagName(optionTag) || hasTagName(optgroupTag)) 3433 if (hasTagName(optionTag) || hasTagName(optgroupTag))
3434 return false; 3434 return false;
3435 if (FullscreenElementStack::isActiveFullScreenElement(this)) 3435 if (FullscreenElementStack::isActiveFullScreenElement(this))
3436 return false; 3436 return false;
3437 return true; 3437 return true;
3438 } 3438 }
3439 3439
3440 } // namespace WebCore 3440 } // namespace WebCore
OLDNEW
« no previous file with comments | « no previous file | Source/core/dom/Node.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698