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

Side by Side Diff: Source/WebCore/html/HTMLElement.cpp

Issue 9569046: Merge 109362 (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/963/
Patch Set: Created 8 years, 9 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
« no previous file with comments | « Source/WebCore/editing/markup.cpp ('k') | Source/WebCore/html/HTMLOptionElement.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) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. 4 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
5 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 5 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
6 * Copyright (C) 2011 Motorola Mobility. All rights reserved. 6 * Copyright (C) 2011 Motorola Mobility. All rights reserved.
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 { 328 {
329 Node* firstChild = node->firstChild(); 329 Node* firstChild = node->firstChild();
330 return firstChild && !firstChild->nextSibling(); 330 return firstChild && !firstChild->nextSibling();
331 } 331 }
332 332
333 static inline bool hasOneTextChild(ContainerNode* node) 333 static inline bool hasOneTextChild(ContainerNode* node)
334 { 334 {
335 return hasOneChild(node) && node->firstChild()->isTextNode(); 335 return hasOneChild(node) && node->firstChild()->isTextNode();
336 } 336 }
337 337
338 static void replaceChildrenWithFragment(HTMLElement* element, PassRefPtr<Documen tFragment> fragment, ExceptionCode& ec) 338 static void replaceChildrenWithFragment(HTMLElement* elementNode, PassRefPtr<Doc umentFragment> fragment, ExceptionCode& ec)
339 { 339 {
340 RefPtr<HTMLElement> element(elementNode);
340 #if ENABLE(MUTATION_OBSERVERS) 341 #if ENABLE(MUTATION_OBSERVERS)
341 ChildListMutationScope mutation(element); 342 ChildListMutationScope mutation(element.get());
342 #endif 343 #endif
343 344
344 if (!fragment->firstChild()) { 345 if (!fragment->firstChild()) {
345 element->removeChildren(); 346 element->removeChildren();
346 return; 347 return;
347 } 348 }
348 349
349 if (hasOneTextChild(element) && hasOneTextChild(fragment.get())) { 350 if (hasOneTextChild(element.get()) && hasOneTextChild(fragment.get())) {
350 static_cast<Text*>(element->firstChild())->setData(static_cast<Text*>(fr agment->firstChild())->data(), ec); 351 static_cast<Text*>(element->firstChild())->setData(static_cast<Text*>(fr agment->firstChild())->data(), ec);
351 return; 352 return;
352 } 353 }
353 354
354 if (hasOneChild(element)) { 355 if (hasOneChild(element.get())) {
355 element->replaceChild(fragment, element->firstChild(), ec); 356 element->replaceChild(fragment, element->firstChild(), ec);
356 return; 357 return;
357 } 358 }
358 359
359 element->removeChildren(); 360 element->removeChildren();
360 element->appendChild(fragment, ec); 361 element->appendChild(fragment, ec);
361 } 362 }
362 363
363 static void replaceChildrenWithText(HTMLElement* element, const String& text, Ex ceptionCode& ec) 364 static void replaceChildrenWithText(HTMLElement* elementNode, const String& text , ExceptionCode& ec)
364 { 365 {
366 RefPtr<HTMLElement> element(elementNode);
365 #if ENABLE(MUTATION_OBSERVERS) 367 #if ENABLE(MUTATION_OBSERVERS)
366 ChildListMutationScope mutation(element); 368 ChildListMutationScope mutation(element.get());
367 #endif 369 #endif
368 370
369 if (hasOneTextChild(element)) { 371 if (hasOneTextChild(element.get())) {
370 static_cast<Text*>(element->firstChild())->setData(text, ec); 372 static_cast<Text*>(element->firstChild())->setData(text, ec);
371 return; 373 return;
372 } 374 }
373 375
374 RefPtr<Text> textNode = Text::create(element->document(), text); 376 RefPtr<Text> textNode = Text::create(element->document(), text);
375 377
376 if (hasOneChild(element)) { 378 if (hasOneChild(element.get())) {
377 element->replaceChild(textNode.release(), element->firstChild(), ec); 379 element->replaceChild(textNode.release(), element->firstChild(), ec);
378 return; 380 return;
379 } 381 }
380 382
381 element->removeChildren(); 383 element->removeChildren();
382 element->appendChild(textNode.release(), ec); 384 element->appendChild(textNode.release(), ec);
383 } 385 }
384 386
385 // We may want to move a version of this function into DocumentFragment.h/cpp 387 // We may want to move a version of this function into DocumentFragment.h/cpp
386 static PassRefPtr<DocumentFragment> createFragmentFromSource(const String& marku p, Element* contextElement, ExceptionCode& ec) 388 static PassRefPtr<DocumentFragment> createFragmentFromSource(const String& marku p, Element* contextElement, ExceptionCode& ec)
(...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after
1043 #ifndef NDEBUG 1045 #ifndef NDEBUG
1044 1046
1045 // For use in the debugger 1047 // For use in the debugger
1046 void dumpInnerHTML(WebCore::HTMLElement*); 1048 void dumpInnerHTML(WebCore::HTMLElement*);
1047 1049
1048 void dumpInnerHTML(WebCore::HTMLElement* element) 1050 void dumpInnerHTML(WebCore::HTMLElement* element)
1049 { 1051 {
1050 printf("%s\n", element->innerHTML().ascii().data()); 1052 printf("%s\n", element->innerHTML().ascii().data());
1051 } 1053 }
1052 #endif 1054 #endif
OLDNEW
« no previous file with comments | « Source/WebCore/editing/markup.cpp ('k') | Source/WebCore/html/HTMLOptionElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698