mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:30:27 +00:00
backout bug 1134280 for fixing yandex search "Read more" link
This commit is contained in:
@@ -134,6 +134,8 @@ protected:
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool IsTag(nsIContent* aContent, nsIAtom* aAtom);
|
||||
|
||||
virtual bool IncludeInContext(nsINode *aNode);
|
||||
|
||||
nsCOMPtr<nsIDocument> mDocument;
|
||||
@@ -528,7 +530,7 @@ nsDocumentEncoder::SerializeToStringIterative(nsINode* aNode,
|
||||
current->NodeType() == nsIDOMNode::DOCUMENT_FRAGMENT_NODE) {
|
||||
DocumentFragment* frag = static_cast<DocumentFragment*>(current);
|
||||
nsIContent* host = frag->GetHost();
|
||||
if (host && host->IsHTMLElement(nsGkAtoms::_template)) {
|
||||
if (host && host->IsHTML(nsGkAtoms::_template)) {
|
||||
current = host;
|
||||
}
|
||||
}
|
||||
@@ -539,6 +541,12 @@ nsDocumentEncoder::SerializeToStringIterative(nsINode* aNode,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
bool
|
||||
nsDocumentEncoder::IsTag(nsIContent* aContent, nsIAtom* aAtom)
|
||||
{
|
||||
return aContent && aContent->Tag() == aAtom;
|
||||
}
|
||||
|
||||
static nsresult
|
||||
ConvertAndWrite(const nsAString& aString,
|
||||
nsIOutputStream* aStream,
|
||||
@@ -1024,7 +1032,7 @@ static bool ParentIsTR(nsIContent* aContent) {
|
||||
if (!parent) {
|
||||
return false;
|
||||
}
|
||||
return parent->IsHTMLElement(nsGkAtoms::tr);
|
||||
return parent->IsHTML(nsGkAtoms::tr);
|
||||
}
|
||||
|
||||
|
||||
@@ -1094,7 +1102,7 @@ nsDocumentEncoder::EncodeToStringWithMaxLength(uint32_t aMaxLength,
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
nsCOMPtr<nsIContent> content = do_QueryInterface(node);
|
||||
if (content && content->IsHTMLElement(nsGkAtoms::tr) && !ParentIsTR(content)) {
|
||||
if (content && content->IsHTML(nsGkAtoms::tr) && !ParentIsTR(content)) {
|
||||
nsINode* n = content;
|
||||
if (!prevNode) {
|
||||
// Went from a non-<tr> to a <tr>
|
||||
@@ -1379,7 +1387,9 @@ nsHTMLCopyEncoder::SetSelection(nsISelection* aSelection)
|
||||
selContent = selContent->GetParent())
|
||||
{
|
||||
// checking for selection inside a plaintext form widget
|
||||
if (selContent->IsAnyOfHTMLElements(nsGkAtoms::input, nsGkAtoms::textarea))
|
||||
nsIAtom *atom = selContent->Tag();
|
||||
if (atom == nsGkAtoms::input ||
|
||||
atom == nsGkAtoms::textarea)
|
||||
{
|
||||
mIsTextWidget = true;
|
||||
break;
|
||||
@@ -1400,7 +1410,7 @@ nsHTMLCopyEncoder::SetSelection(nsISelection* aSelection)
|
||||
|
||||
// also consider ourselves in a text widget if we can't find an html document
|
||||
nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(mDocument);
|
||||
if (!(htmlDoc && mDocument->IsHTMLDocument())) {
|
||||
if (!(htmlDoc && mDocument->IsHTML())) {
|
||||
mIsTextWidget = true;
|
||||
mSelection = aSelection;
|
||||
// mMimeType is set to text/plain when encoding starts.
|
||||
@@ -1513,32 +1523,34 @@ nsHTMLCopyEncoder::IncludeInContext(nsINode *aNode)
|
||||
if (!content)
|
||||
return false;
|
||||
|
||||
return content->IsAnyOfHTMLElements(nsGkAtoms::b,
|
||||
nsGkAtoms::i,
|
||||
nsGkAtoms::u,
|
||||
nsGkAtoms::a,
|
||||
nsGkAtoms::tt,
|
||||
nsGkAtoms::s,
|
||||
nsGkAtoms::big,
|
||||
nsGkAtoms::small,
|
||||
nsGkAtoms::strike,
|
||||
nsGkAtoms::em,
|
||||
nsGkAtoms::strong,
|
||||
nsGkAtoms::dfn,
|
||||
nsGkAtoms::code,
|
||||
nsGkAtoms::cite,
|
||||
nsGkAtoms::var,
|
||||
nsGkAtoms::abbr,
|
||||
nsGkAtoms::font,
|
||||
nsGkAtoms::script,
|
||||
nsGkAtoms::span,
|
||||
nsGkAtoms::pre,
|
||||
nsGkAtoms::h1,
|
||||
nsGkAtoms::h2,
|
||||
nsGkAtoms::h3,
|
||||
nsGkAtoms::h4,
|
||||
nsGkAtoms::h5,
|
||||
nsGkAtoms::h6);
|
||||
nsIAtom *tag = content->Tag();
|
||||
|
||||
return (tag == nsGkAtoms::b ||
|
||||
tag == nsGkAtoms::i ||
|
||||
tag == nsGkAtoms::u ||
|
||||
tag == nsGkAtoms::a ||
|
||||
tag == nsGkAtoms::tt ||
|
||||
tag == nsGkAtoms::s ||
|
||||
tag == nsGkAtoms::big ||
|
||||
tag == nsGkAtoms::small ||
|
||||
tag == nsGkAtoms::strike ||
|
||||
tag == nsGkAtoms::em ||
|
||||
tag == nsGkAtoms::strong ||
|
||||
tag == nsGkAtoms::dfn ||
|
||||
tag == nsGkAtoms::code ||
|
||||
tag == nsGkAtoms::cite ||
|
||||
tag == nsGkAtoms::var ||
|
||||
tag == nsGkAtoms::abbr ||
|
||||
tag == nsGkAtoms::font ||
|
||||
tag == nsGkAtoms::script ||
|
||||
tag == nsGkAtoms::span ||
|
||||
tag == nsGkAtoms::pre ||
|
||||
tag == nsGkAtoms::h1 ||
|
||||
tag == nsGkAtoms::h2 ||
|
||||
tag == nsGkAtoms::h3 ||
|
||||
tag == nsGkAtoms::h4 ||
|
||||
tag == nsGkAtoms::h5 ||
|
||||
tag == nsGkAtoms::h6);
|
||||
}
|
||||
|
||||
|
||||
@@ -1702,11 +1714,10 @@ nsHTMLCopyEncoder::GetPromotedPoint(Endpoint aWhere, nsIDOMNode *aNode, int32_t
|
||||
if (bResetPromotion)
|
||||
{
|
||||
nsCOMPtr<nsIContent> content = do_QueryInterface(parent);
|
||||
if (content && content->IsHTMLElement())
|
||||
if (content)
|
||||
{
|
||||
bool isBlock = false;
|
||||
parserService->IsBlock(parserService->HTMLAtomTagToId(
|
||||
content->NodeInfo()->NameAtom()), isBlock);
|
||||
parserService->IsBlock(parserService->HTMLAtomTagToId(content->Tag()), isBlock);
|
||||
if (isBlock)
|
||||
{
|
||||
bResetPromotion = false;
|
||||
@@ -1785,11 +1796,10 @@ nsHTMLCopyEncoder::GetPromotedPoint(Endpoint aWhere, nsIDOMNode *aNode, int32_t
|
||||
if (bResetPromotion)
|
||||
{
|
||||
nsCOMPtr<nsIContent> content = do_QueryInterface(parent);
|
||||
if (content && content->IsHTMLElement())
|
||||
if (content)
|
||||
{
|
||||
bool isBlock = false;
|
||||
parserService->IsBlock(parserService->HTMLAtomTagToId(
|
||||
content->NodeInfo()->NameAtom()), isBlock);
|
||||
parserService->IsBlock(parserService->HTMLAtomTagToId(content->Tag()), isBlock);
|
||||
if (isBlock)
|
||||
{
|
||||
bResetPromotion = false;
|
||||
@@ -1848,7 +1858,7 @@ nsHTMLCopyEncoder::IsMozBR(nsIDOMNode* aNode)
|
||||
MOZ_ASSERT(aNode);
|
||||
nsCOMPtr<Element> element = do_QueryInterface(aNode);
|
||||
return element &&
|
||||
element->IsHTMLElement(nsGkAtoms::br) &&
|
||||
element->IsHTML(nsGkAtoms::br) &&
|
||||
element->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
|
||||
NS_LITERAL_STRING("_moz"), eIgnoreCase);
|
||||
}
|
||||
@@ -1880,17 +1890,16 @@ bool
|
||||
nsHTMLCopyEncoder::IsRoot(nsIDOMNode* aNode)
|
||||
{
|
||||
nsCOMPtr<nsIContent> content = do_QueryInterface(aNode);
|
||||
if (!content) {
|
||||
return false;
|
||||
}
|
||||
if (content)
|
||||
{
|
||||
if (mIsTextWidget)
|
||||
return (IsTag(content, nsGkAtoms::div));
|
||||
|
||||
if (mIsTextWidget) {
|
||||
return content->IsHTMLElement(nsGkAtoms::div);
|
||||
return (IsTag(content, nsGkAtoms::body) ||
|
||||
IsTag(content, nsGkAtoms::td) ||
|
||||
IsTag(content, nsGkAtoms::th));
|
||||
}
|
||||
|
||||
return content->IsAnyOfHTMLElements(nsGkAtoms::body,
|
||||
nsGkAtoms::td,
|
||||
nsGkAtoms::th);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
@@ -2008,12 +2017,11 @@ nsHTMLCopyEncoder::GetImmediateContextCount(const nsTArray<nsINode*>& aAncestorA
|
||||
break;
|
||||
}
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(node));
|
||||
if (!content ||
|
||||
!content->IsAnyOfHTMLElements(nsGkAtoms::tr,
|
||||
nsGkAtoms::thead,
|
||||
nsGkAtoms::tbody,
|
||||
nsGkAtoms::tfoot,
|
||||
nsGkAtoms::table)) {
|
||||
if (!content || !content->IsHTML() || (content->Tag() != nsGkAtoms::tr &&
|
||||
content->Tag() != nsGkAtoms::thead &&
|
||||
content->Tag() != nsGkAtoms::tbody &&
|
||||
content->Tag() != nsGkAtoms::tfoot &&
|
||||
content->Tag() != nsGkAtoms::table)) {
|
||||
break;
|
||||
}
|
||||
++j;
|
||||
|
||||
Reference in New Issue
Block a user