| 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/CaretBase.h" |
| 28 | 28 |
| 29 #include "core/editing/EditingUtilities.h" | 29 #include "core/editing/EditingUtilities.h" |
| 30 #include "core/editing/VisibleUnits.h" | 30 #include "core/editing/VisibleUnits.h" |
| 31 #include "core/frame/Settings.h" | 31 #include "core/frame/Settings.h" |
| 32 #include "core/layout/LayoutBlock.h" | 32 #include "core/layout/LayoutBlock.h" |
| 33 #include "core/layout/LayoutView.h" | 33 #include "core/layout/LayoutView.h" |
| 34 #include "platform/graphics/GraphicsContext.h" | 34 #include "platform/graphics/GraphicsContext.h" |
| 35 | 35 |
| 36 namespace blink { | 36 namespace blink { |
| 37 | 37 |
| 38 CaretBase::CaretBase(CaretVisibility visibility) | 38 CaretBase::CaretBase(CaretVisibility visibility) |
| 39 : m_caretVisibility(visibility) | 39 : m_caretVisibility(visibility) |
| 40 { | 40 { |
| 41 } | 41 } |
| 42 | 42 |
| 43 void CaretBase::clearCaretRect() | 43 void CaretBase::clearCaretRect() |
| 44 { | 44 { |
| 45 m_caretLocalRect = LayoutRect(); | 45 m_caretLocalRect = LayoutRect(); |
| 46 } | 46 } |
| 47 | 47 |
| 48 static inline bool caretRendersInsideNode(Node* node) | 48 static inline bool caretRendersInsideNode(Node* node) |
| 49 { | 49 { |
| 50 return node && !isRenderedTableElement(node) && !editingIgnoresContent(node)
; | 50 return node && !isRenderedTableElement(node) && !editingIgnoresContent(node)
; |
| 51 } | 51 } |
| 52 | 52 |
| 53 LayoutBlock* CaretBase::caretLayoutObject(Node* node) | 53 LayoutBlock* CaretBase::caretLayoutObject(Node* node) |
| 54 { | 54 { |
| 55 if (!node) | 55 if (!node) |
| 56 return 0; | 56 return nullptr; |
| 57 | 57 |
| 58 LayoutObject* layoutObject = node->layoutObject(); | 58 LayoutObject* layoutObject = node->layoutObject(); |
| 59 if (!layoutObject) | 59 if (!layoutObject) |
| 60 return 0; | 60 return nullptr; |
| 61 | 61 |
| 62 // if caretNode is a block and caret is inside it then caret should be paint
ed by that block | 62 // if caretNode is a block and caret is inside it then caret should be paint
ed by that block |
| 63 bool paintedByBlock = layoutObject->isLayoutBlock() && caretRendersInsideNod
e(node); | 63 bool paintedByBlock = layoutObject->isLayoutBlock() && caretRendersInsideNod
e(node); |
| 64 return paintedByBlock ? toLayoutBlock(layoutObject) : layoutObject->containi
ngBlock(); | 64 return paintedByBlock ? toLayoutBlock(layoutObject) : layoutObject->containi
ngBlock(); |
| 65 } | 65 } |
| 66 | 66 |
| 67 static void mapCaretRectToCaretPainter(LayoutObject* caretLayoutObject, LayoutBl
ock* caretPainter, LayoutRect& caretRect) | 67 static void mapCaretRectToCaretPainter(LayoutObject* caretLayoutObject, LayoutBl
ock* caretPainter, LayoutRect& caretRect) |
| 68 { | 68 { |
| 69 // FIXME: This shouldn't be called on un-rooted subtrees. | 69 // FIXME: This shouldn't be called on un-rooted subtrees. |
| 70 // FIXME: This should probably just use mapLocalToContainer. | 70 // FIXME: This should probably just use mapLocalToContainer. |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 else | 194 else |
| 195 element = node->parentElement(); | 195 element = node->parentElement(); |
| 196 | 196 |
| 197 if (element && element->layoutObject()) | 197 if (element && element->layoutObject()) |
| 198 caretColor = element->layoutObject()->resolveColor(CSSPropertyColor); | 198 caretColor = element->layoutObject()->resolveColor(CSSPropertyColor); |
| 199 | 199 |
| 200 context->fillRect(FloatRect(caret), caretColor); | 200 context->fillRect(FloatRect(caret), caretColor); |
| 201 } | 201 } |
| 202 | 202 |
| 203 } // namespace blink | 203 } // namespace blink |
| OLD | NEW |