Bug 1214377 - Hack to solve Thunderbird's need to detect style pre-wrap. r=roc a=me

--HG--
extra : commitid : 8b0gs3Dmya1
This commit is contained in:
Jorg K 2015-11-06 11:42:29 -08:00
parent c37efdf9c9
commit 2bbbf73717

View File

@ -51,6 +51,7 @@
#include "mozilla/dom/EncodingUtils.h"
#include "nsContainerFrame.h"
#include "nsBlockFrame.h"
#include "nsComputedDOMStyle.h"
using namespace mozilla;
using namespace mozilla::dom;
@ -1428,10 +1429,6 @@ nsHTMLCopyEncoder::SetSelection(nsISelection* aSelection)
return NS_ERROR_NULL_POINTER;
range->GetCommonAncestorContainer(getter_AddRefs(commonParent));
// Thunderbird's msg compose code abuses the HTML copy encoder and gets
// confused if mIsTextWidget ends up becoming true, so for now we skip
// this logic in Thunderbird.
#ifndef MOZ_THUNDERBIRD
for (nsCOMPtr<nsIContent> selContent(do_QueryInterface(commonParent));
selContent;
selContent = selContent->GetParent())
@ -1442,6 +1439,20 @@ nsHTMLCopyEncoder::SetSelection(nsISelection* aSelection)
mIsTextWidget = true;
break;
}
#ifdef MOZ_THUNDERBIRD
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
}
// normalize selection if we are not in a widget
@ -1451,7 +1462,6 @@ nsHTMLCopyEncoder::SetSelection(nsISelection* aSelection)
mMimeType.AssignLiteral("text/plain");
return NS_OK;
}
#endif
// also consider ourselves in a text widget if we can't find an html document
nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(mDocument);