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

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: Created 4 years, 7 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 { 57 {
58 if (!node) 58 if (!node)
59 return nullptr; 59 return nullptr;
60 60
61 LayoutObject* layoutObject = node->layoutObject(); 61 LayoutObject* layoutObject = node->layoutObject();
62 if (!layoutObject) 62 if (!layoutObject)
63 return nullptr; 63 return nullptr;
64 64
65 // if caretNode is a block and caret is inside it then caret should be paint ed by that block 65 // if caretNode is a block and caret is inside it then caret should be paint ed by that block
66 bool paintedByBlock = layoutObject->isLayoutBlock() && caretRendersInsideNod e(node); 66 bool paintedByBlock = layoutObject->isLayoutBlock() && caretRendersInsideNod e(node);
67 // caretRendersInsideNode can layout
68 layoutObject = node->layoutObject();
yosin_UTC9 2016/05/12 06:55:31 We can't explain what this line does. When layout
yosin_UTC9 2016/05/24 08:40:18 Could you change this to below? // TODO(yoichio):
yoichio 2016/05/25 06:46:50 Done.
67 return paintedByBlock ? toLayoutBlock(layoutObject) : layoutObject->containi ngBlock(); 69 return paintedByBlock ? toLayoutBlock(layoutObject) : layoutObject->containi ngBlock();
68 } 70 }
69 71
70 static void mapCaretRectToCaretPainter(LayoutItem caretLayoutItem, LayoutBlockIt em caretPainterItem, LayoutRect& caretRect) 72 static void mapCaretRectToCaretPainter(LayoutItem caretLayoutItem, LayoutBlockIt em caretPainterItem, LayoutRect& caretRect)
71 { 73 {
72 // FIXME: This shouldn't be called on un-rooted subtrees. 74 // FIXME: This shouldn't be called on un-rooted subtrees.
73 // FIXME: This should probably just use mapLocalToAncestor. 75 // FIXME: This should probably just use mapLocalToAncestor.
74 // Compute an offset between the caretLayoutItem and the caretPainterItem. 76 // Compute an offset between the caretLayoutItem and the caretPainterItem.
75 77
76 DCHECK(caretLayoutItem.isDescendantOf(caretPainterItem)); 78 DCHECK(caretLayoutItem.isDescendantOf(caretPainterItem));
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 { 123 {
122 LayoutBlock* caretPainter = caretLayoutObject(node); 124 LayoutBlock* caretPainter = caretLayoutObject(node);
123 if (!caretPainter) 125 if (!caretPainter)
124 return IntRect(); 126 return IntRect();
125 127
126 LayoutRect localRect(rect); 128 LayoutRect localRect(rect);
127 caretPainter->flipForWritingMode(localRect); 129 caretPainter->flipForWritingMode(localRect);
128 return caretPainter->localToAbsoluteQuad(FloatRect(localRect)).enclosingBoun dingBox(); 130 return caretPainter->localToAbsoluteQuad(FloatRect(localRect)).enclosingBoun dingBox();
129 } 131 }
130 132
133 // TODO(yoichio): |node| is FrameSelection::m_previousCaretNode and this is bad
134 // design. We should use only previous layoutObject or Rectangle to invalidate
135 // old caret.
131 void CaretBase::invalidateLocalCaretRect(Node* node, const LayoutRect& rect) 136 void CaretBase::invalidateLocalCaretRect(Node* node, const LayoutRect& rect)
132 { 137 {
133 LayoutBlockItem caretPainter = LayoutBlockItem(caretLayoutObject(node)); 138 LayoutBlockItem caretPainter = LayoutBlockItem(caretLayoutObject(node));
134 if (!caretPainter) 139 if (!caretPainter)
135 return; 140 return;
136 141
137 // FIXME: Need to over-paint 1 pixel to workaround some rounding problems. 142 // FIXME: Need to over-paint 1 pixel to workaround some rounding problems.
138 // https://bugs.webkit.org/show_bug.cgi?id=108283 143 // https://bugs.webkit.org/show_bug.cgi?id=108283
139 LayoutRect inflatedRect = rect; 144 LayoutRect inflatedRect = rect;
140 inflatedRect.inflate(LayoutUnit(1)); 145 inflatedRect.inflate(LayoutUnit(1));
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 else 199 else
195 element = node->parentElement(); 200 element = node->parentElement();
196 201
197 if (element && element->layoutObject()) 202 if (element && element->layoutObject())
198 caretColor = element->layoutObject()->resolveColor(CSSPropertyColor); 203 caretColor = element->layoutObject()->resolveColor(CSSPropertyColor);
199 204
200 context.fillRect(FloatRect(drawingRect), caretColor); 205 context.fillRect(FloatRect(drawingRect), caretColor);
201 } 206 }
202 207
203 } // namespace blink 208 } // 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