Commit 050f2be4 authored by akling@apple.com's avatar akling@apple.com

Avoid setting style twice for generated image content.

<https://webkit.org/b/125128>

Take care of a FIXME I added in r158097 and avoid redundant work in
ImageContentData::createRenderer().

I changed the inheritance helper RenderImage::setPseudoStyle() into
a new createStyleInheritingFromPseudoStyle() function instead so it
can be used from both PseudoElement and ImageContentData.

Reviewed by Antti Koivisto.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@159989 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent b12b8b28
2013-12-02 Andreas Kling <akling@apple.com>
Avoid setting style twice for generated image content.
<https://webkit.org/b/125128>
Take care of a FIXME I added in r158097 and avoid redundant work in
ImageContentData::createRenderer().
I changed the inheritance helper RenderImage::setPseudoStyle() into
a new createStyleInheritingFromPseudoStyle() function instead so it
can be used from both PseudoElement and ImageContentData.
Reviewed by Antti Koivisto.
2013-12-02 Samuel White <samuel_white@apple.com>
AX: Add AXUIElementCountForSearchPredicate parameterized attribute.
......@@ -114,7 +114,7 @@ void PseudoElement::didRecalcStyle(Style::Change)
// We only manage the style for the generated content which must be images or text.
if (!child->isImage())
continue;
toRenderImage(child)->setPseudoStyle(&renderer->style());
toRenderImage(*child).setStyle(RenderImage::createStyleInheritingFromPseudoStyle(renderer->style()));
}
}
......
......@@ -74,17 +74,16 @@ RenderImage::~RenderImage()
m_imageResource->shutdown();
}
void RenderImage::setPseudoStyle(PassRefPtr<RenderStyle> pseudoStyle)
PassRef<RenderStyle> RenderImage::createStyleInheritingFromPseudoStyle(const RenderStyle& pseudoStyle)
{
ASSERT(pseudoStyle->styleType() == BEFORE || pseudoStyle->styleType() == AFTER);
ASSERT(pseudoStyle.styleType() == BEFORE || pseudoStyle.styleType() == AFTER);
// Images are special and must inherit the pseudoStyle so the width and height of
// the pseudo element doesn't change the size of the image. In all other cases we
// can just share the style.
auto style = RenderStyle::create();
style.get().inheritFrom(pseudoStyle.get());
setStyle(std::move(style));
style.get().inheritFrom(&pseudoStyle);
return style;
}
void RenderImage::setImageResource(PassOwnPtr<RenderImageResource> imageResource)
......
......@@ -39,8 +39,8 @@ public:
explicit RenderImage(Document&, PassRef<RenderStyle>);
virtual ~RenderImage();
// Set the style of the object if it's generated content.
void setPseudoStyle(PassRefPtr<RenderStyle>);
// Create a RenderStyle for generated content by inheriting from a pseudo style.
static PassRef<RenderStyle> createStyleInheritingFromPseudoStyle(const RenderStyle&);
void setImageResource(PassOwnPtr<RenderImageResource>);
......
......@@ -49,9 +49,8 @@ std::unique_ptr<ContentData> ContentData::clone() const
RenderObject* ImageContentData::createRenderer(Document& document, RenderStyle& pseudoStyle) const
{
// FIXME: We should find a way to avoid setting the style twice here.
RenderImage* image = new RenderImage(document, pseudoStyle);
image->setPseudoStyle(&pseudoStyle);
RenderImage* image = new RenderImage(document, RenderImage::createStyleInheritingFromPseudoStyle(pseudoStyle));
image->initializeStyle();
image->setAltText(altText());
if (m_image)
image->setImageResource(RenderImageResourceStyleImage::create(*m_image));
......
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