| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 m_isCaretBlinkingSuspended(false), | 59 m_isCaretBlinkingSuspended(false), |
| 60 m_shouldShowBlockCursor(false) {} | 60 m_shouldShowBlockCursor(false) {} |
| 61 | 61 |
| 62 FrameCaret::~FrameCaret() = default; | 62 FrameCaret::~FrameCaret() = default; |
| 63 | 63 |
| 64 DEFINE_TRACE(FrameCaret) { | 64 DEFINE_TRACE(FrameCaret) { |
| 65 visitor->trace(m_selectionEditor); | 65 visitor->trace(m_selectionEditor); |
| 66 visitor->trace(m_frame); | 66 visitor->trace(m_frame); |
| 67 visitor->trace(m_previousCaretNode); | 67 visitor->trace(m_previousCaretNode); |
| 68 visitor->trace(m_previousCaretAnchorNode); | 68 visitor->trace(m_previousCaretAnchorNode); |
| 69 SynchronousMutationObserver::trace(visitor); |
| 70 } |
| 71 |
| 72 void FrameCaret::documentAttached(Document* document) { |
| 73 setContext(document); |
| 69 } | 74 } |
| 70 | 75 |
| 71 const PositionWithAffinity FrameCaret::caretPosition() const { | 76 const PositionWithAffinity FrameCaret::caretPosition() const { |
| 72 const VisibleSelection& selection = | 77 const VisibleSelection& selection = |
| 73 m_selectionEditor->visibleSelection<EditingStrategy>(); | 78 m_selectionEditor->visibleSelection<EditingStrategy>(); |
| 74 if (!selection.isCaret()) | 79 if (!selection.isCaret()) |
| 75 return PositionWithAffinity(); | 80 return PositionWithAffinity(); |
| 76 return PositionWithAffinity(selection.start(), selection.affinity()); | 81 return PositionWithAffinity(selection.start(), selection.affinity()); |
| 77 } | 82 } |
| 78 | 83 |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 // Hits in ManualTests/caret-paint-after-last-text-is-removed.html | 300 // Hits in ManualTests/caret-paint-after-last-text-is-removed.html |
| 296 DisableCompositingQueryAsserts disabler; | 301 DisableCompositingQueryAsserts disabler; |
| 297 m_caretBase->invalidateLocalCaretRect(m_previousCaretAnchorNode.get(), | 302 m_caretBase->invalidateLocalCaretRect(m_previousCaretAnchorNode.get(), |
| 298 m_previousCaretRect); | 303 m_previousCaretRect); |
| 299 m_previousCaretNode = nullptr; | 304 m_previousCaretNode = nullptr; |
| 300 m_previousCaretAnchorNode = nullptr; | 305 m_previousCaretAnchorNode = nullptr; |
| 301 m_previousCaretRect = LayoutRect(); | 306 m_previousCaretRect = LayoutRect(); |
| 302 m_previousCaretVisibility = CaretVisibility::Hidden; | 307 m_previousCaretVisibility = CaretVisibility::Hidden; |
| 303 } | 308 } |
| 304 | 309 |
| 305 void FrameCaret::documentDetached() { | 310 void FrameCaret::contextDestroyed(Document*) { |
| 306 m_caretBlinkTimer.stop(); | 311 m_caretBlinkTimer.stop(); |
| 307 m_previousCaretNode.clear(); | 312 m_previousCaretNode.clear(); |
| 308 m_previousCaretAnchorNode.clear(); | 313 m_previousCaretAnchorNode.clear(); |
| 309 } | 314 } |
| 310 | 315 |
| 311 bool FrameCaret::shouldBlinkCaret() const { | 316 bool FrameCaret::shouldBlinkCaret() const { |
| 312 if (m_caretVisibility != CaretVisibility::Visible || !isActive()) | 317 if (m_caretVisibility != CaretVisibility::Visible || !isActive()) |
| 313 return false; | 318 return false; |
| 314 | 319 |
| 315 Element* root = rootEditableElementOf(caretPosition().position()); | 320 Element* root = rootEditableElementOf(caretPosition().position()); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 326 | 331 |
| 327 void FrameCaret::caretBlinkTimerFired(TimerBase*) { | 332 void FrameCaret::caretBlinkTimerFired(TimerBase*) { |
| 328 DCHECK_EQ(m_caretVisibility, CaretVisibility::Visible); | 333 DCHECK_EQ(m_caretVisibility, CaretVisibility::Visible); |
| 329 if (isCaretBlinkingSuspended() && m_shouldPaintCaret) | 334 if (isCaretBlinkingSuspended() && m_shouldPaintCaret) |
| 330 return; | 335 return; |
| 331 m_shouldPaintCaret = !m_shouldPaintCaret; | 336 m_shouldPaintCaret = !m_shouldPaintCaret; |
| 332 setCaretRectNeedsUpdate(); | 337 setCaretRectNeedsUpdate(); |
| 333 } | 338 } |
| 334 | 339 |
| 335 } // namespace blink | 340 } // namespace blink |
| OLD | NEW |