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

Side by Side Diff: third_party/WebKit/Source/core/layout/line/LineBoxList.cpp

Issue 1780673002: Simplify CullRect computation in LineBoxList::hitTest; fixing off-by-one (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@svg-text-hittest-no-floor
Patch Set: Created 4 years, 9 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/layout/HitTestLocation.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) 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2008 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 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 if (hitTestAction != HitTestForeground) 195 if (hitTestAction != HitTestForeground)
196 return false; 196 return false;
197 197
198 ASSERT(layoutObject.isLayoutBlock() || (layoutObject.isLayoutInline() && lay outObject.hasLayer())); // The only way an inline could hit test like this is if it has a layer. 198 ASSERT(layoutObject.isLayoutBlock() || (layoutObject.isLayoutInline() && lay outObject.hasLayer())); // The only way an inline could hit test like this is if it has a layer.
199 199
200 // If we have no lines then we have no work to do. 200 // If we have no lines then we have no work to do.
201 if (!firstLineBox()) 201 if (!firstLineBox())
202 return false; 202 return false;
203 203
204 LayoutPoint point = locationInContainer.point(); 204 LayoutPoint point = locationInContainer.point();
205 IntRect hitSearchBoundingBox = locationInContainer.boundingBox();
205 206
206 CullRect cullRect(firstLineBox()->isHorizontal() ? 207 CullRect cullRect(firstLineBox()->isHorizontal() ?
207 IntRect(point.x(), point.y() - locationInContainer.topPadding(), 1, loca tionInContainer.topPadding() + locationInContainer.bottomPadding() + 1) : 208 IntRect(point.x(), hitSearchBoundingBox.y(), 1, hitSearchBoundingBox.hei ght()) :
208 IntRect(point.x() - locationInContainer.leftPadding(), point.y(), locati onInContainer.rightPadding() + locationInContainer.leftPadding() + 1, 1)); 209 IntRect(hitSearchBoundingBox.x(), point.y(), hitSearchBoundingBox.width( ), 1));
209 210
210 if (!anyLineIntersectsRect(layoutObject, cullRect, accumulatedOffset)) 211 if (!anyLineIntersectsRect(layoutObject, cullRect, accumulatedOffset))
211 return false; 212 return false;
212 213
213 // See if our root lines contain the point. If so, then we hit test 214 // See if our root lines contain the point. If so, then we hit test
214 // them further. Note that boxes can easily overlap, so we can't make any a ssumptions 215 // them further. Note that boxes can easily overlap, so we can't make any a ssumptions
215 // based off positions of our first line box or our last line box. 216 // based off positions of our first line box or our last line box.
216 for (InlineFlowBox* curr = lastLineBox(); curr; curr = curr->prevLineBox()) { 217 for (InlineFlowBox* curr = lastLineBox(); curr; curr = curr->prevLineBox()) {
217 RootInlineBox& root = curr->root(); 218 RootInlineBox& root = curr->root();
218 if (rangeIntersectsRect(layoutObject, curr->logicalTopVisualOverflow(roo t.lineTop()), curr->logicalBottomVisualOverflow(root.lineBottom()), cullRect, ac cumulatedOffset)) { 219 if (rangeIntersectsRect(layoutObject, curr->logicalTopVisualOverflow(roo t.lineTop()), curr->logicalBottomVisualOverflow(root.lineBottom()), cullRect, ac cumulatedOffset)) {
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 ASSERT(child->prevLineBox() == prev); 318 ASSERT(child->prevLineBox() == prev);
318 prev = child; 319 prev = child;
319 } 320 }
320 ASSERT(prev == m_lastLineBox); 321 ASSERT(prev == m_lastLineBox);
321 #endif 322 #endif
322 } 323 }
323 324
324 #endif 325 #endif
325 326
326 } // namespace blink 327 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/HitTestLocation.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698