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 19 matching lines...) Expand all Loading... |
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 layout tree). | 33 // first letter and that must therefore have different styles (and positions in
the layout 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 LayoutTextFragment final : public LayoutText { | 36 class LayoutTextFragment final : public LayoutText { |
37 public: | 37 public: |
38 LayoutTextFragment(Node*, StringImpl*, int startOffset, int length); | 38 LayoutTextFragment(Node*, StringImpl*, int startOffset, int length); |
39 LayoutTextFragment(Node*, StringImpl*); | 39 LayoutTextFragment(Node*, StringImpl*); |
40 virtual ~LayoutTextFragment(); | 40 ~LayoutTextFragment() override; |
41 | 41 |
42 virtual bool isTextFragment() const override { return true; } | 42 bool isTextFragment() const override { return true; } |
43 | 43 |
44 virtual bool canBeSelectionLeaf() const override { return node() && node()->
hasEditableStyle(); } | 44 bool canBeSelectionLeaf() const override { return node() && node()->hasEdita
bleStyle(); } |
45 | 45 |
46 unsigned start() const { return m_start; } | 46 unsigned start() const { return m_start; } |
47 unsigned end() const { return m_end; } | 47 unsigned end() const { return m_end; } |
48 | 48 |
49 virtual unsigned textStartOffset() const override { return start(); } | 49 unsigned textStartOffset() const override { return start(); } |
50 | 50 |
51 void setContentString(StringImpl*); | 51 void setContentString(StringImpl*); |
52 StringImpl* contentString() const { return m_contentString.get(); } | 52 StringImpl* contentString() const { return m_contentString.get(); } |
53 // The complete text is all of the text in the associated DOM text node. | 53 // The complete text is all of the text in the associated DOM text node. |
54 PassRefPtr<StringImpl> completeText() const; | 54 PassRefPtr<StringImpl> completeText() const; |
55 // The fragment text is the text which will be used by this LayoutTextFragme
nt. For | 55 // The fragment text is the text which will be used by this LayoutTextFragme
nt. For |
56 // things like first-letter this may differ from the completeText as we mayb
e using | 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. | 57 // only a portion of the text nodes content. |
58 | 58 |
59 virtual PassRefPtr<StringImpl> originalText() const override; | 59 PassRefPtr<StringImpl> originalText() const override; |
60 | 60 |
61 virtual void setText(PassRefPtr<StringImpl>, bool force = false) override; | 61 void setText(PassRefPtr<StringImpl>, bool force = false) override; |
62 void setTextFragment(PassRefPtr<StringImpl>, unsigned start, unsigned length
); | 62 void setTextFragment(PassRefPtr<StringImpl>, unsigned start, unsigned length
); |
63 | 63 |
64 virtual void transformText() override; | 64 void transformText() override; |
65 | 65 |
66 // FIXME: Rename to LayoutTextFragment | 66 // FIXME: Rename to LayoutTextFragment |
67 virtual const char* name() const override { return "LayoutTextFragment"; } | 67 const char* name() const override { return "LayoutTextFragment"; } |
68 | 68 |
69 void setFirstLetterPseudoElement(FirstLetterPseudoElement* element) { m_firs
tLetterPseudoElement = element; } | 69 void setFirstLetterPseudoElement(FirstLetterPseudoElement* element) { m_firs
tLetterPseudoElement = element; } |
70 FirstLetterPseudoElement* firstLetterPseudoElement() const { return m_firstL
etterPseudoElement; } | 70 FirstLetterPseudoElement* firstLetterPseudoElement() const { return m_firstL
etterPseudoElement; } |
71 | 71 |
72 void setIsRemainingTextLayoutObject(bool isRemainingText) { m_isRemainingTex
tLayoutObject = isRemainingText; } | 72 void setIsRemainingTextLayoutObject(bool isRemainingText) { m_isRemainingTex
tLayoutObject = isRemainingText; } |
73 bool isRemainingTextLayoutObject() const { return m_isRemainingTextLayoutObj
ect; } | 73 bool isRemainingTextLayoutObject() const { return m_isRemainingTextLayoutObj
ect; } |
74 | 74 |
75 protected: | 75 protected: |
76 virtual void willBeDestroyed() override; | 76 void willBeDestroyed() override; |
77 | 77 |
78 private: | 78 private: |
79 LayoutBlock* blockForAccompanyingFirstLetter() const; | 79 LayoutBlock* blockForAccompanyingFirstLetter() const; |
80 virtual UChar previousCharacter() const override; | 80 UChar previousCharacter() const override; |
81 | 81 |
82 Text* associatedTextNode() const; | 82 Text* associatedTextNode() const; |
83 void updateHitTestResult(HitTestResult&, const LayoutPoint&) override; | 83 void updateHitTestResult(HitTestResult&, const LayoutPoint&) override; |
84 | 84 |
85 unsigned m_start; | 85 unsigned m_start; |
86 unsigned m_end; | 86 unsigned m_end; |
87 bool m_isRemainingTextLayoutObject; | 87 bool m_isRemainingTextLayoutObject; |
88 RefPtr<StringImpl> m_contentString; | 88 RefPtr<StringImpl> m_contentString; |
89 // Reference back to FirstLetterPseudoElement; cleared by FirstLetterPseudoE
lement::detach() if | 89 // Reference back to FirstLetterPseudoElement; cleared by FirstLetterPseudoE
lement::detach() if |
90 // it goes away first. | 90 // it goes away first. |
91 FirstLetterPseudoElement* m_firstLetterPseudoElement; | 91 FirstLetterPseudoElement* m_firstLetterPseudoElement; |
92 }; | 92 }; |
93 | 93 |
94 DEFINE_TYPE_CASTS(LayoutTextFragment, LayoutObject, object, toLayoutText(object)
->isTextFragment(), toLayoutText(object).isTextFragment()); | 94 DEFINE_TYPE_CASTS(LayoutTextFragment, LayoutObject, object, toLayoutText(object)
->isTextFragment(), toLayoutText(object).isTextFragment()); |
95 | 95 |
96 } // namespace blink | 96 } // namespace blink |
97 | 97 |
98 #endif // LayoutTextFragment_h | 98 #endif // LayoutTextFragment_h |
OLD | NEW |