-
Notifications
You must be signed in to change notification settings - Fork 140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[typed-om] Trim CSSResourceValue and subclasses to opaque objects for this level, punt rest to level 2 #716
Comments
Ugh, there's still some details that we'd need to worry about - if the stylesheet says |
Here's a precise example of the above problem:
|
I think I can still get away with explicitly leaning on CSS's current lack of definition, since these values can only be produced from CSS and don't expose anything directly. |
Hey @tabatkins, do we also need to change the wording for reifying an image? |
@darrnshn Yeah, doing that now. I wonder if we want to actually have a different reification behavior for relative URLs, actually. Fragment URLs need to stay as fragments, but we can probably absolutize all other URLs. This is probably less confusing behavior overall; people rarely, if ever, pull properties between documents anyway, and if they do, they probably don't expect their URLs to change! If we define that, then it's easy to add back the |
We'll still have to grapple with the fact that CSS's types don't have a nice subclass/superclass relationship; a I suspect what we'll eventually want is to create a more generic So this'll still leave us with |
So, issue here. Say you have a property like 'mask-image'. It takes a url(). This url() is either an @bfgeek's suggestion: in L2, have a CSSURLValue class, representing a network resource more generally, and give it a promise-returning method that gives back a concrete object representing the actual resource that was fetched. (Or lets you choose to parse it in a particular way? That way you could point to an SVG file and get it as an image or a reference, depending on your needs.) This problem might infect general |
I think Firefox makes that decision based on the presence of a fragment in the URL. But yeah, it'd be good to sort out how that actually works, before adding the API. My example also showed that browsers disagree on when to perform URL parsing here (and Chrome even seems to use a different URL parser from the one it uses normally), which is another problem. A lot of that surfaces with the normal CSSOM as well of course, and results from the underlying model not being clearly specified. |
@annevk Unfortunately, the WG resolved to do differently than Firefox's current behavior https://lists.w3.org/Archives/Public/www-style/2017May/0051.html. We really do need to wait until the response is received before we can decide what it is. |
Okay, I think I've hit on the necessary design. I need a I also need a We'll add a In the next level we'll add a I don't particularly like this design, but I think it's the best I can do while respecting the |
Agenda+ to make sure that the WG is aware of this design and approves of it. |
CSSURLValue details:
|
@astearns could this go on the agenda? thanks |
@darrnshn it is on the agenda for this week (the Agenda+ tag got that done) |
LGTM |
If fragment-only URLs are going to have different behavior, should the type object have a boolean attribute indicating whether it is an absolute URL or a fragment?
SVG
I think the one thing that is missing from your model is a way to distinguish an unresolved URL from a resolved URL that isn't an image type. Maybe that could be indicated by an attribute (
Does it make sense to have a constructor for the "unresolved" type? Should the constructor accept a class name of the type you're trying to resolve as? Or, to be able to fully model the behavior of |
CSS doesn't have any special indicator between the two in the string syntax, so I don't think Typed OM particularly needs to do anything special here.
The only behavioral change I'm suggesting here is that relative URLs get absolutized when you reify them, so we don't have to depend on the (unspecified) absolutization time in CSS. Absolute and fragment-only URLs will remain absolute or fragment-only, and so won't change behavior at all. You can't extract a value from an element inside a
The In L2 I expect that we'll have a
CSSURLValue is the "unresolved" type. |
So you would suggest having to use That way for the URL-value we could also expose normal URL manipulation down the road while not having to special case dealing with it actually being a URL-fragment-value. |
Having a readonly indicator that it's fragment-only and thus specially treated would be fine with me; I was responding to the idea (possibly misread by me) of a flippable boolean switching it from the special fragment-only behavior to treating it like a normal URL and resolving it against a base.
This seems reasonable to me. |
Very weak preference on not having them be two different types, as they are not different objects in Edge. |
Lots of things that might not be different objects internally are different objects when reified - see the math hierarchy. |
The Working Group just discussed The full IRC log of that discussion<dael> Topic: [typed-om] Trim CSSResourceValue and subclasses to opaque objects for this level, punt rest to level 2<dael> github: https://github.com//issues/716 <dael> astearns: now that we have TabAtkins <TabAtkins> I'LL LITERALLY JUST BE FIVE SECONDS OR SO <dael> [everyone curses Tab's internet] <dael> TabAtkins: This was brought up a week o r two ago as an ask f or review. Ana had some discussion. <Chris> s/Ana/Anne <dael> TabAtkins: Big points: I did discuss rough outline before. Newer bits: because CSS distinguishes between normal a nd fragment-only URLs we want to reflect that in the URL structure somehow. To say this is full o r fragment. My plan was storing what it was, but Anne remarked hewould prefer if it was refered more directly either as a bolean or a sep URL class. franremy had a weak preference <dael> TabAtkins: I'll do those edits soon. Any opinions let me know. Otherwise I'll do what I outline in the thread here. <dael> astearns: Any other opinions for TabAtkins to consider? <dael> astearns: Alright. We're on notice you're going to change. <dael> TabAtkins: I guess not. Wanted to ping for review because it's a decent change. |
I don't think we still need the Agenda+ here |
The Working Group just discussed
The full IRC log of that discussion<dael> Topic: Loading and absolutization timing<dael> TabAtkins: CSS is currenlty vague. It happens at some point but we don't know when. <dael> github: https://github.com//issues/716 <nainar> https://github.com//issues/716#issuecomment-368659261 <dael> TabAtkins: Her'es my proposal ^ <dael> TabAtkins: Has a URL attribute. It's either an absolute or a bare hash. If it's not a bare hash we'll use CSS ruels. Underlying value may not be absolutized, but when it reifies we turn it absolute. If you move a style from one doc to another it may be relative in the old way, but it's now absolute. <dael> TabAtkins: I think that's what people want. <dael> TabAtkins: When you contruct a value it's absolutized immediately. <dael> dbaron: When is it bare hash? <dael> TabAtkins: When you pass it in as a local reference. <dael> TabAtkins: That's spec in the value spec? <dael> plinss: It's a string not a URL? <dael> TabAtkins: Yes, it's strictly spec that it's a string. <dael> TabAtkins: Only controversy is the early absolutizing. Is that okay or shouldwe make it retain it's relativeness and better define when it stops being relative. <dael> TabAtkins: If you want to manipulate the URL the URL spec requires an absolute value or a URL with a base. It would be harder for authors since it's hard to get the base. <dael> plinss: Would it make sense to keep it as a relative URL but also expose it as a base? <dael> TabAtkins: Possibly. In the current CSS if you use the OM APIs if you pull a reltivate URL and write it somewhere else it changes the base. <dael> plinss: Are we allowing authors to rationalize it as a valid URL if they want to. <dael> TabAtkins: Do authors want this? <dael> plinss: Yes <dael> TabAtkins: I doubt they do. When this occurs style sheets are usually in same folder. <dael> nainar: If we're being more eager about absolutizing should that be in css as well? <dael> TabAtkins: Pos. <dael> birlets: I'm wondering if there's a cloning use case? <dael> TabAtkins: But would people want to do that? <dael> TabAtkins: I can come up with a reason, but it's a minority case. <dael> krit: If you provide the bbase would you still get back relative? <dael> TabAtkins: You have to know where the split happened. If impl want to preserve I can attach the original URL. But the core easiest to use should be absolute. <dael> krit: I'm fine with it as a default. <dael> plinss: I expect there will be use cases, like editor. In my experience any time someone tries to help me with URL they get in the way at some point. If it's distructive that's painful. If there's a way to preserve the original url. <dael> dbaron: Seems like it's not crazy to have multi accessors. <dael> TabAtkins: I'm happy to put on an original URL value. <dbaron> s/multi/multiple/ <dael> plinss: Should that but the URL <dael> TabAtkins: All the DOM apis do absolute URLs. <dael> TabAtkins: Prop: We accept this proposal but also expose the original URL. <dael> dbaron: You could also expose base URL <nainar> Proposal is comment in https://github.com//issues/716#issuecomment-368659261 <dael> TabAtkins: That would have to be dynamic. Oh, base URL as this instant. I could do that. <dael> dbaron: I don't know how useful, but if you're exposing a bunch of information. <dael> Rossen_: Okay. <dael> Rossen_: Suggestions, objections? <dael> RESOLVED: We accept this proposal https://github.com//issues/716#issuecomment-368659261 but also expose the original URL and base URL |
What does exposing original URL and base URL mean here? The latter is somewhat underdefined in, e.g., |
"original url" is what's actually specified in |
It'll be exposing the inconsistencies in more places... And exposing "original url" doesn't seem super useful if it includes values that cannot even be parsed as a URL. Why would we do that? |
Freshly exposing a previously-hidden inconsistency is a problem. Merely adding another place that exposes a previously-exposed one is fine; the inconsistency still needs to be fixed, but this adds no new problems. (And the base url used has a very large effect on URLs.) In general, this spec isn't trying to fix problems in core CSS, it's just providing a new way to inspect and manipulate CSS values.
It lets you, if desired, exactly reproduce the string-OM behavior of moving a url value between stylesheets; you just have to construct a fresh CSSURLValue from the original url and new base url. I'm not of the opinion that this is particularly useful, but some in the WG wanted it, and it's not a problem to add it; we're just exposing information that's already obtainable via the string-OM. |
@tabatkins but that's not true, as I demonstrated the string-OM doesn't always expose the "original url". |
(I think you're touching on a problem with this API though. The idea that you don't have to understand "core CSS" or can gloss over how it functions when describing this new thing is misguided. Core CSS has to be in a good condition if you want to start exposing it through a public API.) |
??? You didn't demonstrate anything of the sort, tho. Check http://software.hixie.ch/utilities/js/live-dom-viewer/saved/5882, which is using your example troublesome URL - all browsers expose the exact original URL when querying the style directly (some with added quotes, some without), and all (except pre-Blink Opera, and apparently modern Chrome) expose nothing at all in the computed style. In the TypedOM I only want to expose absolute URLs normally, which in this case I guess means that it would have a |
Chrome and Safari expose a computed style? And differently so if you omit the trailing slash... It does seem that everyone also preserves the original value though, that's unfortunate, but I guess we might as well keep it then. |
Right. And the computed value differences are unfortunate, but the string-OM already exposes it, so TypedOM doing so doesn't make things worse (and heck, since I'm speccing it to use URL's absolutizing algorithm, it should generally be more consistent than string-OM). It's just something that needs to be fixed. |
@annevk wrote:
@tabatkins wrote:
Because the "original url" may not be a URL at all, it sounds like it should rather be called Sebastian |
That doesn't sound great to me. I don't think we'd necessarily want to preserve the original input in all cases. |
There's a bunch of undefined behavior around loading, urls, and such of CSSResourceValue right now. Doing it right will require some careful design and probably some research (and probably go hand-in-hand with speccing out these behaviors in more detail for CSS in general). This isn't compatible with shipping level 1 in the near future.
I'd be inclined to punt the entire thing, but Custom Paint relies on CSSImageValue to pipe images into the PaintWorker (tho there's apparently some HTML edits that need to be made, paging @bfgeek).
So, I propose that for this level, we pare it down to the bare minimum we need to represent an image, for Custom Paint purposes. That means removing CSSURLImageValue entirely, and removing all the attributes (state, intrinsicWidth/Height/Ratio) from the classes. We'll be left with an opaque handle to an image value that doesn't expose any information about the loading pipeline, and which can only be obtained from CSS itself (no constructor anymore!), so all the undefined behavior is just what CSS already has undefined.
According to @bfgeek, this should be fine. It does negate one of his use-case examples (rendering with a fallback image), but that's fine for now; most Custom Paint stuff is fine just spamming the CSSImageValue into the canvas, even if it's currently not loaded, and just getting called back when it is loaded and drawing it correctly.
The text was updated successfully, but these errors were encountered: