Commit c2ce3fd9 authored by eae@chromium.org's avatar eae@chromium.org
Browse files

Change RenderThemeChromiumSkia paint methods to use pixel snapping

https://bugs.webkit.org/show_bug.cgi?id=84175

Reviewed by Eric Seidel.

No new tests, no change in functionality.

Change RenderThemeChromiumSkia to use subpixel types and pixel snap
values just before painting.

* rendering/RenderThemeChromiumSkia.cpp:
(WebCore::RenderThemeChromiumSkia::convertToPaintingRect):
(WebCore::RenderThemeChromiumSkia::paintSearchFieldCancelButton):
(WebCore::RenderThemeChromiumSkia::paintSearchFieldResultsDecoration):
(WebCore::RenderThemeChromiumSkia::paintSearchFieldResultsButton):
* rendering/RenderThemeChromiumSkia.h:

 2012-04-17  Levi Weintraub  <leviw@chromium.org>

Clean up outstanding LayoutUnit misuse in WebCore
https://bugs.webkit.org/show_bug.cgi?id=84209

Reviewed by Eric Seidel.

Small changes to a handful of files to prepare trunk for FractionalLayoutUnits.
For more details, see https://trac.webkit.org/wiki/LayoutUnit

No new tests. No change in behavior.

* css/CSSComputedStyleDeclaration.cpp:
(WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue): minimumValueForLength preserves
sub-pixel precision, so we should avoid unnecessarily using integers.
* platform/graphics/FractionalLayoutPoint.h:
(WebCore::FractionalLayoutPoint::FractionalLayoutPoint): Adding an explicit constructor from
FractionalLayoutSizes. This mirrors a method in IntPoint.
* rendering/RenderBoxModelObject.cpp:
(WebCore::RenderBoxModelObject::paintBorder): The rects that change come from roundedRects,
which are already pixel-snapped.
* rendering/RenderBoxModelObject.h: Removing a comment that is no longer applicable.
* rendering/RenderTable.cpp:
(WebCore::RenderTable::computeLogicalWidth): Since we layout tables using integers, we
need to explicitly calculate the width to be integral as well to avoid pushing the next element
over by a pixel that we won't later paint with our own box decorations.
* rendering/RenderText.h:
(RenderText): Correcting an unfortunate mismatch between in the return value of linesBoundingBox
between the header and implementation.
* rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::getRoundedBorderFor): We were incorrectly not using the snapped border
rect to pass to calcRadiiFor (which takes an IntRect). Correcting this.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@114471 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 0e79135f
2012-04-17 Emil A Eklund <eae@chromium.org>
Change RenderThemeChromiumSkia paint methods to use pixel snapping
https://bugs.webkit.org/show_bug.cgi?id=84175
Reviewed by Eric Seidel.
No new tests, no change in functionality.
Change RenderThemeChromiumSkia to use subpixel types and pixel snap
values just before painting.
* rendering/RenderThemeChromiumSkia.cpp:
(WebCore::RenderThemeChromiumSkia::convertToPaintingRect):
(WebCore::RenderThemeChromiumSkia::paintSearchFieldCancelButton):
(WebCore::RenderThemeChromiumSkia::paintSearchFieldResultsDecoration):
(WebCore::RenderThemeChromiumSkia::paintSearchFieldResultsButton):
* rendering/RenderThemeChromiumSkia.h:
2012-04-17 Levi Weintraub <leviw@chromium.org>
 
