| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2004, 2005 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) 2009 Google, Inc. | 4 * Copyright (C) 2009 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 "config.h" | 22 #include "config.h" |
| 23 | 23 |
| 24 #include "core/rendering/svg/RenderSVGTransformableContainer.h" | 24 #include "core/layout/svg/LayoutSVGTransformableContainer.h" |
| 25 | 25 |
| 26 #include "core/layout/svg/SVGLayoutSupport.h" | 26 #include "core/layout/svg/SVGLayoutSupport.h" |
| 27 #include "core/svg/SVGGElement.h" | 27 #include "core/svg/SVGGElement.h" |
| 28 #include "core/svg/SVGGraphicsElement.h" | 28 #include "core/svg/SVGGraphicsElement.h" |
| 29 #include "core/svg/SVGUseElement.h" | 29 #include "core/svg/SVGUseElement.h" |
| 30 | 30 |
| 31 namespace blink { | 31 namespace blink { |
| 32 | 32 |
| 33 RenderSVGTransformableContainer::RenderSVGTransformableContainer(SVGGraphicsElem
ent* node) | 33 LayoutSVGTransformableContainer::LayoutSVGTransformableContainer(SVGGraphicsElem
ent* node) |
| 34 : LayoutSVGContainer(node) | 34 : LayoutSVGContainer(node) |
| 35 , m_needsTransformUpdate(true) | 35 , m_needsTransformUpdate(true) |
| 36 , m_didTransformToRootUpdate(false) | 36 , m_didTransformToRootUpdate(false) |
| 37 { | 37 { |
| 38 } | 38 } |
| 39 | 39 |
| 40 static bool hasValidPredecessor(const Node* node) | 40 static bool hasValidPredecessor(const Node* node) |
| 41 { | 41 { |
| 42 ASSERT(node); | 42 ASSERT(node); |
| 43 for (node = node->previousSibling(); node; node = node->previousSibling()) { | 43 for (node = node->previousSibling(); node; node = node->previousSibling()) { |
| 44 if (node->isSVGElement() && toSVGElement(node)->isValid()) | 44 if (node->isSVGElement() && toSVGElement(node)->isValid()) |
| 45 return true; | 45 return true; |
| 46 } | 46 } |
| 47 return false; | 47 return false; |
| 48 } | 48 } |
| 49 | 49 |
| 50 bool RenderSVGTransformableContainer::isChildAllowed(LayoutObject* child, const
LayoutStyle& style) const | 50 bool LayoutSVGTransformableContainer::isChildAllowed(LayoutObject* child, const
LayoutStyle& style) const |
| 51 { | 51 { |
| 52 ASSERT(element()); | 52 ASSERT(element()); |
| 53 if (isSVGSwitchElement(*element())) { | 53 if (isSVGSwitchElement(*element())) { |
| 54 Node* node = child->node(); | 54 Node* node = child->node(); |
| 55 // Reject non-SVG/non-valid elements. | 55 // Reject non-SVG/non-valid elements. |
| 56 if (!node->isSVGElement() || !toSVGElement(node)->isValid()) | 56 if (!node->isSVGElement() || !toSVGElement(node)->isValid()) |
| 57 return false; | 57 return false; |
| 58 // Reject this child if it isn't the first valid node. | 58 // Reject this child if it isn't the first valid node. |
| 59 if (hasValidPredecessor(node)) | 59 if (hasValidPredecessor(node)) |
| 60 return false; | 60 return false; |
| 61 } else if (isSVGAElement(*element())) { | 61 } else if (isSVGAElement(*element())) { |
| 62 // http://www.w3.org/2003/01/REC-SVG11-20030114-errata#linking-text-envi
ronment | 62 // http://www.w3.org/2003/01/REC-SVG11-20030114-errata#linking-text-envi
ronment |
| 63 // The 'a' element may contain any element that its parent may contain,
except itself. | 63 // The 'a' element may contain any element that its parent may contain,
except itself. |
| 64 if (isSVGAElement(*child->node())) | 64 if (isSVGAElement(*child->node())) |
| 65 return false; | 65 return false; |
| 66 if (parent() && parent()->isSVG()) | 66 if (parent() && parent()->isSVG()) |
| 67 return parent()->isChildAllowed(child, style); | 67 return parent()->isChildAllowed(child, style); |
| 68 } | 68 } |
| 69 return LayoutSVGContainer::isChildAllowed(child, style); | 69 return LayoutSVGContainer::isChildAllowed(child, style); |
| 70 } | 70 } |
| 71 | 71 |
| 72 bool RenderSVGTransformableContainer::calculateLocalTransform() | 72 bool LayoutSVGTransformableContainer::calculateLocalTransform() |
| 73 { | 73 { |
| 74 SVGGraphicsElement* element = toSVGGraphicsElement(this->element()); | 74 SVGGraphicsElement* element = toSVGGraphicsElement(this->element()); |
| 75 ASSERT(element); | 75 ASSERT(element); |
| 76 | 76 |
| 77 // If we're either the renderer for a <use> element, or for any <g> element
inside the shadow | 77 // If we're either the renderer for a <use> element, or for any <g> element
inside the shadow |
| 78 // tree, that was created during the use/symbol/svg expansion in SVGUseEleme
nt. These containers | 78 // tree, that was created during the use/symbol/svg expansion in SVGUseEleme
nt. These containers |
| 79 // need to respect the translations induced by their corresponding use eleme
nts x/y attributes. | 79 // need to respect the translations induced by their corresponding use eleme
nts x/y attributes. |
| 80 SVGUseElement* useElement = 0; | 80 SVGUseElement* useElement = 0; |
| 81 if (isSVGUseElement(*element)) { | 81 if (isSVGUseElement(*element)) { |
| 82 useElement = toSVGUseElement(element); | 82 useElement = toSVGUseElement(element); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 100 if (!m_needsTransformUpdate) | 100 if (!m_needsTransformUpdate) |
| 101 return false; | 101 return false; |
| 102 | 102 |
| 103 m_localTransform = element->calculateAnimatedLocalTransform(); | 103 m_localTransform = element->calculateAnimatedLocalTransform(); |
| 104 m_localTransform.translate(m_lastTranslation.width(), m_lastTranslation.heig
ht()); | 104 m_localTransform.translate(m_lastTranslation.width(), m_lastTranslation.heig
ht()); |
| 105 m_needsTransformUpdate = false; | 105 m_needsTransformUpdate = false; |
| 106 return true; | 106 return true; |
| 107 } | 107 } |
| 108 | 108 |
| 109 } | 109 } |
| OLD | NEW |