Line data Source code
1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* This Source Code Form is subject to the terms of the Mozilla Public
3 : * License, v. 2.0. If a copy of the MPL was not distributed with this
4 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 :
6 : #include "ScrollLinkedEffectDetector.h"
7 :
8 : #include "nsIDocument.h"
9 : #include "nsThreadUtils.h"
10 :
11 : namespace mozilla {
12 : namespace layers {
13 :
14 : uint32_t ScrollLinkedEffectDetector::sDepth = 0;
15 : bool ScrollLinkedEffectDetector::sFoundScrollLinkedEffect = false;
16 :
17 : /* static */ void
18 0 : ScrollLinkedEffectDetector::PositioningPropertyMutated()
19 : {
20 0 : MOZ_ASSERT(NS_IsMainThread());
21 :
22 0 : if (sDepth > 0) {
23 : // We are inside a scroll event dispatch
24 0 : sFoundScrollLinkedEffect = true;
25 : }
26 0 : }
27 :
28 0 : ScrollLinkedEffectDetector::ScrollLinkedEffectDetector(nsIDocument* aDoc)
29 0 : : mDocument(aDoc)
30 : {
31 0 : MOZ_ASSERT(NS_IsMainThread());
32 0 : sDepth++;
33 0 : }
34 :
35 0 : ScrollLinkedEffectDetector::~ScrollLinkedEffectDetector()
36 : {
37 0 : sDepth--;
38 0 : if (sDepth == 0) {
39 : // We have exited all (possibly-nested) scroll event dispatches,
40 : // record whether or not we found an effect, and reset state
41 0 : if (sFoundScrollLinkedEffect) {
42 0 : mDocument->ReportHasScrollLinkedEffect();
43 0 : sFoundScrollLinkedEffect = false;
44 : }
45 : }
46 0 : }
47 :
48 : } // namespace layers
49 : } // namespace mozilla
|