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

Side by Side Diff: Source/core/rendering/RenderInline.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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/rendering/RenderInline.h ('k') | Source/core/rendering/RenderObject.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. 4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 1357 matching lines...) Expand 10 before | Expand all | Expand 10 after
1368 { 1368 {
1369 if (!parent()) 1369 if (!parent())
1370 return; 1370 return;
1371 1371
1372 // FIXME: We can do better. 1372 // FIXME: We can do better.
1373 setShouldDoFullPaintInvalidation(true); 1373 setShouldDoFullPaintInvalidation(true);
1374 } 1374 }
1375 1375
1376 namespace { 1376 namespace {
1377 1377
1378 class AbsoluteRectsIgnoringEmptyRectsGeneratorContext : public AbsoluteRectsGene ratorContext { 1378 class AbsoluteLayoutRectsGeneratorContext {
1379 public: 1379 public:
1380 AbsoluteRectsIgnoringEmptyRectsGeneratorContext(Vector<IntRect>& rects, cons t LayoutPoint& accumulatedOffset) 1380 AbsoluteLayoutRectsGeneratorContext(Vector<LayoutRect>& rects, const LayoutP oint& accumulatedOffset)
1381 : AbsoluteRectsGeneratorContext(rects, accumulatedOffset) { } 1381 : m_rects(rects)
1382 , m_accumulatedOffset(accumulatedOffset) { }
1383
1384 void operator()(const FloatRect& rect)
1385 {
1386 LayoutRect layoutRect(rect);
1387 layoutRect.move(m_accumulatedOffset.x(), m_accumulatedOffset.y());
1388 m_rects.append(layoutRect);
1389 }
1390 private:
1391 Vector<LayoutRect>& m_rects;
1392 const LayoutPoint& m_accumulatedOffset;
1393 };
1394
1395 class AbsoluteLayoutRectsIgnoringEmptyRectsGeneratorContext : public AbsoluteLay outRectsGeneratorContext {
1396 public:
1397 AbsoluteLayoutRectsIgnoringEmptyRectsGeneratorContext(Vector<LayoutRect>& re cts, const LayoutPoint& accumulatedOffset)
1398 : AbsoluteLayoutRectsGeneratorContext(rects, accumulatedOffset) { }
1382 1399
1383 void operator()(const FloatRect& rect) 1400 void operator()(const FloatRect& rect)
1384 { 1401 {
1385 if (!rect.isEmpty()) 1402 if (!rect.isEmpty())
1386 AbsoluteRectsGeneratorContext::operator()(rect); 1403 AbsoluteLayoutRectsGeneratorContext::operator()(rect);
1387 } 1404 }
1388 }; 1405 };
1389 1406
1390 } // unnamed namespace 1407 } // unnamed namespace
1391 1408
1392 void RenderInline::addFocusRingRects(Vector<IntRect>& rects, const LayoutPoint& additionalOffset, const RenderLayerModelObject* paintContainer) const 1409 void RenderInline::addFocusRingRects(Vector<LayoutRect>& rects, const LayoutPoin t& additionalOffset, const RenderLayerModelObject* paintContainer) const
1393 { 1410 {
1394 AbsoluteRectsIgnoringEmptyRectsGeneratorContext context(rects, additionalOff set); 1411 AbsoluteLayoutRectsIgnoringEmptyRectsGeneratorContext context(rects, additio nalOffset);
1395 generateLineBoxRects(context); 1412 generateLineBoxRects(context);
1396 1413
1397 addChildFocusRingRects(rects, additionalOffset, paintContainer); 1414 addChildFocusRingRects(rects, additionalOffset, paintContainer);
1398 1415
1399 if (continuation()) { 1416 if (continuation()) {
1400 // If the continuation doesn't paint into the same container, let its pa int invalidation container handle it. 1417 // If the continuation doesn't paint into the same container, let its pa int invalidation container handle it.
1401 if (paintContainer != continuation()->containerForPaintInvalidation()) 1418 if (paintContainer != continuation()->containerForPaintInvalidation())
1402 return; 1419 return;
1403 if (continuation()->isInline()) 1420 if (continuation()->isInline())
1404 continuation()->addFocusRingRects(rects, flooredLayoutPoint(addition alOffset + continuation()->containingBlock()->location() - containingBlock()->lo cation()), paintContainer); 1421 continuation()->addFocusRingRects(rects, additionalOffset + (continu ation()->containingBlock()->location() - containingBlock()->location()), paintCo ntainer);
1405 else 1422 else
1406 continuation()->addFocusRingRects(rects, flooredLayoutPoint(addition alOffset + toRenderBox(continuation())->location() - containingBlock()->location ()), paintContainer); 1423 continuation()->addFocusRingRects(rects, additionalOffset + (toRende rBox(continuation())->location() - containingBlock()->location()), paintContaine r);
1407 } 1424 }
1408 } 1425 }
1409 1426
1410 namespace {
1411
1412 class AbsoluteLayoutRectsGeneratorContext {
1413 public:
1414 AbsoluteLayoutRectsGeneratorContext(Vector<LayoutRect>& rects, const LayoutP oint& accumulatedOffset)
1415 : m_rects(rects)
1416 , m_accumulatedOffset(accumulatedOffset) { }
1417
1418 void operator()(const FloatRect& rect)
1419 {
1420 LayoutRect layoutRect(rect);
1421 layoutRect.move(m_accumulatedOffset.x(), m_accumulatedOffset.y());
1422 m_rects.append(layoutRect);
1423 }
1424 private:
1425 Vector<LayoutRect>& m_rects;
1426 const LayoutPoint& m_accumulatedOffset;
1427 };
1428
1429 }
1430
1431 void RenderInline::computeSelfHitTestRects(Vector<LayoutRect>& rects, const Layo utPoint& layerOffset) const 1427 void RenderInline::computeSelfHitTestRects(Vector<LayoutRect>& rects, const Layo utPoint& layerOffset) const
1432 { 1428 {
1433 AbsoluteLayoutRectsGeneratorContext context(rects, layerOffset); 1429 AbsoluteLayoutRectsGeneratorContext context(rects, layerOffset);
1434 generateLineBoxRects(context); 1430 generateLineBoxRects(context);
1435 } 1431 }
1436 1432
1437 void RenderInline::paintOutline(PaintInfo& paintInfo, const LayoutPoint& paintOf fset) 1433 void RenderInline::paintOutline(PaintInfo& paintInfo, const LayoutPoint& paintOf fset)
1438 { 1434 {
1439 RenderStyle* styleToUse = style(); 1435 RenderStyle* styleToUse = style();
1440 if (!styleToUse->hasOutline()) 1436 if (!styleToUse->hasOutline())
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
1607 container = this; 1603 container = this;
1608 1604
1609 FloatPoint absPos = container->localToAbsolute(); 1605 FloatPoint absPos = container->localToAbsolute();
1610 region.bounds.setX(absPos.x() + region.bounds.x()); 1606 region.bounds.setX(absPos.x() + region.bounds.x());
1611 region.bounds.setY(absPos.y() + region.bounds.y()); 1607 region.bounds.setY(absPos.y() + region.bounds.y());
1612 1608
1613 regions.append(region); 1609 regions.append(region);
1614 } 1610 }
1615 1611
1616 } // namespace blink 1612 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderInline.h ('k') | Source/core/rendering/RenderObject.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698