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

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

Issue 2042153002: Check node->layoutObject in CaretBase::caretLayoutObject (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2743
Patch Set: 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 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 // TODO(yoichio): This function is called at least
68 // DocumentLifeCycle::LayoutClean but caretRendersInsideNode above can
69 // layout. Thus |node->layoutObject()| can be changed then this is bad
70 // design. We should make caret painting algorithm clean.
71 CHECK_EQ(layoutObject, node->layoutObject()) << "Layout tree should not chan ged";
67 return paintedByBlock ? toLayoutBlock(layoutObject) : layoutObject->containi ngBlock(); 72 return paintedByBlock ? toLayoutBlock(layoutObject) : layoutObject->containi ngBlock();
68 } 73 }
69 74
70 static void mapCaretRectToCaretPainter(LayoutItem caretLayoutItem, LayoutBlockIt em caretPainterItem, LayoutRect& caretRect) 75 static void mapCaretRectToCaretPainter(LayoutItem caretLayoutItem, LayoutBlockIt em caretPainterItem, LayoutRect& caretRect)
71 { 76 {
72 // FIXME: This shouldn't be called on un-rooted subtrees. 77 // FIXME: This shouldn't be called on un-rooted subtrees.
73 // FIXME: This should probably just use mapLocalToAncestor. 78 // FIXME: This should probably just use mapLocalToAncestor.
74 // Compute an offset between the caretLayoutItem and the caretPainterItem. 79 // Compute an offset between the caretLayoutItem and the caretPainterItem.
75 80
76 DCHECK(caretLayoutItem.isDescendantOf(caretPainterItem)); 81 DCHECK(caretLayoutItem.isDescendantOf(caretPainterItem));
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 { 126 {
122 LayoutBlock* caretPainter = caretLayoutObject(node); 127 LayoutBlock* caretPainter = caretLayoutObject(node);
123 if (!caretPainter) 128 if (!caretPainter)
124 return IntRect(); 129 return IntRect();
125 130
126 LayoutRect localRect(rect); 131 LayoutRect localRect(rect);
127 caretPainter->flipForWritingMode(localRect); 132 caretPainter->flipForWritingMode(localRect);
128 return caretPainter->localToAbsoluteQuad(FloatRect(localRect)).enclosingBoun dingBox(); 133 return caretPainter->localToAbsoluteQuad(FloatRect(localRect)).enclosingBoun dingBox();
129 } 134 }
130 135
136 // TODO(yoichio): |node| is FrameSelection::m_previousCaretNode and this is bad
137 // design. We should use only previous layoutObject or Rectangle to invalidate
138 // old caret.
131 void CaretBase::invalidateLocalCaretRect(Node* node, const LayoutRect& rect) 139 void CaretBase::invalidateLocalCaretRect(Node* node, const LayoutRect& rect)
132 { 140 {
133 LayoutBlockItem caretPainter = LayoutBlockItem(caretLayoutObject(node)); 141 LayoutBlockItem caretPainter = LayoutBlockItem(caretLayoutObject(node));
134 if (!caretPainter) 142 if (!caretPainter)
135 return; 143 return;
136 144
137 // FIXME: Need to over-paint 1 pixel to workaround some rounding problems. 145 // FIXME: Need to over-paint 1 pixel to workaround some rounding problems.
138 // https://bugs.webkit.org/show_bug.cgi?id=108283 146 // https://bugs.webkit.org/show_bug.cgi?id=108283
139 LayoutRect inflatedRect = rect; 147 LayoutRect inflatedRect = rect;
140 inflatedRect.inflate(LayoutUnit(1)); 148 inflatedRect.inflate(LayoutUnit(1));
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 else 202 else
195 element = node->parentElement(); 203 element = node->parentElement();
196 204
197 if (element && element->layoutObject()) 205 if (element && element->layoutObject())
198 caretColor = element->layoutObject()->resolveColor(CSSPropertyColor); 206 caretColor = element->layoutObject()->resolveColor(CSSPropertyColor);
199 207
200 context.fillRect(FloatRect(drawingRect), caretColor); 208 context.fillRect(FloatRect(drawingRect), caretColor);
201 } 209 }
202 210
203 } // namespace blink 211 } // 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