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

Unified Diff: sky/sdk/lib/rendering/block.dart

Issue 1223083002: Make RenderBlock painting match its hittesting (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 5 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
« no previous file with comments | « sky/sdk/example/demo_launcher/lib/main.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/sdk/lib/rendering/block.dart
diff --git a/sky/sdk/lib/rendering/block.dart b/sky/sdk/lib/rendering/block.dart
index 939e62ceaba54c2b196f47d817076d9ae78507dc..11f20ef30abb6a1539b03c365ed827abc169a0c3 100644
--- a/sky/sdk/lib/rendering/block.dart
+++ b/sky/sdk/lib/rendering/block.dart
@@ -15,6 +15,8 @@ class RenderBlock extends RenderBox with ContainerRenderObjectMixin<RenderBox, B
// uses the maximum width provided by the parent
// sizes itself to the height of its child stack
+ bool _hasVisualOverflow = false;
+
RenderBlock({
List<RenderBox> children
}) {
@@ -94,7 +96,12 @@ class RenderBlock extends RenderBox with ContainerRenderObjectMixin<RenderBox, B
y += child.size.height;
child = child.parentData.nextSibling;
}
+ // FIXME(eseidel): Block lays out its children with unconstrained height
+ // yet itself remains constrained. Remember that our children wanted to
+ // be taller than we are so we know to clip them (and not cause confusing
+ // mismatch of painting vs. hittesting).
size = new Size(width, constraints.constrainHeight(y));
+ _hasVisualOverflow = y > size.height;
assert(!size.isInfinite);
}
@@ -103,7 +110,14 @@ class RenderBlock extends RenderBox with ContainerRenderObjectMixin<RenderBox, B
}
void paint(PaintingCanvas canvas, Offset offset) {
+ if (_hasVisualOverflow) {
+ canvas.save();
+ canvas.clipRect(offset & size);
+ }
defaultPaint(canvas, offset);
+ if (_hasVisualOverflow) {
+ canvas.restore();
+ }
}
}
« no previous file with comments | « sky/sdk/example/demo_launcher/lib/main.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698