From e7109590041768e108a09cfde2b0d6fbda2c3d7d Mon Sep 17 00:00:00 2001 From: kocienda Date: Fri, 10 Dec 2004 23:02:06 +0000 Subject: [PATCH] Reviewed by Hyatt Fix for this bug: 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

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

from having "too-big" margins. (khtml::InsertParagraphSeparatorCommand::doApply): Call new factory method. * khtml/editing/htmlediting.h: Add createParagraphElement() declaration. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@8190 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- WebCore/ChangeLog-2005-08-23 | 22 ++++++++++++++++++++++ WebCore/khtml/editing/htmlediting.cpp | 22 +++++++++++++++------- WebCore/khtml/editing/htmlediting.h | 2 ++ 3 files changed, 39 insertions(+), 7 deletions(-) diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23 index e4b8c8b23820..7f92126b27eb 100644 --- a/WebCore/ChangeLog-2005-08-23 +++ b/WebCore/ChangeLog-2005-08-23 @@ -1,3 +1,25 @@ +2004-12-10 Ken Kocienda + + Reviewed by Hyatt + + Fix for this bug: + + 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

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

from having "too-big" margins. + (khtml::InsertParagraphSeparatorCommand::doApply): Call new factory method. + * khtml/editing/htmlediting.h: Add createParagraphElement() declaration. + 2004-12-10 Darin Adler Reviewed by Hyatt. diff --git a/WebCore/khtml/editing/htmlediting.cpp b/WebCore/khtml/editing/htmlediting.cpp index 4f01bae82bde..8add5802e60f 100644 --- a/WebCore/khtml/editing/htmlediting.cpp +++ b/WebCore/khtml/editing/htmlediting.cpp @@ -2157,6 +2157,19 @@ InsertParagraphSeparatorCommand::~InsertParagraphSeparatorCommand() 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(); @@ -2200,22 +2213,17 @@ void InsertParagraphSeparatorCommand::doApply() // 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

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

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 { diff --git a/WebCore/khtml/editing/htmlediting.h b/WebCore/khtml/editing/htmlediting.h index 39e469bffe8f..93c1f5bfa294 100644 --- a/WebCore/khtml/editing/htmlediting.h +++ b/WebCore/khtml/editing/htmlediting.h @@ -411,6 +411,8 @@ public: virtual void doApply(); private: + DOM::ElementImpl *createParagraphElement(); + QPtrList ancestors; QPtrList clonedNodes; }; -- 2.36.0