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

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 if (!start)
959 return;
960
961 RenderObject* parentRenderer = NodeRenderingTraversal::parent(start)->render er();
esprehn 2014/11/04 22:03:55 This function can probably be called in situations
962 ASSERT(parentRenderer && parentRenderer->style());
esprehn 2014/11/04 22:03:55 asserting ->style() on a RenderObject doesn't make
958 for (Node* sibling = start; sibling; sibling = sibling->nextSibling()) { 963 for (Node* sibling = start; sibling; sibling = sibling->nextSibling()) {
959 if (sibling->isTextNode() && toText(sibling)->containsOnlyWhitespace()) { 964 if (sibling->isTextNode() && toText(sibling)->containsOnlyWhitespace()) {
960 bool hadRenderer = !!sibling->renderer(); 965 bool hadRenderer = !!sibling->renderer();
966 bool rendererIsNeeded = toText(sibling)->textRendererIsNeeded(*paren tRenderer->style(), *parentRenderer);
esprehn 2014/11/04 22:03:55 This is going to be a perf regression, calling tex
Xianzhu 2014/11/05 01:30:13 To avoid the twice calling to textRendererIsNeeded
967 // If rendererIsNeeded didn't change we don't need to continue check ing
968 // siblings since their rendererIsNeeded won't change either.
969 if (hadRenderer == rendererIsNeeded)
970 return;
961 sibling->reattach(); 971 sibling->reattach();
962 // If the reattach didn't toggle the visibility of the whitespace we don't
963 // need to continue reattaching siblings since they won't toggle vis ibility
964 // either.
965 if (hadRenderer == !!sibling->renderer())
966 return;
967 } else if (sibling->renderer()) { 972 } else if (sibling->renderer()) {
968 return; 973 return;
969 } 974 }
970 } 975 }
971 } 976 }
972 977
973 // FIXME: This code is used by editing. Seems like it could move over there and not pollute Node. 978 // FIXME: This code is used by editing. Seems like it could move over there and not pollute Node.
974 Node* Node::previousNodeConsideringAtomicNodes() const 979 Node* Node::previousNodeConsideringAtomicNodes() const
975 { 980 {
976 if (previousSibling()) { 981 if (previousSibling()) {
(...skipping 1479 matching lines...) Expand 10 before | Expand all | Expand 10 after
2456 node->showTreeForThis(); 2461 node->showTreeForThis();
2457 } 2462 }
2458 2463
2459 void showNodePath(const blink::Node* node) 2464 void showNodePath(const blink::Node* node)
2460 { 2465 {
2461 if (node) 2466 if (node)
2462 node->showNodePathForThis(); 2467 node->showNodePathForThis();
2463 } 2468 }
2464 2469
2465 #endif 2470 #endif
OLDNEW
« no previous file with comments | « Source/core/dom/Node.h ('k') | Source/core/dom/Text.cpp » ('j') | Source/core/dom/Text.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698