2011-05-24 Leo Yang <leo.yang@torchmobile.com.cn>
[WebKit-https.git] / Source / WebCore / editing / ReplaceSelectionCommand.cpp
index a7c79f977f930c093e29623894fef6e61897efd4..0eb6b1bcff1a28a47c8544a105a4df5abc5e8689 100644 (file)
@@ -156,6 +156,10 @@ ReplacementFragment::ReplacementFragment(Document* document, DocumentFragment* f
 
     Node* styleNode = selection.base().deprecatedNode();
     RefPtr<StyledElement> holder = insertFragmentForTestRendering(styleNode);
+    if (!holder) {
+        removeInterchangeNodes(m_fragment.get());
+        return;
+    }
     
     RefPtr<Range> range = VisibleSelection::selectionFromContentsOfNode(holder.get()).toNormalizedRange();
     String text = plainText(range.get());