| 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 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 500 if (startPosition.isNotNull()) | 500 if (startPosition.isNotNull()) |
| 501 startPosition.getInlineBoxAndOffset(startBox, unusedOffset); | 501 startPosition.getInlineBoxAndOffset(startBox, unusedOffset); |
| 502 if (endPosition.isNotNull()) | 502 if (endPosition.isNotNull()) |
| 503 endPosition.getInlineBoxAndOffset(endBox, unusedOffset); | 503 endPosition.getInlineBoxAndOffset(endBox, unusedOffset); |
| 504 if (startBox && endBox && startBox->direction() == endBox->direction()) | 504 if (startBox && endBox && startBox->direction() == endBox->direction()) |
| 505 return startBox->direction(); | 505 return startBox->direction(); |
| 506 | 506 |
| 507 return directionOfEnclosingBlock(); | 507 return directionOfEnclosingBlock(); |
| 508 } | 508 } |
| 509 | 509 |
| 510 void FrameSelection::didChangeFocus() |
| 511 { |
| 512 updateAppearance(); |
| 513 } |
| 514 |
| 510 void FrameSelection::willBeModified(EAlteration alter, SelectionDirection direct
ion) | 515 void FrameSelection::willBeModified(EAlteration alter, SelectionDirection direct
ion) |
| 511 { | 516 { |
| 512 if (alter != AlterationExtend) | 517 if (alter != AlterationExtend) |
| 513 return; | 518 return; |
| 514 | 519 |
| 515 Position start = m_selection.start(); | 520 Position start = m_selection.start(); |
| 516 Position end = m_selection.end(); | 521 Position end = m_selection.end(); |
| 517 | 522 |
| 518 bool baseIsStart = true; | 523 bool baseIsStart = true; |
| 519 | 524 |
| (...skipping 1251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1771 { | 1776 { |
| 1772 // Paint a block cursor instead of a caret in overtype mode unless the caret
is at the end of a line (in this case | 1777 // Paint a block cursor instead of a caret in overtype mode unless the caret
is at the end of a line (in this case |
| 1773 // the FrameSelection will paint a blinking caret as usual). | 1778 // the FrameSelection will paint a blinking caret as usual). |
| 1774 VisiblePosition forwardPosition; | 1779 VisiblePosition forwardPosition; |
| 1775 if (m_shouldShowBlockCursor && m_selection.isCaret()) { | 1780 if (m_shouldShowBlockCursor && m_selection.isCaret()) { |
| 1776 forwardPosition = modifyExtendingForward(CharacterGranularity); | 1781 forwardPosition = modifyExtendingForward(CharacterGranularity); |
| 1777 m_caretPaint = forwardPosition.isNull(); | 1782 m_caretPaint = forwardPosition.isNull(); |
| 1778 } | 1783 } |
| 1779 | 1784 |
| 1780 bool caretRectChangedOrCleared = recomputeCaretRect(); | 1785 bool caretRectChangedOrCleared = recomputeCaretRect(); |
| 1781 | 1786 bool shouldBlink = shouldBlinkCaret() && forwardPosition.isNull(); |
| 1782 bool caretBrowsing = m_frame->settings() && m_frame->settings()->caretBrowsi
ngEnabled(); | |
| 1783 bool shouldBlink = caretIsVisible() && isCaret() && (isContentEditable() ||
caretBrowsing) && forwardPosition.isNull(); | |
| 1784 | 1787 |
| 1785 // If the caret moved, stop the blink timer so we can restart with a | 1788 // If the caret moved, stop the blink timer so we can restart with a |
| 1786 // black caret in the new location. | 1789 // black caret in the new location. |
| 1787 if (caretRectChangedOrCleared || !shouldBlink || shouldStopBlinkingDueToTypi
ngCommand(m_frame)) | 1790 if (caretRectChangedOrCleared || !shouldBlink || shouldStopBlinkingDueToTypi
ngCommand(m_frame)) { |
| 1788 m_caretBlinkTimer.stop(); | 1791 m_caretBlinkTimer.stop(); |
| 1792 if (!shouldBlink && m_caretPaint) { |
| 1793 m_caretPaint = false; |
| 1794 invalidateCaretRect(); |
| 1795 } |
| 1796 } |
| 1789 | 1797 |
| 1790 // Start blinking with a black caret. Be sure not to restart if we're | 1798 // Start blinking with a black caret. Be sure not to restart if we're |
| 1791 // already blinking in the right location. | 1799 // already blinking in the right location. |
| 1792 if (shouldBlink && !m_caretBlinkTimer.isActive()) { | 1800 if (shouldBlink && !m_caretBlinkTimer.isActive()) { |
| 1793 if (double blinkInterval = m_frame->page()->theme()->caretBlinkInterval(
)) | 1801 if (double blinkInterval = m_frame->page()->theme()->caretBlinkInterval(
)) |
| 1794 m_caretBlinkTimer.startRepeating(blinkInterval); | 1802 m_caretBlinkTimer.startRepeating(blinkInterval); |
| 1795 | 1803 |
| 1796 if (!m_caretPaint) { | 1804 if (!m_caretPaint) { |
| 1797 m_caretPaint = true; | 1805 m_caretPaint = true; |
| 1798 invalidateCaretRect(); | 1806 invalidateCaretRect(); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1842 m_frame->document()->updateLayoutIgnorePendingStylesheets(); | 1850 m_frame->document()->updateLayoutIgnorePendingStylesheets(); |
| 1843 if (m_caretPaint) { | 1851 if (m_caretPaint) { |
| 1844 m_caretPaint = false; | 1852 m_caretPaint = false; |
| 1845 invalidateCaretRect(); | 1853 invalidateCaretRect(); |
| 1846 } | 1854 } |
| 1847 CaretBase::setCaretVisibility(visibility); | 1855 CaretBase::setCaretVisibility(visibility); |
| 1848 | 1856 |
| 1849 updateAppearance(); | 1857 updateAppearance(); |
| 1850 } | 1858 } |
| 1851 | 1859 |
| 1860 bool FrameSelection::shouldBlinkCaret() const |
| 1861 { |
| 1862 if (!caretIsVisible() || !isCaret()) |
| 1863 return false; |
| 1864 |
| 1865 if (m_frame->settings() && m_frame->settings()->caretBrowsingEnabled()) |
| 1866 return false; |
| 1867 |
| 1868 Node* root = rootEditableElement(); |
| 1869 if (!root) |
| 1870 return false; |
| 1871 |
| 1872 Node* focusedNode = root->document()->focusedNode(); |
| 1873 if (!focusedNode) |
| 1874 return false; |
| 1875 |
| 1876 return focusedNode->containsIncludingShadowDOM(m_selection.start().anchorNod
e()); |
| 1877 } |
| 1878 |
| 1852 void FrameSelection::caretBlinkTimerFired(Timer<FrameSelection>*) | 1879 void FrameSelection::caretBlinkTimerFired(Timer<FrameSelection>*) |
| 1853 { | 1880 { |
| 1854 ASSERT(caretIsVisible()); | 1881 ASSERT(caretIsVisible()); |
| 1855 ASSERT(isCaret()); | 1882 ASSERT(isCaret()); |
| 1856 bool caretPaint = m_caretPaint; | 1883 bool caretPaint = m_caretPaint; |
| 1857 if (isCaretBlinkingSuspended() && caretPaint) | 1884 if (isCaretBlinkingSuspended() && caretPaint) |
| 1858 return; | 1885 return; |
| 1859 m_caretPaint = !caretPaint; | 1886 m_caretPaint = !caretPaint; |
| 1860 invalidateCaretRect(); | 1887 invalidateCaretRect(); |
| 1861 } | 1888 } |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2097 sel.showTreeForThis(); | 2124 sel.showTreeForThis(); |
| 2098 } | 2125 } |
| 2099 | 2126 |
| 2100 void showTree(const WebCore::FrameSelection* sel) | 2127 void showTree(const WebCore::FrameSelection* sel) |
| 2101 { | 2128 { |
| 2102 if (sel) | 2129 if (sel) |
| 2103 sel->showTreeForThis(); | 2130 sel->showTreeForThis(); |
| 2104 } | 2131 } |
| 2105 | 2132 |
| 2106 #endif | 2133 #endif |
| OLD | NEW |