Back out 7bfec63e417b (bug 950225) for test failures

CLOSED TREE
This commit is contained in:
Phil Ringnalda 2014-01-27 23:12:54 -08:00
Родитель 5fee92e5f2
Коммит 81b53bd666
2 изменённых файлов: 10 добавлений и 45 удалений

Просмотреть файл

@ -227,22 +227,9 @@ AppUnitsFromMM(nsIFrame* aFrame, uint32_t aMM, bool aVertical)
return NSToCoordRound(result);
}
/**
* Clip aRect with the bounds of aFrame in the coordinate system of
* aRootFrame. aRootFrame is an ancestor of aFrame.
*/
static nsRect
ClipToFrame(nsIFrame* aRootFrame, nsIFrame* aFrame, nsRect& aRect)
{
nsRegion bound = nsLayoutUtils::TransformFrameRectToAncestor(
aFrame, nsRect(nsPoint(0, 0), aFrame->GetSize()), aRootFrame);
nsRegion result = bound.Intersect(aRect);
return result.GetBounds();
}
static nsRect
GetTargetRect(nsIFrame* aRootFrame, const nsPoint& aPointRelativeToRootFrame,
nsIFrame* aRestrictToDescendants, const EventRadiusPrefs* aPrefs)
const EventRadiusPrefs* aPrefs)
{
nsMargin m(AppUnitsFromMM(aRootFrame, aPrefs->mSideRadii[0], true),
AppUnitsFromMM(aRootFrame, aPrefs->mSideRadii[1], false),
@ -250,7 +237,7 @@ GetTargetRect(nsIFrame* aRootFrame, const nsPoint& aPointRelativeToRootFrame,
AppUnitsFromMM(aRootFrame, aPrefs->mSideRadii[3], false));
nsRect r(aPointRelativeToRootFrame, nsSize(0,0));
r.Inflate(m);
return ClipToFrame(aRootFrame, aRestrictToDescendants, r);
return r;
}
static float
@ -375,6 +362,13 @@ FindFrameTargetedByInputEvent(const WidgetGUIEvent* aEvent,
return target;
}
nsRect targetRect = GetTargetRect(aRootFrame, aPointRelativeToRootFrame, prefs);
nsAutoTArray<nsIFrame*,8> candidates;
nsresult rv = nsLayoutUtils::GetFramesForArea(aRootFrame, targetRect, candidates, flags);
if (NS_FAILED(rv)) {
return target;
}
// If the exact target is non-null, only consider candidate targets in the same
// document as the exact target. Otherwise, if an ancestor document has
// a mouse event handler for example, targets that are !IsElementClickable can
@ -382,15 +376,6 @@ FindFrameTargetedByInputEvent(const WidgetGUIEvent* aEvent,
// would be targeted instead.
nsIFrame* restrictToDescendants = target ?
target->PresContext()->PresShell()->GetRootFrame() : aRootFrame;
nsRect targetRect = GetTargetRect(aRootFrame, aPointRelativeToRootFrame,
restrictToDescendants, prefs);
nsAutoTArray<nsIFrame*,8> candidates;
nsresult rv = nsLayoutUtils::GetFramesForArea(aRootFrame, targetRect, candidates, flags);
if (NS_FAILED(rv)) {
return target;
}
nsIFrame* closestClickable =
GetClosest(aRootFrame, aPointRelativeToRootFrame, targetRect, prefs,
restrictToDescendants, candidates);

Просмотреть файл

@ -12,7 +12,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=780847
.target { position:absolute; left:100px; top:100px; width:100px; height:100px; background:blue; }
</style>
</head>
<body id="body" onload="setTimeout(startTest, 0)" style="margin:0; width:100%; height:100%; overflow:hidden">
<body id="body" onload="setTimeout(startTest, 0)" style="margin:0; width:100%; height:100%">
<p id="display"></p>
<div id="content">
<div id="ruler" style="position:absolute; left:0; top:0; width:1mozmm; height:0;"></div>
@ -47,11 +47,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=780847
<div id="t9" class="target" ontouchend="x=1" hidden></div>
<div id="t10_left" class="target" style="left:-50px;" onmousedown="x=1" hidden></div>
<div id="t10_right" class="target" style="left:auto;right:-50px" onmousedown="x=1" hidden></div>
<div id="t10_top" class="target" style="top:-50px;" onmousedown="x=1" hidden></div>
<div id="t10_bottom" class="target" style="top:auto;bottom:-50px;" onmousedown="x=1" hidden></div>
<div id="t10_over" style="position:absolute; left:0; top:0; width:100%; height:100%; background:yellow;" hidden></div>
</div>
<pre id="test">
<script type="application/javascript">
@ -219,21 +214,6 @@ function test3() {
});
setShowing("t9", false);
setShowing("t10_over", true);
setShowing("t10_left", true);
setShowing("t10_right", true);
setShowing("t10_top", true);
setShowing("t10_bottom", true);
testMouseClick("t10_left", 51, 10, "t10_over", "element outside of visible area is not selected");
testMouseClick("t10_right", 49, 10, "t10_over", "element outside of visible area is not selected");
testMouseClick("t10_top", 10, 51, "t10_over", "element outside of visible area is not selected");
testMouseClick("t10_bottom", 10, 49, "t10_over", "element outside of visible area is not selected");
setShowing("t10_over", false);
setShowing("t10_left", false);
setShowing("t10_right", false);
setShowing("t10_top", false);
setShowing("t10_bottom", false);
// Not yet tested:
// -- visited link weight
// -- "Closest" using Euclidean distance