This code originally use specialised templates for "switching on type". This change instead uses run time switching to try and make the code more readable.

BUG=

Review URL: https://codereview.chromium.org/63913003

git-svn-id: svn://svn.chromium.org/blink/trunk@163078 bbb929c8-8fbe-4397-9dbb-9b2b20218538