Bug 1022818 - Part 1: Update webidl interfaces. r=bz

- Extended the Element and Window webidl interfaces as described in the
  CSSOM-View smooth-scrolling specification.
- The Element.scrollTop and Element.scrollLeft changes have been omitted
  until either WebIDL is extended to allow properties to have union datatypes
  that contain dictionaries or the CSSOM-View smooth-scroll specification
  is upddated.  This will not prevent the other interface changes from being
  useful.
- Implemented wrapper functions for the nsGlobalWindow to connect to the new
  WebIDL bindings.  The ScrollOptions parameters are ignored in this patch,
  and used in Part 3 of this patch series.
This commit is contained in:
Kearwood (Kip) Gilbert 2014-07-21 11:04:00 -04:00
parent 73424be15b
commit efc9d7cf4a
7 changed files with 63 additions and 16 deletions

View File

@ -35,6 +35,7 @@
#include "nsAttrValue.h" #include "nsAttrValue.h"
#include "mozilla/EventForwards.h" #include "mozilla/EventForwards.h"
#include "mozilla/dom/BindingDeclarations.h" #include "mozilla/dom/BindingDeclarations.h"
#include "mozilla/dom/WindowBinding.h"
#include "Units.h" #include "Units.h"
class nsIDOMEventListener; class nsIDOMEventListener;
@ -720,11 +721,8 @@ public:
already_AddRefed<ShadowRoot> CreateShadowRoot(ErrorResult& aError); already_AddRefed<ShadowRoot> CreateShadowRoot(ErrorResult& aError);
already_AddRefed<DestinationInsertionPointList> GetDestinationInsertionPoints(); already_AddRefed<DestinationInsertionPointList> GetDestinationInsertionPoints();
void ScrollIntoView() void ScrollIntoView();
{ void ScrollIntoView(bool aTop, const ScrollOptions &aOptions);
ScrollIntoView(true);
}
void ScrollIntoView(bool aTop);
int32_t ScrollTop() int32_t ScrollTop()
{ {
nsIScrollableFrame* sf = GetScrollFrame(); nsIScrollableFrame* sf = GetScrollFrame();

View File

@ -586,7 +586,13 @@ Element::GetScrollFrame(nsIFrame **aStyledFrame, bool aFlushLayout)
} }
void void
Element::ScrollIntoView(bool aTop) Element::ScrollIntoView()
{
ScrollIntoView(true, ScrollOptions());
}
void
Element::ScrollIntoView(bool aTop, const ScrollOptions &aOptions)
{ {
nsIDocument *document = GetCurrentDoc(); nsIDocument *document = GetCurrentDoc();
if (!document) { if (!document) {

View File

@ -469,7 +469,7 @@ public:
if (!_argc) { if (!_argc) {
top = true; top = true;
} }
mozilla::dom::Element::ScrollIntoView(top); mozilla::dom::Element::ScrollIntoView(top, mozilla::dom::ScrollOptions());
return NS_OK; return NS_OK;
} }
NS_IMETHOD GetOffsetParent(nsIDOMElement** aOffsetParent) MOZ_FINAL { NS_IMETHOD GetOffsetParent(nsIDOMElement** aOffsetParent) MOZ_FINAL {

View File

@ -7221,6 +7221,20 @@ nsGlobalWindow::GetTopWindowRoot()
return window.forget(); return window.forget();
} }
void
nsGlobalWindow::Scroll(int32_t aXScroll, int32_t aYScroll,
const ScrollOptions& aOptions)
{
ScrollTo(CSSIntPoint(aXScroll, aYScroll));
}
void
nsGlobalWindow::ScrollTo(int32_t aXScroll, int32_t aYScroll,
const ScrollOptions& aOptions)
{
ScrollTo(CSSIntPoint(aXScroll, aYScroll));
}
NS_IMETHODIMP NS_IMETHODIMP
nsGlobalWindow::Scroll(int32_t aXScroll, int32_t aYScroll) nsGlobalWindow::Scroll(int32_t aXScroll, int32_t aYScroll)
{ {
@ -7277,6 +7291,27 @@ nsGlobalWindow::MozRequestOverfill(OverfillCallback& aCallback,
aError.Throw(NS_ERROR_NOT_AVAILABLE); aError.Throw(NS_ERROR_NOT_AVAILABLE);
} }
void
nsGlobalWindow::ScrollBy(int32_t aXScrollDif, int32_t aYScrollDif,
const ScrollOptions& aOptions)
{
ScrollBy(aXScrollDif, aYScrollDif);
}
void
nsGlobalWindow::ScrollByLines(int32_t numLines,
const ScrollOptions& aOptions)
{
ScrollByLines(numLines);
}
void
nsGlobalWindow::ScrollByPages(int32_t numPages,
const ScrollOptions& aOptions)
{
ScrollByPages(numPages);
}
NS_IMETHODIMP NS_IMETHODIMP
nsGlobalWindow::ScrollBy(int32_t aXScrollDif, int32_t aYScrollDif) nsGlobalWindow::ScrollBy(int32_t aXScrollDif, int32_t aYScrollDif)
{ {

View File

@ -49,6 +49,7 @@
#include "nsIDocument.h" #include "nsIDocument.h"
#include "nsIDOMTouchEvent.h" #include "nsIDOMTouchEvent.h"
#include "mozilla/dom/EventTarget.h" #include "mozilla/dom/EventTarget.h"
#include "mozilla/dom/WindowBinding.h"
#include "Units.h" #include "Units.h"
#include "nsComponentManagerUtils.h" #include "nsComponentManagerUtils.h"
@ -934,6 +935,16 @@ public:
mozilla::ErrorResult& aError); mozilla::ErrorResult& aError);
void ResizeBy(int32_t aWidthDif, int32_t aHeightDif, void ResizeBy(int32_t aWidthDif, int32_t aHeightDif,
mozilla::ErrorResult& aError); mozilla::ErrorResult& aError);
void Scroll(int32_t aXScroll, int32_t aYScroll,
const mozilla::dom::ScrollOptions& aOptions);
void ScrollTo(int32_t aXScroll, int32_t aYScroll,
const mozilla::dom::ScrollOptions& aOptions);
void ScrollBy(int32_t aXScrollDif, int32_t aYScrollDif,
const mozilla::dom::ScrollOptions& aOptions);
void ScrollByLines(int32_t numLines,
const mozilla::dom::ScrollOptions& aOptions);
void ScrollByPages(int32_t numPages,
const mozilla::dom::ScrollOptions& aOptions);
int32_t GetInnerWidth(mozilla::ErrorResult& aError); int32_t GetInnerWidth(mozilla::ErrorResult& aError);
void SetInnerWidth(int32_t aInnerWidth, mozilla::ErrorResult& aError); void SetInnerWidth(int32_t aInnerWidth, mozilla::ErrorResult& aError);
int32_t GetInnerHeight(mozilla::ErrorResult& aError); int32_t GetInnerHeight(mozilla::ErrorResult& aError);

View File

@ -156,7 +156,7 @@ partial interface Element {
// scrolling // scrolling
void scrollIntoView(); void scrollIntoView();
void scrollIntoView(boolean top); void scrollIntoView(boolean top, optional ScrollOptions options);
// None of the CSSOM attributes are [Pure], because they flush // None of the CSSOM attributes are [Pure], because they flush
attribute long scrollTop; // scroll on setting attribute long scrollTop; // scroll on setting
attribute long scrollLeft; // scroll on setting attribute long scrollLeft; // scroll on setting

View File

@ -179,16 +179,13 @@ partial interface Window {
//[Throws] readonly attribute double pageXOffset; //[Throws] readonly attribute double pageXOffset;
//[Throws] readonly attribute double scrollY; //[Throws] readonly attribute double scrollY;
//[Throws] readonly attribute double pageYOffset; //[Throws] readonly attribute double pageYOffset;
//void scroll(double x, double y, optional ScrollOptions options); void scroll(double x, double y, optional ScrollOptions options);
//void scrollTo(double x, double y, optional ScrollOptions options); void scrollTo(double x, double y, optional ScrollOptions options);
//void scrollBy(double x, double y, optional ScrollOptions options); void scrollBy(double x, double y, optional ScrollOptions options);
[Replaceable, Throws] readonly attribute long scrollX; [Replaceable, Throws] readonly attribute long scrollX;
[Throws] readonly attribute long pageXOffset; [Throws] readonly attribute long pageXOffset;
[Replaceable, Throws] readonly attribute long scrollY; [Replaceable, Throws] readonly attribute long scrollY;
[Throws] readonly attribute long pageYOffset; [Throws] readonly attribute long pageYOffset;
void scroll(long x, long y);
void scrollTo(long x, long y);
void scrollBy(long x, long y);
// client // client
//[Throws] readonly attribute double screenX; //[Throws] readonly attribute double screenX;
@ -271,12 +268,12 @@ partial interface Window {
/** /**
* Method for scrolling this window by a number of lines. * Method for scrolling this window by a number of lines.
*/ */
void scrollByLines(long numLines); void scrollByLines(long numLines, optional ScrollOptions options);
/** /**
* Method for scrolling this window by a number of pages. * Method for scrolling this window by a number of pages.
*/ */
void scrollByPages(long numPages); void scrollByPages(long numPages, optional ScrollOptions options);
/** /**
* Method for sizing this window to the content in the window. * Method for sizing this window to the content in the window.