This source file includes following definitions.
- shouldAppendLayer
- rebuildTree
- update
- assertNeedsToUpdateGraphicsLayerBitsCleared
#include "config.h"
#include "core/rendering/compositing/GraphicsLayerUpdater.h"
#include "core/html/HTMLMediaElement.h"
#include "core/rendering/RenderLayer.h"
#include "core/rendering/RenderLayerReflectionInfo.h"
#include "core/rendering/RenderPart.h"
#include "core/rendering/RenderView.h"
#include "core/rendering/compositing/CompositedLayerMapping.h"
#include "core/rendering/compositing/RenderLayerCompositor.h"
#include "public/platform/Platform.h"
namespace WebCore {
static bool shouldAppendLayer(const RenderLayer& layer)
{
if (!RuntimeEnabledFeatures::overlayFullscreenVideoEnabled())
return true;
Node* node = layer.renderer()->node();
if (node && isHTMLMediaElement(*node) && toHTMLMediaElement(node)->isFullscreen())
return false;
return true;
}
GraphicsLayerUpdater::GraphicsLayerUpdater()
{
}
GraphicsLayerUpdater::~GraphicsLayerUpdater()
{
}
void GraphicsLayerUpdater::rebuildTree(RenderLayer& layer, GraphicsLayerVector& childLayersOfEnclosingLayer)
{
layer.stackingNode()->updateLayerListsIfNeeded();
const bool hasCompositedLayerMapping = layer.hasCompositedLayerMapping();
CompositedLayerMappingPtr currentCompositedLayerMapping = layer.compositedLayerMapping();
GraphicsLayerVector layerChildren;
GraphicsLayerVector& childList = hasCompositedLayerMapping ? layerChildren : childLayersOfEnclosingLayer;
#if !ASSERT_DISABLED
LayerListMutationDetector mutationChecker(layer.stackingNode());
#endif
if (layer.stackingNode()->isStackingContainer()) {
RenderLayerStackingNodeIterator iterator(*layer.stackingNode(), NegativeZOrderChildren);
while (RenderLayerStackingNode* curNode = iterator.next())
rebuildTree(*curNode->layer(), childList);
if (hasCompositedLayerMapping && currentCompositedLayerMapping->foregroundLayer())
childList.append(currentCompositedLayerMapping->foregroundLayer());
}
RenderLayerStackingNodeIterator iterator(*layer.stackingNode(), NormalFlowChildren | PositiveZOrderChildren);
while (RenderLayerStackingNode* curNode = iterator.next())
rebuildTree(*curNode->layer(), childList);
if (hasCompositedLayerMapping) {
bool parented = false;
if (layer.renderer()->isRenderPart())
parented = RenderLayerCompositor::parentFrameContentLayers(toRenderPart(layer.renderer()));
if (!parented)
currentCompositedLayerMapping->parentForSublayers()->setChildren(layerChildren);
if (!currentCompositedLayerMapping->hasClippingLayer() && !currentCompositedLayerMapping->hasScrollingLayer()) {
if (GraphicsLayer* overflowControlLayer = currentCompositedLayerMapping->layerForHorizontalScrollbar()) {
overflowControlLayer->removeFromParent();
currentCompositedLayerMapping->parentForSublayers()->addChild(overflowControlLayer);
}
if (GraphicsLayer* overflowControlLayer = currentCompositedLayerMapping->layerForVerticalScrollbar()) {
overflowControlLayer->removeFromParent();
currentCompositedLayerMapping->parentForSublayers()->addChild(overflowControlLayer);
}
if (GraphicsLayer* overflowControlLayer = currentCompositedLayerMapping->layerForScrollCorner()) {
overflowControlLayer->removeFromParent();
currentCompositedLayerMapping->parentForSublayers()->addChild(overflowControlLayer);
}
}
if (shouldAppendLayer(layer))
childLayersOfEnclosingLayer.append(currentCompositedLayerMapping->childForSuperlayers());
}
}
void GraphicsLayerUpdater::update(RenderLayer& layer, UpdateType updateType)
{
if (layer.hasCompositedLayerMapping()) {
CompositedLayerMappingPtr mapping = layer.compositedLayerMapping();
mapping->updateCompositedBounds(updateType);
if (RenderLayerReflectionInfo* reflection = layer.reflectionInfo()) {
if (reflection->reflectionLayer()->hasCompositedLayerMapping())
reflection->reflectionLayer()->compositedLayerMapping()->updateCompositedBounds(ForceUpdate);
}
mapping->updateGraphicsLayerConfiguration(updateType);
mapping->updateGraphicsLayerGeometry(updateType);
updateType = mapping->updateTypeForChildren(updateType);
mapping->clearNeedsGraphicsLayerUpdate();
if (!layer.parent())
layer.compositor()->updateRootLayerPosition();
if (mapping->hasUnpositionedOverflowControlsLayers())
layer.scrollableArea()->positionOverflowControls();
}
for (RenderLayer* child = layer.firstChild(); child; child = child->nextSibling())
update(*child, updateType);
}
#if !ASSERT_DISABLED
void GraphicsLayerUpdater::assertNeedsToUpdateGraphicsLayerBitsCleared(RenderLayer& layer)
{
if (layer.hasCompositedLayerMapping())
layer.compositedLayerMapping()->assertNeedsToUpdateGraphicsLayerBitsCleared();
for (RenderLayer* child = layer.firstChild(); child; child = child->nextSibling())
assertNeedsToUpdateGraphicsLayerBitsCleared(*child);
}
#endif
}