| 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 return nullptr; | 61 return nullptr; |
| 62 | 62 |
| 63 // if caretNode is a block and caret is inside it then caret should be paint
ed by that block | 63 // if caretNode is a block and caret is inside it then caret should be paint
ed by that block |
| 64 bool paintedByBlock = layoutObject->isLayoutBlock() && caretRendersInsideNod
e(node); | 64 bool paintedByBlock = layoutObject->isLayoutBlock() && caretRendersInsideNod
e(node); |
| 65 return paintedByBlock ? toLayoutBlock(layoutObject) : layoutObject->containi
ngBlock(); | 65 return paintedByBlock ? toLayoutBlock(layoutObject) : layoutObject->containi
ngBlock(); |
| 66 } | 66 } |
| 67 | 67 |
| 68 static void mapCaretRectToCaretPainter(LayoutObject* caretLayoutObject, LayoutBl
ock* caretPainter, LayoutRect& caretRect) | 68 static void mapCaretRectToCaretPainter(LayoutObject* caretLayoutObject, LayoutBl
ock* caretPainter, LayoutRect& caretRect) |
| 69 { | 69 { |
| 70 // FIXME: This shouldn't be called on un-rooted subtrees. | 70 // FIXME: This shouldn't be called on un-rooted subtrees. |
| 71 // FIXME: This should probably just use mapLocalToContainer. | 71 // FIXME: This should probably just use mapLocalToAncestor. |
| 72 // Compute an offset between the caretLayoutObject and the caretPainter. | 72 // Compute an offset between the caretLayoutObject and the caretPainter. |
| 73 | 73 |
| 74 ASSERT(caretLayoutObject->isDescendantOf(caretPainter)); | 74 ASSERT(caretLayoutObject->isDescendantOf(caretPainter)); |
| 75 | 75 |
| 76 bool unrooted = false; | 76 bool unrooted = false; |
| 77 while (caretLayoutObject != caretPainter) { | 77 while (caretLayoutObject != caretPainter) { |
| 78 LayoutObject* containerObject = caretLayoutObject->container(); | 78 LayoutObject* containerObject = caretLayoutObject->container(); |
| 79 if (!containerObject) { | 79 if (!containerObject) { |
| 80 unrooted = true; | 80 unrooted = true; |
| 81 break; | 81 break; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 { | 130 { |
| 131 LayoutBlock* caretPainter = caretLayoutObject(node); | 131 LayoutBlock* caretPainter = caretLayoutObject(node); |
| 132 if (!caretPainter) | 132 if (!caretPainter) |
| 133 return; | 133 return; |
| 134 | 134 |
| 135 // FIXME: Need to over-paint 1 pixel to workaround some rounding problems. | 135 // FIXME: Need to over-paint 1 pixel to workaround some rounding problems. |
| 136 // https://bugs.webkit.org/show_bug.cgi?id=108283 | 136 // https://bugs.webkit.org/show_bug.cgi?id=108283 |
| 137 LayoutRect inflatedRect = rect; | 137 LayoutRect inflatedRect = rect; |
| 138 inflatedRect.inflate(1); | 138 inflatedRect.inflate(1); |
| 139 | 139 |
| 140 // FIXME: We should use mapLocalToContainer() since we know we're not un-roo
ted. | 140 // FIXME: We should use mapLocalToAncestor() since we know we're not un-root
ed. |
| 141 mapCaretRectToCaretPainter(node->layoutObject(), caretPainter, inflatedRect)
; | 141 mapCaretRectToCaretPainter(node->layoutObject(), caretPainter, inflatedRect)
; |
| 142 | 142 |
| 143 // FIXME: We should not allow paint invalidation out of paint invalidation s
tate. crbug.com/457415 | 143 // FIXME: We should not allow paint invalidation out of paint invalidation s
tate. crbug.com/457415 |
| 144 DisablePaintInvalidationStateAsserts disabler; | 144 DisablePaintInvalidationStateAsserts disabler; |
| 145 caretPainter->invalidatePaintRectangle(inflatedRect); | 145 caretPainter->invalidatePaintRectangle(inflatedRect); |
| 146 } | 146 } |
| 147 | 147 |
| 148 bool CaretBase::shouldRepaintCaret(Node& node) const | 148 bool CaretBase::shouldRepaintCaret(Node& node) const |
| 149 { | 149 { |
| 150 // If PositionAnchorType::BeforeAnchor or PositionAnchorType::AfterAnchor, | 150 // If PositionAnchorType::BeforeAnchor or PositionAnchorType::AfterAnchor, |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 else | 192 else |
| 193 element = node->parentElement(); | 193 element = node->parentElement(); |
| 194 | 194 |
| 195 if (element && element->layoutObject()) | 195 if (element && element->layoutObject()) |
| 196 caretColor = element->layoutObject()->resolveColor(CSSPropertyColor); | 196 caretColor = element->layoutObject()->resolveColor(CSSPropertyColor); |
| 197 | 197 |
| 198 context.fillRect(FloatRect(drawingRect), caretColor); | 198 context.fillRect(FloatRect(drawingRect), caretColor); |
| 199 } | 199 } |
| 200 | 200 |
| 201 } // namespace blink | 201 } // namespace blink |
| OLD | NEW |