OLD | NEW |
1 /* | 1 /* |
2 * (C) 1999 Lars Knoll (knoll@kde.org) | 2 * (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 2000 Dirk Mueller (mueller@kde.org) | 3 * (C) 2000 Dirk Mueller (mueller@kde.org) |
4 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. | 4 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. |
5 * | 5 * |
6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
10 * | 10 * |
11 * This library is distributed in the hope that it will be useful, | 11 * This library is distributed in the hope that it will be useful, |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 * Library General Public License for more details. | 14 * Library General Public License for more details. |
15 * | 15 * |
16 * You should have received a copy of the GNU Library General Public License | 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 | 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, | 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
19 * Boston, MA 02110-1301, USA. | 19 * Boston, MA 02110-1301, USA. |
20 * | 20 * |
21 */ | 21 */ |
22 | 22 |
23 #ifndef RenderTextFragment_h | 23 #ifndef LayoutTextFragment_h |
24 #define RenderTextFragment_h | 24 #define LayoutTextFragment_h |
25 | 25 |
26 #include "core/rendering/RenderText.h" | 26 #include "core/layout/LayoutText.h" |
27 | 27 |
28 namespace blink { | 28 namespace blink { |
29 | 29 |
30 class FirstLetterPseudoElement; | 30 class FirstLetterPseudoElement; |
31 | 31 |
32 // Used to represent a text substring of an element, e.g., for text runs that ar
e split because of | 32 // Used to represent a text substring of an element, e.g., for text runs that ar
e split because of |
33 // first letter and that must therefore have different styles (and positions in
the render tree). | 33 // first letter and that must therefore have different styles (and positions in
the render tree). |
34 // We cache offsets so that text transformations can be applied in such a way th
at we can recover | 34 // We cache offsets so that text transformations can be applied in such a way th
at we can recover |
35 // the original unaltered string from our corresponding DOM node. | 35 // the original unaltered string from our corresponding DOM node. |
36 class RenderTextFragment final : public RenderText { | 36 class LayoutTextFragment final : public LayoutText { |
37 public: | 37 public: |
38 RenderTextFragment(Node*, StringImpl*, int startOffset, int length); | 38 LayoutTextFragment(Node*, StringImpl*, int startOffset, int length); |
39 RenderTextFragment(Node*, StringImpl*); | 39 LayoutTextFragment(Node*, StringImpl*); |
40 virtual ~RenderTextFragment(); | 40 virtual ~LayoutTextFragment(); |
41 virtual void destroy() override; | 41 virtual void destroy() override; |
42 | 42 |
43 virtual bool isTextFragment() const override { return true; } | 43 virtual bool isTextFragment() const override { return true; } |
44 | 44 |
45 virtual bool canBeSelectionLeaf() const override { return node() && node()->
hasEditableStyle(); } | 45 virtual bool canBeSelectionLeaf() const override { return node() && node()->
hasEditableStyle(); } |
46 | 46 |
47 unsigned start() const { return m_start; } | 47 unsigned start() const { return m_start; } |
48 unsigned end() const { return m_end; } | 48 unsigned end() const { return m_end; } |
49 | 49 |
50 virtual unsigned textStartOffset() const override { return start(); } | 50 virtual unsigned textStartOffset() const override { return start(); } |
51 | 51 |
52 void setContentString(StringImpl*); | 52 void setContentString(StringImpl*); |
53 StringImpl* contentString() const { return m_contentString.get(); } | 53 StringImpl* contentString() const { return m_contentString.get(); } |
54 // The complete text is all of the text in the associated DOM text node. | 54 // The complete text is all of the text in the associated DOM text node. |
55 PassRefPtr<StringImpl> completeText() const; | 55 PassRefPtr<StringImpl> completeText() const; |
56 // The fragment text is the text which will be used by this RenderTextFragme
nt. For | 56 // The fragment text is the text which will be used by this LayoutTextFragme
nt. For |
57 // things like first-letter this may differ from the completeText as we mayb
e using | 57 // things like first-letter this may differ from the completeText as we mayb
e using |
58 // only a portion of the text nodes content. | 58 // only a portion of the text nodes content. |
59 | 59 |
60 virtual PassRefPtr<StringImpl> originalText() const override; | 60 virtual PassRefPtr<StringImpl> originalText() const override; |
61 | 61 |
62 virtual void setText(PassRefPtr<StringImpl>, bool force = false) override; | 62 virtual void setText(PassRefPtr<StringImpl>, bool force = false) override; |
63 void setTextFragment(PassRefPtr<StringImpl>, unsigned start, unsigned length
); | 63 void setTextFragment(PassRefPtr<StringImpl>, unsigned start, unsigned length
); |
64 | 64 |
65 virtual void transformText() override; | 65 virtual void transformText() override; |
66 | 66 |
| 67 // FIXME: Rename to LayoutTextFragment |
67 virtual const char* renderName() const override final { return "RenderTextFr
agment"; } | 68 virtual const char* renderName() const override final { return "RenderTextFr
agment"; } |
68 | 69 |
69 void setFirstLetterPseudoElement(FirstLetterPseudoElement* element) { m_firs
tLetterPseudoElement = element; } | 70 void setFirstLetterPseudoElement(FirstLetterPseudoElement* element) { m_firs
tLetterPseudoElement = element; } |
70 FirstLetterPseudoElement* firstLetterPseudoElement() const { return m_firstL
etterPseudoElement; } | 71 FirstLetterPseudoElement* firstLetterPseudoElement() const { return m_firstL
etterPseudoElement; } |
71 | 72 |
72 void setIsRemainingTextRenderer(bool isRemainingText) { m_isRemainingTextRen
derer = isRemainingText; } | 73 void setIsRemainingTextRenderer(bool isRemainingText) { m_isRemainingTextRen
derer = isRemainingText; } |
73 bool isRemainingTextRenderer() const { return m_isRemainingTextRenderer; } | 74 bool isRemainingTextRenderer() const { return m_isRemainingTextRenderer; } |
74 | 75 |
75 private: | 76 private: |
76 LayoutBlock* blockForAccompanyingFirstLetter() const; | 77 LayoutBlock* blockForAccompanyingFirstLetter() const; |
77 virtual UChar previousCharacter() const override; | 78 virtual UChar previousCharacter() const override; |
78 | 79 |
79 Text* associatedTextNode() const; | 80 Text* associatedTextNode() const; |
80 | 81 |
81 unsigned m_start; | 82 unsigned m_start; |
82 unsigned m_end; | 83 unsigned m_end; |
83 bool m_isRemainingTextRenderer; | 84 bool m_isRemainingTextRenderer; |
84 RefPtr<StringImpl> m_contentString; | 85 RefPtr<StringImpl> m_contentString; |
85 // Reference back to FirstLetterPseudoElement; cleared by FirstLetterPseudoE
lement::detach() if | 86 // Reference back to FirstLetterPseudoElement; cleared by FirstLetterPseudoE
lement::detach() if |
86 // it goes away first. | 87 // it goes away first. |
87 FirstLetterPseudoElement* m_firstLetterPseudoElement; | 88 FirstLetterPseudoElement* m_firstLetterPseudoElement; |
88 }; | 89 }; |
89 | 90 |
90 DEFINE_TYPE_CASTS(RenderTextFragment, LayoutObject, object, toRenderText(object)
->isTextFragment(), toRenderText(object).isTextFragment()); | 91 DEFINE_TYPE_CASTS(LayoutTextFragment, LayoutObject, object, toLayoutText(object)
->isTextFragment(), toLayoutText(object).isTextFragment()); |
91 | 92 |
92 } // namespace blink | 93 } // namespace blink |
93 | 94 |
94 #endif // RenderTextFragment_h | 95 #endif // LayoutTextFragment_h |
OLD | NEW |