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

Side by Side Diff: Source/core/dom/Element.cpp

Issue 19266007: Web Animations: Introduce ActiveAnimations and AnimationStack (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Removed maps. Store ActiveAnimations in ElementRareData. Created 7 years, 5 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 | Annotate | Revision Log
OLDNEW
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 Peter Kelly (pmk@post.com) 4 * (C) 2001 Peter Kelly (pmk@post.com)
5 * (C) 2001 Dirk Mueller (mueller@kde.org) 5 * (C) 2001 Dirk Mueller (mueller@kde.org)
6 * (C) 2007 David Smith (catfish.man@gmail.com) 6 * (C) 2007 David Smith (catfish.man@gmail.com)
7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved. 7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved.
8 * (C) 2007 Eric Seidel (eric@webkit.org) 8 * (C) 2007 Eric Seidel (eric@webkit.org)
9 * 9 *
10 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
(...skipping 14 matching lines...) Expand all
25 25
26 #include "config.h" 26 #include "config.h"
27 #include "core/dom/Element.h" 27 #include "core/dom/Element.h"
28 28
29 #include "CSSPropertyNames.h" 29 #include "CSSPropertyNames.h"
30 #include "CSSValueKeywords.h" 30 #include "CSSValueKeywords.h"
31 #include "HTMLNames.h" 31 #include "HTMLNames.h"
32 #include "SVGNames.h" 32 #include "SVGNames.h"
33 #include "XMLNames.h" 33 #include "XMLNames.h"
34 #include "core/accessibility/AXObjectCache.h" 34 #include "core/accessibility/AXObjectCache.h"
35 #include "core/animation/DocumentTimeline.h"
35 #include "core/css/CSSParser.h" 36 #include "core/css/CSSParser.h"
36 #include "core/css/CSSStyleSheet.h" 37 #include "core/css/CSSStyleSheet.h"
37 #include "core/css/CSSValuePool.h" 38 #include "core/css/CSSValuePool.h"
38 #include "core/css/PropertySetCSSStyleDeclaration.h" 39 #include "core/css/PropertySetCSSStyleDeclaration.h"
39 #include "core/css/StylePropertySet.h" 40 #include "core/css/StylePropertySet.h"
40 #include "core/css/resolver/StyleResolver.h" 41 #include "core/css/resolver/StyleResolver.h"
41 #include "core/dom/Attr.h" 42 #include "core/dom/Attr.h"
42 #include "core/dom/Attribute.h" 43 #include "core/dom/Attribute.h"
43 #include "core/dom/ClientRect.h" 44 #include "core/dom/ClientRect.h"
44 #include "core/dom/ClientRectList.h" 45 #include "core/dom/ClientRectList.h"
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 NamedNodeMap* Element::attributes() const 368 NamedNodeMap* Element::attributes() const
368 { 369 {
369 ElementRareData* rareData = const_cast<Element*>(this)->ensureElementRareDat a(); 370 ElementRareData* rareData = const_cast<Element*>(this)->ensureElementRareDat a();
370 if (NamedNodeMap* attributeMap = rareData->attributeMap()) 371 if (NamedNodeMap* attributeMap = rareData->attributeMap())
371 return attributeMap; 372 return attributeMap;
372 373
373 rareData->setAttributeMap(NamedNodeMap::create(const_cast<Element*>(this))); 374 rareData->setAttributeMap(NamedNodeMap::create(const_cast<Element*>(this)));
374 return rareData->attributeMap(); 375 return rareData->attributeMap();
375 } 376 }
376 377
377 void Element::addActiveAnimation(Animation* animation) 378 ActiveAnimations* Element::activeAnimations() const
379 {
380 if (hasActiveAnimations())
381 return elementRareData()->activeAnimations();
382 return 0;
383 }
384
385 ActiveAnimations* Element::ensureActiveAnimations()
378 { 386 {
379 ElementRareData* rareData = ensureElementRareData(); 387 ElementRareData* rareData = ensureElementRareData();
380 if (!rareData->activeAnimations()) 388 if (!elementRareData()->activeAnimations())
381 rareData->setActiveAnimations(adoptPtr(new Vector<Animation*>)); 389 rareData->setActiveAnimations(adoptPtr(new ActiveAnimations()));
382 rareData->activeAnimations()->append(animation); 390 return rareData->activeAnimations();
383 }
384
385 void Element::removeActiveAnimation(Animation* animation)
386 {
387 ElementRareData* rareData = elementRareData();
388 ASSERT(rareData);
389 size_t position = rareData->activeAnimations()->find(animation);
390 ASSERT(position != notFound);
391 rareData->activeAnimations()->remove(position);
392 } 391 }
393 392
394 bool Element::hasActiveAnimations() const 393 bool Element::hasActiveAnimations() const
395 { 394 {
396 return hasRareData() && elementRareData()->activeAnimations() 395 if (!RuntimeEnabledFeatures::webAnimationsEnabled())
397 && elementRareData()->activeAnimations()->size(); 396 return false;
398 }
399 397
400 Vector<Animation*>* Element::activeAnimations() const 398 if (!hasRareData())
401 { 399 return false;
402 if (!elementRareData()) 400
403 return 0; 401 ActiveAnimations* activeAnimations = elementRareData()->activeAnimations();
404 return elementRareData()->activeAnimations(); 402 return activeAnimations && !activeAnimations->isEmpty();
405 } 403 }
406 404
407 Node::NodeType Element::nodeType() const 405 Node::NodeType Element::nodeType() const
408 { 406 {
409 return ELEMENT_NODE; 407 return ELEMENT_NODE;
410 } 408 }
411 409
412 bool Element::hasAttribute(const QualifiedName& name) const 410 bool Element::hasAttribute(const QualifiedName& name) const
413 { 411 {
414 return hasAttributeNS(name.namespaceURI(), name.localName()); 412 return hasAttributeNS(name.namespaceURI(), name.localName());
(...skipping 3234 matching lines...) Expand 10 before | Expand all | Expand 10 after
3649 return 0; 3647 return 0;
3650 } 3648 }
3651 3649
3652 Attribute* UniqueElementData::attributeItem(unsigned index) 3650 Attribute* UniqueElementData::attributeItem(unsigned index)
3653 { 3651 {
3654 ASSERT_WITH_SECURITY_IMPLICATION(index < length()); 3652 ASSERT_WITH_SECURITY_IMPLICATION(index < length());
3655 return &m_attributeVector.at(index); 3653 return &m_attributeVector.at(index);
3656 } 3654 }
3657 3655
3658 } // namespace WebCore 3656 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698