Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(633)

Unified Diff: Source/core/paint/DeprecatedPaintLayerClipper.h

Issue 1327483003: Add documentation to 2 DeprecatedPaintLayer objects (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/paint/DeprecatedPaintLayerClipper.h
diff --git a/Source/core/paint/DeprecatedPaintLayerClipper.h b/Source/core/paint/DeprecatedPaintLayerClipper.h
index a0303716c08c6eb070bd53d13e5d246f8d256bca..e9f337755183548685c2d3caa91c7461b557c66e 100644
--- a/Source/core/paint/DeprecatedPaintLayerClipper.h
+++ b/Source/core/paint/DeprecatedPaintLayerClipper.h
@@ -127,6 +127,50 @@ private:
ShouldRespectOverflowClip respectOverflowClipForViewport;
};
+// DeprecatedPaintLayerClipper is responsible for caching clip rects.
wkorman 2015/09/01 17:58:20 Worth adding a note for any class with 'Deprecated
mstensho (USE GERRIT) 2015/09/01 18:59:06 Calculating and caching, perhaps?
Julien - ping for review 2015/09/03 14:25:54 I have added, that should clarify the status of th
+//
+// 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
wkorman 2015/09/01 17:58:20 The way this is written up makes it sound as if, i
Julien - ping for review 2015/09/03 14:25:54 I don't really have a definite answer to your ques
+// a layout tree walk and cache them for painting.
class DeprecatedPaintLayerClipper {
DISALLOW_ALLOCATION();
WTF_MAKE_NONCOPYABLE(DeprecatedPaintLayerClipper);

Powered by Google App Engine
This is Rietveld 408576698