Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Commit

Permalink
Merge branch 'master' into worie/13274-lp-highlight-transform
Browse files Browse the repository at this point in the history
  • Loading branch information
Worie committed Apr 10, 2017
2 parents fe9237e + aef78dd commit ad915c7
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 27 deletions.
31 changes: 7 additions & 24 deletions src/LiveDevelopment/Agents/RemoteFunctions.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ function RemoteFunctions(config, remoteWSPort) {
parseInt(realElBorder.left),
outerHeight = innerHeight + parseInt(realElBorder.bottom) + parseInt(realElBorder.top);
}


var visualisations = {
horizontal: "left, right",
Expand All @@ -321,7 +322,6 @@ function RemoteFunctions(config, remoteWSPort) {

if (visualisations.horizontal.indexOf(side) >= 0) {
elStyling['width'] = elementStyling.getPropertyValue('padding-' + side);
// get rid of px and remove borders
elStyling['height'] = innerHeight + "px";
elStyling['top'] = 0;

Expand Down Expand Up @@ -355,6 +355,7 @@ function RemoteFunctions(config, remoteWSPort) {
margin['left'] = parseInt(elementStyling.getPropertyValue('margin-left'));

if(visualisations['horizontal'].indexOf(side) >= 0) {

elStyling['width'] = elementStyling.getPropertyValue('margin-' + side);
elStyling['height'] = outerHeight + margin['top'] + margin['bottom'] + "px";
elStyling['top'] = "-" + (margin['top'] + parseInt(realElBorder.top)) + "px";
Expand Down Expand Up @@ -430,37 +431,19 @@ function RemoteFunctions(config, remoteWSPort) {
highlight.className = HIGHLIGHT_CLASSNAME;

var offset = _screenOffset(element);

var el = element,
offsetLeft = 0,
offsetTop = 0;

// Probably the easiest way to get elements position without including transform
do {
offsetLeft += el.offsetLeft;
offsetTop += el.offsetTop;
el = el.offsetParent;
} while(el);

var stylesToSet = {
"left": offsetLeft + "px",
"top": offsetTop + "px",
"width": innerWidth + "px",
"height": innerHeight + "px",
"left": offset.left + "px",
"top": offset.top + "px",
"width": elementBounds.width + "px",
"height": elementBounds.height + "px",
"z-index": 2000000,
"margin": 0,
"padding": 0,
"position": "absolute",
"pointer-events": "none",
"box-shadow": "0 0 1px #fff",
"box-sizing": elementStyling.getPropertyValue('box-sizing'),
"border-right": elementStyling.getPropertyValue('border-right'),
"border-left": elementStyling.getPropertyValue('border-left'),
"border-top": elementStyling.getPropertyValue('border-top'),
"border-bottom": elementStyling.getPropertyValue('border-bottom'),
"transform": elementStyling.getPropertyValue('transform'),
"transform-origin": elementStyling.getPropertyValue('transform-origin'),
"border-color": config.remoteHighlight.borderColor
"box-sizing": "border-box"
};

var mergedStyles = Object.assign({}, stylesToSet, config.remoteHighlight.stylesToSet);
Expand Down
10 changes: 8 additions & 2 deletions src/editor/Editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ define(function (require, exports, module) {
UPPERCASE_COLORS = "uppercaseColors",
USE_TAB_CHAR = "useTabChar",
WORD_WRAP = "wordWrap",
INDENT_LINE_COMMENT = "indentLineComment";
INDENT_LINE_COMMENT = "indentLineComment",
INPUT_STYLE = "inputStyle";

/**
* A list of gutter name and priorities currently registered for editors.
Expand Down Expand Up @@ -137,6 +138,7 @@ define(function (require, exports, module) {
cmOptions[TAB_SIZE] = "tabSize";
cmOptions[USE_TAB_CHAR] = "indentWithTabs";
cmOptions[WORD_WRAP] = "lineWrapping";
cmOptions[INPUT_STYLE] = "inputStyle";

PreferencesManager.definePreference(CLOSE_BRACKETS, "boolean", true, {
description: Strings.DESCRIPTION_CLOSE_BRACKETS
Expand Down Expand Up @@ -228,6 +230,10 @@ define(function (require, exports, module) {
description: Strings.DESCRIPTION_INDENT_LINE_COMMENT
});

PreferencesManager.definePreference(INPUT_STYLE, "string", "textarea", {
description: Strings.DESCRIPTION_INPUT_STYLE
});

var editorOptions = Object.keys(cmOptions);

/** Editor preferences */
Expand Down Expand Up @@ -413,7 +419,7 @@ define(function (require, exports, module) {
highlightSelectionMatches : currentOptions[HIGHLIGHT_MATCHES],
indentUnit : currentOptions[USE_TAB_CHAR] ? currentOptions[TAB_SIZE] : currentOptions[SPACE_UNITS],
indentWithTabs : currentOptions[USE_TAB_CHAR],
inputStyle : "textarea", // the "contenteditable" mode used on mobiles could cause issues
inputStyle : currentOptions[INPUT_STYLE],
lineNumbers : currentOptions[SHOW_LINE_NUMBERS],
lineWiseCopyCut : currentOptions[LINEWISE_COPY_CUT],
lineWrapping : currentOptions[WORD_WRAP],
Expand Down
5 changes: 5 additions & 0 deletions src/extensions/default/MDNDocs/unittest-files/test1.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,10 @@
</style>
</head>
<body style="background-color{{1}}: #000">
<{{2}}nonexistent></nonexistent>
<div>{{3}}some text</div>
<!-- <{{4}}div></div> -->
<div {{5}}class="{{6}}muted" {{7}}nonexistent="false"></div>
<nonexistent {{8}}nonexistent="false"></nonexistent>
</body>
</html>
46 changes: 45 additions & 1 deletion src/extensions/default/MDNDocs/unittests.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,22 @@ define(function (require, exports, module) {
expect(Object.keys(json).length).toBeGreaterThan(0);
});
});

it("should retrieve the HTML docs database", function () {
var json;

runs(function () {
main._getDocs("html.json").done(function (result) {
json = result;
});
});

waitsFor(function () { return json !== undefined; }, "read html.json database", 5000);

runs(function () {
expect(Object.keys(json).length).toBeGreaterThan(0);
});
});

});

Expand Down Expand Up @@ -165,9 +181,37 @@ define(function (require, exports, module) {
queryInlineAtPos(testHTMLInfo, 0, true, "border");
});

it("should open docs for HTML", function () {
it("should open docs when the selection is on an HTML tag", function () {
queryInlineAtPos(testHTMLInfo, 1, true, "<body>");
});

it("should not open docs when the selection is on an invalid HTML tag", function () {
queryInlineAtPos(testHTMLInfo, 2, false);
});

it("should not open docs when the selection is not an HTML tag", function () {
/* Text */
queryInlineAtPos(testHTMLInfo, 3, false);

/* Commented tag */
queryInlineAtPos(testHTMLInfo, 4, false);
});

it("should open docs when the selection is on an HTML attribute", function () {
queryInlineAtPos(testHTMLInfo, 5, true, "<div>");
});

it("should open docs for tag (fallback) when the selection is on an HTML attribute's value", function () {
queryInlineAtPos(testHTMLInfo, 6, true, "<div>");
});

it("should open docs for tag (fallback) when the selection is on an invalid HTML attribute", function () {
queryInlineAtPos(testHTMLInfo, 7, true, "<div>");
});

it("should not open docs when the selection is on an invalid HTML attribute on an invalid HTML tag", function () {
queryInlineAtPos(testHTMLInfo, 8, false);
});

});

Expand Down
1 change: 1 addition & 0 deletions src/nls/root/strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,7 @@ define({
"DESCRIPTION_LANGUAGE_FILE_EXTENSIONS" : "Additional mappings from file extension to language name",
"DESCRIPTION_LANGUAGE_FILE_NAMES" : "Additional mappings from file name to language name",
"DESCRIPTION_LINEWISE_COPY_CUT" : "Doing copy and cut when there's no selection will copy or cut the whole lines that have cursors in them",
"DESCRIPTION_INPUT_STYLE" : "Selects the way CodeMirror handles input and focus. It cans be textarea, which is the default, or contenteditable which is better for screen readers (unstable)",
"DESCRIPTION_LINTING_ENABLED" : "true to enable Code Inspection",
"DESCRIPTION_ASYNC_TIMEOUT" : "The time in milliseconds after which asynchronous linters time out",
"DESCRIPTION_LINTING_PREFER" : "Array of linters to run first",
Expand Down

0 comments on commit ad915c7

Please sign in to comment.