+2004-12-10 Ken Kocienda <kocienda@apple.com>
+
+ Reviewed by Hyatt
+
+ Fix for this bug:
+
+ <rdar://problem/3915008> REGRESSION (Mail): Too much white space between lines separated by carriage returns
+
+ There are a number of interesting things we could do to fix this bug, including SPI and involving
+ the WebKit delegate, etc., however it seems reasonable to start with a hard-coded default that
+ will fix the bug in the general case until such time as we can come up with more specific
+ solutions.
+
+ So, I added a helper method to create <p> elements with an inline style that sets top and bottom margins
+ to 0.1em.
+
+ * khtml/editing/htmlediting.cpp:
+ (khtml::InsertParagraphSeparatorCommand::createParagraphElement): New factory method to create
+ paragraph elements to insert. Also adds style information to keep the <p> from having "too-big" margins.
+ (khtml::InsertParagraphSeparatorCommand::doApply): Call new factory method.
+ * khtml/editing/htmlediting.h: Add createParagraphElement() declaration.
+
2004-12-10 Darin Adler <darin@apple.com>
Reviewed by Hyatt.
derefNodesInList(clonedNodes);
}
+ElementImpl *InsertParagraphSeparatorCommand::createParagraphElement()
+{
+ static DOMString paragraphStyle("margin-top: 0.1em; margin-bottom: 0.1em");
+
+ int exceptionCode = 0;
+ ElementImpl *element = document()->createHTMLElement("p", exceptionCode);
+ ASSERT(exceptionCode == 0);
+ element->setAttribute(ATTR_STYLE, paragraphStyle);
+ element->ref();
+ clonedNodes.append(element);
+ return element;
+}
+
void InsertParagraphSeparatorCommand::doApply()
{
Selection selection = endingSelection();
// of the the start block.
NodeImpl *addedBlock = 0;
if (startBlock == startBlock->rootEditableElement()) {
- int exceptionCode = 0;
if (startBlock->renderer() && !startBlock->renderer()->firstChild()) {
// No rendered kids in the root editable element.
// Just inserting a <p> in this situation is not enough, since this operation
// is supposed to add an additional user-visible line to the content.
// So, insert an extra <p> to make the one we insert right appear as the second
// line in the root editable element.
- NodeImpl *extraBlock = document()->createHTMLElement("P", exceptionCode);
- ASSERT(exceptionCode == 0);
+ NodeImpl *extraBlock = createParagraphElement();
appendNode(extraBlock, startBlock);
- extraBlock->ref();
insertBlockPlaceholderIfNeeded(extraBlock);
- clonedNodes.append(extraBlock);
}
- addedBlock = document()->createHTMLElement("P", exceptionCode);
- ASSERT(exceptionCode == 0);
+ addedBlock = createParagraphElement();
appendNode(addedBlock, startBlock);
}
else {