Brush up localSelectionRectOfPositionTemplate

This CL does:
 1. Import |localCaretRectOfPositionTemplate()| partially to avoid calling
|computeInlineBox()| twice(L2562-L2586).
In |localCaretRectOfPositionTemplate()|, we call |computeInlineBox()|, which already
 called at L2568. Unified it.
Lines from 2562 to 2586 is virtually localCaretRectOfPositionTemplate except
 |boxPosition.inlineBox| null-nonnull condition because we need non-null inlineBox
 to get valid LayoutRect.

 2. Get rid of redundant and unsafe cast(L2586).
We cast InlineBoxPosition.inlineBox to InlineTextBox at L2570.
However, computeInlineBoxPosition returns InlineBoxPosition which inlineBox
 is not InlineTextBox when position.node.layoutObject is not Text and under few
 conditions.
Thus the cast at L2570 fails.
BTW, we don't need to use InlineTextBox following lines because no special
 functions on InlineTextBox but only InlineBox are used.
Then we can use boxPosition.inlineBox just as InlineBox.

BUG=680428
TEST=run_webkit_unittests
--gtest_filter=VisibleUnitsTest.localSelectionRectOfPositionTemplateNotCrash

Review-Url: https://codereview.chromium.org/2641053005
Cr-Commit-Position: refs/heads/master@{#445026}
2 files changed