author | David Anderson <danderson@mozilla.com> |
Sun, 12 Apr 2015 23:03:02 -0400 | |
changeset 238683 | 8c2cb069b031e5483a79135237e67c46c7d9d702 |
parent 238682 | 1c76e0af5ed2e65b7af24a8eb3df963851c3a987 |
child 238684 | 0d51d7946a032369086869c600f49aa3d25f0b20 |
push id | 58315 |
push user | danderson@mozilla.com |
push date | Mon, 13 Apr 2015 03:04:28 +0000 |
treeherder | mozilla-inbound@8c2cb069b031 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | botond, mstange |
bugs | 1152469 |
milestone | 40.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/gfx/layers/Layers.cpp +++ b/gfx/layers/Layers.cpp @@ -203,16 +203,17 @@ Layer::Layer(LayerManager* aManager, voi mContentFlags(0), mUseClipRect(false), mUseTileSourceRect(false), mIsFixedPosition(false), mMargins(0, 0, 0, 0), mStickyPositionData(nullptr), mScrollbarTargetId(FrameMetrics::NULL_SCROLL_ID), mScrollbarDirection(ScrollDirection::NONE), + mScrollbarThumbRatio(0.0f), mIsScrollbarContainer(false), mDebugColorIndex(0), mAnimationGeneration(0) {} Layer::~Layer() {}
--- a/gfx/layers/Layers.h +++ b/gfx/layers/Layers.h @@ -1196,23 +1196,26 @@ public: HORIZONTAL }; /** * CONSTRUCTION PHASE ONLY * If a layer is a scrollbar layer, |aScrollId| holds the scroll identifier * of the scrollable content that the scrollbar is for. */ - void SetScrollbarData(FrameMetrics::ViewID aScrollId, ScrollDirection aDir) + void SetScrollbarData(FrameMetrics::ViewID aScrollId, ScrollDirection aDir, float aThumbRatio) { if (mScrollbarTargetId != aScrollId || - mScrollbarDirection != aDir) { + mScrollbarDirection != aDir || + mScrollbarThumbRatio != aThumbRatio) + { MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) ScrollbarData", this)); mScrollbarTargetId = aScrollId; mScrollbarDirection = aDir; + mScrollbarThumbRatio = aThumbRatio; Mutated(); } } // Set during construction for the container layer of scrollbar components. void SetIsScrollbarContainer() { if (!mIsScrollbarContainer) { @@ -1250,16 +1253,17 @@ public: bool GetIsStickyPosition() { return mStickyPositionData; } LayerPoint GetFixedPositionAnchor() { return mAnchor; } const LayerMargin& GetFixedPositionMargins() { return mMargins; } FrameMetrics::ViewID GetStickyScrollContainerId() { return mStickyPositionData->mScrollId; } const LayerRect& GetStickyScrollRangeOuter() { return mStickyPositionData->mOuter; } const LayerRect& GetStickyScrollRangeInner() { return mStickyPositionData->mInner; } FrameMetrics::ViewID GetScrollbarTargetContainerId() { return mScrollbarTargetId; } ScrollDirection GetScrollbarDirection() { return mScrollbarDirection; } + float GetScrollbarThumbRatio() { return mScrollbarThumbRatio; } bool IsScrollbarContainer() { return mIsScrollbarContainer; } Layer* GetMaskLayer() const { return mMaskLayer; } /** * Retrieve the root level visible region for |this| taking into account * clipping applied to parent layers of |this| as well as subtracting * visible regions of higher siblings of this layer and each ancestor. @@ -1709,16 +1713,18 @@ protected: struct StickyPositionData { FrameMetrics::ViewID mScrollId; LayerRect mOuter; LayerRect mInner; }; nsAutoPtr<StickyPositionData> mStickyPositionData; FrameMetrics::ViewID mScrollbarTargetId; ScrollDirection mScrollbarDirection; + float mScrollbarThumbRatio; // Ratio of the thumb position to the scroll + // position, in app units. bool mIsScrollbarContainer; DebugOnly<uint32_t> mDebugColorIndex; // If this layer is used for OMTA, then this counter is used to ensure we // stay in sync with the animation manager uint64_t mAnimationGeneration; #ifdef MOZ_DUMP_PAINTING nsTArray<nsCString> mExtraDumpInfo; #endif
--- a/gfx/layers/composite/AsyncCompositionManager.cpp +++ b/gfx/layers/composite/AsyncCompositionManager.cpp @@ -731,23 +731,18 @@ ApplyAsyncTransformToScrollbarForContent // Note: |metrics.GetZoom()| doesn't yet include the async zoom, so // |metrics.CalculateCompositedSizeInCssPixels()| would not give a correct // result. const CSSToParentLayerScale effectiveZoom(metrics.GetZoom().yScale * asyncZoomY); const CSSCoord compositedHeight = (metrics.mCompositionBounds / effectiveZoom).height; const CSSCoord scrollableHeight = metrics.GetScrollableRect().height; - // The scroll thumb needs to be translated in opposite direction of the - // async scroll. This is because scrolling down, which translates the layer - // content up, should result in moving the scroll thumb down. - // The amount of the translation should be such that the ratio of the - // translation to the size of the scroll port is the same as the ratio of - // the scroll amount of the size of the scrollable rect. - const float ratio = compositedHeight / scrollableHeight; + // The scrollbar thumb ratio is in AppUnits. + const float ratio = aScrollbar->GetScrollbarThumbRatio(); ParentLayerCoord yTranslation = -asyncScrollY * ratio; // The scroll thumb additionally needs to be translated to compensate for // the scale applied above. The origin with respect to which the scale is // applied is the origin of the entire scrollbar, rather than the origin of // the scroll thumb (meaning, for a vertical scrollbar it's at the top of // the composition bounds). This means that empty space above the thumb // is scaled too, effectively translating the thumb. We undo that @@ -783,17 +778,18 @@ ApplyAsyncTransformToScrollbarForContent const float asyncZoomX = asyncTransform._11; const float xScale = 1.f / asyncZoomX; const CSSToParentLayerScale effectiveZoom(metrics.GetZoom().xScale * asyncZoomX); const CSSCoord compositedWidth = (metrics.mCompositionBounds / effectiveZoom).width; const CSSCoord scrollableWidth = metrics.GetScrollableRect().width; - const float ratio = compositedWidth / scrollableWidth; + // The scrollbar thumb ratio is in AppUnits. + const float ratio = aScrollbar->GetScrollbarThumbRatio(); ParentLayerCoord xTranslation = -asyncScrollX * ratio; const CSSCoord thumbOrigin = (metrics.GetScrollOffset().x / scrollableWidth) * compositedWidth; const CSSCoord thumbOriginScaled = thumbOrigin * xScale; const CSSCoord thumbOriginDelta = thumbOriginScaled - thumbOrigin; const ParentLayerCoord thumbOriginDeltaPL = thumbOriginDelta * effectiveZoom; xTranslation -= thumbOriginDeltaPL;
--- a/gfx/layers/ipc/LayerTransactionParent.cpp +++ b/gfx/layers/ipc/LayerTransactionParent.cpp @@ -334,17 +334,18 @@ LayerTransactionParent::RecvUpdate(Infal layer->SetFixedPositionAnchor(common.fixedPositionAnchor()); layer->SetFixedPositionMargins(common.fixedPositionMargin()); if (common.isStickyPosition()) { layer->SetStickyPositionData(common.stickyScrollContainerId(), common.stickyScrollRangeOuter(), common.stickyScrollRangeInner()); } layer->SetScrollbarData(common.scrollbarTargetContainerId(), - static_cast<Layer::ScrollDirection>(common.scrollbarDirection())); + static_cast<Layer::ScrollDirection>(common.scrollbarDirection()), + common.scrollbarThumbRatio()); layer->SetMixBlendMode((gfx::CompositionOp)common.mixBlendMode()); layer->SetForceIsolatedGroup(common.forceIsolatedGroup()); if (PLayerParent* maskLayer = common.maskLayerParent()) { layer->SetMaskLayer(cast(maskLayer)->AsLayer()); } else { layer->SetMaskLayer(nullptr); } layer->SetAnimations(common.animations());
--- a/gfx/layers/ipc/LayersMessages.ipdlh +++ b/gfx/layers/ipc/LayersMessages.ipdlh @@ -209,16 +209,17 @@ struct CommonLayerAttributes { LayerPoint fixedPositionAnchor; LayerMargin fixedPositionMargin; bool isStickyPosition; uint64_t stickyScrollContainerId; LayerRect stickyScrollRangeOuter; LayerRect stickyScrollRangeInner; uint64_t scrollbarTargetContainerId; uint32_t scrollbarDirection; + float scrollbarThumbRatio; int8_t mixBlendMode; bool forceIsolatedGroup; nullable PLayer maskLayer; // Animated colors will only honored for ColorLayers. Animation[] animations; nsIntRegion invalidRegion; FrameMetrics[] metrics; string contentDescription;
--- a/gfx/layers/ipc/ShadowLayers.cpp +++ b/gfx/layers/ipc/ShadowLayers.cpp @@ -602,16 +602,17 @@ ShadowLayerForwarder::EndTransaction(Inf // to another process. common.stickyScrollContainerId() = 0; common.stickyScrollRangeOuter() = LayerRect(); common.stickyScrollRangeInner() = LayerRect(); #endif } common.scrollbarTargetContainerId() = mutant->GetScrollbarTargetContainerId(); common.scrollbarDirection() = mutant->GetScrollbarDirection(); + common.scrollbarThumbRatio() = mutant->GetScrollbarThumbRatio(); common.mixBlendMode() = (int8_t)mutant->GetMixBlendMode(); common.forceIsolatedGroup() = mutant->GetForceIsolatedGroup(); if (Layer* maskLayer = mutant->GetMaskLayer()) { common.maskLayerChild() = Shadow(maskLayer->AsShadowableLayer()); } else { common.maskLayerChild() = nullptr; } common.maskLayerParent() = nullptr;
--- a/layout/base/nsDisplayList.cpp +++ b/layout/base/nsDisplayList.cpp @@ -4163,43 +4163,47 @@ bool nsDisplayBlendContainer::TryMerge(n if (aItem->GetClip() != GetClip()) return false; MergeFromTrackingMergedFrames(static_cast<nsDisplayBlendContainer*>(aItem)); return true; } nsDisplayOwnLayer::nsDisplayOwnLayer(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame, nsDisplayList* aList, - uint32_t aFlags, ViewID aScrollTarget) + uint32_t aFlags, ViewID aScrollTarget, + float aScrollbarThumbRatio) : nsDisplayWrapList(aBuilder, aFrame, aList) , mFlags(aFlags) - , mScrollTarget(aScrollTarget) { + , mScrollTarget(aScrollTarget) + , mScrollbarThumbRatio(aScrollbarThumbRatio) +{ MOZ_COUNT_CTOR(nsDisplayOwnLayer); } #ifdef NS_BUILD_REFCNT_LOGGING nsDisplayOwnLayer::~nsDisplayOwnLayer() { MOZ_COUNT_DTOR(nsDisplayOwnLayer); } #endif // nsDisplayOpacity uses layers for rendering already_AddRefed<Layer> nsDisplayOwnLayer::BuildLayer(nsDisplayListBuilder* aBuilder, LayerManager* aManager, - const ContainerLayerParameters& aContainerParameters) { + const ContainerLayerParameters& aContainerParameters) +{ nsRefPtr<ContainerLayer> layer = aManager->GetLayerBuilder()-> BuildContainerLayerFor(aBuilder, aManager, mFrame, this, &mList, aContainerParameters, nullptr, FrameLayerBuilder::CONTAINER_ALLOW_PULL_BACKGROUND_COLOR); if (mFlags & VERTICAL_SCROLLBAR) { - layer->SetScrollbarData(mScrollTarget, Layer::ScrollDirection::VERTICAL); + layer->SetScrollbarData(mScrollTarget, Layer::ScrollDirection::VERTICAL, mScrollbarThumbRatio); } if (mFlags & HORIZONTAL_SCROLLBAR) { - layer->SetScrollbarData(mScrollTarget, Layer::ScrollDirection::HORIZONTAL); + layer->SetScrollbarData(mScrollTarget, Layer::ScrollDirection::HORIZONTAL, mScrollbarThumbRatio); } if (mFlags & SCROLLBAR_CONTAINER) { layer->SetIsScrollbarContainer(); } if (mFlags & GENERATE_SUBDOC_INVALIDATIONS) { mFrame->PresContext()->SetNotifySubDocInvalidationData(layer); }
--- a/layout/base/nsDisplayList.h +++ b/layout/base/nsDisplayList.h @@ -3057,17 +3057,18 @@ public: * subclasses), indicates this layer is to be a scrollable layer, so call * ComputeFrameMetrics, etc. * @param aScrollTarget when VERTICAL_SCROLLBAR or HORIZONTAL_SCROLLBAR * is set in the flags, this parameter should be the ViewID of the * scrollable content this scrollbar is for. */ nsDisplayOwnLayer(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame, nsDisplayList* aList, uint32_t aFlags = 0, - ViewID aScrollTarget = mozilla::layers::FrameMetrics::NULL_SCROLL_ID); + ViewID aScrollTarget = mozilla::layers::FrameMetrics::NULL_SCROLL_ID, + float aScrollbarThumbRatio = 0.0f); #ifdef NS_BUILD_REFCNT_LOGGING virtual ~nsDisplayOwnLayer(); #endif virtual already_AddRefed<Layer> BuildLayer(nsDisplayListBuilder* aBuilder, LayerManager* aManager, const ContainerLayerParameters& aContainerParameters) override; virtual LayerState GetLayerState(nsDisplayListBuilder* aBuilder, @@ -3084,16 +3085,17 @@ public: virtual bool ShouldFlattenAway(nsDisplayListBuilder* aBuilder) override { return false; } uint32_t GetFlags() { return mFlags; } NS_DISPLAY_DECL_NAME("OwnLayer", TYPE_OWN_LAYER) protected: uint32_t mFlags; ViewID mScrollTarget; + float mScrollbarThumbRatio; }; /** * A display item for subdocuments. This is more or less the same as nsDisplayOwnLayer, * except that it always populates the FrameMetrics instance on the ContainerLayer it * builds. */ class nsDisplaySubDocument : public nsDisplayOwnLayer {
--- a/layout/xul/nsBoxFrame.cpp +++ b/layout/xul/nsBoxFrame.cpp @@ -61,16 +61,17 @@ #include "nsITheme.h" #include "nsTransform2D.h" #include "mozilla/EventStateManager.h" #include "nsIDOMEvent.h" #include "nsDisplayList.h" #include "mozilla/Preferences.h" #include "nsThemeConstants.h" #include "nsLayoutUtils.h" +#include "nsSliderFrame.h" #include <algorithm> // Needed for Print Preview #include "nsIURI.h" #include "mozilla/TouchEvents.h" using namespace mozilla; @@ -1307,27 +1308,31 @@ void nsBoxFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, const nsRect& aDirtyRect, const nsDisplayListSet& aLists) { bool forceLayer = false; uint32_t flags = 0; mozilla::layers::FrameMetrics::ViewID scrollTargetId = mozilla::layers::FrameMetrics::NULL_SCROLL_ID; + float scrollbarThumbRatio = 0.0f; if (GetContent()->IsXULElement()) { // forcelayer is only supported on XUL elements with box layout if (GetContent()->HasAttr(kNameSpaceID_None, nsGkAtoms::layer)) { forceLayer = true; } else { nsIFrame* parent = GetParentBox(this); if (parent && parent->GetType() == nsGkAtoms::sliderFrame) { aBuilder->GetScrollbarInfo(&scrollTargetId, &flags); forceLayer = (scrollTargetId != layers::FrameMetrics::NULL_SCROLL_ID); nsLayoutUtils::SetScrollbarThumbLayerization(this, forceLayer); + + nsSliderFrame* slider = do_QueryFrame(parent); + scrollbarThumbRatio = slider->GetThumbRatio(); } } // Check for frames that are marked as a part of the region used // in calculating glass margins on Windows. const nsStyleDisplay* styles = StyleDisplay(); if (styles && styles->mAppearance == NS_THEME_WIN_EXCLUDE_GLASS) { aBuilder->AddWindowExcludeGlassRegion( nsRect(aBuilder->ToReferenceFrame(this), GetSize())); @@ -1364,17 +1369,18 @@ nsBoxFrame::BuildDisplayList(nsDisplayLi masterList.AppendToTop(tempLists.BlockBorderBackgrounds()); masterList.AppendToTop(tempLists.Floats()); masterList.AppendToTop(tempLists.Content()); masterList.AppendToTop(tempLists.PositionedDescendants()); masterList.AppendToTop(tempLists.Outlines()); // Wrap the list to make it its own layer aLists.Content()->AppendNewToTop(new (aBuilder) - nsDisplayOwnLayer(aBuilder, this, &masterList, flags, scrollTargetId)); + nsDisplayOwnLayer(aBuilder, this, &masterList, flags, scrollTargetId, + scrollbarThumbRatio)); } } void nsBoxFrame::BuildDisplayListForChildren(nsDisplayListBuilder* aBuilder, const nsRect& aDirtyRect, const nsDisplayListSet& aLists) {
--- a/layout/xul/nsSliderFrame.cpp +++ b/layout/xul/nsSliderFrame.cpp @@ -1272,10 +1272,18 @@ nsSliderFrame::PageScroll(nscoord aChang if (m) { m->ScrollByPage(sb, aChange, nsIScrollbarMediator::ENABLE_SNAP); return; } } PageUpDown(aChange); } +float +nsSliderFrame::GetThumbRatio() const +{ + // mRatio is in thumb app units per scrolled css pixels. Convert it to a + // a true unitless ratio. + return mRatio / mozilla::AppUnitsPerCSSPixel(); +} + NS_IMPL_ISUPPORTS(nsSliderMediator, nsIDOMEventListener)
--- a/layout/xul/nsSliderFrame.h +++ b/layout/xul/nsSliderFrame.h @@ -127,16 +127,20 @@ public: { return NS_OK; } NS_IMETHOD HandleRelease(nsPresContext* aPresContext, mozilla::WidgetGUIEvent* aEvent, nsEventStatus* aEventStatus) override; + // Return the ratio the scrollbar thumb should move in proportion to the + // scrolled frame. + float GetThumbRatio() const; + private: bool GetScrollToClick(); nsIFrame* GetScrollbar(); bool ShouldScrollForEvent(mozilla::WidgetGUIEvent* aEvent); bool ShouldScrollToClickForEvent(mozilla::WidgetGUIEvent* aEvent); bool IsEventOverThumb(mozilla::WidgetGUIEvent* aEvent);