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 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 const Node* result = nullptr; | 380 const Node* result = nullptr; |
381 for (const Node* n = &node; n && hasEditableStyle(*n); n = n->parentNode()) { | 381 for (const Node* n = &node; n && hasEditableStyle(*n); n = n->parentNode()) { |
382 if (n->isElementNode()) | 382 if (n->isElementNode()) |
383 result = n; | 383 result = n; |
384 if (node.document().body() == n) | 384 if (node.document().body() == n) |
385 break; | 385 break; |
386 } | 386 } |
387 return toElement(const_cast<Node*>(result)); | 387 return toElement(const_cast<Node*>(result)); |
388 } | 388 } |
389 | 389 |
390 bool selectionHasFocus(const SelectionInFlatTree& selection) { | |
391 if (selection.isNone()) | |
392 return false; | |
393 | |
394 const Document* document = selection.base().document(); | |
395 const Element* focus = document->focusedElement(); | |
396 if (!focus) { | |
397 // No focused element means document root has focus. | |
398 focus = document->documentElement(); | |
399 } | |
400 | |
401 const Node* const nodeWhereSelectionStarts = | |
402 selection.base().computeContainerNode(); | |
403 const Node* const nodeWhereSelectionEnds = | |
404 selection.extent().computeContainerNode(); | |
405 | |
406 return focus->containsIncludingHostElements(*nodeWhereSelectionStarts) || | |
407 focus->containsIncludingHostElements(*nodeWhereSelectionEnds); | |
408 } | |
409 | |
410 ContainerNode* highestEditableRoot( | 390 ContainerNode* highestEditableRoot( |
411 const Position& position, | 391 const Position& position, |
412 Element* (*rootEditableElementOf)(const Position&), | 392 Element* (*rootEditableElementOf)(const Position&), |
413 bool (*hasEditableStyle)(const Node&)) { | 393 bool (*hasEditableStyle)(const Node&)) { |
414 if (position.isNull()) | 394 if (position.isNull()) |
415 return 0; | 395 return 0; |
416 | 396 |
417 ContainerNode* highestRoot = rootEditableElementOf(position); | 397 ContainerNode* highestRoot = rootEditableElementOf(position); |
418 if (!highestRoot) | 398 if (!highestRoot) |
419 return 0; | 399 return 0; |
(...skipping 1760 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2180 return InputType::DeleteSoftLineBackward; | 2160 return InputType::DeleteSoftLineBackward; |
2181 if (granularity == ParagraphBoundary) | 2161 if (granularity == ParagraphBoundary) |
2182 return InputType::DeleteHardLineBackward; | 2162 return InputType::DeleteHardLineBackward; |
2183 return InputType::DeleteContentBackward; | 2163 return InputType::DeleteContentBackward; |
2184 default: | 2164 default: |
2185 return InputType::None; | 2165 return InputType::None; |
2186 } | 2166 } |
2187 } | 2167 } |
2188 | 2168 |
2189 } // namespace blink | 2169 } // namespace blink |
OLD | NEW |