chrome-extension/js/foreground.js
function getFixedParent(target){
            var documentElement = document.documentElement;
            var node = target;
            var nodeName, path, offset, left, top, savedParent;
            var notFirstNode = false; // 当前点击控件以可见范围内进行定位，其它以全局定位（很多局部控件是不可见的）
            while(node !== null){
                nodeName = node.nodeName.toLowerCase();
                if(nodeName !== '#document-fragment'){
                    path = getDomPath(node, notFirstNode);
                    if(path === null){
                        break;
                    }
                    offset = node.getBoundingClientRect();
                    left = parseInt(offset.left, 10);
                    top = parseInt(offset.top, 10);
                    savedParent = mapParentsOffset[path];
                    if(savedParent && left === savedParent.left && top === savedParent.top){
                        return {
                            path: path,
                            left: left,
                            top: top
                        };
                    }
                }
                if(nodeName === 'html'){
                    node = null;
                }
                else{
                    node = node.parentNode;
                }
                notFirstNode = true;
            }
            path = getDomPath(target);
            if(path !== null){
                offset = target.getBoundingClientRect();
                return {
                    path: path,
                    left: offset.left,
                    top: offset.top
                };
            }
            else{
                return null;
            }
        }
function getFixedParent(target){
            var documentElement = document.documentElement;
            var node = target;
            var nodeName, path, offset, left, top, savedParent;
            var notFirstNode = false; // 当前点击控件以可见范围内进行定位，其它以全局定位（很多局部控件是不可见的）
            while(node !== null){
                nodeName = node.nodeName.toLowerCase();
                if(nodeName !== '#document-fragment'){
                    path = getDomPath(node, notFirstNode);
                    if(path === null){
                        break;
                    }
                    offset = node.getBoundingClientRect();
                    left = parseInt(offset.left, 10);
                    top = parseInt(offset.top, 10);
                    savedParent = mapParentsOffset[path];
                    if(savedParent && left === savedParent.left && top === savedParent.top){
                        return {
                            path: path,
                            left: left,
                            top: top
                        };
                    }
                }
                if(nodeName === 'html'){
                    node = null;
                }
                else{
                    node = node.parentNode;
                }
                notFirstNode = true;
            }
            path = getDomPath(target);
            if(path !== null){
                offset = target.getBoundingClientRect();
                return {
                    path: path,
                    left: offset.left,
                    top: offset.top
                };
            }
            else{
                return null;
            }
        }
function getFixedParent ( target ) { var documentElement = document . documentElement ; var node = target ; var nodeName , path , offset , left , top , savedParent ; var notFirstNode = false ; // 当前点击控件以可见范围内进行定位，其它以全局定位（很多局部控件是不可见的） while ( node !== null ) { nodeName = node . nodeName . toLowerCase ( ) ; if ( nodeName !== '#document-fragment' ) { path = getDomPath ( node , notFirstNode ) ; if ( path === null ) { break ; } offset = node . getBoundingClientRect ( ) ; left = parseInt ( offset . left , 10 ) ; top = parseInt ( offset . top , 10 ) ; savedParent = mapParentsOffset [ path ] ; if ( savedParent && left === savedParent . left && top === savedParent . top ) { return { path : path , left : left , top : top } ; } } if ( nodeName === 'html' ) { node = null ; } else { node = node . parentNode ; } notFirstNode = true ; } path = getDomPath ( target ) ; if ( path !== null ) { offset = target . getBoundingClientRect ( ) ; return { path : path , left : offset . left , top : offset . top } ; } else { return null ; } }
get the fixed offset parent
get the fixed offset parent