Chromium Code Reviews| 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 SelectionInFlatTree& selection) { | |
| 378 if (selection.isNone()) | |
| 379 return false; | |
| 380 | |
| 381 const Document* document = selection.base().document(); | |
| 382 if (!document) | |
|
yosin_UTC9
2017/03/23 01:26:20
nit: Since selection.isNone() implies selection.ba
hugoh_UTC2
2017/03/23 01:38:06
Done. See PS27.
| |
| 383 return false; | |
| 384 | |
| 385 const Element* focus = document->focusedElement(); | |
| 386 if (!focus) { | |
| 387 // No focused element means document root has focus. | |
| 388 focus = document->documentElement(); | |
| 389 } | |
| 390 | |
| 391 const Node* const nodeWhereSelectionStarts = | |
| 392 selection.base().computeContainerNode(); | |
| 393 const Node* const nodeWhereSelectionEnds = | |
| 394 selection.extent().computeContainerNode(); | |
| 395 | |
| 396 return focus->containsIncludingHostElements(*nodeWhereSelectionStarts) || | |
| 397 focus->containsIncludingHostElements(*nodeWhereSelectionEnds); | |
| 398 } | |
| 399 | |
| 377 ContainerNode* highestEditableRoot( | 400 ContainerNode* highestEditableRoot( |
| 378 const Position& position, | 401 const Position& position, |
| 379 Element* (*rootEditableElementOf)(const Position&), | 402 Element* (*rootEditableElementOf)(const Position&), |
| 380 bool (*hasEditableStyle)(const Node&)) { | 403 bool (*hasEditableStyle)(const Node&)) { |
| 381 if (position.isNull()) | 404 if (position.isNull()) |
| 382 return 0; | 405 return 0; |
| 383 | 406 |
| 384 ContainerNode* highestRoot = rootEditableElementOf(position); | 407 ContainerNode* highestRoot = rootEditableElementOf(position); |
| 385 if (!highestRoot) | 408 if (!highestRoot) |
| 386 return 0; | 409 return 0; |
| (...skipping 1786 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2173 return InputType::DeleteWordBackward; | 2196 return InputType::DeleteWordBackward; |
| 2174 if (granularity == LineBoundary) | 2197 if (granularity == LineBoundary) |
| 2175 return InputType::DeleteLineBackward; | 2198 return InputType::DeleteLineBackward; |
| 2176 return InputType::DeleteContentBackward; | 2199 return InputType::DeleteContentBackward; |
| 2177 default: | 2200 default: |
| 2178 return InputType::None; | 2201 return InputType::None; |
| 2179 } | 2202 } |
| 2180 } | 2203 } |
| 2181 | 2204 |
| 2182 } // namespace blink | 2205 } // namespace blink |
| OLD | NEW |