Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 312 headElement = this._headSelection.node; | 312 headElement = this._headSelection.node; |
| 313 headOffset = this._headSelection.offset; | 313 headOffset = this._headSelection.offset; |
| 314 } else { | 314 } else { |
| 315 if (this._headSelection.item < this._firstVisibleIndex) | 315 if (this._headSelection.item < this._firstVisibleIndex) |
| 316 headElement = this._topGapElement; | 316 headElement = this._topGapElement; |
| 317 else if (this._headSelection.item > this._lastVisibleIndex) | 317 else if (this._headSelection.item > this._lastVisibleIndex) |
| 318 headElement = this._bottomGapElement; | 318 headElement = this._bottomGapElement; |
| 319 headOffset = this._selectionIsBackward ? 0 : 1; | 319 headOffset = this._selectionIsBackward ? 0 : 1; |
| 320 } | 320 } |
| 321 | 321 |
| 322 selection.setBaseAndExtent(anchorElement, anchorOffset, headElement, hea dOffset); | 322 selection.setBaseAndExtent(anchorElement || null, anchorOffset, headElem ent || null, headOffset); |
|
lushnikov
2014/06/17 08:15:36
Can't we initialize anchorElement and headElement
apavlov
2014/06/17 08:27:18
Done.
| |
| 323 }, | 323 }, |
| 324 | 324 |
| 325 refresh: function() | 325 refresh: function() |
| 326 { | 326 { |
| 327 if (!this.element.clientHeight) | 327 if (!this.element.clientHeight) |
| 328 return; // Do nothing for invisible controls. | 328 return; // Do nothing for invisible controls. |
| 329 | 329 |
| 330 var itemCount = this._provider.itemCount(); | 330 var itemCount = this._provider.itemCount(); |
| 331 if (!itemCount) { | 331 if (!itemCount) { |
| 332 for (var i = 0; i < this._renderedItems.length; ++i) | 332 for (var i = 0; i < this._renderedItems.length; ++i) |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 432 * @param {!Node} container | 432 * @param {!Node} container |
| 433 * @param {number} offset | 433 * @param {number} offset |
| 434 * @return {number} | 434 * @return {number} |
| 435 */ | 435 */ |
| 436 _textOffsetInNode: function(itemElement, container, offset) | 436 _textOffsetInNode: function(itemElement, container, offset) |
| 437 { | 437 { |
| 438 if (!offset) | 438 if (!offset) |
| 439 return 0; | 439 return 0; |
| 440 var chars = 0; | 440 var chars = 0; |
| 441 var node = itemElement; | 441 var node = itemElement; |
| 442 while ((node = node.traverseNextTextNode(true)) && node !== container) | 442 while ((node = node.traverseNextTextNode()) && node !== container) |
| 443 chars += node.textContent.length; | 443 chars += node.textContent.length; |
| 444 return chars + offset; | 444 return chars + offset; |
| 445 }, | 445 }, |
| 446 | 446 |
| 447 /** | 447 /** |
| 448 * @param {?Event} event | 448 * @param {?Event} event |
| 449 */ | 449 */ |
| 450 _onScroll: function(event) | 450 _onScroll: function(event) |
| 451 { | 451 { |
| 452 this.refresh(); | 452 this.refresh(); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 505 | 505 |
| 506 /** | 506 /** |
| 507 * @param {number} index | 507 * @param {number} index |
| 508 */ | 508 */ |
| 509 forceScrollItemToBeLast: function(index) | 509 forceScrollItemToBeLast: function(index) |
| 510 { | 510 { |
| 511 this._rebuildCumulativeHeightsIfNeeded(); | 511 this._rebuildCumulativeHeightsIfNeeded(); |
| 512 this.element.scrollTop = this._cumulativeHeights[index] - this.element.c lientHeight; | 512 this.element.scrollTop = this._cumulativeHeights[index] - this.element.c lientHeight; |
| 513 } | 513 } |
| 514 } | 514 } |
| OLD | NEW |