WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
3379
attr(X) does not work
https://bugs.webkit.org/show_bug.cgi?id=3379
Summary
attr(X) does not work
Gideon M.L. Klok
Reported
2005-06-09 05:13:43 PDT
If there are two or more elements Y from which you request the attr(X) then it returns the value of attribute X from the first element Y. The seconde Y element's attr(X) will return the same value. e.g. @media print { a:after { content: '[' attr(href) ']'; } } Will have the result that all A elements will show the atribute href of the first A element.
Attachments
test case with 3 links
(522 bytes, text/html)
2005-06-10 11:10 PDT
,
Rémi Zara
no flags
Details
patch which disabled the optimisation if a content property is present
(2.47 KB, patch)
2005-06-10 13:59 PDT
,
Rémi Zara
no flags
Details
Formatted Diff
Diff
layout-tests/fast/css-generated-content test case
(621 bytes, text/html)
2005-06-10 14:01 PDT
,
Rémi Zara
no flags
Details
expected result
(1.46 KB, text/plain)
2005-06-10 14:02 PDT
,
Rémi Zara
no flags
Details
Don't share style for ::after and ::before
(856 bytes, patch)
2005-06-12 04:06 PDT
,
Rémi Zara
no flags
Details
Formatted Diff
Diff
Add an unshareable bit to RenderStyle
(4.16 KB, patch)
2005-06-18 07:48 PDT
,
Rémi Zara
hyatt
: review-
Details
Formatted Diff
Diff
Add a "unique" bit to RenderStyle
(6.06 KB, patch)
2006-05-25 06:41 PDT
,
Rémi Zara
hyatt
: review-
Details
Formatted Diff
Diff
addressed comments
(7.25 KB, patch)
2006-05-26 03:27 PDT
,
Rémi Zara
hyatt
: review+
Details
Formatted Diff
Diff
Show Obsolete
(7)
View All
Add attachment
proposed patch, testcase, etc.
Rémi Zara
Comment 1
2005-06-10 11:10:13 PDT
Created
attachment 2224
[details]
test case with 3 links Here is a test case. The problem seems to come from the CSSStyleSelector::canShareStyleWithElement(NodeImpl* n) optimisation. If made to always return false, then the problem does not appear.
Rémi Zara
Comment 2
2005-06-10 13:59:13 PDT
Created
attachment 2228
[details]
patch which disabled the optimisation if a content property is present This patch records the fact that a content property is present, and disables the canShareStyleWithElement optimisation when present.
Rémi Zara
Comment 3
2005-06-10 14:01:32 PDT
Created
attachment 2229
[details]
layout-tests/fast/css-generated-content test case test case to include in layout-tests/fast/css-generated-content
Rémi Zara
Comment 4
2005-06-10 14:02:46 PDT
Created
attachment 2230
[details]
expected result Expected result for the test case
Dave Hyatt
Comment 5
2005-06-10 19:23:20 PDT
The intent of the original style sharing design was that pseudo-elements should never attempt to share style with one another at all, so this patch should not be necessary. Notice that pseudoStyleForElement does not contain any code to do sharing. I think further investigation is needed to understand how the anchors all sharing the same style is causing the pseudo-element of a later anchor to get the wrong value.
Rémi Zara
Comment 6
2005-06-12 04:06:34 PDT
Created
attachment 2263
[details]
Don't share style for ::after and ::before The style was shared in RenderObject::getPseudoStyle(). This patch disables the sharing only for ::after and ::before pseudo elements, since the content property can only apply to them in css2. This patch passes all tests, including of course the new one attached to this bug. I think that when you'll implement css3 generated content, you'll have to disable style sharing when a declaration contains a content property (or at least those with a content property which contains an attr(X) value), or a counter-increment or a counter-reset property...
Dave Hyatt
Comment 7
2005-06-14 12:32:02 PDT
addPseudoStyle is a dumb function that just throws the resolved pseudo-style onto the style's list. If you bypass the pseudo-style "cache" by not calling getPseudoStyle, you're going to need to make sure you don't add the resultant pseudo-style to the cache either. Ideally the caching of the before/after styles would only be turned off only if attr(x) is used. If you added some sort of "unshareable" bit to RenderStyles and set it when an attr(x) is used, then rather than asking about :before/:after in getPseudoStyle, you could just ask "is the style unshareable". Then we can, as you say, reuse this unshareable bit in other situations (like counters).
Rémi Zara
Comment 8
2005-06-18 07:48:05 PDT
Created
attachment 2459
[details]
Add an unshareable bit to RenderStyle This patch adds an unshareable bit to RenderStyle, which is set when content: attr(X) is used, and checked in canShareStyleWithElement(). The patch passes all regression tests.
Darin Adler
Comment 9
2005-06-18 17:04:39 PDT
Comment on
attachment 2459
[details]
Add an unshareable bit to RenderStyle There's no word "unshareable", so this should probably either be named "sharable" (reversing the sense) or "notSharable" instead. Otherwise, it looks good to me, but I think a patch in this area really needs Dave to review it, so setting the flag to bring it to his attention.
Dave Hyatt
Comment 10
2005-06-19 22:01:15 PDT
Comment on
attachment 2459
[details]
Add an unshareable bit to RenderStyle Yeah nearly ready. Let's use the term "unique." Also, does the extra bit fit or will this add 4 bytes to RenderStyles?
Darin Adler
Comment 11
2005-06-19 22:55:21 PDT
I checked. The bit fits.
Darin Adler
Comment 12
2005-12-05 17:07:00 PST
<
rdar://problem/4362407
> Safari displays same text for two different cases of CSS-generated text that should be different (3379)
Rémi Zara
Comment 13
2006-05-25 06:41:32 PDT
Created
attachment 8538
[details]
Add a "unique" bit to RenderStyle This patch adds a "unique" bit to RenderStyle to disable style sharing when generated content relies on attribute values. Contains a test case and expected results.
Dave Hyatt
Comment 14
2006-05-25 22:59:25 PDT
Comment on
attachment 8538
[details]
Add a "unique" bit to RenderStyle This is really close. I have two remaining concerns. (1) Hardcoding of parentStyle->setUnique(); In CSS3 you'll be able to use the content property without it being in :before/:after, so I think it's better to actually check what you're matching. If you're matching some pseudo-element, then you need to make parentStyle unique, but if you're not, then you need to make style unique instead. (2) This second concern could be handled by another patch but is easy to add I think. Since this patch was last worked on Rob landed some code for us to respond to dynamic attribute changes by registering which attribute affect style. The attr() construct isn't doing this yet though, so dynamically changing attributes that don't already cause a setChanged() will fail. Addressing (1) is enough for me to +. Addressing (2) is extra credit. :)
Rémi Zara
Comment 15
2006-05-26 03:27:46 PDT
Created
attachment 8550
[details]
addressed comments Addressed comments, but I'm not sure if I did it right: * I'm not sure that "if (style->styleType()==RenderStyle::NOPSEUDO)" is ok * I feel like abusing m_selectorAttrs for point (2) of the review, but it works. So either it works by chance, or maybe this class member should be renamed, maybe to m_affectingAttrs (attributes affecting this style, either in selector or properties) ?
Dave Hyatt
Comment 16
2006-05-26 11:30:43 PDT
Comment on
attachment 8550
[details]
addressed comments r=me Yeah, we should probably rename the m_selectorAttrs variable (and the method that queries it) at some point. Another problem I notice is that m_selectorAttrs was coded just to use localName. This make it a little less precise than it could be (if it were to use the full qualified name instead).
Darin Adler
Comment 17
2006-06-02 10:20:28 PDT
Committed revision 14687.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug