createFragmentFromText uses its Range* parameter to determine the kind of block that will be used to wrap paragraphs of text. This is bad because the cloned blocks have the same id as the original and because there is no straightforward way to get it to use a particular kind of block/style. We should write a new function, possibly: PassRefPtr<DocumentFragment> createFragmentFromText(Document* document, CSSStyleDeclaration* style, const QualifiedName& tagName, const String& text) that requires callers to be specific about the kind of block they want to use. <rdar://problem/8446956>
Created attachment 67992 [details] work in progress I wrote the current function and the old one in term of a new internal function that takes in a Document* and a block to clone.
Comment on attachment 67992 [details] work in progress View in context: https://bugs.webkit.org/attachment.cgi?id=67992&action=prettypatch > WebCore/editing/markup.cpp:1280 > + // For last line, use the "magic BR" rather than a P. Since we're wrapping with blockToClone instead of a P, we might want to revise this comment. > WebCore/editing/markup.cpp:1350 > + return createFragmentFromText(document, useClonesOfEnclosingBlock ? block : createDefaultParagraphElement(document).get(), text); Since useClonesOfEnclosingBlock is only used once, can we change the block to RefPtr<Element> and then do element = createDefaultParagraphElement(document) instead of doing trinary here? i.e. RefPtr<Element> block = static_cast<Element*>(blockNode); if (blockNode && ...) block = createDefaultParagraphElement(document); Otherwise looks nice. But as you said, we should figure out a way to test this.