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, 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 891 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1344 // FIXME: Inspector doesn't currently work cross process. | 1357 // FIXME: Inspector doesn't currently work cross process. |
1345 if (frame && frame->deprecatedLocalOwner()) { | 1358 if (frame && frame->deprecatedLocalOwner()) { |
1346 OwnPtr<HighlightConfig> highlightConfig = adoptPtr(new HighlightConfig()
); | 1359 OwnPtr<HighlightConfig> highlightConfig = adoptPtr(new HighlightConfig()
); |
1347 highlightConfig->showInfo = true; // Always show tooltips for frames. | 1360 highlightConfig->showInfo = true; // Always show tooltips for frames. |
1348 highlightConfig->content = parseColor(color); | 1361 highlightConfig->content = parseColor(color); |
1349 highlightConfig->contentOutline = parseColor(outlineColor); | 1362 highlightConfig->contentOutline = parseColor(outlineColor); |
1350 m_overlay->highlightNode(frame->deprecatedLocalOwner(), 0 /* eventTarget
*/, *highlightConfig, false); | 1363 m_overlay->highlightNode(frame->deprecatedLocalOwner(), 0 /* eventTarget
*/, *highlightConfig, false); |
1351 } | 1364 } |
1352 } | 1365 } |
1353 | 1366 |
| 1367 void InspectorDOMAgent::getAnimationPlayersForNode(ErrorString* errorString, int
nodeId, RefPtr<TypeBuilder::Array<TypeBuilder::DOM::AnimationPlayer> >& animati
onPlayersArray) |
| 1368 { |
| 1369 animationPlayersArray = TypeBuilder::Array<TypeBuilder::DOM::AnimationPlayer
>::create(); |
| 1370 Element* element = assertElement(errorString, nodeId); |
| 1371 if (!element) |
| 1372 return; |
| 1373 WillBeHeapVector<RefPtrWillBeMember<AnimationPlayer> > players = ElementAnim
ation::getAnimationPlayers(*element); |
| 1374 for (WillBeHeapVector<RefPtrWillBeMember<AnimationPlayer> >::iterator it = p
layers.begin(); it != players.end(); ++it) { |
| 1375 AnimationPlayer& player = *(it->get()); |
| 1376 m_idToAnimationPlayer.set(player.id(), &player); |
| 1377 RefPtr<TypeBuilder::DOM::AnimationPlayer> animationPlayerObject = buildO
bjectForAnimationPlayer(player); |
| 1378 animationPlayersArray->addItem(animationPlayerObject); |
| 1379 } |
| 1380 } |
| 1381 |
| 1382 void InspectorDOMAgent::pauseAnimationPlayer(ErrorString* errorString, const Str
ing& id, RefPtr<TypeBuilder::DOM::AnimationPlayer>& animationPlayer) |
| 1383 { |
| 1384 AnimationPlayer* player = assertAnimationPlayer(errorString, id); |
| 1385 if (!player) |
| 1386 return; |
| 1387 player->pause(); |
| 1388 animationPlayer = buildObjectForAnimationPlayer(*player); |
| 1389 } |
| 1390 |
| 1391 void InspectorDOMAgent::playAnimationPlayer(ErrorString* errorString, const Stri
ng& id, RefPtr<TypeBuilder::DOM::AnimationPlayer>& animationPlayer) |
| 1392 { |
| 1393 AnimationPlayer* player = assertAnimationPlayer(errorString, id); |
| 1394 if (!player) |
| 1395 return; |
| 1396 player->play(); |
| 1397 animationPlayer = buildObjectForAnimationPlayer(*player); |
| 1398 } |
| 1399 |
| 1400 void InspectorDOMAgent::setAnimationPlayerCurrentTime(ErrorString* errorString,
const String& id, double currentTime, RefPtr<TypeBuilder::DOM::AnimationPlayer>&
animationPlayer) |
| 1401 { |
| 1402 AnimationPlayer* player = assertAnimationPlayer(errorString, id); |
| 1403 if (!player) |
| 1404 return; |
| 1405 player->setCurrentTime(currentTime); |
| 1406 animationPlayer = buildObjectForAnimationPlayer(*player); |
| 1407 } |
| 1408 |
| 1409 void InspectorDOMAgent::getAnimationPlayerState(ErrorString* errorString, const
String& id, double* currentTime, bool* isRunning) |
| 1410 { |
| 1411 AnimationPlayer* player = assertAnimationPlayer(errorString, id); |
| 1412 if (!player) |
| 1413 return; |
| 1414 *currentTime = player->currentTime(); |
| 1415 *isRunning = player->playing(); |
| 1416 } |
| 1417 |
1354 void InspectorDOMAgent::hideHighlight(ErrorString*) | 1418 void InspectorDOMAgent::hideHighlight(ErrorString*) |
1355 { | 1419 { |
1356 m_overlay->hideHighlight(); | 1420 m_overlay->hideHighlight(); |
1357 } | 1421 } |
1358 | 1422 |
1359 void InspectorDOMAgent::copyTo(ErrorString* errorString, int nodeId, int targetE
lementId, const int* const anchorNodeId, int* newNodeId) | 1423 void InspectorDOMAgent::copyTo(ErrorString* errorString, int nodeId, int targetE
lementId, const int* const anchorNodeId, int* newNodeId) |
1360 { | 1424 { |
1361 Node* node = assertEditableNode(errorString, nodeId); | 1425 Node* node = assertEditableNode(errorString, nodeId); |
1362 if (!node) | 1426 if (!node) |
1363 return; | 1427 return; |
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1765 return nullptr; | 1829 return nullptr; |
1766 | 1830 |
1767 RefPtr<TypeBuilder::Array<TypeBuilder::DOM::Node> > pseudoElements = TypeBui
lder::Array<TypeBuilder::DOM::Node>::create(); | 1831 RefPtr<TypeBuilder::Array<TypeBuilder::DOM::Node> > pseudoElements = TypeBui
lder::Array<TypeBuilder::DOM::Node>::create(); |
1768 if (element->pseudoElement(BEFORE)) | 1832 if (element->pseudoElement(BEFORE)) |
1769 pseudoElements->addItem(buildObjectForNode(element->pseudoElement(BEFORE
), 0, nodesMap)); | 1833 pseudoElements->addItem(buildObjectForNode(element->pseudoElement(BEFORE
), 0, nodesMap)); |
1770 if (element->pseudoElement(AFTER)) | 1834 if (element->pseudoElement(AFTER)) |
1771 pseudoElements->addItem(buildObjectForNode(element->pseudoElement(AFTER)
, 0, nodesMap)); | 1835 pseudoElements->addItem(buildObjectForNode(element->pseudoElement(AFTER)
, 0, nodesMap)); |
1772 return pseudoElements.release(); | 1836 return pseudoElements.release(); |
1773 } | 1837 } |
1774 | 1838 |
| 1839 PassRefPtr<TypeBuilder::DOM::AnimationPlayer> InspectorDOMAgent::buildObjectForA
nimationPlayer(AnimationPlayer& animationPlayer) |
| 1840 { |
| 1841 RefPtr<TypeBuilder::DOM::AnimationPlayer> playerObject = TypeBuilder::DOM::A
nimationPlayer::create() |
| 1842 .setId(animationPlayer.id()) |
| 1843 .setPaused(animationPlayer.paused()) |
| 1844 .setFinished(animationPlayer.finished()) |
| 1845 .setPlaybackRate(animationPlayer.playbackRate()) |
| 1846 .setStartTime(animationPlayer.startTime()) |
| 1847 .setCurrentTime(animationPlayer.currentTime()) |
| 1848 .setAnimation(buildObjectForAnimationNode(*(animationPlayer.source()))); |
| 1849 return playerObject.release(); |
| 1850 } |
| 1851 |
| 1852 PassRefPtr<TypeBuilder::DOM::AnimationNode> InspectorDOMAgent::buildObjectForAni
mationNode(AnimationNode& animationNode) |
| 1853 { |
| 1854 RefPtr<TypeBuilder::DOM::AnimationNode> animationObject = TypeBuilder::DOM::
AnimationNode::create() |
| 1855 .setStartDelay(animationNode.specifiedTiming().startDelay) |
| 1856 .setPlaybackRate(animationNode.specifiedTiming().playbackRate) |
| 1857 .setIterationStart(animationNode.specifiedTiming().iterationStart) |
| 1858 .setIterationCount(animationNode.specifiedTiming().iterationCount) |
| 1859 .setDuration(animationNode.duration()) |
| 1860 .setDirection(animationNode.specifiedTiming().direction) |
| 1861 .setFillMode(animationNode.specifiedTiming().fillMode) |
| 1862 .setTimeFraction(animationNode.timeFraction()); |
| 1863 return animationObject.release(); |
| 1864 } |
| 1865 |
1775 Node* InspectorDOMAgent::innerFirstChild(Node* node) | 1866 Node* InspectorDOMAgent::innerFirstChild(Node* node) |
1776 { | 1867 { |
1777 node = node->firstChild(); | 1868 node = node->firstChild(); |
1778 while (isWhitespace(node)) | 1869 while (isWhitespace(node)) |
1779 node = node->nextSibling(); | 1870 node = node->nextSibling(); |
1780 return node; | 1871 return node; |
1781 } | 1872 } |
1782 | 1873 |
1783 Node* InspectorDOMAgent::innerNextSibling(Node* node) | 1874 Node* InspectorDOMAgent::innerNextSibling(Node* node) |
1784 { | 1875 { |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2192 visitor->trace(m_pageAgent); | 2283 visitor->trace(m_pageAgent); |
2193 visitor->trace(m_injectedScriptManager); | 2284 visitor->trace(m_injectedScriptManager); |
2194 #if ENABLE(OILPAN) | 2285 #if ENABLE(OILPAN) |
2195 visitor->trace(m_documentNodeToIdMap); | 2286 visitor->trace(m_documentNodeToIdMap); |
2196 visitor->trace(m_danglingNodeToIdMaps); | 2287 visitor->trace(m_danglingNodeToIdMaps); |
2197 visitor->trace(m_idToNode); | 2288 visitor->trace(m_idToNode); |
2198 visitor->trace(m_idToNodesMap); | 2289 visitor->trace(m_idToNodesMap); |
2199 visitor->trace(m_document); | 2290 visitor->trace(m_document); |
2200 visitor->trace(m_revalidateStyleAttrTask); | 2291 visitor->trace(m_revalidateStyleAttrTask); |
2201 visitor->trace(m_searchResults); | 2292 visitor->trace(m_searchResults); |
| 2293 visitor->trace(m_idToAnimationPlayer); |
2202 #endif | 2294 #endif |
2203 visitor->trace(m_history); | 2295 visitor->trace(m_history); |
2204 visitor->trace(m_domEditor); | 2296 visitor->trace(m_domEditor); |
2205 visitor->trace(m_listener); | 2297 visitor->trace(m_listener); |
2206 InspectorBaseAgent::trace(visitor); | 2298 InspectorBaseAgent::trace(visitor); |
2207 } | 2299 } |
2208 | 2300 |
2209 } // namespace blink | 2301 } // namespace blink |
2210 | 2302 |
OLD | NEW |