| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2006, 2008 Apple 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 |
| 11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
| 12 * | 12 * |
| 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY | 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY |
| 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
| 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #include "platform/scroll/Scrollbar.h" | 26 #include "platform/scroll/Scrollbar.h" |
| 27 | 27 |
| 28 #include <algorithm> | 28 #include "platform/Histogram.h" |
| 29 #include "platform/HostWindow.h" | 29 #include "platform/HostWindow.h" |
| 30 #include "platform/PlatformMouseEvent.h" | 30 #include "platform/PlatformMouseEvent.h" |
| 31 #include "platform/geometry/FloatRect.h" | 31 #include "platform/geometry/FloatRect.h" |
| 32 #include "platform/graphics/paint/CullRect.h" | 32 #include "platform/graphics/paint/CullRect.h" |
| 33 #include "platform/scroll/ScrollAnimatorBase.h" | 33 #include "platform/scroll/ScrollAnimatorBase.h" |
| 34 #include "platform/scroll/ScrollableArea.h" | 34 #include "platform/scroll/ScrollableArea.h" |
| 35 #include "platform/scroll/ScrollbarTheme.h" | 35 #include "platform/scroll/ScrollbarTheme.h" |
| 36 #include "public/platform/WebGestureEvent.h" | 36 #include "public/platform/WebGestureEvent.h" |
| 37 | 37 |
| 38 namespace blink { | 38 namespace blink { |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 m_hoveredPart = part; | 310 m_hoveredPart = part; |
| 311 } | 311 } |
| 312 | 312 |
| 313 void Scrollbar::setPressedPart(ScrollbarPart part) { | 313 void Scrollbar::setPressedPart(ScrollbarPart part) { |
| 314 if (m_pressedPart != NoPart | 314 if (m_pressedPart != NoPart |
| 315 // When we no longer have a pressed part, we can start drawing a hovered | 315 // When we no longer have a pressed part, we can start drawing a hovered |
| 316 // state on the hovered part. | 316 // state on the hovered part. |
| 317 || m_hoveredPart != NoPart) | 317 || m_hoveredPart != NoPart) |
| 318 setNeedsPaintInvalidation( | 318 setNeedsPaintInvalidation( |
| 319 static_cast<ScrollbarPart>(m_pressedPart | m_hoveredPart | part)); | 319 static_cast<ScrollbarPart>(m_pressedPart | m_hoveredPart | part)); |
| 320 |
| 321 sendScrollbarUseUMA(part); |
| 320 m_pressedPart = part; | 322 m_pressedPart = part; |
| 321 } | 323 } |
| 322 | 324 |
| 325 void Scrollbar::sendScrollbarUseUMA(ScrollbarPart part) { |
| 326 DCHECK(root()); |
| 327 |
| 328 ScrollbarUseUMA scrollbarUseUMA = IgnorePart; |
| 329 switch (part) { |
| 330 case BackButtonStartPart: |
| 331 case ForwardButtonStartPart: |
| 332 case BackButtonEndPart: |
| 333 case ForwardButtonEndPart: |
| 334 scrollbarUseUMA = |
| 335 (orientation() == VerticalScrollbar ? VerticalScrollbarButton |
| 336 : HorizontalScrollbarButton); |
| 337 break; |
| 338 case ThumbPart: |
| 339 scrollbarUseUMA = |
| 340 (orientation() == VerticalScrollbar ? VerticalScrollbarThumb |
| 341 : HorizontalScrollbarThumb); |
| 342 break; |
| 343 case BackTrackPart: |
| 344 case ForwardTrackPart: |
| 345 scrollbarUseUMA = |
| 346 (orientation() == VerticalScrollbar ? VerticalScrollbarTrack |
| 347 : HorizontalScrollbarTrack); |
| 348 break; |
| 349 default: |
| 350 scrollbarUseUMA = IgnorePart; |
| 351 } |
| 352 |
| 353 if (scrollbarUseUMA != IgnorePart && |
| 354 root()->shouldSendScrollbarUseUMA(scrollbarUseUMA)) { |
| 355 DEFINE_STATIC_LOCAL(EnumerationHistogram, scrollbarUseHistogram, |
| 356 ("Scrollbar.ScrollbarUse", ScrollbarUseUMAMax)); |
| 357 scrollbarUseHistogram.count(static_cast<ScrollbarUseUMA>(part)); |
| 358 } |
| 359 } |
| 360 |
| 323 bool Scrollbar::gestureEvent(const WebGestureEvent& evt, | 361 bool Scrollbar::gestureEvent(const WebGestureEvent& evt, |
| 324 bool* shouldUpdateCapture) { | 362 bool* shouldUpdateCapture) { |
| 325 DCHECK(shouldUpdateCapture); | 363 DCHECK(shouldUpdateCapture); |
| 326 switch (evt.type()) { | 364 switch (evt.type()) { |
| 327 case WebInputEvent::GestureTapDown: { | 365 case WebInputEvent::GestureTapDown: { |
| 328 IntPoint position = flooredIntPoint(evt.positionInRootFrame()); | 366 IntPoint position = flooredIntPoint(evt.positionInRootFrame()); |
| 329 setPressedPart(theme().hitTest(*this, position)); | 367 setPressedPart(theme().hitTest(*this, position)); |
| 330 m_pressedPos = orientation() == HorizontalScrollbar | 368 m_pressedPos = orientation() == HorizontalScrollbar |
| 331 ? convertFromRootFrame(position).x() | 369 ? convertFromRootFrame(position).x() |
| 332 : convertFromRootFrame(position).y(); | 370 : convertFromRootFrame(position).y(); |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 629 invalidParts = AllParts; | 667 invalidParts = AllParts; |
| 630 if (invalidParts & ~ThumbPart) | 668 if (invalidParts & ~ThumbPart) |
| 631 m_trackNeedsRepaint = true; | 669 m_trackNeedsRepaint = true; |
| 632 if (invalidParts & ThumbPart) | 670 if (invalidParts & ThumbPart) |
| 633 m_thumbNeedsRepaint = true; | 671 m_thumbNeedsRepaint = true; |
| 634 if (m_scrollableArea) | 672 if (m_scrollableArea) |
| 635 m_scrollableArea->setScrollbarNeedsPaintInvalidation(orientation()); | 673 m_scrollableArea->setScrollbarNeedsPaintInvalidation(orientation()); |
| 636 } | 674 } |
| 637 | 675 |
| 638 } // namespace blink | 676 } // namespace blink |
| OLD | NEW |