Backed out changeset e925caf848fa (bug 1214377) for wrong reviewer in commit

This commit is contained in:
Carsten "Tomcat" Book 2015-12-01 10:31:32 +01:00
parent 0710640fa6
commit f294e6c404

View File

@ -1438,44 +1438,18 @@ nsHTMLCopyEncoder::SetSelection(nsISelection* aSelection)
break;
}
#ifdef MOZ_THUNDERBIRD
else if (selContent->IsHTMLElement(nsGkAtoms::body)) {
// Currently, setting mIsTextWidget to 'true' will result in the selection
// being encoded/copied as pre-formatted plain text.
// This is fine for copying pre-formatted plain text with Firefox, it is
// already not correct for copying pre-formatted "rich" text (bold, colour)
// with Firefox. As long as the serialisers aren't fixed, copying
// pre-formatted text in Firefox is broken. If we set mIsTextWidget,
// pre-formatted plain text is copied, but pre-formatted "rich" text loses
// the "rich" formatting. If we don't set mIsTextWidget, "rich" text
// attributes aren't lost, but white-space is lost.
// So far the story for Firefox.
//
// Thunderbird has two *conflicting* requirements.
// Case 1:
// When selecting and copying text, even pre-formatted text, as a quote
// to be placed into a reply, we *always* expect HTML to be copied.
// Case 2:
// When copying text in a so-called "plain text" message, that is
// one where the body carries style "white-space:pre-wrap", the text should
// be copied as pre-formatted plain text.
//
// Therefore the following code checks for "pre-wrap" on the body.
// This is a terrible hack.
//
// The proper fix would be this:
// For case 1:
// Communicate the fact that HTML is required to EncodeToString(),
// bug 1141786.
// For case 2:
// Wait for Firefox to get fixed to detect pre-formatting correctly,
// bug 1174452.
nsAutoString styleVal;
if (selContent->GetAttr(kNameSpaceID_None, nsGkAtoms::style, styleVal) &&
styleVal.Find(NS_LITERAL_STRING("pre-wrap")) != kNotFound) {
mIsTextWidget = true;
break;
else if (selContent->IsElement()) {
RefPtr<nsStyleContext> styleContext =
nsComputedDOMStyle::GetStyleContextForElementNoFlush(
selContent->AsElement(), nullptr, nullptr);
if (styleContext) {
const nsStyleText* textStyle = styleContext->StyleText();
if (textStyle->mWhiteSpace == NS_STYLE_WHITESPACE_PRE_WRAP) {
mIsTextWidget = true;
}
}
}
break;
#endif
}