styleContext =
+ nsComputedDOMStyle::GetStyleContextForElementNoFlush(aElement, nullptr,
+ nullptr);
+ if (styleContext) {
+ const nsStyleDisplay* displayStyle = styleContext->StyleDisplay();
+ return displayStyle->IsBlockOutsideStyle();
+ }
+ // Fall back to looking at the tag, in case there is no style information.
+ return nsContentUtils::IsHTMLBlock(GetIdForContent(aElement));
+}
+
/**
* This method is required only to identify LI's inside OL.
* Returns TRUE if we are inside an OL tag and FALSE otherwise.
diff --git a/dom/base/nsPlainTextSerializer.h b/dom/base/nsPlainTextSerializer.h
index 479272a76ad..9535a59d9d5 100644
--- a/dom/base/nsPlainTextSerializer.h
+++ b/dom/base/nsPlainTextSerializer.h
@@ -115,6 +115,7 @@ private:
bool ShouldReplaceContainerWithPlaceholder(nsIAtom* aTag);
bool IsElementPreformatted(mozilla::dom::Element* aElement);
+ bool IsElementBlock(mozilla::dom::Element* aElement);
private:
nsString mCurrentLine;
@@ -169,7 +170,9 @@ private:
// While handling a new tag, this variable should remind if any line break
// is due because of a closing tag. Setting it to "TRUE" while closing the tags.
// Hence opening tags are guaranteed to start with appropriate line breaks.
- bool mLineBreakDue;
+ bool mLineBreakDue;
+
+ bool mPreformattedBlockBoundary;
nsString mURL;
int32_t mHeaderStrategy; /* Header strategy (pref)
diff --git a/dom/base/test/TestPlainTextSerializer.cpp b/dom/base/test/TestPlainTextSerializer.cpp
index 7be9bce0fda..b1a7f241350 100644
--- a/dom/base/test/TestPlainTextSerializer.cpp
+++ b/dom/base/test/TestPlainTextSerializer.cpp
@@ -137,6 +137,31 @@ TestPreElement()
return NS_OK;
}
+nsresult
+TestBlockElement()
+{
+ nsString test;
+ test.AppendLiteral(
+ "" NS_LINEBREAK
+ "" NS_LINEBREAK
+ "" NS_LINEBREAK
+ " first" NS_LINEBREAK
+ "
" NS_LINEBREAK
+ "" NS_LINEBREAK
+ " second" NS_LINEBREAK
+ "
" NS_LINEBREAK
+ "" NS_LINEBREAK "");
+
+ ConvertBufToPlainText(test, 0);
+ if (!test.EqualsLiteral("first" NS_LINEBREAK "second" NS_LINEBREAK)) {
+ fail("Wrong prettyprinted html to text serialization");
+ return NS_ERROR_FAILURE;
+ }
+
+ passed("prettyprinted HTML to text serialization test");
+ return NS_OK;
+}
+
nsresult
TestPlainTextSerializer()
{
@@ -163,6 +188,9 @@ TestPlainTextSerializer()
rv = TestPreElement();
NS_ENSURE_SUCCESS(rv, rv);
+ rv = TestBlockElement();
+ NS_ENSURE_SUCCESS(rv, rv);
+
// Add new tests here...
return NS_OK;
}
diff --git a/dom/base/test/test_bug116083.html b/dom/base/test/test_bug116083.html
index 4244a13aef6..5ac1181536e 100644
--- a/dom/base/test/test_bug116083.html
+++ b/dom/base/test/test_bug116083.html
@@ -20,6 +20,14 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=116083
bar baz
bar baz
bar baz
+
+
+
+
+
+
+
+
foo bar