Switch PopupMenuClient to layout abstraction
authoreae@chromium.org <eae@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 2 Nov 2011 00:15:10 +0000 (00:15 +0000)
committereae@chromium.org <eae@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 2 Nov 2011 00:15:10 +0000 (00:15 +0000)
https://bugs.webkit.org/show_bug.cgi?id=71308

Reviewed by Darin Adler.

Switch PopupMenuClient and rendering classes implementing it to layout
type abstraction.

No new tests.

* platform/PopupMenuClient.h:
* rendering/RenderListBox.cpp:
(WebCore::RenderListBox::listIndexAtOffset):
(WebCore::RenderListBox::panScroll):
(WebCore::RenderListBox::scrollToward):
(WebCore::RenderListBox::scrollSize):
(WebCore::RenderListBox::scrollPosition):
(WebCore::RenderListBox::setScrollOffset):
(WebCore::RenderListBox::verticalScrollbarWidth):
Revert scroll positions and scroll offsets to ints to align with device
pixels.

* rendering/RenderListBox.h:
* rendering/RenderMenuList.cpp:
(WebCore::RenderMenuList::showPopup):
(WebCore::RenderMenuList::clientPaddingLeft):
(WebCore::RenderMenuList::clientPaddingRight):
* rendering/RenderMenuList.h:
* rendering/RenderTextControl.cpp:
(WebCore::RenderTextControl::hitInnerTextElement):
* rendering/RenderTextControlSingleLine.cpp:
(WebCore::RenderTextControlSingleLine::clientPaddingLeft):
(WebCore::RenderTextControlSingleLine::clientPaddingRight):
* rendering/RenderTextControlSingleLine.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@99016 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/PopupMenuClient.h
Source/WebCore/rendering/RenderListBox.cpp
Source/WebCore/rendering/RenderListBox.h
Source/WebCore/rendering/RenderMenuList.cpp
Source/WebCore/rendering/RenderMenuList.h
Source/WebCore/rendering/RenderTextControl.cpp
Source/WebCore/rendering/RenderTextControlSingleLine.cpp
Source/WebCore/rendering/RenderTextControlSingleLine.h

index 5815556..0a33192 100644 (file)
@@ -1,3 +1,40 @@
+2011-11-01  Emil A Eklund  <eae@chromium.org>
+
+        Switch PopupMenuClient to layout abstraction
+        https://bugs.webkit.org/show_bug.cgi?id=71308
+
+        Reviewed by Darin Adler.
+
+        Switch PopupMenuClient and rendering classes implementing it to layout
+        type abstraction.
+
+        No new tests.
+
+        * platform/PopupMenuClient.h:
+        * rendering/RenderListBox.cpp:
+        (WebCore::RenderListBox::listIndexAtOffset):
+        (WebCore::RenderListBox::panScroll):
+        (WebCore::RenderListBox::scrollToward):
+        (WebCore::RenderListBox::scrollSize):
+        (WebCore::RenderListBox::scrollPosition):
+        (WebCore::RenderListBox::setScrollOffset):
+        (WebCore::RenderListBox::verticalScrollbarWidth):
+        Revert scroll positions and scroll offsets to ints to align with device
+        pixels.
+        
+        * rendering/RenderListBox.h:
+        * rendering/RenderMenuList.cpp:
+        (WebCore::RenderMenuList::showPopup):
+        (WebCore::RenderMenuList::clientPaddingLeft):
+        (WebCore::RenderMenuList::clientPaddingRight):
+        * rendering/RenderMenuList.h:
+        * rendering/RenderTextControl.cpp:
+        (WebCore::RenderTextControl::hitInnerTextElement):
+        * rendering/RenderTextControlSingleLine.cpp:
+        (WebCore::RenderTextControlSingleLine::clientPaddingLeft):
+        (WebCore::RenderTextControlSingleLine::clientPaddingRight):
+        * rendering/RenderTextControlSingleLine.h:
+
 2011-11-01  Nate Chapin  <japhet@chromium.org>
 
         [chromium] As of r98380, ThreadableLoaderClients are having their
index f33b9e2..60d5715 100644 (file)
@@ -22,6 +22,7 @@
 #ifndef PopupMenuClient_h
 #define PopupMenuClient_h
 
+#include "LayoutTypes.h"
 #include "PopupMenuStyle.h"
 #include "ScrollTypes.h"
 #include <wtf/Forward.h>
@@ -51,8 +52,8 @@ public:
     virtual PopupMenuStyle menuStyle() const = 0;
     virtual int clientInsetLeft() const = 0;
     virtual int clientInsetRight() const = 0;
