Adam Barth 68b06c8736 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.
2015-09-02 01:28:54 -07:00

59 lines
1.6 KiB
C++

// 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_