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

Side by Side Diff: Source/core/page/FocusController.cpp

Issue 424973003: Don't clear selection on focus change except for text form control element (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2014-07-30T09:45:59 Created 6 years, 4 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
« no previous file with comments | « LayoutTests/editing/selection/keep-selection-after-set-focus-expected.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
3 * Copyright (C) 2008 Nuanti Ltd. 3 * Copyright (C) 2008 Nuanti Ltd.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 670
671 if (Node* mousePressNode = newFocusedFrame->eventHandler().mousePressNode()) { 671 if (Node* mousePressNode = newFocusedFrame->eventHandler().mousePressNode()) {
672 if (mousePressNode->renderer() && !mousePressNode->canStartSelection()) { 672 if (mousePressNode->renderer() && !mousePressNode->canStartSelection()) {
673 // Don't clear the selection for contentEditable elements, but do 673 // Don't clear the selection for contentEditable elements, but do
674 // clear it for input and textarea. See bug 38696. 674 // clear it for input and textarea. See bug 38696.
675 if (!enclosingTextFormControl(selection.start())) 675 if (!enclosingTextFormControl(selection.start()))
676 return; 676 return;
677 } 677 }
678 } 678 }
679 679
680 selection.clear(); 680 if (newFocusedNode && (newFocusedNode->hasEditableStyle()
681 || (newFocusedNode->isElementNode() && isHTMLTextFormControlElement(toEl ement(newFocusedNode))))) {
leviw_travelin_and_unemployed 2014/07/30 19:19:19 How about a named function to document why you're
yosin_UTC9 2014/08/01 04:39:19 Fumm... There are no good reasons to exclude them.
682 selection.clear();
683 return;
684 }
681 } 685 }
682 686
683 bool FocusController::setFocusedElement(Element* element, PassRefPtr<Frame> newF ocusedFrame, FocusType type) 687 bool FocusController::setFocusedElement(Element* element, PassRefPtr<Frame> newF ocusedFrame, FocusType type)
684 { 688 {
685 RefPtr<LocalFrame> oldFocusedFrame = toLocalFrame(focusedFrame()); 689 RefPtr<LocalFrame> oldFocusedFrame = toLocalFrame(focusedFrame());
686 RefPtrWillBeRawPtr<Document> oldDocument = oldFocusedFrame ? oldFocusedFrame ->document() : 0; 690 RefPtrWillBeRawPtr<Document> oldDocument = oldFocusedFrame ? oldFocusedFrame ->document() : 0;
687 691
688 Element* oldFocusedElement = oldDocument ? oldDocument->focusedElement() : 0 ; 692 Element* oldFocusedElement = oldDocument ? oldDocument->focusedElement() : 0 ;
689 if (element && oldFocusedElement == element) 693 if (element && oldFocusedElement == element)
690 return true; 694 return true;
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
930 startingRect = nodeRectInAbsoluteCoordinates(container, true /* ignore b order */); 934 startingRect = nodeRectInAbsoluteCoordinates(container, true /* ignore b order */);
931 container = scrollableEnclosingBoxOrParentFrameForNodeInDirection(type, container); 935 container = scrollableEnclosingBoxOrParentFrameForNodeInDirection(type, container);
932 if (container && container->isDocumentNode()) 936 if (container && container->isDocumentNode())
933 toDocument(container)->updateLayoutIgnorePendingStylesheets(); 937 toDocument(container)->updateLayoutIgnorePendingStylesheets();
934 } while (!consumed && container); 938 } while (!consumed && container);
935 939
936 return consumed; 940 return consumed;
937 } 941 }
938 942
939 } // namespace blink 943 } // namespace blink
OLDNEW
« no previous file with comments | « LayoutTests/editing/selection/keep-selection-after-set-focus-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698