Changeset 164579 in webkit


Ignore:
Timestamp:
Feb 24, 2014 2:02:10 AM (10 years ago)
Author:
commit-queue@webkit.org
Message:

[CSS Blending] An element having -webkit-mix-blend-mode should only blend with the contents of the parent stacking context
https://bugs.webkit.org/show_bug.cgi?id=129154

Patch by Mihai Tica <mitica@adobe.com> on 2014-02-24
Reviewed by Dean Jackson.

Source/WebCore:

The blending operation of an element having -webkit-mix-blend-mode should be restricted to the parent stacking context.
This change isolates blending, preventing it from blending with other underlying elements besides the parent stacking context.

Tests: css3/compositing/blend-mode-isolated-group-1.html

css3/compositing/blend-mode-isolated-group-2.html
css3/compositing/blend-mode-isolated-group-3.html

  • rendering/RenderLayer.cpp:

(WebCore::RenderLayer::RenderLayer): Initialize added members to false.
(WebCore::RenderLayer::updateBlendMode): Check if a blend mode was set or unset. If so, set the m_updateParentStackingContextShouldIsolateBlendingDirty to true.
(WebCore::RenderLayer::updateParentStackingContextShouldIsolateBlending): Traverse to the parent stacking context and update the
m_isolatesBlending member accordingly.

  • rendering/RenderLayer.h:
  • Add isolatesBlending() as a condition for creating a transparency layer in the paintsWithTransparency method.
  • Add m_updateParentStackingContextShouldIsolateBlendingDirty member.
  • Add m_isolatesBlending member and getter.
  • rendering/RenderLayerCompositor.cpp:

(WebCore::RenderLayerCompositor::computeCompositingRequirements): Call updateParentStackingContextShouldIsolateBlending.

LayoutTests:

Test that isolation is performed for blending, in other words, an element having -webkit-mix-blend-mode is blending with the
contents of the parent stacking context, but not with any of the underlying content.

  • css3/compositing/blend-mode-isolated-group-1.html: Added.
  • css3/compositing/blend-mode-isolated-group-2.html: Added.
  • css3/compositing/blend-mode-isolated-group-3.html: Added.
  • platform/mac/css3/compositing/blend-mode-isolated-group-1-expected.png: Added.
  • platform/mac/css3/compositing/blend-mode-isolated-group-1-expected.txt: Added.
  • platform/mac/css3/compositing/blend-mode-isolated-group-2-expected.png: Added.
  • platform/mac/css3/compositing/blend-mode-isolated-group-2-expected.txt: Added.
  • platform/mac/css3/compositing/blend-mode-isolated-group-3-expected.png: Added.
  • platform/mac/css3/compositing/blend-mode-isolated-group-3-expected.txt: Added.
