Commit cad9446c authored by szager's avatar szager Committed by Commit bot

Fix percent height calc for svg docs.

Previously, percent-height svg elements in a pure-svg doc would get
their size based on the LayoutView's logical height from the previous
layout pass.  In practice, this didn't show up much because FrameView
always does at least one extra initial layout pass to add and then
subtract scrollbars.  The extra layout pass would cause the percent
height descendants to get the right size.

Setting overlay scrollbars on the FrameView eliminates the extra
layout passes and allows the bug to manifest.

Review-Url: https://codereview.chromium.org/2835153002
Cr-Commit-Position: refs/heads/master@{#469327}
parent 7289d3fc
<svg xmlns="http://www.w3.org/2000/svg" onload="startTest()">
<script>
if (self.internals)
internals.runtimeFlags.overlayScrollbarsEnabled = true;
function startTest() {
if (!window.testRunner)
return;
testRunner.dumpAsText();
testRunner.waitUntilDone();
testRunner.setBackingScaleFactor(2, finishTest);
var rect = document.getElementById('rect');
var result = document.getElementById('result');
result.innerHTML = 'rect.offsetHeight = ' + rect.getBoundingClientRect().height;
}
function finishTest() {
setTimeout(function () { testRunner.notifyDone(); }, 0);
}
</script>
<mask id='mask'>
<rect id='rect' width='100%' height='100%' fill='white'/>
</mask>
<text id='result'></text>
</svg>
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include "core/frame/LocalFrame.h" #include "core/frame/LocalFrame.h"
#include "core/layout/HitTestResult.h" #include "core/layout/HitTestResult.h"
#include "core/layout/LayoutAnalyzer.h" #include "core/layout/LayoutAnalyzer.h"
#include "core/layout/LayoutView.h"
#include "core/layout/api/LayoutPartItem.h" #include "core/layout/api/LayoutPartItem.h"
#include "core/layout/svg/LayoutSVGText.h" #include "core/layout/svg/LayoutSVGText.h"
#include "core/layout/svg/SVGLayoutSupport.h" #include "core/layout/svg/SVGLayoutSupport.h"
...@@ -134,6 +135,13 @@ LayoutUnit LayoutSVGRoot::ComputeReplacedLogicalHeight( ...@@ -134,6 +135,13 @@ LayoutUnit LayoutSVGRoot::ComputeReplacedLogicalHeight(
return ContainingBlock()->AvailableLogicalHeight( return ContainingBlock()->AvailableLogicalHeight(
kIncludeMarginBorderPadding); kIncludeMarginBorderPadding);
const Length& logical_height = Style()->LogicalHeight();
if (IsDocumentElement() && logical_height.IsPercentOrCalc()) {
return ValueForLength(
logical_height,
GetDocument().GetLayoutView()->ViewLogicalHeightForPercentages());
}
return LayoutReplaced::ComputeReplacedLogicalHeight(estimated_used_width); return LayoutReplaced::ComputeReplacedLogicalHeight(estimated_used_width);
} }
......
...@@ -696,6 +696,7 @@ ...@@ -696,6 +696,7 @@
}, },
{ {
name: "OverlayScrollbars", name: "OverlayScrollbars",
settable_from_internals: true,
}, },
{ {
name: "PagePopup", name: "PagePopup",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment