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

Side by Side Diff: WebKit/chromium/src/WebScrollbarImpl.cpp

Issue 3364013: Merge 67001 - 2010-09-08 Peter Kasting <pkasting@google.com>... (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/517/
Patch Set: Created 10 years, 3 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 m_scrollbar->setProportion(length, m_scrollbar->totalSize()); 87 m_scrollbar->setProportion(length, m_scrollbar->totalSize());
88 } 88 }
89 89
90 int WebScrollbarImpl::value() const 90 int WebScrollbarImpl::value() const
91 { 91 {
92 return m_scrollbar->value(); 92 return m_scrollbar->value();
93 } 93 }
94 94
95 void WebScrollbarImpl::setValue(int position) 95 void WebScrollbarImpl::setValue(int position)
96 { 96 {
97 m_scrollbar->setValue(position); 97 m_scrollbar->setValue(position, Scrollbar::NotFromScrollAnimator);
98 } 98 }
99 99
100 void WebScrollbarImpl::setDocumentSize(int size) 100 void WebScrollbarImpl::setDocumentSize(int size)
101 { 101 {
102 int length = m_scrollbar->orientation() == HorizontalScrollbar ? m_scrollbar ->width() : m_scrollbar->height(); 102 int length = m_scrollbar->orientation() == HorizontalScrollbar ? m_scrollbar ->width() : m_scrollbar->height();
103 m_scrollbar->setEnabled(size > length); 103 m_scrollbar->setEnabled(size > length);
104 m_scrollbar->setProportion(length, size); 104 m_scrollbar->setProportion(length, size);
105 } 105 }
106 106
107 void WebScrollbarImpl::scroll(ScrollDirection direction, ScrollGranularity granu larity, float multiplier) 107 void WebScrollbarImpl::scroll(ScrollDirection direction, ScrollGranularity granu larity, float multiplier)
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 int maxScrollDelta = m_scrollbar->maximum() - m_scrollbar->value(); 211 int maxScrollDelta = m_scrollbar->maximum() - m_scrollbar->value();
212 float delta = m_scrollbar->orientation() == HorizontalScrollbar ? mousew heel.deltaX : mousewheel.deltaY; 212 float delta = m_scrollbar->orientation() == HorizontalScrollbar ? mousew heel.deltaX : mousewheel.deltaY;
213 if ((delta < 0 && maxScrollDelta > 0) || (delta > 0 && m_scrollbar->valu e() > 0)) { 213 if ((delta < 0 && maxScrollDelta > 0) || (delta > 0 && m_scrollbar->valu e() > 0)) {
214 if (mousewheel.scrollByPage) { 214 if (mousewheel.scrollByPage) {
215 ASSERT(m_scrollbar->orientation() == VerticalScrollbar); 215 ASSERT(m_scrollbar->orientation() == VerticalScrollbar);
216 bool negative = delta < 0; 216 bool negative = delta < 0;
217 delta = max(max(static_cast<float>(m_scrollbar->visibleSize()) * Scrollbar::minFractionToStepWhenPaging(), static_cast<float>(m_scrollbar->visib leSize() - Scrollbar::maxOverlapBetweenPages())), 1.0f); 217 delta = max(max(static_cast<float>(m_scrollbar->visibleSize()) * Scrollbar::minFractionToStepWhenPaging(), static_cast<float>(m_scrollbar->visib leSize() - Scrollbar::maxOverlapBetweenPages())), 1.0f);
218 if (negative) 218 if (negative)
219 delta *= -1; 219 delta *= -1;
220 } 220 }
221 m_scrollbar->setValue(m_scrollbar->value() - delta); 221 m_scrollbar->scroll((m_scrollbar->orientation() == HorizontalScrollb ar) ? WebCore::ScrollLeft : WebCore::ScrollUp, WebCore::ScrollByPixel, delta);
222 return true; 222 return true;
223 } 223 }
224 224
225 return false; 225 return false;
226 } 226 }
227 227
228 bool WebScrollbarImpl::onKeyDown(const WebInputEvent& event) 228 bool WebScrollbarImpl::onKeyDown(const WebInputEvent& event)
229 { 229 {
230 WebKeyboardEvent keyboard = *static_cast<const WebKeyboardEvent*>(&event ); 230 WebKeyboardEvent keyboard = *static_cast<const WebKeyboardEvent*>(&event );
231 int keyCode; 231 int keyCode;
(...skipping 23 matching lines...) Expand all
255 } 255 }
256 WebCore::ScrollDirection scrollDirection; 256 WebCore::ScrollDirection scrollDirection;
257 WebCore::ScrollGranularity scrollGranularity; 257 WebCore::ScrollGranularity scrollGranularity;
258 if (WebViewImpl::mapKeyCodeForScroll(keyCode, &scrollDirection, &scrollG ranularity)) { 258 if (WebViewImpl::mapKeyCodeForScroll(keyCode, &scrollDirection, &scrollG ranularity)) {
259 // Will return false if scroll direction wasn't compatible with this scrollbar. 259 // Will return false if scroll direction wasn't compatible with this scrollbar.
260 return m_scrollbar->scroll(scrollDirection, scrollGranularity); 260 return m_scrollbar->scroll(scrollDirection, scrollGranularity);
261 } 261 }
262 return false; 262 return false;
263 } 263 }
264 264
265 int WebScrollbarImpl::scrollSize(WebCore::ScrollbarOrientation orientation) cons t
266 {
267 return (orientation == m_scrollbar->orientation()) ? (m_scrollbar->totalSize () - m_scrollbar->visibleSize()) : 0;
268 }
269
270 void WebScrollbarImpl::setScrollOffsetFromAnimation(const WebCore::IntPoint& off set)
271 {
272 m_scrollbar->setValue((m_scrollbar->orientation() == HorizontalScrollbar) ? offset.x() : offset.y(), Scrollbar::FromScrollAnimator);
273 }
274
265 void WebScrollbarImpl::valueChanged(WebCore::Scrollbar*) 275 void WebScrollbarImpl::valueChanged(WebCore::Scrollbar*)
266 { 276 {
267 m_client->valueChanged(this); 277 m_client->valueChanged(this);
268 } 278 }
269 279
270 void WebScrollbarImpl::invalidateScrollbarRect(WebCore::Scrollbar*, const WebCor e::IntRect& rect) 280 void WebScrollbarImpl::invalidateScrollbarRect(WebCore::Scrollbar*, const WebCor e::IntRect& rect)
271 { 281 {
272 WebRect webrect(rect); 282 WebRect webrect(rect);
273 webrect.x += m_scrollbar->x(); 283 webrect.x += m_scrollbar->x();
274 webrect.y += m_scrollbar->y(); 284 webrect.y += m_scrollbar->y();
(...skipping 13 matching lines...) Expand all
288 void WebScrollbarImpl::getTickmarks(Vector<WebCore::IntRect>& tickmarks) const 298 void WebScrollbarImpl::getTickmarks(Vector<WebCore::IntRect>& tickmarks) const
289 { 299 {
290 WebVector<WebRect> ticks; 300 WebVector<WebRect> ticks;
291 m_client->getTickmarks(const_cast<WebScrollbarImpl*>(this), &ticks); 301 m_client->getTickmarks(const_cast<WebScrollbarImpl*>(this), &ticks);
292 tickmarks.resize(ticks.size()); 302 tickmarks.resize(ticks.size());
293 for (size_t i = 0; i < ticks.size(); ++i) 303 for (size_t i = 0; i < ticks.size(); ++i)
294 tickmarks[i] = ticks[i]; 304 tickmarks[i] = ticks[i];
295 } 305 }
296 306
297 } // namespace WebKit 307 } // namespace WebKit
OLDNEW
« no previous file with comments | « WebKit/chromium/src/WebScrollbarImpl.h ('k') | WebKit/chromium/src/win/WebInputEventFactory.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698