OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. |
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 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
367 const Node* result = nullptr; | 367 const Node* result = nullptr; |
368 for (const Node* n = &node; n && hasEditableStyle(*n); n = n->parentNode()) { | 368 for (const Node* n = &node; n && hasEditableStyle(*n); n = n->parentNode()) { |
369 if (n->isElementNode()) | 369 if (n->isElementNode()) |
370 result = n; | 370 result = n; |
371 if (node.document().body() == n) | 371 if (node.document().body() == n) |
372 break; | 372 break; |
373 } | 373 } |
374 return toElement(const_cast<Node*>(result)); | 374 return toElement(const_cast<Node*>(result)); |
375 } | 375 } |
376 | 376 |
377 bool selectionHasFocus(const LocalFrame& frame, | |
yosin_UTC9
2017/03/22 05:07:59
Let's take Document from selection instead of extr
hugoh_UTC2
2017/03/22 07:50:33
SelectionTemplate currently keeps Document private
yosin_UTC9
2017/03/22 07:53:19
You can get Document by Position, e.g. selection.b
hugoh_UTC2
2017/03/22 08:32:38
Done. See PS25.
| |
378 const SelectionInFlatTree& selection) { | |
379 const Element* focus = frame.document()->focusedElement(); | |
380 if (!focus) { | |
381 // No focused element means document root has focus. | |
382 focus = frame.document()->documentElement(); | |
383 } | |
384 | |
385 const Node* const nodeWhereSelectionStarts = | |
386 selection.base().computeContainerNode(); | |
387 const Node* const nodeWhereSelectionEnds = | |
388 selection.extent().computeContainerNode(); | |
389 | |
390 return focus->containsIncludingHostElements(*nodeWhereSelectionStarts) || | |
391 focus->containsIncludingHostElements(*nodeWhereSelectionEnds); | |
392 } | |
393 | |
377 ContainerNode* highestEditableRoot( | 394 ContainerNode* highestEditableRoot( |
378 const Position& position, | 395 const Position& position, |
379 Element* (*rootEditableElementOf)(const Position&), | 396 Element* (*rootEditableElementOf)(const Position&), |
380 bool (*hasEditableStyle)(const Node&)) { | 397 bool (*hasEditableStyle)(const Node&)) { |
381 if (position.isNull()) | 398 if (position.isNull()) |
382 return 0; | 399 return 0; |
383 | 400 |
384 ContainerNode* highestRoot = rootEditableElementOf(position); | 401 ContainerNode* highestRoot = rootEditableElementOf(position); |
385 if (!highestRoot) | 402 if (!highestRoot) |
386 return 0; | 403 return 0; |
(...skipping 1786 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2173 return InputType::DeleteWordBackward; | 2190 return InputType::DeleteWordBackward; |
2174 if (granularity == LineBoundary) | 2191 if (granularity == LineBoundary) |
2175 return InputType::DeleteLineBackward; | 2192 return InputType::DeleteLineBackward; |
2176 return InputType::DeleteContentBackward; | 2193 return InputType::DeleteContentBackward; |
2177 default: | 2194 default: |
2178 return InputType::None; | 2195 return InputType::None; |
2179 } | 2196 } |
2180 } | 2197 } |
2181 | 2198 |
2182 } // namespace blink | 2199 } // namespace blink |
OLD | NEW |