2008-08-07 Simon Fraser <simon.fraser@apple.com>

        Reviewed by Sam Weinig

        Rename Marquee to RenderMarquee and move to its own file.
        https://bugs.webkit.org/show_bug.cgi?id=20319

        * GNUmakefile.am:
        * WebCore.pro:
        * WebCore.vcproj/WebCore.vcproj:
        * WebCore.xcodeproj/project.pbxproj:
        * WebCoreSources.bkl:
        * html/HTMLMarqueeElement.cpp:
        * rendering/RenderBlock.cpp:
        * rendering/RenderLayer.cpp:
        (WebCore::RenderLayer::styleChanged):
        * rendering/RenderLayer.h:
        * rendering/RenderMarquee.cpp: Added.
        (WebCore::RenderMarquee::RenderMarquee):
        (WebCore::RenderMarquee::marqueeSpeed):
        (WebCore::RenderMarquee::direction):
        (WebCore::RenderMarquee::isHorizontal):
        (WebCore::RenderMarquee::computePosition):
        (WebCore::RenderMarquee::start):
        (WebCore::RenderMarquee::suspend):
        (WebCore::RenderMarquee::stop):
        (WebCore::RenderMarquee::updateMarqueePosition):
        (WebCore::RenderMarquee::updateMarqueeStyle):
        (WebCore::RenderMarquee::timerFired):
        * rendering/RenderMarquee.h: Added.
        (WebCore::RenderMarquee::speed):
        (WebCore::RenderMarquee::reverseDirection):
        (WebCore::RenderMarquee::setEnd):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@35627 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 5d921b9f
