OLD | NEW |
---|---|
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 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
223 if (shouldClearTypingStyle) | 223 if (shouldClearTypingStyle) |
224 m_frame->editor().clearTypingStyle(); | 224 m_frame->editor().clearTypingStyle(); |
225 | 225 |
226 const SelectionInDOMTree oldSelectionInDOMTree = | 226 const SelectionInDOMTree oldSelectionInDOMTree = |
227 m_selectionEditor->selectionInDOMTree(); | 227 m_selectionEditor->selectionInDOMTree(); |
228 if (oldSelectionInDOMTree == newSelection) | 228 if (oldSelectionInDOMTree == newSelection) |
229 return; | 229 return; |
230 m_selectionEditor->setSelection(newSelection); | 230 m_selectionEditor->setSelection(newSelection); |
231 scheduleVisualUpdateForPaintInvalidationIfNeeded(); | 231 scheduleVisualUpdateForPaintInvalidationIfNeeded(); |
232 | 232 |
233 // TODO(yosin): The use of updateStyleAndLayoutIgnorePendingStylesheets | |
234 // needs to be audited. see http://crbug.com/590369 for more details. | |
235 document().updateStyleAndLayoutIgnorePendingStylesheets(); | |
236 | |
237 const Document& currentDocument = document(); | 233 const Document& currentDocument = document(); |
238 // TODO(yosin): We should get rid of unsued |options| for | 234 // TODO(yosin): We should get rid of unsued |options| for |
239 // |Editor::respondToChangedSelection()|. | 235 // |Editor::respondToChangedSelection()|. |
240 // Note: Since, setting focus can modify DOM tree, we should use | 236 // Note: Since, setting focus can modify DOM tree, we should use |
241 // |oldSelection| before setting focus | 237 // |oldSelection| before setting focus |
242 m_frame->editor().respondToChangedSelection( | 238 m_frame->editor().respondToChangedSelection( |
243 createVisibleSelection(oldSelectionInDOMTree).start(), options); | 239 oldSelectionInDOMTree.computeStartPosition(), options); |
244 DCHECK_EQ(currentDocument, document()); | 240 DCHECK_EQ(currentDocument, document()); |
245 | 241 |
246 if (!computeVisibleSelectionInDOMTree().isNone() && | 242 if (!selectionInDOMTree().isNone() && !(options & DoNotSetFocus)) { |
247 !(options & DoNotSetFocus)) { | |
248 setFocusedNodeIfNeeded(); | 243 setFocusedNodeIfNeeded(); |
249 // |setFocusedNodeIfNeeded()| dispatches sync events "FocusOut" and | 244 // |setFocusedNodeIfNeeded()| dispatches sync events "FocusOut" and |
250 // "FocusIn", |m_frame| may associate to another document. | 245 // "FocusIn", |m_frame| may associate to another document. |
251 if (!isAvailable() || document() != currentDocument) { | 246 if (!isAvailable() || document() != currentDocument) { |
252 // Once we get test case to reach here, we should change this | 247 // Once we get test case to reach here, we should change this |
253 // if-statement to |DCHECK()|. | 248 // if-statement to |DCHECK()|. |
254 NOTREACHED(); | 249 NOTREACHED(); |
255 return; | 250 return; |
256 } | 251 } |
257 } | 252 } |
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
777 // selecting with the mouse or the keyboard after setting the selection. | 772 // selecting with the mouse or the keyboard after setting the selection. |
778 void FrameSelection::selectFrameElementInParentIfFullySelected() { | 773 void FrameSelection::selectFrameElementInParentIfFullySelected() { |
779 // Find the parent frame; if there is none, then we have nothing to do. | 774 // Find the parent frame; if there is none, then we have nothing to do. |
780 Frame* parent = m_frame->tree().parent(); | 775 Frame* parent = m_frame->tree().parent(); |
781 if (!parent) | 776 if (!parent) |
782 return; | 777 return; |
783 Page* page = m_frame->page(); | 778 Page* page = m_frame->page(); |
784 if (!page) | 779 if (!page) |
785 return; | 780 return; |
786 | 781 |
782 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets | |
783 // needs to be audited. See http://crbug.com/590369 for more details. | |
784 document().updateStyleAndLayoutIgnorePendingStylesheets(); | |
785 | |
787 // Check if the selection contains the entire frame contents; if not, then | 786 // Check if the selection contains the entire frame contents; if not, then |
788 // there is nothing to do. | 787 // there is nothing to do. |
789 if (!isRange()) | 788 if (!isRange()) |
yoichio
2017/02/17 04:35:16
ditto. (Rename to computeIsRange())
yosin_UTC9
2017/02/17 05:14:49
This will be done in another patch.
| |
790 return; | 789 return; |
791 | 790 |
792 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets | |
793 // needs to be audited. See http://crbug.com/590369 for more details. | |
794 document().updateStyleAndLayoutIgnorePendingStylesheets(); | |
795 | |
796 if (!isStartOfDocument(selection().visibleStart())) | 791 if (!isStartOfDocument(selection().visibleStart())) |
797 return; | 792 return; |
798 if (!isEndOfDocument(selection().visibleEnd())) | 793 if (!isEndOfDocument(selection().visibleEnd())) |
799 return; | 794 return; |
800 | 795 |
801 // FIXME: This is not yet implemented for cross-process frame relationships. | 796 // FIXME: This is not yet implemented for cross-process frame relationships. |
802 if (!parent->isLocalFrame()) | 797 if (!parent->isLocalFrame()) |
803 return; | 798 return; |
804 | 799 |
805 // Get to the <iframe> or <frame> (or even <object>) element in the parent | 800 // Get to the <iframe> or <frame> (or even <object>) element in the parent |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
929 return m_selectionEditor->firstRange(); | 924 return m_selectionEditor->firstRange(); |
930 } | 925 } |
931 | 926 |
932 bool FrameSelection::isInPasswordField() const { | 927 bool FrameSelection::isInPasswordField() const { |
933 TextControlElement* textControl = enclosingTextControl(start()); | 928 TextControlElement* textControl = enclosingTextControl(start()); |
934 return isHTMLInputElement(textControl) && | 929 return isHTMLInputElement(textControl) && |
935 toHTMLInputElement(textControl)->type() == InputTypeNames::password; | 930 toHTMLInputElement(textControl)->type() == InputTypeNames::password; |
936 } | 931 } |
937 | 932 |
938 void FrameSelection::notifyAccessibilityForSelectionChange() { | 933 void FrameSelection::notifyAccessibilityForSelectionChange() { |
939 if (selection().start().isNotNull() && selection().end().isNotNull()) { | 934 if (selectionInDOMTree().isNone()) |
940 if (AXObjectCache* cache = document().existingAXObjectCache()) | 935 return; |
941 cache->selectionChanged(selection().start().computeContainerNode()); | 936 AXObjectCache* cache = document().existingAXObjectCache(); |
942 } | 937 if (!cache) |
938 return; | |
939 const Position& start = selectionInDOMTree().computeStartPosition(); | |
940 cache->selectionChanged(start.computeContainerNode()); | |
943 } | 941 } |
944 | 942 |
945 void FrameSelection::notifyCompositorForSelectionChange() { | 943 void FrameSelection::notifyCompositorForSelectionChange() { |
946 if (!RuntimeEnabledFeatures::compositedSelectionUpdateEnabled()) | 944 if (!RuntimeEnabledFeatures::compositedSelectionUpdateEnabled()) |
947 return; | 945 return; |
948 | 946 |
949 scheduleVisualUpdate(); | 947 scheduleVisualUpdate(); |
950 } | 948 } |
951 | 949 |
952 void FrameSelection::notifyEventHandlerForSelectionChange() { | 950 void FrameSelection::notifyEventHandlerForSelectionChange() { |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1038 } | 1036 } |
1039 | 1037 |
1040 void FrameSelection::updateAppearance() { | 1038 void FrameSelection::updateAppearance() { |
1041 DCHECK(!m_frame->contentLayoutItem().isNull()); | 1039 DCHECK(!m_frame->contentLayoutItem().isNull()); |
1042 m_frameCaret->scheduleVisualUpdateForPaintInvalidationIfNeeded(); | 1040 m_frameCaret->scheduleVisualUpdateForPaintInvalidationIfNeeded(); |
1043 m_pendingSelection->setHasPendingSelection(); | 1041 m_pendingSelection->setHasPendingSelection(); |
1044 } | 1042 } |
1045 | 1043 |
1046 void FrameSelection::notifyLayoutObjectOfSelectionChange( | 1044 void FrameSelection::notifyLayoutObjectOfSelectionChange( |
1047 EUserTriggered userTriggered) { | 1045 EUserTriggered userTriggered) { |
1048 if (TextControlElement* textControl = enclosingTextControl(start())) | 1046 TextControlElement* textControl = |
1049 textControl->selectionChanged(userTriggered == UserTriggered); | 1047 enclosingTextControl(selectionInDOMTree().base()); |
1048 if (!textControl) | |
1049 return; | |
1050 textControl->selectionChanged(userTriggered == UserTriggered); | |
1050 } | 1051 } |
1051 | 1052 |
1052 // Helper function that tells whether a particular node is an element that has | 1053 // Helper function that tells whether a particular node is an element that has |
1053 // an entire LocalFrame and FrameView, a <frame>, <iframe>, or <object>. | 1054 // an entire LocalFrame and FrameView, a <frame>, <iframe>, or <object>. |
1054 static bool isFrameElement(const Node* n) { | 1055 static bool isFrameElement(const Node* n) { |
1055 if (!n) | 1056 if (!n) |
1056 return false; | 1057 return false; |
1057 LayoutObject* layoutObject = n->layoutObject(); | 1058 LayoutObject* layoutObject = n->layoutObject(); |
1058 if (!layoutObject || !layoutObject->isLayoutPart()) | 1059 if (!layoutObject || !layoutObject->isLayoutPart()) |
1059 return false; | 1060 return false; |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1407 } | 1408 } |
1408 | 1409 |
1409 void showTree(const blink::FrameSelection* sel) { | 1410 void showTree(const blink::FrameSelection* sel) { |
1410 if (sel) | 1411 if (sel) |
1411 sel->showTreeForThis(); | 1412 sel->showTreeForThis(); |
1412 else | 1413 else |
1413 LOG(INFO) << "Cannot showTree for <null> FrameSelection."; | 1414 LOG(INFO) << "Cannot showTree for <null> FrameSelection."; |
1414 } | 1415 } |
1415 | 1416 |
1416 #endif | 1417 #endif |
OLD | NEW |