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

Side by Side Diff: Source/devtools/front_end/ui/ViewportControl.js

Issue 727823002: [DevTools] Ban getSelection, requestAnimationFrame, cancelAnimationFrame global functions. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 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 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 this._renderedItems[i].willHide(); 371 this._renderedItems[i].willHide();
372 this._renderedItems = []; 372 this._renderedItems = [];
373 this._contentElement.removeChildren(); 373 this._contentElement.removeChildren();
374 this._topGapElement.style.height = "0px"; 374 this._topGapElement.style.height = "0px";
375 this._bottomGapElement.style.height = "0px"; 375 this._bottomGapElement.style.height = "0px";
376 this._firstVisibleIndex = -1; 376 this._firstVisibleIndex = -1;
377 this._lastVisibleIndex = -1; 377 this._lastVisibleIndex = -1;
378 return; 378 return;
379 } 379 }
380 380
381 var selection = window.getSelection(); 381 var selection = this.element.window().getSelection();
382 var shouldRestoreSelection = this._updateSelectionModel(selection); 382 var shouldRestoreSelection = this._updateSelectionModel(selection);
383 383
384 var visibleFrom = this.element.scrollTop; 384 var visibleFrom = this.element.scrollTop;
385 var visibleHeight = this._visibleHeight(); 385 var visibleHeight = this._visibleHeight();
386 this._scrolledToBottom = this.element.isScrolledToBottom(); 386 this._scrolledToBottom = this.element.isScrolledToBottom();
387 var isInvalidating = !this._cumulativeHeights; 387 var isInvalidating = !this._cumulativeHeights;
388 388
389 if (this._cumulativeHeights && itemCount !== this._cumulativeHeights.len gth) 389 if (this._cumulativeHeights && itemCount !== this._cumulativeHeights.len gth)
390 delete this._cumulativeHeights; 390 delete this._cumulativeHeights;
391 for (var i = 0; i < this._renderedItems.length; ++i) { 391 for (var i = 0; i < this._renderedItems.length; ++i) {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 } 473 }
474 this._renderedItems.push(viewportElement); 474 this._renderedItems.push(viewportElement);
475 } 475 }
476 }, 476 },
477 477
478 /** 478 /**
479 * @return {?string} 479 * @return {?string}
480 */ 480 */
481 _selectedText: function() 481 _selectedText: function()
482 { 482 {
483 this._updateSelectionModel(window.getSelection()); 483 this._updateSelectionModel(this.element.window().getSelection());
484 if (!this._headSelection || !this._anchorSelection) 484 if (!this._headSelection || !this._anchorSelection)
485 return null; 485 return null;
486 486
487 var startSelection = null; 487 var startSelection = null;
488 var endSelection = null; 488 var endSelection = null;
489 if (this._selectionIsBackward) { 489 if (this._selectionIsBackward) {
490 startSelection = this._headSelection; 490 startSelection = this._headSelection;
491 endSelection = this._anchorSelection; 491 endSelection = this._anchorSelection;
492 } else { 492 } else {
493 startSelection = this._anchorSelection; 493 startSelection = this._anchorSelection;
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 602
603 /** 603 /**
604 * @return {number} 604 * @return {number}
605 */ 605 */
606 _visibleHeight: function() 606 _visibleHeight: function()
607 { 607 {
608 // Use offsetHeight instead of clientHeight to avoid being affected by h orizontal scroll. 608 // Use offsetHeight instead of clientHeight to avoid being affected by h orizontal scroll.
609 return this.element.offsetHeight; 609 return this.element.offsetHeight;
610 } 610 }
611 } 611 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698