提交 92fd88b7 编写于 作者: E Eric Seidel

Fix RenderParagraph to respect text color.

I don't think this is the final API we're going to use.

I suspect we'll add a TextStyle struct to hold
color and size, etc. which back-ends into CSS like
this does today.

Currently no one uses this color even though it exists.

This is one step towards fixing:
https://github.com/domokit/mojo/issues/213

R=ianh@google.com

Review URL: https://codereview.chromium.org/1162573007
上级 903ef07a
...@@ -15,6 +15,11 @@ class Color { ...@@ -15,6 +15,11 @@ class Color {
((g & 0xff) << 8) | ((g & 0xff) << 8) |
((b & 0xff) << 0)); ((b & 0xff) << 0));
int get alpha => (0xff000000 & _value) >> 24;
int get red => (0x00ff0000 & _value) >> 16;
int get green => (0x0000ff00 & _value) >> 8;
int get blue => (0x000000ff & _value) >> 0;
bool operator ==(other) => other is Color && _value == other._value; bool operator ==(other) => other is Color && _value == other._value;
int get hashCode => _value.hashCode; int get hashCode => _value.hashCode;
......
...@@ -76,7 +76,9 @@ class RenderParagraph extends RenderBox { ...@@ -76,7 +76,9 @@ class RenderParagraph extends RenderBox {
} }
void paint(RenderObjectDisplayList canvas) { void paint(RenderObjectDisplayList canvas) {
// _layoutRoot.rootElement.style['color'] = 'rgba(' + ...color... + ')'; if (_color != null)
_layoutRoot.rootElement.style['color'] =
'rgba(${_color.red}, ${_color.green}, ${_color.blue}, ${_color.alpha / 255.0 })';
_layoutRoot.paint(canvas); _layoutRoot.paint(canvas);
} }
......
CONSOLE: unittest-suite-wait-for-done
CONSOLE: PASS: color accessors should work
CONSOLE:
CONSOLE: All 1 tests passed.
CONSOLE: unittest-suite-success
DONE
// 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:sky';
import '../resources/third_party/unittest/unittest.dart';
import '../resources/unit.dart';
void main() {
initUnit();
test("color accessors should work", () {
Color foo = new Color(0x12345678);
expect(foo.alpha, equals(0x12));
expect(foo.red, equals(0x34));
expect(foo.green, equals(0x56));
expect(foo.blue, equals(0x78));
});
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册