Bug 1418558 part 1. Add MOZ_CAN_RUN_SCRIPT annotations to most Element methods that call GetPrimaryFrame. r=mystor

MozReview-Commit-ID: LWI1p75EyxB
This commit is contained in:
Boris Zbarsky 2017-12-05 11:18:16 -05:00
Родитель 631ee424d6
Коммит 723521145b
3 изменённых файлов: 33 добавлений и 27 удалений

Просмотреть файл

@ -1104,8 +1104,8 @@ public:
already_AddRefed<Attr> SetAttributeNodeNS(Attr& aNewAttr,
ErrorResult& aError);
already_AddRefed<DOMRectList> GetClientRects();
already_AddRefed<DOMRect> GetBoundingClientRect();
MOZ_CAN_RUN_SCRIPT already_AddRefed<DOMRectList> GetClientRects();
MOZ_CAN_RUN_SCRIPT already_AddRefed<DOMRect> GetBoundingClientRect();
// Shadow DOM v1
already_AddRefed<ShadowRoot> AttachShadow(const ShadowRootInit& aInit,
@ -1128,60 +1128,60 @@ 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);
void ScrollTo(const ScrollToOptions& aOptions);
void ScrollBy(double aXScrollDif, double aYScrollDif);
void ScrollBy(const ScrollToOptions& aOptions);
MOZ_CAN_RUN_SCRIPT void Scroll(double aXScroll, double aYScroll);
MOZ_CAN_RUN_SCRIPT void Scroll(const ScrollToOptions& aOptions);
MOZ_CAN_RUN_SCRIPT void ScrollTo(double aXScroll, double aYScroll);
MOZ_CAN_RUN_SCRIPT void ScrollTo(const ScrollToOptions& aOptions);
MOZ_CAN_RUN_SCRIPT void ScrollBy(double aXScrollDif, double aYScrollDif);
MOZ_CAN_RUN_SCRIPT void ScrollBy(const ScrollToOptions& aOptions);
/* Scrolls without flushing the layout.
* aDx is the x offset, aDy the y offset in CSS pixels.
* Returns true if we actually scrolled.
*/
bool ScrollByNoFlush(int32_t aDx, int32_t aDy);
int32_t ScrollTop();
void SetScrollTop(int32_t aScrollTop);
int32_t ScrollLeft();
void SetScrollLeft(int32_t aScrollLeft);
int32_t ScrollWidth();
int32_t ScrollHeight();
void MozScrollSnap();
int32_t ClientTop()
MOZ_CAN_RUN_SCRIPT bool ScrollByNoFlush(int32_t aDx, int32_t aDy);
MOZ_CAN_RUN_SCRIPT int32_t ScrollTop();
MOZ_CAN_RUN_SCRIPT void SetScrollTop(int32_t aScrollTop);
MOZ_CAN_RUN_SCRIPT int32_t ScrollLeft();
MOZ_CAN_RUN_SCRIPT void SetScrollLeft(int32_t aScrollLeft);
MOZ_CAN_RUN_SCRIPT int32_t ScrollWidth();
MOZ_CAN_RUN_SCRIPT int32_t ScrollHeight();
MOZ_CAN_RUN_SCRIPT void MozScrollSnap();
MOZ_CAN_RUN_SCRIPT int32_t ClientTop()
{
return nsPresContext::AppUnitsToIntCSSPixels(GetClientAreaRect().y);
}
int32_t ClientLeft()
MOZ_CAN_RUN_SCRIPT int32_t ClientLeft()
{
return nsPresContext::AppUnitsToIntCSSPixels(GetClientAreaRect().x);
}
int32_t ClientWidth()
MOZ_CAN_RUN_SCRIPT int32_t ClientWidth()
{
return nsPresContext::AppUnitsToIntCSSPixels(GetClientAreaRect().Width());
}
int32_t ClientHeight()
MOZ_CAN_RUN_SCRIPT int32_t ClientHeight()
{
return nsPresContext::AppUnitsToIntCSSPixels(GetClientAreaRect().Height());
}
int32_t ScrollTopMin()
MOZ_CAN_RUN_SCRIPT int32_t ScrollTopMin()
{
nsIScrollableFrame* sf = GetScrollFrame();
return sf ?
nsPresContext::AppUnitsToIntCSSPixels(sf->GetScrollRange().y) : 0;
}
int32_t ScrollTopMax()
MOZ_CAN_RUN_SCRIPT int32_t ScrollTopMax()
{
nsIScrollableFrame* sf = GetScrollFrame();
return sf ?
nsPresContext::AppUnitsToIntCSSPixels(sf->GetScrollRange().YMost()) :
0;
}
int32_t ScrollLeftMin()
MOZ_CAN_RUN_SCRIPT int32_t ScrollLeftMin()
{
nsIScrollableFrame* sf = GetScrollFrame();
return sf ?
nsPresContext::AppUnitsToIntCSSPixels(sf->GetScrollRange().x) : 0;
}
int32_t ScrollLeftMax()
MOZ_CAN_RUN_SCRIPT int32_t ScrollLeftMax()
{
nsIScrollableFrame* sf = GetScrollFrame();
return sf ?
@ -1560,6 +1560,7 @@ protected:
* @param aScroll Destination of scroll, in CSS pixels
* @param aOptions Dictionary of options to be evaluated
*/
MOZ_CAN_RUN_SCRIPT
void Scroll(const CSSIntPoint& aScroll, const ScrollOptions& aOptions);
/**
@ -1800,8 +1801,9 @@ private:
* Get this element's client area rect in app units.
* @return the frame's client area
*/
nsRect GetClientAreaRect();
MOZ_CAN_RUN_SCRIPT nsRect GetClientAreaRect();
MOZ_CAN_RUN_SCRIPT
nsIScrollableFrame* GetScrollFrame(nsIFrame **aStyledFrame = nullptr,
FlushType aFlushType = FlushType::Layout);

Просмотреть файл

@ -9437,7 +9437,8 @@ class CGSpecializedSetter(CGAbstractStaticMethod):
Argument('JS::Handle<JSObject*>', 'obj'),
Argument('%s*' % descriptor.nativeType, 'self'),
Argument('JSJitSetterCallArgs', 'args')]
CGAbstractStaticMethod.__init__(self, descriptor, name, "bool", args)
CGAbstractStaticMethod.__init__(self, descriptor, name, "bool", args,
canRunScript=True)
def definition_body(self):
nativeName = CGSpecializedSetter.makeNativeName(self.descriptor,

Просмотреть файл

@ -177,7 +177,10 @@ protected:
nsCOMPtr<nsITabParent> mPrimaryTabParent;
private:
nsresult GetPrimaryTabParentSize(int32_t* aWidth, int32_t* aHeight);
// GetPrimaryTabParentSize is called from xpidl methods and we don't have a
// good way to annotate those with MOZ_CAN_RUN_SCRIPT yet. It takes no
// refcounted args other than "this", and the "this" uses seem ok.
MOZ_CAN_RUN_SCRIPT_BOUNDARY nsresult GetPrimaryTabParentSize(int32_t* aWidth, int32_t* aHeight);
nsresult GetPrimaryContentShellSize(int32_t* aWidth, int32_t* aHeight);
nsresult SetPrimaryTabParentSize(int32_t aWidth, int32_t aHeight);
};