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 1526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1537 | 1537 |
1538 inline static bool shouldStopBlinkingDueToTypingCommand(LocalFrame* frame) | 1538 inline static bool shouldStopBlinkingDueToTypingCommand(LocalFrame* frame) |
1539 { | 1539 { |
1540 return frame->editor().lastEditCommand() && frame->editor().lastEditCommand(
)->shouldStopCaretBlinking(); | 1540 return frame->editor().lastEditCommand() && frame->editor().lastEditCommand(
)->shouldStopCaretBlinking(); |
1541 } | 1541 } |
1542 | 1542 |
1543 void FrameSelection::updateAppearance() | 1543 void FrameSelection::updateAppearance() |
1544 { | 1544 { |
1545 // Paint a block cursor instead of a caret in overtype mode unless the caret
is at the end of a line (in this case | 1545 // Paint a block cursor instead of a caret in overtype mode unless the caret
is at the end of a line (in this case |
1546 // the FrameSelection will paint a blinking caret as usual). | 1546 // the FrameSelection will paint a blinking caret as usual). |
1547 VisiblePosition forwardPosition; | 1547 bool paintBlockCursor = m_shouldShowBlockCursor && m_selection.isCaret() &&
!isLogicalEndOfLine(m_selection.visibleEnd()); |
1548 if (m_shouldShowBlockCursor && m_selection.isCaret()) { | |
1549 forwardPosition = modifyExtendingForward(CharacterGranularity); | |
1550 m_caretPaint = forwardPosition.isNull(); | |
1551 } | |
1552 | 1548 |
1553 bool caretRectChangedOrCleared = recomputeCaretRect(); | 1549 bool caretRectChangedOrCleared = recomputeCaretRect(); |
1554 bool shouldBlink = shouldBlinkCaret() && forwardPosition.isNull(); | 1550 bool shouldBlink = !paintBlockCursor && shouldBlinkCaret(); |
1555 | 1551 |
1556 // If the caret moved, stop the blink timer so we can restart with a | 1552 // If the caret moved, stop the blink timer so we can restart with a |
1557 // black caret in the new location. | 1553 // black caret in the new location. |
1558 if (caretRectChangedOrCleared || !shouldBlink || shouldStopBlinkingDueToTypi
ngCommand(m_frame)) { | 1554 if (caretRectChangedOrCleared || !shouldBlink || shouldStopBlinkingDueToTypi
ngCommand(m_frame)) { |
1559 m_caretBlinkTimer.stop(); | 1555 m_caretBlinkTimer.stop(); |
1560 if (!shouldBlink && m_caretPaint) { | 1556 if (!shouldBlink && m_caretPaint) { |
1561 m_caretPaint = false; | 1557 m_caretPaint = false; |
1562 invalidateCaretRect(); | 1558 invalidateCaretRect(); |
1563 } | 1559 } |
1564 } | 1560 } |
1565 | 1561 |
1566 // Start blinking with a black caret. Be sure not to restart if we're | 1562 // Start blinking with a black caret. Be sure not to restart if we're |
1567 // already blinking in the right location. | 1563 // already blinking in the right location. |
1568 if (shouldBlink && !m_caretBlinkTimer.isActive()) { | 1564 if (shouldBlink && !m_caretBlinkTimer.isActive()) { |
1569 if (double blinkInterval = RenderTheme::theme().caretBlinkInterval()) | 1565 if (double blinkInterval = RenderTheme::theme().caretBlinkInterval()) |
1570 m_caretBlinkTimer.startRepeating(blinkInterval, FROM_HERE); | 1566 m_caretBlinkTimer.startRepeating(blinkInterval, FROM_HERE); |
1571 | 1567 |
1572 if (!m_caretPaint) { | 1568 if (!m_caretPaint) { |
1573 m_caretPaint = true; | 1569 m_caretPaint = true; |
1574 invalidateCaretRect(); | 1570 invalidateCaretRect(); |
1575 } | 1571 } |
1576 } | 1572 } |
1577 | 1573 |
1578 RenderView* view = m_frame->contentRenderer(); | 1574 RenderView* view = m_frame->contentRenderer(); |
1579 if (!view) | 1575 if (!view) |
1580 return; | 1576 return; |
1581 | 1577 |
1582 // Construct a new VisibleSolution, since m_selection is not necessarily val
id, and the following steps | 1578 // Construct a new VisibleSolution, since m_selection is not necessarily val
id, and the following steps |
1583 // assume a valid selection. See <https://bugs.webkit.org/show_bug.cgi?id=69
563> and <rdar://problem/10232866>. | 1579 // assume a valid selection. See <https://bugs.webkit.org/show_bug.cgi?id=69
563> and <rdar://problem/10232866>. |
1584 VisibleSelection selection(m_selection.visibleStart(), forwardPosition.isNot
Null() ? forwardPosition : m_selection.visibleEnd()); | 1580 VisiblePosition endVisiblePosition = paintBlockCursor ? modifyExtendingForwa
rd(CharacterGranularity) : m_selection.visibleEnd(); |
| 1581 VisibleSelection selection(m_selection.visibleStart(), endVisiblePosition); |
1585 | 1582 |
1586 if (!selection.isRange()) { | 1583 if (!selection.isRange()) { |
1587 view->clearSelection(); | 1584 view->clearSelection(); |
1588 return; | 1585 return; |
1589 } | 1586 } |
1590 | 1587 |
1591 // Use the rightmost candidate for the start of the selection, and the leftm
ost candidate for the end of the selection. | 1588 // Use the rightmost candidate for the start of the selection, and the leftm
ost candidate for the end of the selection. |
1592 // Example: foo <a>bar</a>. Imagine that a line wrap occurs after 'foo', an
d that 'bar' is selected. If we pass [foo, 3] | 1589 // Example: foo <a>bar</a>. Imagine that a line wrap occurs after 'foo', an
d that 'bar' is selected. If we pass [foo, 3] |
1593 // as the start of the selection, the selection painting code will think tha
t content on the line containing 'foo' is selected | 1590 // as the start of the selection, the selection painting code will think tha
t content on the line containing 'foo' is selected |
1594 // and will fill the gap before 'bar'. | 1591 // and will fill the gap before 'bar'. |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1927 sel.showTreeForThis(); | 1924 sel.showTreeForThis(); |
1928 } | 1925 } |
1929 | 1926 |
1930 void showTree(const blink::FrameSelection* sel) | 1927 void showTree(const blink::FrameSelection* sel) |
1931 { | 1928 { |
1932 if (sel) | 1929 if (sel) |
1933 sel->showTreeForThis(); | 1930 sel->showTreeForThis(); |
1934 } | 1931 } |
1935 | 1932 |
1936 #endif | 1933 #endif |
OLD | NEW |