Index: Source/core/editing/FrameSelection.cpp |
diff --git a/Source/core/editing/FrameSelection.cpp b/Source/core/editing/FrameSelection.cpp |
index 2612860755ac4f5ff1a9c60394ad1003990fd77e..de3760390f83d70cff3b4d81beb7e563942430ad 100644 |
--- a/Source/core/editing/FrameSelection.cpp |
+++ b/Source/core/editing/FrameSelection.cpp |
@@ -1203,7 +1203,7 @@ void FrameSelection::prepareForDestruction() |
view->clearSelection(); |
setSelection(VisibleSelection(), CloseTyping | ClearTypingStyle | DoNotUpdateAppearance); |
- m_previousCaretNode.clear(); |
+ m_previousCaretPosition.clear(); |
} |
void FrameSelection::setStart(const VisiblePosition &pos, EUserTriggered trigger) |
@@ -1248,7 +1248,7 @@ void FrameSelection::setExtent(const Position &pos, EAffinity affinity, EUserTri |
RenderObject* FrameSelection::caretRenderer() const |
{ |
- return CaretBase::caretRenderer(m_selection.start().deprecatedNode()); |
+ return CaretBase::caretRenderer(m_selection.start()); |
} |
static bool isNonOrphanedCaret(const VisibleSelection& selection) |
@@ -1292,19 +1292,18 @@ bool FrameSelection::recomputeCaretRect() |
return false; |
IntRect oldAbsCaretBounds = m_absCaretBounds; |
- m_absCaretBounds = absoluteBoundsForLocalRect(m_selection.start().deprecatedNode(), localCaretRectWithoutUpdate()); |
+ m_absCaretBounds = absoluteBoundsForLocalRect(m_selection.start(), localCaretRectWithoutUpdate()); |
m_absCaretBoundsDirty = false; |
if (oldAbsCaretBounds == m_absCaretBounds) |
return false; |
if (RenderView* view = m_frame->document()->renderView()) { |
- Node* node = m_selection.start().deprecatedNode(); |
- if (m_previousCaretNode) |
- repaintCaretForLocalRect(m_previousCaretNode.get(), oldRect); |
- m_previousCaretNode = node; |
+ if (m_previousCaretPosition.isNotNull()) |
+ repaintCaretForLocalRect(m_previousCaretPosition, oldRect); |
+ m_previousCaretPosition = m_selection.start(); |
if (shouldRepaintCaret(view, isContentEditable())) |
- repaintCaretForLocalRect(node, newRect); |
+ repaintCaretForLocalRect(m_previousCaretPosition, newRect); |
} |
return true; |
@@ -1315,13 +1314,13 @@ void FrameSelection::invalidateCaretRect() |
if (!isCaret()) |
return; |
- CaretBase::invalidateCaretRect(m_selection.start().deprecatedNode(), recomputeCaretRect()); |
+ CaretBase::invalidateCaretRect(m_selection.start(), recomputeCaretRect()); |
} |
void FrameSelection::paintCaret(GraphicsContext* context, const LayoutPoint& paintOffset, const LayoutRect& clipRect) |
{ |
if (m_selection.isCaret() && m_caretPaint) |
- CaretBase::paintCaret(m_selection.start().deprecatedNode(), context, paintOffset, clipRect); |
+ CaretBase::paintCaret(m_selection.start(), context, paintOffset, clipRect); |
} |
void FrameSelection::debugRenderer(RenderObject *r, bool selected) const |
@@ -1402,11 +1401,11 @@ bool FrameSelection::contains(const LayoutPoint& point) |
HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::DisallowShadowContent); |
HitTestResult result(point); |
document->renderView()->hitTest(request, result); |
- Node* innerNode = result.innerNode(); |
- if (!innerNode || !innerNode->renderer()) |
+ RenderObject* renderer = result.renderer(); |
+ if (!renderer) |
return false; |
- VisiblePosition visiblePos(innerNode->renderer()->positionForPoint(result.localPoint())); |
+ VisiblePosition visiblePos(renderer->positionForPoint(result.localPoint())); |
if (visiblePos.isNull()) |
return false; |
@@ -1685,11 +1684,8 @@ void FrameSelection::updateAppearance() |
// We can get into a state where the selection endpoints map to the same VisiblePosition when a selection is deleted |
// because we don't yet notify the FrameSelection of text removal. |
- if (startPos.isNotNull() && endPos.isNotNull() && selection.visibleStart() != selection.visibleEnd()) { |
- RenderObject* startRenderer = startPos.deprecatedNode()->renderer(); |
- RenderObject* endRenderer = endPos.deprecatedNode()->renderer(); |
- view->setSelection(startRenderer, startPos.deprecatedEditingOffset(), endRenderer, endPos.deprecatedEditingOffset()); |
- } |
+ if (startPos.isNotNull() && endPos.isNotNull() && selection.visibleStart() != selection.visibleEnd()) |
+ view->setSelection(startPos.rendererOfAnchorNode(), startPos.deprecatedOffsetInRendererOfAnchorNode(), endPos.rendererOfAnchorNode(), endPos.deprecatedOffsetInRendererOfAnchorNode()); |
} |
void FrameSelection::setCaretVisibility(CaretVisibility visibility) |
@@ -1908,11 +1904,11 @@ void FrameSelection::revealSelection(const ScrollAlignment& alignment, RevealExt |
Position start = this->start(); |
ASSERT(start.deprecatedNode()); |
- if (start.deprecatedNode() && start.deprecatedNode()->renderer()) { |
+ if (start.rendererOfAnchorNode()) { |
// FIXME: This code only handles scrolling the startContainer's layer, but |
// the selection rect could intersect more than just that. |
// See <rdar://problem/4799899>. |
- if (start.deprecatedNode()->renderer()->scrollRectToVisible(rect, alignment, alignment)) |
+ if (start.rendererOfAnchorNode()->scrollRectToVisible(rect, alignment, alignment)) |
updateAppearance(); |
} |
} |