| Index: Source/core/dom/Document.cpp
 | 
| diff --git a/Source/core/dom/Document.cpp b/Source/core/dom/Document.cpp
 | 
| index 19d77afcb8e6d2c02e924007454be93d07f6d5fe..fd413d2163171848d19d6449020d7e8c7d793647 100644
 | 
| --- a/Source/core/dom/Document.cpp
 | 
| +++ b/Source/core/dom/Document.cpp
 | 
| @@ -1579,7 +1579,7 @@ PassRefPtr<TreeWalker> Document::createTreeWalker(Node* root, unsigned whatToSho
 | 
|  
 | 
|  bool Document::shouldCallRecalcStyleForDocument()
 | 
|  {
 | 
| -    return needsStyleRecalc() || childNeedsStyleRecalc() || childNeedsDistributionRecalc() || !m_useElementsNeedingUpdate.isEmpty();
 | 
| +    return needsStyleRecalc() || childNeedsStyleRecalc() || childNeedsDistributionRecalc() || !m_useElementsNeedingUpdate.isEmpty() || childNeedsStyleInvalidation();
 | 
|  }
 | 
|  
 | 
|  void Document::scheduleStyleRecalc()
 | 
| @@ -1617,6 +1617,21 @@ void Document::updateDistributionIfNeeded()
 | 
|      recalcDistribution();
 | 
|  }
 | 
|  
 | 
| +void Document::updateStyleInvalidationIfNeeded()
 | 
| +{
 | 
| +    if (!childNeedsStyleInvalidation())
 | 
| +        return;
 | 
| +    TRACE_EVENT0("webkit", "Document::computeNeedsStyleRecalcState");
 | 
| +    if (!styleResolver()) {
 | 
| +        clearChildNeedsStyleInvalidation();
 | 
| +        return;
 | 
| +    }
 | 
| +
 | 
| +    // FIXME: the style resolver can be deleted at present. Either resolve
 | 
| +    // crbug.com/335964 or move the invalidation data elsewhere.
 | 
| +    styleResolver()->ensureRuleFeatureSet().computeStyleInvalidation(*this);
 | 
| +}
 | 
| +
 | 
|  void Document::updateDistributionForNodeIfNeeded(Node* node)
 | 
|  {
 | 
|      if (node->inDocument()) {
 | 
| @@ -1705,6 +1720,7 @@ void Document::inheritHtmlAndBodyElementStyles(StyleRecalcChange change)
 | 
|      }
 | 
|  }
 | 
|  
 | 
| +// FIXME: need a better name than recalcStyle. It's performing style invalidation, style recalc, and distribution.
 | 
|  void Document::recalcStyle(StyleRecalcChange change)
 | 
|  {
 | 
|      // we should not enter style recalc while painting
 | 
| @@ -1724,6 +1740,7 @@ void Document::recalcStyle(StyleRecalcChange change)
 | 
|  
 | 
|      updateDistributionIfNeeded();
 | 
|      updateUseShadowTrees();
 | 
| +    updateStyleInvalidationIfNeeded();
 | 
|  
 | 
|      if (m_evaluateMediaQueriesOnStyleRecalc) {
 | 
|          m_evaluateMediaQueriesOnStyleRecalc = false;
 | 
| @@ -1826,7 +1843,7 @@ void Document::updateStyleForNodeIfNeeded(Node* node)
 | 
|      // the path from 'node' to the root needs style recalc.
 | 
|  
 | 
|      // Global needed.
 | 
| -    bool needsRecalc = needsStyleRecalc() || childNeedsDistributionRecalc() || !m_useElementsNeedingUpdate.isEmpty();
 | 
| +    bool needsRecalc = needsStyleRecalc() || childNeedsDistributionRecalc() || !m_useElementsNeedingUpdate.isEmpty() || childNeedsStyleInvalidation();
 | 
|  
 | 
|      // On the path.
 | 
|      for (Node* ancestor = node; ancestor && !needsRecalc; ancestor = ancestor->parentOrShadowHostNode())
 | 
| 
 |