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

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

Issue 1630793002: Stop hit testing culled inlines when a match is found (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Simpler approach, but duplicated code Created 4 years, 10 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) 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 24 matching lines...) Expand all
35 #include "core/html/HTMLImageElement.h" 35 #include "core/html/HTMLImageElement.h"
36 #include "core/html/HTMLInputElement.h" 36 #include "core/html/HTMLInputElement.h"
37 #include "core/html/HTMLMapElement.h" 37 #include "core/html/HTMLMapElement.h"
38 #include "core/html/HTMLMediaElement.h" 38 #include "core/html/HTMLMediaElement.h"
39 #include "core/html/HTMLTextAreaElement.h" 39 #include "core/html/HTMLTextAreaElement.h"
40 #include "core/html/parser/HTMLParserIdioms.h" 40 #include "core/html/parser/HTMLParserIdioms.h"
41 #include "core/layout/LayoutImage.h" 41 #include "core/layout/LayoutImage.h"
42 #include "core/layout/LayoutTextFragment.h" 42 #include "core/layout/LayoutTextFragment.h"
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/geometry/Region.h"
45 #include "platform/scroll/Scrollbar.h" 46 #include "platform/scroll/Scrollbar.h"
46 47
47 namespace blink { 48 namespace blink {
48 49
49 using namespace HTMLNames; 50 using namespace HTMLNames;
50 51
51 HitTestResult::HitTestResult() 52 HitTestResult::HitTestResult()
52 : m_hitTestRequest(HitTestRequest::ReadOnly | HitTestRequest::Active) 53 : m_hitTestRequest(HitTestRequest::ReadOnly | HitTestRequest::Active)
53 , m_cacheable(true) 54 , m_cacheable(true)
54 , m_isOverWidget(false) 55 , m_isOverWidget(false)
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 return !toHTMLTextAreaElement(*m_innerNode).isDisabledOrReadOnly(); 424 return !toHTMLTextAreaElement(*m_innerNode).isDisabledOrReadOnly();
424 425
425 if (isHTMLInputElement(*m_innerNode)) { 426 if (isHTMLInputElement(*m_innerNode)) {
426 HTMLInputElement& inputElement = toHTMLInputElement(*m_innerNode); 427 HTMLInputElement& inputElement = toHTMLInputElement(*m_innerNode);
427 return !inputElement.isDisabledOrReadOnly() && inputElement.isTextField( ); 428 return !inputElement.isDisabledOrReadOnly() && inputElement.isTextField( );
428 } 429 }
429 430
430 return m_innerNode->hasEditableStyle(); 431 return m_innerNode->hasEditableStyle();
431 } 432 }
432 433
433 bool HitTestResult::addNodeToListBasedTestResult(Node* node, const HitTestLocati on& locationInContainer, const LayoutRect& rect) 434 ListBasedHitTestBehavior HitTestResult::addNodeToListBasedTestResult(Node* node, const HitTestLocation& location, const LayoutRect& rect)
434 { 435 {
435 // If not a list-based test, this function should be a no-op. 436 // If not a list-based test, stop testing because the hit has been found.
436 if (!hitTestRequest().listBased()) 437 if (!hitTestRequest().listBased())
437 return false; 438 return StopHitTesting;
438 439
439 // If node is null, return true so the hit test can continue.
440 if (!node) 440 if (!node)
441 return true; 441 return ContinueHitTesting;
442 442
443 mutableListBasedTestResult().add(node); 443 mutableListBasedTestResult().add(node);
444 444
445 if (hitTestRequest().penetratingList()) 445 if (hitTestRequest().penetratingList())
446 return true; 446 return ContinueHitTesting;
447 447
448 bool regionFilled = rect.contains(LayoutRect(locationInContainer.boundingBox ())); 448 return rect.contains(LayoutRect(location.boundingBox())) ? StopHitTesting : ContinueHitTesting;
449 return !regionFilled; 449 }
450
451 ListBasedHitTestBehavior HitTestResult::addNodeToListBasedTestResult(Node* node, const HitTestLocation& location, const Region& region)
452 {
453 // If not a list-based test, stop testing because the hit has been found.
454 if (!hitTestRequest().listBased())
455 return StopHitTesting;
456
457 if (!node)
458 return ContinueHitTesting;
459
460 mutableListBasedTestResult().add(node);
461
462 if (hitTestRequest().penetratingList())
463 return ContinueHitTesting;
464
465 return region.contains(location.boundingBox()) ? StopHitTesting : ContinueHi tTesting;
450 } 466 }
451 467
452 void HitTestResult::append(const HitTestResult& other) 468 void HitTestResult::append(const HitTestResult& other)
453 { 469 {
454 ASSERT(hitTestRequest().listBased()); 470 ASSERT(hitTestRequest().listBased());
455 471
456 if (!m_scrollbar && other.scrollbar()) { 472 if (!m_scrollbar && other.scrollbar()) {
457 setScrollbar(other.scrollbar()); 473 setScrollbar(other.scrollbar());
458 } 474 }
459 475
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 else if (isHTMLMapElement(m_innerNode)) 541 else if (isHTMLMapElement(m_innerNode))
526 imageMapImageElement = toHTMLMapElement(m_innerNode)->imageElement(); 542 imageMapImageElement = toHTMLMapElement(m_innerNode)->imageElement();
527 543
528 if (!imageMapImageElement) 544 if (!imageMapImageElement)
529 return m_innerNode.get(); 545 return m_innerNode.get();
530 546
531 return imageMapImageElement; 547 return imageMapImageElement;
532 } 548 }
533 549
534 } // namespace blink 550 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/HitTestResult.h ('k') | third_party/WebKit/Source/core/layout/LayoutBlock.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698