| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2005, 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2005, 2007, 2008 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2011 Google Inc. All rights reserved. | 3 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 | 59 |
| 60 using namespace blink; | 60 using namespace blink; |
| 61 | 61 |
| 62 static NSAttributedString* attributedSubstringFromRange(const Range* range) | 62 static NSAttributedString* attributedSubstringFromRange(const Range* range) |
| 63 { | 63 { |
| 64 NSMutableAttributedString* string = [[NSMutableAttributedString alloc] init]
; | 64 NSMutableAttributedString* string = [[NSMutableAttributedString alloc] init]
; |
| 65 NSMutableDictionary* attrs = [NSMutableDictionary dictionary]; | 65 NSMutableDictionary* attrs = [NSMutableDictionary dictionary]; |
| 66 size_t length = range->endOffset() - range->startOffset(); | 66 size_t length = range->endOffset() - range->startOffset(); |
| 67 | 67 |
| 68 unsigned position = 0; | 68 unsigned position = 0; |
| 69 for (TextIterator it(range); !it.atEnd() && [string length] < length; it.adv
ance()) { | 69 for (TextIterator it(range->startPosition(), range->endPosition()); !it.atEn
d() && [string length] < length; it.advance()) { |
| 70 unsigned numCharacters = it.length(); | 70 unsigned numCharacters = it.length(); |
| 71 if (!numCharacters) | 71 if (!numCharacters) |
| 72 continue; | 72 continue; |
| 73 | 73 |
| 74 Node* container = it.startContainer(); | 74 Node* container = it.startContainer(); |
| 75 LayoutObject* renderer = container->layoutObject(); | 75 LayoutObject* renderer = container->layoutObject(); |
| 76 ASSERT(renderer); | 76 ASSERT(renderer); |
| 77 if (!renderer) | 77 if (!renderer) |
| 78 continue; | 78 continue; |
| 79 | 79 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 if (!editable) | 159 if (!editable) |
| 160 return nil; | 160 return nil; |
| 161 RefPtrWillBeRawPtr<Range> range(PlainTextRange(location, location + length).
createRange(*editable)); | 161 RefPtrWillBeRawPtr<Range> range(PlainTextRange(location, location + length).
createRange(*editable)); |
| 162 if (!range) | 162 if (!range) |
| 163 return nil; | 163 return nil; |
| 164 | 164 |
| 165 return attributedSubstringFromRange(range.get()); | 165 return attributedSubstringFromRange(range.get()); |
| 166 } | 166 } |
| 167 | 167 |
| 168 } // namespace blink | 168 } // namespace blink |
| OLD | NEW |