+2005-02-25 Chris Blumenberg <cblu@apple.com>
+
+ Fixed: <rdar://problem/4023566> Stickies: Crash in ReplacementFragment::insertFragmentForTestRendering on paste
+
+ Reviewed by darin.
+
+ * khtml/editing/htmlediting.cpp:
+ (khtml::ApplyStyleCommand::addInlineStyleIfNeeded):
+ (khtml::ReplacementFragment::insertFragmentForTestRendering):
+ (khtml::floatRefdElement):
+ (khtml::createDefaultParagraphElement):
+ (khtml::createBlockPlaceholderElement):
+ (khtml::createFontElement):
+ (khtml::createStyleSpanElement):
+ * khtml/editing/htmlediting.h:
+
2005-02-25 Darin Adler <darin@apple.com>
* kwq/character-sets.txt: Checked in updated file. This new file has no effect, because none of the
if (styleChange.cssStyle().length() > 0) {
ElementImpl *styleElement = createStyleSpanElement(document());
+ styleElement->ref();
styleElement->setAttribute(ATTR_STYLE, styleChange.cssStyle());
insertNodeBefore(styleElement, startNode);
+ styleElement->deref();
surroundNodeRangeWithElement(startNode, endNode, styleElement);
}
return true;
}
+// FIXME: callers of createParagraphElement are not properly deref'ing the returned ref'd element.
ElementImpl *InsertParagraphSeparatorCommand::createParagraphElement()
{
ElementImpl *element = createDefaultParagraphElement(document());
return 0;
ElementImpl *holder = createDefaultParagraphElement(m_document);
+ holder->ref();
int exceptionCode = 0;
holder->appendChild(m_fragment, exceptionCode);
m_document->updateLayout();
- return holder;
+ return floatRefdElement(holder);
}
void ReplacementFragment::restoreTestRenderingNodesToFragment(NodeImpl *holder)
return true;
}
+ElementImpl *floatRefdElement(ElementImpl *node)
+{
+ node->setParent(node->getDocument());
+ node->deref();
+ node->setParent(0);
+ return node;
+}
+
ElementImpl *createDefaultParagraphElement(DocumentImpl *document)
{
- // We would need this margin-zeroing and attribute-setter code back if we ever
- // return to using <p> elements for default paragraphs.
- //static const DOMString defaultParagraphStyle("margin-top: 0; margin-bottom: 0");
int exceptionCode = 0;
ElementImpl *element = document->createHTMLElement("div", exceptionCode);
ASSERT(exceptionCode == 0);
- //element->setAttribute(ATTR_STYLE, defaultParagraphStyle);
return element;
}
{
int exceptionCode = 0;
ElementImpl *breakNode = document->createHTMLElement("br", exceptionCode);
+ breakNode->ref();
ASSERT(exceptionCode == 0);
breakNode->setAttribute(ATTR_CLASS, blockPlaceholderClassString());
- return breakNode;
+ return floatRefdElement(breakNode);
}
ElementImpl *createBreakElement(DocumentImpl *document)
{
int exceptionCode = 0;
ElementImpl *fontNode = document->createHTMLElement("font", exceptionCode);
+ fontNode->ref();
ASSERT(exceptionCode == 0);
fontNode->setAttribute(ATTR_CLASS, styleSpanClassString());
- return fontNode;
+ return floatRefdElement(fontNode);
}
ElementImpl *createStyleSpanElement(DocumentImpl *document)
{
int exceptionCode = 0;
ElementImpl *styleElement = document->createHTMLElement("SPAN", exceptionCode);
+ styleElement->ref();
ASSERT(exceptionCode == 0);
styleElement->setAttribute(ATTR_CLASS, styleSpanClassString());
- return styleElement;
+ return floatRefdElement(styleElement);
}
bool isNodeRendered(const NodeImpl *node)