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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/rendering/RenderQuote.h ('k') | Source/core/rendering/RenderTextFragment.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/rendering/RenderQuote.cpp
diff --git a/Source/core/rendering/RenderQuote.cpp b/Source/core/rendering/RenderQuote.cpp
index 1048a8427c1fbbe3fff05c3c1363549ab33cc288..a9e81007ea3e2cef4eeb89f43062b04d8f3f30e7 100644
--- a/Source/core/rendering/RenderQuote.cpp
+++ b/Source/core/rendering/RenderQuote.cpp
@@ -270,12 +270,27 @@ void RenderQuote::updateText()
m_text = text;
- while (RenderObject* child = lastChild())
- child->destroy();
+ RenderTextFragment* fragment = findFragmentChild();
+ if (fragment) {
+ fragment->setStyle(style());
+ fragment->setContentString(m_text.impl());
+ } else {
+ fragment = new RenderTextFragment(&document(), m_text.impl());
+ fragment->setStyle(style());
+ addChild(fragment);
+ }
+}
+
+RenderTextFragment* RenderQuote::findFragmentChild() const
+{
+ // We walk from the end of the child list because, if we've had a first-letter
+ // renderer inserted then the remaining text will be at the end.
+ while (RenderObject* child = lastChild()) {
+ if (child->isText() && toRenderText(child)->isTextFragment())
+ return toRenderTextFragment(child);
+ }
- RenderTextFragment* fragment = new RenderTextFragment(&document(), m_text.impl());
- fragment->setStyle(style());
- addChild(fragment);
+ return nullptr;
}
String RenderQuote::computeText() const
« 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