mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1065244 - Part 1 - Add GetRectRelativeToFrame to nsLayoutUtils. f=mtseng, r=roc
This commit is contained in:
parent
0a0cfcb515
commit
88ac0a85b6
@ -791,39 +791,17 @@ SelectionCarets::SetEndFramePos(const nsPoint& aPosition)
|
||||
nsRect
|
||||
SelectionCarets::GetStartFrameRect()
|
||||
{
|
||||
nsIFrame* canvasFrame = mPresShell->GetCanvasFrame();
|
||||
dom::Element* element = mPresShell->GetSelectionCaretsStartElement();
|
||||
if (!element) {
|
||||
return nsRect();
|
||||
}
|
||||
|
||||
nsIFrame* frame = element->GetPrimaryFrame();
|
||||
if (!frame) {
|
||||
return nsRect();
|
||||
}
|
||||
|
||||
nsRect frameRect = frame->GetRectRelativeToSelf();
|
||||
nsLayoutUtils::TransformRect(frame, canvasFrame, frameRect);
|
||||
return frameRect;
|
||||
nsIFrame* canvasFrame = mPresShell->GetCanvasFrame();
|
||||
return nsLayoutUtils::GetRectRelativeToFrame(element, canvasFrame);
|
||||
}
|
||||
|
||||
nsRect
|
||||
SelectionCarets::GetEndFrameRect()
|
||||
{
|
||||
nsIFrame* canvasFrame = mPresShell->GetCanvasFrame();
|
||||
dom::Element* element = mPresShell->GetSelectionCaretsEndElement();
|
||||
if (!element) {
|
||||
return nsRect();
|
||||
}
|
||||
|
||||
nsIFrame* frame = element->GetPrimaryFrame();
|
||||
if (!frame) {
|
||||
return nsRect();
|
||||
}
|
||||
|
||||
nsRect frameRect = frame->GetRectRelativeToSelf();
|
||||
nsLayoutUtils::TransformRect(frame, canvasFrame, frameRect);
|
||||
return frameRect;
|
||||
nsIFrame* canvasFrame = mPresShell->GetCanvasFrame();
|
||||
return nsLayoutUtils::GetRectRelativeToFrame(element, canvasFrame);
|
||||
}
|
||||
|
||||
nsIFrame*
|
||||
|
@ -145,18 +145,8 @@ TouchCaret::GetTouchFrameRect()
|
||||
}
|
||||
|
||||
dom::Element* touchCaretElement = presShell->GetTouchCaretElement();
|
||||
if (!touchCaretElement) {
|
||||
return nsRect();
|
||||
}
|
||||
|
||||
// Get touch caret position relative to canvas frame.
|
||||
nsIFrame* touchCaretFrame = touchCaretElement->GetPrimaryFrame();
|
||||
nsRect tcRect = touchCaretFrame->GetRectRelativeToSelf();
|
||||
nsIFrame* canvasFrame = GetCanvasFrame();
|
||||
|
||||
nsLayoutUtils::TransformResult rv =
|
||||
nsLayoutUtils::TransformRect(touchCaretFrame, canvasFrame, tcRect);
|
||||
return rv == nsLayoutUtils::TRANSFORM_SUCCEEDED ? tcRect : nsRect();
|
||||
return nsLayoutUtils::GetRectRelativeToFrame(touchCaretElement, canvasFrame);
|
||||
}
|
||||
|
||||
nsRect
|
||||
|
@ -2389,6 +2389,28 @@ nsLayoutUtils::TransformRect(nsIFrame* aFromFrame, nsIFrame* aToFrame,
|
||||
return TRANSFORM_SUCCEEDED;
|
||||
}
|
||||
|
||||
nsRect
|
||||
nsLayoutUtils::GetRectRelativeToFrame(Element* aElement, nsIFrame* aFrame)
|
||||
{
|
||||
if (!aElement || !aFrame) {
|
||||
return nsRect();
|
||||
}
|
||||
|
||||
nsIFrame* frame = aElement->GetPrimaryFrame();
|
||||
if (!frame) {
|
||||
return nsRect();
|
||||
}
|
||||
|
||||
nsRect rect = frame->GetRectRelativeToSelf();
|
||||
nsLayoutUtils::TransformResult rv =
|
||||
nsLayoutUtils::TransformRect(frame, aFrame, rect);
|
||||
if (rv != nsLayoutUtils::TRANSFORM_SUCCEEDED) {
|
||||
return nsRect();
|
||||
}
|
||||
|
||||
return rect;
|
||||
}
|
||||
|
||||
bool
|
||||
nsLayoutUtils::GetLayerTransformForFrame(nsIFrame* aFrame,
|
||||
Matrix4x4* aTransform)
|
||||
|
@ -754,6 +754,13 @@ public:
|
||||
static TransformResult TransformRect(nsIFrame* aFromFrame, nsIFrame* aToFrame,
|
||||
nsRect& aRect);
|
||||
|
||||
/**
|
||||
* Get the border-box of aElement's primary frame, transformed it to be
|
||||
* relative to aFrame.
|
||||
*/
|
||||
static nsRect GetRectRelativeToFrame(mozilla::dom::Element* aElement,
|
||||
nsIFrame* aFrame);
|
||||
|
||||
/**
|
||||
* Return true if a "layer transform" could be computed for aFrame,
|
||||
* and optionally return the computed transform. The returned
|
||||
|
Loading…
Reference in New Issue
Block a user