Add documentation to 2 DeprecatedPaintLayer objects

Added class level comments to DeprecatedPaintLayerClipper
and DeprecatedPaintLayerStackingNode.

While touching DeprecatedPaintLayerStackingNode, added a comment
about NormalFlowChildren.

Review URL: https://codereview.chromium.org/1327483003

git-svn-id: svn://svn.chromium.org/blink/trunk@201805 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 603d3ddf
......@@ -95,6 +95,12 @@ private:
// hardware acceleration (through DeprecatedPaintLayerCompositor),
// scrolling (through DeprecatedPaintLayerScrollableArea)
// along with some optimizations are all handled by DeprecatedPaintLayer.
//
// The class is DEPRECATED, which means that we would like to remove it. The
// reason for removal is that it has been a dumping ground for features for too
// long and is the wrong level of abstraction, bearing no correspondence to any
// CSS concept. Its associated objects and some of its feature need to be
// migrated to LayoutObject (or the appropriate sub-class).
class CORE_EXPORT DeprecatedPaintLayer {
WTF_MAKE_NONCOPYABLE(DeprecatedPaintLayer);
public:
......
......@@ -107,6 +107,54 @@ private:
ShouldRespectOverflowClip respectOverflowClipForViewport;
};
// DeprecatedPaintLayerClipper is responsible for computing and caching clip
// rects.
//
// The main reason for this cache is that we compute the clip rects during
// a layout tree walk but need them during a paint tree walk (see example
// below for some explanations).
//
// A lot of complexity in this class come from the difference in inheritance
// between 'overflow' and 'clip':
// * 'overflow' applies based on the containing blocks chain.
// (http://www.w3.org/TR/CSS2/visufx.html#propdef-overflow)
// * 'clip' applies to all descendants.
// (http://www.w3.org/TR/CSS2/visufx.html#propdef-clip)
//
// Let's take an example:
// <!DOCTYPE html>
// <div id="container" style="position: absolute; height: 100px; width: 100px">
// <div id="inflow" style="height: 200px; width: 200px;
// background-color: purple"></div>
// <div id="fixed" style="height: 200px; width: 200px; position: fixed;
// background-color: orange"></div>
// </div>
//
// The paint tree looks like:
// html
// / \
// / \
// / \
// container fixed
// |
// |
// inflow
//
// If we add "overflow: hidden" to #container, the overflow clip will apply to
// #inflow but not to #fixed. That's because #fixed's containing block is above
// #container and thus 'overflow' doesn't apply to it. During our tree walk,
// #fixed is a child of #container, which is the reason why we keep 3 clip rects
// depending on the 'position' of the elements.
//
// Now instead if we add "clip: rect(0px, 100px, 100px, 0px)" to #container,
// the clip will apply to both #inflow and #fixed. That's because 'clip'
// applies to any descendant, regardless of containing blocks. Note that
// #container and #fixed are siblings in the paint tree but #container does
// clip #fixed. This is the reason why we compute the painting clip rects during
// a layout tree walk and cache them for painting.
//
// This class is NOT DEPRECATED, DeprecatedPaintLayer is and we match its
// naming.
class DeprecatedPaintLayerClipper {
DISALLOW_ALLOCATION();
WTF_MAKE_NONCOPYABLE(DeprecatedPaintLayerClipper);
......
......@@ -58,6 +58,33 @@ class DeprecatedPaintLayerCompositor;
class ComputedStyle;
class LayoutBoxModelObject;
// DeprecatedPaintLayerStackingNode represents anything that is treated as a
// stacking context.
//
// Stacking contexts are the basis for the CSS painting algorithm. The paint
// order is determined by walking stacking contexts (or elements treated like a
// stacking context like positioned objects or floats) in an order defined by
// ‘z-index’. This walk is interleaved with content that is not a stacking.
// context. See CSS 2.1 appendix E for the actual algorithm
// http://www.w3.org/TR/CSS21/zindex.html
// See also DeprecatedPaintLayerPainter (in particular paintLayerContents) for
// our implementation of the walk.
//
// Stacking contexts form a subtree over the layout tree. Ideally we would want
// objects of this class to be a node in this tree but there are potential
// issues with stale pointers so we rely on DeprecatedPaintLayer's tree
// structure.
//
// This class's purpose is to represent a node in the stacking context tree
// (aka paint tree). It currently caches the z-order lists for painting and
// hit-testing.
//
// To implement any z-order list iterations, use
// DeprecatedPaintLayerStackingNodeIterator and
// DeprecatedPaintLayerStackingNodeReverseIterator.
//
// This class is NOT DEPRECATED, DeprecatedPaintLayer is and we match its
// naming.
class CORE_EXPORT DeprecatedPaintLayerStackingNode {
WTF_MAKE_FAST_ALLOCATED(DeprecatedPaintLayerStackingNode);
WTF_MAKE_NONCOPYABLE(DeprecatedPaintLayerStackingNode);
......
......@@ -38,6 +38,10 @@ namespace blink {
enum ChildrenIteration {
NegativeZOrderChildren = 1,
// Normal flow children are not mandated by CSS 2.1 but are an artifact of
// our implementation: we allocate DeprecatedPaintLayers for elements that
// are not treated as stacking contexts and thus we need to walk them
// during painting and hit-testing.
NormalFlowChildren = 1 << 1,
PositiveZOrderChildren = 1 << 2,
AllChildren = NegativeZOrderChildren | NormalFlowChildren | PositiveZOrderChildren
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment