Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/inspector/InspectorAnimationAgent.h" | 5 #include "core/inspector/InspectorAnimationAgent.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include "bindings/core/v8/V8BindingForCore.h" | 8 #include "bindings/core/v8/V8BindingForCore.h" |
| 9 #include "core/animation/Animation.h" | 9 #include "core/animation/Animation.h" |
| 10 #include "core/animation/AnimationEffectReadOnly.h" | 10 #include "core/animation/AnimationEffectReadOnly.h" |
| (...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 447 CSSPropertyAnimationDelay, CSSPropertyAnimationDirection, | 447 CSSPropertyAnimationDelay, CSSPropertyAnimationDirection, |
| 448 CSSPropertyAnimationDuration, CSSPropertyAnimationFillMode, | 448 CSSPropertyAnimationDuration, CSSPropertyAnimationFillMode, |
| 449 CSSPropertyAnimationIterationCount, CSSPropertyAnimationName, | 449 CSSPropertyAnimationIterationCount, CSSPropertyAnimationName, |
| 450 CSSPropertyAnimationTimingFunction}; | 450 CSSPropertyAnimationTimingFunction}; |
| 451 | 451 |
| 452 static CSSPropertyID g_transition_properties[] = { | 452 static CSSPropertyID g_transition_properties[] = { |
| 453 CSSPropertyTransitionDelay, CSSPropertyTransitionDuration, | 453 CSSPropertyTransitionDelay, CSSPropertyTransitionDuration, |
| 454 CSSPropertyTransitionProperty, CSSPropertyTransitionTimingFunction, | 454 CSSPropertyTransitionProperty, CSSPropertyTransitionTimingFunction, |
| 455 }; | 455 }; |
| 456 | 456 |
| 457 static void AddStringToDigestor(WebCryptoDigestor* digestor, | 457 static void AddAsciiStringToDigestor(WebCryptoDigestor* digestor, |
| 458 const String& string) { | 458 const String& string) { |
| 459 digestor->Consume( | 459 digestor->Consume( |
| 460 reinterpret_cast<const unsigned char*>(string.Ascii().data()), | 460 reinterpret_cast<const unsigned char*>(string.Ascii().data()), |
| 461 string.length()); | 461 string.length()); |
|
alph
2017/07/10 21:26:06
ditto.
| |
| 462 } | 462 } |
| 463 | 463 |
| 464 String InspectorAnimationAgent::CreateCSSId(blink::Animation& animation) { | 464 String InspectorAnimationAgent::CreateCSSId(blink::Animation& animation) { |
| 465 String type = | 465 String type = |
| 466 id_to_animation_type_.at(String::Number(animation.SequenceNumber())); | 466 id_to_animation_type_.at(String::Number(animation.SequenceNumber())); |
| 467 DCHECK_NE(type, AnimationType::WebAnimation); | 467 DCHECK_NE(type, AnimationType::WebAnimation); |
| 468 | 468 |
| 469 KeyframeEffectReadOnly* effect = ToKeyframeEffectReadOnly(animation.effect()); | 469 KeyframeEffectReadOnly* effect = ToKeyframeEffectReadOnly(animation.effect()); |
| 470 Vector<CSSPropertyID> css_properties; | 470 Vector<CSSPropertyID> css_properties; |
| 471 if (type == AnimationType::CSSAnimation) { | 471 if (type == AnimationType::CSSAnimation) { |
| 472 for (CSSPropertyID property : g_animation_properties) | 472 for (CSSPropertyID property : g_animation_properties) |
| 473 css_properties.push_back(property); | 473 css_properties.push_back(property); |
| 474 } else { | 474 } else { |
| 475 for (CSSPropertyID property : g_transition_properties) | 475 for (CSSPropertyID property : g_transition_properties) |
| 476 css_properties.push_back(property); | 476 css_properties.push_back(property); |
| 477 css_properties.push_back(cssPropertyID(animation.id())); | 477 css_properties.push_back(cssPropertyID(animation.id())); |
| 478 } | 478 } |
| 479 | 479 |
| 480 Element* element = effect->Target(); | 480 Element* element = effect->Target(); |
| 481 HeapVector<Member<CSSStyleDeclaration>> styles = | 481 HeapVector<Member<CSSStyleDeclaration>> styles = |
| 482 css_agent_->MatchingStyles(element); | 482 css_agent_->MatchingStyles(element); |
| 483 std::unique_ptr<WebCryptoDigestor> digestor = | 483 std::unique_ptr<WebCryptoDigestor> digestor = |
| 484 CreateDigestor(kHashAlgorithmSha1); | 484 CreateDigestor(kHashAlgorithmSha1); |
| 485 AddStringToDigestor(digestor.get(), type); | 485 AddAsciiStringToDigestor(digestor.get(), type); |
| 486 AddStringToDigestor(digestor.get(), animation.id()); | 486 AddAsciiStringToDigestor(digestor.get(), animation.id()); |
| 487 for (CSSPropertyID property : css_properties) { | 487 for (CSSPropertyID property : css_properties) { |
| 488 CSSStyleDeclaration* style = | 488 CSSStyleDeclaration* style = |
| 489 css_agent_->FindEffectiveDeclaration(property, styles); | 489 css_agent_->FindEffectiveDeclaration(property, styles); |
| 490 // Ignore inline styles. | 490 // Ignore inline styles. |
| 491 if (!style || !style->ParentStyleSheet() || !style->parentRule() || | 491 if (!style || !style->ParentStyleSheet() || !style->parentRule() || |
| 492 style->parentRule()->type() != CSSRule::kStyleRule) | 492 style->parentRule()->type() != CSSRule::kStyleRule) |
| 493 continue; | 493 continue; |
| 494 AddStringToDigestor(digestor.get(), getPropertyNameString(property)); | 494 AddAsciiStringToDigestor(digestor.get(), getPropertyNameString(property)); |
| 495 AddStringToDigestor(digestor.get(), | 495 AddAsciiStringToDigestor( |
| 496 css_agent_->StyleSheetId(style->ParentStyleSheet())); | 496 digestor.get(), css_agent_->StyleSheetId(style->ParentStyleSheet())); |
| 497 AddStringToDigestor(digestor.get(), | 497 AddAsciiStringToDigestor( |
| 498 ToCSSStyleRule(style->parentRule())->selectorText()); | 498 digestor.get(), ToCSSStyleRule(style->parentRule())->selectorText()); |
| 499 } | 499 } |
| 500 DigestValue digest_result; | 500 DigestValue digest_result; |
| 501 FinishDigestor(digestor.get(), digest_result); | 501 FinishDigestor(digestor.get(), digest_result); |
| 502 return Base64Encode(reinterpret_cast<const char*>(digest_result.data()), 10); | 502 return Base64Encode(reinterpret_cast<const char*>(digest_result.data()), 10); |
| 503 } | 503 } |
| 504 | 504 |
| 505 void InspectorAnimationAgent::DidCreateAnimation(unsigned sequence_number) { | 505 void InspectorAnimationAgent::DidCreateAnimation(unsigned sequence_number) { |
| 506 if (is_cloning_) | 506 if (is_cloning_) |
| 507 return; | 507 return; |
| 508 GetFrontend()->animationCreated(String::Number(sequence_number)); | 508 GetFrontend()->animationCreated(String::Number(sequence_number)); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 564 | 564 |
| 565 DEFINE_TRACE(InspectorAnimationAgent) { | 565 DEFINE_TRACE(InspectorAnimationAgent) { |
| 566 visitor->Trace(inspected_frames_); | 566 visitor->Trace(inspected_frames_); |
| 567 visitor->Trace(css_agent_); | 567 visitor->Trace(css_agent_); |
| 568 visitor->Trace(id_to_animation_); | 568 visitor->Trace(id_to_animation_); |
| 569 visitor->Trace(id_to_animation_clone_); | 569 visitor->Trace(id_to_animation_clone_); |
| 570 InspectorBaseAgent::Trace(visitor); | 570 InspectorBaseAgent::Trace(visitor); |
| 571 } | 571 } |
| 572 | 572 |
| 573 } // namespace blink | 573 } // namespace blink |
| OLD | NEW |