#pragma once
#include "CharacterData.h"
#include "RenderPtr.h"
namespace WebCore {
class RenderText;
class Text : public CharacterData {
public:
static const unsigned defaultLengthLimit = 1 << 16;
static Ref<Text> create(Document&, const String&);
static Ref<Text> createWithLengthLimit(Document&, const String&, unsigned positionInString, unsigned lengthLimit = defaultLengthLimit);
static Ref<Text> createEditingText(Document&, const String&);
virtual ~Text();
WEBCORE_EXPORT ExceptionOr<Ref<Text>> splitText(unsigned offset);
WEBCORE_EXPORT String wholeText() const;
WEBCORE_EXPORT RefPtr<Text> replaceWholeText(const String&);
RenderPtr<RenderText> createTextRenderer(const RenderStyle&);
bool canContainRangeEndPoint() const final { return true; }
RenderText* renderer() const;
void updateRendererAfterContentChange(unsigned offsetOfReplacedData, unsigned lengthOfReplacedData);
protected:
Text(Document& document, const String& data, ConstructionType type)
: CharacterData(document, data, type)
{
}
private:
String nodeName() const override;
NodeType nodeType() const override;
Ref<Node> cloneNodeInternal(Document&, CloningOperation) override;
bool childTypeAllowed(NodeType) const override;
virtual Ref<Text> virtualCreate(const String&);
#if ENABLE(TREE_DEBUGGING)
void formatForDebugger(char* buffer, unsigned length) const override;
#endif
};
}
SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::Text)
static bool isType(const WebCore::Node& node) { return node.isTextNode(); }
SPECIALIZE_TYPE_TRAITS_END()