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

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

Issue 2023793002: Move VisibleSelection::nonBoundaryShadowTreeRootNode() to FrameSelection.cpp (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 2016-05-30T17:24:37 Created 4 years, 6 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 | « no previous file | third_party/WebKit/Source/core/editing/VisibleSelection.h » ('j') | 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) 2004, 2008, 2009, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2008, 2009, 2010 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 780 matching lines...) Expand 10 before | Expand all | Expand 10 after
791 791
792 // Focus on the parent frame, and then select from before this element to af ter. 792 // Focus on the parent frame, and then select from before this element to af ter.
793 VisibleSelection newSelection(beforeOwnerElement, afterOwnerElement); 793 VisibleSelection newSelection(beforeOwnerElement, afterOwnerElement);
794 page->focusController().setFocusedFrame(parent); 794 page->focusController().setFocusedFrame(parent);
795 // setFocusedFrame can dispatch synchronous focus/blur events. The document 795 // setFocusedFrame can dispatch synchronous focus/blur events. The document
796 // tree might be modified. 796 // tree might be modified.
797 if (newSelection.isNonOrphanedCaretOrRange()) 797 if (newSelection.isNonOrphanedCaretOrRange())
798 toLocalFrame(parent)->selection().setSelection(newSelection); 798 toLocalFrame(parent)->selection().setSelection(newSelection);
799 } 799 }
800 800
801 // Returns a shadow tree node for legacy shadow trees, a child of the
802 // ShadowRoot node for new shadow trees, or 0 for non-shadow trees.
803 static Node* nonBoundaryShadowTreeRootNode(const Position& position)
804 {
805 return position.anchorNode() && !position.anchorNode()->isShadowRoot() ? pos ition.anchorNode()->nonBoundaryShadowTreeRootNode() : nullptr;
806 }
807
801 void FrameSelection::selectAll() 808 void FrameSelection::selectAll()
802 { 809 {
803 Document* document = m_frame->document(); 810 Document* document = m_frame->document();
804 811
805 if (isHTMLSelectElement(document->focusedElement())) { 812 if (isHTMLSelectElement(document->focusedElement())) {
806 HTMLSelectElement* selectElement = toHTMLSelectElement(document->focused Element()); 813 HTMLSelectElement* selectElement = toHTMLSelectElement(document->focused Element());
807 if (selectElement->canSelectAll()) { 814 if (selectElement->canSelectAll()) {
808 selectElement->selectAll(); 815 selectElement->selectAll();
809 return; 816 return;
810 } 817 }
811 } 818 }
812 819
813 Node* root = nullptr; 820 Node* root = nullptr;
814 Node* selectStartTarget = nullptr; 821 Node* selectStartTarget = nullptr;
815 if (isContentEditable()) { 822 if (isContentEditable()) {
816 root = highestEditableRoot(selection().start()); 823 root = highestEditableRoot(selection().start());
817 if (Node* shadowRoot = selection().nonBoundaryShadowTreeRootNode()) 824 if (Node* shadowRoot = nonBoundaryShadowTreeRootNode(selection().start() ))
818 selectStartTarget = shadowRoot->shadowHost(); 825 selectStartTarget = shadowRoot->shadowHost();
819 else 826 else
820 selectStartTarget = root; 827 selectStartTarget = root;
821 } else { 828 } else {
822 root = selection().nonBoundaryShadowTreeRootNode(); 829 root = nonBoundaryShadowTreeRootNode(selection().start());
823 if (root) { 830 if (root) {
824 selectStartTarget = root->shadowHost(); 831 selectStartTarget = root->shadowHost();
825 } else { 832 } else {
826 root = document->documentElement(); 833 root = document->documentElement();
827 selectStartTarget = document->body(); 834 selectStartTarget = document->body();
828 } 835 }
829 } 836 }
830 if (!root || editingIgnoresContent(root)) 837 if (!root || editingIgnoresContent(root))
831 return; 838 return;
832 839
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after
1361 1368
1362 void showTree(const blink::FrameSelection* sel) 1369 void showTree(const blink::FrameSelection* sel)
1363 { 1370 {
1364 if (sel) 1371 if (sel)
1365 sel->showTreeForThis(); 1372 sel->showTreeForThis();
1366 else 1373 else
1367 fprintf(stderr, "Cannot showTree for (nil) FrameSelection.\n"); 1374 fprintf(stderr, "Cannot showTree for (nil) FrameSelection.\n");
1368 } 1375 }
1369 1376
1370 #endif 1377 #endif
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/editing/VisibleSelection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698