Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(370)

Side by Side Diff: Source/core/inspector/InspectorDOMAgent.cpp

Issue 620783002: Devtools Animations: Basic animation inspection & control in Styles pane (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Review changes for AnimationSection Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 1297 matching lines...) Expand 10 before | Expand all | Expand 10 after
1344 // FIXME: Inspector doesn't currently work cross process. 1347 // FIXME: Inspector doesn't currently work cross process.
1345 if (frame && frame->deprecatedLocalOwner()) { 1348 if (frame && frame->deprecatedLocalOwner()) {
1346 OwnPtr<HighlightConfig> highlightConfig = adoptPtr(new HighlightConfig() ); 1349 OwnPtr<HighlightConfig> highlightConfig = adoptPtr(new HighlightConfig() );
1347 highlightConfig->showInfo = true; // Always show tooltips for frames. 1350 highlightConfig->showInfo = true; // Always show tooltips for frames.
1348 highlightConfig->content = parseColor(color); 1351 highlightConfig->content = parseColor(color);
1349 highlightConfig->contentOutline = parseColor(outlineColor); 1352 highlightConfig->contentOutline = parseColor(outlineColor);
1350 m_overlay->highlightNode(frame->deprecatedLocalOwner(), 0 /* eventTarget */, *highlightConfig, false); 1353 m_overlay->highlightNode(frame->deprecatedLocalOwner(), 0 /* eventTarget */, *highlightConfig, false);
1351 } 1354 }
1352 } 1355 }
1353 1356
1357 void InspectorDOMAgent::getAnimationPlayersForNode(ErrorString* errorString, int nodeId, RefPtr<TypeBuilder::Array<TypeBuilder::DOM::AnimationPlayer> >& animati onPlayersArray)
1358 {
1359 animationPlayersArray = TypeBuilder::Array<TypeBuilder::DOM::AnimationPlayer >::create();
1360 Node* node = assertNode(errorString, nodeId);
1361 if (!node)
1362 return;
1363 Element* element = toElement(node);
caseq 2014/10/02 09:48:01 This is a protocol method, what if protocol client
samli 2014/10/03 06:05:04 Done.
1364 WillBeHeapVector<RefPtrWillBeMember<AnimationPlayer> > players = ElementAnim ation::getAnimationPlayers(*element);
1365 for (WillBeHeapVector<RefPtrWillBeMember<AnimationPlayer> >::iterator it = p layers.begin(); it != players.end(); ++it) {
1366 AnimationPlayer& player = *(it->get());
1367 m_idToAnimationPlayer.set(player.sequenceNumber(), &player);
1368 RefPtr<TypeBuilder::DOM::AnimationPlayer> animationPlayerObject = buildO bjectForAnimationPlayer(player);
1369 animationPlayersArray->addItem(animationPlayerObject);
1370 }
1371 }
1372
1373 void InspectorDOMAgent::pauseAnimationPlayer(ErrorString* errorString, int seque nceNumber, RefPtr<TypeBuilder::DOM::AnimationPlayer>& animationPlayer)
1374 {
1375 RefPtrWillBeMember<AnimationPlayer> player = m_idToAnimationPlayer.get(seque nceNumber);
1376 ASSERT(player);
caseq 2014/10/02 09:48:01 You shouldn't ASSERT() on client providing correct
samli 2014/10/03 06:05:04 Done.
1377 player->pause();
1378 animationPlayer = buildObjectForAnimationPlayer(*(player.get()));
1379 }
1380
1381 void InspectorDOMAgent::playAnimationPlayer(ErrorString* errorString, int sequen ceNumber, RefPtr<TypeBuilder::DOM::AnimationPlayer>& animationPlayer)
1382 {
1383 RefPtrWillBeMember<AnimationPlayer> player = m_idToAnimationPlayer.get(seque nceNumber);
1384 ASSERT(player);
caseq 2014/10/02 09:48:01 ditto.
samli 2014/10/03 06:05:04 Done.
1385 player->play();
1386 animationPlayer = buildObjectForAnimationPlayer(*(player.get()));
1387 }
1388
1389 void InspectorDOMAgent::setCurrentTimeAnimationPlayer(ErrorString* errorString, int sequenceNumber, double currentTime, RefPtr<TypeBuilder::DOM::AnimationPlayer >& animationPlayer)
1390 {
1391 RefPtrWillBeMember<AnimationPlayer> player = m_idToAnimationPlayer.get(seque nceNumber);
1392 ASSERT(player);
caseq 2014/10/02 09:48:01 ditto.
samli 2014/10/03 06:05:04 Done.
1393 player->setCurrentTime(currentTime);
1394 animationPlayer = buildObjectForAnimationPlayer(*(player.get()));
1395 }
1396
1397 void InspectorDOMAgent::getStateAnimationPlayer(ErrorString* errorString, int se quenceNumber, double* currentTime, bool* isRunning)
1398 {
1399 RefPtrWillBeMember<AnimationPlayer> player = m_idToAnimationPlayer.get(seque nceNumber);
1400 ASSERT(player);
1401 *currentTime = player->currentTime();
1402 *isRunning = !player->paused() && !player->finished();
caseq 2014/10/02 09:48:01 isn't player->playing()? good for that?
samli 2014/10/03 06:05:04 Done.
1403 }
1404
1354 void InspectorDOMAgent::hideHighlight(ErrorString*) 1405 void InspectorDOMAgent::hideHighlight(ErrorString*)
1355 { 1406 {
1356 m_overlay->hideHighlight(); 1407 m_overlay->hideHighlight();
1357 } 1408 }
1358 1409
1359 void InspectorDOMAgent::copyTo(ErrorString* errorString, int nodeId, int targetE lementId, const int* const anchorNodeId, int* newNodeId) 1410 void InspectorDOMAgent::copyTo(ErrorString* errorString, int nodeId, int targetE lementId, const int* const anchorNodeId, int* newNodeId)
1360 { 1411 {
1361 Node* node = assertEditableNode(errorString, nodeId); 1412 Node* node = assertEditableNode(errorString, nodeId);
1362 if (!node) 1413 if (!node)
1363 return; 1414 return;
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
1765 return nullptr; 1816 return nullptr;
1766 1817
1767 RefPtr<TypeBuilder::Array<TypeBuilder::DOM::Node> > pseudoElements = TypeBui lder::Array<TypeBuilder::DOM::Node>::create(); 1818 RefPtr<TypeBuilder::Array<TypeBuilder::DOM::Node> > pseudoElements = TypeBui lder::Array<TypeBuilder::DOM::Node>::create();
1768 if (element->pseudoElement(BEFORE)) 1819 if (element->pseudoElement(BEFORE))
1769 pseudoElements->addItem(buildObjectForNode(element->pseudoElement(BEFORE ), 0, nodesMap)); 1820 pseudoElements->addItem(buildObjectForNode(element->pseudoElement(BEFORE ), 0, nodesMap));
1770 if (element->pseudoElement(AFTER)) 1821 if (element->pseudoElement(AFTER))
1771 pseudoElements->addItem(buildObjectForNode(element->pseudoElement(AFTER) , 0, nodesMap)); 1822 pseudoElements->addItem(buildObjectForNode(element->pseudoElement(AFTER) , 0, nodesMap));
1772 return pseudoElements.release(); 1823 return pseudoElements.release();
1773 } 1824 }
1774 1825
1826 PassRefPtr<TypeBuilder::DOM::AnimationPlayer> InspectorDOMAgent::buildObjectForA nimationPlayer(AnimationPlayer& animationPlayer)
1827 {
1828 RefPtr<TypeBuilder::DOM::AnimationPlayer> playerObject = TypeBuilder::DOM::A nimationPlayer::create()
1829 .setSequenceNumber(animationPlayer.sequenceNumber())
1830 .setPaused(animationPlayer.paused())
1831 .setFinished(animationPlayer.finished())
1832 .setPlaybackRate(animationPlayer.playbackRate())
1833 .setStartTime(animationPlayer.startTime())
1834 .setCurrentTime(animationPlayer.currentTime())
1835 .setAnimation(buildObjectForAnimationNode(*(animationPlayer.source())));
1836 return playerObject.release();
1837 }
1838
1839 PassRefPtr<TypeBuilder::DOM::AnimationNode> InspectorDOMAgent::buildObjectForAni mationNode(AnimationNode& animationNode)
1840 {
1841 RefPtr<TypeBuilder::DOM::AnimationNode> animationObject = TypeBuilder::DOM:: AnimationNode::create()
1842 .setStartDelay(animationNode.specifiedTiming().startDelay)
1843 .setPlaybackRate(animationNode.specifiedTiming().playbackRate)
1844 .setIterationStart(animationNode.specifiedTiming().iterationStart)
1845 .setIterationCount(animationNode.specifiedTiming().iterationCount)
1846 .setDuration(animationNode.duration())
1847 .setDirection(animationNode.specifiedTiming().direction)
1848 .setFillMode(animationNode.specifiedTiming().fillMode)
1849 .setTimeFraction(animationNode.timeFraction());
1850 return animationObject.release();
1851 }
1852
1775 Node* InspectorDOMAgent::innerFirstChild(Node* node) 1853 Node* InspectorDOMAgent::innerFirstChild(Node* node)
1776 { 1854 {
1777 node = node->firstChild(); 1855 node = node->firstChild();
1778 while (isWhitespace(node)) 1856 while (isWhitespace(node))
1779 node = node->nextSibling(); 1857 node = node->nextSibling();
1780 return node; 1858 return node;
1781 } 1859 }
1782 1860
1783 Node* InspectorDOMAgent::innerNextSibling(Node* node) 1861 Node* InspectorDOMAgent::innerNextSibling(Node* node)
1784 { 1862 {
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
2192 visitor->trace(m_pageAgent); 2270 visitor->trace(m_pageAgent);
2193 visitor->trace(m_injectedScriptManager); 2271 visitor->trace(m_injectedScriptManager);
2194 #if ENABLE(OILPAN) 2272 #if ENABLE(OILPAN)
2195 visitor->trace(m_documentNodeToIdMap); 2273 visitor->trace(m_documentNodeToIdMap);
2196 visitor->trace(m_danglingNodeToIdMaps); 2274 visitor->trace(m_danglingNodeToIdMaps);
2197 visitor->trace(m_idToNode); 2275 visitor->trace(m_idToNode);
2198 visitor->trace(m_idToNodesMap); 2276 visitor->trace(m_idToNodesMap);
2199 visitor->trace(m_document); 2277 visitor->trace(m_document);
2200 visitor->trace(m_revalidateStyleAttrTask); 2278 visitor->trace(m_revalidateStyleAttrTask);
2201 visitor->trace(m_searchResults); 2279 visitor->trace(m_searchResults);
2280 visitor->trace(m_idToAnimationPlayer);
2202 #endif 2281 #endif
2203 visitor->trace(m_history); 2282 visitor->trace(m_history);
2204 visitor->trace(m_domEditor); 2283 visitor->trace(m_domEditor);
2205 visitor->trace(m_listener); 2284 visitor->trace(m_listener);
2206 InspectorBaseAgent::trace(visitor); 2285 InspectorBaseAgent::trace(visitor);
2207 } 2286 }
2208 2287
2209 } // namespace blink 2288 } // namespace blink
2210 2289
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698