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

Side by Side Diff: Source/core/rendering/RenderBlock.cpp

Issue 249133002: hitTest should take care if the location is inside rounded border if border-radius is specified (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixed the review comments Created 6 years, 7 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 | « LayoutTests/fast/borders/border-radius-hittest-expected.txt ('k') | no next file » | 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) 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 * (C) 2007 David Smith (catfish.man@gmail.com) 4 * (C) 2007 David Smith (catfish.man@gmail.com)
5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 6 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 2864 matching lines...) Expand 10 before | Expand all | Expand 10 after
2875 && isPointInOverflowControl(result, locationInContainer.point(), adjuste dLocation)) { 2875 && isPointInOverflowControl(result, locationInContainer.point(), adjuste dLocation)) {
2876 updateHitTestResult(result, locationInContainer.point() - localOffset); 2876 updateHitTestResult(result, locationInContainer.point() - localOffset);
2877 // FIXME: isPointInOverflowControl() doesn't handle rect-based tests yet . 2877 // FIXME: isPointInOverflowControl() doesn't handle rect-based tests yet .
2878 if (!result.addNodeToRectBasedTestResult(nodeForHitTest(), request, loca tionInContainer)) 2878 if (!result.addNodeToRectBasedTestResult(nodeForHitTest(), request, loca tionInContainer))
2879 return true; 2879 return true;
2880 } 2880 }
2881 2881
2882 // If we have clipping, then we can't have any spillout. 2882 // If we have clipping, then we can't have any spillout.
2883 bool useOverflowClip = hasOverflowClip() && !hasSelfPaintingLayer(); 2883 bool useOverflowClip = hasOverflowClip() && !hasSelfPaintingLayer();
2884 bool useClip = (hasControlClip() || useOverflowClip); 2884 bool useClip = (hasControlClip() || useOverflowClip);
2885 bool checkChildren = !useClip || (hasControlClip() ? locationInContainer.int ersects(controlClipRect(adjustedLocation)) : locationInContainer.intersects(over flowClipRect(adjustedLocation, IncludeOverlayScrollbarSize))); 2885 LayoutRect clipRect = overflowClipRect(adjustedLocation, IncludeOverlayScrol lbarSize);
ojan 2014/05/07 03:18:28 It looks like this is only used in the else clause
pals 2014/05/07 06:31:53 Done.
2886 bool checkChildren = !useClip;
2887 if (!checkChildren) {
2888 if (hasControlClip()) {
2889 checkChildren = locationInContainer.intersects(controlClipRect(adjus tedLocation));
2890 } else {
2891 checkChildren = style()->hasBorderRadius() ? locationInContainer.int ersects(style()->getRoundedBorderFor(clipRect)) : locationInContainer.intersects (clipRect);
ojan 2014/05/07 03:18:28 I think the ternary makes this hard to read with s
pals 2014/05/07 06:31:53 Done.
2892 }
2893 }
2886 if (checkChildren) { 2894 if (checkChildren) {
2887 // Hit test descendants first. 2895 // Hit test descendants first.
2888 LayoutSize scrolledOffset(localOffset); 2896 LayoutSize scrolledOffset(localOffset);
2889 if (hasOverflowClip()) 2897 if (hasOverflowClip())
2890 scrolledOffset -= scrolledContentOffset(); 2898 scrolledOffset -= scrolledContentOffset();
2891 2899
2892 // Hit test contents if we don't have columns. 2900 // Hit test contents if we don't have columns.
2893 if (!hasColumns()) { 2901 if (!hasColumns()) {
2894 if (hitTestContents(request, result, locationInContainer, toLayoutPo int(scrolledOffset), hitTestAction)) { 2902 if (hitTestContents(request, result, locationInContainer, toLayoutPo int(scrolledOffset), hitTestAction)) {
2895 updateHitTestResult(result, flipForWritingMode(locationInContain er.point() - localOffset)); 2903 updateHitTestResult(result, flipForWritingMode(locationInContain er.point() - localOffset));
2896 return true; 2904 return true;
2897 } 2905 }
2898 if (hitTestAction == HitTestFloat && hitTestFloats(request, result, locationInContainer, toLayoutPoint(scrolledOffset))) 2906 if (hitTestAction == HitTestFloat && hitTestFloats(request, result, locationInContainer, toLayoutPoint(scrolledOffset)))
2899 return true; 2907 return true;
2900 } else if (hitTestColumns(request, result, locationInContainer, toLayout Point(scrolledOffset), hitTestAction)) { 2908 } else if (hitTestColumns(request, result, locationInContainer, toLayout Point(scrolledOffset), hitTestAction)) {
2901 updateHitTestResult(result, flipForWritingMode(locationInContainer.p oint() - localOffset)); 2909 updateHitTestResult(result, flipForWritingMode(locationInContainer.p oint() - localOffset));
2902 return true; 2910 return true;
2903 } 2911 }
2904 } 2912 }
2905 2913
2906 // Check if the point is outside radii. 2914 // Check if the point is outside radii.
2907 if (!isRenderView() && style()->hasBorderRadius()) { 2915 if (style()->hasBorderRadius()) {
2908 LayoutRect borderRect = borderBoxRect(); 2916 LayoutRect borderRect = borderBoxRect();
2909 borderRect.moveBy(adjustedLocation); 2917 borderRect.moveBy(adjustedLocation);
2910 RoundedRect border = style()->getRoundedBorderFor(borderRect); 2918 RoundedRect border = style()->getRoundedBorderFor(borderRect);
2911 if (!locationInContainer.intersects(border)) 2919 if (!locationInContainer.intersects(border))
2912 return false; 2920 return false;
2913 } 2921 }
2914 2922
2915 // Now hit test our background 2923 // Now hit test our background
2916 if (hitTestAction == HitTestBlockBackground || hitTestAction == HitTestChild BlockBackground) { 2924 if (hitTestAction == HitTestBlockBackground || hitTestAction == HitTestChild BlockBackground) {
2917 LayoutRect boundsRect(adjustedLocation, size()); 2925 LayoutRect boundsRect(adjustedLocation, size());
(...skipping 2103 matching lines...) Expand 10 before | Expand all | Expand 10 after
5021 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render Object* obj) const 5029 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render Object* obj) const
5022 { 5030 {
5023 showRenderObject(); 5031 showRenderObject();
5024 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box()) 5032 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box())
5025 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1); 5033 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1);
5026 } 5034 }
5027 5035
5028 #endif 5036 #endif
5029 5037
5030 } // namespace WebCore 5038 } // namespace WebCore
OLDNEW
« no previous file with comments | « LayoutTests/fast/borders/border-radius-hittest-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698