Changeset 200265 in webkit
- Timestamp:
- Apr 29, 2016 2:48:43 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r200264 r200265 1 2016-04-29 Antonio Gomes <tonikitoo@webkit.org> 2 3 <select multiple> padding should react when scrolling 4 https://bugs.webkit.org/show_bug.cgi?id=156590 5 https://bugs.webkit.org/show_bug.cgi?id=156591 6 7 Reviewed by Reviewed by Darin Adler. 8 9 * fast/forms/listbox-respects-padding-bottom-expected.txt: Added. 10 * fast/forms/listbox-respects-padding-bottom.html: Added. 11 * fast/forms/listbox-top-padding-do-not-clip-items-expected.txt: Added. 12 * fast/forms/listbox-top-padding-do-not-clip-items.html: Added. 13 1 14 2016-04-29 Eric Carlson <eric.carlson@apple.com> 2 15 -
trunk/LayoutTests/platform/ios-simulator/TestExpectations
r200264 r200265 3002 3002 fast/forms/listbox-padding-clip-overlay.html [ ImageOnlyFailure ] 3003 3003 fast/forms/listbox-padding-clip-selected.html [ ImageOnlyFailure ] 3004 fast/forms/listbox-respects-padding-bottom.html [ ImageOnlyFailure ] 3005 fast/forms/listbox-top-padding-do-not-clip-items.html [ ImageOnlyFailure ] 3004 3006 3005 3007 # MSE not enabled. -
trunk/Source/WebCore/ChangeLog
r200264 r200265 1 2016-04-29 Antonio Gomes <tonikitoo@webkit.org> 2 3 <select multiple> padding should react when scrolling 4 5 https://bugs.webkit.org/show_bug.cgi?id=156590 6 https://bugs.webkit.org/show_bug.cgi?id=156591 7 8 Reviewed by Reviewed by Darin Adler. 9 10 Tests: fast/forms/listbox-respects-padding-bottom.html 11 fast/forms/listbox-top-padding-do-not-clip-items.html 12 13 Non-dropdown listboxes have support to padding-{top,bottom} implemented similarly 14 to the border model: the padding area does not move when the listbox' content gets scrolled, 15 but instead it clips out its content. 16 This is not consistent with other browsers and is not consistent with the CSS box model. 17 18 This in practice, if a <select> has padding-top set, the padding-top area will clip out listbox' 19 content as one scrolls upwards. 20 It also means that if padding-bottom is set, when one scrolls all the way to the bottom 21 of the listbox content, padding-bottom is not respected. 22 23 In order to fix these two problems, and make WebKit match Blink with respect to the the way 24 padding-{top,bottom} are handled, patch adds two class member variables that control the number 25 of list items (i.e. <option>s) that can be painted over the current listbox' padding area. 26 27 In short, depending on the scroll position and the amount of space available in the padding top/bottom 28 areas, items are painted or not on top of it, mimic'ing the CSS box model behavior of other browsers. 29 30 Note that this is specific solution is worth it to pursue on the short/mid term, but a long-term solution 31 to this problem and many other listbox discrepancies on WebKit's implementation, would be to reimplement 32 RenderListBox class in terms of RenderLayer. This will be a follow up work. 33 34 * rendering/RenderListBox.cpp: 35 (WebCore::RenderListBox::updateFromElement): 36 (WebCore::RenderListBox::numVisibleItems): 37 (WebCore::RenderListBox::paintObject): 38 (WebCore::RenderListBox::scrollToRevealElementAtListIndex): 39 (WebCore::RenderListBox::listIndexIsVisible): 40 (WebCore::RenderListBox::maximumNumberOfItemsThatFitInPaddingBottomArea): 41 (WebCore::RenderListBox::numberOfVisibleItemsInPaddingTop): 42 (WebCore::RenderListBox::numberOfVisibleItemsInPaddingBottom): 43 (WebCore::RenderListBox::computeFirstIndexesVisibleInPaddingTopBottomAreas): 44 (WebCore::RenderListBox::scrollTo): 45 * rendering/RenderListBox.h: 46 1 47 2016-04-29 Eric Carlson <eric.carlson@apple.com> 2 48 -
trunk/Source/WebCore/rendering/RenderListBox.cpp
r200190 r200265 140 140 setHasVerticalScrollbar(true); 141 141 142 computeFirstIndexesVisibleInPaddingTopBottomAreas(); 143 142 144 setNeedsLayoutAndPrefWidthsRecalc(); 143 145 } … … 237 239 } 238 240 239 int RenderListBox::numVisibleItems( ) const241 int RenderListBox::numVisibleItems(ConsiderPadding considerPadding) const 240 242 { 241 243 // Only count fully visible rows. But don't return 0 even if only part of a row shows. 242 return std::max<int>(1, (contentHeight() + paddingBottom() + rowSpacing) / itemHeight()); 244 int visibleItemsExcludingPadding = std::max<int>(1, (contentHeight() + rowSpacing) / itemHeight()); 245 if (considerPadding == ConsiderPadding::No) 246 return visibleItemsExcludingPadding; 247 248 return numberOfVisibleItemsInPaddingTop() + visibleItemsExcludingPadding + numberOfVisibleItemsInPaddingBottom(); 243 249 } 244 250 … … 276 282 { 277 283 int listItemsSize = numItems(); 278 int endIndex = m_indexOffset + numVisibleItems(); 279 for (int i = m_indexOffset; i < listItemsSize && i <= endIndex; ++i) 284 int firstVisibleItem = m_indexOfFirstVisibleItemInsidePaddingTopArea.valueOr(m_indexOffset); 285 int endIndex = firstVisibleItem + numVisibleItems(ConsiderPadding::Yes); 286 for (int i = firstVisibleItem; i < listItemsSize && i < endIndex; ++i) 280 287 paintFunction(paintInfo, paintOffset, i); 281 288 } … … 590 597 591 598 bool RenderListBox::listIndexIsVisible(int index) 592 { 593 return index >= m_indexOffset && index < m_indexOffset + numVisibleItems(); 599 { 600 int firstIndex = m_indexOfFirstVisibleItemInsidePaddingTopArea.valueOr(m_indexOffset); 601 int endIndex = m_indexOfFirstVisibleItemInsidePaddingBottomArea 602 ? m_indexOfFirstVisibleItemInsidePaddingBottomArea.value() + numberOfVisibleItemsInPaddingBottom() 603 : m_indexOffset + numVisibleItems(); 604 605 return index >= firstIndex && index < endIndex; 594 606 } 595 607 … … 635 647 } 636 648 649 int RenderListBox::maximumNumberOfItemsThatFitInPaddingBottomArea() const 650 { 651 return paddingBottom() / itemHeight(); 652 } 653 654 int RenderListBox::numberOfVisibleItemsInPaddingTop() const 655 { 656 if (!m_indexOfFirstVisibleItemInsidePaddingTopArea) 657 return 0; 658 659 return m_indexOffset - m_indexOfFirstVisibleItemInsidePaddingTopArea.value(); 660 } 661 662 int RenderListBox::numberOfVisibleItemsInPaddingBottom() const 663 { 664 if (!m_indexOfFirstVisibleItemInsidePaddingBottomArea) 665 return 0; 666 667 return std::min(maximumNumberOfItemsThatFitInPaddingBottomArea(), numItems() - m_indexOffset - numVisibleItems()); 668 } 669 670 void RenderListBox::computeFirstIndexesVisibleInPaddingTopBottomAreas() 671 { 672 m_indexOfFirstVisibleItemInsidePaddingTopArea = Nullopt; 673 m_indexOfFirstVisibleItemInsidePaddingBottomArea = Nullopt; 674 675 int maximumNumberOfItemsThatFitInPaddingTopArea = paddingTop() / itemHeight(); 676 if (maximumNumberOfItemsThatFitInPaddingTopArea) { 677 if (m_indexOffset) 678 m_indexOfFirstVisibleItemInsidePaddingTopArea = std::max(0, m_indexOffset - maximumNumberOfItemsThatFitInPaddingTopArea); 679 } 680 681 if (maximumNumberOfItemsThatFitInPaddingBottomArea()) { 682 if (numItems() > (m_indexOffset + numVisibleItems())) 683 m_indexOfFirstVisibleItemInsidePaddingBottomArea = m_indexOffset + numVisibleItems(); 684 } 685 } 686 637 687 void RenderListBox::scrollTo(int newOffset) 638 688 { … … 641 691 642 692 m_indexOffset = newOffset; 693 694 computeFirstIndexesVisibleInPaddingTopBottomAreas(); 695 643 696 repaint(); 644 697 document().eventQueue().enqueueOrDispatchScrollEvent(selectElement()); -
trunk/Source/WebCore/rendering/RenderListBox.h
r200230 r200265 34 34 #include "RenderBlockFlow.h" 35 35 #include "ScrollableArea.h" 36 37 #include <wtf/Optional.h> 36 38 37 39 namespace WebCore { … … 150 152 void destroyScrollbar(); 151 153 154 int maximumNumberOfItemsThatFitInPaddingBottomArea() const; 155 156 int numberOfVisibleItemsInPaddingTop() const; 157 int numberOfVisibleItemsInPaddingBottom() const; 158 159 void computeFirstIndexesVisibleInPaddingTopBottomAreas(); 160 152 161 LayoutUnit itemHeight() const; 153 162 void valueChanged(unsigned listIndex); 154 int numVisibleItems() const; 163 164 enum class ConsiderPadding { Yes, No }; 165 int numVisibleItems(ConsiderPadding = ConsiderPadding::No) const; 155 166 int numItems() const; 156 167 LayoutUnit listHeight() const; … … 168 179 int m_indexOffset; 169 180 181 Optional<int> m_indexOfFirstVisibleItemInsidePaddingTopArea; 182 Optional<int> m_indexOfFirstVisibleItemInsidePaddingBottomArea; 183 170 184 RefPtr<Scrollbar> m_vBar; 171 185 };
Note: See TracChangeset
for help on using the changeset viewer.