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

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

Issue 2638423005: Make FrameSelection to utilize SynchronousMutationObserver (Closed)
Patch Set: 2017-01-20T19:16:11 Rebase Created 3 years, 11 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 | « third_party/WebKit/Source/core/editing/FrameSelection.h ('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) 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 17 matching lines...) Expand all
28 #include "bindings/core/v8/ExceptionState.h" 28 #include "bindings/core/v8/ExceptionState.h"
29 #include "core/HTMLNames.h" 29 #include "core/HTMLNames.h"
30 #include "core/InputTypeNames.h" 30 #include "core/InputTypeNames.h"
31 #include "core/css/StylePropertySet.h" 31 #include "core/css/StylePropertySet.h"
32 #include "core/dom/AXObjectCache.h" 32 #include "core/dom/AXObjectCache.h"
33 #include "core/dom/CharacterData.h" 33 #include "core/dom/CharacterData.h"
34 #include "core/dom/Document.h" 34 #include "core/dom/Document.h"
35 #include "core/dom/Element.h" 35 #include "core/dom/Element.h"
36 #include "core/dom/ElementTraversal.h" 36 #include "core/dom/ElementTraversal.h"
37 #include "core/dom/NodeTraversal.h" 37 #include "core/dom/NodeTraversal.h"
38 #include "core/dom/NodeWithIndex.h"
38 #include "core/dom/Text.h" 39 #include "core/dom/Text.h"
39 #include "core/editing/CaretBase.h" 40 #include "core/editing/CaretBase.h"
40 #include "core/editing/EditingUtilities.h" 41 #include "core/editing/EditingUtilities.h"
41 #include "core/editing/Editor.h" 42 #include "core/editing/Editor.h"
42 #include "core/editing/FrameCaret.h" 43 #include "core/editing/FrameCaret.h"
43 #include "core/editing/GranularityStrategy.h" 44 #include "core/editing/GranularityStrategy.h"
44 #include "core/editing/InputMethodController.h" 45 #include "core/editing/InputMethodController.h"
45 #include "core/editing/PendingSelection.h" 46 #include "core/editing/PendingSelection.h"
46 #include "core/editing/SelectionController.h" 47 #include "core/editing/SelectionController.h"
47 #include "core/editing/SelectionEditor.h" 48 #include "core/editing/SelectionEditor.h"
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 544
544 if (position.anchorNode() == &oldNode) 545 if (position.anchorNode() == &oldNode)
545 return Position(toText(oldNode.previousSibling()), positionOffset + offset); 546 return Position(toText(oldNode.previousSibling()), positionOffset + offset);
546 547
547 if (position.anchorNode() == oldNode.parentNode() && positionOffset == offset) 548 if (position.anchorNode() == oldNode.parentNode() && positionOffset == offset)
548 return Position(toText(oldNode.previousSibling()), offset); 549 return Position(toText(oldNode.previousSibling()), offset);
549 550
550 return position; 551 return position;
551 } 552 }
552 553
553 void FrameSelection::didMergeTextNodes(const Text& oldNode, unsigned offset) { 554 void FrameSelection::didMergeTextNodes(
555 const Text& mergedNode,
556 const NodeWithIndex& nodeToBeRemovedWithIndex,
557 unsigned offset) {
558 const Text& oldNode = toText(nodeToBeRemovedWithIndex.node());
554 if (isNone() || !oldNode.isConnected()) 559 if (isNone() || !oldNode.isConnected())
555 return; 560 return;
556 Position base = updatePostionAfterAdoptingTextNodesMerged(selection().base(), 561 Position base = updatePostionAfterAdoptingTextNodesMerged(selection().base(),
557 oldNode, offset); 562 oldNode, offset);
558 Position extent = updatePostionAfterAdoptingTextNodesMerged( 563 Position extent = updatePostionAfterAdoptingTextNodesMerged(
559 selection().extent(), oldNode, offset); 564 selection().extent(), oldNode, offset);
560 Position start = updatePostionAfterAdoptingTextNodesMerged( 565 Position start = updatePostionAfterAdoptingTextNodesMerged(
561 selection().start(), oldNode, offset); 566 selection().start(), oldNode, offset);
562 Position end = updatePostionAfterAdoptingTextNodesMerged(selection().end(), 567 Position end = updatePostionAfterAdoptingTextNodesMerged(selection().end(),
563 oldNode, offset); 568 oldNode, offset);
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
703 setSelection(SelectionInDOMTree()); 708 setSelection(SelectionInDOMTree());
704 } 709 }
705 710
706 void FrameSelection::documentAttached(Document* document) { 711 void FrameSelection::documentAttached(Document* document) {
707 DCHECK(document); 712 DCHECK(document);
708 DCHECK(!m_document) << "FrameSelection is already attached to " << m_document; 713 DCHECK(!m_document) << "FrameSelection is already attached to " << m_document;
709 m_document = document; 714 m_document = document;
710 m_useSecureKeyboardEntryWhenActive = false; 715 m_useSecureKeyboardEntryWhenActive = false;
711 m_selectionEditor->documentAttached(document); 716 m_selectionEditor->documentAttached(document);
712 m_frameCaret->documentAttached(document); 717 m_frameCaret->documentAttached(document);
718 setContext(document);
713 } 719 }
714 720
715 void FrameSelection::documentDetached(const Document& document) { 721 void FrameSelection::contextDestroyed(Document* document) {
716 DCHECK_EQ(m_document, document); 722 DCHECK_EQ(m_document, document);
717 m_document = nullptr; 723 m_document = nullptr;
718 m_granularity = CharacterGranularity; 724 m_granularity = CharacterGranularity;
719 725
720 LayoutViewItem view = m_frame->contentLayoutItem(); 726 LayoutViewItem view = m_frame->contentLayoutItem();
721 if (!view.isNull()) 727 if (!view.isNull())
722 view.clearSelection(); 728 view.clearSelection();
723 729
724 clearTypingStyle(); 730 clearTypingStyle();
725 m_selectionEditor->documentDetached(document); 731 m_selectionEditor->documentDetached(*document);
726 } 732 }
727 733
728 LayoutBlock* FrameSelection::caretLayoutObject() const { 734 LayoutBlock* FrameSelection::caretLayoutObject() const {
729 DCHECK(selection().isValidFor(document())); 735 DCHECK(selection().isValidFor(document()));
730 if (!isCaret()) 736 if (!isCaret())
731 return nullptr; 737 return nullptr;
732 return CaretBase::caretLayoutObject(selection().start().anchorNode()); 738 return CaretBase::caretLayoutObject(selection().start().anchorNode());
733 } 739 }
734 740
735 IntRect FrameSelection::absoluteCaretBounds() { 741 IntRect FrameSelection::absoluteCaretBounds() {
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after
1287 1293
1288 #endif 1294 #endif
1289 1295
1290 DEFINE_TRACE(FrameSelection) { 1296 DEFINE_TRACE(FrameSelection) {
1291 visitor->trace(m_document); 1297 visitor->trace(m_document);
1292 visitor->trace(m_frame); 1298 visitor->trace(m_frame);
1293 visitor->trace(m_pendingSelection); 1299 visitor->trace(m_pendingSelection);
1294 visitor->trace(m_selectionEditor); 1300 visitor->trace(m_selectionEditor);
1295 visitor->trace(m_typingStyle); 1301 visitor->trace(m_typingStyle);
1296 visitor->trace(m_frameCaret); 1302 visitor->trace(m_frameCaret);
1303 SynchronousMutationObserver::trace(visitor);
1297 } 1304 }
1298 1305
1299 void FrameSelection::scheduleVisualUpdate() const { 1306 void FrameSelection::scheduleVisualUpdate() const {
1300 if (Page* page = m_frame->page()) 1307 if (Page* page = m_frame->page())
1301 page->animator().scheduleVisualUpdate(m_frame->localFrameRoot()); 1308 page->animator().scheduleVisualUpdate(m_frame->localFrameRoot());
1302 } 1309 }
1303 1310
1304 bool FrameSelection::selectWordAroundPosition(const VisiblePosition& position) { 1311 bool FrameSelection::selectWordAroundPosition(const VisiblePosition& position) {
1305 static const EWordSide wordSideList[2] = {RightWordIfOnBoundary, 1312 static const EWordSide wordSideList[2] = {RightWordIfOnBoundary,
1306 LeftWordIfOnBoundary}; 1313 LeftWordIfOnBoundary};
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
1419 } 1426 }
1420 1427
1421 void showTree(const blink::FrameSelection* sel) { 1428 void showTree(const blink::FrameSelection* sel) {
1422 if (sel) 1429 if (sel)
1423 sel->showTreeForThis(); 1430 sel->showTreeForThis();
1424 else 1431 else
1425 LOG(INFO) << "Cannot showTree for <null> FrameSelection."; 1432 LOG(INFO) << "Cannot showTree for <null> FrameSelection.";
1426 } 1433 }
1427 1434
1428 #endif 1435 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/editing/FrameSelection.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698