Chromium Code Reviews| 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 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 396 // being removed, the selection in the document that created the fragment | 396 // being removed, the selection in the document that created the fragment |
| 397 // needs no adjustment. | 397 // needs no adjustment. |
| 398 if (isNone() || !node.inActiveDocument()) | 398 if (isNone() || !node.inActiveDocument()) |
| 399 return; | 399 return; |
| 400 | 400 |
| 401 respondToNodeModification( | 401 respondToNodeModification( |
| 402 node, removingNodeRemovesPosition(node, selection().base()), | 402 node, removingNodeRemovesPosition(node, selection().base()), |
| 403 removingNodeRemovesPosition(node, selection().extent()), | 403 removingNodeRemovesPosition(node, selection().extent()), |
| 404 removingNodeRemovesPosition(node, selection().start()), | 404 removingNodeRemovesPosition(node, selection().start()), |
| 405 removingNodeRemovesPosition(node, selection().end())); | 405 removingNodeRemovesPosition(node, selection().end())); |
| 406 | |
| 407 m_frameCaret->nodeWillBeRemoved(node); | |
|
yoichio
2017/01/20 08:44:00
I'm afraid if there is race condition between
Fr
yosin_UTC9
2017/01/20 08:49:14
|FrameCaret::nodeWillBeRemoved()| doesn't access |
| |
| 408 } | 406 } |
| 409 | 407 |
| 410 static SelectionState selectionStateOf(const Node& node) { | 408 static SelectionState selectionStateOf(const Node& node) { |
| 411 const LayoutObject* layoutObject = node.layoutObject(); | 409 const LayoutObject* layoutObject = node.layoutObject(); |
| 412 if (!layoutObject) | 410 if (!layoutObject) |
| 413 return SelectionNone; | 411 return SelectionNone; |
| 414 return layoutObject->getSelectionState(); | 412 return layoutObject->getSelectionState(); |
| 415 } | 413 } |
| 416 | 414 |
| 417 void FrameSelection::respondToNodeModification(Node& node, | 415 void FrameSelection::respondToNodeModification(Node& node, |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 462 clearLayoutTreeSelection = true; | 460 clearLayoutTreeSelection = true; |
| 463 } | 461 } |
| 464 | 462 |
| 465 if (clearLayoutTreeSelection) | 463 if (clearLayoutTreeSelection) |
| 466 selection().start().document()->layoutViewItem().clearSelection(); | 464 selection().start().document()->layoutViewItem().clearSelection(); |
| 467 | 465 |
| 468 if (clearDOMTreeSelection) | 466 if (clearDOMTreeSelection) |
| 469 setSelection(SelectionInDOMTree(), DoNotSetFocus); | 467 setSelection(SelectionInDOMTree(), DoNotSetFocus); |
| 470 m_frameCaret->setCaretRectNeedsUpdate(); | 468 m_frameCaret->setCaretRectNeedsUpdate(); |
| 471 | 469 |
| 472 // TODO(yosin): We should move to call |TypingCommand::closeTyping()| to | 470 // TODO(yosin): We should move to call |TypingCommand::closeTyping()| to |
|
Xiaocheng
2017/01/20 08:56:53
Is this OK?
Do we need to cleanup the access from
yosin_UTC9
2017/01/20 09:09:39
Multiple calls of FrameCaret::setCaretRectNeedsUpd
| |
| 473 // |Editor| class. | 471 // |Editor| class. |
| 474 if (!document().isRunningExecCommand()) | 472 if (!document().isRunningExecCommand()) |
| 475 TypingCommand::closeTyping(m_frame); | 473 TypingCommand::closeTyping(m_frame); |
| 476 } | 474 } |
| 477 | 475 |
| 478 static Position updatePositionAfterAdoptingTextReplacement( | 476 static Position updatePositionAfterAdoptingTextReplacement( |
| 479 const Position& position, | 477 const Position& position, |
| 480 CharacterData* node, | 478 CharacterData* node, |
| 481 unsigned offset, | 479 unsigned offset, |
| 482 unsigned oldLength, | 480 unsigned oldLength, |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 704 m_granularityStrategy->Clear(); | 702 m_granularityStrategy->Clear(); |
| 705 setSelection(SelectionInDOMTree()); | 703 setSelection(SelectionInDOMTree()); |
| 706 } | 704 } |
| 707 | 705 |
| 708 void FrameSelection::documentAttached(Document* document) { | 706 void FrameSelection::documentAttached(Document* document) { |
| 709 DCHECK(document); | 707 DCHECK(document); |
| 710 DCHECK(!m_document) << "FrameSelection is already attached to " << m_document; | 708 DCHECK(!m_document) << "FrameSelection is already attached to " << m_document; |
| 711 m_document = document; | 709 m_document = document; |
| 712 m_useSecureKeyboardEntryWhenActive = false; | 710 m_useSecureKeyboardEntryWhenActive = false; |
| 713 m_selectionEditor->documentAttached(document); | 711 m_selectionEditor->documentAttached(document); |
| 712 m_frameCaret->documentAttached(document); | |
| 714 } | 713 } |
| 715 | 714 |
| 716 void FrameSelection::documentDetached(const Document& document) { | 715 void FrameSelection::documentDetached(const Document& document) { |
| 717 DCHECK_EQ(m_document, document); | 716 DCHECK_EQ(m_document, document); |
| 718 m_document = nullptr; | 717 m_document = nullptr; |
| 719 m_granularity = CharacterGranularity; | 718 m_granularity = CharacterGranularity; |
| 720 | 719 |
| 721 LayoutViewItem view = m_frame->contentLayoutItem(); | 720 LayoutViewItem view = m_frame->contentLayoutItem(); |
| 722 if (!view.isNull()) | 721 if (!view.isNull()) |
| 723 view.clearSelection(); | 722 view.clearSelection(); |
| 724 | 723 |
| 725 clearTypingStyle(); | 724 clearTypingStyle(); |
| 726 m_selectionEditor->documentDetached(document); | 725 m_selectionEditor->documentDetached(document); |
| 727 m_frameCaret->documentDetached(); | |
| 728 } | 726 } |
| 729 | 727 |
| 730 LayoutBlock* FrameSelection::caretLayoutObject() const { | 728 LayoutBlock* FrameSelection::caretLayoutObject() const { |
| 731 DCHECK(selection().isValidFor(document())); | 729 DCHECK(selection().isValidFor(document())); |
| 732 if (!isCaret()) | 730 if (!isCaret()) |
| 733 return nullptr; | 731 return nullptr; |
| 734 return CaretBase::caretLayoutObject(selection().start().anchorNode()); | 732 return CaretBase::caretLayoutObject(selection().start().anchorNode()); |
| 735 } | 733 } |
| 736 | 734 |
| 737 IntRect FrameSelection::absoluteCaretBounds() { | 735 IntRect FrameSelection::absoluteCaretBounds() { |
| (...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1421 } | 1419 } |
| 1422 | 1420 |
| 1423 void showTree(const blink::FrameSelection* sel) { | 1421 void showTree(const blink::FrameSelection* sel) { |
| 1424 if (sel) | 1422 if (sel) |
| 1425 sel->showTreeForThis(); | 1423 sel->showTreeForThis(); |
| 1426 else | 1424 else |
| 1427 LOG(INFO) << "Cannot showTree for <null> FrameSelection."; | 1425 LOG(INFO) << "Cannot showTree for <null> FrameSelection."; |
| 1428 } | 1426 } |
| 1429 | 1427 |
| 1430 #endif | 1428 #endif |
| OLD | NEW |