Changeset 19008 in webkit
- Timestamp:
- Jan 21, 2007 8:20:07 AM (17 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r19007 r19008 1 2007-01-21 Darin Adler <darin@apple.com> 2 3 Reviewed by Adam and Mitz. 4 5 - fix http://bugs.webkit.org/show_bug.cgi?id=12347 6 REGRESSION: list box scrolling broken (fast/forms/listbox-selection.html) 7 8 Covered by existing test: fast/forms/listbox-selection.html 9 10 * rendering/RenderListBox.h: Added override of layout(), made selectionChanged() 11 no longer an inline. Added private scrollToRevealSelection(), 12 m_scrollToRevealSelectionAfterLayout, and m_inAutoscroll. 13 * rendering/RenderListBox.cpp: 14 (WebCore::RenderListBox::RenderListBox): Initialize new data members. 15 (WebCore::RenderListBox::updateFromElement): Remove scrolling code. 16 (WebCore::RenderListBox::selectionChanged): Moved from header. Calls repaint 17 and then scrollToRevealSelection, but if we need layout, instead schedules 18 scrollToRevealSelection to be done after layout. 19 (WebCore::RenderListBox::layout): Added. After calling base class, calls 20 scrollToRevealSelection if the m_scrollToRevealSelectionAfterLayout is set. 21 (WebCore::RenderListBox::scrollToRevealSelection): Added. Code was originally 22 in updateFromElement. 23 (WebCore::RenderListBox::autoscroll): Set m_inAutoscroll so that the 24 selectionChanged function knows not to scroll. Also removed the repaint() 25 here because updateListBoxSelection() takes care of repainting by calling 26 selectionChanged(). 27 1 28 2007-01-21 David Kilzer <ddkilzer@webkit.org> 2 3 Reviewed by NOBODY (no-svg build fix).4 29 5 30 * page/EventHandler.cpp: -
trunk/WebCore/rendering/RenderListBox.cpp
r18989 r19008 70 70 : RenderBlock(element) 71 71 , m_optionsChanged(true) 72 , m_scrollToRevealSelectionAfterLayout(false) 73 , m_inAutoscroll(false) 72 74 , m_optionsWidth(0) 73 75 , m_indexOffset(0) … … 90 92 void RenderListBox::updateFromElement() 91 93 { 92 HTMLSelectElement* select = static_cast<HTMLSelectElement*>(node());93 94 94 if (m_optionsChanged) { 95 const Vector<HTMLElement*>& listItems = s elect->listItems();95 const Vector<HTMLElement*>& listItems = static_cast<HTMLSelectElement*>(node())->listItems(); 96 96 int size = numItems(); 97 97 … … 121 121 setNeedsLayoutAndMinMaxRecalc(); 122 122 } 123 123 } 124 125 void RenderListBox::selectionChanged() 126 { 127 repaint(); 128 if (!m_inAutoscroll) { 129 if (needsLayout()) 130 m_scrollToRevealSelectionAfterLayout = true; 131 else 132 scrollToRevealSelection(); 133 } 134 } 135 136 void RenderListBox::layout() 137 { 138 RenderBlock::layout(); 139 if (m_scrollToRevealSelectionAfterLayout) 140 scrollToRevealSelection(); 141 } 142 143 void RenderListBox::scrollToRevealSelection() 144 { 145 HTMLSelectElement* select = static_cast<HTMLSelectElement*>(node()); 146 147 m_scrollToRevealSelectionAfterLayout = false; 148 124 149 int firstIndex = select->optionToListIndex(select->selectedIndex()); 125 int lastIndex = select->lastSelectedListIndex(); 126 if (firstIndex >= 0 && !listIndexIsVisible(firstIndex) && !listIndexIsVisible(lastIndex)) 150 if (firstIndex >= 0 && !listIndexIsVisible(select->lastSelectedListIndex())) 127 151 scrollToRevealElementAtListIndex(firstIndex); 128 152 } … … 378 402 endIndex = listIndexAtOffset(offsetX, offsetY); 379 403 380 HTMLSelectElement* select = static_cast<HTMLSelectElement*>(node()); 381 if (endIndex >= 0 && select) { 404 if (endIndex >= 0) { 405 HTMLSelectElement* select = static_cast<HTMLSelectElement*>(node()); 406 m_inAutoscroll = true; 382 407 if (!select->multiple()) 383 408 select->setActiveSelectionAnchorIndex(endIndex); 384 409 select->setActiveSelectionEndIndex(endIndex); 385 410 select->updateListBoxSelection(!select->multiple()); 386 repaint();411 m_inAutoscroll = false; 387 412 } 388 413 } … … 394 419 395 420 bool RenderListBox::scrollToRevealElementAtListIndex(int index) 396 { 421 { 397 422 if (index < 0 || index >= numItems() || listIndexIsVisible(index)) 398 423 return false; -
trunk/WebCore/rendering/RenderListBox.h
r18989 r19008 65 65 virtual void calcHeight(); 66 66 67 void selectionChanged() { repaint(); } 67 virtual void layout(); 68 69 void selectionChanged(); 68 70 69 71 void setOptionsChanged(bool changed) { m_optionsChanged = changed; } … … 101 103 void paintItemBackground(PaintInfo&, int tx, int ty, int listIndex); 102 104 bool listIndexIsVisible(int index); 105 void scrollToRevealSelection(); 103 106 104 107 bool m_optionsChanged; 108 bool m_scrollToRevealSelectionAfterLayout; 109 bool m_inAutoscroll; 105 110 int m_optionsWidth; 106 111 int m_indexOffset;
Note: See TracChangeset
for help on using the changeset viewer.