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

Side by Side Diff: Source/core/css/RuleFeature.cpp

Issue 170873004: Fix issue in which removing a class does not always invalidate style (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fixed comments. Created 6 years, 10 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) 3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com)
4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) 4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com)
5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All r ights reserved. 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All r ights reserved.
6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> 6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> 7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org>
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. 9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved.
10 * Copyright (C) Research In Motion Limited 2011. All rights reserved. 10 * Copyright (C) Research In Motion Limited 2011. All rights reserved.
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 Element* childElement = toElement(child); 373 Element* childElement = toElement(child);
374 bool childRecalced = invalidateStyleForClassChange(childElement, inv alidationClasses, foundInvalidationSet); 374 bool childRecalced = invalidateStyleForClassChange(childElement, inv alidationClasses, foundInvalidationSet);
375 someChildrenNeedStyleRecalc = someChildrenNeedStyleRecalc || childRe calced; 375 someChildrenNeedStyleRecalc = someChildrenNeedStyleRecalc || childRe calced;
376 } 376 }
377 } 377 }
378 return someChildrenNeedStyleRecalc; 378 return someChildrenNeedStyleRecalc;
379 } 379 }
380 380
381 bool RuleFeatureSet::invalidateStyleForClassChange(Element* element, Vector<Atom icString>& invalidationClasses, bool foundInvalidationSet) 381 bool RuleFeatureSet::invalidateStyleForClassChange(Element* element, Vector<Atom icString>& invalidationClasses, bool foundInvalidationSet)
382 { 382 {
383 bool thisElementNeedsStyleRecalc = false;
383 int oldSize = invalidationClasses.size(); 384 int oldSize = invalidationClasses.size();
385
384 if (element->needsStyleInvalidation()) { 386 if (element->needsStyleInvalidation()) {
385 if (InvalidationList* invalidationList = m_pendingInvalidationMap.get(el ement)) { 387 if (InvalidationList* invalidationList = m_pendingInvalidationMap.get(el ement)) {
388 thisElementNeedsStyleRecalc = true;
386 foundInvalidationSet = true; 389 foundInvalidationSet = true;
esprehn 2014/02/18 22:52:33 Isn't this bool identical to foundInvalidationSet
chrishtr 2014/02/18 23:14:31 No, because not all elements in the subtree of an
387 for (InvalidationList::const_iterator it = invalidationList->begin() ; it != invalidationList->end(); ++it) { 390 for (InvalidationList::const_iterator it = invalidationList->begin() ; it != invalidationList->end(); ++it) {
388 if ((*it)->wholeSubtreeInvalid()) { 391 if ((*it)->wholeSubtreeInvalid()) {
389 element->setNeedsStyleRecalc(SubtreeStyleChange); 392 element->setNeedsStyleRecalc(SubtreeStyleChange);
390 invalidationClasses.remove(oldSize, invalidationClasses.size () - oldSize); 393 invalidationClasses.remove(oldSize, invalidationClasses.size () - oldSize);
391 element->clearChildNeedsStyleInvalidation(); 394 element->clearChildNeedsStyleInvalidation();
392 return true; 395 return true;
393 } 396 }
394 (*it)->getClasses(invalidationClasses); 397 (*it)->getClasses(invalidationClasses);
395 } 398 }
396 } 399 }
397 } 400 }
398 401
399 bool thisElementNeedsStyleRecalc = false;
400
401 if (element->hasClass()) { 402 if (element->hasClass()) {
402 const SpaceSplitString& classNames = element->classNames(); 403 const SpaceSplitString& classNames = element->classNames();
403 for (Vector<AtomicString>::const_iterator it = invalidationClasses.begin (); it != invalidationClasses.end(); ++it) { 404 for (Vector<AtomicString>::const_iterator it = invalidationClasses.begin (); it != invalidationClasses.end(); ++it) {
404 if (classNames.contains(*it)) { 405 if (classNames.contains(*it)) {
405 thisElementNeedsStyleRecalc = true; 406 thisElementNeedsStyleRecalc = true;
406 break; 407 break;
407 } 408 }
408 } 409 }
409 } 410 }
410 411
411 // foundInvalidationSet will be true if we are in a subtree of a node with a DescendantInvalidationSet on it. 412 // foundInvalidationSet will be true if we are in a subtree of a node with a DescendantInvalidationSet on it.
412 // We need to check all nodes in the subtree of such a node. 413 // We need to check all nodes in the subtree of such a node.
413 if (foundInvalidationSet || element->childNeedsStyleInvalidation()) { 414 if (foundInvalidationSet || element->childNeedsStyleInvalidation()) {
414 bool someChildrenNeedStyleRecalc = invalidateStyleForClassChangeOnChildr en(element, invalidationClasses, foundInvalidationSet); 415 bool someChildrenNeedStyleRecalc = invalidateStyleForClassChangeOnChildr en(element, invalidationClasses, foundInvalidationSet);
415 // We only need to possibly recalc style if this node is in the subtree of a node with a DescendantInvalidationSet on it. 416 // We only need to possibly recalc style if this node is in the subtree of a node with a DescendantInvalidationSet on it.
416 if (foundInvalidationSet) 417 if (foundInvalidationSet)
417 thisElementNeedsStyleRecalc = thisElementNeedsStyleRecalc || someChi ldrenNeedStyleRecalc; 418 thisElementNeedsStyleRecalc = thisElementNeedsStyleRecalc || someChi ldrenNeedStyleRecalc;
esprehn 2014/02/18 22:52:33 This doesn't make sense now, thisElementNeedsStyle
chrishtr 2014/02/18 23:14:31 It's the other way around - foundInvalidationSet i
418 } 419 }
419 420
420 if (thisElementNeedsStyleRecalc) 421 if (thisElementNeedsStyleRecalc)
421 element->setNeedsStyleRecalc(LocalStyleChange); 422 element->setNeedsStyleRecalc(LocalStyleChange);
422 423
423 invalidationClasses.remove(oldSize, invalidationClasses.size() - oldSize); 424 invalidationClasses.remove(oldSize, invalidationClasses.size() - oldSize);
424 element->clearChildNeedsStyleInvalidation(); 425 element->clearChildNeedsStyleInvalidation();
425 return thisElementNeedsStyleRecalc; 426 return thisElementNeedsStyleRecalc;
426 } 427 }
427 428
428 } // namespace WebCore 429 } // namespace WebCore
OLDNEW
« no previous file with comments | « LayoutTests/virtual/targetedstylerecalc/fast/css/invalidation/targeted-class-style-invalidation-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698