LeichtgewichtLeichtgewicht

2011/08/06 – 17:50

Plugins and Browsers (ideas)

Flash’s popularity has dropped in the past years/month. I think in this discussions the original value of Flash has been forgotten: It extends the browser’s capabilities.
HTML has always been a war field between the different browser vendors. Flash was (and is) for some things the only secure haven for content that works in all browsers.

I think Flash can do better. Error handling is terrible, printing is broken, etc. but I also think Browsers can do better!

I want to get a little into features I miss browsing the web (mobile and regular) and how some of those features pushes us to fall back to HTML.

Plugins and Browsers

  1. Direct JavaScript extension
  2. Multiple instances
  3. Non-interactive elements
  4. Proper printing integration
  5. Context Menu
  6. Search integration
  7. Custom shaped elements
  8. Passing CSS
  9. Global Mouse
  10. Conclusion

Direct JavaScript extension

Today flash logic can be used just using Embed tags and interacting via ExternalInterface. It would be very nice to have a JavaScript API to just instantiate Flash objects like:

// Creates a custom Dom object that works like flash.Video
var video = new adobe.flash.media.Video();
var conn = new adobe.flash.net.NetConnection();
var stream = new adobe.flash.net.NetStream(netconnection);
video.attachNetStream(stream);
document.body.appendChild(video);

This way the plugin (flash) could be instantiated using regular javascript code, without the need to use embed tags everywhere but right now plugins are not able to offer that (as far as I know). This would make flash (or any other plugin) easier to use by just having a JavaScript api.

Multiple Instances

Ever tried to mix HTML and Flash? JavaScript code (SWFObject) needs to be called to instantiate (Eolas, remember?). The flash run-time has to instantiate a new system timer. The swf might be needed to load more than once, at the very least it has to be checked in the cache. That costs time in our fight for milli- and nanoseconds.

I suggest that it is possible to have “child objects”. DOM object areas that are actually part of a main object.

<object type="application/x-shockwave-flash"
          data="x.swf" width="400" height="120" id="main">
  <param name="movie" value="x.swf"></param>
</object>
<object type="application/attach" target="main" id="screen2"/>

With this little addition the Flash running in the first swf could take the “display” area of the second object. Additionally screen estate at a different place. With that we would be able to create more fluid experiences using less memory: just one plugin running instead of 10 like on a common wordpress page with youtube plugins.

Non-interactive elements

Flash, Processing, Unity – all of them are able to create stunning art on many platforms. It would be awesome to use this as interactive background for html. Unfortunately – right now – that is not possible. Right now: Every object is automatically interactive. Right click, Left click, Keyboard included. It would be nice to have a way to ignore those controls to have it just rendering a new background.

<object type="application/x-shockwave-flash" data="x.swf" width="400" height="120" allow-controls="false">
  <param name="movie" value="x.swf"></param>
</object>

If the plugin automatically reads the keyboard input it also means that some/many browser shortcuts won’t work. Having parameters like for example deny-keyboard-input="true" as a drastic option would be possible. More flexible would be if the plugin could ask the browser if the current keyboard input actually would be a shortcut and then decide whether or not to allow it to pass it through.

Proper printing integration

Generally speaking: Adobe has the the only really working printing solution available: pdf. It just works very, very well (at least the printing part). Printing companies love it.

Browsers are not so keen if its about printing, and Flash even managed to break its printing totally. Plugin content is displayed as white area in Firefox and Chrome. My Opera even crashed. Just IE showed the content as picture.

Come on. Browser vendors: you can do better!

How much better? Well: In an ideal world, the plugin should be asked “Hey: got any PostScript data for me?” (onPrintRequest). PostScript seems to be the common denominator. I could be wrong though, HTML might be an option too. And the Plugin can answer to it by offering PostScript or not, if not: the bitmap data is taken to print.

This would allow Plugin makers to give its users (AS3 developers) the option to implement custom providers:

