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

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

Issue 2616623002: Do not send redundant selectionchange-events (decouple focus) (Closed)
Patch Set: Get Document from selection Created 3 years, 9 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 const Document* document = selection.base().document();
yosin_UTC9 2017/03/22 09:11:35 Let's handle document == nullptr case, selection.i
hugoh_UTC2 2017/03/22 09:19:14 You mean when selection.isNone(), we return false?
yosin_UTC9 2017/03/22 09:26:35 Yes, just return false if selection.isNone(), So,
hugoh_UTC2 2017/03/22 09:41:11 Done. See PS26.
379 const Element* focus = document->focusedElement();
380 if (!focus) {
381 // No focused element means document root has focus.
382 focus = 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
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
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