This source file includes following definitions.
- m_childLayerHasBlendModeStatusDirty
- hasBlendMode
- updateBlendMode
- dirtyAncestorChainBlendedDescendantStatus
- setAncestorChainBlendedDescendant
#include "config.h"
#include "core/rendering/RenderLayerBlendInfo.h"
#include "core/rendering/RenderLayer.h"
#include "core/rendering/RenderLayerModelObject.h"
#include "core/rendering/compositing/CompositedLayerMapping.h"
namespace WebCore {
RenderLayerBlendInfo::RenderLayerBlendInfo(RenderLayerModelObject* renderer)
: m_renderer(renderer)
, m_blendMode(blink::WebBlendModeNormal)
, m_childLayerHasBlendMode(false)
, m_childLayerHasBlendModeStatusDirty(false)
{
}
bool RenderLayerBlendInfo::hasBlendMode() const
{
return RuntimeEnabledFeatures::cssCompositingEnabled() && m_renderer->hasBlendMode();
}
void RenderLayerBlendInfo::updateBlendMode()
{
if (!RuntimeEnabledFeatures::cssCompositingEnabled())
return;
blink::WebBlendMode newBlendMode = m_renderer->style()->blendMode();
if (newBlendMode == m_blendMode)
return;
bool hadBlendMode = m_blendMode != blink::WebBlendModeNormal;
m_blendMode = newBlendMode;
RenderLayer* layer = m_renderer->layer();
if (layer->parent() && (!hadBlendMode || !hasBlendMode()))
layer->parent()->blendInfo().dirtyAncestorChainBlendedDescendantStatus();
if (layer->hasCompositedLayerMapping())
layer->compositedLayerMapping()->setBlendMode(newBlendMode);
}
void RenderLayerBlendInfo::dirtyAncestorChainBlendedDescendantStatus()
{
for (RenderLayer* layer = m_renderer->layer(); layer; layer = layer->parent()) {
if (layer->blendInfo().childLayerHasBlendModeStatusDirty())
break;
layer->blendInfo().setChildLayerHasBlendModeStatusDirty(true);
if (layer->stackingNode()->isStackingContext())
break;
}
}
void RenderLayerBlendInfo::setAncestorChainBlendedDescendant()
{
for (RenderLayer* layer = m_renderer->layer(); layer; layer = layer->parent()) {
if (!layer->blendInfo().childLayerHasBlendModeStatusDirty() && layer->blendInfo().childLayerHasBlendMode())
break;
layer->blendInfo().setChildLayerHasBlendMode(true);
layer->blendInfo().setChildLayerHasBlendModeStatusDirty(false);
if (layer->stackingNode()->isStackingContext())
break;
}
}
}