| 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 17 matching lines...) Expand all Loading... |
| 28 #include "core/editing/EditingUtilities.h" | 28 #include "core/editing/EditingUtilities.h" |
| 29 #include "core/editing/VisibleUnits.h" | 29 #include "core/editing/VisibleUnits.h" |
| 30 #include "core/frame/FrameView.h" | 30 #include "core/frame/FrameView.h" |
| 31 #include "core/frame/Settings.h" | 31 #include "core/frame/Settings.h" |
| 32 #include "core/layout/LayoutBlock.h" | 32 #include "core/layout/LayoutBlock.h" |
| 33 #include "core/layout/LayoutView.h" | 33 #include "core/layout/LayoutView.h" |
| 34 #include "core/layout/api/LayoutBlockItem.h" | 34 #include "core/layout/api/LayoutBlockItem.h" |
| 35 #include "core/layout/api/LayoutItem.h" | 35 #include "core/layout/api/LayoutItem.h" |
| 36 #include "core/layout/api/LayoutViewItem.h" | 36 #include "core/layout/api/LayoutViewItem.h" |
| 37 #include "core/paint/PaintInfo.h" | 37 #include "core/paint/PaintInfo.h" |
| 38 #include "core/paint/PaintLayer.h" | |
| 39 #include "platform/graphics/GraphicsContext.h" | 38 #include "platform/graphics/GraphicsContext.h" |
| 40 #include "platform/graphics/GraphicsLayer.h" | |
| 41 #include "platform/graphics/paint/DrawingRecorder.h" | 39 #include "platform/graphics/paint/DrawingRecorder.h" |
| 42 | 40 |
| 43 namespace blink { | 41 namespace blink { |
| 44 | 42 |
| 45 CaretDisplayItemClient::CaretDisplayItemClient() = default; | 43 CaretDisplayItemClient::CaretDisplayItemClient() = default; |
| 46 CaretDisplayItemClient::~CaretDisplayItemClient() = default; | 44 CaretDisplayItemClient::~CaretDisplayItemClient() = default; |
| 47 | 45 |
| 48 static inline bool caretRendersInsideNode(Node* node) { | 46 static inline bool caretRendersInsideNode(Node* node) { |
| 49 return node && !isDisplayInsideTable(node) && !editingIgnoresContent(*node); | 47 return node && !isDisplayInsideTable(node) && !editingIgnoresContent(*node); |
| 50 } | 48 } |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 | 104 |
| 107 // Get the layoutObject that will be responsible for painting the caret | 105 // Get the layoutObject that will be responsible for painting the caret |
| 108 // (which is either the layoutObject we just found, or one of its containers). | 106 // (which is either the layoutObject we just found, or one of its containers). |
| 109 LayoutBlockItem caretPainterItem = | 107 LayoutBlockItem caretPainterItem = |
| 110 LayoutBlockItem(caretLayoutObject(caretPosition.anchorNode())); | 108 LayoutBlockItem(caretLayoutObject(caretPosition.anchorNode())); |
| 111 | 109 |
| 112 return mapCaretRectToCaretPainter(LayoutItem(layoutObject), caretPainterItem, | 110 return mapCaretRectToCaretPainter(LayoutItem(layoutObject), caretPainterItem, |
| 113 caretLocalRect); | 111 caretLocalRect); |
| 114 } | 112 } |
| 115 | 113 |
| 116 // TODO(yoichio): |node| is FrameSelection::m_previousCaretNode and this is bad | |
| 117 // design. We should use only previous layoutObject or Rectangle to invalidate | |
| 118 // old caret. | |
| 119 void CaretDisplayItemClient::invalidateLocalCaretRect(Node* node, | |
| 120 const LayoutRect& rect) { | |
| 121 LayoutBlock* caretLayoutBlock = caretLayoutObject(node); | |
| 122 if (!caretLayoutBlock) | |
| 123 return; | |
| 124 | |
| 125 // FIXME: Need to over-paint 1 pixel to workaround some rounding problems. | |
| 126 // https://bugs.webkit.org/show_bug.cgi?id=108283 | |
| 127 LayoutRect inflatedRect = rect; | |
| 128 inflatedRect.inflate(LayoutUnit(1)); | |
| 129 | |
| 130 // FIXME: We should not allow paint invalidation out of paint invalidation | |
| 131 // state. crbug.com/457415 | |
| 132 DisablePaintInvalidationStateAsserts disabler; | |
| 133 | |
| 134 m_visualRect = | |
| 135 node->layoutObject()->invalidatePaintRectangle(inflatedRect, this); | |
| 136 } | |
| 137 | |
| 138 void CaretDisplayItemClient::paintCaret(Node* node, | 114 void CaretDisplayItemClient::paintCaret(Node* node, |
| 139 GraphicsContext& context, | 115 GraphicsContext& context, |
| 140 const LayoutRect& caretLocalRect, | 116 const LayoutRect& caretLocalRect, |
| 141 const LayoutPoint& paintOffset, | 117 const LayoutPoint& paintOffset, |
| 142 DisplayItem::Type displayItemType) { | 118 DisplayItem::Type displayItemType) { |
| 143 if (DrawingRecorder::useCachedDrawingIfPossible(context, *this, | 119 if (DrawingRecorder::useCachedDrawingIfPossible(context, *this, |
| 144 displayItemType)) | 120 displayItemType)) |
| 145 return; | 121 return; |
| 146 | 122 |
| 147 LayoutRect drawingRect = caretLocalRect; | 123 LayoutRect drawingRect = caretLocalRect; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 159 | 135 |
| 160 String CaretDisplayItemClient::debugName() const { | 136 String CaretDisplayItemClient::debugName() const { |
| 161 return "Caret"; | 137 return "Caret"; |
| 162 } | 138 } |
| 163 | 139 |
| 164 LayoutRect CaretDisplayItemClient::visualRect() const { | 140 LayoutRect CaretDisplayItemClient::visualRect() const { |
| 165 return m_visualRect; | 141 return m_visualRect; |
| 166 } | 142 } |
| 167 | 143 |
| 168 } // namespace blink | 144 } // namespace blink |
| OLD | NEW |