提交 bd3a181d 编写于 作者: A Adam Barth

Remove IDL from engine/core/text

Instead, use our new template magic.
上级 f018291f
......@@ -9,6 +9,8 @@
#include "sky/engine/core/compositing/Scene.h"
#include "sky/engine/core/compositing/SceneBuilder.h"
#include "sky/engine/core/painting/painting.h"
#include "sky/engine/core/text/Paragraph.h"
#include "sky/engine/core/text/ParagraphBuilder.h"
#include "sky/engine/core/window/window.h"
#include "sky/engine/tonic/dart_converter.h"
#include "sky/engine/tonic/dart_error.h"
......@@ -40,10 +42,12 @@ void DartUI::InitForIsolate() {
if (!g_natives) {
g_natives = new DartLibraryNatives();
DartRuntimeHooks::RegisterNatives(g_natives);
Window::RegisterNatives(g_natives);
Painting::RegisterNatives(g_natives);
Paragraph::RegisterNatives(g_natives);
ParagraphBuilder::RegisterNatives(g_natives);
Scene::RegisterNatives(g_natives);
SceneBuilder::RegisterNatives(g_natives);
Window::RegisterNatives(g_natives);
}
DART_CHECK_VALID(Dart_SetNativeResolver(
......
......@@ -250,8 +250,6 @@ core_idl_files = get_path_info([
"painting/Picture.idl",
"painting/PictureRecorder.idl",
"painting/Shader.idl",
"text/Paragraph.idl",
"text/ParagraphBuilder.idl",
],
"abspath")
......
......@@ -309,16 +309,41 @@ class ParagraphStyle {
final double _lineHeight;
}
class ParagraphBuilder extends _ParagraphBuilder {
abstract class Paragraph extends NativeFieldWrapperClass2 {
double get minWidth native "Paragraph_minWidth";
void set minWidth(double value) native "Paragraph_setMinWidth";
double get maxWidth native "Paragraph_maxWidth";
void set maxWidth(double value) native "Paragraph_setMaxWidth";
double get minHeight native "Paragraph_minHeight";
void set minHeight(double value) native "Paragraph_setMinHeight";
double get maxHeight native "Paragraph_maxHeight";
void set maxHeight(double value) native "Paragraph_setMaxHeight";
double get width native "Paragraph_width";
double get height native "Paragraph_height";
double get minIntrinsicWidth native "Paragraph_minIntrinsicWidth";
double get maxIntrinsicWidth native "Paragraph_maxIntrinsicWidth";
double get alphabeticBaseline native "Paragraph_alphabeticBaseline";
double get ideographicBaseline native "Paragraph_ideographicBaseline";
void layout() native "Paragraph_layout";
void paint(Canvas canvas, Offset offset) native "Paragraph_paint";
}
class ParagraphBuilder extends NativeFieldWrapperClass2 {
void _constructor() native "ParagraphBuilder_constructor";
ParagraphBuilder() { _constructor(); }
void _pushStyle(Int32List encoded, String fontFamily, double fontSize, double letterSpacing) native "ParagraphBuilder_pushStyle";
void pushStyle(TextStyle style) {
_pushStyle(style._encoded, style._fontFamily, style._fontSize, style._letterSpacing);
}
void pop() => _pop();
void addText(String text) => _addText(text);
void pop() native "ParagraphBuilder_pop";
void addText(String text) native "ParagraphBuilder_addText";
Paragraph build(ParagraphStyle style) {
Paragraph result = _build(style._encoded, style._lineHeight);
return result;
}
Paragraph _build(Int32List encoded, double lineHeight) native "ParagraphBuilder_build";
Paragraph build(ParagraphStyle style) => _build(style._encoded, style._lineHeight);
}
......@@ -8,9 +8,35 @@
#include "sky/engine/core/rendering/style/RenderStyle.h"
#include "sky/engine/platform/fonts/FontCache.h"
#include "sky/engine/platform/graphics/GraphicsContext.h"
#include "sky/engine/tonic/dart_args.h"
#include "sky/engine/tonic/dart_binding_macros.h"
#include "sky/engine/tonic/dart_converter.h"
#include "sky/engine/tonic/dart_library_natives.h"
namespace blink {
IMPLEMENT_WRAPPERTYPEINFO(Paragraph);
#define FOR_EACH_BINDING(V) \
V(Paragraph, minWidth) \
V(Paragraph, setMinWidth) \
V(Paragraph, maxWidth) \
V(Paragraph, setMaxWidth) \
V(Paragraph, minHeight) \
V(Paragraph, setMinHeight) \
V(Paragraph, maxHeight) \
V(Paragraph, setMaxHeight) \
V(Paragraph, width) \
V(Paragraph, height) \
V(Paragraph, minIntrinsicWidth) \
V(Paragraph, maxIntrinsicWidth) \
V(Paragraph, alphabeticBaseline) \
V(Paragraph, ideographicBaseline) \
V(Paragraph, layout) \
V(Paragraph, paint)
DART_BIND_ALL(Paragraph, FOR_EACH_BINDING)
Paragraph::Paragraph(PassOwnPtr<RenderView> renderView)
: m_renderView(renderView)
{
......
......@@ -13,6 +13,7 @@
#include "sky/engine/core/rendering/RenderView.h"
namespace blink {
class DartLibraryNatives;
class Paragraph : public RefCounted<Paragraph>, public DartWrappable {
DEFINE_WRAPPERTYPEINFO();
......@@ -23,17 +24,17 @@ public:
~Paragraph() override;
LayoutUnit minWidth() const { return m_minWidth; }
void setMinWidth(LayoutUnit width) { m_minWidth = width; }
double minWidth() { return m_minWidth; }
void setMinWidth(double width) { m_minWidth = width; }
LayoutUnit maxWidth() const { return m_maxWidth; }
void setMaxWidth(LayoutUnit width) { m_maxWidth = width; }
double maxWidth() { return m_maxWidth; }
void setMaxWidth(double width) { m_maxWidth = width; }
LayoutUnit minHeight() const { return m_minHeight; }
void setMinHeight(LayoutUnit height) { m_minHeight = height; }
double minHeight() { return m_minHeight; }
void setMinHeight(double height) { m_minHeight = height; }
LayoutUnit maxHeight() const { return m_maxHeight; }
void setMaxHeight(LayoutUnit height) { m_maxHeight = height; }
double maxHeight() { return m_maxHeight; }
void setMaxHeight(double height) { m_maxHeight = height; }
double width();
double height();
......@@ -47,6 +48,8 @@ public:
RenderView* renderView() const { return m_renderView.get(); }
static void RegisterNatives(DartLibraryNatives* natives);
private:
RenderBox* firstChildBox() const { return m_renderView->firstChildBox(); }
......
// 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);
};
......@@ -9,6 +9,10 @@
#include "sky/engine/core/rendering/RenderParagraph.h"
#include "sky/engine/core/rendering/RenderText.h"
#include "sky/engine/core/rendering/style/RenderStyle.h"
#include "sky/engine/tonic/dart_args.h"
#include "sky/engine/tonic/dart_binding_macros.h"
#include "sky/engine/tonic/dart_converter.h"
#include "sky/engine/tonic/dart_library_natives.h"
namespace blink {
namespace {
......@@ -67,6 +71,27 @@ const int kLineHeightMask = 1 << kLineHeightIndex;
} // namespace
static void ParagraphBuilder_constructor(Dart_NativeArguments args) {
DartCallConstructor(&ParagraphBuilder::create, args);
}
IMPLEMENT_WRAPPERTYPEINFO(ParagraphBuilder);
#define FOR_EACH_BINDING(V) \
V(ParagraphBuilder, pushStyle) \
V(ParagraphBuilder, pop) \
V(ParagraphBuilder, addText) \
V(ParagraphBuilder, build)
FOR_EACH_BINDING(DART_NATIVE_CALLBACK)
void ParagraphBuilder::RegisterNatives(DartLibraryNatives* natives) {
natives->Register({
{ "ParagraphBuilder_constructor", ParagraphBuilder_constructor, 1, true },
FOR_EACH_BINDING(DART_REGISTER_NATIVE)
});
}
ParagraphBuilder::ParagraphBuilder()
{
m_fontSelector = CSSFontSelector::create();
......
......@@ -14,6 +14,7 @@
#include "sky/engine/wtf/RefCounted.h"
namespace blink {
class DartLibraryNatives;
class ParagraphBuilder : public RefCounted<ParagraphBuilder>, public DartWrappable {
DEFINE_WRAPPERTYPEINFO();
......@@ -31,6 +32,8 @@ public:
PassRefPtr<Paragraph> build(Int32List& encoded, double lineHeight);
static void RegisterNatives(DartLibraryNatives* natives);
private:
explicit ParagraphBuilder();
......
// 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(),
PrivateDart,
] interface ParagraphBuilder {
void pushStyle(Int32List encoded, DOMString fontFamily, double fontSize, double letterSpacing);
void pop();
void addText(DOMString text);
Paragraph build(Int32List encoded, double lineHeight);
};
......@@ -90,6 +90,11 @@ struct DartArgHolder {
: value(it->GetNext<ValueType>()) {}
};
template<typename T>
void DartReturn(T result, Dart_NativeArguments args) {
DartConverter<T>::SetReturnValue(args, result);
}
template <typename IndicesType, typename T>
class DartDispatcher {
};
......@@ -149,11 +154,6 @@ struct DartDispatcher<IndicesHolder<indices...>, ResultType (C::*)(ArgTypes...)>
}
};
template<typename T>
void DartReturn(T result, Dart_NativeArguments args) {
DartConverter<T>::SetReturnValue(args, result);
}
template<typename Sig>
void DartCall(Sig func, Dart_NativeArguments args) {
DartArgIterator it(args);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册