| 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 678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 689 | 689 |
| 690 void Node::markAncestorsWithChildNeedsDistributionRecalc() | 690 void Node::markAncestorsWithChildNeedsDistributionRecalc() |
| 691 { | 691 { |
| 692 for (Node* node = this; node && !node->childNeedsDistributionRecalc(); node
= node->parentOrShadowHostNode()) | 692 for (Node* node = this; node && !node->childNeedsDistributionRecalc(); node
= node->parentOrShadowHostNode()) |
| 693 node->setChildNeedsDistributionRecalc(); | 693 node->setChildNeedsDistributionRecalc(); |
| 694 document().scheduleRenderTreeUpdateIfNeeded(); | 694 document().scheduleRenderTreeUpdateIfNeeded(); |
| 695 } | 695 } |
| 696 | 696 |
| 697 namespace { | 697 namespace { |
| 698 | 698 |
| 699 PassRefPtr<JSONArray> jsStackAsJSONArray() | 699 void addJsStack(TracedArray<TracedValue>& stackFrames) |
| 700 { | 700 { |
| 701 RefPtr<JSONArray> jsonArray = JSONArray::create(); | |
| 702 RefPtrWillBeRawPtr<ScriptCallStack> stack = createScriptCallStack(10); | 701 RefPtrWillBeRawPtr<ScriptCallStack> stack = createScriptCallStack(10); |
| 703 if (!stack) | 702 if (!stack) |
| 704 return jsonArray.release(); | 703 return; |
| 705 for (size_t i = 0; i < stack->size(); i++) | 704 for (size_t i = 0; i < stack->size(); i++) |
| 706 jsonArray->pushString(stack->at(i).functionName()); | 705 stackFrames.pushString(stack->at(i).functionName()); |
| 707 return jsonArray.release(); | |
| 708 } | 706 } |
| 709 | 707 |
| 710 PassRefPtr<JSONObject> jsonObjectForStyleInvalidation(unsigned nodeCount, const
Node* rootNode) | 708 PassRefPtr<TraceEvent::ConvertableToTraceFormat> jsonObjectForStyleInvalidation(
unsigned nodeCount, const Node* rootNode) |
| 711 { | 709 { |
| 712 RefPtr<JSONObject> jsonObject = JSONObject::create(); | 710 TracedValue value; |
| 713 jsonObject->setNumber("node_count", nodeCount); | 711 value.setInteger("node_count", nodeCount); |
| 714 jsonObject->setString("root_node", rootNode->debugName()); | 712 value.setString("root_node", rootNode->debugName()); |
| 715 jsonObject->setArray("js_stack", jsStackAsJSONArray()); | 713 TracedArray<TracedValue>& array = value.beginArray("js_stack"); |
| 716 return jsonObject.release(); | 714 addJsStack(array); |
| 715 array.endArray(); |
| 716 return value.finish(); |
| 717 } | 717 } |
| 718 | 718 |
| 719 } // anonymous namespace'd functions supporting traceStyleChange | 719 } // anonymous namespace'd functions supporting traceStyleChange |
| 720 | 720 |
| 721 unsigned Node::styledSubtreeSize() const | 721 unsigned Node::styledSubtreeSize() const |
| 722 { | 722 { |
| 723 unsigned nodeCount = 0; | 723 unsigned nodeCount = 0; |
| 724 | 724 |
| 725 for (const Node* node = this; node; node = NodeTraversal::next(*node, this))
{ | 725 for (const Node* node = this; node; node = NodeTraversal::next(*node, this))
{ |
| 726 if (node->isTextNode() || node->isElementNode()) | 726 if (node->isTextNode() || node->isElementNode()) |
| 727 nodeCount++; | 727 nodeCount++; |
| 728 for (ShadowRoot* root = node->youngestShadowRoot(); root; root = root->o
lderShadowRoot()) | 728 for (ShadowRoot* root = node->youngestShadowRoot(); root; root = root->o
lderShadowRoot()) |
| 729 nodeCount += root->styledSubtreeSize(); | 729 nodeCount += root->styledSubtreeSize(); |
| 730 } | 730 } |
| 731 | 731 |
| 732 return nodeCount; | 732 return nodeCount; |
| 733 } | 733 } |
| 734 | 734 |
| 735 void Node::traceStyleChange(StyleChangeType changeType) | 735 void Node::traceStyleChange(StyleChangeType changeType) |
| 736 { | 736 { |
| 737 static const unsigned kMinLoggedSize = 100; | 737 static const unsigned kMinLoggedSize = 100; |
| 738 unsigned nodeCount = styledSubtreeSize(); | 738 unsigned nodeCount = styledSubtreeSize(); |
| 739 if (nodeCount < kMinLoggedSize) | 739 if (nodeCount < kMinLoggedSize) |
| 740 return; | 740 return; |
| 741 | 741 |
| 742 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("style.debug"), | 742 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("style.debug"), |
| 743 "Node::setNeedsStyleRecalc", | 743 "Node::setNeedsStyleRecalc", |
| 744 "data", TracedValue::fromJSONValue(jsonObjectForStyleInvalidation(nodeCo
unt, this)) | 744 "data", jsonObjectForStyleInvalidation(nodeCount, this) |
| 745 ); | 745 ); |
| 746 } | 746 } |
| 747 | 747 |
| 748 void Node::traceStyleChangeIfNeeded(StyleChangeType changeType) | 748 void Node::traceStyleChangeIfNeeded(StyleChangeType changeType) |
| 749 { | 749 { |
| 750 // TRACE_EVENT_CATEGORY_GROUP_ENABLED macro loads a global static bool into
our local bool. | 750 // TRACE_EVENT_CATEGORY_GROUP_ENABLED macro loads a global static bool into
our local bool. |
| 751 bool styleTracingEnabled; | 751 bool styleTracingEnabled; |
| 752 TRACE_EVENT_CATEGORY_GROUP_ENABLED(TRACE_DISABLED_BY_DEFAULT("style.debug"),
&styleTracingEnabled); | 752 TRACE_EVENT_CATEGORY_GROUP_ENABLED(TRACE_DISABLED_BY_DEFAULT("style.debug"),
&styleTracingEnabled); |
| 753 if (UNLIKELY(styleTracingEnabled)) | 753 if (UNLIKELY(styleTracingEnabled)) |
| 754 traceStyleChange(changeType); | 754 traceStyleChange(changeType); |
| (...skipping 1817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2572 node->showTreeForThis(); | 2572 node->showTreeForThis(); |
| 2573 } | 2573 } |
| 2574 | 2574 |
| 2575 void showNodePath(const WebCore::Node* node) | 2575 void showNodePath(const WebCore::Node* node) |
| 2576 { | 2576 { |
| 2577 if (node) | 2577 if (node) |
| 2578 node->showNodePathForThis(); | 2578 node->showNodePathForThis(); |
| 2579 } | 2579 } |
| 2580 | 2580 |
| 2581 #endif | 2581 #endif |
| OLD | NEW |