| <!DOCTYPE html> | |
| <html> | |
| <style> | |
| .container { | |
| position: relative; | |
| background-color: pink; | |
| outline: 1px solid red; | |
| display: inline-block; | |
| } | |
| .flexbox { | |
| display: -webkit-flex; | |
| background-color: grey; | |
| width: 100px; | |
| height: 100px; | |
| } | |
| .title { | |
| margin-top: 1em; | |
| } | |
| .ltr { | |
| direction: ltr; | |
| } | |
| .rtl { | |
| direction: rtl; | |
| } | |
| .horizontal-tb { | |
| -webkit-writing-mode: horizontal-tb; | |
| } | |
| .horizontal-bt { | |
| -webkit-writing-mode: horizontal-bt; | |
| } | |
| .vertical-rl { | |
| -webkit-writing-mode: vertical-rl; | |
| } | |
| .vertical-lr { | |
| -webkit-writing-mode: vertical-lr; | |
| } | |
| .row { | |
| -webkit-flex-flow: row; | |
| } | |
| .row-reverse { | |
| -webkit-flex-flow: row-reverse; | |
| } | |
| .column { | |
| -webkit-flex-flow: column; | |
| } | |
| .column-reverse { | |
| -webkit-flex-flow: column-reverse; | |
| } | |
| .flexbox > :nth-child(1) { | |
| background-color: blue; | |
| } | |
| </style> | |
| <script> | |
| if (window.testRunner) | |
| testRunner.dumpAsText(); | |
| </script> | |
| <script src="../../resources/check-layout.js"></script> | |
| <body onload="checkLayout('.flexbox')"> | |
| <script> | |
| function positionAsString(position) | |
| { | |
| return 'data-offset-x="' + position[0] + '" data-offset-y="' + position[1] + '"'; | |
| } | |
| function sizeAsString(size) | |
| { | |
| return 'data-expected-width="' + size[0] + '" data-expected-height="' + size[1] + '"'; | |
| } | |
| var containerSize = [100, 100]; | |
| var expectations = { | |
| 'horizontal-tb': { | |
| rtl: [-5, 0], | |
| ltr: [0, 0], | |
| 'rtl-column-reverse': [-5, -5], | |
| 'ltr-column-reverse': [0, -5], | |
| }, | |
| 'horizontal-bt': { | |
| rtl: [-5, -5], | |
| ltr: [0, -5], | |
| 'rtl-column-reverse': [-5, 0], | |
| 'ltr-column-reverse': [0, 0], | |
| }, | |
| 'vertical-lr': { | |
| rtl: [0, -5], | |
| ltr: [0, 0], | |
| 'rtl-column-reverse': [-5, -5], | |
| 'ltr-column-reverse': [-5, 0], | |
| }, | |
| 'vertical-rl': { | |
| rtl: [-5, -5], | |
| ltr: [-5, 0], | |
| 'rtl-column-reverse': [0, -5], | |
| 'ltr-column-reverse': [0, 0], | |
| } | |
| } | |
| var writingModes = ['horizontal-tb', 'horizontal-bt', 'vertical-lr', 'vertical-rl']; | |
| var flexFlows = ['row', 'column', 'row-reverse', 'column-reverse']; | |
| var directions = ['rtl', 'ltr']; | |
| writingModes.forEach(function(writingMode) { | |
| flexFlows.forEach(function(flexFlow) { | |
| directions.forEach(function(direction) { | |
| var flexboxClassName = writingMode + ' ' + direction + ' ' + flexFlow; | |
| var title = document.createElement('div'); | |
| title.className = 'title'; | |
| title.innerHTML = flexboxClassName; | |
| document.body.appendChild(title); | |
| var container = document.createElement('div'); | |
| container.className = 'container'; | |
| container.setAttribute('data-expected-width', containerSize[0]); | |
| container.setAttribute('data-expected-height', containerSize[1]); | |
| var flowDirection = direction; | |
| // row-reverse is the same as flipping the writing direction. | |
| if (flexFlow == "row-reverse") | |
| flowDirection = direction == "rtl" ? "ltr" : "rtl"; | |
| else if (flexFlow == "column-reverse") | |
| flowDirection = direction + "-column-reverse"; | |
| container.innerHTML = '\n<div class="flexbox ' + flexboxClassName + '" ' + sizeAsString(containerSize) + '>\n' + | |
| '<div style="-webkit-flex: 1 0 auto; width: 105px; height: 105px;" ' + sizeAsString([105, 105]) + ' ' + positionAsString(expectations[writingMode][flowDirection]) + '></div>\n' + | |
| '</div>\n'; | |
| document.body.appendChild(container); | |
| }) | |
| }) | |
| }) | |
| </script> | |
| </body> | |
| </html> |