| 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 |
| 11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
| 12 * | 12 * |
| 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY | 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY |
| 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
| 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #include "config.h" | 26 #include "config.h" |
| 27 #include "core/editing/Caret.h" | 27 #include "core/editing/Caret.h" |
| 28 | 28 |
| 29 #include "core/dom/Document.h" | 29 #include "core/dom/Document.h" |
| 30 #include "core/editing/VisibleUnits.h" | 30 #include "core/editing/VisibleUnits.h" |
| 31 #include "core/editing/htmlediting.h" | 31 #include "core/editing/htmlediting.h" |
| 32 #include "core/frame/LocalFrame.h" | 32 #include "core/frame/LocalFrame.h" |
| 33 #include "core/frame/Settings.h" | 33 #include "core/frame/Settings.h" |
| 34 #include "core/html/HTMLTextFormControlElement.h" | 34 #include "core/html/HTMLTextFormControlElement.h" |
| 35 #include "core/rendering/RenderBlock.h" | 35 #include "core/rendering/RenderBlock.h" |
| 36 #include "core/rendering/RenderLayer.h" | |
| 37 #include "core/rendering/RenderView.h" | 36 #include "core/rendering/RenderView.h" |
| 38 #include "platform/graphics/GraphicsContext.h" | 37 #include "platform/graphics/GraphicsContext.h" |
| 39 | 38 |
| 40 namespace blink { | 39 namespace blink { |
| 41 | 40 |
| 42 CaretBase::CaretBase(CaretVisibility visibility) | 41 CaretBase::CaretBase(CaretVisibility visibility) |
| 43 : m_caretRectNeedsUpdate(true) | 42 : m_caretRectNeedsUpdate(true) |
| 44 , m_caretVisibility(visibility) | 43 , m_caretVisibility(visibility) |
| 45 { | 44 { |
| 46 } | 45 } |
| 47 | 46 |
| 48 DragCaretController::DragCaretController() | 47 DragCaretController::DragCaretController() |
| 49 : CaretBase(Visible) | 48 : CaretBase(Visible) |
| 50 { | 49 { |
| 51 } | 50 } |
| 52 | 51 |
| 53 PassOwnPtrWillBeRawPtr<DragCaretController> DragCaretController::create() | 52 PassOwnPtrWillBeRawPtr<DragCaretController> DragCaretController::create() |
| 54 { | 53 { |
| 55 return adoptPtrWillBeNoop(new DragCaretController); | 54 return adoptPtrWillBeNoop(new DragCaretController); |
| 56 } | 55 } |
| 57 | 56 |
| 58 bool DragCaretController::isContentRichlyEditable() const | 57 bool DragCaretController::isContentRichlyEditable() const |
| 59 { | 58 { |
| 60 return isRichlyEditablePosition(m_position.deepEquivalent()); | 59 return isRichlyEditablePosition(m_position.deepEquivalent()); |
| 61 } | 60 } |
| 62 | 61 |
| 63 void DragCaretController::setCaretPosition(const VisiblePosition& position) | 62 void DragCaretController::setCaretPosition(const VisiblePosition& position) |
| 64 { | 63 { |
| 65 // for querying RenderLayer::compositingState() | |
| 66 // This code is probably correct, since it doesn't occur in a stack that inv
olves updating compositing state. | |
| 67 DisableCompositingQueryAsserts disabler; | |
| 68 | |
| 69 if (Node* node = m_position.deepEquivalent().deprecatedNode()) | 64 if (Node* node = m_position.deepEquivalent().deprecatedNode()) |
| 70 invalidateCaretRect(node); | 65 invalidateCaretRect(node); |
| 71 m_position = position; | 66 m_position = position; |
| 72 setCaretRectNeedsUpdate(); | 67 setCaretRectNeedsUpdate(); |
| 73 Document* document = 0; | 68 Document* document = 0; |
| 74 if (Node* node = m_position.deepEquivalent().deprecatedNode()) { | 69 if (Node* node = m_position.deepEquivalent().deprecatedNode()) { |
| 75 invalidateCaretRect(node); | 70 invalidateCaretRect(node); |
| 76 document = &node->document(); | 71 document = &node->document(); |
| 77 } | 72 } |
| 78 if (m_position.isNull() || m_position.isOrphan()) { | 73 if (m_position.isNull() || m_position.isOrphan()) { |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 context->fillRect(caret, caretColor); | 268 context->fillRect(caret, caretColor); |
| 274 } | 269 } |
| 275 | 270 |
| 276 void DragCaretController::paintDragCaret(LocalFrame* frame, GraphicsContext* p,
const LayoutPoint& paintOffset, const LayoutRect& clipRect) const | 271 void DragCaretController::paintDragCaret(LocalFrame* frame, GraphicsContext* p,
const LayoutPoint& paintOffset, const LayoutRect& clipRect) const |
| 277 { | 272 { |
| 278 if (m_position.deepEquivalent().deprecatedNode()->document().frame() == fram
e) | 273 if (m_position.deepEquivalent().deprecatedNode()->document().frame() == fram
e) |
| 279 paintCaret(m_position.deepEquivalent().deprecatedNode(), p, paintOffset,
clipRect); | 274 paintCaret(m_position.deepEquivalent().deprecatedNode(), p, paintOffset,
clipRect); |
| 280 } | 275 } |
| 281 | 276 |
| 282 } | 277 } |
| OLD | NEW |