/*
Copyright 2012, KISSY UI Library v1.30rc
MIT Licensed
build time: Jul 11 21:28
*/
KISSY.add("editor/core/walker",function(i,m){function g(a,c){if(this._.end)return j;var b,d=this.range,f,i=this.guard,g=this.type,l=a?"_4e_previousSourceNode":"_4e_nextSourceNode";if(!this._.start&&(this._.start=1,d.trim(),d.collapsed))return this.end(),j;if(!a&&!this._.guardLTR){var m=d.endContainer[0],o=m.childNodes[d.endOffset];this._.guardLTR=function(a,b){return b&&(m==a||"body"==h.nodeName(a))?!1:a!=o}}if(a&&!this._.guardRTL){var n=d.startContainer[0],q=0<d.startOffset&&n.childNodes[d.startOffset-
1]||null;this._.guardRTL=function(a,b){return b&&(n==a||"body"==h.nodeName(a))?!1:a!=q}}var r=a?this._.guardRTL:this._.guardLTR;f=i?function(a,b){return r(a,b)===e?e:i(a,b)}:r;this.current?b=this.current[l](e,g,f):a?(b=d.endContainer,0<d.endOffset?(b=new p(b[0].childNodes[d.endOffset-1]),f(b[0])===e&&(b=j)):b=f(b,k)===e?j:b._4e_previousSourceNode(k,g,f,void 0)):(b=d.startContainer,b=new p(b[0].childNodes[d.startOffset]),b.length?f(b[0])===e&&(b=j):b=f(d.startContainer,k)===e?j:d.startContainer._4e_nextSourceNode(k,
g,f,void 0));for(;b&&!this._.end;){this.current=b;if(!this.evaluator||this.evaluator(b[0])!==e){if(!c)return b}else if(c&&this.evaluator)return e;b=b[l](e,g,f)}this.end();return this.current=j}function o(a){for(var c,b=j;c=g.call(this,a);)b=c;return b}function l(a){this.range=a;this.guard=this.evaluator=j;this._={}}var k=!0,e=!1,j=null,q=i.UA,h=i.DOM,n=m.XHTML_DTD,p=i.Node;i.augment(l,{end:function(){this._.end=1},next:function(){return g.call(this)},previous:function(){return g.call(this,k)},checkForward:function(){return g.call(this,
e,k)!==e},checkBackward:function(){return g.call(this,k,k)!==e},lastForward:function(){return o.call(this)},lastBackward:function(){return o.call(this,k)},reset:function(){delete this.current;this._={}},_iterator:g});i.mix(l,{blockBoundary:function(a){return function(c){return!(c.nodeType==h.ELEMENT_NODE&&h._4e_isBlockBoundary(c,a))}},bookmark:function(a,c){function b(a){return"span"==h.nodeName(a)&&h.attr(a,"_ke_bookmark")}return function(d){var f,e;f=d.nodeType==h.TEXT_NODE&&(e=d.parentNode)&&b(e);
f=a?f:f||b(d);return!!(c^f)}},whitespaces:function(a){return function(c){c=c.nodeType==h.TEXT_NODE&&!i.trim(c.nodeValue);return!!(a^c)}},invisible:function(a){var c=l.whitespaces();return function(b){b=c(b)||b.nodeType==h.ELEMENT_NODE&&!b.offsetHeight;return!!(a^b)}}});var s=/^[\t\r\n ]*(?:&nbsp;|\xa0)$/,t=l.whitespaces(),u=l.bookmark(),v=function(a){var c=h.nodeName(a);return u(a)||t(a)||1==a.nodeType&&c in n.$inline&&!(c in n.$empty)};m.Utils.injectDom({_4e_getBogus:function(a){a=new p(a);do a=
a._4e_previousSourceNode();while(a&&v(a[0]));return a&&(!q.ie?"br"==a.nodeName():3==a[0].nodeType&&s.test(a.text()))?a[0]:!1}});return m.Walker=l},{requires:["./base","./utils","./dom"]});
