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

Side by Side Diff: Source/core/dom/Text.cpp

Issue 17054002: Element::recalcStyle() overly reattach()-es InsertionPoints. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 6 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
OLDNEW
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 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 269
270 return new (arena) RenderText(this, dataImpl()); 270 return new (arena) RenderText(this, dataImpl());
271 } 271 }
272 272
273 void Text::attach(const AttachContext& context) 273 void Text::attach(const AttachContext& context)
274 { 274 {
275 createTextRendererIfNeeded(); 275 createTextRendererIfNeeded();
276 CharacterData::attach(context); 276 CharacterData::attach(context);
277 } 277 }
278 278
279 class ClearNeedsStyleRecalcScope {
280 public:
281 ClearNeedsStyleRecalcScope(Node* node) : m_node(node) { }
282 ~ClearNeedsStyleRecalcScope() { m_node->clearNeedsStyleRecalc(); }
esprehn 2013/06/14 08:32:29 I'd prefer you just put the clearNeedsStyleRecalc(
Hajime Morrita 2013/06/14 09:59:14 Done.
283 private:
284 Node* m_node;
285 };
286
279 void Text::recalcTextStyle(StyleChange change) 287 void Text::recalcTextStyle(StyleChange change)
esprehn 2013/06/14 08:32:29 I don't understand why you changed this function,
Hajime Morrita 2013/06/14 09:59:14 There is a case there change == NoChange but needs
280 { 288 {
289 ClearNeedsStyleRecalcScope scope(this);
281 RenderText* renderer = toRenderText(this->renderer()); 290 RenderText* renderer = toRenderText(this->renderer());
282 291
283 if (change != NoChange && renderer) 292 if (!renderer) {
284 renderer->setStyle(document()->styleResolver()->styleForText(this)); 293 if (needsStyleRecalc())
294 reattach();
295 return;
296 }
285 297
286 if (needsStyleRecalc()) { 298 if (needsStyleRecalc()) {
287 if (renderer) 299 renderer->setStyle(document()->styleResolver()->styleForText(this));
288 renderer->setText(dataImpl()); 300 renderer->setText(dataImpl());
289 else 301 return;
esprehn 2013/06/14 08:32:29 Remove this return and make the below if () an els
Hajime Morrita 2013/06/14 09:59:14 Done.
290 reattach();
291 } 302 }
292 clearNeedsStyleRecalc(); 303
304 if (change != NoChange)
305 renderer->setStyle(document()->styleResolver()->styleForText(this));
293 } 306 }
294 307
295 void Text::updateTextRenderer(unsigned offsetOfReplacedData, unsigned lengthOfRe placedData) 308 void Text::updateTextRenderer(unsigned offsetOfReplacedData, unsigned lengthOfRe placedData)
296 { 309 {
297 if (!attached()) 310 if (!attached())
298 return; 311 return;
299 RenderText* textRenderer = toRenderText(renderer()); 312 RenderText* textRenderer = toRenderText(renderer());
300 if (!textRenderer || !textRendererIsNeeded(NodeRenderingContext(this, textRe nderer->style()))) { 313 if (!textRenderer || !textRendererIsNeeded(NodeRenderingContext(this, textRe nderer->style()))) {
301 reattach(); 314 reattach();
302 return; 315 return;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 result.appendLiteral("; "); 354 result.appendLiteral("; ");
342 result.appendLiteral("value="); 355 result.appendLiteral("value=");
343 result.append(s); 356 result.append(s);
344 } 357 }
345 358
346 strncpy(buffer, result.toString().utf8().data(), length - 1); 359 strncpy(buffer, result.toString().utf8().data(), length - 1);
347 } 360 }
348 #endif 361 #endif
349 362
350 } // namespace WebCore 363 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698