OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> |
3 * Copyright (C) 2004, 2005, 2007, 2008, 2009 Rob Buis <buis@kde.org> | 3 * Copyright (C) 2004, 2005, 2007, 2008, 2009 Rob Buis <buis@kde.org> |
4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org> | 4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org> |
5 * Copyright (C) 2009 Google, Inc. | 5 * Copyright (C) 2009 Google, Inc. |
6 * Copyright (C) Research In Motion Limited 2011. All rights reserved. | 6 * Copyright (C) Research In Motion Limited 2011. All rights reserved. |
7 * | 7 * |
8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 } | 418 } |
419 | 419 |
420 bool RenderSVGRoot::nodeAtPoint(const HitTestRequest& request, HitTestResult& re
sult, const HitTestLocation& locationInContainer, const LayoutPoint& accumulated
Offset, HitTestAction hitTestAction) | 420 bool RenderSVGRoot::nodeAtPoint(const HitTestRequest& request, HitTestResult& re
sult, const HitTestLocation& locationInContainer, const LayoutPoint& accumulated
Offset, HitTestAction hitTestAction) |
421 { | 421 { |
422 LayoutPoint pointInParent = locationInContainer.point() - toLayoutSize(accum
ulatedOffset); | 422 LayoutPoint pointInParent = locationInContainer.point() - toLayoutSize(accum
ulatedOffset); |
423 LayoutPoint pointInBorderBox = pointInParent - toLayoutSize(location()); | 423 LayoutPoint pointInBorderBox = pointInParent - toLayoutSize(location()); |
424 | 424 |
425 // Only test SVG content if the point is in our content box. | 425 // Only test SVG content if the point is in our content box. |
426 // FIXME: This should be an intersection when rect-based hit tests are suppo
rted by nodeAtFloatPoint. | 426 // FIXME: This should be an intersection when rect-based hit tests are suppo
rted by nodeAtFloatPoint. |
427 if (contentBoxRect().contains(pointInBorderBox)) { | 427 if (contentBoxRect().contains(pointInBorderBox)) { |
428 FloatPoint localPoint = localToParentTransform().inverse().mapPoint(Floa
tPoint(pointInParent)); | 428 const AffineTransform& localToParentTransform = this->localToParentTrans
form(); |
| 429 if (localToParentTransform.isInvertible()) { |
| 430 FloatPoint localPoint = localToParentTransform.inverse().mapPoint(Fl
oatPoint(pointInParent)); |
429 | 431 |
430 for (RenderObject* child = lastChild(); child; child = child->previousSi
bling()) { | 432 for (RenderObject* child = lastChild(); child; child = child->previo
usSibling()) { |
431 // FIXME: nodeAtFloatPoint() doesn't handle rect-based hit tests yet
. | 433 // FIXME: nodeAtFloatPoint() doesn't handle rect-based hit tests
yet. |
432 if (child->nodeAtFloatPoint(request, result, localPoint, hitTestActi
on)) { | 434 if (child->nodeAtFloatPoint(request, result, localPoint, hitTest
Action)) { |
433 updateHitTestResult(result, pointInBorderBox); | 435 updateHitTestResult(result, pointInBorderBox); |
434 if (!result.addNodeToRectBasedTestResult(child->node(), request,
locationInContainer)) | 436 if (!result.addNodeToRectBasedTestResult(child->node(), requ
est, locationInContainer)) |
435 return true; | 437 return true; |
| 438 } |
436 } | 439 } |
437 } | 440 } |
438 } | 441 } |
439 | 442 |
440 // If we didn't early exit above, we've just hit the container <svg> element
. Unlike SVG 1.1, 2nd Edition allows container elements to be hit. | 443 // If we didn't early exit above, we've just hit the container <svg> element
. Unlike SVG 1.1, 2nd Edition allows container elements to be hit. |
441 if ((hitTestAction == HitTestBlockBackground || hitTestAction == HitTestChil
dBlockBackground) && visibleToHitTestRequest(request)) { | 444 if ((hitTestAction == HitTestBlockBackground || hitTestAction == HitTestChil
dBlockBackground) && visibleToHitTestRequest(request)) { |
442 // Only return true here, if the last hit testing phase 'BlockBackground
' (or 'ChildBlockBackground' - depending on context) is executed. | 445 // Only return true here, if the last hit testing phase 'BlockBackground
' (or 'ChildBlockBackground' - depending on context) is executed. |
443 // If we'd return true in the 'Foreground' phase, hit testing would stop
immediately. For SVG only trees this doesn't matter. | 446 // If we'd return true in the 'Foreground' phase, hit testing would stop
immediately. For SVG only trees this doesn't matter. |
444 // Though when we have a <foreignObject> subtree we need to be able to d
etect hits on the background of a <div> element. | 447 // Though when we have a <foreignObject> subtree we need to be able to d
etect hits on the background of a <div> element. |
445 // If we'd return true here in the 'Foreground' phase, we are not able t
o detect these hits anymore. | 448 // If we'd return true here in the 'Foreground' phase, we are not able t
o detect these hits anymore. |
446 LayoutRect boundsRect(accumulatedOffset + location(), size()); | 449 LayoutRect boundsRect(accumulatedOffset + location(), size()); |
447 if (locationInContainer.intersects(boundsRect)) { | 450 if (locationInContainer.intersects(boundsRect)) { |
448 updateHitTestResult(result, pointInBorderBox); | 451 updateHitTestResult(result, pointInBorderBox); |
449 if (!result.addNodeToRectBasedTestResult(node(), request, locationIn
Container, boundsRect)) | 452 if (!result.addNodeToRectBasedTestResult(node(), request, locationIn
Container, boundsRect)) |
450 return true; | 453 return true; |
451 } | 454 } |
452 } | 455 } |
453 | 456 |
454 return false; | 457 return false; |
455 } | 458 } |
456 | 459 |
457 } | 460 } |
OLD | NEW |