Index: third_party/WebKit/Source/core/dom/DocumentLifecycle.h |
diff --git a/third_party/WebKit/Source/core/dom/DocumentLifecycle.h b/third_party/WebKit/Source/core/dom/DocumentLifecycle.h |
index 8a05f66132effcf255ec2ebb9ff72cbda8ce650a..170006505f026fa74b722e83bbe8aee029879484 100644 |
--- a/third_party/WebKit/Source/core/dom/DocumentLifecycle.h |
+++ b/third_party/WebKit/Source/core/dom/DocumentLifecycle.h |
@@ -150,6 +150,28 @@ class CORE_EXPORT DocumentLifecycle { |
DocumentLifecycle& m_documentLifecycle; |
}; |
+ // This scope should only be used when we need to call hasEditableStyle(), but |
+ // the document's style may be dirty and cannot be updated due to some other |
+ // blockers. In the long term, we should fix those blockers and remove this |
+ // scope. See crbug.com/667575 for details. |
+ class DisallowStyleRecalcScope { |
+ STACK_ALLOCATED(); |
+ DISALLOW_COPY_AND_ASSIGN(DisallowStyleRecalcScope); |
+ |
+ public: |
+ explicit DisallowStyleRecalcScope(DocumentLifecycle& documentLifecycle) |
+ : m_documentLifecycle(documentLifecycle) { |
+ m_documentLifecycle.incrementNoStyleRecalcCount(); |
+ } |
+ |
+ ~DisallowStyleRecalcScope() { |
+ m_documentLifecycle.decrementNoStyleRecalcCount(); |
+ } |
+ |
+ private: |
+ DocumentLifecycle& m_documentLifecycle; |
+ }; |
+ |
// Throttling is disabled by default. Instantiating this class allows |
// throttling (e.g., during BeginMainFrame). If a script needs to run inside |
// this scope, DisallowThrottlingScope should be used to let the script |
@@ -204,6 +226,10 @@ class CORE_EXPORT DocumentLifecycle { |
m_detachCount--; |
} |
+ bool styleRecalcDisallowed() const { return m_disallowStyleRecalcCount; } |
+ void incrementNoStyleRecalcCount() { ++m_disallowStyleRecalcCount; } |
+ void decrementNoStyleRecalcCount() { --m_disallowStyleRecalcCount; } |
+ |
bool throttlingAllowed() const; |
private: |
@@ -216,6 +242,7 @@ class CORE_EXPORT DocumentLifecycle { |
LifecycleState m_state; |
int m_detachCount; |
int m_disallowTransitionCount; |
+ int m_disallowStyleRecalcCount; |
}; |
inline bool DocumentLifecycle::stateAllowsTreeMutations() const { |