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 |
(...skipping 13 matching lines...) Expand all Loading... | |
24 */ | 24 */ |
25 | 25 |
26 #include "config.h" | 26 #include "config.h" |
27 #include "platform/scroll/Scrollbar.h" | 27 #include "platform/scroll/Scrollbar.h" |
28 | 28 |
29 #include <algorithm> | 29 #include <algorithm> |
30 #include "platform/graphics/GraphicsContext.h" | 30 #include "platform/graphics/GraphicsContext.h" |
31 #include "platform/PlatformGestureEvent.h" | 31 #include "platform/PlatformGestureEvent.h" |
32 #include "platform/PlatformMouseEvent.h" | 32 #include "platform/PlatformMouseEvent.h" |
33 #include "platform/scroll/ScrollAnimator.h" | 33 #include "platform/scroll/ScrollAnimator.h" |
34 #include "platform/scroll/ScrollView.h" | |
35 #include "platform/scroll/ScrollableArea.h" | 34 #include "platform/scroll/ScrollableArea.h" |
36 #include "platform/scroll/ScrollbarTheme.h" | 35 #include "platform/scroll/ScrollbarTheme.h" |
37 | 36 |
38 #if ((OS(POSIX) && !OS(MACOSX)) || OS(WIN)) | 37 #if ((OS(POSIX) && !OS(MACOSX)) || OS(WIN)) |
39 // The position of the scrollbar thumb affects the appearance of the steppers, s o | 38 // The position of the scrollbar thumb affects the appearance of the steppers, s o |
40 // when the thumb moves, we have to invalidate them for painting. | 39 // when the thumb moves, we have to invalidate them for painting. |
41 #define THUMB_POSITION_AFFECTS_BUTTONS | 40 #define THUMB_POSITION_AFFECTS_BUTTONS |
42 #endif | 41 #endif |
43 | 42 |
44 namespace blink { | 43 namespace blink { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
83 m_currentPos = scrollableAreaCurrentPos(); | 82 m_currentPos = scrollableAreaCurrentPos(); |
84 } | 83 } |
85 | 84 |
86 Scrollbar::~Scrollbar() | 85 Scrollbar::~Scrollbar() |
87 { | 86 { |
88 stopTimerIfNeeded(); | 87 stopTimerIfNeeded(); |
89 | 88 |
90 m_theme->unregisterScrollbar(this); | 89 m_theme->unregisterScrollbar(this); |
91 } | 90 } |
92 | 91 |
93 void Scrollbar::removeFromParent() | |
94 { | |
95 if (parent()) | |
96 toScrollView(parent())->removeChild(this); | |
97 } | |
98 | |
99 ScrollView* Scrollbar::parentScrollView() const | |
100 { | |
101 return parent() && parent()->isScrollView() ? toScrollView(parent()) : 0; | |
102 } | |
103 | |
104 ScrollbarOverlayStyle Scrollbar::scrollbarOverlayStyle() const | 92 ScrollbarOverlayStyle Scrollbar::scrollbarOverlayStyle() const |
105 { | 93 { |
106 return m_scrollableArea ? m_scrollableArea->scrollbarOverlayStyle() : Scroll barOverlayStyleDefault; | 94 return m_scrollableArea ? m_scrollableArea->scrollbarOverlayStyle() : Scroll barOverlayStyleDefault; |
107 } | 95 } |
108 | 96 |
109 void Scrollbar::getTickmarks(Vector<IntRect>& tickmarks) const | 97 void Scrollbar::getTickmarks(Vector<IntRect>& tickmarks) const |
110 { | 98 { |
111 if (m_scrollableArea) | 99 if (m_scrollableArea) |
112 m_scrollableArea->getTickmarks(tickmarks); | 100 m_scrollableArea->getTickmarks(tickmarks); |
113 } | 101 } |
114 | 102 |
115 bool Scrollbar::isScrollableAreaActive() const | 103 bool Scrollbar::isScrollableAreaActive() const |
116 { | 104 { |
117 return m_scrollableArea && m_scrollableArea->isActive(); | 105 return m_scrollableArea && m_scrollableArea->isActive(); |
118 } | 106 } |
119 | 107 |
120 bool Scrollbar::isScrollViewScrollbar() const | 108 bool Scrollbar::isScrollViewScrollbar() const |
121 { | 109 { |
122 return parent() && parent()->isFrameView() && toScrollView(parent())->isScro llViewScrollbar(this); | 110 return m_scrollableArea && m_scrollableArea->isScrollViewScrollbar(this); |
Ian Vollick
2014/10/04 01:25:45
Wouldn't this have previously returned true for Re
skobes
2014/10/06 18:18:53
No, ScrollView::isScrollViewScrollbar returns fals
| |
123 } | 111 } |
124 | 112 |
125 bool Scrollbar::isLeftSideVerticalScrollbar() const | 113 bool Scrollbar::isLeftSideVerticalScrollbar() const |
126 { | 114 { |
127 if (m_orientation == VerticalScrollbar && m_scrollableArea) | 115 if (m_orientation == VerticalScrollbar && m_scrollableArea) |
128 return m_scrollableArea->shouldPlaceVerticalScrollbarOnLeft(); | 116 return m_scrollableArea->shouldPlaceVerticalScrollbarOnLeft(); |
129 return false; | 117 return false; |
130 } | 118 } |
131 | 119 |
132 void Scrollbar::offsetDidChange() | 120 void Scrollbar::offsetDidChange() |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
464 moveThumb(desiredPos); | 452 moveThumb(desiredPos); |
465 return; | 453 return; |
466 } else if (m_pressedPart == ThumbPart) | 454 } else if (m_pressedPart == ThumbPart) |
467 m_dragOrigin = m_currentPos; | 455 m_dragOrigin = m_currentPos; |
468 | 456 |
469 m_pressedPos = pressedPos; | 457 m_pressedPos = pressedPos; |
470 | 458 |
471 autoscrollPressedPart(theme()->initialAutoscrollTimerDelay()); | 459 autoscrollPressedPart(theme()->initialAutoscrollTimerDelay()); |
472 } | 460 } |
473 | 461 |
474 void Scrollbar::setFrameRect(const IntRect& rect) | |
475 { | |
476 // Get our window resizer rect and see if we overlap. Adjust to avoid the ov erlap | |
477 // if necessary. | |
478 IntRect adjustedRect(rect); | |
479 bool overlapsResizer = false; | |
480 ScrollView* view = parentScrollView(); | |
481 if (view && !rect.isEmpty() && !view->windowResizerRect().isEmpty()) { | |
482 IntRect resizerRect = view->convertFromContainingWindow(view->windowResi zerRect()); | |
483 if (rect.intersects(resizerRect)) { | |
484 if (orientation() == HorizontalScrollbar) { | |
485 int overlap = rect.maxX() - resizerRect.x(); | |
486 if (overlap > 0 && resizerRect.maxX() >= rect.maxX()) { | |
487 adjustedRect.setWidth(rect.width() - overlap); | |
488 overlapsResizer = true; | |
489 } | |
490 } else { | |
491 int overlap = rect.maxY() - resizerRect.y(); | |
492 if (overlap > 0 && resizerRect.maxY() >= rect.maxY()) { | |
493 adjustedRect.setHeight(rect.height() - overlap); | |
494 overlapsResizer = true; | |
495 } | |
496 } | |
497 } | |
498 } | |
499 if (overlapsResizer != m_overlapsResizer) { | |
500 m_overlapsResizer = overlapsResizer; | |
501 if (view) | |
502 view->adjustScrollbarsAvoidingResizerCount(m_overlapsResizer ? 1 : - 1); | |
503 } | |
504 | |
505 Widget::setFrameRect(adjustedRect); | |
506 } | |
507 | |
508 void Scrollbar::setParent(Widget* parentView) | |
509 { | |
510 if (!parentView && m_overlapsResizer && parentScrollView()) | |
511 parentScrollView()->adjustScrollbarsAvoidingResizerCount(-1); | |
512 Widget::setParent(parentView); | |
513 } | |
514 | |
515 void Scrollbar::setEnabled(bool e) | 462 void Scrollbar::setEnabled(bool e) |
516 { | 463 { |
517 if (m_enabled == e) | 464 if (m_enabled == e) |
518 return; | 465 return; |
519 m_enabled = e; | 466 m_enabled = e; |
520 theme()->updateEnabledState(this); | 467 theme()->updateEnabledState(this); |
521 invalidate(); | 468 invalidate(); |
522 } | 469 } |
523 | 470 |
524 bool Scrollbar::isOverlayScrollbar() const | 471 bool Scrollbar::isOverlayScrollbar() const |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
585 if (!m_scrollableArea) | 532 if (!m_scrollableArea) |
586 return 0; | 533 return 0; |
587 | 534 |
588 if (m_orientation == HorizontalScrollbar) | 535 if (m_orientation == HorizontalScrollbar) |
589 return m_scrollableArea->scrollPosition().x() - m_scrollableArea->minimu mScrollPosition().x(); | 536 return m_scrollableArea->scrollPosition().x() - m_scrollableArea->minimu mScrollPosition().x(); |
590 | 537 |
591 return m_scrollableArea->scrollPosition().y() - m_scrollableArea->minimumScr ollPosition().y(); | 538 return m_scrollableArea->scrollPosition().y() - m_scrollableArea->minimumScr ollPosition().y(); |
592 } | 539 } |
593 | 540 |
594 } // namespace blink | 541 } // namespace blink |
OLD | NEW |