Changeset 142215 in webkit
- Timestamp:
- Feb 7, 2013 5:40:30 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r142214 r142215 1 2013-02-07 Elliott Sprehn <esprehn@chromium.org> 2 3 getComputedStyle() doesn't report intermediate values during a transition of a pseudo element 4 https://bugs.webkit.org/show_bug.cgi?id=106535 5 6 Reviewed by Ojan Vafai. 7 8 Update tests to also check getComputedStyle during animations and transitions. 9 10 * fast/css-generated-content/pseudo-animation-expected.txt: 11 * fast/css-generated-content/pseudo-animation.html: 12 * fast/css-generated-content/pseudo-transition-expected.txt: 13 * fast/css-generated-content/pseudo-transition.html: 14 1 15 2013-02-07 Kent Tamura <tkent@chromium.org> 2 16 -
trunk/LayoutTests/fast/css-generated-content/pseudo-animation-expected.txt
r138632 r142215 5 5 6 6 PASS div.offsetWidth is 52 7 PASS div.offsetWidth is 20 8 PASS div.offsetWidth is 12 7 PASS div.offsetWidth is within 1 of 20 8 PASS computedTop is within 1 of 170 9 PASS div.offsetWidth is within 1 of 12 10 PASS computedTop is within 1 of 200 9 11 PASS div.offsetWidth is 52 10 PASS div.offsetWidth is 20 11 PASS div.offsetWidth is 12 12 PASS div.offsetWidth is within 1 of 20 13 PASS computedTop is within 1 of 170 14 PASS div.offsetWidth is within 1 of 12 15 PASS computedTop is within 1 of 200 12 16 PASS successfullyParsed is true 13 17 -
trunk/LayoutTests/fast/css-generated-content/pseudo-animation.html
r138632 r142215 8 8 width: 50px; 9 9 height: 50px; 10 top: 50px; 10 11 } 11 12 to { 12 13 width: 10px; 13 14 height: 10px; 15 top: 200px; 14 16 } 15 17 } … … 19 21 width: 50px; 20 22 height: 50px; 23 top: 50px; 21 24 } 22 25 to { 23 26 width: 10px; 24 27 height: 10px; 28 top: 200px; 25 29 } 26 30 } … … 32 36 height: 50px; 33 37 width: 50px; 38 position: relative; 34 39 } 35 40 36 41 #after.animate:after, 37 42 #before.animate:before { 43 top: 200px; 38 44 width: 10px; 39 45 height: 10px; … … 65 71 testRunner.dumpAsText(); 66 72 73 function getPseudoComputedTop(id) 74 { 75 return Math.round(parseFloat(getComputedStyle(document.getElementById(id), ':' + id).top)); 76 } 77 78 // FIXME: This test should be modified so subpixel doesn't cause off by one 79 // below and it no longer needs shouldBeCloseTo. 80 67 81 function testAnimation(id) 68 82 { … … 73 87 if (window.internals) { 74 88 internals.pauseAnimationAtTimeOnPseudoElement('example', 1.0, div, id); 75 shouldBe('div.offsetWidth', '20'); 89 shouldBeCloseTo('div.offsetWidth', 20, 1); 90 computedTop = getPseudoComputedTop(id); 91 shouldBeCloseTo('computedTop', 170, 1); 76 92 internals.pauseAnimationAtTimeOnPseudoElement('example', 2.0, div, id); 77 shouldBe('div.offsetWidth', '12'); 93 shouldBeCloseTo('div.offsetWidth', 12, 1); 94 computedTop = getPseudoComputedTop(id); 95 shouldBeCloseTo('computedTop', 200, 1); 78 96 } else { 79 97 // This will be flaky, but it's a reasonable approximation for testing … … 81 99 setTimeout(function() { 82 100 window.div = div; 83 shouldBe('div.offsetWidth', '20'); 101 shouldBeCloseTo('div.offsetWidth', 20, 1); 102 computedTop = getPseudoComputedTop(id); 103 shouldBeCloseTo('computedTop', 170, 1); 84 104 }, 1000); 85 105 setTimeout(function() { 86 106 window.div = div; 87 shouldBe('div.offsetWidth', '12'); 107 shouldBeCloseTo('div.offsetWidth', 12, 1); 108 computedTop = getPseudoComputedTop(id); 109 shouldBeCloseTo('computedTop', 200, 1); 88 110 }, 2000); 89 111 } -
trunk/LayoutTests/fast/css-generated-content/pseudo-transition-expected.txt
r138632 r142215 5 5 6 6 PASS div.offsetWidth is 52 7 PASS div.offsetWidth is 20 8 PASS div.offsetWidth is 12 7 PASS div.offsetWidth is within 1 of 20 8 PASS computedTop is within 1 of 170 9 PASS div.offsetWidth is within 1 of 12 10 PASS computedTop is within 1 of 200 9 11 PASS div.offsetWidth is 52 10 PASS div.offsetWidth is 20 11 PASS div.offsetWidth is 12 12 PASS div.offsetWidth is within 1 of 20 13 PASS computedTop is within 1 of 170 14 PASS div.offsetWidth is within 1 of 12 15 PASS computedTop is within 1 of 200 12 16 PASS successfullyParsed is true 13 17 -
trunk/LayoutTests/fast/css-generated-content/pseudo-transition.html
r138632 r142215 10 10 height: 50px; 11 11 width: 50px; 12 -webkit-transition: width 2s; 13 -moz-transition: width 2s; 14 transition: width 2s; 12 top: 50px; 13 position: relative; 14 -webkit-transition: width 2s, top 2s; 15 -moz-transition: width 2s, top 2s; 16 transition: width 2s, top 2s; 15 17 } 16 18 17 19 #before.transition:before, 18 20 #after.transition:after { 21 top: 200px; 19 22 height: 10px; 20 23 width: 10px; … … 43 46 testRunner.dumpAsText(); 44 47 48 function getPseudoComputedTop(id) 49 { 50 return Math.round(parseFloat(getComputedStyle(document.getElementById(id), ':' + id).top)); 51 } 52 53 // FIXME: This test should be modified so subpixel doesn't cause off by one 54 // below and it no longer needs shouldBeCloseTo. 55 45 56 function testTransition(id) 46 57 { … … 51 62 if (window.internals) { 52 63 internals.pauseTransitionAtTimeOnPseudoElement('width', 1.0, div, id); 53 shouldBe('div.offsetWidth', '20'); 64 shouldBeCloseTo('div.offsetWidth', 20, 1); 65 internals.pauseTransitionAtTimeOnPseudoElement('top', 1.0, div, id); 66 computedTop = getPseudoComputedTop(id); 67 shouldBeCloseTo('computedTop', 170, 1); 54 68 internals.pauseTransitionAtTimeOnPseudoElement('width', 2.0, div, id); 55 shouldBe('div.offsetWidth', '12'); 69 shouldBeCloseTo('div.offsetWidth', 12, 1); 70 internals.pauseTransitionAtTimeOnPseudoElement('top', 2.0, div, id); 71 computedTop = getPseudoComputedTop(id); 72 shouldBeCloseTo('computedTop', 200, 1); 56 73 } else { 57 74 // This will be flaky, but it's a reasonable approximation for testing … … 59 76 setTimeout(function() { 60 77 window.div = div; 61 shouldBe('div.offsetWidth', '20'); 78 shouldBeCloseTo('div.offsetWidth', 20, 1); 79 computedTop = getPseudoComputedTop(id); 80 shouldBeCloseTo('computedTop', 170, 1); 62 81 }, 1000); 63 82 setTimeout(function() { 64 83 window.div = div; 65 shouldBe('div.offsetWidth', '12'); 84 shouldBeCloseTo('div.offsetWidth', 12, 1); 85 computedTop = getPseudoComputedTop(id); 86 shouldBeCloseTo('computedTop', 200, 1); 66 87 }, 2000); 67 88 } -
trunk/Source/WebCore/ChangeLog
r142213 r142215 1 2013-02-07 Elliott Sprehn <esprehn@chromium.org> 2 3 getComputedStyle() doesn't report intermediate values during a transition of a pseudo element 4 https://bugs.webkit.org/show_bug.cgi?id=106535 5 6 Reviewed by Ojan Vafai. 7 8 Element::computedStyle and CSSComputedStyleDeclaration::getPropertyCSSValue 9 should use the PseudoElement and it's renderer if they exist so that 10 querying the computed style while an animation is running returns 11 the intermediate values. 12 13 No new tests, updated existing tests. 14 15 * css/CSSComputedStyleDeclaration.cpp: 16 (WebCore::CSSComputedStyleDeclaration::styledNode): Added, returns either the PseudoElement or the Node. 17 (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue): Updated to use styledNode. 18 * css/CSSComputedStyleDeclaration.h: 19 (CSSComputedStyleDeclaration): 20 * dom/Element.cpp: 21 (WebCore::Element::computedStyle): Check the PseudoElement, not just the cached pseudo style. 22 * dom/ElementRareData.h: 23 (WebCore::ElementRareData::pseudoElement): Remove ASSERT_NOT_REACHED so passing other pseudos returns 0. 24 1 25 2013-02-07 Mark Lam <mark.lam@apple.com> 2 26 -
trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp
r142168 r142215 52 52 #include "HTMLFrameOwnerElement.h" 53 53 #include "Pair.h" 54 #include "PseudoElement.h" 54 55 #include "Rect.h" 55 56 #include "RenderBox.h" … … 1511 1512 } 1512 1513 1514 Node* CSSComputedStyleDeclaration::styledNode() const 1515 { 1516 if (!m_node) 1517 return 0; 1518 if (m_node->isElementNode()) { 1519 if (PseudoElement* element = toElement(m_node.get())->pseudoElement(m_pseudoElementSpecifier)) 1520 return element; 1521 } 1522 return m_node.get(); 1523 } 1524 1513 1525 PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(CSSPropertyID propertyID, EUpdateLayout updateLayout) const 1514 1526 { 1515 Node* node = m_node.get();1516 if (! node)1527 Node* styledNode = this->styledNode(); 1528 if (!styledNode) 1517 1529 return 0; 1518 1530 1519 1531 if (updateLayout) { 1520 Document* document = m_node->document();1532 Document* document = styledNode->document(); 1521 1533 // FIXME: Some of these cases could be narrowed down or optimized better. 1522 1534 bool forceFullLayout = isLayoutDependentProperty(propertyID) 1523 || node->isInShadowTree()1535 || styledNode->isInShadowTree() 1524 1536 || (document->styleResolverIfExists() && document->styleResolverIfExists()->hasViewportDependentMediaQueries() && document->ownerElement()) 1525 1537 || document->seamlessParentIFrame(); … … 1529 1541 else { 1530 1542 bool needsStyleRecalc = document->hasPendingForcedStyleRecalc(); 1531 for (Node* n = m_node.get(); n && !needsStyleRecalc; n = n->parentNode())1543 for (Node* n = styledNode; n && !needsStyleRecalc; n = n->parentNode()) 1532 1544 needsStyleRecalc = n->needsStyleRecalc(); 1533 1545 if (needsStyleRecalc) 1534 1546 document->updateStyleIfNeeded(); 1535 1547 } 1536 } 1537 1538 RenderObject* renderer = node->renderer(); 1548 1549 // The style recalc could have caused the styled node to be discarded or replaced 1550 // if it was a PseudoElement so we need to update it. 1551 styledNode = this->styledNode(); 1552 } 1553 1554 RenderObject* renderer = styledNode->renderer(); 1539 1555 1540 1556 RefPtr<RenderStyle> style; … … 1542 1558 AnimationUpdateBlock animationUpdateBlock(renderer->animation()); 1543 1559 style = renderer->animation()->getAnimatedStyleForRenderer(renderer); 1544 if (m_pseudoElementSpecifier ) {1560 if (m_pseudoElementSpecifier && !styledNode->isPseudoElement()) { 1545 1561 // FIXME: This cached pseudo style will only exist if the animation has been run at least once. 1546 1562 style = style->getCachedPseudoStyle(m_pseudoElementSpecifier); 1547 1563 } 1548 1564 } else 1549 style = node->computedStyle(m_pseudoElementSpecifier);1565 style = styledNode->computedStyle(styledNode->isPseudoElement() ? NOPSEUDO : m_pseudoElementSpecifier); 1550 1566 1551 1567 if (!style) 1552 1568 return 0; 1553 1554 if (node->isElementNode() && (m_pseudoElementSpecifier == BEFORE || m_pseudoElementSpecifier == AFTER))1555 renderer = toElement(node)->pseudoElementRenderer(m_pseudoElementSpecifier);1556 1569 1557 1570 propertyID = CSSProperty::resolveDirectionAwareProperty(propertyID, style->direction(), style->writingMode()); … … 1839 1852 case CSSPropertyWebkitAlignSelf: 1840 1853 if (style->alignSelf() == AlignAuto) { 1841 if (m_node && m_node->parentNode() && m_node->parentNode()->computedStyle()) 1842 return cssValuePool().createValue(m_node->parentNode()->computedStyle()->alignItems()); 1854 Node* parent = styledNode->parentNode(); 1855 if (parent && parent->computedStyle()) 1856 return cssValuePool().createValue(parent->computedStyle()->alignItems()); 1843 1857 return cssValuePool().createValue(AlignStretch); 1844 1858 } -
trunk/Source/WebCore/css/CSSComputedStyleDeclaration.h
r132952 r142215 79 79 CSSComputedStyleDeclaration(PassRefPtr<Node>, bool allowVisitedStyle, const String&); 80 80 81 // The styled node is either the node passed into getComputedStyle, or the 82 // PseudoElement for :before and :after if they exist. 83 // FIXME: This should be styledElement since in JS getComputedStyle only works 84 // on Elements, but right now editing creates these for text nodes. We should fix 85 // that. 86 Node* styledNode() const; 87 81 88 // CSSOM functions. Don't make these public. 82 89 virtual CSSRule* parentRule() const; -
trunk/Source/WebCore/dom/Element.cpp
r141816 r142215 1992 1992 RenderStyle* Element::computedStyle(PseudoId pseudoElementSpecifier) 1993 1993 { 1994 if (PseudoElement* element = pseudoElement(pseudoElementSpecifier)) 1995 return element->computedStyle(); 1996 1994 1997 // FIXME: Find and use the renderer from the pseudo element instead of the actual element so that the 'length' 1995 1998 // properties, which are only known by the renderer because it did the layout, will be correct and so that the -
trunk/Source/WebCore/dom/ElementRareData.h
r141524 r142215 241 241 return m_generatedAfter.get(); 242 242 default: 243 ASSERT_NOT_REACHED();244 243 return 0; 245 244 }
Note: See TracChangeset
for help on using the changeset viewer.