| OLD | NEW |
| 1 /** | 1 /** |
| 2 * Copyright (C) 2011 Nokia Inc. All rights reserved. | 2 * Copyright (C) 2011 Nokia Inc. All rights reserved. |
| 3 * Copyright (C) 2012 Google Inc. All rights reserved. | 3 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
| 6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
| 7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
| 8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
| 9 * | 9 * |
| 10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 } | 263 } |
| 264 | 264 |
| 265 void RenderQuote::updateText() | 265 void RenderQuote::updateText() |
| 266 { | 266 { |
| 267 String text = computeText(); | 267 String text = computeText(); |
| 268 if (m_text == text) | 268 if (m_text == text) |
| 269 return; | 269 return; |
| 270 | 270 |
| 271 m_text = text; | 271 m_text = text; |
| 272 | 272 |
| 273 while (RenderObject* child = lastChild()) | 273 RenderTextFragment* fragment = findFragmentChild(); |
| 274 child->destroy(); | 274 if (fragment) { |
| 275 fragment->setStyle(style()); |
| 276 fragment->setContentString(m_text.impl()); |
| 277 } else { |
| 278 fragment = new RenderTextFragment(&document(), m_text.impl()); |
| 279 fragment->setStyle(style()); |
| 280 addChild(fragment); |
| 281 } |
| 282 } |
| 275 | 283 |
| 276 RenderTextFragment* fragment = new RenderTextFragment(&document(), m_text.im
pl()); | 284 RenderTextFragment* RenderQuote::findFragmentChild() const |
| 277 fragment->setStyle(style()); | 285 { |
| 278 addChild(fragment); | 286 // We walk from the end of the child list because, if we've had a first-lett
er |
| 287 // renderer inserted then the remaining text will be at the end. |
| 288 while (RenderObject* child = lastChild()) { |
| 289 if (child->isText() && toRenderText(child)->isTextFragment()) |
| 290 return toRenderTextFragment(child); |
| 291 } |
| 292 |
| 293 return nullptr; |
| 279 } | 294 } |
| 280 | 295 |
| 281 String RenderQuote::computeText() const | 296 String RenderQuote::computeText() const |
| 282 { | 297 { |
| 283 switch (m_type) { | 298 switch (m_type) { |
| 284 case NO_OPEN_QUOTE: | 299 case NO_OPEN_QUOTE: |
| 285 case NO_CLOSE_QUOTE: | 300 case NO_CLOSE_QUOTE: |
| 286 return emptyString(); | 301 return emptyString(); |
| 287 case CLOSE_QUOTE: | 302 case CLOSE_QUOTE: |
| 288 return quotesData()->getCloseQuote(m_depth - 1).impl(); | 303 return quotesData()->getCloseQuote(m_depth - 1).impl(); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 if (m_depth) | 401 if (m_depth) |
| 387 m_depth--; | 402 m_depth--; |
| 388 break; | 403 break; |
| 389 } | 404 } |
| 390 } | 405 } |
| 391 if (oldDepth != m_depth) | 406 if (oldDepth != m_depth) |
| 392 updateText(); | 407 updateText(); |
| 393 } | 408 } |
| 394 | 409 |
| 395 } // namespace blink | 410 } // namespace blink |
| OLD | NEW |