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

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

Issue 899163003: Move rendering/RenderObject to layout/LayoutObject. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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/editing/ApplyBlockElementCommand.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 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 Node::NodeType Text::nodeType() const 230 Node::NodeType Text::nodeType() const
231 { 231 {
232 return TEXT_NODE; 232 return TEXT_NODE;
233 } 233 }
234 234
235 PassRefPtrWillBeRawPtr<Node> Text::cloneNode(bool /*deep*/) 235 PassRefPtrWillBeRawPtr<Node> Text::cloneNode(bool /*deep*/)
236 { 236 {
237 return cloneWithData(data()); 237 return cloneWithData(data());
238 } 238 }
239 239
240 static inline bool canHaveWhitespaceChildren(const RenderObject& parent) 240 static inline bool canHaveWhitespaceChildren(const LayoutObject& parent)
241 { 241 {
242 // <button> should allow whitespace even though RenderFlexibleBox doesn't. 242 // <button> should allow whitespace even though RenderFlexibleBox doesn't.
243 if (parent.isRenderButton()) 243 if (parent.isRenderButton())
244 return true; 244 return true;
245 245
246 if (parent.isTable() || parent.isTableRow() || parent.isTableSection() 246 if (parent.isTable() || parent.isTableRow() || parent.isTableSection()
247 || parent.isLayoutTableCol() || parent.isFrameSet() 247 || parent.isLayoutTableCol() || parent.isFrameSet()
248 || parent.isFlexibleBox() || parent.isRenderGrid() 248 || parent.isFlexibleBox() || parent.isRenderGrid()
249 || parent.isSVGRoot() 249 || parent.isSVGRoot()
250 || parent.isSVGContainer() 250 || parent.isSVGContainer()
251 || parent.isSVGImage() 251 || parent.isSVGImage()
252 || parent.isSVGShape()) 252 || parent.isSVGShape())
253 return false; 253 return false;
254 return true; 254 return true;
255 } 255 }
256 256
257 bool Text::textRendererIsNeeded(const RenderStyle& style, const RenderObject& pa rent) 257 bool Text::textRendererIsNeeded(const RenderStyle& style, const LayoutObject& pa rent)
258 { 258 {
259 if (!parent.canHaveChildren()) 259 if (!parent.canHaveChildren())
260 return false; 260 return false;
261 261
262 if (isEditingText()) 262 if (isEditingText())
263 return true; 263 return true;
264 264
265 if (!length()) 265 if (!length())
266 return false; 266 return false;
267 267
268 if (style.display() == NONE) 268 if (style.display() == NONE)
269 return false; 269 return false;
270 270
271 if (!containsOnlyWhitespace()) 271 if (!containsOnlyWhitespace())
272 return true; 272 return true;
273 273
274 if (!canHaveWhitespaceChildren(parent)) 274 if (!canHaveWhitespaceChildren(parent))
275 return false; 275 return false;
276 276
277 if (style.preserveNewline()) // pre/pre-wrap/pre-line always make renderers. 277 if (style.preserveNewline()) // pre/pre-wrap/pre-line always make renderers.
278 return true; 278 return true;
279 279
280 // childNeedsDistributionRecalc() here is rare, only happens JS calling surr oundContents() etc. from DOMNodeInsertedIntoDocument etc. 280 // childNeedsDistributionRecalc() here is rare, only happens JS calling surr oundContents() etc. from DOMNodeInsertedIntoDocument etc.
281 if (document().childNeedsDistributionRecalc()) 281 if (document().childNeedsDistributionRecalc())
282 return true; 282 return true;
283 283
284 const RenderObject* prev = NodeRenderingTraversal::previousSiblingRenderer(* this); 284 const LayoutObject* prev = NodeRenderingTraversal::previousSiblingRenderer(* this);
285 if (prev && prev->isBR()) // <span><br/> <br/></span> 285 if (prev && prev->isBR()) // <span><br/> <br/></span>
286 return false; 286 return false;
287 287
288 if (parent.isRenderInline()) { 288 if (parent.isRenderInline()) {
289 // <span><div/> <div/></span> 289 // <span><div/> <div/></span>
290 if (prev && !prev->isInline()) 290 if (prev && !prev->isInline())
291 return false; 291 return false;
292 } else { 292 } else {
293 if (parent.isRenderBlock() && !parent.childrenInline() && (!prev || !pre v->isInline())) 293 if (parent.isRenderBlock() && !parent.childrenInline() && (!prev || !pre v->isInline()))
294 return false; 294 return false;
295 295
296 // Avoiding creation of a Renderer for the text node is a non-essential memory optimization. 296 // Avoiding creation of a Renderer for the text node is a non-essential memory optimization.
297 // So to avoid blowing up on very wide DOMs, we limit the number of sibl ings to visit. 297 // So to avoid blowing up on very wide DOMs, we limit the number of sibl ings to visit.
298 unsigned maxSiblingsToVisit = 50; 298 unsigned maxSiblingsToVisit = 50;
299 299
300 RenderObject* first = parent.slowFirstChild(); 300 LayoutObject* first = parent.slowFirstChild();
301 while (first && first->isFloatingOrOutOfFlowPositioned() && maxSiblingsT oVisit--) 301 while (first && first->isFloatingOrOutOfFlowPositioned() && maxSiblingsT oVisit--)
302 first = first->nextSibling(); 302 first = first->nextSibling();
303 if (!first || first == renderer() || NodeRenderingTraversal::nextSibling Renderer(*this) == first) 303 if (!first || first == renderer() || NodeRenderingTraversal::nextSibling Renderer(*this) == first)
304 // Whitespace at the start of a block just goes away. Don't even 304 // Whitespace at the start of a block just goes away. Don't even
305 // make a render object for this text. 305 // make a render object for this text.
306 return false; 306 return false;
307 } 307 }
308 return true; 308 return true;
309 } 309 }
310 310
(...skipping 11 matching lines...) Expand all
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 (RenderObject* parentRenderer = renderingParent->renderer()) { 332 if (LayoutObject* parentRenderer = renderingParent->renderer()) {
333 if (textRendererIsNeeded(*parentRenderer->style(), *parentRenderer)) 333 if (textRendererIsNeeded(*parentRenderer->style(), *parentRenderer))
334 RenderTreeBuilderForText(*this, parentRenderer).createRenderer() ; 334 RenderTreeBuilderForText(*this, parentRenderer).createRenderer() ;
335 } 335 }
336 } 336 }
337 CharacterData::attach(context); 337 CharacterData::attach(context);
338 } 338 }
339 339
340 void Text::reattachIfNeeded(const AttachContext& context) 340 void Text::reattachIfNeeded(const AttachContext& context)
341 { 341 {
342 bool rendererIsNeeded = false; 342 bool rendererIsNeeded = false;
343 ContainerNode* renderingParent = NodeRenderingTraversal::parent(*this); 343 ContainerNode* renderingParent = NodeRenderingTraversal::parent(*this);
344 if (renderingParent) { 344 if (renderingParent) {
345 if (RenderObject* parentRenderer = renderingParent->renderer()) { 345 if (LayoutObject* parentRenderer = renderingParent->renderer()) {
346 if (textRendererIsNeeded(*parentRenderer->style(), *parentRenderer)) 346 if (textRendererIsNeeded(*parentRenderer->style(), *parentRenderer))
347 rendererIsNeeded = true; 347 rendererIsNeeded = true;
348 } 348 }
349 } 349 }
350 350
351 if (rendererIsNeeded == !!renderer()) 351 if (rendererIsNeeded == !!renderer())
352 return; 352 return;
353 353
354 // The following is almost the same as Node::reattach() except that we creat e renderer only if needed. 354 // The following is almost the same as Node::reattach() except that we creat e renderer only if needed.
355 // Not calling reattach() to avoid repeated calls to Text::textRendererIsNee ded(). 355 // Not calling reattach() to avoid repeated calls to Text::textRendererIsNee ded().
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
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/editing/ApplyBlockElementCommand.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698