| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * Copyright (C) 2007, 2010 Apple Inc. All rights reserved. | 4 * Copyright (C) 2007, 2010 Apple Inc. All rights reserved. |
| 5 * | 5 * |
| 6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
| 7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
| 8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
| 9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
| 10 * | 10 * |
| 11 * This library is distributed in the hope that it will be useful, | 11 * This library is distributed in the hope that it will be useful, |
| 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 * Library General Public License for more details. | 14 * Library General Public License for more details. |
| 15 * | 15 * |
| 16 * You should have received a copy of the GNU Library General Public License | 16 * You should have received a copy of the GNU Library General Public License |
| 17 * along with this library; see the file COPYING.LIB. If not, write to | 17 * along with this library; see the file COPYING.LIB. If not, write to |
| 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 19 * Boston, MA 02110-1301, USA. | 19 * Boston, MA 02110-1301, USA. |
| 20 * | 20 * |
| 21 */ | 21 */ |
| 22 | 22 |
| 23 #ifndef HTMLMarqueeElement_h | 23 #ifndef HTMLMarqueeElement_h |
| 24 #define HTMLMarqueeElement_h | 24 #define HTMLMarqueeElement_h |
| 25 | 25 |
| 26 #include "core/animation/Animation.h" |
| 27 #include "core/animation/KeyframeEffectModel.h" |
| 28 #include "core/dom/FrameRequestCallback.h" |
| 26 #include "core/html/HTMLElement.h" | 29 #include "core/html/HTMLElement.h" |
| 30 #include "wtf/Noncopyable.h" |
| 27 | 31 |
| 28 namespace blink { | 32 namespace blink { |
| 29 | 33 |
| 30 class HTMLMarqueeElement final : public HTMLElement { | 34 class HTMLMarqueeElement final : public HTMLElement { |
| 31 DEFINE_WRAPPERTYPEINFO(); | 35 DEFINE_WRAPPERTYPEINFO(); |
| 32 | 36 |
| 33 public: | 37 public: |
| 38 DECLARE_VIRTUAL_TRACE(); |
| 39 |
| 34 static HTMLMarqueeElement* create(Document&); | 40 static HTMLMarqueeElement* create(Document&); |
| 35 | 41 |
| 36 void attributeChanged(const QualifiedName&, | 42 void attributeChanged(const QualifiedName&, |
| 37 const AtomicString& oldValue, | 43 const AtomicString& oldValue, |
| 38 const AtomicString& newValue, | 44 const AtomicString& newValue, |
| 39 AttributeModificationReason) final; | 45 AttributeModificationReason) final; |
| 40 InsertionNotificationRequest insertedInto(ContainerNode*) final; | 46 InsertionNotificationRequest insertedInto(ContainerNode*) final; |
| 41 void removedFrom(ContainerNode*) final; | 47 void removedFrom(ContainerNode*) final; |
| 42 | 48 |
| 43 bool isHorizontal() const; | 49 bool isHorizontal() const; |
| 44 | 50 |
| 51 int scrollAmount(); |
| 52 void setScrollAmount(int, ExceptionState&); |
| 53 |
| 54 int scrollDelay(); |
| 55 void setScrollDelay(int, ExceptionState&); |
| 56 |
| 57 int loop(); |
| 58 void setLoop(int, ExceptionState&); |
| 59 |
| 60 void start(); |
| 61 void stop(); |
| 62 |
| 45 private: | 63 private: |
| 46 explicit HTMLMarqueeElement(Document&); | 64 explicit HTMLMarqueeElement(Document&); |
| 65 |
| 66 class RequestAnimationFrameCallback : public FrameRequestCallback { |
| 67 WTF_MAKE_NONCOPYABLE(RequestAnimationFrameCallback); |
| 68 |
| 69 public: |
| 70 RequestAnimationFrameCallback(HTMLMarqueeElement* marquee) |
| 71 : m_marquee(marquee) {} |
| 72 void handleEvent(double) override; |
| 73 |
| 74 DEFINE_INLINE_VIRTUAL_TRACE() { |
| 75 visitor->trace(m_marquee); |
| 76 FrameRequestCallback::trace(visitor); |
| 77 } |
| 78 |
| 79 private: |
| 80 Member<HTMLMarqueeElement> m_marquee; |
| 81 }; |
| 82 |
| 83 class AnimationFinished : public EventListener { |
| 84 WTF_MAKE_NONCOPYABLE(AnimationFinished); |
| 85 |
| 86 public: |
| 87 AnimationFinished(HTMLMarqueeElement* marquee) |
| 88 : EventListener(CPPEventListenerType), m_marquee(marquee) {} |
| 89 |
| 90 bool operator==(const EventListener& that) const override { |
| 91 return this == &that; |
| 92 } |
| 93 |
| 94 void handleEvent(ExecutionContext*, Event*) override; |
| 95 |
| 96 DEFINE_INLINE_VIRTUAL_TRACE() { |
| 97 visitor->trace(m_marquee); |
| 98 EventListener::trace(visitor); |
| 99 } |
| 100 |
| 101 private: |
| 102 Member<HTMLMarqueeElement> m_marquee; |
| 103 }; |
| 104 |
| 105 struct AnimationParameters { |
| 106 AtomicString transformBegin; |
| 107 AtomicString transformEnd; |
| 108 double distance; |
| 109 }; |
| 110 |
| 111 struct Metrics { |
| 112 double contentWidth; |
| 113 double contentHeight; |
| 114 double marqueeWidth; |
| 115 double marqueeHeight; |
| 116 }; |
| 117 |
| 118 void initializeAttribute(const QualifiedName& attr); |
| 119 void attributeChangedCallback(const QualifiedName& attr, |
| 120 const String& newValue); |
| 121 |
| 122 StringKeyframeEffectModel* createEffectModel(AnimationParameters&); |
| 123 static void initializeTiming(Timing&, double duration); |
| 124 |
| 125 void continueAnimation(); |
| 126 bool shouldContinue(); |
| 127 |
| 128 enum Behavior { Scroll, Slide, Alternate }; |
| 129 Behavior behavior() const; |
| 130 |
| 131 enum Direction { Left, Right, Up, Down }; |
| 132 Direction direction() const; |
| 133 |
| 134 bool trueSpeed() const; |
| 135 |
| 136 Metrics getMetrics(); |
| 137 AnimationParameters getAnimationParameters(); |
| 138 AtomicString createTransform(bool isNegative, double value) const; |
| 139 |
| 140 static const int kDefaultScrollAmount = 6; |
| 141 static const int kDefaultScrollDelayMS = 85; |
| 142 static const int kMinimumScrollDelayMS = 60; |
| 143 static const int kDefaultLoopLimit = -1; |
| 144 |
| 145 int m_continueCallbackRequestId = 0; |
| 146 int m_loopCount = 0; |
| 147 Member<Element> m_mover; |
| 148 Member<Animation> m_player; |
| 47 }; | 149 }; |
| 48 | 150 |
| 49 } // namespace blink | 151 } // namespace blink |
| 50 | 152 |
| 51 #endif // HTMLMarqueeElement_h | 153 #endif // HTMLMarqueeElement_h |
| OLD | NEW |