mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-04-01 12:03:08 +00:00
Bug 1603889 - Simplify the scrollbar preference setup. r=smaug
So much plumbing to pass an enum down. Differential Revision: https://phabricator.services.mozilla.com/D57182 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
ddcd5d3d38
commit
ac506d6f4b
@ -44,7 +44,6 @@ XPIDL_SOURCES += [
|
||||
'nsIPrivacyTransitionObserver.idl',
|
||||
'nsIReflowObserver.idl',
|
||||
'nsIRefreshURI.idl',
|
||||
'nsIScrollable.idl',
|
||||
'nsITooltipListener.idl',
|
||||
'nsITooltipTextProvider.idl',
|
||||
'nsIURIFixup.idl',
|
||||
|
@ -311,7 +311,7 @@ nsDocShell::nsDocShell(BrowsingContext* aBrowsingContext,
|
||||
mForcedCharset(nullptr),
|
||||
mParentCharset(nullptr),
|
||||
mTreeOwner(nullptr),
|
||||
mDefaultScrollbarPref(Scrollbar_Auto, Scrollbar_Auto),
|
||||
mScrollbarPref(ScrollbarPreference::Auto),
|
||||
mCharsetReloadState(eCharsetReloadInit),
|
||||
mOrientationLock(hal::eScreenOrientation_None),
|
||||
mParentCharsetSource(0),
|
||||
@ -541,7 +541,6 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsDocShell)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDocShellTreeItem)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIWebNavigation)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIBaseWindow)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIScrollable)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIRefreshURI)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIWebProgressListener)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
|
||||
@ -5242,64 +5241,21 @@ nsresult nsDocShell::SetCurScrollPosEx(int32_t aCurHorizontalPos,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
// nsDocShell::nsIScrollable
|
||||
//*****************************************************************************
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::GetDefaultScrollbarPreferences(int32_t aScrollOrientation,
|
||||
int32_t* aScrollbarPref) {
|
||||
NS_ENSURE_ARG_POINTER(aScrollbarPref);
|
||||
switch (aScrollOrientation) {
|
||||
case ScrollOrientation_X:
|
||||
*aScrollbarPref = mDefaultScrollbarPref.x;
|
||||
return NS_OK;
|
||||
|
||||
case ScrollOrientation_Y:
|
||||
*aScrollbarPref = mDefaultScrollbarPref.y;
|
||||
return NS_OK;
|
||||
|
||||
default:
|
||||
NS_ENSURE_TRUE(false, NS_ERROR_INVALID_ARG);
|
||||
void nsDocShell::SetScrollbarPreference(mozilla::ScrollbarPreference aPref) {
|
||||
if (mScrollbarPref == aPref) {
|
||||
return;
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::SetDefaultScrollbarPreferences(int32_t aScrollOrientation,
|
||||
int32_t aScrollbarPref) {
|
||||
switch (aScrollOrientation) {
|
||||
case ScrollOrientation_X:
|
||||
mDefaultScrollbarPref.x = aScrollbarPref;
|
||||
return NS_OK;
|
||||
|
||||
case ScrollOrientation_Y:
|
||||
mDefaultScrollbarPref.y = aScrollbarPref;
|
||||
return NS_OK;
|
||||
|
||||
default:
|
||||
NS_ENSURE_TRUE(false, NS_ERROR_INVALID_ARG);
|
||||
mScrollbarPref = aPref;
|
||||
auto* ps = GetPresShell();
|
||||
if (!ps) {
|
||||
return;
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::GetScrollbarVisibility(bool* aVerticalVisible,
|
||||
bool* aHorizontalVisible) {
|
||||
nsIScrollableFrame* sf = GetRootScrollFrame();
|
||||
NS_ENSURE_TRUE(sf, NS_ERROR_FAILURE);
|
||||
|
||||
uint32_t scrollbarVisibility = sf->GetScrollbarVisibility();
|
||||
if (aVerticalVisible) {
|
||||
*aVerticalVisible =
|
||||
(scrollbarVisibility & nsIScrollableFrame::VERTICAL) != 0;
|
||||
nsIFrame* scrollFrame = ps->GetRootScrollFrame();
|
||||
if (!scrollFrame) {
|
||||
return;
|
||||
}
|
||||
if (aHorizontalVisible) {
|
||||
*aHorizontalVisible =
|
||||
(scrollbarVisibility & nsIScrollableFrame::HORIZONTAL) != 0;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
ps->FrameNeedsReflow(scrollFrame, IntrinsicDirty::StyleChange,
|
||||
NS_FRAME_IS_DIRTY);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
|
@ -33,7 +33,6 @@
|
||||
#include "nsILoadURIDelegate.h"
|
||||
#include "nsINetworkInterceptController.h"
|
||||
#include "nsIRefreshURI.h"
|
||||
#include "nsIScrollable.h"
|
||||
#include "nsIWebNavigation.h"
|
||||
#include "nsIWebPageDescriptor.h"
|
||||
#include "nsIWebProgressListener.h"
|
||||
@ -56,6 +55,7 @@
|
||||
#include "Units.h"
|
||||
|
||||
#include "mozilla/ObservedDocShell.h"
|
||||
#include "mozilla/ScrollbarPreferences.h"
|
||||
#include "mozilla/TimelineConsumers.h"
|
||||
#include "mozilla/TimelineMarker.h"
|
||||
|
||||
@ -116,7 +116,6 @@ class nsDocShell final : public nsDocLoader,
|
||||
public nsIDocShell,
|
||||
public nsIWebNavigation,
|
||||
public nsIBaseWindow,
|
||||
public nsIScrollable,
|
||||
public nsIRefreshURI,
|
||||
public nsIWebProgressListener,
|
||||
public nsIWebPageDescriptor,
|
||||
@ -190,7 +189,6 @@ class nsDocShell final : public nsDocLoader,
|
||||
NS_DECL_NSIDOCSHELLTREEITEM
|
||||
NS_DECL_NSIWEBNAVIGATION
|
||||
NS_DECL_NSIBASEWINDOW
|
||||
NS_DECL_NSISCROLLABLE
|
||||
NS_DECL_NSIINTERFACEREQUESTOR
|
||||
NS_DECL_NSIWEBPROGRESSLISTENER
|
||||
NS_DECL_NSIREFRESHURI
|
||||
@ -210,6 +208,11 @@ class nsDocShell final : public nsDocLoader,
|
||||
return nsDocLoader::Stop();
|
||||
}
|
||||
|
||||
mozilla::ScrollbarPreference ScrollbarPreference() const {
|
||||
return mScrollbarPref;
|
||||
}
|
||||
void SetScrollbarPreference(mozilla::ScrollbarPreference);
|
||||
|
||||
/**
|
||||
* Process a click on a link.
|
||||
*
|
||||
@ -1181,7 +1184,7 @@ class nsDocShell final : public nsDocLoader,
|
||||
|
||||
RefPtr<mozilla::dom::EventTarget> mChromeEventHandler;
|
||||
|
||||
nsIntPoint mDefaultScrollbarPref; // persistent across doc loads
|
||||
mozilla::ScrollbarPreference mScrollbarPref; // persistent across doc loads
|
||||
|
||||
eCharsetReloadState mCharsetReloadState;
|
||||
|
||||
|
@ -1,55 +0,0 @@
|
||||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
* vim: set ts=2 sw=2 et tw=78:
|
||||
*
|
||||
* 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 "nsISupports.idl"
|
||||
|
||||
/**
|
||||
* The nsIScrollable is an interface that can be implemented by a control that
|
||||
* supports scrolling. This is a generic interface without concern for the
|
||||
* type of content that may be inside.
|
||||
*/
|
||||
[scriptable, uuid(3507fc93-313e-4a4c-8ca8-4d0ea0f97315)]
|
||||
interface nsIScrollable : nsISupports
|
||||
{
|
||||
/**
|
||||
* Constants declaring the two scroll orientations a scrollbar can be in.
|
||||
* ScrollOrientation_X - Horizontal scrolling. When passing this
|
||||
* in to a method you are requesting or setting data for the
|
||||
* horizontal scrollbar.
|
||||
* ScrollOrientation_Y - Vertical scrolling. When passing this
|
||||
* in to a method you are requesting or setting data for the
|
||||
* vertical scrollbar.
|
||||
*/
|
||||
const long ScrollOrientation_X = 1;
|
||||
const long ScrollOrientation_Y = 2;
|
||||
|
||||
/**
|
||||
* Constants declaring the states of the scrollbars.
|
||||
* ScrollPref_Auto - bars visible only when needed.
|
||||
* ScrollPref_Never - bars never visible, even when scrolling still possible.
|
||||
* ScrollPref_Always - bars always visible, even when scrolling is not possible
|
||||
*/
|
||||
const long Scrollbar_Auto = 1;
|
||||
const long Scrollbar_Never = 2;
|
||||
const long Scrollbar_Always = 3;
|
||||
|
||||
/**
|
||||
* Get or set the default scrollbar state for all documents in
|
||||
* this shell.
|
||||
*/
|
||||
long getDefaultScrollbarPreferences(in long scrollOrientation);
|
||||
void setDefaultScrollbarPreferences(in long scrollOrientation,
|
||||
in long scrollbarPref);
|
||||
|
||||
/**
|
||||
* Get information about whether the vertical and horizontal scrollbars are
|
||||
* currently visible. If you are only interested in one of the visibility
|
||||
* settings pass nullptr in for the one you aren't interested in.
|
||||
*/
|
||||
void getScrollbarVisibility(out boolean verticalVisible,
|
||||
out boolean horizontalVisible);
|
||||
};
|
@ -7,8 +7,8 @@
|
||||
#include "mozilla/dom/BarProps.h"
|
||||
#include "mozilla/dom/BarPropBinding.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsDocShell.h"
|
||||
#include "nsGlobalWindow.h"
|
||||
#include "nsIScrollable.h"
|
||||
#include "nsIWebBrowserChrome.h"
|
||||
|
||||
namespace mozilla {
|
||||
@ -192,23 +192,13 @@ bool ScrollbarsProp::GetVisible(CallerType aCallerType, ErrorResult& aRv) {
|
||||
return true;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIScrollable> scroller =
|
||||
do_QueryInterface(mDOMWindow->GetDocShell());
|
||||
|
||||
if (!scroller) {
|
||||
nsIDocShell* ds = mDOMWindow->GetDocShell();
|
||||
if (!ds) {
|
||||
return true;
|
||||
}
|
||||
|
||||
int32_t prefValue;
|
||||
scroller->GetDefaultScrollbarPreferences(nsIScrollable::ScrollOrientation_Y,
|
||||
&prefValue);
|
||||
if (prefValue != nsIScrollable::Scrollbar_Never) {
|
||||
return true;
|
||||
}
|
||||
|
||||
scroller->GetDefaultScrollbarPreferences(nsIScrollable::ScrollOrientation_X,
|
||||
&prefValue);
|
||||
return prefValue != nsIScrollable::Scrollbar_Never;
|
||||
ScrollbarPreference pref = nsDocShell::Cast(ds)->ScrollbarPreference();
|
||||
return pref != ScrollbarPreference::Never;
|
||||
}
|
||||
|
||||
void ScrollbarsProp::SetVisible(bool aVisible, CallerType aCallerType,
|
||||
|
@ -194,7 +194,6 @@
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIScriptObjectPrincipal.h"
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
#include "nsIScrollable.h"
|
||||
#include "nsIStreamConverter.h"
|
||||
#include "nsIStreamConverterService.h"
|
||||
#include "nsIStringBundle.h"
|
||||
@ -8695,22 +8694,11 @@ bool nsContentUtils::IsSpecificAboutPage(JSObject* aGlobal, const char* aUri) {
|
||||
/* static */
|
||||
void nsContentUtils::SetScrollbarsVisibility(nsIDocShell* aDocShell,
|
||||
bool aVisible) {
|
||||
nsCOMPtr<nsIScrollable> scroller = do_QueryInterface(aDocShell);
|
||||
|
||||
if (scroller) {
|
||||
int32_t prefValue;
|
||||
|
||||
if (aVisible) {
|
||||
prefValue = nsIScrollable::Scrollbar_Auto;
|
||||
} else {
|
||||
prefValue = nsIScrollable::Scrollbar_Never;
|
||||
}
|
||||
|
||||
scroller->SetDefaultScrollbarPreferences(nsIScrollable::ScrollOrientation_Y,
|
||||
prefValue);
|
||||
scroller->SetDefaultScrollbarPreferences(nsIScrollable::ScrollOrientation_X,
|
||||
prefValue);
|
||||
if (!aDocShell) {
|
||||
return;
|
||||
}
|
||||
auto pref = aVisible ? ScrollbarPreference::Auto : ScrollbarPreference::Never;
|
||||
nsDocShell::Cast(aDocShell)->SetScrollbarPreference(pref);
|
||||
}
|
||||
|
||||
/* static */
|
||||
|
@ -29,7 +29,6 @@
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
#include "nsIScrollable.h"
|
||||
#include "nsFrameLoader.h"
|
||||
#include "nsFrameLoaderOwner.h"
|
||||
#include "nsIFrame.h"
|
||||
@ -852,7 +851,7 @@ void nsFrameLoader::MaybeShowFrame() {
|
||||
}
|
||||
|
||||
bool nsFrameLoader::Show(int32_t marginWidth, int32_t marginHeight,
|
||||
int32_t scrollbarPrefX, int32_t scrollbarPrefY,
|
||||
ScrollbarPreference aScrollbarPref,
|
||||
nsSubDocumentFrame* frame) {
|
||||
if (mInShow) {
|
||||
return false;
|
||||
@ -879,11 +878,7 @@ bool nsFrameLoader::Show(int32_t marginWidth, int32_t marginHeight,
|
||||
|
||||
GetDocShell()->SetMarginWidth(marginWidth);
|
||||
GetDocShell()->SetMarginHeight(marginHeight);
|
||||
|
||||
GetDocShell()->SetDefaultScrollbarPreferences(
|
||||
nsIScrollable::ScrollOrientation_X, scrollbarPrefX);
|
||||
GetDocShell()->SetDefaultScrollbarPreferences(
|
||||
nsIScrollable::ScrollOrientation_Y, scrollbarPrefY);
|
||||
GetDocShell()->SetScrollbarPreference(aScrollbarPref);
|
||||
|
||||
if (PresShell* presShell = GetDocShell()->GetPresShell()) {
|
||||
// Ensure root scroll frame is reflowed in case scroll preferences or
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/dom/RemoteBrowser.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/ScrollbarPreferences.h"
|
||||
#include "mozilla/layers/LayersTypes.h"
|
||||
#include "nsStubMutationObserver.h"
|
||||
#include "Units.h"
|
||||
@ -260,9 +261,8 @@ class nsFrameLoader final : public nsStubMutationObserver,
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY bool Show(int32_t marginWidth,
|
||||
int32_t marginHeight,
|
||||
int32_t scrollbarPrefX,
|
||||
int32_t scrollbarPrefY,
|
||||
nsSubDocumentFrame* frame);
|
||||
mozilla::ScrollbarPreference,
|
||||
nsSubDocumentFrame*);
|
||||
|
||||
void MaybeShowFrame();
|
||||
|
||||
|
@ -20,7 +20,6 @@
|
||||
#include "nsIFrame.h"
|
||||
#include "nsIInterfaceRequestorUtils.h"
|
||||
#include "nsIPermissionManager.h"
|
||||
#include "nsIScrollable.h"
|
||||
#include "nsPresContext.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsSubDocumentFrame.h"
|
||||
@ -251,19 +250,17 @@ void nsGenericHTMLFrameElement::UnbindFromTree(bool aNullParent) {
|
||||
}
|
||||
|
||||
/* static */
|
||||
int32_t nsGenericHTMLFrameElement::MapScrollingAttribute(
|
||||
ScrollbarPreference nsGenericHTMLFrameElement::MapScrollingAttribute(
|
||||
const nsAttrValue* aValue) {
|
||||
int32_t mappedValue = nsIScrollable::Scrollbar_Auto;
|
||||
if (aValue && aValue->Type() == nsAttrValue::eEnum) {
|
||||
switch (aValue->GetEnumValue()) {
|
||||
case NS_STYLE_FRAME_OFF:
|
||||
case NS_STYLE_FRAME_NOSCROLL:
|
||||
case NS_STYLE_FRAME_NO:
|
||||
mappedValue = nsIScrollable::Scrollbar_Never;
|
||||
break;
|
||||
return ScrollbarPreference::Never;
|
||||
}
|
||||
}
|
||||
return mappedValue;
|
||||
return ScrollbarPreference::Auto;
|
||||
}
|
||||
|
||||
static bool PrincipalAllowsBrowserFrame(nsIPrincipal* aPrincipal) {
|
||||
@ -295,27 +292,9 @@ nsresult nsGenericHTMLFrameElement::AfterSetAttr(
|
||||
if (aName == nsGkAtoms::scrolling) {
|
||||
if (mFrameLoader) {
|
||||
// FIXME(bug 1588791): This should work for fission iframes.
|
||||
nsIDocShell* docshell = mFrameLoader->GetExistingDocShell();
|
||||
if (nsCOMPtr<nsIScrollable> scrollable = do_QueryInterface(docshell)) {
|
||||
int32_t cur;
|
||||
scrollable->GetDefaultScrollbarPreferences(
|
||||
nsIScrollable::ScrollOrientation_X, &cur);
|
||||
int32_t val = MapScrollingAttribute(aValue);
|
||||
if (cur != val) {
|
||||
scrollable->SetDefaultScrollbarPreferences(
|
||||
nsIScrollable::ScrollOrientation_X, val);
|
||||
scrollable->SetDefaultScrollbarPreferences(
|
||||
nsIScrollable::ScrollOrientation_Y, val);
|
||||
RefPtr<nsPresContext> presContext = docshell->GetPresContext();
|
||||
PresShell* presShell =
|
||||
presContext ? presContext->GetPresShell() : nullptr;
|
||||
nsIFrame* rootScroll =
|
||||
presShell ? presShell->GetRootScrollFrame() : nullptr;
|
||||
if (rootScroll) {
|
||||
presShell->FrameNeedsReflow(
|
||||
rootScroll, IntrinsicDirty::StyleChange, NS_FRAME_IS_DIRTY);
|
||||
}
|
||||
}
|
||||
if (nsIDocShell* docshell = mFrameLoader->GetExistingDocShell()) {
|
||||
nsDocShell::Cast(docshell)->SetScrollbarPreference(
|
||||
MapScrollingAttribute(aValue));
|
||||
}
|
||||
}
|
||||
} else if (aName == nsGkAtoms::mozbrowser) {
|
||||
|
@ -114,14 +114,11 @@ class nsGenericHTMLFrameElement : public nsGenericHTMLElement,
|
||||
void CreateRemoteFrameLoader(mozilla::dom::BrowserParent* aBrowserParent);
|
||||
|
||||
/**
|
||||
* Helper method to map a HTML 'scrolling' attribute value to a nsIScrollable
|
||||
* enum value. scrolling="no" (and its synonyms) maps to
|
||||
* nsIScrollable::Scrollbar_Never, and anything else (including nullptr) maps
|
||||
* to nsIScrollable::Scrollbar_Auto.
|
||||
* @param aValue the attribute value to map or nullptr
|
||||
* @return nsIScrollable::Scrollbar_Never or nsIScrollable::Scrollbar_Auto
|
||||
* Helper method to map a HTML 'scrolling' attribute value (which can be null)
|
||||
* to a ScrollbarPreference value value. scrolling="no" (and its synonyms)
|
||||
* map to Never, and anything else to Auto.
|
||||
*/
|
||||
static int32_t MapScrollingAttribute(const nsAttrValue* aValue);
|
||||
static mozilla::ScrollbarPreference MapScrollingAttribute(const nsAttrValue*);
|
||||
|
||||
nsIPrincipal* GetSrcTriggeringPrincipal() const {
|
||||
return mSrcTriggeringPrincipal;
|
||||
|
@ -1164,12 +1164,14 @@ bool nsPresContext::ElementWouldPropagateScrollStyles(const Element& aElement) {
|
||||
return GetPropagatedScrollStylesForViewport(this, &dummy) == &aElement;
|
||||
}
|
||||
|
||||
nsISupports* nsPresContext::GetContainerWeak() const { return GetDocShell(); }
|
||||
|
||||
nsIDocShell* nsPresContext::GetDocShell() const {
|
||||
nsISupports* nsPresContext::GetContainerWeak() const {
|
||||
return mDocument->GetDocShell();
|
||||
}
|
||||
|
||||
nsDocShell* nsPresContext::GetDocShell() const {
|
||||
return nsDocShell::Cast(mDocument->GetDocShell());
|
||||
}
|
||||
|
||||
bool nsPresContext::BidiEnabled() const { return Document()->GetBidiEnabled(); }
|
||||
|
||||
void nsPresContext::SetBidiEnabled() const { Document()->SetBidiEnabled(); }
|
||||
|
@ -355,7 +355,7 @@ class nsPresContext : public nsISupports,
|
||||
|
||||
nsISupports* GetContainerWeak() const;
|
||||
|
||||
nsIDocShell* GetDocShell() const;
|
||||
nsDocShell* GetDocShell() const;
|
||||
|
||||
/**
|
||||
* Get the visible area associated with this presentation context.
|
||||
|
21
layout/generic/ScrollbarPreferences.h
Normal file
21
layout/generic/ScrollbarPreferences.h
Normal file
@ -0,0 +1,21 @@
|
||||
/* -*- 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 mozilla_ScrollbarPreferences_h
|
||||
#define mozilla_ScrollbarPreferences_h
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
enum class ScrollbarPreference : uint8_t {
|
||||
Auto,
|
||||
Never,
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
#endif
|
@ -147,6 +147,7 @@ EXPORTS.mozilla += [
|
||||
'CSSOrderAwareFrameIterator.h',
|
||||
'ReflowInput.h',
|
||||
'ReflowOutput.h',
|
||||
'ScrollbarPreferences.h',
|
||||
'ViewportFrame.h',
|
||||
'WritingModes.h',
|
||||
]
|
||||
|
@ -16,7 +16,6 @@
|
||||
#include "nsPresContext.h"
|
||||
#include "nsView.h"
|
||||
#include "nsViewportInfo.h"
|
||||
#include "nsIScrollable.h"
|
||||
#include "nsContainerFrame.h"
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsNameSpaceManager.h"
|
||||
@ -37,10 +36,12 @@
|
||||
#include "nsLayoutUtils.h"
|
||||
#include "nsBidiPresUtils.h"
|
||||
#include "nsBidiUtils.h"
|
||||
#include "nsDocShell.h"
|
||||
#include "mozilla/ContentEvents.h"
|
||||
#include "mozilla/EventDispatcher.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/PresShell.h"
|
||||
#include "mozilla/ScrollbarPreferences.h"
|
||||
#include "mozilla/LookAndFeel.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/dom/Event.h"
|
||||
@ -4070,23 +4071,6 @@ bool ScrollFrameHelper::IsRectNearlyVisible(const nsRect& aRect) const {
|
||||
ExpandRectToNearlyVisible(usingDisplayport ? displayPort : mScrollPort));
|
||||
}
|
||||
|
||||
static void HandleScrollPref(nsIScrollable* aScrollable, int32_t aOrientation,
|
||||
StyleOverflow& aValue) {
|
||||
int32_t pref;
|
||||
aScrollable->GetDefaultScrollbarPreferences(aOrientation, &pref);
|
||||
switch (pref) {
|
||||
case nsIScrollable::Scrollbar_Auto:
|
||||
// leave |aValue| untouched
|
||||
break;
|
||||
case nsIScrollable::Scrollbar_Never:
|
||||
aValue = StyleOverflow::Hidden;
|
||||
break;
|
||||
case nsIScrollable::Scrollbar_Always:
|
||||
aValue = StyleOverflow::Scroll;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
OverscrollBehaviorInfo ScrollFrameHelper::GetOverscrollBehaviorInfo() const {
|
||||
nsIFrame* frame = GetFrameForStyle();
|
||||
if (!frame) {
|
||||
@ -4110,13 +4094,14 @@ ScrollStyles ScrollFrameHelper::GetScrollStylesFromFrame() const {
|
||||
}
|
||||
|
||||
ScrollStyles result = presContext->GetViewportScrollStylesOverride();
|
||||
nsCOMPtr<nsISupports> container = presContext->GetContainerWeak();
|
||||
nsCOMPtr<nsIScrollable> scrollable = do_QueryInterface(container);
|
||||
if (scrollable) {
|
||||
HandleScrollPref(scrollable, nsIScrollable::ScrollOrientation_X,
|
||||
result.mHorizontal);
|
||||
HandleScrollPref(scrollable, nsIScrollable::ScrollOrientation_Y,
|
||||
result.mVertical);
|
||||
if (nsDocShell* ds = presContext->GetDocShell()) {
|
||||
switch (ds->ScrollbarPreference()) {
|
||||
case ScrollbarPreference::Auto:
|
||||
break;
|
||||
case ScrollbarPreference::Never:
|
||||
result.mHorizontal = result.mVertical = StyleOverflow::Hidden;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -34,7 +34,6 @@
|
||||
#include "nsStyleStruct.h"
|
||||
#include "nsStyleStructInlines.h"
|
||||
#include "nsFrameSetFrame.h"
|
||||
#include "nsIScrollable.h"
|
||||
#include "nsNameSpaceManager.h"
|
||||
#include "nsDisplayList.h"
|
||||
#include "nsIScrollableFrame.h"
|
||||
@ -193,10 +192,10 @@ void nsSubDocumentFrame::ShowViewer() {
|
||||
mCallingShow = true;
|
||||
const nsAttrValue* attrValue =
|
||||
GetContent()->AsElement()->GetParsedAttr(nsGkAtoms::scrolling);
|
||||
int32_t scrolling =
|
||||
ScrollbarPreference scrolling =
|
||||
nsGenericHTMLFrameElement::MapScrollingAttribute(attrValue);
|
||||
bool didCreateDoc = frameloader->Show(margin.width, margin.height,
|
||||
scrolling, scrolling, this);
|
||||
bool didCreateDoc =
|
||||
frameloader->Show(margin.width, margin.height, scrolling, this);
|
||||
if (!weakThis.IsAlive()) {
|
||||
return;
|
||||
}
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
#include "nsPresContext.h"
|
||||
#include "nsFrameManager.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsDocShell.h"
|
||||
#include "nsIDocShellTreeOwner.h"
|
||||
#include "nsIBaseWindow.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
|
@ -209,15 +209,13 @@ NS_IMPL_CYCLE_COLLECTING_ADDREF(nsWebBrowser)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsWebBrowser)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION(nsWebBrowser, mDocShell, mDocShellAsReq,
|
||||
mDocShellAsWin, mDocShellAsNav, mDocShellAsScrollable,
|
||||
mWebProgress)
|
||||
mDocShellAsWin, mDocShellAsNav, mWebProgress)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsWebBrowser)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIWebBrowser)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIWebBrowser)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIWebNavigation)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIBaseWindow)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIScrollable)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDocShellTreeItem)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIWebBrowserPersist)
|
||||
@ -1154,37 +1152,6 @@ nsWebBrowser::SetTitle(const nsAString& aTitle) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
// nsWebBrowser::nsIScrollable
|
||||
//*****************************************************************************
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWebBrowser::GetDefaultScrollbarPreferences(int32_t aScrollOrientation,
|
||||
int32_t* aScrollbarPref) {
|
||||
NS_ENSURE_STATE(mDocShell);
|
||||
|
||||
return mDocShellAsScrollable->GetDefaultScrollbarPreferences(
|
||||
aScrollOrientation, aScrollbarPref);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWebBrowser::SetDefaultScrollbarPreferences(int32_t aScrollOrientation,
|
||||
int32_t aScrollbarPref) {
|
||||
NS_ENSURE_STATE(mDocShell);
|
||||
|
||||
return mDocShellAsScrollable->SetDefaultScrollbarPreferences(
|
||||
aScrollOrientation, aScrollbarPref);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWebBrowser::GetScrollbarVisibility(bool* aVerticalVisible,
|
||||
bool* aHorizontalVisible) {
|
||||
NS_ENSURE_STATE(mDocShell);
|
||||
|
||||
return mDocShellAsScrollable->GetScrollbarVisibility(aVerticalVisible,
|
||||
aHorizontalVisible);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
// nsWebBrowser: Listener Helpers
|
||||
//*****************************************************************************
|
||||
@ -1202,16 +1169,13 @@ nsWebBrowser::SetDocShell(nsIDocShell* aDocShell) {
|
||||
nsCOMPtr<nsIInterfaceRequestor> req(do_QueryInterface(aDocShell));
|
||||
nsCOMPtr<nsIBaseWindow> baseWin(do_QueryInterface(aDocShell));
|
||||
nsCOMPtr<nsIWebNavigation> nav(do_QueryInterface(aDocShell));
|
||||
nsCOMPtr<nsIScrollable> scrollable(do_QueryInterface(aDocShell));
|
||||
nsCOMPtr<nsIWebProgress> progress(do_GetInterface(aDocShell));
|
||||
NS_ENSURE_TRUE(req && baseWin && nav && scrollable && progress,
|
||||
NS_ERROR_FAILURE);
|
||||
NS_ENSURE_TRUE(req && baseWin && nav && progress, NS_ERROR_FAILURE);
|
||||
|
||||
mDocShell = aDocShell;
|
||||
mDocShellAsReq = req;
|
||||
mDocShellAsWin = baseWin;
|
||||
mDocShellAsNav = nav;
|
||||
mDocShellAsScrollable = scrollable;
|
||||
mWebProgress = progress;
|
||||
|
||||
// By default, do not allow DNS prefetch, so we don't break our frozen
|
||||
@ -1229,7 +1193,6 @@ nsWebBrowser::SetDocShell(nsIDocShell* aDocShell) {
|
||||
mDocShellAsReq = nullptr;
|
||||
mDocShellAsWin = nullptr;
|
||||
mDocShellAsNav = nullptr;
|
||||
mDocShellAsScrollable = nullptr;
|
||||
mWebProgress = nullptr;
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,6 @@
|
||||
#include "nsIDocShellTreeItem.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsIInterfaceRequestorUtils.h"
|
||||
#include "nsIScrollable.h"
|
||||
#include "nsIWidget.h"
|
||||
#include "nsIWebProgress.h"
|
||||
#include "nsIWebBrowser.h"
|
||||
@ -66,7 +65,6 @@ class nsWebBrowser final : public nsIWebBrowser,
|
||||
public nsIWebNavigation,
|
||||
public nsIDocShellTreeItem,
|
||||
public nsIBaseWindow,
|
||||
public nsIScrollable,
|
||||
public nsIInterfaceRequestor,
|
||||
public nsIWebBrowserPersist,
|
||||
public nsIWebProgressListener,
|
||||
@ -98,7 +96,6 @@ class nsWebBrowser final : public nsIWebBrowser,
|
||||
NS_DECL_NSIBASEWINDOW
|
||||
NS_DECL_NSIDOCSHELLTREEITEM
|
||||
NS_DECL_NSIINTERFACEREQUESTOR
|
||||
NS_DECL_NSISCROLLABLE
|
||||
NS_DECL_NSIWEBBROWSER
|
||||
NS_DECL_NSIWEBNAVIGATION
|
||||
NS_DECL_NSIWEBBROWSERPERSIST
|
||||
@ -141,7 +138,6 @@ class nsWebBrowser final : public nsIWebBrowser,
|
||||
nsCOMPtr<nsIInterfaceRequestor> mDocShellAsReq;
|
||||
nsCOMPtr<nsIBaseWindow> mDocShellAsWin;
|
||||
nsCOMPtr<nsIWebNavigation> mDocShellAsNav;
|
||||
nsCOMPtr<nsIScrollable> mDocShellAsScrollable;
|
||||
mozilla::OriginAttributes mOriginAttributes;
|
||||
|
||||
nsCOMPtr<nsIWidget> mInternalWidget;
|
||||
|
@ -35,7 +35,6 @@
|
||||
#include "nsIWindowMediator.h"
|
||||
#include "nsIScreenManager.h"
|
||||
#include "nsIScreen.h"
|
||||
#include "nsIScrollable.h"
|
||||
#include "nsIWindowWatcher.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsAppShellCID.h"
|
||||
@ -2443,21 +2442,14 @@ void AppWindow::SetContentScrollbarVisibility(bool aVisible) {
|
||||
}
|
||||
|
||||
bool AppWindow::GetContentScrollbarVisibility() {
|
||||
// This code already exists in dom/src/base/nsBarProp.cpp, but we
|
||||
// can't safely get to that from here as this function is called
|
||||
// while the DOM window is being set up, and we need the DOM window
|
||||
// to get to that code.
|
||||
nsCOMPtr<nsIScrollable> scroller(do_QueryInterface(mPrimaryContentShell));
|
||||
|
||||
if (scroller) {
|
||||
int32_t prefValue;
|
||||
scroller->GetDefaultScrollbarPreferences(nsIScrollable::ScrollOrientation_Y,
|
||||
&prefValue);
|
||||
if (prefValue == nsIScrollable::Scrollbar_Never) // try the other way
|
||||
scroller->GetDefaultScrollbarPreferences(
|
||||
nsIScrollable::ScrollOrientation_X, &prefValue);
|
||||
|
||||
if (prefValue == nsIScrollable::Scrollbar_Never) return false;
|
||||
// This code already exists in dom/src/base/nsBarProp.cpp, but we can't safely
|
||||
// get to that from here as this function is called while the DOM window is
|
||||
// being set up, and we need the DOM window to get to that code.
|
||||
//
|
||||
// FIXME(emilio): This doesn't work at all for e10s or anything like that,
|
||||
// it's likely that nobody is relying on this function.
|
||||
if (nsCOMPtr<nsIDocShell> ds = do_QueryInterface(mPrimaryContentShell)) {
|
||||
return nsDocShell::Cast(ds)->ScrollbarPreference() != ScrollbarPreference::Never;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user