Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1114)

Unified Diff: Source/core/rendering/RenderObject.cpp

Issue 492053002: Use LayoutRect during addFocusRingRects to avoid loss of precision (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: NeedsRebaseline (pixel tests about focus rings. 1-pixel width diff at the edge because of different rounding) Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/rendering/RenderObject.h ('k') | Source/core/rendering/RenderTextControl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/rendering/RenderObject.cpp
diff --git a/Source/core/rendering/RenderObject.cpp b/Source/core/rendering/RenderObject.cpp
index 7c7a927b2e69365484122abad4d332f73df97f1c..912b01e14740fc400321457f418e0ff4215f9f6f 100644
--- a/Source/core/rendering/RenderObject.cpp
+++ b/Source/core/rendering/RenderObject.cpp
@@ -1218,10 +1218,13 @@ void RenderObject::drawSolidBoxSide(GraphicsContext* graphicsContext, int x1, in
void RenderObject::paintFocusRing(PaintInfo& paintInfo, const LayoutPoint& paintOffset, RenderStyle* style)
{
- Vector<IntRect> focusRingRects;
+ Vector<LayoutRect> focusRingRects;
addFocusRingRects(focusRingRects, paintOffset, paintInfo.paintContainer());
ASSERT(style->outlineStyleIsAuto());
- paintInfo.context->drawFocusRing(focusRingRects, style->outlineWidth(), style->outlineOffset(), resolveColor(style, CSSPropertyOutlineColor));
+ Vector<IntRect> focusRingIntRects;
+ for (size_t i = 0; i < focusRingRects.size(); ++i)
+ focusRingIntRects.append(pixelSnappedIntRect(focusRingRects[i]));
+ paintInfo.context->drawFocusRing(focusRingIntRects, style->outlineWidth(), style->outlineOffset(), resolveColor(style, CSSPropertyOutlineColor));
}
void RenderObject::paintOutline(PaintInfo& paintInfo, const LayoutRect& paintRect)
@@ -1292,7 +1295,7 @@ void RenderObject::paintOutline(PaintInfo& paintInfo, const LayoutRect& paintRec
graphicsContext->endLayer();
}
-void RenderObject::addChildFocusRingRects(Vector<IntRect>& rects, const LayoutPoint& additionalOffset, const RenderLayerModelObject* paintContainer) const
+void RenderObject::addChildFocusRingRects(Vector<LayoutRect>& rects, const LayoutPoint& additionalOffset, const RenderLayerModelObject* paintContainer) const
{
for (RenderObject* current = slowFirstChild(); current; current = current->nextSibling()) {
if (current->isText() || current->isListMarker())
@@ -1301,21 +1304,16 @@ void RenderObject::addChildFocusRingRects(Vector<IntRect>& rects, const LayoutPo
if (current->isBox()) {
RenderBox* box = toRenderBox(current);
if (box->hasLayer()) {
- Vector<IntRect> layerFocusRingRects;
+ Vector<LayoutRect> layerFocusRingRects;
box->addFocusRingRects(layerFocusRingRects, LayoutPoint(), box);
for (size_t i = 0; i < layerFocusRingRects.size(); ++i) {
- FloatQuad quadInBox = box->localToContainerQuad(FloatRect(layerFocusRingRects[i]), paintContainer);
- FloatRect rect = quadInBox.boundingBox();
- // Floor the location instead of using pixelSnappedIntRect to match the !hasLayer() path.
- // FIXME: roundedIntSize matches pixelSnappedIntRect in other places of addFocusRingRects
- // because we always floor the offset.
- // This assumption is fragile and should be replaced by better solution.
- rects.append(IntRect(flooredIntPoint(rect.location()), roundedIntSize(rect.size())));
+ FloatQuad quadInBox = box->localToContainerQuad(FloatQuad(layerFocusRingRects[i]), paintContainer);
+ LayoutRect rect = LayoutRect(quadInBox.boundingBox());
+ if (!rect.isEmpty())
+ rects.append(rect);
}
} else {
- FloatPoint pos(additionalOffset);
- pos.move(box->locationOffset());
- box->addFocusRingRects(rects, flooredIntPoint(pos), paintContainer);
+ box->addFocusRingRects(rects, additionalOffset + box->locationOffset(), paintContainer);
}
} else {
current->addFocusRingRects(rects, additionalOffset, paintContainer);
@@ -1366,7 +1364,7 @@ IntRect RenderObject::absoluteBoundingBoxRectIgnoringTransforms() const
void RenderObject::absoluteFocusRingQuads(Vector<FloatQuad>& quads)
{
- Vector<IntRect> rects;
+ Vector<LayoutRect> rects;
const RenderLayerModelObject* container = containerForPaintInvalidation();
addFocusRingRects(rects, LayoutPoint(localToContainerPoint(FloatPoint(), container)), container);
size_t count = rects.size();
« no previous file with comments | « Source/core/rendering/RenderObject.h ('k') | Source/core/rendering/RenderTextControl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698