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

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: modify Document::styleResolver 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 971 matching lines...) Expand 10 before | Expand all | Expand 10 after
982 } else if (isStyledElement() && isPresentationAttribute(name)) { 982 } else if (isStyledElement() && isPresentationAttribute(name)) {
983 elementData()->m_presentationAttributeStyleIsDirty = true; 983 elementData()->m_presentationAttributeStyleIsDirty = true;
984 setNeedsStyleRecalc(LocalStyleChange); 984 setNeedsStyleRecalc(LocalStyleChange);
985 } 985 }
986 986
987 if (isIdAttributeName(name)) { 987 if (isIdAttributeName(name)) {
988 AtomicString oldId = elementData()->idForStyleResolution(); 988 AtomicString oldId = elementData()->idForStyleResolution();
989 AtomicString newId = makeIdForStyleResolution(newValue, document().inQui rksMode()); 989 AtomicString newId = makeIdForStyleResolution(newValue, document().inQui rksMode());
990 if (newId != oldId) { 990 if (newId != oldId) {
991 elementData()->setIdForStyleResolution(newId); 991 elementData()->setIdForStyleResolution(newId);
992 shouldInvalidateStyle = testShouldInvalidateStyle && checkNeedsStyle InvalidationForIdChange(oldId, newId, styleResolver->ruleFeatureSet()); 992 shouldInvalidateStyle = testShouldInvalidateStyle && checkNeedsStyle InvalidationForIdChange(oldId, newId, styleResolver->ensureRuleFeatureSet());
993 } 993 }
994 } else if (name == classAttr) { 994 } else if (name == classAttr) {
995 classAttributeChanged(newValue); 995 classAttributeChanged(newValue);
996 } else if (name == HTMLNames::nameAttr) { 996 } else if (name == HTMLNames::nameAttr) {
997 setHasName(!newValue.isNull()); 997 setHasName(!newValue.isNull());
998 } else if (name == HTMLNames::pseudoAttr) { 998 } else if (name == HTMLNames::pseudoAttr) {
999 shouldInvalidateStyle |= testShouldInvalidateStyle && isInShadowTree(); 999 shouldInvalidateStyle |= testShouldInvalidateStyle && isInShadowTree();
1000 } 1000 }
1001 1001
1002 invalidateNodeListCachesInAncestors(&name, this); 1002 invalidateNodeListCachesInAncestors(&name, this);
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
1097 { 1097 {
1098 StyleResolver* styleResolver = document().styleResolverIfExists(); 1098 StyleResolver* styleResolver = document().styleResolverIfExists();
1099 bool testShouldInvalidateStyle = inActiveDocument() && styleResolver && styl eChangeType() < SubtreeStyleChange; 1099 bool testShouldInvalidateStyle = inActiveDocument() && styleResolver && styl eChangeType() < SubtreeStyleChange;
1100 bool shouldInvalidateStyle = false; 1100 bool shouldInvalidateStyle = false;
1101 1101
1102 if (classStringHasClassName(newClassString)) { 1102 if (classStringHasClassName(newClassString)) {
1103 const bool shouldFoldCase = document().inQuirksMode(); 1103 const bool shouldFoldCase = document().inQuirksMode();
1104 const SpaceSplitString oldClasses = elementData()->classNames(); 1104 const SpaceSplitString oldClasses = elementData()->classNames();
1105 elementData()->setClass(newClassString, shouldFoldCase); 1105 elementData()->setClass(newClassString, shouldFoldCase);
1106 const SpaceSplitString& newClasses = elementData()->classNames(); 1106 const SpaceSplitString& newClasses = elementData()->classNames();
1107 shouldInvalidateStyle = testShouldInvalidateStyle && checkSelectorForCla ssChange(oldClasses, newClasses, styleResolver->ruleFeatureSet()); 1107 shouldInvalidateStyle = testShouldInvalidateStyle && checkSelectorForCla ssChange(oldClasses, newClasses, styleResolver->ensureRuleFeatureSet());
1108 } else { 1108 } else {
1109 const SpaceSplitString& oldClasses = elementData()->classNames(); 1109 const SpaceSplitString& oldClasses = elementData()->classNames();
1110 shouldInvalidateStyle = testShouldInvalidateStyle && checkSelectorForCla ssChange(oldClasses, styleResolver->ruleFeatureSet()); 1110 shouldInvalidateStyle = testShouldInvalidateStyle && checkSelectorForCla ssChange(oldClasses, styleResolver->ensureRuleFeatureSet());
1111 elementData()->clearClass(); 1111 elementData()->clearClass();
1112 } 1112 }
1113 1113
1114 if (hasRareData()) 1114 if (hasRareData())
1115 elementRareData()->clearClassListValueForQuirksMode(); 1115 elementRareData()->clearClassListValueForQuirksMode();
1116 1116
1117 if (shouldInvalidateStyle) 1117 if (shouldInvalidateStyle)
1118 setNeedsStyleRecalc(); 1118 setNeedsStyleRecalc();
1119 } 1119 }
1120 1120
(...skipping 1858 matching lines...) Expand 10 before | Expand all | Expand 10 after
2979 return; 2979 return;
2980 2980
2981 if (!oldForAttributeValue.isEmpty()) 2981 if (!oldForAttributeValue.isEmpty())
2982 scope.removeLabel(oldForAttributeValue, toHTMLLabelElement(this)); 2982 scope.removeLabel(oldForAttributeValue, toHTMLLabelElement(this));
2983 if (!newForAttributeValue.isEmpty()) 2983 if (!newForAttributeValue.isEmpty())
2984 scope.addLabel(newForAttributeValue, toHTMLLabelElement(this)); 2984 scope.addLabel(newForAttributeValue, toHTMLLabelElement(this));
2985 } 2985 }
2986 2986
2987 static bool hasSelectorForAttribute(Document* document, const AtomicString& loca lName) 2987 static bool hasSelectorForAttribute(Document* document, const AtomicString& loca lName)
2988 { 2988 {
2989 return document->styleResolver() && document->styleResolver()->ruleFeatureSe t().hasSelectorForAttribute(localName); 2989 return document->styleResolver() && document->styleResolver()->ensureRuleFea tureSet().hasSelectorForAttribute(localName);
2990 } 2990 }
2991 2991
2992 void Element::willModifyAttribute(const QualifiedName& name, const AtomicString& oldValue, const AtomicString& newValue) 2992 void Element::willModifyAttribute(const QualifiedName& name, const AtomicString& oldValue, const AtomicString& newValue)
2993 { 2993 {
2994 if (isIdAttributeName(name)) 2994 if (isIdAttributeName(name))
2995 updateId(oldValue, newValue); 2995 updateId(oldValue, newValue);
2996 else if (name == HTMLNames::nameAttr) 2996 else if (name == HTMLNames::nameAttr)
2997 updateName(oldValue, newValue); 2997 updateName(oldValue, newValue);
2998 else if (name == HTMLNames::forAttr && hasTagName(labelTag)) { 2998 else if (name == HTMLNames::forAttr && hasTagName(labelTag)) {
2999 TreeScope& scope = treeScope(); 2999 TreeScope& scope = treeScope();
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after
3507 // Before doing so, we need to resolve issues in HTMLSelectElement::recalcLi stItems 3507 // Before doing so, we need to resolve issues in HTMLSelectElement::recalcLi stItems
3508 // and RenderMenuList::setText. See also https://bugs.webkit.org/show_bug.cg i?id=88405 3508 // and RenderMenuList::setText. See also https://bugs.webkit.org/show_bug.cg i?id=88405
3509 if (hasTagName(optionTag) || hasTagName(optgroupTag)) 3509 if (hasTagName(optionTag) || hasTagName(optgroupTag))
3510 return false; 3510 return false;
3511 if (FullscreenElementStack::isActiveFullScreenElement(this)) 3511 if (FullscreenElementStack::isActiveFullScreenElement(this))
3512 return false; 3512 return false;
3513 return true; 3513 return true;
3514 } 3514 }
3515 3515
3516 } // namespace WebCore 3516 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698