Changeset 180683 in webkit


Ignore:
Timestamp:
Feb 26, 2015 10:34:51 AM (9 years ago)
Author:
commit-queue@webkit.org
Message:

Setting any of the <object> element plugin controlling attributes does not have any affect.
https://bugs.webkit.org/show_bug.cgi?id=141936.

Patch by Said Abou-Hallawa <sabouhallawa@apple.com> on 2015-02-26
Reviewed by Zalan Bujtas.

Source/WebCore:

When setting any of the <object> element plugin controlling attributes
dynamically we need to mark the the element to be dirty by calling
setNeedsStyleRecalc(), so it has to recreate its renderer when needed.

Test: svg/as-object/svg-in-object-dynamic-attribute-change.html

  • dom/Element.h: Delete unimplemented function.
  • html/HTMLObjectElement.cpp:

(WebCore::HTMLObjectElement::parseAttribute): Dirty the element by calling
setNeedsStyleRecalc() when one of the plugin controlling attributes gets
changed. We have to clear the m_useFallbackContent because the attribute's
new value might fix the object rendering.

  • html/HTMLObjectElement.h: Add a function to clear m_useFallbackContent.
  • html/HTMLPlugInImageElement.cpp:

(WebCore::HTMLPlugInImageElement::willRecalcStyle): We might need to
reconstruct the object renderer in the image case. This can happen if the
image was rendering fallback content and the attribute's new value fixes
the object rendering.

LayoutTests:

  • svg/as-object/resources/lime100x100.html: Added.
  • svg/as-object/resources/lime100x100.png: Added.
  • svg/as-object/resources/lime100x100.svg: Added.
  • svg/as-object/resources/red100x100.svg: Added.
  • svg/as-object/svg-in-object-dynamic-attribute-change-expected.html: Added.
  • svg/as-object/svg-in-object-dynamic-attribute-change.html: Added.

Ensure that changing the 'type' and the 'data' attributes of the <object>
element will have the expected outcome. Also make sure that the <object>
element renderer falls back correctly when setting any of the attributes
to some unexpected value.

