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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
88 static inline bool shouldAlwaysUseDirectionalSelection(LocalFrame* frame) | 88 static inline bool shouldAlwaysUseDirectionalSelection(LocalFrame* frame) |
89 { | 89 { |
90 return !frame || frame->editor().behavior().shouldConsiderSelectionAsDirecti onal(); | 90 return !frame || frame->editor().behavior().shouldConsiderSelectionAsDirecti onal(); |
91 } | 91 } |
92 | 92 |
93 FrameSelection::FrameSelection(LocalFrame* frame) | 93 FrameSelection::FrameSelection(LocalFrame* frame) |
94 : m_frame(frame) | 94 : m_frame(frame) |
95 , m_pendingSelection(PendingSelection::create(*this)) | 95 , m_pendingSelection(PendingSelection::create(*this)) |
96 , m_selectionEditor(SelectionEditor::create(*this)) | 96 , m_selectionEditor(SelectionEditor::create(*this)) |
97 , m_granularity(CharacterGranularity) | 97 , m_granularity(CharacterGranularity) |
98 , m_parentOfPreviousCaretNode(nullptr) | |
98 , m_previousCaretVisibility(Hidden) | 99 , m_previousCaretVisibility(Hidden) |
99 , m_caretBlinkTimer(this, &FrameSelection::caretBlinkTimerFired) | 100 , m_caretBlinkTimer(this, &FrameSelection::caretBlinkTimerFired) |
100 , m_caretRectDirty(true) | 101 , m_caretRectDirty(true) |
101 , m_shouldPaintCaret(true) | 102 , m_shouldPaintCaret(true) |
102 , m_isCaretBlinkingSuspended(false) | 103 , m_isCaretBlinkingSuspended(false) |
103 , m_focused(frame && frame->page() && frame->page()->focusController().focus edFrame() == frame) | 104 , m_focused(frame && frame->page() && frame->page()->focusController().focus edFrame() == frame) |
104 , m_shouldShowBlockCursor(false) | 105 , m_shouldShowBlockCursor(false) |
105 { | 106 { |
106 if (shouldAlwaysUseDirectionalSelection(m_frame)) | 107 if (shouldAlwaysUseDirectionalSelection(m_frame)) |
107 m_selectionEditor->setIsDirectional(true); | 108 m_selectionEditor->setIsDirectional(true); |
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
627 | 628 |
628 m_caretBlinkTimer.stop(); | 629 m_caretBlinkTimer.stop(); |
629 | 630 |
630 LayoutView* view = m_frame->contentLayoutObject(); | 631 LayoutView* view = m_frame->contentLayoutObject(); |
631 if (view) | 632 if (view) |
632 view->clearSelection(); | 633 view->clearSelection(); |
633 | 634 |
634 setSelection(VisibleSelection(), CloseTyping | ClearTypingStyle | DoNotUpdat eAppearance); | 635 setSelection(VisibleSelection(), CloseTyping | ClearTypingStyle | DoNotUpdat eAppearance); |
635 m_selectionEditor->dispose(); | 636 m_selectionEditor->dispose(); |
636 m_previousCaretNode.clear(); | 637 m_previousCaretNode.clear(); |
638 m_parentOfPreviousCaretNode = nullptr; | |
637 } | 639 } |
638 | 640 |
639 void FrameSelection::setStart(const VisiblePosition &pos, EUserTriggered trigger ) | 641 void FrameSelection::setStart(const VisiblePosition &pos, EUserTriggered trigger ) |
640 { | 642 { |
641 if (selection().isBaseFirst()) | 643 if (selection().isBaseFirst()) |
642 setBase(pos, trigger); | 644 setBase(pos, trigger); |
643 else | 645 else |
644 setExtent(pos, trigger); | 646 setExtent(pos, trigger); |
645 } | 647 } |
646 | 648 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
710 && newNode == m_previousCaretNode | 712 && newNode == m_previousCaretNode |
711 && newRect == m_previousCaretRect | 713 && newRect == m_previousCaretRect |
712 && caretVisibility() == m_previousCaretVisibility) | 714 && caretVisibility() == m_previousCaretVisibility) |
713 return; | 715 return; |
714 | 716 |
715 LayoutView* view = m_frame->document()->layoutView(); | 717 LayoutView* view = m_frame->document()->layoutView(); |
716 if (m_previousCaretNode && (shouldRepaintCaret(*m_previousCaretNode) || shou ldRepaintCaret(view))) | 718 if (m_previousCaretNode && (shouldRepaintCaret(*m_previousCaretNode) || shou ldRepaintCaret(view))) |
717 invalidateLocalCaretRect(m_previousCaretNode.get(), m_previousCaretRect) ; | 719 invalidateLocalCaretRect(m_previousCaretNode.get(), m_previousCaretRect) ; |
718 if (newNode && (shouldRepaintCaret(*newNode) || shouldRepaintCaret(view))) | 720 if (newNode && (shouldRepaintCaret(*newNode) || shouldRepaintCaret(view))) |
719 invalidateLocalCaretRect(newNode, newRect); | 721 invalidateLocalCaretRect(newNode, newRect); |
722 // Must invalidate #text even if it's detached. crbug.com/528922 | |
723 if (m_previousCaretNode && newNode == m_parentOfPreviousCaretNode && !m_prev iousCaretNode->inDocument()) | |
yosin_UTC9
2016/02/05 04:04:48
This condition isn't enough, e.g.
- ancestor of
| |
724 invalidateLocalCaretRect(newNode, m_previousCaretRect); | |
720 m_previousCaretNode = newNode; | 725 m_previousCaretNode = newNode; |
726 if (newNode) | |
727 m_parentOfPreviousCaretNode = newNode->parentNode(); | |
721 m_previousCaretRect = newRect; | 728 m_previousCaretRect = newRect; |
722 m_previousCaretVisibility = caretVisibility(); | 729 m_previousCaretVisibility = caretVisibility(); |
723 } | 730 } |
724 | 731 |
725 void FrameSelection::paintCaret(GraphicsContext& context, const LayoutPoint& pai ntOffset) | 732 void FrameSelection::paintCaret(GraphicsContext& context, const LayoutPoint& pai ntOffset) |
726 { | 733 { |
727 if (selection().isCaret() && m_shouldPaintCaret) { | 734 if (selection().isCaret() && m_shouldPaintCaret) { |
728 updateCaretRect(PositionWithAffinity(selection().start(), selection().af finity())); | 735 updateCaretRect(PositionWithAffinity(selection().start(), selection().af finity())); |
729 CaretBase::paintCaret(selection().start().anchorNode(), context, paintOf fset); | 736 CaretBase::paintCaret(selection().start().anchorNode(), context, paintOf fset); |
730 } | 737 } |
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1424 | 1431 |
1425 void showTree(const blink::FrameSelection* sel) | 1432 void showTree(const blink::FrameSelection* sel) |
1426 { | 1433 { |
1427 if (sel) | 1434 if (sel) |
1428 sel->showTreeForThis(); | 1435 sel->showTreeForThis(); |
1429 else | 1436 else |
1430 fprintf(stderr, "Cannot showTree for (nil) FrameSelection.\n"); | 1437 fprintf(stderr, "Cannot showTree for (nil) FrameSelection.\n"); |
1431 } | 1438 } |
1432 | 1439 |
1433 #endif | 1440 #endif |
OLD | NEW |