Auto merge of #14839 - Permutatrix:iss-12939, r=emilio

Make offset parent queries less buggy.

<!-- Please describe your changes on the following line: -->
Offset parent queries, which are used in the getters for HTMLElement's `offsetParent`, `offsetTop`, `offsetLeft`, `offsetWidth`, and `offsetHeight`, are pretty busted. The most egregious bug is that, as reported in #12939, inline elements are treated as if they're not present in the document. This PR fixes that and all of the other bugs I could trace directly to the offset parent query code, but `offsetTop` and `offsetLeft` are still unreliable in certain circumstances for reasons I haven't looked into (#13708). Inline elements with no content are still treated as not present due to #13982, so #13944 isn't fixed with this PR, either.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #12939 and fix #12595

<!-- Either: -->
- [X] There are tests for these changes

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/14839)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-01-18 10:03:37 -08:00 committed by GitHub
commit b08d4a7d39
30 changed files with 364 additions and 74 deletions

View file

@ -0,0 +1,20 @@
[seg-break-transformation-001.htm]
type: testharness
[linebreak only]
expected: FAIL
[spaces linebreak]
expected: FAIL
[linebreak spaces]
expected: FAIL
[spaces linebreak spaces]
expected: FAIL
[multiple linebreaks]
expected: FAIL
[multiple linebreaks + spaces]
expected: FAIL

View file

@ -0,0 +1,20 @@
[seg-break-transformation-002.htm]
type: testharness
[linebreak only]
expected: FAIL
[spaces linebreak]
expected: FAIL
[linebreak spaces]
expected: FAIL
[spaces linebreak spaces]
expected: FAIL
[multiple linebreaks]
expected: FAIL
[multiple linebreaks + spaces]
expected: FAIL

View file

@ -0,0 +1,20 @@
[seg-break-transformation-003.htm]
type: testharness
[linebreak only]
expected: FAIL
[spaces linebreak]
expected: FAIL
[linebreak spaces]
expected: FAIL
[spaces linebreak spaces]
expected: FAIL
[multiple linebreaks]
expected: FAIL
[multiple linebreaks + spaces]
expected: FAIL

View file

@ -0,0 +1,38 @@
[seg-break-transformation-004.htm]
type: testharness
[linebreak only ₩24]
expected: FAIL
[spaces linebreak ₩24]
expected: FAIL
[linebreak spaces ₩24]
expected: FAIL
[spaces linebreak spaces ₩24]
expected: FAIL
[multiple linebreaks ₩24]
expected: FAIL
[multiple linebreaks + spaces ₩24]
expected: FAIL
[linebreak only 24₩]
expected: FAIL
[spaces linebreak 24₩]
expected: FAIL
[linebreak spaces 24₩]
expected: FAIL
[spaces linebreak spaces 24₩]
expected: FAIL
[multiple linebreaks 24₩]
expected: FAIL
[multiple linebreaks + spaces 24₩]
expected: FAIL

View file

@ -0,0 +1,5 @@
[seg-break-transformation-006.htm]
type: testharness
[spaces linebreak]
expected: FAIL

View file

@ -0,0 +1,20 @@
[seg-break-transformation-008.htm]
type: testharness
[linebreak only]
expected: FAIL
[spaces linebreak]
expected: FAIL
[linebreak spaces]
expected: FAIL
[spaces linebreak spaces]
expected: FAIL
[multiple linebreaks]
expected: FAIL
[multiple linebreaks + spaces]
expected: FAIL

View file

@ -0,0 +1,20 @@
[seg-break-transformation-009.htm]
type: testharness
[linebreak only]
expected: FAIL
[spaces linebreak]
expected: FAIL
[linebreak spaces]
expected: FAIL
[spaces linebreak spaces]
expected: FAIL
[multiple linebreaks]
expected: FAIL
[multiple linebreaks + spaces]
expected: FAIL

View file

@ -0,0 +1,20 @@
[seg-break-transformation-016.htm]
type: testharness
[linebreak only]
expected: FAIL
[spaces linebreak]
expected: FAIL
[linebreak spaces]
expected: FAIL
[spaces linebreak spaces]
expected: FAIL
[multiple linebreaks]
expected: FAIL
[multiple linebreaks + spaces]
expected: FAIL

View file

@ -0,0 +1,20 @@
[seg-break-transformation-017.htm]
type: testharness
[linebreak only]
expected: FAIL
[spaces linebreak]
expected: FAIL
[linebreak spaces]
expected: FAIL
[spaces linebreak spaces]
expected: FAIL
[multiple linebreaks]
expected: FAIL
[multiple linebreaks + spaces]
expected: FAIL

View file

@ -1,3 +0,0 @@
[word-break-break-all-001.htm]
type: reftest
expected: FAIL

View file

@ -1,3 +0,0 @@
[word-break-break-all-002.htm]
type: reftest
expected: FAIL

View file

@ -1,3 +0,0 @@
[word-break-break-all-003.htm]
type: reftest
expected: FAIL

View file

@ -1,3 +0,0 @@
[word-break-break-all-005.htm]
type: reftest
expected: FAIL

View file

