Commit f9c17fc0 authored by shans@chromium.org's avatar shans@chromium.org

WebIDL Dictionaries should access prototype chains when searching for...

WebIDL Dictionaries should access prototype chains when searching for properties. This change adds getPropertyNames to the v8 Dictionary class.

Web Animations Keyframes should make use of prototype chains when looking for CSS properties to animate. This change makes use of getPropertyNames to ensure this happens.

Review URL: https://codereview.chromium.org/661453004

git-svn-id: svn://svn.chromium.org/blink/trunk@184350 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 79942503
...@@ -36,11 +36,10 @@ test(function() { ...@@ -36,11 +36,10 @@ test(function() {
value: '100px', value: '100px',
enumerable: 'true'}); enumerable: 'true'});
var keyframe = new Keyframe(); var keyframe = new Keyframe();
assert_array_equals(Object.keys(keyframe), ["top"]);
try { try {
div.animate([keyframe, {top: '200px'}], 1); div.animate([keyframe, {top: '200px', left: '200px', height: '200px'}], 1);
} catch (e) { } catch (e) {
assert_unreached("Mismatched properties - left, width or height considered on keyframe."); assert_unreached("Mismatched properties - left, width or height not considered on keyframe.");
} }
}, },
'inherited keyframe properties tests', 'inherited keyframe properties tests',
......
...@@ -264,6 +264,29 @@ bool Dictionary::getOwnPropertyNames(Vector<String>& names) const ...@@ -264,6 +264,29 @@ bool Dictionary::getOwnPropertyNames(Vector<String>& names) const
return true; return true;
} }
bool Dictionary::getPropertyNames(Vector<String>& names) const
{
if (!isObject())
return false;
v8::Handle<v8::Object> options = m_options->ToObject();
if (options.IsEmpty())
return false;
v8::Local<v8::Array> properties = options->GetPropertyNames();
if (properties.IsEmpty())
return true;
for (uint32_t i = 0; i < properties->Length(); ++i) {
v8::Local<v8::String> key = properties->Get(i)->ToString();
if (!options->Has(key))
continue;
TOSTRING_DEFAULT(V8StringResource<>, stringKey, key, false);
names.append(stringKey);
}
return true;
}
void Dictionary::ConversionContext::resetPerPropertyContext() void Dictionary::ConversionContext::resetPerPropertyContext()
{ {
if (m_dirty) { if (m_dirty) {
......
...@@ -125,6 +125,7 @@ public: ...@@ -125,6 +125,7 @@ public:
bool getOwnPropertiesAsStringHashMap(HashMap<String, String>&) const; bool getOwnPropertiesAsStringHashMap(HashMap<String, String>&) const;
bool getOwnPropertyNames(Vector<String>&) const; bool getOwnPropertyNames(Vector<String>&) const;
bool getPropertyNames(Vector<String>&) const;
bool getWithUndefinedOrNullCheck(const String&, String&) const; bool getWithUndefinedOrNullCheck(const String&, String&) const;
bool getWithUndefinedOrNullCheck(const String&, RefPtrWillBeMember<Element>&) const; bool getWithUndefinedOrNullCheck(const String&, RefPtrWillBeMember<Element>&) const;
......
...@@ -95,7 +95,7 @@ PassRefPtrWillBeRawPtr<AnimationEffect> EffectInput::convert(Element* element, c ...@@ -95,7 +95,7 @@ PassRefPtrWillBeRawPtr<AnimationEffect> EffectInput::convert(Element* element, c
} }
Vector<String> keyframeProperties; Vector<String> keyframeProperties;
keyframeDictionaryVector[i].getOwnPropertyNames(keyframeProperties); keyframeDictionaryVector[i].getPropertyNames(keyframeProperties);
for (size_t j = 0; j < keyframeProperties.size(); ++j) { for (size_t j = 0; j < keyframeProperties.size(); ++j) {
String property = keyframeProperties[j]; String property = keyframeProperties[j];
CSSPropertyID id = AnimationInputHelpers::keyframeAttributeToCSSPropertyID(property); CSSPropertyID id = AnimationInputHelpers::keyframeAttributeToCSSPropertyID(property);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment