2 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
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.
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.
14 * You should have received a copy of the GNU Library General Public License
15 * along 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.
23 #include "SVGShadowTreeElements.h"
25 #include "CSSStyleSelector.h"
27 #include "FloatSize.h"
28 #include "RenderObject.h"
30 #include "SVGUseElement.h"
34 // SVGShadowTreeContainerElement
36 SVGShadowTreeContainerElement::SVGShadowTreeContainerElement(Document* document, ConstructionType constructionType)
37 : SVGGElement(SVGNames::gTag, document, constructionType)
38 , m_containerOffsetChanged(false)
42 PassRefPtr<SVGShadowTreeContainerElement> SVGShadowTreeContainerElement::create(Document* document)
44 return adoptRef(new SVGShadowTreeContainerElement(document));
47 void SVGShadowTreeContainerElement::setContainerOffset(const SVGLength& x, const SVGLength& y)
49 m_containerOffsetChanged = true;
54 FloatSize SVGShadowTreeContainerElement::containerTranslation() const
56 SVGLengthContext lengthContext(this);
57 return FloatSize(m_xOffset.value(lengthContext), m_yOffset.value(lengthContext));
60 PassRefPtr<Element> SVGShadowTreeContainerElement::cloneElementWithoutAttributesAndChildren()
62 return adoptRef(new SVGShadowTreeContainerElement(document()));
64 // SVGShadowTreeRootElement
66 inline SVGShadowTreeRootElement::SVGShadowTreeRootElement(Document* document, SVGUseElement* host)
67 : SVGShadowTreeContainerElement(document, CreateSVGShadowRoot)
73 PassRefPtr<SVGShadowTreeRootElement> SVGShadowTreeRootElement::create(Document* document, SVGUseElement* host)
75 return adoptRef(new SVGShadowTreeRootElement(document, host));
78 void SVGShadowTreeRootElement::attachElement(PassRefPtr<RenderStyle> style, RenderArena* arena)
80 ASSERT(svgShadowHost());
82 // Create the renderer with the specified style
83 RenderObject* renderer = createRenderer(arena, style.get());
85 setRenderer(renderer);
86 renderer->setStyle(style);
89 // Set these explicitly since this normally happens during an attach()
92 // Add the renderer to the render tree
94 svgShadowHost()->renderer()->addChild(renderer);
97 void SVGShadowTreeRootElement::clearSVGShadowHost()
102 PassRefPtr<RenderStyle> SVGShadowTreeContainerElement::customStyleForRenderer()
104 return document()->styleSelector()->styleForElement(this, 0, true/*allowSharing*/);