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

Side by Side Diff: Source/core/layout/LayoutBox.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) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) 4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com)
5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com) 5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com)
6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv ed. 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv ed.
7 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. 7 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved.
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 1111 matching lines...) Expand 10 before | Expand all | Expand 10 after
1122 if (style()->boxSizing() == BORDER_BOX) 1122 if (style()->boxSizing() == BORDER_BOX)
1123 height -= borderAndPaddingLogicalHeight(); 1123 height -= borderAndPaddingLogicalHeight();
1124 return std::max(LayoutUnit(), height); 1124 return std::max(LayoutUnit(), height);
1125 } 1125 }
1126 1126
1127 // Hit Testing 1127 // Hit Testing
1128 bool LayoutBox::nodeAtPoint(HitTestResult& result, const HitTestLocation& locati onInContainer, const LayoutPoint& accumulatedOffset, HitTestAction action) 1128 bool LayoutBox::nodeAtPoint(HitTestResult& result, const HitTestLocation& locati onInContainer, const LayoutPoint& accumulatedOffset, HitTestAction action)
1129 { 1129 {
1130 LayoutPoint adjustedLocation = accumulatedOffset + location(); 1130 LayoutPoint adjustedLocation = accumulatedOffset + location();
1131 1131
1132 LayoutRect boundsRect = borderBoxRect();
1133 boundsRect.moveBy(adjustedLocation);
1132 // Check kids first. 1134 // Check kids first.
1133 for (LayoutObject* child = slowLastChild(); child; child = child->previousSi bling()) { 1135 for (LayoutObject* child = slowLastChild(); child; child = child->previousSi bling()) {
1134 if ((!child->hasLayer() || !toLayoutBoxModelObject(child)->layer()->isSe lfPaintingLayer()) && child->nodeAtPoint(result, locationInContainer, adjustedLo cation, action)) { 1136 if ((!child->hasLayer() || !toLayoutBoxModelObject(child)->layer()->isSe lfPaintingLayer()) && child->nodeAtPoint(result, locationInContainer, adjustedLo cation, action)) {
1135 updateHitTestResult(result, locationInContainer.point() - toLayoutSi ze(adjustedLocation)); 1137 updateHitTestResult(result, locationInContainer.point() - toLayoutSi ze(adjustedLocation), boundsRect);
1136 return true; 1138 return true;
1137 } 1139 }
1138 } 1140 }
1139 1141
1140 // Check our bounds next. For this purpose always assume that we can only be hit in the 1142 // Check our bounds next. For this purpose always assume that we can only be hit in the
1141 // foreground phase (which is true for replaced elements like images). 1143 // foreground phase (which is true for replaced elements like images).
1142 LayoutRect boundsRect = borderBoxRect();
1143 boundsRect.moveBy(adjustedLocation);
1144 if (visibleToHitTestRequest(result.hitTestRequest()) && action == HitTestFor eground && locationInContainer.intersects(boundsRect)) { 1144 if (visibleToHitTestRequest(result.hitTestRequest()) && action == HitTestFor eground && locationInContainer.intersects(boundsRect)) {
1145 updateHitTestResult(result, locationInContainer.point() - toLayoutSize(a djustedLocation)); 1145 updateHitTestResult(result, locationInContainer.point() - toLayoutSize(a djustedLocation), boundsRect);
1146 if (!result.addNodeToListBasedTestResult(node(), locationInContainer, bo undsRect)) 1146 if (!result.addNodeToListBasedTestResult(node(), locationInContainer, bo undsRect))
1147 return true; 1147 return true;
1148 } 1148 }
1149 result.shrinkValidityRect(boundsRect);
1149 1150
1150 return false; 1151 return false;
1151 } 1152 }
1152 1153
1153 void LayoutBox::paint(const PaintInfo& paintInfo, const LayoutPoint& paintOffset ) 1154 void LayoutBox::paint(const PaintInfo& paintInfo, const LayoutPoint& paintOffset )
1154 { 1155 {
1155 BoxPainter(*this).paint(paintInfo, paintOffset); 1156 BoxPainter(*this).paint(paintInfo, paintOffset);
1156 } 1157 }
1157 1158
1158 1159
(...skipping 3635 matching lines...) Expand 10 before | Expand all | Expand 10 after
4794 bool LayoutBox::canRenderBorderImage() const 4795 bool LayoutBox::canRenderBorderImage() const
4795 { 4796 {
4796 if (!style()->hasBorder()) 4797 if (!style()->hasBorder())
4797 return false; 4798 return false;
4798 4799
4799 StyleImage* borderImage = style()->borderImage().image(); 4800 StyleImage* borderImage = style()->borderImage().image();
4800 return borderImage && borderImage->canRender(*this, style()->effectiveZoom() ) && borderImage->isLoaded(); 4801 return borderImage && borderImage->canRender(*this, style()->effectiveZoom() ) && borderImage->isLoaded();
4801 } 4802 }
4802 4803
4803 } // namespace blink 4804 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698