Make title and content functions cachable.

This commit introduces an opt-in flag for tooltips and popovers which
allows the widgets to cache the return values from the `title` and
`content` functions, where they have been provided. This is useful for
when the title and content need computation, but are not going to
change. Obviously the functions themselves can be memoised, but this
approach also avoids the cost of repeated (and pointless) function
calls.
Added repositioning mechanism for dynamic content.

Tooltip and popover content may have cause to grow dynamically, and its
final form cannot always be determined synchronously. An important use
case for this is popover elements that fetch their content via ajax.
This commit adds a mechanism for such dynamic elements to be reflown
when their content changes. This must still be managed manually by the
caller, but at least it is now possible without external modification. A
typical system for doing this is expected to be calling the `reposition`
method on the tooltip/popover when the content is changed and its
position needs to be recalculated.