mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
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
This commit is contained in:
parent
903ef07abb
commit
92fd88b73f
@ -15,6 +15,11 @@ class Color {
|
||||
((g & 0xff) << 8) |
|
||||
((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;
|
||||
|
||||
int get hashCode => _value.hashCode;
|
||||
|
||||
@ -76,7 +76,9 @@ class RenderParagraph extends RenderBox {
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
6
tests/framework/color_accessors-expected.txt
Normal file
6
tests/framework/color_accessors-expected.txt
Normal file
@ -0,0 +1,6 @@
|
||||
CONSOLE: unittest-suite-wait-for-done
|
||||
CONSOLE: PASS: color accessors should work
|
||||
CONSOLE:
|
||||
CONSOLE: All 1 tests passed.
|
||||
CONSOLE: unittest-suite-success
|
||||
DONE
|
||||
19
tests/framework/color_accessors.dart
Normal file
19
tests/framework/color_accessors.dart
Normal file
@ -0,0 +1,19 @@
|
||||
// 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));
|
||||
});
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user