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 using namespace blink; | 59 using namespace blink; |
60 | 60 |
61 static NSAttributedString* attributedSubstringFromRange(const EphemeralRange& ra
nge) | 61 static NSAttributedString* attributedSubstringFromRange(const EphemeralRange& ra
nge) |
62 { | 62 { |
63 NSMutableAttributedString* string = [[NSMutableAttributedString alloc] init]
; | 63 NSMutableAttributedString* string = [[NSMutableAttributedString alloc] init]
; |
64 NSMutableDictionary* attrs = [NSMutableDictionary dictionary]; | 64 NSMutableDictionary* attrs = [NSMutableDictionary dictionary]; |
65 size_t length = range.endPosition().computeOffsetInContainerNode() - range.s
tartPosition().computeOffsetInContainerNode(); | 65 size_t length = range.endPosition().computeOffsetInContainerNode() - range.s
tartPosition().computeOffsetInContainerNode(); |
66 | 66 |
67 unsigned position = 0; | 67 unsigned position = 0; |
68 | 68 |
69 // TODO(dglazkov): The use of updateLayoutIgnorePendingStylesheets needs to
be audited. | 69 // TODO(dglazkov): The use of updateStyleAndLayoutIgnorePendingStylesheets n
eeds to be audited. |
70 // see http://crbug.com/590369 for more details. | 70 // see http://crbug.com/590369 for more details. |
71 range.startPosition().document()->updateLayoutIgnorePendingStylesheets(); | 71 range.startPosition().document()->updateStyleAndLayoutIgnorePendingStyleshee
ts(); |
72 | 72 |
73 for (TextIterator it(range.startPosition(), range.endPosition()); !it.atEnd(
) && [string length] < length; it.advance()) { | 73 for (TextIterator it(range.startPosition(), range.endPosition()); !it.atEnd(
) && [string length] < length; it.advance()) { |
74 unsigned numCharacters = it.length(); | 74 unsigned numCharacters = it.length(); |
75 if (!numCharacters) | 75 if (!numCharacters) |
76 continue; | 76 continue; |
77 | 77 |
78 Node* container = it.currentContainer(); | 78 Node* container = it.currentContainer(); |
79 LayoutObject* layoutObject = container->layoutObject(); | 79 LayoutObject* layoutObject = container->layoutObject(); |
80 DCHECK(layoutObject); | 80 DCHECK(layoutObject); |
81 if (!layoutObject) | 81 if (!layoutObject) |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 if (ephemeralRange.isNull()) | 175 if (ephemeralRange.isNull()) |
176 return nil; | 176 return nil; |
177 | 177 |
178 NSAttributedString* result = attributedSubstringFromRange(ephemeralRange); | 178 NSAttributedString* result = attributedSubstringFromRange(ephemeralRange); |
179 if (baselinePoint) | 179 if (baselinePoint) |
180 *baselinePoint = getBaselinePoint(frame->view(), ephemeralRange, result)
; | 180 *baselinePoint = getBaselinePoint(frame->view(), ephemeralRange, result)
; |
181 return result; | 181 return result; |
182 } | 182 } |
183 | 183 |
184 } // namespace blink | 184 } // namespace blink |
OLD | NEW |