@ -1,3 +1,3 @@
[word-break-break-all-000.htm]
[word-break-break-all-007.htm]
type: reftest
expected: FAIL

View file

@ -1,3 +0,0 @@
[word-break-keep-all-000.htm]
type: reftest
expected: FAIL

View file

@ -1,3 +0,0 @@
[word-break-keep-all-001.htm]
type: reftest
expected: FAIL

View file

@ -1,3 +0,0 @@
[word-break-keep-all-002.htm]
type: reftest
expected: FAIL

View file

@ -1,3 +0,0 @@
[word-break-normal-001.htm]
type: reftest
expected: FAIL

View file

@ -1,3 +0,0 @@
[word-break-normal-bo-000.htm]
type: reftest
expected: FAIL

View file

@ -1,3 +0,0 @@
[word-break-normal-en-000.htm]
type: reftest
expected: FAIL

View file

@ -1,3 +0,0 @@
[word-break-normal-hi-000.htm]
type: reftest
expected: FAIL

View file

@ -1,3 +0,0 @@
[word-break-normal-ja-000.htm]
type: reftest
expected: FAIL

View file

@ -1,3 +0,0 @@
[word-break-normal-ja-001.htm]
type: reftest
expected: FAIL

View file

@ -1,3 +0,0 @@
[word-break-normal-ja-002.htm]
type: reftest
expected: FAIL

View file

@ -1,3 +0,0 @@
[word-break-normal-ja-004.htm]
type: reftest
expected: FAIL

View file

@ -1,3 +0,0 @@
[word-break-normal-ko-000.htm]
type: reftest
expected: FAIL

View file

@ -1,3 +1,4 @@
[word-break-normal-zh-000.htm]
type: reftest
expected: FAIL
expected:
if os == "mac": FAIL

View file

@ -6734,6 +6734,12 @@
"url": "/_mozilla/css/meta_viewport_resize.html"
}
],
"css/offset_properties_inline.html": [
{
"path": "css/offset_properties_inline.html",
"url": "/_mozilla/css/offset_properties_inline.html"
}
],
"css/test_variable_legal_values.html": [
{
"path": "css/test_variable_legal_values.html",

View file

@ -0,0 +1,83 @@
<!DOCTYPE html>
<meta charset="utf-8" />
<title>cssom-view - offsetParent, offsetTop, offsetLeft, offsetWidth, and offsetHeight on inline elements</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
#real-offset-parent {
font: 10px/1 Ahem;
margin: 0;
border: none;
padding: 0;
}
#real-offset-parent, #decoy-offset-parent {
position: relative;
}
</style>
<body>
<div id="real-offset-parent">
<span id="inline-1">ABC</span>
<span id="inline-2">ABC<br />ABC</span>
<span id="inline-3">ABC</span>
</div>
<div id="decoy-offset-parent">
<!--
Servo used to simply return the last valid offsetParent in the
document for inline nodes. This was often coincidentally the
correct result in contrived test cases such as this one. This
element is here to catch such bad behavior in the unlikely event
that it ever arises again.
-->
</div>
<script>
var realOffsetParent = document.getElementById('real-offset-parent');
var inline1 = document.getElementById('inline-1');
var inline2 = document.getElementById('inline-2');
var inline3 = document.getElementById('inline-3');
test(function() {
assert_equals(inline1.offsetParent, realOffsetParent,
"offsetParent of #inline-1 should be #real-offset-parent.");
assert_equals(inline2.offsetParent, realOffsetParent,
"offsetParent of #inline-2 should be #real-offset-parent.");
assert_equals(inline3.offsetParent, realOffsetParent,
"offsetParent of #inline-3 should be #real-offset-parent.");
}, "offsetParent");
test(function() {
assert_equals(inline1.offsetTop, 0,
"offsetTop of #inline-1 should be 0.");
assert_equals(inline2.offsetTop, 0,
"offsetTop of #inline-2 should be 0.");
assert_equals(inline3.offsetTop, 10,
"offsetTop of #inline-3 should be 10.");
}, "offsetTop");
test(function() {
assert_equals(inline1.offsetLeft, 0,
"offsetLeft of #inline-1 should be 0.");
assert_equals(inline2.offsetLeft, 40,
"offsetLeft of #inline-2 should be 40.");
assert_equals(inline3.offsetLeft, 40,
"offsetLeft of #inline-3 should be 40.");
}, "offsetLeft");
test(function() {
assert_equals(inline1.offsetWidth, 30,
"offsetWidth of #inline-1 should be 30.");
assert_equals(inline2.offsetWidth, 70,
"offsetWidth of #inline-2 should be 70.");
assert_equals(inline3.offsetWidth, 30,
"offsetWidth of #inline-3 should be 30.");
}, "offsetWidth");
test(function() {
assert_equals(inline1.offsetHeight, 10,
"offsetHeight of #inline-1 should be 10.");
assert_equals(inline2.offsetHeight, 20,
"offsetHeight of #inline-2 should be 20.");
assert_equals(inline3.offsetHeight, 10,
"offsetHeight of #inline-3 should be 10.");
}, "offsetHeight");
</script>
</body>