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 RenderTextFragment_h |
24 #define RenderTextFragment_h | 24 #define RenderTextFragment_h |
25 | 25 |
26 #include "core/rendering/RenderText.h" | 26 #include "core/rendering/RenderText.h" |
27 | 27 |
28 namespace blink { | 28 namespace blink { |
29 | 29 |
30 class FirstLetterPseudoElement; | |
31 | |
32 // Used to represent a text substring of an element, e.g., for text runs that ar
e split because of | 30 // 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). | 31 // 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 | 32 // 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. | 33 // the original unaltered string from our corresponding DOM node. |
36 class RenderTextFragment final : public RenderText { | 34 class RenderTextFragment final : public RenderText { |
37 public: | 35 public: |
38 RenderTextFragment(Node*, StringImpl*, int startOffset, int length); | 36 RenderTextFragment(Node*, StringImpl*, int startOffset, int length); |
39 RenderTextFragment(Node*, StringImpl*); | 37 RenderTextFragment(Node*, StringImpl*); |
40 virtual ~RenderTextFragment(); | 38 virtual ~RenderTextFragment(); |
41 virtual void trace(Visitor*) override; | 39 virtual void trace(Visitor*) override; |
42 virtual void destroy() override; | |
43 | 40 |
44 virtual bool isTextFragment() const override { return true; } | 41 virtual bool isTextFragment() const override { return true; } |
45 | 42 |
46 virtual bool canBeSelectionLeaf() const override { return node() && node()->
hasEditableStyle(); } | 43 virtual bool canBeSelectionLeaf() const override { return node() && node()->
hasEditableStyle(); } |
47 | 44 |
48 unsigned start() const { return m_start; } | 45 unsigned start() const { return m_start; } |
49 unsigned end() const { return m_end; } | 46 unsigned end() const { return m_end; } |
50 virtual unsigned textStartOffset() const override { return start(); } | 47 virtual unsigned textStartOffset() const override { return start(); } |
51 | 48 |
| 49 RenderBoxModelObject* firstLetter() const { return m_firstLetter; } |
| 50 void setFirstLetter(RenderBoxModelObject* firstLetter) { m_firstLetter = fir
stLetter; } |
| 51 RenderText* firstRenderTextInFirstLetter() const; |
| 52 |
52 StringImpl* contentString() const { return m_contentString.get(); } | 53 StringImpl* contentString() const { return m_contentString.get(); } |
53 // The complete text is all of the text in the associated DOM text node. | |
54 PassRefPtr<StringImpl> completeText() const; | |
55 // The fragment text is the text which will be used by this RenderTextFragme
nt. For | |
56 // things like first-letter this may differ from the completeText as we mayb
e using | |
57 // only a portion of the text nodes content. | |
58 virtual PassRefPtr<StringImpl> originalText() const override; | 54 virtual PassRefPtr<StringImpl> originalText() const override; |
59 | 55 |
60 virtual void setText(PassRefPtr<StringImpl>, bool force = false) override; | 56 virtual void setText(PassRefPtr<StringImpl>, bool force = false) override; |
61 | 57 |
62 virtual void transformText() override; | 58 virtual void transformText() override; |
63 | 59 |
64 virtual const char* renderName() const override final { return "RenderTextFr
agment"; } | 60 virtual const char* renderName() const override final { return "RenderTextFr
agment"; } |
65 | 61 |
66 void setFirstLetterPseudoElement(FirstLetterPseudoElement* element) { m_firs
tLetterPseudoElement = element; } | 62 protected: |
67 FirstLetterPseudoElement* firstLetterPseudoElement() const { return m_firstL
etterPseudoElement; } | 63 virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle) ov
erride; |
68 | |
69 void setIsRemainingTextRenderer() { m_isRemainingTextRenderer = true; } | |
70 bool isRemainingTextRenderer() const { return m_isRemainingTextRenderer; } | |
71 | 64 |
72 private: | 65 private: |
| 66 virtual void willBeDestroyed() override; |
| 67 |
| 68 virtual UChar previousCharacter() const override; |
73 RenderBlock* blockForAccompanyingFirstLetter() const; | 69 RenderBlock* blockForAccompanyingFirstLetter() const; |
74 virtual UChar previousCharacter() const override; | 70 virtual void updateHitTestResult(HitTestResult&, const LayoutPoint&) overrid
e; |
75 | |
76 Text* associatedTextNode() const; | |
77 | 71 |
78 unsigned m_start; | 72 unsigned m_start; |
79 unsigned m_end; | 73 unsigned m_end; |
80 bool m_isRemainingTextRenderer; | |
81 RefPtr<StringImpl> m_contentString; | 74 RefPtr<StringImpl> m_contentString; |
82 RawPtrWillBeMember<FirstLetterPseudoElement> m_firstLetterPseudoElement; | 75 RawPtrWillBeMember<RenderBoxModelObject> m_firstLetter; |
83 }; | 76 }; |
84 | 77 |
85 DEFINE_TYPE_CASTS(RenderTextFragment, RenderObject, object, toRenderText(object)
->isTextFragment(), toRenderText(object).isTextFragment()); | 78 DEFINE_TYPE_CASTS(RenderTextFragment, RenderObject, object, toRenderText(object)
->isTextFragment(), toRenderText(object).isTextFragment()); |
86 | 79 |
87 } // namespace blink | 80 } // namespace blink |
88 | 81 |
89 #endif // RenderTextFragment_h | 82 #endif // RenderTextFragment_h |
OLD | NEW |