mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1119503 - Part 1: Determine whether an element is a block element based on the style, not the tag; r=bzbarsky
This probably fixes a whole bunch of edge cases where content uses elements other than div.
This commit is contained in:
parent
12d0b4a9b2
commit
dcf81189d1
@ -670,7 +670,7 @@ nsPlainTextSerializer::DoOpenContainer(nsIAtom* aTag)
|
||||
|
||||
// Else make sure we'll separate block level tags,
|
||||
// even if we're about to leave, before doing any other formatting.
|
||||
else if (nsContentUtils::IsHTMLBlock(aTag)) {
|
||||
else if (IsElementBlock(mElement)) {
|
||||
EnsureVerticalSpace(0);
|
||||
}
|
||||
|
||||
@ -887,8 +887,7 @@ nsPlainTextSerializer::DoCloseContainer(nsIAtom* aTag)
|
||||
else if (aTag == nsGkAtoms::q) {
|
||||
Write(NS_LITERAL_STRING("\""));
|
||||
}
|
||||
else if (nsContentUtils::IsHTMLBlock(aTag)
|
||||
&& aTag != nsGkAtoms::script) {
|
||||
else if (IsElementBlock(mElement) && aTag != nsGkAtoms::script) {
|
||||
// All other blocks get 1 vertical space after them
|
||||
// in formatted mode, otherwise 0.
|
||||
// This is hard. Sometimes 0 is a better number, but
|
||||
@ -1778,6 +1777,20 @@ nsPlainTextSerializer::IsElementPreformatted(Element* aElement)
|
||||
return GetIdForContent(aElement) == nsGkAtoms::pre;
|
||||
}
|
||||
|
||||
bool
|
||||
nsPlainTextSerializer::IsElementBlock(Element* aElement)
|
||||
{
|
||||
nsRefPtr<nsStyleContext> 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.
|
||||
|
@ -115,6 +115,7 @@ private:
|
||||
bool ShouldReplaceContainerWithPlaceholder(nsIAtom* aTag);
|
||||
|
||||
bool IsElementPreformatted(mozilla::dom::Element* aElement);
|
||||
bool IsElementBlock(mozilla::dom::Element* aElement);
|
||||
|
||||
private:
|
||||
nsString mCurrentLine;
|
||||
|
Loading…
Reference in New Issue
Block a user