mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-09 09:18:42 +09:00
Align Element.ScrollIntoView() with the spec.
This also removes the (unused) shadow alias from nsIDOMHTMLElement which used the different calling convention. This resolves #927
This commit is contained in:
parent
83b95f2c5b
commit
14ea8bb121
5 changed files with 56 additions and 25 deletions
|
|
@ -687,19 +687,23 @@ Element::GetScrollFrame(nsIFrame **aStyledFrame, bool aFlushLayout)
|
|||
}
|
||||
|
||||
void
|
||||
Element::ScrollIntoView()
|
||||
Element::ScrollIntoView(const BooleanOrScrollIntoViewOptions& aObject)
|
||||
{
|
||||
ScrollIntoView(ScrollIntoViewOptions());
|
||||
}
|
||||
|
||||
void
|
||||
Element::ScrollIntoView(bool aTop)
|
||||
{
|
||||
ScrollIntoViewOptions options;
|
||||
if (!aTop) {
|
||||
options.mBlock = ScrollLogicalPosition::End;
|
||||
if (aObject.IsScrollIntoViewOptions()) {
|
||||
return ScrollIntoView(aObject.GetAsScrollIntoViewOptions());
|
||||
}
|
||||
ScrollIntoView(options);
|
||||
|
||||
MOZ_DIAGNOSTIC_ASSERT(aObject.IsBoolean());
|
||||
|
||||
ScrollIntoViewOptions options;
|
||||
if (aObject.GetAsBoolean()) {
|
||||
options.mBlock = ScrollLogicalPosition::Start;
|
||||
options.mInline = ScrollLogicalPosition::Nearest;
|
||||
} else {
|
||||
options.mBlock = ScrollLogicalPosition::End;
|
||||
options.mInline = ScrollLogicalPosition::Nearest;
|
||||
}
|
||||
return ScrollIntoView(options);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -716,9 +720,41 @@ Element::ScrollIntoView(const ScrollIntoViewOptions &aOptions)
|
|||
return;
|
||||
}
|
||||
|
||||
int16_t vpercent = (aOptions.mBlock == ScrollLogicalPosition::Start)
|
||||
? nsIPresShell::SCROLL_TOP
|
||||
: nsIPresShell::SCROLL_BOTTOM;
|
||||
int16_t vpercent = nsIPresShell::SCROLL_CENTER;
|
||||
switch (aOptions.mBlock) {
|
||||
case ScrollLogicalPosition::Start:
|
||||
vpercent = nsIPresShell::SCROLL_TOP;
|
||||
break;
|
||||
case ScrollLogicalPosition::Center:
|
||||
vpercent = nsIPresShell::SCROLL_CENTER;
|
||||
break;
|
||||
case ScrollLogicalPosition::End:
|
||||
vpercent = nsIPresShell::SCROLL_BOTTOM;
|
||||
break;
|
||||
case ScrollLogicalPosition::Nearest:
|
||||
vpercent = nsIPresShell::SCROLL_MINIMUM;
|
||||
break;
|
||||
default:
|
||||
MOZ_ASSERT_UNREACHABLE("Unexpected ScrollLogicalPosition value");
|
||||
}
|
||||
|
||||
int16_t hpercent = nsIPresShell::SCROLL_CENTER;
|
||||
switch (aOptions.mInline) {
|
||||
case ScrollLogicalPosition::Start:
|
||||
hpercent = nsIPresShell::SCROLL_LEFT;
|
||||
break;
|
||||
case ScrollLogicalPosition::Center:
|
||||
hpercent = nsIPresShell::SCROLL_CENTER;
|
||||
break;
|
||||
case ScrollLogicalPosition::End:
|
||||
hpercent = nsIPresShell::SCROLL_RIGHT;
|
||||
break;
|
||||
case ScrollLogicalPosition::Nearest:
|
||||
hpercent = nsIPresShell::SCROLL_MINIMUM;
|
||||
break;
|
||||
default:
|
||||
MOZ_ASSERT_UNREACHABLE("Unexpected ScrollLogicalPosition value");
|
||||
}
|
||||
|
||||
uint32_t flags = nsIPresShell::SCROLL_OVERFLOW_HIDDEN;
|
||||
if (aOptions.mBehavior == ScrollBehavior::Smooth) {
|
||||
|
|
@ -731,7 +767,9 @@ Element::ScrollIntoView(const ScrollIntoViewOptions &aOptions)
|
|||
nsIPresShell::ScrollAxis(
|
||||
vpercent,
|
||||
nsIPresShell::SCROLL_ALWAYS),
|
||||
nsIPresShell::ScrollAxis(),
|
||||
nsIPresShell::ScrollAxis(
|
||||
hpercent,
|
||||
nsIPresShell::SCROLL_ALWAYS),
|
||||
flags);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue