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

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

Issue 437843002: Invalid caret at the end of line in overtype mode (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 4 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
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 1516 matching lines...) Expand 10 before | Expand all | Expand 10 after
1527 1527
1528 inline static bool shouldStopBlinkingDueToTypingCommand(LocalFrame* frame) 1528 inline static bool shouldStopBlinkingDueToTypingCommand(LocalFrame* frame)
1529 { 1529 {
1530 return frame->editor().lastEditCommand() && frame->editor().lastEditCommand( )->shouldStopCaretBlinking(); 1530 return frame->editor().lastEditCommand() && frame->editor().lastEditCommand( )->shouldStopCaretBlinking();
1531 } 1531 }
1532 1532
1533 void FrameSelection::updateAppearance() 1533 void FrameSelection::updateAppearance()
1534 { 1534 {
1535 // Paint a block cursor instead of a caret in overtype mode unless the caret is at the end of a line (in this case 1535 // Paint a block cursor instead of a caret in overtype mode unless the caret is at the end of a line (in this case
1536 // the FrameSelection will paint a blinking caret as usual). 1536 // the FrameSelection will paint a blinking caret as usual).
1537 VisiblePosition forwardPosition; 1537 bool paintBlockCursor = m_shouldShowBlockCursor && m_selection.isCaret() && !isLogicalEndOfLine(endForPlatform());
leviw_travelin_and_unemployed 2014/08/07 18:39:16 Since we're only using it if it's a caret, endForP
svillar 2014/08/08 09:01:25 Indeed, you're totally right.
1538 if (m_shouldShowBlockCursor && m_selection.isCaret()) {
1539 forwardPosition = modifyExtendingForward(CharacterGranularity);
1540 m_caretPaint = forwardPosition.isNull();
1541 }
1542 1538
1543 bool caretRectChangedOrCleared = recomputeCaretRect(); 1539 bool caretRectChangedOrCleared = recomputeCaretRect();
1544 bool shouldBlink = shouldBlinkCaret() && forwardPosition.isNull(); 1540 bool shouldBlink = !paintBlockCursor && shouldBlinkCaret();
1545 1541
1546 // If the caret moved, stop the blink timer so we can restart with a 1542 // If the caret moved, stop the blink timer so we can restart with a
1547 // black caret in the new location. 1543 // black caret in the new location.
1548 if (caretRectChangedOrCleared || !shouldBlink || shouldStopBlinkingDueToTypi ngCommand(m_frame)) { 1544 if (caretRectChangedOrCleared || !shouldBlink || shouldStopBlinkingDueToTypi ngCommand(m_frame)) {
1549 m_caretBlinkTimer.stop(); 1545 m_caretBlinkTimer.stop();
1550 if (!shouldBlink && m_caretPaint) { 1546 if (!shouldBlink && m_caretPaint) {
1551 m_caretPaint = false; 1547 m_caretPaint = false;
1552 invalidateCaretRect(); 1548 invalidateCaretRect();
1553 } 1549 }
1554 } 1550 }
1555 1551
1556 // Start blinking with a black caret. Be sure not to restart if we're 1552 // Start blinking with a black caret. Be sure not to restart if we're
1557 // already blinking in the right location. 1553 // already blinking in the right location.
1558 if (shouldBlink && !m_caretBlinkTimer.isActive()) { 1554 if (shouldBlink && !m_caretBlinkTimer.isActive()) {
1559 if (double blinkInterval = RenderTheme::theme().caretBlinkInterval()) 1555 if (double blinkInterval = RenderTheme::theme().caretBlinkInterval())
1560 m_caretBlinkTimer.startRepeating(blinkInterval, FROM_HERE); 1556 m_caretBlinkTimer.startRepeating(blinkInterval, FROM_HERE);
1561 1557
1562 if (!m_caretPaint) { 1558 if (!m_caretPaint) {
1563 m_caretPaint = true; 1559 m_caretPaint = true;
1564 invalidateCaretRect(); 1560 invalidateCaretRect();
1565 } 1561 }
1566 } 1562 }
1567 1563
1568 RenderView* view = m_frame->contentRenderer(); 1564 RenderView* view = m_frame->contentRenderer();
1569 if (!view) 1565 if (!view)
1570 return; 1566 return;
1571 1567
1572 // Construct a new VisibleSolution, since m_selection is not necessarily val id, and the following steps 1568 // Construct a new VisibleSolution, since m_selection is not necessarily val id, and the following steps
1573 // assume a valid selection. See <https://bugs.webkit.org/show_bug.cgi?id=69 563> and <rdar://problem/10232866>. 1569 // assume a valid selection. See <https://bugs.webkit.org/show_bug.cgi?id=69 563> and <rdar://problem/10232866>.
1574 VisibleSelection selection(m_selection.visibleStart(), forwardPosition.isNot Null() ? forwardPosition : m_selection.visibleEnd()); 1570 VisiblePosition endVisiblePosition = paintBlockCursor ? modifyExtendingForwa rd(CharacterGranularity) : m_selection.visibleEnd();
1571 VisibleSelection selection(m_selection.visibleStart(), endVisiblePosition);
1575 1572
1576 if (!selection.isRange()) { 1573 if (!selection.isRange()) {
1577 view->clearSelection(); 1574 view->clearSelection();
1578 return; 1575 return;
1579 } 1576 }
1580 1577
1581 // Use the rightmost candidate for the start of the selection, and the leftm ost candidate for the end of the selection. 1578 // Use the rightmost candidate for the start of the selection, and the leftm ost candidate for the end of the selection.
1582 // Example: foo <a>bar</a>. Imagine that a line wrap occurs after 'foo', an d that 'bar' is selected. If we pass [foo, 3] 1579 // Example: foo <a>bar</a>. Imagine that a line wrap occurs after 'foo', an d that 'bar' is selected. If we pass [foo, 3]
1583 // as the start of the selection, the selection painting code will think tha t content on the line containing 'foo' is selected 1580 // as the start of the selection, the selection painting code will think tha t content on the line containing 'foo' is selected
1584 // and will fill the gap before 'bar'. 1581 // and will fill the gap before 'bar'.
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
1918 sel.showTreeForThis(); 1915 sel.showTreeForThis();
1919 } 1916 }
1920 1917
1921 void showTree(const blink::FrameSelection* sel) 1918 void showTree(const blink::FrameSelection* sel)
1922 { 1919 {
1923 if (sel) 1920 if (sel)
1924 sel->showTreeForThis(); 1921 sel->showTreeForThis();
1925 } 1922 }
1926 1923
1927 #endif 1924 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698