mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-20 16:55:40 +00:00
Bug 992384 - Make sure we always propagate root element's mWritingMode. r=emilio
Bug 1102175 Part 1 only handles HTML documents correctly because they always have a body element (even if the <body> tag is not written explicitly in the document). For SVG documents and all other documents lacking <body> element, we always want to propagate mWritingMode from the root element, which is our old behavior prior to Bug 1102175. Note that mDocElementContainingBlock (i.e. nsCanvasFrame) is using viewport's style, so we need to use the root element's computed style to compute WritingMode for propagating. Differential Revision: https://phabricator.services.mozilla.com/D49695 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
fe6102fc27
commit
cbe975548d
@ -2186,8 +2186,7 @@ static inline bool NeedFrameFor(const nsFrameConstructorState& aState,
|
||||
// list.
|
||||
if (!aParentFrame ||
|
||||
!aParentFrame->IsFrameOfType(nsIFrame::eExcludesIgnorableWhitespace) ||
|
||||
aParentFrame->IsGeneratedContentFrame() ||
|
||||
!aChildContent->IsText()) {
|
||||
aParentFrame->IsGeneratedContentFrame() || !aChildContent->IsText()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -2315,13 +2314,12 @@ nsIFrame* nsCSSFrameConstructor::ConstructDocElementFrame(
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (aDocElement->IsHTMLElement() &&
|
||||
mDocElementContainingBlock->IsCanvasFrame()) {
|
||||
if (mDocElementContainingBlock->IsCanvasFrame()) {
|
||||
// This implements "The Principal Writing Mode".
|
||||
// https://drafts.csswg.org/css-writing-modes-3/#principal-flow
|
||||
//
|
||||
// If there's a <body> element, its writing-mode, direction, and
|
||||
// text-orientation override the root element's used value.
|
||||
// If there's a <body> element in an HTML document, its writing-mode,
|
||||
// direction, and text-orientation override the root element's used value.
|
||||
//
|
||||
// We need to copy <body>'s WritingMode to mDocElementContainingBlock before
|
||||
// construct mRootElementFrame so that anonymous internal frames such as
|
||||
@ -2331,12 +2329,13 @@ nsIFrame* nsCSSFrameConstructor::ConstructDocElementFrame(
|
||||
"We need to copy <body>'s principal writing-mode before "
|
||||
"constructing mRootElementFrame.");
|
||||
|
||||
const WritingMode docElementWM(computedStyle);
|
||||
Element* body = mDocument->GetBodyElement();
|
||||
if (body) {
|
||||
RefPtr<ComputedStyle> bodyStyle = ResolveComputedStyle(body);
|
||||
WritingMode bodyWM(bodyStyle);
|
||||
const WritingMode bodyWM(bodyStyle);
|
||||
|
||||
if (bodyWM != mDocElementContainingBlock->GetWritingMode()) {
|
||||
if (bodyWM != docElementWM) {
|
||||
nsContentUtils::ReportToConsole(
|
||||
nsIScriptError::warningFlag, NS_LITERAL_CSTRING("Layout"),
|
||||
mDocument, nsContentUtils::eLAYOUT_PROPERTIES,
|
||||
@ -2347,7 +2346,7 @@ nsIFrame* nsCSSFrameConstructor::ConstructDocElementFrame(
|
||||
bodyWM);
|
||||
} else {
|
||||
mDocElementContainingBlock->PropagateWritingModeToSelfAndAncestors(
|
||||
mDocElementContainingBlock->GetWritingMode());
|
||||
docElementWM);
|
||||
}
|
||||
}
|
||||
|
||||
@ -5567,8 +5566,7 @@ void nsCSSFrameConstructor::AddFrameConstructionItemsInternal(
|
||||
aItems.SetParentHasNoXBLChildren(!iter.XBLInvolved());
|
||||
|
||||
CreateGeneratedContentItem(aState, aParentFrame, *aContent->AsElement(),
|
||||
*aComputedStyle, PseudoStyleType::after,
|
||||
aItems);
|
||||
*aComputedStyle, PseudoStyleType::after, aItems);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,11 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:html="http://www.w3.org/1999/xhtml" width="2000px" height="100px" style="direction: rtl;">
|
||||
<g id="testmeta">
|
||||
<title>CSS-Writing Modes Test: Principal Writing Mode</title>
|
||||
<html:link rel="author" title="Ting-Yu Lin" href="tlin@mozilla.com"/>
|
||||
<html:link rel="author" title="Mozilla" href="https://mozilla.org/"/>
|
||||
<html:link rel="help" href="https://drafts.csswg.org/css-writing-modes-3/#principal-flow"/>
|
||||
<html:link rel="mismatch" href="../reference/blank.html"/>
|
||||
<decs class="assert">This test verifies setting "direction:rtl" on the svg root
|
||||
with a large width can generate a horizontal scroll bar.</decs>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 696 B |
Loading…
Reference in New Issue
Block a user