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 30 matching lines...) Expand all Loading... |
41 , m_end(str ? str->length() : 0) | 41 , m_end(str ? str->length() : 0) |
42 , m_contentString(str) | 42 , m_contentString(str) |
43 , m_firstLetter(0) | 43 , m_firstLetter(0) |
44 { | 44 { |
45 } | 45 } |
46 | 46 |
47 PassRefPtr<StringImpl> RenderTextFragment::originalText() const | 47 PassRefPtr<StringImpl> RenderTextFragment::originalText() const |
48 { | 48 { |
49 Node* e = node(); | 49 Node* e = node(); |
50 RefPtr<StringImpl> result = ((e && e->isTextNode()) ? static_cast<Text*>(e)-
>dataImpl() : contentString()); | 50 RefPtr<StringImpl> result = ((e && e->isTextNode()) ? static_cast<Text*>(e)-
>dataImpl() : contentString()); |
51 if (result && (start() > 0 || start() < result->length())) | 51 if (!result) |
52 result = result->substring(start(), end()); | 52 return 0; |
53 return result.release(); | 53 return result->substring(start(), end()); |
54 } | 54 } |
55 | 55 |
56 void RenderTextFragment::destroy() | 56 void RenderTextFragment::destroy() |
57 { | 57 { |
58 if (m_firstLetter) | 58 if (m_firstLetter) |
59 m_firstLetter->destroy(); | 59 m_firstLetter->destroy(); |
60 RenderText::destroy(); | 60 RenderText::destroy(); |
61 } | 61 } |
62 | 62 |
63 void RenderTextFragment::setTextInternal(PassRefPtr<StringImpl> text) | 63 void RenderTextFragment::setTextInternal(PassRefPtr<StringImpl> text) |
(...skipping 10 matching lines...) Expand all Loading... |
74 t->setRenderer(this); | 74 t->setRenderer(this); |
75 } | 75 } |
76 } | 76 } |
77 } | 77 } |
78 | 78 |
79 UChar RenderTextFragment::previousCharacter() const | 79 UChar RenderTextFragment::previousCharacter() const |
80 { | 80 { |
81 if (start()) { | 81 if (start()) { |
82 Node* e = node(); | 82 Node* e = node(); |
83 StringImpl* original = ((e && e->isTextNode()) ? static_cast<Text*>(e)-
>dataImpl() : contentString()); | 83 StringImpl* original = ((e && e->isTextNode()) ? static_cast<Text*>(e)-
>dataImpl() : contentString()); |
84 if (original) | 84 if (original && start() <= original->length()) |
85 return (*original)[start() - 1]; | 85 return (*original)[start() - 1]; |
86 } | 86 } |
87 | 87 |
88 return RenderText::previousCharacter(); | 88 return RenderText::previousCharacter(); |
89 } | 89 } |
90 | 90 |
91 } // namespace WebCore | 91 } // namespace WebCore |
OLD | NEW |