Chromium Code Reviews| Index: Source/core/editing/FrameSelection.cpp |
| diff --git a/Source/core/editing/FrameSelection.cpp b/Source/core/editing/FrameSelection.cpp |
| index 6183f67653c5cddc2ab1a423a11431876047f94a..9902e1a079f5ae5d5caa3b7a3b93698bd3ac3c1a 100644 |
| --- a/Source/core/editing/FrameSelection.cpp |
| +++ b/Source/core/editing/FrameSelection.cpp |
| @@ -507,6 +507,11 @@ TextDirection FrameSelection::directionOfSelection() |
| return directionOfEnclosingBlock(); |
| } |
| +void FrameSelection::didFocusChanged() |
| +{ |
| + updateAppearance(); |
| +} |
| + |
| void FrameSelection::willBeModified(EAlteration alter, SelectionDirection direction) |
| { |
| if (alter != AlterationExtend) |
| @@ -1780,12 +1785,17 @@ void FrameSelection::updateAppearance() |
| bool caretRectChangedOrCleared = recomputeCaretRect(); |
| bool caretBrowsing = m_frame->settings() && m_frame->settings()->caretBrowsingEnabled(); |
|
tkent
2013/06/28 06:46:56
The variable 'caretBrowing' is not used.
yosin_UTC9
2013/06/28 08:22:46
Done.
|
| - bool shouldBlink = caretIsVisible() && isCaret() && (isContentEditable() || caretBrowsing) && forwardPosition.isNull(); |
| + bool shouldBlink = shouldBlinkCaret() && forwardPosition.isNull(); |
| // If the caret moved, stop the blink timer so we can restart with a |
| // black caret in the new location. |
| - if (caretRectChangedOrCleared || !shouldBlink || shouldStopBlinkingDueToTypingCommand(m_frame)) |
| + if (caretRectChangedOrCleared || !shouldBlink || shouldStopBlinkingDueToTypingCommand(m_frame)) { |
| m_caretBlinkTimer.stop(); |
| + if (!shouldBlink && m_caretPaint) { |
| + m_caretPaint = false; |
| + invalidateCaretRect(); |
| + } |
| + } |
| // Start blinking with a black caret. Be sure not to restart if we're |
| // already blinking in the right location. |
| @@ -1849,6 +1859,25 @@ void FrameSelection::setCaretVisibility(CaretVisibility visibility) |
| updateAppearance(); |
| } |
| +bool FrameSelection::shouldBlinkCaret() const |
| +{ |
| + if (!caretIsVisible() || !isCaret()) |
| + return false; |
| + |
| + if (m_frame->settings() && m_frame->settings()->caretBrowsingEnabled()) |
| + return false; |
| + |
| + Node* root = rootEditableElement(); |
| + if (!root) |
| + return false; |
| + |
| + Node* focusedNode = root->document()->focusedNode(); |
| + if (!focusedNode) |
| + return false; |
| + |
| + return focusedNode->containsIncludingShadowDOM(m_selection.start().deprecatedNode()); |
|
tkent
2013/06/28 06:46:56
We should not use deprecatedNode in new code.
yosin_UTC9
2013/06/28 08:22:46
Done.
|
| +} |
| + |
| void FrameSelection::caretBlinkTimerFired(Timer<FrameSelection>*) |
| { |
| ASSERT(caretIsVisible()); |