~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to src/3rdparty/webkit/WebCore/rendering/RenderMarquee.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghersi
  • Date: 2009-11-02 18:30:08 UTC
  • mfrom: (1.2.2 upstream)
  • mto: (15.2.5 experimental)
  • mto: This revision was merged to the branch mainline in revision 88.
  • Revision ID: james.westby@ubuntu.com-20091102183008-b6a4gcs128mvfb3m
Tags: upstream-4.6.0~beta1
ImportĀ upstreamĀ versionĀ 4.6.0~beta1

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
 
3
 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
3
4
 *
4
5
 * Portions are Copyright (C) 1998 Netscape Communications Corporation.
5
6
 *
68
69
int RenderMarquee::marqueeSpeed() const
69
70
{
70
71
    int result = m_layer->renderer()->style()->marqueeSpeed();
71
 
    Node* elt = m_layer->renderer()->element();
72
 
    if (elt && elt->hasTagName(marqueeTag)) {
73
 
        HTMLMarqueeElement* marqueeElt = static_cast<HTMLMarqueeElement*>(elt);
 
72
    Node* n = m_layer->renderer()->node();
 
73
    if (n && n->hasTagName(marqueeTag)) {
 
74
        HTMLMarqueeElement* marqueeElt = static_cast<HTMLMarqueeElement*>(n);
74
75
        result = max(result, marqueeElt->minimumDelay());
75
76
    }
76
77
    return result;
105
106
 
106
107
int RenderMarquee::computePosition(EMarqueeDirection dir, bool stopAtContentEdge)
107
108
{
108
 
    RenderObject* o = m_layer->renderer();
109
 
    RenderStyle* s = o->style();
 
109
    RenderBox* box = m_layer->renderBox();
 
110
    ASSERT(box);
 
111
    RenderStyle* s = box->style();
110
112
    if (isHorizontal()) {
111
113
        bool ltr = s->direction() == LTR;
112
 
        int clientWidth = o->clientWidth();
113
 
        int contentWidth = ltr ? o->rightmostPosition(true, false) : o->leftmostPosition(true, false);
 
114
        int clientWidth = box->clientWidth();
 
115
        int contentWidth = ltr ? box->rightmostPosition(true, false) : box->leftmostPosition(true, false);
114
116
        if (ltr)
115
 
            contentWidth += (o->paddingRight() - o->borderLeft());
 
117
            contentWidth += (box->paddingRight() - box->borderLeft());
116
118
        else {
117
 
            contentWidth = o->width() - contentWidth;
118
 
            contentWidth += (o->paddingLeft() - o->borderRight());
 
119
            contentWidth = box->width() - contentWidth;
 
120
            contentWidth += (box->paddingLeft() - box->borderRight());
119
121
        }
120
122
        if (dir == MRIGHT) {
121
123
            if (stopAtContentEdge)
131
133
        }
132
134
    }
133
135
    else {
134
 
        int contentHeight = m_layer->renderer()->lowestPosition(true, false) - 
135
 
                            m_layer->renderer()->borderTop() + m_layer->renderer()->paddingBottom();
136
 
        int clientHeight = m_layer->renderer()->clientHeight();
 
136
        int contentHeight = box->lowestPosition(true, false) - 
 
137
                            box->borderTop() + box->paddingBottom();
 
138
        int clientHeight = box->clientHeight();
137
139
        if (dir == MUP) {
138
140
            if (stopAtContentEdge)
139
141
                 return min(contentHeight - clientHeight, 0);
151
153
 
152
154
void RenderMarquee::start()
153
155
{
154
 
    if (m_timer.isActive() || m_layer->renderer()->style()->marqueeIncrement().isZero())
 
156
    if (m_timer.isActive() || m_layer->renderer()->style()->marqueeIncrement().isZero()
 
157
#if ENABLE(WCSS) && ENABLE(XHTMLMP)
 
158
        || (m_layer->renderer()->document()->isXHTMLMPDocument() && !m_layer->renderer()->style()->marqueeLoopCount())
 
159
#endif
 
160
       )
155
161
        return;
156
162
 
157
163
    // We may end up propagating a scroll event. It is important that we suspend events until 
234
240
    // to a marquee of 200px.
235
241
    if (isHorizontal()) {
236
242
        if (s->height().isFixed() && s->height().value() < s->fontSize())
237
 
            s->setHeight(Length(s->fontSize(),Fixed));
 
243
            s->setHeight(Length(s->fontSize(), Fixed));
238
244
    } else if (s->height().isAuto())  //vertical marquee with no specified height
239
245
        s->setHeight(Length(200, Fixed)); 
240
246
   
283
289
            addIncrement = !addIncrement;
284
290
        }
285
291
        bool positive = range > 0;
286
 
        int clientSize = (isHorizontal() ? m_layer->renderer()->clientWidth() : m_layer->renderer()->clientHeight());
 
292
        int clientSize = (isHorizontal() ? m_layer->renderBox()->clientWidth() : m_layer->renderBox()->clientHeight());
287
293
        int increment = max(1, abs(m_layer->renderer()->style()->marqueeIncrement().calcValue(clientSize)));
288
294
        int currentPos = (isHorizontal() ? m_layer->scrollXOffset() : m_layer->scrollYOffset());
289
295
        newPos =  currentPos + (addIncrement ? increment : -increment);
308
314
}
309
315
 
310
316
} // namespace WebCore
311