| 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 | 74 |
| 75 inline static bool shouldStopBlinkingDueToTypingCommand(LocalFrame* frame) { | 75 inline static bool shouldStopBlinkingDueToTypingCommand(LocalFrame* frame) { |
| 76 return frame->editor().lastEditCommand() && | 76 return frame->editor().lastEditCommand() && |
| 77 frame->editor().lastEditCommand()->shouldStopCaretBlinking(); | 77 frame->editor().lastEditCommand()->shouldStopCaretBlinking(); |
| 78 } | 78 } |
| 79 | 79 |
| 80 void FrameCaret::updateAppearance() { | 80 void FrameCaret::updateAppearance() { |
| 81 // Paint a block cursor instead of a caret in overtype mode unless the caret | 81 // Paint a block cursor instead of a caret in overtype mode unless the caret |
| 82 // is at the end of a line (in this case the FrameSelection will paint a | 82 // is at the end of a line (in this case the FrameSelection will paint a |
| 83 // blinking caret as usual). | 83 // blinking caret as usual). |
| 84 bool paintBlockCursor = | 84 bool paintBlockCursor = m_shouldShowBlockCursor && isActive(); |
| 85 m_shouldShowBlockCursor && isActive() && | 85 if (paintBlockCursor) { |
| 86 !isLogicalEndOfLine(createVisiblePositionDeprecated(caretPosition())); | 86 // TODO(editing-dev): Use of updateStyleAndLayoutIgnorePendingStylesheets |
| 87 // needs to be audited. see http://crbug.com/590369 for more details. |
| 88 // In the long term, we should defer the update of the caret's appearance |
| 89 // to prevent synchronous layout. |
| 90 m_frame->document()->updateStyleAndLayoutIgnorePendingStylesheets(); |
| 91 |
| 92 if (isLogicalEndOfLine(createVisiblePosition(caretPosition()))) |
| 93 paintBlockCursor = false; |
| 94 } |
| 87 | 95 |
| 88 bool shouldBlink = !paintBlockCursor && shouldBlinkCaret(); | 96 bool shouldBlink = !paintBlockCursor && shouldBlinkCaret(); |
| 89 | 97 |
| 90 // If the caret moved, stop the blink timer so we can restart with a | 98 // If the caret moved, stop the blink timer so we can restart with a |
| 91 // black caret in the new location. | 99 // black caret in the new location. |
| 92 if (!shouldBlink || shouldStopBlinkingDueToTypingCommand(m_frame)) | 100 if (!shouldBlink || shouldStopBlinkingDueToTypingCommand(m_frame)) |
| 93 stopCaretBlinkTimer(); | 101 stopCaretBlinkTimer(); |
| 94 | 102 |
| 95 // Start blinking with a black caret. Be sure not to restart if we're | 103 // Start blinking with a black caret. Be sure not to restart if we're |
| 96 // already blinking in the right location. | 104 // already blinking in the right location. |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 | 289 |
| 282 void FrameCaret::caretBlinkTimerFired(TimerBase*) { | 290 void FrameCaret::caretBlinkTimerFired(TimerBase*) { |
| 283 DCHECK_EQ(m_caretVisibility, CaretVisibility::Visible); | 291 DCHECK_EQ(m_caretVisibility, CaretVisibility::Visible); |
| 284 if (isCaretBlinkingSuspended() && m_shouldPaintCaret) | 292 if (isCaretBlinkingSuspended() && m_shouldPaintCaret) |
| 285 return; | 293 return; |
| 286 m_shouldPaintCaret = !m_shouldPaintCaret; | 294 m_shouldPaintCaret = !m_shouldPaintCaret; |
| 287 setCaretRectNeedsUpdate(); | 295 setCaretRectNeedsUpdate(); |
| 288 } | 296 } |
| 289 | 297 |
| 290 } // namespace blink | 298 } // namespace blink |
| OLD | NEW |