| 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 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 FloatPoint absPos = renderer()->localToAbsolute(); | 452 FloatPoint absPos = renderer()->localToAbsolute(); |
| 453 renderer()->absoluteRects(rects, flooredLayoutPoint(absPos)); | 453 renderer()->absoluteRects(rects, flooredLayoutPoint(absPos)); |
| 454 size_t n = rects.size(); | 454 size_t n = rects.size(); |
| 455 for (size_t i = 0; i < n; ++i) | 455 for (size_t i = 0; i < n; ++i) |
| 456 if (!rects[i].isEmpty()) | 456 if (!rects[i].isEmpty()) |
| 457 return true; | 457 return true; |
| 458 | 458 |
| 459 return false; | 459 return false; |
| 460 } | 460 } |
| 461 | 461 |
| 462 #ifndef NDEBUG | |
| 463 inline static ShadowRoot* oldestShadowRootFor(const Node* node) | |
| 464 { | |
| 465 if (!node->isElementNode()) | |
| 466 return 0; | |
| 467 if (ElementShadow* shadow = toElement(node)->shadow()) | |
| 468 return shadow->oldestShadowRoot(); | |
| 469 return 0; | |
| 470 } | |
| 471 #endif | |
| 472 | |
| 473 void Node::recalcDistribution() | 462 void Node::recalcDistribution() |
| 474 { | 463 { |
| 475 if (isElementNode()) { | 464 if (isElementNode()) { |
| 476 if (ElementShadow* shadow = toElement(this)->shadow()) | 465 if (ElementShadow* shadow = toElement(this)->shadow()) |
| 477 shadow->distributeIfNeeded(); | 466 shadow->distributeIfNeeded(); |
| 478 } | 467 } |
| 479 | 468 |
| 480 for (Node* child = firstChild(); child; child = child->nextSibling()) { | 469 for (Node* child = firstChild(); child; child = child->nextSibling()) { |
| 481 if (child->childNeedsDistributionRecalc()) | 470 if (child->childNeedsDistributionRecalc()) |
| 482 child->recalcDistribution(); | 471 child->recalcDistribution(); |
| 483 } | 472 } |
| 484 | 473 |
| 485 for (ShadowRoot* root = youngestShadowRoot(); root; root = root->olderShadow
Root()) { | 474 if (ShadowRoot* root = shadowRoot()) { |
| 486 if (root->childNeedsDistributionRecalc()) | 475 if (root->childNeedsDistributionRecalc()) |
| 487 root->recalcDistribution(); | 476 root->recalcDistribution(); |
| 488 } | 477 } |
| 489 | 478 |
| 490 clearChildNeedsDistributionRecalc(); | 479 clearChildNeedsDistributionRecalc(); |
| 491 } | 480 } |
| 492 | 481 |
| 493 void Node::setIsLink(bool isLink) | 482 void Node::setIsLink(bool isLink) |
| 494 { | 483 { |
| 495 setFlag(isLink, IsLinkFlag); | 484 setFlag(isLink, IsLinkFlag); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 526 | 515 |
| 527 } // anonymous namespace'd functions supporting traceStyleChange | 516 } // anonymous namespace'd functions supporting traceStyleChange |
| 528 | 517 |
| 529 unsigned Node::styledSubtreeSize() const | 518 unsigned Node::styledSubtreeSize() const |
| 530 { | 519 { |
| 531 unsigned nodeCount = 0; | 520 unsigned nodeCount = 0; |
| 532 | 521 |
| 533 for (const Node* node = this; node; node = NodeTraversal::next(*node, this))
{ | 522 for (const Node* node = this; node; node = NodeTraversal::next(*node, this))
{ |
| 534 if (node->isTextNode() || node->isElementNode()) | 523 if (node->isTextNode() || node->isElementNode()) |
| 535 nodeCount++; | 524 nodeCount++; |
| 536 for (ShadowRoot* root = node->youngestShadowRoot(); root; root = root->o
lderShadowRoot()) | 525 if (ShadowRoot* root = node->shadowRoot()) |
| 537 nodeCount += root->styledSubtreeSize(); | 526 nodeCount += root->styledSubtreeSize(); |
| 538 } | 527 } |
| 539 | 528 |
| 540 return nodeCount; | 529 return nodeCount; |
| 541 } | 530 } |
| 542 | 531 |
| 543 void Node::traceStyleChange(StyleChangeType changeType) | 532 void Node::traceStyleChange(StyleChangeType changeType) |
| 544 { | 533 { |
| 545 static const unsigned kMinLoggedSize = 100; | 534 static const unsigned kMinLoggedSize = 100; |
| 546 unsigned nodeCount = styledSubtreeSize(); | 535 unsigned nodeCount = styledSubtreeSize(); |
| (...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1087 const Node* child1 = chain1[--index1]; | 1076 const Node* child1 = chain1[--index1]; |
| 1088 const Node* child2 = chain2[--index2]; | 1077 const Node* child2 = chain2[--index2]; |
| 1089 if (child1 != child2) { | 1078 if (child1 != child2) { |
| 1090 // If one of the children is a shadow root, | 1079 // If one of the children is a shadow root, |
| 1091 if (child1->isShadowRoot() || child2->isShadowRoot()) { | 1080 if (child1->isShadowRoot() || child2->isShadowRoot()) { |
| 1092 if (!child2->isShadowRoot()) | 1081 if (!child2->isShadowRoot()) |
| 1093 return Node::DOCUMENT_POSITION_FOLLOWING | connection; | 1082 return Node::DOCUMENT_POSITION_FOLLOWING | connection; |
| 1094 if (!child1->isShadowRoot()) | 1083 if (!child1->isShadowRoot()) |
| 1095 return Node::DOCUMENT_POSITION_PRECEDING | connection; | 1084 return Node::DOCUMENT_POSITION_PRECEDING | connection; |
| 1096 | 1085 |
| 1097 for (ShadowRoot* child = toShadowRoot(child2)->olderShadowRoot()
; child; child = child->olderShadowRoot()) | |
| 1098 if (child == child1) | |
| 1099 return Node::DOCUMENT_POSITION_FOLLOWING | connection; | |
| 1100 | |
| 1101 return Node::DOCUMENT_POSITION_PRECEDING | connection; | 1086 return Node::DOCUMENT_POSITION_PRECEDING | connection; |
| 1102 } | 1087 } |
| 1103 | 1088 |
| 1104 if (!child2->nextSibling()) | 1089 if (!child2->nextSibling()) |
| 1105 return DOCUMENT_POSITION_FOLLOWING | connection; | 1090 return DOCUMENT_POSITION_FOLLOWING | connection; |
| 1106 if (!child1->nextSibling()) | 1091 if (!child1->nextSibling()) |
| 1107 return DOCUMENT_POSITION_PRECEDING | connection; | 1092 return DOCUMENT_POSITION_PRECEDING | connection; |
| 1108 | 1093 |
| 1109 // Otherwise we need to see which node occurs first. Crawl backward
s from child2 looking for child1. | 1094 // Otherwise we need to see which node occurs first. Crawl backward
s from child2 looking for child1. |
| 1110 for (Node* child = child2->previousSibling(); child; child = child->
previousSibling()) { | 1095 for (Node* child = child2->previousSibling(); child; child = child->
previousSibling()) { |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1193 { | 1178 { |
| 1194 Vector<const Node*, 16> chain; | 1179 Vector<const Node*, 16> chain; |
| 1195 const Node* node = this; | 1180 const Node* node = this; |
| 1196 while (node->parentOrShadowHostNode()) { | 1181 while (node->parentOrShadowHostNode()) { |
| 1197 chain.append(node); | 1182 chain.append(node); |
| 1198 node = node->parentOrShadowHostNode(); | 1183 node = node->parentOrShadowHostNode(); |
| 1199 } | 1184 } |
| 1200 for (unsigned index = chain.size(); index > 0; --index) { | 1185 for (unsigned index = chain.size(); index > 0; --index) { |
| 1201 const Node* node = chain[index - 1]; | 1186 const Node* node = chain[index - 1]; |
| 1202 if (node->isShadowRoot()) { | 1187 if (node->isShadowRoot()) { |
| 1203 int count = 0; | 1188 fprintf(stderr, "/#shadow-root"); |
| 1204 for (ShadowRoot* shadowRoot = toShadowRoot(node)->olderShadowRoot();
shadowRoot; shadowRoot = shadowRoot->olderShadowRoot()) | |
| 1205 ++count; | |
| 1206 fprintf(stderr, "/#shadow-root[%d]", count); | |
| 1207 continue; | 1189 continue; |
| 1208 } | 1190 } |
| 1209 | 1191 |
| 1210 switch (node->nodeType()) { | 1192 switch (node->nodeType()) { |
| 1211 case ELEMENT_NODE: { | 1193 case ELEMENT_NODE: { |
| 1212 fprintf(stderr, "/%s", node->nodeName().utf8().data()); | 1194 fprintf(stderr, "/%s", node->nodeName().utf8().data()); |
| 1213 | 1195 |
| 1214 const Element* element = toElement(node); | 1196 const Element* element = toElement(node); |
| 1215 const AtomicString& idattr = element->getIdAttribute(); | 1197 const AtomicString& idattr = element->getIdAttribute(); |
| 1216 bool hasIdAttr = !idattr.isNull() && !idattr.isEmpty(); | 1198 bool hasIdAttr = !idattr.isNull() && !idattr.isEmpty(); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1246 if (node == markedNode2) | 1228 if (node == markedNode2) |
| 1247 fprintf(stderr, "%s", markedLabel2); | 1229 fprintf(stderr, "%s", markedLabel2); |
| 1248 | 1230 |
| 1249 StringBuilder indent; | 1231 StringBuilder indent; |
| 1250 indent.append(baseIndent); | 1232 indent.append(baseIndent); |
| 1251 for (const Node* tmpNode = node; tmpNode && tmpNode != rootNode; tmpNode
= tmpNode->parentOrShadowHostNode()) | 1233 for (const Node* tmpNode = node; tmpNode && tmpNode != rootNode; tmpNode
= tmpNode->parentOrShadowHostNode()) |
| 1252 indent.append('\t'); | 1234 indent.append('\t'); |
| 1253 fprintf(stderr, "%s", indent.toString().utf8().data()); | 1235 fprintf(stderr, "%s", indent.toString().utf8().data()); |
| 1254 node->showNode(); | 1236 node->showNode(); |
| 1255 indent.append('\t'); | 1237 indent.append('\t'); |
| 1256 if (node->isShadowRoot()) { | 1238 if (ShadowRoot* shadowRoot = node->shadowRoot()) |
| 1257 if (ShadowRoot* youngerShadowRoot = toShadowRoot(node)->youngerShado
wRoot()) | 1239 traverseTreeAndMark(indent.toString(), shadowRoot, markedNode1, mark
edLabel1, markedNode2, markedLabel2); |
| 1258 traverseTreeAndMark(indent.toString(), youngerShadowRoot, marked
Node1, markedLabel1, markedNode2, markedLabel2); | |
| 1259 } else if (ShadowRoot* oldestShadowRoot = oldestShadowRootFor(node)) | |
| 1260 traverseTreeAndMark(indent.toString(), oldestShadowRoot, markedNode1
, markedLabel1, markedNode2, markedLabel2); | |
| 1261 } | 1240 } |
| 1262 } | 1241 } |
| 1263 | 1242 |
| 1264 void Node::showTreeAndMark(const Node* markedNode1, const char* markedLabel1, co
nst Node* markedNode2, const char* markedLabel2) const | 1243 void Node::showTreeAndMark(const Node* markedNode1, const char* markedLabel1, co
nst Node* markedNode2, const char* markedLabel2) const |
| 1265 { | 1244 { |
| 1266 const Node* rootNode; | 1245 const Node* rootNode; |
| 1267 const Node* node = this; | 1246 const Node* node = this; |
| 1268 while (node->parentOrShadowHostNode()) | 1247 while (node->parentOrShadowHostNode()) |
| 1269 node = node->parentOrShadowHostNode(); | 1248 node = node->parentOrShadowHostNode(); |
| 1270 rootNode = node; | 1249 rootNode = node; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1286 | 1265 |
| 1287 strncpy(buffer, result.utf8().data(), length - 1); | 1266 strncpy(buffer, result.utf8().data(), length - 1); |
| 1288 } | 1267 } |
| 1289 | 1268 |
| 1290 static void showSubTreeAcrossFrame(const Node* node, const Node* markedNode, con
st String& indent) | 1269 static void showSubTreeAcrossFrame(const Node* node, const Node* markedNode, con
st String& indent) |
| 1291 { | 1270 { |
| 1292 if (node == markedNode) | 1271 if (node == markedNode) |
| 1293 fputs("*", stderr); | 1272 fputs("*", stderr); |
| 1294 fputs(indent.utf8().data(), stderr); | 1273 fputs(indent.utf8().data(), stderr); |
| 1295 node->showNode(); | 1274 node->showNode(); |
| 1296 if (node->isShadowRoot()) { | 1275 if (ShadowRoot* shadowRoot = node->shadowRoot()) |
| 1297 if (ShadowRoot* youngerShadowRoot = toShadowRoot(node)->youngerShadowRoo
t()) | 1276 showSubTreeAcrossFrame(shadowRoot, markedNode, indent + "\t"); |
| 1298 showSubTreeAcrossFrame(youngerShadowRoot, markedNode, indent + "\t")
; | |
| 1299 } else { | |
| 1300 if (ShadowRoot* oldestShadowRoot = oldestShadowRootFor(node)) | |
| 1301 showSubTreeAcrossFrame(oldestShadowRoot, markedNode, indent + "\t"); | |
| 1302 } | |
| 1303 for (Node* child = node->firstChild(); child; child = child->nextSibling()) | 1277 for (Node* child = node->firstChild(); child; child = child->nextSibling()) |
| 1304 showSubTreeAcrossFrame(child, markedNode, indent + "\t"); | 1278 showSubTreeAcrossFrame(child, markedNode, indent + "\t"); |
| 1305 } | 1279 } |
| 1306 | 1280 |
| 1307 #endif | 1281 #endif |
| 1308 | 1282 |
| 1309 // -------- | 1283 // -------- |
| 1310 | 1284 |
| 1311 Element* Node::enclosingLinkEventParentOrSelf() | 1285 Element* Node::enclosingLinkEventParentOrSelf() |
| 1312 { | 1286 { |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1391 | 1365 |
| 1392 void Node::removeAllEventListeners() | 1366 void Node::removeAllEventListeners() |
| 1393 { | 1367 { |
| 1394 EventTarget::removeAllEventListeners(); | 1368 EventTarget::removeAllEventListeners(); |
| 1395 } | 1369 } |
| 1396 | 1370 |
| 1397 void Node::removeAllEventListenersRecursively() | 1371 void Node::removeAllEventListenersRecursively() |
| 1398 { | 1372 { |
| 1399 for (Node* node = this; node; node = NodeTraversal::next(*node)) { | 1373 for (Node* node = this; node; node = NodeTraversal::next(*node)) { |
| 1400 node->removeAllEventListeners(); | 1374 node->removeAllEventListeners(); |
| 1401 for (ShadowRoot* root = node->youngestShadowRoot(); root; root = root->o
lderShadowRoot()) | 1375 if (ShadowRoot* root = node->shadowRoot()) |
| 1402 root->removeAllEventListenersRecursively(); | 1376 root->removeAllEventListenersRecursively(); |
| 1403 } | 1377 } |
| 1404 } | 1378 } |
| 1405 | 1379 |
| 1406 typedef HashMap<RawPtr<Node>, OwnPtr<EventTargetData> > EventTargetDataMap; | 1380 typedef HashMap<RawPtr<Node>, OwnPtr<EventTargetData> > EventTargetDataMap; |
| 1407 | 1381 |
| 1408 static EventTargetDataMap& eventTargetDataMap() | 1382 static EventTargetDataMap& eventTargetDataMap() |
| 1409 { | 1383 { |
| 1410 DEFINE_STATIC_LOCAL(OwnPtr<EventTargetDataMap>, map, (adoptPtr(new EventTarg
etDataMap()))); | 1384 DEFINE_STATIC_LOCAL(OwnPtr<EventTargetDataMap>, map, (adoptPtr(new EventTarg
etDataMap()))); |
| 1411 return *map; | 1385 return *map; |
| (...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1850 node->showTreeForThis(); | 1824 node->showTreeForThis(); |
| 1851 } | 1825 } |
| 1852 | 1826 |
| 1853 void showNodePath(const blink::Node* node) | 1827 void showNodePath(const blink::Node* node) |
| 1854 { | 1828 { |
| 1855 if (node) | 1829 if (node) |
| 1856 node->showNodePathForThis(); | 1830 node->showNodePathForThis(); |
| 1857 } | 1831 } |
| 1858 | 1832 |
| 1859 #endif | 1833 #endif |
| OLD | NEW |