Esanders has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/380538 )

Change subject: Allow focusable nodes to define an element to be their bounding 
box
......................................................................

Allow focusable nodes to define an element to be their bounding box

Set it to the full element for images.

Bug: T176646
Change-Id: Iea8001320f24d507a7aaa25ec079c747ad03ee83
---
M src/ce/nodes/ve.ce.ImageNode.js
M src/ce/ve.ce.FocusableNode.js
2 files changed, 10 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/VisualEditor/VisualEditor 
refs/changes/38/380538/1

diff --git a/src/ce/nodes/ve.ce.ImageNode.js b/src/ce/nodes/ve.ce.ImageNode.js
index d43b7a4..b00d2f6 100644
--- a/src/ce/nodes/ve.ce.ImageNode.js
+++ b/src/ce/nodes/ve.ce.ImageNode.js
@@ -20,7 +20,8 @@
 ve.ce.ImageNode = function VeCeImageNode( $figure, $image, config ) {
        config = ve.extendObject( {
                enforceMax: false,
-               minDimensions: { width: 1, height: 1 }
+               minDimensions: { width: 1, height: 1 },
+               $attachable: this.$element
        }, config );
 
        this.$figure = $figure;
diff --git a/src/ce/ve.ce.FocusableNode.js b/src/ce/ve.ce.FocusableNode.js
index c75ee99..21875f8 100644
--- a/src/ce/ve.ce.FocusableNode.js
+++ b/src/ce/ve.ce.FocusableNode.js
@@ -23,6 +23,7 @@
  * @constructor
  * @param {jQuery} [$focusable=this.$element] Primary element user is focusing 
on
  * @param {Object} [config] Configuration options
+ * @param {jQuery} [$bounding=$focusable] Element to consider for bounding box 
calculations (e.g. attaching inpsectors)
  * @cfg {string[]} [classes] CSS classes to be added to the highlight container
  */
 ve.ce.FocusableNode = function VeCeFocusableNode( $focusable, config ) {
@@ -34,6 +35,7 @@
        this.isFocusableSetup = false;
        this.$highlights = $( '<div>' ).addClass( 
've-ce-focusableNode-highlights' );
        this.$focusable = $focusable || this.$element;
+       this.$bounding = config.$bounding || this.$focusable;
        this.focusableSurface = null;
        this.rects = null;
        this.boundingRect = null;
@@ -752,6 +754,12 @@
  * @return {Object|null} Top, left, bottom & right positions of the focusable 
node relative to the surface
  */
 ve.ce.FocusableNode.prototype.getBoundingRect = function () {
+       var surfaceOffset, allRects;
+       if ( !this.$bounding.is( this.$focusable ) ) {
+               surfaceOffset = 
this.focusableSurface.getSurface().getBoundingClientRect();
+               allRects = this.constructor.static.getRectsForElement( 
this.$bounding, surfaceOffset );
+               return allRects.boundingRect;
+       }
        if ( !this.highlighted ) {
                this.calculateHighlights();
        }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iea8001320f24d507a7aaa25ec079c747ad03ee83
Gerrit-PatchSet: 1
Gerrit-Project: VisualEditor/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Esanders <esand...@wikimedia.org>

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

Reply via email to