Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv ed. | 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv ed. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 2153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2164 HitTestResult result(request, contentsPoint); | 2164 HitTestResult result(request, contentsPoint); |
| 2165 frame->document()->layoutView()->hitTest(result); | 2165 frame->document()->layoutView()->hitTest(result); |
| 2166 | 2166 |
| 2167 if (Node* node = result.innerNode()) | 2167 if (Node* node = result.innerNode()) |
| 2168 return frame->selection().selection().visiblePositionRespectingEditingBo undary(result.localPoint(), node); | 2168 return frame->selection().selection().visiblePositionRespectingEditingBo undary(result.localPoint(), node); |
| 2169 return VisiblePosition(); | 2169 return VisiblePosition(); |
| 2170 } | 2170 } |
| 2171 | 2171 |
| 2172 // TODO(yosin): We should use |associatedLayoutObjectOf()| in "VisibleUnits.cpp" | 2172 // TODO(yosin): We should use |associatedLayoutObjectOf()| in "VisibleUnits.cpp" |
| 2173 // where it takes |LayoutObject| from |Position|. | 2173 // where it takes |LayoutObject| from |Position|. |
| 2174 static LayoutObject* associatedLayoutObjectOf(const Node& node, int offsetInNode ) | 2174 LayoutObject* associatedLayoutObjectOf(const Node& node, int offsetInNode) |
| 2175 { | 2175 { |
| 2176 ASSERT(offsetInNode >= 0); | 2176 ASSERT(offsetInNode >= 0); |
| 2177 LayoutObject* layoutObject = node.layoutObject(); | 2177 LayoutObject* layoutObject = node.layoutObject(); |
| 2178 if (!node.isTextNode() || !layoutObject || !toLayoutText(layoutObject)->isTe xtFragment()) | 2178 if (!node.isTextNode() || !layoutObject || !toLayoutText(layoutObject)->isTe xtFragment()) |
| 2179 return layoutObject; | 2179 return layoutObject; |
| 2180 // ::first-letter pseudo element yields following layout objects. | |
| 2181 // |Text::layoutObject()| returns |LayoutTextFragment| for first-letter | |
| 2182 // patter, e.g. "B\n", or remaining part "abc". | |
|
tkent
2016/01/29 03:52:16
patter -> part?
I don't understand what you mean
yosin_UTC9
2016/01/29 05:27:45
Add more explanation about first-letter.
| |
| 2183 // Note: Remaining part can be empty if all characters in first-letter, e.g. | |
| 2184 // "(a)". | |
| 2185 // LayoutBlockFlow {DIV} at (0,0) size 784x55 | |
| 2186 // LayoutInline {<pseudo:first-letter>} at (0,0) size 22x53 | |
| 2187 // LayoutTextFragment (anonymous) at (0,1) size 22x53 | |
| 2188 // text run at (0,1) width 22: "a" | |
| 2189 // LayoutTextFragment {#text} at (21,30) size 16x17 | |
| 2190 // text run at (21,30) width 16: "bc" | |
| 2180 LayoutTextFragment* layoutTextFragment = toLayoutTextFragment(layoutObject); | 2191 LayoutTextFragment* layoutTextFragment = toLayoutTextFragment(layoutObject); |
| 2181 if (layoutTextFragment->isRemainingTextLayoutObject()) { | 2192 if (!layoutTextFragment->isRemainingTextLayoutObject()) { |
| 2182 if (static_cast<unsigned>(offsetInNode) >= layoutTextFragment->start()) | 2193 // In case of there are no visible characters after first letter, e.g. |
| 2183 return layoutObject; | 2194 // "B\n" |
| 2184 LayoutObject* firstLetterLayoutObject = layoutTextFragment->firstLetterP seudoElement()->layoutObject(); | 2195 ASSERT(static_cast<unsigned>(offsetInNode) <= layoutTextFragment->start( ) + layoutTextFragment->fragmentLength()); |
| 2185 if (!firstLetterLayoutObject) | 2196 return layoutTextFragment; |
| 2186 return nullptr; | |
| 2187 // TODO(yosin): We're not sure when |firstLetterLayoutObject| has | |
| 2188 // multiple child layout object. | |
| 2189 ASSERT(firstLetterLayoutObject->slowFirstChild() == firstLetterLayoutObj ect->slowLastChild()); | |
| 2190 return firstLetterLayoutObject->slowFirstChild(); | |
| 2191 } | 2197 } |
| 2192 // TODO(yosin): We should rename |LayoutTextFramge::length()| instead of | 2198 // In case of |node| contains first-letter only, e.g. <div>"a" "bc"</div> |
| 2193 // |end()|, once |LayoutTextFramge| has it. See http://crbug.com/545789 | 2199 // we have "a" is associated to |LayoutTextFragment| with |
| 2194 ASSERT(static_cast<unsigned>(offsetInNode) <= layoutTextFragment->start() + layoutTextFragment->fragmentLength()); | 2200 // |isRemainingTextLayoutObject()| == true and |fragmentLength()| == 0. |
| 2195 return layoutTextFragment; | 2201 if (layoutTextFragment->fragmentLength() && static_cast<unsigned>(offsetInNo de) >= layoutTextFragment->start()) |
| 2202 return layoutObject; | |
| 2203 LayoutObject* firstLetterLayoutObject = layoutTextFragment->firstLetterPseud oElement()->layoutObject(); | |
| 2204 // TODO(yosin): We're not sure when |firstLetterLayoutObject| has | |
| 2205 // multiple child layout object. | |
| 2206 ASSERT(firstLetterLayoutObject->slowFirstChild() == firstLetterLayoutObject- >slowLastChild()); | |
| 2207 return firstLetterLayoutObject->slowFirstChild(); | |
| 2196 } | 2208 } |
| 2197 | 2209 |
| 2198 int caretMinOffset(const Node* node) | 2210 int caretMinOffset(const Node* node) |
| 2199 { | 2211 { |
| 2200 LayoutObject* layoutObject = associatedLayoutObjectOf(*node, 0); | 2212 LayoutObject* layoutObject = associatedLayoutObjectOf(*node, 0); |
| 2201 return layoutObject ? layoutObject->caretMinOffset() : 0; | 2213 return layoutObject ? layoutObject->caretMinOffset() : 0; |
| 2202 } | 2214 } |
| 2203 | 2215 |
| 2204 int caretMaxOffset(const Node* n) | 2216 int caretMaxOffset(const Node* n) |
| 2205 { | 2217 { |
| (...skipping 1121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3327 { | 3339 { |
| 3328 return previousPositionOfAlgorithm<EditingStrategy>(visiblePosition, rule); | 3340 return previousPositionOfAlgorithm<EditingStrategy>(visiblePosition, rule); |
| 3329 } | 3341 } |
| 3330 | 3342 |
| 3331 VisiblePositionInComposedTree previousPositionOf(const VisiblePositionInComposed Tree& visiblePosition, EditingBoundaryCrossingRule rule) | 3343 VisiblePositionInComposedTree previousPositionOf(const VisiblePositionInComposed Tree& visiblePosition, EditingBoundaryCrossingRule rule) |
| 3332 { | 3344 { |
| 3333 return previousPositionOfAlgorithm<EditingInComposedTreeStrategy>(visiblePos ition, rule); | 3345 return previousPositionOfAlgorithm<EditingInComposedTreeStrategy>(visiblePos ition, rule); |
| 3334 } | 3346 } |
| 3335 | 3347 |
| 3336 } // namespace blink | 3348 } // namespace blink |
| OLD | NEW |