1/*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
20 *
21 */
22
23#ifndef Text_h
24#define Text_h
25
26#include "CharacterData.h"
27#include "RenderPtr.h"
28
29namespace WebCore {
30
31class RenderText;
32
33class Text : public CharacterData {
34public:
35 static const unsigned defaultLengthLimit = 1 << 16;
36
37 static Ref<Text> create(Document&, const String&);
38 static Ref<Text> createWithLengthLimit(Document&, const String&, unsigned positionInString, unsigned lengthLimit = defaultLengthLimit);
39 static Ref<Text> createEditingText(Document&, const String&);
40
41 virtual ~Text();
42
43 RefPtr<Text> splitText(unsigned offset, ExceptionCode&);
44
45 // DOM Level 3: http://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-1312295772
46
47 String wholeText() const;
48 RefPtr<Text> replaceWholeText(const String&, ExceptionCode&);
49
50 RenderPtr<RenderText> createTextRenderer(const RenderStyle&);
51
52 virtual bool canContainRangeEndPoint() const override final { return true; }
53
54 RenderText* renderer() const;
55
56protected:
57 Text(Document& document, const String& data, ConstructionType type)
58 : CharacterData(document, data, type)
59 {
60 }
61
62private:
63 virtual String nodeName() const override;
64 virtual NodeType nodeType() const override;
65 virtual Ref<Node> cloneNodeInternal(Document&, CloningOperation) override;
66 virtual bool childTypeAllowed(NodeType) const override;
67
68 virtual Ref<Text> virtualCreate(const String&);
69
70#if ENABLE(TREE_DEBUGGING)
71 virtual void formatForDebugger(char* buffer, unsigned length) const override;
72#endif
73};
74
75} // namespace WebCore
76
77SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::Text)
78 static bool isType(const WebCore::Node& node) { return node.isTextNode(); }
79SPECIALIZE_TYPE_TRAITS_END()
80
81#endif // Text_h
82