changing the GC algorith. Only operations left to an deleted insertion can be garbage collected. (incomplete!)
This commit is contained in:
@@ -10,6 +10,9 @@ adaptConnector = (connector, engine, HB, execution_listener)->
|
||||
if o.uid.creator is HB.getUserId() and (typeof o.uid.op_number isnt "string")
|
||||
connector.broadcast o
|
||||
|
||||
if connector.invokeSync?
|
||||
HB.setInvokeSyncHandler connector.invokeSync
|
||||
|
||||
execution_listener.push send_
|
||||
# For the XMPPConnector: lets send it as an array
|
||||
# therefore, we have to restructure it later
|
||||
@@ -43,6 +46,5 @@ adaptConnector = (connector, engine, HB, execution_listener)->
|
||||
if op.uid.creator isnt HB.getUserId()
|
||||
engine.applyOp op
|
||||
|
||||
HB.setInvokeSyncHandler connector.invokeSync
|
||||
|
||||
module.exports = adaptConnector
|
||||
@@ -273,18 +273,18 @@ module.exports = (HB)->
|
||||
if o?
|
||||
@deleted_by.push o
|
||||
garbagecollect = false
|
||||
if not (@prev_cl? and @next_cl?) or @prev_cl.isDeleted()
|
||||
if @next_cl.isDeleted()
|
||||
garbagecollect = true
|
||||
super garbagecollect
|
||||
if callLater
|
||||
@callOperationSpecificDeleteEvents(o)
|
||||
if @next_cl?.isDeleted()
|
||||
# garbage collect next_cl
|
||||
@next_cl.applyDelete()
|
||||
if @prev_cl?.isDeleted()
|
||||
# garbage collect prev_cl
|
||||
@prev_cl.applyDelete()
|
||||
|
||||
cleanup: ()->
|
||||
# TODO: Debugging
|
||||
if @prev_cl?.isDeleted()
|
||||
if @next_cl?.isDeleted()
|
||||
# delete all ops that delete this insertion
|
||||
for d in @deleted_by
|
||||
d.cleanup()
|
||||
@@ -300,7 +300,8 @@ module.exports = (HB)->
|
||||
@prev_cl.next_cl = @next_cl
|
||||
@next_cl.prev_cl = @prev_cl
|
||||
super
|
||||
|
||||
else if @next_cl? and @prev_cl?
|
||||
throw new Error "This insertion was not supposed to be deleted!"
|
||||
|
||||
#
|
||||
# @private
|
||||
|
||||
@@ -343,12 +343,13 @@ module.exports = (HB)->
|
||||
# @param {ReplaceManager} parent Used to replace this Replaceable with another one.
|
||||
# @param {Object} uid A unique identifier. If uid is undefined, a new uid will be created.
|
||||
#
|
||||
constructor: (content, parent, uid, prev, next, origin)->
|
||||
constructor: (content, parent, uid, prev, next, origin, is_deleted)->
|
||||
@saveOperation 'content', content
|
||||
@saveOperation 'parent', parent
|
||||
if not (prev? and next?)
|
||||
throw new Error "You must define prev, and next for Replaceable-types!"
|
||||
super uid, prev, next, origin
|
||||
@is_deleted = is_deleted
|
||||
|
||||
type: "Replaceable"
|
||||
|
||||
@@ -379,12 +380,13 @@ module.exports = (HB)->
|
||||
callOperationSpecificInsertEvents: ()->
|
||||
if @next_cl.type is "Delimiter" and @prev_cl.type isnt "Delimiter"
|
||||
# this replaces another Replaceable
|
||||
old_value = @prev_cl.content
|
||||
@parent.callEventDecorator [
|
||||
type: "update"
|
||||
changedBy: @uid.creator
|
||||
oldValue: old_value
|
||||
]
|
||||
if not @is_deleted # When this is received from the HB, this could already be deleted!
|
||||
old_value = @prev_cl.content
|
||||
@parent.callEventDecorator [
|
||||
type: "update"
|
||||
changedBy: @uid.creator
|
||||
oldValue: old_value
|
||||
]
|
||||
@prev_cl.applyDelete()
|
||||
else if @next_cl.type isnt "Delimiter"
|
||||
# This won't be recognized by the user, because another
|
||||
@@ -417,6 +419,7 @@ module.exports = (HB)->
|
||||
'prev': @prev_cl.getUid()
|
||||
'next': @next_cl.getUid()
|
||||
'uid' : @getUid()
|
||||
'is_deleted': @is_deleted
|
||||
}
|
||||
if @origin? and @origin isnt @prev_cl
|
||||
json["origin"] = @origin.getUid()
|
||||
@@ -430,8 +433,9 @@ module.exports = (HB)->
|
||||
'prev': prev
|
||||
'next': next
|
||||
'origin' : origin
|
||||
'is_deleted': is_deleted
|
||||
} = json
|
||||
new Replaceable content, parent, uid, prev, next, origin
|
||||
new Replaceable content, parent, uid, prev, next, origin, is_deleted
|
||||
|
||||
types['ListManager'] = ListManager
|
||||
types['MapManager'] = MapManager
|
||||
|
||||
@@ -124,10 +124,6 @@ module.exports = (HB)->
|
||||
type: "WordType"
|
||||
|
||||
applyDelete: ()->
|
||||
for textfield in @textfields
|
||||
textfield.onkeypress = null
|
||||
textfield.onpaste = null
|
||||
textfield.oncut = null
|
||||
o = @beginning
|
||||
while o?
|
||||
o.applyDelete()
|
||||
@@ -141,9 +137,10 @@ module.exports = (HB)->
|
||||
@insertAfter @end.prev_cl, content
|
||||
|
||||
insertAfter: (left, content)->
|
||||
while left.isDeleted()
|
||||
left = left.prev_cl # find the first character to the left, that is not deleted. Case position is 0, its the Delimiter.
|
||||
right = left.next_cl
|
||||
while right.isDeleted()
|
||||
right = right.next_cl # find the first character to the right, that is not deleted. In the case that position is 0, its the Delimiter.
|
||||
left = right.prev_cl
|
||||
if content.type?
|
||||
(new TextInsert content, undefined, left, right).execute()
|
||||
else
|
||||
@@ -243,6 +240,10 @@ module.exports = (HB)->
|
||||
|
||||
# consume all text-insert changes.
|
||||
textfield.onkeypress = (event)->
|
||||
if word.is_deleted
|
||||
# if word is deleted, do not do anything ever again
|
||||
textfield.onkeypress = null
|
||||
return true
|
||||
char = null
|
||||
if event.key?
|
||||
if event.charCode is 32
|
||||
@@ -265,8 +266,16 @@ module.exports = (HB)->
|
||||
event.preventDefault()
|
||||
|
||||
textfield.onpaste = (event)->
|
||||
if word.is_deleted
|
||||
# if word is deleted, do not do anything ever again
|
||||
textfield.onpaste = null
|
||||
return true
|
||||
event.preventDefault()
|
||||
textfield.oncut = (event)->
|
||||
if word.is_deleted
|
||||
# if word is deleted, do not do anything ever again
|
||||
textfield.oncut = null
|
||||
return true
|
||||
event.preventDefault()
|
||||
|
||||
#
|
||||
@@ -277,6 +286,10 @@ module.exports = (HB)->
|
||||
# Every browser supports keyCode. Let's stick with it for now..
|
||||
#
|
||||
textfield.onkeydown = (event)->
|
||||
if word.is_deleted
|
||||
# if word is deleted, do not do anything ever again
|
||||
textfield.onkeydown = null
|
||||
return true
|
||||
pos = Math.min textfield.selectionStart, textfield.selectionEnd
|
||||
diff = Math.abs(textfield.selectionEnd - textfield.selectionStart)
|
||||
if event.keyCode? and event.keyCode is 8 # Backspace
|
||||
|
||||
Reference in New Issue
Block a user