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

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

Issue 2706033011: Expand FrameSeleciton::rootEditableElement() to increase chances of hoisting update layout (Closed)
Patch Set: 2017-02-22T12:50:05 Created 3 years, 10 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, 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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 return computeVisibleSelectionInDOMTree(); 159 return computeVisibleSelectionInDOMTree();
160 } 160 }
161 161
162 const VisibleSelectionInFlatTree& FrameSelection::selectionInFlatTree() const { 162 const VisibleSelectionInFlatTree& FrameSelection::selectionInFlatTree() const {
163 return computeVisibleSelectionInFlatTree(); 163 return computeVisibleSelectionInFlatTree();
164 } 164 }
165 165
166 void FrameSelection::moveCaretSelection(const IntPoint& point) { 166 void FrameSelection::moveCaretSelection(const IntPoint& point) {
167 DCHECK(!document().needsLayoutTreeUpdate()); 167 DCHECK(!document().needsLayoutTreeUpdate());
168 168
169 Element* const editable = rootEditableElement(); 169 Element* const editable =
170 computeVisibleSelectionInDOMTree().rootEditableElement();
170 if (!editable) 171 if (!editable)
171 return; 172 return;
172 173
173 const VisiblePosition position = 174 const VisiblePosition position =
174 visiblePositionForContentsPoint(point, frame()); 175 visiblePositionForContentsPoint(point, frame());
175 SelectionInDOMTree::Builder builder; 176 SelectionInDOMTree::Builder builder;
176 builder.setIsDirectional( 177 builder.setIsDirectional(
177 computeVisibleSelectionInDOMTreeDeprecated().isDirectional()); 178 computeVisibleSelectionInDOMTreeDeprecated().isDirectional());
178 builder.setIsHandleVisible(true); 179 builder.setIsHandleVisible(true);
179 if (position.isNotNull()) 180 if (position.isNotNull())
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after
828 if (!layoutObject || !layoutObject->isLayoutPart()) 829 if (!layoutObject || !layoutObject->isLayoutPart())
829 return false; 830 return false;
830 Widget* widget = toLayoutPart(layoutObject)->widget(); 831 Widget* widget = toLayoutPart(layoutObject)->widget();
831 return widget && widget->isFrameView(); 832 return widget && widget->isFrameView();
832 } 833 }
833 834
834 void FrameSelection::setFocusedNodeIfNeeded() { 835 void FrameSelection::setFocusedNodeIfNeeded() {
835 if (isNone() || !isFocused()) 836 if (isNone() || !isFocused())
836 return; 837 return;
837 838
838 if (Element* target = rootEditableElement()) { 839 if (Element* target =
840 computeVisibleSelectionInDOMTreeDeprecated().rootEditableElement()) {
839 // Walk up the DOM tree to search for a node to focus. 841 // Walk up the DOM tree to search for a node to focus.
840 document().updateStyleAndLayoutTreeIgnorePendingStylesheets(); 842 document().updateStyleAndLayoutTreeIgnorePendingStylesheets();
841 while (target) { 843 while (target) {
842 // We don't want to set focus on a subframe when selecting in a parent 844 // We don't want to set focus on a subframe when selecting in a parent
843 // frame, so add the !isFrameElement check here. There's probably a better 845 // frame, so add the !isFrameElement check here. There's probably a better
844 // way to make this work in the long term, but this is the safest fix at 846 // way to make this work in the long term, but this is the safest fix at
845 // this time. 847 // this time.
846 if (target->isMouseFocusable() && !isFrameElement(target)) { 848 if (target->isMouseFocusable() && !isFrameElement(target)) {
847 m_frame->page()->focusController().setFocusedElement(target, m_frame); 849 m_frame->page()->focusController().setFocusedElement(target, m_frame);
848 return; 850 return;
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
1177 } 1179 }
1178 1180
1179 void showTree(const blink::FrameSelection* sel) { 1181 void showTree(const blink::FrameSelection* sel) {
1180 if (sel) 1182 if (sel)
1181 sel->showTreeForThis(); 1183 sel->showTreeForThis();
1182 else 1184 else
1183 LOG(INFO) << "Cannot showTree for <null> FrameSelection."; 1185 LOG(INFO) << "Cannot showTree for <null> FrameSelection.";
1184 } 1186 }
1185 1187
1186 #endif 1188 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/editing/FrameSelection.h ('k') | third_party/WebKit/Source/core/input/EventHandler.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698