11ae29591efbb29492ce05378909ccf4028d7c1eeBehdad Esfahbod/*
230e691edd056ba22fa8970280e986747817bec3dBehdad Esfahbod * Copyright (C) 2013 Samsung Electronics. All rights reserved.
38413c108d21e8cf0e9059bbfffde8d13f2616340Behdad Esfahbod *
4c33b0a22ef0046c392275e3dba974dfbadee24faMatt Fontaine * Redistribution and use in source and binary forms, with or without
52b06aaa2a6bcd363c25fb0c43f6bb906906594bdBehdad Esfahbod * modification, are permitted provided that the following conditions are
630e691edd056ba22fa8970280e986747817bec3dBehdad Esfahbod * met:
730e691edd056ba22fa8970280e986747817bec3dBehdad Esfahbod *
830e691edd056ba22fa8970280e986747817bec3dBehdad Esfahbod *     * Redistributions of source code must retain the above copyright
930e691edd056ba22fa8970280e986747817bec3dBehdad Esfahbod * notice, this list of conditions and the following disclaimer.
10c33b0a22ef0046c392275e3dba974dfbadee24faMatt Fontaine *     * Redistributions in binary form must reproduce the above
11c33b0a22ef0046c392275e3dba974dfbadee24faMatt Fontaine * copyright notice, this list of conditions and the following disclaimer
12c33b0a22ef0046c392275e3dba974dfbadee24faMatt Fontaine * in the documentation and/or other materials provided with the
13c33b0a22ef0046c392275e3dba974dfbadee24faMatt Fontaine * distribution.
14c33b0a22ef0046c392275e3dba974dfbadee24faMatt Fontaine *     * Neither the name of Google Inc. nor the names of its
15c33b0a22ef0046c392275e3dba974dfbadee24faMatt Fontaine * contributors may be used to endorse or promote products derived from
16c33b0a22ef0046c392275e3dba974dfbadee24faMatt Fontaine * this software without specific prior written permission.
17c33b0a22ef0046c392275e3dba974dfbadee24faMatt Fontaine *
18c33b0a22ef0046c392275e3dba974dfbadee24faMatt Fontaine * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19c33b0a22ef0046c392275e3dba974dfbadee24faMatt Fontaine * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20c33b0a22ef0046c392275e3dba974dfbadee24faMatt Fontaine * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21c33b0a22ef0046c392275e3dba974dfbadee24faMatt Fontaine * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22c33b0a22ef0046c392275e3dba974dfbadee24faMatt Fontaine * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23c33b0a22ef0046c392275e3dba974dfbadee24faMatt Fontaine * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24c33b0a22ef0046c392275e3dba974dfbadee24faMatt Fontaine * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25c33b0a22ef0046c392275e3dba974dfbadee24faMatt Fontaine * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26c33b0a22ef0046c392275e3dba974dfbadee24faMatt Fontaine * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27c33b0a22ef0046c392275e3dba974dfbadee24faMatt Fontaine * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28c33b0a22ef0046c392275e3dba974dfbadee24faMatt Fontaine * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29c33b0a22ef0046c392275e3dba974dfbadee24faMatt Fontaine */
30c33b0a22ef0046c392275e3dba974dfbadee24faMatt Fontaine
31c33b0a22ef0046c392275e3dba974dfbadee24faMatt Fontaine#include "config.h"
32c33b0a22ef0046c392275e3dba974dfbadee24faMatt Fontaine#include "core/svg/SVGGeometryElement.h"
33c33b0a22ef0046c392275e3dba974dfbadee24faMatt Fontaine
34c33b0a22ef0046c392275e3dba974dfbadee24faMatt Fontaine#include "core/SVGNames.h"
35c33b0a22ef0046c392275e3dba974dfbadee24faMatt Fontaine#include "core/rendering/HitTestRequest.h"
36c33b0a22ef0046c392275e3dba974dfbadee24faMatt Fontaine#include "core/rendering/PointerEventsHitRules.h"
37c33b0a22ef0046c392275e3dba974dfbadee24faMatt Fontaine#include "core/rendering/svg/RenderSVGShape.h"
38c33b0a22ef0046c392275e3dba974dfbadee24faMatt Fontaine#include "core/svg/SVGPointTearOff.h"
39c33b0a22ef0046c392275e3dba974dfbadee24faMatt Fontaine
40c33b0a22ef0046c392275e3dba974dfbadee24faMatt Fontainenamespace blink {
41c33b0a22ef0046c392275e3dba974dfbadee24faMatt Fontaine
42c33b0a22ef0046c392275e3dba974dfbadee24faMatt FontaineSVGGeometryElement::SVGGeometryElement(const QualifiedName& tagName, Document& document, ConstructionType constructionType)
43c33b0a22ef0046c392275e3dba974dfbadee24faMatt Fontaine    : SVGGraphicsElement(tagName, document, constructionType)
44c33b0a22ef0046c392275e3dba974dfbadee24faMatt Fontaine{
45c33b0a22ef0046c392275e3dba974dfbadee24faMatt Fontaine}
46c33b0a22ef0046c392275e3dba974dfbadee24faMatt Fontaine
47c33b0a22ef0046c392275e3dba974dfbadee24faMatt Fontainebool SVGGeometryElement::isPointInFill(PassRefPtr<SVGPointTearOff> point) const
48c33b0a22ef0046c392275e3dba974dfbadee24faMatt Fontaine{
49c33b0a22ef0046c392275e3dba974dfbadee24faMatt Fontaine    document().updateLayoutIgnorePendingStylesheets();
50c33b0a22ef0046c392275e3dba974dfbadee24faMatt Fontaine
51c33b0a22ef0046c392275e3dba974dfbadee24faMatt Fontaine    // FIXME: Eventually we should support isPointInFill for display:none elements.
52c33b0a22ef0046c392275e3dba974dfbadee24faMatt Fontaine    if (!renderer() || !renderer()->isSVGShape())
53c33b0a22ef0046c392275e3dba974dfbadee24faMatt Fontaine        return false;
544b775ee5f16b7feef22dd796f2faefb366f535f3Behdad Esfahbod
55c33b0a22ef0046c392275e3dba974dfbadee24faMatt Fontaine    HitTestRequest request(HitTestRequest::ReadOnly);
56c33b0a22ef0046c392275e3dba974dfbadee24faMatt Fontaine    PointerEventsHitRules hitRules(PointerEventsHitRules::SVG_GEOMETRY_HITTESTING, request, renderer()->style()->pointerEvents());
57c33b0a22ef0046c392275e3dba974dfbadee24faMatt Fontaine    hitRules.canHitStroke = false;
58c33b0a22ef0046c392275e3dba974dfbadee24faMatt Fontaine    return toRenderSVGShape(renderer())->nodeAtFloatPointInternal(request, point->target()->value(), hitRules);
59c33b0a22ef0046c392275e3dba974dfbadee24faMatt Fontaine}
60c33b0a22ef0046c392275e3dba974dfbadee24faMatt Fontaine
61c33b0a22ef0046c392275e3dba974dfbadee24faMatt Fontainebool SVGGeometryElement::isPointInStroke(PassRefPtr<SVGPointTearOff> point) const
62c33b0a22ef0046c392275e3dba974dfbadee24faMatt Fontaine{
63c33b0a22ef0046c392275e3dba974dfbadee24faMatt Fontaine    document().updateLayoutIgnorePendingStylesheets();
64c33b0a22ef0046c392275e3dba974dfbadee24faMatt Fontaine
65c33b0a22ef0046c392275e3dba974dfbadee24faMatt Fontaine    // FIXME: Eventually we should support isPointInStroke for display:none elements.
66c33b0a22ef0046c392275e3dba974dfbadee24faMatt Fontaine    if (!renderer() || !renderer()->isSVGShape())
67c33b0a22ef0046c392275e3dba974dfbadee24faMatt Fontaine        return false;
68c33b0a22ef0046c392275e3dba974dfbadee24faMatt Fontaine
69c33b0a22ef0046c392275e3dba974dfbadee24faMatt Fontaine    HitTestRequest request(HitTestRequest::ReadOnly);
70c33b0a22ef0046c392275e3dba974dfbadee24faMatt Fontaine    PointerEventsHitRules hitRules(PointerEventsHitRules::SVG_GEOMETRY_HITTESTING, request, renderer()->style()->pointerEvents());
71c33b0a22ef0046c392275e3dba974dfbadee24faMatt Fontaine    hitRules.canHitFill = false;
72c33b0a22ef0046c392275e3dba974dfbadee24faMatt Fontaine    return toRenderSVGShape(renderer())->nodeAtFloatPointInternal(request, point->target()->value(), hitRules);
73c33b0a22ef0046c392275e3dba974dfbadee24faMatt Fontaine}
74c33b0a22ef0046c392275e3dba974dfbadee24faMatt Fontaine
75c33b0a22ef0046c392275e3dba974dfbadee24faMatt Fontaine}
76c33b0a22ef0046c392275e3dba974dfbadee24faMatt Fontaine