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 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
627 | 627 |
628 m_caretBlinkTimer.stop(); | 628 m_caretBlinkTimer.stop(); |
629 | 629 |
630 LayoutView* view = m_frame->contentLayoutObject(); | 630 LayoutView* view = m_frame->contentLayoutObject(); |
631 if (view) | 631 if (view) |
632 view->clearSelection(); | 632 view->clearSelection(); |
633 | 633 |
634 setSelection(VisibleSelection(), CloseTyping | ClearTypingStyle | DoNotUpdat eAppearance); | 634 setSelection(VisibleSelection(), CloseTyping | ClearTypingStyle | DoNotUpdat eAppearance); |
635 m_selectionEditor->dispose(); | 635 m_selectionEditor->dispose(); |
636 m_previousCaretNode.clear(); | 636 m_previousCaretNode.clear(); |
637 m_parentOfPreviousCaretNode.clear(); | |
637 } | 638 } |
638 | 639 |
639 void FrameSelection::setStart(const VisiblePosition &pos, EUserTriggered trigger ) | 640 void FrameSelection::setStart(const VisiblePosition &pos, EUserTriggered trigger ) |
640 { | 641 { |
641 if (selection().isBaseFirst()) | 642 if (selection().isBaseFirst()) |
642 setBase(pos, trigger); | 643 setBase(pos, trigger); |
643 else | 644 else |
644 setExtent(pos, trigger); | 645 setExtent(pos, trigger); |
645 } | 646 } |
646 | 647 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
706 newRect = localCaretRectOfPosition(PositionWithAffinity(selection().star t(), selection().affinity()), layoutObject); | 707 newRect = localCaretRectOfPosition(PositionWithAffinity(selection().star t(), selection().affinity()), layoutObject); |
707 Node* newNode = layoutObject ? layoutObject->node() : nullptr; | 708 Node* newNode = layoutObject ? layoutObject->node() : nullptr; |
708 | 709 |
709 if (!m_caretBlinkTimer.isActive() | 710 if (!m_caretBlinkTimer.isActive() |
710 && newNode == m_previousCaretNode | 711 && newNode == m_previousCaretNode |
711 && newRect == m_previousCaretRect | 712 && newRect == m_previousCaretRect |
712 && caretVisibility() == m_previousCaretVisibility) | 713 && caretVisibility() == m_previousCaretVisibility) |
713 return; | 714 return; |
714 | 715 |
715 LayoutView* view = m_frame->document()->layoutView(); | 716 LayoutView* view = m_frame->document()->layoutView(); |
716 if (m_previousCaretNode && (shouldRepaintCaret(*m_previousCaretNode) || shou ldRepaintCaret(view))) | 717 if (m_previousCaretNode && (shouldRepaintCaret(*m_previousCaretNode) || shou ldRepaintCaret(view))) { |
717 invalidateLocalCaretRect(m_previousCaretNode.get(), m_previousCaretRect) ; | 718 invalidateLocalCaretRect(m_previousCaretNode.get(), m_previousCaretRect) ; |
718 if (newNode && (shouldRepaintCaret(*newNode) || shouldRepaintCaret(view))) | 719 m_previousCaretRect = LayoutRect(); |
720 } | |
721 if (newNode && (shouldRepaintCaret(*newNode) || shouldRepaintCaret(view))) { | |
719 invalidateLocalCaretRect(newNode, newRect); | 722 invalidateLocalCaretRect(newNode, newRect); |
723 if (!m_previousCaretRect.isEmpty() && m_previousCaretNode && !m_previous CaretNode->parentNode() | |
724 && newNode == m_parentOfPreviousCaretNode.get()) { | |
dshwang
2016/02/05 10:25:47
It means |newNode| is also detached from document.
yosin_UTC9
2016/02/12 03:53:13
I would like to have radical change. Current imple
| |
725 // Must invalidate #text even if it's detached. crbug.com/528922 | |
726 invalidateLocalCaretRect(newNode, m_previousCaretRect); | |
727 } | |
728 } | |
720 m_previousCaretNode = newNode; | 729 m_previousCaretNode = newNode; |
730 m_parentOfPreviousCaretNode = newNode ? newNode->parentNode() : nullptr; | |
721 m_previousCaretRect = newRect; | 731 m_previousCaretRect = newRect; |
722 m_previousCaretVisibility = caretVisibility(); | 732 m_previousCaretVisibility = caretVisibility(); |
723 } | 733 } |
724 | 734 |
725 void FrameSelection::paintCaret(GraphicsContext& context, const LayoutPoint& pai ntOffset) | 735 void FrameSelection::paintCaret(GraphicsContext& context, const LayoutPoint& pai ntOffset) |
726 { | 736 { |
727 if (selection().isCaret() && m_shouldPaintCaret) { | 737 if (selection().isCaret() && m_shouldPaintCaret) { |
728 updateCaretRect(PositionWithAffinity(selection().start(), selection().af finity())); | 738 updateCaretRect(PositionWithAffinity(selection().start(), selection().af finity())); |
729 CaretBase::paintCaret(selection().start().anchorNode(), context, paintOf fset); | 739 CaretBase::paintCaret(selection().start().anchorNode(), context, paintOf fset); |
730 } | 740 } |
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1321 #endif | 1331 #endif |
1322 | 1332 |
1323 DEFINE_TRACE(FrameSelection) | 1333 DEFINE_TRACE(FrameSelection) |
1324 { | 1334 { |
1325 visitor->trace(m_frame); | 1335 visitor->trace(m_frame); |
1326 visitor->trace(m_pendingSelection); | 1336 visitor->trace(m_pendingSelection); |
1327 visitor->trace(m_selectionEditor); | 1337 visitor->trace(m_selectionEditor); |
1328 visitor->trace(m_originalBase); | 1338 visitor->trace(m_originalBase); |
1329 visitor->trace(m_originalBaseInComposedTree); | 1339 visitor->trace(m_originalBaseInComposedTree); |
1330 visitor->trace(m_previousCaretNode); | 1340 visitor->trace(m_previousCaretNode); |
1341 visitor->trace(m_parentOfPreviousCaretNode); | |
1331 visitor->trace(m_typingStyle); | 1342 visitor->trace(m_typingStyle); |
1332 } | 1343 } |
1333 | 1344 |
1334 void FrameSelection::setCaretRectNeedsUpdate() | 1345 void FrameSelection::setCaretRectNeedsUpdate() |
1335 { | 1346 { |
1336 if (m_caretRectDirty) | 1347 if (m_caretRectDirty) |
1337 return; | 1348 return; |
1338 m_caretRectDirty = true; | 1349 m_caretRectDirty = true; |
1339 | 1350 |
1340 scheduleVisualUpdate(); | 1351 scheduleVisualUpdate(); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1424 | 1435 |
1425 void showTree(const blink::FrameSelection* sel) | 1436 void showTree(const blink::FrameSelection* sel) |
1426 { | 1437 { |
1427 if (sel) | 1438 if (sel) |
1428 sel->showTreeForThis(); | 1439 sel->showTreeForThis(); |
1429 else | 1440 else |
1430 fprintf(stderr, "Cannot showTree for (nil) FrameSelection.\n"); | 1441 fprintf(stderr, "Cannot showTree for (nil) FrameSelection.\n"); |
1431 } | 1442 } |
1432 | 1443 |
1433 #endif | 1444 #endif |
OLD | NEW |