-    virtual int clientPaddingLeft() const = 0;
-    virtual int clientPaddingRight() const = 0;
+    virtual LayoutUnit clientPaddingLeft() const = 0;
+    virtual LayoutUnit clientPaddingRight() const = 0;
     virtual int listSize() const = 0;
     virtual int selectedIndex() const = 0;
     virtual void popupDidHide() = 0;
index 20a00b7..9e1e376 100644 (file)
@@ -467,7 +467,7 @@ int RenderListBox::listIndexAtOffset(const LayoutSize& offset)
     if (offset.height() < borderTop() + paddingTop() || offset.height() > height() - paddingBottom() - borderBottom())
         return -1;
 
-    LayoutUnit scrollbarWidth = m_vBar ? m_vBar->width() : 0;
+    LayoutUnit scrollbarWidth = m_vBar ? m_vBar->width() : LayoutUnit(0);
     if (offset.width() < borderLeft() + paddingLeft() || offset.width() > width() - borderRight() - paddingRight() - scrollbarWidth)
         return -1;
 
@@ -492,10 +492,10 @@ void RenderListBox::panScroll(const IntPoint& panStartMousePosition)
     else
         previousMousePosition = currentMousePosition;
 
-    LayoutUnit yDelta = currentMousePosition.y() - panStartMousePosition.y();
+    int yDelta = currentMousePosition.y() - panStartMousePosition.y();
 
     // If the point is too far from the center we limit the speed
-    yDelta = max<LayoutUnit>(min<LayoutUnit>(yDelta, maxSpeed), -maxSpeed);
+    yDelta = max<int>(min<int>(yDelta, maxSpeed), -maxSpeed);
     
     if (abs(yDelta) < iconRadius) // at the center we let the space for the icon
         return;
@@ -509,9 +509,9 @@ void RenderListBox::panScroll(const IntPoint& panStartMousePosition)
     // Let's attenuate the speed
     yDelta /= speedReducer;
 
-    LayoutPoint scrollPoint(0, 0);
+    IntPoint scrollPoint(0, 0);
     scrollPoint.setY(absOffset.y() + yDelta);
-    LayoutUnit newOffset = scrollToward(scrollPoint);
+    int newOffset = scrollToward(scrollPoint);
     if (newOffset < 0) 
         return;
 
@@ -521,11 +521,11 @@ void RenderListBox::panScroll(const IntPoint& panStartMousePosition)
     m_inAutoscroll = false;
 }
 
-int RenderListBox::scrollToward(const LayoutPoint& destination)
+int RenderListBox::scrollToward(const IntPoint& destination)
 {
     // FIXME: This doesn't work correctly with transforms.
     FloatPoint absPos = localToAbsolute();
-    LayoutSize positionOffset = roundedLayoutSize(destination - absPos);
+    IntSize positionOffset = roundedIntSize(destination - absPos);
 
     int rows = numVisibleItems();
     int offset = m_indexOffset;
@@ -600,17 +600,17 @@ void RenderListBox::valueChanged(unsigned listIndex)
     element->dispatchFormControlChangeEvent();
 }
 
-LayoutUnit RenderListBox::scrollSize(ScrollbarOrientation orientation) const
+int RenderListBox::scrollSize(ScrollbarOrientation orientation) const
 {
     return ((orientation == VerticalScrollbar) && m_vBar) ? (m_vBar->totalSize() - m_vBar->visibleSize()) : 0;
 }
 
-LayoutUnit RenderListBox::scrollPosition(Scrollbar*) const
+int RenderListBox::scrollPosition(Scrollbar*) const
 {
     return m_indexOffset;
 }
 
-void RenderListBox::setScrollOffset(const LayoutPoint& offset)
+void RenderListBox::setScrollOffset(const IntPoint& offset)
 {
     scrollTo(offset.y());
 }
@@ -632,7 +632,7 @@ LayoutUnit RenderListBox::itemHeight() const
 
 LayoutUnit RenderListBox::verticalScrollbarWidth() const
 {
-    return m_vBar && !m_vBar->isOverlayScrollbar() ? m_vBar->width() : 0;
+    return m_vBar && !m_vBar->isOverlayScrollbar() ? m_vBar->width() : LayoutUnit(0);
 }
 
 // FIXME: We ignore padding in the vertical direction as far as these values are concerned, since that's
index 7dfd753..522c255 100644 (file)
@@ -51,7 +51,7 @@ public:
     bool scrollToRevealElementAtListIndex(int index);
     bool listIndexIsVisible(int index);
 
