| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009, 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2009, 2011 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 return; | 370 return; |
| 371 | 371 |
| 372 bool hasNamedItem = toHTMLDocument(doc)->hasNamedItem(name); | 372 bool hasNamedItem = toHTMLDocument(doc)->hasNamedItem(name); |
| 373 bool hasIdItem = doc->hasElementWithId(name); | 373 bool hasIdItem = doc->hasElementWithId(name); |
| 374 | 374 |
| 375 if (!hasNamedItem && !hasIdItem) | 375 if (!hasNamedItem && !hasIdItem) |
| 376 return; | 376 return; |
| 377 | 377 |
| 378 if (!hasNamedItem && hasIdItem && | 378 if (!hasNamedItem && hasIdItem && |
| 379 !doc->containsMultipleElementsWithId(name)) { | 379 !doc->containsMultipleElementsWithId(name)) { |
| 380 UseCounter::count(doc, UseCounter::DOMClobberedVariableAccessed); |
| 380 v8SetReturnValueFast(info, doc->getElementById(name), window); | 381 v8SetReturnValueFast(info, doc->getElementById(name), window); |
| 381 return; | 382 return; |
| 382 } | 383 } |
| 383 | 384 |
| 384 HTMLCollection* items = doc->windowNamedItems(name); | 385 HTMLCollection* items = doc->windowNamedItems(name); |
| 385 if (!items->isEmpty()) { | 386 if (!items->isEmpty()) { |
| 387 UseCounter::count(doc, UseCounter::DOMClobberedVariableAccessed); |
| 388 |
| 386 // TODO(esprehn): Firefox doesn't return an HTMLCollection here if there's | 389 // TODO(esprehn): Firefox doesn't return an HTMLCollection here if there's |
| 387 // multiple with the same name, but Chrome and Safari does. What's the | 390 // multiple with the same name, but Chrome and Safari does. What's the |
| 388 // right behavior? | 391 // right behavior? |
| 389 if (items->hasExactlyOneItem()) { | 392 if (items->hasExactlyOneItem()) { |
| 390 v8SetReturnValueFast(info, items->item(0), window); | 393 v8SetReturnValueFast(info, items->item(0), window); |
| 391 return; | 394 return; |
| 392 } | 395 } |
| 393 v8SetReturnValueFast(info, items, window); | 396 v8SetReturnValueFast(info, items, window); |
| 394 return; | 397 return; |
| 395 } | 398 } |
| 396 } | 399 } |
| 397 | 400 |
| 398 } // namespace blink | 401 } // namespace blink |
| OLD | NEW |