Location:
trunk
Files:
6 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r180678 r180683  
     12015-02-26  Said Abou-Hallawa  <sabouhallawa@apple.com>
     2
     3        Setting any of the <object> element plugin controlling attributes does not have any affect.
     4        https://bugs.webkit.org/show_bug.cgi?id=141936.
     5
     6        Reviewed by Zalan Bujtas.
     7
     8        * svg/as-object/resources/lime100x100.html: Added.
     9        * svg/as-object/resources/lime100x100.png: Added.
     10        * svg/as-object/resources/lime100x100.svg: Added.
     11        * svg/as-object/resources/red100x100.svg: Added.
     12        * svg/as-object/svg-in-object-dynamic-attribute-change-expected.html: Added.
     13        * svg/as-object/svg-in-object-dynamic-attribute-change.html: Added.
     14        Ensure that changing the 'type' and the 'data' attributes of the <object>
     15        element will have the expected outcome. Also make sure that the <object>
     16        element renderer falls back correctly when setting any of the attributes
     17        to some unexpected value.
     18
    1192015-02-26  Brent Fulgham  <bfulgham@apple.com>
    220
  • trunk/Source/WebCore/ChangeLog

    r180676 r180683  
     12015-02-26  Said Abou-Hallawa  <sabouhallawa@apple.com>
     2
     3        Setting any of the <object> element plugin controlling attributes does not have any affect.
     4        https://bugs.webkit.org/show_bug.cgi?id=141936.
     5
     6        Reviewed by Zalan Bujtas.
     7
     8        When setting any of the <object> element plugin controlling attributes
     9        dynamically we need to mark the the element to be dirty by calling
     10        setNeedsStyleRecalc(), so it has to recreate its renderer when needed.
     11       
     12        Test: svg/as-object/svg-in-object-dynamic-attribute-change.html
     13
     14        * dom/Element.h: Delete unimplemented function.
     15       
     16        * html/HTMLObjectElement.cpp:
     17        (WebCore::HTMLObjectElement::parseAttribute): Dirty the element by calling
     18        setNeedsStyleRecalc() when one of the plugin controlling attributes gets
     19        changed. We have to clear the m_useFallbackContent because the attribute's
     20        new value might fix the object rendering.
     21       
     22        * html/HTMLObjectElement.h: Add a function to clear m_useFallbackContent.
     23       
     24        * html/HTMLPlugInImageElement.cpp:
     25        (WebCore::HTMLPlugInImageElement::willRecalcStyle): We might need to
     26        reconstruct the object renderer in the image case. This can happen if the
     27        image was rendering fallback content and the attribute's new value fixes
     28        the object rendering.
     29
    1302015-02-26  Brent Fulgham  <bfulgham@apple.com>
    231
  • trunk/Source/WebCore/dom/Element.h

    r179770 r180683  
    311311    virtual void copyNonAttributePropertiesFromElement(const Element&) { }
    312312
    313     void lazyReattach();
    314 
    315313    virtual RenderPtr<RenderElement> createElementRenderer(Ref<RenderStyle>&&);
    316314    virtual bool rendererIsNeeded(const RenderStyle&);
  • trunk/Source/WebCore/html/HTMLObjectElement.cpp

    r177996 r180683  
    108108void HTMLObjectElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
    109109{
     110    bool invalidateRenderer = false;
     111
    110112    if (name == formAttr)
    111113        formAttributeChanged();
    112114    else if (name == typeAttr) {
    113115        m_serviceType = value.string().left(value.find(';')).lower();
     116        invalidateRenderer = !fastHasAttribute(classidAttr);
    114117        setNeedsWidgetUpdate(true);
    115118    } else if (name == dataAttr) {
    116119        m_url = stripLeadingAndTrailingHTMLSpaces(value);
     120        document().updateStyleIfNeeded();
     121        if (isImageType() && renderer()) {
     122            if (!m_imageLoader)
     123                m_imageLoader = std::make_unique<HTMLImageLoader>(*this);
     124            m_imageLoader->updateFromElementIgnoringPreviousError();
     125        }
     126        invalidateRenderer = !fastHasAttribute(classidAttr);
    117127        setNeedsWidgetUpdate(true);
    118         document().updateStyleIfNeeded();
    119         if (renderer()) {
    120             if (isImageType()) {
    121                 if (!m_imageLoader)
    122                     m_imageLoader = std::make_unique<HTMLImageLoader>(*this);
    123                 m_imageLoader->updateFromElementIgnoringPreviousError();
    124             }
    125         }
    126     } else if (name == classidAttr)
     128    } else if (name == classidAttr) {
     129        invalidateRenderer = true;
    127130        setNeedsWidgetUpdate(true);
    128     else if (name == onbeforeloadAttr)
     131    } else if (name == onbeforeloadAttr)
    129132        setAttributeEventListener(eventNames().beforeloadEvent, name, value);
    130133    else
    131134        HTMLPlugInImageElement::parseAttribute(name, value);
     135
     136    if (!invalidateRenderer || !inDocument() || !renderer())
     137        return;
     138
     139    clearUseFallbackContent();
     140    setNeedsStyleRecalc(SyntheticStyleChange);
    132141}
    133142
  • trunk/Source/WebCore/html/HTMLObjectElement.h

    r177996 r180683  
    8686    bool shouldAllowQuickTimeClassIdQuirk();
    8787    bool hasValidClassId();
     88    void clearUseFallbackContent() { m_useFallbackContent = false; }
    8889
    8990    virtual void refFormAssociatedElement() override { ref(); }
  • trunk/Source/WebCore/html/HTMLPlugInImageElement.cpp

    r179597 r180683  
    238238    // FIXME: There shoudn't be need to force render tree reconstruction here.
    239239    // It is only done because loading and load event dispatching is tied to render tree construction.
    240     if (!useFallbackContent() && needsWidgetUpdate() && renderer() && !isImageType() && (displayState() != DisplayingSnapshot))
     240    if (!useFallbackContent() && needsWidgetUpdate() && renderer() && (displayState() != DisplayingSnapshot))
    241241        setNeedsStyleRecalc(ReconstructRenderTree);
    242242    return true;
Note: See TracChangeset for help on using the changeset viewer.