OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights | 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights |
3 * reserved. | 3 * 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 | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 4022 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4033 // it as trailing white space. | 4033 // it as trailing white space. |
4034 for (; charIt.length(); charIt.advance(1)) { | 4034 for (; charIt.length(); charIt.advance(1)) { |
4035 UChar c = charIt.characterAt(0); | 4035 UChar c = charIt.characterAt(0); |
4036 if ((!isSpaceOrNewline(c) && c != noBreakSpaceCharacter) || c == '\n') | 4036 if ((!isSpaceOrNewline(c) && c != noBreakSpaceCharacter) || c == '\n') |
4037 return runner; | 4037 return runner; |
4038 runner = charIt.endPosition(); | 4038 runner = charIt.endPosition(); |
4039 } | 4039 } |
4040 return runner; | 4040 return runner; |
4041 } | 4041 } |
4042 | 4042 |
| 4043 template <typename Strategy> |
| 4044 void textRects(Vector<IntRect>& rects, |
| 4045 const EphemeralRangeTemplate<Strategy>& range) { |
| 4046 const PositionTemplate<Strategy> startPosition = range.startPosition(); |
| 4047 const PositionTemplate<Strategy> endPosition = range.startPosition(); |
| 4048 Node* startContainer = startPosition.computeContainerNode(); |
| 4049 DCHECK(startContainer); |
| 4050 Node* endContainer = endPosition.computeContainerNode(); |
| 4051 DCHECK(endContainer); |
| 4052 |
| 4053 for (Node& node : range.nodes()) { |
| 4054 LayoutObject* layoutObject = node.layoutObject(); |
| 4055 if (!layoutObject || !layoutObject->isText()) |
| 4056 continue; |
| 4057 LayoutText* layoutText = toLayoutText(layoutObject); |
| 4058 unsigned startOffset = |
| 4059 node == startContainer ? startPosition.offsetInContainerNode() : 0; |
| 4060 unsigned endOffset = node == endContainer |
| 4061 ? endPosition.offsetInContainerNode() |
| 4062 : std::numeric_limits<unsigned>::max(); |
| 4063 layoutText->absoluteRectsForRange(rects, startOffset, endOffset); |
| 4064 } |
| 4065 } |
| 4066 |
| 4067 IntRect boundingBox(const EphemeralRange& range) { |
| 4068 IntRect result; |
| 4069 Vector<IntRect> rects; |
| 4070 textRects(rects, range); |
| 4071 for (const IntRect& rect : rects) |
| 4072 result.unite(rect); |
| 4073 return result; |
| 4074 } |
| 4075 |
| 4076 IntRect boundingBox(const EphemeralRangeInFlatTree& range) { |
| 4077 IntRect result; |
| 4078 Vector<IntRect> rects; |
| 4079 textRects(rects, range); |
| 4080 for (const IntRect& rect : rects) |
| 4081 result.unite(rect); |
| 4082 return result; |
| 4083 } |
| 4084 |
4043 Position skipWhitespace(const Position& position) { | 4085 Position skipWhitespace(const Position& position) { |
4044 return skipWhitespaceAlgorithm(position); | 4086 return skipWhitespaceAlgorithm(position); |
4045 } | 4087 } |
4046 | 4088 |
4047 PositionInFlatTree skipWhitespace(const PositionInFlatTree& position) { | 4089 PositionInFlatTree skipWhitespace(const PositionInFlatTree& position) { |
4048 return skipWhitespaceAlgorithm(position); | 4090 return skipWhitespaceAlgorithm(position); |
4049 } | 4091 } |
4050 | 4092 |
4051 } // namespace blink | 4093 } // namespace blink |
OLD | NEW |