| 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 * (C) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
| 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r
ights reserved. | 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r
ights reserved. |
| 6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) | 6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) |
| 7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) | 7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) |
| 8 * | 8 * |
| 9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
| 10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
| (...skipping 1384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1395 void Node::setTextContent(const String& text) | 1395 void Node::setTextContent(const String& text) |
| 1396 { | 1396 { |
| 1397 switch (nodeType()) { | 1397 switch (nodeType()) { |
| 1398 case TEXT_NODE: | 1398 case TEXT_NODE: |
| 1399 case CDATA_SECTION_NODE: | 1399 case CDATA_SECTION_NODE: |
| 1400 case COMMENT_NODE: | 1400 case COMMENT_NODE: |
| 1401 case PROCESSING_INSTRUCTION_NODE: | 1401 case PROCESSING_INSTRUCTION_NODE: |
| 1402 setNodeValue(text); | 1402 setNodeValue(text); |
| 1403 return; | 1403 return; |
| 1404 case ELEMENT_NODE: | 1404 case ELEMENT_NODE: |
| 1405 case ATTRIBUTE_NODE: | |
| 1406 case DOCUMENT_FRAGMENT_NODE: { | 1405 case DOCUMENT_FRAGMENT_NODE: { |
| 1407 // FIXME: Merge this logic into replaceChildrenWithText. | 1406 // FIXME: Merge this logic into replaceChildrenWithText. |
| 1408 RefPtrWillBeRawPtr<ContainerNode> container = toContainerNode(this); | 1407 RefPtrWillBeRawPtr<ContainerNode> container = toContainerNode(this); |
| 1409 | 1408 |
| 1410 // Note: This is an intentional optimization. | 1409 // Note: This is an intentional optimization. |
| 1411 // See crbug.com/352836 also. | 1410 // See crbug.com/352836 also. |
| 1412 // No need to do anything if the text is identical. | 1411 // No need to do anything if the text is identical. |
| 1413 if (container->hasOneTextChild() && toText(container->firstChild())-
>data() == text) | 1412 if (container->hasOneTextChild() && toText(container->firstChild())-
>data() == text) |
| 1414 return; | 1413 return; |
| 1415 | 1414 |
| 1416 ChildListMutationScope mutation(*this); | 1415 ChildListMutationScope mutation(*this); |
| 1417 // Note: This API will not insert empty text nodes: | 1416 // Note: This API will not insert empty text nodes: |
| 1418 // http://dom.spec.whatwg.org/#dom-node-textcontent | 1417 // http://dom.spec.whatwg.org/#dom-node-textcontent |
| 1419 if (text.isEmpty()) { | 1418 if (text.isEmpty()) { |
| 1420 container->removeChildren(DispatchSubtreeModifiedEvent); | 1419 container->removeChildren(DispatchSubtreeModifiedEvent); |
| 1421 } else { | 1420 } else { |
| 1422 container->removeChildren(OmitSubtreeModifiedEvent); | 1421 container->removeChildren(OmitSubtreeModifiedEvent); |
| 1423 container->appendChild(document().createTextNode(text), ASSERT_N
O_EXCEPTION); | 1422 container->appendChild(document().createTextNode(text), ASSERT_N
O_EXCEPTION); |
| 1424 } | 1423 } |
| 1425 return; | 1424 return; |
| 1426 } | 1425 } |
| 1426 case ATTRIBUTE_NODE: |
| 1427 case DOCUMENT_NODE: | 1427 case DOCUMENT_NODE: |
| 1428 case DOCUMENT_TYPE_NODE: | 1428 case DOCUMENT_TYPE_NODE: |
| 1429 // Do nothing. | 1429 // Do nothing. |
| 1430 return; | 1430 return; |
| 1431 } | 1431 } |
| 1432 ASSERT_NOT_REACHED(); | 1432 ASSERT_NOT_REACHED(); |
| 1433 } | 1433 } |
| 1434 | 1434 |
| 1435 bool Node::offsetInCharacters() const | 1435 bool Node::offsetInCharacters() const |
| 1436 { | 1436 { |
| (...skipping 1000 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2437 { | 2437 { |
| 2438 // This switch statement must be consistent with that of Range::processConte
ntsBetweenOffsets. | 2438 // This switch statement must be consistent with that of Range::processConte
ntsBetweenOffsets. |
| 2439 switch (nodeType()) { | 2439 switch (nodeType()) { |
| 2440 case Node::TEXT_NODE: | 2440 case Node::TEXT_NODE: |
| 2441 case Node::CDATA_SECTION_NODE: | 2441 case Node::CDATA_SECTION_NODE: |
| 2442 case Node::COMMENT_NODE: | 2442 case Node::COMMENT_NODE: |
| 2443 return toCharacterData(this)->length(); | 2443 return toCharacterData(this)->length(); |
| 2444 case Node::PROCESSING_INSTRUCTION_NODE: | 2444 case Node::PROCESSING_INSTRUCTION_NODE: |
| 2445 return toProcessingInstruction(this)->data().length(); | 2445 return toProcessingInstruction(this)->data().length(); |
| 2446 case Node::ELEMENT_NODE: | 2446 case Node::ELEMENT_NODE: |
| 2447 case Node::ATTRIBUTE_NODE: | |
| 2448 case Node::DOCUMENT_NODE: | 2447 case Node::DOCUMENT_NODE: |
| 2449 case Node::DOCUMENT_FRAGMENT_NODE: | 2448 case Node::DOCUMENT_FRAGMENT_NODE: |
| 2450 return toContainerNode(this)->countChildren(); | 2449 return toContainerNode(this)->countChildren(); |
| 2450 case Node::ATTRIBUTE_NODE: |
| 2451 case Node::DOCUMENT_TYPE_NODE: | 2451 case Node::DOCUMENT_TYPE_NODE: |
| 2452 return 0; | 2452 return 0; |
| 2453 } | 2453 } |
| 2454 ASSERT_NOT_REACHED(); | 2454 ASSERT_NOT_REACHED(); |
| 2455 return 0; | 2455 return 0; |
| 2456 } | 2456 } |
| 2457 | 2457 |
| 2458 v8::Local<v8::Object> Node::wrap(v8::Isolate* isolate, v8::Local<v8::Object> cre
ationContext) | 2458 v8::Local<v8::Object> Node::wrap(v8::Isolate* isolate, v8::Local<v8::Object> cre
ationContext) |
| 2459 { | 2459 { |
| 2460 // It's possible that no one except for the new wrapper owns this object at | 2460 // It's possible that no one except for the new wrapper owns this object at |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2501 | 2501 |
| 2502 void showNodePath(const blink::Node* node) | 2502 void showNodePath(const blink::Node* node) |
| 2503 { | 2503 { |
| 2504 if (node) | 2504 if (node) |
| 2505 node->showNodePathForThis(); | 2505 node->showNodePathForThis(); |
| 2506 else | 2506 else |
| 2507 fprintf(stderr, "Cannot showNodePath for (nil)\n"); | 2507 fprintf(stderr, "Cannot showNodePath for (nil)\n"); |
| 2508 } | 2508 } |
| 2509 | 2509 |
| 2510 #endif | 2510 #endif |
| OLD | NEW |