Index: Source/core/editing/FrameSelection.cpp |
diff --git a/Source/core/editing/FrameSelection.cpp b/Source/core/editing/FrameSelection.cpp |
index 94ce606d67ffa66af9ccb2649d3974f5e244f777..12bcd0127c09880d683bd42de47483e9a4fd1e16 100644 |
--- a/Source/core/editing/FrameSelection.cpp |
+++ b/Source/core/editing/FrameSelection.cpp |
@@ -45,6 +45,7 @@ |
#include "core/editing/VisibleUnits.h" |
#include "core/editing/htmlediting.h" |
#include "core/events/Event.h" |
+#include "core/frame/FrameProtector.h" |
#include "core/frame/LocalDOMWindow.h" |
#include "core/frame/LocalFrame.h" |
#include "core/html/HTMLBodyElement.h" |
@@ -237,12 +238,12 @@ void FrameSelection::setSelection(const VisibleSelection& newSelection, SetSelec |
if (s.base().anchorNode()) { |
Document& document = *s.base().document(); |
if (document.frame() && document.frame() != m_frame && document != m_frame->document()) { |
- RefPtr<LocalFrame> guard = document.frame(); |
+ FrameProtector guard(document.frame()); |
document.frame()->selection().setSelection(s, options, align, granularity); |
// It's possible that during the above set selection, this FrameSelection has been modified by |
// selectFrameElementInParentIfFullySelected, but that the selection is no longer valid since |
// the frame is about to be destroyed. If this is the case, clear our selection. |
- if (guard->hasOneRef() && !m_selection.isNonOrphanedCaretOrRange()) |
+ if (guard.willDispose() && !m_selection.isNonOrphanedCaretOrRange()) |
clear(); |
return; |
} |