mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 06:11:37 +00:00
Backed out changeset e925caf848fa (bug 1214377) for wrong reviewer in commit
This commit is contained in:
parent
717f6dbf0b
commit
5fb313776a
@ -1438,44 +1438,18 @@ nsHTMLCopyEncoder::SetSelection(nsISelection* aSelection)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#ifdef MOZ_THUNDERBIRD
|
#ifdef MOZ_THUNDERBIRD
|
||||||
else if (selContent->IsHTMLElement(nsGkAtoms::body)) {
|
else if (selContent->IsElement()) {
|
||||||
// Currently, setting mIsTextWidget to 'true' will result in the selection
|
RefPtr<nsStyleContext> styleContext =
|
||||||
// being encoded/copied as pre-formatted plain text.
|
nsComputedDOMStyle::GetStyleContextForElementNoFlush(
|
||||||
// This is fine for copying pre-formatted plain text with Firefox, it is
|
selContent->AsElement(), nullptr, nullptr);
|
||||||
// already not correct for copying pre-formatted "rich" text (bold, colour)
|
if (styleContext) {
|
||||||
// with Firefox. As long as the serialisers aren't fixed, copying
|
const nsStyleText* textStyle = styleContext->StyleText();
|
||||||
// pre-formatted text in Firefox is broken. If we set mIsTextWidget,
|
if (textStyle->mWhiteSpace == NS_STYLE_WHITESPACE_PRE_WRAP) {
|
||||||
// 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;
|
mIsTextWidget = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user