LayerAncestorClippingStack.h [plain text]
#pragma once
#include "LayoutRect.h"
#include "RenderLayer.h"
#include "ScrollTypes.h"
#include <wtf/Vector.h>
#include <wtf/WeakPtr.h>
namespace WTF {
class TextStream;
}
namespace WebCore {
class ScrollingCoordinator;
struct CompositedClipData {
CompositedClipData(RenderLayer* layer, LayoutRect rect, bool isOverflowScrollEntry)
: clippingLayer(makeWeakPtr(layer))
, clipRect(rect)
, isOverflowScroll(isOverflowScrollEntry)
{
}
bool operator==(const CompositedClipData& other) const
{
return clippingLayer == other.clippingLayer
&& clipRect == other.clipRect
&& isOverflowScroll == other.isOverflowScroll;
}
bool operator!=(const CompositedClipData& other) const
{
return !(*this == other);
}
WeakPtr<RenderLayer> clippingLayer; LayoutRect clipRect; bool isOverflowScroll { false };
};
class LayerAncestorClippingStack {
WTF_MAKE_FAST_ALLOCATED;
public:
LayerAncestorClippingStack(Vector<CompositedClipData>&&);
~LayerAncestorClippingStack() = default;
bool hasAnyScrollingLayers() const;
bool equalToClipData(const Vector<CompositedClipData>&) const;
bool updateWithClipData(ScrollingCoordinator*, Vector<CompositedClipData>&&);
void clear(ScrollingCoordinator*);
void detachFromScrollingCoordinator(ScrollingCoordinator&);
void updateScrollingNodeLayers(ScrollingCoordinator&);
GraphicsLayer* firstClippingLayer() const;
GraphicsLayer* lastClippingLayer() const;
ScrollingNodeID lastOverflowScrollProxyNodeID() const;
bool update(LayerAncestorClippingStack&&);
struct ClippingStackEntry {
CompositedClipData clipData;
ScrollingNodeID overflowScrollProxyNodeID { 0 }; RefPtr<GraphicsLayer> clippingLayer;
};
Vector<ClippingStackEntry>& stack() { return m_stack; }
const Vector<ClippingStackEntry>& stack() const { return m_stack; }
private:
Vector<ClippingStackEntry> m_stack;
};
TextStream& operator<<(TextStream&, const LayerAncestorClippingStack&);
}