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 * |
(...skipping 13 matching lines...) Expand all Loading... |
24 #define LayoutTextFragment_h | 24 #define LayoutTextFragment_h |
25 | 25 |
26 #include "core/editing/EditingUtilities.h" | 26 #include "core/editing/EditingUtilities.h" |
27 #include "core/layout/LayoutText.h" | 27 #include "core/layout/LayoutText.h" |
28 #include "platform/heap/Handle.h" | 28 #include "platform/heap/Handle.h" |
29 | 29 |
30 namespace blink { | 30 namespace blink { |
31 | 31 |
32 class FirstLetterPseudoElement; | 32 class FirstLetterPseudoElement; |
33 | 33 |
34 // Used to represent a text substring of an element, e.g., for text runs that ar
e split because of | 34 // Used to represent a text substring of an element, e.g., for text runs that |
35 // first letter and that must therefore have different styles (and positions in
the layout tree). | 35 // are split because of first letter and that must therefore have different |
36 // We cache offsets so that text transformations can be applied in such a way th
at we can recover | 36 // styles (and positions in the layout tree). |
37 // the original unaltered string from our corresponding DOM node. | 37 // We cache offsets so that text transformations can be applied in such a way |
| 38 // that we can recover the original unaltered string from our corresponding DOM |
| 39 // node. |
38 class LayoutTextFragment final : public LayoutText { | 40 class LayoutTextFragment final : public LayoutText { |
39 public: | 41 public: |
40 LayoutTextFragment(Node*, StringImpl*, int startOffset, int length); | 42 LayoutTextFragment(Node*, StringImpl*, int startOffset, int length); |
41 LayoutTextFragment(Node*, StringImpl*); | 43 LayoutTextFragment(Node*, StringImpl*); |
42 ~LayoutTextFragment() override; | 44 ~LayoutTextFragment() override; |
43 | 45 |
44 bool isTextFragment() const override { return true; } | 46 bool isTextFragment() const override { return true; } |
45 | 47 |
46 bool canBeSelectionLeaf() const override { | 48 bool canBeSelectionLeaf() const override { |
47 return node() && hasEditableStyle(*node()); | 49 return node() && hasEditableStyle(*node()); |
48 } | 50 } |
49 | 51 |
50 unsigned start() const { return m_start; } | 52 unsigned start() const { return m_start; } |
51 unsigned fragmentLength() const { return m_fragmentLength; } | 53 unsigned fragmentLength() const { return m_fragmentLength; } |
52 | 54 |
53 unsigned textStartOffset() const override { return start(); } | 55 unsigned textStartOffset() const override { return start(); } |
54 | 56 |
55 void setContentString(StringImpl*); | 57 void setContentString(StringImpl*); |
56 StringImpl* contentString() const { return m_contentString.get(); } | 58 StringImpl* contentString() const { return m_contentString.get(); } |
57 // The complete text is all of the text in the associated DOM text node. | 59 // The complete text is all of the text in the associated DOM text node. |
58 PassRefPtr<StringImpl> completeText() const; | 60 PassRefPtr<StringImpl> completeText() const; |
59 // The fragment text is the text which will be used by this LayoutTextFragment
. For | 61 // The fragment text is the text which will be used by this |
60 // things like first-letter this may differ from the completeText as we maybe
using | 62 // LayoutTextFragment. For things like first-letter this may differ from the |
61 // only a portion of the text nodes content. | 63 // completeText as we maybe using only a portion of the text nodes content. |
62 | 64 |
63 PassRefPtr<StringImpl> originalText() const override; | 65 PassRefPtr<StringImpl> originalText() const override; |
64 | 66 |
65 void setText(PassRefPtr<StringImpl>, bool force = false) override; | 67 void setText(PassRefPtr<StringImpl>, bool force = false) override; |
66 void setTextFragment(PassRefPtr<StringImpl>, unsigned start, unsigned length); | 68 void setTextFragment(PassRefPtr<StringImpl>, unsigned start, unsigned length); |
67 | 69 |
68 void transformText() override; | 70 void transformText() override; |
69 | 71 |
70 // FIXME: Rename to LayoutTextFragment | 72 // FIXME: Rename to LayoutTextFragment |
71 const char* name() const override { return "LayoutTextFragment"; } | 73 const char* name() const override { return "LayoutTextFragment"; } |
(...skipping 19 matching lines...) Expand all Loading... |
91 LayoutBlock* blockForAccompanyingFirstLetter() const; | 93 LayoutBlock* blockForAccompanyingFirstLetter() const; |
92 UChar previousCharacter() const override; | 94 UChar previousCharacter() const override; |
93 | 95 |
94 Text* associatedTextNode() const; | 96 Text* associatedTextNode() const; |
95 void updateHitTestResult(HitTestResult&, const LayoutPoint&) override; | 97 void updateHitTestResult(HitTestResult&, const LayoutPoint&) override; |
96 | 98 |
97 unsigned m_start; | 99 unsigned m_start; |
98 unsigned m_fragmentLength; | 100 unsigned m_fragmentLength; |
99 bool m_isRemainingTextLayoutObject; | 101 bool m_isRemainingTextLayoutObject; |
100 RefPtr<StringImpl> m_contentString; | 102 RefPtr<StringImpl> m_contentString; |
101 // Reference back to FirstLetterPseudoElement; cleared by FirstLetterPseudoEle
ment::detachLayoutTree() if | 103 // Reference back to FirstLetterPseudoElement; cleared by |
102 // it goes away first. | 104 // FirstLetterPseudoElement::detachLayoutTree() if it goes away first. |
103 UntracedMember<FirstLetterPseudoElement> m_firstLetterPseudoElement; | 105 UntracedMember<FirstLetterPseudoElement> m_firstLetterPseudoElement; |
104 }; | 106 }; |
105 | 107 |
106 DEFINE_TYPE_CASTS(LayoutTextFragment, | 108 DEFINE_TYPE_CASTS(LayoutTextFragment, |
107 LayoutObject, | 109 LayoutObject, |
108 object, | 110 object, |
109 toLayoutText(object)->isTextFragment(), | 111 toLayoutText(object)->isTextFragment(), |
110 toLayoutText(object).isTextFragment()); | 112 toLayoutText(object).isTextFragment()); |
111 | 113 |
112 } // namespace blink | 114 } // namespace blink |
113 | 115 |
114 #endif // LayoutTextFragment_h | 116 #endif // LayoutTextFragment_h |
OLD | NEW |