StyledText is just a convenient way to specify a

tree of InlineStyle and InlineText elements.
StyledText builds an Inline that renders the tree.

For example this StyledText object:

  new StyledText(["FOO", [boldLargerStyle, [greenStyle "BAR"], "BAZ"] BORF]);

Renders the same way the following HTML would,
assuming that TextStyles boldLargerStyle and
greenStyle were defined.

<style>
div {
  display: inline;
}
</style>
<p>
  <div>
    FOO
    <div style="font-weight:bold; font-size:larger">
      <div style="color:green">
        BAR
      </div>
      BAZ
    </div>
    BORF
  </div>
</p>

R=abarth@chromium.org

Review URL: https://codereview.chromium.org/1194693002.
This commit is contained in:
Hans Muller 2015-06-18 14:35:11 -07:00
parent d44912aa00
commit a38f8b65ac
2 changed files with 118 additions and 0 deletions

View File

@ -0,0 +1,100 @@
CONSOLE: TestRenderView enabled
CONSOLE:
PAINT FOR FRAME #1 ----------------------------------------------
1 | TestDisplayList() constructor: 800.0 x 600.0
------------------------------------------------------------------------
CONSOLE:
PAINT FOR FRAME #2 ----------------------------------------------
2 | TestDisplayList() constructor: 800.0 x 600.0
2 | paintChild RenderScaffold at Point(0.0, 0.0)
2 | | TestDisplayList() constructor: 800.0 x 600.0
2 | | paintChild RenderDecoratedBox at Point(0.0, 81.0)
2 | | | TestDisplayList() constructor: 800.0 x 600.0
2 | | | drawRRect(Instance of 'RRect', Paint(color:Color(0xfffafafa)))
2 | | | paintChild RenderFlex at Point(8.0, 0.0)
2 | | | | TestDisplayList() constructor: 800.0 x 600.0
2 | | | | paintChild RenderParagraph at Point(0.0, 117.5)
2 | | | | | TestDisplayList() constructor: 800.0 x 600.0
2 | | | | paintChild RenderPadding at Point(0.0, 149.5)
2 | | | | | TestDisplayList() constructor: 800.0 x 600.0
2 | | | | | paintChild RenderConstrainedBox at Point(64.0, 10.0)
2 | | | | | | TestDisplayList() constructor: 800.0 x 600.0
2 | | | | | | drawPath(Instance of 'Path', Paint(color:Color(0xff000000)))
2 | | | | | | drawPath(Instance of 'Path', Paint(color:Color(0xff000000)))
2 | | | | | | drawPath(Instance of 'Path', Paint(color:Color(0x18000000)))
2 | | | | | | drawPath(Instance of 'Path', Paint(color:Color(0xff000000)))
2 | | | | paintChild RenderParagraph at Point(0.0, 169.5)
2 | | | | | TestDisplayList() constructor: 800.0 x 600.0
2 | | | | paintChild RenderPadding at Point(0.0, 185.5)
2 | | | | | TestDisplayList() constructor: 800.0 x 600.0
2 | | | | | paintChild RenderConstrainedBox at Point(64.0, 10.0)
2 | | | | | | TestDisplayList() constructor: 800.0 x 600.0
2 | | | | | | drawPath(Instance of 'Path', Paint(color:Color(0xff000000)))
2 | | | | | | drawPath(Instance of 'Path', Paint(color:Color(0xff000000)))
2 | | | | | | drawPath(Instance of 'Path', Paint(color:Color(0x18000000)))
2 | | | | | | drawPath(Instance of 'Path', Paint(color:Color(0xff000000)))
2 | | | | paintChild RenderParagraph at Point(0.0, 205.5)
2 | | | | | TestDisplayList() constructor: 800.0 x 600.0
2 | | | | paintChild RenderPadding at Point(0.0, 221.5)
2 | | | | | TestDisplayList() constructor: 800.0 x 600.0
2 | | | | | paintChild RenderConstrainedBox at Point(64.0, 10.0)
2 | | | | | | TestDisplayList() constructor: 800.0 x 600.0
2 | | | | | | drawPath(Instance of 'Path', Paint(color:Color(0xff000000)))
2 | | | | | | drawPath(Instance of 'Path', Paint(color:Color(0xff000000)))
2 | | | | | | drawPath(Instance of 'Path', Paint(color:Color(0x18000000)))
2 | | | | | | drawPath(Instance of 'Path', Paint(color:Color(0xff000000)))
2 | | | | paintChild RenderParagraph at Point(0.0, 241.5)
2 | | | | | TestDisplayList() constructor: 800.0 x 600.0
2 | | | | paintChild RenderPadding at Point(0.0, 257.5)
2 | | | | | TestDisplayList() constructor: 800.0 x 600.0
2 | | | | | paintChild RenderConstrainedBox at Point(64.0, 10.0)
2 | | | | | | TestDisplayList() constructor: 800.0 x 600.0
2 | | | | | | drawPath(Instance of 'Path', Paint(color:Color(0xff000000)))
2 | | | | | | drawPath(Instance of 'Path', Paint(color:Color(0xff000000)))
2 | | | | | | drawPath(Instance of 'Path', Paint(color:Color(0x18000000)))
2 | | | | | | drawPath(Instance of 'Path', Paint(color:Color(0xff000000)))
2 | | | | paintChild RenderParagraph at Point(0.0, 277.5)
2 | | | | | TestDisplayList() constructor: 800.0 x 600.0
2 | | | | paintChild RenderPadding at Point(0.0, 293.5)
2 | | | | | TestDisplayList() constructor: 800.0 x 600.0
2 | | | | | paintChild RenderConstrainedBox at Point(64.0, 10.0)
2 | | | | | | TestDisplayList() constructor: 800.0 x 600.0
2 | | | | | | drawPath(Instance of 'Path', Paint(color:Color(0xff000000)))
2 | | | | | | drawPath(Instance of 'Path', Paint(color:Color(0xff000000)))
2 | | | | | | drawPath(Instance of 'Path', Paint(color:Color(0x18000000)))
2 | | | | | | drawPath(Instance of 'Path', Paint(color:Color(0xff000000)))
2 | | | | paintChild RenderParagraph at Point(0.0, 313.5)
2 | | | | | TestDisplayList() constructor: 800.0 x 600.0
2 | | | | paintChild RenderPadding at Point(0.0, 329.5)
2 | | | | | TestDisplayList() constructor: 800.0 x 600.0
2 | | | | | paintChild RenderConstrainedBox at Point(64.0, 10.0)
2 | | | | | | TestDisplayList() constructor: 800.0 x 600.0
2 | | | | | | drawPath(Instance of 'Path', Paint(color:Color(0xff000000)))
2 | | | | | | drawPath(Instance of 'Path', Paint(color:Color(0xff000000)))
2 | | | | | | drawPath(Instance of 'Path', Paint(color:Color(0x18000000)))
2 | | | | | | drawPath(Instance of 'Path', Paint(color:Color(0xff000000)))
2 | | | | paintChild RenderParagraph at Point(0.0, 349.5)
2 | | | | | TestDisplayList() constructor: 800.0 x 600.0
2 | | | | paintChild RenderPadding at Point(0.0, 365.5)
2 | | | | | TestDisplayList() constructor: 800.0 x 600.0
2 | | | | | paintChild RenderConstrainedBox at Point(64.0, 10.0)
2 | | | | | | TestDisplayList() constructor: 800.0 x 600.0
2 | | | | | | drawPath(Instance of 'Path', Paint(color:Color(0xff000000)))
2 | | | | | | drawPath(Instance of 'Path', Paint(color:Color(0xff000000)))
2 | | | | | | drawPath(Instance of 'Path', Paint(color:Color(0x18000000)))
2 | | | | | | drawPath(Instance of 'Path', Paint(color:Color(0xff000000)))
2 | | | | paintChild RenderParagraph at Point(0.0, 385.5)
2 | | | | | TestDisplayList() constructor: 800.0 x 600.0
2 | | paintChild RenderDecoratedBox at Point(0.0, 0.0)
2 | | | TestDisplayList() constructor: 800.0 x 600.0
2 | | | drawRect(Rect.fromLTRB(0.0, 0.0, 800.0, 81.0), Paint(color:Color(0xff2196f3), drawLooper:true))
2 | | | paintChild RenderFlex at Point(8.0, 0.0)
2 | | | | TestDisplayList() constructor: 800.0 x 600.0
2 | | | | paintChild RenderConstrainedBox at Point(0.0, 25.0)
2 | | | | | TestDisplayList() constructor: 800.0 x 600.0
2 | | | | | paintChild RenderPadding at Point(0.0, 16.0)
2 | | | | | | TestDisplayList() constructor: 800.0 x 600.0
2 | | | | | | paintChild RenderParagraph at Point(24.0, 0.0)
2 | | | | | | | TestDisplayList() constructor: 800.0 x 600.0
------------------------------------------------------------------------
PAINTED 2 FRAMES

View File

@ -0,0 +1,18 @@
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:async';
import 'package:sky/widgets/widget.dart';
import '../../examples/widgets/styled_text.dart';
import '../resources/display_list.dart';
main() async {
TestRenderView testRenderView = new TestRenderView();
StyledTextApp app = new StyledTextApp();
runApp(app, renderViewOverride: testRenderView);
await testRenderView.checkFrame();
testRenderView.endTest();
}