Bug 878843 - Integrate with replaceSurroundingText for autocorrect (with fallback for older builds of gecko)

See https://github.com/mozilla-b2g/gaia/pull/10165 for the original pull request without fallback.