OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 30 matching lines...) Expand all Loading... | |
41 namespace WebCore { | 41 namespace WebCore { |
42 | 42 |
43 static bool checkDocumentAndRenderer(Element* element) | 43 static bool checkDocumentAndRenderer(Element* element) |
44 { | 44 { |
45 if (!element->inActiveDocument()) | 45 if (!element->inActiveDocument()) |
46 return false; | 46 return false; |
47 element->document().updateStyleIfNeeded(); | 47 element->document().updateStyleIfNeeded(); |
48 return element->renderer(); | 48 return element->renderer(); |
49 } | 49 } |
50 | 50 |
51 PassRefPtrWillBeRawPtr<AnimationEffect> EffectInput::convert(Element* element, c onst Vector<Dictionary>& keyframeDictionaryVector, bool unsafe) | 51 static bool hasPartialKeyframe(Vector<RefPtr<MutableStylePropertySet> > property SetVector) |
52 { | |
53 HashCountedSet<CSSPropertyID> counter; | |
54 for (size_t i = 0; i < propertySetVector.size(); ++i) { | |
55 for (size_t j = 0; j < propertySetVector[i]->propertyCount(); ++j) { | |
56 CSSPropertyID property = propertySetVector[i]->propertyAt(j).id(); | |
57 counter.add(property); | |
58 } | |
59 } | |
60 for (HashCountedSet<CSSPropertyID>::iterator iterator = counter.begin(); ite rator != counter.end(); ++iterator) { | |
61 if (iterator->value == 1) | |
62 return true; | |
63 } | |
64 return false; | |
65 } | |
shans
2014/03/10 23:28:40
This won't pick up cases like:
element.animate(
rjwright
2014/03/10 23:35:37
It is meant to?
rjwright
2014/03/11 01:48:42
Done.
| |
66 | |
67 PassRefPtrWillBeRawPtr<AnimationEffect> EffectInput::convert(Element* element, c onst Vector<Dictionary>& keyframeDictionaryVector, ExceptionState& exceptionSta te, bool unsafe) | |
52 { | 68 { |
53 // FIXME: This test will not be neccessary once resolution of keyframe value s occurs at | 69 // FIXME: This test will not be neccessary once resolution of keyframe value s occurs at |
54 // animation application time. | 70 // animation application time. |
55 if (!unsafe && !checkDocumentAndRenderer(element)) | 71 if (!unsafe && !checkDocumentAndRenderer(element)) |
56 return nullptr; | 72 return nullptr; |
57 | 73 |
58 // FIXME: Move this code into KeyframeEffectModel, it will be used by the ID L constructor for that class. | 74 // FIXME: Move this code into KeyframeEffectModel, it will be used by the ID L constructor for that class. |
59 KeyframeEffectModel::KeyframeVector keyframes; | 75 KeyframeEffectModel::KeyframeVector keyframes; |
60 Vector<RefPtr<MutableStylePropertySet> > propertySetVector; | 76 Vector<RefPtr<MutableStylePropertySet> > propertySetVector; |
61 | 77 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
96 // KeyframeEffectModel, store input keyframes and implement getFrame s. | 112 // KeyframeEffectModel, store input keyframes and implement getFrame s. |
97 if (id == CSSPropertyInvalid || !CSSAnimations::isAnimatableProperty (id)) | 113 if (id == CSSPropertyInvalid || !CSSAnimations::isAnimatableProperty (id)) |
98 continue; | 114 continue; |
99 | 115 |
100 String value; | 116 String value; |
101 keyframeDictionaryVector[i].get(property, value); | 117 keyframeDictionaryVector[i].get(property, value); |
102 propertySet->setProperty(id, value); | 118 propertySet->setProperty(id, value); |
103 } | 119 } |
104 } | 120 } |
105 | 121 |
122 // FIXME: Web Animations can't yet handle keyframe sets where a property app ears in only one keyframe (called "partial keyframes"). | |
123 // This check can be removed once support for such inputs is added. | |
124 if (hasPartialKeyframe(propertySetVector)) | |
125 exceptionState.throwDOMException(NotSupportedError, "Keyframe effect con tains properties that appear in only one keyframe."); | |
126 | |
106 // FIXME: Replace this with code that just parses, when that code is availab le. | 127 // FIXME: Replace this with code that just parses, when that code is availab le. |
107 return StyleResolver::createKeyframeEffectModel(*element, propertySetVector, keyframes); | 128 return StyleResolver::createKeyframeEffectModel(*element, propertySetVector, keyframes); |
108 } | 129 } |
109 | 130 |
110 } // namespace WebCore | 131 } // namespace WebCore |
OLD | NEW |