Across Browsers SVG Implementation

Liang Wang, Nies Huijsmans, Michael S. Lew, Dan TsymbalaarXiv 2011 · arXiv

Abstract

In 2009, native Scalable Vector Graphics (SVG) support was absent in Internet Explorer (IE), the dominant browser of the era. This paper details the development of a lightweight JavaScript-based translator that dynamically maps SVG elements to Microsoft's proprietary Vector Markup Language (VML). By addressing fundamental differences in rendering engines and coordinate systems, the implementation enables plugin-free, interactive vector graphics across all major browsers.

The Compatibility Nightmare

While modern web development enjoys universal SVG support, the landscape in 2009 was deeply fractured. Standard browsers like Firefox and Safari supported SVG natively, but Internet Explorer relied on its own XML-based vector format, VML. This forced developers to either maintain two separate codebases or require users to install third-party plugins like the Adobe SVG Viewer.

Furthermore, developers preferred "inline SVG"—writing vector code directly within HTML—to allow for dynamic DOM manipulation via JavaScript. This research addresses the compatibility gap by creating a JavaScript extension for the Backbase Client Framework that intercepts inline SVG and translates it into VML for IE, or standard XML for other browsers, in real-time.

Methodology: Why JavaScript?

The author evaluated several translation methods, including XSLT and HTML Components (HTC). JavaScript was ultimately selected because it offered superior performance and a significantly smaller footprint for client-side delivery.

Comparison of implementation libraries showing the efficiency of the JavaScript approach.

The implementation utilizes an Object-Oriented Programming (OOP) approach via Backbase's Tag Definition Language (TDL). Key components include:

  • DOM Interception: The framework scans the DOM upon loading. In IE environments, it replaces SVG tags with VML equivalents (e.g., <svg:rect> becomes <vml:roundrect>).
  • Abstract Class Inheritance: To minimize redundancy, abstract classes like SVGStylable and SVGTransformable provide child elements with inherited attributes for fills, strokes, and transformations.

Solving the Transformation Puzzle

Simulating SVG transformations (rotate, scale, skew) in VML presented the project's greatest technical hurdle. Because the two engines handle coordinate systems differently—SVG scaling originates from the left, while VML originates from the right—a 1:1 mapping was impossible.

The author developed a three-pronged strategy:

  1. VML Skew Elements: Used for basic shapes, requiring a 3x3 transformation matrix.
  2. CSS Matrix Filters: Applied to complex elements containing child nodes or text (like <foreignObject>), as standard VML skew tools are limited to basic shapes.
  3. Coordinate Recalculation: For point-based shapes like <polyline>, the script applies trigonometric formulas to every individual coordinate point manually.

Key Results and Performance

The project successfully implemented a robust subset of the SVG specification, including structural tags, geometric shapes, and text paths. A significant achievement was the replication of the <foreignObject> tag, allowing standard HTML to be embedded and transformed within vector graphics.

A complex vector graphic rendered successfully using the translation framework.

As shown in the performance analysis, the JavaScript approach was estimated to require only ~360KB to cover the full SVG specification, roughly half the size of an equivalent XSLT-based library. This made it a highly viable solution for the resource-constrained web environments of the time.

Limitations and Future Work

Despite its success, the implementation faced challenges with mathematical complexity. Chaining multiple transformations (e.g., simultaneous scaling and rotation) remains partially unimplemented due to the difficulty of calculating manual X/Y offsets for compounded matrices. Additionally, the elliptical arc command in SVG paths remains unsupported due to fundamental differences in how SVG and VML define arc parameters. Future work would focus on expanding coverage to advanced visual effects like radial gradients and blending modes.

Summary updated

BibTeX
@misc{wang2011across,
  author = {Liang Wang and Nies Huijsmans and Michael S. Lew and Dan Tsymbala},
  title = {{Across Browsers SVG Implementation}},
  year = {2011},
  eprint = {1101.0243},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1101.0243},
}
Figure