[MediaWiki-commits] [Gerrit] Fix contextChange events from annotations - change (VisualEditor/VisualEditor)

2014-10-17 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged.

Change subject: Fix contextChange events from annotations
..


Fix contextChange events from annotations

'contextChange' should be emitted whenever the covered annotations
change, not just insertion annotations.

Bug: 72152
Change-Id: I6b680a7e6e2992764b59bfdce53ae99c3b5deb1d
---
M src/dm/ve.dm.Surface.js
M src/ui/ve.ui.DesktopContext.js
2 files changed, 10 insertions(+), 7 deletions(-)

Approvals:
  Catrope: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/src/dm/ve.dm.Surface.js b/src/dm/ve.dm.Surface.js
index 3cb65c2..9a31ef7 100644
--- a/src/dm/ve.dm.Surface.js
+++ b/src/dm/ve.dm.Surface.js
@@ -31,6 +31,7 @@
this.undoIndex = 0;
this.historyTrackingInterval = null;
this.insertionAnnotations = new ve.dm.AnnotationSet( 
this.getDocument().getStore() );
+   this.coveredAnnotations = new ve.dm.AnnotationSet( 
this.getDocument().getStore() );
this.enabled = true;
this.transacting = false;
this.queueingContextChanges = false;
@@ -572,7 +573,7 @@
  */
 ve.dm.Surface.prototype.setSelection = function ( selection ) {
var left, right, leftAnnotations, rightAnnotations, 
insertionAnnotations,
-   startNode, selectedNode, range,
+   startNode, selectedNode, range, coveredAnnotations,
branchNodes = {},
oldSelection = this.selection,
oldBranchNodes = this.branchNodes,
@@ -603,6 +604,8 @@
branchNodes.start = this.getDocument().getBranchNodeFromOffset( 
range.start );
if ( !range.isCollapsed() ) {
branchNodes.end = 
this.getDocument().getBranchNodeFromOffset( range.end );
+   } else {
+   branchNodes.end = branchNodes.start;
}
// Update selected node
if ( !range.isCollapsed() ) {
@@ -623,10 +626,12 @@
if ( !linearData.isContentOffset( right ) ) {
right = -1;
}
+   coveredAnnotations = 
linearData.getAnnotationsFromOffset( range.start );
} else {
// Get annotations from the first character of the range
left = linearData.getNearestContentOffset( range.start 
);
right = linearData.getNearestContentOffset( range.end );
+   coveredAnnotations = 
linearData.getAnnotationsFromRange( range );
}
if ( left === -1 ) {
// No content offset to our left, use empty set
@@ -647,11 +652,11 @@
}
 
// Only emit an annotations change event if there's a 
meaningful difference
-   if (
-   !insertionAnnotations.containsAllOf( 
this.insertionAnnotations ) ||
-   !this.insertionAnnotations.containsAllOf( 
insertionAnnotations )
-   ) {
+   if ( !insertionAnnotations.compareTo( this.insertionAnnotations 
) ) {
this.setInsertionAnnotations( insertionAnnotations );
+   }
+   if ( !coveredAnnotations.compareTo( this.coveredAnnotations ) ) 
{
+   this.coveredAnnotations = coveredAnnotations;
contextChange = true;
}
}
diff --git a/src/ui/ve.ui.DesktopContext.js b/src/ui/ve.ui.DesktopContext.js
index b79e180..7cdef35 100644
--- a/src/ui/ve.ui.DesktopContext.js
+++ b/src/ui/ve.ui.DesktopContext.js
@@ -27,8 +27,6 @@
 
// Events
this.surface.getView().connect( this, {
-   selectionStart: 'onSuppress',
-   selectionEnd: 'onUnsuppress',
relocationStart: 'onSuppress',
relocationEnd: 'onUnsuppress',
blur: 'onSuppress',

-- 
To view, visit https://gerrit.wikimedia.org/r/167217
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I6b680a7e6e2992764b59bfdce53ae99c3b5deb1d
Gerrit-PatchSet: 3
Gerrit-Project: VisualEditor/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Esanders 
Gerrit-Reviewer: Catrope 
Gerrit-Reviewer: Esanders 
Gerrit-Reviewer: jenkins-bot <>

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Fix contextChange events from annotations - change (VisualEditor/VisualEditor)

2014-10-17 Thread Esanders (Code Review)
Esanders has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/167217

Change subject: Fix contextChange events from annotations
..

Fix contextChange events from annotations

contextChange should be emitted whenever the covered annotations
change, not just insertion annotations.

Bug: 72152

Change-Id: I6b680a7e6e2992764b59bfdce53ae99c3b5deb1d
---
M src/dm/ve.dm.Surface.js
M src/ui/ve.ui.DesktopContext.js
2 files changed, 10 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/VisualEditor/VisualEditor 
refs/changes/17/167217/1

diff --git a/src/dm/ve.dm.Surface.js b/src/dm/ve.dm.Surface.js
index 3cb65c2..9a31ef7 100644
--- a/src/dm/ve.dm.Surface.js
+++ b/src/dm/ve.dm.Surface.js
@@ -31,6 +31,7 @@
this.undoIndex = 0;
this.historyTrackingInterval = null;
this.insertionAnnotations = new ve.dm.AnnotationSet( 
this.getDocument().getStore() );
+   this.coveredAnnotations = new ve.dm.AnnotationSet( 
this.getDocument().getStore() );
this.enabled = true;
this.transacting = false;
this.queueingContextChanges = false;
@@ -572,7 +573,7 @@
  */
 ve.dm.Surface.prototype.setSelection = function ( selection ) {
var left, right, leftAnnotations, rightAnnotations, 
insertionAnnotations,
-   startNode, selectedNode, range,
+   startNode, selectedNode, range, coveredAnnotations,
branchNodes = {},
oldSelection = this.selection,
oldBranchNodes = this.branchNodes,
@@ -603,6 +604,8 @@
branchNodes.start = this.getDocument().getBranchNodeFromOffset( 
range.start );
if ( !range.isCollapsed() ) {
branchNodes.end = 
this.getDocument().getBranchNodeFromOffset( range.end );
+   } else {
+   branchNodes.end = branchNodes.start;
}
// Update selected node
if ( !range.isCollapsed() ) {
@@ -623,10 +626,12 @@
if ( !linearData.isContentOffset( right ) ) {
right = -1;
}
+   coveredAnnotations = 
linearData.getAnnotationsFromOffset( range.start );
} else {
// Get annotations from the first character of the range
left = linearData.getNearestContentOffset( range.start 
);
right = linearData.getNearestContentOffset( range.end );
+   coveredAnnotations = 
linearData.getAnnotationsFromRange( range );
}
if ( left === -1 ) {
// No content offset to our left, use empty set
@@ -647,11 +652,11 @@
}
 
// Only emit an annotations change event if there's a 
meaningful difference
-   if (
-   !insertionAnnotations.containsAllOf( 
this.insertionAnnotations ) ||
-   !this.insertionAnnotations.containsAllOf( 
insertionAnnotations )
-   ) {
+   if ( !insertionAnnotations.compareTo( this.insertionAnnotations 
) ) {
this.setInsertionAnnotations( insertionAnnotations );
+   }
+   if ( !coveredAnnotations.compareTo( this.coveredAnnotations ) ) 
{
+   this.coveredAnnotations = coveredAnnotations;
contextChange = true;
}
}
diff --git a/src/ui/ve.ui.DesktopContext.js b/src/ui/ve.ui.DesktopContext.js
index b79e180..7cdef35 100644
--- a/src/ui/ve.ui.DesktopContext.js
+++ b/src/ui/ve.ui.DesktopContext.js
@@ -27,8 +27,6 @@
 
// Events
this.surface.getView().connect( this, {
-   selectionStart: 'onSuppress',
-   selectionEnd: 'onUnsuppress',
relocationStart: 'onSuppress',
relocationEnd: 'onUnsuppress',
blur: 'onSuppress',

-- 
To view, visit https://gerrit.wikimedia.org/r/167217
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6b680a7e6e2992764b59bfdce53ae99c3b5deb1d
Gerrit-PatchSet: 1
Gerrit-Project: VisualEditor/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Esanders 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits