Skip to content
Permalink
Browse files
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):


Canonical link: https://commits.webkit.org/98326@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@110761 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
leviw committed Mar 14, 2012
1 parent 7e1e13b commit cc14f1649245cd32e862ff03334a772450bbebf0
Showing 2 changed files with 26 additions and 5 deletions.
@@ -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
@@ -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));
}
}

0 comments on commit cc14f16

Please sign in to comment.