| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2009, Google Inc. All rights reserved. | 2 * Copyright (c) 2009, Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 RenderObject::styleDidChange(diff, oldStyle); | 121 RenderObject::styleDidChange(diff, oldStyle); |
| 122 SVGResourcesCache::clientStyleChanged(this, diff, style()); | 122 SVGResourcesCache::clientStyleChanged(this, diff, style()); |
| 123 } | 123 } |
| 124 | 124 |
| 125 bool RenderSVGModelObject::nodeAtPoint(const HitTestRequest&, HitTestResult&, co
nst HitTestLocation&, const LayoutPoint&, HitTestAction) | 125 bool RenderSVGModelObject::nodeAtPoint(const HitTestRequest&, HitTestResult&, co
nst HitTestLocation&, const LayoutPoint&, HitTestAction) |
| 126 { | 126 { |
| 127 ASSERT_NOT_REACHED(); | 127 ASSERT_NOT_REACHED(); |
| 128 return false; | 128 return false; |
| 129 } | 129 } |
| 130 | 130 |
| 131 static void getElementCTM(SVGGraphicsElement* element, AffineTransform& transfor
m) | |
| 132 { | |
| 133 ASSERT(element); | |
| 134 element->document().updateLayoutIgnorePendingStylesheets(); | |
| 135 | |
| 136 SVGElement* stopAtElement = element->nearestViewportElement(); | |
| 137 ASSERT(stopAtElement); | |
| 138 | |
| 139 AffineTransform localTransform; | |
| 140 Node* current = element; | |
| 141 | |
| 142 while (current && current->isSVGElement()) { | |
| 143 SVGElement* currentElement = toSVGElement(current); | |
| 144 localTransform = currentElement->renderer()->localToParentTransform(); | |
| 145 transform = localTransform.multiply(transform); | |
| 146 // For getCTM() computation, stop at the nearest viewport element | |
| 147 if (currentElement == stopAtElement) | |
| 148 break; | |
| 149 | |
| 150 current = current->parentOrShadowHostNode(); | |
| 151 } | |
| 152 } | |
| 153 | |
| 154 // FloatRect::intersects does not consider horizontal or vertical lines (because
of isEmpty()). | |
| 155 // So special-case handling of such lines. | |
| 156 static bool intersectsAllowingEmpty(const FloatRect& r, const FloatRect& other) | |
| 157 { | |
| 158 if (r.isEmpty() && other.isEmpty()) | |
| 159 return false; | |
| 160 if (r.isEmpty() && !other.isEmpty()) { | |
| 161 return (other.contains(r.x(), r.y()) && !other.contains(r.maxX(), r.maxY
())) | |
| 162 || (!other.contains(r.x(), r.y()) && other.contains(r.maxX(), r.m
axY())); | |
| 163 } | |
| 164 if (other.isEmpty() && !r.isEmpty()) | |
| 165 return intersectsAllowingEmpty(other, r); | |
| 166 return r.intersects(other); | |
| 167 } | |
| 168 | |
| 169 // One of the element types that can cause graphics to be drawn onto the target
canvas. Specifically: circle, ellipse, | |
| 170 // image, line, path, polygon, polyline, rect, text and use. | |
| 171 static bool isGraphicsElement(RenderObject* renderer) | |
| 172 { | |
| 173 return renderer->isSVGShape() || renderer->isSVGText() || renderer->isSVGIma
ge() || renderer->node()->hasTagName(SVGNames::useTag); | |
| 174 } | |
| 175 | |
| 176 // The SVG addFocusRingRects() method adds rects in local coordinates so the def
ault absoluteFocusRingQuads | 131 // The SVG addFocusRingRects() method adds rects in local coordinates so the def
ault absoluteFocusRingQuads |
| 177 // returns incorrect values for SVG objects. Overriding this method provides acc
ess to the absolute bounds. | 132 // returns incorrect values for SVG objects. Overriding this method provides acc
ess to the absolute bounds. |
| 178 void RenderSVGModelObject::absoluteFocusRingQuads(Vector<FloatQuad>& quads) | 133 void RenderSVGModelObject::absoluteFocusRingQuads(Vector<FloatQuad>& quads) |
| 179 { | 134 { |
| 180 quads.append(localToAbsoluteQuad(FloatQuad(repaintRectInLocalCoordinates()))
); | 135 quads.append(localToAbsoluteQuad(FloatQuad(repaintRectInLocalCoordinates()))
); |
| 181 } | 136 } |
| 182 | 137 |
| 183 bool RenderSVGModelObject::checkIntersection(RenderObject* renderer, const Float
Rect& rect) | |
| 184 { | |
| 185 if (!renderer || renderer->style()->pointerEvents() == PE_NONE) | |
| 186 return false; | |
| 187 if (!isGraphicsElement(renderer)) | |
| 188 return false; | |
| 189 AffineTransform ctm; | |
| 190 SVGGraphicsElement* svgElement = toSVGGraphicsElement(renderer->node()); | |
| 191 getElementCTM(svgElement, ctm); | |
| 192 ASSERT(svgElement->renderer()); | |
| 193 return intersectsAllowingEmpty(rect, ctm.mapRect(svgElement->renderer()->rep
aintRectInLocalCoordinates())); | |
| 194 } | |
| 195 | |
| 196 bool RenderSVGModelObject::checkEnclosure(RenderObject* renderer, const FloatRec
t& rect) | |
| 197 { | |
| 198 if (!renderer || renderer->style()->pointerEvents() == PE_NONE) | |
| 199 return false; | |
| 200 if (!isGraphicsElement(renderer)) | |
| 201 return false; | |
| 202 AffineTransform ctm; | |
| 203 SVGGraphicsElement* svgElement = toSVGGraphicsElement(renderer->node()); | |
| 204 getElementCTM(svgElement, ctm); | |
| 205 ASSERT(svgElement->renderer()); | |
| 206 return rect.contains(ctm.mapRect(svgElement->renderer()->repaintRectInLocalC
oordinates())); | |
| 207 } | |
| 208 | |
| 209 } // namespace WebCore | 138 } // namespace WebCore |
| OLD | NEW |