Cache calculated style information when applying direct formatting

When direct formatting, often extremely similar (if not identical) style
hierarchies are being continually retrieved. Allowing external consumers
to provide a limited-life cache vastly speeds up the lookup for this data.
Merge pull request #326 from peitschie/cache-style-lookup

Cache calculated style information when applying direct formatting