Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(516)

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/custom/V8WindowCustom.cpp

Issue 2697353002: Measure usage of JavaScript variables created from named elements. (Closed)
Patch Set: rebase Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/frame/UseCounter.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/frame/UseCounter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698