Adam Barth 29ab28d922 ParagraphBuilder should be able to build a paragraph
This patch start down the road of implementing text layout and painting without
the DOM. We can construct a basic paragraph consisting of a single run of text
and we can get through layout without crashing.
2015-09-11 10:23:15 -07:00

64 lines
1.9 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"
#include "sky/engine/core/rendering/RenderView.h"
namespace blink {
class Paragraph : public RefCounted<Paragraph>, public DartWrappable {
DEFINE_WRAPPERTYPEINFO();
public:
static PassRefPtr<Paragraph> create(PassOwnPtr<RenderView> renderView) {
return adoptRef(new Paragraph(renderView));
}
~Paragraph() override;
LayoutUnit minWidth() const { return m_minWidth; }
void setMinWidth(LayoutUnit width) { m_minWidth = width; }
LayoutUnit maxWidth() const { return m_maxWidth; }
void setMaxWidth(LayoutUnit width) { m_maxWidth = width; }
LayoutUnit minHeight() const { return m_minHeight; }
void setMinHeight(LayoutUnit height) { m_minHeight = height; }
LayoutUnit maxHeight() const { return m_maxHeight; }
void setMaxHeight(LayoutUnit height) { m_maxHeight = height; }
double width();
double height();
double minIntrinsicWidth();
double maxIntrinsicWidth();
double alphabeticBaseline();
double ideographicBaseline();
void layout();
void paint(Canvas* canvas, const Offset& offset);
RenderView* renderView() const { return m_renderView.get(); }
private:
LayoutUnit m_minWidth;
LayoutUnit m_maxWidth;
LayoutUnit m_minHeight;
LayoutUnit m_maxHeight;
explicit Paragraph(PassOwnPtr<RenderView> renderView);
OwnPtr<RenderView> m_renderView;
};
} // namespace blink
#endif // SKY_ENGINE_CORE_TEXT_PARAGRAPH_H_