nddelima    2004/08/04 13:24:13

  Modified:    java/src/org/apache/xerces/dom RangeImpl.java
  Log:
  DOM Ranges Fix:  If one boundary-point of a Range is set to have a root container 
other than the current one for the Range, the Range should be collapsed to the new 
position.
  This enforces the restriction that both boundary-points of a Range must have the 
same root container.
  
  Revision  Changes    Path
  1.30      +46 -2     xml-xerces/java/src/org/apache/xerces/dom/RangeImpl.java
  
  Index: RangeImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/dom/RangeImpl.java,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- RangeImpl.java    24 Feb 2004 23:23:17 -0000      1.29
  +++ RangeImpl.java    4 Aug 2004 20:24:13 -0000       1.30
  @@ -173,6 +173,13 @@
           
           fStartContainer = refNode;
           fStartOffset = offset;
  +        
  +        // If one boundary-point of a Range is set to have a root container other
  +        // than the current one for the Range, the Range should be collapsed to
  +        // the new position.
  +         if (getCommonAncestorContainer() == null ) {
  +             collapse(true);
  +         }  
       }
       
       public void setEnd(Node refNode, int offset)
  @@ -198,6 +205,14 @@
           
           fEndContainer = refNode;
           fEndOffset = offset;
  +        
  +        // If one boundary-point of a Range is set to have a root container other
  +        // than the current one for the Range, the Range should be collapsed to
  +        // the new position.
  +         if (getCommonAncestorContainer() == null ) {
  +             collapse(true);
  +         }  
  +
       }
   
       public void setStartBefore(Node refNode) 
  @@ -226,6 +241,13 @@
               i++;
           }
           fStartOffset = i-1;
  +        
  +        // If one boundary-point of a Range is set to have a root container other
  +        // than the current one for the Range, the Range should be collapsed to
  +        // the new position.
  +         if (getCommonAncestorContainer() == null ) {
  +             collapse(true);
  +         }  
       }
       
       public void setStartAfter(Node refNode)
  @@ -253,6 +275,13 @@
               i++;
           }
           fStartOffset = i;
  +        
  +        // If one boundary-point of a Range is set to have a root container other
  +        // than the current one for the Range, the Range should be collapsed to
  +        // the new position.
  +         if (getCommonAncestorContainer() == null ) {
  +             collapse(true);
  +         }  
       }
       
       public void setEndBefore(Node refNode)
  @@ -280,6 +309,13 @@
               i++;
           }
           fEndOffset = i-1;
  +
  +        // If one boundary-point of a Range is set to have a root container other
  +        // than the current one for the Range, the Range should be collapsed to
  +        // the new position.
  +         if (getCommonAncestorContainer() == null ) {
  +             collapse(false);
  +         }    
       }
                                               
       public void setEndAfter(Node refNode)
  @@ -307,6 +343,13 @@
               i++;
           }
           fEndOffset = i;
  +        
  +       // If one boundary-point of a Range is set to have a root container other
  +       // than the current one for the Range, the Range should be collapsed to
  +       // the new position.
  +        if (getCommonAncestorContainer() == null ) {
  +            collapse(false);
  +        }                
       }
       
       public void collapse(boolean toStart) {
  @@ -669,6 +712,7 @@
           Range range = fDocument.createRange();
           range.setStart(fStartContainer, fStartOffset);
           range.setEnd(fEndContainer, fEndOffset);
  +        //System.out.println ("Clone Range " + fStartOffset);
           return range;
       }
       
  @@ -678,7 +722,7 @@
                DOMException.INVALID_STATE_ERR, 
                   DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, 
"INVALID_STATE_ERR", null));
        }
  -     
  +
        Node node = fStartContainer;
           Node stopNode = fEndContainer;
        StringBuffer sb = new StringBuffer();
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to