Clean up outstanding LayoutUnit misuse in WebCore
......@@ -261,16 +261,16 @@ void RenderThemeChromiumSkia::adjustSearchFieldCancelButtonStyle(CSSStyleSelecto
style->setHeight(Length(cancelButtonSize, Fixed));
}
IntRect RenderThemeChromiumSkia::convertToPaintingRect(RenderObject* inputRenderer, const RenderObject* partRenderer, IntRect partRect, const IntRect& localOffset) const
IntRect RenderThemeChromiumSkia::convertToPaintingRect(RenderObject* inputRenderer, const RenderObject* partRenderer, LayoutRect partRect, const IntRect& localOffset) const
{
// Compute an offset between the part renderer and the input renderer.
IntSize offsetFromInputRenderer = -(partRenderer->offsetFromAncestorContainer(inputRenderer));
LayoutSize offsetFromInputRenderer = -partRenderer->offsetFromAncestorContainer(inputRenderer);
// Move the rect into partRenderer's coords.
partRect.move(offsetFromInputRenderer);
// Account for the local drawing offset.
partRect.move(localOffset.x(), localOffset.y());
return partRect;
return pixelSnappedIntRect(partRect);
}
bool RenderThemeChromiumSkia::paintSearchFieldCancelButton(RenderObject* cancelButtonObject, const PaintInfo& paintInfo, const IntRect& r)
......@@ -280,16 +280,16 @@ bool RenderThemeChromiumSkia::paintSearchFieldCancelButton(RenderObject* cancelB
if (!input->renderer()->isBox())
return false;
RenderBox* inputRenderBox = toRenderBox(input->renderer());
IntRect inputContentBox = inputRenderBox->contentBoxRect();
LayoutRect inputContentBox = inputRenderBox->contentBoxRect();
// Make sure the scaled button stays square and will fit in its parent's box.
int cancelButtonSize = std::min(inputContentBox.width(), std::min<int>(inputContentBox.height(), r.height()));
LayoutUnit cancelButtonSize = std::min(inputContentBox.width(), std::min(inputContentBox.height(), r.height()));
// Calculate cancel button's coordinates relative to the input element.
// Center the button vertically. Round up though, so if it has to be one pixel off-center, it will
// be one pixel closer to the bottom of the field. This tends to look better with the text.
IntRect cancelButtonRect(cancelButtonObject->offsetFromAncestorContainer(inputRenderBox).width(),
inputContentBox.y() + (inputContentBox.height() - cancelButtonSize + 1) / 2,
cancelButtonSize, cancelButtonSize);
LayoutRect cancelButtonRect(cancelButtonObject->offsetFromAncestorContainer(inputRenderBox).width(),
inputContentBox.y() + (inputContentBox.height() - cancelButtonSize + 1) / 2,
cancelButtonSize, cancelButtonSize);
IntRect paintingRect = convertToPaintingRect(inputRenderBox, cancelButtonObject, cancelButtonRect, r);
static Image* cancelImage = Image::loadPlatformResource("searchCancel").leakRef();
......@@ -323,16 +323,16 @@ bool RenderThemeChromiumSkia::paintSearchFieldResultsDecoration(RenderObject* ma
if (!input->renderer()->isBox())
return false;
RenderBox* inputRenderBox = toRenderBox(input->renderer());
IntRect inputContentBox = inputRenderBox->contentBoxRect();
LayoutRect inputContentBox = inputRenderBox->contentBoxRect();
// Make sure the scaled decoration stays square and will fit in its parent's box.
int magnifierSize = std::min(inputContentBox.width(), std::min<int>(inputContentBox.height(), r.height()));
LayoutUnit magnifierSize = std::min(inputContentBox.width(), std::min(inputContentBox.height(), r.height()));
// Calculate decoration's coordinates relative to the input element.
// Center the decoration vertically. Round up though, so if it has to be one pixel off-center, it will
// be one pixel closer to the bottom of the field. This tends to look better with the text.
IntRect magnifierRect(magnifierObject->offsetFromAncestorContainer(inputRenderBox).width(),
inputContentBox.y() + (inputContentBox.height() - magnifierSize + 1) / 2,
magnifierSize, magnifierSize);
LayoutRect magnifierRect(magnifierObject->offsetFromAncestorContainer(inputRenderBox).width(),
inputContentBox.y() + (inputContentBox.height() - magnifierSize + 1) / 2,
magnifierSize, magnifierSize);
IntRect paintingRect = convertToPaintingRect(inputRenderBox, magnifierObject, magnifierRect, r);
static Image* magnifierImage = Image::loadPlatformResource("searchMagnifier").leakRef();
......@@ -358,14 +358,14 @@ bool RenderThemeChromiumSkia::paintSearchFieldResultsButton(RenderObject* magnif
if (!input->renderer()->isBox())
return false;
RenderBox* inputRenderBox = toRenderBox(input->renderer());
IntRect inputContentBox = inputRenderBox->contentBoxRect();
LayoutRect inputContentBox = inputRenderBox->contentBoxRect();
// Make sure the scaled decoration will fit in its parent's box.
int magnifierHeight = std::min<int>(inputContentBox.height(), r.height());
int magnifierWidth = std::min<int>(inputContentBox.width(), magnifierHeight * defaultSearchFieldResultsButtonWidth / defaultSearchFieldResultsDecorationSize);
IntRect magnifierRect(magnifierObject->offsetFromAncestorContainer(inputRenderBox).width(),
inputContentBox.y() + (inputContentBox.height() - magnifierHeight + 1) / 2,
magnifierWidth, magnifierHeight);
LayoutUnit magnifierHeight = std::min(inputContentBox.height(), r.height());
LayoutUnit magnifierWidth = std::min<LayoutUnit>(inputContentBox.width(), magnifierHeight * defaultSearchFieldResultsButtonWidth / defaultSearchFieldResultsDecorationSize);
LayoutRect magnifierRect(magnifierObject->offsetFromAncestorContainer(inputRenderBox).width(),
inputContentBox.y() + (inputContentBox.height() - magnifierHeight + 1) / 2,
magnifierWidth, magnifierHeight);
IntRect paintingRect = convertToPaintingRect(inputRenderBox, magnifierObject, magnifierRect, r);
static Image* magnifierImage = Image::loadPlatformResource("searchMagnifierResults").leakRef();
......
......@@ -157,7 +157,7 @@ private:
int menuListInternalPadding(RenderStyle*, int paddingType) const;
bool paintMediaButtonInternal(GraphicsContext*, const IntRect&, Image*);
IntRect convertToPaintingRect(RenderObject* inputRenderer, const RenderObject* partRenderer, IntRect partRect, const IntRect& localOffset) const;
IntRect convertToPaintingRect(RenderObject* inputRenderer, const RenderObject* partRenderer, LayoutRect partRect, const IntRect& localOffset) const;
};
} // namespace WebCore
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment