Chromium Code Reviews| 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 // Send ScrollbarPressedPart histogram. | |
| 322 ScrollbarPressedPart scrollbarPressedPart = IgnorePart; | |
|
bokan
2017/01/16 21:25:33
Put all of this into a helper method that you call
| |
| 323 switch (part) { | |
| 324 case BackButtonStartPart: | |
| 325 case ForwardButtonStartPart: | |
| 326 case BackButtonEndPart: | |
| 327 case ForwardButtonEndPart: | |
| 328 scrollbarPressedPart = | |
| 329 (orientation() == VerticalScrollbar ? VerticalScrollbarButton | |
| 330 : HorizontalScrollbarButton); | |
| 331 break; | |
| 332 case ThumbPart: | |
| 333 scrollbarPressedPart = | |
| 334 (orientation() == VerticalScrollbar ? VerticalScrollbarThumb | |
| 335 : HorizontalScrollbarThumb); | |
| 336 break; | |
| 337 case BackTrackPart: | |
| 338 case ForwardTrackPart: | |
| 339 scrollbarPressedPart = | |
| 340 (orientation() == VerticalScrollbar ? VerticalScrollbarTrack | |
| 341 : HorizontalScrollbarTrack); | |
| 342 break; | |
| 343 default: | |
| 344 scrollbarPressedPart = IgnorePart; | |
| 345 } | |
| 346 | |
| 347 if (scrollbarPressedPart != IgnorePart) { | |
| 348 DEFINE_STATIC_LOCAL(EnumerationHistogram, scrollbarPressedPartHistogram, | |
| 349 ("ScrollbarPressedPart", ScrollbarPressedPartMax)); | |
| 350 scrollbarPressedPartHistogram.count( | |
|
bokan
2017/01/16 21:25:33
This will still count multiple uses on a page load
| |
| 351 static_cast<ScrollbarPressedPart>(scrollbarPressedPart)); | |
| 352 } | |
| 353 | |
| 320 m_pressedPart = part; | 354 m_pressedPart = part; |
| 321 } | 355 } |
| 322 | 356 |
| 323 bool Scrollbar::gestureEvent(const WebGestureEvent& evt, | 357 bool Scrollbar::gestureEvent(const WebGestureEvent& evt, |
| 324 bool* shouldUpdateCapture) { | 358 bool* shouldUpdateCapture) { |
| 325 DCHECK(shouldUpdateCapture); | 359 DCHECK(shouldUpdateCapture); |
| 326 switch (evt.type()) { | 360 switch (evt.type()) { |
| 327 case WebInputEvent::GestureTapDown: { | 361 case WebInputEvent::GestureTapDown: { |
| 328 IntPoint position = flooredIntPoint(evt.positionInRootFrame()); | 362 IntPoint position = flooredIntPoint(evt.positionInRootFrame()); |
| 329 setPressedPart(theme().hitTest(*this, position)); | 363 setPressedPart(theme().hitTest(*this, position)); |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 629 invalidParts = AllParts; | 663 invalidParts = AllParts; |
| 630 if (invalidParts & ~ThumbPart) | 664 if (invalidParts & ~ThumbPart) |
| 631 m_trackNeedsRepaint = true; | 665 m_trackNeedsRepaint = true; |
| 632 if (invalidParts & ThumbPart) | 666 if (invalidParts & ThumbPart) |
| 633 m_thumbNeedsRepaint = true; | 667 m_thumbNeedsRepaint = true; |
| 634 if (m_scrollableArea) | 668 if (m_scrollableArea) |
| 635 m_scrollableArea->setScrollbarNeedsPaintInvalidation(orientation()); | 669 m_scrollableArea->setScrollbarNeedsPaintInvalidation(orientation()); |
| 636 } | 670 } |
| 637 | 671 |
| 638 } // namespace blink | 672 } // namespace blink |
| OLD | NEW |