OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006 Apple Computer, Inc. | 2 * Copyright (C) 2006 Apple Computer, Inc. |
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 * |
11 * This library is distributed in the hope that it will be useful, | 11 * This library is distributed in the hope that it will be useful, |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 * Library General Public License for more details. | 14 * Library General Public License for more details. |
15 * | 15 * |
16 * You should have received a copy of the GNU Library General Public License | 16 * You should have received a copy of the GNU Library General Public License |
17 * along with this library; see the file COPYING.LIB. If not, write to | 17 * along with this library; see the file COPYING.LIB. If not, write to |
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
19 * Boston, MA 02110-1301, USA. | 19 * Boston, MA 02110-1301, USA. |
20 */ | 20 */ |
21 | 21 |
22 #include "core/layout/svg/LayoutSVGBlock.h" | 22 #include "core/layout/svg/LayoutSVGBlock.h" |
23 | 23 |
| 24 #include "core/layout/LayoutGeometryMap.h" |
24 #include "core/layout/LayoutView.h" | 25 #include "core/layout/LayoutView.h" |
25 #include "core/layout/svg/LayoutSVGRoot.h" | 26 #include "core/layout/svg/LayoutSVGRoot.h" |
26 #include "core/layout/svg/SVGLayoutSupport.h" | 27 #include "core/layout/svg/SVGLayoutSupport.h" |
27 #include "core/layout/svg/SVGResourcesCache.h" | 28 #include "core/layout/svg/SVGResourcesCache.h" |
28 #include "core/style/ShadowList.h" | 29 #include "core/style/ShadowList.h" |
29 #include "core/svg/SVGElement.h" | 30 #include "core/svg/SVGElement.h" |
| 31 #include "platform/geometry/TransformState.h" |
30 | 32 |
31 namespace blink { | 33 namespace blink { |
32 | 34 |
33 LayoutSVGBlock::LayoutSVGBlock(SVGElement* element) | 35 LayoutSVGBlock::LayoutSVGBlock(SVGElement* element) |
34 : LayoutBlockFlow(element) {} | 36 : LayoutBlockFlow(element) {} |
35 | 37 |
36 bool LayoutSVGBlock::allowsOverflowClip() const { | 38 bool LayoutSVGBlock::allowsOverflowClip() const { |
37 // LayoutSVGBlock, used by Layout(SVGText|ForeignObject), is not allowed to | 39 // LayoutSVGBlock, used by Layout(SVGText|ForeignObject), is not allowed to |
38 // have overflow clip. | 40 // have overflow clip. |
39 // LayoutBlock assumes a layer to be present when the overflow clip | 41 // LayoutBlock assumes a layer to be present when the overflow clip |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 : DescendantIsolationNeedsUpdate); | 87 : DescendantIsolationNeedsUpdate); |
86 } | 88 } |
87 | 89 |
88 LayoutBlock::styleDidChange(diff, oldStyle); | 90 LayoutBlock::styleDidChange(diff, oldStyle); |
89 SVGResourcesCache::clientStyleChanged(this, diff, styleRef()); | 91 SVGResourcesCache::clientStyleChanged(this, diff, styleRef()); |
90 } | 92 } |
91 | 93 |
92 void LayoutSVGBlock::mapLocalToAncestor(const LayoutBoxModelObject* ancestor, | 94 void LayoutSVGBlock::mapLocalToAncestor(const LayoutBoxModelObject* ancestor, |
93 TransformState& transformState, | 95 TransformState& transformState, |
94 MapCoordinatesFlags flags) const { | 96 MapCoordinatesFlags flags) const { |
| 97 // Convert from local HTML coordinates to local SVG coordinates. |
| 98 transformState.move(locationOffset()); |
| 99 // Apply other mappings on local SVG coordinates. |
95 SVGLayoutSupport::mapLocalToAncestor(this, ancestor, transformState, flags); | 100 SVGLayoutSupport::mapLocalToAncestor(this, ancestor, transformState, flags); |
96 } | 101 } |
97 | 102 |
98 void LayoutSVGBlock::mapAncestorToLocal(const LayoutBoxModelObject* ancestor, | 103 void LayoutSVGBlock::mapAncestorToLocal(const LayoutBoxModelObject* ancestor, |
99 TransformState& transformState, | 104 TransformState& transformState, |
100 MapCoordinatesFlags flags) const { | 105 MapCoordinatesFlags flags) const { |
101 if (this == ancestor) | 106 if (this == ancestor) |
102 return; | 107 return; |
| 108 |
| 109 // Map to local SVG coordinates. |
103 SVGLayoutSupport::mapAncestorToLocal(*this, ancestor, transformState, flags); | 110 SVGLayoutSupport::mapAncestorToLocal(*this, ancestor, transformState, flags); |
| 111 // Convert from local SVG coordinates to local HTML coordinates. |
| 112 transformState.move(-locationOffset()); |
104 } | 113 } |
105 | 114 |
106 const LayoutObject* LayoutSVGBlock::pushMappingToContainer( | 115 const LayoutObject* LayoutSVGBlock::pushMappingToContainer( |
107 const LayoutBoxModelObject* ancestorToStopAt, | 116 const LayoutBoxModelObject* ancestorToStopAt, |
108 LayoutGeometryMap& geometryMap) const { | 117 LayoutGeometryMap& geometryMap) const { |
| 118 // Convert from local HTML coordinates to local SVG coordinates. |
| 119 geometryMap.push(this, locationOffset()); |
| 120 // Apply other mappings on local SVG coordinates. |
109 return SVGLayoutSupport::pushMappingToContainer(this, ancestorToStopAt, | 121 return SVGLayoutSupport::pushMappingToContainer(this, ancestorToStopAt, |
110 geometryMap); | 122 geometryMap); |
111 } | 123 } |
112 | 124 |
113 LayoutRect LayoutSVGBlock::absoluteVisualRect() const { | 125 LayoutRect LayoutSVGBlock::absoluteVisualRect() const { |
114 return SVGLayoutSupport::visualRectInAncestorSpace(*this, *view()); | 126 return SVGLayoutSupport::visualRectInAncestorSpace(*this, *view()); |
115 } | 127 } |
116 | 128 |
117 bool LayoutSVGBlock::mapToVisualRectInAncestorSpace( | 129 bool LayoutSVGBlock::mapToVisualRectInAncestorSpace( |
118 const LayoutBoxModelObject* ancestor, | 130 const LayoutBoxModelObject* ancestor, |
119 LayoutRect& rect, | 131 LayoutRect& rect, |
120 VisualRectFlags) const { | 132 VisualRectFlags) const { |
| 133 // Convert from local HTML coordinates to local SVG coordinates. |
| 134 rect.moveBy(location()); |
| 135 // Apply other mappings on local SVG coordinates. |
121 return SVGLayoutSupport::mapToVisualRectInAncestorSpace( | 136 return SVGLayoutSupport::mapToVisualRectInAncestorSpace( |
122 *this, ancestor, FloatRect(rect), rect); | 137 *this, ancestor, FloatRect(rect), rect); |
123 } | 138 } |
124 | 139 |
125 bool LayoutSVGBlock::nodeAtPoint(HitTestResult&, | 140 bool LayoutSVGBlock::nodeAtPoint(HitTestResult&, |
126 const HitTestLocation&, | 141 const HitTestLocation&, |
127 const LayoutPoint&, | 142 const LayoutPoint&, |
128 HitTestAction) { | 143 HitTestAction) { |
129 ASSERT_NOT_REACHED(); | 144 ASSERT_NOT_REACHED(); |
130 return false; | 145 return false; |
131 } | 146 } |
132 | 147 |
133 } // namespace blink | 148 } // namespace blink |
OLD | NEW |