Commit d4925584 authored by hyatt@apple.com's avatar hyatt@apple.com

2008-10-16 David Hyatt <hyatt@apple.com>

        Simplify styleForRenderer to avoid confusion.  Callers in the SVG filter code thought "forRenderer" meant
        they would be given a style that corresponded to the RenderObject* passed in.  This is not what the code
        did though.  This patch removes the renderer argument and the Element subclass shadow implementation
        so that confusion like this can't occur again.

        Reviewed by Oliver Hunt

        * dom/Element.cpp:
        * dom/Element.h:
        * dom/Node.cpp:
        (WebCore::Node::createRendererIfNeeded):
        (WebCore::Node::styleForRenderer):
        * dom/Node.h:
        * html/HTMLOptGroupElement.cpp:
        (WebCore::HTMLOptGroupElement::attach):
        * html/HTMLOptionElement.cpp:
        (WebCore::HTMLOptionElement::attach):
        * svg/SVGClipPathElement.cpp:
        (WebCore::SVGClipPathElement::canvasResource):
        * svg/SVGFEDiffuseLightingElement.cpp:
        (WebCore::SVGFEDiffuseLightingElement::build):
        * svg/SVGFEFloodElement.cpp:
        (WebCore::SVGFEFloodElement::build):
        * svg/SVGFESpecularLightingElement.cpp:
        (WebCore::SVGFESpecularLightingElement::build):
        * svg/SVGGradientElement.cpp:
        (WebCore::SVGGradientElement::buildStops):
        * svg/SVGUseElement.cpp:
        (WebCore::SVGUseElement::attachShadowTree):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@37644 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 79e4dd90
