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

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

Issue 1854423002: ASSERT -> {DCHECK|DCHECK_XX}, ENABLE(ASSERT) -> DCHECK_IS_ON() in dom (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: mark svg/as-image/svg-nested.html crash on win Created 4 years, 8 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
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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 CRASH(); 177 CRASH();
178 resultLength += data.length(); 178 resultLength += data.length();
179 } 179 }
180 StringBuilder result; 180 StringBuilder result;
181 result.reserveCapacity(resultLength); 181 result.reserveCapacity(resultLength);
182 for (const Node* n = startText; n != onePastEndText; n = n->nextSibling()) { 182 for (const Node* n = startText; n != onePastEndText; n = n->nextSibling()) {
183 if (!n->isTextNode()) 183 if (!n->isTextNode())
184 continue; 184 continue;
185 result.append(toText(n)->data()); 185 result.append(toText(n)->data());
186 } 186 }
187 ASSERT(result.length() == resultLength); 187 DCHECK_EQ(result.length(), resultLength);
188 188
189 return result.toString(); 189 return result.toString();
190 } 190 }
191 191
192 RawPtr<Text> Text::replaceWholeText(const String& newText) 192 RawPtr<Text> Text::replaceWholeText(const String& newText)
193 { 193 {
194 // Remove all adjacent text nodes, and replace the contents of this one. 194 // Remove all adjacent text nodes, and replace the contents of this one.
195 195
196 // Protect startText and endText against mutation event handlers removing th e last ref 196 // Protect startText and endText against mutation event handlers removing th e last ref
197 RawPtr<Text> startText = const_cast<Text*>(earliestLogicallyAdjacentTextNode (this)); 197 RawPtr<Text> startText = const_cast<Text*>(earliestLogicallyAdjacentTextNode (this));
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 // make a layout object for this text. 319 // make a layout object for this text.
320 return !firstChildNode; 320 return !firstChildNode;
321 } 321 }
322 } 322 }
323 return true; 323 return true;
324 } 324 }
325 325
326 static bool isSVGText(Text* text) 326 static bool isSVGText(Text* text)
327 { 327 {
328 Node* parentOrShadowHostNode = text->parentOrShadowHostNode(); 328 Node* parentOrShadowHostNode = text->parentOrShadowHostNode();
329 ASSERT(parentOrShadowHostNode); 329 DCHECK(parentOrShadowHostNode);
330 return parentOrShadowHostNode->isSVGElement() && !isSVGForeignObjectElement( *parentOrShadowHostNode); 330 return parentOrShadowHostNode->isSVGElement() && !isSVGForeignObjectElement( *parentOrShadowHostNode);
331 } 331 }
332 332
333 LayoutText* Text::createTextLayoutObject(const ComputedStyle& style) 333 LayoutText* Text::createTextLayoutObject(const ComputedStyle& style)
334 { 334 {
335 if (isSVGText(this)) 335 if (isSVGText(this))
336 return new LayoutSVGInlineText(this, dataImpl()); 336 return new LayoutSVGInlineText(this, dataImpl());
337 337
338 if (style.hasTextCombine()) 338 if (style.hasTextCombine())
339 return new LayoutTextCombine(this, dataImpl()); 339 return new LayoutTextCombine(this, dataImpl());
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 reattach(); 390 reattach();
391 if (this->layoutObject()) 391 if (this->layoutObject())
392 reattachWhitespaceSiblingsIfNeeded(nextTextSibling); 392 reattachWhitespaceSiblingsIfNeeded(nextTextSibling);
393 } 393 }
394 } 394 }
395 395
396 // If a whitespace node had no layoutObject and goes through a recalcStyle it ma y 396 // If a whitespace node had no layoutObject and goes through a recalcStyle it ma y
397 // need to create one if the parent style now has white-space: pre. 397 // need to create one if the parent style now has white-space: pre.
398 bool Text::needsWhitespaceLayoutObject() 398 bool Text::needsWhitespaceLayoutObject()
399 { 399 {
400 ASSERT(!layoutObject()); 400 DCHECK(!layoutObject());
401 if (const ComputedStyle* style = parentComputedStyle()) 401 if (const ComputedStyle* style = parentComputedStyle())
402 return style->preserveNewline(); 402 return style->preserveNewline();
403 return false; 403 return false;
404 } 404 }
405 405
406 // Passing both |textNode| and its layout object because repeated calls to 406 // Passing both |textNode| and its layout object because repeated calls to
407 // |Node::layoutObject()| are discouraged. 407 // |Node::layoutObject()| are discouraged.
408 static bool shouldUpdateLayoutByReattaching(const Text& textNode, LayoutText* te xtLayoutObject) 408 static bool shouldUpdateLayoutByReattaching(const Text& textNode, LayoutText* te xtLayoutObject)
409 { 409 {
410 ASSERT(textNode.layoutObject() == textLayoutObject); 410 DCHECK_EQ(textNode.layoutObject(), textLayoutObject);
411 if (!textLayoutObject) 411 if (!textLayoutObject)
412 return true; 412 return true;
413 if (!textNode.textLayoutObjectIsNeeded(*textLayoutObject->style(), *textLayo utObject->parent())) 413 if (!textNode.textLayoutObjectIsNeeded(*textLayoutObject->style(), *textLayo utObject->parent()))
414 return true; 414 return true;
415 if (textLayoutObject->isTextFragment()) { 415 if (textLayoutObject->isTextFragment()) {
416 FirstLetterPseudoElement* pseudo = toLayoutTextFragment(textLayoutObject )->firstLetterPseudoElement(); 416 FirstLetterPseudoElement* pseudo = toLayoutTextFragment(textLayoutObject )->firstLetterPseudoElement();
417 if (pseudo && !FirstLetterPseudoElement::firstLetterTextLayoutObject(*ps eudo)) 417 if (pseudo && !FirstLetterPseudoElement::firstLetterTextLayoutObject(*ps eudo))
418 return true; 418 return true;
419 } 419 }
420 return false; 420 return false;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 result.appendLiteral("; "); 459 result.appendLiteral("; ");
460 result.appendLiteral("value="); 460 result.appendLiteral("value=");
461 result.append(s); 461 result.append(s);
462 } 462 }
463 463
464 strncpy(buffer, result.toString().utf8().data(), length - 1); 464 strncpy(buffer, result.toString().utf8().data(), length - 1);
465 } 465 }
466 #endif 466 #endif
467 467
468 } // namespace blink 468 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/TagCollection.cpp ('k') | third_party/WebKit/Source/core/dom/TreeScope.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698