| 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 17 matching lines...) Expand all Loading... |
| 28 #include "core/dom/StyleChangeReason.h" | 28 #include "core/dom/StyleChangeReason.h" |
| 29 #include "core/dom/Text.h" | 29 #include "core/dom/Text.h" |
| 30 #include "core/layout/HitTestResult.h" | 30 #include "core/layout/HitTestResult.h" |
| 31 #include "core/layout/LayoutBlock.h" | 31 #include "core/layout/LayoutBlock.h" |
| 32 | 32 |
| 33 namespace blink { | 33 namespace blink { |
| 34 | 34 |
| 35 LayoutTextFragment::LayoutTextFragment(Node* node, StringImpl* str, int startOff
set, int length) | 35 LayoutTextFragment::LayoutTextFragment(Node* node, StringImpl* str, int startOff
set, int length) |
| 36 : LayoutText(node, str ? str->substring(startOffset, length) : PassRefPtr<St
ringImpl>(nullptr)) | 36 : LayoutText(node, str ? str->substring(startOffset, length) : PassRefPtr<St
ringImpl>(nullptr)) |
| 37 , m_start(startOffset) | 37 , m_start(startOffset) |
| 38 , m_end(length) | 38 , m_fragmentLength(length) |
| 39 , m_isRemainingTextLayoutObject(false) | 39 , m_isRemainingTextLayoutObject(false) |
| 40 , m_contentString(str) | 40 , m_contentString(str) |
| 41 , m_firstLetterPseudoElement(nullptr) | 41 , m_firstLetterPseudoElement(nullptr) |
| 42 { | 42 { |
| 43 } | 43 } |
| 44 | 44 |
| 45 LayoutTextFragment::LayoutTextFragment(Node* node, StringImpl* str) | 45 LayoutTextFragment::LayoutTextFragment(Node* node, StringImpl* str) |
| 46 : LayoutText(node, str) | 46 : LayoutText(node, str) |
| 47 , m_start(0) | 47 , m_start(0) |
| 48 , m_end(str ? str->length() : 0) | 48 , m_fragmentLength(str ? str->length() : 0) |
| 49 , m_isRemainingTextLayoutObject(false) | 49 , m_isRemainingTextLayoutObject(false) |
| 50 , m_contentString(str) | 50 , m_contentString(str) |
| 51 , m_firstLetterPseudoElement(nullptr) | 51 , m_firstLetterPseudoElement(nullptr) |
| 52 { | 52 { |
| 53 } | 53 } |
| 54 | 54 |
| 55 LayoutTextFragment::~LayoutTextFragment() | 55 LayoutTextFragment::~LayoutTextFragment() |
| 56 { | 56 { |
| 57 ASSERT(!m_firstLetterPseudoElement); | 57 ASSERT(!m_firstLetterPseudoElement); |
| 58 } | 58 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 75 { | 75 { |
| 76 m_contentString = str; | 76 m_contentString = str; |
| 77 setText(str); | 77 setText(str); |
| 78 } | 78 } |
| 79 | 79 |
| 80 PassRefPtr<StringImpl> LayoutTextFragment::originalText() const | 80 PassRefPtr<StringImpl> LayoutTextFragment::originalText() const |
| 81 { | 81 { |
| 82 RefPtr<StringImpl> result = completeText(); | 82 RefPtr<StringImpl> result = completeText(); |
| 83 if (!result) | 83 if (!result) |
| 84 return nullptr; | 84 return nullptr; |
| 85 return result->substring(start(), end()); | 85 return result->substring(start(), fragmentLength()); |
| 86 } | 86 } |
| 87 | 87 |
| 88 void LayoutTextFragment::setText(PassRefPtr<StringImpl> text, bool force) | 88 void LayoutTextFragment::setText(PassRefPtr<StringImpl> text, bool force) |
| 89 { | 89 { |
| 90 LayoutText::setText(text, force); | 90 LayoutText::setText(text, force); |
| 91 | 91 |
| 92 m_start = 0; | 92 m_start = 0; |
| 93 m_end = textLength(); | 93 m_fragmentLength = textLength(); |
| 94 | 94 |
| 95 // If we're the remaining text from a first letter then we have to tell the | 95 // If we're the remaining text from a first letter then we have to tell the |
| 96 // first letter pseudo element to reattach itself so it can re-calculate the | 96 // first letter pseudo element to reattach itself so it can re-calculate the |
| 97 // correct first-letter settings. | 97 // correct first-letter settings. |
| 98 if (isRemainingTextLayoutObject()) { | 98 if (isRemainingTextLayoutObject()) { |
| 99 ASSERT(firstLetterPseudoElement()); | 99 ASSERT(firstLetterPseudoElement()); |
| 100 firstLetterPseudoElement()->updateTextFragments(); | 100 firstLetterPseudoElement()->updateTextFragments(); |
| 101 } | 101 } |
| 102 } | 102 } |
| 103 | 103 |
| 104 void LayoutTextFragment::setTextFragment(PassRefPtr<StringImpl> text, unsigned s
tart, unsigned length) | 104 void LayoutTextFragment::setTextFragment(PassRefPtr<StringImpl> text, unsigned s
tart, unsigned length) |
| 105 { | 105 { |
| 106 LayoutText::setText(text, false); | 106 LayoutText::setText(text, false); |
| 107 | 107 |
| 108 m_start = start; | 108 m_start = start; |
| 109 m_end = length; | 109 m_fragmentLength = length; |
| 110 } | 110 } |
| 111 | 111 |
| 112 void LayoutTextFragment::transformText() | 112 void LayoutTextFragment::transformText() |
| 113 { | 113 { |
| 114 // Note, we have to call LayoutText::setText here because, if we use our | 114 // Note, we have to call LayoutText::setText here because, if we use our |
| 115 // version we will, potentially, screw up the first-letter settings where | 115 // version we will, potentially, screw up the first-letter settings where |
| 116 // we only use portions of the string. | 116 // we only use portions of the string. |
| 117 if (RefPtr<StringImpl> textToTransform = originalText()) | 117 if (RefPtr<StringImpl> textToTransform = originalText()) |
| 118 LayoutText::setText(textToTransform.release(), true); | 118 LayoutText::setText(textToTransform.release(), true); |
| 119 } | 119 } |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 LayoutObject::updateHitTestResult(result, point); | 163 LayoutObject::updateHitTestResult(result, point); |
| 164 | 164 |
| 165 // If we aren't part of a first-letter element, or if we | 165 // If we aren't part of a first-letter element, or if we |
| 166 // are part of first-letter but we're the remaining text then return. | 166 // are part of first-letter but we're the remaining text then return. |
| 167 if (m_isRemainingTextLayoutObject || !firstLetterPseudoElement()) | 167 if (m_isRemainingTextLayoutObject || !firstLetterPseudoElement()) |
| 168 return; | 168 return; |
| 169 result.setInnerNode(firstLetterPseudoElement()); | 169 result.setInnerNode(firstLetterPseudoElement()); |
| 170 } | 170 } |
| 171 | 171 |
| 172 } // namespace blink | 172 } // namespace blink |
| OLD | NEW |