OLD | NEW |
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 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 { | 350 { |
351 Node* firstChild = node->firstChild(); | 351 Node* firstChild = node->firstChild(); |
352 return firstChild && !firstChild->nextSibling(); | 352 return firstChild && !firstChild->nextSibling(); |
353 } | 353 } |
354 | 354 |
355 static inline bool hasOneTextChild(ContainerNode* node) | 355 static inline bool hasOneTextChild(ContainerNode* node) |
356 { | 356 { |
357 return hasOneChild(node) && node->firstChild()->isTextNode(); | 357 return hasOneChild(node) && node->firstChild()->isTextNode(); |
358 } | 358 } |
359 | 359 |
360 static void replaceChildrenWithFragment(HTMLElement* element, PassRefPtr<Documen
tFragment> fragment, ExceptionCode& ec) | 360 static void replaceChildrenWithFragment(HTMLElement* elementNode, PassRefPtr<Doc
umentFragment> fragment, ExceptionCode& ec) |
361 { | 361 { |
| 362 RefPtr<HTMLElement> element(elementNode); |
362 #if ENABLE(MUTATION_OBSERVERS) | 363 #if ENABLE(MUTATION_OBSERVERS) |
363 ChildListMutationScope mutation(element); | 364 ChildListMutationScope mutation(element.get()); |
364 #endif | 365 #endif |
365 | 366 |
366 if (!fragment->firstChild()) { | 367 if (!fragment->firstChild()) { |
367 element->removeChildren(); | 368 element->removeChildren(); |
368 return; | 369 return; |
369 } | 370 } |
370 | 371 |
371 if (hasOneTextChild(element) && hasOneTextChild(fragment.get())) { | 372 if (hasOneTextChild(element.get()) && hasOneTextChild(fragment.get())) { |
372 static_cast<Text*>(element->firstChild())->setData(static_cast<Text*>(fr
agment->firstChild())->data(), ec); | 373 static_cast<Text*>(element->firstChild())->setData(static_cast<Text*>(fr
agment->firstChild())->data(), ec); |
373 return; | 374 return; |
374 } | 375 } |
375 | 376 |
376 if (hasOneChild(element)) { | 377 if (hasOneChild(element.get())) { |
377 element->replaceChild(fragment, element->firstChild(), ec); | 378 element->replaceChild(fragment, element->firstChild(), ec); |
378 return; | 379 return; |
379 } | 380 } |
380 | 381 |
381 element->removeChildren(); | 382 element->removeChildren(); |
382 element->appendChild(fragment, ec); | 383 element->appendChild(fragment, ec); |
383 } | 384 } |
384 | 385 |
385 static void replaceChildrenWithText(HTMLElement* element, const String& text, Ex
ceptionCode& ec) | 386 static void replaceChildrenWithText(HTMLElement* elementNode, const String& text
, ExceptionCode& ec) |
386 { | 387 { |
| 388 RefPtr<HTMLElement> element(elementNode); |
387 #if ENABLE(MUTATION_OBSERVERS) | 389 #if ENABLE(MUTATION_OBSERVERS) |
388 ChildListMutationScope mutation(element); | 390 ChildListMutationScope mutation(element.get()); |
389 #endif | 391 #endif |
390 | 392 |
391 if (hasOneTextChild(element)) { | 393 if (hasOneTextChild(element.get())) { |
392 static_cast<Text*>(element->firstChild())->setData(text, ec); | 394 static_cast<Text*>(element->firstChild())->setData(text, ec); |
393 return; | 395 return; |
394 } | 396 } |
395 | 397 |
396 RefPtr<Text> textNode = Text::create(element->document(), text); | 398 RefPtr<Text> textNode = Text::create(element->document(), text); |
397 | 399 |
398 if (hasOneChild(element)) { | 400 if (hasOneChild(element.get())) { |
399 element->replaceChild(textNode.release(), element->firstChild(), ec); | 401 element->replaceChild(textNode.release(), element->firstChild(), ec); |
400 return; | 402 return; |
401 } | 403 } |
402 | 404 |
403 element->removeChildren(); | 405 element->removeChildren(); |
404 element->appendChild(textNode.release(), ec); | 406 element->appendChild(textNode.release(), ec); |
405 } | 407 } |
406 | 408 |
407 // We may want to move a version of this function into DocumentFragment.h/cpp | 409 // We may want to move a version of this function into DocumentFragment.h/cpp |
408 static PassRefPtr<DocumentFragment> createFragmentFromSource(const String& marku
p, Element* contextElement, ExceptionCode& ec) | 410 static PassRefPtr<DocumentFragment> createFragmentFromSource(const String& marku
p, Element* contextElement, ExceptionCode& ec) |
(...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1065 #ifndef NDEBUG | 1067 #ifndef NDEBUG |
1066 | 1068 |
1067 // For use in the debugger | 1069 // For use in the debugger |
1068 void dumpInnerHTML(WebCore::HTMLElement*); | 1070 void dumpInnerHTML(WebCore::HTMLElement*); |
1069 | 1071 |
1070 void dumpInnerHTML(WebCore::HTMLElement* element) | 1072 void dumpInnerHTML(WebCore::HTMLElement* element) |
1071 { | 1073 { |
1072 printf("%s\n", element->innerHTML().ascii().data()); | 1074 printf("%s\n", element->innerHTML().ascii().data()); |
1073 } | 1075 } |
1074 #endif | 1076 #endif |
OLD | NEW |