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

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

Issue 61833006: DO NOT LAND - Code for debugging excess style recalcs (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add JS stack printing and make output nicer Created 7 years 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 #include "core/svg/graphics/SVGImage.h" 89 #include "core/svg/graphics/SVGImage.h"
90 #include "platform/Partitions.h" 90 #include "platform/Partitions.h"
91 #include "wtf/HashSet.h" 91 #include "wtf/HashSet.h"
92 #include "wtf/PassOwnPtr.h" 92 #include "wtf/PassOwnPtr.h"
93 #include "wtf/RefCountedLeakCounter.h" 93 #include "wtf/RefCountedLeakCounter.h"
94 #include "wtf/UnusedParam.h" 94 #include "wtf/UnusedParam.h"
95 #include "wtf/Vector.h" 95 #include "wtf/Vector.h"
96 #include "wtf/text/CString.h" 96 #include "wtf/text/CString.h"
97 #include "wtf/text/StringBuilder.h" 97 #include "wtf/text/StringBuilder.h"
98 98
99 #include "base/debug/stack_trace.h"
100 #include "bindings/v8/ScriptCallStackFactory.h"
101
99 using namespace std; 102 using namespace std;
100 103
101 namespace WebCore { 104 namespace WebCore {
102 105
103 using namespace HTMLNames; 106 using namespace HTMLNames;
104 107
105 void* Node::operator new(size_t size) 108 void* Node::operator new(size_t size)
106 { 109 {
107 ASSERT(isMainThread()); 110 ASSERT(isMainThread());
108 return partitionAlloc(Partitions::getObjectModelPartition(), size); 111 return partitionAlloc(Partitions::getObjectModelPartition(), size);
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 } 695 }
693 696
694 void Node::markAncestorsWithChildNeedsDistributionRecalc() 697 void Node::markAncestorsWithChildNeedsDistributionRecalc()
695 { 698 {
696 for (Node* node = this; node && !node->childNeedsDistributionRecalc(); node = node->parentOrShadowHostNode()) 699 for (Node* node = this; node && !node->childNeedsDistributionRecalc(); node = node->parentOrShadowHostNode())
697 node->setChildNeedsDistributionRecalc(); 700 node->setChildNeedsDistributionRecalc();
698 if (document().childNeedsDistributionRecalc()) 701 if (document().childNeedsDistributionRecalc())
699 document().scheduleStyleRecalc(); 702 document().scheduleStyleRecalc();
700 } 703 }
701 704
705 size_t subtreeSize(Node* rootNode)
706 {
707 size_t subtreeSize = 1;
708 Node* currentNode = rootNode;
709 while ((currentNode = NodeTraversal::next(*currentNode, rootNode)))
710 subtreeSize++;
711 return subtreeSize;
712 }
713
714 static void printJSStackTrace()
715 {
716 RefPtr<ScriptCallStack> stack = createScriptCallStack(10);
717 if (!stack) {
718 // The last function in the JS stack always seems to be an empty string?
719 // to compensate, print an extra \n here.
720 printf("Not JS triggered.\n\n");
721 return;
722 }
723 printf("JS Stack:\n");
724 for (size_t i = 0; i < stack->size(); i++)
725 printf("%s\n", stack->at(i).functionName().ascii().data());
726 printf("\n");
727 }
728
702 inline void Node::setStyleChange(StyleChangeType changeType) 729 inline void Node::setStyleChange(StyleChangeType changeType)
703 { 730 {
731 static const size_t kMinLoggedSize = 100;
732 if (changeType >= SubtreeStyleChange) {
733 size_t nodeCount = subtreeSize(this);
734 if (nodeCount >= kMinLoggedSize) {
735 printf("\n\nINVALIDATED style on tree of %zu nodes (threshold: %zu)\ n", nodeCount, kMinLoggedSize);
736 printf("Root: %s\n\n", debugName().ascii().data());
737 printJSStackTrace();
738 printf("C++ Stack:\n");
739 base::debug::StackTrace().Print();
740 }
741 }
704 m_nodeFlags = (m_nodeFlags & ~StyleChangeMask) | changeType; 742 m_nodeFlags = (m_nodeFlags & ~StyleChangeMask) | changeType;
705 } 743 }
706 744
707 void Node::markAncestorsWithChildNeedsStyleRecalc() 745 void Node::markAncestorsWithChildNeedsStyleRecalc()
708 { 746 {
709 for (ContainerNode* p = parentOrShadowHostNode(); p && !p->childNeedsStyleRe calc(); p = p->parentOrShadowHostNode()) 747 for (ContainerNode* p = parentOrShadowHostNode(); p && !p->childNeedsStyleRe calc(); p = p->parentOrShadowHostNode())
710 p->setChildNeedsStyleRecalc(); 748 p->setChildNeedsStyleRecalc();
711 749
712 if (document().needsStyleRecalc() || document().childNeedsStyleRecalc()) 750 if (document().needsStyleRecalc() || document().childNeedsStyleRecalc())
713 document().scheduleStyleRecalc(); 751 document().scheduleStyleRecalc();
(...skipping 1957 matching lines...) Expand 10 before | Expand all | Expand 10 after
2671 node->showTreeForThis(); 2709 node->showTreeForThis();
2672 } 2710 }
2673 2711
2674 void showNodePath(const WebCore::Node* node) 2712 void showNodePath(const WebCore::Node* node)
2675 { 2713 {
2676 if (node) 2714 if (node)
2677 node->showNodePathForThis(); 2715 node->showNodePathForThis();
2678 } 2716 }
2679 2717
2680 #endif 2718 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698