| 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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 return; | 203 return; |
| 204 | 204 |
| 205 // FIXME: Need to over-paint 1 pixel to workaround some rounding problems. | 205 // FIXME: Need to over-paint 1 pixel to workaround some rounding problems. |
| 206 // https://bugs.webkit.org/show_bug.cgi?id=108283 | 206 // https://bugs.webkit.org/show_bug.cgi?id=108283 |
| 207 LayoutRect inflatedRect = rect; | 207 LayoutRect inflatedRect = rect; |
| 208 inflatedRect.inflate(1); | 208 inflatedRect.inflate(1); |
| 209 | 209 |
| 210 caretPainter->invalidatePaintRectangle(inflatedRect); | 210 caretPainter->invalidatePaintRectangle(inflatedRect); |
| 211 } | 211 } |
| 212 | 212 |
| 213 bool CaretBase::shouldRepaintCaret(const RenderView* view, bool isContentEditabl
e) const | |
| 214 { | |
| 215 ASSERT(view); | |
| 216 bool caretBrowsing = false; | |
| 217 if (FrameView* frameView = view->frameView()) { | |
| 218 LocalFrame& frame = frameView->frame(); // The frame where the selection
started | |
| 219 caretBrowsing = frame.settings() && frame.settings()->caretBrowsingEnabl
ed(); | |
| 220 } | |
| 221 return (caretBrowsing || isContentEditable); | |
| 222 } | |
| 223 | |
| 224 void CaretBase::invalidateCaretRect(Node* node, bool caretRectChanged) | 213 void CaretBase::invalidateCaretRect(Node* node, bool caretRectChanged) |
| 225 { | 214 { |
| 226 // EDIT FIXME: This is an unfortunate hack. | 215 // EDIT FIXME: This is an unfortunate hack. |
| 227 // Basically, we can't trust this layout position since we | 216 // Basically, we can't trust this layout position since we |
| 228 // can't guarantee that the check to see if we are in unrendered | 217 // can't guarantee that the check to see if we are in unrendered |
| 229 // content will work at this point. We may have to wait for | 218 // content will work at this point. We may have to wait for |
| 230 // a layout and re-render of the document to happen. So, resetting this | 219 // a layout and re-render of the document to happen. So, resetting this |
| 231 // flag will cause another caret layout to happen the first time | 220 // flag will cause another caret layout to happen the first time |
| 232 // that we try to paint the caret after this call. That one will work since | 221 // that we try to paint the caret after this call. That one will work since |
| 233 // it happens after the document has accounted for any editing | 222 // it happens after the document has accounted for any editing |
| 234 // changes which may have been done. | 223 // changes which may have been done. |
| 235 // And, we need to leave this layout here so the caret moves right | 224 // And, we need to leave this layout here so the caret moves right |
| 236 // away after clicking. | 225 // away after clicking. |
| 237 m_caretRectNeedsUpdate = true; | 226 m_caretRectNeedsUpdate = true; |
| 238 | 227 |
| 239 if (caretRectChanged) | 228 if (caretRectChanged) |
| 240 return; | 229 return; |
| 241 | 230 |
| 242 if (RenderView* view = node->document().renderView()) { | 231 if (node->isContentEditable(Node::UserSelectAllIsAlwaysNonEditable)) |
| 243 if (shouldRepaintCaret(view, node->isContentEditable(Node::UserSelectAll
IsAlwaysNonEditable))) | 232 invalidateLocalCaretRect(node, localCaretRectWithoutUpdate()); |
| 244 invalidateLocalCaretRect(node, localCaretRectWithoutUpdate()); | |
| 245 } | |
| 246 } | 233 } |
| 247 | 234 |
| 248 void CaretBase::paintCaret(Node* node, GraphicsContext* context, const LayoutPoi
nt& paintOffset, const LayoutRect& clipRect) const | 235 void CaretBase::paintCaret(Node* node, GraphicsContext* context, const LayoutPoi
nt& paintOffset, const LayoutRect& clipRect) const |
| 249 { | 236 { |
| 250 if (m_caretVisibility == Hidden) | 237 if (m_caretVisibility == Hidden) |
| 251 return; | 238 return; |
| 252 | 239 |
| 253 LayoutRect drawingRect = localCaretRectWithoutUpdate(); | 240 LayoutRect drawingRect = localCaretRectWithoutUpdate(); |
| 254 if (RenderBlock* renderer = caretRenderer(node)) | 241 if (RenderBlock* renderer = caretRenderer(node)) |
| 255 renderer->flipForWritingMode(drawingRect); | 242 renderer->flipForWritingMode(drawingRect); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 272 context->fillRect(caret, caretColor); | 259 context->fillRect(caret, caretColor); |
| 273 } | 260 } |
| 274 | 261 |
| 275 void DragCaretController::paintDragCaret(LocalFrame* frame, GraphicsContext* p,
const LayoutPoint& paintOffset, const LayoutRect& clipRect) const | 262 void DragCaretController::paintDragCaret(LocalFrame* frame, GraphicsContext* p,
const LayoutPoint& paintOffset, const LayoutRect& clipRect) const |
| 276 { | 263 { |
| 277 if (m_position.deepEquivalent().deprecatedNode()->document().frame() == fram
e) | 264 if (m_position.deepEquivalent().deprecatedNode()->document().frame() == fram
e) |
| 278 paintCaret(m_position.deepEquivalent().deprecatedNode(), p, paintOffset,
clipRect); | 265 paintCaret(m_position.deepEquivalent().deprecatedNode(), p, paintOffset,
clipRect); |
| 279 } | 266 } |
| 280 | 267 |
| 281 } | 268 } |
| OLD | NEW |