Use the relative luminance function provided by the W3C to determine whether to show the light or dark text.
* Use white or black text only.
Cleanup of the foreground color changes.

* Update the tests
* Instead of setting the foreground-color manually, use CSS w/ .light & .dark classes.
* Rename foregroundColor to foregroundColorClass

fixes #3725
More cleanup:

* Remove calculate from function names
* Pass rgb colors as an object with named keys instead of an array.
Merge pull request #3837 from mozilla/issue_3725-color-clash

Issue 3725 color clash

@callahad is sat next to me. He gives me the r+