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

Side by Side Diff: Source/core/layout/LayoutInline.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
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 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. 4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 767 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 778
779 const char* LayoutInline::name() const 779 const char* LayoutInline::name() const
780 { 780 {
781 if (isRelPositioned()) 781 if (isRelPositioned())
782 return "LayoutInline (relative positioned)"; 782 return "LayoutInline (relative positioned)";
783 if (isAnonymous()) 783 if (isAnonymous())
784 return "LayoutInline (anonymous)"; 784 return "LayoutInline (anonymous)";
785 return "LayoutInline"; 785 return "LayoutInline";
786 } 786 }
787 787
788 bool LayoutInline::nodeAtPoint(const HitTestRequest& request, HitTestResult& res ult, 788 bool LayoutInline::nodeAtPoint(HitTestResult& result,
789 const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOf fset, HitTestAction hitTestAction) 789 const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOf fset, HitTestAction hitTestAction)
790 { 790 {
791 return m_lineBoxes.hitTest(this, request, result, locationInContainer, accum ulatedOffset, hitTestAction); 791 return m_lineBoxes.hitTest(this, result, locationInContainer, accumulatedOff set, hitTestAction);
792 } 792 }
793 793
794 namespace { 794 namespace {
795 795
796 class HitTestCulledInlinesGeneratorContext { 796 class HitTestCulledInlinesGeneratorContext {
797 public: 797 public:
798 HitTestCulledInlinesGeneratorContext(Region& region, const HitTestLocation& location) : m_intersected(false), m_region(region), m_location(location) { } 798 HitTestCulledInlinesGeneratorContext(Region& region, const HitTestLocation& location) : m_intersected(false), m_region(region), m_location(location) { }
799 void operator()(const FloatRect& rect) 799 void operator()(const FloatRect& rect)
800 { 800 {
801 m_intersected = m_intersected || m_location.intersects(rect); 801 m_intersected = m_intersected || m_location.intersects(rect);
802 m_region.unite(enclosingIntRect(rect)); 802 m_region.unite(enclosingIntRect(rect));
803 } 803 }
804 bool intersected() const { return m_intersected; } 804 bool intersected() const { return m_intersected; }
805 private: 805 private:
806 bool m_intersected; 806 bool m_intersected;
807 Region& m_region; 807 Region& m_region;
808 const HitTestLocation& m_location; 808 const HitTestLocation& m_location;
809 }; 809 };
810 810
811 } // unnamed namespace 811 } // unnamed namespace
812 812
813 bool LayoutInline::hitTestCulledInline(const HitTestRequest& request, HitTestRes ult& result, const HitTestLocation& locationInContainer, const LayoutPoint& accu mulatedOffset) 813 bool LayoutInline::hitTestCulledInline(HitTestResult& result, const HitTestLocat ion& locationInContainer, const LayoutPoint& accumulatedOffset)
814 { 814 {
815 ASSERT(result.isRectBasedTest() && !alwaysCreateLineBoxes()); 815 ASSERT(result.isRectBasedTest() && !alwaysCreateLineBoxes());
816 if (!visibleToHitTestRequest(request)) 816 if (!visibleToHitTestRequest(result.hitTestRequest()))
817 return false; 817 return false;
818 818
819 HitTestLocation tmpLocation(locationInContainer, -toLayoutSize(accumulatedOf fset)); 819 HitTestLocation tmpLocation(locationInContainer, -toLayoutSize(accumulatedOf fset));
820 820
821 Region regionResult; 821 Region regionResult;
822 HitTestCulledInlinesGeneratorContext context(regionResult, tmpLocation); 822 HitTestCulledInlinesGeneratorContext context(regionResult, tmpLocation);
823 generateCulledLineBoxRects(context, this); 823 generateCulledLineBoxRects(context, this);
824 824
825 if (context.intersected()) { 825 if (context.intersected()) {
826 updateHitTestResult(result, tmpLocation.point()); 826 updateHitTestResult(result, tmpLocation.point());
827 // We can not use addNodeToListBasedTestResult to determine if we fully enclose the hit-test area 827 // We can not use addNodeToListBasedTestResult to determine if we fully enclose the hit-test area
828 // because it can only handle rectangular targets. 828 // because it can only handle rectangular targets.
829 result.addNodeToListBasedTestResult(node(), request, locationInContainer ); 829 result.addNodeToListBasedTestResult(node(), locationInContainer);
830 return regionResult.contains(tmpLocation.boundingBox()); 830 return regionResult.contains(tmpLocation.boundingBox());
831 } 831 }
832 return false; 832 return false;
833 } 833 }
834 834
835 PositionWithAffinity LayoutInline::positionForPoint(const LayoutPoint& point) 835 PositionWithAffinity LayoutInline::positionForPoint(const LayoutPoint& point)
836 { 836 {
837 // FIXME: Does not deal with relative positioned inlines (should it?) 837 // FIXME: Does not deal with relative positioned inlines (should it?)
838 LayoutBlock* cb = containingBlock(); 838 LayoutBlock* cb = containingBlock();
839 if (firstLineBoxIncludingCulling()) { 839 if (firstLineBoxIncludingCulling()) {
(...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after
1455 } 1455 }
1456 1456
1457 void LayoutInline::invalidateDisplayItemClients(const LayoutBoxModelObject& pain tInvalidationContainer) const 1457 void LayoutInline::invalidateDisplayItemClients(const LayoutBoxModelObject& pain tInvalidationContainer) const
1458 { 1458 {
1459 LayoutBoxModelObject::invalidateDisplayItemClients(paintInvalidationContaine r); 1459 LayoutBoxModelObject::invalidateDisplayItemClients(paintInvalidationContaine r);
1460 for (InlineFlowBox* box = firstLineBox(); box; box = box->nextLineBox()) 1460 for (InlineFlowBox* box = firstLineBox(); box; box = box->nextLineBox())
1461 paintInvalidationContainer.invalidateDisplayItemClientOnBacking(*box); 1461 paintInvalidationContainer.invalidateDisplayItemClientOnBacking(*box);
1462 } 1462 }
1463 1463
1464 } // namespace blink 1464 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/layout/LayoutInline.h ('k') | Source/core/layout/LayoutMultiColumnSpannerPlaceholder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698