Bug 1067728 - Part 1.1 - Move IsRectVisibleInScrollFrames to nsLayoutUtils. f=mtseng, r=roc

This commit is contained in:
Ting-Yu Lin 2014-12-08 01:53:00 +01:00
parent 6a76eb960c
commit ce2cdc6f5d
4 changed files with 36 additions and 36 deletions

View File

@ -458,7 +458,7 @@ TouchCaret::IsDisplayable()
return false; return false;
} }
if (!IsRectVisibleInScrollFrames(focusFrame, focusRect)) { if (!nsLayoutUtils::IsRectVisibleInScrollFrames(focusFrame, focusRect)) {
TOUCHCARET_LOG("Caret does not show in the scrollable frame!"); TOUCHCARET_LOG("Caret does not show in the scrollable frame!");
return false; return false;
} }
@ -494,34 +494,6 @@ TouchCaret::GetTouchCaretPosition()
return pos; return pos;
} }
bool
TouchCaret::IsRectVisibleInScrollFrames(nsIFrame* aFrame, const nsRect& aRect)
{
nsIFrame* closestScrollFrame =
nsLayoutUtils::GetClosestFrameOfType(aFrame, nsGkAtoms::scrollFrame);
while (closestScrollFrame) {
nsIScrollableFrame* sf = do_QueryFrame(closestScrollFrame);
nsRect scrollPortRect = sf->GetScrollPortRect();
nsRect rectRelativeToScrollFrame = aRect;
nsLayoutUtils::TransformRect(aFrame, closestScrollFrame,
rectRelativeToScrollFrame);
// Check whether aRect is visible in the scroll frame or not.
if (!scrollPortRect.Intersects(rectRelativeToScrollFrame)) {
return false;
}
// Get next ancestor scroll frame.
closestScrollFrame =
nsLayoutUtils::GetClosestFrameOfType(closestScrollFrame->GetParent(),
nsGkAtoms::scrollFrame);
}
return true;
}
nsPoint nsPoint
TouchCaret::ClampPositionToScrollFrame(const nsPoint& aPosition) TouchCaret::ClampPositionToScrollFrame(const nsPoint& aPosition)
{ {

View File

@ -117,13 +117,6 @@ private:
*/ */
nsPoint GetTouchCaretPosition(); nsPoint GetTouchCaretPosition();
/**
* Check whether aRect is visible in the boundary of the scroll frames
* boundary.
*/
static bool IsRectVisibleInScrollFrames(nsIFrame* aFrame,
const nsRect& aRect);
/** /**
* Clamp the position of the touch caret to the scroll frame boundary. * Clamp the position of the touch caret to the scroll frame boundary.
* The returned point is relative to the canvas frame. * The returned point is relative to the canvas frame.

View File

@ -2452,6 +2452,34 @@ nsLayoutUtils::ContainsPoint(const nsRect& aRect, const nsPoint& aPoint,
return rect.Contains(aPoint); return rect.Contains(aPoint);
} }
bool
nsLayoutUtils::IsRectVisibleInScrollFrames(nsIFrame* aFrame, const nsRect& aRect)
{
nsIFrame* closestScrollFrame =
nsLayoutUtils::GetClosestFrameOfType(aFrame, nsGkAtoms::scrollFrame);
while (closestScrollFrame) {
nsIScrollableFrame* sf = do_QueryFrame(closestScrollFrame);
nsRect scrollPortRect = sf->GetScrollPortRect();
nsRect rectRelativeToScrollFrame = aRect;
nsLayoutUtils::TransformRect(aFrame, closestScrollFrame,
rectRelativeToScrollFrame);
// Check whether aRect is visible in the scroll frame or not.
if (!scrollPortRect.Intersects(rectRelativeToScrollFrame)) {
return false;
}
// Get next ancestor scroll frame.
closestScrollFrame =
nsLayoutUtils::GetClosestFrameOfType(closestScrollFrame->GetParent(),
nsGkAtoms::scrollFrame);
}
return true;
}
bool bool
nsLayoutUtils::GetLayerTransformForFrame(nsIFrame* aFrame, nsLayoutUtils::GetLayerTransformForFrame(nsIFrame* aFrame,
Matrix4x4* aTransform) Matrix4x4* aTransform)

View File

@ -841,6 +841,13 @@ public:
static bool ContainsPoint(const nsRect& aRect, const nsPoint& aPoint, static bool ContainsPoint(const nsRect& aRect, const nsPoint& aPoint,
nscoord aInflateSize); nscoord aInflateSize);
/**
* Check whether aRect is visible in the boundary of the scroll frames
* boundary.
*/
static bool IsRectVisibleInScrollFrames(nsIFrame* aFrame,
const nsRect& aRect);
/** /**
* Return true if a "layer transform" could be computed for aFrame, * Return true if a "layer transform" could be computed for aFrame,
* and optionally return the computed transform. The returned * and optionally return the computed transform. The returned