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

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

Issue 1032823003: Refactor HitTestResult to store the HitTestRequest (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Updated as per review comments Created 5 years, 8 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/LayoutBlock.h » ('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 29 matching lines...) Expand all
40 #include "core/layout/LayoutTextFragment.h" 40 #include "core/layout/LayoutTextFragment.h"
41 #include "core/page/FrameTree.h" 41 #include "core/page/FrameTree.h"
42 #include "core/svg/SVGElement.h" 42 #include "core/svg/SVGElement.h"
43 #include "platform/scroll/Scrollbar.h" 43 #include "platform/scroll/Scrollbar.h"
44 44
45 namespace blink { 45 namespace blink {
46 46
47 using namespace HTMLNames; 47 using namespace HTMLNames;
48 48
49 HitTestResult::HitTestResult() 49 HitTestResult::HitTestResult()
50 : m_isOverWidget(false) 50 : m_hitTestRequest(HitTestRequest::ReadOnly | HitTestRequest::Active)
51 , m_isOverWidget(false)
51 { 52 {
52 } 53 }
53 54
54 HitTestResult::HitTestResult(const LayoutPoint& point) 55 HitTestResult::HitTestResult(const HitTestRequest& request, const LayoutPoint& p oint)
55 : m_hitTestLocation(point) 56 : m_hitTestLocation(point)
57 , m_hitTestRequest(request)
56 , m_pointInInnerNodeFrame(point) 58 , m_pointInInnerNodeFrame(point)
57 , m_isOverWidget(false) 59 , m_isOverWidget(false)
58 { 60 {
59 } 61 }
60 62
61 HitTestResult::HitTestResult(const LayoutPoint& centerPoint, unsigned topPadding , unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding) 63 HitTestResult::HitTestResult(const HitTestRequest& request, const LayoutPoint& c enterPoint, unsigned topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding)
62 : m_hitTestLocation(centerPoint, topPadding, rightPadding, bottomPadding, le ftPadding) 64 : m_hitTestLocation(centerPoint, topPadding, rightPadding, bottomPadding, le ftPadding)
65 , m_hitTestRequest(request)
63 , m_pointInInnerNodeFrame(centerPoint) 66 , m_pointInInnerNodeFrame(centerPoint)
64 , m_isOverWidget(false) 67 , m_isOverWidget(false)
65 { 68 {
66 } 69 }
67 70
68 HitTestResult::HitTestResult(const HitTestLocation& other) 71 HitTestResult::HitTestResult(const HitTestRequest& otherRequest, const HitTestLo cation& other)
69 : m_hitTestLocation(other) 72 : m_hitTestLocation(other)
73 , m_hitTestRequest(otherRequest)
70 , m_pointInInnerNodeFrame(m_hitTestLocation.point()) 74 , m_pointInInnerNodeFrame(m_hitTestLocation.point())
71 , m_isOverWidget(false) 75 , m_isOverWidget(false)
72 { 76 {
73 } 77 }
74 78
75 HitTestResult::HitTestResult(const HitTestResult& other) 79 HitTestResult::HitTestResult(const HitTestResult& other)
76 : m_hitTestLocation(other.m_hitTestLocation) 80 : m_hitTestLocation(other.m_hitTestLocation)
81 , m_hitTestRequest(other.m_hitTestRequest)
77 , m_innerNode(other.innerNode()) 82 , m_innerNode(other.innerNode())
78 , m_innerPossiblyPseudoNode(other.m_innerPossiblyPseudoNode) 83 , m_innerPossiblyPseudoNode(other.m_innerPossiblyPseudoNode)
79 , m_innerNonSharedNode(other.innerNonSharedNode()) 84 , m_innerNonSharedNode(other.innerNonSharedNode())
80 , m_pointInInnerNodeFrame(other.m_pointInInnerNodeFrame) 85 , m_pointInInnerNodeFrame(other.m_pointInInnerNodeFrame)
81 , m_localPoint(other.localPoint()) 86 , m_localPoint(other.localPoint())
82 , m_innerURLElement(other.URLElement()) 87 , m_innerURLElement(other.URLElement())
83 , m_scrollbar(other.scrollbar()) 88 , m_scrollbar(other.scrollbar())
84 , m_isOverWidget(other.isOverWidget()) 89 , m_isOverWidget(other.isOverWidget())
85 { 90 {
86 // Only copy the NodeSet in case of list hit test. 91 // Only copy the NodeSet in case of list hit test.
87 m_listBasedTestResult = adoptPtrWillBeNoop(other.m_listBasedTestResult ? new NodeSet(*other.m_listBasedTestResult) : 0); 92 m_listBasedTestResult = adoptPtrWillBeNoop(other.m_listBasedTestResult ? new NodeSet(*other.m_listBasedTestResult) : 0);
88 } 93 }
89 94
90 HitTestResult::~HitTestResult() 95 HitTestResult::~HitTestResult()
91 { 96 {
92 } 97 }
93 98
94 HitTestResult& HitTestResult::operator=(const HitTestResult& other) 99 HitTestResult& HitTestResult::operator=(const HitTestResult& other)
95 { 100 {
96 m_hitTestLocation = other.m_hitTestLocation; 101 m_hitTestLocation = other.m_hitTestLocation;
102 m_hitTestRequest = other.m_hitTestRequest;
97 m_innerNode = other.innerNode(); 103 m_innerNode = other.innerNode();
98 m_innerPossiblyPseudoNode = other.innerPossiblyPseudoNode(); 104 m_innerPossiblyPseudoNode = other.innerPossiblyPseudoNode();
99 m_innerNonSharedNode = other.innerNonSharedNode(); 105 m_innerNonSharedNode = other.innerNonSharedNode();
100 m_pointInInnerNodeFrame = other.m_pointInInnerNodeFrame; 106 m_pointInInnerNodeFrame = other.m_pointInInnerNodeFrame;
101 m_localPoint = other.localPoint(); 107 m_localPoint = other.localPoint();
102 m_innerURLElement = other.URLElement(); 108 m_innerURLElement = other.URLElement();
103 m_scrollbar = other.scrollbar(); 109 m_scrollbar = other.scrollbar();
104 m_isOverWidget = other.isOverWidget(); 110 m_isOverWidget = other.isOverWidget();
105 111
106 // Only copy the NodeSet in case of list hit test. 112 // Only copy the NodeSet in case of list hit test.
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 return !toHTMLTextAreaElement(*m_innerNonSharedNode).isDisabledOrReadOnl y(); 371 return !toHTMLTextAreaElement(*m_innerNonSharedNode).isDisabledOrReadOnl y();
366 372
367 if (isHTMLInputElement(*m_innerNonSharedNode)) { 373 if (isHTMLInputElement(*m_innerNonSharedNode)) {
368 HTMLInputElement& inputElement = toHTMLInputElement(*m_innerNonSharedNod e); 374 HTMLInputElement& inputElement = toHTMLInputElement(*m_innerNonSharedNod e);
369 return !inputElement.isDisabledOrReadOnly() && inputElement.isTextField( ); 375 return !inputElement.isDisabledOrReadOnly() && inputElement.isTextField( );
370 } 376 }
371 377
372 return m_innerNonSharedNode->hasEditableStyle(); 378 return m_innerNonSharedNode->hasEditableStyle();
373 } 379 }
374 380
375 bool HitTestResult::addNodeToListBasedTestResult(Node* node, const HitTestReques t& request, const HitTestLocation& locationInContainer, const LayoutRect& rect) 381 bool HitTestResult::addNodeToListBasedTestResult(Node* node, const HitTestLocati on& locationInContainer, const LayoutRect& rect)
376 { 382 {
377 // If not a list-based test, this function should be a no-op. 383 // If not a list-based test, this function should be a no-op.
378 if (!request.listBased()) { 384 if (!hitTestRequest().listBased())
379 ASSERT(!isRectBasedTest());
380 return false; 385 return false;
381 }
382 386
383 // If node is null, return true so the hit test can continue. 387 // If node is null, return true so the hit test can continue.
384 if (!node) 388 if (!node)
385 return true; 389 return true;
386 390
387 mutableListBasedTestResult().add(node); 391 mutableListBasedTestResult().add(node);
388 392
389 if (request.penetratingList()) 393 if (hitTestRequest().penetratingList())
390 return true; 394 return true;
391 395
392 bool regionFilled = rect.contains(LayoutRect(locationInContainer.boundingBox ())); 396 bool regionFilled = rect.contains(LayoutRect(locationInContainer.boundingBox ()));
393 return !regionFilled; 397 return !regionFilled;
394 } 398 }
395 399
396 bool HitTestResult::addNodeToListBasedTestResult(Node* node, const HitTestReques t& request, const HitTestLocation& locationInContainer, const FloatRect& rect) 400 bool HitTestResult::addNodeToListBasedTestResult(Node* node, const HitTestLocati on& locationInContainer, const FloatRect& rect)
397 { 401 {
398 // If not a list-based test, this function should be a no-op. 402 // If not a list-based test, this function should be a no-op.
399 if (!request.listBased()) { 403 if (!hitTestRequest().listBased())
400 ASSERT(!isRectBasedTest());
401 return false; 404 return false;
402 }
403 405
404 // If node is null, return true so the hit test can continue. 406 // If node is null, return true so the hit test can continue.
405 if (!node) 407 if (!node)
406 return true; 408 return true;
407 409
408 mutableListBasedTestResult().add(node); 410 mutableListBasedTestResult().add(node);
409 411
410 if (request.penetratingList()) 412 if (hitTestRequest().penetratingList())
411 return true; 413 return true;
412 414
413 bool regionFilled = rect.contains(locationInContainer.boundingBox()); 415 bool regionFilled = rect.contains(locationInContainer.boundingBox());
414 return !regionFilled; 416 return !regionFilled;
415 } 417 }
416 418
417 void HitTestResult::append(const HitTestResult& other, const HitTestRequest& req uest) 419 void HitTestResult::append(const HitTestResult& other)
418 { 420 {
419 ASSERT(request.listBased()); 421 ASSERT(hitTestRequest().listBased());
420 422
421 if (!m_scrollbar && other.scrollbar()) { 423 if (!m_scrollbar && other.scrollbar()) {
422 setScrollbar(other.scrollbar()); 424 setScrollbar(other.scrollbar());
423 } 425 }
424 426
425 if (!m_innerNode && other.innerNode()) { 427 if (!m_innerNode && other.innerNode()) {
426 m_innerNode = other.innerNode(); 428 m_innerNode = other.innerNode();
427 m_innerPossiblyPseudoNode = other.innerPossiblyPseudoNode(); 429 m_innerPossiblyPseudoNode = other.innerPossiblyPseudoNode();
428 m_innerNonSharedNode = other.innerNonSharedNode(); 430 m_innerNonSharedNode = other.innerNonSharedNode();
429 m_localPoint = other.localPoint(); 431 m_localPoint = other.localPoint();
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 { 477 {
476 for (Node* node = m_innerNode.get(); node; node = NodeRenderingTraversal::pa rent(*node)) { 478 for (Node* node = m_innerNode.get(); node; node = NodeRenderingTraversal::pa rent(*node)) {
477 if (node->isElementNode()) 479 if (node->isElementNode())
478 return toElement(node); 480 return toElement(node);
479 } 481 }
480 482
481 return 0; 483 return 0;
482 } 484 }
483 485
484 } // namespace blink 486 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/layout/HitTestResult.h ('k') | Source/core/layout/LayoutBlock.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698