| 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 |
| 11 * License as published by the Free Software Foundation; either | 11 * License as published by the Free Software Foundation; either |
| 12 * version 2 of the License, or (at your option) any later version. | 12 * version 2 of the License, or (at your option) any later version. |
| 13 * | 13 * |
| 14 * This library is distributed in the hope that it will be useful, | 14 * This library is distributed in the hope that it will be useful, |
| 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 17 * Library General Public License for more details. | 17 * Library General Public License for more details. |
| 18 * | 18 * |
| 19 * You should have received a copy of the GNU Library General Public License | 19 * You should have received a copy of the GNU Library General Public License |
| 20 * along with this library; see the file COPYING.LIB. If not, write to | 20 * along with this library; see the file COPYING.LIB. If not, write to |
| 21 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 21 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 22 * Boston, MA 02110-1301, USA. | 22 * Boston, MA 02110-1301, USA. |
| 23 */ | 23 */ |
| 24 | 24 |
| 25 #include "sky/engine/config.h" | 25 #include "sky/engine/config.h" |
| 26 #include "sky/engine/core/dom/Node.h" | 26 #include "sky/engine/core/dom/Node.h" |
| 27 | 27 |
| 28 #include "base/trace_event/trace_event_impl.h" |
| 28 #include "gen/sky/core/HTMLNames.h" | 29 #include "gen/sky/core/HTMLNames.h" |
| 29 #include "sky/engine/bindings/core/v8/DOMDataStore.h" | 30 #include "sky/engine/bindings/core/v8/DOMDataStore.h" |
| 30 #include "sky/engine/bindings/core/v8/ExceptionState.h" | 31 #include "sky/engine/bindings/core/v8/ExceptionState.h" |
| 31 #include "sky/engine/bindings/core/v8/ScriptCallStackFactory.h" | 32 #include "sky/engine/bindings/core/v8/ScriptCallStackFactory.h" |
| 32 #include "sky/engine/bindings/core/v8/V8DOMWrapper.h" | 33 #include "sky/engine/bindings/core/v8/V8DOMWrapper.h" |
| 33 #include "sky/engine/core/css/resolver/StyleResolver.h" | 34 #include "sky/engine/core/css/resolver/StyleResolver.h" |
| 34 #include "sky/engine/core/dom/Attr.h" | 35 #include "sky/engine/core/dom/Attr.h" |
| 35 #include "sky/engine/core/dom/Attribute.h" | 36 #include "sky/engine/core/dom/Attribute.h" |
| 36 #include "sky/engine/core/dom/ChildListMutationScope.h" | 37 #include "sky/engine/core/dom/ChildListMutationScope.h" |
| 37 #include "sky/engine/core/dom/Document.h" | 38 #include "sky/engine/core/dom/Document.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 63 #include "sky/engine/core/events/TextEvent.h" | 64 #include "sky/engine/core/events/TextEvent.h" |
| 64 #include "sky/engine/core/events/UIEvent.h" | 65 #include "sky/engine/core/events/UIEvent.h" |
| 65 #include "sky/engine/core/frame/LocalFrame.h" | 66 #include "sky/engine/core/frame/LocalFrame.h" |
| 66 #include "sky/engine/core/frame/Settings.h" | 67 #include "sky/engine/core/frame/Settings.h" |
| 67 #include "sky/engine/core/html/HTMLAnchorElement.h" | 68 #include "sky/engine/core/html/HTMLAnchorElement.h" |
| 68 #include "sky/engine/core/html/HTMLStyleElement.h" | 69 #include "sky/engine/core/html/HTMLStyleElement.h" |
| 69 #include "sky/engine/core/page/EventHandler.h" | 70 #include "sky/engine/core/page/EventHandler.h" |
| 70 #include "sky/engine/core/page/Page.h" | 71 #include "sky/engine/core/page/Page.h" |
| 71 #include "sky/engine/core/rendering/RenderBox.h" | 72 #include "sky/engine/core/rendering/RenderBox.h" |
| 72 #include "sky/engine/platform/EventDispatchForbiddenScope.h" | 73 #include "sky/engine/platform/EventDispatchForbiddenScope.h" |
| 74 #include "sky/engine/platform/JSONValues.h" |
| 73 #include "sky/engine/platform/Partitions.h" | 75 #include "sky/engine/platform/Partitions.h" |
| 74 #include "sky/engine/platform/TraceEvent.h" | 76 #include "sky/engine/platform/TraceEvent.h" |
| 75 #include "sky/engine/platform/TracedValue.h" | |
| 76 #include "sky/engine/wtf/HashSet.h" | 77 #include "sky/engine/wtf/HashSet.h" |
| 77 #include "sky/engine/wtf/PassOwnPtr.h" | 78 #include "sky/engine/wtf/PassOwnPtr.h" |
| 78 #include "sky/engine/wtf/RefCountedLeakCounter.h" | 79 #include "sky/engine/wtf/RefCountedLeakCounter.h" |
| 79 #include "sky/engine/wtf/Vector.h" | 80 #include "sky/engine/wtf/Vector.h" |
| 80 #include "sky/engine/wtf/text/CString.h" | 81 #include "sky/engine/wtf/text/CString.h" |
| 81 #include "sky/engine/wtf/text/StringBuilder.h" | 82 #include "sky/engine/wtf/text/StringBuilder.h" |
| 82 | 83 |
| 83 namespace blink { | 84 namespace blink { |
| 84 | 85 |
| 85 struct SameSizeAsNode : public EventTarget, public TreeShared<Node> { | 86 struct SameSizeAsNode : public EventTarget, public TreeShared<Node> { |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 | 461 |
| 461 void Node::markAncestorsWithChildNeedsDistributionRecalc() | 462 void Node::markAncestorsWithChildNeedsDistributionRecalc() |
| 462 { | 463 { |
| 463 for (Node* node = this; node && !node->childNeedsDistributionRecalc(); node
= node->parentOrShadowHostNode()) | 464 for (Node* node = this; node && !node->childNeedsDistributionRecalc(); node
= node->parentOrShadowHostNode()) |
| 464 node->setChildNeedsDistributionRecalc(); | 465 node->setChildNeedsDistributionRecalc(); |
| 465 document().scheduleRenderTreeUpdateIfNeeded(); | 466 document().scheduleRenderTreeUpdateIfNeeded(); |
| 466 } | 467 } |
| 467 | 468 |
| 468 namespace { | 469 namespace { |
| 469 | 470 |
| 470 void addJsStack(TracedValue* stackFrames) | 471 class JSONTraceValue : public base::debug::ConvertableToTraceFormat { |
| 472 public: |
| 473 explicit JSONTraceValue(RefPtr<JSONValue> value) |
| 474 : m_value(value.release()) { } |
| 475 |
| 476 void AppendAsTraceFormat(std::string* out) const override |
| 477 { |
| 478 out->append(m_value->toJSONString().utf8().data()); |
| 479 } |
| 480 |
| 481 private: |
| 482 RefPtr<JSONValue> m_value; |
| 483 }; |
| 484 |
| 485 void addJsStack(JSONArray* stackFrames) |
| 471 { | 486 { |
| 472 RefPtr<ScriptCallStack> stack = createScriptCallStack(10); | 487 RefPtr<ScriptCallStack> stack = createScriptCallStack(10); |
| 473 if (!stack) | 488 if (!stack) |
| 474 return; | 489 return; |
| 475 for (size_t i = 0; i < stack->size(); i++) | 490 for (size_t i = 0; i < stack->size(); i++) |
| 476 stackFrames->pushString(stack->at(i).functionName()); | 491 stackFrames->pushString(stack->at(i).functionName()); |
| 477 } | 492 } |
| 478 | 493 |
| 479 PassRefPtr<TraceEvent::ConvertableToTraceFormat> jsonObjectForStyleInvalidation(
unsigned nodeCount, const Node* rootNode) | 494 scoped_refptr<base::debug::ConvertableToTraceFormat> jsonObjectForStyleInvalidat
ion(unsigned nodeCount, const Node* rootNode) |
| 480 { | 495 { |
| 481 RefPtr<TracedValue> value = TracedValue::create(); | 496 RefPtr<JSONObject> value = JSONObject::create(); |
| 482 value->setInteger("node_count", nodeCount); | 497 value->setNumber("node_count", nodeCount); |
| 483 value->setString("root_node", rootNode->debugName()); | 498 value->setString("root_node", rootNode->debugName()); |
| 484 value->beginArray("js_stack"); | 499 RefPtr<JSONArray> stack; |
| 485 addJsStack(value.get()); | 500 addJsStack(stack.get()); |
| 486 value->endArray(); | 501 value->setArray("js_stack", stack.release()); |
| 487 return value; | 502 return make_scoped_refptr(new JSONTraceValue(value)); |
| 488 } | 503 } |
| 489 | 504 |
| 490 } // anonymous namespace'd functions supporting traceStyleChange | 505 } // namespace |
| 491 | 506 |
| 492 unsigned Node::styledSubtreeSize() const | 507 unsigned Node::styledSubtreeSize() const |
| 493 { | 508 { |
| 494 unsigned nodeCount = 0; | 509 unsigned nodeCount = 0; |
| 495 | 510 |
| 496 for (const Node* node = this; node; node = NodeTraversal::next(*node, this))
{ | 511 for (const Node* node = this; node; node = NodeTraversal::next(*node, this))
{ |
| 497 if (node->isTextNode() || node->isElementNode()) | 512 if (node->isTextNode() || node->isElementNode()) |
| 498 nodeCount++; | 513 nodeCount++; |
| 499 if (ShadowRoot* root = node->shadowRoot()) | 514 if (ShadowRoot* root = node->shadowRoot()) |
| 500 nodeCount += root->styledSubtreeSize(); | 515 nodeCount += root->styledSubtreeSize(); |
| (...skipping 1117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1618 node->showTreeForThis(); | 1633 node->showTreeForThis(); |
| 1619 } | 1634 } |
| 1620 | 1635 |
| 1621 void showNodePath(const blink::Node* node) | 1636 void showNodePath(const blink::Node* node) |
| 1622 { | 1637 { |
| 1623 if (node) | 1638 if (node) |
| 1624 node->showNodePathForThis(); | 1639 node->showNodePathForThis(); |
| 1625 } | 1640 } |
| 1626 | 1641 |
| 1627 #endif | 1642 #endif |
| OLD | NEW |