Skip to content

Commit

Permalink
Move convertToPixels into sizeUtils
Browse files Browse the repository at this point in the history
  • Loading branch information
mjbvz committed Apr 11, 2019
1 parent e7e32af commit 4151e3e
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/vs/base/browser/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -467,14 +467,6 @@ export function getComputedStyle(el: HTMLElement): CSSStyleDeclaration {
return document.defaultView!.getComputedStyle(el, null);
}

// Adapted from WinJS
// Converts a CSS positioning string for the specified element to pixels.
const convertToPixels: (element: HTMLElement, value: string) => number = (function () {
return function (element: HTMLElement, value: string): number {
return parseFloat(value) || 0;
};
})();

export function getClientArea(element: HTMLElement): Dimension {

// Try with DOM clientWidth / clientHeight
Expand All @@ -501,6 +493,12 @@ export function getClientArea(element: HTMLElement): Dimension {
}

class SizeUtils {
// Adapted from WinJS
// Converts a CSS positioning string for the specified element to pixels.
private static convertToPixels(element: HTMLElement, value: string): number {
return parseFloat(value) || 0;
}

private static getDimension(element: HTMLElement, cssPropertyName: string, jsPropertyName: string): number {
let computedStyle: CSSStyleDeclaration = getComputedStyle(element);
let value = '0';
Expand All @@ -512,7 +510,7 @@ class SizeUtils {
value = (<any>computedStyle).getAttribute(jsPropertyName);
}
}
return convertToPixels(element, value);
return SizeUtils.convertToPixels(element, value);
}

static getBorderLeftWidth(element: HTMLElement): number {
Expand Down

0 comments on commit 4151e3e

Please sign in to comment.