stage.printProvider = new PrintProvider();

class PrintProvider implements IPrintProvider {
  public function print(configuration:IPrintConfig): Vector.<Sprite> {}
}

Context Menu

Okay, Plugins can take over the context menu. But browsers evolve, there are more options in a right click menu than copy/paste. Links can be opened in tabs, images can be copied into the memory. Those are not available if the pluing overrides the context menu.

There is a way to do that differently. For example: The browser could ask the plugin “Can you give me a representation for the current object as html?”. With the responded information the browser could create a context menu.

Example: You hover over some text that should be a link in Flash. You right-click it. The browser triggers currentAsHtml() on the plugin. Flash returns <a href="url">text</a> and the browser can display the context menu for this link.

Doesn’t that sound awesome?

Search integration

That is something that really isn’t too hard to implement. Pass the search string to all plugins on the page and see what they answer. The result taken as a pointer and passed on tabbing through the entries.

Detail thoughts: Without the position the browser can not scroll to where the area of the plugin is visible. So: Position, relative + id per found entry and the browser would have enough data to scroll to the position in the page where the search term would be visible. Also the plugin should be informed that it should show that particular entry as marked.

Custom shaped elements

By default a plugin is a rectangle area. Did you ever try it as a inline element, surrounded by text? Wouldn’t it be cool to have a bigger swf with some text where the baseline of the text is actually on the baseline of the surrounding html text? An option to define, dynamically, the baseline of the plugin could indeed make a difference.

Another thing is that it would be cool to define just some areas Interactive (alternative/extension to Non-Interactive plugins). Actually the w3c defined the object tag already with an option for “usemap“, unfortunately it doesn’t work for Flash, and even if it would it isn’t sufficient. But it would be not a far leap to use the map for the definition of those interactive areas of a Plugin.

I can imagine something like:

<object inline-area="#swf-inline" interactive-map="#swf-map">
  <area shape="rect" id="swf-inline" coords="9,372,66,397"  />
  <map id="swf-map">
    <area shape="rect" coords="0,0,66,397">
  </map>
</object>

Passing CSS

I would love to have regular CSS styling my Flash. Just write in my CSS file a sub-selector and the browser passes the properties to the Plugin, and the plugin can use the style or not. Flex styling via the same mechanisms that are used for html.

<style type="text/css">
  #flash a {
     color: red;
  }
</style>
<object type="application/x-shockwave-flash"
          data="x.swf" width="400" height="120" id="flash">
</object>

and Flash receives:

{ a { color: 0xFF0000 } }

If it would also take care of things like: em to px conversation it would be even more awesome.

Global Mouse

Did you ever see a mouse follow implemented in flash? It sort of stops right at the border. Now: I do understand that it could be seen as somewhat of a security problem to pass the mouse position to all swf’s. But hey: All it needs is javascript to achieve that right now! So dear browser vendors, plugin builders: Just pass the mouse position and we are fine?

Conclusion

Both Adobe and the browser vendors could do better. Plugins are intended to “enhance” the Web experience by better browser capabilities. Right now the mechanism is flawed. To some extend it actually “reduces” the experience and that is why plugins loose so much credibility. Are plugins even necessary? I think yes! Plugins allow us to show things to a wide audience that are next generation, away from what we thought would be possible and that is important. Its not HTML, its not “common grounds” but its good for us to get better.

I am sure that not all of the implementations are as simple as I have in mind. There are for sure reasons why they are not yet implemented. But its 2011. Browsers can render 3D! No reason why this browsers can’t be made better. However: I am not able (can’t find my way around in the source code of any browser) to just try and implement this for a “dummy plugin”. Right now anyways. But I think it could be done easily. Chromium, Webkit and Firefox are open-source.


What do you think?


Tags: , , , ,

Leave a Reply

Site informations

Martin Heidegger – Web Developerskype:mastakanedaxing:martin.heideggertwitter:leichtgewicht