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 | 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All |
6 * rights reserved. | 6 * rights reserved. |
7 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) | 7 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) |
8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. | 8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. |
9 * (http://www.torchmobile.com/) | 9 * (http://www.torchmobile.com/) |
10 * | 10 * |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 #include "platform/instrumentation/tracing/TraceEvent.h" | 102 #include "platform/instrumentation/tracing/TraceEvent.h" |
103 #include "platform/instrumentation/tracing/TracedValue.h" | 103 #include "platform/instrumentation/tracing/TracedValue.h" |
104 #include "wtf/HashSet.h" | 104 #include "wtf/HashSet.h" |
105 #include "wtf/Vector.h" | 105 #include "wtf/Vector.h" |
106 #include "wtf/allocator/Partitions.h" | 106 #include "wtf/allocator/Partitions.h" |
107 #include "wtf/text/CString.h" | 107 #include "wtf/text/CString.h" |
108 #include "wtf/text/StringBuilder.h" | 108 #include "wtf/text/StringBuilder.h" |
109 | 109 |
110 namespace blink { | 110 namespace blink { |
111 | 111 |
| 112 namespace { |
| 113 |
| 114 // TODO(crbug.com/545926): Unsafe hack to avoid triggering the |
| 115 // ThreadRestrictionVerifier on StringImpl. This should be fixed completely, and |
| 116 // we should always avoid accessing these strings from the impl thread. |
| 117 // Currently code that calls into this method from the impl thread tries to make |
| 118 // sure that the main thread is not running at this time. |
| 119 void appendUnsafe(StringBuilder& builder, const String& offThreadString) { |
| 120 StringImpl* impl = offThreadString.impl(); |
| 121 if (impl) { |
| 122 builder.append(impl->is8Bit() |
| 123 ? StringView(impl->characters8(), impl->length()) |
| 124 : StringView(impl->characters16(), impl->length())); |
| 125 } |
| 126 } |
| 127 |
| 128 } // namespace |
| 129 |
112 using namespace HTMLNames; | 130 using namespace HTMLNames; |
113 | 131 |
114 struct SameSizeAsNode : EventTarget { | 132 struct SameSizeAsNode : EventTarget { |
115 uint32_t m_nodeFlags; | 133 uint32_t m_nodeFlags; |
116 Member<void*> m_willbeMember[4]; | 134 Member<void*> m_willbeMember[4]; |
117 void* m_pointer; | 135 void* m_pointer; |
118 }; | 136 }; |
119 | 137 |
120 static_assert(sizeof(Node) <= sizeof(SameSizeAsNode), "Node should stay small"); | 138 static_assert(sizeof(Node) <= sizeof(SameSizeAsNode), "Node should stay small"); |
121 | 139 |
(...skipping 1359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1481 // subset of the other. The shorter chain is the ancestor. | 1499 // subset of the other. The shorter chain is the ancestor. |
1482 return index1 < index2 | 1500 return index1 < index2 |
1483 ? kDocumentPositionFollowing | kDocumentPositionContainedBy | | 1501 ? kDocumentPositionFollowing | kDocumentPositionContainedBy | |
1484 connection | 1502 connection |
1485 : kDocumentPositionPreceding | kDocumentPositionContains | | 1503 : kDocumentPositionPreceding | kDocumentPositionContains | |
1486 connection; | 1504 connection; |
1487 } | 1505 } |
1488 | 1506 |
1489 String Node::debugName() const { | 1507 String Node::debugName() const { |
1490 StringBuilder name; | 1508 StringBuilder name; |
1491 name.append(debugNodeName()); | 1509 appendUnsafe(name, debugNodeName()); |
1492 if (isElementNode()) { | 1510 if (isElementNode()) { |
1493 const Element& thisElement = toElement(*this); | 1511 const Element& thisElement = toElement(*this); |
1494 if (thisElement.hasID()) { | 1512 if (thisElement.hasID()) { |
1495 name.append(" id=\'"); | 1513 name.append(" id=\'"); |
1496 name.append(thisElement.getIdAttribute()); | 1514 appendUnsafe(name, thisElement.getIdAttribute()); |
1497 name.append('\''); | 1515 name.append('\''); |
1498 } | 1516 } |
1499 | 1517 |
1500 if (thisElement.hasClass()) { | 1518 if (thisElement.hasClass()) { |
1501 name.append(" class=\'"); | 1519 name.append(" class=\'"); |
1502 for (size_t i = 0; i < thisElement.classNames().size(); ++i) { | 1520 for (size_t i = 0; i < thisElement.classNames().size(); ++i) { |
1503 if (i > 0) | 1521 if (i > 0) |
1504 name.append(' '); | 1522 name.append(' '); |
1505 name.append(thisElement.classNames()[i]); | 1523 appendUnsafe(name, thisElement.classNames()[i]); |
1506 } | 1524 } |
1507 name.append('\''); | 1525 name.append('\''); |
1508 } | 1526 } |
1509 } | 1527 } |
1510 return name.toString(); | 1528 return name.toString(); |
1511 } | 1529 } |
1512 | 1530 |
1513 String Node::debugNodeName() const { | 1531 String Node::debugNodeName() const { |
1514 return nodeName(); | 1532 return nodeName(); |
1515 } | 1533 } |
(...skipping 1026 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2542 if (node) { | 2560 if (node) { |
2543 std::stringstream stream; | 2561 std::stringstream stream; |
2544 node->printNodePathTo(stream); | 2562 node->printNodePathTo(stream); |
2545 LOG(INFO) << stream.str(); | 2563 LOG(INFO) << stream.str(); |
2546 } else { | 2564 } else { |
2547 LOG(INFO) << "Cannot showNodePath for <null>"; | 2565 LOG(INFO) << "Cannot showNodePath for <null>"; |
2548 } | 2566 } |
2549 } | 2567 } |
2550 | 2568 |
2551 #endif | 2569 #endif |
OLD | NEW |