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

Unified Diff: third_party/WebKit/Source/platform/graphics/paint/PropertyTreeState.h

Issue 2105273004: GeometryMapper: Support computing visual rects in spaces that are not direct ancestors. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: none Created 4 years, 6 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: third_party/WebKit/Source/platform/graphics/paint/PropertyTreeState.h
diff --git a/third_party/WebKit/Source/platform/graphics/paint/PropertyTreeState.h b/third_party/WebKit/Source/platform/graphics/paint/PropertyTreeState.h
index 2c8daf3979d348d7f5a1693ba165e7521119c174..c0520c27c1eeaa9ec2b7d208df097e05d2840865 100644
--- a/third_party/WebKit/Source/platform/graphics/paint/PropertyTreeState.h
+++ b/third_party/WebKit/Source/platform/graphics/paint/PropertyTreeState.h
@@ -17,17 +17,57 @@ class EffectPaintPropertyNode;
// Represents the combination of transform, clip and effect nodes for a particular coordinate space.
// See GeometryMapper.
struct PropertyTreeState {
+ PropertyTreeState() : PropertyTreeState(nullptr, nullptr, nullptr) {}
+
PropertyTreeState(
TransformPaintPropertyNode* transform,
ClipPaintPropertyNode* clip,
EffectPaintPropertyNode* effect)
: transform(transform), clip(clip), effect(effect) {}
- TransformPaintPropertyNode* transform;
- ClipPaintPropertyNode* clip;
- EffectPaintPropertyNode* effect;
+ RefPtr<TransformPaintPropertyNode> transform;
+ RefPtr<ClipPaintPropertyNode> clip;
+ RefPtr<EffectPaintPropertyNode> effect;
};
+template <class A>
+unsigned propertyTreeNodeDepth(const A* node)
+{
+ unsigned depth = 0;
+ while (node) {
+ depth++;
+ node = node->parent();
+ }
+ return depth;
+}
+
+template <class A>
+const A* propertyTreeNearestCommonAncestor(const A* a, const A* b)
+{
+ // Measure both depths.
+ unsigned depthA = propertyTreeNodeDepth<A>(a);
+ unsigned depthB = propertyTreeNodeDepth<A>(b);
+
+ // Make it so depthA >= depthB.
+ if (depthA < depthB) {
+ std::swap(a, b);
+ std::swap(depthA, depthB);
+ }
+
+ // Make it so depthA == depthB.
+ while (depthA > depthB) {
+ a = a->parent();
+ depthA--;
+ }
+
+ // Walk up until we find the ancestor.
+ while (a != b) {
+ a = a->parent();
+ b = b->parent();
+ }
+ return a;
+}
+
} // namespace blink
#endif // PropertyTreeState_h

Powered by Google App Engine
This is Rietveld 408576698