From 22056382c062bddd0246a378c3f35042c80ec15a Mon Sep 17 00:00:00 2001 From: Hiroyuki Ikezoe Date: Wed, 28 Nov 2018 00:58:46 +0000 Subject: [PATCH 01/13] Bug 1504065 - Run background-color animations on the compositor. r=birtles Changes for nsIDOMWindowUtils.getOMTAValue is in the next commit with come test cases. Differential Revision: https://phabricator.services.mozilla.com/D13001 --HG-- extra : moz-landing-system : lando --- dom/animation/KeyframeEffect.cpp | 17 +++++++ .../chrome/test_running_on_compositor.html | 40 ++++++++++++++++- dom/animation/test/mochitest.ini | 1 + gfx/layers/AnimationHelper.cpp | 15 +++++-- .../composite/AsyncCompositionManager.cpp | 36 ++++++++++----- gfx/layers/ipc/LayersMessages.ipdlh | 2 + layout/painting/nsDisplayList.cpp | 39 +++++++++++++++- layout/painting/nsDisplayList.h | 2 + layout/style/LayerAnimationInfo.cpp | 3 ++ layout/style/LayerAnimationInfo.h | 6 +++ layout/style/ServoBindings.h | 5 +++ layout/style/StyleAnimationValue.cpp | 7 +++ layout/style/StyleAnimationValue.h | 4 ++ modules/libpref/init/StaticPrefList.h | 12 +++++ .../properties/longhands/background.mako.rs | 3 +- servo/ports/geckolib/glue.rs | 45 +++++++++++++++++++ 16 files changed, 220 insertions(+), 17 deletions(-) diff --git a/dom/animation/KeyframeEffect.cpp b/dom/animation/KeyframeEffect.cpp index bf758bab3f8f..472a1006d62e 100644 --- a/dom/animation/KeyframeEffect.cpp +++ b/dom/animation/KeyframeEffect.cpp @@ -1894,6 +1894,23 @@ KeyframeEffect::IsMatchForCompositor( return KeyframeEffect::MatchForCompositor::NoAndBlockThisProperty; } + if (aProperty == eCSSProperty_background_color) { + if (!StaticPrefs::gfx_omta_background_color()) { + return KeyframeEffect::MatchForCompositor::No; + } + + if (nsIContent* content = aFrame->GetContent()) { + RefPtr layerManager = + nsContentUtils::LayerManagerForContent(content); + if (layerManager && + layerManager->GetBackendType() == layers::LayersBackend::LAYERS_WR) { + // Bug 1510030: We don't yet support background-color animations on the + // compositor for WebRender. + return KeyframeEffect::MatchForCompositor::No; + } + } + } + return mAnimation->IsPlaying() ? KeyframeEffect::MatchForCompositor::Yes : KeyframeEffect::MatchForCompositor::IfNeeded; diff --git a/dom/animation/test/chrome/test_running_on_compositor.html b/dom/animation/test/chrome/test_running_on_compositor.html index a0a67ca0955a..7bc948ef687f 100644 --- a/dom/animation/test/chrome/test_running_on_compositor.html +++ b/dom/animation/test/chrome/test_running_on_compositor.html @@ -50,7 +50,9 @@ div { /** Test for bug 1045994 - Add a chrome-only property to inspect if an animation is running on the compositor or not **/ -var omtaEnabled = isOMTAEnabled(); +const omtaEnabled = isOMTAEnabled(); +const isWebRender = + SpecialPowers.DOMWindowUtils.layerManagerType == 'WebRender'; function assert_animation_is_running_on_compositor(animation, desc) { assert_equals(animation.isRunningOnCompositor, omtaEnabled, @@ -988,5 +990,41 @@ promise_test(async t => { 'Transform animation on table element should be running on the compositor'); }, 'Transform animation on table element runs on the compositor'); +promise_test(async t => { + const div = addDiv(t); + const animation = div.animate({ backgroundColor: ['blue', 'green'] }, + 100 * MS_PER_SEC); + + await waitForAnimationReadyToRestyle(animation); + await waitForPaints(); + + if (!isWebRender) { + assert_animation_is_running_on_compositor(animation, + 'background-color animation should be running on the compositor'); + } else { + assert_animation_is_not_running_on_compositor(animation, + 'background-color animation is not yet able to run on the compositor ' + + 'on WebRender'); + } +}, 'backgound-color animation runs on the compositor'); + +promise_test(async t => { + await SpecialPowers.pushPrefEnv({ + set: [["gfx.omta.background-color", false]] + }); + + const div = addDiv(t); + const animation = div.animate({ backgroundColor: ['blue', 'green'] }, + 100 * MS_PER_SEC); + + await waitForAnimationReadyToRestyle(animation); + await waitForPaints(); + + assert_animation_is_not_running_on_compositor(animation, + 'background-color animation should NOT be running on the compositor ' + + 'if the pref is disabled'); +}, 'backgound-color animation does not run on the compositor if the pref ' + + 'is disabled'); + diff --git a/dom/animation/test/mochitest.ini b/dom/animation/test/mochitest.ini index 7a40e2463958..abde89be5c24 100644 --- a/dom/animation/test/mochitest.ini +++ b/dom/animation/test/mochitest.ini @@ -5,6 +5,7 @@ prefs = dom.animations-api.getAnimations.enabled=true dom.animations-api.implicit-keyframes.enabled=true dom.animations-api.timelines.enabled=true + gfx.omta.background-color=true layout.css.motion-path.enabled=true layout.css.individual-transform.enabled=true # Support files for chrome tests that we want to load over HTTP need diff --git a/gfx/layers/AnimationHelper.cpp b/gfx/layers/AnimationHelper.cpp index ab189b7e1640..4e60088ad321 100644 --- a/gfx/layers/AnimationHelper.cpp +++ b/gfx/layers/AnimationHelper.cpp @@ -519,7 +519,7 @@ CreateCSSValueList(const InfallibleTArray& aFunctions) } static already_AddRefed -ToAnimationValue(const Animatable& aAnimatable) +ToAnimationValue(nsCSSPropertyID aProperty, const Animatable& aAnimatable) { RefPtr result; @@ -540,6 +540,10 @@ ToAnimationValue(const Animatable& aAnimatable) case Animatable::Tfloat: result = Servo_AnimationValue_Opacity(aAnimatable.get_float()).Consume(); break; + case Animatable::Tnscolor: + result = Servo_AnimationValue_Color(aProperty, + aAnimatable.get_nscolor()).Consume(); + break; default: MOZ_ASSERT_UNREACHABLE("Unsupported type"); } @@ -580,7 +584,8 @@ AnimationHelper::SetAnimations( } if (animation.baseStyle().type() != Animatable::Tnull_t) { - aBaseAnimationStyle = ToAnimationValue(animation.baseStyle()); + aBaseAnimationStyle = ToAnimationValue(animation.property(), + animation.baseStyle()); } AnimData* data = aAnimData.AppendElement(); @@ -605,8 +610,10 @@ AnimationHelper::SetAnimations( const InfallibleTArray& segments = animation.segments(); for (const AnimationSegment& segment : segments) { - startValues.AppendElement(ToAnimationValue(segment.startState())); - endValues.AppendElement(ToAnimationValue(segment.endState())); + startValues.AppendElement(ToAnimationValue(animation.property(), + segment.startState())); + endValues.AppendElement(ToAnimationValue(animation.property(), + segment.endState())); TimingFunction tf = segment.sampleFn(); Maybe ctf = diff --git a/gfx/layers/composite/AsyncCompositionManager.cpp b/gfx/layers/composite/AsyncCompositionManager.cpp index 60c89dc1945d..754a84cfb877 100644 --- a/gfx/layers/composite/AsyncCompositionManager.cpp +++ b/gfx/layers/composite/AsyncCompositionManager.cpp @@ -633,6 +633,19 @@ ApplyAnimatedValue(Layer* aLayer, HostLayer* layerCompositor = aLayer->AsHostLayer(); switch (aProperty) { + case eCSSProperty_background_color: { + // We don't support 'color' animations on the compositor yet so we never + // meet currentColor on the compositor. + nscolor color = Servo_AnimationValue_GetColor(aValue, NS_RGBA(0, 0, 0, 0)); + aLayer->AsColorLayer()->SetColor(gfx::Color::FromABGR(color)); + aStorage->SetAnimatedValue(aLayer->GetCompositorAnimationsId(), color); + + layerCompositor->SetShadowOpacity(aLayer->GetOpacity()); + layerCompositor->SetShadowOpacitySetByAnimation(false); + layerCompositor->SetShadowBaseTransform(aLayer->GetBaseTransform()); + layerCompositor->SetShadowTransformSetByAnimation(false); + break; + } case eCSSProperty_opacity: { float opacity = Servo_AnimationValue_GetOpacity(aValue); layerCompositor->SetShadowOpacity(opacity); @@ -709,19 +722,22 @@ SampleAnimations(Layer* aLayer, } case AnimationHelper::SampleResult::Skipped: switch (animations[0].property()) { + case eCSSProperty_background_color: case eCSSProperty_opacity: { - MOZ_ASSERT( - layer->AsHostLayer()->GetShadowOpacitySetByAnimation()); + if (animations[0].property() == eCSSProperty_opacity) { + MOZ_ASSERT( + layer->AsHostLayer()->GetShadowOpacitySetByAnimation()); #ifdef DEBUG - // Disable this assertion until the root cause is fixed in bug - // 1459775. - // MOZ_ASSERT(FuzzyEqualsMultiplicative( - // Servo_AnimationValue_GetOpacity(animationValue), - // *(aStorage->GetAnimationOpacity(layer->GetCompositorAnimationsId())))); + // Disable this assertion until the root cause is fixed in bug + // 1459775. + // MOZ_ASSERT(FuzzyEqualsMultiplicative( + // Servo_AnimationValue_GetOpacity(animationValue), + // *(aStorage->GetAnimationOpacity(layer->GetCompositorAnimationsId())))); #endif - // Even if opacity animation value has unchanged, we have to set - // the shadow base transform value here since the value might - // have been changed by APZC. + } + // Even if opacity or background-color animation value has + // unchanged, we have to set the shadow base transform value + // here since the value might have been changed by APZC. HostLayer* layerCompositor = layer->AsHostLayer(); layerCompositor->SetShadowBaseTransform( layer->GetBaseTransform()); diff --git a/gfx/layers/ipc/LayersMessages.ipdlh b/gfx/layers/ipc/LayersMessages.ipdlh index abb2ff6f251d..81a02dff0e6f 100644 --- a/gfx/layers/ipc/LayersMessages.ipdlh +++ b/gfx/layers/ipc/LayersMessages.ipdlh @@ -19,6 +19,7 @@ using struct mozilla::gfx::Color from "mozilla/gfx/2D.h"; using struct mozilla::gfx::Point3D from "mozilla/gfx/Point.h"; using mozilla::gfx::IntPoint from "mozilla/gfx/Point.h"; using class mozilla::gfx::Matrix4x4 from "mozilla/gfx/Matrix.h"; +using nscolor from "nsColor.h"; using nscoord from "nsCoord.h"; using struct nsRect from "nsRect.h"; using struct nsPoint from "nsPoint.h"; @@ -160,6 +161,7 @@ union MaybeTimeDuration { union Animatable { null_t; float; + nscolor; TransformFunction[]; }; diff --git a/layout/painting/nsDisplayList.cpp b/layout/painting/nsDisplayList.cpp index 846eed140761..cdcd5f28e4d3 100644 --- a/layout/painting/nsDisplayList.cpp +++ b/layout/painting/nsDisplayList.cpp @@ -441,6 +441,23 @@ SetAnimatable(nsCSSPropertyID aProperty, } switch (aProperty) { + case eCSSProperty_background_color: { + // We don't support color animation on the compositor yet so that we can + // resolve currentColor at this moment. + nscolor foreground; + if (aFrame->Style()->RelevantLinkVisited()) { + if (ComputedStyle* styleIfVisited = + aFrame->Style()->GetStyleIfVisited()) { + foreground = styleIfVisited->StyleColor()->mColor; + } else { + foreground = aFrame->Style()->StyleColor()->mColor; + } + } else { + foreground = aFrame->Style()->StyleColor()->mColor; + } + aAnimatable = aAnimationValue.GetColor(foreground); + break; + } case eCSSProperty_opacity: aAnimatable = aAnimationValue.GetOpacity(); break; @@ -676,7 +693,7 @@ AddAnimationsForProperty(nsIFrame* aFrame, scaleX, scaleY, hasPerspectiveParent); - } else if (aProperty == eCSSProperty_opacity) { + } else { data = null_t(); } @@ -3532,6 +3549,7 @@ nsDisplaySolidColor::GetLayerState(nsDisplayListBuilder* aBuilder, if (ForceActiveLayers()) { return LAYER_ACTIVE; } + return LAYER_NONE; } @@ -5025,6 +5043,12 @@ nsDisplayBackgroundColor::GetLayerState( if (ForceActiveLayers() && clip != StyleGeometryBox::Text) { return LAYER_ACTIVE; } + + if (EffectCompositor::HasAnimationsForCompositor( + mFrame, eCSSProperty_background_color)) { + return LAYER_ACTIVE_FORCE; + } + return LAYER_NONE; } @@ -5052,6 +5076,11 @@ nsDisplayBackgroundColor::BuildLayer( layer->SetBaseTransform(gfx::Matrix4x4::Translation( aContainerParameters.mOffset.x, aContainerParameters.mOffset.y, 0)); + nsDisplayListBuilder::AddAnimationsAndTransitionsToLayer( + layer, aBuilder, + this, mFrame, + eCSSProperty_background_color); + return layer.forget(); } @@ -8574,6 +8603,14 @@ nsDisplayTransform::CanUseAsyncAnimations(nsDisplayListBuilder* aBuilder) return mAllowAsyncAnimation; } +bool +nsDisplayBackgroundColor::CanUseAsyncAnimations(nsDisplayListBuilder* aBuilder) +{ + LayerManager* layerManager = aBuilder->GetWidgetLayerManager(); + return layerManager && + layerManager->GetBackendType() != layers::LayersBackend::LAYERS_WR; +} + /* static */ auto nsDisplayTransform::ShouldPrerenderTransformedContent( nsDisplayListBuilder* aBuilder, diff --git a/layout/painting/nsDisplayList.h b/layout/painting/nsDisplayList.h index d4708c479311..d47c52c518bf 100644 --- a/layout/painting/nsDisplayList.h +++ b/layout/painting/nsDisplayList.h @@ -5074,6 +5074,8 @@ public: void WriteDebugInfo(std::stringstream& aStream) override; + bool CanUseAsyncAnimations(nsDisplayListBuilder* aBuilder) override; + protected: const nsRect mBackgroundRect; RefPtr mBackgroundStyle; diff --git a/layout/style/LayerAnimationInfo.cpp b/layout/style/LayerAnimationInfo.cpp index f0ebbecf2dd9..e3b958f61b8c 100644 --- a/layout/style/LayerAnimationInfo.cpp +++ b/layout/style/LayerAnimationInfo.cpp @@ -14,6 +14,7 @@ namespace mozilla { /* static */ const Array LayerAnimationInfo::sDisplayItemTypes = { + DisplayItemType::TYPE_BACKGROUND_COLOR, DisplayItemType::TYPE_OPACITY, DisplayItemType::TYPE_TRANSFORM, }; @@ -22,6 +23,8 @@ namespace mozilla { LayerAnimationInfo::GetDisplayItemTypeForProperty(nsCSSPropertyID aProperty) { switch (aProperty) { + case eCSSProperty_background_color: + return DisplayItemType::TYPE_BACKGROUND_COLOR; case eCSSProperty_opacity: return DisplayItemType::TYPE_OPACITY; case eCSSProperty_transform: diff --git a/layout/style/LayerAnimationInfo.h b/layout/style/LayerAnimationInfo.h index adc34b86851c..7163e4d9d71d 100644 --- a/layout/style/LayerAnimationInfo.h +++ b/layout/style/LayerAnimationInfo.h @@ -34,9 +34,13 @@ struct LayerAnimationInfo { nsCSSPropertyIDSet{ eCSSProperty_transform }; static const nsCSSPropertyIDSet opacityProperties = nsCSSPropertyIDSet{ eCSSProperty_opacity }; + static const nsCSSPropertyIDSet backgroundColorProperties = + nsCSSPropertyIDSet{ eCSSProperty_background_color }; static const nsCSSPropertyIDSet empty = nsCSSPropertyIDSet(); switch (aDisplayItemType) { + case DisplayItemType::TYPE_BACKGROUND_COLOR: + return backgroundColorProperties; case DisplayItemType::TYPE_OPACITY: return opacityProperties; case DisplayItemType::TYPE_TRANSFORM: @@ -58,6 +62,8 @@ struct LayerAnimationInfo { GetChangeHintFor(DisplayItemType aDisplayItemType) { switch (aDisplayItemType) { + case DisplayItemType::TYPE_BACKGROUND_COLOR: + return nsChangeHint_RepaintFrame; case DisplayItemType::TYPE_OPACITY: return nsChangeHint_UpdateOpacityLayer; case DisplayItemType::TYPE_TRANSFORM: diff --git a/layout/style/ServoBindings.h b/layout/style/ServoBindings.h index 31be74f3d862..9b1a1373aef0 100644 --- a/layout/style/ServoBindings.h +++ b/layout/style/ServoBindings.h @@ -676,6 +676,11 @@ void Servo_AnimationValue_Serialize( nsCSSPropertyID property, nsAString* buffer); +nscolor Servo_AnimationValue_GetColor(RawServoAnimationValueBorrowed value, + nscolor foregroundColor); +RawServoAnimationValueStrong Servo_AnimationValue_Color(nsCSSPropertyID, + nscolor); + float Servo_AnimationValue_GetOpacity(RawServoAnimationValueBorrowed value); RawServoAnimationValueStrong Servo_AnimationValue_Opacity(float); diff --git a/layout/style/StyleAnimationValue.cpp b/layout/style/StyleAnimationValue.cpp index 4f43e4de0686..7a875dd02fdf 100644 --- a/layout/style/StyleAnimationValue.cpp +++ b/layout/style/StyleAnimationValue.cpp @@ -120,6 +120,13 @@ AnimationValue::GetOpacity() const return Servo_AnimationValue_GetOpacity(mServo); } +nscolor +AnimationValue::GetColor(nscolor aForegroundColor) const +{ + MOZ_ASSERT(mServo); + return Servo_AnimationValue_GetColor(mServo, aForegroundColor); +} + already_AddRefed AnimationValue::GetTransformList() const { diff --git a/layout/style/StyleAnimationValue.h b/layout/style/StyleAnimationValue.h index 53fb7ab30a87..4e6dd8d2fd79 100644 --- a/layout/style/StyleAnimationValue.h +++ b/layout/style/StyleAnimationValue.h @@ -78,6 +78,10 @@ struct AnimationValue float GetOpacity() const; + // Returns nscolor value in this AnimationValue. + // Currently only background-color is supported. + nscolor GetColor(nscolor aForegroundColor) const; + // Return the transform list as a RefPtr. already_AddRefed GetTransformList() const; diff --git a/modules/libpref/init/StaticPrefList.h b/modules/libpref/init/StaticPrefList.h index f8c29cd989c9..35f7898c3cec 100644 --- a/modules/libpref/init/StaticPrefList.h +++ b/modules/libpref/init/StaticPrefList.h @@ -502,6 +502,18 @@ VARCACHE_PREF( RelaxedAtomicBool, false ) +#ifdef RELEASE_OR_BETA +# define PREF_VALUE false +#else +# define PREF_VALUE true +#endif +VARCACHE_PREF( + "gfx.omta.background-color", + gfx_omta_background_color, + bool, PREF_VALUE +) +#undef PREF_VALUE + //--------------------------------------------------------------------------- // HTML5 parser prefs //--------------------------------------------------------------------------- diff --git a/servo/components/style/properties/longhands/background.mako.rs b/servo/components/style/properties/longhands/background.mako.rs index 65df61a2e711..3cba4cc9a28a 100644 --- a/servo/components/style/properties/longhands/background.mako.rs +++ b/servo/components/style/properties/longhands/background.mako.rs @@ -15,7 +15,8 @@ ${helpers.predefined_type( animation_value_type="AnimatedColor", ignored_when_colors_disabled=True, allow_quirks=True, - flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER", + flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER \ + CAN_ANIMATE_ON_COMPOSITOR", )} ${helpers.predefined_type( diff --git a/servo/ports/geckolib/glue.rs b/servo/ports/geckolib/glue.rs index ba0da71729dd..a551892bf3fd 100644 --- a/servo/ports/geckolib/glue.rs +++ b/servo/ports/geckolib/glue.rs @@ -797,6 +797,27 @@ pub extern "C" fn Servo_AnimationValue_Serialize( debug_assert!(rv.is_ok()); } +#[no_mangle] +pub extern "C" fn Servo_AnimationValue_GetColor( + value: RawServoAnimationValueBorrowed, + foreground_color: structs::nscolor, +) -> structs::nscolor { + use style::gecko::values::convert_nscolor_to_rgba; + use style::gecko::values::convert_rgba_to_nscolor; + use style::values::animated::ToAnimatedValue; + use style::values::computed::color::Color as ComputedColor; + + let value = AnimationValue::as_arc(&value); + match **value { + AnimationValue::BackgroundColor(color) => { + let computed: ComputedColor = ToAnimatedValue::from_animated_value(color); + let foreground_color = convert_nscolor_to_rgba(foreground_color); + convert_rgba_to_nscolor(&computed.to_rgba(foreground_color)) + } + _ => panic!("Other color properties are not supported yet"), + } +} + #[no_mangle] pub extern "C" fn Servo_AnimationValue_GetOpacity(value: RawServoAnimationValueBorrowed) -> f32 { let value = AnimationValue::as_arc(&value); @@ -812,6 +833,30 @@ pub extern "C" fn Servo_AnimationValue_Opacity(opacity: f32) -> RawServoAnimatio Arc::new(AnimationValue::Opacity(opacity)).into_strong() } +#[no_mangle] +pub extern "C" fn Servo_AnimationValue_Color( + color_property: nsCSSPropertyID, + color: structs::nscolor +) -> RawServoAnimationValueStrong { + use style::gecko::values::convert_nscolor_to_rgba; + use style::values::animated::color::RGBA as AnimatedRGBA; + + let property = LonghandId::from_nscsspropertyid(color_property) + .expect("We don't have shorthand property animation value"); + + let rgba = convert_nscolor_to_rgba(color); + + let animatedRGBA = AnimatedRGBA::new(rgba.red_f32(), + rgba.green_f32(), + rgba.blue_f32(), + rgba.alpha_f32()); + match property { + LonghandId::BackgroundColor => + Arc::new(AnimationValue::BackgroundColor(animatedRGBA.into())).into_strong(), + _ => panic!("Should be background-color property"), + } +} + #[no_mangle] pub extern "C" fn Servo_AnimationValue_GetTransform( value: RawServoAnimationValueBorrowed, From 218b4e70381bbed3416c0cdae80802b0c27eb274 Mon Sep 17 00:00:00 2001 From: Hiroyuki Ikezoe Date: Wed, 28 Nov 2018 00:59:15 +0000 Subject: [PATCH 02/13] Bug 1504065 - Support background-color animations on the compositor for nsIDOMWindowUtils::GetOMTAValue. r=birtles Depends on D13001 Differential Revision: https://phabricator.services.mozilla.com/D13002 --HG-- extra : moz-landing-system : lando --- dom/base/nsDOMWindowUtils.cpp | 8 ++ gfx/layers/AnimationHelper.cpp | 15 +++ gfx/layers/AnimationHelper.h | 13 +++ gfx/layers/ipc/LayersMessages.ipdlh | 1 + layout/style/nsComputedDOMStyle.cpp | 2 +- layout/style/nsComputedDOMStyle.h | 2 +- layout/style/test/animation_utils.js | 29 +++-- layout/style/test/mochitest.ini | 1 + layout/style/test/test_animations_omta.html | 117 ++++++++++++++++++++ 9 files changed, 177 insertions(+), 11 deletions(-) diff --git a/dom/base/nsDOMWindowUtils.cpp b/dom/base/nsDOMWindowUtils.cpp index 76cb4c0a4a89..5169e789d05d 100644 --- a/dom/base/nsDOMWindowUtils.cpp +++ b/dom/base/nsDOMWindowUtils.cpp @@ -3733,6 +3733,14 @@ nsDOMWindowUtils::GetOMTAStyle(Element* aElement, if (value.type() == OMTAValue::TMatrix4x4) { cssValue = nsComputedDOMStyle::MatrixToCSSValue(value.get_Matrix4x4()); } + } else if (aProperty.EqualsLiteral("background-color")) { + OMTAValue value = GetOMTAValue(frame, + DisplayItemType::TYPE_BACKGROUND_COLOR, + GetWebRenderBridge()); + if (value.type() == OMTAValue::Tnscolor) { + cssValue = new nsROCSSPrimitiveValue; + nsComputedDOMStyle::SetToRGBAColor(cssValue, value.get_nscolor()); + } } } diff --git a/gfx/layers/AnimationHelper.cpp b/gfx/layers/AnimationHelper.cpp index 4e60088ad321..9eeedc29eab3 100644 --- a/gfx/layers/AnimationHelper.cpp +++ b/gfx/layers/AnimationHelper.cpp @@ -55,6 +55,9 @@ CompositorAnimationStorage::GetOMTAValue(const uint64_t& aId) const } switch (animatedValue->mType) { + case AnimatedValue::COLOR: + omtaValue = animatedValue->mColor; + break; case AnimatedValue::OPACITY: omtaValue = animatedValue->mOpacity; break; @@ -118,6 +121,18 @@ CompositorAnimationStorage::SetAnimatedValue(uint64_t aId, dontCare); } +void +CompositorAnimationStorage::SetAnimatedValue(uint64_t aId, nscolor aColor) +{ + MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread()); + auto count = mAnimatedValues.Count(); + AnimatedValue* value = mAnimatedValues.LookupOrAdd(aId, aColor); + if (count == mAnimatedValues.Count()) { + MOZ_ASSERT(value->mType == AnimatedValue::COLOR); + value->mColor = aColor; + } +} + void CompositorAnimationStorage::SetAnimatedValue(uint64_t aId, const float& aOpacity) diff --git a/gfx/layers/AnimationHelper.h b/gfx/layers/AnimationHelper.h index 8e557c29fdfd..5da73932a072 100644 --- a/gfx/layers/AnimationHelper.h +++ b/gfx/layers/AnimationHelper.h @@ -55,12 +55,14 @@ struct AnimatedValue { enum { TRANSFORM, OPACITY, + COLOR, NONE } mType {NONE}; union { AnimationTransform mTransform; float mOpacity; + nscolor mColor; }; AnimatedValue(gfx::Matrix4x4&& aTransformInDevSpace, @@ -80,6 +82,12 @@ struct AnimatedValue { { } + explicit AnimatedValue(nscolor aValue) + : mType(AnimatedValue::COLOR) + , mColor(aValue) + { + } + ~AnimatedValue() {} private: @@ -128,6 +136,11 @@ public: */ void SetAnimatedValue(uint64_t aId, const float& aOpacity); + /** + * Set the animation color based on the unique id + */ + void SetAnimatedValue(uint64_t aId, nscolor aColor); + /** * Return the animated value if a given id can map to its animated value */ diff --git a/gfx/layers/ipc/LayersMessages.ipdlh b/gfx/layers/ipc/LayersMessages.ipdlh index 81a02dff0e6f..ac26b386cb15 100644 --- a/gfx/layers/ipc/LayersMessages.ipdlh +++ b/gfx/layers/ipc/LayersMessages.ipdlh @@ -567,6 +567,7 @@ union MaybeTransform { union OMTAValue { null_t; + nscolor; float; Matrix4x4; }; diff --git a/layout/style/nsComputedDOMStyle.cpp b/layout/style/nsComputedDOMStyle.cpp index 4d494f5a0f1d..870bad330195 100644 --- a/layout/style/nsComputedDOMStyle.cpp +++ b/layout/style/nsComputedDOMStyle.cpp @@ -1117,7 +1117,7 @@ nsComputedDOMStyle::DoGetBottom() return GetOffsetWidthFor(eSideBottom); } -void +/* static */ void nsComputedDOMStyle::SetToRGBAColor(nsROCSSPrimitiveValue* aValue, nscolor aColor) { diff --git a/layout/style/nsComputedDOMStyle.h b/layout/style/nsComputedDOMStyle.h index 3c1358ade79e..341621eb8db3 100644 --- a/layout/style/nsComputedDOMStyle.h +++ b/layout/style/nsComputedDOMStyle.h @@ -131,6 +131,7 @@ public: static already_AddRefed MatrixToCSSValue(const mozilla::gfx::Matrix4x4& aMatrix); + static void SetToRGBAColor(nsROCSSPrimitiveValue* aValue, nscolor aColor); static void RegisterPrefChangeCallbacks(); static void UnregisterPrefChangeCallbacks(); @@ -428,7 +429,6 @@ private: already_AddRefed DummyGetter(); /* Helper functions */ - void SetToRGBAColor(nsROCSSPrimitiveValue* aValue, nscolor aColor); void SetValueFromComplexColor(nsROCSSPrimitiveValue* aValue, const mozilla::StyleComplexColor& aColor); void SetValueToPositionCoord(const mozilla::Position::Coord& aCoord, diff --git a/layout/style/test/animation_utils.js b/layout/style/test/animation_utils.js index 63d6d7578cfb..c57d2f3cc505 100644 --- a/layout/style/test/animation_utils.js +++ b/layout/style/test/animation_utils.js @@ -422,19 +422,30 @@ const ExpectComparisonTo = { runningOn, desc, expectedComparisonResult, pseudo) { // Check input - const omtaProperties = [ "transform", "opacity" ]; + // FIXME: Auto generate this array. + const omtaProperties = [ "transform", "opacity", "background-color" ]; if (!omtaProperties.includes(property)) { ok(false, property + " is not an OMTA property"); return; } - var isTransform = property == "transform"; - var normalize = isTransform ? convertTo3dMatrix : parseFloat; - var compare = isTransform ? - matricesRoughlyEqual : - function(a, b, error) { return Math.abs(a - b) <= error; }; - var normalizedToString = isTransform ? - convert3dMatrixToString : - JSON.stringify; + var normalize; + var compare; + var normalizedToString = JSON.stringify; + switch (property) { + case "transform": + normalize = convertTo3dMatrix; + compare = matricesRoughlyEqual; + normalizedToString = convert3dMatrixToString; + break; + case "opacity": + normalize = parseFloat; + compare = function(a, b, error) { return Math.abs(a - b) <= error; }; + break; + default: + normalize = function(value) { return value; }; + compare = function(a, b, error) { return a == b; }; + break; + } // Get actual values var compositorStr = diff --git a/layout/style/test/mochitest.ini b/layout/style/test/mochitest.ini index 33833fdcfe27..9fd849e7dde5 100644 --- a/layout/style/test/mochitest.ini +++ b/layout/style/test/mochitest.ini @@ -5,6 +5,7 @@ prefs = dom.animations-api.getAnimations.enabled=true dom.animations-api.implicit-keyframes.enabled=true dom.animations-api.timelines.enabled=true + gfx.omta.background-color=true layout.css.step-position-jump.enabled=true support-files = animation_utils.js diff --git a/layout/style/test/test_animations_omta.html b/layout/style/test/test_animations_omta.html index da5e774029cf..2e2a221595cc 100644 --- a/layout/style/test/test_animations_omta.html +++ b/layout/style/test/test_animations_omta.html @@ -2391,5 +2391,122 @@ addAsyncAnimTest(async function() { done_div(); }); +if (SpecialPowers.DOMWindowUtils.layerManagerType != 'WebRender') { + // Normal background-color animation. + addAsyncAnimTest(async function() { + new_div("background-color: rgb(255, 0, 0); " + + "transition: background-color 10s linear"); + await waitForPaintsFlushed(); + + gDiv.style.backgroundColor = "rgb(0, 255, 0)"; + await waitForPaintsFlushed(); + + omta_is("background-color", "rgb(255, 0, 0)", RunningOn.Compositor, + "background-color transition runs on compositor thread"); + + advance_clock(5000); + omta_is("background-color", "rgb(128, 128, 0)", RunningOn.Compositor, + "background-color on compositor at 5s"); + + done_div(); + }); + + // background-color animation with currentColor. + addAsyncAnimTest(async function() { + new_div("color: rgb(255, 0, 0); " + + "background-color: currentColor; " + + "transition: background-color 10s linear"); + await waitForPaintsFlushed(); + + gDiv.style.backgroundColor = "rgb(0, 255, 0)"; + await waitForPaintsFlushed(); + + omta_is("background-color", "rgb(255, 0, 0)", RunningOn.Compositor, + "background-color transition starting with current-color runs on " + + "compositor thread"); + + advance_clock(5000); + omta_is("background-color", "rgb(128, 128, 0)", RunningOn.Compositor, + "background-color on compositor at 5s"); + + done_div(); + }); + + // Tests that a background-color animation from inherited currentColor to + // a normal color on the compositor is updated when the parent color is + // changed. + addAsyncAnimTest(async function() { + new_div(""); + const parent = document.createElement("div"); + gDiv.parentNode.insertBefore(parent, gDiv); + parent.style.color = "rgb(255, 0, 0)"; + parent.appendChild(gDiv); + + gDiv.animate({ backgroundColor: [ "currentColor", "rgb(0, 255, 0)" ] }, 1000); + + await waitForPaintsFlushed(); + + omta_is("background-color", "rgb(255, 0, 0)", RunningOn.Compositor, + "background-color animation starting with current-color runs on " + + "compositor thread"); + + advance_clock(500); + + omta_is("background-color", "rgb(128, 128, 0)", RunningOn.Compositor, + "background-color on compositor at 5s"); + + // Change the parent's color in the middle of the animation. + parent.style.color = "rgb(0, 0, 255)"; + await waitForPaintsFlushed(); + + omta_is("background-color", "rgb(0, 128, 128)", RunningOn.Compositor, + "background-color on compositor is reflected by the parent's " + + "color change"); + + done_div(); + parent.remove(); + }); + + // Tests that a background-color animation from currentColor to a normal color + // on element is updated when the link is visited. + addAsyncAnimTest(async function() { + [ gDiv ] = new_element("a", "display: block"); + gDiv.setAttribute("href", "not-exist.html"); + gDiv.classList.add("visited"); + + const extraStyle = document.createElement('style'); + document.head.appendChild(extraStyle); + extraStyle.sheet.insertRule(".visited:visited { color: rgb(0, 0, 255); }", 0); + extraStyle.sheet.insertRule(".visited:link { color: rgb(255, 0, 0); }", 1); + + gDiv.animate({ backgroundColor: [ "currentColor", "rgb(0, 255, 0)" ] }, 1000); + await waitForPaintsFlushed(); + + omta_is("background-color", "rgb(255, 0, 0)", RunningOn.Compositor, + "background-color animation starting with current-color runs on " + + "compositor thread"); + + advance_clock(500); + + omta_is("background-color", "rgb(128, 128, 0)", RunningOn.Compositor, + "background-color on compositor at 5s"); + + gDiv.setAttribute("href", window.top.location.href); + await waitForVisitedLinkColoring(gDiv, "color", "rgb(0, 0, 255)"); + await waitForPaintsFlushed(); + + // `omta_is` checks that the result on the compositor equals to the value by + // getComputedValue() but getComputedValue lies for visited link values so + // we use getOMTAStyle directly instead. + is(SpecialPowers.DOMWindowUtils.getOMTAStyle(gDiv, "background-color"), + "rgb(0, 128, 128)", + "background-color on element after the link is visited"); + + extraStyle.remove(); + done_element(); + gDiv = null; + }); +} + From d745109dfb761e111feb50d6836214e1a9c7326a Mon Sep 17 00:00:00 2001 From: Hiroyuki Ikezoe Date: Wed, 28 Nov 2018 01:43:55 +0000 Subject: [PATCH 03/13] Bug 1504065 - Drop text in the child element inside background-color animated element to avoid fuzziness on Windows 7 GPU. r=birtles Depends on D13002 Differential Revision: https://phabricator.services.mozilla.com/D13171 --HG-- extra : moz-landing-system : lando --- .../child-in-animating-element-display-none-ref.html | 6 ++++-- .../child-in-animating-element-display-none.html | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/layout/reftests/web-animations/child-in-animating-element-display-none-ref.html b/layout/reftests/web-animations/child-in-animating-element-display-none-ref.html index 159ceeda4bc4..9a5a1dec9672 100644 --- a/layout/reftests/web-animations/child-in-animating-element-display-none-ref.html +++ b/layout/reftests/web-animations/child-in-animating-element-display-none-ref.html @@ -6,11 +6,13 @@ div { height: 100px; background-color: blue; } -span { +#child { background-color: green; + width: 50px; + height: 50px; }
- child +
diff --git a/layout/reftests/web-animations/child-in-animating-element-display-none.html b/layout/reftests/web-animations/child-in-animating-element-display-none.html index eab4c8044390..57ad9f1ad207 100644 --- a/layout/reftests/web-animations/child-in-animating-element-display-none.html +++ b/layout/reftests/web-animations/child-in-animating-element-display-none.html @@ -9,12 +9,14 @@ Child element in animating element that display property is changed from none width: 100px; height: 100px; } -span { +#child { background-color: green; + width: 50px; + height: 50px; }
- child +
diff --git a/toolkit/content/tests/widgets/test_ua_widget_unbind.html b/toolkit/content/tests/widgets/test_ua_widget_unbind.html new file mode 100644 index 000000000000..677e15f578a5 --- /dev/null +++ b/toolkit/content/tests/widgets/test_ua_widget_unbind.html @@ -0,0 +1,57 @@ + + + + UA Widget unbind test + + + + + + + +

+ +
+
+ +
+
+
+ + From d23a7312fcfd95926df9aa6298f577f69df92a73 Mon Sep 17 00:00:00 2001 From: Thomas Daede Date: Wed, 28 Nov 2018 03:10:55 +0000 Subject: [PATCH 05/13] Bug 1510113 - Never inline SaveToEnv or SaveWordToEnv. r=karlt This allows Valgrind to recognize the call stacks to this function, avoiding Valgrind warnings in intentional leaks in these functions. Differential Revision: https://phabricator.services.mozilla.com/D13036 --HG-- extra : moz-landing-system : lando --- toolkit/xre/CmdLineAndEnvUtils.h | 2 +- toolkit/xre/nsAppRunner.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/toolkit/xre/CmdLineAndEnvUtils.h b/toolkit/xre/CmdLineAndEnvUtils.h index 5a3e4ef028ca..591f675f8435 100644 --- a/toolkit/xre/CmdLineAndEnvUtils.h +++ b/toolkit/xre/CmdLineAndEnvUtils.h @@ -394,7 +394,7 @@ SetArgv0ToFullBinaryPath(wchar_t* aArgv[]) #endif // defined(XP_WIN) // Save literal putenv string to environment variable. -inline void +MOZ_NEVER_INLINE inline void SaveToEnv(const char *aEnvString) { #if defined(MOZILLA_INTERNAL_API) diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp index e00969276d4c..fd2782295865 100644 --- a/toolkit/xre/nsAppRunner.cpp +++ b/toolkit/xre/nsAppRunner.cpp @@ -319,7 +319,7 @@ using mozilla::dom::ContentChild; using mozilla::intl::LocaleService; // Save the given word to the specified environment variable. -static void +static void MOZ_NEVER_INLINE SaveWordToEnv(const char *name, const nsACString & word) { char *expr = Smprintf("%s=%s", name, PromiseFlatCString(word).get()).release(); From f608f5fc83231a612870582ff349ba236d4194bf Mon Sep 17 00:00:00 2001 From: Thomas Daede Date: Wed, 28 Nov 2018 03:23:08 +0000 Subject: [PATCH 06/13] Bug 1501796 - Add nasm to debian7-build dockerfile. r=glandium Differential Revision: https://phabricator.services.mozilla.com/D9747 --HG-- extra : moz-landing-system : lando --- taskcluster/ci/docker-image/kind.yml | 2 ++ taskcluster/docker/debian7-build/Dockerfile | 1 + 2 files changed, 3 insertions(+) diff --git a/taskcluster/ci/docker-image/kind.yml b/taskcluster/ci/docker-image/kind.yml index ac62400635ba..2f68950f6f9f 100644 --- a/taskcluster/ci/docker-image/kind.yml +++ b/taskcluster/ci/docker-image/kind.yml @@ -63,6 +63,7 @@ jobs: - deb7-gtk3 - deb7-harfbuzz - deb7-libxkbcommon + - deb7-nasm - deb7-pango - deb7-pcre3 - deb7-valgrind @@ -88,6 +89,7 @@ jobs: - deb7-glib - deb7-gtk3 - deb7-harfbuzz + - deb7-nasm - deb7-python-defaults - deb7-pcre3 - deb7-valgrind diff --git a/taskcluster/docker/debian7-build/Dockerfile b/taskcluster/docker/debian7-build/Dockerfile index 443d2a6923df..b7568e1237e8 100644 --- a/taskcluster/docker/debian7-build/Dockerfile +++ b/taskcluster/docker/debian7-build/Dockerfile @@ -32,6 +32,7 @@ RUN apt-get update && \ gawk \ gcc-multilib \ gnupg \ + nasm \ p7zip-full \ procps \ python-pip \ From e821d52f9bbf138109e1851589d2d5343bf890d3 Mon Sep 17 00:00:00 2001 From: Kyle Machulis Date: Wed, 28 Nov 2018 03:30:54 +0000 Subject: [PATCH 07/13] Bug 1505601 - Move nsIDocShell INTERNAL_LOAD consts to nsDocShell; r=bzbarsky Consts aren't used in JS anyways, so there's no reason for them to be in the IDL. Differential Revision: https://phabricator.services.mozilla.com/D11715 --HG-- extra : moz-landing-system : lando --- docshell/base/nsDocShell.h | 34 +++++++++++++++++++++++++++ docshell/base/nsDocShellLoadState.cpp | 18 +++++++------- docshell/base/nsIDocShell.idl | 32 ------------------------- 3 files changed, 43 insertions(+), 41 deletions(-) diff --git a/docshell/base/nsDocShell.h b/docshell/base/nsDocShell.h index 1d313cf9c73b..0e90f90a54ec 100644 --- a/docshell/base/nsDocShell.h +++ b/docshell/base/nsDocShell.h @@ -132,6 +132,40 @@ class nsDocShell final , public mozilla::SupportsWeakPtr { public: + enum InternalLoad : uint32_t { + INTERNAL_LOAD_FLAGS_NONE = 0x0, + INTERNAL_LOAD_FLAGS_INHERIT_PRINCIPAL = 0x1, + INTERNAL_LOAD_FLAGS_DONT_SEND_REFERRER = 0x2, + INTERNAL_LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP = 0x4, + + // This flag marks the first load in this object + // @see nsIWebNavigation::LOAD_FLAGS_FIRST_LOAD + INTERNAL_LOAD_FLAGS_FIRST_LOAD = 0x8, + + + // The set of flags that should not be set before calling into + // nsDocShell::LoadURI and other nsDocShell loading functions. + INTERNAL_LOAD_FLAGS_LOADURI_SETUP_FLAGS = 0xf, + + + INTERNAL_LOAD_FLAGS_BYPASS_CLASSIFIER = 0x10, + INTERNAL_LOAD_FLAGS_FORCE_ALLOW_COOKIES = 0x20, + + // Whether the load should be treated as srcdoc load, rather than a URI one. + INTERNAL_LOAD_FLAGS_IS_SRCDOC = 0x40, + + // Whether this is the load of a frame's original src attribute + INTERNAL_LOAD_FLAGS_ORIGINAL_FRAME_SRC = 0x80, + + INTERNAL_LOAD_FLAGS_NO_OPENER = 0x100, + + // Whether a top-level data URI navigation is allowed for that load + INTERNAL_LOAD_FLAGS_FORCE_ALLOW_DATA_URI = 0x200, + + // Whether the load was triggered by user interaction. + INTERNAL_LOAD_FLAGS_IS_USER_TRIGGERED = 0x1000, + }; + // Event type dispatched by RestorePresentation class RestorePresentationEvent : public mozilla::Runnable { diff --git a/docshell/base/nsDocShellLoadState.cpp b/docshell/base/nsDocShellLoadState.cpp index a4b7717ed682..436e9c784f38 100644 --- a/docshell/base/nsDocShellLoadState.cpp +++ b/docshell/base/nsDocShellLoadState.cpp @@ -515,44 +515,44 @@ nsDocShellLoadState::CalculateDocShellInternalLoadFlags() MOZ_ASSERT(!nsContentUtils::IsSystemPrincipal(mPrincipalToInherit), "Should not inherit SystemPrincipal"); mDocShellInternalLoadFlags |= - nsIDocShell::INTERNAL_LOAD_FLAGS_INHERIT_PRINCIPAL; + nsDocShell::INTERNAL_LOAD_FLAGS_INHERIT_PRINCIPAL; } if (!mSendReferrer) { mDocShellInternalLoadFlags |= - nsIDocShell::INTERNAL_LOAD_FLAGS_DONT_SEND_REFERRER; + nsDocShell::INTERNAL_LOAD_FLAGS_DONT_SEND_REFERRER; } if (mLoadFlags & nsIWebNavigation::LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP) { mDocShellInternalLoadFlags |= - nsIDocShell::INTERNAL_LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP; + nsDocShell::INTERNAL_LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP; } if (mLoadFlags & nsIWebNavigation::LOAD_FLAGS_FIRST_LOAD) { - mDocShellInternalLoadFlags |= nsIDocShell::INTERNAL_LOAD_FLAGS_FIRST_LOAD; + mDocShellInternalLoadFlags |= nsDocShell::INTERNAL_LOAD_FLAGS_FIRST_LOAD; } if (mLoadFlags & nsIWebNavigation::LOAD_FLAGS_BYPASS_CLASSIFIER) { mDocShellInternalLoadFlags |= - nsIDocShell::INTERNAL_LOAD_FLAGS_BYPASS_CLASSIFIER; + nsDocShell::INTERNAL_LOAD_FLAGS_BYPASS_CLASSIFIER; } if (mLoadFlags & nsIWebNavigation::LOAD_FLAGS_FORCE_ALLOW_COOKIES) { mDocShellInternalLoadFlags |= - nsIDocShell::INTERNAL_LOAD_FLAGS_FORCE_ALLOW_COOKIES; + nsDocShell::INTERNAL_LOAD_FLAGS_FORCE_ALLOW_COOKIES; } if (mIsSrcdocLoad) { - mDocShellInternalLoadFlags |= nsIDocShell::INTERNAL_LOAD_FLAGS_IS_SRCDOC; + mDocShellInternalLoadFlags |= nsDocShell::INTERNAL_LOAD_FLAGS_IS_SRCDOC; } if (mForceAllowDataURI) { mDocShellInternalLoadFlags |= - nsIDocShell::INTERNAL_LOAD_FLAGS_FORCE_ALLOW_DATA_URI; + nsDocShell::INTERNAL_LOAD_FLAGS_FORCE_ALLOW_DATA_URI; } if (mOriginalFrameSrc) { mDocShellInternalLoadFlags |= - nsIDocShell::INTERNAL_LOAD_FLAGS_ORIGINAL_FRAME_SRC; + nsDocShell::INTERNAL_LOAD_FLAGS_ORIGINAL_FRAME_SRC; } } diff --git a/docshell/base/nsIDocShell.idl b/docshell/base/nsIDocShell.idl index 45f6f5f8c6d2..87c366abf19c 100644 --- a/docshell/base/nsIDocShell.idl +++ b/docshell/base/nsIDocShell.idl @@ -82,38 +82,6 @@ interface nsIDocShell : nsIDocShellTreeItem */ [noscript]void loadURI(in nsDocShellLoadStatePtr loadState); - const long INTERNAL_LOAD_FLAGS_NONE = 0x0; - const long INTERNAL_LOAD_FLAGS_INHERIT_PRINCIPAL = 0x1; - const long INTERNAL_LOAD_FLAGS_DONT_SEND_REFERRER = 0x2; - const long INTERNAL_LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP = 0x4; - - // This flag marks the first load in this object - // @see nsIWebNavigation::LOAD_FLAGS_FIRST_LOAD - const long INTERNAL_LOAD_FLAGS_FIRST_LOAD = 0x8; - - - // The set of flags that should not be set before calling into - // nsDocShell::LoadURI and other nsDocShell loading functions. - const long INTERNAL_LOAD_FLAGS_LOADURI_SETUP_FLAGS = 0xf; - - - const long INTERNAL_LOAD_FLAGS_BYPASS_CLASSIFIER = 0x10; - const long INTERNAL_LOAD_FLAGS_FORCE_ALLOW_COOKIES = 0x20; - - // Whether the load should be treated as srcdoc load, rather than a URI one. - const long INTERNAL_LOAD_FLAGS_IS_SRCDOC = 0x40; - - // Whether this is the load of a frame's original src attribute - const long INTERNAL_LOAD_FLAGS_ORIGINAL_FRAME_SRC = 0x80; - - const long INTERNAL_LOAD_FLAGS_NO_OPENER = 0x100; - - // Whether a top-level data URI navigation is allowed for that load - const long INTERNAL_LOAD_FLAGS_FORCE_ALLOW_DATA_URI = 0x200; - - // Whether the load was triggered by user interaction. - const long INTERNAL_LOAD_FLAGS_IS_USER_TRIGGERED = 0x1000; - /** * Loads the given URI. This method is identical to loadURI(...) except * that its parameter list is broken out instead of being packaged inside From c241567f0f3d80d66f5dcc7492d528fe60e84754 Mon Sep 17 00:00:00 2001 From: Kyle Machulis Date: Wed, 28 Nov 2018 03:30:56 +0000 Subject: [PATCH 08/13] Bug 1505601 - Turn nsIDocShell XPIDL const lists into cenums; r=bzbarsky Turn all const lists and related attributes into cenums, to provide a vague sense of type safety. Depends on D11715 Differential Revision: https://phabricator.services.mozilla.com/D11716 --HG-- extra : moz-landing-system : lando --- accessible/base/Logging.cpp | 2 +- docshell/base/nsDocShell.cpp | 147 ++++++++++--------- docshell/base/nsDocShell.h | 68 ++++----- docshell/base/nsIDocShell.idl | 141 ++++++++++-------- dom/base/nsContentUtils.cpp | 11 +- dom/base/nsGlobalWindowOuter.cpp | 5 +- dom/events/EventStateManager.cpp | 5 +- dom/events/TouchEvent.cpp | 4 +- dom/presentation/PresentationCallbacks.cpp | 6 +- dom/security/nsContentSecurityManager.cpp | 6 +- editor/libeditor/TextEditorDataTransfer.cpp | 7 +- layout/base/nsDocumentViewer.cpp | 5 +- layout/base/nsLayoutUtils.cpp | 4 +- layout/printing/nsPrintJob.cpp | 5 +- toolkit/components/find/nsWebBrowserFind.cpp | 5 +- 15 files changed, 215 insertions(+), 206 deletions(-) diff --git a/accessible/base/Logging.cpp b/accessible/base/Logging.cpp index 922d5e7113c4..c2377bd63e6e 100644 --- a/accessible/base/Logging.cpp +++ b/accessible/base/Logging.cpp @@ -102,7 +102,7 @@ LogDocShellState(nsIDocument* aDocumentNode) nsAutoCString docShellBusy; nsCOMPtr docShell = aDocumentNode->GetDocShell(); - uint32_t busyFlags = nsIDocShell::BUSY_FLAGS_NONE; + nsIDocShell::BusyFlags busyFlags = nsIDocShell::BUSY_FLAGS_NONE; docShell->GetBusyFlags(&busyFlags); if (busyFlags == nsIDocShell::BUSY_FLAGS_NONE) { printf("'none'"); diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index eac01dabf986..3dddca097024 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -791,9 +791,9 @@ void nsDocShell::MaybeHandleSubframeHistory(nsDocShellLoadState* aLoadState) { // First, verify if this is a subframe. - nsCOMPtr parentAsItem; - GetSameTypeParent(getter_AddRefs(parentAsItem)); - nsCOMPtr parentDS(do_QueryInterface(parentAsItem)); + nsCOMPtr parentAsItem; + GetSameTypeParent(getter_AddRefs(parentAsItem)); + nsCOMPtr parentDS(do_QueryInterface(parentAsItem)); if (!parentDS || parentDS == static_cast(this)) { // This is the root docshell. If we got here while @@ -813,58 +813,57 @@ nsDocShell::MaybeHandleSubframeHistory(nsDocShellLoadState* aLoadState) * back/forward. If the parent was loaded through any other loadType, set the * child's loadType too accordingly, so that session history does not get * confused. - */ + */ - // Get the parent's load type + // Get the parent's load type uint32_t parentLoadType; - parentDS->GetLoadType(&parentLoadType); + parentDS->GetLoadType(&parentLoadType); - // Get the ShEntry for the child from the parent - nsCOMPtr currentSH; - bool oshe = false; - parentDS->GetCurrentSHEntry(getter_AddRefs(currentSH), &oshe); - bool dynamicallyAddedChild = mDynamicallyCreated; + // Get the ShEntry for the child from the parent + nsCOMPtr currentSH; + bool oshe = false; + parentDS->GetCurrentSHEntry(getter_AddRefs(currentSH), &oshe); + bool dynamicallyAddedChild = mDynamicallyCreated; - if (!dynamicallyAddedChild && !oshe && currentSH) { - currentSH->HasDynamicallyAddedChild(&dynamicallyAddedChild); - } + if (!dynamicallyAddedChild && !oshe && currentSH) { + currentSH->HasDynamicallyAddedChild(&dynamicallyAddedChild); + } - if (!dynamicallyAddedChild) { - // Only use the old SHEntry, if we're sure enough that - // it wasn't originally for some other frame. + if (!dynamicallyAddedChild) { + // Only use the old SHEntry, if we're sure enough that + // it wasn't originally for some other frame. nsCOMPtr shEntry; - parentDS->GetChildSHEntry(mChildOffset, getter_AddRefs(shEntry)); + parentDS->GetChildSHEntry(mChildOffset, getter_AddRefs(shEntry)); aLoadState->SetSHEntry(shEntry); - } + } - // Make some decisions on the child frame's loadType based on the - // parent's loadType, if the subframe hasn't loaded anything into it. - // - // In some cases privileged scripts may try to get the DOMWindow - // reference of this docshell before the loading starts, causing the - // initial about:blank content viewer being created and mCurrentURI being - // set. To handle this case we check if mCurrentURI is about:blank and - // currentSHEntry is null. - nsCOMPtr currentChildEntry; - GetCurrentSHEntry(getter_AddRefs(currentChildEntry), &oshe); + // Make some decisions on the child frame's loadType based on the + // parent's loadType, if the subframe hasn't loaded anything into it. + // + // In some cases privileged scripts may try to get the DOMWindow + // reference of this docshell before the loading starts, causing the + // initial about:blank content viewer being created and mCurrentURI being + // set. To handle this case we check if mCurrentURI is about:blank and + // currentSHEntry is null. + nsCOMPtr currentChildEntry; + GetCurrentSHEntry(getter_AddRefs(currentChildEntry), &oshe); if (mCurrentURI && (!NS_IsAboutBlank(mCurrentURI) || currentChildEntry)) { - // This is a pre-existing subframe. If - // 1. The load of this frame was not originally initiated by session - // history directly (i.e. (!shEntry) condition succeeded, but it can - // still be a history load on parent which causes this frame being + // This is a pre-existing subframe. If + // 1. The load of this frame was not originally initiated by session + // history directly (i.e. (!shEntry) condition succeeded, but it can + // still be a history load on parent which causes this frame being // loaded), which we checked with the above assert, and - // 2. mCurrentURI is not null, nor the initial about:blank, - // it is possible that a parent's onLoadHandler or even self's - // onLoadHandler is loading a new page in this child. Check parent's and - // self's busy flag and if it is set, we don't want this onLoadHandler - // load to get in to session history. - uint32_t parentBusy = BUSY_FLAGS_NONE; - uint32_t selfBusy = BUSY_FLAGS_NONE; - parentDS->GetBusyFlags(&parentBusy); - GetBusyFlags(&selfBusy); - if (parentBusy & BUSY_FLAGS_BUSY || - selfBusy & BUSY_FLAGS_BUSY) { + // 2. mCurrentURI is not null, nor the initial about:blank, + // it is possible that a parent's onLoadHandler or even self's + // onLoadHandler is loading a new page in this child. Check parent's and + // self's busy flag and if it is set, we don't want this onLoadHandler + // load to get in to session history. + BusyFlags parentBusy = parentDS->GetBusyFlags(); + BusyFlags selfBusy = GetBusyFlags(); + + if (parentBusy & BUSY_FLAGS_BUSY || + selfBusy & BUSY_FLAGS_BUSY) { aLoadState->SetLoadType(LOAD_NORMAL_REPLACE); aLoadState->SetSHEntry(nullptr); } @@ -882,9 +881,9 @@ nsDocShell::MaybeHandleSubframeHistory(nsDocShellLoadState* aLoadState) // in the onLoadHandler. We don't want this url to get into session // history. Clear off shEntry, and set load type to // LOAD_BYPASS_HISTORY. - bool inOnLoadHandler = false; + bool inOnLoadHandler = false; parentDS->GetIsExecutingOnLoadHandler(&inOnLoadHandler); - if (inOnLoadHandler) { + if (inOnLoadHandler) { aLoadState->SetLoadType(LOAD_NORMAL_REPLACE); aLoadState->SetSHEntry(nullptr); } @@ -2010,7 +2009,7 @@ nsDocShell::GetMayEnableCharacterEncodingMenu( } NS_IMETHODIMP -nsDocShell::GetDocShellEnumerator(int32_t aItemType, int32_t aDirection, +nsDocShell::GetDocShellEnumerator(int32_t aItemType, DocShellEnumeratorDirection aDirection, nsISimpleEnumerator** aResult) { NS_ENSURE_ARG_POINTER(aResult); @@ -2045,14 +2044,14 @@ nsDocShell::GetDocShellEnumerator(int32_t aItemType, int32_t aDirection, } NS_IMETHODIMP -nsDocShell::GetAppType(uint32_t* aAppType) +nsDocShell::GetAppType(AppType* aAppType) { *aAppType = mAppType; return NS_OK; } NS_IMETHODIMP -nsDocShell::SetAppType(uint32_t aAppType) +nsDocShell::SetAppType(AppType aAppType) { mAppType = aAppType; return NS_OK; @@ -2119,7 +2118,7 @@ nsDocShell::SetMarginHeight(int32_t aHeight) } NS_IMETHODIMP -nsDocShell::GetBusyFlags(uint32_t* aBusyFlags) +nsDocShell::GetBusyFlags(BusyFlags* aBusyFlags) { NS_ENSURE_ARG_POINTER(aBusyFlags); @@ -2521,18 +2520,20 @@ nsDocShell::SetCustomUserAgent(const nsAString& aCustomUserAgent) } NS_IMETHODIMP -nsDocShell::GetTouchEventsOverride(uint32_t* aTouchEventsOverride) +nsDocShell::GetTouchEventsOverride(TouchEventsOverride* aTouchEventsOverride) { *aTouchEventsOverride = mTouchEventsOverride; return NS_OK; } NS_IMETHODIMP -nsDocShell::SetTouchEventsOverride(uint32_t aTouchEventsOverride) +nsDocShell::SetTouchEventsOverride(TouchEventsOverride aTouchEventsOverride) { - if (!(aTouchEventsOverride == nsIDocShell::TOUCHEVENTS_OVERRIDE_NONE || - aTouchEventsOverride == nsIDocShell::TOUCHEVENTS_OVERRIDE_ENABLED || - aTouchEventsOverride == nsIDocShell::TOUCHEVENTS_OVERRIDE_DISABLED)) { + // We don't have a way to verify this coming from Javascript, so this check is + // still needed. + if (!(aTouchEventsOverride == TOUCHEVENTS_OVERRIDE_NONE || + aTouchEventsOverride == TOUCHEVENTS_OVERRIDE_ENABLED || + aTouchEventsOverride == TOUCHEVENTS_OVERRIDE_DISABLED)) { return NS_ERROR_INVALID_ARG; } @@ -2549,7 +2550,7 @@ nsDocShell::SetTouchEventsOverride(uint32_t aTouchEventsOverride) } NS_IMETHODIMP -nsDocShell::GetMetaViewportOverride(uint32_t* aMetaViewportOverride) +nsDocShell::GetMetaViewportOverride(MetaViewportOverride* aMetaViewportOverride) { NS_ENSURE_ARG_POINTER(aMetaViewportOverride); @@ -2558,11 +2559,13 @@ nsDocShell::GetMetaViewportOverride(uint32_t* aMetaViewportOverride) } NS_IMETHODIMP -nsDocShell::SetMetaViewportOverride(uint32_t aMetaViewportOverride) +nsDocShell::SetMetaViewportOverride(MetaViewportOverride aMetaViewportOverride) { - if (!(aMetaViewportOverride == nsIDocShell::META_VIEWPORT_OVERRIDE_NONE || - aMetaViewportOverride == nsIDocShell::META_VIEWPORT_OVERRIDE_ENABLED || - aMetaViewportOverride == nsIDocShell::META_VIEWPORT_OVERRIDE_DISABLED)) { + // We don't have a way to verify this coming from Javascript, so this check is + // still needed. + if (!(aMetaViewportOverride == META_VIEWPORT_OVERRIDE_NONE || + aMetaViewportOverride == META_VIEWPORT_OVERRIDE_ENABLED || + aMetaViewportOverride == META_VIEWPORT_OVERRIDE_DISABLED)) { return NS_ERROR_INVALID_ARG; } @@ -2827,10 +2830,9 @@ nsDocShell::SetDocLoaderParent(nsDocLoader* aParent) if (NS_SUCCEEDED(parentAsDocShell->GetDefaultLoadFlags(&flags))) { SetDefaultLoadFlags(flags); } - uint32_t touchEventsOverride; - if (NS_SUCCEEDED(parentAsDocShell->GetTouchEventsOverride(&touchEventsOverride))) { - SetTouchEventsOverride(touchEventsOverride); - } + + SetTouchEventsOverride(parentAsDocShell->GetTouchEventsOverride()); + // We don't need to inherit metaViewportOverride, because the viewport // is only relevant for the outermost nsDocShell, not for any iframes // like this that might be embedded within it. @@ -6114,8 +6116,7 @@ nsDocShell::RefreshURI(nsIURI* aURI, nsIPrincipal* aPrincipal, nsCOMPtr refreshTimer = new nsRefreshTimer(this, aURI, aPrincipal, aDelay, aRepeat, aMetaRefresh); - uint32_t busyFlags = 0; - GetBusyFlags(&busyFlags); + BusyFlags busyFlags = GetBusyFlags(); if (!mRefreshURIList) { mRefreshURIList = nsArray::Create(); @@ -6798,7 +6799,7 @@ nsDocShell::OnStateChange(nsIWebProgress* aProgress, nsIRequest* aRequest, } } // Page has begun to load - mBusyFlags = BUSY_FLAGS_BUSY | BUSY_FLAGS_BEFORE_PAGE_LOAD; + mBusyFlags = (BusyFlags)(BUSY_FLAGS_BUSY | BUSY_FLAGS_BEFORE_PAGE_LOAD); if ((aStateFlags & STATE_RESTORING) == 0) { // Show the progress cursor if the pref is set @@ -6812,7 +6813,7 @@ nsDocShell::OnStateChange(nsIWebProgress* aProgress, nsIRequest* aRequest, } } else if ((~aStateFlags & (STATE_TRANSFERRING | STATE_IS_DOCUMENT)) == 0) { // Page is loading - mBusyFlags = BUSY_FLAGS_BUSY | BUSY_FLAGS_PAGE_LOADING; + mBusyFlags = (BusyFlags)(BUSY_FLAGS_BUSY | BUSY_FLAGS_PAGE_LOADING); } else if ((aStateFlags & STATE_STOP) && (aStateFlags & STATE_IS_NETWORK)) { // Page has finished loading mBusyFlags = BUSY_FLAGS_NONE; @@ -13574,14 +13575,14 @@ nsDocShell::GetCanExecuteScripts(bool* aResult) } /* [infallible] */ NS_IMETHODIMP -nsDocShell::SetFrameType(uint32_t aFrameType) +nsDocShell::SetFrameType(FrameType aFrameType) { mFrameType = aFrameType; return NS_OK; } /* [infallible] */ NS_IMETHODIMP -nsDocShell::GetFrameType(uint32_t* aFrameType) +nsDocShell::GetFrameType(FrameType* aFrameType) { *aFrameType = mFrameType; return NS_OK; @@ -14064,15 +14065,17 @@ nsIDocShell::SetHTMLEditor(HTMLEditor* aHTMLEditor) } NS_IMETHODIMP -nsDocShell::GetDisplayMode(uint32_t* aDisplayMode) +nsDocShell::GetDisplayMode(DisplayMode* aDisplayMode) { *aDisplayMode = mDisplayMode; return NS_OK; } NS_IMETHODIMP -nsDocShell::SetDisplayMode(uint32_t aDisplayMode) +nsDocShell::SetDisplayMode(DisplayMode aDisplayMode) { + // We don't have a way to verify this coming from Javascript, so this check is + // still needed. if (!(aDisplayMode == nsIDocShell::DISPLAY_MODE_BROWSER || aDisplayMode == nsIDocShell::DISPLAY_MODE_STANDALONE || aDisplayMode == nsIDocShell::DISPLAY_MODE_FULLSCREEN || diff --git a/docshell/base/nsDocShell.h b/docshell/base/nsDocShell.h index 0e90f90a54ec..caeda129ef76 100644 --- a/docshell/base/nsDocShell.h +++ b/docshell/base/nsDocShell.h @@ -133,38 +133,38 @@ class nsDocShell final { public: enum InternalLoad : uint32_t { - INTERNAL_LOAD_FLAGS_NONE = 0x0, - INTERNAL_LOAD_FLAGS_INHERIT_PRINCIPAL = 0x1, - INTERNAL_LOAD_FLAGS_DONT_SEND_REFERRER = 0x2, - INTERNAL_LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP = 0x4, + INTERNAL_LOAD_FLAGS_NONE = 0x0, + INTERNAL_LOAD_FLAGS_INHERIT_PRINCIPAL = 0x1, + INTERNAL_LOAD_FLAGS_DONT_SEND_REFERRER = 0x2, + INTERNAL_LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP = 0x4, - // This flag marks the first load in this object - // @see nsIWebNavigation::LOAD_FLAGS_FIRST_LOAD - INTERNAL_LOAD_FLAGS_FIRST_LOAD = 0x8, + // This flag marks the first load in this object + // @see nsIWebNavigation::LOAD_FLAGS_FIRST_LOAD + INTERNAL_LOAD_FLAGS_FIRST_LOAD = 0x8, - // The set of flags that should not be set before calling into - // nsDocShell::LoadURI and other nsDocShell loading functions. - INTERNAL_LOAD_FLAGS_LOADURI_SETUP_FLAGS = 0xf, + // The set of flags that should not be set before calling into + // nsDocShell::LoadURI and other nsDocShell loading functions. + INTERNAL_LOAD_FLAGS_LOADURI_SETUP_FLAGS = 0xf, - INTERNAL_LOAD_FLAGS_BYPASS_CLASSIFIER = 0x10, - INTERNAL_LOAD_FLAGS_FORCE_ALLOW_COOKIES = 0x20, + INTERNAL_LOAD_FLAGS_BYPASS_CLASSIFIER = 0x10, + INTERNAL_LOAD_FLAGS_FORCE_ALLOW_COOKIES = 0x20, - // Whether the load should be treated as srcdoc load, rather than a URI one. - INTERNAL_LOAD_FLAGS_IS_SRCDOC = 0x40, + // Whether the load should be treated as srcdoc load, rather than a URI one. + INTERNAL_LOAD_FLAGS_IS_SRCDOC = 0x40, - // Whether this is the load of a frame's original src attribute - INTERNAL_LOAD_FLAGS_ORIGINAL_FRAME_SRC = 0x80, + // Whether this is the load of a frame's original src attribute + INTERNAL_LOAD_FLAGS_ORIGINAL_FRAME_SRC = 0x80, - INTERNAL_LOAD_FLAGS_NO_OPENER = 0x100, + INTERNAL_LOAD_FLAGS_NO_OPENER = 0x100, - // Whether a top-level data URI navigation is allowed for that load - INTERNAL_LOAD_FLAGS_FORCE_ALLOW_DATA_URI = 0x200, + // Whether a top-level data URI navigation is allowed for that load + INTERNAL_LOAD_FLAGS_FORCE_ALLOW_DATA_URI = 0x200, - // Whether the load was triggered by user interaction. - INTERNAL_LOAD_FLAGS_IS_USER_TRIGGERED = 0x1000, - }; + // Whether the load was triggered by user interaction. + INTERNAL_LOAD_FLAGS_IS_USER_TRIGGERED = 0x1000, + }; // Event type dispatched by RestorePresentation class RestorePresentationEvent : public mozilla::Runnable @@ -1089,15 +1089,15 @@ private: // data members int32_t mChildOffset; uint32_t mSandboxFlags; - uint32_t mBusyFlags; - uint32_t mAppType; + BusyFlags mBusyFlags; + AppType mAppType; uint32_t mLoadType; uint32_t mDefaultLoadFlags; uint32_t mReferrerPolicy; uint32_t mFailedLoadType; // Are we a regular frame, a browser frame, or an app frame? - uint32_t mFrameType; + FrameType mFrameType; // This represents the state of private browsing in the docshell. // Currently treated as a binary value: 1 - in private mode, 0 - not private mode @@ -1106,17 +1106,9 @@ private: // data members // origin attribute set. uint32_t mPrivateBrowsingId; - // This represents the CSS display-mode we are currently using. - // It can be any of the following values from nsIDocShell.idl: - // - // DISPLAY_MODE_BROWSER = 0 - // DISPLAY_MODE_MINIMAL_UI = 1 - // DISPLAY_MODE_STANDALONE = 2 - // DISPLAY_MODE_FULLSCREEN = 3 - // - // This is mostly used for media queries. The integer values above - // match those used in nsStyleConsts.h - uint32_t mDisplayMode; + // This represents the CSS display-mode we are currently using. This is mostly + // used for media queries. + DisplayMode mDisplayMode; // A depth count of how many times NotifyRunToCompletionStart // has been called without a matching NotifyRunToCompletionStop. @@ -1124,11 +1116,11 @@ private: // data members // Whether or not touch events are overridden. Possible values are defined // as constants in the nsIDocShell.idl file. - uint32_t mTouchEventsOverride; + TouchEventsOverride mTouchEventsOverride; // Whether or not handling of the tag is overridden. // Possible values are defined as constants in nsIDocShell.idl. - uint32_t mMetaViewportOverride; + MetaViewportOverride mMetaViewportOverride; // mFullscreenAllowed stores how we determine whether fullscreen is allowed // when GetFullscreenAllowed() is called. Fullscreen is allowed in a diff --git a/docshell/base/nsIDocShell.idl b/docshell/base/nsIDocShell.idl index 87c366abf19c..1b3a5ecd7020 100644 --- a/docshell/base/nsIDocShell.idl +++ b/docshell/base/nsIDocShell.idl @@ -323,20 +323,29 @@ interface nsIDocShell : nsIDocShellTreeItem * @param aDirection - Whether to enumerate forwards or backwards. */ - const long ENUMERATE_FORWARDS = 0; - const long ENUMERATE_BACKWARDS = 1; + cenum DocShellEnumeratorDirection : 8 { + ENUMERATE_FORWARDS = 0, + ENUMERATE_BACKWARDS = 1 + }; nsISimpleEnumerator getDocShellEnumerator(in long aItemType, - in long aDirection); + in nsIDocShell_DocShellEnumeratorDirection aDirection); /** - * The type of application that created this window + * The type of application that created this window. + * + * DO NOT DELETE, see bug 176166. For firefox, this value will always be + * UNKNOWN. However, it is used heavily in Thunderbird/comm-central and we + * don't really have a great replacement at the moment, so we'll just leave it + * here. */ - const unsigned long APP_TYPE_UNKNOWN = 0; - const unsigned long APP_TYPE_MAIL = 1; - const unsigned long APP_TYPE_EDITOR = 2; + cenum AppType : 8 { + APP_TYPE_UNKNOWN = 0, + APP_TYPE_MAIL = 1, + APP_TYPE_EDITOR = 2 + }; - attribute unsigned long appType; + [infallible] attribute nsIDocShell_AppType appType; /** * certain dochshells (like the message pane) @@ -384,25 +393,30 @@ interface nsIDocShell : nsIDocShellTreeItem /** * Current busy state for DocShell */ - const unsigned long BUSY_FLAGS_NONE = 0; - const unsigned long BUSY_FLAGS_BUSY = 1; - const unsigned long BUSY_FLAGS_BEFORE_PAGE_LOAD = 2; - const unsigned long BUSY_FLAGS_PAGE_LOADING = 4; + cenum BusyFlags : 8 { + BUSY_FLAGS_NONE = 0, + BUSY_FLAGS_BUSY = 1, + BUSY_FLAGS_BEFORE_PAGE_LOAD = 2, + BUSY_FLAGS_PAGE_LOADING = 4, + }; + + [infallible] readonly attribute nsIDocShell_BusyFlags busyFlags; /** * Load commands for the document */ - const unsigned long LOAD_CMD_NORMAL = 0x1; // Normal load - const unsigned long LOAD_CMD_RELOAD = 0x2; // Reload - const unsigned long LOAD_CMD_HISTORY = 0x4; // Load from history - const unsigned long LOAD_CMD_PUSHSTATE = 0x8; // History.pushState() - - readonly attribute unsigned long busyFlags; + cenum LoadCommand : 8 { + LOAD_CMD_NORMAL = 0x1, // Normal load + LOAD_CMD_RELOAD = 0x2, // Reload + LOAD_CMD_HISTORY = 0x4, // Load from history + LOAD_CMD_PUSHSTATE = 0x8, // History.pushState() + }; /* - * attribute to access the loadtype for the document + * Attribute to access the loadtype for the document. LoadType Enum is + * defined in nsDocShellLoadTypes.h */ - attribute unsigned long loadType; + [infallible] attribute unsigned long loadType; /* * Default load flags (as defined in nsIRequest) that will be set on all @@ -787,10 +801,11 @@ interface nsIDocShell : nsIDocShellTreeItem /** * The type of iframe that this docshell lives. */ - const unsigned long FRAME_TYPE_REGULAR = 0; - const unsigned long FRAME_TYPE_BROWSER = 1; - - [infallible] attribute unsigned long frameType; + cenum FrameType : 8 { + FRAME_TYPE_REGULAR = 0, + FRAME_TYPE_BROWSER = 1, + }; + [infallible] attribute nsIDocShell_FrameType frameType; /** * Returns true if this docshell corresponds to an