| 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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 // FIXME: We should not allow paint invalidation out of paint invalidation s
tate. crbug.com/457415 | 159 // FIXME: We should not allow paint invalidation out of paint invalidation s
tate. crbug.com/457415 |
| 160 DisablePaintInvalidationStateAsserts disabler; | 160 DisablePaintInvalidationStateAsserts disabler; |
| 161 caretPainter.invalidatePaintRectangle(inflatedRect); | 161 caretPainter.invalidatePaintRectangle(inflatedRect); |
| 162 } | 162 } |
| 163 | 163 |
| 164 bool CaretBase::shouldRepaintCaret(Node& node) const | 164 bool CaretBase::shouldRepaintCaret(Node& node) const |
| 165 { | 165 { |
| 166 // If PositionAnchorType::BeforeAnchor or PositionAnchorType::AfterAnchor, | 166 // If PositionAnchorType::BeforeAnchor or PositionAnchorType::AfterAnchor, |
| 167 // carets need to be repainted not only when the node is contentEditable but | 167 // carets need to be repainted not only when the node is contentEditable but |
| 168 // also when its parentNode() is contentEditable. | 168 // also when its parentNode() is contentEditable. |
| 169 return node.isContentEditable() || (node.parentNode() && node.parentNode()->
isContentEditable()); | 169 return isContentEditable(node) || (node.parentNode() && isContentEditable(*n
ode.parentNode())); |
| 170 } | 170 } |
| 171 | 171 |
| 172 bool CaretBase::shouldRepaintCaret(const LayoutViewItem view) const | 172 bool CaretBase::shouldRepaintCaret(const LayoutViewItem view) const |
| 173 { | 173 { |
| 174 DCHECK(view); | 174 DCHECK(view); |
| 175 if (FrameView* frameView = view.frameView()) { | 175 if (FrameView* frameView = view.frameView()) { |
| 176 LocalFrame& frame = frameView->frame(); // The frame where the selection
started | 176 LocalFrame& frame = frameView->frame(); // The frame where the selection
started |
| 177 return frame.settings() && frame.settings()->caretBrowsingEnabled(); | 177 return frame.settings() && frame.settings()->caretBrowsingEnabled(); |
| 178 } | 178 } |
| 179 return false; | 179 return false; |
| 180 } | 180 } |
| 181 | 181 |
| 182 void CaretBase::invalidateCaretRect(Node* node, bool caretRectChanged) | 182 void CaretBase::invalidateCaretRect(Node* node, bool caretRectChanged) |
| 183 { | 183 { |
| 184 if (caretRectChanged) | 184 if (caretRectChanged) |
| 185 return; | 185 return; |
| 186 | 186 |
| 187 if (LayoutViewItem view = node->document().layoutViewItem()) { | 187 if (LayoutViewItem view = node->document().layoutViewItem()) { |
| 188 if (node->isContentEditable() || shouldRepaintCaret(view)) | 188 if (isContentEditable(*node) || shouldRepaintCaret(view)) |
| 189 invalidateLocalCaretRect(node, localCaretRectWithoutUpdate()); | 189 invalidateLocalCaretRect(node, localCaretRectWithoutUpdate()); |
| 190 } | 190 } |
| 191 } | 191 } |
| 192 | 192 |
| 193 void CaretBase::paintCaret(Node* node, GraphicsContext& context, const LayoutPoi
nt& paintOffset) const | 193 void CaretBase::paintCaret(Node* node, GraphicsContext& context, const LayoutPoi
nt& paintOffset) const |
| 194 { | 194 { |
| 195 if (m_caretVisibility == CaretVisibility::Hidden) | 195 if (m_caretVisibility == CaretVisibility::Hidden) |
| 196 return; | 196 return; |
| 197 | 197 |
| 198 LayoutRect drawingRect = localCaretRectWithoutUpdate(); | 198 LayoutRect drawingRect = localCaretRectWithoutUpdate(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 213 | 213 |
| 214 context.fillRect(FloatRect(drawingRect), caretColor); | 214 context.fillRect(FloatRect(drawingRect), caretColor); |
| 215 } | 215 } |
| 216 | 216 |
| 217 void CaretBase::setCaretVisibility(CaretVisibility visibility) | 217 void CaretBase::setCaretVisibility(CaretVisibility visibility) |
| 218 { | 218 { |
| 219 m_caretVisibility = visibility; | 219 m_caretVisibility = visibility; |
| 220 } | 220 } |
| 221 | 221 |
| 222 } // namespace blink | 222 } // namespace blink |
| OLD | NEW |