| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2011 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 |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 paintTickmarks(graphicsContext, scrollbar, trackPaintRect); | 123 paintTickmarks(graphicsContext, scrollbar, trackPaintRect); |
| 124 } | 124 } |
| 125 | 125 |
| 126 // Paint the thumb. | 126 // Paint the thumb. |
| 127 if (scrollMask & ThumbPart) | 127 if (scrollMask & ThumbPart) |
| 128 paintThumb(graphicsContext, scrollbar, thumbRect); | 128 paintThumb(graphicsContext, scrollbar, thumbRect); |
| 129 | 129 |
| 130 return true; | 130 return true; |
| 131 } | 131 } |
| 132 | 132 |
| 133 ScrollbarPart ScrollbarTheme::hitTest(const ScrollbarThemeClient* scrollbar, con
st IntPoint& position) | 133 ScrollbarPart ScrollbarTheme::hitTest(const ScrollbarThemeClient* scrollbar, con
st IntPoint& positionInRootFrame) |
| 134 { | 134 { |
| 135 ScrollbarPart result = NoPart; | 135 ScrollbarPart result = NoPart; |
| 136 if (!scrollbar->enabled()) | 136 if (!scrollbar->enabled()) |
| 137 return result; | 137 return result; |
| 138 | 138 |
| 139 IntPoint testPosition = scrollbar->convertFromContainingWindow(position); | 139 IntPoint testPosition = scrollbar->convertFromRootFrame(positionInRootFrame)
; |
| 140 testPosition.move(scrollbar->x(), scrollbar->y()); | 140 testPosition.move(scrollbar->x(), scrollbar->y()); |
| 141 | 141 |
| 142 if (!scrollbar->frameRect().contains(testPosition)) | 142 if (!scrollbar->frameRect().contains(testPosition)) |
| 143 return NoPart; | 143 return NoPart; |
| 144 | 144 |
| 145 result = ScrollbarBGPart; | 145 result = ScrollbarBGPart; |
| 146 | 146 |
| 147 IntRect track = trackRect(scrollbar); | 147 IntRect track = trackRect(scrollbar); |
| 148 if (track.contains(testPosition)) { | 148 if (track.contains(testPosition)) { |
| 149 IntRect beforeThumbRect; | 149 IntRect beforeThumbRect; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 #endif | 186 #endif |
| 187 } | 187 } |
| 188 | 188 |
| 189 bool ScrollbarTheme::shouldCenterOnThumb(const ScrollbarThemeClient* scrollbar,
const PlatformMouseEvent& evt) | 189 bool ScrollbarTheme::shouldCenterOnThumb(const ScrollbarThemeClient* scrollbar,
const PlatformMouseEvent& evt) |
| 190 { | 190 { |
| 191 return Platform::current()->scrollbarBehavior()->shouldCenterOnThumb(static_
cast<WebScrollbarBehavior::Button>(evt.button()), evt.shiftKey(), evt.altKey()); | 191 return Platform::current()->scrollbarBehavior()->shouldCenterOnThumb(static_
cast<WebScrollbarBehavior::Button>(evt.button()), evt.shiftKey(), evt.altKey()); |
| 192 } | 192 } |
| 193 | 193 |
| 194 bool ScrollbarTheme::shouldSnapBackToDragOrigin(const ScrollbarThemeClient* scro
llbar, const PlatformMouseEvent& evt) | 194 bool ScrollbarTheme::shouldSnapBackToDragOrigin(const ScrollbarThemeClient* scro
llbar, const PlatformMouseEvent& evt) |
| 195 { | 195 { |
| 196 IntPoint mousePosition = scrollbar->convertFromContainingWindow(evt.position
()); | 196 IntPoint mousePosition = scrollbar->convertFromRootFrame(evt.position()); |
| 197 mousePosition.move(scrollbar->x(), scrollbar->y()); | 197 mousePosition.move(scrollbar->x(), scrollbar->y()); |
| 198 return Platform::current()->scrollbarBehavior()->shouldSnapBackToDragOrigin(
mousePosition, trackRect(scrollbar), scrollbar->orientation() == HorizontalScrol
lbar); | 198 return Platform::current()->scrollbarBehavior()->shouldSnapBackToDragOrigin(
mousePosition, trackRect(scrollbar), scrollbar->orientation() == HorizontalScrol
lbar); |
| 199 } | 199 } |
| 200 | 200 |
| 201 int ScrollbarTheme::thumbPosition(const ScrollbarThemeClient* scrollbar) | 201 int ScrollbarTheme::thumbPosition(const ScrollbarThemeClient* scrollbar) |
| 202 { | 202 { |
| 203 if (scrollbar->enabled()) { | 203 if (scrollbar->enabled()) { |
| 204 float size = scrollbar->totalSize() - scrollbar->visibleSize(); | 204 float size = scrollbar->totalSize() - scrollbar->visibleSize(); |
| 205 // Avoid doing a floating point divide by zero and return 1 when usedTot
alSize == visibleSize. | 205 // Avoid doing a floating point divide by zero and return 1 when usedTot
alSize == visibleSize. |
| 206 if (!size) | 206 if (!size) |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 return DisplayItem::ScrollbarBackTrack; | 332 return DisplayItem::ScrollbarBackTrack; |
| 333 case ForwardTrackPart: | 333 case ForwardTrackPart: |
| 334 return DisplayItem::ScrollbarForwardTrack; | 334 return DisplayItem::ScrollbarForwardTrack; |
| 335 default: | 335 default: |
| 336 ASSERT_NOT_REACHED(); | 336 ASSERT_NOT_REACHED(); |
| 337 return DisplayItem::ScrollbarBackTrack; | 337 return DisplayItem::ScrollbarBackTrack; |
| 338 } | 338 } |
| 339 } | 339 } |
| 340 | 340 |
| 341 } // namespace blink | 341 } // namespace blink |
| OLD | NEW |