| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2011 Google Inc. All rights reserved. | 3 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 4 * Copyright (C) 2009 Joseph Pecoraro | 4 * Copyright (C) 2009 Joseph Pecoraro |
| 5 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
| 8 * are met: | 8 * are met: |
| 9 * | 9 * |
| 10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 #include "core/inspector/InspectorDOMAgent.h" | 32 #include "core/inspector/InspectorDOMAgent.h" |
| 33 | 33 |
| 34 #include "bindings/core/v8/ExceptionState.h" | 34 #include "bindings/core/v8/ExceptionState.h" |
| 35 #include "bindings/core/v8/ScriptEventListener.h" | 35 #include "bindings/core/v8/ScriptEventListener.h" |
| 36 #include "core/InputTypeNames.h" | 36 #include "core/InputTypeNames.h" |
| 37 #include "core/animation/AnimationNode.h" |
| 38 #include "core/animation/AnimationPlayer.h" |
| 39 #include "core/animation/ElementAnimation.h" |
| 37 #include "core/dom/Attr.h" | 40 #include "core/dom/Attr.h" |
| 38 #include "core/dom/CharacterData.h" | 41 #include "core/dom/CharacterData.h" |
| 39 #include "core/dom/ContainerNode.h" | 42 #include "core/dom/ContainerNode.h" |
| 40 #include "core/dom/DOMException.h" | 43 #include "core/dom/DOMException.h" |
| 41 #include "core/dom/Document.h" | 44 #include "core/dom/Document.h" |
| 42 #include "core/dom/DocumentFragment.h" | 45 #include "core/dom/DocumentFragment.h" |
| 43 #include "core/dom/DocumentType.h" | 46 #include "core/dom/DocumentType.h" |
| 44 #include "core/dom/Element.h" | 47 #include "core/dom/Element.h" |
| 45 #include "core/dom/Node.h" | 48 #include "core/dom/Node.h" |
| 46 #include "core/dom/PseudoElement.h" | 49 #include "core/dom/PseudoElement.h" |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 if (!node) | 436 if (!node) |
| 434 return 0; | 437 return 0; |
| 435 | 438 |
| 436 if (!node->isElementNode()) { | 439 if (!node->isElementNode()) { |
| 437 *errorString = "Node is not an Element"; | 440 *errorString = "Node is not an Element"; |
| 438 return 0; | 441 return 0; |
| 439 } | 442 } |
| 440 return toElement(node); | 443 return toElement(node); |
| 441 } | 444 } |
| 442 | 445 |
| 446 AnimationPlayer* InspectorDOMAgent::assertAnimationPlayer(ErrorString* errorStri
ng, const String& id) |
| 447 { |
| 448 AnimationPlayer* player = m_idToAnimationPlayer.get(id); |
| 449 if (!player) { |
| 450 *errorString = "Could not find animation player with given id"; |
| 451 return 0; |
| 452 } |
| 453 return player; |
| 454 } |
| 455 |
| 443 static ShadowRoot* userAgentShadowRoot(Node* node) | 456 static ShadowRoot* userAgentShadowRoot(Node* node) |
| 444 { | 457 { |
| 445 if (!node || !node->isInShadowTree()) | 458 if (!node || !node->isInShadowTree()) |
| 446 return 0; | 459 return 0; |
| 447 | 460 |
| 448 Node* candidate = node; | 461 Node* candidate = node; |
| 449 while (candidate && !candidate->isShadowRoot()) | 462 while (candidate && !candidate->isShadowRoot()) |
| 450 candidate = candidate->parentOrShadowHostNode(); | 463 candidate = candidate->parentOrShadowHostNode(); |
| 451 ASSERT(candidate); | 464 ASSERT(candidate); |
| 452 ShadowRoot* shadowRoot = toShadowRoot(candidate); | 465 ShadowRoot* shadowRoot = toShadowRoot(candidate); |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 598 m_history->reset(); | 611 m_history->reset(); |
| 599 m_searchResults.clear(); | 612 m_searchResults.clear(); |
| 600 m_documentNodeToIdMap->clear(); | 613 m_documentNodeToIdMap->clear(); |
| 601 m_idToNode.clear(); | 614 m_idToNode.clear(); |
| 602 m_idToNodesMap.clear(); | 615 m_idToNodesMap.clear(); |
| 603 releaseDanglingNodes(); | 616 releaseDanglingNodes(); |
| 604 m_childrenRequested.clear(); | 617 m_childrenRequested.clear(); |
| 605 m_cachedChildCount.clear(); | 618 m_cachedChildCount.clear(); |
| 606 if (m_revalidateStyleAttrTask) | 619 if (m_revalidateStyleAttrTask) |
| 607 m_revalidateStyleAttrTask->reset(); | 620 m_revalidateStyleAttrTask->reset(); |
| 621 m_idToAnimationPlayer.clear(); |
| 608 } | 622 } |
| 609 | 623 |
| 610 Node* InspectorDOMAgent::nodeForId(int id) | 624 Node* InspectorDOMAgent::nodeForId(int id) |
| 611 { | 625 { |
| 612 if (!id) | 626 if (!id) |
| 613 return 0; | 627 return 0; |
| 614 | 628 |
| 615 WillBeHeapHashMap<int, RawPtrWillBeMember<Node> >::iterator it = m_idToNode.
find(id); | 629 WillBeHeapHashMap<int, RawPtrWillBeMember<Node> >::iterator it = m_idToNode.
find(id); |
| 616 if (it != m_idToNode.end()) | 630 if (it != m_idToNode.end()) |
| 617 return it->value; | 631 return it->value; |
| (...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1344 // FIXME: Inspector doesn't currently work cross process. | 1358 // FIXME: Inspector doesn't currently work cross process. |
| 1345 if (frame && frame->deprecatedLocalOwner()) { | 1359 if (frame && frame->deprecatedLocalOwner()) { |
| 1346 OwnPtr<HighlightConfig> highlightConfig = adoptPtr(new HighlightConfig()
); | 1360 OwnPtr<HighlightConfig> highlightConfig = adoptPtr(new HighlightConfig()
); |
| 1347 highlightConfig->showInfo = true; // Always show tooltips for frames. | 1361 highlightConfig->showInfo = true; // Always show tooltips for frames. |
| 1348 highlightConfig->content = parseColor(color); | 1362 highlightConfig->content = parseColor(color); |
| 1349 highlightConfig->contentOutline = parseColor(outlineColor); | 1363 highlightConfig->contentOutline = parseColor(outlineColor); |
| 1350 m_overlay->highlightNode(frame->deprecatedLocalOwner(), 0 /* eventTarget
*/, *highlightConfig, false); | 1364 m_overlay->highlightNode(frame->deprecatedLocalOwner(), 0 /* eventTarget
*/, *highlightConfig, false); |
| 1351 } | 1365 } |
| 1352 } | 1366 } |
| 1353 | 1367 |
| 1368 void InspectorDOMAgent::getAnimationPlayersForNode(ErrorString* errorString, int
nodeId, RefPtr<TypeBuilder::Array<TypeBuilder::DOM::AnimationPlayer> >& animati
onPlayersArray) |
| 1369 { |
| 1370 animationPlayersArray = TypeBuilder::Array<TypeBuilder::DOM::AnimationPlayer
>::create(); |
| 1371 Element* element = assertElement(errorString, nodeId); |
| 1372 if (!element) |
| 1373 return; |
| 1374 m_idToAnimationPlayer.clear(); |
| 1375 WillBeHeapVector<RefPtrWillBeMember<AnimationPlayer> > players = ElementAnim
ation::getAnimationPlayers(*element); |
| 1376 for (WillBeHeapVector<RefPtrWillBeMember<AnimationPlayer> >::iterator it = p
layers.begin(); it != players.end(); ++it) { |
| 1377 AnimationPlayer& player = *(it->get()); |
| 1378 m_idToAnimationPlayer.set(playerId(player), &player); |
| 1379 RefPtr<TypeBuilder::DOM::AnimationPlayer> animationPlayerObject = buildO
bjectForAnimationPlayer(player); |
| 1380 animationPlayersArray->addItem(animationPlayerObject); |
| 1381 } |
| 1382 } |
| 1383 |
| 1384 void InspectorDOMAgent::pauseAnimationPlayer(ErrorString* errorString, const Str
ing& id, RefPtr<TypeBuilder::DOM::AnimationPlayer>& animationPlayer) |
| 1385 { |
| 1386 AnimationPlayer* player = assertAnimationPlayer(errorString, id); |
| 1387 if (!player) |
| 1388 return; |
| 1389 player->pause(); |
| 1390 animationPlayer = buildObjectForAnimationPlayer(*player); |
| 1391 } |
| 1392 |
| 1393 void InspectorDOMAgent::playAnimationPlayer(ErrorString* errorString, const Stri
ng& id, RefPtr<TypeBuilder::DOM::AnimationPlayer>& animationPlayer) |
| 1394 { |
| 1395 AnimationPlayer* player = assertAnimationPlayer(errorString, id); |
| 1396 if (!player) |
| 1397 return; |
| 1398 player->play(); |
| 1399 animationPlayer = buildObjectForAnimationPlayer(*player); |
| 1400 } |
| 1401 |
| 1402 void InspectorDOMAgent::setAnimationPlayerCurrentTime(ErrorString* errorString,
const String& id, double currentTime, RefPtr<TypeBuilder::DOM::AnimationPlayer>&
animationPlayer) |
| 1403 { |
| 1404 AnimationPlayer* player = assertAnimationPlayer(errorString, id); |
| 1405 if (!player) |
| 1406 return; |
| 1407 player->setCurrentTime(currentTime); |
| 1408 animationPlayer = buildObjectForAnimationPlayer(*player); |
| 1409 } |
| 1410 |
| 1411 void InspectorDOMAgent::getAnimationPlayerState(ErrorString* errorString, const
String& id, double* currentTime, bool* isRunning) |
| 1412 { |
| 1413 AnimationPlayer* player = assertAnimationPlayer(errorString, id); |
| 1414 if (!player) |
| 1415 return; |
| 1416 *currentTime = player->currentTime(); |
| 1417 *isRunning = player->playing(); |
| 1418 } |
| 1419 |
| 1354 void InspectorDOMAgent::hideHighlight(ErrorString*) | 1420 void InspectorDOMAgent::hideHighlight(ErrorString*) |
| 1355 { | 1421 { |
| 1356 m_overlay->hideHighlight(); | 1422 m_overlay->hideHighlight(); |
| 1357 } | 1423 } |
| 1358 | 1424 |
| 1359 void InspectorDOMAgent::copyTo(ErrorString* errorString, int nodeId, int targetE
lementId, const int* const anchorNodeId, int* newNodeId) | 1425 void InspectorDOMAgent::copyTo(ErrorString* errorString, int nodeId, int targetE
lementId, const int* const anchorNodeId, int* newNodeId) |
| 1360 { | 1426 { |
| 1361 Node* node = assertEditableNode(errorString, nodeId); | 1427 Node* node = assertEditableNode(errorString, nodeId); |
| 1362 if (!node) | 1428 if (!node) |
| 1363 return; | 1429 return; |
| (...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1761 return nullptr; | 1827 return nullptr; |
| 1762 | 1828 |
| 1763 RefPtr<TypeBuilder::Array<TypeBuilder::DOM::Node> > pseudoElements = TypeBui
lder::Array<TypeBuilder::DOM::Node>::create(); | 1829 RefPtr<TypeBuilder::Array<TypeBuilder::DOM::Node> > pseudoElements = TypeBui
lder::Array<TypeBuilder::DOM::Node>::create(); |
| 1764 if (element->pseudoElement(BEFORE)) | 1830 if (element->pseudoElement(BEFORE)) |
| 1765 pseudoElements->addItem(buildObjectForNode(element->pseudoElement(BEFORE
), 0, nodesMap)); | 1831 pseudoElements->addItem(buildObjectForNode(element->pseudoElement(BEFORE
), 0, nodesMap)); |
| 1766 if (element->pseudoElement(AFTER)) | 1832 if (element->pseudoElement(AFTER)) |
| 1767 pseudoElements->addItem(buildObjectForNode(element->pseudoElement(AFTER)
, 0, nodesMap)); | 1833 pseudoElements->addItem(buildObjectForNode(element->pseudoElement(AFTER)
, 0, nodesMap)); |
| 1768 return pseudoElements.release(); | 1834 return pseudoElements.release(); |
| 1769 } | 1835 } |
| 1770 | 1836 |
| 1837 PassRefPtr<TypeBuilder::DOM::AnimationPlayer> InspectorDOMAgent::buildObjectForA
nimationPlayer(AnimationPlayer& animationPlayer) |
| 1838 { |
| 1839 RefPtr<TypeBuilder::DOM::AnimationPlayer> playerObject = TypeBuilder::DOM::A
nimationPlayer::create() |
| 1840 .setId(playerId(animationPlayer)) |
| 1841 .setPaused(animationPlayer.paused()) |
| 1842 .setFinished(animationPlayer.finished()) |
| 1843 .setPlaybackRate(animationPlayer.playbackRate()) |
| 1844 .setStartTime(animationPlayer.startTime()) |
| 1845 .setCurrentTime(animationPlayer.currentTime()) |
| 1846 .setAnimation(buildObjectForAnimationNode(*(animationPlayer.source()))); |
| 1847 return playerObject.release(); |
| 1848 } |
| 1849 |
| 1850 PassRefPtr<TypeBuilder::DOM::AnimationNode> InspectorDOMAgent::buildObjectForAni
mationNode(AnimationNode& animationNode) |
| 1851 { |
| 1852 RefPtr<TypeBuilder::DOM::AnimationNode> animationObject = TypeBuilder::DOM::
AnimationNode::create() |
| 1853 .setStartDelay(animationNode.specifiedTiming().startDelay) |
| 1854 .setPlaybackRate(animationNode.specifiedTiming().playbackRate) |
| 1855 .setIterationStart(animationNode.specifiedTiming().iterationStart) |
| 1856 .setIterationCount(animationNode.specifiedTiming().iterationCount) |
| 1857 .setDuration(animationNode.duration()) |
| 1858 .setDirection(animationNode.specifiedTiming().direction) |
| 1859 .setFillMode(animationNode.specifiedTiming().fillMode) |
| 1860 .setTimeFraction(animationNode.timeFraction()) |
| 1861 .setName(animationNode.name()); |
| 1862 return animationObject.release(); |
| 1863 } |
| 1864 |
| 1771 Node* InspectorDOMAgent::innerFirstChild(Node* node) | 1865 Node* InspectorDOMAgent::innerFirstChild(Node* node) |
| 1772 { | 1866 { |
| 1773 node = node->firstChild(); | 1867 node = node->firstChild(); |
| 1774 while (isWhitespace(node)) | 1868 while (isWhitespace(node)) |
| 1775 node = node->nextSibling(); | 1869 node = node->nextSibling(); |
| 1776 return node; | 1870 return node; |
| 1777 } | 1871 } |
| 1778 | 1872 |
| 1779 Node* InspectorDOMAgent::innerNextSibling(Node* node) | 1873 Node* InspectorDOMAgent::innerNextSibling(Node* node) |
| 1780 { | 1874 { |
| (...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2188 visitor->trace(m_pageAgent); | 2282 visitor->trace(m_pageAgent); |
| 2189 visitor->trace(m_injectedScriptManager); | 2283 visitor->trace(m_injectedScriptManager); |
| 2190 #if ENABLE(OILPAN) | 2284 #if ENABLE(OILPAN) |
| 2191 visitor->trace(m_documentNodeToIdMap); | 2285 visitor->trace(m_documentNodeToIdMap); |
| 2192 visitor->trace(m_danglingNodeToIdMaps); | 2286 visitor->trace(m_danglingNodeToIdMaps); |
| 2193 visitor->trace(m_idToNode); | 2287 visitor->trace(m_idToNode); |
| 2194 visitor->trace(m_idToNodesMap); | 2288 visitor->trace(m_idToNodesMap); |
| 2195 visitor->trace(m_document); | 2289 visitor->trace(m_document); |
| 2196 visitor->trace(m_revalidateStyleAttrTask); | 2290 visitor->trace(m_revalidateStyleAttrTask); |
| 2197 visitor->trace(m_searchResults); | 2291 visitor->trace(m_searchResults); |
| 2292 visitor->trace(m_idToAnimationPlayer); |
| 2198 #endif | 2293 #endif |
| 2199 visitor->trace(m_history); | 2294 visitor->trace(m_history); |
| 2200 visitor->trace(m_domEditor); | 2295 visitor->trace(m_domEditor); |
| 2201 visitor->trace(m_listener); | 2296 visitor->trace(m_listener); |
| 2202 InspectorBaseAgent::trace(visitor); | 2297 InspectorBaseAgent::trace(visitor); |
| 2203 } | 2298 } |
| 2204 | 2299 |
| 2205 } // namespace blink | 2300 } // namespace blink |
| 2206 | 2301 |
| OLD | NEW |