Compare commits

..

No commits in common. "2b54735175cf404d92b5f3e3c6ce4744096b4af6" and "a507f243268b74e9e4e4009a38121891654c56db" have entirely different histories.

View File

@ -886,11 +886,10 @@ class BesService {
* @param {Number} scale Sign scale * @param {Number} scale Sign scale
* @param {Number} dpr Device pixel ratio * @param {Number} dpr Device pixel ratio
*/ */
setCtxFont(scale, dpr) { setCtxFont(scale, dpr)
{
const styles = window.getComputedStyle(this.canvasPanel) const styles = window.getComputedStyle(this.canvasPanel)
this.ctx.font = `${styles.fontStyle} ${styles.fontWeight} ${ this.ctx.font = `${styles.fontStyle} ${styles.fontWeight} ${14 * scale * dpr}px ${styles.fontFamily}`
14 * scale * dpr
}px ${styles.fontFamily}`
} }
/** /**
@ -945,16 +944,10 @@ class BesService {
* @param {Number} x X coordinate * @param {Number} x X coordinate
* @param {Number} y Y coordinate * @param {Number} y Y coordinate
* @param {DOMRect} rect Rectangle * @param {DOMRect} rect Rectangle
* @param {Number} tolerance Extra margin around the rectangle treated as "inside"
* @returns * @returns
*/ */
static isPointInRect(x, y, rect, tolerance) { static isPointInRect(x, y, rect) {
return ( return rect.left <= x && x < rect.right && rect.top <= y && y < rect.bottom
rect.left - tolerance <= x &&
x < rect.right + tolerance &&
rect.top - tolerance <= y &&
y < rect.bottom + tolerance
)
} }
/** /**
@ -1525,7 +1518,7 @@ class BesTreeService extends BesService {
for (let result of this.results) { for (let result of this.results) {
for (let m of result.matches) { for (let m of result.matches) {
for (let rect of m.highlights) { for (let rect of m.highlights) {
if (BesService.isPointInRect(x, y, rect, 5)) { if (BesService.isPointInRect(x, y, rect)) {
pointsInRect.push({ el, match: m }) pointsInRect.push({ el, match: m })
break break
} }
@ -2193,7 +2186,7 @@ class BesPlainTextService extends BesService {
for (let result of this.results) { for (let result of this.results) {
for (let m of result.matches) { for (let m of result.matches) {
for (let rect of m.highlights) { for (let rect of m.highlights) {
if (BesService.isPointInRect(x, y, rect, 5)) { if (BesService.isPointInRect(x, y, rect)) {
pointsInRect.push({ el: result.range, match: m }) pointsInRect.push({ el: result.range, match: m })
break break
} }
@ -2474,13 +2467,11 @@ class BesTAService extends BesPlainTextService {
parseFloat(styles.paddingRight) - parseFloat(styles.paddingRight) -
parseFloat(styles.borderRightWidth) parseFloat(styles.borderRightWidth)
}px` }px`
textElement.style.height = `${ textElement.style.height = `${rect.height -
rect.height -
parseFloat(styles.borderTopWidth) - parseFloat(styles.borderTopWidth) -
parseFloat(styles.paddingTop) - parseFloat(styles.paddingTop) -
parseFloat(styles.paddingBottom) - parseFloat(styles.paddingBottom) -
parseFloat(styles.borderBottomWidth) parseFloat(styles.borderBottomWidth)}px`
}px`
} }
/** /**