2008-10-16 David Hyatt <hyatt@apple.com>
Simplify styleForRenderer to avoid confusion. Callers in the SVG filter code thought "forRenderer" meant
they would be given a style that corresponded to the RenderObject* passed in. This is not what the code
did though. This patch removes the renderer argument and the Element subclass shadow implementation
so that confusion like this can't occur again.
Reviewed by Oliver Hunt
* dom/Element.cpp:
* dom/Element.h:
* dom/Node.cpp:
(WebCore::Node::createRendererIfNeeded):
(WebCore::Node::styleForRenderer):
* dom/Node.h:
* html/HTMLOptGroupElement.cpp:
(WebCore::HTMLOptGroupElement::attach):
* html/HTMLOptionElement.cpp:
(WebCore::HTMLOptionElement::attach):
* svg/SVGClipPathElement.cpp:
(WebCore::SVGClipPathElement::canvasResource):
* svg/SVGFEDiffuseLightingElement.cpp:
(WebCore::SVGFEDiffuseLightingElement::build):
* svg/SVGFEFloodElement.cpp:
(WebCore::SVGFEFloodElement::build):
* svg/SVGFESpecularLightingElement.cpp:
(WebCore::SVGFESpecularLightingElement::build):
* svg/SVGGradientElement.cpp:
(WebCore::SVGGradientElement::buildStops):
* svg/SVGUseElement.cpp:
(WebCore::SVGUseElement::attachShadowTree):
2008-10-16 David Hyatt <hyatt@apple.com>
https://bugs.webkit.org/attachment.cgi?bugid=21647
......
......@@ -609,11 +609,6 @@ const QualifiedName& Element::imageSourceAttributeName() const
return srcAttr;
}
PassRefPtr<RenderStyle> Element::styleForRenderer(RenderObject* parentRenderer)
{
return document()->styleSelector()->styleForElement(this);
}
RenderObject* Element::createRenderer(RenderArena* arena, RenderStyle* style)
{
if (document()->documentElement() == this && style->display() == NONE) {
......
......@@ -140,7 +140,6 @@ public:
virtual void attach();
virtual void detach();
PassRefPtr<RenderStyle> styleForRenderer(RenderObject* parent);
virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
virtual void recalcStyle(StyleChange = NoChange);
......
......@@ -1018,23 +1018,23 @@ void Node::createRendererIfNeeded()
ASSERT(!renderer());
Node *parent = parentNode();
Node* parent = parentNode();
ASSERT(parent);
RenderObject *parentRenderer = parent->renderer();
RenderObject* parentRenderer = parent->renderer();
if (parentRenderer && parentRenderer->canHaveChildren()
#if ENABLE(SVG)
&& parent->childShouldCreateRenderer(this)
#endif
) {
RefPtr<RenderStyle> style = styleForRenderer(parentRenderer);
RefPtr<RenderStyle> style = styleForRenderer();
if (rendererIsNeeded(style.get())) {
if (RenderObject* r = createRenderer(document()->renderArena(), style.get())) {
if (!parentRenderer->isChildAllowed(r, style.get()))
r->destroy();
else {
setRenderer(r);
renderer()->setAnimatableStyle(style);
renderer()->setAnimatableStyle(style.release());
parentRenderer->addChild(renderer(), nextRenderer());
}
}
......@@ -1042,11 +1042,11 @@ void Node::createRendererIfNeeded()
}
}
PassRefPtr<RenderStyle> Node::styleForRenderer(RenderObject* parent)
PassRefPtr<RenderStyle> Node::styleForRenderer()
{
if (isElementNode())
return document()->styleSelector()->styleForElement(static_cast<Element*>(this));
return parent->style();
return parentNode() && parentNode()->renderer() ? parentNode()->renderer()->style() : 0;
}
bool Node::rendererIsNeeded(RenderStyle *style)
......
......@@ -408,7 +408,7 @@ public:
virtual void willRemove();
void createRendererIfNeeded();
PassRefPtr<RenderStyle> styleForRenderer(RenderObject* parent);
PassRefPtr<RenderStyle> styleForRenderer();
virtual bool rendererIsNeeded(RenderStyle*);
#if ENABLE(SVG)
virtual bool childShouldCreateRenderer(Node*) const { return true; }
......
......@@ -133,7 +133,7 @@ bool HTMLOptGroupElement::checkDTD(const Node* newChild)
void HTMLOptGroupElement::attach()
{
if (parentNode()->renderStyle())
setRenderStyle(styleForRenderer(0));
setRenderStyle(styleForRenderer());
HTMLFormControlElement::attach();
}
......
......@@ -58,7 +58,7 @@ bool HTMLOptionElement::checkDTD(const Node* newChild)
void HTMLOptionElement::attach()
{
if (parentNode()->renderStyle())
setRenderStyle(styleForRenderer(0));
setRenderStyle(styleForRenderer());
HTMLFormControlElement::attach();
}
......
......@@ -98,7 +98,7 @@ SVGResource* SVGClipPathElement::canvasResource()
bool bbox = clipPathUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX;
RefPtr<RenderStyle> clipPathStyle = styleForRenderer(parent()->renderer()); // FIXME: Manual style resolution is a hack
RefPtr<RenderStyle> clipPathStyle = styleForRenderer(); // FIXME: Manual style resolution is a hack
for (Node* n = firstChild(); n; n = n->nextSibling()) {
if (n->isSVGElement() && static_cast<SVGElement*>(n)->isStyledTransformable()) {
SVGStyledTransformableElement* styled = static_cast<SVGStyledTransformableElement*>(n);
......
......@@ -84,9 +84,7 @@ bool SVGFEDiffuseLightingElement::build(FilterBuilder* builder)
if(!input1)
return false;
// FIXME: This style code is totally wrong and makes no sense. It's not really getting a parent style.
RefPtr<RenderStyle> parentStyle = styleForRenderer(parent()->renderer());
RefPtr<RenderStyle> filterStyle = resolveStyle(parentStyle.get());
RefPtr<RenderStyle> filterStyle = styleForRenderer();
Color color = filterStyle->svgStyle()->lightingColor();
RefPtr<FilterEffect> addedEffect = FEDiffuseLighting::create(input1, color, surfaceScale(), diffuseConstant(),
......
......@@ -57,9 +57,7 @@ SVGFilterEffect* SVGFEFloodElement::filterEffect(SVGResourceFilter* filter) cons
bool SVGFEFloodElement::build(FilterBuilder* builder)
{
// FIXME: This style code is totally wrong and makes no sense. It's not really getting a parent style.
RefPtr<RenderStyle> parentStyle = styleForRenderer(parent()->renderer());
RefPtr<RenderStyle> filterStyle = resolveStyle(parentStyle.get());
RefPtr<RenderStyle> filterStyle = styleForRenderer();
Color color = filterStyle->svgStyle()->floodColor();
float opacity = filterStyle->svgStyle()->floodOpacity();
......
......@@ -99,9 +99,7 @@ bool SVGFESpecularLightingElement::build(FilterBuilder* builder)
if(!input1)
return false;
// FIXME: This style code is totally wrong and makes no sense. It's not really getting a parent style.
RefPtr<RenderStyle> parentStyle = styleForRenderer(parent()->renderer());
RefPtr<RenderStyle> filterStyle = resolveStyle(parentStyle.get());
RefPtr<RenderStyle> filterStyle = styleForRenderer();
Color color = filterStyle->svgStyle()->lightingColor();
......
......@@ -149,7 +149,7 @@ Vector<SVGGradientStop> SVGGradientElement::buildStops() const
// set display="none" - ie. <g display="none"><linearGradient><stop>..
// Unfortunately we have to manually rebuild the stop style. See pservers-grad-19-b.svg
if (!gradientStyle)
gradientStyle = const_cast<SVGGradientElement*>(this)->styleForRenderer(parent()->renderer());
gradientStyle = const_cast<SVGGradientElement*>(this)->styleForRenderer();
RefPtr<RenderStyle> stopStyle = stop->resolveStyle(gradientStyle.get());
......
......@@ -741,7 +741,7 @@ void SVGUseElement::attachShadowTree()
// Inspired by RenderTextControl::createSubtreeIfNeeded().
if (renderer()->canHaveChildren() && childShouldCreateRenderer(m_shadowTreeRootElement.get())) {
RefPtr<RenderStyle> style = m_shadowTreeRootElement->styleForRenderer(renderer());
RefPtr<RenderStyle> style = m_shadowTreeRootElement->styleForRenderer();
if (m_shadowTreeRootElement->rendererIsNeeded(style.get())) {
m_shadowTreeRootElement->setRenderer(m_shadowTreeRootElement->createRenderer(document()->renderArena(), style.get()));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment