OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 import 'node.dart'; | 5 import 'node.dart'; |
6 import 'dart:sky' as sky; | 6 import 'dart:sky' as sky; |
7 | 7 |
8 // ABSTRACT LAYOUT | 8 // ABSTRACT LAYOUT |
9 | 9 |
10 class ParentData { | 10 class ParentData { |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 void markNeedsPaint() { | 181 void markNeedsPaint() { |
182 assert(!_debugDoingPaint); | 182 assert(!_debugDoingPaint); |
183 // TODO(abarth): It's very redundant to call this for every node in the | 183 // TODO(abarth): It's very redundant to call this for every node in the |
184 // render tree during layout. We should instead compute a summary bit and | 184 // render tree during layout. We should instead compute a summary bit and |
185 // call it once at the end of layout. | 185 // call it once at the end of layout. |
186 sky.view.scheduleFrame(); | 186 sky.view.scheduleFrame(); |
187 } | 187 } |
188 void paint(RenderNodeDisplayList canvas) { } | 188 void paint(RenderNodeDisplayList canvas) { } |
189 | 189 |
190 | 190 |
191 // HIT TESTING | 191 // HIT TESTING |
192 | 192 |
193 void handlePointer(sky.PointerEvent event) { | 193 void handlePointer(sky.PointerEvent event) { |
194 // override this if you have a client, to hand it to the client | 194 // override this if you have a client, to hand it to the client |
195 // override this if you want to do anything with the pointer event | 195 // override this if you want to do anything with the pointer event |
196 } | 196 } |
197 | 197 |
198 // RenderNode subclasses are expected to have a method like the | 198 // RenderNode subclasses are expected to have a method like the |
199 // following (with the signature being whatever passes for coordinates | 199 // following (with the signature being whatever passes for coordinates |
200 // for this particular class): | 200 // for this particular class): |
201 // bool hitTest(HitTestResult result, { double x, double y }) { | 201 // bool hitTest(HitTestResult result, { double x, double y }) { |
(...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
915 | 915 |
916 void hitTestChildren(HitTestResult result, { double x, double y }) { | 916 void hitTestChildren(HitTestResult result, { double x, double y }) { |
917 defaultHitTestChildren(result, x: x, y: y); | 917 defaultHitTestChildren(result, x: x, y: y); |
918 } | 918 } |
919 | 919 |
920 void paint(RenderNodeDisplayList canvas) { | 920 void paint(RenderNodeDisplayList canvas) { |
921 super.paint(canvas); | 921 super.paint(canvas); |
922 defaultPaint(canvas); | 922 defaultPaint(canvas); |
923 } | 923 } |
924 } | 924 } |
| 925 |
| 926 class RenderParagraph extends RenderDecoratedBox { |
| 927 final String text; |
| 928 LayoutRoot _layoutRoot = new LayoutRoot(); |
| 929 Document _document; |
| 930 |
| 931 RenderParagraph(String this.text) : |
| 932 super(new BoxDecoration(backgroundColor: 0xFFFFFFFF)) { |
| 933 _document = new Document(); |
| 934 _layoutRoot.rootElement = _document.createElement('p'); |
| 935 _layoutRoot.rootElement.appendChild(_document.createText(this.text)); |
| 936 } |
| 937 |
| 938 void performLayout() { |
| 939 _layoutRoot.maxWidth = constraints.maxWidth; |
| 940 _layoutRoot.minWidth = constraints.minWidth; |
| 941 _layoutRoot.layout(); |
| 942 width = _layoutRoot.rootElement.width; |
| 943 height = _layoutRoot.rootElement.height; |
| 944 } |
| 945 |
| 946 void hitTestChildren(HitTestResult result, { double x, double y }) { |
| 947 // defaultHitTestChildren(result, x: x, y: y); |
| 948 } |
| 949 |
| 950 void paint(RenderNodeDisplayList canvas) { |
| 951 super.paint(canvas); |
| 952 _layoutRoot.paint(canvas); |
| 953 } |
| 954 } |
OLD | NEW |