Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support for debugging of difference in cell dimension (#253)
* [FINE] added support for debug config where clients can receive callback in case there is non-deterministic heights and there is a discrepancy in it. * [FINE] made the debug handler pluggable. * [FINE] made debugHandler container of other handlers. * [FINE] not using I coding style for the interface.
- Loading branch information
1 parent
9e62414
commit 84ab6d1
Showing
6 changed files
with
78 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
echo "Deleting old packages..." | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import ResizeDebugHandler from "./resize/ResizeDebugHandler"; | ||
|
||
// It is basically container of all debugHandlers. | ||
export interface DebugHandlers { | ||
resizeDebugHandler?: ResizeDebugHandler; | ||
} |
29 changes: 29 additions & 0 deletions
29
src/core/devutils/debughandlers/resize/DefaultResizeDebugHandler.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { Dimension } from "../../../.."; | ||
import ResizeDebugHandler from "./ResizeDebugHandler"; | ||
|
||
export default class DefaultResizeDebugHandler implements ResizeDebugHandler { | ||
private readonly relaxation: Dimension; | ||
private readonly onRelaxationViolation: (expectedDim: Dimension, actualDim: Dimension, index: number) => void; | ||
|
||
// Relaxation is the Dimension object where it accepts the relaxation to allow for each dimension. | ||
// Any of the dimension (height or width) whose value for relaxation is less than 0 would be ignored. | ||
public constructor(relaxation: Dimension, onRelaxationViolation: (expectedDim: Dimension, actualDim: Dimension, index: number) => void) { | ||
this.relaxation = relaxation; | ||
this.onRelaxationViolation = onRelaxationViolation; | ||
} | ||
|
||
public resizeDebug(oldDim: Dimension, newDim: Dimension, index: number): void { | ||
let isViolated: boolean = false; | ||
if (this.relaxation.height >= 0 && Math.abs(newDim.height - oldDim.height) >= this.relaxation.height) { | ||
isViolated = true; | ||
} | ||
|
||
if (!isViolated && this.relaxation.width >= 0 && Math.abs(newDim.width - oldDim.width) >= this.relaxation.width) { | ||
isViolated = true; | ||
} | ||
|
||
if (isViolated) { | ||
this.onRelaxationViolation(oldDim, newDim, index); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { Dimension } from "../../../.."; | ||
|
||
export default interface ResizeDebugHandler { | ||
resizeDebug(oldDim: Dimension, newDim: Dimension, index: number): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters