Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(585)

Side by Side Diff: third_party/WebKit/Source/core/editing/EditingUtilities.cpp

Issue 2784653002: Revert of Do not send redundant selectionchange-events (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 const Element* focus = document->focusedElement();
383 if (!focus) {
384 // No focused element means document root has focus.
385 focus = document->documentElement();
386 }
387
388 const Node* const nodeWhereSelectionStarts =
389 selection.base().computeContainerNode();
390 const Node* const nodeWhereSelectionEnds =
391 selection.extent().computeContainerNode();
392
393 return focus->containsIncludingHostElements(*nodeWhereSelectionStarts) ||
394 focus->containsIncludingHostElements(*nodeWhereSelectionEnds);
395 }
396
397 ContainerNode* highestEditableRoot( 377 ContainerNode* highestEditableRoot(
398 const Position& position, 378 const Position& position,
399 Element* (*rootEditableElementOf)(const Position&), 379 Element* (*rootEditableElementOf)(const Position&),
400 bool (*hasEditableStyle)(const Node&)) { 380 bool (*hasEditableStyle)(const Node&)) {
401 if (position.isNull()) 381 if (position.isNull())
402 return 0; 382 return 0;
403 383
404 ContainerNode* highestRoot = rootEditableElementOf(position); 384 ContainerNode* highestRoot = rootEditableElementOf(position);
405 if (!highestRoot) 385 if (!highestRoot)
406 return 0; 386 return 0;
(...skipping 1786 matching lines...) Expand 10 before | Expand all | Expand 10 after
2193 return InputType::DeleteWordBackward; 2173 return InputType::DeleteWordBackward;
2194 if (granularity == LineBoundary) 2174 if (granularity == LineBoundary)
2195 return InputType::DeleteLineBackward; 2175 return InputType::DeleteLineBackward;
2196 return InputType::DeleteContentBackward; 2176 return InputType::DeleteContentBackward;
2197 default: 2177 default:
2198 return InputType::None; 2178 return InputType::None;
2199 } 2179 }
2200 } 2180 }
2201 2181
2202 } // namespace blink 2182 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/editing/EditingUtilities.h ('k') | third_party/WebKit/Source/core/editing/PendingSelection.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698