OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights
reserved. | 4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 setDataWithoutUpdate(oldStr.substring(0, offset)); | 117 setDataWithoutUpdate(oldStr.substring(0, offset)); |
118 | 118 |
119 didModifyData(oldStr); | 119 didModifyData(oldStr); |
120 | 120 |
121 if (parentNode()) | 121 if (parentNode()) |
122 parentNode()->insertBefore(newText.get(), nextSibling(), exceptionState)
; | 122 parentNode()->insertBefore(newText.get(), nextSibling(), exceptionState)
; |
123 if (exceptionState.hadException()) | 123 if (exceptionState.hadException()) |
124 return nullptr; | 124 return nullptr; |
125 | 125 |
126 if (renderer()) | 126 if (renderer()) |
127 toRenderText(renderer())->setTextWithOffset(dataImpl(), 0, oldStr.length
()); | 127 renderer()->setTextWithOffset(dataImpl(), 0, oldStr.length()); |
128 | 128 |
129 if (parentNode()) | 129 if (parentNode()) |
130 document().didSplitTextNode(*this); | 130 document().didSplitTextNode(*this); |
131 | 131 |
132 return newText.release(); | 132 return newText.release(); |
133 } | 133 } |
134 | 134 |
135 static const Text* earliestLogicallyAdjacentTextNode(const Text* t) | 135 static const Text* earliestLogicallyAdjacentTextNode(const Text* t) |
136 { | 136 { |
137 for (const Node* n = t->previousSibling(); n; n = n->previousSibling()) { | 137 for (const Node* n = t->previousSibling(); n; n = n->previousSibling()) { |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 } | 303 } |
304 | 304 |
305 void Text::attach(const AttachContext& context) | 305 void Text::attach(const AttachContext& context) |
306 { | 306 { |
307 RenderTreeBuilder(this, context.resolvedStyle).createRendererForTextIfNeeded
(); | 307 RenderTreeBuilder(this, context.resolvedStyle).createRendererForTextIfNeeded
(); |
308 CharacterData::attach(context); | 308 CharacterData::attach(context); |
309 } | 309 } |
310 | 310 |
311 void Text::recalcTextStyle(StyleRecalcChange change, Text* nextTextSibling) | 311 void Text::recalcTextStyle(StyleRecalcChange change, Text* nextTextSibling) |
312 { | 312 { |
313 if (RenderText* renderer = toRenderText(this->renderer())) { | 313 if (RenderText* renderer = this->renderer()) { |
314 if (change != NoChange || needsStyleRecalc()) | 314 if (change != NoChange || needsStyleRecalc()) |
315 renderer->setStyle(document().ensureStyleResolver().styleForText(thi
s)); | 315 renderer->setStyle(document().ensureStyleResolver().styleForText(thi
s)); |
316 if (needsStyleRecalc()) | 316 if (needsStyleRecalc()) |
317 renderer->setText(dataImpl()); | 317 renderer->setText(dataImpl()); |
318 clearNeedsStyleRecalc(); | 318 clearNeedsStyleRecalc(); |
319 } else if (needsStyleRecalc() || needsWhitespaceRenderer()) { | 319 } else if (needsStyleRecalc() || needsWhitespaceRenderer()) { |
320 reattach(); | 320 reattach(); |
321 reattachWhitespaceSiblings(nextTextSibling); | 321 reattachWhitespaceSiblings(nextTextSibling); |
322 } | 322 } |
323 } | 323 } |
324 | 324 |
325 // If a whitespace node had no renderer and goes through a recalcStyle it may | 325 // If a whitespace node had no renderer and goes through a recalcStyle it may |
326 // need to create one if the parent style now has white-space: pre. | 326 // need to create one if the parent style now has white-space: pre. |
327 bool Text::needsWhitespaceRenderer() | 327 bool Text::needsWhitespaceRenderer() |
328 { | 328 { |
329 ASSERT(!renderer()); | 329 ASSERT(!renderer()); |
330 if (RenderStyle* style = parentRenderStyle()) | 330 if (RenderStyle* style = parentRenderStyle()) |
331 return style->preserveNewline(); | 331 return style->preserveNewline(); |
332 return false; | 332 return false; |
333 } | 333 } |
334 | 334 |
335 void Text::updateTextRenderer(unsigned offsetOfReplacedData, unsigned lengthOfRe
placedData, RecalcStyleBehavior recalcStyleBehavior) | 335 void Text::updateTextRenderer(unsigned offsetOfReplacedData, unsigned lengthOfRe
placedData, RecalcStyleBehavior recalcStyleBehavior) |
336 { | 336 { |
337 if (!inActiveDocument()) | 337 if (!inActiveDocument()) |
338 return; | 338 return; |
339 RenderText* textRenderer = toRenderText(renderer()); | 339 RenderText* textRenderer = renderer(); |
340 if (!textRenderer || !textRendererIsNeeded(*textRenderer->style(), *textRend
erer->parent())) { | 340 if (!textRenderer || !textRendererIsNeeded(*textRenderer->style(), *textRend
erer->parent())) { |
341 lazyReattachIfAttached(); | 341 lazyReattachIfAttached(); |
342 // FIXME: Editing should be updated so this is not neccesary. | 342 // FIXME: Editing should be updated so this is not neccesary. |
343 if (recalcStyleBehavior == DeprecatedRecalcStyleImmediatlelyForEditing) | 343 if (recalcStyleBehavior == DeprecatedRecalcStyleImmediatlelyForEditing) |
344 document().updateRenderTreeIfNeeded(); | 344 document().updateRenderTreeIfNeeded(); |
345 return; | 345 return; |
346 } | 346 } |
347 textRenderer->setTextWithOffset(dataImpl(), offsetOfReplacedData, lengthOfRe
placedData); | 347 textRenderer->setTextWithOffset(dataImpl(), offsetOfReplacedData, lengthOfRe
placedData); |
348 } | 348 } |
349 | 349 |
(...skipping 16 matching lines...) Expand all Loading... |
366 result.appendLiteral("; "); | 366 result.appendLiteral("; "); |
367 result.appendLiteral("value="); | 367 result.appendLiteral("value="); |
368 result.append(s); | 368 result.append(s); |
369 } | 369 } |
370 | 370 |
371 strncpy(buffer, result.toString().utf8().data(), length - 1); | 371 strncpy(buffer, result.toString().utf8().data(), length - 1); |
372 } | 372 } |
373 #endif | 373 #endif |
374 | 374 |
375 } // namespace blink | 375 } // namespace blink |
OLD | NEW |