ScrollLinkedEffectDetector.h (1598B)
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #ifndef mozilla_layers_ScrollLinkedEffectDetector_h 8 #define mozilla_layers_ScrollLinkedEffectDetector_h 9 10 #include "mozilla/RefPtr.h" 11 #include "mozilla/TimeStamp.h" 12 13 namespace mozilla { 14 15 namespace dom { 16 class Document; 17 } 18 19 namespace layers { 20 21 // ScrollLinkedEffectDetector is used to detect the existence of a scroll-linked 22 // effect on a webpage. Generally speaking, a scroll-linked effect is something 23 // on the page that animates or changes with respect to the scroll position. 24 // Content authors usually rely on running some JS in response to the scroll 25 // event in order to implement such effects, and therefore it tends to be laggy 26 // or work improperly with APZ enabled. This class helps us detect such an 27 // effect so that we can warn the author and/or take other preventative 28 // measures. 29 class MOZ_STACK_CLASS ScrollLinkedEffectDetector final { 30 private: 31 static uint32_t sDepth; 32 static bool sFoundScrollLinkedEffect; 33 34 public: 35 static void PositioningPropertyMutated(); 36 37 ScrollLinkedEffectDetector(dom::Document*, const TimeStamp& aTimeStamp); 38 ~ScrollLinkedEffectDetector(); 39 40 private: 41 RefPtr<dom::Document> mDocument; 42 TimeStamp mTimeStamp; 43 }; 44 45 } // namespace layers 46 } // namespace mozilla 47 48 #endif /* mozilla_layers_ScrollLinkedEffectDetector_h */