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

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

Issue 42543007: StyleResolver should update RuleSets lazily. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Revised 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
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 974 matching lines...) Expand 10 before | Expand all | Expand 10 after
985 } else if (isStyledElement() && isPresentationAttribute(name)) { 985 } else if (isStyledElement() && isPresentationAttribute(name)) {
986 elementData()->m_presentationAttributeStyleIsDirty = true; 986 elementData()->m_presentationAttributeStyleIsDirty = true;
987 setNeedsStyleRecalc(LocalStyleChange); 987 setNeedsStyleRecalc(LocalStyleChange);
988 } 988 }
989 989
990 if (isIdAttributeName(name)) { 990 if (isIdAttributeName(name)) {
991 AtomicString oldId = elementData()->idForStyleResolution(); 991 AtomicString oldId = elementData()->idForStyleResolution();
992 AtomicString newId = makeIdForStyleResolution(newValue, document().inQui rksMode()); 992 AtomicString newId = makeIdForStyleResolution(newValue, document().inQui rksMode());
993 if (newId != oldId) { 993 if (newId != oldId) {
994 elementData()->setIdForStyleResolution(newId); 994 elementData()->setIdForStyleResolution(newId);
995 shouldInvalidateStyle = testShouldInvalidateStyle && checkNeedsStyle InvalidationForIdChange(oldId, newId, styleResolver->ruleFeatureSet()); 995 shouldInvalidateStyle = testShouldInvalidateStyle && checkNeedsStyle InvalidationForIdChange(oldId, newId, styleResolver->ensureRuleFeatureSet());
996 } 996 }
997 } else if (name == classAttr) { 997 } else if (name == classAttr) {
998 classAttributeChanged(newValue); 998 classAttributeChanged(newValue);
999 } else if (name == HTMLNames::nameAttr) { 999 } else if (name == HTMLNames::nameAttr) {
1000 setHasName(!newValue.isNull()); 1000 setHasName(!newValue.isNull());
1001 } else if (name == HTMLNames::pseudoAttr) { 1001 } else if (name == HTMLNames::pseudoAttr) {
1002 shouldInvalidateStyle |= testShouldInvalidateStyle && isInShadowTree(); 1002 shouldInvalidateStyle |= testShouldInvalidateStyle && isInShadowTree();
1003 } 1003 }
1004 1004
1005 invalidateNodeListCachesInAncestors(&name, this); 1005 invalidateNodeListCachesInAncestors(&name, this);
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
1100 { 1100 {
1101 StyleResolver* styleResolver = document().styleResolverIfExists(); 1101 StyleResolver* styleResolver = document().styleResolverIfExists();
1102 bool testShouldInvalidateStyle = inActiveDocument() && styleResolver && styl eChangeType() < SubtreeStyleChange; 1102 bool testShouldInvalidateStyle = inActiveDocument() && styleResolver && styl eChangeType() < SubtreeStyleChange;
1103 bool shouldInvalidateStyle = false; 1103 bool shouldInvalidateStyle = false;
1104 1104
1105 if (classStringHasClassName(newClassString)) { 1105 if (classStringHasClassName(newClassString)) {
1106 const bool shouldFoldCase = document().inQuirksMode(); 1106 const bool shouldFoldCase = document().inQuirksMode();
1107 const SpaceSplitString oldClasses = elementData()->classNames(); 1107 const SpaceSplitString oldClasses = elementData()->classNames();
1108 elementData()->setClass(newClassString, shouldFoldCase); 1108 elementData()->setClass(newClassString, shouldFoldCase);
1109 const SpaceSplitString& newClasses = elementData()->classNames(); 1109 const SpaceSplitString& newClasses = elementData()->classNames();
1110 shouldInvalidateStyle = testShouldInvalidateStyle && checkSelectorForCla ssChange(oldClasses, newClasses, styleResolver->ruleFeatureSet()); 1110 shouldInvalidateStyle = testShouldInvalidateStyle && checkSelectorForCla ssChange(oldClasses, newClasses, styleResolver->ensureRuleFeatureSet());
1111 } else { 1111 } else {
1112 const SpaceSplitString& oldClasses = elementData()->classNames(); 1112 const SpaceSplitString& oldClasses = elementData()->classNames();
1113 shouldInvalidateStyle = testShouldInvalidateStyle && checkSelectorForCla ssChange(oldClasses, styleResolver->ruleFeatureSet()); 1113 shouldInvalidateStyle = testShouldInvalidateStyle && checkSelectorForCla ssChange(oldClasses, styleResolver->ensureRuleFeatureSet());
1114 elementData()->clearClass(); 1114 elementData()->clearClass();
1115 } 1115 }
1116 1116
1117 if (hasRareData()) 1117 if (hasRareData())
1118 elementRareData()->clearClassListValueForQuirksMode(); 1118 elementRareData()->clearClassListValueForQuirksMode();
1119 1119
1120 if (shouldInvalidateStyle) 1120 if (shouldInvalidateStyle)
1121 setNeedsStyleRecalc(); 1121 setNeedsStyleRecalc();
1122 } 1122 }
1123 1123
(...skipping 1865 matching lines...) Expand 10 before | Expand all | Expand 10 after
2989 return; 2989 return;
2990 2990
2991 if (!oldForAttributeValue.isEmpty()) 2991 if (!oldForAttributeValue.isEmpty())
2992 scope.removeLabel(oldForAttributeValue, toHTMLLabelElement(this)); 2992 scope.removeLabel(oldForAttributeValue, toHTMLLabelElement(this));
2993 if (!newForAttributeValue.isEmpty()) 2993 if (!newForAttributeValue.isEmpty())
2994 scope.addLabel(newForAttributeValue, toHTMLLabelElement(this)); 2994 scope.addLabel(newForAttributeValue, toHTMLLabelElement(this));
2995 } 2995 }
2996 2996
2997 static bool hasSelectorForAttribute(Document* document, const AtomicString& loca lName) 2997 static bool hasSelectorForAttribute(Document* document, const AtomicString& loca lName)
2998 { 2998 {
2999 return document->styleResolver() && document->styleResolver()->ruleFeatureSe t().hasSelectorForAttribute(localName); 2999 return document->styleResolver() && document->styleResolver()->ensureRuleFea tureSet().hasSelectorForAttribute(localName);
3000 } 3000 }
3001 3001
3002 void Element::willModifyAttribute(const QualifiedName& name, const AtomicString& oldValue, const AtomicString& newValue) 3002 void Element::willModifyAttribute(const QualifiedName& name, const AtomicString& oldValue, const AtomicString& newValue)
3003 { 3003 {
3004 if (isIdAttributeName(name)) 3004 if (isIdAttributeName(name))
3005 updateId(oldValue, newValue); 3005 updateId(oldValue, newValue);
3006 else if (name == HTMLNames::nameAttr) 3006 else if (name == HTMLNames::nameAttr)
3007 updateName(oldValue, newValue); 3007 updateName(oldValue, newValue);
3008 else if (name == HTMLNames::forAttr && hasTagName(labelTag)) { 3008 else if (name == HTMLNames::forAttr && hasTagName(labelTag)) {
3009 TreeScope& scope = treeScope(); 3009 TreeScope& scope = treeScope();
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after
3517 // Before doing so, we need to resolve issues in HTMLSelectElement::recalcLi stItems 3517 // Before doing so, we need to resolve issues in HTMLSelectElement::recalcLi stItems
3518 // and RenderMenuList::setText. See also https://bugs.webkit.org/show_bug.cg i?id=88405 3518 // and RenderMenuList::setText. See also https://bugs.webkit.org/show_bug.cg i?id=88405
3519 if (hasTagName(optionTag) || hasTagName(optgroupTag)) 3519 if (hasTagName(optionTag) || hasTagName(optgroupTag))
3520 return false; 3520 return false;
3521 if (FullscreenElementStack::isActiveFullScreenElement(this)) 3521 if (FullscreenElementStack::isActiveFullScreenElement(this))
3522 return false; 3522 return false;
3523 return true; 3523 return true;
3524 } 3524 }
3525 3525
3526 } // namespace WebCore 3526 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698