Implement proper sub-pixel support in RenderFileUploadControl
authorleviw@chromium.org <leviw@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 Mar 2012 22:02:00 +0000 (22:02 +0000)
committerleviw@chromium.org <leviw@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 Mar 2012 22:02:00 +0000 (22:02 +0000)
https://bugs.webkit.org/show_bug.cgi?id=80881

Reviewed by Dimitri Glazkov.

Correcting improper usage of LayoutUnits when interacting with the graphics context
and platform code. Specifically:
- pixel snapping the clip rect and paint offsets before sending values to the
  graphics context in paintObject.
- using on-screen (pixel snapped) values to pass off to platform code to determine
  the max length of the filename to be drawn.

No new tests. No change in behavior.

* rendering/RenderFileUploadControl.cpp:
(WebCore::nodeWidth):
(WebCore::RenderFileUploadControl::maxFilenameWidth):
(WebCore::RenderFileUploadControl::paintObject):

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

Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderFileUploadControl.cpp

index 0af39a4..919f79a 100644 (file)
@@ -1,3 +1,24 @@
+2012-03-14  Levi Weintraub  <leviw@chromium.org>
+
+        Implement proper sub-pixel support in RenderFileUploadControl
+        https://bugs.webkit.org/show_bug.cgi?id=80881
+
+        Reviewed by Dimitri Glazkov.
+
+        Correcting improper usage of LayoutUnits when interacting with the graphics context
+        and platform code. Specifically:
+        - pixel snapping the clip rect and paint offsets before sending values to the
+          graphics context in paintObject.
+        - using on-screen (pixel snapped) values to pass off to platform code to determine
+          the max length of the filename to be drawn.
+
+        No new tests. No change in behavior.
+
+        * rendering/RenderFileUploadControl.cpp:
+        (WebCore::nodeWidth):
+        (WebCore::RenderFileUploadControl::maxFilenameWidth):
+        (WebCore::RenderFileUploadControl::paintObject):
+
 2012-03-14  Joseph Pecoraro  <pecoraro@apple.com>
 
         [JSC] Web Inspector: CRASH running $0, $1, etc before they are set
index 07dd77f..b8cb628 100644 (file)
@@ -91,13 +91,13 @@ void RenderFileUploadControl::updateFromElement()
 
 static int nodeWidth(Node* node)
 {
-    return node ? node->renderBox()->width() : zeroLayoutUnit;
+    return node ? node->renderBox()->pixelSnappedWidth() : 0;
 }
 
 int RenderFileUploadControl::maxFilenameWidth() const
 {
     HTMLInputElement* input = static_cast<HTMLInputElement*>(node());
-    return max(0, contentWidth() - nodeWidth(uploadButton()) - afterButtonSpacing
+    return max(0, contentBoxRect().pixelSnappedWidth() - nodeWidth(uploadButton()) - afterButtonSpacing
         - (input->icon() ? iconWidth + iconFilenameSpacing : 0));
 }
 
@@ -109,7 +109,7 @@ void RenderFileUploadControl::paintObject(PaintInfo& paintInfo, const LayoutPoin
     // Push a clip.
     GraphicsContextStateSaver stateSaver(*paintInfo.context, false);
     if (paintInfo.phase == PaintPhaseForeground || paintInfo.phase == PaintPhaseChildBlockBackgrounds) {
-        LayoutRect clipRect(paintOffset.x() + borderLeft(), paintOffset.y() + borderTop(),
+        IntRect clipRect = pixelSnappedIntRect(paintOffset.x() + borderLeft(), paintOffset.y() + borderTop(),
                          width() - borderLeft() - borderRight(), height() - borderBottom() - borderTop() + buttonShadowHeight);
         if (clipRect.isEmpty())
             return;
@@ -147,7 +147,7 @@ void RenderFileUploadControl::paintObject(PaintInfo& paintInfo, const LayoutPoin
         paintInfo.context->setFillColor(style()->visitedDependentColor(CSSPropertyColor), style()->colorSpace());
         
         // Draw the filename
-        paintInfo.context->drawBidiText(font, textRun, LayoutPoint(textX, textY));
+        paintInfo.context->drawBidiText(font, textRun, IntPoint(roundToInt(textX), roundToInt(textY)));
         
         if (input->icon()) {
             // Determine where the icon should be placed
@@ -159,7 +159,7 @@ void RenderFileUploadControl::paintObject(PaintInfo& paintInfo, const LayoutPoin
                 iconX = contentLeft + contentWidth() - buttonWidth - afterButtonSpacing - iconWidth;
 
             // Draw the file icon
-            input->icon()->paint(paintInfo.context, LayoutRect(iconX, iconY, iconWidth, iconHeight));
+            input->icon()->paint(paintInfo.context, IntRect(roundToInt(iconX), roundToInt(iconY), iconWidth, iconHeight));
         }
     }