| 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" | |
| 27 #include "core/layout/LayoutObject.h" | 26 #include "core/layout/LayoutObject.h" |
| 28 #include "core/layout/svg/LayoutSVGRoot.h" | |
| 29 #include "core/svg/SVGElementRareData.h" | 27 #include "core/svg/SVGElementRareData.h" |
| 30 #include "core/svg/SVGMatrixTearOff.h" | 28 #include "core/svg/SVGMatrixTearOff.h" |
| 31 #include "core/svg/SVGRectTearOff.h" | 29 #include "core/svg/SVGRectTearOff.h" |
| 32 #include "platform/transforms/AffineTransform.h" | 30 #include "platform/transforms/AffineTransform.h" |
| 33 | 31 |
| 34 namespace blink { | 32 namespace blink { |
| 35 | 33 |
| 36 SVGGraphicsElement::SVGGraphicsElement(const QualifiedName& tag_name, | 34 SVGGraphicsElement::SVGGraphicsElement(const QualifiedName& tag_name, |
| 37 Document& document, | 35 Document& document, |
| 38 ConstructionType construction_type) | 36 ConstructionType construction_type) |
| (...skipping 27 matching lines...) Expand all Loading... |
| 66 | 64 |
| 67 AffineTransform ctm; | 65 AffineTransform ctm; |
| 68 bool done = false; | 66 bool done = false; |
| 69 | 67 |
| 70 for (const Element* current_element = this; current_element && !done; | 68 for (const Element* current_element = this; current_element && !done; |
| 71 current_element = current_element->ParentOrShadowHostElement()) { | 69 current_element = current_element->ParentOrShadowHostElement()) { |
| 72 if (!current_element->IsSVGElement()) | 70 if (!current_element->IsSVGElement()) |
| 73 break; | 71 break; |
| 74 | 72 |
| 75 ctm = ToSVGElement(current_element) | 73 ctm = ToSVGElement(current_element) |
| 76 ->LocalCoordinateSpaceTransform() | 74 ->LocalCoordinateSpaceTransform(mode) |
| 77 .Multiply(ctm); | 75 .Multiply(ctm); |
| 78 | 76 |
| 79 switch (mode) { | 77 switch (mode) { |
| 80 case kNearestViewportScope: | 78 case kNearestViewportScope: |
| 81 // Stop at the nearest viewport ancestor. | 79 // Stop at the nearest viewport ancestor. |
| 82 done = current_element != this && IsViewportElement(*current_element); | 80 done = current_element != this && IsViewportElement(*current_element); |
| 83 break; | 81 break; |
| 84 case kAncestorScope: | 82 case kAncestorScope: |
| 85 // Stop at the designated ancestor. | 83 // Stop at the designated ancestor. |
| 86 done = current_element == ancestor; | 84 done = current_element == ancestor; |
| 87 break; | 85 break; |
| 88 default: | 86 default: |
| 89 NOTREACHED(); | 87 DCHECK_EQ(mode, kScreenScope); |
| 90 break; | 88 break; |
| 91 } | 89 } |
| 92 } | 90 } |
| 93 | 91 |
| 94 return ctm; | 92 return ctm; |
| 95 } | 93 } |
| 96 | 94 |
| 97 AffineTransform SVGGraphicsElement::GetCTM( | 95 AffineTransform SVGGraphicsElement::GetCTM( |
| 98 StyleUpdateStrategy style_update_strategy) { | 96 StyleUpdateStrategy style_update_strategy) { |
| 99 return ComputeCTM(kNearestViewportScope, style_update_strategy); | 97 return ComputeCTM(kNearestViewportScope, style_update_strategy); |
| 100 } | 98 } |
| 101 | 99 |
| 102 AffineTransform SVGGraphicsElement::GetScreenCTM( | 100 AffineTransform SVGGraphicsElement::GetScreenCTM( |
| 103 StyleUpdateStrategy style_update_strategy) { | 101 StyleUpdateStrategy style_update_strategy) { |
| 104 if (style_update_strategy == kAllowStyleUpdate) | 102 return ComputeCTM(kScreenScope, style_update_strategy); |
| 105 GetDocument().UpdateStyleAndLayoutIgnorePendingStylesheets(); | |
| 106 TransformationMatrix transform; | |
| 107 if (LayoutObject* layout_object = this->GetLayoutObject()) { | |
| 108 // Adjust for the zoom level factored into CSS coordinates (WK bug #96361). | |
| 109 transform.Scale(1.0 / layout_object->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 = GetDocument().View()) { | |
| 116 LayoutRect visible_content_rect(view->VisibleContentRect()); | |
| 117 transform.Translate(-visible_content_rect.X(), -visible_content_rect.Y()); | |
| 118 } | |
| 119 | |
| 120 // Apply transforms from our ancestor coordinate space, including any | |
| 121 // non-SVG ancestor transforms. | |
| 122 transform.Multiply(layout_object->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 (layout_object->IsSVGRoot()) { | |
| 128 transform.Multiply( | |
| 129 ToLayoutSVGRoot(layout_object)->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(); | |
| 136 } | 103 } |
| 137 | 104 |
| 138 SVGMatrixTearOff* SVGGraphicsElement::getCTMFromJavascript() { | 105 SVGMatrixTearOff* SVGGraphicsElement::getCTMFromJavascript() { |
| 139 return SVGMatrixTearOff::Create(GetCTM()); | 106 return SVGMatrixTearOff::Create(GetCTM()); |
| 140 } | 107 } |
| 141 | 108 |
| 142 SVGMatrixTearOff* SVGGraphicsElement::getScreenCTMFromJavascript() { | 109 SVGMatrixTearOff* SVGGraphicsElement::getScreenCTMFromJavascript() { |
| 143 return SVGMatrixTearOff::Create(GetScreenCTM()); | 110 return SVGMatrixTearOff::Create(GetScreenCTM()); |
| 144 } | 111 } |
| 145 | 112 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 | 181 |
| 215 return GetLayoutObject()->ObjectBoundingBox(); | 182 return GetLayoutObject()->ObjectBoundingBox(); |
| 216 } | 183 } |
| 217 | 184 |
| 218 SVGRectTearOff* SVGGraphicsElement::getBBoxFromJavascript() { | 185 SVGRectTearOff* SVGGraphicsElement::getBBoxFromJavascript() { |
| 219 return SVGRectTearOff::Create(SVGRect::Create(GetBBox()), 0, | 186 return SVGRectTearOff::Create(SVGRect::Create(GetBBox()), 0, |
| 220 kPropertyIsNotAnimVal); | 187 kPropertyIsNotAnimVal); |
| 221 } | 188 } |
| 222 | 189 |
| 223 } // namespace blink | 190 } // namespace blink |
| OLD | NEW |