2008-08-07 Simon Fraser <simon.fraser@apple.com>
Reviewed by Sam Weinig
Rename Marquee to RenderMarquee and move to its own file.
https://bugs.webkit.org/show_bug.cgi?id=20319
* GNUmakefile.am:
* WebCore.pro:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:
* WebCoreSources.bkl:
* html/HTMLMarqueeElement.cpp:
* rendering/RenderBlock.cpp:
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::styleChanged):
* rendering/RenderLayer.h:
* rendering/RenderMarquee.cpp: Added.
(WebCore::RenderMarquee::RenderMarquee):
(WebCore::RenderMarquee::marqueeSpeed):
(WebCore::RenderMarquee::direction):
(WebCore::RenderMarquee::isHorizontal):
(WebCore::RenderMarquee::computePosition):
(WebCore::RenderMarquee::start):
(WebCore::RenderMarquee::suspend):
(WebCore::RenderMarquee::stop):
(WebCore::RenderMarquee::updateMarqueePosition):
(WebCore::RenderMarquee::updateMarqueeStyle):
(WebCore::RenderMarquee::timerFired):
* rendering/RenderMarquee.h: Added.
(WebCore::RenderMarquee::speed):
(WebCore::RenderMarquee::reverseDirection):
(WebCore::RenderMarquee::setEnd):
2008-08-07 Dan Bernstein <mitz@apple.com>
Reviewed by Dave Hyatt.
......@@ -1023,6 +1023,7 @@ webcore_sources += \
WebCore/rendering/RenderListBox.cpp \
WebCore/rendering/RenderListItem.cpp \
WebCore/rendering/RenderListMarker.cpp \
WebCore/rendering/RenderMarquee.cpp \
WebCore/rendering/RenderMenuList.cpp \
WebCore/rendering/RenderObject.cpp \
WebCore/rendering/RenderPart.cpp \
......
......@@ -860,6 +860,7 @@ SOURCES += \
rendering/RenderListBox.cpp \
rendering/RenderListItem.cpp \
rendering/RenderListMarker.cpp \
rendering/RenderMarquee.cpp \
rendering/RenderMenuList.cpp \
rendering/RenderObject.cpp \
rendering/RenderPart.cpp \
......
......@@ -9637,6 +9637,22 @@
/>
</FileConfiguration>
</File>
<File
RelativePath="..\rendering\RenderMarquee.h"
>
</File>
<File
RelativePath="..\rendering\RenderMarquee.cpp"
>
<FileConfiguration
Name="Release_PGO|Win32"
>
<Tool
Name="VCCLCompilerTool"
WholeProgramOptimization="true"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\rendering\RenderMedia.h"
>
......@@ -9653,6 +9669,7 @@
/>
</FileConfiguration>
</File>
<File
RelativePath="..\rendering\RenderMenuList.h"
>
......
......@@ -41,6 +41,8 @@
06E81EEC0AB5DA9700C87837 /* LocalCurrentGraphicsContext.mm in Sources */ = {isa = PBXBuildFile; fileRef = 06E81EEB0AB5DA9700C87837 /* LocalCurrentGraphicsContext.mm */; };
08E4FE460E2BD41400F4CAE0 /* JSSVGLengthCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 08E4FE450E2BD41400F4CAE0 /* JSSVGLengthCustom.cpp */; };
0A4844990CA44CB200B7BD48 /* SoftLinking.h in Headers */ = {isa = PBXBuildFile; fileRef = 0A4844980CA44CB200B7BD48 /* SoftLinking.h */; settings = {ATTRIBUTES = (Private, ); }; };
0F56028F0E4B76580065B038 /* RenderMarquee.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F56028D0E4B76580065B038 /* RenderMarquee.h */; };
0F5602900E4B76580065B038 /* RenderMarquee.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F56028E0E4B76580065B038 /* RenderMarquee.cpp */; };
1402645E0AFDC19B005919E2 /* LoggingMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1402645D0AFDC19B005919E2 /* LoggingMac.mm */; };
1403B99709EB13AF00797C7F /* DOMWindow.h in Headers */ = {isa = PBXBuildFile; fileRef = 1403B99509EB13AF00797C7F /* DOMWindow.h */; settings = {ATTRIBUTES = (Private, ); }; };
1403B99809EB13AF00797C7F /* DOMWindow.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1403B99609EB13AF00797C7F /* DOMWindow.cpp */; };
......@@ -4525,6 +4527,8 @@
06E81EEB0AB5DA9700C87837 /* LocalCurrentGraphicsContext.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = LocalCurrentGraphicsContext.mm; sourceTree = "<group>"; };
08E4FE450E2BD41400F4CAE0 /* JSSVGLengthCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSSVGLengthCustom.cpp; sourceTree = "<group>"; };
0A4844980CA44CB200B7BD48 /* SoftLinking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SoftLinking.h; sourceTree = "<group>"; };
0F56028D0E4B76580065B038 /* RenderMarquee.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderMarquee.h; sourceTree = "<group>"; };
0F56028E0E4B76580065B038 /* RenderMarquee.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderMarquee.cpp; sourceTree = "<group>"; };
1402645D0AFDC19B005919E2 /* LoggingMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = LoggingMac.mm; sourceTree = "<group>"; };
1403B90C09EB124500797C7F /* DOMWindow.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = DOMWindow.idl; sourceTree = "<group>"; };
1403B99509EB13AF00797C7F /* DOMWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMWindow.h; sourceTree = "<group>"; };
......@@ -13027,6 +13031,8 @@
A8EA7A4C0A191A5200A8EF5F /* RenderListItem.h */,
A8EA7A4B0A191A5200A8EF5F /* RenderListMarker.cpp */,
A8EA7A4A0A191A5200A8EF5F /* RenderListMarker.h */,
0F56028E0E4B76580065B038 /* RenderMarquee.cpp */,
0F56028D0E4B76580065B038 /* RenderMarquee.h */,
E4C279560CF9741900E97B98 /* RenderMedia.cpp */,
E4C279570CF9741900E97B98 /* RenderMedia.h */,
ABDDFE730A5C6E6F00A3E11D /* RenderMenuList.cpp */,
......@@ -15326,6 +15332,7 @@
31288E730E3005D6003619AE /* WebKitCSSKeyframeRule.h in Headers */,
31288E750E3005D6003619AE /* WebKitCSSKeyframesRule.h in Headers */,
4415292E0E1AE8A000C4A2D0 /* HTMLPlugInImageElement.h in Headers */,
0F56028F0E4B76580065B038 /* RenderMarquee.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -17100,6 +17107,7 @@
31288E740E3005D6003619AE /* WebKitCSSKeyframesRule.cpp in Sources */,
A83E1C740E49042C00140B9C /* ScriptControllerMac.mm in Sources */,
4415292F0E1AE8A000C4A2D0 /* HTMLPlugInImageElement.cpp in Sources */,
0F5602900E4B76580065B038 /* RenderMarquee.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -812,6 +812,7 @@ This file contains the list of files needed to build WebCore.
rendering/RenderListBox.cpp
rendering/RenderListItem.cpp
rendering/RenderListMarker.cpp
rendering/RenderMarquee.cpp
rendering/RenderMenuList.cpp
rendering/RenderObject.cpp
rendering/RenderPart.cpp
......
......@@ -28,6 +28,7 @@
#include "CSSValueKeywords.h"
#include "HTMLNames.h"
#include "RenderLayer.h"
#include "RenderMarquee.h"
namespace WebCore {
......
......@@ -32,6 +32,7 @@
#include "HitTestResult.h"
#include "InlineTextBox.h"
#include "RenderImage.h"
#include "RenderMarquee.h"
#include "RenderReplica.h"
#include "RenderTableCell.h"
#include "RenderTextFragment.h"
......
......@@ -55,7 +55,6 @@
#include "FrameView.h"
#include "Gradient.h"
#include "GraphicsContext.h"
#include "HTMLMarqueeElement.h"
#include "HTMLNames.h"
#include "HitTestRequest.h"
#include "HitTestResult.h"
......@@ -65,6 +64,7 @@
#include "PlatformScrollBar.h"
#include "RenderArena.h"
#include "RenderInline.h"
#include "RenderMarquee.h"
#include "RenderReplica.h"
#include "RenderTheme.h"
#include "RenderView.h"
......@@ -2359,7 +2359,7 @@ void RenderLayer::styleChanged(RenderStyle* oldStyle)
if (m_object->style()->overflowX() == OMARQUEE && m_object->style()->marqueeBehavior() != MNONE) {
if (!m_marquee)
m_marquee = new Marquee(this);
m_marquee = new RenderMarquee(this);
m_marquee->updateMarqueeStyle();
}
else if (m_marquee) {
......@@ -2435,258 +2435,4 @@ void RenderLayer::suspendMarquees()
curr->suspendMarquees();
}
// --------------------------------------------------------------------------
// Marquee implementation
Marquee::Marquee(RenderLayer* l)
: m_layer(l), m_currentLoop(0)
, m_totalLoops(0)
, m_timer(this, &Marquee::timerFired)
, m_start(0), m_end(0), m_speed(0), m_reset(false)
, m_suspended(false), m_stopped(false), m_direction(MAUTO)
{
}
int Marquee::marqueeSpeed() const
{
int result = m_layer->renderer()->style()->marqueeSpeed();
Node* elt = m_layer->renderer()->element();
if (elt && elt->hasTagName(marqueeTag)) {
HTMLMarqueeElement* marqueeElt = static_cast<HTMLMarqueeElement*>(elt);
result = max(result, marqueeElt->minimumDelay());
}
return result;
}
EMarqueeDirection Marquee::direction() const
{
// FIXME: Support the CSS3 "auto" value for determining the direction of the marquee.
// For now just map MAUTO to MBACKWARD
EMarqueeDirection result = m_layer->renderer()->style()->marqueeDirection();
TextDirection dir = m_layer->renderer()->style()->direction();
if (result == MAUTO)
result = MBACKWARD;
if (result == MFORWARD)
result = (dir == LTR) ? MRIGHT : MLEFT;
if (result == MBACKWARD)
result = (dir == LTR) ? MLEFT : MRIGHT;
// Now we have the real direction. Next we check to see if the increment is negative.
// If so, then we reverse the direction.
Length increment = m_layer->renderer()->style()->marqueeIncrement();
if (increment.isNegative())
result = static_cast<EMarqueeDirection>(-result);
return result;
}
bool Marquee::isHorizontal() const
{
return direction() == MLEFT || direction() == MRIGHT;
}
int Marquee::computePosition(EMarqueeDirection dir, bool stopAtContentEdge)
{
RenderObject* o = m_layer->renderer();
RenderStyle* s = o->style();
if (isHorizontal()) {
bool ltr = s->direction() == LTR;
int clientWidth = o->clientWidth();
int contentWidth = ltr ? o->rightmostPosition(true, false) : o->leftmostPosition(true, false);
if (ltr)
contentWidth += (o->paddingRight() - o->borderLeft());
else {
contentWidth = o->width() - contentWidth;
contentWidth += (o->paddingLeft() - o->borderRight());
}
if (dir == MRIGHT) {
if (stopAtContentEdge)
return max(0, ltr ? (contentWidth - clientWidth) : (clientWidth - contentWidth));
else
return ltr ? contentWidth : clientWidth;
}
else {
if (stopAtContentEdge)
return min(0, ltr ? (contentWidth - clientWidth) : (clientWidth - contentWidth));
else
return ltr ? -clientWidth : -contentWidth;
}
}
else {
int contentHeight = m_layer->renderer()->lowestPosition(true, false) -
m_layer->renderer()->borderTop() + m_layer->renderer()->paddingBottom();
int clientHeight = m_layer->renderer()->clientHeight();
if (dir == MUP) {
if (stopAtContentEdge)
return min(contentHeight - clientHeight, 0);
else
return -clientHeight;
}
else {
if (stopAtContentEdge)
return max(contentHeight - clientHeight, 0);
else
return contentHeight;
}
}
}
void Marquee::start()
{
if (m_timer.isActive() || m_layer->renderer()->style()->marqueeIncrement().isZero())
return;
// We may end up propagating a scroll event. It is important that we suspend events until
// the end of the function since they could delete the layer, including the marquee.
FrameView* frameView = m_layer->renderer()->document()->view();
if (frameView)
frameView->pauseScheduledEvents();
if (!m_suspended && !m_stopped) {
if (isHorizontal())
m_layer->scrollToOffset(m_start, 0, false, false);
else
m_layer->scrollToOffset(0, m_start, false, false);
}
else {
m_suspended = false;
m_stopped = false;
}
m_timer.startRepeating(speed() * 0.001);
if (frameView)
frameView->resumeScheduledEvents();
}
void Marquee::suspend()
{
m_timer.stop();
m_suspended = true;
}
void Marquee::stop()
{
m_timer.stop();
m_stopped = true;
}
void Marquee::updateMarqueePosition()
{
bool activate = (m_totalLoops <= 0 || m_currentLoop < m_totalLoops);
if (activate) {
EMarqueeBehavior behavior = m_layer->renderer()->style()->marqueeBehavior();
m_start = computePosition(direction(), behavior == MALTERNATE);
m_end = computePosition(reverseDirection(), behavior == MALTERNATE || behavior == MSLIDE);
if (!m_stopped)
start();
}
}
void Marquee::updateMarqueeStyle()
{
RenderStyle* s = m_layer->renderer()->style();
if (m_direction != s->marqueeDirection() || (m_totalLoops != s->marqueeLoopCount() && m_currentLoop >= m_totalLoops))
m_currentLoop = 0; // When direction changes or our loopCount is a smaller number than our current loop, reset our loop.
m_totalLoops = s->marqueeLoopCount();
m_direction = s->marqueeDirection();
if (m_layer->renderer()->isHTMLMarquee()) {
// Hack for WinIE. In WinIE, a value of 0 or lower for the loop count for SLIDE means to only do
// one loop.
if (m_totalLoops <= 0 && s->marqueeBehavior() == MSLIDE)
m_totalLoops = 1;
// Hack alert: Set the white-space value to nowrap for horizontal marquees with inline children, thus ensuring
// all the text ends up on one line by default. Limit this hack to the <marquee> element to emulate
// WinIE's behavior. Someone using CSS3 can use white-space: nowrap on their own to get this effect.
// Second hack alert: Set the text-align back to auto. WinIE completely ignores text-align on the
// marquee element.
// FIXME: Bring these up with the CSS WG.
if (isHorizontal() && m_layer->renderer()->childrenInline()) {
s->setWhiteSpace(NOWRAP);
s->setTextAlign(TAAUTO);
}
}
// Marquee height hack!! Make sure that, if it is a horizontal marquee, the height attribute is overridden
// if it is smaller than the font size. If it is a vertical marquee and height is not specified, we default
// to a marquee of 200px.
if (isHorizontal()) {
if (s->height().isFixed() && s->height().value() < s->fontSize())
s->setHeight(Length(s->fontSize(),Fixed));
} else if (s->height().isAuto()) //vertical marquee with no specified height
s->setHeight(Length(200, Fixed));
if (speed() != marqueeSpeed()) {
m_speed = marqueeSpeed();
if (m_timer.isActive())
m_timer.startRepeating(speed() * 0.001);
}
// Check the loop count to see if we should now stop.
bool activate = (m_totalLoops <= 0 || m_currentLoop < m_totalLoops);
if (activate && !m_timer.isActive())
m_layer->renderer()->setNeedsLayout(true);
else if (!activate && m_timer.isActive())
m_timer.stop();
}
void Marquee::timerFired(Timer<Marquee>*)
{
if (m_layer->renderer()->needsLayout())
return;
if (m_reset) {
m_reset = false;
if (isHorizontal())
m_layer->scrollToXOffset(m_start);
else
m_layer->scrollToYOffset(m_start);
return;
}
RenderStyle* s = m_layer->renderer()->style();
int endPoint = m_end;
int range = m_end - m_start;
int newPos;
if (range == 0)
newPos = m_end;
else {
bool addIncrement = direction() == MUP || direction() == MLEFT;
bool isReversed = s->marqueeBehavior() == MALTERNATE && m_currentLoop % 2;
if (isReversed) {
// We're going in the reverse direction.
endPoint = m_start;
range = -range;
addIncrement = !addIncrement;
}
bool positive = range > 0;
int clientSize = (isHorizontal() ? m_layer->renderer()->clientWidth() : m_layer->renderer()->clientHeight());
int increment = max(1, abs(m_layer->renderer()->style()->marqueeIncrement().calcValue(clientSize)));
int currentPos = (isHorizontal() ? m_layer->scrollXOffset() : m_layer->scrollYOffset());
newPos = currentPos + (addIncrement ? increment : -increment);
if (positive)
newPos = min(newPos, endPoint);
else
newPos = max(newPos, endPoint);
}
if (newPos == endPoint) {
m_currentLoop++;
if (m_totalLoops > 0 && m_currentLoop >= m_totalLoops)
m_timer.stop();
else if (s->marqueeBehavior() != MALTERNATE)
m_reset = true;
}
if (isHorizontal())
m_layer->scrollToXOffset(newPos);
else
m_layer->scrollToYOffset(newPos);
}
} // namespace WebCore
......@@ -56,6 +56,7 @@ class CachedResource;
class HitTestResult;
class PlatformScrollbar;
class RenderFrameSet;
class RenderMarquee;
class RenderObject;
class RenderReplica;
class RenderStyle;
......@@ -114,49 +115,6 @@ private:
bool m_fixed : 1;
};
// FIXME: move this to its own file
// This class handles the auto-scrolling of layers with overflow: marquee.
class Marquee {
public:
Marquee(RenderLayer*);
int speed() const { return m_speed; }
int marqueeSpeed() const;
EMarqueeDirection reverseDirection() const { return static_cast<EMarqueeDirection>(-direction()); }
EMarqueeDirection direction() const;
bool isHorizontal() const;
int computePosition(EMarqueeDirection, bool stopAtClientEdge);
void setEnd(int end) { m_end = end; }
void start();
void suspend();
void stop();
void updateMarqueeStyle();
void updateMarqueePosition();
private:
void timerFired(Timer<Marquee>*);
RenderLayer* m_layer;
int m_currentLoop;
int m_totalLoops;
Timer<Marquee> m_timer;
int m_start;
int m_end;
int m_speed;
Length m_height;
bool m_reset: 1;
bool m_suspended : 1;
bool m_stopped : 1;
EMarqueeDirection m_direction : 4;
};
class RenderLayer : public ScrollbarClient {
public:
enum ScrollBehavior {
......@@ -207,7 +165,7 @@ public:
void styleChanged(RenderStyle*);
Marquee* marquee() const { return m_marquee; }
RenderMarquee* marquee() const { return m_marquee; }
void suspendMarquees();
bool isOverflowOnly() const { return m_isOverflowOnly; }
......@@ -481,7 +439,7 @@ protected:
bool m_visibleDescendantStatusDirty : 1;
bool m_hasVisibleDescendant : 1;
Marquee* m_marquee; // Used by layers with overflow:marquee
RenderMarquee* m_marquee; // Used by layers with overflow:marquee
// Cached normal flow values for absolute positioned elements with static left/top values.
int m_staticX;
......
/*
* Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
*
* Portions are Copyright (C) 1998 Netscape Communications Corporation.
*
* Other contributors:
* Robert O'Callahan <roc+@cs.cmu.edu>
* David Baron <dbaron@fas.harvard.edu>
* Christian Biesinger <cbiesinger@web.de>
* Randall Jesup <rjesup@wgate.com>
* Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
* Josh Soref <timeless@mac.com>
* Boris Zbarsky <bzbarsky@mit.edu>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Alternatively, the contents of this file may be used under the terms
* of either the Mozilla Public License Version 1.1, found at
* http://www.mozilla.org/MPL/ (the "MPL") or the GNU General Public
* License Version 2.0, found at http://www.fsf.org/copyleft/gpl.html
* (the "GPL"), in which case the provisions of the MPL or the GPL are
* applicable instead of those above. If you wish to allow use of your
* version of this file only under the terms of one of those two
* licenses (the MPL or the GPL) and not to allow others to use your
* version of this file under the LGPL, indicate your decision by
* deletingthe provisions above and replace them with the notice and
* other provisions required by the MPL or the GPL, as the case may be.
* If you do not delete the provisions above, a recipient may use your
* version of this file under any of the LGPL, the MPL or the GPL.
*/
#include "config.h"
#include "RenderMarquee.h"
#include "FrameView.h"
#include "HTMLMarqueeElement.h"
#include "HTMLNames.h"
#include "RenderLayer.h"
using namespace std;
namespace WebCore {
using namespace HTMLNames;
RenderMarquee::RenderMarquee(RenderLayer* l)
: m_layer(l), m_currentLoop(0)
, m_totalLoops(0)
, m_timer(this, &RenderMarquee::timerFired)
, m_start(0), m_end(0), m_speed(0), m_reset(false)
, m_suspended(false), m_stopped(false), m_direction(MAUTO)
{
}
int RenderMarquee::marqueeSpeed() const
{
int result = m_layer->renderer()->style()->marqueeSpeed();
Node* elt = m_layer->renderer()->element();
if (elt && elt->hasTagName(marqueeTag)) {
HTMLMarqueeElement* marqueeElt = static_cast<HTMLMarqueeElement*>(elt);
result = max(result, marqueeElt->minimumDelay());
}
return result;
}
EMarqueeDirection RenderMarquee::direction() const
{
// FIXME: Support the CSS3 "auto" value for determining the direction of the marquee.
// For now just map MAUTO to MBACKWARD
EMarqueeDirection result = m_layer->renderer()->style()->marqueeDirection();
TextDirection dir = m_layer->renderer()->style()->direction();
if (result == MAUTO)
result = MBACKWARD;
if (result == MFORWARD)
result = (dir == LTR) ? MRIGHT : MLEFT;
if (result == MBACKWARD)
result = (dir == LTR) ? MLEFT : MRIGHT;
// Now we have the real direction. Next we check to see if the increment is negative.
// If so, then we reverse the direction.
Length increment = m_layer->renderer()->style()->marqueeIncrement();
if (increment.isNegative())
result = static_cast<EMarqueeDirection>(-result);
return result;
}
bool RenderMarquee::isHorizontal() const
{
return direction() == MLEFT || direction() == MRIGHT;
}
int RenderMarquee::computePosition(EMarqueeDirection dir, bool stopAtContentEdge)
{
RenderObject* o = m_layer->renderer();
RenderStyle* s = o->style();
if (isHorizontal()) {
bool ltr = s->direction() == LTR;
int clientWidth = o->clientWidth();
int contentWidth = ltr ? o->rightmostPosition(true, false) : o->leftmostPosition(true, false);
if (ltr)
contentWidth += (o->paddingRight() - o->borderLeft());
else {
contentWidth = o->width() - contentWidth;
contentWidth += (o->paddingLeft() - o->borderRight());
}
if (dir == MRIGHT) {