mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1082486 - Part 4 - Check whether nsCaret shows in the scroll frame. r=roc
This patch check whether nsCaret shows in scroll frame. If yes, touch caret will show, and its position will be clamp to scroll frame as before. Otherwise, we hide it since the nsCaret will not be seen in this case.
This commit is contained in:
parent
7cd6cb94a0
commit
142b3b8d13
@ -371,7 +371,6 @@ TouchCaret::UpdatePositionIfNeeded()
|
|||||||
if (!IsDisplayable()) {
|
if (!IsDisplayable()) {
|
||||||
SetVisibility(false);
|
SetVisibility(false);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mVisible) {
|
if (mVisible) {
|
||||||
@ -427,6 +426,11 @@ TouchCaret::IsDisplayable()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!IsCaretShowingInScrollFrame()) {
|
||||||
|
TOUCHCARET_LOG("Caret does not show in the scrollable frame!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -457,6 +461,37 @@ TouchCaret::GetTouchCaretPosition()
|
|||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
TouchCaret::IsCaretShowingInScrollFrame()
|
||||||
|
{
|
||||||
|
nsRect caretRect;
|
||||||
|
nsIFrame* caretFrame = GetCaretFocusFrame(&caretRect);
|
||||||
|
|
||||||
|
nsIFrame* closestScrollFrame =
|
||||||
|
nsLayoutUtils::GetClosestFrameOfType(caretFrame, nsGkAtoms::scrollFrame);
|
||||||
|
|
||||||
|
while (closestScrollFrame) {
|
||||||
|
nsIScrollableFrame* sf = do_QueryFrame(closestScrollFrame);
|
||||||
|
nsRect scrollPortRect = sf->GetScrollPortRect();
|
||||||
|
|
||||||
|
nsRect caretRectRelativeToScrollFrame = caretRect;
|
||||||
|
nsLayoutUtils::TransformRect(caretFrame, closestScrollFrame,
|
||||||
|
caretRectRelativeToScrollFrame);
|
||||||
|
|
||||||
|
// Check whether nsCaret appears in the scroll frame or not.
|
||||||
|
if (!scrollPortRect.Intersects(caretRectRelativeToScrollFrame)) {
|
||||||
|
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)
|
||||||
{
|
{
|
||||||
@ -467,6 +502,7 @@ TouchCaret::ClampPositionToScrollFrame(const nsPoint& aPosition)
|
|||||||
// Clamp the touch caret position to the scrollframe boundary.
|
// Clamp the touch caret position to the scrollframe boundary.
|
||||||
nsIFrame* closestScrollFrame =
|
nsIFrame* closestScrollFrame =
|
||||||
nsLayoutUtils::GetClosestFrameOfType(focusFrame, nsGkAtoms::scrollFrame);
|
nsLayoutUtils::GetClosestFrameOfType(focusFrame, nsGkAtoms::scrollFrame);
|
||||||
|
|
||||||
while (closestScrollFrame) {
|
while (closestScrollFrame) {
|
||||||
nsIScrollableFrame* sf = do_QueryFrame(closestScrollFrame);
|
nsIScrollableFrame* sf = do_QueryFrame(closestScrollFrame);
|
||||||
nsRect visualRect = sf->GetScrollPortRect();
|
nsRect visualRect = sf->GetScrollPortRect();
|
||||||
|
@ -117,6 +117,12 @@ private:
|
|||||||
*/
|
*/
|
||||||
nsPoint GetTouchCaretPosition();
|
nsPoint GetTouchCaretPosition();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether nsCaret shows in the scroll frame boundary, i.e. its rect
|
||||||
|
* intersects scroll frame's rect.
|
||||||
|
*/
|
||||||
|
bool IsCaretShowingInScrollFrame();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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.
|
||||||
|
Loading…
Reference in New Issue
Block a user