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

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

Issue 200763006: Node::setTextContent should avoid work when nothing changes (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 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 | Annotate | Revision Log
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 * (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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 #include "core/dom/StaticNodeList.h" 52 #include "core/dom/StaticNodeList.h"
53 #include "core/dom/TemplateContentDocumentFragment.h" 53 #include "core/dom/TemplateContentDocumentFragment.h"
54 #include "core/dom/Text.h" 54 #include "core/dom/Text.h"
55 #include "core/dom/TreeScopeAdopter.h" 55 #include "core/dom/TreeScopeAdopter.h"
56 #include "core/dom/UserActionElementSet.h" 56 #include "core/dom/UserActionElementSet.h"
57 #include "core/dom/WheelController.h" 57 #include "core/dom/WheelController.h"
58 #include "core/dom/shadow/ElementShadow.h" 58 #include "core/dom/shadow/ElementShadow.h"
59 #include "core/dom/shadow/InsertionPoint.h" 59 #include "core/dom/shadow/InsertionPoint.h"
60 #include "core/dom/shadow/ShadowRoot.h" 60 #include "core/dom/shadow/ShadowRoot.h"
61 #include "core/editing/htmlediting.h" 61 #include "core/editing/htmlediting.h"
62 #include "core/editing/markup.h"
62 #include "core/events/BeforeLoadEvent.h" 63 #include "core/events/BeforeLoadEvent.h"
63 #include "core/events/Event.h" 64 #include "core/events/Event.h"
64 #include "core/events/EventDispatchMediator.h" 65 #include "core/events/EventDispatchMediator.h"
65 #include "core/events/EventDispatcher.h" 66 #include "core/events/EventDispatcher.h"
66 #include "core/events/EventListener.h" 67 #include "core/events/EventListener.h"
67 #include "core/events/GestureEvent.h" 68 #include "core/events/GestureEvent.h"
68 #include "core/events/KeyboardEvent.h" 69 #include "core/events/KeyboardEvent.h"
69 #include "core/events/MouseEvent.h" 70 #include "core/events/MouseEvent.h"
70 #include "core/events/MutationEvent.h" 71 #include "core/events/MutationEvent.h"
71 #include "core/events/TextEvent.h" 72 #include "core/events/TextEvent.h"
(...skipping 1418 matching lines...) Expand 10 before | Expand all | Expand 10 after
1490 switch (nodeType()) { 1491 switch (nodeType()) {
1491 case TEXT_NODE: 1492 case TEXT_NODE:
1492 case CDATA_SECTION_NODE: 1493 case CDATA_SECTION_NODE:
1493 case COMMENT_NODE: 1494 case COMMENT_NODE:
1494 case PROCESSING_INSTRUCTION_NODE: 1495 case PROCESSING_INSTRUCTION_NODE:
1495 setNodeValue(text); 1496 setNodeValue(text);
1496 return; 1497 return;
1497 case ELEMENT_NODE: 1498 case ELEMENT_NODE:
1498 case ATTRIBUTE_NODE: 1499 case ATTRIBUTE_NODE:
1499 case DOCUMENT_FRAGMENT_NODE: { 1500 case DOCUMENT_FRAGMENT_NODE: {
1500 RefPtr<ContainerNode> container = toContainerNode(this); 1501 replaceChildrenWithText(toContainerNode(this), text, ASSERT_NO_EXCEP TION);
1501 ChildListMutationScope mutation(*this);
1502 container->removeChildren();
1503 if (!text.isEmpty())
1504 container->appendChild(document().createTextNode(text), ASSERT_N O_EXCEPTION);
1505 return; 1502 return;
1506 } 1503 }
1507 case DOCUMENT_NODE: 1504 case DOCUMENT_NODE:
1508 case DOCUMENT_TYPE_NODE: 1505 case DOCUMENT_TYPE_NODE:
1509 // Do nothing. 1506 // Do nothing.
1510 return; 1507 return;
1511 } 1508 }
1512 ASSERT_NOT_REACHED(); 1509 ASSERT_NOT_REACHED();
1513 } 1510 }
1514 1511
(...skipping 1020 matching lines...) Expand 10 before | Expand all | Expand 10 after
2535 node->showTreeForThis(); 2532 node->showTreeForThis();
2536 } 2533 }
2537 2534
2538 void showNodePath(const WebCore::Node* node) 2535 void showNodePath(const WebCore::Node* node)
2539 { 2536 {
2540 if (node) 2537 if (node)
2541 node->showNodePathForThis(); 2538 node->showNodePathForThis();
2542 } 2539 }
2543 2540
2544 #endif 2541 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698