Changeset 117091 in webkit
- Timestamp:
- May 15, 2012 10:41:34 AM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r117086 r117091 1 2012-05-15 Allan Sandfeld Jensen <allan.jensen@nokia.com> 2 3 Factor HitTestPoint out of HitTestResult. 4 https://bugs.webkit.org/show_bug.cgi?id=85965 5 6 Reviewed by Simon Fraser. 7 8 In preparation for handling transformations on area-based hit-testing, 9 we need to factor test-point and test-area out of HitTestResult so that 10 it can be transformed independently. 11 12 To maintain the current API as closely as possible HitTestResult now 13 inherit from HitTestPoint, representing the original untransformed 14 hitTestPoint. 15 16 No change in functionality. No new tests. 17 18 * rendering/HitTestResult.cpp: 19 (WebCore::HitTestPoint::HitTestPoint): 20 (WebCore::HitTestPoint::~HitTestPoint): 21 (WebCore::HitTestPoint::operator=): 22 (WebCore::HitTestPoint::rectForPoint): 23 (WebCore::HitTestResult::HitTestResult): 24 (WebCore::HitTestResult::operator=): 25 (WebCore::HitTestResult::isSelected): 26 (WebCore::HitTestResult::spellingToolTip): 27 (WebCore::HitTestResult::replacedString): 28 * rendering/HitTestResult.h: 29 (HitTestPoint): 30 (WebCore::HitTestPoint::point): 31 (WebCore::HitTestPoint::roundedPoint): 32 (WebCore::HitTestPoint::setPoint): 33 (WebCore::HitTestPoint::isRectBasedTest): 34 (WebCore::HitTestPoint::topPadding): 35 (WebCore::HitTestPoint::rightPadding): 36 (WebCore::HitTestPoint::bottomPadding): 37 (WebCore::HitTestPoint::leftPadding): 38 (HitTestResult): 39 (WebCore::HitTestResult::hitTestPoint): 40 (WebCore::HitTestPoint::rectForPoint): 41 * rendering/RenderLayer.cpp: 42 (WebCore::RenderLayer::hitTestLayer): 43 (WebCore::RenderLayer::hitTestList): 44 1 45 2012-05-15 Rob Buis <rbuis@rim.com> 2 46 -
trunk/Source/WebCore/rendering/HitTestResult.cpp
r114926 r117091 1 1 /* 2 2 * Copyright (C) 2006, 2008, 2011 Apple Inc. All rights reserved. 3 * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies) 3 4 * 4 5 * This library is free software; you can redistribute it and/or … … 48 49 using namespace HTMLNames; 49 50 50 HitTestResult::HitTestResult() 51 : m_isOverWidget(false) 51 HitTestPoint::HitTestPoint() 52 : m_topPadding(0) 53 , m_rightPadding(0) 54 , m_bottomPadding(0) 55 , m_leftPadding(0) 52 56 , m_isRectBased(false) 57 { 58 } 59 60 HitTestPoint::HitTestPoint(const LayoutPoint& point) 61 : m_point(point) 53 62 , m_topPadding(0) 54 63 , m_rightPadding(0) 55 64 , m_bottomPadding(0) 56 65 , m_leftPadding(0) 57 , m_shadowContentFilterPolicy(DoNotAllowShadowContent)58 , m_region(0)59 {60 }61 62 HitTestResult::HitTestResult(const LayoutPoint& point)63 : m_point(point)64 , m_isOverWidget(false)65 66 , m_isRectBased(false) 66 , m_topPadding(0) 67 , m_rightPadding(0) 68 , m_bottomPadding(0) 69 , m_leftPadding(0) 70 , m_shadowContentFilterPolicy(DoNotAllowShadowContent) 71 , m_region(0) 72 { 73 } 74 75 HitTestResult::HitTestResult(const LayoutPoint& centerPoint, unsigned topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding, ShadowContentFilterPolicy allowShadowContent) 67 { 68 } 69 70 HitTestPoint::HitTestPoint(const LayoutPoint& centerPoint, unsigned topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding) 76 71 : m_point(centerPoint) 77 , m_isOverWidget(false)78 72 , m_topPadding(topPadding) 79 73 , m_rightPadding(rightPadding) 80 74 , m_bottomPadding(bottomPadding) 81 75 , m_leftPadding(leftPadding) 76 { 77 // If all padding values passed in are zero then it is not a rect based hit test. 78 m_isRectBased = topPadding || rightPadding || bottomPadding || leftPadding; 79 } 80 81 HitTestPoint::HitTestPoint(const HitTestPoint& other) 82 : m_point(other.m_point) 83 , m_topPadding(other.m_topPadding) 84 , m_rightPadding(other.m_rightPadding) 85 , m_bottomPadding(other.m_bottomPadding) 86 , m_leftPadding(other.m_leftPadding) 87 , m_isRectBased(other.m_isRectBased) 88 { 89 } 90 91 HitTestPoint::~HitTestPoint() 92 { 93 } 94 95 HitTestPoint& HitTestPoint::operator=(const HitTestPoint& other) 96 { 97 m_point = other.m_point; 98 m_topPadding = other.m_topPadding; 99 m_rightPadding = other.m_rightPadding; 100 m_bottomPadding = other.m_bottomPadding; 101 m_leftPadding = other.m_leftPadding; 102 m_isRectBased = other.m_isRectBased; 103 104 return *this; 105 } 106 107 IntRect HitTestPoint::rectForPoint(const LayoutPoint& point, unsigned topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding) 108 { 109 IntPoint actualPoint(roundedIntPoint(point)); 110 actualPoint -= IntSize(leftPadding, topPadding); 111 112 IntSize actualPadding(leftPadding + rightPadding, topPadding + bottomPadding); 113 // As IntRect is left inclusive and right exclusive (seeing IntRect::contains(x, y)), adding "1". 114 // FIXME: Remove this once non-rect based hit-detection stops using IntRect:intersects. 115 actualPadding += IntSize(1, 1); 116 117 return IntRect(actualPoint, actualPadding); 118 } 119 120 HitTestResult::HitTestResult() : HitTestPoint() 121 , m_isOverWidget(false) 122 , m_shadowContentFilterPolicy(DoNotAllowShadowContent) 123 , m_region(0) 124 { 125 } 126 127 HitTestResult::HitTestResult(const LayoutPoint& point) : HitTestPoint(point) 128 , m_isOverWidget(false) 129 , m_shadowContentFilterPolicy(DoNotAllowShadowContent) 130 , m_region(0) 131 { 132 } 133 134 HitTestResult::HitTestResult(const LayoutPoint& centerPoint, unsigned topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding, ShadowContentFilterPolicy allowShadowContent) 135 : HitTestPoint(centerPoint, topPadding, rightPadding, bottomPadding, leftPadding) 136 , m_isOverWidget(false) 82 137 , m_shadowContentFilterPolicy(allowShadowContent) 83 138 , m_region(0) 84 139 { 85 // If all padding values passed in are zero then it is not a rect based hit test. 86 m_isRectBased = topPadding || rightPadding || bottomPadding || leftPadding; 87 88 // Make sure all padding values are clamped to zero if it is not a rect hit test. 89 if (!m_isRectBased) 90 m_topPadding = m_rightPadding = m_bottomPadding = m_leftPadding = 0; 140 } 141 142 HitTestResult::HitTestResult(const HitTestPoint& other, ShadowContentFilterPolicy allowShadowContent) 143 : HitTestPoint(other) 144 , m_isOverWidget(false) 145 , m_shadowContentFilterPolicy(allowShadowContent) 146 , m_region(0) 147 { 91 148 } 92 149 93 150 HitTestResult::HitTestResult(const HitTestResult& other) 94 : m_innerNode(other.innerNode()) 151 : HitTestPoint(other) 152 , m_innerNode(other.innerNode()) 95 153 , m_innerNonSharedNode(other.innerNonSharedNode()) 96 , m_point(other.point())97 154 , m_localPoint(other.localPoint()) 98 155 , m_innerURLElement(other.URLElement()) … … 102 159 , m_region(other.region()) 103 160 { 104 // Only copy the padding and NodeSet in case of rect hit test. 105 // Copying the later is rather expensive. 106 if ((m_isRectBased = other.isRectBasedTest())) { 107 m_topPadding = other.m_topPadding; 108 m_rightPadding = other.m_rightPadding; 109 m_bottomPadding = other.m_bottomPadding; 110 m_leftPadding = other.m_leftPadding; 111 } else 112 m_topPadding = m_rightPadding = m_bottomPadding = m_leftPadding = 0; 113 161 // Only copy the NodeSet in case of rect hit test. 114 162 m_rectBasedTestResult = adoptPtr(other.m_rectBasedTestResult ? new NodeSet(*other.m_rectBasedTestResult) : 0); 115 163 } … … 121 169 HitTestResult& HitTestResult::operator=(const HitTestResult& other) 122 170 { 171 HitTestPoint::operator=(other); 123 172 m_innerNode = other.innerNode(); 124 173 m_innerNonSharedNode = other.innerNonSharedNode(); 125 m_point = other.point();126 174 m_localPoint = other.localPoint(); 127 175 m_innerURLElement = other.URLElement(); 128 176 m_scrollbar = other.scrollbar(); 129 177 m_isOverWidget = other.isOverWidget(); 130 // Only copy the padding and NodeSet in case of rect hit test. 131 // Copying the later is rather expensive. 132 if ((m_isRectBased = other.isRectBasedTest())) { 133 m_topPadding = other.m_topPadding; 134 m_rightPadding = other.m_rightPadding; 135 m_bottomPadding = other.m_bottomPadding; 136 m_leftPadding = other.m_leftPadding; 137 } else 138 m_topPadding = m_rightPadding = m_bottomPadding = m_leftPadding = 0; 139 178 179 // Only copy the NodeSet in case of rect hit test. 140 180 m_rectBasedTestResult = adoptPtr(other.m_rectBasedTestResult ? new NodeSet(*other.m_rectBasedTestResult) : 0); 141 m_shadowContentFilterPolicy = other.shadowContentFilterPolicy();181 m_shadowContentFilterPolicy = other.shadowContentFilterPolicy(); 142 182 143 183 m_region = other.m_region; … … 199 239 return false; 200 240 201 return frame->selection()->contains( m_point);241 return frame->selection()->contains(point()); 202 242 } 203 243 … … 210 250 return String(); 211 251 212 DocumentMarker* marker = m_innerNonSharedNode->document()->markers()->markerContainingPoint( m_point, DocumentMarker::Grammar);252 DocumentMarker* marker = m_innerNonSharedNode->document()->markers()->markerContainingPoint(point(), DocumentMarker::Grammar); 213 253 if (!marker) 214 254 return String(); … … 226 266 return String(); 227 267 228 DocumentMarker* marker = m_innerNonSharedNode->document()->markers()->markerContainingPoint( m_point, DocumentMarker::Replacement);268 DocumentMarker* marker = m_innerNonSharedNode->document()->markers()->markerContainingPoint(point(), DocumentMarker::Replacement); 229 269 if (!marker) 230 270 return String(); … … 653 693 } 654 694 655 IntRect HitTestResult::rectForPoint(const LayoutPoint& point, unsigned topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding)656 {657 IntPoint actualPoint(roundedIntPoint(point));658 actualPoint -= IntSize(leftPadding, topPadding);659 660 IntSize actualPadding(leftPadding + rightPadding, topPadding + bottomPadding);661 // As IntRect is left inclusive and right exclusive (seeing IntRect::contains(x, y)), adding "1".662 actualPadding += IntSize(1, 1);663 664 return IntRect(actualPoint, actualPadding);665 }666 667 695 const HitTestResult::NodeSet& HitTestResult::rectBasedTestResult() const 668 696 { -
trunk/Source/WebCore/rendering/HitTestResult.h
r114926 r117091 1 1 /* 2 2 * Copyright (C) 2006 Apple Computer, Inc. 3 * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies) 3 4 * 4 5 * This library is free software; you can redistribute it and/or … … 23 24 24 25 #include "FloatRect.h" 26 #include "HitTestRequest.h" 25 27 #include "LayoutTypes.h" 26 28 #include "TextDirection.h" … … 45 47 enum ShadowContentFilterPolicy { DoNotAllowShadowContent, AllowShadowContent }; 46 48 47 class HitTestResult { 49 class HitTestPoint { 50 public: 51 52 HitTestPoint(); 53 HitTestPoint(const LayoutPoint&); 54 // Pass non-negative padding values to perform a rect-based hit test. 55 HitTestPoint(const LayoutPoint& centerPoint, unsigned topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding); 56 HitTestPoint(const HitTestPoint&); 57 ~HitTestPoint(); 58 HitTestPoint& operator=(const HitTestPoint&); 59 60 LayoutPoint point() const { return m_point; } 61 IntPoint roundedPoint() const { return roundedIntPoint(m_point); } 62 63 void setPoint(const LayoutPoint& p) { m_point = p; } 64 65 // Rect-based hit test related methods. 66 bool isRectBasedTest() const { return m_isRectBased; } 67 IntRect rectForPoint(const LayoutPoint&) const; 68 static IntRect rectForPoint(const LayoutPoint&, unsigned topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding); 69 int topPadding() const { return m_topPadding; } 70 int rightPadding() const { return m_rightPadding; } 71 int bottomPadding() const { return m_bottomPadding; } 72 int leftPadding() const { return m_leftPadding; } 73 74 private: 75 LayoutPoint m_point; 76 77 int m_topPadding; 78 int m_rightPadding; 79 int m_bottomPadding; 80 int m_leftPadding; 81 bool m_isRectBased; 82 }; 83 84 class HitTestResult : public HitTestPoint { 48 85 public: 49 86 typedef ListHashSet<RefPtr<Node> > NodeSet; … … 53 90 // Pass non-negative padding values to perform a rect-based hit test. 54 91 HitTestResult(const LayoutPoint& centerPoint, unsigned topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding, ShadowContentFilterPolicy); 92 HitTestResult(const HitTestPoint&, ShadowContentFilterPolicy); 55 93 HitTestResult(const HitTestResult&); 56 94 ~HitTestResult(); … … 59 97 Node* innerNode() const { return m_innerNode.get(); } 60 98 Node* innerNonSharedNode() const { return m_innerNonSharedNode.get(); } 61 LayoutPoint point() const { return m_point; }62 IntPoint roundedPoint() const { return roundedIntPoint(m_point); }63 99 LayoutPoint localPoint() const { return m_localPoint; } 64 100 Element* URLElement() const { return m_innerURLElement.get(); } … … 71 107 void setToNonShadowAncestor(); 72 108 109 const HitTestPoint& hitTestPoint() const { return *this; } 73 110 ShadowContentFilterPolicy shadowContentFilterPolicy() const { return m_shadowContentFilterPolicy; } 74 111 75 112 void setInnerNode(Node*); 76 113 void setInnerNonSharedNode(Node*); 77 void setPoint(const LayoutPoint& p) { m_point = p; }78 114 void setLocalPoint(const LayoutPoint& p) { m_localPoint = p; } 79 115 void setURLElement(Element*); … … 111 147 void toggleMediaMuteState() const; 112 148 113 // Rect-based hit test related methods.114 bool isRectBasedTest() const { return m_isRectBased; }115 IntRect rectForPoint(const LayoutPoint&) const;116 static IntRect rectForPoint(const LayoutPoint&, unsigned topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding);117 int topPadding() const { return m_topPadding; }118 int rightPadding() const { return m_rightPadding; }119 int bottomPadding() const { return m_bottomPadding; }120 int leftPadding() const { return m_leftPadding; }121 122 149 // Returns true if it is rect-based hit test and needs to continue until the rect is fully 123 150 // enclosed by the boundaries of a node. … … 140 167 RefPtr<Node> m_innerNode; 141 168 RefPtr<Node> m_innerNonSharedNode; 142 LayoutPoint m_point;143 169 LayoutPoint m_localPoint; // A point in the local coordinate space of m_innerNonSharedNode's renderer. Allows us to efficiently 144 170 // determine where inside the renderer we hit on subsequent operations. … … 146 172 RefPtr<Scrollbar> m_scrollbar; 147 173 bool m_isOverWidget; // Returns true if we are over a widget (and not in the border/padding area of a RenderWidget for example). 148 bool m_isRectBased; 149 int m_topPadding; 150 int m_rightPadding; 151 int m_bottomPadding; 152 int m_leftPadding; 174 153 175 ShadowContentFilterPolicy m_shadowContentFilterPolicy; 154 176 155 177 RenderRegion* m_region; // The region we're inside. 156 178 … … 163 185 // width = leftPadding + rightPadding + 1 164 186 // height = topPadding + bottomPadding + 1 165 inline IntRect HitTest Result::rectForPoint(const LayoutPoint& point) const187 inline IntRect HitTestPoint::rectForPoint(const LayoutPoint& point) const 166 188 { 167 189 return rectForPoint(point, m_topPadding, m_rightPadding, m_bottomPadding, m_leftPadding); -
trunk/Source/WebCore/rendering/RenderLayer.cpp
r117032 r117091 3574 3574 if (fgRect.intersects(hitTestArea) && isSelfPaintingLayer()) { 3575 3575 // Hit test with a temporary HitTestResult, because we only want to commit to 'result' if we know we're frontmost. 3576 HitTestResult tempResult(result. point(), result.topPadding(), result.rightPadding(), result.bottomPadding(), result.leftPadding(), result.shadowContentFilterPolicy());3576 HitTestResult tempResult(result.hitTestPoint(), result.shadowContentFilterPolicy()); 3577 3577 if (hitTestContents(request, tempResult, layerBounds, hitTestPoint, HitTestDescendants) && 3578 3578 isHitCandidate(this, false, zOffsetForContentsPtr, unflattenedTransformState.get())) { … … 3603 3603 3604 3604 if (bgRect.intersects(hitTestArea) && isSelfPaintingLayer()) { 3605 HitTestResult tempResult(result. point(), result.topPadding(), result.rightPadding(), result.bottomPadding(), result.leftPadding(), result.shadowContentFilterPolicy());3605 HitTestResult tempResult(result.hitTestPoint(), result.shadowContentFilterPolicy()); 3606 3606 if (hitTestContents(request, tempResult, layerBounds, hitTestPoint, HitTestSelf) && 3607 3607 isHitCandidate(this, false, zOffsetForContentsPtr, unflattenedTransformState.get())) { … … 3659 3659 RenderLayer* childLayer = list->at(i); 3660 3660 RenderLayer* hitLayer = 0; 3661 HitTestResult tempResult(result. point(), result.topPadding(), result.rightPadding(), result.bottomPadding(), result.leftPadding(), result.shadowContentFilterPolicy());3661 HitTestResult tempResult(result.hitTestPoint(), result.shadowContentFilterPolicy()); 3662 3662 if (childLayer->isPaginated()) 3663 3663 hitLayer = hitTestPaginatedChildLayer(childLayer, rootLayer, request, tempResult, hitTestRect, hitTestPoint, transformState, zOffsetForDescendants);
Note: See TracChangeset
for help on using the changeset viewer.