flutter_flutter/sky/engine/core/text/ParagraphBuilder.h
Adam Barth 0140555b54 Remove integration between tonic and WTFString
We used to share memory between Dart strings and WTF::String objects by
way of the Dart externalized strings. That used to be important when the
DOM shared many strings between C++ and Dart. However, now that we don't
retain strings in C++ much anymore, we don't need this complexity.

This patch removes DartStringCache and the integration. It also unwinds
several cases where we were converting back and forth between
WTF::String and std::string for no reason. Now we use std::string more
consistently.

For the case of ParagraphBuilder::addText, we now take a raw const
char*, which more closely matches the API the DartVM exposes. That means
we do a single copy out of the VM and into the render tree at that
point.
2016-01-18 20:47:46 -08:00

48 lines
1.4 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_PARAGRAPHBUILDER_H_
#define SKY_ENGINE_CORE_TEXT_PARAGRAPHBUILDER_H_
#include "sky/engine/core/text/Paragraph.h"
#include "sky/engine/tonic/dart_wrappable.h"
#include "sky/engine/tonic/int32_list.h"
#include "sky/engine/wtf/PassRefPtr.h"
#include "sky/engine/wtf/RefCounted.h"
namespace blink {
class DartLibraryNatives;
class ParagraphBuilder : public RefCounted<ParagraphBuilder>, public DartWrappable {
DEFINE_WRAPPERTYPEINFO();
public:
static PassRefPtr<ParagraphBuilder> create() {
return adoptRef(new ParagraphBuilder());
}
~ParagraphBuilder() override;
void pushStyle(Int32List& encoded, const std::string& fontFamily, double fontSize, double letterSpacing, double wordSpacing, double lineHeight);
void pop();
void addText(const std::string& text);
PassRefPtr<Paragraph> build(Int32List& encoded, double lineHeight);
static void RegisterNatives(DartLibraryNatives* natives);
private:
explicit ParagraphBuilder();
void createRenderView();
OwnPtr<RenderView> m_renderView;
RenderObject* m_renderParagraph;
RenderObject* m_currentRenderObject;
};
} // namespace blink
#endif // SKY_ENGINE_CORE_TEXT_PARAGRAPHBUILDER_H_