Add a selection state "updateposition" and a field "visible" to indicate
that the current selection's boundingClientRect or visible is changed.
We dispatch this state after scrolling or reflowing is done.
Make DispatchSelectionStateChangedEvent() and GetSelectionBoundingRect()
become member functions of SeletionCarets so that they are easier to use
in later patches.
When SelectionCarets::Terminate() is called, it's not guaranteed that we
can get nsDocShell from PresContext. It causes that SelectionCarets
cannot remove itself as an observer.
To fix this, we keep a member WeakPtr<nsDocShell> so that we can always
have nsDocShell in SelectionCarets::Terminate().
LaunchLongTapDetector() is used to fire long tap to select word when
async pan zoom is not enabled. We should check if async pan zoom is
enabled rather than check whether it's on main process.
This can also fix selection carets not working on e10s.
Let SelectionCarets inherits from nsIReflowObserver so it could refresh
its position after reflow. This fixes the incorrect position of
selection carets after we rotate the device to change the screen from
portrait mode to landscape mode and vice versa.