Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(702)

Side by Side Diff: third_party/WebKit/Source/core/editing/CaretBase.cpp

Issue 2325933002: Move m_caretVisibility from CaretBase to FrameCaret (Closed)
Patch Set: 2016-09-09T14:05:22 Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 24 matching lines...) Expand all
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" 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(CaretVisibility visibility) 45 CaretBase::CaretBase() = default;
46 : m_caretVisibility(visibility)
47 {
48 }
49
50 CaretBase::~CaretBase() = default; 46 CaretBase::~CaretBase() = default;
51 47
52 DEFINE_TRACE(CaretBase) 48 DEFINE_TRACE(CaretBase)
53 { 49 {
54 } 50 }
55 51
56 void CaretBase::clearCaretRect() 52 void CaretBase::clearCaretRect()
57 { 53 {
58 m_caretLocalRect = LayoutRect(); 54 m_caretLocalRect = LayoutRect();
59 } 55 }
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 { 182 {
187 if (LayoutViewItem view = node->document().layoutViewItem()) { 183 if (LayoutViewItem view = node->document().layoutViewItem()) {
188 node->document().updateStyleAndLayoutTree(); 184 node->document().updateStyleAndLayoutTree();
189 if (hasEditableStyle(*node) || shouldRepaintCaret(view)) 185 if (hasEditableStyle(*node) || shouldRepaintCaret(view))
190 invalidateLocalCaretRect(node, localCaretRectWithoutUpdate()); 186 invalidateLocalCaretRect(node, localCaretRectWithoutUpdate());
191 } 187 }
192 } 188 }
193 189
194 void CaretBase::paintCaret(Node* node, GraphicsContext& context, const LayoutPoi nt& paintOffset, DisplayItem::Type displayItemType) const 190 void CaretBase::paintCaret(Node* node, GraphicsContext& context, const LayoutPoi nt& paintOffset, DisplayItem::Type displayItemType) const
195 { 191 {
196 if (m_caretVisibility == CaretVisibility::Hidden)
197 return;
198
199 if (DrawingRecorder::useCachedDrawingIfPossible(context, *this, displayItemT ype)) 192 if (DrawingRecorder::useCachedDrawingIfPossible(context, *this, displayItemT ype))
200 return; 193 return;
201 194
202 LayoutRect drawingRect = localCaretRectWithoutUpdate(); 195 LayoutRect drawingRect = localCaretRectWithoutUpdate();
203 if (LayoutBlock* layoutObject = caretLayoutObject(node)) 196 if (LayoutBlock* layoutObject = caretLayoutObject(node))
204 layoutObject->flipForWritingMode(drawingRect); 197 layoutObject->flipForWritingMode(drawingRect);
205 drawingRect.moveBy(roundedIntPoint(paintOffset)); 198 drawingRect.moveBy(roundedIntPoint(paintOffset));
206 199
207 Color caretColor = Color::black; 200 Color caretColor = Color::black;
208 201
209 Element* element; 202 Element* element;
210 if (node->isElementNode()) 203 if (node->isElementNode())
211 element = toElement(node); 204 element = toElement(node);
212 else 205 else
213 element = node->parentElement(); 206 element = node->parentElement();
214 207
215 if (element && element->layoutObject()) 208 if (element && element->layoutObject())
216 caretColor = element->layoutObject()->resolveColor(CSSPropertyColor); 209 caretColor = element->layoutObject()->resolveColor(CSSPropertyColor);
217 210
218 IntRect paintRect = pixelSnappedIntRect(drawingRect); 211 IntRect paintRect = pixelSnappedIntRect(drawingRect);
219 DrawingRecorder drawingRecorder(context, *this, DisplayItem::kCaret, paintRe ct); 212 DrawingRecorder drawingRecorder(context, *this, DisplayItem::kCaret, paintRe ct);
220 context.fillRect(paintRect, caretColor); 213 context.fillRect(paintRect, caretColor);
221 } 214 }
222 215
223 void CaretBase::setCaretVisibility(CaretVisibility visibility)
224 {
225 m_caretVisibility = visibility;
226 }
227
228 String CaretBase::debugName() const 216 String CaretBase::debugName() const
229 { 217 {
230 return "Caret"; 218 return "Caret";
231 } 219 }
232 220
233 LayoutRect CaretBase::visualRect() const 221 LayoutRect CaretBase::visualRect() const
234 { 222 {
235 return m_visualRect; 223 return m_visualRect;
236 } 224 }
237 225
238 } // namespace blink 226 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/editing/CaretBase.h ('k') | third_party/WebKit/Source/core/editing/DragCaretController.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698