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 : LayoutTextFragment(node, str, 0, str ? str->length() : 0) {} | 48 : LayoutTextFragment(node, str, 0, str ? str->length() : 0) {} |
48 | 49 |
49 LayoutTextFragment::~LayoutTextFragment() { | 50 LayoutTextFragment::~LayoutTextFragment() { |
50 ASSERT(!m_firstLetterPseudoElement); | 51 ASSERT(!m_firstLetterPseudoElement); |
51 } | 52 } |
52 | 53 |
| 54 LayoutTextFragment* LayoutTextFragment::createAnonymous(PseudoElement& pseudo, |
| 55 StringImpl* text, |
| 56 unsigned start, |
| 57 unsigned length) { |
| 58 LayoutTextFragment* fragment = |
| 59 new LayoutTextFragment(nullptr, text, start, length); |
| 60 fragment->setDocumentForAnonymous(&pseudo.document()); |
| 61 if (length) |
| 62 pseudo.document().view()->incrementVisuallyNonEmptyCharacterCount(length); |
| 63 return fragment; |
| 64 } |
| 65 |
| 66 LayoutTextFragment* LayoutTextFragment::createAnonymous(PseudoElement& pseudo, |
| 67 StringImpl* text) { |
| 68 return createAnonymous(pseudo, text, 0, text ? text->length() : 0); |
| 69 } |
| 70 |
53 void LayoutTextFragment::willBeDestroyed() { | 71 void LayoutTextFragment::willBeDestroyed() { |
54 if (m_isRemainingTextLayoutObject && m_firstLetterPseudoElement) | 72 if (m_isRemainingTextLayoutObject && m_firstLetterPseudoElement) |
55 m_firstLetterPseudoElement->setRemainingTextLayoutObject(nullptr); | 73 m_firstLetterPseudoElement->setRemainingTextLayoutObject(nullptr); |
56 m_firstLetterPseudoElement = nullptr; | 74 m_firstLetterPseudoElement = nullptr; |
57 LayoutText::willBeDestroyed(); | 75 LayoutText::willBeDestroyed(); |
58 } | 76 } |
59 | 77 |
60 PassRefPtr<StringImpl> LayoutTextFragment::completeText() const { | 78 PassRefPtr<StringImpl> LayoutTextFragment::completeText() const { |
61 Text* text = associatedTextNode(); | 79 Text* text = associatedTextNode(); |
62 return text ? text->dataImpl() : contentString(); | 80 return text ? text->dataImpl() : contentString(); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 LayoutObject::updateHitTestResult(result, point); | 168 LayoutObject::updateHitTestResult(result, point); |
151 | 169 |
152 // If we aren't part of a first-letter element, or if we | 170 // If we aren't part of a first-letter element, or if we |
153 // are part of first-letter but we're the remaining text then return. | 171 // are part of first-letter but we're the remaining text then return. |
154 if (m_isRemainingTextLayoutObject || !firstLetterPseudoElement()) | 172 if (m_isRemainingTextLayoutObject || !firstLetterPseudoElement()) |
155 return; | 173 return; |
156 result.setInnerNode(firstLetterPseudoElement()); | 174 result.setInnerNode(firstLetterPseudoElement()); |
157 } | 175 } |
158 | 176 |
159 } // namespace blink | 177 } // namespace blink |
OLD | NEW |