diff --git a/dom/bindings/BindingUtils.cpp b/dom/bindings/BindingUtils.cpp index 27fbc2262b2f..6b0302018be4 100644 --- a/dom/bindings/BindingUtils.cpp +++ b/dom/bindings/BindingUtils.cpp @@ -67,7 +67,6 @@ #include "mozilla/dom/WorkerScope.h" #include "mozilla/dom/XrayExpandoClass.h" #include "mozilla/dom/WindowProxyHolder.h" -#include "mozilla/dom/XULScrollElementBinding.h" #include "mozilla/jsipc/CrossProcessObjectWrappers.h" #include "ipc/ErrorIPCUtils.h" #include "mozilla/UseCounter.h" @@ -3619,8 +3618,6 @@ bool HTMLConstructor(JSContext* aCx, unsigned aArgc, JS::Value* aVp, } else if (definition->mLocalName == nsGkAtoms::menu || definition->mLocalName == nsGkAtoms::menulist) { cb = XULMenuElement_Binding::GetConstructorObject; - } else if (definition->mLocalName == nsGkAtoms::scrollbox) { - cb = XULScrollElement_Binding::GetConstructorObject; } else if (definition->mLocalName == nsGkAtoms::tree) { cb = XULTreeElement_Binding::GetConstructorObject; } else { diff --git a/dom/chrome-webidl/XULScrollElement.webidl b/dom/chrome-webidl/XULScrollElement.webidl deleted file mode 100644 index ac417969950a..000000000000 --- a/dom/chrome-webidl/XULScrollElement.webidl +++ /dev/null @@ -1,15 +0,0 @@ -/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. - */ - -[HTMLConstructor, Func="IsChromeOrXBL"] -interface XULScrollElement : XULElement { - [Throws] - void scrollToElement(Element child); - [Throws] - void scrollByIndex(long aIndexes); - [Throws] - void ensureElementIsVisible(Element child); -}; diff --git a/dom/chrome-webidl/moz.build b/dom/chrome-webidl/moz.build index 890fd3c648d8..a363cb7e794d 100644 --- a/dom/chrome-webidl/moz.build +++ b/dom/chrome-webidl/moz.build @@ -58,7 +58,6 @@ WEBIDL_FILES = [ 'WindowGlobalActors.webidl', 'XULFrameElement.webidl', 'XULMenuElement.webidl', - 'XULScrollElement.webidl', 'XULTextElement.webidl', 'XULTreeElement.webidl' ] diff --git a/dom/tests/mochitest/general/test_interfaces.js b/dom/tests/mochitest/general/test_interfaces.js index cfc0d0599790..90fa7e0f0a00 100644 --- a/dom/tests/mochitest/general/test_interfaces.js +++ b/dom/tests/mochitest/general/test_interfaces.js @@ -1279,8 +1279,6 @@ var interfaceNamesInGlobalScope = {name: "XULMenuElement", insecureContext: true, xbl: true}, // IMPORTANT: Do not change this list without review from a DOM peer! {name: "XULPopupElement", insecureContext: true, xbl: true}, -// IMPORTANT: Do not change this list without review from a DOM peer! - {name: "XULScrollElement", insecureContext: true, xbl: true}, // IMPORTANT: Do not change this list without review from a DOM peer! {name: "XULTextElement", insecureContext: true, xbl: true}, // IMPORTANT: Do not change this list without review from a DOM peer! diff --git a/dom/xul/XULScrollElement.cpp b/dom/xul/XULScrollElement.cpp deleted file mode 100644 index b65ed8b04d8b..000000000000 --- a/dom/xul/XULScrollElement.cpp +++ /dev/null @@ -1,186 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "mozilla/dom/Element.h" -#include "mozilla/dom/ToJSValue.h" -#include "nsCOMPtr.h" -#include "nsIPresShell.h" -#include "nsIContent.h" -#include "nsPresContext.h" -#include "nsBox.h" -#include "nsIScrollableFrame.h" -#include "mozilla/dom/XULScrollElement.h" -#include "mozilla/dom/XULScrollElementBinding.h" - -namespace mozilla { -namespace dom { - -JSObject* XULScrollElement::WrapNode(JSContext* aCx, - JS::Handle aGivenProto) { - return XULScrollElement_Binding::Wrap(aCx, this, aGivenProto); -} - -void XULScrollElement::ScrollByIndex(int32_t aIndex, ErrorResult& aRv) { - nsIScrollableFrame* sf = GetScrollFrame(); - if (!sf) { - aRv.Throw(NS_ERROR_FAILURE); - return; - } - - nsIFrame* scrolledFrame = sf->GetScrolledFrame(); - if (!scrolledFrame) { - aRv.Throw(NS_ERROR_FAILURE); - return; - } - - nsRect rect; - - // now get the element's first child - nsIFrame* child = nsBox::GetChildXULBox(scrolledFrame); - - bool horiz = scrolledFrame->IsXULHorizontal(); - nsPoint cp = sf->GetScrollPosition(); - nscoord diff = 0; - int32_t curIndex = 0; - bool isLTR = scrolledFrame->IsXULNormalDirection(); - - nscoord frameWidth = 0; - if (!isLTR && horiz) { - nsCOMPtr doc = GetComposedDoc(); - - nsCOMPtr shell = doc->GetShell(); - if (!shell) { - aRv.Throw(NS_ERROR_UNEXPECTED); - return; - } - nsRect rcFrame = nsLayoutUtils::GetAllInFlowRectsUnion( - GetPrimaryFrame(), shell->GetRootFrame()); - frameWidth = rcFrame.width; - } - - // first find out what index we are currently at - while (child) { - rect = child->GetRect(); - if (horiz) { - // In the left-to-right case we break from the loop when the center of - // the current child rect is greater than the scrolled position of - // the left edge of the scrollbox - // In the right-to-left case we break when the center of the current - // child rect is less than the scrolled position of the right edge of - // the scrollelement. - diff = - rect.x + rect.width / 2; // use the center, to avoid rounding errors - if ((isLTR && diff > cp.x) || (!isLTR && diff < cp.x + frameWidth)) { - break; - } - } else { - diff = - rect.y + rect.height / 2; // use the center, to avoid rounding errors - if (diff > cp.y) { - break; - } - } - child = nsBox::GetNextXULBox(child); - curIndex++; - } - - int32_t count = 0; - - if (aIndex == 0) return; - - if (aIndex > 0) { - while (child) { - child = nsBox::GetNextXULBox(child); - if (child) { - rect = child->GetRect(); - } - count++; - if (count >= aIndex) { - break; - } - } - - } else if (aIndex < 0) { - child = nsBox::GetChildXULBox(scrolledFrame); - while (child) { - rect = child->GetRect(); - if (count >= curIndex + aIndex) { - break; - } - count++; - child = nsBox::GetNextXULBox(child); - } - } - - nscoord csspixel = nsPresContext::CSSPixelsToAppUnits(1); - if (horiz) { - // In the left-to-right case we scroll so that the left edge of the - // selected child is scrolled to the left edge of the scrollbox. - // In the right-to-left case we scroll so that the right edge of the - // selected child is scrolled to the right edge of the scrollbox. - - nsPoint pt(isLTR ? rect.x : rect.x + rect.width - frameWidth, cp.y); - - // Use a destination range that ensures the left edge (or right edge, - // for RTL) will indeed be visible. Also ensure that the top edge - // is visible. - nsRect range(pt.x, pt.y, csspixel, 0); - if (isLTR) { - range.x -= csspixel; - } - sf->ScrollTo(pt, nsIScrollableFrame::INSTANT, &range); - } else { - // Use a destination range that ensures the top edge will be visible. - nsRect range(cp.x, rect.y - csspixel, 0, csspixel); - sf->ScrollTo(nsPoint(cp.x, rect.y), nsIScrollableFrame::INSTANT, &range); - } -} - -void XULScrollElement::ScrollToElement(Element& child, ErrorResult& aRv) { - nsCOMPtr doc = GetComposedDoc(); - if (!doc) { - aRv.Throw(NS_ERROR_FAILURE); - return; - } - - nsCOMPtr shell = doc->GetShell(); - if (!shell) { - aRv.Throw(NS_ERROR_UNEXPECTED); - return; - } - - shell->ScrollContentIntoView( - &child, - nsIPresShell::ScrollAxis(nsIPresShell::SCROLL_TOP, - nsIPresShell::SCROLL_ALWAYS), - nsIPresShell::ScrollAxis(nsIPresShell::SCROLL_LEFT, - nsIPresShell::SCROLL_ALWAYS), - nsIPresShell::SCROLL_FIRST_ANCESTOR_ONLY | - nsIPresShell::SCROLL_OVERFLOW_HIDDEN); -} - -void XULScrollElement::EnsureElementIsVisible(Element& aChild, - ErrorResult& aRv) { - nsCOMPtr doc = GetComposedDoc(); - if (!doc) { - aRv.Throw(NS_ERROR_FAILURE); - return; - } - - nsCOMPtr shell = doc->GetShell(); - if (!shell) { - aRv.Throw(NS_ERROR_UNEXPECTED); - return; - } - - shell->ScrollContentIntoView(&aChild, nsIPresShell::ScrollAxis(), - nsIPresShell::ScrollAxis(), - nsIPresShell::SCROLL_FIRST_ANCESTOR_ONLY | - nsIPresShell::SCROLL_OVERFLOW_HIDDEN); -} - -} // namespace dom -} // namespace mozilla diff --git a/dom/xul/XULScrollElement.h b/dom/xul/XULScrollElement.h deleted file mode 100644 index ba27fd28db90..000000000000 --- a/dom/xul/XULScrollElement.h +++ /dev/null @@ -1,35 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef XULScrollElement_h__ -#define XULScrollElement_h__ - -#include "nsXULElement.h" -#include "Units.h" - -namespace mozilla { -namespace dom { - -class XULScrollElement final : public nsXULElement { - public: - explicit XULScrollElement( - already_AddRefed&& aNodeInfo) - : nsXULElement(std::move(aNodeInfo)) {} - - MOZ_CAN_RUN_SCRIPT void ScrollByIndex(int32_t aIndex, ErrorResult& aRv); - MOZ_CAN_RUN_SCRIPT void EnsureElementIsVisible(Element& aChild, - ErrorResult& aRv); - MOZ_CAN_RUN_SCRIPT void ScrollToElement(Element& child, ErrorResult& aRv); - - protected: - virtual ~XULScrollElement() {} - JSObject* WrapNode(JSContext* aCx, JS::Handle aGivenProto) final; -}; - -} // namespace dom -} // namespace mozilla - -#endif // XULScrollElement_h diff --git a/dom/xul/moz.build b/dom/xul/moz.build index 6f68b48c39a6..53830d8671a5 100644 --- a/dom/xul/moz.build +++ b/dom/xul/moz.build @@ -27,7 +27,6 @@ if CONFIG['MOZ_XUL']: 'XULMenuElement.h', 'XULPersist.h', 'XULPopupElement.h', - 'XULScrollElement.h', 'XULTextElement.h', 'XULTooltipElement.h', 'XULTreeElement.h', @@ -48,7 +47,6 @@ if CONFIG['MOZ_XUL']: 'XULMenuElement.cpp', 'XULPersist.cpp', 'XULPopupElement.cpp', - 'XULScrollElement.cpp', 'XULTextElement.cpp', 'XULTooltipElement.cpp', 'XULTreeElement.cpp', diff --git a/dom/xul/nsXULElement.cpp b/dom/xul/nsXULElement.cpp index 0ffe575fd222..9ef0a6fc0796 100644 --- a/dom/xul/nsXULElement.cpp +++ b/dom/xul/nsXULElement.cpp @@ -77,7 +77,6 @@ #include "XULFrameElement.h" #include "XULMenuElement.h" #include "XULPopupElement.h" -#include "XULScrollElement.h" #include "XULTreeElement.h" #include "mozilla/dom/XULElementBinding.h" @@ -167,10 +166,6 @@ nsXULElement* nsXULElement::Construct( return new XULMenuElement(nodeInfo.forget()); } - if (nodeInfo->Equals(nsGkAtoms::scrollbox)) { - return new XULScrollElement(nodeInfo.forget()); - } - if (nodeInfo->Equals(nsGkAtoms::tree)) { return new XULTreeElement(nodeInfo.forget()); }