summaryrefslogtreecommitdiffstats
path: root/dom/base
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@wolfbeast.com>2019-01-08 17:35:24 +0100
committerwolfbeast <mcwerewolf@wolfbeast.com>2019-01-08 17:35:24 +0100
commitc0a05ada187f09736b5b607f7ba3da903153ae38 (patch)
treee4ecc0772c762a81123012a241d9f5a7081bc13e /dom/base
parente8cebef9d2a524067863741333a6784db4ea258d (diff)
downloadUXP-c0a05ada187f09736b5b607f7ba3da903153ae38.tar
UXP-c0a05ada187f09736b5b607f7ba3da903153ae38.tar.gz
UXP-c0a05ada187f09736b5b607f7ba3da903153ae38.tar.lz
UXP-c0a05ada187f09736b5b607f7ba3da903153ae38.tar.xz
UXP-c0a05ada187f09736b5b607f7ba3da903153ae38.zip
Align Element.ScrollIntoView() with the spec.
This also removes the (unused) shadow alias from nsIDOMHTMLElement which used the different calling convention. This resolves #927
Diffstat (limited to 'dom/base')
-rw-r--r--dom/base/Element.cpp62
-rw-r--r--dom/base/Element.h5
2 files changed, 53 insertions, 14 deletions
diff --git a/dom/base/Element.cpp b/dom/base/Element.cpp
index 67759fdb2..5c3277e84 100644
--- a/dom/base/Element.cpp
+++ b/dom/base/Element.cpp
@@ -687,19 +687,23 @@ Element::GetScrollFrame(nsIFrame **aStyledFrame, bool aFlushLayout)
}
void
-Element::ScrollIntoView()
+Element::ScrollIntoView(const BooleanOrScrollIntoViewOptions& aObject)
{
- ScrollIntoView(ScrollIntoViewOptions());
-}
+ if (aObject.IsScrollIntoViewOptions()) {
+ return ScrollIntoView(aObject.GetAsScrollIntoViewOptions());
+ }
+
+ MOZ_DIAGNOSTIC_ASSERT(aObject.IsBoolean());
-void
-Element::ScrollIntoView(bool aTop)
-{
ScrollIntoViewOptions options;
- if (!aTop) {
+ if (aObject.GetAsBoolean()) {
+ options.mBlock = ScrollLogicalPosition::Start;
+ options.mInline = ScrollLogicalPosition::Nearest;
+ } else {
options.mBlock = ScrollLogicalPosition::End;
+ options.mInline = ScrollLogicalPosition::Nearest;
}
- ScrollIntoView(options);
+ 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);
}
diff --git a/dom/base/Element.h b/dom/base/Element.h
index ef57a6466..ce84b74fb 100644
--- a/dom/base/Element.h
+++ b/dom/base/Element.h
@@ -818,9 +818,10 @@ public:
return slots ? slots->mShadowRoot.get() : nullptr;
}
- void ScrollIntoView();
- void ScrollIntoView(bool aTop);
+private:
void ScrollIntoView(const ScrollIntoViewOptions &aOptions);
+public:
+ void ScrollIntoView(const BooleanOrScrollIntoViewOptions& aObject);
void Scroll(double aXScroll, double aYScroll);
void Scroll(const ScrollToOptions& aOptions);
void ScrollTo(double aXScroll, double aYScroll);