Modified: trunk/Source/WebCore/ChangeLog (200189 => 200190)
--- trunk/Source/WebCore/ChangeLog 2016-04-28 14:02:02 UTC (rev 200189)
+++ trunk/Source/WebCore/ChangeLog 2016-04-28 14:35:24 UTC (rev 200190)
@@ -1,3 +1,21 @@
+2016-04-28 Antonio Gomes <[email protected]>
+
+ Factor out the "paint item" logic in RenderListBox into a helper
+ https://bugs.webkit.org/show_bug.cgi?id=157117
+
+ Reviewed by Daniel Bates.
+
+ Patch factors out the duplicated painting logic in RenderListBox::paintObject()
+ into a member function named paintItem.
+
+ This is in preparation for bug 156590.
+ No new tests, since there is no behavior change.
+
+ * rendering/RenderListBox.cpp:
+ (WebCore::RenderListBox::paintItem):
+ (WebCore::RenderListBox::paintObject):
+ * rendering/RenderListBox.h:
+
2016-04-28 Joanmarie Diggs <[email protected]>
AX: [ATK] We need to be smarter about flattening and the accessible text implementation
Modified: trunk/Source/WebCore/rendering/RenderListBox.cpp (200189 => 200190)
--- trunk/Source/WebCore/rendering/RenderListBox.cpp 2016-04-28 14:02:02 UTC (rev 200189)
+++ trunk/Source/WebCore/rendering/RenderListBox.cpp 2016-04-28 14:35:24 UTC (rev 200190)
@@ -271,20 +271,24 @@
LayoutUnit y = additionalOffset.y() + borderTop() + paddingTop() + itemHeight() * (index - m_indexOffset);
return LayoutRect(x, y, contentWidth(), itemHeight());
}
-
+
+void RenderListBox::paintItem(PaintInfo& paintInfo, const LayoutPoint& paintOffset, PaintFunction paintFunction)
+{
+ int listItemsSize = numItems();
+ int endIndex = m_indexOffset + numVisibleItems();
+ for (int i = m_indexOffset; i < listItemsSize && i <= endIndex; ++i)
+ paintFunction(paintInfo, paintOffset, i);
+}
+
void RenderListBox::paintObject(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
{
if (style().visibility() != VISIBLE)
return;
- int listItemsSize = numItems();
-
if (paintInfo.phase == PaintPhaseForeground) {
- int index = m_indexOffset;
- while (index < listItemsSize && index <= m_indexOffset + numVisibleItems()) {
- paintItemForeground(paintInfo, paintOffset, index);
- index++;
- }
+ paintItem(paintInfo, paintOffset, [this](PaintInfo& paintInfo, const LayoutPoint& paintOffset, int listItemIndex) {
+ paintItemForeground(paintInfo, paintOffset, listItemIndex);
+ });
}
// Paint the children.
@@ -303,11 +307,9 @@
break;
case PaintPhaseChildBlockBackground:
case PaintPhaseChildBlockBackgrounds: {
- int index = m_indexOffset;
- while (index < listItemsSize && index <= m_indexOffset + numVisibleItems()) {
- paintItemBackground(paintInfo, paintOffset, index);
- index++;
- }
+ paintItem(paintInfo, paintOffset, [this](PaintInfo& paintInfo, const LayoutPoint& paintOffset, int listItemIndex) {
+ paintItemBackground(paintInfo, paintOffset, listItemIndex);
+ });
break;
}
default:
Modified: trunk/Source/WebCore/rendering/RenderListBox.h (200189 => 200190)
--- trunk/Source/WebCore/rendering/RenderListBox.h 2016-04-28 14:02:02 UTC (rev 200189)
+++ trunk/Source/WebCore/rendering/RenderListBox.h 2016-04-28 14:35:24 UTC (rev 200190)
@@ -142,6 +142,9 @@
// NOTE: This should only be called by the overriden setScrollOffset from ScrollableArea.
void scrollTo(int newOffset);
+ using PaintFunction = std::function<void(PaintInfo&, const LayoutPoint&, int listItemIndex)>;
+ void paintItem(PaintInfo& , const LayoutPoint& , PaintFunction);
+
void setHasVerticalScrollbar(bool hasScrollbar);
PassRefPtr<Scrollbar> createScrollbar();
void destroyScrollbar();