OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 } | 195 } |
196 | 196 |
197 void WebPluginScrollbarImpl::setLocation(const WebRect& rect) | 197 void WebPluginScrollbarImpl::setLocation(const WebRect& rect) |
198 { | 198 { |
199 IntRect oldRect = m_scrollbar->frameRect(); | 199 IntRect oldRect = m_scrollbar->frameRect(); |
200 m_scrollbar->setFrameRect(rect); | 200 m_scrollbar->setFrameRect(rect); |
201 if (WebRect(oldRect) != rect) | 201 if (WebRect(oldRect) != rect) |
202 m_scrollbar->invalidate(); | 202 m_scrollbar->invalidate(); |
203 | 203 |
204 int length = m_scrollbar->orientation() == HorizontalScrollbar ? m_scrollbar
->width() : m_scrollbar->height(); | 204 int length = m_scrollbar->orientation() == HorizontalScrollbar ? m_scrollbar
->width() : m_scrollbar->height(); |
205 int pageStep = max(max(static_cast<int>(static_cast<float>(length) * Scrollb
ar::minFractionToStepWhenPaging()), length - Scrollbar::maxOverlapBetweenPages()
), 1); | |
206 m_scrollbar->setSteps(Scrollbar::pixelsPerLineStep(), pageStep); | |
207 m_scrollbar->setEnabled(m_scrollbar->totalSize() > length); | 205 m_scrollbar->setEnabled(m_scrollbar->totalSize() > length); |
208 m_scrollbar->setProportion(length, m_scrollbar->totalSize()); | 206 m_scrollbar->setProportion(length, m_scrollbar->totalSize()); |
209 } | 207 } |
210 | 208 |
211 void WebPluginScrollbarImpl::setValue(int position) | 209 void WebPluginScrollbarImpl::setValue(int position) |
212 { | 210 { |
213 m_group->scrollToOffsetWithoutAnimation(m_scrollbar->orientation(), static_c
ast<float>(position)); | 211 m_group->scrollToOffsetWithoutAnimation(m_scrollbar->orientation(), static_c
ast<float>(position)); |
214 } | 212 } |
215 | 213 |
216 void WebPluginScrollbarImpl::setDocumentSize(int size) | 214 void WebPluginScrollbarImpl::setDocumentSize(int size) |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 WebCore::ScrollDirection scrollDirection; | 360 WebCore::ScrollDirection scrollDirection; |
363 WebCore::ScrollGranularity scrollGranularity; | 361 WebCore::ScrollGranularity scrollGranularity; |
364 if (WebViewImpl::mapKeyCodeForScroll(keyCode, &scrollDirection, &scrollGranu
larity)) { | 362 if (WebViewImpl::mapKeyCodeForScroll(keyCode, &scrollDirection, &scrollGranu
larity)) { |
365 // Will return false if scroll direction wasn't compatible with this scr
ollbar. | 363 // Will return false if scroll direction wasn't compatible with this scr
ollbar. |
366 return m_group->scroll(scrollDirection, scrollGranularity); | 364 return m_group->scroll(scrollDirection, scrollGranularity); |
367 } | 365 } |
368 return false; | 366 return false; |
369 } | 367 } |
370 | 368 |
371 } // namespace WebKit | 369 } // namespace WebKit |
OLD | NEW |