OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2011, Google Inc. All rights reserved. | 2 * Copyright (c) 2011, 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 are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 948 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
959 // NOTE: Unlike FrameView we do not need to incorporate any scaling factor, | 959 // NOTE: Unlike FrameView we do not need to incorporate any scaling factor, |
960 // and there is only one scrollbar to exclude. | 960 // and there is only one scrollbar to exclude. |
961 IntSize size = frameRect().size(); | 961 IntSize size = frameRect().size(); |
962 Scrollbar* verticalBar = verticalScrollbar(); | 962 Scrollbar* verticalBar = verticalScrollbar(); |
963 if (scrollbarInclusion == ExcludeScrollbars && verticalBar && !verticalBar->
isOverlayScrollbar()) { | 963 if (scrollbarInclusion == ExcludeScrollbars && verticalBar && !verticalBar->
isOverlayScrollbar()) { |
964 size.setWidth(std::max(0, size.width() - verticalBar->width())); | 964 size.setWidth(std::max(0, size.width() - verticalBar->width())); |
965 } | 965 } |
966 return IntRect(m_scrollOffset, size); | 966 return IntRect(m_scrollOffset, size); |
967 } | 967 } |
968 | 968 |
969 void PopupListBox::updateScrollbars(const IntPoint& desiredOffset) | 969 void PopupListBox::updateScrollbars(IntPoint desiredOffset) |
970 { | 970 { |
971 IntSize oldVisibleSize = visibleContentRect().size(); | 971 IntSize oldVisibleSize = visibleContentRect().size(); |
972 adjustScrollbarExistence(); | 972 adjustScrollbarExistence(); |
973 updateScrollbarGeometry(); | 973 updateScrollbarGeometry(); |
974 IntSize newVisibleSize = visibleContentRect().size(); | 974 IntSize newVisibleSize = visibleContentRect().size(); |
975 | 975 |
976 if (newVisibleSize.width() > oldVisibleSize.width()) { | 976 if (newVisibleSize.width() > oldVisibleSize.width()) { |
977 if (shouldPlaceVerticalScrollbarOnLeft()) | 977 if (shouldPlaceVerticalScrollbarOnLeft()) |
978 invalidateRect(IntRect(0, 0, newVisibleSize.width() - oldVisibleSize
.width(), newVisibleSize.height())); | 978 invalidateRect(IntRect(0, 0, newVisibleSize.width() - oldVisibleSize
.width(), newVisibleSize.height())); |
979 else | 979 else |
980 invalidateRect(IntRect(oldVisibleSize.width(), 0, newVisibleSize.wid
th() - oldVisibleSize.width(), newVisibleSize.height())); | 980 invalidateRect(IntRect(oldVisibleSize.width(), 0, newVisibleSize.wid
th() - oldVisibleSize.width(), newVisibleSize.height())); |
981 } | 981 } |
| 982 |
| 983 desiredOffset = desiredOffset.shrunkTo(maximumScrollPosition()); |
| 984 desiredOffset = desiredOffset.expandedTo(minimumScrollPosition()); |
| 985 |
982 if (desiredOffset != scrollPosition()) | 986 if (desiredOffset != scrollPosition()) |
983 ScrollableArea::scrollToOffsetWithoutAnimation(desiredOffset); | 987 ScrollableArea::scrollToOffsetWithoutAnimation(desiredOffset); |
984 } | 988 } |
985 | 989 |
986 void PopupListBox::adjustScrollbarExistence() | 990 void PopupListBox::adjustScrollbarExistence() |
987 { | 991 { |
988 bool needsVerticalScrollbar = contentsSize().height() > visibleHeight(); | 992 bool needsVerticalScrollbar = contentsSize().height() > visibleHeight(); |
989 if (!!m_verticalScrollbar != needsVerticalScrollbar) { | 993 if (!!m_verticalScrollbar != needsVerticalScrollbar) { |
990 setHasVerticalScrollbar(needsVerticalScrollbar); | 994 setHasVerticalScrollbar(needsVerticalScrollbar); |
991 contentsResized(); | 995 contentsResized(); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1055 maximumOffset.clampNegativeToZero(); | 1059 maximumOffset.clampNegativeToZero(); |
1056 return maximumOffset; | 1060 return maximumOffset; |
1057 } | 1061 } |
1058 | 1062 |
1059 IntPoint PopupListBox::minimumScrollPosition() const | 1063 IntPoint PopupListBox::minimumScrollPosition() const |
1060 { | 1064 { |
1061 return IntPoint(-scrollOrigin().x(), -scrollOrigin().y()); | 1065 return IntPoint(-scrollOrigin().x(), -scrollOrigin().y()); |
1062 } | 1066 } |
1063 | 1067 |
1064 } // namespace blink | 1068 } // namespace blink |
OLD | NEW |