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

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-08-13T13:21:11 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 | « Source/core/dom/Element.cpp ('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 647 matching lines...) Expand 10 before | Expand all | Expand 10 after
658 return; 658 return;
659 659
660 bool caretBrowsing = oldFocusedFrame->settings()->caretBrowsingEnabled(); 660 bool caretBrowsing = oldFocusedFrame->settings()->caretBrowsingEnabled();
661 if (caretBrowsing) 661 if (caretBrowsing)
662 return; 662 return;
663 663
664 Node* selectionStartNode = selection.selection().start().deprecatedNode(); 664 Node* selectionStartNode = selection.selection().start().deprecatedNode();
665 if (selectionStartNode == newFocusedNode || selectionStartNode->isDescendant Of(newFocusedNode)) 665 if (selectionStartNode == newFocusedNode || selectionStartNode->isDescendant Of(newFocusedNode))
666 return; 666 return;
667 667
668 if (!enclosingTextFormControl(selectionStartNode))
669 return;
670
668 if (selectionStartNode->isInShadowTree() && selectionStartNode->shadowHost() == newFocusedNode) 671 if (selectionStartNode->isInShadowTree() && selectionStartNode->shadowHost() == newFocusedNode)
669 return; 672 return;
670 673
671 if (Node* mousePressNode = newFocusedFrame->eventHandler().mousePressNode()) {
672 if (mousePressNode->renderer() && !mousePressNode->canStartSelection()) {
673 // Don't clear the selection for contentEditable elements, but do
674 // clear it for input and textarea. See bug 38696.
675 if (!enclosingTextFormControl(selection.start()))
676 return;
677 }
678 }
679
680 selection.clear(); 674 selection.clear();
681 } 675 }
682 676
683 bool FocusController::setFocusedElement(Element* element, PassRefPtr<Frame> newF ocusedFrame, FocusType type) 677 bool FocusController::setFocusedElement(Element* element, PassRefPtr<Frame> newF ocusedFrame, FocusType type)
684 { 678 {
685 RefPtr<LocalFrame> oldFocusedFrame = toLocalFrame(focusedFrame()); 679 RefPtr<LocalFrame> oldFocusedFrame = toLocalFrame(focusedFrame());
686 RefPtrWillBeRawPtr<Document> oldDocument = oldFocusedFrame ? oldFocusedFrame ->document() : 0; 680 RefPtrWillBeRawPtr<Document> oldDocument = oldFocusedFrame ? oldFocusedFrame ->document() : 0;
687 681
688 Element* oldFocusedElement = oldDocument ? oldDocument->focusedElement() : 0 ; 682 Element* oldFocusedElement = oldDocument ? oldDocument->focusedElement() : 0 ;
689 if (element && oldFocusedElement == element) 683 if (element && oldFocusedElement == element)
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
925 startingRect = nodeRectInAbsoluteCoordinates(container, true /* ignore b order */); 919 startingRect = nodeRectInAbsoluteCoordinates(container, true /* ignore b order */);
926 container = scrollableEnclosingBoxOrParentFrameForNodeInDirection(type, container); 920 container = scrollableEnclosingBoxOrParentFrameForNodeInDirection(type, container);
927 if (container && container->isDocumentNode()) 921 if (container && container->isDocumentNode())
928 toDocument(container)->updateLayoutIgnorePendingStylesheets(); 922 toDocument(container)->updateLayoutIgnorePendingStylesheets();
929 } while (!consumed && container); 923 } while (!consumed && container);
930 924
931 return consumed; 925 return consumed;
932 } 926 }
933 927
934 } // namespace blink 928 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/dom/Element.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698