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

Side by Side Diff: third_party/WebKit/Source/core/layout/svg/line/SVGInlineTextBox.cpp

Issue 2124793002: Use the correct bounding rect in SVGInlineTextBox::nodeAtPoint (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
OLDNEW
1 /** 1 /**
2 * Copyright (C) 2007 Rob Buis <buis@kde.org> 2 * Copyright (C) 2007 Rob Buis <buis@kde.org>
3 * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> 3 * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org>
4 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 4 * Copyright (C) Research In Motion Limited 2010. 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 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 { 237 {
238 // FIXME: integrate with InlineTextBox::nodeAtPoint better. 238 // FIXME: integrate with InlineTextBox::nodeAtPoint better.
239 ASSERT(!isLineBreak()); 239 ASSERT(!isLineBreak());
240 240
241 PointerEventsHitRules hitRules(PointerEventsHitRules::SVG_TEXT_HITTESTING, r esult.hitTestRequest(), getLineLayoutItem().style()->pointerEvents()); 241 PointerEventsHitRules hitRules(PointerEventsHitRules::SVG_TEXT_HITTESTING, r esult.hitTestRequest(), getLineLayoutItem().style()->pointerEvents());
242 bool isVisible = getLineLayoutItem().style()->visibility() == VISIBLE; 242 bool isVisible = getLineLayoutItem().style()->visibility() == VISIBLE;
243 if (isVisible || !hitRules.requireVisible) { 243 if (isVisible || !hitRules.requireVisible) {
244 if (hitRules.canHitBoundingBox 244 if (hitRules.canHitBoundingBox
245 || (hitRules.canHitStroke && (getLineLayoutItem().style()->svgStyle( ).hasStroke() || !hitRules.requireStroke)) 245 || (hitRules.canHitStroke && (getLineLayoutItem().style()->svgStyle( ).hasStroke() || !hitRules.requireStroke))
246 || (hitRules.canHitFill && (getLineLayoutItem().style()->svgStyle(). hasFill() || !hitRules.requireFill))) { 246 || (hitRules.canHitFill && (getLineLayoutItem().style()->svgStyle(). hasFill() || !hitRules.requireFill))) {
247 LayoutPoint boxOrigin(x(), y()); 247 LayoutRect rect(topLeft(), logicalSize());
Stephen Chennney 2016/07/06 14:47:37 You can do "LayoutRect rect(topLeft(), LayoutSize(
fs 2016/07/06 15:00:51 Yes. Done, and dropped method.
248 boxOrigin.moveBy(accumulatedOffset); 248 rect.moveBy(accumulatedOffset);
249 LayoutRect rect(boxOrigin, size());
250 if (locationInContainer.intersects(rect)) { 249 if (locationInContainer.intersects(rect)) {
251 LineLayoutSVGInlineText lineLayoutItem = LineLayoutSVGInlineText (this->getLineLayoutItem()); 250 LineLayoutSVGInlineText lineLayoutItem = LineLayoutSVGInlineText (this->getLineLayoutItem());
252 ASSERT(lineLayoutItem.scalingFactor()); 251 ASSERT(lineLayoutItem.scalingFactor());
253 float baseline = lineLayoutItem.scaledFont().getFontMetrics().fl oatAscent() / lineLayoutItem.scalingFactor(); 252 float baseline = lineLayoutItem.scaledFont().getFontMetrics().fl oatAscent() / lineLayoutItem.scalingFactor();
254 253
255 FloatPoint floatLocation = FloatPoint(locationInContainer.point( )); 254 FloatPoint floatLocation = FloatPoint(locationInContainer.point( ));
256 for (const SVGTextFragment& fragment : m_textFragments) { 255 for (const SVGTextFragment& fragment : m_textFragments) {
257 FloatQuad fragmentQuad = fragment.boundingQuad(baseline); 256 FloatQuad fragmentQuad = fragment.boundingQuad(baseline);
258 if (fragmentQuad.containsPoint(floatLocation)) { 257 if (fragmentQuad.containsPoint(floatLocation)) {
259 lineLayoutItem.updateHitTestResult(result, locationInCon tainer.point() - toLayoutSize(accumulatedOffset)); 258 lineLayoutItem.updateHitTestResult(result, locationInCon tainer.point() - toLayoutSize(accumulatedOffset));
260 if (result.addNodeToListBasedTestResult(lineLayoutItem.n ode(), locationInContainer, rect) == StopHitTesting) 259 if (result.addNodeToListBasedTestResult(lineLayoutItem.n ode(), locationInContainer, rect) == StopHitTesting)
261 return true; 260 return true;
262 } 261 }
263 } 262 }
264 } 263 }
265 } 264 }
266 } 265 }
267 return false; 266 return false;
268 } 267 }
269 268
270 } // namespace blink 269 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698