Chromium Code Reviews| 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..382a1129e6cf7af8d9f18c9a3a5f341c3d899c05 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(); |
| + WTF_MAKE_NONCOPYABLE(DisallowStyleRecalcScope); |
|
yosin_UTC9
2016/11/25 09:52:37
Use |DISALLOW_COPY_AND_ASSIGN(DisallowStyleRecalcS
Xiaocheng
2016/11/25 10:05:32
Done.
|
| + |
| + 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 { |