Changeset 201818 in webkit for trunk/Source/WebCore/css/StyleResolver.cpp
- Timestamp:
- Jun 8, 2016, 11:46:43 AM (9 years ago)
- File:
-
- 1 edited
-
trunk/Source/WebCore/css/StyleResolver.cpp (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/css/StyleResolver.cpp
r201799 r201818 514 514 list.clear(); 515 515 516 // Get the keyframesRule for this name 516 // Get the keyframesRule for this name. 517 517 if (list.animationName().isEmpty()) 518 518 return; … … 526 526 const StyleRuleKeyframes* keyframesRule = it->value.get(); 527 527 528 // Construct and populate the style for each keyframe 529 for (auto& keyframe : keyframesRule->keyframes()) { 530 // Apply the declaration to the style. This is a simplified version of the logic in styleForElement 528 auto* keyframes = &keyframesRule->keyframes(); 529 Vector<Ref<StyleKeyframe>> newKeyframesIfNecessary; 530 531 bool hasDuplicateKeys; 532 HashSet<double> keyframeKeys; 533 for (auto& keyframe : *keyframes) { 534 for (auto key : keyframe->keys()) { 535 if (!keyframeKeys.add(key)) { 536 hasDuplicateKeys = true; 537 break; 538 } 539 } 540 if (hasDuplicateKeys) 541 break; 542 } 543 544 // FIXME: If HashMaps could have Ref<> as value types, we wouldn't need 545 // to copy the HashMap into a Vector. 546 if (hasDuplicateKeys) { 547 // Merge duplicate key times. 548 HashMap<double, RefPtr<StyleKeyframe>> keyframesMap; 549 550 for (auto& originalKeyframe : keyframesRule->keyframes()) { 551 for (auto key : originalKeyframe->keys()) { 552 if (auto keyframe = keyframesMap.get(key)) 553 keyframe->mutableProperties().mergeAndOverrideOnConflict(originalKeyframe->properties()); 554 else { 555 auto styleKeyframe = StyleKeyframe::create(MutableStyleProperties::create()); 556 styleKeyframe.ptr()->setKey(key); 557 styleKeyframe.ptr()->mutableProperties().mergeAndOverrideOnConflict(originalKeyframe->properties()); 558 keyframesMap.set(key, styleKeyframe.ptr()); 559 } 560 } 561 } 562 563 for (auto& keyframe : keyframesMap.values()) 564 newKeyframesIfNecessary.append(*keyframe.get()); 565 566 keyframes = &newKeyframesIfNecessary; 567 } 568 569 // Construct and populate the style for each keyframe. 570 for (auto& keyframe : *keyframes) { 571 // Apply the declaration to the style. This is a simplified version of the logic in styleForElement. 531 572 m_state = State(element, nullptr); 532 573 533 574 // Add this keyframe style to all the indicated key times 534 for (auto &key : keyframe->keys()) {575 for (auto key : keyframe->keys()) { 535 576 KeyframeValue keyframeValue(0, nullptr); 536 577 keyframeValue.setStyle(styleForKeyframe(elementStyle, keyframe.ptr(), keyframeValue)); … … 540 581 } 541 582 542 // If the 0% keyframe is missing, create it (but only if there is at least one other keyframe) 583 // If the 0% keyframe is missing, create it (but only if there is at least one other keyframe). 543 584 int initialListSize = list.size(); 544 585 if (initialListSize > 0 && list[0].key()) { … … 546 587 if (!zeroPercentKeyframe) { 547 588 zeroPercentKeyframe = &StyleKeyframe::create(MutableStyleProperties::create()).leakRef(); 548 zeroPercentKeyframe->setKey Text("0%");589 zeroPercentKeyframe->setKey(0); 549 590 } 550 591 KeyframeValue keyframeValue(0, nullptr); … … 553 594 } 554 595 555 // If the 100% keyframe is missing, create it (but only if there is at least one other keyframe) 596 // If the 100% keyframe is missing, create it (but only if there is at least one other keyframe). 556 597 if (initialListSize > 0 && (list[list.size() - 1].key() != 1)) { 557 598 static StyleKeyframe* hundredPercentKeyframe; 558 599 if (!hundredPercentKeyframe) { 559 600 hundredPercentKeyframe = &StyleKeyframe::create(MutableStyleProperties::create()).leakRef(); 560 hundredPercentKeyframe->setKey Text("100%");601 hundredPercentKeyframe->setKey(1); 561 602 } 562 603 KeyframeValue keyframeValue(1, nullptr);
Note:
See TracChangeset
for help on using the changeset viewer.