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

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

Issue 217713002: Refactor StyleInvalidator to encapsulate all style invalidation state. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Remove explicit. Created 6 years, 8 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/css/RuleFeature.h ('k') | Source/core/css/invalidation/StyleInvalidator.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) 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 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 uncommonAttributeRules.appendVector(other.uncommonAttributeRules); 341 uncommonAttributeRules.appendVector(other.uncommonAttributeRules);
342 } 342 }
343 343
344 void RuleFeatureSet::clear() 344 void RuleFeatureSet::clear()
345 { 345 {
346 siblingRules.clear(); 346 siblingRules.clear();
347 uncommonAttributeRules.clear(); 347 uncommonAttributeRules.clear();
348 m_metadata.clear(); 348 m_metadata.clear();
349 m_classInvalidationSets.clear(); 349 m_classInvalidationSets.clear();
350 m_attributeInvalidationSets.clear(); 350 m_attributeInvalidationSets.clear();
351 m_pendingInvalidationMap.clear(); 351 m_styleInvalidator.clearPendingInvalidations();
352 } 352 }
353 353
354 void RuleFeatureSet::scheduleStyleInvalidationForClassChange(const SpaceSplitStr ing& changedClasses, Element* element) 354 void RuleFeatureSet::scheduleStyleInvalidationForClassChange(const SpaceSplitStr ing& changedClasses, Element& element)
355 { 355 {
356 unsigned changedSize = changedClasses.size(); 356 unsigned changedSize = changedClasses.size();
357 for (unsigned i = 0; i < changedSize; ++i) { 357 for (unsigned i = 0; i < changedSize; ++i) {
358 addClassToInvalidationSet(changedClasses[i], element); 358 addClassToInvalidationSet(changedClasses[i], element);
359 } 359 }
360 } 360 }
361 361
362 void RuleFeatureSet::scheduleStyleInvalidationForClassChange(const SpaceSplitStr ing& oldClasses, const SpaceSplitString& newClasses, Element* element) 362 void RuleFeatureSet::scheduleStyleInvalidationForClassChange(const SpaceSplitStr ing& oldClasses, const SpaceSplitString& newClasses, Element& element)
363 { 363 {
364 if (!oldClasses.size()) 364 if (!oldClasses.size())
365 scheduleStyleInvalidationForClassChange(newClasses, element); 365 scheduleStyleInvalidationForClassChange(newClasses, element);
366 366
367 // Class vectors tend to be very short. This is faster than using a hash tab le. 367 // Class vectors tend to be very short. This is faster than using a hash tab le.
368 BitVector remainingClassBits; 368 BitVector remainingClassBits;
369 remainingClassBits.ensureSize(oldClasses.size()); 369 remainingClassBits.ensureSize(oldClasses.size());
370 370
371 for (unsigned i = 0; i < newClasses.size(); ++i) { 371 for (unsigned i = 0; i < newClasses.size(); ++i) {
372 bool found = false; 372 bool found = false;
(...skipping 12 matching lines...) Expand all
385 } 385 }
386 386
387 for (unsigned i = 0; i < oldClasses.size(); ++i) { 387 for (unsigned i = 0; i < oldClasses.size(); ++i) {
388 if (remainingClassBits.quickGet(i)) 388 if (remainingClassBits.quickGet(i))
389 continue; 389 continue;
390 // Class was removed. 390 // Class was removed.
391 addClassToInvalidationSet(oldClasses[i], element); 391 addClassToInvalidationSet(oldClasses[i], element);
392 } 392 }
393 } 393 }
394 394
395 void RuleFeatureSet::scheduleStyleInvalidationForAttributeChange(const Qualified Name& attributeName, Element* element) 395 void RuleFeatureSet::scheduleStyleInvalidationForAttributeChange(const Qualified Name& attributeName, Element& element)
396 { 396 {
397 if (RefPtr<DescendantInvalidationSet> invalidationSet = m_attributeInvalidat ionSets.get(attributeName.localName())) { 397 if (RefPtr<DescendantInvalidationSet> invalidationSet = m_attributeInvalidat ionSets.get(attributeName.localName()))
398 ensurePendingInvalidationList(element).append(invalidationSet); 398 m_styleInvalidator.scheduleInvalidation(invalidationSet, element);
399 element->setNeedsStyleInvalidation();
400 }
401 } 399 }
402 400
403 void RuleFeatureSet::addClassToInvalidationSet(const AtomicString& className, El ement* element) 401 void RuleFeatureSet::addClassToInvalidationSet(const AtomicString& className, El ement& element)
404 { 402 {
405 if (RefPtr<DescendantInvalidationSet> invalidationSet = m_classInvalidationS ets.get(className)) { 403 if (RefPtr<DescendantInvalidationSet> invalidationSet = m_classInvalidationS ets.get(className))
406 ensurePendingInvalidationList(element).append(invalidationSet); 404 m_styleInvalidator.scheduleInvalidation(invalidationSet, element);
407 element->setNeedsStyleInvalidation();
408 }
409 } 405 }
410 406
411 RuleFeatureSet::InvalidationList& RuleFeatureSet::ensurePendingInvalidationList( Element* element) 407 StyleInvalidator& RuleFeatureSet::styleInvalidator()
412 { 408 {
413 PendingInvalidationMap::AddResult addResult = m_pendingInvalidationMap.add(e lement, nullptr); 409 return m_styleInvalidator;
414 if (addResult.isNewEntry)
415 addResult.storedValue->value = adoptPtr(new InvalidationList);
416 return *addResult.storedValue->value;
417 }
418
419 void RuleFeatureSet::clearStyleInvalidation(Node* node)
420 {
421 node->clearChildNeedsStyleInvalidation();
422 node->clearNeedsStyleInvalidation();
423 if (node->isElementNode())
424 m_pendingInvalidationMap.remove(toElement(node));
425 }
426
427 RuleFeatureSet::PendingInvalidationMap& RuleFeatureSet::pendingInvalidationMap()
428 {
429 return m_pendingInvalidationMap;
430 } 410 }
431 411
432 } // namespace WebCore 412 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/css/RuleFeature.h ('k') | Source/core/css/invalidation/StyleInvalidator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698