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

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

Issue 1972523002: [asan][Editing] Check node->layoutObject in CaretBase::caretLayoutObject (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Change to CHECK_EQ Created 4 years, 6 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 | « no previous file | 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 { 63 {
64 if (!node) 64 if (!node)
65 return nullptr; 65 return nullptr;
66 66
67 LayoutObject* layoutObject = node->layoutObject(); 67 LayoutObject* layoutObject = node->layoutObject();
68 if (!layoutObject) 68 if (!layoutObject)
69 return nullptr; 69 return nullptr;
70 70
71 // if caretNode is a block and caret is inside it then caret should be paint ed by that block 71 // if caretNode is a block and caret is inside it then caret should be paint ed by that block
72 bool paintedByBlock = layoutObject->isLayoutBlock() && caretRendersInsideNod e(node); 72 bool paintedByBlock = layoutObject->isLayoutBlock() && caretRendersInsideNod e(node);
73 // TODO(yoichio): This function is called at least
74 // DocumentLifeCycle::LayoutClean but caretRendersInsideNode above can
75 // layout. Thus |node->layoutObject()| can be changed then this is bad
76 // design. We should make caret painting algorithm clean.
77 CHECK_EQ(layoutObject, node->layoutObject()) << "Layout tree should not chan ged";
73 return paintedByBlock ? toLayoutBlock(layoutObject) : layoutObject->containi ngBlock(); 78 return paintedByBlock ? toLayoutBlock(layoutObject) : layoutObject->containi ngBlock();
74 } 79 }
75 80
76 static void mapCaretRectToCaretPainter(LayoutItem caretLayoutItem, LayoutBlockIt em caretPainterItem, LayoutRect& caretRect) 81 static void mapCaretRectToCaretPainter(LayoutItem caretLayoutItem, LayoutBlockIt em caretPainterItem, LayoutRect& caretRect)
77 { 82 {
78 // FIXME: This shouldn't be called on un-rooted subtrees. 83 // FIXME: This shouldn't be called on un-rooted subtrees.
79 // FIXME: This should probably just use mapLocalToAncestor. 84 // FIXME: This should probably just use mapLocalToAncestor.
80 // Compute an offset between the caretLayoutItem and the caretPainterItem. 85 // Compute an offset between the caretLayoutItem and the caretPainterItem.
81 86
82 DCHECK(caretLayoutItem.isDescendantOf(caretPainterItem)); 87 DCHECK(caretLayoutItem.isDescendantOf(caretPainterItem));
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 { 132 {
128 LayoutBlock* caretPainter = caretLayoutObject(node); 133 LayoutBlock* caretPainter = caretLayoutObject(node);
129 if (!caretPainter) 134 if (!caretPainter)
130 return IntRect(); 135 return IntRect();
131 136
132 LayoutRect localRect(rect); 137 LayoutRect localRect(rect);
133 caretPainter->flipForWritingMode(localRect); 138 caretPainter->flipForWritingMode(localRect);
134 return caretPainter->localToAbsoluteQuad(FloatRect(localRect)).enclosingBoun dingBox(); 139 return caretPainter->localToAbsoluteQuad(FloatRect(localRect)).enclosingBoun dingBox();
135 } 140 }
136 141
142 // TODO(yoichio): |node| is FrameSelection::m_previousCaretNode and this is bad
143 // design. We should use only previous layoutObject or Rectangle to invalidate
144 // old caret.
137 void CaretBase::invalidateLocalCaretRect(Node* node, const LayoutRect& rect) 145 void CaretBase::invalidateLocalCaretRect(Node* node, const LayoutRect& rect)
138 { 146 {
139 LayoutBlockItem caretPainter = LayoutBlockItem(caretLayoutObject(node)); 147 LayoutBlockItem caretPainter = LayoutBlockItem(caretLayoutObject(node));
140 if (!caretPainter) 148 if (!caretPainter)
141 return; 149 return;
142 150
143 // FIXME: Need to over-paint 1 pixel to workaround some rounding problems. 151 // FIXME: Need to over-paint 1 pixel to workaround some rounding problems.
144 // https://bugs.webkit.org/show_bug.cgi?id=108283 152 // https://bugs.webkit.org/show_bug.cgi?id=108283
145 LayoutRect inflatedRect = rect; 153 LayoutRect inflatedRect = rect;
146 inflatedRect.inflate(LayoutUnit(1)); 154 inflatedRect.inflate(LayoutUnit(1));
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 else 208 else
201 element = node->parentElement(); 209 element = node->parentElement();
202 210
203 if (element && element->layoutObject()) 211 if (element && element->layoutObject())
204 caretColor = element->layoutObject()->resolveColor(CSSPropertyColor); 212 caretColor = element->layoutObject()->resolveColor(CSSPropertyColor);
205 213
206 context.fillRect(FloatRect(drawingRect), caretColor); 214 context.fillRect(FloatRect(drawingRect), caretColor);
207 } 215 }
208 216
209 } // namespace blink 217 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698