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 #include "core/layout/LayoutTextFragment.h" | 23 #include "core/layout/LayoutTextFragment.h" |
24 | 24 |
25 #include "core/dom/FirstLetterPseudoElement.h" | 25 #include "core/dom/FirstLetterPseudoElement.h" |
26 #include "core/dom/PseudoElement.h" | 26 #include "core/dom/PseudoElement.h" |
27 #include "core/dom/StyleChangeReason.h" | 27 #include "core/dom/StyleChangeReason.h" |
28 #include "core/dom/Text.h" | 28 #include "core/dom/Text.h" |
| 29 #include "core/frame/FrameView.h" |
29 #include "core/layout/HitTestResult.h" | 30 #include "core/layout/HitTestResult.h" |
30 | 31 |
31 namespace blink { | 32 namespace blink { |
32 | 33 |
33 LayoutTextFragment::LayoutTextFragment(Node* node, | 34 LayoutTextFragment::LayoutTextFragment(Node* node, |
34 StringImpl* str, | 35 StringImpl* str, |
35 int startOffset, | 36 int startOffset, |
36 int length) | 37 int length) |
37 : LayoutText(node, | 38 : LayoutText(node, |
38 str ? str->substring(startOffset, length) | 39 str ? str->substring(startOffset, length) |
39 : PassRefPtr<StringImpl>(nullptr)), | 40 : PassRefPtr<StringImpl>(nullptr)), |
40 m_start(startOffset), | 41 m_start(startOffset), |
41 m_fragmentLength(length), | 42 m_fragmentLength(length), |
42 m_isRemainingTextLayoutObject(false), | 43 m_isRemainingTextLayoutObject(false), |
43 m_contentString(str), | 44 m_contentString(str), |
44 m_firstLetterPseudoElement(nullptr) {} | 45 m_firstLetterPseudoElement(nullptr) {} |
45 | 46 |
46 LayoutTextFragment::LayoutTextFragment(Node* node, StringImpl* str) | 47 LayoutTextFragment::LayoutTextFragment(Node* node, StringImpl* str) |
47 : LayoutText(node, str), | 48 : LayoutText(node, str), |
48 m_start(0), | 49 m_start(0), |
49 m_fragmentLength(str ? str->length() : 0), | 50 m_fragmentLength(str ? str->length() : 0), |
50 m_isRemainingTextLayoutObject(false), | 51 m_isRemainingTextLayoutObject(false), |
51 m_contentString(str), | 52 m_contentString(str), |
52 m_firstLetterPseudoElement(nullptr) {} | 53 m_firstLetterPseudoElement(nullptr) {} |
53 | 54 |
54 LayoutTextFragment::~LayoutTextFragment() { | 55 LayoutTextFragment::~LayoutTextFragment() { |
55 ASSERT(!m_firstLetterPseudoElement); | 56 ASSERT(!m_firstLetterPseudoElement); |
56 } | 57 } |
57 | 58 |
| 59 LayoutTextFragment* LayoutTextFragment::createAnonymous(PseudoElement& pseudo, |
| 60 StringImpl* str, |
| 61 unsigned start, |
| 62 unsigned length) { |
| 63 LayoutTextFragment* text = |
| 64 new LayoutTextFragment(nullptr, str, start, length); |
| 65 text->setPseudoForAnonymous(pseudo); |
| 66 pseudo.document().view()->incrementVisuallyNonEmptyCharacterCount(length); |
| 67 return text; |
| 68 } |
| 69 |
| 70 LayoutTextFragment* LayoutTextFragment::createAnonymous(PseudoElement& pseudo, |
| 71 StringImpl* str) { |
| 72 return createAnonymous(pseudo, str, 0, str ? str->length() : 0); |
| 73 } |
| 74 |
58 void LayoutTextFragment::willBeDestroyed() { | 75 void LayoutTextFragment::willBeDestroyed() { |
59 if (m_isRemainingTextLayoutObject && m_firstLetterPseudoElement) | 76 if (m_isRemainingTextLayoutObject && m_firstLetterPseudoElement) |
60 m_firstLetterPseudoElement->setRemainingTextLayoutObject(nullptr); | 77 m_firstLetterPseudoElement->setRemainingTextLayoutObject(nullptr); |
61 m_firstLetterPseudoElement = nullptr; | 78 m_firstLetterPseudoElement = nullptr; |
62 LayoutText::willBeDestroyed(); | 79 LayoutText::willBeDestroyed(); |
63 } | 80 } |
64 | 81 |
65 PassRefPtr<StringImpl> LayoutTextFragment::completeText() const { | 82 PassRefPtr<StringImpl> LayoutTextFragment::completeText() const { |
66 Text* text = associatedTextNode(); | 83 Text* text = associatedTextNode(); |
67 return text ? text->dataImpl() : contentString(); | 84 return text ? text->dataImpl() : contentString(); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 LayoutObject::updateHitTestResult(result, point); | 172 LayoutObject::updateHitTestResult(result, point); |
156 | 173 |
157 // If we aren't part of a first-letter element, or if we | 174 // If we aren't part of a first-letter element, or if we |
158 // are part of first-letter but we're the remaining text then return. | 175 // are part of first-letter but we're the remaining text then return. |
159 if (m_isRemainingTextLayoutObject || !firstLetterPseudoElement()) | 176 if (m_isRemainingTextLayoutObject || !firstLetterPseudoElement()) |
160 return; | 177 return; |
161 result.setInnerNode(firstLetterPseudoElement()); | 178 result.setInnerNode(firstLetterPseudoElement()); |
162 } | 179 } |
163 | 180 |
164 } // namespace blink | 181 } // namespace blink |
OLD | NEW |