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

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

Issue 1231943002: Implement hit testing and baseline alignment for RenderBlockViewport. (Closed) Base URL: https://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 | « no previous file | 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 b772b0419693e7e9f5c89717ac80edc0d6162214..3a1ea069f5788406b7cabce2abb83a163d9facef 100644
--- a/sky/sdk/lib/rendering/block.dart
+++ b/sky/sdk/lib/rendering/block.dart
@@ -26,10 +26,6 @@ abstract class RenderBlockBase extends RenderBox with ContainerRenderObjectMixin
child.parentData = new BlockParentData();
}
- double computeDistanceToActualBaseline(TextBaseline baseline) {
- return defaultComputeDistanceToFirstActualBaseline(baseline);
- }
-
double _childrenHeight;
double get childrenHeight => _childrenHeight;
@@ -54,14 +50,6 @@ abstract class RenderBlockBase extends RenderBox with ContainerRenderObjectMixin
_childrenHeight = y;
}
- void hitTestChildren(HitTestResult result, { Point position }) {
- defaultHitTestChildren(result, position: position);
- }
-
- void paint(PaintingCanvas canvas, Offset offset) {
- defaultPaint(canvas, offset);
- }
-
}
class RenderBlock extends RenderBlockBase {
@@ -117,6 +105,10 @@ class RenderBlock extends RenderBlockBase {
return _getIntrinsicHeight(constraints);
}
+ double computeDistanceToActualBaseline(TextBaseline baseline) {
+ return defaultComputeDistanceToFirstActualBaseline(baseline);
+ }
+
bool _hasVisualOverflow = false;
void performLayout() {
@@ -136,12 +128,16 @@ class RenderBlock extends RenderBlockBase {
canvas.save();
canvas.clipRect(offset & size);
}
- super.paint(canvas, offset);
+ defaultPaint(canvas, offset);
if (_hasVisualOverflow) {
canvas.restore();
}
}
+ void hitTestChildren(HitTestResult result, { Point position }) {
+ defaultHitTestChildren(result, position: position);
+ }
+
}
class RenderBlockViewport extends RenderBlockBase {
@@ -175,7 +171,7 @@ class RenderBlockViewport extends RenderBlockBase {
return;
_startOffset = value;
if (!_inCallback)
- markNeedsLayout();
+ markNeedsPaint();
}
double getMinIntrinsicWidth(BoxConstraints constraints) {
@@ -194,6 +190,11 @@ class RenderBlockViewport extends RenderBlockBase {
return constraints.constrainHeight();
}
+ // We don't override computeDistanceToActualBaseline(), because we
+ // want the default behaviour (returning null). Otherwise, as you
+ // scroll the RenderBlockViewport, it would shift in its parent if
+ // the parent was baseline-aligned, which makes no sense.
+
bool get sizedByParent => true;
void performResize() {
@@ -217,9 +218,13 @@ class RenderBlockViewport extends RenderBlockBase {
void paint(PaintingCanvas canvas, Offset offset) {
canvas.save();
canvas.clipRect(offset & size);
- super.paint(canvas, offset.translate(0.0, _startOffset));
+ defaultPaint(canvas, offset.translate(0.0, startOffset));
canvas.restore();
}
+ void hitTestChildren(HitTestResult result, { Point position }) {
+ defaultHitTestChildren(result, position: position + new Offset(0.0, -startOffset));
+ }
+
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698