| 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 | 63 |
| 64 RefPtr<Range> range(TextIterator::rangeFromLocationAndLength(frame->selectio
n()->rootEditableElementOrDocumentElement(), location, length)); | 64 RefPtr<Range> range(TextIterator::rangeFromLocationAndLength(frame->selectio
n()->rootEditableElementOrDocumentElement(), location, length)); |
| 65 if (!range) | 65 if (!range) |
| 66 return nil; | 66 return nil; |
| 67 | 67 |
| 68 NSMutableAttributedString* string = [[NSMutableAttributedString alloc] init]
; | 68 NSMutableAttributedString* string = [[NSMutableAttributedString alloc] init]
; |
| 69 NSMutableDictionary* attrs = [NSMutableDictionary dictionary]; | 69 NSMutableDictionary* attrs = [NSMutableDictionary dictionary]; |
| 70 | 70 |
| 71 unsigned position = 0; | 71 unsigned position = 0; |
| 72 for (TextIterator it(range.get()); !it.atEnd() && [string length] < length;
it.advance()) { | 72 for (TextIterator it(range.get()); !it.atEnd() && [string length] < length;
it.advance()) { |
| 73 HandleScope scope; |
| 73 unsigned numCharacters = it.length(); | 74 unsigned numCharacters = it.length(); |
| 74 if (!numCharacters) | 75 if (!numCharacters) |
| 75 continue; | 76 continue; |
| 76 | 77 |
| 77 ExceptionCode exception = 0; | 78 ExceptionCode exception = 0; |
| 78 Node* container = it.range()->startContainer(exception); | 79 Handle<Node> container = it.range()->startContainer(exception); |
| 79 RenderObject* renderer = container->renderer(); | 80 RenderObject* renderer = container->renderer(); |
| 80 ASSERT(renderer); | 81 ASSERT(renderer); |
| 81 if (!renderer) | 82 if (!renderer) |
| 82 continue; | 83 continue; |
| 83 | 84 |
| 84 RenderStyle* style = renderer->style(); | 85 RenderStyle* style = renderer->style(); |
| 85 NSFont* font = style->font().primaryFont()->getNSFont(); | 86 NSFont* font = style->font().primaryFont()->getNSFont(); |
| 86 // If the platform font can't be loaded, it's likely that the site is | 87 // If the platform font can't be loaded, it's likely that the site is |
| 87 // using a web font. For now, just use the default font instead. | 88 // using a web font. For now, just use the default font instead. |
| 88 // TODO(rsesek): Change the font activation flags to allow other process
es | 89 // TODO(rsesek): Change the font activation flags to allow other process
es |
| (...skipping 17 matching lines...) Expand all Loading... |
| 106 freeWhenDone:NO] autorelease]; | 107 freeWhenDone:NO] autorelease]; |
| 107 [string replaceCharactersInRange:NSMakeRange(position, 0) | 108 [string replaceCharactersInRange:NSMakeRange(position, 0) |
| 108 withString:substring]; | 109 withString:substring]; |
| 109 [string setAttributes:attrs range:NSMakeRange(position, numCharacters)]; | 110 [string setAttributes:attrs range:NSMakeRange(position, numCharacters)]; |
| 110 position += numCharacters; | 111 position += numCharacters; |
| 111 } | 112 } |
| 112 return [string autorelease]; | 113 return [string autorelease]; |
| 113 } | 114 } |
| 114 | 115 |
| 115 } // namespace WebKit | 116 } // namespace WebKit |
| OLD | NEW |