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

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

Issue 889563002: Make RenderObject::style() return a const object (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Updated change after Doug's review. Created 5 years, 10 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/dom/Text.h ('k') | Source/core/dom/TreeScope.cpp » ('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) 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 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 return true; 308 return true;
309 } 309 }
310 310
311 static bool isSVGText(Text* text) 311 static bool isSVGText(Text* text)
312 { 312 {
313 Node* parentOrShadowHostNode = text->parentOrShadowHostNode(); 313 Node* parentOrShadowHostNode = text->parentOrShadowHostNode();
314 ASSERT(parentOrShadowHostNode); 314 ASSERT(parentOrShadowHostNode);
315 return parentOrShadowHostNode->isSVGElement() && !isSVGForeignObjectElement( *parentOrShadowHostNode); 315 return parentOrShadowHostNode->isSVGElement() && !isSVGForeignObjectElement( *parentOrShadowHostNode);
316 } 316 }
317 317
318 RenderText* Text::createTextRenderer(LayoutStyle* style) 318 RenderText* Text::createTextRenderer(const LayoutStyle& style)
319 { 319 {
320 if (isSVGText(this)) 320 if (isSVGText(this))
321 return new LayoutSVGInlineText(this, dataImpl()); 321 return new LayoutSVGInlineText(this, dataImpl());
322 322
323 if (style->hasTextCombine()) 323 if (style.hasTextCombine())
324 return new RenderCombineText(this, dataImpl()); 324 return new RenderCombineText(this, dataImpl());
325 325
326 return new RenderText(this, dataImpl()); 326 return new RenderText(this, dataImpl());
327 } 327 }
328 328
329 void Text::attach(const AttachContext& context) 329 void Text::attach(const AttachContext& context)
330 { 330 {
331 if (ContainerNode* renderingParent = NodeRenderingTraversal::parent(*this)) { 331 if (ContainerNode* renderingParent = NodeRenderingTraversal::parent(*this)) {
332 if (LayoutObject* parentRenderer = renderingParent->renderer()) { 332 if (LayoutObject* parentRenderer = renderingParent->renderer()) {
333 if (textRendererIsNeeded(*parentRenderer->style(), *parentRenderer)) 333 if (textRendererIsNeeded(*parentRenderer->style(), *parentRenderer))
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 if (this->renderer()) 376 if (this->renderer())
377 reattachWhitespaceSiblingsIfNeeded(nextTextSibling); 377 reattachWhitespaceSiblingsIfNeeded(nextTextSibling);
378 } 378 }
379 } 379 }
380 380
381 // If a whitespace node had no renderer and goes through a recalcStyle it may 381 // If a whitespace node had no renderer and goes through a recalcStyle it may
382 // need to create one if the parent style now has white-space: pre. 382 // need to create one if the parent style now has white-space: pre.
383 bool Text::needsWhitespaceRenderer() 383 bool Text::needsWhitespaceRenderer()
384 { 384 {
385 ASSERT(!renderer()); 385 ASSERT(!renderer());
386 if (LayoutStyle* style = parentLayoutStyle()) 386 if (const LayoutStyle* style = parentLayoutStyle())
387 return style->preserveNewline(); 387 return style->preserveNewline();
388 return false; 388 return false;
389 } 389 }
390 390
391 void Text::updateTextRenderer(unsigned offsetOfReplacedData, unsigned lengthOfRe placedData, RecalcStyleBehavior recalcStyleBehavior) 391 void Text::updateTextRenderer(unsigned offsetOfReplacedData, unsigned lengthOfRe placedData, RecalcStyleBehavior recalcStyleBehavior)
392 { 392 {
393 if (!inActiveDocument()) 393 if (!inActiveDocument())
394 return; 394 return;
395 RenderText* textRenderer = renderer(); 395 RenderText* textRenderer = renderer();
396 if (!textRenderer || !textRendererIsNeeded(*textRenderer->style(), *textRend erer->parent())) { 396 if (!textRenderer || !textRendererIsNeeded(*textRenderer->style(), *textRend erer->parent())) {
(...skipping 25 matching lines...) Expand all
422 result.appendLiteral("; "); 422 result.appendLiteral("; ");
423 result.appendLiteral("value="); 423 result.appendLiteral("value=");
424 result.append(s); 424 result.append(s);
425 } 425 }
426 426
427 strncpy(buffer, result.toString().utf8().data(), length - 1); 427 strncpy(buffer, result.toString().utf8().data(), length - 1);
428 } 428 }
429 #endif 429 #endif
430 430
431 } // namespace blink 431 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/dom/Text.h ('k') | Source/core/dom/TreeScope.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698