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

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

Issue 1142283004: Implement a Hit Test Cache. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 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
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 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 202
203 // If we have no lines then we have no work to do. 203 // If we have no lines then we have no work to do.
204 if (!firstLineBox()) 204 if (!firstLineBox())
205 return false; 205 return false;
206 206
207 LayoutPoint point = locationInContainer.point(); 207 LayoutPoint point = locationInContainer.point();
208 LayoutRect rect(firstLineBox()->isHorizontal() ? 208 LayoutRect rect(firstLineBox()->isHorizontal() ?
209 IntRect(point.x(), point.y() - locationInContainer.topPadding(), 1, loca tionInContainer.topPadding() + locationInContainer.bottomPadding() + 1) : 209 IntRect(point.x(), point.y() - locationInContainer.topPadding(), 1, loca tionInContainer.topPadding() + locationInContainer.bottomPadding() + 1) :
210 IntRect(point.x() - locationInContainer.leftPadding(), point.y(), locati onInContainer.rightPadding() + locationInContainer.leftPadding() + 1, 1)); 210 IntRect(point.x() - locationInContainer.leftPadding(), point.y(), locati onInContainer.rightPadding() + locationInContainer.leftPadding() + 1, 1));
211 211
212 if (!anyLineIntersectsRect(layoutObject, rect, accumulatedOffset)) 212 if (!anyLineIntersectsRect(layoutObject, rect, accumulatedOffset)) {
213 InlineFlowBox* first = firstLineBox();
214 RootInlineBox& firstRoot = first->root();
215 InlineFlowBox* last = lastLineBox();
216 RootInlineBox& lastRoot = last->root();
217
218 result.shrinkValidityRect(first->visualOverflowRect(firstRoot.lineTop(), firstRoot.lineBottom()));
219 if (first != last)
220 result.shrinkValidityRect(last->visualOverflowRect(lastRoot.lineTop( ), lastRoot.lineBottom()));
213 return false; 221 return false;
222 }
214 223
215 // See if our root lines contain the point. If so, then we hit test 224 // See if our root lines contain the point. If so, then we hit test
216 // them further. Note that boxes can easily overlap, so we can't make any a ssumptions 225 // them further. Note that boxes can easily overlap, so we can't make any a ssumptions
217 // based off positions of our first line box or our last line box. 226 // based off positions of our first line box or our last line box.
218 for (InlineFlowBox* curr = lastLineBox(); curr; curr = curr->prevLineBox()) { 227 for (InlineFlowBox* curr = lastLineBox(); curr; curr = curr->prevLineBox()) {
219 RootInlineBox& root = curr->root(); 228 RootInlineBox& root = curr->root();
220 if (rangeIntersectsRect(layoutObject, curr->logicalTopVisualOverflow(roo t.lineTop()), curr->logicalBottomVisualOverflow(root.lineBottom()), rect, accumu latedOffset)) { 229 if (rangeIntersectsRect(layoutObject, curr->logicalTopVisualOverflow(roo t.lineTop()), curr->logicalBottomVisualOverflow(root.lineBottom()), rect, accumu latedOffset)) {
221 bool inside = curr->nodeAtPoint(result, locationInContainer, accumul atedOffset, root.lineTop(), root.lineBottom()); 230 bool inside = curr->nodeAtPoint(result, locationInContainer, accumul atedOffset, root.lineTop(), root.lineBottom());
222 if (inside) { 231 if (inside) {
223 layoutObject->updateHitTestResult(result, locationInContainer.po int() - toLayoutSize(accumulatedOffset)); 232 layoutObject->updateHitTestResult(result, locationInContainer.po int() - toLayoutSize(accumulatedOffset), curr->visualOverflowRect(root.lineTop() , root.lineBottom()));
224 return true; 233 return true;
225 } 234 }
235 } else {
236 result.shrinkValidityRect(curr->visualOverflowRect(root.lineTop(), r oot.lineBottom()));
226 } 237 }
227 } 238 }
228 239
229 return false; 240 return false;
230 } 241 }
231 242
232 void LineBoxList::dirtyLinesFromChangedChild(LayoutObject* container, LayoutObje ct* child) 243 void LineBoxList::dirtyLinesFromChangedChild(LayoutObject* container, LayoutObje ct* child)
233 { 244 {
234 if (!container->parent() || (container->isLayoutBlock() && (container->selfN eedsLayout() || !container->isLayoutBlockFlow()))) 245 if (!container->parent() || (container->isLayoutBlock() && (container->selfN eedsLayout() || !container->isLayoutBlockFlow())))
235 return; 246 return;
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 ASSERT(child->prevLineBox() == prev); 331 ASSERT(child->prevLineBox() == prev);
321 prev = child; 332 prev = child;
322 } 333 }
323 ASSERT(prev == m_lastLineBox); 334 ASSERT(prev == m_lastLineBox);
324 #endif 335 #endif
325 } 336 }
326 337
327 #endif 338 #endif
328 339
329 } 340 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698