| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #ifndef SharedBufferReader_h | 31 #ifndef ProgrammaticScrollAnimator_h |
| 32 #define SharedBufferReader_h | 32 #define ProgrammaticScrollAnimator_h |
| 33 | 33 |
| 34 #include "platform/geometry/FloatPoint.h" |
| 34 #include "wtf/FastAllocBase.h" | 35 #include "wtf/FastAllocBase.h" |
| 35 #include "wtf/Forward.h" | 36 #include "wtf/Noncopyable.h" |
| 36 #include "wtf/RefPtr.h" | 37 #include "wtf/OwnPtr.h" |
| 38 #include "wtf/PassOwnPtr.h" |
| 39 |
| 40 namespace blink { |
| 41 class WebScrollOffsetAnimationCurve; |
| 42 } |
| 37 | 43 |
| 38 namespace WebCore { | 44 namespace WebCore { |
| 39 | 45 |
| 40 class SharedBuffer; | 46 class ScrollableArea; |
| 41 | 47 |
| 42 // Allows transfer of data in multiple chunks from a SharedBuffer to a provided
buffer. | 48 class ProgrammaticScrollAnimator { |
| 43 class SharedBufferReader { | 49 WTF_MAKE_NONCOPYABLE(ProgrammaticScrollAnimator); |
| 44 WTF_MAKE_FAST_ALLOCATED; | 50 WTF_MAKE_FAST_ALLOCATED; |
| 45 public: | 51 public: |
| 46 SharedBufferReader(PassRefPtr<SharedBuffer>); | 52 static PassOwnPtr<ProgrammaticScrollAnimator> create(ScrollableArea*); |
| 47 | 53 |
| 48 ~SharedBufferReader(); | 54 ~ProgrammaticScrollAnimator(); |
| 49 | 55 |
| 50 // Returns the number of bytes that were read (i.e. written to |outputBuffer
|). | 56 void animateToOffset(FloatPoint); |
| 51 int readData(char* outputBuffer, unsigned askedToRead); | 57 void cancelAnimation(); |
| 58 void tickAnimation(double monotonicTime); |
| 59 |
| 60 void notifyAnimationStarted(double monotonicTime); |
| 61 void notifyAnimationFinished(double monotonicTime); |
| 62 |
| 63 void canUseCompositedScrollAnimationsDidChange(); |
| 52 | 64 |
| 53 private: | 65 private: |
| 54 RefPtr<SharedBuffer> m_buffer; | 66 explicit ProgrammaticScrollAnimator(ScrollableArea*); |
| 55 unsigned m_currentOffset; | 67 |
| 68 void resetAnimationState(); |
| 69 |
| 70 ScrollableArea* m_scrollableArea; |
| 71 OwnPtr<blink::WebScrollOffsetAnimationCurve> m_animationCurve; |
| 72 FloatPoint m_targetOffset; |
| 73 int m_animationId; |
| 74 double m_startTime; |
| 56 }; | 75 }; |
| 57 | 76 |
| 58 } // namespace WebCore | 77 } // namespace WebCore |
| 59 | 78 |
| 60 #endif // SharedBufferReader_h | 79 #endif // ProgrammaticScrollAnimator_h |
| OLD | NEW |