| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) | 3 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) |
| 4 * | 4 * |
| 5 * Portions are Copyright (C) 1998 Netscape Communications Corporation. | 5 * Portions are Copyright (C) 1998 Netscape Communications Corporation. |
| 6 * | 6 * |
| 7 * Other contributors: | 7 * Other contributors: |
| 8 * Robert O'Callahan <roc+@cs.cmu.edu> | 8 * Robert O'Callahan <roc+@cs.cmu.edu> |
| 9 * David Baron <dbaron@fas.harvard.edu> | 9 * David Baron <dbaron@fas.harvard.edu> |
| 10 * Christian Biesinger <cbiesinger@web.de> | 10 * Christian Biesinger <cbiesinger@web.de> |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 #include "core/rendering/RenderMarquee.h" | 47 #include "core/rendering/RenderMarquee.h" |
| 48 | 48 |
| 49 #include "core/HTMLNames.h" | 49 #include "core/HTMLNames.h" |
| 50 #include "core/html/HTMLMarqueeElement.h" | 50 #include "core/html/HTMLMarqueeElement.h" |
| 51 #include "core/frame/FrameView.h" | 51 #include "core/frame/FrameView.h" |
| 52 #include "core/frame/UseCounter.h" | 52 #include "core/frame/UseCounter.h" |
| 53 #include "core/rendering/RenderLayer.h" | 53 #include "core/rendering/RenderLayer.h" |
| 54 #include "core/rendering/RenderView.h" | 54 #include "core/rendering/RenderView.h" |
| 55 #include "platform/LengthFunctions.h" | 55 #include "platform/LengthFunctions.h" |
| 56 | 56 |
| 57 using namespace std; | |
| 58 | |
| 59 namespace WebCore { | 57 namespace WebCore { |
| 60 | 58 |
| 61 using namespace HTMLNames; | 59 using namespace HTMLNames; |
| 62 | 60 |
| 63 RenderMarquee::RenderMarquee(HTMLMarqueeElement* element) | 61 RenderMarquee::RenderMarquee(HTMLMarqueeElement* element) |
| 64 : RenderBlockFlow(element) | 62 : RenderBlockFlow(element) |
| 65 , m_currentLoop(0) | 63 , m_currentLoop(0) |
| 66 , m_totalLoops(0) | 64 , m_totalLoops(0) |
| 67 , m_timer(element, &HTMLMarqueeElement::timerFired) | 65 , m_timer(element, &HTMLMarqueeElement::timerFired) |
| 68 , m_start(0) | 66 , m_start(0) |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 LayoutUnit clientWidth = this->clientWidth(); | 120 LayoutUnit clientWidth = this->clientWidth(); |
| 123 LayoutUnit contentWidth = ltr ? maxPreferredLogicalWidth() : minPreferre
dLogicalWidth(); | 121 LayoutUnit contentWidth = ltr ? maxPreferredLogicalWidth() : minPreferre
dLogicalWidth(); |
| 124 if (ltr) | 122 if (ltr) |
| 125 contentWidth += (paddingRight() - borderLeft()); | 123 contentWidth += (paddingRight() - borderLeft()); |
| 126 else { | 124 else { |
| 127 contentWidth = width() - contentWidth; | 125 contentWidth = width() - contentWidth; |
| 128 contentWidth += (paddingLeft() - borderRight()); | 126 contentWidth += (paddingLeft() - borderRight()); |
| 129 } | 127 } |
| 130 if (dir == MRIGHT) { | 128 if (dir == MRIGHT) { |
| 131 if (stopAtContentEdge) | 129 if (stopAtContentEdge) |
| 132 return max<LayoutUnit>(0, ltr ? (contentWidth - clientWidth) : (
clientWidth - contentWidth)); | 130 return std::max<LayoutUnit>(0, ltr ? (contentWidth - clientWidth
) : (clientWidth - contentWidth)); |
| 133 else | 131 else |
| 134 return ltr ? contentWidth : clientWidth; | 132 return ltr ? contentWidth : clientWidth; |
| 135 } | 133 } |
| 136 else { | 134 else { |
| 137 if (stopAtContentEdge) | 135 if (stopAtContentEdge) |
| 138 return min<LayoutUnit>(0, ltr ? (contentWidth - clientWidth) : (
clientWidth - contentWidth)); | 136 return std::min<LayoutUnit>(0, ltr ? (contentWidth - clientWidth
) : (clientWidth - contentWidth)); |
| 139 else | 137 else |
| 140 return ltr ? -clientWidth : -contentWidth; | 138 return ltr ? -clientWidth : -contentWidth; |
| 141 } | 139 } |
| 142 } | 140 } |
| 143 else { | 141 else { |
| 144 int contentHeight = layoutOverflowRect().maxY() - borderTop() + paddingB
ottom(); | 142 int contentHeight = layoutOverflowRect().maxY() - borderTop() + paddingB
ottom(); |
| 145 int clientHeight = this->clientHeight(); | 143 int clientHeight = this->clientHeight(); |
| 146 if (dir == MUP) { | 144 if (dir == MUP) { |
| 147 if (stopAtContentEdge) | 145 if (stopAtContentEdge) |
| 148 return min(contentHeight - clientHeight, 0); | 146 return std::min(contentHeight - clientHeight, 0); |
| 149 else | 147 else |
| 150 return -clientHeight; | 148 return -clientHeight; |
| 151 } | 149 } |
| 152 else { | 150 else { |
| 153 if (stopAtContentEdge) | 151 if (stopAtContentEdge) |
| 154 return max(contentHeight - clientHeight, 0); | 152 return std::max(contentHeight - clientHeight, 0); |
| 155 else | 153 else |
| 156 return contentHeight; | 154 return contentHeight; |
| 157 } | 155 } |
| 158 } | 156 } |
| 159 } | 157 } |
| 160 | 158 |
| 161 void RenderMarquee::start() | 159 void RenderMarquee::start() |
| 162 { | 160 { |
| 163 if (m_timer.isActive() || style()->marqueeIncrement().isZero()) | 161 if (m_timer.isActive() || style()->marqueeIncrement().isZero()) |
| 164 return; | 162 return; |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 endPoint = m_start; | 298 endPoint = m_start; |
| 301 range = -range; | 299 range = -range; |
| 302 addIncrement = !addIncrement; | 300 addIncrement = !addIncrement; |
| 303 } | 301 } |
| 304 bool positive = range > 0; | 302 bool positive = range > 0; |
| 305 int clientSize = (isHorizontal() ? clientWidth() : clientHeight()); | 303 int clientSize = (isHorizontal() ? clientWidth() : clientHeight()); |
| 306 int increment = abs(intValueForLength(style()->marqueeIncrement(), clien
tSize)); | 304 int increment = abs(intValueForLength(style()->marqueeIncrement(), clien
tSize)); |
| 307 int currentPos = (isHorizontal() ? layer()->scrollableArea()->scrollXOff
set() : layer()->scrollableArea()->scrollYOffset()); | 305 int currentPos = (isHorizontal() ? layer()->scrollableArea()->scrollXOff
set() : layer()->scrollableArea()->scrollYOffset()); |
| 308 newPos = currentPos + (addIncrement ? increment : -increment); | 306 newPos = currentPos + (addIncrement ? increment : -increment); |
| 309 if (positive) | 307 if (positive) |
| 310 newPos = min(newPos, endPoint); | 308 newPos = std::min(newPos, endPoint); |
| 311 else | 309 else |
| 312 newPos = max(newPos, endPoint); | 310 newPos = std::max(newPos, endPoint); |
| 313 } | 311 } |
| 314 | 312 |
| 315 if (newPos == endPoint) { | 313 if (newPos == endPoint) { |
| 316 m_currentLoop++; | 314 m_currentLoop++; |
| 317 if (m_totalLoops > 0 && m_currentLoop >= m_totalLoops) | 315 if (m_totalLoops > 0 && m_currentLoop >= m_totalLoops) |
| 318 m_timer.stop(); | 316 m_timer.stop(); |
| 319 else if (s->marqueeBehavior() != MALTERNATE) | 317 else if (s->marqueeBehavior() != MALTERNATE) |
| 320 m_reset = true; | 318 m_reset = true; |
| 321 } | 319 } |
| 322 | 320 |
| 323 if (isHorizontal()) | 321 if (isHorizontal()) |
| 324 layer()->scrollableArea()->scrollToXOffset(newPos); | 322 layer()->scrollableArea()->scrollToXOffset(newPos); |
| 325 else | 323 else |
| 326 layer()->scrollableArea()->scrollToYOffset(newPos); | 324 layer()->scrollableArea()->scrollToYOffset(newPos); |
| 327 } | 325 } |
| 328 | 326 |
| 329 } // namespace WebCore | 327 } // namespace WebCore |
| OLD | NEW |