Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(47)

Side by Side Diff: third_party/WebKit/WebCore/rendering/RenderMarquee.cpp

Issue 21152: WebKit merge 40668:40722 part 1. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 * 3 *
4 * Portions are Copyright (C) 1998 Netscape Communications Corporation. 4 * Portions are Copyright (C) 1998 Netscape Communications Corporation.
5 * 5 *
6 * Other contributors: 6 * Other contributors:
7 * Robert O'Callahan <roc+@cs.cmu.edu> 7 * Robert O'Callahan <roc+@cs.cmu.edu>
8 * David Baron <dbaron@fas.harvard.edu> 8 * David Baron <dbaron@fas.harvard.edu>
9 * Christian Biesinger <cbiesinger@web.de> 9 * Christian Biesinger <cbiesinger@web.de>
10 * Randall Jesup <rjesup@wgate.com> 10 * Randall Jesup <rjesup@wgate.com>
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 return result; 98 return result;
99 } 99 }
100 100
101 bool RenderMarquee::isHorizontal() const 101 bool RenderMarquee::isHorizontal() const
102 { 102 {
103 return direction() == MLEFT || direction() == MRIGHT; 103 return direction() == MLEFT || direction() == MRIGHT;
104 } 104 }
105 105
106 int RenderMarquee::computePosition(EMarqueeDirection dir, bool stopAtContentEdge ) 106 int RenderMarquee::computePosition(EMarqueeDirection dir, bool stopAtContentEdge )
107 { 107 {
108 RenderBox* o = m_layer->renderer(); 108 RenderBox* box = m_layer->renderBox();
109 RenderStyle* s = o->style(); 109 ASSERT(box);
110 RenderStyle* s = box->style();
110 if (isHorizontal()) { 111 if (isHorizontal()) {
111 bool ltr = s->direction() == LTR; 112 bool ltr = s->direction() == LTR;
112 int clientWidth = o->clientWidth(); 113 int clientWidth = box->clientWidth();
113 int contentWidth = ltr ? o->rightmostPosition(true, false) : o->leftmost Position(true, false); 114 int contentWidth = ltr ? box->rightmostPosition(true, false) : box->left mostPosition(true, false);
114 if (ltr) 115 if (ltr)
115 contentWidth += (o->paddingRight() - o->borderLeft()); 116 contentWidth += (box->paddingRight() - box->borderLeft());
116 else { 117 else {
117 contentWidth = o->width() - contentWidth; 118 contentWidth = box->width() - contentWidth;
118 contentWidth += (o->paddingLeft() - o->borderRight()); 119 contentWidth += (box->paddingLeft() - box->borderRight());
119 } 120 }
120 if (dir == MRIGHT) { 121 if (dir == MRIGHT) {
121 if (stopAtContentEdge) 122 if (stopAtContentEdge)
122 return max(0, ltr ? (contentWidth - clientWidth) : (clientWidth - contentWidth)); 123 return max(0, ltr ? (contentWidth - clientWidth) : (clientWidth - contentWidth));
123 else 124 else
124 return ltr ? contentWidth : clientWidth; 125 return ltr ? contentWidth : clientWidth;
125 } 126 }
126 else { 127 else {
127 if (stopAtContentEdge) 128 if (stopAtContentEdge)
128 return min(0, ltr ? (contentWidth - clientWidth) : (clientWidth - contentWidth)); 129 return min(0, ltr ? (contentWidth - clientWidth) : (clientWidth - contentWidth));
129 else 130 else
130 return ltr ? -clientWidth : -contentWidth; 131 return ltr ? -clientWidth : -contentWidth;
131 } 132 }
132 } 133 }
133 else { 134 else {
134 int contentHeight = m_layer->renderer()->lowestPosition(true, false) - 135 int contentHeight = box->lowestPosition(true, false) -
135 m_layer->renderer()->borderTop() + m_layer->renderer ()->paddingBottom(); 136 box->borderTop() + box->paddingBottom();
136 int clientHeight = m_layer->renderer()->clientHeight(); 137 int clientHeight = box->clientHeight();
137 if (dir == MUP) { 138 if (dir == MUP) {
138 if (stopAtContentEdge) 139 if (stopAtContentEdge)
139 return min(contentHeight - clientHeight, 0); 140 return min(contentHeight - clientHeight, 0);
140 else 141 else
141 return -clientHeight; 142 return -clientHeight;
142 } 143 }
143 else { 144 else {
144 if (stopAtContentEdge) 145 if (stopAtContentEdge)
145 return max(contentHeight - clientHeight, 0); 146 return max(contentHeight - clientHeight, 0);
146 else 147 else
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 else { 277 else {
277 bool addIncrement = direction() == MUP || direction() == MLEFT; 278 bool addIncrement = direction() == MUP || direction() == MLEFT;
278 bool isReversed = s->marqueeBehavior() == MALTERNATE && m_currentLoop % 2; 279 bool isReversed = s->marqueeBehavior() == MALTERNATE && m_currentLoop % 2;
279 if (isReversed) { 280 if (isReversed) {
280 // We're going in the reverse direction. 281 // We're going in the reverse direction.
281 endPoint = m_start; 282 endPoint = m_start;
282 range = -range; 283 range = -range;
283 addIncrement = !addIncrement; 284 addIncrement = !addIncrement;
284 } 285 }
285 bool positive = range > 0; 286 bool positive = range > 0;
286 int clientSize = (isHorizontal() ? m_layer->renderer()->clientWidth() : m_layer->renderer()->clientHeight()); 287 int clientSize = (isHorizontal() ? m_layer->renderBox()->clientWidth() : m_layer->renderBox()->clientHeight());
287 int increment = max(1, abs(m_layer->renderer()->style()->marqueeIncremen t().calcValue(clientSize))); 288 int increment = max(1, abs(m_layer->renderer()->style()->marqueeIncremen t().calcValue(clientSize)));
288 int currentPos = (isHorizontal() ? m_layer->scrollXOffset() : m_layer->s crollYOffset()); 289 int currentPos = (isHorizontal() ? m_layer->scrollXOffset() : m_layer->s crollYOffset());
289 newPos = currentPos + (addIncrement ? increment : -increment); 290 newPos = currentPos + (addIncrement ? increment : -increment);
290 if (positive) 291 if (positive)
291 newPos = min(newPos, endPoint); 292 newPos = min(newPos, endPoint);
292 else 293 else
293 newPos = max(newPos, endPoint); 294 newPos = max(newPos, endPoint);
294 } 295 }
295 296
296 if (newPos == endPoint) { 297 if (newPos == endPoint) {
297 m_currentLoop++; 298 m_currentLoop++;
298 if (m_totalLoops > 0 && m_currentLoop >= m_totalLoops) 299 if (m_totalLoops > 0 && m_currentLoop >= m_totalLoops)
299 m_timer.stop(); 300 m_timer.stop();
300 else if (s->marqueeBehavior() != MALTERNATE) 301 else if (s->marqueeBehavior() != MALTERNATE)
301 m_reset = true; 302 m_reset = true;
302 } 303 }
303 304
304 if (isHorizontal()) 305 if (isHorizontal())
305 m_layer->scrollToXOffset(newPos); 306 m_layer->scrollToXOffset(newPos);
306 else 307 else
307 m_layer->scrollToYOffset(newPos); 308 m_layer->scrollToYOffset(newPos);
308 } 309 }
309 310
310 } // namespace WebCore 311 } // namespace WebCore
311 312
OLDNEW
« no previous file with comments | « third_party/WebKit/WebCore/rendering/RenderListMarker.cpp ('k') | third_party/WebKit/WebCore/rendering/RenderMedia.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698