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/LayoutSVGText.cpp

Issue 1870983002: Only hit-test SVG <text> foreground (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase; return early. Created 4 years, 8 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) 2006 Apple Computer, Inc. 2 * Copyright (C) 2006 Apple Computer, Inc.
3 * Copyright (C) 2006 Alexander Kellett <lypanov@kde.org> 3 * Copyright (C) 2006 Alexander Kellett <lypanov@kde.org>
4 * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz> 4 * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz>
5 * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> 5 * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org>
6 * Copyright (C) 2008 Rob Buis <buis@kde.org> 6 * Copyright (C) 2008 Rob Buis <buis@kde.org>
7 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> 7 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org>
8 * Copyright (C) Research In Motion Limited 2010-2012. All rights reserved. 8 * Copyright (C) Research In Motion Limited 2010-2012. All rights reserved.
9 * Copyright (C) 2012 Google Inc. 9 * Copyright (C) 2012 Google Inc.
10 * 10 *
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 286
287 RootInlineBox* LayoutSVGText::createRootInlineBox() 287 RootInlineBox* LayoutSVGText::createRootInlineBox()
288 { 288 {
289 RootInlineBox* box = new SVGRootInlineBox(LineLayoutItem(this)); 289 RootInlineBox* box = new SVGRootInlineBox(LineLayoutItem(this));
290 box->setHasVirtualLogicalHeight(); 290 box->setHasVirtualLogicalHeight();
291 return box; 291 return box;
292 } 292 }
293 293
294 bool LayoutSVGText::nodeAtFloatPoint(HitTestResult& result, const FloatPoint& po intInParent, HitTestAction hitTestAction) 294 bool LayoutSVGText::nodeAtFloatPoint(HitTestResult& result, const FloatPoint& po intInParent, HitTestAction hitTestAction)
295 { 295 {
296 // We only draw in the foreground phase, so we only hit-test then.
297 if (hitTestAction != HitTestForeground)
298 return false;
299
296 PointerEventsHitRules hitRules(PointerEventsHitRules::SVG_TEXT_HITTESTING, r esult.hitTestRequest(), style()->pointerEvents()); 300 PointerEventsHitRules hitRules(PointerEventsHitRules::SVG_TEXT_HITTESTING, r esult.hitTestRequest(), style()->pointerEvents());
297 bool isVisible = (style()->visibility() == VISIBLE); 301 bool isVisible = (style()->visibility() == VISIBLE);
298 if (isVisible || !hitRules.requireVisible) { 302 if (isVisible || !hitRules.requireVisible) {
299 if ((hitRules.canHitBoundingBox && !objectBoundingBox().isEmpty()) 303 if ((hitRules.canHitBoundingBox && !objectBoundingBox().isEmpty())
300 || (hitRules.canHitStroke && (style()->svgStyle().hasStroke() || !hi tRules.requireStroke)) 304 || (hitRules.canHitStroke && (style()->svgStyle().hasStroke() || !hi tRules.requireStroke))
301 || (hitRules.canHitFill && (style()->svgStyle().hasFill() || !hitRul es.requireFill))) { 305 || (hitRules.canHitFill && (style()->svgStyle().hasFill() || !hitRul es.requireFill))) {
302 FloatPoint localPoint; 306 FloatPoint localPoint;
303 if (!SVGLayoutSupport::transformToUserSpaceAndCheckClipping(this, lo calToSVGParentTransform(), pointInParent, localPoint)) 307 if (!SVGLayoutSupport::transformToUserSpaceAndCheckClipping(this, lo calToSVGParentTransform(), pointInParent, localPoint))
304 return false; 308 return false;
305 309
306 if (hitRules.canHitBoundingBox && !objectBoundingBox().contains(loca lPoint)) 310 HitTestLocation hitTestLocation(localPoint);
307 return false; 311 if (LayoutBlock::nodeAtPoint(result, hitTestLocation, LayoutPoint(), hitTestAction))
312 return true;
308 313
309 HitTestLocation hitTestLocation(localPoint); 314 // Consider the bounding box if requested.
310 return LayoutBlock::nodeAtPoint(result, hitTestLocation, LayoutPoint (), hitTestAction); 315 if (hitRules.canHitBoundingBox && objectBoundingBox().contains(local Point)) {
316 const LayoutPoint& localLayoutPoint = roundedLayoutPoint(localPo int);
317 updateHitTestResult(result, localLayoutPoint);
318 if (result.addNodeToListBasedTestResult(node(), localLayoutPoint ) == StopHitTesting)
319 return true;
320 }
311 } 321 }
312 } 322 }
313 323
314 return false; 324 return false;
315 } 325 }
316 326
317 PositionWithAffinity LayoutSVGText::positionForPoint(const LayoutPoint& pointInC ontents) 327 PositionWithAffinity LayoutSVGText::positionForPoint(const LayoutPoint& pointInC ontents)
318 { 328 {
319 RootInlineBox* rootBox = firstRootBox(); 329 RootInlineBox* rootBox = firstRootBox();
320 if (!rootBox) 330 if (!rootBox)
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 paintInvalidationState.pushDelayedPaintInvalidationTarget(*this); 415 paintInvalidationState.pushDelayedPaintInvalidationTarget(*this);
406 416
407 if (reason == PaintInvalidationSVGResourceChange) 417 if (reason == PaintInvalidationSVGResourceChange)
408 newPaintInvalidationState.setForceSubtreeInvalidationWithinContainer(); 418 newPaintInvalidationState.setForceSubtreeInvalidationWithinContainer();
409 419
410 newPaintInvalidationState.updateForChildren(); 420 newPaintInvalidationState.updateForChildren();
411 invalidatePaintOfSubtreesIfNeeded(newPaintInvalidationState); 421 invalidatePaintOfSubtreesIfNeeded(newPaintInvalidationState);
412 } 422 }
413 423
414 } // namespace blink 424 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698