mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Sketch a DOM-free API for laying out and painting text
Rather than using the DOM to upload text and styling information into the engine, this patch begins sketching a more direct API that bypasses the DOM and CSS. Currently, this API doesn't do anything, but it's a first step. The approach is to have a ParagraphBuilder object that can record a tree of style interior nodes and text leaves. The build() function then applies container-level styling information (such as TextAlign) and returns a Paragraph object that can undergo layout and paint. The inputs to the builder process are immutable style objects constructed from primitive values. These primitives are currently carbon-copies of the primitive we use in the framework today. After this patch lands, I'll convert the frame to re-expose these values instead of re-defining them.
This commit is contained in:
parent
dc318408a1
commit
68b06c8736
@ -128,6 +128,13 @@ CPP_SPECIAL_CONVERSION_RULES = {
|
||||
'TransferMode': 'SkXfermode::Mode',
|
||||
'FilterQuality': 'SkFilterQuality',
|
||||
'PaintingStyle': 'SkPaint::Style',
|
||||
# TODO(abarth): Give these better C++ types.
|
||||
'FontStyle': 'int',
|
||||
'FontWeight': 'int',
|
||||
'TextAlign': 'int',
|
||||
'TextBaseline': 'int',
|
||||
'TextDecoration': 'int',
|
||||
'TextDecorationStyle': 'int',
|
||||
}
|
||||
|
||||
|
||||
@ -381,6 +388,12 @@ DART_TO_CPP_VALUE = {
|
||||
'TransferMode': pass_by_value_format('TransferMode', ''),
|
||||
'FilterQuality': pass_by_value_format('FilterQuality', ''),
|
||||
'PaintingStyle': pass_by_value_format('PaintingStyle', ''),
|
||||
'FontStyle': pass_by_value_format('FontStyle', ''),
|
||||
'FontWeight': pass_by_value_format('FontWeight', ''),
|
||||
'TextAlign': pass_by_value_format('TextAlign', ''),
|
||||
'TextBaseline': pass_by_value_format('TextBaseline', ''),
|
||||
'TextDecoration': pass_by_value_format('TextDecoration', ''),
|
||||
'TextDecorationStyle': pass_by_value_format('TextDecorationStyle', ''),
|
||||
'MojoDataPipeConsumer': pass_by_value_format('mojo::ScopedDataPipeConsumerHandle'),
|
||||
}
|
||||
|
||||
|
||||
@ -625,6 +625,20 @@ sky_core_files = [
|
||||
"script/dom_dart_state.cc",
|
||||
"script/dom_dart_state.h",
|
||||
"script/monitor.h",
|
||||
"text/FontStyle.h",
|
||||
"text/FontWeight.h",
|
||||
"text/Paragraph.cpp",
|
||||
"text/Paragraph.h",
|
||||
"text/ParagraphBuilder.cpp",
|
||||
"text/ParagraphBuilder.h",
|
||||
"text/ParagraphStyle.cpp",
|
||||
"text/ParagraphStyle.h",
|
||||
"text/TextAlign.h",
|
||||
"text/TextBaseline.h",
|
||||
"text/TextDecoration.h",
|
||||
"text/TextDecorationStyle.h",
|
||||
"text/TextStyle.cpp",
|
||||
"text/TextStyle.h",
|
||||
"view/EventCallback.h",
|
||||
"view/FrameCallback.h",
|
||||
"view/View.cpp",
|
||||
@ -690,6 +704,10 @@ core_idl_files = get_path_info([
|
||||
"painting/PictureRecorder.idl",
|
||||
"painting/RRect.idl",
|
||||
"painting/Shader.idl",
|
||||
"text/Paragraph.idl",
|
||||
"text/ParagraphBuilder.idl",
|
||||
"text/ParagraphStyle.idl",
|
||||
"text/TextStyle.idl",
|
||||
"view/EventCallback.idl",
|
||||
"view/FrameCallback.idl",
|
||||
"view/View.idl",
|
||||
@ -712,6 +730,12 @@ core_dart_files = get_path_info([
|
||||
"painting/RSTransform.dart",
|
||||
"painting/Size.dart",
|
||||
"painting/TransferMode.dart",
|
||||
"text/FontStyle.dart",
|
||||
"text/FontWeight.dart",
|
||||
"text/TextAlign.dart",
|
||||
"text/TextBaseline.dart",
|
||||
"text/TextDecoration.dart",
|
||||
"text/TextDecorationStyle.dart",
|
||||
],
|
||||
"abspath")
|
||||
|
||||
|
||||
17
sky/engine/core/text/FontStyle.dart
Normal file
17
sky/engine/core/text/FontStyle.dart
Normal file
@ -0,0 +1,17 @@
|
||||
// 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.
|
||||
|
||||
part of dart.sky;
|
||||
|
||||
/// Whether to slant the glyphs in the font
|
||||
enum FontStyle {
|
||||
/// Use the upright glyphs
|
||||
normal,
|
||||
|
||||
/// Use glyphs designed for slanting
|
||||
italic,
|
||||
|
||||
/// Use the upright glyphs but slant them during painting
|
||||
oblique // TODO(abarth): Remove. We don't really support this value.
|
||||
}
|
||||
20
sky/engine/core/text/FontStyle.h
Normal file
20
sky/engine/core/text/FontStyle.h
Normal file
@ -0,0 +1,20 @@
|
||||
// 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.
|
||||
|
||||
#ifndef SKY_ENGINE_CORE_TEXT_FONTSTYLE_H_
|
||||
#define SKY_ENGINE_CORE_TEXT_FONTSTYLE_H_
|
||||
|
||||
#include "sky/engine/tonic/dart_converter.h"
|
||||
|
||||
namespace blink {
|
||||
|
||||
class FontStyle {};
|
||||
|
||||
template <>
|
||||
struct DartConverter<FontStyle>
|
||||
: public DartConverterEnum<int> {};
|
||||
|
||||
} // namespace blink
|
||||
|
||||
#endif // SKY_ENGINE_CORE_TEXT_FONTSTYLE_H_
|
||||
35
sky/engine/core/text/FontWeight.dart
Normal file
35
sky/engine/core/text/FontWeight.dart
Normal file
@ -0,0 +1,35 @@
|
||||
// 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.
|
||||
|
||||
part of dart.sky;
|
||||
|
||||
/// The thickness of the glyphs used to draw the text
|
||||
enum FontWeight {
|
||||
/// Thin, the least thick
|
||||
w100,
|
||||
|
||||
/// Extra-light
|
||||
w200,
|
||||
|
||||
/// Light
|
||||
w300,
|
||||
|
||||
/// Normal / regular / plain
|
||||
w400,
|
||||
|
||||
/// Medium
|
||||
w500,
|
||||
|
||||
/// Semi-bold
|
||||
w600,
|
||||
|
||||
/// Bold
|
||||
w700,
|
||||
|
||||
/// Extra-bold
|
||||
w800,
|
||||
|
||||
/// Black, the most thick
|
||||
w900
|
||||
}
|
||||
20
sky/engine/core/text/FontWeight.h
Normal file
20
sky/engine/core/text/FontWeight.h
Normal file
@ -0,0 +1,20 @@
|
||||
// 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.
|
||||
|
||||
#ifndef SKY_ENGINE_CORE_TEXT_FONTWEIGHT_H_
|
||||
#define SKY_ENGINE_CORE_TEXT_FONTWEIGHT_H_
|
||||
|
||||
#include "sky/engine/tonic/dart_converter.h"
|
||||
|
||||
namespace blink {
|
||||
|
||||
class FontWeight {};
|
||||
|
||||
template <>
|
||||
struct DartConverter<FontWeight>
|
||||
: public DartConverterEnum<int> {};
|
||||
|
||||
} // namespace blink
|
||||
|
||||
#endif // SKY_ENGINE_CORE_TEXT_FONTWEIGHT_H_
|
||||
55
sky/engine/core/text/Paragraph.cpp
Normal file
55
sky/engine/core/text/Paragraph.cpp
Normal file
@ -0,0 +1,55 @@
|
||||
// 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.
|
||||
|
||||
#include "sky/engine/core/text/ParagraphBuilder.h"
|
||||
|
||||
namespace blink {
|
||||
|
||||
Paragraph::Paragraph()
|
||||
{
|
||||
}
|
||||
|
||||
Paragraph::~Paragraph()
|
||||
{
|
||||
}
|
||||
|
||||
double Paragraph::width()
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
double Paragraph::height()
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
double Paragraph::minIntrinsicWidth()
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
double Paragraph::maxIntrinsicWidth()
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
double Paragraph::alphabeticBaseline()
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
double Paragraph::ideographicBaseline()
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
void Paragraph::layout()
|
||||
{
|
||||
}
|
||||
|
||||
void Paragraph::paint(Canvas* canvas, const Offset& offset)
|
||||
{
|
||||
}
|
||||
|
||||
} // namespace blink
|
||||
58
sky/engine/core/text/Paragraph.h
Normal file
58
sky/engine/core/text/Paragraph.h
Normal file
@ -0,0 +1,58 @@
|
||||
// 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.
|
||||
|
||||
#ifndef SKY_ENGINE_CORE_TEXT_PARAGRAPH_H_
|
||||
#define SKY_ENGINE_CORE_TEXT_PARAGRAPH_H_
|
||||
|
||||
#include "sky/engine/tonic/dart_wrappable.h"
|
||||
#include "sky/engine/wtf/PassRefPtr.h"
|
||||
#include "sky/engine/wtf/RefCounted.h"
|
||||
#include "sky/engine/core/painting/Canvas.h"
|
||||
#include "sky/engine/core/painting/Offset.h"
|
||||
|
||||
namespace blink {
|
||||
|
||||
class Paragraph : public RefCounted<Paragraph>, public DartWrappable {
|
||||
DEFINE_WRAPPERTYPEINFO();
|
||||
public:
|
||||
static PassRefPtr<Paragraph> create() {
|
||||
return adoptRef(new Paragraph());
|
||||
}
|
||||
|
||||
~Paragraph() override;
|
||||
|
||||
double minWidth() const { return m_minWidth; }
|
||||
void setMinWidth(double value) { m_minWidth = value; }
|
||||
|
||||
double maxWidth() const { return m_maxWidth; }
|
||||
void setMaxWidth(double value) { m_maxWidth = value; }
|
||||
|
||||
double minHeight() const { return m_minHeight; }
|
||||
void setMinHeight(double value) { m_minHeight = value; }
|
||||
|
||||
double maxHeight() const { return m_maxHeight; }
|
||||
void setMaxHeight(double value) { m_maxHeight = value; }
|
||||
|
||||
double width();
|
||||
double height();
|
||||
double minIntrinsicWidth();
|
||||
double maxIntrinsicWidth();
|
||||
double alphabeticBaseline();
|
||||
double ideographicBaseline();
|
||||
|
||||
void layout();
|
||||
void paint(Canvas* canvas, const Offset& offset);
|
||||
|
||||
private:
|
||||
double m_minWidth;
|
||||
double m_maxWidth;
|
||||
double m_minHeight;
|
||||
double m_maxHeight;
|
||||
|
||||
explicit Paragraph();
|
||||
};
|
||||
|
||||
} // namespace blink
|
||||
|
||||
#endif // SKY_ENGINE_CORE_TEXT_PARAGRAPH_H_
|
||||
22
sky/engine/core/text/Paragraph.idl
Normal file
22
sky/engine/core/text/Paragraph.idl
Normal file
@ -0,0 +1,22 @@
|
||||
// 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.
|
||||
|
||||
interface Paragraph {
|
||||
// Inputs to layout
|
||||
attribute double minWidth;
|
||||
attribute double maxWidth;
|
||||
attribute double minHeight;
|
||||
attribute double maxHeight;
|
||||
|
||||
// Outputs from layout
|
||||
readonly attribute double width;
|
||||
readonly attribute double height;
|
||||
readonly attribute double minIntrinsicWidth; // Intrinsic width if all wrappable points wrap.
|
||||
readonly attribute double maxIntrinsicWidth; // Intrinsic width if no wrappable points wrap.
|
||||
readonly attribute double alphabeticBaseline; // Distance from top to alphabetic baseline of first line
|
||||
readonly attribute double ideographicBaseline; // Distance from top to ideographic baseline of first line
|
||||
|
||||
void layout();
|
||||
void paint(Canvas canvas, Offset offset);
|
||||
};
|
||||
34
sky/engine/core/text/ParagraphBuilder.cpp
Normal file
34
sky/engine/core/text/ParagraphBuilder.cpp
Normal file
@ -0,0 +1,34 @@
|
||||
// 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.
|
||||
|
||||
#include "sky/engine/core/text/ParagraphBuilder.h"
|
||||
|
||||
namespace blink {
|
||||
|
||||
ParagraphBuilder::ParagraphBuilder()
|
||||
{
|
||||
}
|
||||
|
||||
ParagraphBuilder::~ParagraphBuilder()
|
||||
{
|
||||
}
|
||||
|
||||
void ParagraphBuilder::pushStyle(TextStyle* style)
|
||||
{
|
||||
}
|
||||
|
||||
void ParagraphBuilder::pop()
|
||||
{
|
||||
}
|
||||
|
||||
void ParagraphBuilder::addText(const String& text)
|
||||
{
|
||||
}
|
||||
|
||||
PassRefPtr<Paragraph> ParagraphBuilder::build(ParagraphStyle* style)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
} // namespace blink
|
||||
39
sky/engine/core/text/ParagraphBuilder.h
Normal file
39
sky/engine/core/text/ParagraphBuilder.h
Normal file
@ -0,0 +1,39 @@
|
||||
// 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.
|
||||
|
||||
#ifndef SKY_ENGINE_CORE_TEXT_PARAGRAPHBUILDER_H_
|
||||
#define SKY_ENGINE_CORE_TEXT_PARAGRAPHBUILDER_H_
|
||||
|
||||
#include "sky/engine/core/text/Paragraph.h"
|
||||
#include "sky/engine/core/text/ParagraphStyle.h"
|
||||
#include "sky/engine/core/text/TextStyle.h"
|
||||
#include "sky/engine/tonic/dart_wrappable.h"
|
||||
#include "sky/engine/wtf/PassRefPtr.h"
|
||||
#include "sky/engine/wtf/RefCounted.h"
|
||||
|
||||
namespace blink {
|
||||
|
||||
class ParagraphBuilder : public RefCounted<ParagraphBuilder>, public DartWrappable {
|
||||
DEFINE_WRAPPERTYPEINFO();
|
||||
public:
|
||||
static PassRefPtr<ParagraphBuilder> create() {
|
||||
return adoptRef(new ParagraphBuilder());
|
||||
}
|
||||
|
||||
~ParagraphBuilder() override;
|
||||
|
||||
void pushStyle(TextStyle* style);
|
||||
void pop();
|
||||
|
||||
void addText(const String& text);
|
||||
|
||||
PassRefPtr<Paragraph> build(ParagraphStyle* style);
|
||||
|
||||
private:
|
||||
explicit ParagraphBuilder();
|
||||
};
|
||||
|
||||
} // namespace blink
|
||||
|
||||
#endif // SKY_ENGINE_CORE_TEXT_PARAGRAPHBUILDER_H_
|
||||
14
sky/engine/core/text/ParagraphBuilder.idl
Normal file
14
sky/engine/core/text/ParagraphBuilder.idl
Normal file
@ -0,0 +1,14 @@
|
||||
// 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.
|
||||
|
||||
[
|
||||
Constructor(),
|
||||
] interface ParagraphBuilder {
|
||||
void pushStyle(TextStyle style);
|
||||
void pop();
|
||||
|
||||
void addText(DOMString text);
|
||||
|
||||
Paragraph build(ParagraphStyle style);
|
||||
};
|
||||
17
sky/engine/core/text/ParagraphStyle.cpp
Normal file
17
sky/engine/core/text/ParagraphStyle.cpp
Normal file
@ -0,0 +1,17 @@
|
||||
// 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.
|
||||
|
||||
#include "sky/engine/core/text/ParagraphStyle.h"
|
||||
|
||||
namespace blink {
|
||||
|
||||
ParagraphStyle::ParagraphStyle(int align, double lineHeight, int textBaseline)
|
||||
{
|
||||
}
|
||||
|
||||
ParagraphStyle::~ParagraphStyle()
|
||||
{
|
||||
}
|
||||
|
||||
} // namespace blink
|
||||
31
sky/engine/core/text/ParagraphStyle.h
Normal file
31
sky/engine/core/text/ParagraphStyle.h
Normal file
@ -0,0 +1,31 @@
|
||||
// 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.
|
||||
|
||||
#ifndef SKY_ENGINE_CORE_TEXT_PARAGRAPHSTYLE_H_
|
||||
#define SKY_ENGINE_CORE_TEXT_PARAGRAPHSTYLE_H_
|
||||
|
||||
#include "sky/engine/core/text/TextAlign.h"
|
||||
#include "sky/engine/core/text/TextBaseline.h"
|
||||
#include "sky/engine/tonic/dart_wrappable.h"
|
||||
#include "sky/engine/wtf/PassRefPtr.h"
|
||||
#include "sky/engine/wtf/RefCounted.h"
|
||||
|
||||
namespace blink {
|
||||
|
||||
class ParagraphStyle : public RefCounted<ParagraphStyle>, public DartWrappable {
|
||||
DEFINE_WRAPPERTYPEINFO();
|
||||
public:
|
||||
static PassRefPtr<ParagraphStyle> create(int align = 0, double lineHeight = 0.0, int textBaseline = 0) {
|
||||
return adoptRef(new ParagraphStyle(align, lineHeight, textBaseline));
|
||||
}
|
||||
|
||||
~ParagraphStyle() override;
|
||||
|
||||
private:
|
||||
explicit ParagraphStyle(int align, double lineHeight, int textBaseline);
|
||||
};
|
||||
|
||||
} // namespace blink
|
||||
|
||||
#endif // SKY_ENGINE_CORE_TEXT_PARAGRAPHSTYLE_H_
|
||||
12
sky/engine/core/text/ParagraphStyle.idl
Normal file
12
sky/engine/core/text/ParagraphStyle.idl
Normal file
@ -0,0 +1,12 @@
|
||||
// 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.
|
||||
|
||||
[
|
||||
Constructor(
|
||||
[Named] optional TextAlign align,
|
||||
[Named] optional double lineHeight,
|
||||
[Named] optional TextBaseline textBaseline
|
||||
)
|
||||
] interface ParagraphStyle {
|
||||
};
|
||||
17
sky/engine/core/text/TextAlign.dart
Normal file
17
sky/engine/core/text/TextAlign.dart
Normal file
@ -0,0 +1,17 @@
|
||||
// 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.
|
||||
|
||||
part of dart.sky;
|
||||
|
||||
/// Whether to align text horizontally
|
||||
enum TextAlign {
|
||||
/// Align the text on the left edge of the container
|
||||
left,
|
||||
|
||||
/// Align the text on the right edge of the container
|
||||
right,
|
||||
|
||||
/// Align the text in the center of the container
|
||||
center
|
||||
}
|
||||
20
sky/engine/core/text/TextAlign.h
Normal file
20
sky/engine/core/text/TextAlign.h
Normal file
@ -0,0 +1,20 @@
|
||||
// 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.
|
||||
|
||||
#ifndef SKY_ENGINE_CORE_TEXT_TEXTALIGN_H_
|
||||
#define SKY_ENGINE_CORE_TEXT_TEXTALIGN_H_
|
||||
|
||||
#include "sky/engine/tonic/dart_converter.h"
|
||||
|
||||
namespace blink {
|
||||
|
||||
class TextAlign {};
|
||||
|
||||
template <>
|
||||
struct DartConverter<TextAlign>
|
||||
: public DartConverterEnum<int> {};
|
||||
|
||||
} // namespace blink
|
||||
|
||||
#endif // SKY_ENGINE_CORE_TEXT_TEXTALIGN_H_
|
||||
14
sky/engine/core/text/TextBaseline.dart
Normal file
14
sky/engine/core/text/TextBaseline.dart
Normal file
@ -0,0 +1,14 @@
|
||||
// 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.
|
||||
|
||||
part of dart.sky;
|
||||
|
||||
/// A horizontal line used for aligning text
|
||||
enum TextBaseline {
|
||||
// The horizontal line used to align the bottom of glyphs for alphabetic characters
|
||||
alphabetic,
|
||||
|
||||
// The horizontal line used to align ideographic characters
|
||||
ideographic
|
||||
}
|
||||
20
sky/engine/core/text/TextBaseline.h
Normal file
20
sky/engine/core/text/TextBaseline.h
Normal file
@ -0,0 +1,20 @@
|
||||
// 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.
|
||||
|
||||
#ifndef SKY_ENGINE_CORE_TEXT_TEXTBASELINE_H_
|
||||
#define SKY_ENGINE_CORE_TEXT_TEXTBASELINE_H_
|
||||
|
||||
#include "sky/engine/tonic/dart_converter.h"
|
||||
|
||||
namespace blink {
|
||||
|
||||
class TextBaseline {};
|
||||
|
||||
template <>
|
||||
struct DartConverter<TextBaseline>
|
||||
: public DartConverterEnum<int> {};
|
||||
|
||||
} // namespace blink
|
||||
|
||||
#endif // SKY_ENGINE_CORE_TEXT_TEXTALIGN_H_
|
||||
20
sky/engine/core/text/TextDecoration.dart
Normal file
20
sky/engine/core/text/TextDecoration.dart
Normal file
@ -0,0 +1,20 @@
|
||||
// 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.
|
||||
|
||||
part of dart.sky;
|
||||
|
||||
/// A linear decoration to draw near the text
|
||||
enum TextDecoration {
|
||||
/// Do not draw a decoration
|
||||
none,
|
||||
|
||||
/// Draw a line underneath each line of text
|
||||
underline,
|
||||
|
||||
/// Draw a line above each line of text
|
||||
overline,
|
||||
|
||||
/// Draw a line through each line of text
|
||||
lineThrough
|
||||
}
|
||||
19
sky/engine/core/text/TextDecoration.h
Normal file
19
sky/engine/core/text/TextDecoration.h
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.
|
||||
|
||||
#ifndef SKY_ENGINE_CORE_TEXT_TEXTDECORATION_H_
|
||||
#define SKY_ENGINE_CORE_TEXT_TEXTDECORATION_H_
|
||||
|
||||
#include "sky/engine/core/rendering/style/RenderStyleConstants.h"
|
||||
#include "sky/engine/tonic/dart_converter.h"
|
||||
|
||||
namespace blink {
|
||||
|
||||
template <>
|
||||
struct DartConverter<TextDecoration>
|
||||
: public DartConverterEnum<int> {};
|
||||
|
||||
} // namespace blink
|
||||
|
||||
#endif // SKY_ENGINE_CORE_TEXT_TEXTDECORATION_H_
|
||||
23
sky/engine/core/text/TextDecorationStyle.dart
Normal file
23
sky/engine/core/text/TextDecorationStyle.dart
Normal file
@ -0,0 +1,23 @@
|
||||
// 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.
|
||||
|
||||
part of dart.sky;
|
||||
|
||||
/// The style in which to draw a text decoration
|
||||
enum TextDecorationStyle {
|
||||
/// Draw a solid line
|
||||
solid,
|
||||
|
||||
/// Draw two lines
|
||||
double,
|
||||
|
||||
/// Draw a dotted line
|
||||
dotted,
|
||||
|
||||
/// Draw a dashed line
|
||||
dashed,
|
||||
|
||||
/// Draw a sinusoidal line
|
||||
wavy
|
||||
}
|
||||
19
sky/engine/core/text/TextDecorationStyle.h
Normal file
19
sky/engine/core/text/TextDecorationStyle.h
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.
|
||||
|
||||
#ifndef SKY_ENGINE_CORE_TEXT_TEXTDECORATIONSTYLE_H_
|
||||
#define SKY_ENGINE_CORE_TEXT_TEXTDECORATIONSTYLE_H_
|
||||
|
||||
#include "sky/engine/core/rendering/style/RenderStyleConstants.h"
|
||||
#include "sky/engine/tonic/dart_converter.h"
|
||||
|
||||
namespace blink {
|
||||
|
||||
template <>
|
||||
struct DartConverter<TextDecorationStyle>
|
||||
: public DartConverterEnum<int> {};
|
||||
|
||||
} // namespace blink
|
||||
|
||||
#endif // SKY_ENGINE_CORE_TEXT_TEXTDECORATIONSTYLE_H_
|
||||
25
sky/engine/core/text/TextStyle.cpp
Normal file
25
sky/engine/core/text/TextStyle.cpp
Normal file
@ -0,0 +1,25 @@
|
||||
// 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.
|
||||
|
||||
#include "sky/engine/core/text/TextStyle.h"
|
||||
|
||||
namespace blink {
|
||||
|
||||
TextStyle::TextStyle(
|
||||
SkColor color,
|
||||
const String& fontFamily,
|
||||
double fontSize,
|
||||
int fontWeight,
|
||||
int fontStyle,
|
||||
const Vector<int>& decoration,
|
||||
SkColor decorationColor,
|
||||
int decorationStyle)
|
||||
{
|
||||
}
|
||||
|
||||
TextStyle::~TextStyle()
|
||||
{
|
||||
}
|
||||
|
||||
} // namespace blink
|
||||
62
sky/engine/core/text/TextStyle.h
Normal file
62
sky/engine/core/text/TextStyle.h
Normal file
@ -0,0 +1,62 @@
|
||||
// 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.
|
||||
|
||||
#ifndef SKY_ENGINE_CORE_TEXT_TEXTSTYLE_H_
|
||||
#define SKY_ENGINE_CORE_TEXT_TEXTSTYLE_H_
|
||||
|
||||
#include "sky/engine/core/painting/CanvasColor.h"
|
||||
#include "sky/engine/core/text/FontStyle.h"
|
||||
#include "sky/engine/core/text/FontWeight.h"
|
||||
#include "sky/engine/core/text/TextDecoration.h"
|
||||
#include "sky/engine/core/text/TextDecorationStyle.h"
|
||||
#include "sky/engine/tonic/dart_wrappable.h"
|
||||
#include "sky/engine/wtf/PassRefPtr.h"
|
||||
#include "sky/engine/wtf/RefCounted.h"
|
||||
#include "sky/engine/wtf/Vector.h"
|
||||
|
||||
namespace blink {
|
||||
|
||||
class TextStyle : public RefCounted<TextStyle>, public DartWrappable {
|
||||
DEFINE_WRAPPERTYPEINFO();
|
||||
public:
|
||||
static PassRefPtr<TextStyle> create(
|
||||
SkColor color = SK_ColorWHITE,
|
||||
const String& fontFamily = nullAtom,
|
||||
double fontSize = 0.0,
|
||||
int fontWeight = 0,
|
||||
int fontStyle = 0,
|
||||
const Vector<int>& decoration = Vector<int>(),
|
||||
SkColor decorationColor = SK_ColorWHITE,
|
||||
int decorationStyle = 0
|
||||
) {
|
||||
return adoptRef(new TextStyle(
|
||||
color,
|
||||
fontFamily,
|
||||
fontSize,
|
||||
fontWeight,
|
||||
fontStyle,
|
||||
decoration,
|
||||
decorationColor,
|
||||
decorationStyle
|
||||
));
|
||||
}
|
||||
|
||||
~TextStyle() override;
|
||||
|
||||
private:
|
||||
explicit TextStyle(
|
||||
SkColor color,
|
||||
const String& fontFamily,
|
||||
double fontSize,
|
||||
int fontWeight,
|
||||
int fontStyle,
|
||||
const Vector<int>& decoration,
|
||||
SkColor decorationColor,
|
||||
int decorationStyle
|
||||
);
|
||||
};
|
||||
|
||||
} // namespace blink
|
||||
|
||||
#endif // SKY_ENGINE_CORE_TEXT_TEXTSTYLE_H_
|
||||
17
sky/engine/core/text/TextStyle.idl
Normal file
17
sky/engine/core/text/TextStyle.idl
Normal file
@ -0,0 +1,17 @@
|
||||
// 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.
|
||||
|
||||
[
|
||||
Constructor(
|
||||
[Named] optional Color color,
|
||||
[Named] optional DOMString fontFamily,
|
||||
[Named] optional double fontSize,
|
||||
[Named] optional FontWeight fontWeight,
|
||||
[Named] optional FontStyle fontStyle,
|
||||
[Named] optional sequence<TextDecoration> decoration,
|
||||
[Named] optional Color decorationColor,
|
||||
[Named] optional TextDecorationStyle decorationStyle
|
||||
)
|
||||
] interface TextStyle {
|
||||
};
|
||||
Loading…
x
Reference in New Issue
Block a user