2 * Copyright (C) 2006 Apple Computer, Inc.
3 * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org>
4 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
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
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
25 #include "RenderSVGBlock.h"
27 #include "RenderSVGResource.h"
28 #include "SVGElement.h"
29 #include "SVGResourcesCache.h"
33 RenderSVGBlock::RenderSVGBlock(SVGElement* node)
38 LayoutRect RenderSVGBlock::visualOverflowRect() const
40 LayoutRect borderRect = borderBoxRect();
42 if (const ShadowData* textShadow = style()->textShadow())
43 textShadow->adjustRectForShadow(borderRect);
48 void RenderSVGBlock::setStyle(PassRefPtr<RenderStyle> style)
50 RefPtr<RenderStyle> useStyle = style;
52 // SVG text layout code expects us to be a block-level style element.
53 if (useStyle->isDisplayInlineType()) {
54 RefPtr<RenderStyle> newStyle = RenderStyle::create();
55 newStyle->inheritFrom(useStyle.get());
56 newStyle->setDisplay(BLOCK);
57 useStyle = newStyle.release();
60 RenderBlock::setStyle(useStyle.release());
63 void RenderSVGBlock::updateBoxModelInfoFromStyle()
65 RenderBlock::updateBoxModelInfoFromStyle();
67 // RenderSVGlock, used by Render(SVGText|ForeignObject), is not allowed to call setHasOverflowClip(true).
68 // RenderBlock assumes a layer to be present when the overflow clip functionality is requested. Both
69 // Render(SVGText|ForeignObject) return 'false' on 'requiresLayer'. Fine for RenderSVGText.
71 // If we want to support overflow rules for <foreignObject> we can choose between two solutions:
72 // a) make RenderSVGForeignObject require layers and SVG layer aware
73 // b) reactor overflow logic out of RenderLayer (as suggested by dhyatt), which is a large task
75 // Until this is resolved, disable overflow support. Opera/FF don't support it as well at the moment (Feb 2010).
77 // Note: This does NOT affect overflow handling on outer/inner <svg> elements - this is handled
78 // manually by RenderSVGRoot - which owns the documents enclosing root layer and thus works fine.
79 setHasOverflowClip(false);
82 void RenderSVGBlock::absoluteRects(Vector<LayoutRect>&, const LayoutPoint&) const
84 // This code path should never be taken for SVG, as we're assuming useTransforms=true everywhere, absoluteQuads should be used.
88 void RenderSVGBlock::willBeDestroyed()
90 SVGResourcesCache::clientDestroyed(this);
91 RenderBlock::willBeDestroyed();
94 void RenderSVGBlock::styleWillChange(StyleDifference diff, const RenderStyle* newStyle)
96 if (diff == StyleDifferenceLayout)
97 setNeedsBoundariesUpdate();
98 RenderBlock::styleWillChange(diff, newStyle);
101 void RenderSVGBlock::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)
103 RenderBlock::styleDidChange(diff, oldStyle);
104 SVGResourcesCache::clientStyleChanged(this, diff, style());
107 void RenderSVGBlock::updateFromElement()
109 RenderBlock::updateFromElement();
110 SVGResourcesCache::clientUpdatedFromElement(this, style());