| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 } | 54 } |
| 55 | 55 |
| 56 void DragCaretController::setCaretPosition( | 56 void DragCaretController::setCaretPosition( |
| 57 const PositionWithAffinity& position) { | 57 const PositionWithAffinity& position) { |
| 58 // for querying Layer::compositingState() | 58 // for querying Layer::compositingState() |
| 59 // This code is probably correct, since it doesn't occur in a stack that | 59 // This code is probably correct, since it doesn't occur in a stack that |
| 60 // involves updating compositing state. | 60 // involves updating compositing state. |
| 61 DisableCompositingQueryAsserts disabler; | 61 DisableCompositingQueryAsserts disabler; |
| 62 | 62 |
| 63 if (Node* node = m_position.anchorNode()) | 63 if (Node* node = m_position.anchorNode()) |
| 64 m_caretBase->invalidateCaretRect(node); | 64 m_caretBase->invalidateCaretRect(node, m_caretLocalRect); |
| 65 m_position = createVisiblePosition(position).toPositionWithAffinity(); | 65 m_position = createVisiblePosition(position).toPositionWithAffinity(); |
| 66 Document* document = nullptr; | 66 Document* document = nullptr; |
| 67 if (Node* node = m_position.anchorNode()) { | 67 if (Node* node = m_position.anchorNode()) { |
| 68 m_caretBase->invalidateCaretRect(node); | 68 m_caretBase->invalidateCaretRect(node, m_caretLocalRect); |
| 69 document = &node->document(); | 69 document = &node->document(); |
| 70 setContext(document); | 70 setContext(document); |
| 71 } | 71 } |
| 72 if (m_position.isNull()) { | 72 if (m_position.isNull()) { |
| 73 m_caretBase->clearCaretRect(); | 73 m_caretLocalRect = LayoutRect(); |
| 74 } else { | 74 } else { |
| 75 DCHECK(!m_position.isOrphan()); | 75 DCHECK(!m_position.isOrphan()); |
| 76 document->updateStyleAndLayoutTree(); | 76 document->updateStyleAndLayoutTree(); |
| 77 m_caretBase->updateCaretRect(m_position); | 77 m_caretLocalRect = CaretBase::computeCaretRect(m_position); |
| 78 } | 78 } |
| 79 } | 79 } |
| 80 | 80 |
| 81 void DragCaretController::nodeChildrenWillBeRemoved(ContainerNode& container) { | 81 void DragCaretController::nodeChildrenWillBeRemoved(ContainerNode& container) { |
| 82 if (!hasCaret() || !container.inActiveDocument()) | 82 if (!hasCaret() || !container.inActiveDocument()) |
| 83 return; | 83 return; |
| 84 Node* const anchorNode = m_position.position().anchorNode(); | 84 Node* const anchorNode = m_position.position().anchorNode(); |
| 85 if (!anchorNode || anchorNode == container) | 85 if (!anchorNode || anchorNode == container) |
| 86 return; | 86 return; |
| 87 if (!container.isShadowIncludingInclusiveAncestorOf(anchorNode)) | 87 if (!container.isShadowIncludingInclusiveAncestorOf(anchorNode)) |
| (...skipping 17 matching lines...) Expand all Loading... |
| 105 DEFINE_TRACE(DragCaretController) { | 105 DEFINE_TRACE(DragCaretController) { |
| 106 visitor->trace(m_position); | 106 visitor->trace(m_position); |
| 107 visitor->trace(m_caretBase); | 107 visitor->trace(m_caretBase); |
| 108 SynchronousMutationObserver::trace(visitor); | 108 SynchronousMutationObserver::trace(visitor); |
| 109 } | 109 } |
| 110 | 110 |
| 111 void DragCaretController::paintDragCaret(LocalFrame* frame, | 111 void DragCaretController::paintDragCaret(LocalFrame* frame, |
| 112 GraphicsContext& context, | 112 GraphicsContext& context, |
| 113 const LayoutPoint& paintOffset) const { | 113 const LayoutPoint& paintOffset) const { |
| 114 if (m_position.anchorNode()->document().frame() == frame) { | 114 if (m_position.anchorNode()->document().frame() == frame) { |
| 115 m_caretBase->paintCaret(m_position.anchorNode(), context, paintOffset, | 115 CaretBase::paintCaret(m_position.anchorNode(), context, *m_caretBase, |
| 116 DisplayItem::kDragCaret); | 116 m_caretLocalRect, paintOffset, |
| 117 DisplayItem::kDragCaret); |
| 117 } | 118 } |
| 118 } | 119 } |
| 119 | 120 |
| 120 } // namespace blink | 121 } // namespace blink |
| OLD | NEW |