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

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

Issue 684633006: Reattach whitespace siblings only when needed (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 1 month 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 935 matching lines...) Expand 10 before | Expand all | Expand 10 after
946 if (StyleResolver* resolver = document().styleResolver()) 946 if (StyleResolver* resolver = document().styleResolver())
947 resolver->ruleFeatureSet().styleInvalidator().clearInvalidation(*this); 947 resolver->ruleFeatureSet().styleInvalidator().clearInvalidation(*this);
948 clearChildNeedsStyleInvalidation(); 948 clearChildNeedsStyleInvalidation();
949 clearNeedsStyleInvalidation(); 949 clearNeedsStyleInvalidation();
950 950
951 #if ENABLE(ASSERT) 951 #if ENABLE(ASSERT)
952 detachingNode = nullptr; 952 detachingNode = nullptr;
953 #endif 953 #endif
954 } 954 }
955 955
956 void Node::reattachWhitespaceSiblings(Text* start) 956 void Node::reattachWhitespaceSiblingsIfNeeded(Text* start)
957 { 957 {
958 for (Node* sibling = start; sibling; sibling = sibling->nextSibling()) { 958 for (Node* sibling = start; sibling; sibling = sibling->nextSibling()) {
959 if (sibling->isTextNode() && toText(sibling)->containsOnlyWhitespace()) { 959 if (sibling->isTextNode() && toText(sibling)->containsOnlyWhitespace()) {
960 bool hadRenderer = !!sibling->renderer(); 960 bool hadRenderer = !!sibling->renderer();
961 sibling->reattach(); 961 toText(sibling)->reattachIfNeeded();
962 // If the reattach didn't toggle the visibility of the whitespace we don't 962 // If sibling's renderer status didn't change we don't need to conti nue checking
963 // need to continue reattaching siblings since they won't toggle vis ibility 963 // other siblings since their renderer status won't change either.
964 // either. 964 if (!!sibling->renderer() == hadRenderer)
965 if (hadRenderer == !!sibling->renderer())
966 return; 965 return;
967 } else if (sibling->renderer()) { 966 } else if (sibling->renderer()) {
968 return; 967 return;
969 } 968 }
970 } 969 }
971 } 970 }
972 971
973 // FIXME: This code is used by editing. Seems like it could move over there and not pollute Node. 972 // FIXME: This code is used by editing. Seems like it could move over there and not pollute Node.
974 Node* Node::previousNodeConsideringAtomicNodes() const 973 Node* Node::previousNodeConsideringAtomicNodes() const
975 { 974 {
(...skipping 1480 matching lines...) Expand 10 before | Expand all | Expand 10 after
2456 node->showTreeForThis(); 2455 node->showTreeForThis();
2457 } 2456 }
2458 2457
2459 void showNodePath(const blink::Node* node) 2458 void showNodePath(const blink::Node* node)
2460 { 2459 {
2461 if (node) 2460 if (node)
2462 node->showNodePathForThis(); 2461 node->showNodePathForThis();
2463 } 2462 }
2464 2463
2465 #endif 2464 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698