| Index: third_party/WebKit/Source/core/editing/PendingSelection.cpp | 
| diff --git a/third_party/WebKit/Source/core/editing/PendingSelection.cpp b/third_party/WebKit/Source/core/editing/PendingSelection.cpp | 
| index 1b106656d49673990d8f12016ed2f04fad889264..e7d4ca5b8ce67aea21646328c417c49cc3c3beae 100644 | 
| --- a/third_party/WebKit/Source/core/editing/PendingSelection.cpp | 
| +++ b/third_party/WebKit/Source/core/editing/PendingSelection.cpp | 
| @@ -123,10 +123,12 @@ void PendingSelection::commit(LayoutView& layoutView) { | 
| // necessarily valid, and the following steps assume a valid selection. See | 
| // <https://bugs.webkit.org/show_bug.cgi?id=69563> and | 
| // <rdar://problem/10232866>. | 
| -  const VisibleSelectionInFlatTree& selection = | 
| -      createVisibleSelection(calcVisibleSelection(originalSelection)); | 
| +  const SelectionInFlatTree selection = calcVisibleSelection(originalSelection); | 
| +  const VisibleSelectionInFlatTree& visibleSelection = | 
| +      createVisibleSelection(selection); | 
|  | 
| -  if (!selection.isRange()) { | 
| +  const LocalFrame& frame = *layoutView.document().frame(); | 
| +  if (!visibleSelection.isRange() || !selectionHasFocus(frame, selection)) { | 
| layoutView.clearSelection(); | 
| return; | 
| } | 
| @@ -137,11 +139,11 @@ void PendingSelection::commit(LayoutView& layoutView) { | 
| // If we pass [foo, 3] as the start of the selection, the selection painting | 
| // code will think that content on the line containing 'foo' is selected | 
| // and will fill the gap before 'bar'. | 
| -  PositionInFlatTree startPos = selection.start(); | 
| +  PositionInFlatTree startPos = visibleSelection.start(); | 
| PositionInFlatTree candidate = mostForwardCaretPosition(startPos); | 
| if (isVisuallyEquivalentCandidate(candidate)) | 
| startPos = candidate; | 
| -  PositionInFlatTree endPos = selection.end(); | 
| +  PositionInFlatTree endPos = visibleSelection.end(); | 
| candidate = mostBackwardCaretPosition(endPos); | 
| if (isVisuallyEquivalentCandidate(candidate)) | 
| endPos = candidate; | 
| @@ -150,8 +152,8 @@ void PendingSelection::commit(LayoutView& layoutView) { | 
| // |VisiblePosition| when a selection is deleted because we don't yet notify | 
| // the |FrameSelection| of text removal. | 
| if (startPos.isNull() || endPos.isNull() || | 
| -      selection.visibleStart().deepEquivalent() == | 
| -          selection.visibleEnd().deepEquivalent()) | 
| +      visibleSelection.visibleStart().deepEquivalent() == | 
| +          visibleSelection.visibleEnd().deepEquivalent()) | 
| return; | 
| LayoutObject* startLayoutObject = startPos.anchorNode()->layoutObject(); | 
| LayoutObject* endLayoutObject = endPos.anchorNode()->layoutObject(); | 
|  |