-    int scrollToward(const LayoutPoint&); // Returns the new index or -1 if no scroll occurred
+    int scrollToward(const IntPoint&); // Returns the new index or -1 if no scroll occurred
 
     int size() const;
 
index f75feb8..b84d3cd 100644 (file)
@@ -305,7 +305,7 @@ void RenderMenuList::showPopup()
     // the actual width of the element to size the popup.
     FloatPoint absTopLeft = localToAbsolute(FloatPoint(), false, true);
     LayoutRect absBounds = absoluteBoundingBoxRectIgnoringTransforms();
-    absBounds.setLocation(roundedIntPoint(absTopLeft));
+    absBounds.setLocation(roundedLayoutPoint(absTopLeft));
     HTMLSelectElement* select = toHTMLSelectElement(node());
     m_popup->show(absBounds, document()->view(), select->optionToListIndex(select->selectedIndex()));
 }
@@ -502,13 +502,13 @@ int RenderMenuList::clientInsetRight() const
     return 0;
 }
 
-int RenderMenuList::clientPaddingLeft() const
+LayoutUnit RenderMenuList::clientPaddingLeft() const
 {
     return paddingLeft() + m_innerBlock->paddingLeft();
 }
 
 const int endOfLinePadding = 2;
-int RenderMenuList::clientPaddingRight() const
+LayoutUnit RenderMenuList::clientPaddingRight() const
 {
     if (style()->appearance() == MenulistPart || style()->appearance() == MenulistButtonPart) {
         // For these appearance values, the theme applies padding to leave room for the
index 73f981b..8ce18fa 100644 (file)
@@ -24,6 +24,7 @@
 #ifndef RenderMenuList_h
 #define RenderMenuList_h
 
+#include "LayoutTypes.h"
 #include "PopupMenu.h"
 #include "PopupMenuClient.h"
 #include "RenderDeprecatedFlexibleBox.h"
@@ -91,8 +92,8 @@ private:
     virtual PopupMenuStyle menuStyle() const;
     virtual int clientInsetLeft() const;
     virtual int clientInsetRight() const;
-    virtual int clientPaddingLeft() const;
-    virtual int clientPaddingRight() const;
+    virtual LayoutUnit clientPaddingLeft() const;
+    virtual LayoutUnit clientPaddingRight() const;
     virtual int listSize() const;
     virtual int selectedIndex() const;
     virtual void popupDidHide();
index 82490f2..8036eb6 100644 (file)
@@ -187,7 +187,7 @@ void RenderTextControl::hitInnerTextElement(HitTestResult& result, const LayoutP
     HTMLElement* innerText = innerTextElement();
     result.setInnerNode(innerText);
     result.setInnerNonSharedNode(innerText);
-    result.setLocalPoint(pointInContainer - toSize(adjustedLocation + innerText->renderBox()->location()));
+    result.setLocalPoint(pointInContainer - toLayoutSize(adjustedLocation + innerText->renderBox()->location()));
 }
 
 static const char* fontFamiliesWithInvalidCharWidth[] = {
index ff90770..9cf89d1 100644 (file)
@@ -628,9 +628,9 @@ int RenderTextControlSingleLine::clientInsetRight() const
     return height() / 2;
 }
 
-int RenderTextControlSingleLine::clientPaddingLeft() const
+LayoutUnit RenderTextControlSingleLine::clientPaddingLeft() const
 {
-    int padding = paddingLeft();
+    LayoutUnit padding = paddingLeft();
 
     HTMLElement* resultsButton = resultsButtonElement();
     if (RenderBox* resultsRenderer = resultsButton ? resultsButton->renderBox() : 0)
@@ -639,9 +639,9 @@ int RenderTextControlSingleLine::clientPaddingLeft() const
     return padding;
 }
 
-int RenderTextControlSingleLine::clientPaddingRight() const
+LayoutUnit RenderTextControlSingleLine::clientPaddingRight() const
 {
-    int padding = paddingRight();
+    LayoutUnit padding = paddingRight();
 
     HTMLElement* cancelButton = cancelButtonElement();
     if (RenderBox* cancelRenderer = cancelButton ? cancelButton->renderBox() : 0)
index 474d353..6cfcfe3 100644 (file)
@@ -102,8 +102,8 @@ private:
     virtual PopupMenuStyle menuStyle() const;
     virtual int clientInsetLeft() const;
     virtual int clientInsetRight() const;
-    virtual int clientPaddingLeft() const;
-    virtual int clientPaddingRight() const;
+    virtual LayoutUnit clientPaddingLeft() const;
+    virtual LayoutUnit clientPaddingRight() const;
     virtual int listSize() const;
     virtual int selectedIndex() const;
     virtual void popupDidHide();