mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 982141 - Introduce nsLayoutUtils::SetDisplayPortMargins, with an option to not repaint. r=tn
--HG-- extra : rebase_source : 7d8245831828d60df4fb6e20d98fd2b08d4e3857
This commit is contained in:
parent
55a6ddb4d9
commit
eee5f0ebb7
@ -434,12 +434,6 @@ nsDOMWindowUtils::SetDisplayPortMarginsForElement(float aLeftMargin,
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
DisplayPortMarginsPropertyData* currentData =
|
||||
static_cast<DisplayPortMarginsPropertyData*>(content->GetProperty(nsGkAtoms::DisplayPortMargins));
|
||||
if (currentData && currentData->mPriority > aPriority) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Note order change of arguments between our function signature and
|
||||
// LayerMargin constructor.
|
||||
LayerMargin displayportMargins(aTopMargin,
|
||||
@ -447,21 +441,8 @@ nsDOMWindowUtils::SetDisplayPortMarginsForElement(float aLeftMargin,
|
||||
aBottomMargin,
|
||||
aLeftMargin);
|
||||
|
||||
content->SetProperty(nsGkAtoms::DisplayPortMargins,
|
||||
new DisplayPortMarginsPropertyData(displayportMargins, aAlignmentX, aAlignmentY, aPriority),
|
||||
nsINode::DeleteProperty<DisplayPortMarginsPropertyData>);
|
||||
|
||||
nsIFrame* rootScrollFrame = presShell->GetRootScrollFrame();
|
||||
if (rootScrollFrame && content == rootScrollFrame->GetContent()) {
|
||||
// We are setting a root displayport for a document.
|
||||
// The pres shell needs a special flag set.
|
||||
presShell->SetIgnoreViewportScrolling(true);
|
||||
}
|
||||
|
||||
nsIFrame* rootFrame = presShell->FrameManager()->GetRootFrame();
|
||||
if (rootFrame) {
|
||||
rootFrame->SchedulePaint();
|
||||
}
|
||||
nsLayoutUtils::SetDisplayPortMargins(content, presShell, displayportMargins,
|
||||
aAlignmentX, aAlignmentY, aPriority);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@ -497,8 +478,7 @@ nsDOMWindowUtils::SetDisplayPortBaseForElement(int32_t aX,
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
content->SetProperty(nsGkAtoms::DisplayPortBase, new nsRect(aX, aY, aWidth, aHeight),
|
||||
nsINode::DeleteProperty<nsRect>);
|
||||
nsLayoutUtils::SetDisplayPortBase(content, nsRect(aX, aY, aWidth, aHeight));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -772,6 +772,41 @@ nsLayoutUtils::GetDisplayPort(nsIContent* aContent, nsRect *aResult)
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
nsLayoutUtils::SetDisplayPortMargins(nsIContent* aContent,
|
||||
nsIPresShell* aPresShell,
|
||||
const LayerMargin& aMargins,
|
||||
uint32_t aAlignmentX,
|
||||
uint32_t aAlignmentY,
|
||||
uint32_t aPriority,
|
||||
RepaintMode aRepaintMode)
|
||||
{
|
||||
DisplayPortMarginsPropertyData* currentData =
|
||||
static_cast<DisplayPortMarginsPropertyData*>(aContent->GetProperty(nsGkAtoms::DisplayPortMargins));
|
||||
if (currentData && currentData->mPriority > aPriority) {
|
||||
return;
|
||||
}
|
||||
|
||||
aContent->SetProperty(nsGkAtoms::DisplayPortMargins,
|
||||
new DisplayPortMarginsPropertyData(
|
||||
aMargins, aAlignmentX, aAlignmentY, aPriority),
|
||||
nsINode::DeleteProperty<DisplayPortMarginsPropertyData>);
|
||||
|
||||
nsIFrame* rootScrollFrame = aPresShell->GetRootScrollFrame();
|
||||
if (rootScrollFrame && aContent == rootScrollFrame->GetContent()) {
|
||||
// We are setting a root displayport for a document.
|
||||
// The pres shell needs a special flag set.
|
||||
aPresShell->SetIgnoreViewportScrolling(true);
|
||||
}
|
||||
|
||||
if (aRepaintMode == RepaintMode::Repaint) {
|
||||
nsIFrame* rootFrame = aPresShell->FrameManager()->GetRootFrame();
|
||||
if (rootFrame) {
|
||||
rootFrame->SchedulePaint();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsLayoutUtils::SetDisplayPortBase(nsIContent* aContent, const nsRect& aBase)
|
||||
{
|
||||
|
@ -127,6 +127,7 @@ public:
|
||||
typedef FrameMetrics::ViewID ViewID;
|
||||
typedef mozilla::CSSPoint CSSPoint;
|
||||
typedef mozilla::CSSSize CSSSize;
|
||||
typedef mozilla::LayerMargin LayerMargin;
|
||||
|
||||
/**
|
||||
* Finds previously assigned ViewID for the given content element, if any.
|
||||
@ -155,11 +156,38 @@ public:
|
||||
*/
|
||||
static bool GetDisplayPort(nsIContent* aContent, nsRect *aResult = nullptr);
|
||||
|
||||
/**
|
||||
* Set the display port base rect for given element to be used with display
|
||||
* port margins.
|
||||
*/
|
||||
static void SetDisplayPortBase(nsIContent* aContent, const nsRect& aBase);
|
||||
MOZ_BEGIN_ENUM_CLASS(RepaintMode, uint8_t)
|
||||
Repaint,
|
||||
DoNotRepaint
|
||||
MOZ_END_ENUM_CLASS(RepaintMode)
|
||||
|
||||
/**
|
||||
* Set the display port margins for a content element to be used with a
|
||||
* display port base (see SetDisplayPortBase()).
|
||||
* See also nsIDOMWindowUtils.setDisplayPortMargins.
|
||||
* @param aContent the content element for which to set the margins
|
||||
* @param aPresShell the pres shell for the document containing the element
|
||||
* @param aMargins the margins to set
|
||||
* @param aAlignmentX, alignmentY the amount of pixels to which to align the
|
||||
* displayport built by combining the base
|
||||
* rect with the margins, in either direction
|
||||
* @param aPriority a priority value to determine which margins take effect
|
||||
* when multiple callers specify margins
|
||||
* @param aRepaintMode whether to schedule a paint after setting the margins
|
||||
*/
|
||||
static void SetDisplayPortMargins(nsIContent* aContent,
|
||||
nsIPresShell* aPresShell,
|
||||
const LayerMargin& aMargins,
|
||||
uint32_t aAlignmentX,
|
||||
uint32_t aAlignmentY,
|
||||
uint32_t aPriority = 0,
|
||||
RepaintMode aRepaintMode = RepaintMode::Repaint);
|
||||
|
||||
/**
|
||||
* Set the display port base rect for given element to be used with display
|
||||
* port margins.
|
||||
*/
|
||||
static void SetDisplayPortBase(nsIContent* aContent, const nsRect& aBase);
|
||||
|
||||
/**
|
||||
* Get the critical display port for the given element.
|
||||
|
Loading…
Reference in New Issue
Block a user