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

Side by Side Diff: Source/core/layout/HitTestResult.cpp

Issue 1142283004: Implement a Hit Test Cache. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Remove validity rect as per Elliott's request Created 5 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 | « Source/core/layout/HitTestResult.h ('k') | Source/core/layout/LayoutPart.cpp » ('j') | 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) 2006, 2008, 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2008, 2011 Apple Inc. All rights reserved.
3 * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 #include "core/page/FrameTree.h" 43 #include "core/page/FrameTree.h"
44 #include "core/svg/SVGElement.h" 44 #include "core/svg/SVGElement.h"
45 #include "platform/scroll/Scrollbar.h" 45 #include "platform/scroll/Scrollbar.h"
46 46
47 namespace blink { 47 namespace blink {
48 48
49 using namespace HTMLNames; 49 using namespace HTMLNames;
50 50
51 HitTestResult::HitTestResult() 51 HitTestResult::HitTestResult()
52 : m_hitTestRequest(HitTestRequest::ReadOnly | HitTestRequest::Active) 52 : m_hitTestRequest(HitTestRequest::ReadOnly | HitTestRequest::Active)
53 , m_cacheable(true)
53 , m_isOverWidget(false) 54 , m_isOverWidget(false)
54 { 55 {
55 } 56 }
56 57
57 HitTestResult::HitTestResult(const HitTestRequest& request, const LayoutPoint& p oint) 58 HitTestResult::HitTestResult(const HitTestRequest& request, const LayoutPoint& p oint)
58 : m_hitTestLocation(point) 59 : m_hitTestLocation(point)
59 , m_hitTestRequest(request) 60 , m_hitTestRequest(request)
61 , m_cacheable(true)
60 , m_pointInInnerNodeFrame(point) 62 , m_pointInInnerNodeFrame(point)
61 , m_isOverWidget(false) 63 , m_isOverWidget(false)
62 { 64 {
63 } 65 }
64 66
65 HitTestResult::HitTestResult(const HitTestRequest& request, const LayoutPoint& c enterPoint, unsigned topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding) 67 HitTestResult::HitTestResult(const HitTestRequest& request, const LayoutPoint& c enterPoint, unsigned topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding)
66 : m_hitTestLocation(centerPoint, topPadding, rightPadding, bottomPadding, le ftPadding) 68 : m_hitTestLocation(centerPoint, topPadding, rightPadding, bottomPadding, le ftPadding)
67 , m_hitTestRequest(request) 69 , m_hitTestRequest(request)
70 , m_cacheable(true)
68 , m_pointInInnerNodeFrame(centerPoint) 71 , m_pointInInnerNodeFrame(centerPoint)
69 , m_isOverWidget(false) 72 , m_isOverWidget(false)
70 { 73 {
71 } 74 }
72 75
73 HitTestResult::HitTestResult(const HitTestRequest& otherRequest, const HitTestLo cation& other) 76 HitTestResult::HitTestResult(const HitTestRequest& otherRequest, const HitTestLo cation& other)
74 : m_hitTestLocation(other) 77 : m_hitTestLocation(other)
75 , m_hitTestRequest(otherRequest) 78 , m_hitTestRequest(otherRequest)
79 , m_cacheable(true)
76 , m_pointInInnerNodeFrame(m_hitTestLocation.point()) 80 , m_pointInInnerNodeFrame(m_hitTestLocation.point())
77 , m_isOverWidget(false) 81 , m_isOverWidget(false)
78 { 82 {
79 } 83 }
80 84
81 HitTestResult::HitTestResult(const HitTestResult& other) 85 HitTestResult::HitTestResult(const HitTestResult& other)
82 : m_hitTestLocation(other.m_hitTestLocation) 86 : m_hitTestLocation(other.m_hitTestLocation)
83 , m_hitTestRequest(other.m_hitTestRequest) 87 , m_hitTestRequest(other.m_hitTestRequest)
84 , m_innerNode(other.innerNode()) 88 , m_innerNode(other.innerNode())
85 , m_innerPossiblyPseudoNode(other.m_innerPossiblyPseudoNode) 89 , m_innerPossiblyPseudoNode(other.m_innerPossiblyPseudoNode)
86 , m_pointInInnerNodeFrame(other.m_pointInInnerNodeFrame) 90 , m_pointInInnerNodeFrame(other.m_pointInInnerNodeFrame)
87 , m_localPoint(other.localPoint()) 91 , m_localPoint(other.localPoint())
88 , m_innerURLElement(other.URLElement()) 92 , m_innerURLElement(other.URLElement())
89 , m_scrollbar(other.scrollbar()) 93 , m_scrollbar(other.scrollbar())
90 , m_isOverWidget(other.isOverWidget()) 94 , m_isOverWidget(other.isOverWidget())
91 { 95 {
92 // Only copy the NodeSet in case of list hit test. 96 // Only copy the NodeSet in case of list hit test.
93 m_listBasedTestResult = adoptPtrWillBeNoop(other.m_listBasedTestResult ? new NodeSet(*other.m_listBasedTestResult) : 0); 97 m_listBasedTestResult = adoptPtrWillBeNoop(other.m_listBasedTestResult ? new NodeSet(*other.m_listBasedTestResult) : 0);
94 } 98 }
95 99
96 HitTestResult::~HitTestResult() 100 HitTestResult::~HitTestResult()
97 { 101 {
98 } 102 }
99 103
100 HitTestResult& HitTestResult::operator=(const HitTestResult& other) 104 HitTestResult& HitTestResult::operator=(const HitTestResult& other)
101 { 105 {
102 m_hitTestLocation = other.m_hitTestLocation; 106 m_hitTestLocation = other.m_hitTestLocation;
103 m_hitTestRequest = other.m_hitTestRequest; 107 m_hitTestRequest = other.m_hitTestRequest;
108 populateFromCachedResult(other);
109
110 return *this;
111 }
112
113 bool HitTestResult::equalForCacheability(const HitTestResult& other) const
114 {
115 return m_hitTestRequest.equalForCacheability(other.m_hitTestRequest)
116 && m_innerNode == other.innerNode()
117 && m_innerPossiblyPseudoNode == other.innerPossiblyPseudoNode()
118 && m_pointInInnerNodeFrame == other.m_pointInInnerNodeFrame
119 && m_localPoint == other.localPoint()
120 && m_innerURLElement == other.URLElement()
121 && m_scrollbar == other.scrollbar()
122 && m_isOverWidget == other.isOverWidget();
123 }
124
125 void HitTestResult::cacheValues(const HitTestResult& other)
126 {
127 *this = other;
128 m_hitTestRequest = other.m_hitTestRequest.type() & ~HitTestRequest::AvoidCac he;
129 }
130
131 void HitTestResult::populateFromCachedResult(const HitTestResult& other)
132 {
104 m_innerNode = other.innerNode(); 133 m_innerNode = other.innerNode();
105 m_innerPossiblyPseudoNode = other.innerPossiblyPseudoNode(); 134 m_innerPossiblyPseudoNode = other.innerPossiblyPseudoNode();
106 m_pointInInnerNodeFrame = other.m_pointInInnerNodeFrame; 135 m_pointInInnerNodeFrame = other.m_pointInInnerNodeFrame;
107 m_localPoint = other.localPoint(); 136 m_localPoint = other.localPoint();
108 m_innerURLElement = other.URLElement(); 137 m_innerURLElement = other.URLElement();
109 m_scrollbar = other.scrollbar(); 138 m_scrollbar = other.scrollbar();
110 m_isOverWidget = other.isOverWidget(); 139 m_isOverWidget = other.isOverWidget();
140 m_cacheable = other.m_cacheable;
111 141
112 // Only copy the NodeSet in case of list hit test. 142 // Only copy the NodeSet in case of list hit test.
113 m_listBasedTestResult = adoptPtrWillBeNoop(other.m_listBasedTestResult ? new NodeSet(*other.m_listBasedTestResult) : 0); 143 m_listBasedTestResult = adoptPtrWillBeNoop(other.m_listBasedTestResult ? new NodeSet(*other.m_listBasedTestResult) : 0);
114
115 return *this;
116 } 144 }
117 145
118 DEFINE_TRACE(HitTestResult) 146 DEFINE_TRACE(HitTestResult)
119 { 147 {
120 visitor->trace(m_innerNode); 148 visitor->trace(m_innerNode);
121 visitor->trace(m_innerPossiblyPseudoNode); 149 visitor->trace(m_innerPossiblyPseudoNode);
122 visitor->trace(m_innerURLElement); 150 visitor->trace(m_innerURLElement);
123 visitor->trace(m_scrollbar); 151 visitor->trace(m_scrollbar);
124 #if ENABLE(OILPAN) 152 #if ENABLE(OILPAN)
125 visitor->trace(m_listBasedTestResult); 153 visitor->trace(m_listBasedTestResult);
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 else if (isHTMLMapElement(m_innerNode)) 539 else if (isHTMLMapElement(m_innerNode))
512 imageMapImageElement = toHTMLMapElement(m_innerNode)->imageElement(); 540 imageMapImageElement = toHTMLMapElement(m_innerNode)->imageElement();
513 541
514 if (!imageMapImageElement) 542 if (!imageMapImageElement)
515 return m_innerNode.get(); 543 return m_innerNode.get();
516 544
517 return imageMapImageElement; 545 return imageMapImageElement;
518 } 546 }
519 547
520 } // namespace blink 548 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/layout/HitTestResult.h ('k') | Source/core/layout/LayoutPart.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698