| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * @fileoverview Class which allows construction of annotated strings. | 6 * @fileoverview Class which allows construction of annotated strings. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 goog.provide('Spannable'); | 9 goog.provide('Spannable'); |
| 10 | 10 |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 | 421 |
| 422 // Helpers for implementing the various |get*| methods of |Spannable|. | 422 // Helpers for implementing the various |get*| methods of |Spannable|. |
| 423 | 423 |
| 424 /** | 424 /** |
| 425 * @param {Function} constructor | 425 * @param {Function} constructor |
| 426 * @return {function(SpanStruct): boolean} | 426 * @return {function(SpanStruct): boolean} |
| 427 */ | 427 */ |
| 428 function spanInstanceOf(constructor) { | 428 function spanInstanceOf(constructor) { |
| 429 return function(span) { | 429 return function(span) { |
| 430 return span.value instanceof constructor; | 430 return span.value instanceof constructor; |
| 431 } | 431 }; |
| 432 } | 432 } |
| 433 | 433 |
| 434 /** | 434 /** |
| 435 * @param {number} position | 435 * @param {number} position |
| 436 * @return {function(SpanStruct): boolean} | 436 * @return {function(SpanStruct): boolean} |
| 437 */ | 437 */ |
| 438 function spanCoversPosition(position) { | 438 function spanCoversPosition(position) { |
| 439 return function(span) { | 439 return function(span) { |
| 440 return span.start <= position && position < span.end; | 440 return span.start <= position && position < span.end; |
| 441 } | 441 }; |
| 442 } | 442 } |
| 443 | 443 |
| 444 /** | 444 /** |
| 445 * @param {*} value | 445 * @param {*} value |
| 446 * @return {function(SpanStruct): boolean} | 446 * @return {function(SpanStruct): boolean} |
| 447 */ | 447 */ |
| 448 function spanValueIs(value) { | 448 function spanValueIs(value) { |
| 449 return function(span) { | 449 return function(span) { |
| 450 return span.value === value; | 450 return span.value === value; |
| 451 } | 451 }; |
| 452 } | 452 } |
| 453 | 453 |
| 454 /** | 454 /** |
| 455 * @param {!SpanStruct|undefined} span | 455 * @param {!SpanStruct|undefined} span |
| 456 * @return {*} | 456 * @return {*} |
| 457 */ | 457 */ |
| 458 function valueOfSpan(span) { | 458 function valueOfSpan(span) { |
| 459 return span ? span.value : undefined; | 459 return span ? span.value : undefined; |
| 460 } | 460 } |
| 461 | 461 |
| 462 }); | 462 }); |
| OLD | NEW |