Monday, 29 October 2012

Trouble Ahead For SVG Stacks (Maybe)

We have a large impending problem for CSS and SVG, and the solution may require breaking content using the "SVG Stack" image-bundling technique that's starting to become popular.

The problem arises because we want to unify support for images and SVG paint servers in CSS syntax. For example, we'd like CSS 'background', 'mask' and 'fill' properties to accept both SVG paint server values (e.g. SVG gradients and patterns), and CSS image values (such as CSS gradients and images). This seems like a significant improvement in both simplicity and power for Web authors.

The problem is that if we do this, then syntax such as 'background:url(foo.svg#abc)' becomes ambiguous. It could refer to either an SVG paint server element (such as a <pattern>) with ID "abc" in the external resource document "foo.svg", or an SVG image "foo.svg" in which we should make visible the element with ID "abc".

The obvious way to resolve this ambiguity would be to load the document foo.svg and check if the element with ID "abc" is an SVG paint server element. Unfortunately that is very difficult to do because we load external resource documents differently to SVG images and subject them to different constraints. For example, for security reasons external resource documents for paint servers are required to be same-origin with the main document --- in Gecko, at least, and we think the security reasons are good enough to require the same behavior in every browser. (Webkit hasn't addressed this yet because they don't support references to SVG paint servers in other documents.) On the other hand, we definitely can't disallow cross-origin SVG image loads. We really want to be able to determine the kind of load to perform before we start loading the document!

Relying on checking the kind of element a reference points to is also problematic if that can change dynamically. I don't actually know of a way that an SVG image or external resource document can cause the element referenced by a fragment identifier to change, but there are a lot of "near misses" --- for example, it would be possible if script was allowed to run in an SVG image or an external resource document, or if declarative animations could animate the 'id' attribute, or if we had a declarative Web feature for transclusions, or if <meta refresh> was supported in SVG images or external resource documents. If it turns out that the element referenced by a fragment identifier can change, then it doesn't really make sense to try to reload the document in a different way when such a change happens. (It might also be possible for the element referenced by a fragment identifier to depend on whether the document was loaded as an SVG image or an external resource document!)

Therefore I have proposed on www-svg and www-style that we inspect the URIs in a 'url()' value to determine whether to perform an external resource document load or an image load. A URI without a fragment identifier would be loaded as an image, but a URI with a fragment identifier that isn't obviously supposed to be part of an image (e.g. a Media Fragment URI) would have to be interpreted as a reference to an external resource document. This would work fine with almost all content out there, but would break SVG Stacks :-(. That is not good, but no-one has proposed a better solution yet.

If we do take this approach, we would probably have a workaround for SVG Stacks such as requiring them to use the "=" character in their fragment identifiers to make it clear the URI should be treated as an image load, not an external resource document reference.

I hope that this can be resolved at the upcoming W3C TPAC, since any solution needs concerted effort from browser vendors, and soon.

Tuesday, 2 October 2012

Motutapu Camping

This weekend was the first weekend of the school holidays so I took the kids camping. We took the 9:15am ferry to Rangitoto Island and got off at Islington Bay right near the bridge to Motutapu Island. We tramped with our gear along the Motutapu Walkway for two hours, including stops, to get to the campground at Home Bay on the east side of Motutapu, mostly through farmland. We spent two nights camped at Home Bay and then yesterday tramped back to Islington Bay along the road (taking about an hour) to catch the morning ferry back to the city.

The weather was good on Saturday and great on Sunday. It was rainy on Monday but that was fun in its own way --- I like being out in the rain if there's a good reason to be. On Sunday a ferry pulled into Home Bay with some day-trippers --- a group doing a walk as part of the Auckland Heritage Festival, and some volunteers doing weed control. The latter were part of a huge ongoing project to reforest a third of Motutapu. The island (along with Rangitoto) has been cleared of predators and colonies of rare birds --- including takahe and shore plovers --- have been transplanted to the island. Native fish and freshwater crayfish are also being reintroduced to the streams.

Like some other sites around the Hauraki Gulf, Motutapu has some old WW2 fortifications --- a number of pillboxes and gun emplacements. These have some tunnels that are fun to explore with a torch, and of course at the surface they have excellent views over the outer Gulf.

On Sunday we did a decent-sized walk from Home Bay up to the gun emplacements and then to Billy Goat Point at the northern tip of the island. Except we didn't quite reach the point, since the path led through a large paddock with cows. As we walked along the path, every cow that saw us started following us. After a while we all got a bit nervous and were wondering how we'd get back through the herd of about fifty cows that had gathered --- assuming they didn't decide to cause problems for us on their own! The kids were scared and I was rather nervous myself, but everyone did well and didn't panic. We turned back and just walked slowly in the direction we wanted to go. The herd surrounded us and moved with us and we didn't have any problems, but it was a relief to get over the stile to put a fence between us and the cattle. We completed our walk through Sandy Bay, Administration Bay, the Motutapu Outdoor Education Centre camp, and the road back across the island to Home Bay.

There wasn't a lot to do at the campsite but the kids had fun just being kids --- playing on the swing, fossicking on the beach, skipping stones on the water, smashing rocks, reading books, playing tag, that sort of thing. The campsite is huge and there were only three tents on it the whole time we were there. Overall it was a great weekend away, highly recommended.

Karekare

Nine days ago we took our research intern out to the west coast. In a change from our usual Waitakere destinations, we went directly to Karekare beach, walked south through the dunes into Whatipu (passing the tramline tunnel), inland at the Paraha valley, and then back to Karekare through the hills along the Zion Hill track. It was excellent, although the Zion Hill track was quite muddy. The whole walk took about four hours.

It's probably a little better to do the loop in the other direction, to get the up-and-down stuff out of the way first. We did the beach first because I hadn't been that way before and maps warn that it might not be passable at high tide. But either those warnings only apply during a big storm, or the dunes have grown since those warnings were written --- it didn't look likely that a high tide would cut off the path. So next time I'd definitely take the Zion Hill track first if the weather's reasonable.