Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2008, Google Inc. | 1 // Copyright (c) 2008, Google Inc. |
| 2 // All rights reserved. | 2 // 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 875 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 886 } | 886 } |
| 887 } | 887 } |
| 888 | 888 |
| 889 void PopupListBox::setOriginalIndex(int index) | 889 void PopupListBox::setOriginalIndex(int index) |
| 890 { | 890 { |
| 891 m_originalIndex = m_selectedIndex = index; | 891 m_originalIndex = m_selectedIndex = index; |
| 892 } | 892 } |
| 893 | 893 |
| 894 int PopupListBox::getRowHeight(int index) | 894 int PopupListBox::getRowHeight(int index) |
| 895 { | 895 { |
| 896 return m_popupClient->itemStyle(index).font().height(); | 896 if (index >= 0) { |
| 897 return m_popupClient->itemStyle(index).font().height(); | |
| 898 } else { | |
| 899 return 0; | |
| 900 } | |
| 897 } | 901 } |
| 898 | 902 |
| 899 IntRect PopupListBox::getRowBounds(int index) | 903 IntRect PopupListBox::getRowBounds(int index) |
| 900 { | 904 { |
| 901 if (index >= 0) { | 905 if (index >= 0) { |
| 902 return IntRect(0, m_items[index]->y, visibleWidth(), getRowHeight(index) ); | 906 return IntRect(0, m_items[index]->y, visibleWidth(), getRowHeight(index) ); |
| 903 } else { | 907 } else { |
| 904 return IntRect(0, 0, visibleWidth(), getRowHeight(index)); | 908 return IntRect(0, 0, visibleWidth(), getRowHeight(index)); |
| 905 } | 909 } |
| 906 } | 910 } |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1028 for (int i = 0; i < m_visibleRows; ++i) { | 1032 for (int i = 0; i < m_visibleRows; ++i) { |
| 1029 int rowHeight = getRowHeight(i); | 1033 int rowHeight = getRowHeight(i); |
| 1030 if (windowHeight + rowHeight > kMaxHeight) { | 1034 if (windowHeight + rowHeight > kMaxHeight) { |
| 1031 m_visibleRows = i; | 1035 m_visibleRows = i; |
| 1032 break; | 1036 break; |
| 1033 } | 1037 } |
| 1034 | 1038 |
| 1035 windowHeight += rowHeight; | 1039 windowHeight += rowHeight; |
| 1036 } | 1040 } |
| 1037 | 1041 |
| 1038 if (windowHeight == 0) | |
| 1039 windowHeight = min(getRowHeight(-1), kMaxHeight); | |
|
darin (slow to review)
2008/12/20 18:24:25
it is not obvious to me why you are removing this
| |
| 1040 | |
| 1041 // Set our widget and scrollable contents sizes. | 1042 // Set our widget and scrollable contents sizes. |
| 1042 int scrollbarWidth = 0; | 1043 int scrollbarWidth = 0; |
| 1043 if (m_visibleRows < numItems()) | 1044 if (m_visibleRows < numItems()) |
| 1044 scrollbarWidth = ScrollbarTheme::nativeTheme()->scrollbarThickness(); | 1045 scrollbarWidth = ScrollbarTheme::nativeTheme()->scrollbarThickness(); |
| 1045 | 1046 |
| 1046 int windowWidth = baseWidth + scrollbarWidth + paddingWidth; | 1047 int windowWidth = baseWidth + scrollbarWidth + paddingWidth; |
| 1047 int contentWidth = baseWidth; | 1048 int contentWidth = baseWidth; |
| 1048 | 1049 |
| 1049 if (windowWidth < m_baseWidth) { | 1050 if (windowWidth < m_baseWidth) { |
| 1050 windowWidth = m_baseWidth; | 1051 windowWidth = m_baseWidth; |
| 1051 contentWidth = m_baseWidth - scrollbarWidth - paddingWidth; | 1052 contentWidth = m_baseWidth - scrollbarWidth - paddingWidth; |
| 1052 } else { | 1053 } else { |
| 1053 m_baseWidth = baseWidth; | 1054 m_baseWidth = baseWidth; |
| 1054 } | 1055 } |
| 1055 | 1056 |
| 1056 resize(windowWidth, windowHeight); | 1057 resize(windowWidth, windowHeight); |
| 1057 setContentsSize(IntSize(contentWidth, getRowBounds(numItems() - 1).bottom()) ); | 1058 setContentsSize(IntSize(contentWidth, getRowBounds(numItems() - 1).bottom()) ); |
| 1058 | 1059 |
| 1059 if (hostWindow()) | 1060 if (hostWindow()) |
| 1060 scrollToRevealSelection(); | 1061 scrollToRevealSelection(); |
| 1061 | 1062 |
| 1062 invalidate(); | 1063 invalidate(); |
| 1063 } | 1064 } |
| 1064 | 1065 |
| 1065 void PopupListBox::clear() | 1066 void PopupListBox::clear() |
| 1066 { | 1067 { |
| 1067 for (Vector<ListItem*>::iterator it = m_items.begin(); it != m_items.end(); ++it) | 1068 for (Vector<ListItem*>::iterator it = m_items.begin(); it != m_items.end(); ++it) |
| 1068 delete *it; | 1069 delete *it; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1110 { | 1111 { |
| 1111 p.m_popup->listBox()->updateFromElement(); | 1112 p.m_popup->listBox()->updateFromElement(); |
| 1112 } | 1113 } |
| 1113 | 1114 |
| 1114 bool PopupMenu::itemWritingDirectionIsNatural() | 1115 bool PopupMenu::itemWritingDirectionIsNatural() |
| 1115 { | 1116 { |
| 1116 return false; | 1117 return false; |
| 1117 } | 1118 } |
| 1118 | 1119 |
| 1119 } // namespace WebCore | 1120 } // namespace WebCore |
| OLD | NEW |