OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> |
3 * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org> | 3 * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org> |
4 * Copyright (C) 2014 Google, Inc. | 4 * Copyright (C) 2014 Google, Inc. |
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/svg/SVGGraphicsElement.h" | 22 #include "core/svg/SVGGraphicsElement.h" |
23 | 23 |
24 #include "core/SVGNames.h" | 24 #include "core/SVGNames.h" |
25 #include "core/dom/StyleChangeReason.h" | 25 #include "core/dom/StyleChangeReason.h" |
| 26 #include "core/frame/FrameView.h" |
26 #include "core/layout/LayoutObject.h" | 27 #include "core/layout/LayoutObject.h" |
| 28 #include "core/layout/svg/LayoutSVGRoot.h" |
27 #include "core/svg/SVGElementRareData.h" | 29 #include "core/svg/SVGElementRareData.h" |
28 #include "core/svg/SVGMatrixTearOff.h" | 30 #include "core/svg/SVGMatrixTearOff.h" |
29 #include "core/svg/SVGRectTearOff.h" | 31 #include "core/svg/SVGRectTearOff.h" |
30 #include "platform/transforms/AffineTransform.h" | 32 #include "platform/transforms/AffineTransform.h" |
31 | 33 |
32 namespace blink { | 34 namespace blink { |
33 | 35 |
34 SVGGraphicsElement::SVGGraphicsElement(const QualifiedName& tagName, | 36 SVGGraphicsElement::SVGGraphicsElement(const QualifiedName& tagName, |
35 Document& document, | 37 Document& document, |
36 ConstructionType constructionType) | 38 ConstructionType constructionType) |
(...skipping 27 matching lines...) Expand all Loading... |
64 | 66 |
65 AffineTransform ctm; | 67 AffineTransform ctm; |
66 bool done = false; | 68 bool done = false; |
67 | 69 |
68 for (const Element* currentElement = this; currentElement && !done; | 70 for (const Element* currentElement = this; currentElement && !done; |
69 currentElement = currentElement->parentOrShadowHostElement()) { | 71 currentElement = currentElement->parentOrShadowHostElement()) { |
70 if (!currentElement->isSVGElement()) | 72 if (!currentElement->isSVGElement()) |
71 break; | 73 break; |
72 | 74 |
73 ctm = toSVGElement(currentElement) | 75 ctm = toSVGElement(currentElement) |
74 ->localCoordinateSpaceTransform(mode) | 76 ->localCoordinateSpaceTransform() |
75 .multiply(ctm); | 77 .multiply(ctm); |
76 | 78 |
77 switch (mode) { | 79 switch (mode) { |
78 case NearestViewportScope: | 80 case NearestViewportScope: |
79 // Stop at the nearest viewport ancestor. | 81 // Stop at the nearest viewport ancestor. |
80 done = currentElement != this && isViewportElement(*currentElement); | 82 done = currentElement != this && isViewportElement(*currentElement); |
81 break; | 83 break; |
82 case AncestorScope: | 84 case AncestorScope: |
83 // Stop at the designated ancestor. | 85 // Stop at the designated ancestor. |
84 done = currentElement == ancestor; | 86 done = currentElement == ancestor; |
85 break; | 87 break; |
86 default: | 88 default: |
87 ASSERT(mode == ScreenScope); | 89 NOTREACHED(); |
88 break; | 90 break; |
89 } | 91 } |
90 } | 92 } |
91 | 93 |
92 return ctm; | 94 return ctm; |
93 } | 95 } |
94 | 96 |
95 AffineTransform SVGGraphicsElement::getCTM( | 97 AffineTransform SVGGraphicsElement::getCTM( |
96 StyleUpdateStrategy styleUpdateStrategy) { | 98 StyleUpdateStrategy styleUpdateStrategy) { |
97 return computeCTM(NearestViewportScope, styleUpdateStrategy); | 99 return computeCTM(NearestViewportScope, styleUpdateStrategy); |
98 } | 100 } |
99 | 101 |
100 AffineTransform SVGGraphicsElement::getScreenCTM( | 102 AffineTransform SVGGraphicsElement::getScreenCTM( |
101 StyleUpdateStrategy styleUpdateStrategy) { | 103 StyleUpdateStrategy styleUpdateStrategy) { |
102 return computeCTM(ScreenScope, styleUpdateStrategy); | 104 if (styleUpdateStrategy == AllowStyleUpdate) |
| 105 document().updateStyleAndLayoutIgnorePendingStylesheets(); |
| 106 TransformationMatrix transform; |
| 107 if (LayoutObject* layoutObject = this->layoutObject()) { |
| 108 // Adjust for the zoom level factored into CSS coordinates (WK bug #96361). |
| 109 transform.scale(1.0 / layoutObject->styleRef().effectiveZoom()); |
| 110 |
| 111 // Origin in the document. (This, together with the inverse-scale above, |
| 112 // performs the same operation as |
| 113 // Document::adjustFloatRectForScrollAndAbsoluteZoom, but in transformation |
| 114 // matrix form.) |
| 115 if (FrameView* view = document().view()) { |
| 116 LayoutRect visibleContentRect(view->visibleContentRect()); |
| 117 transform.translate(-visibleContentRect.x(), -visibleContentRect.y()); |
| 118 } |
| 119 |
| 120 // Apply transforms from our ancestor coordinate space, including any |
| 121 // non-SVG ancestor transforms. |
| 122 transform.multiply(layoutObject->localToAbsoluteTransform()); |
| 123 |
| 124 // At the SVG/HTML boundary (aka LayoutSVGRoot), we need to apply the |
| 125 // localToBorderBoxTransform to map an element from SVG viewport |
| 126 // coordinates to CSS box coordinates. |
| 127 if (layoutObject->isSVGRoot()) { |
| 128 transform.multiply( |
| 129 toLayoutSVGRoot(layoutObject)->localToBorderBoxTransform()); |
| 130 } |
| 131 } |
| 132 // Drop any potential non-affine parts, because we're not able to convey that |
| 133 // information further anyway until getScreenCTM returns a DOMMatrix (4x4 |
| 134 // matrix.) |
| 135 return transform.toAffineTransform(); |
103 } | 136 } |
104 | 137 |
105 SVGMatrixTearOff* SVGGraphicsElement::getCTMFromJavascript() { | 138 SVGMatrixTearOff* SVGGraphicsElement::getCTMFromJavascript() { |
106 return SVGMatrixTearOff::create(getCTM()); | 139 return SVGMatrixTearOff::create(getCTM()); |
107 } | 140 } |
108 | 141 |
109 SVGMatrixTearOff* SVGGraphicsElement::getScreenCTMFromJavascript() { | 142 SVGMatrixTearOff* SVGGraphicsElement::getScreenCTMFromJavascript() { |
110 return SVGMatrixTearOff::create(getScreenCTM()); | 143 return SVGMatrixTearOff::create(getScreenCTM()); |
111 } | 144 } |
112 | 145 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 | 218 |
186 return layoutObject()->objectBoundingBox(); | 219 return layoutObject()->objectBoundingBox(); |
187 } | 220 } |
188 | 221 |
189 SVGRectTearOff* SVGGraphicsElement::getBBoxFromJavascript() { | 222 SVGRectTearOff* SVGGraphicsElement::getBBoxFromJavascript() { |
190 return SVGRectTearOff::create(SVGRect::create(getBBox()), 0, | 223 return SVGRectTearOff::create(SVGRect::create(getBBox()), 0, |
191 PropertyIsNotAnimVal); | 224 PropertyIsNotAnimVal); |
192 } | 225 } |
193 | 226 |
194 } // namespace blink | 227 } // namespace blink |
OLD | NEW |