/*
 * Copyright 2010 Google Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * 1. in IE6 IE7 IE8(Q) 'white-space' priority level : CSS property > nowrap attribute
 * 2. object.noWrap = true can't overlap effect of 'white-space' property that set by author,
 *    but it can overlap effect of 'white-space' property through setting by UA(normal) or nowrap attribute(nowrap).
 * 3. set object.noWrap to true or false only affect the 'white-space' property of DIV DD DT.
 */
addScriptToInject(function() {

chrome_comp.CompDetect.declareDetector(

'nowrap_attribute',

chrome_comp.CompDetect.ScanDomBaseDetector,

null, // constructor

/*
 * report problem if meeting one of the following 2 conditions:
 * 1. If element has nowrap attribute and computed value of 'white-space' property is not 'nowrap'
 *		1.1. Current element DOM object has not noWrap DOM attribute;
 *		1.2. element DOM object has noWrap DOM attribute and attribute value is excluding 
 *           false, 0, '', null, undefined, NaN etc.
 * 2. Author set elementDomObject.noWrap = true and not set 'white-space' property.
 *    This equals to only set nowrap attribute.
 */

function checkNode(node, context) {
  if(Node.ELEMENT_NODE != node.nodeType)
    return;
  var tagName = node.tagName;
  //if BODY has nowrap attribute, DIV and P can inherit from BODY and apply 'white-space : nowrap' in IE6 IE7 IE8(Q)
  //The page may has problem when only detecting BODY 
  if ((tagName != 'BODY' && tagName != 'DIV' && tagName != 'DT' && tagName != 'DD') || 
       context.isDisplayNone())
    return;
	
  var computedStyle = chrome_comp.getComputedStyle(node);
  var defStyle = chrome_comp.getDefinedStylePropertyByName(node, '', 'white-space');
	
	//main
  if ((node.hasAttribute('nowrap') && computedStyle.whiteSpace != 'nowrap' && 
      (!node.hasOwnProperty('noWrap') || node.noWrap)) || (node.noWrap && !defStyle) ){
    this.addProblem('HE1003', [node]);
  }
}
); // declareDetector

});

@@ -645,18 +645,24 @@
 ty level
- 
 :
+ %0A *   
  CSS pro
@@ -685,16 +685,17 @@
 ttribute
+.
 %0A * 2. o
@@ -761,16 +761,23 @@
 roperty 
+%0A *    
 that set
@@ -787,22 +787,16 @@
  author,
-%0A *   
  but it 
@@ -840,16 +840,23 @@
 roperty 
+%0A *    
 through 
@@ -969,32 +969,39 @@
 e 'white-space' 
+%0A *    
 property of DIV 
@@ -1305,32 +1305,39 @@
 f 'white-space' 
+%0A *    
 property is not 
@@ -1344,21 +1344,24 @@
 'nowrap'
+.
 %0A *
-%09%09
+    
 1.1. Cur
@@ -1420,10 +1420,12 @@
 ;%0A *
-%09%09
+    
 1.2.
@@ -1496,18 +1496,8 @@
  is 
-excluding 
 %0A * 
@@ -1504,17 +1504,25 @@
         
- 
+excluding
  false, 
@@ -1620,32 +1620,39 @@
 t 'white-space' 
+%0A *    
 property.%0A *    
@@ -1644,22 +1644,16 @@
 roperty.
-%0A *   
  This eq
@@ -1815,16 +1815,17 @@
 me;%0A  //
+ 
 if BODY 
@@ -1888,16 +1888,22 @@
 d apply 
+%0A  // 
 'white-s
@@ -1934,21 +1934,23 @@
 7 IE8(Q)
+.
 %0A  //
+ 
 The page
@@ -2055,24 +2055,31 @@
  != 'DT' && 
+%0A      
 tagName != '
@@ -2090,16 +2090,8 @@
  %7C%7C 
-%0A       
 cont
@@ -2123,17 +2123,16 @@
 return;%0A
-%09
 %0A  var c
@@ -2191,32 +2191,37 @@
  var defStyle = 
+%0A    
 chrome_comp.getD
@@ -2276,11 +2276,11 @@
 ');%0A
-%09%0A%09
+%0A  
 //ma
@@ -2419,16 +2419,23 @@
 ap)) %7C%7C 
+%0A      
 (node.no
@@ -2456,10 +2456,10 @@
 yle)
- 
 )
+ 
 %7B%0A  

improve code style.