Location:
trunk
Files:
9 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r164577 r164579  
     12014-02-24  Mihai Tica  <mitica@adobe.com>
     2
     3        [CSS Blending] An element having -webkit-mix-blend-mode should only blend with the contents of the parent stacking context
     4        https://bugs.webkit.org/show_bug.cgi?id=129154
     5
     6        Reviewed by Dean Jackson.
     7
     8        Test that isolation is performed for blending, in other words, an element having -webkit-mix-blend-mode is blending with the
     9        contents of the parent stacking context, but not with any of the underlying content.
     10
     11        * css3/compositing/blend-mode-isolated-group-1.html: Added.
     12        * css3/compositing/blend-mode-isolated-group-2.html: Added.
     13        * css3/compositing/blend-mode-isolated-group-3.html: Added.
     14        * platform/mac/css3/compositing/blend-mode-isolated-group-1-expected.png: Added.
     15        * platform/mac/css3/compositing/blend-mode-isolated-group-1-expected.txt: Added.
     16        * platform/mac/css3/compositing/blend-mode-isolated-group-2-expected.png: Added.
     17        * platform/mac/css3/compositing/blend-mode-isolated-group-2-expected.txt: Added.
     18        * platform/mac/css3/compositing/blend-mode-isolated-group-3-expected.png: Added.
     19        * platform/mac/css3/compositing/blend-mode-isolated-group-3-expected.txt: Added.
     20
    1212014-02-24  Krzysztof Czech  <k.czech@samsung.com>
    222
  • trunk/Source/WebCore/ChangeLog

    r164577 r164579  
     12014-02-24  Mihai Tica  <mitica@adobe.com>
     2
     3        [CSS Blending] An element having -webkit-mix-blend-mode should only blend with the contents of the parent stacking context
     4        https://bugs.webkit.org/show_bug.cgi?id=129154
     5
     6        Reviewed by Dean Jackson.
     7
     8        The blending operation of an element having -webkit-mix-blend-mode should be restricted to the parent stacking context.
     9        This change isolates blending, preventing it from blending with other underlying elements besides the parent stacking context.
     10
     11        Tests: css3/compositing/blend-mode-isolated-group-1.html
     12               css3/compositing/blend-mode-isolated-group-2.html
     13               css3/compositing/blend-mode-isolated-group-3.html
     14
     15        * rendering/RenderLayer.cpp:
     16        (WebCore::RenderLayer::RenderLayer): Initialize added members to false.
     17        (WebCore::RenderLayer::updateBlendMode): Check if a blend mode was set or unset. If so, set the m_updateParentStackingContextShouldIsolateBlendingDirty to true.
     18        (WebCore::RenderLayer::updateParentStackingContextShouldIsolateBlending): Traverse to the parent stacking context and update the
     19        m_isolatesBlending member accordingly.
     20        * rendering/RenderLayer.h:
     21        - Add isolatesBlending() as a condition for creating a transparency layer in the paintsWithTransparency method.
     22        - Add m_updateParentStackingContextShouldIsolateBlendingDirty member.
     23        - Add m_isolatesBlending member and getter.
     24        * rendering/RenderLayerCompositor.cpp:
     25        (WebCore::RenderLayerCompositor::computeCompositingRequirements): Call updateParentStackingContextShouldIsolateBlending.
     26
    1272014-02-24  Krzysztof Czech  <k.czech@samsung.com>
    228
  • trunk/Source/WebCore/rendering/RenderLayer.cpp

    r164482 r164579  
    186186#if ENABLE(CSS_COMPOSITING)
    187187    , m_blendMode(BlendModeNormal)
     188    , m_isolatesBlending(false)
     189    , m_updateParentStackingContextShouldIsolateBlendingDirty(false)
    188190#endif
    189191    , m_renderer(rendererLayerModelObject)
     
    802804#if ENABLE(CSS_COMPOSITING)
    803805
    804 void RenderLayer::updateBlendMode()
    805 {
     806void RenderLayer::updateBlendMode(const RenderStyle* oldStyle)
     807{
     808    m_updateParentStackingContextShouldIsolateBlendingDirty = false;
     809
     810    if ((!oldStyle && renderer().style().hasBlendMode()) || (oldStyle && oldStyle->hasBlendMode() != renderer().style().hasBlendMode()))
     811        m_updateParentStackingContextShouldIsolateBlendingDirty = true;
     812
    806813    BlendMode newBlendMode = renderer().style().blendMode();
    807814    if (newBlendMode != m_blendMode) {
     
    810817            backing()->setBlendMode(newBlendMode);
    811818    }
     819}
     820
     821void RenderLayer::updateParentStackingContextShouldIsolateBlending()
     822{
     823    if (!m_updateParentStackingContextShouldIsolateBlendingDirty)
     824        return;
     825
     826    if (isComposited()) {
     827        m_updateParentStackingContextShouldIsolateBlendingDirty = false;
     828        return;
     829    }
     830
     831    for (auto ancestor = parent(); ancestor && !ancestor->isComposited() && !ancestor->isRootLayer(); ancestor = ancestor->parent()) {
     832        if (ancestor->isStackingContext()) {
     833            ancestor->m_isolatesBlending = renderer().style().hasBlendMode();
     834            break;
     835        }
     836    }
     837
     838    m_updateParentStackingContextShouldIsolateBlendingDirty = false;
    812839}
    813840
     
    65166543    updateTransform();
    65176544#if ENABLE(CSS_COMPOSITING)
    6518     updateBlendMode();
     6545    updateBlendMode(oldStyle);
    65196546#endif
    65206547#if ENABLE(CSS_FILTERS)
  • trunk/Source/WebCore/rendering/RenderLayer.h

    r164482 r164579  
    504504   
    505505#if ENABLE(CSS_COMPOSITING)
    506     void updateBlendMode();
     506    void updateBlendMode(const RenderStyle*);
     507    void updateParentStackingContextShouldIsolateBlending();
    507508#endif
    508509
     
    776777#endif
    777778
     779    bool hasBlendMode() const
     780    {
    778781#if ENABLE(CSS_COMPOSITING)
    779     bool hasBlendMode() const { return renderer().hasBlendMode(); }
     782        return renderer().hasBlendMode();
    780783#else
    781     bool hasBlendMode() const { return false; }
    782 #endif
     784        return false;
     785#endif
     786    }
     787
     788    bool isolatesBlending() const
     789    {
     790#if ENABLE(CSS_COMPOSITING)
     791        return m_isolatesBlending;
     792#else
     793        return false;
     794#endif
     795    }
    783796
    784797    bool isComposited() const { return m_backing != 0; }
     
    799812    bool paintsWithTransparency(PaintBehavior paintBehavior) const
    800813    {
    801         return (isTransparent() || hasBlendMode()) && ((paintBehavior & PaintBehaviorFlattenCompositingLayers) || !isComposited());
     814        return (isTransparent() || hasBlendMode() || isolatesBlending()) && ((paintBehavior & PaintBehaviorFlattenCompositingLayers) || !isComposited());
    802815    }
    803816
     
    12321245#if ENABLE(CSS_COMPOSITING)
    12331246    BlendMode m_blendMode : 5;
     1247    bool m_isolatesBlending : 1;
     1248    bool m_updateParentStackingContextShouldIsolateBlendingDirty : 1;
    12341249#endif
    12351250
  • trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp

    r164415 r164579  
    10541054    layer.updateLayerListsIfNeeded();
    10551055
     1056#if ENABLE(CSS_COMPOSITING)
     1057    layer.updateParentStackingContextShouldIsolateBlending();
     1058#endif
     1059
    10561060    if (layer.isFlowThreadCollectingGraphicsLayersUnderRegions()) {
    10571061        RenderFlowThread& flowThread = toRenderFlowThread(layer.renderer());
Note: See TracChangeset for help on using the changeset viewer.