| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 } | 56 } |
| 57 | 57 |
| 58 LayoutBlock* CaretBase::caretLayoutObject(Node* node) { | 58 LayoutBlock* CaretBase::caretLayoutObject(Node* node) { |
| 59 if (!node) | 59 if (!node) |
| 60 return nullptr; | 60 return nullptr; |
| 61 | 61 |
| 62 LayoutObject* layoutObject = node->layoutObject(); | 62 LayoutObject* layoutObject = node->layoutObject(); |
| 63 if (!layoutObject) | 63 if (!layoutObject) |
| 64 return nullptr; | 64 return nullptr; |
| 65 | 65 |
| 66 // if caretNode is a block and caret is inside it then caret should be painted
by that block | 66 // if caretNode is a block and caret is inside it then caret should be painted |
| 67 // by that block |
| 67 bool paintedByBlock = | 68 bool paintedByBlock = |
| 68 layoutObject->isLayoutBlock() && caretRendersInsideNode(node); | 69 layoutObject->isLayoutBlock() && caretRendersInsideNode(node); |
| 69 // TODO(yoichio): This function is called at least | 70 // TODO(yoichio): This function is called at least |
| 70 // DocumentLifeCycle::LayoutClean but caretRendersInsideNode above can | 71 // DocumentLifeCycle::LayoutClean but caretRendersInsideNode above can |
| 71 // layout. Thus |node->layoutObject()| can be changed then this is bad | 72 // layout. Thus |node->layoutObject()| can be changed then this is bad |
| 72 // design. We should make caret painting algorithm clean. | 73 // design. We should make caret painting algorithm clean. |
| 73 CHECK_EQ(layoutObject, node->layoutObject()) | 74 CHECK_EQ(layoutObject, node->layoutObject()) |
| 74 << "Layout tree should not changed"; | 75 << "Layout tree should not changed"; |
| 75 return paintedByBlock ? toLayoutBlock(layoutObject) | 76 return paintedByBlock ? toLayoutBlock(layoutObject) |
| 76 : layoutObject->containingBlock(); | 77 : layoutObject->containingBlock(); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 void CaretBase::invalidateLocalCaretRect(Node* node, const LayoutRect& rect) { | 144 void CaretBase::invalidateLocalCaretRect(Node* node, const LayoutRect& rect) { |
| 144 LayoutBlock* caretLayoutBlock = caretLayoutObject(node); | 145 LayoutBlock* caretLayoutBlock = caretLayoutObject(node); |
| 145 if (!caretLayoutBlock) | 146 if (!caretLayoutBlock) |
| 146 return; | 147 return; |
| 147 | 148 |
| 148 // FIXME: Need to over-paint 1 pixel to workaround some rounding problems. | 149 // FIXME: Need to over-paint 1 pixel to workaround some rounding problems. |
| 149 // https://bugs.webkit.org/show_bug.cgi?id=108283 | 150 // https://bugs.webkit.org/show_bug.cgi?id=108283 |
| 150 LayoutRect inflatedRect = rect; | 151 LayoutRect inflatedRect = rect; |
| 151 inflatedRect.inflate(LayoutUnit(1)); | 152 inflatedRect.inflate(LayoutUnit(1)); |
| 152 | 153 |
| 153 // FIXME: We should not allow paint invalidation out of paint invalidation sta
te. crbug.com/457415 | 154 // FIXME: We should not allow paint invalidation out of paint invalidation |
| 155 // state. crbug.com/457415 |
| 154 DisablePaintInvalidationStateAsserts disabler; | 156 DisablePaintInvalidationStateAsserts disabler; |
| 155 | 157 |
| 156 m_visualRect = | 158 m_visualRect = |
| 157 node->layoutObject()->invalidatePaintRectangle(inflatedRect, this); | 159 node->layoutObject()->invalidatePaintRectangle(inflatedRect, this); |
| 158 } | 160 } |
| 159 | 161 |
| 160 bool CaretBase::shouldRepaintCaret(Node& node) const { | 162 bool CaretBase::shouldRepaintCaret(Node& node) const { |
| 161 // If PositionAnchorType::BeforeAnchor or PositionAnchorType::AfterAnchor, | 163 // If PositionAnchorType::BeforeAnchor or PositionAnchorType::AfterAnchor, |
| 162 // carets need to be repainted not only when the node is contentEditable but | 164 // carets need to be repainted not only when the node is contentEditable but |
| 163 // also when its parentNode() is contentEditable. | 165 // also when its parentNode() is contentEditable. |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 | 208 |
| 207 String CaretBase::debugName() const { | 209 String CaretBase::debugName() const { |
| 208 return "Caret"; | 210 return "Caret"; |
| 209 } | 211 } |
| 210 | 212 |
| 211 LayoutRect CaretBase::visualRect() const { | 213 LayoutRect CaretBase::visualRect() const { |
| 212 return m_visualRect; | 214 return m_visualRect; |
| 213 } | 215 } |
| 214 | 216 |
| 215 } // namespace blink | 217 } // namespace blink |
| OLD | NEW |