1 /* 2 * Copyright (C) 2003 Apple Computer, Inc. 3 * 4 * Portions are Copyright (C) 1998 Netscape Communications Corporation. 5 * 6 * Other contributors: 7 * Robert O'Callahan <roc+@cs.cmu.edu> 8 * David Baron <dbaron (at) fas.harvard.edu> 9 * Christian Biesinger <cbiesinger (at) web.de> 10 * Randall Jesup <rjesup (at) wgate.com> 11 * Roland Mainz <roland.mainz (at) informatik.med.uni-giessen.de> 12 * Josh Soref <timeless (at) mac.com> 13 * Boris Zbarsky <bzbarsky (at) mit.edu> 14 * 15 * This library is free software; you can redistribute it and/or 16 * modify it under the terms of the GNU Lesser General Public 17 * License as published by the Free Software Foundation; either 18 * version 2.1 of the License, or (at your option) any later version. 19 * 20 * This library is distributed in the hope that it will be useful, 21 * but WITHOUT ANY WARRANTY; without even the implied warranty of 22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 23 * Lesser General Public License for more details. 24 * 25 * You should have received a copy of the GNU Lesser General Public 26 * License along with this library; if not, write to the Free Software 27 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 28 * 29 * Alternatively, the contents of this file may be used under the terms 30 * of either the Mozilla Public License Version 1.1, found at 31 * http://www.mozilla.org/MPL/ (the "MPL") or the GNU General Public 32 * License Version 2.0, found at http://www.fsf.org/copyleft/gpl.html 33 * (the "GPL"), in which case the provisions of the MPL or the GPL are 34 * applicable instead of those above. If you wish to allow use of your 35 * version of this file only under the terms of one of those two 36 * licenses (the MPL or the GPL) and not to allow others to use your 37 * version of this file under the LGPL, indicate your decision by 38 * deletingthe provisions above and replace them with the notice and 39 * other provisions required by the MPL or the GPL, as the case may be. 40 * If you do not delete the provisions above, a recipient may use your 41 * version of this file under any of the LGPL, the MPL or the GPL. 42 */ 43 44 #ifndef RenderMarquee_h 45 #define RenderMarquee_h 46 47 #include "core/platform/Length.h" 48 #include "core/platform/Timer.h" 49 #include "core/rendering/RenderBlock.h" 50 #include "core/rendering/style/RenderStyleConstants.h" 51 52 namespace WebCore { 53 54 class RenderLayer; 55 56 // This class handles the auto-scrolling for <marquee> 57 class RenderMarquee FINAL : public RenderBlock { 58 public: 59 explicit RenderMarquee(Element*); 60 virtual ~RenderMarquee(); 61 62 int speed() const { return m_speed; } 63 int marqueeSpeed() const; 64 65 EMarqueeDirection reverseDirection() const { return static_cast<EMarqueeDirection>(-direction()); } 66 EMarqueeDirection direction() const; 67 68 bool isHorizontal() const; 69 70 int computePosition(EMarqueeDirection, bool stopAtClientEdge); 71 72 void setEnd(int end) { m_end = end; } 73 74 void start(); 75 void suspend(); 76 void stop(); 77 78 // FIXME: This function should be private and called at layout time. 79 // However <marquee> tests are very timing dependent so we need to keep the existing timing. 80 void updateMarqueePosition(); 81 82 private: 83 virtual const char* renderName() const OVERRIDE FINAL; 84 85 virtual bool isMarquee() const OVERRIDE FINAL { return true; } 86 87 virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle) OVERRIDE FINAL; 88 89 virtual void layoutBlock(bool relayoutChildren, LayoutUnit pageLogicalHeight = 0) OVERRIDE FINAL; 90 91 void timerFired(Timer<RenderMarquee>*); 92 93 int m_currentLoop; 94 int m_totalLoops; 95 Timer<RenderMarquee> m_timer; 96 int m_start; 97 int m_end; 98 int m_speed; 99 Length m_height; 100 bool m_reset: 1; 101 bool m_suspended : 1; 102 bool m_stopped : 1; 103 EMarqueeDirection m_direction : 4; 104 }; 105 106 inline RenderMarquee* toRenderMarquee(RenderObject* renderer) 107 { 108 ASSERT_WITH_SECURITY_IMPLICATION(!renderer || renderer->isMarquee()); 109 return static_cast<RenderMarquee*>(renderer); 110 } 111 112 inline const RenderMarquee* toRenderMarquee(const RenderObject* renderer) 113 { 114 ASSERT_WITH_SECURITY_IMPLICATION(!renderer || renderer->isMarquee()); 115 return static_cast<const RenderMarquee*>(renderer); 116 } 117 118 // Catch unneeded cast. 119 void toRenderMarquee(const RenderMarquee*); 120 121 } // namespace WebCore 122 123 #endif // RenderMarquee_h 124