Created attachment 87615 [details] a.html the attached "a.html" prints the computed color of foo:first-char and foo:first-line. I expect both to have the same value. instead, getComputedStyle(foo, 'first-line') returns a style object where all the values are "".
The second parameter to getComputedStyle in your testcase must include the colon. Also, it's :first-letter, not :first-char.
It also appears that ::selection doesn't work either.
Sorry to spam, but none of the ::-webkit-scrollbar stuff works either. This is essential for my dom2canvas webpage screenshot utility.
<!doctype html> <body> <style> p:first-letter { color: red } </style> <div id="test"></div> <p id="foo">hello</p> <script> var foo = document.getElementById('foo'); var test = document.getElementById('test'); test.innerHTML = window.getComputedStyle(foo, ':first-letter').color </script> </body> works perfectly. (r108516).
(In reply to comment #4) > <!doctype html> > <body> > <style> > p:first-letter { color: red } > </style> > <div id="test"></div> > <p id="foo">hello</p> > <script> > var foo = document.getElementById('foo'); > var test = document.getElementById('test'); > test.innerHTML = window.getComputedStyle(foo, ':first-letter').color > </script> > </body> > > works perfectly. (r108516). Quick question: ":first-letter" and ":first-line" are the same / work the same?
Sorry for the typos in the a.html attachment. Here's a better example. This does what I expect in firefox, but not in safari or chrome: <!doctype html> <html> <body> <style> #a { color: red; } #b:first-letter { color: red; } </style> <p id="a">hello</p> <p id="b">world</p> <script> var a = document.getElementById('a'); var b = document.getElementById('b'); alert(window.getComputedStyle(a, ':first-letter').color + ':' + window.getComputedStyle(b, ':first-letter').color); </script> </body> </html> In firefox 11.0 it alerts 'rgb(255, 0, 0):rgb(255, 0, 0)' In safari 5.1.3 it alerts ':rgb(255, 0, 0)'
Created attachment 129221 [details] Patch
Comment on attachment 129221 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=129221&action=review > Source/WebCore/dom/Element.cpp:1671 > + } I will fix that later.
Comment on attachment 129221 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=129221&action=review > Source/WebCore/ChangeLog:14 > + No new tests : I updated the expectation of one. Please name the test that you updated here. > LayoutTests/fast/css/getComputedStyle/getComputedStyle-with-pseudo-element.html:70 > - { 'elementId' : 'testNoPseudoElement', 'pseudoElement' : ':first-line', 'property' : 'color', 'expectedValue' : '' }, > + { 'elementId' : 'testNoPseudoElement', 'pseudoElement' : ':first-line', 'property' : 'color', 'expectedValue' : 'rgb(165, 42, 42)' }, Can we add test cases for more pseudo styles?
Created attachment 129295 [details] Patch for landing
Comment on attachment 129295 [details] Patch for landing Clearing flags on attachment: 129295 Committed r109134: <http://trac.webkit.org/changeset/109134>
All reviewed patches have been landed. Closing bug.