1 /* 2 Copyright (C) Research In Motion Limited 2010. All rights reserved. 3 4 This library is free software; you can redistribute it and/or 5 modify it under the terms of the GNU Library General Public 6 License as published by the Free Software Foundation; either 7 version 2 of the License, or (at your option) any later version. 8 9 This library is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 Library General Public License for more details. 13 14 You should have received a copy of the GNU Library General Public License 15 aint with this library; see the file COPYING.LIB. If not, write to 16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 Boston, MA 02110-1301, USA. 18 */ 19 20 #include "config.h" 21 22 #if ENABLE(SVG) 23 #include "SVGShadowTreeElements.h" 24 25 #include "Document.h" 26 #include "FloatSize.h" 27 #include "RenderObject.h" 28 #include "SVGNames.h" 29 30 namespace WebCore { 31 32 // SVGShadowTreeContainerElement 33 SVGShadowTreeContainerElement::SVGShadowTreeContainerElement(Document* document) 34 : SVGGElement(SVGNames::gTag, document) 35 { 36 } 37 38 SVGShadowTreeContainerElement::~SVGShadowTreeContainerElement() 39 { 40 } 41 42 FloatSize SVGShadowTreeContainerElement::containerTranslation() const 43 { 44 return FloatSize(m_xOffset.value(this), m_yOffset.value(this)); 45 } 46 47 // SVGShadowTreeRootElement 48 SVGShadowTreeRootElement::SVGShadowTreeRootElement(Document* document, Node* shadowParent) 49 : SVGShadowTreeContainerElement(document) 50 , m_shadowParent(shadowParent) 51 { 52 setInDocument(true); 53 } 54 55 SVGShadowTreeRootElement::~SVGShadowTreeRootElement() 56 { 57 } 58 59 void SVGShadowTreeRootElement::attachElement(PassRefPtr<RenderStyle> style, RenderArena* arena) 60 { 61 ASSERT(m_shadowParent); 62 63 // Create the renderer with the specified style 64 RenderObject* renderer = createRenderer(arena, style.get()); 65 if (renderer) { 66 setRenderer(renderer); 67 renderer->setStyle(style); 68 } 69 70 // Set these explicitly since this normally happens during an attach() 71 setAttached(); 72 73 // Add the renderer to the render tree 74 if (renderer) 75 m_shadowParent->renderer()->addChild(renderer); 76 } 77 78 } 79 80 #endif 81