| 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 15 matching lines...) Expand all Loading... |
| 26 #include "core/dom/Text.h" | 26 #include "core/dom/Text.h" |
| 27 #include "core/rendering/HitTestResult.h" | 27 #include "core/rendering/HitTestResult.h" |
| 28 #include "core/rendering/RenderBlock.h" | 28 #include "core/rendering/RenderBlock.h" |
| 29 | 29 |
| 30 namespace blink { | 30 namespace blink { |
| 31 | 31 |
| 32 RenderTextFragment::RenderTextFragment(Node* node, StringImpl* str, int startOff
set, int length) | 32 RenderTextFragment::RenderTextFragment(Node* node, StringImpl* str, int startOff
set, int length) |
| 33 : RenderText(node, str ? str->substring(startOffset, length) : PassRefPtr<St
ringImpl>(nullptr)) | 33 : RenderText(node, str ? str->substring(startOffset, length) : PassRefPtr<St
ringImpl>(nullptr)) |
| 34 , m_start(startOffset) | 34 , m_start(startOffset) |
| 35 , m_end(length) | 35 , m_end(length) |
| 36 , m_firstLetter(0) | 36 , m_firstLetter(nullptr) |
| 37 { | 37 { |
| 38 } | 38 } |
| 39 | 39 |
| 40 RenderTextFragment::RenderTextFragment(Node* node, StringImpl* str) | 40 RenderTextFragment::RenderTextFragment(Node* node, StringImpl* str) |
| 41 : RenderText(node, str) | 41 : RenderText(node, str) |
| 42 , m_start(0) | 42 , m_start(0) |
| 43 , m_end(str ? str->length() : 0) | 43 , m_end(str ? str->length() : 0) |
| 44 , m_contentString(str) | 44 , m_contentString(str) |
| 45 , m_firstLetter(0) | 45 , m_firstLetter(nullptr) |
| 46 { | 46 { |
| 47 } | 47 } |
| 48 | 48 |
| 49 RenderTextFragment::~RenderTextFragment() | 49 RenderTextFragment::~RenderTextFragment() |
| 50 { | 50 { |
| 51 } | 51 } |
| 52 | 52 |
| 53 void RenderTextFragment::trace(Visitor* visitor) |
| 54 { |
| 55 visitor->trace(m_firstLetter); |
| 56 RenderText::trace(visitor); |
| 57 } |
| 58 |
| 53 RenderText* RenderTextFragment::firstRenderTextInFirstLetter() const | 59 RenderText* RenderTextFragment::firstRenderTextInFirstLetter() const |
| 54 { | 60 { |
| 55 for (RenderObject* current = m_firstLetter; current; current = current->next
InPreOrder(m_firstLetter)) { | 61 for (RenderObject* current = m_firstLetter; current; current = current->next
InPreOrder(m_firstLetter)) { |
| 56 if (current->isText()) | 62 if (current->isText()) |
| 57 return toRenderText(current); | 63 return toRenderText(current); |
| 58 } | 64 } |
| 59 return 0; | 65 return 0; |
| 60 } | 66 } |
| 61 | 67 |
| 62 PassRefPtr<StringImpl> RenderTextFragment::originalText() const | 68 PassRefPtr<StringImpl> RenderTextFragment::originalText() const |
| (...skipping 28 matching lines...) Expand all Loading... |
| 91 | 97 |
| 92 m_start = 0; | 98 m_start = 0; |
| 93 m_end = textLength(); | 99 m_end = textLength(); |
| 94 if (m_firstLetter) { | 100 if (m_firstLetter) { |
| 95 // FIXME: We should not modify the structure of the render tree during | 101 // FIXME: We should not modify the structure of the render tree during |
| 96 // layout. crbug.com/370458 | 102 // layout. crbug.com/370458 |
| 97 DeprecatedDisableModifyRenderTreeStructureAsserts disabler; | 103 DeprecatedDisableModifyRenderTreeStructureAsserts disabler; |
| 98 | 104 |
| 99 ASSERT(!m_contentString); | 105 ASSERT(!m_contentString); |
| 100 m_firstLetter->destroy(); | 106 m_firstLetter->destroy(); |
| 101 m_firstLetter = 0; | 107 m_firstLetter = nullptr; |
| 102 if (Node* t = node()) { | 108 if (Node* t = node()) { |
| 103 ASSERT(!t->renderer()); | 109 ASSERT(!t->renderer()); |
| 104 t->setRenderer(this); | 110 t->setRenderer(this); |
| 105 } | 111 } |
| 106 } | 112 } |
| 107 } | 113 } |
| 108 | 114 |
| 109 void RenderTextFragment::transformText() | 115 void RenderTextFragment::transformText() |
| 110 { | 116 { |
| 111 // Don't reset first-letter here because we are only transforming the trunca
ted fragment. | 117 // Don't reset first-letter here because we are only transforming the trunca
ted fragment. |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 return; | 152 return; |
| 147 RenderObject* nodeRenderer = node()->renderer(); | 153 RenderObject* nodeRenderer = node()->renderer(); |
| 148 if (!nodeRenderer || !nodeRenderer->isText() || !toRenderText(nodeRenderer)-
>isTextFragment()) | 154 if (!nodeRenderer || !nodeRenderer->isText() || !toRenderText(nodeRenderer)-
>isTextFragment()) |
| 149 return; | 155 return; |
| 150 | 156 |
| 151 if (isDescendantOf(toRenderTextFragment(nodeRenderer)->m_firstLetter)) | 157 if (isDescendantOf(toRenderTextFragment(nodeRenderer)->m_firstLetter)) |
| 152 result.setIsFirstLetter(true); | 158 result.setIsFirstLetter(true); |
| 153 } | 159 } |
| 154 | 160 |
| 155 } // namespace blink | 161 } // namespace blink |
| OLD | NEW |