| 858 | // display-related state. |
| 859 | |
| 860 | function Display(place, doc, input) { |
| 861 | var d = this |
| 862 | this.input = input |
| 863 | |
| 864 | // Covers bottom-right square when both scrollbars are present. |
| 865 | d.scrollbarFiller = elt("div", null, "CodeMirror-scrollbar-filler") |
| 866 | d.scrollbarFiller.setAttribute("cm-not-content", "true") |
| 867 | // Covers bottom of gutter when coverGutterNextToScrollbar is on |
| 868 | // and h scrollbar is present. |
| 869 | d.gutterFiller = elt("div", null, "CodeMirror-gutter-filler") |
| 870 | d.gutterFiller.setAttribute("cm-not-content", "true") |
| 871 | // Will contain the actual code, positioned to cover the viewport. |
| 872 | d.lineDiv = eltP("div", null, "CodeMirror-code") |
| 873 | // Elements are added to these to represent selection and cursors. |
| 874 | d.selectionDiv = elt("div", null, null, "position: relative; z-index: 1") |
| 875 | d.cursorDiv = elt("div", null, "CodeMirror-cursors") |
| 876 | // A visibility: hidden element used to find the size of things. |
| 877 | d.measure = elt("div", null, "CodeMirror-measure") |
| 878 | // When lines outside of the viewport are measured, they are drawn in this. |
| 879 | d.lineMeasure = elt("div", null, "CodeMirror-measure") |
| 880 | // Wraps everything that needs to exist inside the vertically-padded coordinate system |
| 881 | d.lineSpace = eltP("div", [d.measure, d.lineMeasure, d.selectionDiv, d.cursorDiv, d.lineDiv], null, "position: relative; outline: none") |
| 882 | var lines = eltP("div", [d.lineSpace], "CodeMirror-lines") |
| 883 | // Moved around its parent to cover visible view. |
| 884 | d.mover = elt("div", [lines], null, "position: relative") |
| 885 | // Set to the height of the document, allowing scrolling. |
| 886 | d.sizer = elt("div", [d.mover], "CodeMirror-sizer") |
| 887 | d.sizerWidth = null |
| 888 | // Behavior of elts with overflow: auto and padding is |
| 889 | // inconsistent across browsers. This is used to ensure the |
| 890 | // scrollable area is big enough. |
| 891 | d.heightForcer = elt("div", null, null, "position: absolute; height: " + scrollerGap + "px; width: 1px;") |
| 892 | // Will contain the gutters, if any. |
| 893 | d.gutters = elt("div", null, "CodeMirror-gutters") |
| 894 | d.lineGutter = null |
| 895 | // Actual scrollable element. |
| 896 | d.scroller = elt("div", [d.sizer, d.heightForcer, d.gutters], "CodeMirror-scroll") |
| 897 | d.scroller.setAttribute("tabIndex", "-1") |
| 898 | // The element in which the editor lives. |
| 899 | d.wrapper = elt("div", [d.scrollbarFiller, d.gutterFiller, d.scroller], "CodeMirror") |
| 900 | |
| 901 | // Work around IE7 z-index bug (not perfect, hence IE7 not really being supported) |
| 902 | if (ie && ie_version < 8) { |
| 903 | d.gutters.style.zIndex = -1 |
| 904 | d.scroller.style.paddingRight = 0 |
| 905 | } |
| 906 | if (!webkit && !(gecko && mobile)) { |
| 907 | d.scroller.draggable = true |
| 908 | } |
| 909 | |
| 910 | if (place) { |
| 911 | if (place.appendChild) { |
| 912 | place.appendChild(d.wrapper) |
| 913 | } else { |
| 914 | place(d.wrapper) |
| 915 | } |
| 916 | } |
| 917 | |