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

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

Issue 2650633002: Move CaretBase::invalidateCaretRect() to DragCaretController (Closed)
Patch Set: 2017-01-23T13:45:50 Created 3 years, 11 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
« no previous file with comments | « third_party/WebKit/Source/core/editing/DragCaretController.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 return false; 46 return false;
47 if (layoutBlock != CaretBase::caretLayoutObject(node)) 47 if (layoutBlock != CaretBase::caretLayoutObject(node))
48 return false; 48 return false;
49 return rootEditableElementOf(m_position.position()); 49 return rootEditableElementOf(m_position.position());
50 } 50 }
51 51
52 bool DragCaretController::isContentRichlyEditable() const { 52 bool DragCaretController::isContentRichlyEditable() const {
53 return isRichlyEditablePosition(m_position.position()); 53 return isRichlyEditablePosition(m_position.position());
54 } 54 }
55 55
56 void DragCaretController::invalidateCaretRect(
57 Node* node,
58 const LayoutRect& caretLocalRect) {
59 // TODO(editing-dev): The use of updateStyleAndLayout
60 // needs to be audited. See http://crbug.com/590369 for more details.
61 // In the long term we should use idle time spell checker to prevent
62 // synchronous layout caused by spell checking (see crbug.com/517298).
63 node->document().updateStyleAndLayoutTree();
64 if (!hasEditableStyle(*node))
65 return;
66 m_caretBase->invalidateLocalCaretRect(node, caretLocalRect);
67 }
68
56 void DragCaretController::setCaretPosition( 69 void DragCaretController::setCaretPosition(
57 const PositionWithAffinity& position) { 70 const PositionWithAffinity& position) {
58 // for querying Layer::compositingState() 71 // for querying Layer::compositingState()
59 // This code is probably correct, since it doesn't occur in a stack that 72 // This code is probably correct, since it doesn't occur in a stack that
60 // involves updating compositing state. 73 // involves updating compositing state.
61 DisableCompositingQueryAsserts disabler; 74 DisableCompositingQueryAsserts disabler;
62 75
63 if (Node* node = m_position.anchorNode()) 76 if (Node* node = m_position.anchorNode())
64 m_caretBase->invalidateCaretRect(node, m_caretLocalRect); 77 invalidateCaretRect(node, m_caretLocalRect);
65 m_position = createVisiblePosition(position).toPositionWithAffinity(); 78 m_position = createVisiblePosition(position).toPositionWithAffinity();
66 Document* document = nullptr; 79 Document* document = nullptr;
67 if (Node* node = m_position.anchorNode()) { 80 if (Node* node = m_position.anchorNode()) {
68 m_caretBase->invalidateCaretRect(node, m_caretLocalRect); 81 invalidateCaretRect(node, m_caretLocalRect);
69 document = &node->document(); 82 document = &node->document();
70 setContext(document); 83 setContext(document);
71 } 84 }
72 if (m_position.isNull()) { 85 if (m_position.isNull()) {
73 m_caretLocalRect = LayoutRect(); 86 m_caretLocalRect = LayoutRect();
74 } else { 87 } else {
75 DCHECK(!m_position.isOrphan()); 88 DCHECK(!m_position.isOrphan());
76 document->updateStyleAndLayoutTree(); 89 document->updateStyleAndLayoutTree();
77 m_caretLocalRect = CaretBase::computeCaretRect(m_position); 90 m_caretLocalRect = CaretBase::computeCaretRect(m_position);
78 } 91 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 void DragCaretController::paintDragCaret(LocalFrame* frame, 123 void DragCaretController::paintDragCaret(LocalFrame* frame,
111 GraphicsContext& context, 124 GraphicsContext& context,
112 const LayoutPoint& paintOffset) const { 125 const LayoutPoint& paintOffset) const {
113 if (m_position.anchorNode()->document().frame() == frame) { 126 if (m_position.anchorNode()->document().frame() == frame) {
114 m_caretBase->paintCaret(m_position.anchorNode(), context, m_caretLocalRect, 127 m_caretBase->paintCaret(m_position.anchorNode(), context, m_caretLocalRect,
115 paintOffset, DisplayItem::kDragCaret); 128 paintOffset, DisplayItem::kDragCaret);
116 } 129 }
117 } 130 }
118 131
119 } // namespace blink 132 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/editing/DragCaretController.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698