Chromium Code Reviews| 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::didFocusChanged() | |
| 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 1252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 |
| 1782 bool caretBrowsing = m_frame->settings() && m_frame->settings()->caretBrowsi ngEnabled(); | 1787 bool caretBrowsing = m_frame->settings() && m_frame->settings()->caretBrowsi ngEnabled(); |
|
tkent
2013/06/28 06:46:56
The variable 'caretBrowing' is not used.
yosin_UTC9
2013/06/28 08:22:46
Done.
| |
| 1783 bool shouldBlink = caretIsVisible() && isCaret() && (isContentEditable() || caretBrowsing) && forwardPosition.isNull(); | 1788 bool shouldBlink = shouldBlinkCaret() && forwardPosition.isNull(); |
| 1784 | 1789 |
| 1785 // If the caret moved, stop the blink timer so we can restart with a | 1790 // If the caret moved, stop the blink timer so we can restart with a |
| 1786 // black caret in the new location. | 1791 // black caret in the new location. |
| 1787 if (caretRectChangedOrCleared || !shouldBlink || shouldStopBlinkingDueToTypi ngCommand(m_frame)) | 1792 if (caretRectChangedOrCleared || !shouldBlink || shouldStopBlinkingDueToTypi ngCommand(m_frame)) { |
| 1788 m_caretBlinkTimer.stop(); | 1793 m_caretBlinkTimer.stop(); |
| 1794 if (!shouldBlink && m_caretPaint) { | |
| 1795 m_caretPaint = false; | |
| 1796 invalidateCaretRect(); | |
| 1797 } | |
| 1798 } | |
| 1789 | 1799 |
| 1790 // Start blinking with a black caret. Be sure not to restart if we're | 1800 // Start blinking with a black caret. Be sure not to restart if we're |
| 1791 // already blinking in the right location. | 1801 // already blinking in the right location. |
| 1792 if (shouldBlink && !m_caretBlinkTimer.isActive()) { | 1802 if (shouldBlink && !m_caretBlinkTimer.isActive()) { |
| 1793 if (double blinkInterval = m_frame->page()->theme()->caretBlinkInterval( )) | 1803 if (double blinkInterval = m_frame->page()->theme()->caretBlinkInterval( )) |
| 1794 m_caretBlinkTimer.startRepeating(blinkInterval); | 1804 m_caretBlinkTimer.startRepeating(blinkInterval); |
| 1795 | 1805 |
| 1796 if (!m_caretPaint) { | 1806 if (!m_caretPaint) { |
| 1797 m_caretPaint = true; | 1807 m_caretPaint = true; |
| 1798 invalidateCaretRect(); | 1808 invalidateCaretRect(); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1842 m_frame->document()->updateLayoutIgnorePendingStylesheets(); | 1852 m_frame->document()->updateLayoutIgnorePendingStylesheets(); |
| 1843 if (m_caretPaint) { | 1853 if (m_caretPaint) { |
| 1844 m_caretPaint = false; | 1854 m_caretPaint = false; |
| 1845 invalidateCaretRect(); | 1855 invalidateCaretRect(); |
| 1846 } | 1856 } |
| 1847 CaretBase::setCaretVisibility(visibility); | 1857 CaretBase::setCaretVisibility(visibility); |
| 1848 | 1858 |
| 1849 updateAppearance(); | 1859 updateAppearance(); |
| 1850 } | 1860 } |
| 1851 | 1861 |
| 1862 bool FrameSelection::shouldBlinkCaret() const | |
| 1863 { | |
| 1864 if (!caretIsVisible() || !isCaret()) | |
| 1865 return false; | |
| 1866 | |
| 1867 if (m_frame->settings() && m_frame->settings()->caretBrowsingEnabled()) | |
| 1868 return false; | |
| 1869 | |
| 1870 Node* root = rootEditableElement(); | |
| 1871 if (!root) | |
| 1872 return false; | |
| 1873 | |
| 1874 Node* focusedNode = root->document()->focusedNode(); | |
| 1875 if (!focusedNode) | |
| 1876 return false; | |
| 1877 | |
| 1878 return focusedNode->containsIncludingShadowDOM(m_selection.start().deprecate dNode()); | |
|
tkent
2013/06/28 06:46:56
We should not use deprecatedNode in new code.
yosin_UTC9
2013/06/28 08:22:46
Done.
| |
| 1879 } | |
| 1880 | |
| 1852 void FrameSelection::caretBlinkTimerFired(Timer<FrameSelection>*) | 1881 void FrameSelection::caretBlinkTimerFired(Timer<FrameSelection>*) |
| 1853 { | 1882 { |
| 1854 ASSERT(caretIsVisible()); | 1883 ASSERT(caretIsVisible()); |
| 1855 ASSERT(isCaret()); | 1884 ASSERT(isCaret()); |
| 1856 bool caretPaint = m_caretPaint; | 1885 bool caretPaint = m_caretPaint; |
| 1857 if (isCaretBlinkingSuspended() && caretPaint) | 1886 if (isCaretBlinkingSuspended() && caretPaint) |
| 1858 return; | 1887 return; |
| 1859 m_caretPaint = !caretPaint; | 1888 m_caretPaint = !caretPaint; |
| 1860 invalidateCaretRect(); | 1889 invalidateCaretRect(); |
| 1861 } | 1890 } |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2097 sel.showTreeForThis(); | 2126 sel.showTreeForThis(); |
| 2098 } | 2127 } |
| 2099 | 2128 |
| 2100 void showTree(const WebCore::FrameSelection* sel) | 2129 void showTree(const WebCore::FrameSelection* sel) |
| 2101 { | 2130 { |
| 2102 if (sel) | 2131 if (sel) |
| 2103 sel->showTreeForThis(); | 2132 sel->showTreeForThis(); |
| 2104 } | 2133 } |
| 2105 | 2134 |
| 2106 #endif | 2135 #endif |
| OLD | NEW |