| 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 27 matching lines...) Expand all Loading... |
| 38 #include "core/paint/PaintLayer.h" | 38 #include "core/paint/PaintLayer.h" |
| 39 #include "platform/graphics/GraphicsContext.h" | 39 #include "platform/graphics/GraphicsContext.h" |
| 40 #include "platform/graphics/GraphicsLayer.h" | 40 #include "platform/graphics/GraphicsLayer.h" |
| 41 #include "platform/graphics/paint/DrawingRecorder.h" | 41 #include "platform/graphics/paint/DrawingRecorder.h" |
| 42 | 42 |
| 43 namespace blink { | 43 namespace blink { |
| 44 | 44 |
| 45 CaretBase::CaretBase() = default; | 45 CaretBase::CaretBase() = default; |
| 46 CaretBase::~CaretBase() = default; | 46 CaretBase::~CaretBase() = default; |
| 47 | 47 |
| 48 DEFINE_TRACE(CaretBase) {} | |
| 49 | |
| 50 static inline bool caretRendersInsideNode(Node* node) { | 48 static inline bool caretRendersInsideNode(Node* node) { |
| 51 return node && !isDisplayInsideTable(node) && !editingIgnoresContent(*node); | 49 return node && !isDisplayInsideTable(node) && !editingIgnoresContent(*node); |
| 52 } | 50 } |
| 53 | 51 |
| 54 LayoutBlock* CaretBase::caretLayoutObject(Node* node) { | 52 LayoutBlock* CaretBase::caretLayoutObject(Node* node) { |
| 55 if (!node) | 53 if (!node) |
| 56 return nullptr; | 54 return nullptr; |
| 57 | 55 |
| 58 LayoutObject* layoutObject = node->layoutObject(); | 56 LayoutObject* layoutObject = node->layoutObject(); |
| 59 if (!layoutObject) | 57 if (!layoutObject) |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 | 111 |
| 114 return mapCaretRectToCaretPainter(LayoutItem(layoutObject), caretPainterItem, | 112 return mapCaretRectToCaretPainter(LayoutItem(layoutObject), caretPainterItem, |
| 115 caretLocalRect); | 113 caretLocalRect); |
| 116 } | 114 } |
| 117 | 115 |
| 118 LayoutRect CaretBase::computeCaretRect(const VisiblePosition& caretPosition) { | 116 LayoutRect CaretBase::computeCaretRect(const VisiblePosition& caretPosition) { |
| 119 return computeCaretRect(caretPosition.toPositionWithAffinity()); | 117 return computeCaretRect(caretPosition.toPositionWithAffinity()); |
| 120 } | 118 } |
| 121 | 119 |
| 122 IntRect CaretBase::absoluteBoundsForLocalRect(Node* node, | 120 IntRect CaretBase::absoluteBoundsForLocalRect(Node* node, |
| 123 const LayoutRect& rect) const { | 121 const LayoutRect& rect) { |
| 124 LayoutBlock* caretPainter = caretLayoutObject(node); | 122 LayoutBlock* caretPainter = caretLayoutObject(node); |
| 125 if (!caretPainter) | 123 if (!caretPainter) |
| 126 return IntRect(); | 124 return IntRect(); |
| 127 | 125 |
| 128 LayoutRect localRect(rect); | 126 LayoutRect localRect(rect); |
| 129 caretPainter->flipForWritingMode(localRect); | 127 caretPainter->flipForWritingMode(localRect); |
| 130 return caretPainter->localToAbsoluteQuad(FloatRect(localRect)) | 128 return caretPainter->localToAbsoluteQuad(FloatRect(localRect)) |
| 131 .enclosingBoundingBox(); | 129 .enclosingBoundingBox(); |
| 132 } | 130 } |
| 133 | 131 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 145 inflatedRect.inflate(LayoutUnit(1)); | 143 inflatedRect.inflate(LayoutUnit(1)); |
| 146 | 144 |
| 147 // FIXME: We should not allow paint invalidation out of paint invalidation | 145 // FIXME: We should not allow paint invalidation out of paint invalidation |
| 148 // state. crbug.com/457415 | 146 // state. crbug.com/457415 |
| 149 DisablePaintInvalidationStateAsserts disabler; | 147 DisablePaintInvalidationStateAsserts disabler; |
| 150 | 148 |
| 151 m_visualRect = | 149 m_visualRect = |
| 152 node->layoutObject()->invalidatePaintRectangle(inflatedRect, this); | 150 node->layoutObject()->invalidatePaintRectangle(inflatedRect, this); |
| 153 } | 151 } |
| 154 | 152 |
| 155 bool CaretBase::shouldRepaintCaret(Node& node) const { | 153 bool CaretBase::shouldRepaintCaret(Node& node) { |
| 156 // If PositionAnchorType::BeforeAnchor or PositionAnchorType::AfterAnchor, | 154 // If PositionAnchorType::BeforeAnchor or PositionAnchorType::AfterAnchor, |
| 157 // carets need to be repainted not only when the node is contentEditable but | 155 // carets need to be repainted not only when the node is contentEditable but |
| 158 // also when its parentNode() is contentEditable. | 156 // also when its parentNode() is contentEditable. |
| 159 node.document().updateStyleAndLayoutTree(); | 157 node.document().updateStyleAndLayoutTree(); |
| 160 return hasEditableStyle(node) || | 158 return hasEditableStyle(node) || |
| 161 (node.parentNode() && hasEditableStyle(*node.parentNode())); | 159 (node.parentNode() && hasEditableStyle(*node.parentNode())); |
| 162 } | 160 } |
| 163 | 161 |
| 164 void CaretBase::invalidateCaretRect(Node* node, | 162 void CaretBase::invalidateCaretRect(Node* node, |
| 165 const LayoutRect& caretLocalRect) { | 163 const LayoutRect& caretLocalRect) { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 193 | 191 |
| 194 String CaretBase::debugName() const { | 192 String CaretBase::debugName() const { |
| 195 return "Caret"; | 193 return "Caret"; |
| 196 } | 194 } |
| 197 | 195 |
| 198 LayoutRect CaretBase::visualRect() const { | 196 LayoutRect CaretBase::visualRect() const { |
| 199 return m_visualRect; | 197 return m_visualRect; |
| 200 } | 198 } |
| 201 | 199 |
| 202 } // namespace blink | 200 } // namespace blink |
| OLD | NEW |