Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Side by Side Diff: Source/core/rendering/RenderQuote.cpp

Issue 679593004: Refactor RenderQuote to not delete renderers on style change. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/rendering/RenderQuote.h ('k') | Source/core/rendering/RenderTextFragment.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderQuote.h ('k') | Source/core/rendering/RenderTextFragment.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698