Improve LinesYardstick design

We have shifted the responsibility of orchestrating state updates and
measurements to the yardstick. The presenter still needs to be updated to make
use of these new capabilities.
This commit is contained in:
Antonio Scandurra
2015-09-18 10:17:53 +02:00
parent 5a2e4ba2aa
commit bf7d7e0d2a
4 changed files with 31 additions and 32 deletions

View File

@@ -4,14 +4,18 @@ AcceptFilter = {acceptNode: -> NodeFilter.FILTER_ACCEPT}
module.exports =
class LinesYardstick
constructor: (@model, @lineNodesProvider) ->
constructor: (@model, @presenter, @lineNodesProvider) ->
@cachedPositionsByLineId = {}
@tokenIterator = new TokenIterator
@rangeForMeasurement = document.createRange()
@cachedPositionsByLineId = {}
clearCache: ->
@cachedPositionsByLineId = {}
prepareScreenRowsForMeasurement: (screenRows) ->
state = @presenter.getStateForMeasurements(screenRows)
@lineNodesProvider.updateSync(state)
pixelPositionForScreenPosition: (screenPosition, clip=true) ->
screenPosition = Point.fromObject(screenPosition)
screenPosition = @model.clipScreenPosition(screenPosition) if clip