From a93dcc56d17f12b688d60f663f6af7836b4017d9 Mon Sep 17 00:00:00 2001 From: Hannes Verschore Date: Tue, 19 Mar 2013 11:12:17 +0100 Subject: [PATCH 001/146] Bug 851552: IonMonkey: Disable GetElement caches after failing multiple times to attach stubs, r=djvj --- js/src/ion/IonCaches.cpp | 16 ++++++++++++---- js/src/ion/IonCaches.h | 19 ++++++++++++++++++- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/js/src/ion/IonCaches.cpp b/js/src/ion/IonCaches.cpp index 20a505123f94..8c058909b8ec 100644 --- a/js/src/ion/IonCaches.cpp +++ b/js/src/ion/IonCaches.cpp @@ -1486,6 +1486,8 @@ SetPropertyIC::update(JSContext *cx, size_t cacheIndex, HandleObject obj, return true; } +const size_t GetElementIC::MAX_FAILED_UPDATES = 16; + bool GetElementIC::attachGetProp(JSContext *cx, IonScript *ion, HandleObject obj, const Value &idval, HandlePropertyName name) @@ -1725,10 +1727,16 @@ GetElementIC::update(JSContext *cx, size_t cacheIndex, HandleObject obj, if (!GetElementOperation(cx, JSOp(*pc), &lval, idval, res)) return false; - // If no new attach was done, and we've reached maximum number of stubs, then - // disable the cache. - if (!attachedStub && !cache.canAttachStub()) - cache.disable(); + // Disable cache when we reach max stubs or update failed too much. + if (!attachedStub) { + cache.incFailedUpdates(); + if (cache.shouldDisable()) { + IonSpew(IonSpew_InlineCaches, "Disable inline cache"); + cache.disable(); + } + } else { + cache.resetFailedUpdates(); + } types::TypeScript::Monitor(cx, script, pc, res); return true; diff --git a/js/src/ion/IonCaches.h b/js/src/ion/IonCaches.h index 7c37ccb227f5..1f1dad3b3c32 100644 --- a/js/src/ion/IonCaches.h +++ b/js/src/ion/IonCaches.h @@ -411,9 +411,14 @@ class GetElementIC : public IonCache Register object_; ConstantOrRegister index_; TypedOrValueRegister output_; + bool monitoredResult_ : 1; bool hasDenseStub_ : 1; + size_t failedUpdates_; + + static const size_t MAX_FAILED_UPDATES; + public: GetElementIC(Register object, ConstantOrRegister index, TypedOrValueRegister output, bool monitoredResult) @@ -421,7 +426,8 @@ class GetElementIC : public IonCache index_(index), output_(output), monitoredResult_(monitoredResult), - hasDenseStub_(false) + hasDenseStub_(false), + failedUpdates_(0) { } @@ -454,6 +460,17 @@ class GetElementIC : public IonCache static bool update(JSContext *cx, size_t cacheIndex, HandleObject obj, HandleValue idval, MutableHandleValue vp); + + void incFailedUpdates() { + failedUpdates_++; + } + void resetFailedUpdates() { + failedUpdates_ = 0; + } + bool shouldDisable() const { + return !canAttachStub() || + (stubCount_ == 0 && failedUpdates_ > MAX_FAILED_UPDATES); + } }; class BindNameIC : public IonCache From cdaa20a0dd16cff0b80579187edb291262d40c63 Mon Sep 17 00:00:00 2001 From: Jan de Mooij Date: Tue, 19 Mar 2013 12:23:51 +0100 Subject: [PATCH 002/146] Bug 851053 - Remove MRecompileCheck. r=bhackett --- js/src/ion/Bailouts.cpp | 21 --------------- js/src/ion/Bailouts.h | 11 +++----- js/src/ion/IonBuilder.cpp | 31 +---------------------- js/src/ion/IonBuilder.h | 2 -- js/src/ion/IonMacroAssembler.cpp | 23 ++++------------- js/src/ion/IonTypes.h | 3 --- js/src/ion/LOpcodes.h | 1 - js/src/ion/MIR.h | 26 ------------------- js/src/ion/MOpcodes.h | 1 - js/src/ion/ParallelArrayAnalysis.cpp | 1 - js/src/ion/TypeOracle.cpp | 6 ----- js/src/ion/TypeOracle.h | 4 --- js/src/ion/arm/CodeGenerator-arm.cpp | 20 --------------- js/src/ion/arm/CodeGenerator-arm.h | 1 - js/src/ion/arm/LIR-arm.h | 16 ------------ js/src/ion/arm/Lowering-arm.cpp | 7 ----- js/src/ion/arm/Lowering-arm.h | 1 - js/src/ion/shared/LIR-x86-shared.h | 10 -------- js/src/ion/shared/Lowering-x86-shared.cpp | 7 ----- js/src/ion/shared/Lowering-x86-shared.h | 1 - js/src/ion/x64/CodeGenerator-x64.cpp | 17 ------------- js/src/ion/x64/CodeGenerator-x64.h | 1 - js/src/ion/x86/CodeGenerator-x86.cpp | 15 ----------- js/src/ion/x86/CodeGenerator-x86.h | 1 - 24 files changed, 10 insertions(+), 217 deletions(-) diff --git a/js/src/ion/Bailouts.cpp b/js/src/ion/Bailouts.cpp index 96dce48e37cf..4adcc700967f 100644 --- a/js/src/ion/Bailouts.cpp +++ b/js/src/ion/Bailouts.cpp @@ -315,8 +315,6 @@ ConvertFrames(JSContext *cx, IonActivation *activation, IonBailoutIterator &it) return BAILOUT_RETURN_TYPE_BARRIER; case Bailout_Monitor: return BAILOUT_RETURN_MONITOR; - case Bailout_RecompileCheck: - return BAILOUT_RETURN_RECOMPILE_CHECK; case Bailout_BoundsCheck: return BAILOUT_RETURN_BOUNDS_CHECK; case Bailout_ShapeGuard: @@ -471,25 +469,6 @@ ion::ReflowTypeInfo(uint32_t bailoutResult) return true; } -uint32_t -ion::RecompileForInlining() -{ - JSContext *cx = GetIonContext()->cx; - RawScript script = cx->fp()->script(); - - IonSpew(IonSpew_Inlining, "Recompiling script to inline calls %s:%d", script->filename(), - script->lineno); - - // Invalidate the script to force a recompile. - if (!Invalidate(cx, script, /* resetUses */ false)) - return BAILOUT_RETURN_FATAL_ERROR; - - // Invalidation should not reset the use count. - JS_ASSERT(script->getUseCount() >= js_IonOptions.usesBeforeInlining()); - - return true; -} - // Initialize the decl env Object and the call object of the current frame. bool ion::EnsureHasScopeObjects(JSContext *cx, StackFrame *fp) diff --git a/js/src/ion/Bailouts.h b/js/src/ion/Bailouts.h index 4924c7e81395..1bd8b64b26e9 100644 --- a/js/src/ion/Bailouts.h +++ b/js/src/ion/Bailouts.h @@ -104,11 +104,10 @@ static const uint32_t BAILOUT_RETURN_FATAL_ERROR = 1; static const uint32_t BAILOUT_RETURN_ARGUMENT_CHECK = 2; static const uint32_t BAILOUT_RETURN_TYPE_BARRIER = 3; static const uint32_t BAILOUT_RETURN_MONITOR = 4; -static const uint32_t BAILOUT_RETURN_RECOMPILE_CHECK = 5; -static const uint32_t BAILOUT_RETURN_BOUNDS_CHECK = 6; -static const uint32_t BAILOUT_RETURN_SHAPE_GUARD = 7; -static const uint32_t BAILOUT_RETURN_OVERRECURSED = 8; -static const uint32_t BAILOUT_RETURN_CACHED_SHAPE_GUARD = 9; +static const uint32_t BAILOUT_RETURN_BOUNDS_CHECK = 5; +static const uint32_t BAILOUT_RETURN_SHAPE_GUARD = 6; +static const uint32_t BAILOUT_RETURN_OVERRECURSED = 7; +static const uint32_t BAILOUT_RETURN_CACHED_SHAPE_GUARD = 8; // Attached to the compartment for easy passing through from ::Bailout to // ::ThunkToInterpreter. @@ -218,8 +217,6 @@ uint32_t ThunkToInterpreter(Value *vp); uint32_t ReflowTypeInfo(uint32_t bailoutResult); -uint32_t RecompileForInlining(); - uint32_t BoundsCheckFailure(); uint32_t ShapeGuardFailure(); diff --git a/js/src/ion/IonBuilder.cpp b/js/src/ion/IonBuilder.cpp index 8aec70f9a80a..7c4aebd0f0ce 100644 --- a/js/src/ion/IonBuilder.cpp +++ b/js/src/ion/IonBuilder.cpp @@ -338,9 +338,6 @@ IonBuilder::build() ins->setResumePoint(current->entryResumePoint()); } - // Recompile to inline calls if this function is hot. - insertRecompileCheck(); - if (script()->argumentsHasVarBinding()) { lazyArguments_ = MConstant::New(MagicValue(JS_OPTIMIZED_ARGUMENTS)); current->add(lazyArguments_); @@ -763,12 +760,9 @@ IonBuilder::inspectOpcode(JSOp op) return true; switch (op) { - case JSOP_LOOPENTRY: - insertRecompileCheck(); - return true; - case JSOP_NOP: case JSOP_LINENO: + case JSOP_LOOPENTRY: return true; case JSOP_LABEL: @@ -4975,29 +4969,6 @@ IonBuilder::maybeInsertResume() return resumeAfter(ins); } -void -IonBuilder::insertRecompileCheck() -{ - if (!inliningEnabled()) - return; - - if (inliningDepth_ > 0) - return; - - // Don't recompile if we are already inlining. - if (script()->getUseCount() >= js_IonOptions.usesBeforeInlining()) - return; - - // Don't recompile if the oracle cannot provide inlining information - // or if the script has no calls. - if (!oracle->canInlineCalls()) - return; - - uint32_t minUses = UsesBeforeIonRecompile(script(), pc); - MRecompileCheck *check = MRecompileCheck::New(minUses); - current->add(check); -} - static inline bool TestSingletonProperty(JSContext *cx, HandleObject obj, HandleId id, bool *isKnownConstant) { diff --git a/js/src/ion/IonBuilder.h b/js/src/ion/IonBuilder.h index 3e5176dc94dd..2f4fd052a3c0 100644 --- a/js/src/ion/IonBuilder.h +++ b/js/src/ion/IonBuilder.h @@ -271,8 +271,6 @@ class IonBuilder : public MIRGenerator bool resumeAfter(MInstruction *ins); bool maybeInsertResume(); - void insertRecompileCheck(); - bool initParameters(); void rewriteParameters(); bool initScopeChain(); diff --git a/js/src/ion/IonMacroAssembler.cpp b/js/src/ion/IonMacroAssembler.cpp index 8e9fb27fde43..250364d8ead8 100644 --- a/js/src/ion/IonMacroAssembler.cpp +++ b/js/src/ion/IonMacroAssembler.cpp @@ -655,7 +655,6 @@ MacroAssembler::generateBailoutTail(Register scratch) Label interpret; Label exception; Label osr; - Label recompile; Label boundscheck; Label overrecursed; Label invalidate; @@ -666,17 +665,15 @@ MacroAssembler::generateBailoutTail(Register scratch) // - 0x2: reflow args // - 0x3: reflow barrier // - 0x4: monitor types - // - 0x5: recompile to inline calls - // - 0x6: bounds check failure - // - 0x7: force invalidation - // - 0x8: overrecursed - // - 0x9: cached shape guard failure + // - 0x5: bounds check failure + // - 0x6: force invalidation + // - 0x7: overrecursed + // - 0x8: cached shape guard failure branch32(LessThan, ReturnReg, Imm32(BAILOUT_RETURN_FATAL_ERROR), &interpret); branch32(Equal, ReturnReg, Imm32(BAILOUT_RETURN_FATAL_ERROR), &exception); - branch32(LessThan, ReturnReg, Imm32(BAILOUT_RETURN_RECOMPILE_CHECK), &reflow); - branch32(Equal, ReturnReg, Imm32(BAILOUT_RETURN_RECOMPILE_CHECK), &recompile); + branch32(LessThan, ReturnReg, Imm32(BAILOUT_RETURN_BOUNDS_CHECK), &reflow); branch32(Equal, ReturnReg, Imm32(BAILOUT_RETURN_BOUNDS_CHECK), &boundscheck); branch32(Equal, ReturnReg, Imm32(BAILOUT_RETURN_OVERRECURSED), &overrecursed); @@ -711,16 +708,6 @@ MacroAssembler::generateBailoutTail(Register scratch) jump(&interpret); } - // Recompile to inline calls. - bind(&recompile); - { - setupUnalignedABICall(0, scratch); - callWithABI(JS_FUNC_TO_DATA_PTR(void *, RecompileForInlining)); - - branchTest32(Zero, ReturnReg, ReturnReg, &exception); - jump(&interpret); - } - // Reflow types. bind(&reflow); { diff --git a/js/src/ion/IonTypes.h b/js/src/ion/IonTypes.h index aab161adcf55..35a1b233697e 100644 --- a/js/src/ion/IonTypes.h +++ b/js/src/ion/IonTypes.h @@ -37,9 +37,6 @@ enum BailoutKind // A bailout required to monitor the result of a VM call. Bailout_Monitor, - // A bailout to trigger recompilation to inline calls when the script is hot. - Bailout_RecompileCheck, - // A bailout triggered by a bounds-check failure. Bailout_BoundsCheck, diff --git a/js/src/ion/LOpcodes.h b/js/src/ion/LOpcodes.h index 895eafab4fc4..73cad11e8721 100644 --- a/js/src/ion/LOpcodes.h +++ b/js/src/ion/LOpcodes.h @@ -36,7 +36,6 @@ _(InitProp) \ _(CheckOverRecursed) \ _(ParCheckOverRecursed) \ - _(RecompileCheck) \ _(DefVar) \ _(DefFun) \ _(CallKnown) \ diff --git a/js/src/ion/MIR.h b/js/src/ion/MIR.h index 92d98ef8e7d7..560b85103c23 100644 --- a/js/src/ion/MIR.h +++ b/js/src/ion/MIR.h @@ -3475,32 +3475,6 @@ class MParCheckInterrupt : public MUnaryInstruction } }; -// Check the script's use count and trigger recompilation to inline -// calls when the script becomes hot. -class MRecompileCheck : public MNullaryInstruction -{ - uint32_t minUses_; - - MRecompileCheck(uint32_t minUses) - : minUses_(minUses) - { - setGuard(); - } - - public: - INSTRUCTION_HEADER(RecompileCheck) - - uint32_t minUses() const { - return minUses_; - } - static MRecompileCheck *New(uint32_t minUses) { - return new MRecompileCheck(minUses); - } - AliasSet getAliasSet() const { - return AliasSet::None(); - } -}; - // Check whether we need to fire the interrupt handler. class MInterruptCheck : public MNullaryInstruction { diff --git a/js/src/ion/MOpcodes.h b/js/src/ion/MOpcodes.h index 1053f52dea78..745ecf2ee1fa 100644 --- a/js/src/ion/MOpcodes.h +++ b/js/src/ion/MOpcodes.h @@ -27,7 +27,6 @@ namespace ion { _(OsrScopeChain) \ _(ReturnFromCtor) \ _(CheckOverRecursed) \ - _(RecompileCheck) \ _(DefVar) \ _(DefFun) \ _(CreateThis) \ diff --git a/js/src/ion/ParallelArrayAnalysis.cpp b/js/src/ion/ParallelArrayAnalysis.cpp index ed7ab81495f3..83cb6705551a 100644 --- a/js/src/ion/ParallelArrayAnalysis.cpp +++ b/js/src/ion/ParallelArrayAnalysis.cpp @@ -131,7 +131,6 @@ class ParallelArrayVisitor : public MInstructionVisitor UNSAFE_OP(OsrScopeChain) UNSAFE_OP(ReturnFromCtor) CUSTOM_OP(CheckOverRecursed) - DROP_OP(RecompileCheck) UNSAFE_OP(DefVar) UNSAFE_OP(DefFun) UNSAFE_OP(CreateThis) diff --git a/js/src/ion/TypeOracle.cpp b/js/src/ion/TypeOracle.cpp index 22124daa400d..e9fec71e0106 100644 --- a/js/src/ion/TypeOracle.cpp +++ b/js/src/ion/TypeOracle.cpp @@ -528,12 +528,6 @@ TypeInferenceOracle::arrayResultShouldHaveDoubleConversion(RawScript script, jsb return conversion == types::StackTypeSet::AlwaysConvertToDoubles; } -bool -TypeInferenceOracle::canInlineCalls() -{ - return script()->analysis()->hasFunctionCalls(); -} - bool TypeInferenceOracle::propertyWriteCanSpecialize(RawScript script, jsbytecode *pc) { diff --git a/js/src/ion/TypeOracle.h b/js/src/ion/TypeOracle.h index a09d8c513396..e85b36d81bb8 100644 --- a/js/src/ion/TypeOracle.h +++ b/js/src/ion/TypeOracle.h @@ -144,9 +144,6 @@ class TypeOracle virtual MIRType elementWrite(RawScript script, jsbytecode *pc) { return MIRType_None; } - virtual bool canInlineCalls() { - return false; - } /* |pc| must be a |JSOP_CALL|. */ virtual types::StackTypeSet *getCallTarget(RawScript caller, uint32_t argc, jsbytecode *pc) { @@ -274,7 +271,6 @@ class TypeInferenceOracle : public TypeOracle bool propertyWriteNeedsBarrier(RawScript script, jsbytecode *pc, RawId id); bool elementWriteNeedsBarrier(RawScript script, jsbytecode *pc); MIRType elementWrite(RawScript script, jsbytecode *pc); - bool canInlineCalls(); bool canInlineCall(HandleScript caller, jsbytecode *pc); types::TypeBarrier *callArgsBarrier(HandleScript caller, jsbytecode *pc); bool canEnterInlinedFunction(RawScript caller, jsbytecode *pc, RawFunction callee); diff --git a/js/src/ion/arm/CodeGenerator-arm.cpp b/js/src/ion/arm/CodeGenerator-arm.cpp index 8ff13700e18d..5d4762828a3c 100644 --- a/js/src/ion/arm/CodeGenerator-arm.cpp +++ b/js/src/ion/arm/CodeGenerator-arm.cpp @@ -1556,26 +1556,6 @@ CodeGeneratorARM::visitImplicitThis(LImplicitThis *lir) return true; } -bool -CodeGeneratorARM::visitRecompileCheck(LRecompileCheck *lir) -{ - Register tmp = ToRegister(lir->tempInt()); - size_t *addr = gen->info().script()->addressOfUseCount(); - - // Bump the script's use count. Note that it's safe to bake in this pointer - // since scripts are never nursery allocated and jitcode will be purged before - // doing a compacting GC. - masm.load32(AbsoluteAddress(addr), tmp); - masm.ma_add(Imm32(1), tmp); - masm.store32(tmp, AbsoluteAddress(addr)); - - // Bailout if the script is hot. - masm.ma_cmp(tmp, Imm32(lir->mir()->minUses())); - if (!bailoutIf(Assembler::AboveOrEqual, lir->snapshot())) - return false; - return true; -} - typedef bool (*InterruptCheckFn)(JSContext *); static const VMFunction InterruptCheckInfo = FunctionInfo(InterruptCheck); diff --git a/js/src/ion/arm/CodeGenerator-arm.h b/js/src/ion/arm/CodeGenerator-arm.h index 4d9c777eb72f..1fea2a536250 100644 --- a/js/src/ion/arm/CodeGenerator-arm.h +++ b/js/src/ion/arm/CodeGenerator-arm.h @@ -139,7 +139,6 @@ class CodeGeneratorARM : public CodeGeneratorShared bool visitGuardClass(LGuardClass *guard); bool visitImplicitThis(LImplicitThis *lir); - bool visitRecompileCheck(LRecompileCheck *lir); bool visitInterruptCheck(LInterruptCheck *lir); bool generateInvalidateEpilogue(); diff --git a/js/src/ion/arm/LIR-arm.h b/js/src/ion/arm/LIR-arm.h index bd5e41971575..89321255ac7e 100644 --- a/js/src/ion/arm/LIR-arm.h +++ b/js/src/ion/arm/LIR-arm.h @@ -278,22 +278,6 @@ class LGuardShape : public LInstructionHelper<0, 1, 1> } }; -class LRecompileCheck : public LInstructionHelper<0, 0, 1> -{ - public: - LIR_HEADER(RecompileCheck); - - LRecompileCheck(const LDefinition &temp) { - setTemp(0, temp); - } - const LAllocation *tempInt() { - return getTemp(0)->output(); - } - const MRecompileCheck *mir() const { - return mir_->toRecompileCheck(); - } -}; - class LInterruptCheck : public LInstructionHelper<0, 0, 0> { public: diff --git a/js/src/ion/arm/Lowering-arm.cpp b/js/src/ion/arm/Lowering-arm.cpp index 13e5d0d583cc..25854c99c0d0 100644 --- a/js/src/ion/arm/Lowering-arm.cpp +++ b/js/src/ion/arm/Lowering-arm.cpp @@ -316,13 +316,6 @@ LIRGeneratorARM::visitGuardShape(MGuardShape *ins) return redefine(ins, ins->obj()); } -bool -LIRGeneratorARM::visitRecompileCheck(MRecompileCheck *ins) -{ - LRecompileCheck *lir = new LRecompileCheck(temp(LDefinition::GENERAL)); - return assignSnapshot(lir, Bailout_RecompileCheck) && add(lir, ins); -} - bool LIRGeneratorARM::visitStoreTypedArrayElement(MStoreTypedArrayElement *ins) { diff --git a/js/src/ion/arm/Lowering-arm.h b/js/src/ion/arm/Lowering-arm.h index e90cd818d850..6d13b2b8ecd0 100644 --- a/js/src/ion/arm/Lowering-arm.h +++ b/js/src/ion/arm/Lowering-arm.h @@ -60,7 +60,6 @@ class LIRGeneratorARM : public LIRGeneratorShared bool visitReturn(MReturn *ret); bool lowerPhi(MPhi *phi); bool visitGuardShape(MGuardShape *ins); - bool visitRecompileCheck(MRecompileCheck *ins); bool visitStoreTypedArrayElement(MStoreTypedArrayElement *ins); bool visitInterruptCheck(MInterruptCheck *ins); }; diff --git a/js/src/ion/shared/LIR-x86-shared.h b/js/src/ion/shared/LIR-x86-shared.h index 1549fff6e367..4cec8fbed08a 100644 --- a/js/src/ion/shared/LIR-x86-shared.h +++ b/js/src/ion/shared/LIR-x86-shared.h @@ -188,16 +188,6 @@ class LGuardShape : public LInstructionHelper<0, 1, 0> } }; -class LRecompileCheck : public LInstructionHelper<0, 0, 0> -{ - public: - LIR_HEADER(RecompileCheck) - - const MRecompileCheck *mir() const { - return mir_->toRecompileCheck(); - } -}; - class LInterruptCheck : public LInstructionHelper<0, 0, 0> { public: diff --git a/js/src/ion/shared/Lowering-x86-shared.cpp b/js/src/ion/shared/Lowering-x86-shared.cpp index 27e63dc4bf4b..95496d77e916 100644 --- a/js/src/ion/shared/Lowering-x86-shared.cpp +++ b/js/src/ion/shared/Lowering-x86-shared.cpp @@ -25,13 +25,6 @@ LIRGeneratorX86Shared::newLTableSwitchV(MTableSwitch *tableswitch) return new LTableSwitchV(temp(), tempFloat(), temp(), tableswitch); } -bool -LIRGeneratorX86Shared::visitRecompileCheck(MRecompileCheck *ins) -{ - LRecompileCheck *lir = new LRecompileCheck(); - return assignSnapshot(lir, Bailout_RecompileCheck) && add(lir, ins); -} - bool LIRGeneratorX86Shared::visitInterruptCheck(MInterruptCheck *ins) { diff --git a/js/src/ion/shared/Lowering-x86-shared.h b/js/src/ion/shared/Lowering-x86-shared.h index 8d8f316c9584..797f552baeb2 100644 --- a/js/src/ion/shared/Lowering-x86-shared.h +++ b/js/src/ion/shared/Lowering-x86-shared.h @@ -24,7 +24,6 @@ class LIRGeneratorX86Shared : public LIRGeneratorShared MTableSwitch *ins); LTableSwitchV *newLTableSwitchV(MTableSwitch *ins); - bool visitRecompileCheck(MRecompileCheck *ins); bool visitInterruptCheck(MInterruptCheck *ins); bool visitGuardShape(MGuardShape *ins); bool visitPowHalf(MPowHalf *ins); diff --git a/js/src/ion/x64/CodeGenerator-x64.cpp b/js/src/ion/x64/CodeGenerator-x64.cpp index ce99e7348b3d..ea26f568dbe1 100644 --- a/js/src/ion/x64/CodeGenerator-x64.cpp +++ b/js/src/ion/x64/CodeGenerator-x64.cpp @@ -285,23 +285,6 @@ CodeGeneratorX64::visitImplicitThis(LImplicitThis *lir) return true; } -bool -CodeGeneratorX64::visitRecompileCheck(LRecompileCheck *lir) -{ - // Bump the script's use count and bailout if the script is hot. Note that - // it's safe to bake in this pointer since scripts are never nursery - // allocated and jitcode will be purged before doing a compacting GC. - const uint32_t *useCount = gen->info().script()->addressOfUseCount(); - masm.movq(ImmWord(useCount), ScratchReg); - - Operand addr(ScratchReg, 0); - masm.addl(Imm32(1), addr); - masm.cmpl(addr, Imm32(lir->mir()->minUses())); - if (!bailoutIf(Assembler::AboveOrEqual, lir->snapshot())) - return false; - return true; -} - typedef bool (*InterruptCheckFn)(JSContext *); static const VMFunction InterruptCheckInfo = FunctionInfo(InterruptCheck); diff --git a/js/src/ion/x64/CodeGenerator-x64.h b/js/src/ion/x64/CodeGenerator-x64.h index eb897bce6ccb..5360dc710413 100644 --- a/js/src/ion/x64/CodeGenerator-x64.h +++ b/js/src/ion/x64/CodeGenerator-x64.h @@ -46,7 +46,6 @@ class CodeGeneratorX64 : public CodeGeneratorX86Shared bool visitStoreSlotT(LStoreSlotT *store); bool visitLoadElementT(LLoadElementT *load); bool visitImplicitThis(LImplicitThis *lir); - bool visitRecompileCheck(LRecompileCheck *lir); bool visitInterruptCheck(LInterruptCheck *lir); bool visitCompareB(LCompareB *lir); bool visitCompareBAndBranch(LCompareBAndBranch *lir); diff --git a/js/src/ion/x86/CodeGenerator-x86.cpp b/js/src/ion/x86/CodeGenerator-x86.cpp index 34e7574f540c..48b60e0977dd 100644 --- a/js/src/ion/x86/CodeGenerator-x86.cpp +++ b/js/src/ion/x86/CodeGenerator-x86.cpp @@ -262,21 +262,6 @@ CodeGeneratorX86::visitImplicitThis(LImplicitThis *lir) return true; } -bool -CodeGeneratorX86::visitRecompileCheck(LRecompileCheck *lir) -{ - // Bump the script's use count and bailout if the script is hot. Note that - // it's safe to bake in this pointer since scripts are never nursery - // allocated and jitcode will be purged before doing a compacting GC. - // Without this assumption we'd need a temp register here. - Operand addr(gen->info().script()->addressOfUseCount()); - masm.addl(Imm32(1), addr); - masm.cmpl(addr, Imm32(lir->mir()->minUses())); - if (!bailoutIf(Assembler::AboveOrEqual, lir->snapshot())) - return false; - return true; -} - typedef bool (*InterruptCheckFn)(JSContext *); static const VMFunction InterruptCheckInfo = FunctionInfo(InterruptCheck); diff --git a/js/src/ion/x86/CodeGenerator-x86.h b/js/src/ion/x86/CodeGenerator-x86.h index 581e099517f1..9fdc4b6a1b05 100644 --- a/js/src/ion/x86/CodeGenerator-x86.h +++ b/js/src/ion/x86/CodeGenerator-x86.h @@ -45,7 +45,6 @@ class CodeGeneratorX86 : public CodeGeneratorX86Shared bool visitStoreSlotT(LStoreSlotT *store); bool visitLoadElementT(LLoadElementT *load); bool visitImplicitThis(LImplicitThis *lir); - bool visitRecompileCheck(LRecompileCheck *lir); bool visitInterruptCheck(LInterruptCheck *lir); bool visitCompareB(LCompareB *lir); bool visitCompareBAndBranch(LCompareBAndBranch *lir); From 8be12f2ab4098bebb953563ff25b34a4d6667276 Mon Sep 17 00:00:00 2001 From: Gene Lian Date: Tue, 19 Mar 2013 17:08:29 +0800 Subject: [PATCH 003/146] Bug 852460 - B2G MMS: provide nsIDOMMobileMessageManager.onreceived event (follow-up fix). r=vicamo,gene.lian --- dom/mms/src/ril/MmsService.js | 3 ++- dom/mms/src/ril/WspPduHelper.jsm | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/dom/mms/src/ril/MmsService.js b/dom/mms/src/ril/MmsService.js index 18048cf5e90c..64cfff965161 100644 --- a/dom/mms/src/ril/MmsService.js +++ b/dom/mms/src/ril/MmsService.js @@ -1058,6 +1058,7 @@ MmsService.prototype = { mmsStatus, reportAllowed); transaction.run(); + return; } this.retrieveMessage(url, (function responseNotify(mmsStatus, @@ -1082,6 +1083,7 @@ MmsService.prototype = { mmsStatus, reportAllowed); transaction.run(); + return; } savableMessage = this.mergeRetrievalConfirmation(retrievedMessage, @@ -1110,7 +1112,6 @@ MmsService.prototype = { }).bind(this) ); }).bind(this)); - return; }).bind(this) ); }, diff --git a/dom/mms/src/ril/WspPduHelper.jsm b/dom/mms/src/ril/WspPduHelper.jsm index d64588b35408..926c9b957f74 100644 --- a/dom/mms/src/ril/WspPduHelper.jsm +++ b/dom/mms/src/ril/WspPduHelper.jsm @@ -2292,8 +2292,19 @@ this.PduHelper = { let octetArray = Octet.decodeMultiple(data, contentEnd); let content = null; if (octetArray) { - content = new Blob([octetArray], - {type : headers["content-type"].media}); + // If the content is a SMIL type, convert it to a string. + // We hope to save and expose the SMIL content as a string way. + if (headers["content-type"].media == "application/smil") { + let charset = headers["content-type"].params && + headers["content-type"].params.charset + ? headers["content-type"].params.charset["charset"] + : null; + content = this.decodeStringContent(octetArray, charset); + } + if (!content) { + content = new Blob([octetArray], + {type : headers["content-type"].media}); + } } parts[i] = { From 0bf81a6aff7b90fb6d4744628cfeb955465558d4 Mon Sep 17 00:00:00 2001 From: Gene Lian Date: Tue, 19 Mar 2013 19:32:32 +0800 Subject: [PATCH 004/146] Bug 852471 - B2G MMS: provide nsIDOMMobileMessageManager interface (with sendMMS() first) (follow-up fix). r=vicamo a=leo+ --- dom/mms/src/ril/MmsService.js | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/dom/mms/src/ril/MmsService.js b/dom/mms/src/ril/MmsService.js index 64cfff965161..3248efa78219 100644 --- a/dom/mms/src/ril/MmsService.js +++ b/dom/mms/src/ril/MmsService.js @@ -39,21 +39,22 @@ const CONFIG_SEND_REPORT_ALWAYS = 3; const TIME_TO_BUFFER_MMS_REQUESTS = 30000; const TIME_TO_RELEASE_MMS_CONNECTION = 30000; -const PREF_RETRIEVAL_MODE = 'dom.mms.retrieval_mode'; -const RETRIEVAL_MODE_MANUAL = "manual"; +const PREF_RETRIEVAL_MODE = 'dom.mms.retrieval_mode'; +const RETRIEVAL_MODE_MANUAL = "manual"; const RETRIEVAL_MODE_AUTOMATIC = "automatic"; -const RETRIEVAL_MODE_NEVER = "never"; +const RETRIEVAL_MODE_NEVER = "never"; //Internal const values. -const DELIVERY_RECEIVED = "received"; +const DELIVERY_RECEIVED = "received"; const DELIVERY_NOT_DOWNLOADED = "not-downloaded"; -const DELIVERY_SENDING = "sending"; -const DELIVERY_SENT = "sent"; -const DELIVERY_ERROR = "error"; +const DELIVERY_SENDING = "sending"; +const DELIVERY_SENT = "sent"; +const DELIVERY_ERROR = "error"; const DELIVERY_STATUS_SUCCESS = "success"; const DELIVERY_STATUS_PENDING = "pending"; +const DELIVERY_STATUS_ERROR = "error"; const MAX_RETRY_COUNT = Services.prefs.getIntPref("dom.mms.retrievalRetryCount"); @@ -1137,6 +1138,7 @@ MmsService.prototype = { createSavableFromParams: function createSavableFromParams(aParams) { debug("createSavableFromParams: aParams: " + JSON.stringify(aParams)); let message = {}; + let smil = aParams.smil; // |message.headers| let headers = message["headers"] = {}; @@ -1153,18 +1155,24 @@ MmsService.prototype = { // |message.parts| let attachments = aParams.attachments; - if (attachments.length != 0 || aParams.smil) { + if (attachments.length != 0 || smil) { let parts = message["parts"] = []; // Set the SMIL part if needed. - if (aParams.smil) { + if (smil) { let part = { "headers": { "content-type": { "media": "application/smil", + "params": { + "name": "smil.xml" + } }, + "content-length": smil.length, + "content-location": "smil.xml", + "content-id": "" }, - "content": aParams.smil + "content": smil }; parts.push(part); } @@ -1214,8 +1222,8 @@ MmsService.prototype = { gMobileMessageDatabaseService .setMessageDelivery(aRecordId, null, - aIsSentSuccess ? "sent" : "error", - aIsSentSuccess ? null : "error", + aIsSentSuccess ? DELIVERY_SENT : DELIVERY_ERROR, + aIsSentSuccess ? null : DELIVERY_STATUS_ERROR, function notifySetDeliveryResult(aRv, aDomMessage) { debug("Marking the delivery state/staus is done. Notify sent or failed."); if (!aIsSentSuccess) { From eb3d295f7f9734ed0d728f0bd318c8fe80b7b93b Mon Sep 17 00:00:00 2001 From: Andrea Marchesini Date: Tue, 19 Mar 2013 13:23:54 +0100 Subject: [PATCH 005/146] Bug 841493 - Rename nsHTMLMediaElement to HTMLMediaElement, r=Ms2ger --HG-- rename : content/html/content/public/nsHTMLMediaElement.h => content/html/content/public/HTMLMediaElement.h rename : content/html/content/src/nsHTMLMediaElement.cpp => content/html/content/src/HTMLMediaElement.cpp --- content/base/public/nsINode.h | 4 +- content/base/src/nsContentUtils.cpp | 2 +- content/base/src/nsDocument.cpp | 6 +- content/base/src/nsNodeUtils.cpp | 4 +- ...sHTMLMediaElement.h => HTMLMediaElement.h} | 53 +- content/html/content/public/Makefile.in | 2 +- .../html/content/public/nsHTMLAudioElement.h | 8 +- .../html/content/public/nsHTMLVideoElement.h | 8 +- ...LMediaElement.cpp => HTMLMediaElement.cpp} | 509 +++++++++--------- .../html/content/src/HTMLSourceElement.cpp | 2 +- content/html/content/src/HTMLSourceElement.h | 2 +- content/html/content/src/Makefile.in | 2 +- content/html/content/src/MediaError.cpp | 2 +- content/html/content/src/MediaError.h | 8 +- content/html/content/src/TimeRanges.cpp | 2 +- .../html/content/src/nsHTMLAudioElement.cpp | 8 +- .../html/content/src/nsHTMLVideoElement.cpp | 14 +- content/html/document/src/VideoDocument.cpp | 8 +- content/media/MediaDecoderOwner.h | 10 +- content/media/MediaDecoderReader.h | 2 +- content/media/MediaResource.cpp | 20 +- content/media/VideoFrameContainer.cpp | 4 +- content/media/VideoFrameContainer.h | 14 +- content/media/dash/DASHDecoder.cpp | 8 +- content/media/dash/DASHReader.cpp | 2 +- content/media/ogg/OggCodecState.h | 2 +- content/media/plugins/MediaPluginHost.cpp | 2 +- content/media/test/test_playback_rate.html | 2 +- content/media/wave/WaveReader.cpp | 8 +- content/media/wave/WaveReader.h | 4 +- content/media/webaudio/MediaBufferDecoder.cpp | 2 +- layout/base/nsPresShell.cpp | 2 +- layout/generic/nsVideoFrame.cpp | 4 +- 33 files changed, 370 insertions(+), 360 deletions(-) rename content/html/content/public/{nsHTMLMediaElement.h => HTMLMediaElement.h} (96%) rename content/html/content/src/{nsHTMLMediaElement.cpp => HTMLMediaElement.cpp} (86%) diff --git a/content/base/public/nsINode.h b/content/base/public/nsINode.h index 93bdf5e6c5cf..5ff9dc0f14a5 100644 --- a/content/base/public/nsINode.h +++ b/content/base/public/nsINode.h @@ -284,7 +284,7 @@ public: // - HTMLFrameSetElement: mRowSpecs, mColSpecs // - nsHTMLInputElement: mInputData, mFiles, mFileList, mStaticDocfileList // - nsHTMLMapElement: mAreas - // - nsHTMLMediaElement: many! + // - HTMLMediaElement: many! // - nsHTMLOutputElement: mDefaultValue, mTokenList // - nsHTMLRowElement: mCells // - nsHTMLSelectElement: mOptions, mRestoreState @@ -360,7 +360,7 @@ public: /** data nodes (comments, PIs, text). Nodes of this type always returns a non-null value for nsIContent::GetText() */ eDATA_NODE = 1 << 8, - /** nsHTMLMediaElement */ + /** HTMLMediaElement */ eMEDIA = 1 << 9, /** animation elements */ eANIMATION = 1 << 10, diff --git a/content/base/src/nsContentUtils.cpp b/content/base/src/nsContentUtils.cpp index 7a47e565d58d..79507d123bcc 100644 --- a/content/base/src/nsContentUtils.cpp +++ b/content/base/src/nsContentUtils.cpp @@ -168,7 +168,7 @@ #include "nsIBidiKeyboard.h" #endif #ifdef MOZ_MEDIA -#include "nsHTMLMediaElement.h" +#include "mozilla/dom/HTMLMediaElement.h" #endif extern "C" int MOZ_XMLTranslateEntity(const char* ptr, const char* end, diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp index 36fd23eab80b..65955152ca73 100644 --- a/content/base/src/nsDocument.cpp +++ b/content/base/src/nsDocument.cpp @@ -147,7 +147,7 @@ #include "nsHtml5TreeOpExecutor.h" #include "nsIDOMElementReplaceEvent.h" #ifdef MOZ_MEDIA -#include "nsHTMLMediaElement.h" +#include "mozilla/dom/HTMLMediaElement.h" #endif // MOZ_MEDIA #ifdef MOZ_WEBRTC #include "IPeerConnection.h" @@ -3979,7 +3979,7 @@ NotifyActivityChanged(nsIContent *aContent, void *aUnused) #ifdef MOZ_MEDIA nsCOMPtr domMediaElem(do_QueryInterface(aContent)); if (domMediaElem) { - nsHTMLMediaElement* mediaElem = static_cast(aContent); + HTMLMediaElement* mediaElem = static_cast(aContent); mediaElem->NotifyOwnerDocumentActivityChanged(); } #endif @@ -8955,7 +8955,7 @@ NotifyAudioAvailableListener(nsIContent *aContent, void *aUnused) #ifdef MOZ_MEDIA nsCOMPtr domMediaElem(do_QueryInterface(aContent)); if (domMediaElem) { - nsHTMLMediaElement* mediaElem = static_cast(aContent); + HTMLMediaElement* mediaElem = static_cast(aContent); mediaElem->NotifyAudioAvailableListener(); } #endif diff --git a/content/base/src/nsNodeUtils.cpp b/content/base/src/nsNodeUtils.cpp index 249310f4efad..1e95255b1d1b 100644 --- a/content/base/src/nsNodeUtils.cpp +++ b/content/base/src/nsNodeUtils.cpp @@ -25,7 +25,7 @@ #include "nsBindingManager.h" #include "nsGenericHTMLElement.h" #ifdef MOZ_MEDIA -#include "nsHTMLMediaElement.h" +#include "mozilla/dom/HTMLMediaElement.h" #endif // MOZ_MEDIA #include "nsWrapperCacheInlines.h" #include "nsObjectLoadingContent.h" @@ -508,7 +508,7 @@ nsNodeUtils::CloneAndAdopt(nsINode *aNode, bool aClone, bool aDeep, #ifdef MOZ_MEDIA nsCOMPtr domMediaElem(do_QueryInterface(aNode)); if (domMediaElem) { - nsHTMLMediaElement* mediaElem = static_cast(aNode); + HTMLMediaElement* mediaElem = static_cast(aNode); mediaElem->NotifyOwnerDocumentActivityChanged(); } #endif diff --git a/content/html/content/public/nsHTMLMediaElement.h b/content/html/content/public/HTMLMediaElement.h similarity index 96% rename from content/html/content/public/nsHTMLMediaElement.h rename to content/html/content/public/HTMLMediaElement.h index 6c52b584a2e1..18b846859498 100644 --- a/content/html/content/public/nsHTMLMediaElement.h +++ b/content/html/content/public/HTMLMediaElement.h @@ -3,8 +3,8 @@ /* 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/. */ -#if !defined(nsHTMLMediaElement_h__) -#define nsHTMLMediaElement_h__ +#ifndef mozilla_dom_HTMLMediaElement_h +#define mozilla_dom_HTMLMediaElement_h #include "nsIDOMHTMLMediaElement.h" #include "nsGenericHTMLElement.h" @@ -39,10 +39,13 @@ class MediaResource; class MediaDecoder; } -class nsHTMLMediaElement : public nsGenericHTMLElement, - public nsIObserver, - public mozilla::MediaDecoderOwner, - public nsIAudioChannelAgentCallback +namespace mozilla { +namespace dom { + +class HTMLMediaElement : public nsGenericHTMLElement, + public nsIObserver, + public MediaDecoderOwner, + public nsIAudioChannelAgentCallback { public: typedef mozilla::TimeStamp TimeStamp; @@ -52,16 +55,13 @@ public: typedef mozilla::MediaResource MediaResource; typedef mozilla::MediaDecoderOwner MediaDecoderOwner; typedef mozilla::MetadataTags MetadataTags; - typedef mozilla::AudioStream AudioStream; - typedef mozilla::MediaDecoder MediaDecoder; - typedef mozilla::DOMMediaStream DOMMediaStream; - mozilla::CORSMode GetCORSMode() { + CORSMode GetCORSMode() { return mCORSMode; } - nsHTMLMediaElement(already_AddRefed aNodeInfo); - virtual ~nsHTMLMediaElement(); + HTMLMediaElement(already_AddRefed aNodeInfo); + virtual ~HTMLMediaElement(); /** * This is used when the browser is constructing a video element to play @@ -82,7 +82,7 @@ public: // nsISupports NS_DECL_ISUPPORTS_INHERITED - NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsHTMLMediaElement, + NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLMediaElement, nsGenericHTMLElement) virtual bool ParseAttribute(int32_t aNamespaceID, @@ -194,7 +194,7 @@ public: // Called by the media decoder and the video frame to get the // ImageContainer containing the video data. virtual VideoFrameContainer* GetVideoFrameContainer() MOZ_FINAL MOZ_OVERRIDE; - ImageContainer* GetImageContainer(); + layers::ImageContainer* GetImageContainer(); // Called by the video frame to get the print surface, if this is // a static document and we're not actually playing video @@ -255,7 +255,7 @@ public: // Returns the CanPlayStatus indicating if we can handle the // full MIME type including the optional codecs parameter. - static mozilla::CanPlayStatus GetCanPlay(const nsAString& aType); + static CanPlayStatus GetCanPlay(const nsAString& aType); /** * Called when a child source element is added to this media element. This @@ -296,7 +296,7 @@ public: */ bool GetPlayedOrSeeked() const { return mHasPlayedOrSeeked; } - nsresult CopyInnerTo(mozilla::dom::Element* aDest); + nsresult CopyInnerTo(Element* aDest); /** * Sets the Accept header on the HTTP channel to the required @@ -334,13 +334,13 @@ protected: class WakeLockBoolWrapper { public: WakeLockBoolWrapper(bool val = false) : mValue(val), mOuter(NULL), mWakeLock(NULL) {} - void SetOuter(nsHTMLMediaElement* outer) { mOuter = outer; } + void SetOuter(HTMLMediaElement* outer) { mOuter = outer; } operator bool() { return mValue; } WakeLockBoolWrapper& operator=(bool val); bool operator !() const { return !mValue; } private: bool mValue; - nsHTMLMediaElement* mOuter; + HTMLMediaElement* mOuter; nsCOMPtr mWakeLock; }; @@ -415,7 +415,7 @@ protected: * Call this to find a media element with the same NodePrincipal and mLoadingSrc * set to aURI, and with a decoder on which Load() has been called. */ - nsHTMLMediaElement* LookupMediaElementURITable(nsIURI* aURI); + HTMLMediaElement* LookupMediaElementURITable(nsIURI* aURI); /** * Shutdown and clear mDecoder and maintain associated invariants. @@ -595,9 +595,9 @@ protected: */ void SuspendOrResumeElement(bool aPauseElement, bool aSuspendEvents); - // Get the nsHTMLMediaElement object if the decoder is being used from an + // Get the HTMLMediaElement object if the decoder is being used from an // HTML media element, and null otherwise. - virtual nsHTMLMediaElement* GetMediaElement() MOZ_FINAL MOZ_OVERRIDE + virtual HTMLMediaElement* GetMediaElement() MOZ_FINAL MOZ_OVERRIDE { return this; } @@ -771,7 +771,7 @@ protected: nsAutoPtr mAudioStream; // Range of time played. - mozilla::dom::TimeRanges mPlayed; + TimeRanges mPlayed; // Stores the time at the start of the current 'played' range. double mCurrentPlayRangeStart; @@ -880,7 +880,7 @@ protected: bool mMediaSecurityVerified; // The CORS mode when loading the media element - mozilla::CORSMode mCORSMode; + CORSMode mCORSMode; // True if the media has an audio track bool mHasAudio; @@ -889,7 +889,7 @@ protected: bool mDownloadSuspendedByCache; // Audio Channel Type. - mozilla::dom::AudioChannelType mAudioChannelType; + AudioChannelType mAudioChannelType; // The audiochannel has been suspended. bool mChannelSuspended; @@ -901,4 +901,7 @@ protected: nsCOMPtr mAudioChannelAgent; }; -#endif +} // namespace dom +} // namespace mozilla + +#endif // mozilla_dom_HTMLMediaElement_h diff --git a/content/html/content/public/Makefile.in b/content/html/content/public/Makefile.in index 5ef5259e747c..593944d08e93 100644 --- a/content/html/content/public/Makefile.in +++ b/content/html/content/public/Makefile.in @@ -22,7 +22,6 @@ EXPORTS = \ nsITextControlElement.h \ nsFormSubmission.h \ nsHTMLAudioElement.h \ - nsHTMLMediaElement.h \ nsHTMLVideoElement.h \ nsIHTMLCollection.h \ $(NULL) @@ -31,6 +30,7 @@ EXPORTS_NAMESPACES = mozilla/dom EXPORTS_mozilla/dom = \ HTMLCanvasElement.h \ + HTMLMediaElement.h \ $(NULL) include $(topsrcdir)/config/rules.mk diff --git a/content/html/content/public/nsHTMLAudioElement.h b/content/html/content/public/nsHTMLAudioElement.h index 23d9d8c5dc68..962f5042c613 100644 --- a/content/html/content/public/nsHTMLAudioElement.h +++ b/content/html/content/public/nsHTMLAudioElement.h @@ -8,12 +8,12 @@ #include "nsIDOMHTMLAudioElement.h" #include "nsIJSNativeInitializer.h" -#include "nsHTMLMediaElement.h" +#include "mozilla/dom/HTMLMediaElement.h" typedef uint16_t nsMediaNetworkState; typedef uint16_t nsMediaReadyState; -class nsHTMLAudioElement : public nsHTMLMediaElement, +class nsHTMLAudioElement : public mozilla::dom::HTMLMediaElement, public nsIDOMHTMLAudioElement, public nsIJSNativeInitializer { @@ -34,8 +34,8 @@ public: NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC // nsIDOMHTMLMediaElement - using nsHTMLMediaElement::GetPaused; - NS_FORWARD_NSIDOMHTMLMEDIAELEMENT(nsHTMLMediaElement::) + using mozilla::dom::HTMLMediaElement::GetPaused; + NS_FORWARD_NSIDOMHTMLMEDIAELEMENT(mozilla::dom::HTMLMediaElement::) // nsIDOMHTMLAudioElement NS_DECL_NSIDOMHTMLAUDIOELEMENT diff --git a/content/html/content/public/nsHTMLVideoElement.h b/content/html/content/public/nsHTMLVideoElement.h index 9322c02347fb..1c20a69377e3 100644 --- a/content/html/content/public/nsHTMLVideoElement.h +++ b/content/html/content/public/nsHTMLVideoElement.h @@ -7,9 +7,9 @@ #define nsHTMLVideoElement_h__ #include "nsIDOMHTMLVideoElement.h" -#include "nsHTMLMediaElement.h" +#include "mozilla/dom/HTMLMediaElement.h" -class nsHTMLVideoElement : public nsHTMLMediaElement, +class nsHTMLVideoElement : public mozilla::dom::HTMLMediaElement, public nsIDOMHTMLVideoElement { public: @@ -31,8 +31,8 @@ public: NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC // nsIDOMHTMLMediaElement - using nsHTMLMediaElement::GetPaused; - NS_FORWARD_NSIDOMHTMLMEDIAELEMENT(nsHTMLMediaElement::) + using mozilla::dom::HTMLMediaElement::GetPaused; + NS_FORWARD_NSIDOMHTMLMEDIAELEMENT(mozilla::dom::HTMLMediaElement::) // nsIDOMHTMLVideoElement NS_DECL_NSIDOMHTMLVIDEOELEMENT diff --git a/content/html/content/src/nsHTMLMediaElement.cpp b/content/html/content/src/HTMLMediaElement.cpp similarity index 86% rename from content/html/content/src/nsHTMLMediaElement.cpp rename to content/html/content/src/HTMLMediaElement.cpp index 604e6e27a9b2..61d5d7f229c8 100644 --- a/content/html/content/src/nsHTMLMediaElement.cpp +++ b/content/html/content/src/HTMLMediaElement.cpp @@ -4,7 +4,7 @@ * 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 "nsHTMLMediaElement.h" +#include "mozilla/dom/HTMLMediaElement.h" #include "mozilla/MathAlgorithms.h" #include "mozilla/Util.h" @@ -93,12 +93,12 @@ static PRLogModuleInfo* gMediaElementEventsLog; #include "nsIPermissionManager.h" -using namespace mozilla; -using namespace mozilla::dom; using namespace mozilla::layers; - using mozilla::net::nsMediaFragmentURIParser; +namespace mozilla { +namespace dom { + // Number of milliseconds between timeupdate events as defined by spec #define TIMEUPDATE_MS 250 @@ -160,7 +160,7 @@ class nsMediaEvent : public nsRunnable { public: - nsMediaEvent(nsHTMLMediaElement* aElement) : + nsMediaEvent(HTMLMediaElement* aElement) : mElement(aElement), mLoadID(mElement->GetCurrentLoadID()) {} ~nsMediaEvent() {} @@ -172,7 +172,7 @@ protected: return mElement->GetCurrentLoadID() != mLoadID; } - nsRefPtr mElement; + nsRefPtr mElement; uint32_t mLoadID; }; @@ -182,7 +182,7 @@ private: nsString mName; public: - nsAsyncEventRunner(const nsAString& aName, nsHTMLMediaElement* aElement) : + nsAsyncEventRunner(const nsAString& aName, HTMLMediaElement* aElement) : nsMediaEvent(aElement), mName(aName) { } @@ -202,7 +202,7 @@ class nsSourceErrorEventRunner : public nsMediaEvent private: nsCOMPtr mSource; public: - nsSourceErrorEventRunner(nsHTMLMediaElement* aElement, + nsSourceErrorEventRunner(HTMLMediaElement* aElement, nsIContent* aSource) : nsMediaEvent(aElement), mSource(aSource) @@ -224,14 +224,14 @@ public: /** * There is a reference cycle involving this class: MediaLoadListener - * holds a reference to the nsHTMLMediaElement, which holds a reference + * holds a reference to the HTMLMediaElement, which holds a reference * to an nsIChannel, which holds a reference to this listener. * We break the reference cycle in OnStartRequest by clearing mElement. */ -class nsHTMLMediaElement::MediaLoadListener MOZ_FINAL : public nsIStreamListener, - public nsIChannelEventSink, - public nsIInterfaceRequestor, - public nsIObserver +class HTMLMediaElement::MediaLoadListener MOZ_FINAL : public nsIStreamListener, + public nsIChannelEventSink, + public nsIInterfaceRequestor, + public nsIObserver { NS_DECL_ISUPPORTS NS_DECL_NSIREQUESTOBSERVER @@ -241,7 +241,7 @@ class nsHTMLMediaElement::MediaLoadListener MOZ_FINAL : public nsIStreamListener NS_DECL_NSIINTERFACEREQUESTOR public: - MediaLoadListener(nsHTMLMediaElement* aElement) + MediaLoadListener(HTMLMediaElement* aElement) : mElement(aElement), mLoadID(aElement->GetCurrentLoadID()) { @@ -249,18 +249,18 @@ public: } private: - nsRefPtr mElement; + nsRefPtr mElement; nsCOMPtr mNextListener; uint32_t mLoadID; }; -NS_IMPL_ISUPPORTS5(nsHTMLMediaElement::MediaLoadListener, nsIRequestObserver, +NS_IMPL_ISUPPORTS5(HTMLMediaElement::MediaLoadListener, nsIRequestObserver, nsIStreamListener, nsIChannelEventSink, nsIInterfaceRequestor, nsIObserver) NS_IMETHODIMP -nsHTMLMediaElement::MediaLoadListener::Observe(nsISupports* aSubject, - const char* aTopic, const PRUnichar* aData) +HTMLMediaElement::MediaLoadListener::Observe(nsISupports* aSubject, + const char* aTopic, const PRUnichar* aData) { nsContentUtils::UnregisterShutdownObserver(this); @@ -269,9 +269,9 @@ nsHTMLMediaElement::MediaLoadListener::Observe(nsISupports* aSubject, return NS_OK; } -void nsHTMLMediaElement::ReportLoadError(const char* aMsg, - const PRUnichar** aParams, - uint32_t aParamCount) +void HTMLMediaElement::ReportLoadError(const char* aMsg, + const PRUnichar** aParams, + uint32_t aParamCount) { nsContentUtils::ReportToConsole(nsIScriptError::warningFlag, "Media", @@ -283,7 +283,7 @@ void nsHTMLMediaElement::ReportLoadError(const char* aMsg, } -NS_IMETHODIMP nsHTMLMediaElement::MediaLoadListener::OnStartRequest(nsIRequest* aRequest, nsISupports* aContext) +NS_IMETHODIMP HTMLMediaElement::MediaLoadListener::OnStartRequest(nsIRequest* aRequest, nsISupports* aContext) { nsContentUtils::UnregisterShutdownObserver(this); @@ -294,7 +294,7 @@ NS_IMETHODIMP nsHTMLMediaElement::MediaLoadListener::OnStartRequest(nsIRequest* // The element is only needed until we've had a chance to call // InitializeDecoderForChannel. So make sure mElement is cleared here. - nsRefPtr element; + nsRefPtr element; element.swap(mElement); if (mLoadID != element->GetCurrentLoadID()) { @@ -352,8 +352,8 @@ NS_IMETHODIMP nsHTMLMediaElement::MediaLoadListener::OnStartRequest(nsIRequest* return rv; } -NS_IMETHODIMP nsHTMLMediaElement::MediaLoadListener::OnStopRequest(nsIRequest* aRequest, nsISupports* aContext, - nsresult aStatus) +NS_IMETHODIMP HTMLMediaElement::MediaLoadListener::OnStopRequest(nsIRequest* aRequest, nsISupports* aContext, + nsresult aStatus) { if (mNextListener) { return mNextListener->OnStopRequest(aRequest, aContext, aStatus); @@ -362,11 +362,11 @@ NS_IMETHODIMP nsHTMLMediaElement::MediaLoadListener::OnStopRequest(nsIRequest* a } NS_IMETHODIMP -nsHTMLMediaElement::MediaLoadListener::OnDataAvailable(nsIRequest* aRequest, - nsISupports* aContext, - nsIInputStream* aStream, - uint64_t aOffset, - uint32_t aCount) +HTMLMediaElement::MediaLoadListener::OnDataAvailable(nsIRequest* aRequest, + nsISupports* aContext, + nsIInputStream* aStream, + uint64_t aOffset, + uint32_t aCount) { if (!mNextListener) { NS_ERROR("Must have a chained listener; OnStartRequest should have canceled this request"); @@ -375,10 +375,10 @@ nsHTMLMediaElement::MediaLoadListener::OnDataAvailable(nsIRequest* aRequest, return mNextListener->OnDataAvailable(aRequest, aContext, aStream, aOffset, aCount); } -NS_IMETHODIMP nsHTMLMediaElement::MediaLoadListener::AsyncOnChannelRedirect(nsIChannel* aOldChannel, - nsIChannel* aNewChannel, - uint32_t aFlags, - nsIAsyncVerifyRedirectCallback* cb) +NS_IMETHODIMP HTMLMediaElement::MediaLoadListener::AsyncOnChannelRedirect(nsIChannel* aOldChannel, + nsIChannel* aNewChannel, + uint32_t aFlags, + nsIAsyncVerifyRedirectCallback* cb) { // TODO is this really correct?? See bug #579329. if (mElement) @@ -391,15 +391,15 @@ NS_IMETHODIMP nsHTMLMediaElement::MediaLoadListener::AsyncOnChannelRedirect(nsIC return NS_OK; } -NS_IMETHODIMP nsHTMLMediaElement::MediaLoadListener::GetInterface(const nsIID & aIID, void **aResult) +NS_IMETHODIMP HTMLMediaElement::MediaLoadListener::GetInterface(const nsIID & aIID, void **aResult) { return QueryInterface(aIID, aResult); } -NS_IMPL_ADDREF_INHERITED(nsHTMLMediaElement, nsGenericHTMLElement) -NS_IMPL_RELEASE_INHERITED(nsHTMLMediaElement, nsGenericHTMLElement) +NS_IMPL_ADDREF_INHERITED(HTMLMediaElement, nsGenericHTMLElement) +NS_IMPL_RELEASE_INHERITED(HTMLMediaElement, nsGenericHTMLElement) -NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsHTMLMediaElement, nsGenericHTMLElement) +NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(HTMLMediaElement, nsGenericHTMLElement) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSrcStream) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSrcAttrStream) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSourcePointer) @@ -411,7 +411,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsHTMLMediaElement, nsGenericH } NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END -NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsHTMLMediaElement, nsGenericHTMLElement) +NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(HTMLMediaElement, nsGenericHTMLElement) if (tmp->mSrcStream) { // Need to EndMediaStreamPlayback to clear mStream and make sure everything // gets unhooked correctly. @@ -427,23 +427,23 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsHTMLMediaElement, nsGenericHTM } NS_IMPL_CYCLE_COLLECTION_UNLINK_END -NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsHTMLMediaElement) +NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(HTMLMediaElement) NS_INTERFACE_MAP_ENTRY(nsIObserver) NS_INTERFACE_MAP_ENTRY(nsIAudioChannelAgentCallback) NS_INTERFACE_MAP_END_INHERITING(nsGenericHTMLElement) // nsIDOMHTMLMediaElement -NS_IMPL_URI_ATTR(nsHTMLMediaElement, Src, src) -NS_IMPL_STRING_ATTR(nsHTMLMediaElement, Crossorigin, crossorigin) -NS_IMPL_BOOL_ATTR(nsHTMLMediaElement, Controls, controls) -NS_IMPL_BOOL_ATTR(nsHTMLMediaElement, Autoplay, autoplay) -NS_IMPL_BOOL_ATTR(nsHTMLMediaElement, Loop, loop) -NS_IMPL_BOOL_ATTR(nsHTMLMediaElement, DefaultMuted, muted) -NS_IMPL_ENUM_ATTR_DEFAULT_VALUE(nsHTMLMediaElement, Preload, preload, NULL) -NS_IMPL_ENUM_ATTR_DEFAULT_VALUE(nsHTMLMediaElement, MozAudioChannelType, mozaudiochannel, "normal") +NS_IMPL_URI_ATTR(HTMLMediaElement, Src, src) +NS_IMPL_STRING_ATTR(HTMLMediaElement, Crossorigin, crossorigin) +NS_IMPL_BOOL_ATTR(HTMLMediaElement, Controls, controls) +NS_IMPL_BOOL_ATTR(HTMLMediaElement, Autoplay, autoplay) +NS_IMPL_BOOL_ATTR(HTMLMediaElement, Loop, loop) +NS_IMPL_BOOL_ATTR(HTMLMediaElement, DefaultMuted, muted) +NS_IMPL_ENUM_ATTR_DEFAULT_VALUE(HTMLMediaElement, Preload, preload, NULL) +NS_IMPL_ENUM_ATTR_DEFAULT_VALUE(HTMLMediaElement, MozAudioChannelType, mozaudiochannel, "normal") NS_IMETHODIMP -nsHTMLMediaElement::GetMozSrcObject(nsIDOMMediaStream** aStream) +HTMLMediaElement::GetMozSrcObject(nsIDOMMediaStream** aStream) { NS_ASSERTION(!mSrcAttrStream || mSrcAttrStream->GetStream(), "MediaStream should have been set up properly"); @@ -453,7 +453,7 @@ nsHTMLMediaElement::GetMozSrcObject(nsIDOMMediaStream** aStream) } NS_IMETHODIMP -nsHTMLMediaElement::SetMozSrcObject(nsIDOMMediaStream* aStream) +HTMLMediaElement::SetMozSrcObject(nsIDOMMediaStream* aStream) { mSrcAttrStream = static_cast(aStream); Load(); @@ -461,7 +461,7 @@ nsHTMLMediaElement::SetMozSrcObject(nsIDOMMediaStream* aStream) } /* readonly attribute nsIDOMHTMLMediaElement mozAutoplayEnabled; */ -NS_IMETHODIMP nsHTMLMediaElement::GetMozAutoplayEnabled(bool *aAutoplayEnabled) +NS_IMETHODIMP HTMLMediaElement::GetMozAutoplayEnabled(bool *aAutoplayEnabled) { *aAutoplayEnabled = mAutoplayEnabled; @@ -469,7 +469,7 @@ NS_IMETHODIMP nsHTMLMediaElement::GetMozAutoplayEnabled(bool *aAutoplayEnabled) } /* readonly attribute nsIDOMMediaError error; */ -NS_IMETHODIMP nsHTMLMediaElement::GetError(nsIDOMMediaError * *aError) +NS_IMETHODIMP HTMLMediaElement::GetError(nsIDOMMediaError * *aError) { NS_IF_ADDREF(*aError = mError); @@ -477,7 +477,7 @@ NS_IMETHODIMP nsHTMLMediaElement::GetError(nsIDOMMediaError * *aError) } /* readonly attribute boolean ended; */ -NS_IMETHODIMP nsHTMLMediaElement::GetEnded(bool *aEnded) +NS_IMETHODIMP HTMLMediaElement::GetEnded(bool *aEnded) { if (mSrcStream) { *aEnded = GetSrcMediaStream()->IsFinished(); @@ -488,7 +488,7 @@ NS_IMETHODIMP nsHTMLMediaElement::GetEnded(bool *aEnded) } /* readonly attribute DOMString currentSrc; */ -NS_IMETHODIMP nsHTMLMediaElement::GetCurrentSrc(nsAString & aCurrentSrc) +NS_IMETHODIMP HTMLMediaElement::GetCurrentSrc(nsAString & aCurrentSrc) { nsAutoCString src; GetCurrentSpec(src); @@ -497,7 +497,7 @@ NS_IMETHODIMP nsHTMLMediaElement::GetCurrentSrc(nsAString & aCurrentSrc) } /* readonly attribute unsigned short networkState; */ -NS_IMETHODIMP nsHTMLMediaElement::GetNetworkState(uint16_t *aNetworkState) +NS_IMETHODIMP HTMLMediaElement::GetNetworkState(uint16_t *aNetworkState) { *aNetworkState = mNetworkState; @@ -505,9 +505,9 @@ NS_IMETHODIMP nsHTMLMediaElement::GetNetworkState(uint16_t *aNetworkState) } nsresult -nsHTMLMediaElement::OnChannelRedirect(nsIChannel *aChannel, - nsIChannel *aNewChannel, - uint32_t aFlags) +HTMLMediaElement::OnChannelRedirect(nsIChannel *aChannel, + nsIChannel *aNewChannel, + uint32_t aFlags) { NS_ASSERTION(aChannel == mChannel, "Channels should match!"); mChannel = aNewChannel; @@ -533,7 +533,7 @@ nsHTMLMediaElement::OnChannelRedirect(nsIChannel *aChannel, return NS_OK; } -void nsHTMLMediaElement::ShutdownDecoder() +void HTMLMediaElement::ShutdownDecoder() { RemoveMediaElementFromURITable(); NS_ASSERTION(mDecoder, "Must have decoder to shut down"); @@ -541,7 +541,7 @@ void nsHTMLMediaElement::ShutdownDecoder() mDecoder = nullptr; } -void nsHTMLMediaElement::AbortExistingLoads() +void HTMLMediaElement::AbortExistingLoads() { // Abort any already-running instance of the resource selection algorithm. mLoadWaitStatus = NOT_WAITING; @@ -610,7 +610,7 @@ void nsHTMLMediaElement::AbortExistingLoads() mIsRunningSelectResource = false; } -void nsHTMLMediaElement::NoSupportedMediaSourceError() +void HTMLMediaElement::NoSupportedMediaSourceError() { NS_ASSERTION(mDelayingLoadEvent, "Load event not delayed during source selection?"); @@ -621,7 +621,7 @@ void nsHTMLMediaElement::NoSupportedMediaSourceError() ChangeDelayLoadStatus(false); } -typedef void (nsHTMLMediaElement::*SyncSectionFn)(); +typedef void (HTMLMediaElement::*SyncSectionFn)(); // Runs a "synchronous section", a function that must run once the event loop // has reached a "stable state". See: @@ -631,7 +631,7 @@ class nsSyncSection : public nsMediaEvent private: SyncSectionFn mClosure; public: - nsSyncSection(nsHTMLMediaElement* aElement, + nsSyncSection(HTMLMediaElement* aElement, SyncSectionFn aClosure) : nsMediaEvent(aElement), mClosure(aClosure) @@ -652,7 +652,7 @@ static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID); // Asynchronously awaits a stable state, whereupon aClosure runs on the main // thread. This adds an event which run aClosure to the appshell's list of // sections synchronous the next time control returns to the event loop. -void AsyncAwaitStableState(nsHTMLMediaElement* aElement, +void AsyncAwaitStableState(HTMLMediaElement* aElement, SyncSectionFn aClosure) { nsCOMPtr event = new nsSyncSection(aElement, aClosure); @@ -660,25 +660,25 @@ void AsyncAwaitStableState(nsHTMLMediaElement* aElement, appShell->RunInStableState(event); } -void nsHTMLMediaElement::QueueLoadFromSourceTask() +void HTMLMediaElement::QueueLoadFromSourceTask() { ChangeDelayLoadStatus(true); mNetworkState = nsIDOMHTMLMediaElement::NETWORK_LOADING; - AsyncAwaitStableState(this, &nsHTMLMediaElement::LoadFromSourceChildren); + AsyncAwaitStableState(this, &HTMLMediaElement::LoadFromSourceChildren); } -void nsHTMLMediaElement::QueueSelectResourceTask() +void HTMLMediaElement::QueueSelectResourceTask() { // Don't allow multiple async select resource calls to be queued. if (mHaveQueuedSelectResource) return; mHaveQueuedSelectResource = true; mNetworkState = nsIDOMHTMLMediaElement::NETWORK_NO_SOURCE; - AsyncAwaitStableState(this, &nsHTMLMediaElement::SelectResourceWrapper); + AsyncAwaitStableState(this, &HTMLMediaElement::SelectResourceWrapper); } /* void load (); */ -NS_IMETHODIMP nsHTMLMediaElement::Load() +NS_IMETHODIMP HTMLMediaElement::Load() { if (mIsRunningLoadMethod) return NS_OK; @@ -692,7 +692,7 @@ NS_IMETHODIMP nsHTMLMediaElement::Load() return NS_OK; } -void nsHTMLMediaElement::ResetState() +void HTMLMediaElement::ResetState() { mMediaSize = nsIntSize(-1, -1); VideoFrameContainer* container = GetVideoFrameContainer(); @@ -714,14 +714,14 @@ static bool HasSourceChildren(nsIContent *aElement) return false; } -void nsHTMLMediaElement::SelectResourceWrapper() +void HTMLMediaElement::SelectResourceWrapper() { SelectResource(); mIsRunningSelectResource = false; mHaveQueuedSelectResource = false; } -void nsHTMLMediaElement::SelectResource() +void HTMLMediaElement::SelectResource() { if (!mSrcAttrStream && !HasAttr(kNameSpaceID_None, nsGkAtoms::src) && !HasSourceChildren(this)) { @@ -759,7 +759,7 @@ void nsHTMLMediaElement::SelectResource() "Should think we're not loading from source children by default"); mLoadingSrc = uri; - if (mPreloadAction == nsHTMLMediaElement::PRELOAD_NONE) { + if (mPreloadAction == HTMLMediaElement::PRELOAD_NONE) { // preload:none media, suspend the load here before we make any // network requests. SuspendLoad(); @@ -782,7 +782,7 @@ void nsHTMLMediaElement::SelectResource() } } -void nsHTMLMediaElement::NotifyLoadError() +void HTMLMediaElement::NotifyLoadError() { if (!mIsLoadingFromSourceChildren) { LOG(PR_LOG_DEBUG, ("NotifyLoadError(), no supported media error")); @@ -795,9 +795,9 @@ void nsHTMLMediaElement::NotifyLoadError() } } -void nsHTMLMediaElement::NotifyAudioAvailable(float* aFrameBuffer, - uint32_t aFrameBufferLength, - float aTime) +void HTMLMediaElement::NotifyAudioAvailable(float* aFrameBuffer, + uint32_t aFrameBufferLength, + float aTime) { // Auto manage the memory for the frame buffer, so that if we add an early // return-on-error here in future, we won't forget to release the memory. @@ -816,7 +816,7 @@ void nsHTMLMediaElement::NotifyAudioAvailable(float* aFrameBuffer, DispatchAudioAvailableEvent(frameBuffer.forget(), aFrameBufferLength, aTime); } -void nsHTMLMediaElement::LoadFromSourceChildren() +void HTMLMediaElement::LoadFromSourceChildren() { NS_ASSERTION(mDelayingLoadEvent, "Should delay load event (if in document) during load"); @@ -887,7 +887,7 @@ void nsHTMLMediaElement::LoadFromSourceChildren() NS_ASSERTION(mNetworkState == nsIDOMHTMLMediaElement::NETWORK_LOADING, "Network state should be loading"); - if (mPreloadAction == nsHTMLMediaElement::PRELOAD_NONE) { + if (mPreloadAction == HTMLMediaElement::PRELOAD_NONE) { // preload:none media, suspend the load here before we make any // network requests. SuspendLoad(); @@ -904,7 +904,7 @@ void nsHTMLMediaElement::LoadFromSourceChildren() NS_NOTREACHED("Execution should not reach here!"); } -void nsHTMLMediaElement::SuspendLoad() +void HTMLMediaElement::SuspendLoad() { mSuspendedForPreloadNone = true; mNetworkState = nsIDOMHTMLMediaElement::NETWORK_IDLE; @@ -912,7 +912,7 @@ void nsHTMLMediaElement::SuspendLoad() ChangeDelayLoadStatus(false); } -void nsHTMLMediaElement::ResumeLoad(PreloadAction aAction) +void HTMLMediaElement::ResumeLoad(PreloadAction aAction) { NS_ASSERTION(mSuspendedForPreloadNone, "Must be halted for preload:none to resume from preload:none suspended load."); @@ -939,7 +939,7 @@ static bool IsAutoplayEnabled() return Preferences::GetBool("media.autoplay.enabled"); } -void nsHTMLMediaElement::UpdatePreloadAction() +void HTMLMediaElement::UpdatePreloadAction() { PreloadAction nextAction = PRELOAD_UNDEFINED; // If autoplay is set, or we're playing, we should always preload data, @@ -947,31 +947,31 @@ void nsHTMLMediaElement::UpdatePreloadAction() if ((IsAutoplayEnabled() && HasAttr(kNameSpaceID_None, nsGkAtoms::autoplay)) || !mPaused) { - nextAction = nsHTMLMediaElement::PRELOAD_ENOUGH; + nextAction = HTMLMediaElement::PRELOAD_ENOUGH; } else { // Find the appropriate preload action by looking at the attribute. const nsAttrValue* val = mAttrsAndChildren.GetAttr(nsGkAtoms::preload, kNameSpaceID_None); uint32_t preloadDefault = Preferences::GetInt("media.preload.default", - nsHTMLMediaElement::PRELOAD_ATTR_METADATA); + HTMLMediaElement::PRELOAD_ATTR_METADATA); uint32_t preloadAuto = Preferences::GetInt("media.preload.auto", - nsHTMLMediaElement::PRELOAD_ENOUGH); + HTMLMediaElement::PRELOAD_ENOUGH); if (!val) { // Attribute is not set. Use the preload action specified by the // media.preload.default pref, or just preload metadata if not present. nextAction = static_cast(preloadDefault); } else if (val->Type() == nsAttrValue::eEnum) { PreloadAttrValue attr = static_cast(val->GetEnumValue()); - if (attr == nsHTMLMediaElement::PRELOAD_ATTR_EMPTY || - attr == nsHTMLMediaElement::PRELOAD_ATTR_AUTO) + if (attr == HTMLMediaElement::PRELOAD_ATTR_EMPTY || + attr == HTMLMediaElement::PRELOAD_ATTR_AUTO) { nextAction = static_cast(preloadAuto); - } else if (attr == nsHTMLMediaElement::PRELOAD_ATTR_METADATA) { - nextAction = nsHTMLMediaElement::PRELOAD_METADATA; - } else if (attr == nsHTMLMediaElement::PRELOAD_ATTR_NONE) { - nextAction = nsHTMLMediaElement::PRELOAD_NONE; + } else if (attr == HTMLMediaElement::PRELOAD_ATTR_METADATA) { + nextAction = HTMLMediaElement::PRELOAD_METADATA; + } else if (attr == HTMLMediaElement::PRELOAD_ATTR_NONE) { + nextAction = HTMLMediaElement::PRELOAD_NONE; } } else { // Use the suggested "missing value default" of "metadata", or the value @@ -988,7 +988,7 @@ void nsHTMLMediaElement::UpdatePreloadAction() } mPreloadAction = nextAction; - if (nextAction == nsHTMLMediaElement::PRELOAD_ENOUGH) { + if (nextAction == HTMLMediaElement::PRELOAD_ENOUGH) { if (mSuspendedForPreloadNone) { // Our load was previouly suspended due to the media having preload // value "none". The preload value has changed to preload:auto, so @@ -1000,7 +1000,7 @@ void nsHTMLMediaElement::UpdatePreloadAction() StopSuspendingAfterFirstFrame(); } - } else if (nextAction == nsHTMLMediaElement::PRELOAD_METADATA) { + } else if (nextAction == HTMLMediaElement::PRELOAD_METADATA) { // Ensure that the video can be suspended after first frame. mAllowSuspendAfterFirstFrame = true; if (mSuspendedForPreloadNone) { @@ -1013,7 +1013,7 @@ void nsHTMLMediaElement::UpdatePreloadAction() } } -nsresult nsHTMLMediaElement::LoadResource() +nsresult HTMLMediaElement::LoadResource() { NS_ASSERTION(mDelayingLoadEvent, "Should delay load event (if in document) during load"); @@ -1041,7 +1041,7 @@ nsresult nsHTMLMediaElement::LoadResource() // Set the media element's CORS mode only when loading a resource mCORSMode = AttrValueToCORSMode(GetParsedAttr(nsGkAtoms::crossorigin)); - nsHTMLMediaElement* other = LookupMediaElementURITable(mLoadingSrc); + HTMLMediaElement* other = LookupMediaElementURITable(mLoadingSrc); if (other && other->mDecoder) { // Clone it. nsresult rv = InitializeDecoderAsClone(other->mDecoder); @@ -1142,8 +1142,8 @@ nsresult nsHTMLMediaElement::LoadResource() return NS_OK; } -nsresult nsHTMLMediaElement::LoadWithChannel(nsIChannel *aChannel, - nsIStreamListener **aListener) +nsresult HTMLMediaElement::LoadWithChannel(nsIChannel *aChannel, + nsIStreamListener **aListener) { NS_ENSURE_ARG_POINTER(aChannel); NS_ENSURE_ARG_POINTER(aListener); @@ -1173,7 +1173,7 @@ nsresult nsHTMLMediaElement::LoadWithChannel(nsIChannel *aChannel, return NS_OK; } -NS_IMETHODIMP nsHTMLMediaElement::MozLoadFrom(nsIDOMHTMLMediaElement* aOther) +NS_IMETHODIMP HTMLMediaElement::MozLoadFrom(nsIDOMHTMLMediaElement* aOther) { NS_ENSURE_ARG_POINTER(aOther); @@ -1185,7 +1185,7 @@ NS_IMETHODIMP nsHTMLMediaElement::MozLoadFrom(nsIDOMHTMLMediaElement* aOther) mIsRunningLoadMethod = false; nsCOMPtr content = do_QueryInterface(aOther); - nsHTMLMediaElement* other = static_cast(content.get()); + HTMLMediaElement* other = static_cast(content.get()); if (!other || !other->mDecoder) return NS_OK; @@ -1205,7 +1205,7 @@ NS_IMETHODIMP nsHTMLMediaElement::MozLoadFrom(nsIDOMHTMLMediaElement* aOther) } /* readonly attribute unsigned short readyState; */ -NS_IMETHODIMP nsHTMLMediaElement::GetReadyState(uint16_t *aReadyState) +NS_IMETHODIMP HTMLMediaElement::GetReadyState(uint16_t *aReadyState) { *aReadyState = mReadyState; @@ -1213,7 +1213,7 @@ NS_IMETHODIMP nsHTMLMediaElement::GetReadyState(uint16_t *aReadyState) } /* readonly attribute boolean seeking; */ -NS_IMETHODIMP nsHTMLMediaElement::GetSeeking(bool *aSeeking) +NS_IMETHODIMP HTMLMediaElement::GetSeeking(bool *aSeeking) { *aSeeking = mDecoder && mDecoder->IsSeeking(); @@ -1221,7 +1221,7 @@ NS_IMETHODIMP nsHTMLMediaElement::GetSeeking(bool *aSeeking) } /* attribute double currentTime; */ -NS_IMETHODIMP nsHTMLMediaElement::GetCurrentTime(double *aCurrentTime) +NS_IMETHODIMP HTMLMediaElement::GetCurrentTime(double *aCurrentTime) { if (mSrcStream) { *aCurrentTime = MediaTimeToSeconds(GetSrcMediaStream()->GetCurrentTime()); @@ -1233,7 +1233,7 @@ NS_IMETHODIMP nsHTMLMediaElement::GetCurrentTime(double *aCurrentTime) return NS_OK; } -NS_IMETHODIMP nsHTMLMediaElement::SetCurrentTime(double aCurrentTime) +NS_IMETHODIMP HTMLMediaElement::SetCurrentTime(double aCurrentTime) { StopSuspendingAfterFirstFrame(); @@ -1291,7 +1291,7 @@ NS_IMETHODIMP nsHTMLMediaElement::SetCurrentTime(double aCurrentTime) } /* readonly attribute double duration; */ -NS_IMETHODIMP nsHTMLMediaElement::GetDuration(double *aDuration) +NS_IMETHODIMP HTMLMediaElement::GetDuration(double *aDuration) { if (mSrcStream) { *aDuration = std::numeric_limits::infinity(); @@ -1304,7 +1304,7 @@ NS_IMETHODIMP nsHTMLMediaElement::GetDuration(double *aDuration) } /* readonly attribute nsIDOMHTMLTimeRanges seekable; */ -NS_IMETHODIMP nsHTMLMediaElement::GetSeekable(nsIDOMTimeRanges** aSeekable) +NS_IMETHODIMP HTMLMediaElement::GetSeekable(nsIDOMTimeRanges** aSeekable) { nsRefPtr ranges = new TimeRanges(); if (mDecoder && mReadyState > nsIDOMHTMLMediaElement::HAVE_NOTHING) { @@ -1316,7 +1316,7 @@ NS_IMETHODIMP nsHTMLMediaElement::GetSeekable(nsIDOMTimeRanges** aSeekable) /* readonly attribute boolean paused; */ -NS_IMETHODIMP nsHTMLMediaElement::GetPaused(bool *aPaused) +NS_IMETHODIMP HTMLMediaElement::GetPaused(bool *aPaused) { *aPaused = mPaused; @@ -1324,7 +1324,7 @@ NS_IMETHODIMP nsHTMLMediaElement::GetPaused(bool *aPaused) } /* readonly attribute nsIDOMHTMLTimeRanges played; */ -NS_IMETHODIMP nsHTMLMediaElement::GetPlayed(nsIDOMTimeRanges** aPlayed) +NS_IMETHODIMP HTMLMediaElement::GetPlayed(nsIDOMTimeRanges** aPlayed) { TimeRanges* ranges = new TimeRanges(); NS_ADDREF(*aPlayed = ranges); @@ -1353,7 +1353,7 @@ NS_IMETHODIMP nsHTMLMediaElement::GetPlayed(nsIDOMTimeRanges** aPlayed) } /* void pause (); */ -NS_IMETHODIMP nsHTMLMediaElement::Pause() +NS_IMETHODIMP HTMLMediaElement::Pause() { if (mNetworkState == nsIDOMHTMLMediaElement::NETWORK_EMPTY) { LOG(PR_LOG_DEBUG, ("Loading due to Pause()")); @@ -1381,14 +1381,14 @@ NS_IMETHODIMP nsHTMLMediaElement::Pause() } /* attribute double volume; */ -NS_IMETHODIMP nsHTMLMediaElement::GetVolume(double *aVolume) +NS_IMETHODIMP HTMLMediaElement::GetVolume(double *aVolume) { *aVolume = mVolume; return NS_OK; } -NS_IMETHODIMP nsHTMLMediaElement::SetVolume(double aVolume) +NS_IMETHODIMP HTMLMediaElement::SetVolume(double aVolume) { if (!(aVolume >= 0.0 && aVolume <= 1.0)) return NS_ERROR_DOM_INDEX_SIZE_ERR; @@ -1414,7 +1414,7 @@ NS_IMETHODIMP nsHTMLMediaElement::SetVolume(double aVolume) } NS_IMETHODIMP -nsHTMLMediaElement::GetMozChannels(uint32_t *aMozChannels) +HTMLMediaElement::GetMozChannels(uint32_t *aMozChannels) { if (!mDecoder && !mAudioStream) { return NS_ERROR_DOM_INVALID_STATE_ERR; @@ -1425,7 +1425,7 @@ nsHTMLMediaElement::GetMozChannels(uint32_t *aMozChannels) } NS_IMETHODIMP -nsHTMLMediaElement::GetMozSampleRate(uint32_t *aMozSampleRate) +HTMLMediaElement::GetMozSampleRate(uint32_t *aMozSampleRate) { if (!mDecoder && !mAudioStream) { return NS_ERROR_DOM_INVALID_STATE_ERR; @@ -1443,9 +1443,9 @@ typedef struct { } MetadataIterCx; PLDHashOperator -nsHTMLMediaElement::BuildObjectFromTags(nsCStringHashKey::KeyType aKey, - nsCString aValue, - void* aUserArg) +HTMLMediaElement::BuildObjectFromTags(nsCStringHashKey::KeyType aKey, + nsCString aValue, + void* aUserArg) { MetadataIterCx* args = static_cast(aUserArg); @@ -1468,7 +1468,7 @@ nsHTMLMediaElement::BuildObjectFromTags(nsCStringHashKey::KeyType aKey, } NS_IMETHODIMP -nsHTMLMediaElement::MozGetMetadata(JSContext* cx, JS::Value* aValue) +HTMLMediaElement::MozGetMetadata(JSContext* cx, JS::Value* aValue) { if (mReadyState < nsIDOMHTMLMediaElement::HAVE_METADATA) { return NS_ERROR_DOM_INVALID_STATE_ERR; @@ -1492,7 +1492,7 @@ nsHTMLMediaElement::MozGetMetadata(JSContext* cx, JS::Value* aValue) } NS_IMETHODIMP -nsHTMLMediaElement::GetMozFrameBufferLength(uint32_t *aMozFrameBufferLength) +HTMLMediaElement::GetMozFrameBufferLength(uint32_t *aMozFrameBufferLength) { // The framebuffer (via MozAudioAvailable events) is only available // when reading vs. writing audio directly. @@ -1505,7 +1505,7 @@ nsHTMLMediaElement::GetMozFrameBufferLength(uint32_t *aMozFrameBufferLength) } NS_IMETHODIMP -nsHTMLMediaElement::SetMozFrameBufferLength(uint32_t aMozFrameBufferLength) +HTMLMediaElement::SetMozFrameBufferLength(uint32_t aMozFrameBufferLength) { if (!mDecoder) return NS_ERROR_DOM_INVALID_STATE_ERR; @@ -1514,14 +1514,14 @@ nsHTMLMediaElement::SetMozFrameBufferLength(uint32_t aMozFrameBufferLength) } /* attribute boolean muted; */ -NS_IMETHODIMP nsHTMLMediaElement::GetMuted(bool *aMuted) +NS_IMETHODIMP HTMLMediaElement::GetMuted(bool *aMuted) { *aMuted = mMuted; return NS_OK; } -void nsHTMLMediaElement::SetMutedInternal(bool aMuted) +void HTMLMediaElement::SetMutedInternal(bool aMuted) { float effectiveVolume = aMuted ? 0.0f : float(mVolume); @@ -1534,7 +1534,7 @@ void nsHTMLMediaElement::SetMutedInternal(bool aMuted) } } -NS_IMETHODIMP nsHTMLMediaElement::SetMuted(bool aMuted) +NS_IMETHODIMP HTMLMediaElement::SetMuted(bool aMuted) { if (aMuted == mMuted) return NS_OK; @@ -1548,7 +1548,7 @@ NS_IMETHODIMP nsHTMLMediaElement::SetMuted(bool aMuted) } already_AddRefed -nsHTMLMediaElement::CaptureStreamInternal(bool aFinishWhenEnded) +HTMLMediaElement::CaptureStreamInternal(bool aFinishWhenEnded) { nsIDOMWindow* window = OwnerDoc()->GetInnerWindow(); if (!window) { @@ -1575,7 +1575,7 @@ nsHTMLMediaElement::CaptureStreamInternal(bool aFinishWhenEnded) return result.forget(); } -NS_IMETHODIMP nsHTMLMediaElement::MozCaptureStream(nsIDOMMediaStream** aStream) +NS_IMETHODIMP HTMLMediaElement::MozCaptureStream(nsIDOMMediaStream** aStream) { *aStream = CaptureStreamInternal(false).get(); if (!*aStream) { @@ -1584,7 +1584,7 @@ NS_IMETHODIMP nsHTMLMediaElement::MozCaptureStream(nsIDOMMediaStream** aStream) return NS_OK; } -NS_IMETHODIMP nsHTMLMediaElement::MozCaptureStreamUntilEnded(nsIDOMMediaStream** aStream) +NS_IMETHODIMP HTMLMediaElement::MozCaptureStreamUntilEnded(nsIDOMMediaStream** aStream) { *aStream = CaptureStreamInternal(true).get(); if (!*aStream) { @@ -1593,7 +1593,7 @@ NS_IMETHODIMP nsHTMLMediaElement::MozCaptureStreamUntilEnded(nsIDOMMediaStream** return NS_OK; } -NS_IMETHODIMP nsHTMLMediaElement::GetMozAudioCaptured(bool *aCaptured) +NS_IMETHODIMP HTMLMediaElement::GetMozAudioCaptured(bool *aCaptured) { *aCaptured = mAudioCaptured; return NS_OK; @@ -1604,7 +1604,7 @@ public: MediaElementSetForURI(const nsIURI* aKey) : nsURIHashKey(aKey) {} MediaElementSetForURI(const MediaElementSetForURI& toCopy) : nsURIHashKey(toCopy), mElements(toCopy.mElements) {} - nsTArray mElements; + nsTArray mElements; }; typedef nsTHashtable MediaElementURITable; @@ -1618,7 +1618,7 @@ static MediaElementURITable* gElementTable; // Returns the number of times aElement appears in the media element table // for aURI. If this returns other than 0 or 1, there's a bug somewhere! static unsigned -MediaElementTableCount(nsHTMLMediaElement* aElement, nsIURI* aURI) +MediaElementTableCount(HTMLMediaElement* aElement, nsIURI* aURI) { if (!gElementTable || !aElement || !aURI) { return 0; @@ -1629,7 +1629,7 @@ MediaElementTableCount(nsHTMLMediaElement* aElement, nsIURI* aURI) } uint32_t count = 0; for (uint32_t i = 0; i < entry->mElements.Length(); ++i) { - nsHTMLMediaElement* elem = entry->mElements[i]; + HTMLMediaElement* elem = entry->mElements[i]; if (elem == aElement) { count++; } @@ -1639,7 +1639,7 @@ MediaElementTableCount(nsHTMLMediaElement* aElement, nsIURI* aURI) #endif void -nsHTMLMediaElement::AddMediaElementToURITable() +HTMLMediaElement::AddMediaElementToURITable() { NS_ASSERTION(mDecoder && mDecoder->GetResource(), "Call this only with decoder Load called"); NS_ASSERTION(MediaElementTableCount(this, mLoadingSrc) == 0, @@ -1655,7 +1655,7 @@ nsHTMLMediaElement::AddMediaElementToURITable() } void -nsHTMLMediaElement::RemoveMediaElementFromURITable() +HTMLMediaElement::RemoveMediaElementFromURITable() { NS_ASSERTION(MediaElementTableCount(this, mLoadingSrc) == 1, "Before remove, should have a single entry for element in element table"); @@ -1678,8 +1678,8 @@ nsHTMLMediaElement::RemoveMediaElementFromURITable() "After remove, should no longer have an entry in element table"); } -nsHTMLMediaElement* -nsHTMLMediaElement::LookupMediaElementURITable(nsIURI* aURI) +HTMLMediaElement* +HTMLMediaElement::LookupMediaElementURITable(nsIURI* aURI) { if (!gElementTable) return nullptr; @@ -1687,7 +1687,7 @@ nsHTMLMediaElement::LookupMediaElementURITable(nsIURI* aURI) if (!entry) return nullptr; for (uint32_t i = 0; i < entry->mElements.Length(); ++i) { - nsHTMLMediaElement* elem = entry->mElements[i]; + HTMLMediaElement* elem = entry->mElements[i]; bool equal; // Look for elements that have the same principal and CORS mode. // Ditto for anything else that could cause us to send different headers. @@ -1703,7 +1703,7 @@ nsHTMLMediaElement::LookupMediaElementURITable(nsIURI* aURI) return nullptr; } -nsHTMLMediaElement::nsHTMLMediaElement(already_AddRefed aNodeInfo) +HTMLMediaElement::HTMLMediaElement(already_AddRefed aNodeInfo) : nsGenericHTMLElement(aNodeInfo), mSrcStreamListener(nullptr), mCurrentLoadID(0), @@ -1768,7 +1768,7 @@ nsHTMLMediaElement::nsHTMLMediaElement(already_AddRefed aNodeInfo) NotifyOwnerDocumentActivityChanged(); } -nsHTMLMediaElement::~nsHTMLMediaElement() +HTMLMediaElement::~HTMLMediaElement() { NS_ASSERTION(!mHasSelfReference, "How can we be destroyed if we're still holding a self reference?"); @@ -1796,20 +1796,20 @@ nsHTMLMediaElement::~nsHTMLMediaElement() } void -nsHTMLMediaElement::GetItemValueText(nsAString& aValue) +HTMLMediaElement::GetItemValueText(nsAString& aValue) { // Can't call GetSrc because we don't have a JSContext GetURIAttr(nsGkAtoms::src, nullptr, aValue); } void -nsHTMLMediaElement::SetItemValueText(const nsAString& aValue) +HTMLMediaElement::SetItemValueText(const nsAString& aValue) { // Can't call SetSrc because we don't have a JSContext SetAttr(kNameSpaceID_None, nsGkAtoms::src, aValue, true); } -void nsHTMLMediaElement::StopSuspendingAfterFirstFrame() +void HTMLMediaElement::StopSuspendingAfterFirstFrame() { mAllowSuspendAfterFirstFrame = false; if (!mSuspendedAfterFirstFrame) @@ -1820,7 +1820,7 @@ void nsHTMLMediaElement::StopSuspendingAfterFirstFrame() } } -void nsHTMLMediaElement::SetPlayedOrSeeked(bool aValue) +void HTMLMediaElement::SetPlayedOrSeeked(bool aValue) { if (aValue == mHasPlayedOrSeeked) { return; @@ -1838,7 +1838,7 @@ void nsHTMLMediaElement::SetPlayedOrSeeked(bool aValue) NS_FRAME_IS_DIRTY); } -NS_IMETHODIMP nsHTMLMediaElement::Play() +NS_IMETHODIMP HTMLMediaElement::Play() { StopSuspendingAfterFirstFrame(); SetPlayedOrSeeked(true); @@ -1901,7 +1901,7 @@ NS_IMETHODIMP nsHTMLMediaElement::Play() return NS_OK; } -nsHTMLMediaElement::WakeLockBoolWrapper& nsHTMLMediaElement::WakeLockBoolWrapper::operator=(bool val) { +HTMLMediaElement::WakeLockBoolWrapper& HTMLMediaElement::WakeLockBoolWrapper::operator=(bool val) { if (mValue == val) return *this; if (!mWakeLock && !val && mOuter) { @@ -1918,17 +1918,17 @@ nsHTMLMediaElement::WakeLockBoolWrapper& nsHTMLMediaElement::WakeLockBoolWrapper return *this; } -bool nsHTMLMediaElement::ParseAttribute(int32_t aNamespaceID, - nsIAtom* aAttribute, - const nsAString& aValue, - nsAttrValue& aResult) +bool HTMLMediaElement::ParseAttribute(int32_t aNamespaceID, + nsIAtom* aAttribute, + const nsAString& aValue, + nsAttrValue& aResult) { // Mappings from 'preload' attribute strings to an enumeration. static const nsAttrValue::EnumTable kPreloadTable[] = { - { "", nsHTMLMediaElement::PRELOAD_ATTR_EMPTY }, - { "none", nsHTMLMediaElement::PRELOAD_ATTR_NONE }, - { "metadata", nsHTMLMediaElement::PRELOAD_ATTR_METADATA }, - { "auto", nsHTMLMediaElement::PRELOAD_ATTR_AUTO }, + { "", HTMLMediaElement::PRELOAD_ATTR_EMPTY }, + { "none", HTMLMediaElement::PRELOAD_ATTR_NONE }, + { "metadata", HTMLMediaElement::PRELOAD_ATTR_METADATA }, + { "auto", HTMLMediaElement::PRELOAD_ATTR_AUTO }, { 0 } }; @@ -1979,7 +1979,7 @@ bool nsHTMLMediaElement::ParseAttribute(int32_t aNamespaceID, aResult); } -bool nsHTMLMediaElement::CheckAudioChannelPermissions(const nsAString& aString) +bool HTMLMediaElement::CheckAudioChannelPermissions(const nsAString& aString) { #ifdef MOZ_B2G // Only normal channel doesn't need permission. @@ -2001,15 +2001,15 @@ bool nsHTMLMediaElement::CheckAudioChannelPermissions(const nsAString& aString) return true; } -void nsHTMLMediaElement::DoneCreatingElement() +void HTMLMediaElement::DoneCreatingElement() { if (HasAttr(kNameSpaceID_None, nsGkAtoms::muted)) mMuted = true; } -bool nsHTMLMediaElement::IsHTMLFocusable(bool aWithMouse, - bool *aIsFocusable, - int32_t *aTabIndex) +bool HTMLMediaElement::IsHTMLFocusable(bool aWithMouse, + bool *aIsFocusable, + int32_t *aTabIndex) { if (nsGenericHTMLElement::IsHTMLFocusable(aWithMouse, aIsFocusable, aTabIndex)) { return true; @@ -2019,14 +2019,14 @@ bool nsHTMLMediaElement::IsHTMLFocusable(bool aWithMouse, return false; } -int32_t nsHTMLMediaElement::TabIndexDefault() +int32_t HTMLMediaElement::TabIndexDefault() { return 0; } -nsresult nsHTMLMediaElement::SetAttr(int32_t aNameSpaceID, nsIAtom* aName, - nsIAtom* aPrefix, const nsAString& aValue, - bool aNotify) +nsresult HTMLMediaElement::SetAttr(int32_t aNameSpaceID, nsIAtom* aName, + nsIAtom* aPrefix, const nsAString& aValue, + bool aNotify) { nsresult rv = nsGenericHTMLElement::SetAttr(aNameSpaceID, aName, aPrefix, aValue, @@ -2053,8 +2053,8 @@ nsresult nsHTMLMediaElement::SetAttr(int32_t aNameSpaceID, nsIAtom* aName, return rv; } -nsresult nsHTMLMediaElement::UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttr, - bool aNotify) +nsresult HTMLMediaElement::UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttr, + bool aNotify) { nsresult rv = nsGenericHTMLElement::UnsetAttr(aNameSpaceID, aAttr, aNotify); if (NS_FAILED(rv)) @@ -2072,9 +2072,9 @@ nsresult nsHTMLMediaElement::UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttr, return rv; } -nsresult nsHTMLMediaElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent, - nsIContent* aBindingParent, - bool aCompileEventHandlers) +nsresult HTMLMediaElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent, + nsIContent* aBindingParent, + bool aCompileEventHandlers) { nsresult rv = nsGenericHTMLElement::BindToTree(aDocument, aParent, @@ -2099,8 +2099,8 @@ nsresult nsHTMLMediaElement::BindToTree(nsIDocument* aDocument, nsIContent* aPar return rv; } -void nsHTMLMediaElement::UnbindFromTree(bool aDeep, - bool aNullParent) +void HTMLMediaElement::UnbindFromTree(bool aDeep, + bool aNullParent) { if (!mPaused && mNetworkState != nsIDOMHTMLMediaElement::NETWORK_EMPTY) Pause(); @@ -2109,7 +2109,7 @@ void nsHTMLMediaElement::UnbindFromTree(bool aDeep, /* static */ CanPlayStatus -nsHTMLMediaElement::GetCanPlay(const nsAString& aType) +HTMLMediaElement::GetCanPlay(const nsAString& aType) { nsContentTypeParser parser(aType); nsAutoString mimeType; @@ -2127,7 +2127,7 @@ nsHTMLMediaElement::GetCanPlay(const nsAString& aType) } NS_IMETHODIMP -nsHTMLMediaElement::CanPlayType(const nsAString& aType, nsAString& aResult) +HTMLMediaElement::CanPlayType(const nsAString& aType, nsAString& aResult) { switch (GetCanPlay(aType)) { case CANPLAY_NO: @@ -2149,7 +2149,7 @@ nsHTMLMediaElement::CanPlayType(const nsAString& aType, nsAString& aResult) return NS_OK; } -nsresult nsHTMLMediaElement::InitializeDecoderAsClone(MediaDecoder* aOriginal) +nsresult HTMLMediaElement::InitializeDecoderAsClone(MediaDecoder* aOriginal) { NS_ASSERTION(mLoadingSrc, "mLoadingSrc must already be set"); NS_ASSERTION(mDecoder == nullptr, "Shouldn't have a decoder"); @@ -2184,8 +2184,8 @@ nsresult nsHTMLMediaElement::InitializeDecoderAsClone(MediaDecoder* aOriginal) return FinishDecoderSetup(decoder, resource, nullptr, aOriginal); } -nsresult nsHTMLMediaElement::InitializeDecoderForChannel(nsIChannel *aChannel, - nsIStreamListener **aListener) +nsresult HTMLMediaElement::InitializeDecoderForChannel(nsIChannel *aChannel, + nsIStreamListener **aListener) { NS_ASSERTION(mLoadingSrc, "mLoadingSrc must already be set"); NS_ASSERTION(mDecoder == nullptr, "Shouldn't have a decoder"); @@ -2217,10 +2217,10 @@ nsresult nsHTMLMediaElement::InitializeDecoderForChannel(nsIChannel *aChannel, return FinishDecoderSetup(decoder, resource, aListener, nullptr); } -nsresult nsHTMLMediaElement::FinishDecoderSetup(MediaDecoder* aDecoder, - MediaResource* aStream, - nsIStreamListener **aListener, - MediaDecoder* aCloneDonor) +nsresult HTMLMediaElement::FinishDecoderSetup(MediaDecoder* aDecoder, + MediaResource* aStream, + nsIStreamListener **aListener, + MediaDecoder* aCloneDonor) { mNetworkState = nsIDOMHTMLMediaElement::NETWORK_LOADING; @@ -2284,13 +2284,13 @@ nsresult nsHTMLMediaElement::FinishDecoderSetup(MediaDecoder* aDecoder, return rv; } -class nsHTMLMediaElement::StreamListener : public MediaStreamListener { +class HTMLMediaElement::StreamListener : public MediaStreamListener { public: - StreamListener(nsHTMLMediaElement* aElement) : + StreamListener(HTMLMediaElement* aElement) : mElement(aElement), mHaveCurrentData(false), mBlocked(false), - mMutex("nsHTMLMediaElement::StreamListener"), + mMutex("HTMLMediaElement::StreamListener"), mPendingNotifyOutput(false), mDidHaveCurrentData(false) {} @@ -2388,7 +2388,7 @@ public: private: // These fields may only be accessed on the main thread - nsHTMLMediaElement* mElement; + HTMLMediaElement* mElement; bool mHaveCurrentData; bool mBlocked; @@ -2398,7 +2398,7 @@ private: bool mDidHaveCurrentData; }; -void nsHTMLMediaElement::SetupSrcMediaStreamPlayback(DOMMediaStream* aStream) +void HTMLMediaElement::SetupSrcMediaStreamPlayback(DOMMediaStream* aStream) { NS_ASSERTION(!mSrcStream && !mSrcStreamListener, "Should have been ended already"); @@ -2430,7 +2430,7 @@ void nsHTMLMediaElement::SetupSrcMediaStreamPlayback(DOMMediaStream* aStream) // to complete the setup by entering the HAVE_CURRENT_DATA state. } -void nsHTMLMediaElement::EndSrcMediaStreamPlayback() +void HTMLMediaElement::EndSrcMediaStreamPlayback() { GetSrcMediaStream()->RemoveListener(mSrcStreamListener); // Kill its reference to this element @@ -2451,7 +2451,7 @@ void nsHTMLMediaElement::EndSrcMediaStreamPlayback() mSrcStream = nullptr; } -nsresult nsHTMLMediaElement::NewURIFromString(const nsAutoString& aURISpec, nsIURI** aURI) +nsresult HTMLMediaElement::NewURIFromString(const nsAutoString& aURISpec, nsIURI** aURI) { NS_ENSURE_ARG_POINTER(aURI); @@ -2483,7 +2483,7 @@ nsresult nsHTMLMediaElement::NewURIFromString(const nsAutoString& aURISpec, nsIU return NS_OK; } -void nsHTMLMediaElement::ProcessMediaFragmentURI() +void HTMLMediaElement::ProcessMediaFragmentURI() { nsMediaFragmentURIParser parser(mLoadingSrc); @@ -2497,11 +2497,11 @@ void nsHTMLMediaElement::ProcessMediaFragmentURI() } } -void nsHTMLMediaElement::MetadataLoaded(int aChannels, - int aRate, - bool aHasAudio, - bool aHasVideo, - const MetadataTags* aTags) +void HTMLMediaElement::MetadataLoaded(int aChannels, + int aRate, + bool aHasAudio, + bool aHasVideo, + const MetadataTags* aTags) { mChannels = aChannels; mRate = aRate; @@ -2523,7 +2523,7 @@ void nsHTMLMediaElement::MetadataLoaded(int aChannels, } } -void nsHTMLMediaElement::FirstFrameLoaded(bool aResourceFullyLoaded) +void HTMLMediaElement::FirstFrameLoaded(bool aResourceFullyLoaded) { ChangeReadyState(aResourceFullyLoaded ? nsIDOMHTMLMediaElement::HAVE_ENOUGH_DATA : @@ -2535,7 +2535,7 @@ void nsHTMLMediaElement::FirstFrameLoaded(bool aResourceFullyLoaded) if (mDecoder && mAllowSuspendAfterFirstFrame && mPaused && !aResourceFullyLoaded && !HasAttr(kNameSpaceID_None, nsGkAtoms::autoplay) && - mPreloadAction == nsHTMLMediaElement::PRELOAD_METADATA) { + mPreloadAction == HTMLMediaElement::PRELOAD_METADATA) { mSuspendedAfterFirstFrame = true; mDecoder->Suspend(); } else if (mLoadedFirstFrame && @@ -2555,7 +2555,7 @@ void nsHTMLMediaElement::FirstFrameLoaded(bool aResourceFullyLoaded) } } -void nsHTMLMediaElement::ResourceLoaded() +void HTMLMediaElement::ResourceLoaded() { NS_ASSERTION(!mSrcStream, "Don't call this for streams"); @@ -2575,12 +2575,12 @@ void nsHTMLMediaElement::ResourceLoaded() DispatchAsyncEvent(NS_LITERAL_STRING("suspend")); } -void nsHTMLMediaElement::NetworkError() +void HTMLMediaElement::NetworkError() { Error(nsIDOMMediaError::MEDIA_ERR_NETWORK); } -void nsHTMLMediaElement::DecodeError() +void HTMLMediaElement::DecodeError() { nsAutoString src; GetCurrentSrc(src); @@ -2604,12 +2604,12 @@ void nsHTMLMediaElement::DecodeError() } } -void nsHTMLMediaElement::LoadAborted() +void HTMLMediaElement::LoadAborted() { Error(nsIDOMMediaError::MEDIA_ERR_ABORTED); } -void nsHTMLMediaElement::Error(uint16_t aErrorCode) +void HTMLMediaElement::Error(uint16_t aErrorCode) { NS_ASSERTION(aErrorCode == nsIDOMMediaError::MEDIA_ERR_DECODE || aErrorCode == nsIDOMMediaError::MEDIA_ERR_NETWORK || @@ -2628,7 +2628,7 @@ void nsHTMLMediaElement::Error(uint16_t aErrorCode) ChangeDelayLoadStatus(false); } -void nsHTMLMediaElement::PlaybackEnded() +void HTMLMediaElement::PlaybackEnded() { // We changed state which can affect AddRemoveSelfReference AddRemoveSelfReference(); @@ -2659,14 +2659,14 @@ void nsHTMLMediaElement::PlaybackEnded() DispatchAsyncEvent(NS_LITERAL_STRING("ended")); } -void nsHTMLMediaElement::SeekStarted() +void HTMLMediaElement::SeekStarted() { DispatchAsyncEvent(NS_LITERAL_STRING("seeking")); ChangeReadyState(nsIDOMHTMLMediaElement::HAVE_METADATA); FireTimeUpdate(false); } -void nsHTMLMediaElement::SeekCompleted() +void HTMLMediaElement::SeekCompleted() { mPlayingBeforeSeek = false; SetPlayedOrSeeked(true); @@ -2675,12 +2675,12 @@ void nsHTMLMediaElement::SeekCompleted() AddRemoveSelfReference(); } -void nsHTMLMediaElement::NotifySuspendedByCache(bool aIsSuspended) +void HTMLMediaElement::NotifySuspendedByCache(bool aIsSuspended) { mDownloadSuspendedByCache = aIsSuspended; } -void nsHTMLMediaElement::DownloadSuspended() +void HTMLMediaElement::DownloadSuspended() { DispatchAsyncEvent(NS_LITERAL_STRING("progress")); if (mBegun) { @@ -2690,7 +2690,7 @@ void nsHTMLMediaElement::DownloadSuspended() } } -void nsHTMLMediaElement::DownloadResumed(bool aForceNetworkLoading) +void HTMLMediaElement::DownloadResumed(bool aForceNetworkLoading) { if (mBegun || aForceNetworkLoading) { mNetworkState = nsIDOMHTMLMediaElement::NETWORK_LOADING; @@ -2698,19 +2698,19 @@ void nsHTMLMediaElement::DownloadResumed(bool aForceNetworkLoading) } } -void nsHTMLMediaElement::DownloadStalled() +void HTMLMediaElement::DownloadStalled() { if (mNetworkState == nsIDOMHTMLMediaElement::NETWORK_LOADING) { DispatchAsyncEvent(NS_LITERAL_STRING("stalled")); } } -bool nsHTMLMediaElement::ShouldCheckAllowOrigin() +bool HTMLMediaElement::ShouldCheckAllowOrigin() { return mCORSMode != CORS_NONE; } -void nsHTMLMediaElement::UpdateReadyStateForData(MediaDecoderOwner::NextFrameStatus aNextFrame) +void HTMLMediaElement::UpdateReadyStateForData(MediaDecoderOwner::NextFrameStatus aNextFrame) { if (mReadyState < nsIDOMHTMLMediaElement::HAVE_METADATA) { // aNextFrame might have a next frame because the decoder can advance @@ -2779,7 +2779,7 @@ static const char* gReadyStateToString[] = { }; #endif -void nsHTMLMediaElement::ChangeReadyState(nsMediaReadyState aState) +void HTMLMediaElement::ChangeReadyState(nsMediaReadyState aState) { nsMediaReadyState oldState = mReadyState; mReadyState = aState; @@ -2832,7 +2832,7 @@ void nsHTMLMediaElement::ChangeReadyState(nsMediaReadyState aState) } } -bool nsHTMLMediaElement::CanActivateAutoplay() +bool HTMLMediaElement::CanActivateAutoplay() { return mAutoplaying && mPaused && @@ -2841,7 +2841,7 @@ bool nsHTMLMediaElement::CanActivateAutoplay() !IsEditable(); } -void nsHTMLMediaElement::NotifyAutoplayDataReady() +void HTMLMediaElement::NotifyAutoplayDataReady() { if (CanActivateAutoplay()) { mPaused = false; @@ -2862,7 +2862,7 @@ void nsHTMLMediaElement::NotifyAutoplayDataReady() } } -VideoFrameContainer* nsHTMLMediaElement::GetVideoFrameContainer() +VideoFrameContainer* HTMLMediaElement::GetVideoFrameContainer() { // If we have loaded the metadata, and the size of the video is still // (-1, -1), the media has no video. Don't go a create a video frame @@ -2891,9 +2891,9 @@ VideoFrameContainer* nsHTMLMediaElement::GetVideoFrameContainer() return mVideoFrameContainer; } -nsresult nsHTMLMediaElement::DispatchAudioAvailableEvent(float* aFrameBuffer, - uint32_t aFrameBufferLength, - float aTime) +nsresult HTMLMediaElement::DispatchAudioAvailableEvent(float* aFrameBuffer, + uint32_t aFrameBufferLength, + float aTime) { // Auto manage the memory for the frame buffer. If we fail and return // an error, this ensures we free the memory in the frame buffer. Otherwise @@ -2920,7 +2920,7 @@ nsresult nsHTMLMediaElement::DispatchAudioAvailableEvent(float* aFrameBuffer, return target->DispatchEvent(event, &dummy); } -nsresult nsHTMLMediaElement::DispatchEvent(const nsAString& aName) +nsresult HTMLMediaElement::DispatchEvent(const nsAString& aName) { LOG_EVENT(PR_LOG_DEBUG, ("%p Dispatching event %s", this, NS_ConvertUTF16toUTF8(aName).get())); @@ -2939,7 +2939,7 @@ nsresult nsHTMLMediaElement::DispatchEvent(const nsAString& aName) false); } -nsresult nsHTMLMediaElement::DispatchAsyncEvent(const nsAString& aName) +nsresult HTMLMediaElement::DispatchAsyncEvent(const nsAString& aName) { LOG_EVENT(PR_LOG_DEBUG, ("%p Queuing event %s", this, NS_ConvertUTF16toUTF8(aName).get())); @@ -2949,7 +2949,7 @@ nsresult nsHTMLMediaElement::DispatchAsyncEvent(const nsAString& aName) return NS_OK; } -nsresult nsHTMLMediaElement::DispatchPendingMediaEvents() +nsresult HTMLMediaElement::DispatchPendingMediaEvents() { NS_ASSERTION(!mEventDeliveryPaused, "Must not be in bfcache when dispatching pending media events"); @@ -2963,7 +2963,7 @@ nsresult nsHTMLMediaElement::DispatchPendingMediaEvents() return NS_OK; } -bool nsHTMLMediaElement::IsPotentiallyPlaying() const +bool HTMLMediaElement::IsPotentiallyPlaying() const { // TODO: // playback has not stopped due to errors, @@ -2975,7 +2975,7 @@ bool nsHTMLMediaElement::IsPotentiallyPlaying() const !IsPlaybackEnded(); } -bool nsHTMLMediaElement::IsPlaybackEnded() const +bool HTMLMediaElement::IsPlaybackEnded() const { // TODO: // the current playback position is equal to the effective end of the media resource. @@ -2984,7 +2984,7 @@ bool nsHTMLMediaElement::IsPlaybackEnded() const mDecoder ? mDecoder->IsEnded() : false; } -already_AddRefed nsHTMLMediaElement::GetCurrentPrincipal() +already_AddRefed HTMLMediaElement::GetCurrentPrincipal() { if (mDecoder) { return mDecoder->GetCurrentPrincipal(); @@ -2996,7 +2996,7 @@ already_AddRefed nsHTMLMediaElement::GetCurrentPrincipal() return nullptr; } -void nsHTMLMediaElement::NotifyDecoderPrincipalChanged() +void HTMLMediaElement::NotifyDecoderPrincipalChanged() { for (uint32_t i = 0; i < mOutputStreams.Length(); ++i) { OutputMediaStream* ms = &mOutputStreams[i]; @@ -3005,12 +3005,12 @@ void nsHTMLMediaElement::NotifyDecoderPrincipalChanged() } } -void nsHTMLMediaElement::UpdateMediaSize(nsIntSize size) +void HTMLMediaElement::UpdateMediaSize(nsIntSize size) { mMediaSize = size; } -void nsHTMLMediaElement::SuspendOrResumeElement(bool aPauseElement, bool aSuspendEvents) +void HTMLMediaElement::SuspendOrResumeElement(bool aPauseElement, bool aSuspendEvents) { if (aPauseElement != mPausedForInactiveDocumentOrChannel) { mPausedForInactiveDocumentOrChannel = aPauseElement; @@ -3039,7 +3039,7 @@ void nsHTMLMediaElement::SuspendOrResumeElement(bool aPauseElement, bool aSuspen } } -void nsHTMLMediaElement::NotifyOwnerDocumentActivityChanged() +void HTMLMediaElement::NotifyOwnerDocumentActivityChanged() { nsIDocument* ownerDoc = OwnerDoc(); #ifdef MOZ_B2G @@ -3061,7 +3061,7 @@ void nsHTMLMediaElement::NotifyOwnerDocumentActivityChanged() AddRemoveSelfReference(); } -void nsHTMLMediaElement::AddRemoveSelfReference() +void HTMLMediaElement::AddRemoveSelfReference() { // XXX we could release earlier here in many situations if we examined // which event listeners are attached. Right now we assume there is a @@ -3092,7 +3092,7 @@ void nsHTMLMediaElement::AddRemoveSelfReference() // Dispatch Release asynchronously so that we don't destroy this object // inside a call stack of method calls on this object nsCOMPtr event = - NS_NewRunnableMethod(this, &nsHTMLMediaElement::DoRemoveSelfReference); + NS_NewRunnableMethod(this, &HTMLMediaElement::DoRemoveSelfReference); NS_DispatchToMainThread(event); } } @@ -3100,15 +3100,15 @@ void nsHTMLMediaElement::AddRemoveSelfReference() UpdateAudioChannelPlayingState(); } -void nsHTMLMediaElement::DoRemoveSelfReference() +void HTMLMediaElement::DoRemoveSelfReference() { // We don't need the shutdown observer anymore. Unregistering releases // its reference to us, which we were using as our self-reference. nsContentUtils::UnregisterShutdownObserver(this); } -nsresult nsHTMLMediaElement::Observe(nsISupports* aSubject, - const char* aTopic, const PRUnichar* aData) +nsresult HTMLMediaElement::Observe(nsISupports* aSubject, + const char* aTopic, const PRUnichar* aData) { NS_ENSURE_TRUE(nsContentUtils::IsCallerChrome(), NS_ERROR_NOT_AVAILABLE); @@ -3120,12 +3120,12 @@ nsresult nsHTMLMediaElement::Observe(nsISupports* aSubject, } bool -nsHTMLMediaElement::IsNodeOfType(uint32_t aFlags) const +HTMLMediaElement::IsNodeOfType(uint32_t aFlags) const { return !(aFlags & ~(eCONTENT | eMEDIA)); } -void nsHTMLMediaElement::DispatchAsyncSourceError(nsIContent* aSourceElement) +void HTMLMediaElement::DispatchAsyncSourceError(nsIContent* aSourceElement) { LOG_EVENT(PR_LOG_DEBUG, ("%p Queuing simple source error event", this)); @@ -3133,7 +3133,7 @@ void nsHTMLMediaElement::DispatchAsyncSourceError(nsIContent* aSourceElement) NS_DispatchToMainThread(event, NS_DISPATCH_NORMAL); } -void nsHTMLMediaElement::NotifyAddedSource() +void HTMLMediaElement::NotifyAddedSource() { // If a source element is inserted as a child of a media element // that has no src attribute and whose networkState has the value @@ -3152,7 +3152,7 @@ void nsHTMLMediaElement::NotifyAddedSource() } } -nsIContent* nsHTMLMediaElement::GetNextSource() +nsIContent* HTMLMediaElement::GetNextSource() { nsCOMPtr thisDomNode = do_QueryObject(this); @@ -3202,7 +3202,7 @@ nsIContent* nsHTMLMediaElement::GetNextSource() return nullptr; } -void nsHTMLMediaElement::ChangeDelayLoadStatus(bool aDelay) +void HTMLMediaElement::ChangeDelayLoadStatus(bool aDelay) { if (mDelayingLoadEvent == aDelay) return; @@ -3229,7 +3229,7 @@ void nsHTMLMediaElement::ChangeDelayLoadStatus(bool aDelay) AddRemoveSelfReference(); } -already_AddRefed nsHTMLMediaElement::GetDocumentLoadGroup() +already_AddRefed HTMLMediaElement::GetDocumentLoadGroup() { if (!OwnerDoc()->IsActive()) { NS_WARNING("Load group requested for media element in inactive document."); @@ -3238,12 +3238,12 @@ already_AddRefed nsHTMLMediaElement::GetDocumentLoadGroup() } nsresult -nsHTMLMediaElement::CopyInnerTo(Element* aDest) +HTMLMediaElement::CopyInnerTo(Element* aDest) { nsresult rv = nsGenericHTMLElement::CopyInnerTo(aDest); NS_ENSURE_SUCCESS(rv, rv); if (aDest->OwnerDoc()->IsStaticDocument()) { - nsHTMLMediaElement* dest = static_cast(aDest); + HTMLMediaElement* dest = static_cast(aDest); if (mPrintSurface) { dest->mPrintSurface = mPrintSurface; dest->mMediaSize = mMediaSize; @@ -3255,7 +3255,7 @@ nsHTMLMediaElement::CopyInnerTo(Element* aDest) nsIContent* content = static_cast(frame)->GetPosterImage(); element = content ? content->AsElement() : NULL; } else { - element = const_cast(this); + element = const_cast(this); } nsLayoutUtils::SurfaceFromElementResult res = @@ -3268,7 +3268,7 @@ nsHTMLMediaElement::CopyInnerTo(Element* aDest) return rv; } -nsresult nsHTMLMediaElement::GetBuffered(nsIDOMTimeRanges** aBuffered) +nsresult HTMLMediaElement::GetBuffered(nsIDOMTimeRanges** aBuffered) { nsRefPtr ranges = new TimeRanges(); if (mReadyState > nsIDOMHTMLMediaElement::HAVE_NOTHING && mDecoder) { @@ -3280,7 +3280,7 @@ nsresult nsHTMLMediaElement::GetBuffered(nsIDOMTimeRanges** aBuffered) return NS_OK; } -void nsHTMLMediaElement::SetRequestHeaders(nsIHttpChannel* aChannel) +void HTMLMediaElement::SetRequestHeaders(nsIHttpChannel* aChannel) { // Send Accept header for video and audio types only (Bug 489071) SetAcceptHeader(aChannel); @@ -3304,7 +3304,7 @@ void nsHTMLMediaElement::SetRequestHeaders(nsIHttpChannel* aChannel) aChannel->SetReferrer(OwnerDoc()->GetDocumentURI()); } -void nsHTMLMediaElement::FireTimeUpdate(bool aPeriodic) +void HTMLMediaElement::FireTimeUpdate(bool aPeriodic) { NS_ASSERTION(NS_IsMainThread(), "Should be on main thread."); @@ -3332,7 +3332,7 @@ void nsHTMLMediaElement::FireTimeUpdate(bool aPeriodic) } } -void nsHTMLMediaElement::GetCurrentSpec(nsCString& aString) +void HTMLMediaElement::GetCurrentSpec(nsCString& aString) { if (mLoadingSrc) { mLoadingSrc->GetSpec(aString); @@ -3342,7 +3342,7 @@ void nsHTMLMediaElement::GetCurrentSpec(nsCString& aString) } /* attribute double initialTime; */ -NS_IMETHODIMP nsHTMLMediaElement::GetInitialTime(double *aTime) +NS_IMETHODIMP HTMLMediaElement::GetInitialTime(double *aTime) { // If there is no start fragment then the initalTime is zero. // Clamp to duration if it is greater than duration. @@ -3358,7 +3358,7 @@ NS_IMETHODIMP nsHTMLMediaElement::GetInitialTime(double *aTime) } /* attribute double mozFragmentEnd; */ -NS_IMETHODIMP nsHTMLMediaElement::GetMozFragmentEnd(double *aTime) +NS_IMETHODIMP HTMLMediaElement::GetMozFragmentEnd(double *aTime) { double duration = 0.0; nsresult rv = GetDuration(&duration); @@ -3370,7 +3370,7 @@ NS_IMETHODIMP nsHTMLMediaElement::GetMozFragmentEnd(double *aTime) return NS_OK; } -void nsHTMLMediaElement::NotifyAudioAvailableListener() +void HTMLMediaElement::NotifyAudioAvailableListener() { if (mDecoder) { mDecoder->NotifyAudioAvailableListener(); @@ -3392,13 +3392,13 @@ static double ClampPlaybackRate(double aPlaybackRate) } /* attribute double defaultPlaybackRate; */ -NS_IMETHODIMP nsHTMLMediaElement::GetDefaultPlaybackRate(double* aDefaultPlaybackRate) +NS_IMETHODIMP HTMLMediaElement::GetDefaultPlaybackRate(double* aDefaultPlaybackRate) { *aDefaultPlaybackRate = mDefaultPlaybackRate; return NS_OK; } -NS_IMETHODIMP nsHTMLMediaElement::SetDefaultPlaybackRate(double aDefaultPlaybackRate) +NS_IMETHODIMP HTMLMediaElement::SetDefaultPlaybackRate(double aDefaultPlaybackRate) { if (aDefaultPlaybackRate < 0) { return NS_ERROR_NOT_IMPLEMENTED; @@ -3410,13 +3410,13 @@ NS_IMETHODIMP nsHTMLMediaElement::SetDefaultPlaybackRate(double aDefaultPlayback } /* attribute double playbackRate; */ -NS_IMETHODIMP nsHTMLMediaElement::GetPlaybackRate(double* aPlaybackRate) +NS_IMETHODIMP HTMLMediaElement::GetPlaybackRate(double* aPlaybackRate) { *aPlaybackRate = mPlaybackRate; return NS_OK; } -NS_IMETHODIMP nsHTMLMediaElement::SetPlaybackRate(double aPlaybackRate) +NS_IMETHODIMP HTMLMediaElement::SetPlaybackRate(double aPlaybackRate) { // Changing the playback rate of a media that has more than two channels is // not supported. @@ -3444,13 +3444,13 @@ NS_IMETHODIMP nsHTMLMediaElement::SetPlaybackRate(double aPlaybackRate) } /* attribute bool mozPreservesPitch; */ -NS_IMETHODIMP nsHTMLMediaElement::GetMozPreservesPitch(bool* aPreservesPitch) +NS_IMETHODIMP HTMLMediaElement::GetMozPreservesPitch(bool* aPreservesPitch) { *aPreservesPitch = mPreservesPitch; return NS_OK; } -NS_IMETHODIMP nsHTMLMediaElement::SetMozPreservesPitch(bool aPreservesPitch) +NS_IMETHODIMP HTMLMediaElement::SetMozPreservesPitch(bool aPreservesPitch) { mPreservesPitch = aPreservesPitch; if (mDecoder) { @@ -3459,15 +3459,15 @@ NS_IMETHODIMP nsHTMLMediaElement::SetMozPreservesPitch(bool aPreservesPitch) return NS_OK; } -ImageContainer* nsHTMLMediaElement::GetImageContainer() +ImageContainer* HTMLMediaElement::GetImageContainer() { VideoFrameContainer* container = GetVideoFrameContainer(); return container ? container->GetImageContainer() : nullptr; } -nsresult nsHTMLMediaElement::UpdateChannelMuteState(bool aCanPlay) +nsresult HTMLMediaElement::UpdateChannelMuteState(bool aCanPlay) { - // Only on B2G we mute the nsHTMLMediaElement following the rules of + // Only on B2G we mute the HTMLMediaElement following the rules of // AudioChannelService. #ifdef MOZ_B2G // We have to mute this channel: @@ -3485,9 +3485,9 @@ nsresult nsHTMLMediaElement::UpdateChannelMuteState(bool aCanPlay) return NS_OK; } -void nsHTMLMediaElement::UpdateAudioChannelPlayingState() +void HTMLMediaElement::UpdateAudioChannelPlayingState() { - // The nsHTMLMediaElement is registered to the AudioChannelService only on B2G. + // The HTMLMediaElement is registered to the AudioChannelService only on B2G. #ifdef MOZ_B2G bool playingThroughTheAudioChannel = (!mPaused && @@ -3525,10 +3525,13 @@ void nsHTMLMediaElement::UpdateAudioChannelPlayingState() } /* void canPlayChanged (in boolean canPlay); */ -NS_IMETHODIMP nsHTMLMediaElement::CanPlayChanged(bool canPlay) +NS_IMETHODIMP HTMLMediaElement::CanPlayChanged(bool canPlay) { NS_ENSURE_TRUE(nsContentUtils::IsCallerChrome(), NS_ERROR_NOT_AVAILABLE); UpdateChannelMuteState(canPlay); return NS_OK; } + +} // namespace dom +} // namespace mozilla diff --git a/content/html/content/src/HTMLSourceElement.cpp b/content/html/content/src/HTMLSourceElement.cpp index e0918341e8c6..6a6d4cc044f8 100644 --- a/content/html/content/src/HTMLSourceElement.cpp +++ b/content/html/content/src/HTMLSourceElement.cpp @@ -70,7 +70,7 @@ HTMLSourceElement::BindToTree(nsIDocument *aDocument, if (!aParent || !aParent->IsNodeOfType(nsINode::eMEDIA)) return NS_OK; - nsHTMLMediaElement* media = static_cast(aParent); + HTMLMediaElement* media = static_cast(aParent); media->NotifyAddedSource(); return NS_OK; diff --git a/content/html/content/src/HTMLSourceElement.h b/content/html/content/src/HTMLSourceElement.h index 69e5ecdfe82e..0025905d647f 100644 --- a/content/html/content/src/HTMLSourceElement.h +++ b/content/html/content/src/HTMLSourceElement.h @@ -9,7 +9,7 @@ #include "nsIDOMHTMLSourceElement.h" #include "nsGenericHTMLElement.h" -#include "nsHTMLMediaElement.h" +#include "mozilla/dom/HTMLMediaElement.h" namespace mozilla { namespace dom { diff --git a/content/html/content/src/Makefile.in b/content/html/content/src/Makefile.in index 5ece96e1171c..1c8f0d1f0c9f 100644 --- a/content/html/content/src/Makefile.in +++ b/content/html/content/src/Makefile.in @@ -161,7 +161,7 @@ EXPORTS_mozilla/dom += \ CPPSRCS += \ nsHTMLAudioElement.cpp \ - nsHTMLMediaElement.cpp \ + HTMLMediaElement.cpp \ MediaError.cpp \ HTMLSourceElement.cpp \ TimeRanges.cpp \ diff --git a/content/html/content/src/MediaError.cpp b/content/html/content/src/MediaError.cpp index 076a06cc6885..413932564d51 100644 --- a/content/html/content/src/MediaError.cpp +++ b/content/html/content/src/MediaError.cpp @@ -21,7 +21,7 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(MediaError) NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMMediaError) NS_INTERFACE_MAP_END -MediaError::MediaError(nsHTMLMediaElement* aParent, uint16_t aCode) +MediaError::MediaError(HTMLMediaElement* aParent, uint16_t aCode) : mParent(aParent) , mCode(aCode) { diff --git a/content/html/content/src/MediaError.h b/content/html/content/src/MediaError.h index 7ee64eb66a24..f9ff9923fc10 100644 --- a/content/html/content/src/MediaError.h +++ b/content/html/content/src/MediaError.h @@ -8,7 +8,7 @@ #define mozilla_dom_MediaError_h #include "nsIDOMMediaError.h" -#include "nsHTMLMediaElement.h" +#include "mozilla/dom/HTMLMediaElement.h" #include "nsWrapperCache.h" #include "nsISupports.h" #include "mozilla/Attributes.h" @@ -20,7 +20,7 @@ class MediaError MOZ_FINAL : public nsIDOMMediaError, public nsWrapperCache { public: - MediaError(nsHTMLMediaElement* aParent, uint16_t aCode); + MediaError(HTMLMediaElement* aParent, uint16_t aCode); // nsISupports NS_DECL_CYCLE_COLLECTING_ISUPPORTS @@ -29,7 +29,7 @@ public: // nsIDOMMediaError NS_DECL_NSIDOMMEDIAERROR - nsHTMLMediaElement* GetParentObject() const + HTMLMediaElement* GetParentObject() const { return mParent; } @@ -42,7 +42,7 @@ public: } private: - nsRefPtr mParent; + nsRefPtr mParent; // Error code const uint16_t mCode; diff --git a/content/html/content/src/TimeRanges.cpp b/content/html/content/src/TimeRanges.cpp index d1735f643836..5facecced9e0 100644 --- a/content/html/content/src/TimeRanges.cpp +++ b/content/html/content/src/TimeRanges.cpp @@ -6,7 +6,7 @@ #include "mozilla/dom/TimeRanges.h" #include "mozilla/dom/TimeRangesBinding.h" -#include "nsHTMLMediaElement.h" +#include "mozilla/dom/HTMLMediaElement.h" #include "nsContentUtils.h" #include "nsDOMClassInfoID.h" #include "nsError.h" diff --git a/content/html/content/src/nsHTMLAudioElement.cpp b/content/html/content/src/nsHTMLAudioElement.cpp index 562c3819eeff..da0908e1606f 100644 --- a/content/html/content/src/nsHTMLAudioElement.cpp +++ b/content/html/content/src/nsHTMLAudioElement.cpp @@ -50,8 +50,8 @@ NS_NewHTMLAudioElement(already_AddRefed aNodeInfo, return new nsHTMLAudioElement(nodeInfo.forget()); } -NS_IMPL_ADDREF_INHERITED(nsHTMLAudioElement, nsHTMLMediaElement) -NS_IMPL_RELEASE_INHERITED(nsHTMLAudioElement, nsHTMLMediaElement) +NS_IMPL_ADDREF_INHERITED(nsHTMLAudioElement, HTMLMediaElement) +NS_IMPL_RELEASE_INHERITED(nsHTMLAudioElement, HTMLMediaElement) DOMCI_NODE_DATA(HTMLAudioElement, nsHTMLAudioElement) @@ -59,14 +59,14 @@ NS_INTERFACE_TABLE_HEAD(nsHTMLAudioElement) NS_HTML_CONTENT_INTERFACE_TABLE3(nsHTMLAudioElement, nsIDOMHTMLMediaElement, nsIDOMHTMLAudioElement, nsIJSNativeInitializer) NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLAudioElement, - nsHTMLMediaElement) + HTMLMediaElement) NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLAudioElement) NS_IMPL_ELEMENT_CLONE(nsHTMLAudioElement) nsHTMLAudioElement::nsHTMLAudioElement(already_AddRefed aNodeInfo) - : nsHTMLMediaElement(aNodeInfo) + : HTMLMediaElement(aNodeInfo) { } diff --git a/content/html/content/src/nsHTMLVideoElement.cpp b/content/html/content/src/nsHTMLVideoElement.cpp index 4bf51a55584e..0d79fc92a64f 100644 --- a/content/html/content/src/nsHTMLVideoElement.cpp +++ b/content/html/content/src/nsHTMLVideoElement.cpp @@ -37,15 +37,15 @@ using namespace mozilla::dom; NS_IMPL_NS_NEW_HTML_ELEMENT(Video) -NS_IMPL_ADDREF_INHERITED(nsHTMLVideoElement, nsHTMLMediaElement) -NS_IMPL_RELEASE_INHERITED(nsHTMLVideoElement, nsHTMLMediaElement) +NS_IMPL_ADDREF_INHERITED(nsHTMLVideoElement, HTMLMediaElement) +NS_IMPL_RELEASE_INHERITED(nsHTMLVideoElement, HTMLMediaElement) DOMCI_NODE_DATA(HTMLVideoElement, nsHTMLVideoElement) NS_INTERFACE_TABLE_HEAD(nsHTMLVideoElement) NS_HTML_CONTENT_INTERFACE_TABLE2(nsHTMLVideoElement, nsIDOMHTMLMediaElement, nsIDOMHTMLVideoElement) NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLVideoElement, - nsHTMLMediaElement) + HTMLMediaElement) NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLVideoElement) NS_IMPL_ELEMENT_CLONE(nsHTMLVideoElement) @@ -70,7 +70,7 @@ NS_IMETHODIMP nsHTMLVideoElement::GetVideoHeight(uint32_t *aVideoHeight) } nsHTMLVideoElement::nsHTMLVideoElement(already_AddRefed aNodeInfo) - : nsHTMLMediaElement(aNodeInfo) + : HTMLMediaElement(aNodeInfo) { } @@ -99,8 +99,8 @@ nsHTMLVideoElement::ParseAttribute(int32_t aNamespaceID, return aResult.ParseSpecialIntValue(aValue); } - return nsHTMLMediaElement::ParseAttribute(aNamespaceID, aAttribute, aValue, - aResult); + return HTMLMediaElement::ParseAttribute(aNamespaceID, aAttribute, aValue, + aResult); } static void @@ -180,7 +180,7 @@ NS_IMETHODIMP nsHTMLVideoElement::GetMozPresentedFrames(uint32_t *aMozPresentedF NS_IMETHODIMP nsHTMLVideoElement::GetMozPaintedFrames(uint32_t *aMozPaintedFrames) { NS_ASSERTION(NS_IsMainThread(), "Should be on main thread."); - ImageContainer* container = GetImageContainer(); + layers::ImageContainer* container = GetImageContainer(); *aMozPaintedFrames = container ? container->GetPaintCount() : 0; return NS_OK; } diff --git a/content/html/document/src/VideoDocument.cpp b/content/html/document/src/VideoDocument.cpp index c14e1c2d1ef6..6496d95c8b7c 100644 --- a/content/html/document/src/VideoDocument.cpp +++ b/content/html/document/src/VideoDocument.cpp @@ -7,7 +7,7 @@ #include "nsGkAtoms.h" #include "nsNodeInfoManager.h" #include "nsContentCreatorFunctions.h" -#include "nsHTMLMediaElement.h" +#include "mozilla/dom/HTMLMediaElement.h" #include "nsIDocumentInlines.h" #include "nsContentUtils.h" #include "mozilla/dom/Element.h" @@ -101,9 +101,9 @@ VideoDocument::CreateSyntheticVideoDocument(nsIChannel* aChannel, nsIDOMNode::ELEMENT_NODE); NS_ENSURE_TRUE(nodeInfo, NS_ERROR_FAILURE); - nsRefPtr element = - static_cast(NS_NewHTMLVideoElement(nodeInfo.forget(), - NOT_FROM_PARSER)); + nsRefPtr element = + static_cast(NS_NewHTMLVideoElement(nodeInfo.forget(), + NOT_FROM_PARSER)); if (!element) return NS_ERROR_OUT_OF_MEMORY; element->SetAutoplay(true); diff --git a/content/media/MediaDecoderOwner.h b/content/media/MediaDecoderOwner.h index 03f148ac6819..e3774e4220ec 100644 --- a/content/media/MediaDecoderOwner.h +++ b/content/media/MediaDecoderOwner.h @@ -7,12 +7,14 @@ #define MediaDecoderOwner_h_ #include "AbstractMediaDecoder.h" -class nsHTMLMediaElement; - namespace mozilla { class VideoFrameContainer; +namespace dom { +class HTMLMediaElement; +} + class MediaDecoderOwner { public: @@ -34,9 +36,9 @@ public: */ virtual void FireTimeUpdate(bool aPeriodic) = 0; - // Get the nsHTMLMediaElement object if the decoder is being used from an + // Get the HTMLMediaElement object if the decoder is being used from an // HTML media element, and null otherwise. - virtual nsHTMLMediaElement* GetMediaElement() + virtual dom::HTMLMediaElement* GetMediaElement() { return nullptr; } diff --git a/content/media/MediaDecoderReader.h b/content/media/MediaDecoderReader.h index 198bd2eb49ae..8b2fe5047e38 100644 --- a/content/media/MediaDecoderReader.h +++ b/content/media/MediaDecoderReader.h @@ -14,7 +14,7 @@ #include "ImageLayers.h" #include "AudioSampleFormat.h" #include "MediaResource.h" -#include "nsHTMLMediaElement.h" +#include "mozilla/dom/HTMLMediaElement.h" namespace mozilla { diff --git a/content/media/MediaResource.cpp b/content/media/MediaResource.cpp index b458e32b6d37..ba9e7ad1442b 100644 --- a/content/media/MediaResource.cpp +++ b/content/media/MediaResource.cpp @@ -23,7 +23,7 @@ #include "nsIStreamListener.h" #include "nsIScriptSecurityManager.h" #include "nsCrossSiteListenerProxy.h" -#include "nsHTMLMediaElement.h" +#include "mozilla/dom/HTMLMediaElement.h" #include "nsError.h" #include "nsICachingChannel.h" #include "nsURILoader.h" @@ -152,7 +152,7 @@ ChannelMediaResource::OnStartRequest(nsIRequest* aRequest) MediaDecoderOwner* owner = mDecoder->GetMediaOwner(); NS_ENSURE_TRUE(owner, NS_ERROR_FAILURE); - nsHTMLMediaElement* element = owner->GetMediaElement(); + HTMLMediaElement* element = owner->GetMediaElement(); NS_ENSURE_TRUE(element, NS_ERROR_FAILURE); nsresult status; nsresult rv = aRequest->GetStatus(&status); @@ -610,7 +610,7 @@ nsresult ChannelMediaResource::OpenChannel(nsIStreamListener** aStreamListener) // an authorizing Access-Control header. MediaDecoderOwner* owner = mDecoder->GetMediaOwner(); NS_ENSURE_TRUE(owner, NS_ERROR_FAILURE); - nsHTMLMediaElement* element = owner->GetMediaElement(); + HTMLMediaElement* element = owner->GetMediaElement(); NS_ENSURE_TRUE(element, NS_ERROR_FAILURE); if (element->ShouldCheckAllowOrigin()) { nsRefPtr crossSiteListener = @@ -669,7 +669,7 @@ void ChannelMediaResource::SetupChannelHeaders() if (!owner) { return; } - nsHTMLMediaElement* element = owner->GetMediaElement(); + HTMLMediaElement* element = owner->GetMediaElement(); if (!element) { return; } @@ -818,7 +818,7 @@ void ChannelMediaResource::Suspend(bool aCloseImmediately) // Shutting down; do nothing. return; } - nsHTMLMediaElement* element = owner->GetMediaElement(); + HTMLMediaElement* element = owner->GetMediaElement(); if (!element) { // Shutting down; do nothing. return; @@ -853,7 +853,7 @@ void ChannelMediaResource::Resume() // Shutting down; do nothing. return; } - nsHTMLMediaElement* element = owner->GetMediaElement(); + HTMLMediaElement* element = owner->GetMediaElement(); if (!element) { // Shutting down; do nothing. return; @@ -902,7 +902,7 @@ ChannelMediaResource::RecreateChannel() // The decoder is being shut down, so don't bother opening a new channel return NS_OK; } - nsHTMLMediaElement* element = owner->GetMediaElement(); + HTMLMediaElement* element = owner->GetMediaElement(); if (!element) { // The decoder is being shut down, so don't bother opening a new channel return NS_OK; @@ -1430,7 +1430,7 @@ nsresult FileMediaResource::Open(nsIStreamListener** aStreamListener) // web server. MediaDecoderOwner* owner = mDecoder->GetMediaOwner(); NS_ENSURE_TRUE(owner, NS_ERROR_FAILURE); - nsHTMLMediaElement* element = owner->GetMediaElement(); + HTMLMediaElement* element = owner->GetMediaElement(); NS_ENSURE_TRUE(element, NS_ERROR_FAILURE); rv = nsContentUtils::GetSecurityManager()-> @@ -1495,7 +1495,7 @@ MediaResource* FileMediaResource::CloneData(MediaDecoder* aDecoder) // The decoder is being shut down, so we can't clone return nullptr; } - nsHTMLMediaElement* element = owner->GetMediaElement(); + HTMLMediaElement* element = owner->GetMediaElement(); if (!element) { // The decoder is being shut down, so we can't clone return nullptr; @@ -1610,7 +1610,7 @@ void BaseMediaResource::MoveLoadsToBackground() { NS_WARNING("Null owner in MediaResource::MoveLoadsToBackground()"); return; } - nsHTMLMediaElement* element = owner->GetMediaElement(); + HTMLMediaElement* element = owner->GetMediaElement(); if (!element) { NS_WARNING("Null element in MediaResource::MoveLoadsToBackground()"); return; diff --git a/content/media/VideoFrameContainer.cpp b/content/media/VideoFrameContainer.cpp index f015d83106db..83ba71cf77df 100644 --- a/content/media/VideoFrameContainer.cpp +++ b/content/media/VideoFrameContainer.cpp @@ -6,7 +6,7 @@ #include "VideoFrameContainer.h" -#include "nsHTMLMediaElement.h" +#include "mozilla/dom/HTMLMediaElement.h" #include "nsIFrame.h" #include "nsDisplayList.h" #include "nsSVGEffects.h" @@ -16,7 +16,7 @@ using namespace mozilla::layers; namespace mozilla { -VideoFrameContainer::VideoFrameContainer(nsHTMLMediaElement* aElement, +VideoFrameContainer::VideoFrameContainer(dom::HTMLMediaElement* aElement, already_AddRefed aContainer) : mElement(aElement), mImageContainer(aContainer), mMutex("nsVideoFrameContainer"), diff --git a/content/media/VideoFrameContainer.h b/content/media/VideoFrameContainer.h index fc2f719b165d..8690570d9ea4 100644 --- a/content/media/VideoFrameContainer.h +++ b/content/media/VideoFrameContainer.h @@ -14,10 +14,12 @@ #include "nsCOMPtr.h" #include "nsAutoPtr.h" -class nsHTMLMediaElement; - namespace mozilla { +namespace dom { +class HTMLMediaElement; +} + namespace layers { class Image; class ImageContainer; @@ -34,12 +36,12 @@ class ImageContainer; */ class VideoFrameContainer { public: - typedef mozilla::layers::ImageContainer ImageContainer; - typedef mozilla::layers::Image Image; + typedef layers::ImageContainer ImageContainer; + typedef layers::Image Image; NS_INLINE_DECL_THREADSAFE_REFCOUNTING(VideoFrameContainer) - VideoFrameContainer(nsHTMLMediaElement* aElement, + VideoFrameContainer(dom::HTMLMediaElement* aElement, already_AddRefed aContainer); ~VideoFrameContainer(); @@ -61,7 +63,7 @@ public: protected: // Non-addreffed pointer to the element. The element calls ForgetElement // to clear this reference when the element is destroyed. - nsHTMLMediaElement* mElement; + dom::HTMLMediaElement* mElement; nsRefPtr mImageContainer; // mMutex protects all the fields below. diff --git a/content/media/dash/DASHDecoder.cpp b/content/media/dash/DASHDecoder.cpp index a0313ba3ee23..34333351a5c6 100644 --- a/content/media/dash/DASHDecoder.cpp +++ b/content/media/dash/DASHDecoder.cpp @@ -10,11 +10,11 @@ * DASH is an adaptive bitrate streaming technology where a multimedia file is * partitioned into one or more segments and delivered to a client using HTTP. * - * Interaction with MediaDecoderStateMachine, nsHTMLMediaElement, + * Interaction with MediaDecoderStateMachine, HTMLMediaElement, * ChannelMediaResource and sub-decoders (WebMDecoder). * * - * MediaDecoderStateMachine nsHTMLMediaElement + * MediaDecoderStateMachine HTMLMediaElement * 1 / \ 1 / 1 * / \ / * 1 / \ 1 / 1 @@ -81,7 +81,7 @@ * -- At this point the Segment media stream downloads are managed by * individual |ChannelMediaResource|s and |WebMReader|s. * A single |DASHDecoder| and |MediaDecoderStateMachine| manage them - * and communicate to |nsHTMLMediaElement|. + * and communicate to |HTMLMediaElement|. * * Each |DASHRepDecoder| gets init range and index range from its MPD * |Representation|. |DASHRepDecoder| uses ChannelMediaResource to start the @@ -565,7 +565,7 @@ DASHDecoder::CreateSubChannel(nsIURI* aUrl, nsIChannel** aChannel) NS_ENSURE_ARG(aUrl); NS_ENSURE_TRUE(mOwner, NS_ERROR_NULL_POINTER); - nsHTMLMediaElement* element = mOwner->GetMediaElement(); + HTMLMediaElement* element = mOwner->GetMediaElement(); NS_ENSURE_TRUE(element, NS_ERROR_NULL_POINTER); nsCOMPtr loadGroup = diff --git a/content/media/dash/DASHReader.cpp b/content/media/dash/DASHReader.cpp index 51c5bb8fa3bd..f30da45fae5f 100644 --- a/content/media/dash/DASHReader.cpp +++ b/content/media/dash/DASHReader.cpp @@ -196,7 +196,7 @@ DASHReader::ReadMetadata(VideoInfo* aInfo, // Read metadata for all video streams. for (uint i = 0; i < mVideoReaders.Length(); i++) { // Use an nsAutoPtr here to ensure |tags| memory does not leak. - nsAutoPtr tags; + nsAutoPtr tags; rv = mVideoReaders[i]->ReadMetadata(&videoInfo, getter_Transfers(tags)); NS_ENSURE_SUCCESS(rv, rv); // Use metadata from current video sub reader to populate aInfo. diff --git a/content/media/ogg/OggCodecState.h b/content/media/ogg/OggCodecState.h index 66e8fffa7f44..ff06f9425659 100644 --- a/content/media/ogg/OggCodecState.h +++ b/content/media/ogg/OggCodecState.h @@ -17,7 +17,7 @@ #include #include "opus/opus_multistream.h" // For MOZ_SAMPLE_TYPE_* -#include "nsHTMLMediaElement.h" +#include "mozilla/dom/HTMLMediaElement.h" #include "MediaDecoderStateMachine.h" #include "MediaDecoderReader.h" #endif diff --git a/content/media/plugins/MediaPluginHost.cpp b/content/media/plugins/MediaPluginHost.cpp index 300e483c3ca9..db88a828d3f4 100644 --- a/content/media/plugins/MediaPluginHost.cpp +++ b/content/media/plugins/MediaPluginHost.cpp @@ -7,7 +7,7 @@ #include "mozilla/TimeStamp.h" #include "mozilla/dom/TimeRanges.h" #include "MediaResource.h" -#include "nsHTMLMediaElement.h" +#include "mozilla/dom/HTMLMediaElement.h" #include "MediaPluginHost.h" #include "nsXPCOMStrings.h" #include "nsISeekableStream.h" diff --git a/content/media/test/test_playback_rate.html b/content/media/test/test_playback_rate.html index 6a2e65119fa4..e29455c4c1b4 100644 --- a/content/media/test/test_playback_rate.html +++ b/content/media/test/test_playback_rate.html @@ -33,7 +33,7 @@ function checkPlaybackRate(wallclock, media, expected, threshold) { return false; } -// Those value are expected to match those at the top of nsHTMLMediaElement.cpp. +// Those value are expected to match those at the top of HTMLMediaElement.cpp. let VERY_SLOW_RATE = 0.1, SLOW_RATE = 0.25, FAST_RATE = 5, diff --git a/content/media/wave/WaveReader.cpp b/content/media/wave/WaveReader.cpp index 2c9346bfb385..c913e43fa686 100644 --- a/content/media/wave/WaveReader.cpp +++ b/content/media/wave/WaveReader.cpp @@ -140,7 +140,7 @@ nsresult WaveReader::ReadMetadata(VideoInfo* aInfo, return NS_ERROR_FAILURE; } - nsAutoPtr tags; + nsAutoPtr tags; bool loadAllChunks = LoadAllChunks(tags); if (!loadAllChunks) { @@ -531,7 +531,7 @@ WaveReader::GetNextChunk(uint32_t* aChunk, uint32_t* aChunkSize) bool WaveReader::LoadListChunk(uint32_t aChunkSize, - nsAutoPtr &aTags) + nsAutoPtr &aTags) { // List chunks are always word (two byte) aligned. NS_ABORT_IF_FALSE(mDecoder->GetResource()->Tell() % 2 == 0, @@ -564,7 +564,7 @@ WaveReader::LoadListChunk(uint32_t aChunkSize, const char* const end = chunk.get() + aChunkSize; - aTags = new nsHTMLMediaElement::MetadataTags; + aTags = new HTMLMediaElement::MetadataTags; aTags->Init(); while (p + 8 < end) { @@ -605,7 +605,7 @@ WaveReader::LoadListChunk(uint32_t aChunkSize, } bool -WaveReader::LoadAllChunks(nsAutoPtr &aTags) +WaveReader::LoadAllChunks(nsAutoPtr &aTags) { // Chunks are always word (two byte) aligned. NS_ABORT_IF_FALSE(mDecoder->GetResource()->Tell() % 2 == 0, diff --git a/content/media/wave/WaveReader.h b/content/media/wave/WaveReader.h index f7c9aa8c131c..fdd6e7373ec6 100644 --- a/content/media/wave/WaveReader.h +++ b/content/media/wave/WaveReader.h @@ -53,8 +53,8 @@ private: bool GetNextChunk(uint32_t* aChunk, uint32_t* aChunkSize); bool LoadFormatChunk(uint32_t aChunkSize); bool FindDataOffset(uint32_t aChunkSize); - bool LoadListChunk(uint32_t aChunkSize, nsAutoPtr &aTags); - bool LoadAllChunks(nsAutoPtr &aTags); + bool LoadListChunk(uint32_t aChunkSize, nsAutoPtr &aTags); + bool LoadAllChunks(nsAutoPtr &aTags); // Returns the number of seconds that aBytes represents based on the // current audio parameters. e.g. 176400 bytes is 1 second at 16-bit diff --git a/content/media/webaudio/MediaBufferDecoder.cpp b/content/media/webaudio/MediaBufferDecoder.cpp index d3a5af5f7f18..a850178623f6 100644 --- a/content/media/webaudio/MediaBufferDecoder.cpp +++ b/content/media/webaudio/MediaBufferDecoder.cpp @@ -397,7 +397,7 @@ MediaDecodeTask::CreateReader() mBufferDecoder = new BufferDecoder(resource); // If you change this list to add support for new decoders, please consider - // updating nsHTMLMediaElement::CreateDecoder as well. + // updating HTMLMediaElement::CreateDecoder as well. mDecoderReader = DecoderTraits::CreateReader(mContentType, mBufferDecoder); diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index 902bd0ce87a7..f3baafe8bc24 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -117,7 +117,7 @@ #include "gfxImageSurface.h" #include "gfxContext.h" #ifdef MOZ_MEDIA -#include "nsHTMLMediaElement.h" +#include "mozilla/dom/HTMLMediaElement.h" #endif #include "nsSMILAnimationController.h" #include "SVGContentUtils.h" diff --git a/layout/generic/nsVideoFrame.cpp b/layout/generic/nsVideoFrame.cpp index 805d79446968..bf7c45385b57 100644 --- a/layout/generic/nsVideoFrame.cpp +++ b/layout/generic/nsVideoFrame.cpp @@ -399,8 +399,8 @@ public: // cheap (i.e. hardware accelerated). return LAYER_ACTIVE; } - nsHTMLMediaElement* elem = - static_cast(mFrame->GetContent()); + HTMLMediaElement* elem = + static_cast(mFrame->GetContent()); return elem->IsPotentiallyPlaying() ? LAYER_ACTIVE_FORCE : LAYER_INACTIVE; } }; From f1041ff584b61b72edbeb43cc8b7bd030eae6c2d Mon Sep 17 00:00:00 2001 From: Andrea Marchesini Date: Tue, 19 Mar 2013 13:25:19 +0100 Subject: [PATCH 006/146] Bug 841493 - Move HTMLMediaElement to WebIDL, r=Ms2ger --- .../html/content/public/HTMLMediaElement.h | 198 ++++++- content/html/content/src/HTMLMediaElement.cpp | 530 ++++++++++++------ content/html/content/test/Makefile.in | 5 + .../html/content/test/test_mozLoadFrom.html | 19 + content/media/test/test_constants.html | 18 +- .../media/test/test_streams_srcObject.html | 2 +- content/media/test/test_volume.html | 18 +- dom/webidl/HTMLMediaElement.webidl | 181 ++++++ dom/webidl/WebIDL.mk | 1 + 9 files changed, 786 insertions(+), 186 deletions(-) create mode 100644 content/html/content/test/test_mozLoadFrom.html create mode 100644 dom/webidl/HTMLMediaElement.webidl diff --git a/content/html/content/public/HTMLMediaElement.h b/content/html/content/public/HTMLMediaElement.h index 18b846859498..1c279333e6ac 100644 --- a/content/html/content/public/HTMLMediaElement.h +++ b/content/html/content/public/HTMLMediaElement.h @@ -27,6 +27,8 @@ #include "DecoderTraits.h" #include "MediaMetadataManager.h" #include "AudioChannelAgent.h" +#include "mozilla/Attributes.h" +#include "mozilla/ErrorResult.h" // Define to output information on decoding and painting framerate /* #define DEBUG_FRAME_RATE 1 */ @@ -42,6 +44,8 @@ class MediaDecoder; namespace mozilla { namespace dom { +class MediaError; + class HTMLMediaElement : public nsGenericHTMLElement, public nsIObserver, public MediaDecoderOwner, @@ -86,9 +90,9 @@ public: nsGenericHTMLElement) virtual bool ParseAttribute(int32_t aNamespaceID, - nsIAtom* aAttribute, - const nsAString& aValue, - nsAttrValue& aResult); + nsIAtom* aAttribute, + const nsAString& aValue, + nsAttrValue& aResult); // SetAttr override. C++ is stupid, so have to override both // overloaded methods. nsresult SetAttr(int32_t aNameSpaceID, nsIAtom* aName, @@ -318,12 +322,194 @@ public: */ virtual void FireTimeUpdate(bool aPeriodic) MOZ_FINAL MOZ_OVERRIDE; - MediaStream* GetSrcMediaStream() + MediaStream* GetSrcMediaStream() const { NS_ASSERTION(mSrcStream, "Don't call this when not playing a stream"); return mSrcStream->GetStream(); } + // WebIDL + + MediaError* GetError() const + { + return mError; + } + + // XPCOM GetSrc() is OK + void SetSrc(const nsAString& aSrc, ErrorResult& aRv) + { + SetHTMLAttr(nsGkAtoms::src, aSrc, aRv); + } + + // XPCOM GetCurrentSrc() is OK + + // XPCOM GetCrossorigin() is OK + void SetCrossorigin(const nsAString& aValue, ErrorResult& aRv) + { + SetHTMLAttr(nsGkAtoms::crossorigin, aValue, aRv); + } + + uint16_t NetworkState() const + { + return mNetworkState; + } + + // XPCOM GetPreload() is OK + void SetPreload(const nsAString& aValue, ErrorResult& aRv) + { + SetHTMLAttr(nsGkAtoms::preload, aValue, aRv); + } + + already_AddRefed Buffered() const; + + // XPCOM Load() is OK + + // XPCOM CanPlayType() is OK + + uint16_t ReadyState() const + { + return mReadyState; + } + + bool Seeking() const; + + double CurrentTime() const; + + void SetCurrentTime(double aCurrentTime, ErrorResult& aRv); + + double Duration() const; + + bool Paused() const + { + return mPaused; + } + + double DefaultPlaybackRate() const + { + return mDefaultPlaybackRate; + } + + void SetDefaultPlaybackRate(double aDefaultPlaybackRate, ErrorResult& aRv); + + double PlaybackRate() const + { + return mPlaybackRate; + } + + void SetPlaybackRate(double aPlaybackRate, ErrorResult& aRv); + + already_AddRefed Played(); + + already_AddRefed Seekable() const; + + bool Ended(); + + bool Autoplay() const + { + return GetBoolAttr(nsGkAtoms::autoplay); + } + + void SetAutoplay(bool aValue, ErrorResult& aRv) + { + SetHTMLBoolAttr(nsGkAtoms::autoplay, aValue, aRv); + } + + bool Loop() const + { + return GetBoolAttr(nsGkAtoms::loop); + } + + void SetLoop(bool aValue, ErrorResult& aRv) + { + SetHTMLBoolAttr(nsGkAtoms::loop, aValue, aRv); + } + + void Play(ErrorResult& aRv); + + void Pause(ErrorResult& aRv); + + bool Controls() const + { + return GetBoolAttr(nsGkAtoms::controls); + } + + void SetControls(bool aValue, ErrorResult& aRv) + { + SetHTMLBoolAttr(nsGkAtoms::controls, aValue, aRv); + } + + double Volume() const + { + return mVolume; + } + + void SetVolume(double aVolume, ErrorResult& aRv); + + bool Muted() const + { + return mMuted; + } + + // XPCOM SetMuted() is OK + + bool DefaultMuted() const + { + return GetBoolAttr(nsGkAtoms::muted); + } + + void SetDefaultMuted(bool aMuted, ErrorResult& aRv) + { + SetHTMLBoolAttr(nsGkAtoms::muted, aMuted, aRv); + } + + already_AddRefed GetMozSrcObject() const; + + void SetMozSrcObject(DOMMediaStream& aValue); + + double InitialTime(); + + bool MozPreservesPitch() const + { + return mPreservesPitch; + } + + // XPCOM MozPreservesPitch() is OK + + bool MozAutoplayEnabled() const + { + return mAutoplayEnabled; + } + + already_AddRefed MozCaptureStream(ErrorResult& aRv); + + already_AddRefed MozCaptureStreamUntilEnded(ErrorResult& aRv); + + bool MozAudioCaptured() const + { + return mAudioCaptured; + } + + uint32_t GetMozChannels(ErrorResult& aRv) const; + + uint32_t GetMozSampleRate(ErrorResult& aRv) const; + + uint32_t GetMozFrameBufferLength(ErrorResult& aRv) const; + + void SetMozFrameBufferLength(uint32_t aValue, ErrorResult& aRv); + + JSObject* MozGetMetadata(JSContext* aCx, ErrorResult& aRv); + + void MozLoadFrom(HTMLMediaElement& aOther, ErrorResult& aRv); + + double MozFragmentEnd(); + + // XPCOM GetMozAudioChannelType() is OK + + void SetMozAudioChannelType(const nsAString& aValue, ErrorResult& aRv) + { + SetHTMLAttr(nsGkAtoms::mozaudiochannel, aValue, aRv); + } + protected: class MediaLoadListener; class StreamListener; @@ -335,7 +521,7 @@ protected: public: WakeLockBoolWrapper(bool val = false) : mValue(val), mOuter(NULL), mWakeLock(NULL) {} void SetOuter(HTMLMediaElement* outer) { mOuter = outer; } - operator bool() { return mValue; } + operator bool() const { return mValue; } WakeLockBoolWrapper& operator=(bool val); bool operator !() const { return !mValue; } private: @@ -654,7 +840,7 @@ protected: nsCOMPtr mChannel; // Error attribute - nsCOMPtr mError; + nsRefPtr mError; // The current media load ID. This is incremented every time we start a // new load. Async events note the ID when they're first sent, and only fire diff --git a/content/html/content/src/HTMLMediaElement.cpp b/content/html/content/src/HTMLMediaElement.cpp index 61d5d7f229c8..5436719aaf44 100644 --- a/content/html/content/src/HTMLMediaElement.cpp +++ b/content/html/content/src/HTMLMediaElement.cpp @@ -5,6 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "mozilla/dom/HTMLMediaElement.h" +#include "mozilla/dom/HTMLMediaElementBinding.h" #include "mozilla/MathAlgorithms.h" #include "mozilla/Util.h" @@ -442,21 +443,35 @@ NS_IMPL_BOOL_ATTR(HTMLMediaElement, DefaultMuted, muted) NS_IMPL_ENUM_ATTR_DEFAULT_VALUE(HTMLMediaElement, Preload, preload, NULL) NS_IMPL_ENUM_ATTR_DEFAULT_VALUE(HTMLMediaElement, MozAudioChannelType, mozaudiochannel, "normal") -NS_IMETHODIMP -HTMLMediaElement::GetMozSrcObject(nsIDOMMediaStream** aStream) +already_AddRefed +HTMLMediaElement::GetMozSrcObject() const { NS_ASSERTION(!mSrcAttrStream || mSrcAttrStream->GetStream(), "MediaStream should have been set up properly"); nsRefPtr stream = mSrcAttrStream; + return stream.forget(); +} + +NS_IMETHODIMP +HTMLMediaElement::GetMozSrcObject(nsIDOMMediaStream** aStream) +{ + nsRefPtr stream = GetMozSrcObject(); stream.forget(aStream); return NS_OK; } +void +HTMLMediaElement::SetMozSrcObject(DOMMediaStream& aValue) +{ + mSrcAttrStream = &aValue; + Load(); +} + NS_IMETHODIMP HTMLMediaElement::SetMozSrcObject(nsIDOMMediaStream* aStream) { - mSrcAttrStream = static_cast(aStream); - Load(); + DOMMediaStream* stream = static_cast(aStream); + SetMozSrcObject(*stream); return NS_OK; } @@ -477,13 +492,23 @@ NS_IMETHODIMP HTMLMediaElement::GetError(nsIDOMMediaError * *aError) } /* readonly attribute boolean ended; */ -NS_IMETHODIMP HTMLMediaElement::GetEnded(bool *aEnded) +bool +HTMLMediaElement::Ended() { if (mSrcStream) { - *aEnded = GetSrcMediaStream()->IsFinished(); - } else if (mDecoder) { - *aEnded = mDecoder->IsEnded(); + return GetSrcMediaStream()->IsFinished(); } + + if (mDecoder) { + return mDecoder->IsEnded(); + } + + return false; +} + +NS_IMETHODIMP HTMLMediaElement::GetEnded(bool* aEnded) +{ + *aEnded = Ended(); return NS_OK; } @@ -497,16 +522,15 @@ NS_IMETHODIMP HTMLMediaElement::GetCurrentSrc(nsAString & aCurrentSrc) } /* readonly attribute unsigned short networkState; */ -NS_IMETHODIMP HTMLMediaElement::GetNetworkState(uint16_t *aNetworkState) +NS_IMETHODIMP HTMLMediaElement::GetNetworkState(uint16_t* aNetworkState) { - *aNetworkState = mNetworkState; - + *aNetworkState = NetworkState(); return NS_OK; } nsresult -HTMLMediaElement::OnChannelRedirect(nsIChannel *aChannel, - nsIChannel *aNewChannel, +HTMLMediaElement::OnChannelRedirect(nsIChannel* aChannel, + nsIChannel* aNewChannel, uint32_t aFlags) { NS_ASSERTION(aChannel == mChannel, "Channels should match!"); @@ -682,6 +706,7 @@ NS_IMETHODIMP HTMLMediaElement::Load() { if (mIsRunningLoadMethod) return NS_OK; + SetPlayedOrSeeked(false); mIsRunningLoadMethod = true; AbortExistingLoads(); @@ -689,6 +714,7 @@ NS_IMETHODIMP HTMLMediaElement::Load() QueueSelectResourceTask(); ResetState(); mIsRunningLoadMethod = false; + return NS_OK; } @@ -701,7 +727,7 @@ void HTMLMediaElement::ResetState() } } -static bool HasSourceChildren(nsIContent *aElement) +static bool HasSourceChildren(nsIContent* aElement) { for (nsIContent* child = aElement->GetFirstChild(); child; @@ -1142,8 +1168,8 @@ nsresult HTMLMediaElement::LoadResource() return NS_OK; } -nsresult HTMLMediaElement::LoadWithChannel(nsIChannel *aChannel, - nsIStreamListener **aListener) +nsresult HTMLMediaElement::LoadWithChannel(nsIChannel* aChannel, + nsIStreamListener** aListener) { NS_ENSURE_ARG_POINTER(aChannel); NS_ENSURE_ARG_POINTER(aListener); @@ -1173,79 +1199,110 @@ nsresult HTMLMediaElement::LoadWithChannel(nsIChannel *aChannel, return NS_OK; } -NS_IMETHODIMP HTMLMediaElement::MozLoadFrom(nsIDOMHTMLMediaElement* aOther) +void +HTMLMediaElement::MozLoadFrom(HTMLMediaElement& aOther, ErrorResult& aRv) { - NS_ENSURE_ARG_POINTER(aOther); - // Make sure we don't reenter during synchronous abort events. - if (mIsRunningLoadMethod) - return NS_OK; + if (mIsRunningLoadMethod) { + return; + } + mIsRunningLoadMethod = true; AbortExistingLoads(); mIsRunningLoadMethod = false; - nsCOMPtr content = do_QueryInterface(aOther); - HTMLMediaElement* other = static_cast(content.get()); - if (!other || !other->mDecoder) - return NS_OK; + if (!aOther.mDecoder) { + return; + } ChangeDelayLoadStatus(true); - mLoadingSrc = other->mLoadingSrc; - nsresult rv = InitializeDecoderAsClone(other->mDecoder); - if (NS_FAILED(rv)) { + mLoadingSrc = aOther.mLoadingSrc; + aRv = InitializeDecoderAsClone(aOther.mDecoder); + if (aRv.Failed()) { ChangeDelayLoadStatus(false); - return rv; + return; } SetPlaybackRate(mDefaultPlaybackRate); DispatchAsyncEvent(NS_LITERAL_STRING("loadstart")); +} - return NS_OK; +NS_IMETHODIMP HTMLMediaElement::MozLoadFrom(nsIDOMHTMLMediaElement* aOther) +{ + NS_ENSURE_ARG_POINTER(aOther); + + nsCOMPtr content = do_QueryInterface(aOther); + HTMLMediaElement* other = static_cast(content.get()); + + if (!other) { + return NS_ERROR_FAILURE; + } + + ErrorResult rv; + MozLoadFrom(*other, rv); + + return rv.ErrorCode(); } /* readonly attribute unsigned short readyState; */ -NS_IMETHODIMP HTMLMediaElement::GetReadyState(uint16_t *aReadyState) +NS_IMETHODIMP HTMLMediaElement::GetReadyState(uint16_t* aReadyState) { - *aReadyState = mReadyState; + *aReadyState = ReadyState(); return NS_OK; } /* readonly attribute boolean seeking; */ -NS_IMETHODIMP HTMLMediaElement::GetSeeking(bool *aSeeking) +bool +HTMLMediaElement::Seeking() const { - *aSeeking = mDecoder && mDecoder->IsSeeking(); + return mDecoder && mDecoder->IsSeeking(); +} +NS_IMETHODIMP HTMLMediaElement::GetSeeking(bool* aSeeking) +{ + *aSeeking = Seeking(); return NS_OK; } /* attribute double currentTime; */ -NS_IMETHODIMP HTMLMediaElement::GetCurrentTime(double *aCurrentTime) +double +HTMLMediaElement::CurrentTime() const { if (mSrcStream) { - *aCurrentTime = MediaTimeToSeconds(GetSrcMediaStream()->GetCurrentTime()); - } else if (mDecoder) { - *aCurrentTime = mDecoder->GetCurrentTime(); - } else { - *aCurrentTime = 0.0; + return MediaTimeToSeconds(GetSrcMediaStream()->GetCurrentTime()); } + + if (mDecoder) { + return mDecoder->GetCurrentTime(); + } + + return 0.0; +} + +NS_IMETHODIMP HTMLMediaElement::GetCurrentTime(double* aCurrentTime) +{ + *aCurrentTime = CurrentTime(); return NS_OK; } -NS_IMETHODIMP HTMLMediaElement::SetCurrentTime(double aCurrentTime) +void +HTMLMediaElement::SetCurrentTime(double aCurrentTime, ErrorResult& aRv) { + MOZ_ASSERT(aCurrentTime == aCurrentTime); + StopSuspendingAfterFirstFrame(); if (mSrcStream) { // do nothing since streams aren't seekable; we effectively clamp to // the current time. - return NS_ERROR_DOM_INVALID_STATE_ERR; + aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR); + return; } if (mCurrentPlayRangeStart != -1.0) { - double rangeEndTime = 0; - GetCurrentTime(&rangeEndTime); + double rangeEndTime = CurrentTime(); LOG(PR_LOG_DEBUG, ("%p Adding \'played\' a range : [%f, %f]", this, mCurrentPlayRangeStart, rangeEndTime)); // Multiple seek without playing, or seek while playing. if (mCurrentPlayRangeStart != rangeEndTime) { @@ -1255,18 +1312,14 @@ NS_IMETHODIMP HTMLMediaElement::SetCurrentTime(double aCurrentTime) if (!mDecoder) { LOG(PR_LOG_DEBUG, ("%p SetCurrentTime(%f) failed: no decoder", this, aCurrentTime)); - return NS_ERROR_DOM_INVALID_STATE_ERR; + aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR); + return; } if (mReadyState == nsIDOMHTMLMediaElement::HAVE_NOTHING) { LOG(PR_LOG_DEBUG, ("%p SetCurrentTime(%f) failed: no source", this, aCurrentTime)); - return NS_ERROR_DOM_INVALID_STATE_ERR; - } - - // Detect for a NaN and invalid values. - if (aCurrentTime != aCurrentTime) { - LOG(PR_LOG_DEBUG, ("%p SetCurrentTime(%f) failed: bad time", this, aCurrentTime)); - return NS_ERROR_FAILURE; + aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR); + return; } // Clamp the time to [0, duration] as required by the spec. @@ -1280,54 +1333,78 @@ NS_IMETHODIMP HTMLMediaElement::SetCurrentTime(double aCurrentTime) // The media backend is responsible for dispatching the timeupdate // event if it changes the playback position as a result of the seek. LOG(PR_LOG_DEBUG, ("%p SetCurrentTime(%f) starting seek", this, aCurrentTime)); - nsresult rv = mDecoder->Seek(clampedTime); + aRv = mDecoder->Seek(clampedTime); // Start a new range at position we seeked to. mCurrentPlayRangeStart = mDecoder->GetCurrentTime(); // We changed whether we're seeking so we need to AddRemoveSelfReference. AddRemoveSelfReference(); +} - return rv; +NS_IMETHODIMP HTMLMediaElement::SetCurrentTime(double aCurrentTime) +{ + // Detect for a NaN and invalid values. + if (aCurrentTime != aCurrentTime) { + LOG(PR_LOG_DEBUG, ("%p SetCurrentTime(%f) failed: bad time", this, aCurrentTime)); + return NS_ERROR_FAILURE; + } + + ErrorResult rv; + SetCurrentTime(aCurrentTime, rv); + return rv.ErrorCode(); } /* readonly attribute double duration; */ -NS_IMETHODIMP HTMLMediaElement::GetDuration(double *aDuration) +double +HTMLMediaElement::Duration() const { if (mSrcStream) { - *aDuration = std::numeric_limits::infinity(); - } else if (mDecoder) { - *aDuration = mDecoder->GetDuration(); - } else { - *aDuration = std::numeric_limits::quiet_NaN(); + return std::numeric_limits::infinity(); } + + if (mDecoder) { + return mDecoder->GetDuration(); + } + + return std::numeric_limits::quiet_NaN(); +} + +NS_IMETHODIMP HTMLMediaElement::GetDuration(double* aDuration) +{ + *aDuration = Duration(); return NS_OK; } -/* readonly attribute nsIDOMHTMLTimeRanges seekable; */ -NS_IMETHODIMP HTMLMediaElement::GetSeekable(nsIDOMTimeRanges** aSeekable) +already_AddRefed +HTMLMediaElement::Seekable() const { nsRefPtr ranges = new TimeRanges(); if (mDecoder && mReadyState > nsIDOMHTMLMediaElement::HAVE_NOTHING) { mDecoder->GetSeekable(ranges); } + return ranges.forget(); +} + +/* readonly attribute nsIDOMHTMLTimeRanges seekable; */ +NS_IMETHODIMP HTMLMediaElement::GetSeekable(nsIDOMTimeRanges** aSeekable) +{ + nsRefPtr ranges = Seekable(); ranges.forget(aSeekable); return NS_OK; } - /* readonly attribute boolean paused; */ -NS_IMETHODIMP HTMLMediaElement::GetPaused(bool *aPaused) +NS_IMETHODIMP HTMLMediaElement::GetPaused(bool* aPaused) { - *aPaused = mPaused; + *aPaused = Paused(); return NS_OK; } -/* readonly attribute nsIDOMHTMLTimeRanges played; */ -NS_IMETHODIMP HTMLMediaElement::GetPlayed(nsIDOMTimeRanges** aPlayed) +already_AddRefed +HTMLMediaElement::Played() { - TimeRanges* ranges = new TimeRanges(); - NS_ADDREF(*aPlayed = ranges); + nsRefPtr ranges = new TimeRanges(); uint32_t timeRangeCount = 0; mPlayed.GetLength(&timeRangeCount); @@ -1340,25 +1417,34 @@ NS_IMETHODIMP HTMLMediaElement::GetPlayed(nsIDOMTimeRanges** aPlayed) } if (mCurrentPlayRangeStart != -1.0) { - double now = 0.0; - GetCurrentTime(&now); + double now = CurrentTime(); if (mCurrentPlayRangeStart != now) { ranges->Add(mCurrentPlayRangeStart, now); } } ranges->Normalize(); + return ranges.forget(); +} +/* readonly attribute nsIDOMHTMLTimeRanges played; */ +NS_IMETHODIMP HTMLMediaElement::GetPlayed(nsIDOMTimeRanges** aPlayed) +{ + nsRefPtr ranges = Played(); + ranges.forget(aPlayed); return NS_OK; } /* void pause (); */ -NS_IMETHODIMP HTMLMediaElement::Pause() +void +HTMLMediaElement::Pause(ErrorResult& aRv) { if (mNetworkState == nsIDOMHTMLMediaElement::NETWORK_EMPTY) { LOG(PR_LOG_DEBUG, ("Loading due to Pause()")); - nsresult rv = Load(); - NS_ENSURE_SUCCESS(rv, rv); + aRv = Load(); + if (aRv.Failed()) { + return; + } } else if (mDecoder) { mDecoder->Pause(); } @@ -1376,25 +1462,32 @@ NS_IMETHODIMP HTMLMediaElement::Pause() FireTimeUpdate(false); DispatchAsyncEvent(NS_LITERAL_STRING("pause")); } +} - return NS_OK; +NS_IMETHODIMP HTMLMediaElement::Pause() +{ + ErrorResult rv; + Pause(rv); + return rv.ErrorCode(); } /* attribute double volume; */ -NS_IMETHODIMP HTMLMediaElement::GetVolume(double *aVolume) +NS_IMETHODIMP HTMLMediaElement::GetVolume(double* aVolume) { - *aVolume = mVolume; - + *aVolume = Volume(); return NS_OK; } -NS_IMETHODIMP HTMLMediaElement::SetVolume(double aVolume) +void +HTMLMediaElement::SetVolume(double aVolume, ErrorResult& aRv) { - if (!(aVolume >= 0.0 && aVolume <= 1.0)) - return NS_ERROR_DOM_INDEX_SIZE_ERR; + if (aVolume < 0.0 || aVolume > 1.0) { + aRv.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR); + return; + } if (aVolume == mVolume) - return NS_OK; + return; mVolume = aVolume; @@ -1409,30 +1502,51 @@ NS_IMETHODIMP HTMLMediaElement::SetVolume(double aVolume) } DispatchAsyncEvent(NS_LITERAL_STRING("volumechange")); +} - return NS_OK; +NS_IMETHODIMP HTMLMediaElement::SetVolume(double aVolume) +{ + ErrorResult rv; + SetVolume(aVolume, rv); + return rv.ErrorCode(); +} + +uint32_t +HTMLMediaElement::GetMozChannels(ErrorResult& aRv) const +{ + if (!mDecoder && !mAudioStream) { + aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR); + return 0; + } + + return mChannels; } NS_IMETHODIMP -HTMLMediaElement::GetMozChannels(uint32_t *aMozChannels) +HTMLMediaElement::GetMozChannels(uint32_t* aMozChannels) +{ + ErrorResult rv; + *aMozChannels = GetMozChannels(rv); + return rv.ErrorCode(); +} + +uint32_t +HTMLMediaElement::GetMozSampleRate(ErrorResult& aRv) const { if (!mDecoder && !mAudioStream) { - return NS_ERROR_DOM_INVALID_STATE_ERR; + aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR); + return 0; } - *aMozChannels = mChannels; - return NS_OK; + return mRate; } NS_IMETHODIMP -HTMLMediaElement::GetMozSampleRate(uint32_t *aMozSampleRate) +HTMLMediaElement::GetMozSampleRate(uint32_t* aMozSampleRate) { - if (!mDecoder && !mAudioStream) { - return NS_ERROR_DOM_INVALID_STATE_ERR; - } - - *aMozSampleRate = mRate; - return NS_OK; + ErrorResult rv; + *aMozSampleRate = GetMozSampleRate(rv); + return rv.ErrorCode(); } // Helper struct with arguments for our hash iterator. @@ -1467,57 +1581,90 @@ HTMLMediaElement::BuildObjectFromTags(nsCStringHashKey::KeyType aKey, return PL_DHASH_NEXT; } -NS_IMETHODIMP -HTMLMediaElement::MozGetMetadata(JSContext* cx, JS::Value* aValue) +JSObject* +HTMLMediaElement::MozGetMetadata(JSContext* cx, ErrorResult& aRv) { if (mReadyState < nsIDOMHTMLMediaElement::HAVE_METADATA) { - return NS_ERROR_DOM_INVALID_STATE_ERR; + aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR); + return nullptr; } JSObject* tags = JS_NewObject(cx, NULL, NULL, NULL); if (!tags) { - return NS_ERROR_FAILURE; + aRv.Throw(NS_ERROR_FAILURE); + return nullptr; } if (mTags) { MetadataIterCx iter = {cx, tags, false}; mTags->EnumerateRead(BuildObjectFromTags, static_cast(&iter)); if (iter.error) { NS_WARNING("couldn't create metadata object!"); - return NS_ERROR_FAILURE; + aRv.Throw(NS_ERROR_FAILURE); + return nullptr; } } - *aValue = OBJECT_TO_JSVAL(tags); - return NS_OK; + return tags; } NS_IMETHODIMP -HTMLMediaElement::GetMozFrameBufferLength(uint32_t *aMozFrameBufferLength) +HTMLMediaElement::MozGetMetadata(JSContext* cx, JS::Value* aValue) +{ + ErrorResult rv; + + JSObject* obj = MozGetMetadata(cx, rv); + if (!rv.Failed()) { + MOZ_ASSERT(obj); + *aValue = JS::ObjectValue(*obj); + } + + return rv.ErrorCode(); +} + +uint32_t +HTMLMediaElement::GetMozFrameBufferLength(ErrorResult& aRv) const { // The framebuffer (via MozAudioAvailable events) is only available // when reading vs. writing audio directly. if (!mDecoder) { - return NS_ERROR_DOM_INVALID_STATE_ERR; + aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR); + return 0; } - *aMozFrameBufferLength = mDecoder->GetFrameBufferLength(); - return NS_OK; + return mDecoder->GetFrameBufferLength(); +} + +NS_IMETHODIMP +HTMLMediaElement::GetMozFrameBufferLength(uint32_t* aMozFrameBufferLength) +{ + ErrorResult rv; + *aMozFrameBufferLength = GetMozFrameBufferLength(rv); + return rv.ErrorCode(); +} + +void +HTMLMediaElement::SetMozFrameBufferLength(uint32_t aMozFrameBufferLength, ErrorResult& aRv) +{ + if (!mDecoder) { + aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR); + return; + } + + aRv = mDecoder->RequestFrameBufferLength(aMozFrameBufferLength); } NS_IMETHODIMP HTMLMediaElement::SetMozFrameBufferLength(uint32_t aMozFrameBufferLength) { - if (!mDecoder) - return NS_ERROR_DOM_INVALID_STATE_ERR; - - return mDecoder->RequestFrameBufferLength(aMozFrameBufferLength); + ErrorResult rv; + SetMozFrameBufferLength(aMozFrameBufferLength, rv); + return rv.ErrorCode(); } /* attribute boolean muted; */ -NS_IMETHODIMP HTMLMediaElement::GetMuted(bool *aMuted) +NS_IMETHODIMP HTMLMediaElement::GetMuted(bool* aMuted) { - *aMuted = mMuted; - + *aMuted = Muted(); return NS_OK; } @@ -1543,7 +1690,6 @@ NS_IMETHODIMP HTMLMediaElement::SetMuted(bool aMuted) SetMutedInternal(aMuted); DispatchAsyncEvent(NS_LITERAL_STRING("volumechange")); - return NS_OK; } @@ -1575,27 +1721,47 @@ HTMLMediaElement::CaptureStreamInternal(bool aFinishWhenEnded) return result.forget(); } +already_AddRefed +HTMLMediaElement::MozCaptureStream(ErrorResult& aRv) +{ + nsRefPtr stream = CaptureStreamInternal(false); + if (!stream) { + aRv.Throw(NS_ERROR_FAILURE); + return nullptr; + } + + return stream.forget(); +} + NS_IMETHODIMP HTMLMediaElement::MozCaptureStream(nsIDOMMediaStream** aStream) { - *aStream = CaptureStreamInternal(false).get(); - if (!*aStream) { - return NS_ERROR_FAILURE; + ErrorResult rv; + *aStream = MozCaptureStream(rv).get(); + return rv.ErrorCode(); +} + +already_AddRefed +HTMLMediaElement::MozCaptureStreamUntilEnded(ErrorResult& aRv) +{ + nsRefPtr stream = CaptureStreamInternal(true); + if (!stream) { + aRv.Throw(NS_ERROR_FAILURE); + return nullptr; } - return NS_OK; + + return stream.forget(); } NS_IMETHODIMP HTMLMediaElement::MozCaptureStreamUntilEnded(nsIDOMMediaStream** aStream) { - *aStream = CaptureStreamInternal(true).get(); - if (!*aStream) { - return NS_ERROR_FAILURE; - } - return NS_OK; + ErrorResult rv; + *aStream = MozCaptureStreamUntilEnded(rv).get(); + return rv.ErrorCode(); } -NS_IMETHODIMP HTMLMediaElement::GetMozAudioCaptured(bool *aCaptured) +NS_IMETHODIMP HTMLMediaElement::GetMozAudioCaptured(bool* aCaptured) { - *aCaptured = mAudioCaptured; + *aCaptured = MozAudioCaptured(); return NS_OK; } @@ -1838,14 +2004,17 @@ void HTMLMediaElement::SetPlayedOrSeeked(bool aValue) NS_FRAME_IS_DIRTY); } -NS_IMETHODIMP HTMLMediaElement::Play() +void +HTMLMediaElement::Play(ErrorResult& aRv) { StopSuspendingAfterFirstFrame(); SetPlayedOrSeeked(true); if (mNetworkState == nsIDOMHTMLMediaElement::NETWORK_EMPTY) { - nsresult rv = Load(); - NS_ENSURE_SUCCESS(rv, rv); + aRv = Load(); + if (aRv.Failed()) { + return; + } } if (mSuspendedForPreloadNone) { ResumeLoad(PRELOAD_ENOUGH); @@ -1857,13 +2026,15 @@ NS_IMETHODIMP HTMLMediaElement::Play() SetCurrentTime(0); } if (!mPausedForInactiveDocumentOrChannel) { - nsresult rv = mDecoder->Play(); - NS_ENSURE_SUCCESS(rv, rv); + aRv = mDecoder->Play(); + if (aRv.Failed()) { + return; + } } } if (mCurrentPlayRangeStart == -1.0) { - GetCurrentTime(&mCurrentPlayRangeStart); + mCurrentPlayRangeStart = CurrentTime(); } // TODO: If the playback has ended, then the user agent must set @@ -1897,8 +2068,13 @@ NS_IMETHODIMP HTMLMediaElement::Play() // and our preload status. AddRemoveSelfReference(); UpdatePreloadAction(); +} - return NS_OK; +NS_IMETHODIMP HTMLMediaElement::Play() +{ + ErrorResult rv; + Play(rv); + return rv.ErrorCode(); } HTMLMediaElement::WakeLockBoolWrapper& HTMLMediaElement::WakeLockBoolWrapper::operator=(bool val) { @@ -2008,8 +2184,8 @@ void HTMLMediaElement::DoneCreatingElement() } bool HTMLMediaElement::IsHTMLFocusable(bool aWithMouse, - bool *aIsFocusable, - int32_t *aTabIndex) + bool* aIsFocusable, + int32_t* aTabIndex) { if (nsGenericHTMLElement::IsHTMLFocusable(aWithMouse, aIsFocusable, aTabIndex)) { return true; @@ -2184,8 +2360,8 @@ nsresult HTMLMediaElement::InitializeDecoderAsClone(MediaDecoder* aOriginal) return FinishDecoderSetup(decoder, resource, nullptr, aOriginal); } -nsresult HTMLMediaElement::InitializeDecoderForChannel(nsIChannel *aChannel, - nsIStreamListener **aListener) +nsresult HTMLMediaElement::InitializeDecoderForChannel(nsIChannel* aChannel, + nsIStreamListener** aListener) { NS_ASSERTION(mLoadingSrc, "mLoadingSrc must already be set"); NS_ASSERTION(mDecoder == nullptr, "Shouldn't have a decoder"); @@ -2219,7 +2395,7 @@ nsresult HTMLMediaElement::InitializeDecoderForChannel(nsIChannel *aChannel, nsresult HTMLMediaElement::FinishDecoderSetup(MediaDecoder* aDecoder, MediaResource* aStream, - nsIStreamListener **aListener, + nsIStreamListener** aListener, MediaDecoder* aCloneDonor) { mNetworkState = nsIDOMHTMLMediaElement::NETWORK_LOADING; @@ -2851,7 +3027,7 @@ void HTMLMediaElement::NotifyAutoplayDataReady() if (mDecoder) { SetPlayedOrSeeked(true); if (mCurrentPlayRangeStart == -1.0) { - GetCurrentTime(&mCurrentPlayRangeStart); + mCurrentPlayRangeStart = CurrentTime(); } mDecoder->Play(); } else if (mSrcStream) { @@ -3268,7 +3444,8 @@ HTMLMediaElement::CopyInnerTo(Element* aDest) return rv; } -nsresult HTMLMediaElement::GetBuffered(nsIDOMTimeRanges** aBuffered) +already_AddRefed +HTMLMediaElement::Buffered() const { nsRefPtr ranges = new TimeRanges(); if (mReadyState > nsIDOMHTMLMediaElement::HAVE_NOTHING && mDecoder) { @@ -3276,6 +3453,12 @@ nsresult HTMLMediaElement::GetBuffered(nsIDOMTimeRanges** aBuffered) // time ranges we found up till the error. mDecoder->GetBuffered(ranges); } + return ranges.forget(); +} + +nsresult HTMLMediaElement::GetBuffered(nsIDOMTimeRanges** aBuffered) +{ + nsRefPtr ranges = Buffered(); ranges.forget(aBuffered); return NS_OK; } @@ -3309,8 +3492,7 @@ void HTMLMediaElement::FireTimeUpdate(bool aPeriodic) NS_ASSERTION(NS_IsMainThread(), "Should be on main thread."); TimeStamp now = TimeStamp::Now(); - double time = 0; - GetCurrentTime(&time); + double time = CurrentTime(); // Fire a timeupdate event if this is not a periodic update (i.e. it's a // timeupdate event mandated by the spec), or if it's a periodic update @@ -3342,31 +3524,41 @@ void HTMLMediaElement::GetCurrentSpec(nsCString& aString) } /* attribute double initialTime; */ -NS_IMETHODIMP HTMLMediaElement::GetInitialTime(double *aTime) +double +HTMLMediaElement::InitialTime() { // If there is no start fragment then the initalTime is zero. // Clamp to duration if it is greater than duration. - double duration = 0.0; - nsresult rv = GetDuration(&duration); - NS_ENSURE_SUCCESS(rv, rv); + double duration = Duration(); - *aTime = mFragmentStart < 0.0 ? 0.0 : mFragmentStart; - if (*aTime > duration) { - *aTime = duration; + double time = mFragmentStart < 0.0 ? 0.0 : mFragmentStart; + if (time > duration) { + time = duration; } + + return time; +} + +NS_IMETHODIMP HTMLMediaElement::GetInitialTime(double* aTime) +{ + *aTime = InitialTime(); return NS_OK; } /* attribute double mozFragmentEnd; */ -NS_IMETHODIMP HTMLMediaElement::GetMozFragmentEnd(double *aTime) +double +HTMLMediaElement::MozFragmentEnd() { - double duration = 0.0; - nsresult rv = GetDuration(&duration); - NS_ENSURE_SUCCESS(rv, rv); + double duration = Duration(); // If there is no end fragment, or the fragment end is greater than the // duration, return the duration. - *aTime = (mFragmentEnd < 0.0 || mFragmentEnd > duration) ? duration : mFragmentEnd; + return (mFragmentEnd < 0.0 || mFragmentEnd > duration) ? duration : mFragmentEnd; +} + +NS_IMETHODIMP HTMLMediaElement::GetMozFragmentEnd(double* aTime) +{ + *aTime = MozFragmentEnd(); return NS_OK; } @@ -3394,34 +3586,44 @@ static double ClampPlaybackRate(double aPlaybackRate) /* attribute double defaultPlaybackRate; */ NS_IMETHODIMP HTMLMediaElement::GetDefaultPlaybackRate(double* aDefaultPlaybackRate) { - *aDefaultPlaybackRate = mDefaultPlaybackRate; + *aDefaultPlaybackRate = DefaultPlaybackRate(); return NS_OK; } -NS_IMETHODIMP HTMLMediaElement::SetDefaultPlaybackRate(double aDefaultPlaybackRate) +void +HTMLMediaElement::SetDefaultPlaybackRate(double aDefaultPlaybackRate, ErrorResult& aRv) { if (aDefaultPlaybackRate < 0) { - return NS_ERROR_NOT_IMPLEMENTED; + aRv.Throw(NS_ERROR_NOT_IMPLEMENTED); + return; } mDefaultPlaybackRate = ClampPlaybackRate(aDefaultPlaybackRate); DispatchAsyncEvent(NS_LITERAL_STRING("ratechange")); - return NS_OK; +} + +NS_IMETHODIMP HTMLMediaElement::SetDefaultPlaybackRate(double aDefaultPlaybackRate) +{ + ErrorResult rv; + SetDefaultPlaybackRate(aDefaultPlaybackRate, rv); + return rv.ErrorCode(); } /* attribute double playbackRate; */ NS_IMETHODIMP HTMLMediaElement::GetPlaybackRate(double* aPlaybackRate) { - *aPlaybackRate = mPlaybackRate; + *aPlaybackRate = PlaybackRate(); return NS_OK; } -NS_IMETHODIMP HTMLMediaElement::SetPlaybackRate(double aPlaybackRate) +void +HTMLMediaElement::SetPlaybackRate(double aPlaybackRate, ErrorResult& aRv) { // Changing the playback rate of a media that has more than two channels is // not supported. if (aPlaybackRate < 0 || (mChannels > 2 && aPlaybackRate != 1.0)) { - return NS_ERROR_NOT_IMPLEMENTED; + aRv.Throw(NS_ERROR_NOT_IMPLEMENTED); + return; } mPlaybackRate = ClampPlaybackRate(aPlaybackRate); @@ -3440,13 +3642,19 @@ NS_IMETHODIMP HTMLMediaElement::SetPlaybackRate(double aPlaybackRate) mDecoder->SetPlaybackRate(mPlaybackRate); } DispatchAsyncEvent(NS_LITERAL_STRING("ratechange")); - return NS_OK; +} + +NS_IMETHODIMP HTMLMediaElement::SetPlaybackRate(double aPlaybackRate) +{ + ErrorResult rv; + SetPlaybackRate(aPlaybackRate, rv); + return rv.ErrorCode(); } /* attribute bool mozPreservesPitch; */ NS_IMETHODIMP HTMLMediaElement::GetMozPreservesPitch(bool* aPreservesPitch) { - *aPreservesPitch = mPreservesPitch; + *aPreservesPitch = MozPreservesPitch(); return NS_OK; } diff --git a/content/html/content/test/Makefile.in b/content/html/content/test/Makefile.in index 77b796a85d05..292987354d0c 100644 --- a/content/html/content/test/Makefile.in +++ b/content/html/content/test/Makefile.in @@ -353,6 +353,11 @@ MOCHITEST_FILES = \ test_formData.html \ $(NULL) +ifdef MOZ_MEDIA +MOCHITEST_FILES += \ + test_mozLoadFrom.html \ + $(NULL) +endif MOCHITEST_BROWSER_FILES = \ browser_bug649778.js \ diff --git a/content/html/content/test/test_mozLoadFrom.html b/content/html/content/test/test_mozLoadFrom.html new file mode 100644 index 000000000000..3b100be41a11 --- /dev/null +++ b/content/html/content/test/test_mozLoadFrom.html @@ -0,0 +1,19 @@ + + + + Test for mozLoadFrom + + + + + + + diff --git a/content/media/test/test_constants.html b/content/media/test/test_constants.html index 21044e836fdb..bbc1b1fffcae 100644 --- a/content/media/test/test_constants.html +++ b/content/media/test/test_constants.html @@ -156,15 +156,15 @@ is(HTMLElement.prototype.MEDIA_ERR_ABORTED, undefined); is(HTMLElement.prototype.MEDIA_ERR_NETWORK, undefined); is(HTMLElement.prototype.MEDIA_ERR_DECODE, undefined); is(HTMLElement.prototype.MEDIA_ERR_SRC_NOT_SUPPORTED, undefined); -todo_is(HTMLMediaElement.prototype.NETWORK_EMPTY, 0, "HTMLMediaElement.prototype.NETWORK_EMPTY"); -todo_is(HTMLMediaElement.prototype.NETWORK_IDLE, 1, "HTMLMediaElement.prototype.NETWORK_IDLE"); -todo_is(HTMLMediaElement.prototype.NETWORK_LOADING, 2, "HTMLMediaElement.prototype.NETWORK_LOADING"); -todo_is(HTMLMediaElement.prototype.NETWORK_NO_SOURCE, 3, "HTMLMediaElement.prototype.NETWORK_NO_SOURCE"); -todo_is(HTMLMediaElement.prototype.HAVE_NOTHING, 0, "HTMLMediaElement.prototype.HAVE_NOTHING"); -todo_is(HTMLMediaElement.prototype.HAVE_METADATA, 1, "HTMLMediaElement.prototype.HAVE_METADATA"); -todo_is(HTMLMediaElement.prototype.HAVE_CURRENT_DATA, 2, "HTMLMediaElement.prototype.HAVE_CURRENT_DATA"); -todo_is(HTMLMediaElement.prototype.HAVE_FUTURE_DATA, 3, "HTMLMediaElement.prototype.HAVE_FUTURE_DATA"); -todo_is(HTMLMediaElement.prototype.HAVE_ENOUGH_DATA, 4, "HTMLMediaElement.prototype.HAVE_ENOUGH_DATA"); +is(HTMLMediaElement.prototype.NETWORK_EMPTY, 0, "HTMLMediaElement.prototype.NETWORK_EMPTY"); +is(HTMLMediaElement.prototype.NETWORK_IDLE, 1, "HTMLMediaElement.prototype.NETWORK_IDLE"); +is(HTMLMediaElement.prototype.NETWORK_LOADING, 2, "HTMLMediaElement.prototype.NETWORK_LOADING"); +is(HTMLMediaElement.prototype.NETWORK_NO_SOURCE, 3, "HTMLMediaElement.prototype.NETWORK_NO_SOURCE"); +is(HTMLMediaElement.prototype.HAVE_NOTHING, 0, "HTMLMediaElement.prototype.HAVE_NOTHING"); +is(HTMLMediaElement.prototype.HAVE_METADATA, 1, "HTMLMediaElement.prototype.HAVE_METADATA"); +is(HTMLMediaElement.prototype.HAVE_CURRENT_DATA, 2, "HTMLMediaElement.prototype.HAVE_CURRENT_DATA"); +is(HTMLMediaElement.prototype.HAVE_FUTURE_DATA, 3, "HTMLMediaElement.prototype.HAVE_FUTURE_DATA"); +is(HTMLMediaElement.prototype.HAVE_ENOUGH_DATA, 4, "HTMLMediaElement.prototype.HAVE_ENOUGH_DATA"); is(HTMLMediaElement.prototype.MEDIA_ERR_ABORTED, undefined, "HTMLMediaElement.prototype.MEDIA_ERR_ABORTED"); is(HTMLMediaElement.prototype.MEDIA_ERR_NETWORK, undefined, "HTMLMediaElement.prototype.MEDIA_ERR_NETWORK"); is(HTMLMediaElement.prototype.MEDIA_ERR_DECODE, undefined, "HTMLMediaElement.prototype.MEDIA_ERR_DECODE"); diff --git a/content/media/test/test_streams_srcObject.html b/content/media/test/test_streams_srcObject.html index e2d98347afd2..446c5466b41a 100644 --- a/content/media/test/test_streams_srcObject.html +++ b/content/media/test/test_streams_srcObject.html @@ -28,7 +28,7 @@ function doTest() { b.mozSrcObject = "invalid"; ok(false, "Setting mozSrcObject to an invalid value should throw."); } catch (e) { - todo(e instanceof TypeError, "Exception should be a TypeError"); + ok(e instanceof TypeError, "Exception should be a TypeError"); } is(b.mozSrcObject, stream, "Stream not set to invalid value"); is(b.src, newSrc, "src attribute not affected by setting srcObject"); diff --git a/content/media/test/test_volume.html b/content/media/test/test_volume.html index 9e2262237eaa..07f51f52ab24 100644 --- a/content/media/test/test_volume.html +++ b/content/media/test/test_volume.html @@ -13,11 +13,11 @@ diff --git a/dom/webidl/HTMLMediaElement.webidl b/dom/webidl/HTMLMediaElement.webidl new file mode 100644 index 000000000000..c52d03effcba --- /dev/null +++ b/dom/webidl/HTMLMediaElement.webidl @@ -0,0 +1,181 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* 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/. + * + * The origin of this IDL file is + * http://www.whatwg.org/specs/web-apps/current-work/#media-elements + * + * Ā© Copyright 2004-2011 Apple Computer, Inc., Mozilla Foundation, and + * Opera Software ASA. You are granted a license to use, reproduce + * and create derivative works of this document. + */ + +interface HTMLMediaElement : HTMLElement { + + // error state + readonly attribute MediaError? error; + + // network state + [SetterThrows] + attribute DOMString src; + readonly attribute DOMString currentSrc; + + // Bug 847370 - crossOrigin vs crossorigin. + [SetterThrows] + attribute DOMString crossorigin; + const unsigned short NETWORK_EMPTY = 0; + const unsigned short NETWORK_IDLE = 1; + const unsigned short NETWORK_LOADING = 2; + const unsigned short NETWORK_NO_SOURCE = 3; + readonly attribute unsigned short networkState; + [SetterThrows] + attribute DOMString preload; + [Creator] + readonly attribute TimeRanges buffered; + void load(); + DOMString canPlayType(DOMString type); + + // ready state + const unsigned short HAVE_NOTHING = 0; + const unsigned short HAVE_METADATA = 1; + const unsigned short HAVE_CURRENT_DATA = 2; + const unsigned short HAVE_FUTURE_DATA = 3; + const unsigned short HAVE_ENOUGH_DATA = 4; + readonly attribute unsigned short readyState; + readonly attribute boolean seeking; + + // playback state + [SetterThrows] + attribute double currentTime; + // TODO: Bug 847375 - void fastSeek(double time); + readonly attribute unrestricted double duration; + // TODO: Bug 847376 - readonly attribute any startDate; + readonly attribute boolean paused; + [SetterThrows] + attribute double defaultPlaybackRate; + [SetterThrows] + attribute double playbackRate; + [Creator] + readonly attribute TimeRanges played; + [Creator] + readonly attribute TimeRanges seekable; + readonly attribute boolean ended; + [SetterThrows] + attribute boolean autoplay; + [SetterThrows] + attribute boolean loop; + [Throws] + void play(); + [Throws] + void pause(); + + // TODO: Bug 847377 - mediaGroup and MediaController + // media controller + // attribute DOMString mediaGroup; + // attribute MediaController? controller; + + // controls + [SetterThrows] + attribute boolean controls; + [SetterThrows] + attribute double volume; + attribute boolean muted; + [SetterThrows] + attribute boolean defaultMuted; + + // TODO: Bug 847379 + // tracks + //readonly attribute AudioTrackList audioTracks; + //readonly attribute VideoTrackList videoTracks; + //readonly attribute TextTrackList textTracks; + //TextTrack addTextTrack(DOMString kind, optional DOMString label, optional DOMString language); +}; + +// Mozilla extensions: +partial interface HTMLMediaElement { + attribute MediaStream? mozSrcObject; + readonly attribute double initialTime; + attribute boolean mozPreservesPitch; + readonly attribute boolean mozAutoplayEnabled; + + // Mozilla extension: stream capture + [Throws] + MediaStream mozCaptureStream(); + [Throws] + MediaStream mozCaptureStreamUntilEnded(); + readonly attribute boolean mozAudioCaptured; + + // Mozilla extension: extra stream metadata information, used as part + // of MozAudioAvailable events and the mozWriteAudio() method. The + // mozFrameBufferLength method allows for the size of the framebuffer + // used within MozAudioAvailable events to be changed. The new size must + // be between 512 and 16384. The default size, for a media element with + // audio is (mozChannels * 1024). + [GetterThrows] + readonly attribute unsigned long mozChannels; + [GetterThrows] + readonly attribute unsigned long mozSampleRate; + [Throws] + attribute unsigned long mozFrameBufferLength; + + // Mozilla extension: return embedded metadata from the stream as a + // JSObject with key:value pairs for each tag. This can be used by + // player interfaces to display the song title, artist, etc. + [Throws] + object? mozGetMetadata(); + + // Mozilla extension: load data from another media element. This is like + // load() but we don't run the resource selection algorithm; instead + // we just set our source to other's currentSrc. This is optimized + // so that this element will get access to all of other's cached/ + // buffered data. In fact any future data downloaded by this element or + // other will be sharable by both elements. + [Throws] + void mozLoadFrom(HTMLMediaElement other); + + // Mozilla extension: provides access to the fragment end time if + // the media element has a fragment URI for the currentSrc, otherwise + // it is equal to the media duration. + readonly attribute double mozFragmentEnd; + + // Mozilla extension: an audio channel type for media elements. + // An exception is thrown if the app tries to change the audio channel type + // without the permission (manifest file for B2G apps). + // The supported values are: + // * normal (default value) + // Automatically paused if "notification" or higher priority channel + // is played + // Use case: normal applications + // * content + // Automatically paused if "notification" or higher priority channel + // is played. Also paused if another app starts using "content" + // channel. Using this channel never affects applications using + // the "normal" channel. + // Use case: video/audio players + // * notification + // Automatically paused if "alarm" or higher priority channel is played. + // Use case: New email, incoming SMS + // * alarm + // Automatically paused if "telephony" or higher priority channel is + // played. + // User case: Alarm clock, calendar alarms + // * telephony + // Automatically paused if "ringer" or higher priority + // channel is played. + // Use case: dialer, voip + // * ringer + // Automatically paused if "publicnotification" or higher priority + // channel is played. + // Use case: dialer, voip + // * publicnotification + // Always plays in speaker, even when headphones are plugged in. + // Use case: Camera shutter sound. + [SetterThrows] + attribute DOMString mozAudioChannelType; + + // In addition the media element has this new events: + // * onmozinterruptbegin - called when the media element is interrupted + // because of the audiochannel manager. + // * onmozinterruptend - called when the interruption is concluded +}; diff --git a/dom/webidl/WebIDL.mk b/dom/webidl/WebIDL.mk index 1c44ac323f6b..073b7941b104 100644 --- a/dom/webidl/WebIDL.mk +++ b/dom/webidl/WebIDL.mk @@ -96,6 +96,7 @@ webidl_files = \ HTMLLIElement.webidl \ HTMLLinkElement.webidl \ HTMLMapElement.webidl \ + HTMLMediaElement.webidl \ HTMLMenuElement.webidl \ HTMLMenuItemElement.webidl \ HTMLMetaElement.webidl \ From 0ede3d60da557a2bc8f54dff25c9b8cc677ac371 Mon Sep 17 00:00:00 2001 From: Andrea Marchesini Date: Tue, 19 Mar 2013 13:25:46 +0100 Subject: [PATCH 007/146] Bug 841493 - Renaming HTMLAudioElement, r=Ms2ger --HG-- rename : content/html/content/public/nsHTMLAudioElement.h => content/html/content/public/HTMLAudioElement.h rename : content/html/content/src/nsHTMLAudioElement.cpp => content/html/content/src/HTMLAudioElement.cpp --- ...sHTMLAudioElement.h => HTMLAudioElement.h} | 26 ++++++---- content/html/content/public/Makefile.in | 2 +- ...LAudioElement.cpp => HTMLAudioElement.cpp} | 47 ++++++++++--------- content/html/content/src/Makefile.in | 2 +- 4 files changed, 43 insertions(+), 34 deletions(-) rename content/html/content/public/{nsHTMLAudioElement.h => HTMLAudioElement.h} (69%) rename content/html/content/src/{nsHTMLAudioElement.cpp => HTMLAudioElement.cpp} (81%) diff --git a/content/html/content/public/nsHTMLAudioElement.h b/content/html/content/public/HTMLAudioElement.h similarity index 69% rename from content/html/content/public/nsHTMLAudioElement.h rename to content/html/content/public/HTMLAudioElement.h index 962f5042c613..a0c4970f7974 100644 --- a/content/html/content/public/nsHTMLAudioElement.h +++ b/content/html/content/public/HTMLAudioElement.h @@ -3,8 +3,8 @@ /* 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/. */ -#if !defined(nsHTMLAudioElement_h__) -#define nsHTMLAudioElement_h__ +#ifndef mozilla_dom_HTMLAudioElement_h +#define mozilla_dom_HTMLAudioElement_h #include "nsIDOMHTMLAudioElement.h" #include "nsIJSNativeInitializer.h" @@ -13,13 +13,16 @@ typedef uint16_t nsMediaNetworkState; typedef uint16_t nsMediaReadyState; -class nsHTMLAudioElement : public mozilla::dom::HTMLMediaElement, - public nsIDOMHTMLAudioElement, - public nsIJSNativeInitializer +namespace mozilla { +namespace dom { + +class HTMLAudioElement : public HTMLMediaElement, + public nsIDOMHTMLAudioElement, + public nsIJSNativeInitializer { public: - nsHTMLAudioElement(already_AddRefed aNodeInfo); - virtual ~nsHTMLAudioElement(); + HTMLAudioElement(already_AddRefed aNodeInfo); + virtual ~HTMLAudioElement(); // nsISupports NS_DECL_ISUPPORTS_INHERITED @@ -34,8 +37,8 @@ public: NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC // nsIDOMHTMLMediaElement - using mozilla::dom::HTMLMediaElement::GetPaused; - NS_FORWARD_NSIDOMHTMLMEDIAELEMENT(mozilla::dom::HTMLMediaElement::) + using HTMLMediaElement::GetPaused; + NS_FORWARD_NSIDOMHTMLMEDIAELEMENT(HTMLMediaElement::) // nsIDOMHTMLAudioElement NS_DECL_NSIDOMHTMLAUDIOELEMENT @@ -52,4 +55,7 @@ public: virtual nsIDOMNode* AsDOMNode() { return this; } }; -#endif +} // namespace dom +} // namespace mozilla + +#endif // mozilla_dom_HTMLAudioElement_h diff --git a/content/html/content/public/Makefile.in b/content/html/content/public/Makefile.in index 593944d08e93..3d572a89944b 100644 --- a/content/html/content/public/Makefile.in +++ b/content/html/content/public/Makefile.in @@ -21,7 +21,6 @@ EXPORTS = \ nsIRadioGroupContainer.h \ nsITextControlElement.h \ nsFormSubmission.h \ - nsHTMLAudioElement.h \ nsHTMLVideoElement.h \ nsIHTMLCollection.h \ $(NULL) @@ -31,6 +30,7 @@ EXPORTS_NAMESPACES = mozilla/dom EXPORTS_mozilla/dom = \ HTMLCanvasElement.h \ HTMLMediaElement.h \ + HTMLAudioElement.h \ $(NULL) include $(topsrcdir)/config/rules.mk diff --git a/content/html/content/src/nsHTMLAudioElement.cpp b/content/html/content/src/HTMLAudioElement.cpp similarity index 81% rename from content/html/content/src/nsHTMLAudioElement.cpp rename to content/html/content/src/HTMLAudioElement.cpp index da0908e1606f..494939a4c824 100644 --- a/content/html/content/src/nsHTMLAudioElement.cpp +++ b/content/html/content/src/HTMLAudioElement.cpp @@ -5,7 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "nsError.h" #include "nsIDOMHTMLAudioElement.h" -#include "nsHTMLAudioElement.h" +#include "mozilla/dom/HTMLAudioElement.h" #include "nsGenericHTMLElement.h" #include "nsGkAtoms.h" #include "nsIDocument.h" @@ -17,21 +17,20 @@ #include #include "mozilla/Preferences.h" -using namespace mozilla; -using namespace mozilla::dom; +DOMCI_NODE_DATA(HTMLAudioElement, mozilla::dom::HTMLAudioElement) static bool IsAudioAPIEnabled() { - return Preferences::GetBool("media.audio_data.enabled", true); + return mozilla::Preferences::GetBool("media.audio_data.enabled", true); } nsGenericHTMLElement* NS_NewHTMLAudioElement(already_AddRefed aNodeInfo, - FromParser aFromParser) + mozilla::dom::FromParser aFromParser) { /* - * nsHTMLAudioElement's will be created without a nsINodeInfo passed in + * HTMLAudioElement's will be created without a nsINodeInfo passed in * if someone says "var audio = new Audio();" in JavaScript, in a case like * that we request the nsINodeInfo from the document's nodeinfo list. */ @@ -47,36 +46,37 @@ NS_NewHTMLAudioElement(already_AddRefed aNodeInfo, NS_ENSURE_TRUE(nodeInfo, nullptr); } - return new nsHTMLAudioElement(nodeInfo.forget()); + return new mozilla::dom::HTMLAudioElement(nodeInfo.forget()); } -NS_IMPL_ADDREF_INHERITED(nsHTMLAudioElement, HTMLMediaElement) -NS_IMPL_RELEASE_INHERITED(nsHTMLAudioElement, HTMLMediaElement) +namespace mozilla { +namespace dom { -DOMCI_NODE_DATA(HTMLAudioElement, nsHTMLAudioElement) +NS_IMPL_ADDREF_INHERITED(HTMLAudioElement, HTMLMediaElement) +NS_IMPL_RELEASE_INHERITED(HTMLAudioElement, HTMLMediaElement) -NS_INTERFACE_TABLE_HEAD(nsHTMLAudioElement) -NS_HTML_CONTENT_INTERFACE_TABLE3(nsHTMLAudioElement, nsIDOMHTMLMediaElement, +NS_INTERFACE_TABLE_HEAD(HTMLAudioElement) +NS_HTML_CONTENT_INTERFACE_TABLE3(HTMLAudioElement, nsIDOMHTMLMediaElement, nsIDOMHTMLAudioElement, nsIJSNativeInitializer) -NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLAudioElement, +NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(HTMLAudioElement, HTMLMediaElement) NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLAudioElement) -NS_IMPL_ELEMENT_CLONE(nsHTMLAudioElement) +NS_IMPL_ELEMENT_CLONE(HTMLAudioElement) -nsHTMLAudioElement::nsHTMLAudioElement(already_AddRefed aNodeInfo) +HTMLAudioElement::HTMLAudioElement(already_AddRefed aNodeInfo) : HTMLMediaElement(aNodeInfo) { } -nsHTMLAudioElement::~nsHTMLAudioElement() +HTMLAudioElement::~HTMLAudioElement() { } NS_IMETHODIMP -nsHTMLAudioElement::Initialize(nsISupports* aOwner, JSContext* aContext, - JSObject *aObj, uint32_t argc, jsval *argv) +HTMLAudioElement::Initialize(nsISupports* aOwner, JSContext* aContext, + JSObject *aObj, uint32_t argc, jsval *argv) { // Audio elements created using "new Audio(...)" should have // 'preload' set to 'auto' (since the script must intend to @@ -106,7 +106,7 @@ nsHTMLAudioElement::Initialize(nsISupports* aOwner, JSContext* aContext, } NS_IMETHODIMP -nsHTMLAudioElement::MozSetup(uint32_t aChannels, uint32_t aRate) +HTMLAudioElement::MozSetup(uint32_t aChannels, uint32_t aRate) { if (!IsAudioAPIEnabled()) { return NS_ERROR_DOM_NOT_SUPPORTED_ERR; @@ -141,7 +141,7 @@ nsHTMLAudioElement::MozSetup(uint32_t aChannels, uint32_t aRate) } NS_IMETHODIMP -nsHTMLAudioElement::MozWriteAudio(const JS::Value& aData, JSContext* aCx, uint32_t* aRetVal) +HTMLAudioElement::MozWriteAudio(const JS::Value& aData, JSContext* aCx, uint32_t* aRetVal) { if (!IsAudioAPIEnabled()) { return NS_ERROR_DOM_NOT_SUPPORTED_ERR; @@ -203,7 +203,7 @@ nsHTMLAudioElement::MozWriteAudio(const JS::Value& aData, JSContext* aCx, uint32 } NS_IMETHODIMP -nsHTMLAudioElement::MozCurrentSampleOffset(uint64_t *aRetVal) +HTMLAudioElement::MozCurrentSampleOffset(uint64_t *aRetVal) { if (!IsAudioAPIEnabled()) { return NS_ERROR_DOM_NOT_SUPPORTED_ERR; @@ -222,7 +222,7 @@ nsHTMLAudioElement::MozCurrentSampleOffset(uint64_t *aRetVal) return NS_OK; } -nsresult nsHTMLAudioElement::SetAcceptHeader(nsIHttpChannel* aChannel) +nsresult HTMLAudioElement::SetAcceptHeader(nsIHttpChannel* aChannel) { nsAutoCString value( #ifdef MOZ_WEBM @@ -244,3 +244,6 @@ nsresult nsHTMLAudioElement::SetAcceptHeader(nsIHttpChannel* aChannel) value, false); } + +} // namespace dom +} // namespace mozilla diff --git a/content/html/content/src/Makefile.in b/content/html/content/src/Makefile.in index 1c8f0d1f0c9f..b482c0daa707 100644 --- a/content/html/content/src/Makefile.in +++ b/content/html/content/src/Makefile.in @@ -160,7 +160,7 @@ EXPORTS_mozilla/dom += \ $(NULL) CPPSRCS += \ - nsHTMLAudioElement.cpp \ + HTMLAudioElement.cpp \ HTMLMediaElement.cpp \ MediaError.cpp \ HTMLSourceElement.cpp \ From f9fb2710420f15cf707e34000bf36946fe66b0e0 Mon Sep 17 00:00:00 2001 From: Andrea Marchesini Date: Tue, 19 Mar 2013 13:26:39 +0100 Subject: [PATCH 008/146] Bug 841493 - HTMLAudioElement to WebIDL, r=Ms2ger --- .../html/content/public/HTMLAudioElement.h | 17 ++ content/html/content/src/HTMLAudioElement.cpp | 156 +++++++++++++----- dom/webidl/HTMLAudioElement.webidl | 32 ++++ dom/webidl/WebIDL.mk | 1 + 4 files changed, 168 insertions(+), 38 deletions(-) create mode 100644 dom/webidl/HTMLAudioElement.webidl diff --git a/content/html/content/public/HTMLAudioElement.h b/content/html/content/public/HTMLAudioElement.h index a0c4970f7974..fe8988d46a29 100644 --- a/content/html/content/public/HTMLAudioElement.h +++ b/content/html/content/public/HTMLAudioElement.h @@ -53,6 +53,23 @@ public: virtual nsXPCClassInfo* GetClassInfo(); virtual nsIDOMNode* AsDOMNode() { return this; } + + // WebIDL + + static already_AddRefed Audio(const GlobalObject& global, + ErrorResult& aRv); + static already_AddRefed Audio(const GlobalObject& global, + const nsAString& src, + ErrorResult& aRv); + + void MozSetup(uint32_t aChannels, uint32_t aRate, ErrorResult& aRv); + + uint32_t MozWriteAudio(JSContext* aCx, JS::Value aData, ErrorResult& aRv); + + uint64_t MozCurrentSampleOffset(ErrorResult& aRv); + +protected: + virtual JSObject* WrapNode(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE; }; } // namespace dom diff --git a/content/html/content/src/HTMLAudioElement.cpp b/content/html/content/src/HTMLAudioElement.cpp index 494939a4c824..ac6665faaa3a 100644 --- a/content/html/content/src/HTMLAudioElement.cpp +++ b/content/html/content/src/HTMLAudioElement.cpp @@ -3,9 +3,11 @@ /* 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 "mozilla/dom/HTMLAudioElement.h" +#include "mozilla/dom/HTMLAudioElementBinding.h" #include "nsError.h" #include "nsIDOMHTMLAudioElement.h" -#include "mozilla/dom/HTMLAudioElement.h" #include "nsGenericHTMLElement.h" #include "nsGkAtoms.h" #include "nsIDocument.h" @@ -68,12 +70,14 @@ NS_IMPL_ELEMENT_CLONE(HTMLAudioElement) HTMLAudioElement::HTMLAudioElement(already_AddRefed aNodeInfo) : HTMLMediaElement(aNodeInfo) { + SetIsDOMBinding(); } HTMLAudioElement::~HTMLAudioElement() { } + NS_IMETHODIMP HTMLAudioElement::Initialize(nsISupports* aOwner, JSContext* aContext, JSObject *aObj, uint32_t argc, jsval *argv) @@ -105,21 +109,63 @@ HTMLAudioElement::Initialize(nsISupports* aOwner, JSContext* aContext, return SetSrc(str); } -NS_IMETHODIMP -HTMLAudioElement::MozSetup(uint32_t aChannels, uint32_t aRate) +already_AddRefed +HTMLAudioElement::Audio(const GlobalObject& aGlobal, ErrorResult& aRv) +{ + nsCOMPtr win = do_QueryInterface(aGlobal.Get()); + nsIDocument* doc; + if (!win || !(doc = win->GetExtantDoc())) { + aRv.Throw(NS_ERROR_FAILURE); + return nullptr; + } + + nsCOMPtr nodeInfo = + doc->NodeInfoManager()->GetNodeInfo(nsGkAtoms::audio, nullptr, + kNameSpaceID_XHTML, + nsIDOMNode::ELEMENT_NODE); + if (!nodeInfo) { + aRv.Throw(NS_ERROR_FAILURE); + return nullptr; + } + + nsRefPtr audio = new HTMLAudioElement(nodeInfo.forget()); + audio->SetHTMLAttr(nsGkAtoms::preload, NS_LITERAL_STRING("auto"), aRv); + if (aRv.Failed()) { + return nullptr; + } + + return audio.forget(); +} + +already_AddRefed +HTMLAudioElement::Audio(const GlobalObject& aGlobal, const nsAString& aSrc, ErrorResult& aRv) +{ + nsRefPtr audio = Audio(aGlobal, aRv); + if (audio) { + aRv = audio->SetSrc(aSrc); + } + + return audio.forget(); +} + +void +HTMLAudioElement::MozSetup(uint32_t aChannels, uint32_t aRate, ErrorResult& aRv) { if (!IsAudioAPIEnabled()) { - return NS_ERROR_DOM_NOT_SUPPORTED_ERR; + aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR); + return; } // If there is already a src provided, don't setup another stream if (mDecoder) { - return NS_ERROR_FAILURE; + aRv.Throw(NS_ERROR_FAILURE); + return; } // MozWriteAudio divides by mChannels, so validate now. if (0 == aChannels) { - return NS_ERROR_FAILURE; + aRv.Throw(NS_ERROR_FAILURE); + return; } if (mAudioStream) { @@ -127,32 +173,41 @@ HTMLAudioElement::MozSetup(uint32_t aChannels, uint32_t aRate) } mAudioStream = AudioStream::AllocateStream(); - nsresult rv = mAudioStream->Init(aChannels, aRate, mAudioChannelType); - if (NS_FAILED(rv)) { + aRv = mAudioStream->Init(aChannels, aRate, mAudioChannelType); + if (aRv.Failed()) { mAudioStream->Shutdown(); mAudioStream = nullptr; - return rv; + return; } MetadataLoaded(aChannels, aRate, true, false, nullptr); mAudioStream->SetVolume(mVolume); - - return NS_OK; } NS_IMETHODIMP -HTMLAudioElement::MozWriteAudio(const JS::Value& aData, JSContext* aCx, uint32_t* aRetVal) +HTMLAudioElement::MozSetup(uint32_t aChannels, uint32_t aRate) +{ + ErrorResult rv; + MozSetup(aChannels, aRate, rv); + return rv.ErrorCode(); +} + +uint32_t +HTMLAudioElement::MozWriteAudio(JSContext* aCx, JS::Value aData, ErrorResult& aRv) { if (!IsAudioAPIEnabled()) { - return NS_ERROR_DOM_NOT_SUPPORTED_ERR; + aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR); + return 0; } if (!mAudioStream) { - return NS_ERROR_DOM_INVALID_STATE_ERR; + aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR); + return 0; } if (!aData.isObject()) { - return NS_ERROR_DOM_TYPE_MISMATCH_ERR; + aRv.Throw(NS_ERROR_DOM_TYPE_MISMATCH_ERR); + return 0; } JSObject* darray = &aData.toObject(); @@ -165,11 +220,13 @@ HTMLAudioElement::MozWriteAudio(const JS::Value& aData, JSContext* aCx, uint32_t } else if (JS_IsArrayObject(aCx, darray)) { JSObject* nobj = JS_NewFloat32ArrayFromArray(aCx, darray); if (!nobj) { - return NS_ERROR_DOM_TYPE_MISMATCH_ERR; + aRv.Throw(NS_ERROR_DOM_TYPE_MISMATCH_ERR); + return 0; } tsrc = nobj; } else { - return NS_ERROR_DOM_TYPE_MISMATCH_ERR; + aRv.Throw(NS_ERROR_DOM_TYPE_MISMATCH_ERR); + return 0; } tvr.setObject(tsrc); @@ -178,7 +235,8 @@ HTMLAudioElement::MozWriteAudio(const JS::Value& aData, JSContext* aCx, uint32_t // Make sure that we are going to write the correct amount of data based // on number of channels. if (dataLength % mChannels != 0) { - return NS_ERROR_DOM_INDEX_SIZE_ERR; + aRv.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR); + return 0; } // Don't write more than can be written without blocking. @@ -191,35 +249,51 @@ HTMLAudioElement::MozWriteAudio(const JS::Value& aData, JSContext* aCx, uint32_t // AudioDataValue is 'float', but it's not worth it for this deprecated API. nsAutoArrayPtr audioData(new AudioDataValue[writeLen * mChannels]); ConvertAudioSamples(frames, audioData.get(), writeLen * mChannels); - nsresult rv = mAudioStream->Write(audioData.get(), writeLen); - if (NS_FAILED(rv)) { - return rv; + aRv = mAudioStream->Write(audioData.get(), writeLen); + if (aRv.Failed()) { + return 0; } mAudioStream->Start(); // Return the actual amount written. - *aRetVal = writeLen * mChannels; - return rv; + return writeLen * mChannels; +} + +NS_IMETHODIMP +HTMLAudioElement::MozWriteAudio(const JS::Value& aData, JSContext* aCx, uint32_t* aRetVal) +{ + ErrorResult rv; + *aRetVal = MozWriteAudio(aCx, aData, rv); + return rv.ErrorCode(); +} + +uint64_t +HTMLAudioElement::MozCurrentSampleOffset(ErrorResult& aRv) +{ + if (!IsAudioAPIEnabled()) { + aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR); + return 0; + } + + if (!mAudioStream) { + aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR); + return 0; + } + + int64_t position = mAudioStream->GetPositionInFrames(); + if (position < 0) { + return 0; + } + + return position * mChannels; } NS_IMETHODIMP HTMLAudioElement::MozCurrentSampleOffset(uint64_t *aRetVal) { - if (!IsAudioAPIEnabled()) { - return NS_ERROR_DOM_NOT_SUPPORTED_ERR; - } - - if (!mAudioStream) { - return NS_ERROR_DOM_INVALID_STATE_ERR; - } - - int64_t position = mAudioStream->GetPositionInFrames(); - if (position < 0) { - *aRetVal = 0; - } else { - *aRetVal = position * mChannels; - } - return NS_OK; + ErrorResult rv; + *aRetVal = MozCurrentSampleOffset(rv); + return rv.ErrorCode(); } nsresult HTMLAudioElement::SetAcceptHeader(nsIHttpChannel* aChannel) @@ -245,5 +319,11 @@ nsresult HTMLAudioElement::SetAcceptHeader(nsIHttpChannel* aChannel) false); } +JSObject* +HTMLAudioElement::WrapNode(JSContext* aCx, JSObject* aScope) +{ + return HTMLAudioElementBinding::Wrap(aCx, aScope, this); +} + } // namespace dom } // namespace mozilla diff --git a/dom/webidl/HTMLAudioElement.webidl b/dom/webidl/HTMLAudioElement.webidl new file mode 100644 index 000000000000..a9fd56d329a4 --- /dev/null +++ b/dom/webidl/HTMLAudioElement.webidl @@ -0,0 +1,32 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* 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/. + * + * The origin of this IDL file is + * http://www.whatwg.org/specs/web-apps/current-work/#the-audio-element + * + * Ā© Copyright 2004-2011 Apple Computer, Inc., Mozilla Foundation, and + * Opera Software ASA. You are granted a license to use, reproduce + * and create derivative works of this document. + */ + +[NamedConstructor=Audio(), + NamedConstructor=Audio(DOMString src)] +interface HTMLAudioElement : HTMLMediaElement {}; + +partial interface HTMLAudioElement +{ + // Setup the audio stream for writing + [Throws] + void mozSetup(unsigned long channels, unsigned long rate); + + // Write audio to the audio stream + [Throws] + unsigned long mozWriteAudio(any data); + + // Get the current offset (measured in samples since the start) of the audio + // stream created using mozWriteAudio(). + [Throws] + unsigned long long mozCurrentSampleOffset(); +}; diff --git a/dom/webidl/WebIDL.mk b/dom/webidl/WebIDL.mk index 073b7941b104..7bd1be0c616c 100644 --- a/dom/webidl/WebIDL.mk +++ b/dom/webidl/WebIDL.mk @@ -69,6 +69,7 @@ webidl_files = \ HTMLAnchorElement.webidl \ HTMLAppletElement.webidl \ HTMLAreaElement.webidl \ + HTMLAudioElement.webidl \ HTMLBaseElement.webidl \ HTMLBodyElement.webidl \ HTMLBRElement.webidl \ From a7e3b326adfbfc6647fe1e1ad6be998ddb4a0055 Mon Sep 17 00:00:00 2001 From: Andrea Marchesini Date: Tue, 19 Mar 2013 13:27:35 +0100 Subject: [PATCH 009/146] Bug 841493 - Rename nsHTMLVideoElement to HTMLVideoElement, r=Ms2ger --HG-- rename : content/html/content/public/nsHTMLVideoElement.h => content/html/content/public/HTMLVideoElement.h rename : content/html/content/src/nsHTMLVideoElement.cpp => content/html/content/src/HTMLVideoElement.cpp --- .../canvas/src/CanvasRenderingContext2D.cpp | 4 +- content/canvas/src/CanvasRenderingContext2D.h | 2 +- ...sHTMLVideoElement.h => HTMLVideoElement.h} | 27 +++++--- content/html/content/public/Makefile.in | 2 +- ...LVideoElement.cpp => HTMLVideoElement.cpp} | 66 ++++++++++--------- content/html/content/src/Makefile.in | 2 +- content/media/MediaDecoder.cpp | 2 +- dom/bindings/Bindings.conf | 2 +- js/xpconnect/src/nsDOMQS.h | 4 +- layout/base/nsLayoutUtils.cpp | 8 +-- layout/base/nsLayoutUtils.h | 4 +- layout/generic/nsVideoFrame.cpp | 12 ++-- 12 files changed, 72 insertions(+), 63 deletions(-) rename content/html/content/public/{nsHTMLVideoElement.h => HTMLVideoElement.h} (73%) rename content/html/content/src/{nsHTMLVideoElement.cpp => HTMLVideoElement.cpp} (67%) diff --git a/content/canvas/src/CanvasRenderingContext2D.cpp b/content/canvas/src/CanvasRenderingContext2D.cpp index 044c60d6b89c..e53340116c97 100644 --- a/content/canvas/src/CanvasRenderingContext2D.cpp +++ b/content/canvas/src/CanvasRenderingContext2D.cpp @@ -93,7 +93,7 @@ #include "XPCQuickStubs.h" #include "mozilla/dom/BindingUtils.h" #include "mozilla/dom/HTMLImageElement.h" -#include "nsHTMLVideoElement.h" +#include "mozilla/dom/HTMLVideoElement.h" #include "mozilla/dom/CanvasRenderingContext2DBinding.h" #ifdef USE_SKIA @@ -2940,7 +2940,7 @@ CanvasRenderingContext2D::DrawImage(const HTMLImageOrCanvasOrVideoElement& image HTMLImageElement* img = &image.GetAsHTMLImageElement(); element = img; } else { - nsHTMLVideoElement* video = image.GetAsHTMLVideoElement(); + HTMLVideoElement* video = image.GetAsHTMLVideoElement(); element = video; } diff --git a/content/canvas/src/CanvasRenderingContext2D.h b/content/canvas/src/CanvasRenderingContext2D.h index 210400b9f25d..28ad92d0fc5b 100644 --- a/content/canvas/src/CanvasRenderingContext2D.h +++ b/content/canvas/src/CanvasRenderingContext2D.h @@ -11,7 +11,7 @@ #include "mozilla/RefPtr.h" #include "nsColor.h" #include "mozilla/dom/HTMLCanvasElement.h" -#include "nsHTMLVideoElement.h" +#include "mozilla/dom/HTMLVideoElement.h" #include "CanvasUtils.h" #include "gfxFont.h" #include "mozilla/ErrorResult.h" diff --git a/content/html/content/public/nsHTMLVideoElement.h b/content/html/content/public/HTMLVideoElement.h similarity index 73% rename from content/html/content/public/nsHTMLVideoElement.h rename to content/html/content/public/HTMLVideoElement.h index 1c20a69377e3..e3ff9c817faa 100644 --- a/content/html/content/public/nsHTMLVideoElement.h +++ b/content/html/content/public/HTMLVideoElement.h @@ -3,20 +3,24 @@ /* 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/. */ -#if !defined(nsHTMLVideoElement_h__) -#define nsHTMLVideoElement_h__ + +#ifndef mozilla_dom_HTMLVideoElement_h +#define mozilla_dom_HTMLVideoElement_h #include "nsIDOMHTMLVideoElement.h" #include "mozilla/dom/HTMLMediaElement.h" -class nsHTMLVideoElement : public mozilla::dom::HTMLMediaElement, - public nsIDOMHTMLVideoElement +namespace mozilla { +namespace dom { + +class HTMLVideoElement : public HTMLMediaElement, + public nsIDOMHTMLVideoElement { public: - nsHTMLVideoElement(already_AddRefed aNodeInfo); - virtual ~nsHTMLVideoElement(); + HTMLVideoElement(already_AddRefed aNodeInfo); + virtual ~HTMLVideoElement(); - NS_IMPL_FROMCONTENT_HTML_WITH_TAG(nsHTMLVideoElement, video) + NS_IMPL_FROMCONTENT_HTML_WITH_TAG(HTMLVideoElement, video) // nsISupports NS_DECL_ISUPPORTS_INHERITED @@ -31,8 +35,8 @@ public: NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC // nsIDOMHTMLMediaElement - using mozilla::dom::HTMLMediaElement::GetPaused; - NS_FORWARD_NSIDOMHTMLMEDIAELEMENT(mozilla::dom::HTMLMediaElement::) + using HTMLMediaElement::GetPaused; + NS_FORWARD_NSIDOMHTMLMEDIAELEMENT(HTMLMediaElement::) // nsIDOMHTMLVideoElement NS_DECL_NSIDOMHTMLVIDEOELEMENT @@ -57,4 +61,7 @@ public: virtual nsIDOMNode* AsDOMNode() { return this; } }; -#endif +} // namespace dom +} // namespace mozilla + +#endif // mozilla_dom_HTMLVideoElement_h diff --git a/content/html/content/public/Makefile.in b/content/html/content/public/Makefile.in index 3d572a89944b..1f421b96329c 100644 --- a/content/html/content/public/Makefile.in +++ b/content/html/content/public/Makefile.in @@ -21,7 +21,6 @@ EXPORTS = \ nsIRadioGroupContainer.h \ nsITextControlElement.h \ nsFormSubmission.h \ - nsHTMLVideoElement.h \ nsIHTMLCollection.h \ $(NULL) @@ -31,6 +30,7 @@ EXPORTS_mozilla/dom = \ HTMLCanvasElement.h \ HTMLMediaElement.h \ HTMLAudioElement.h \ + HTMLVideoElement.h \ $(NULL) include $(topsrcdir)/config/rules.mk diff --git a/content/html/content/src/nsHTMLVideoElement.cpp b/content/html/content/src/HTMLVideoElement.cpp similarity index 67% rename from content/html/content/src/nsHTMLVideoElement.cpp rename to content/html/content/src/HTMLVideoElement.cpp index 0d79fc92a64f..ce808d85c31f 100644 --- a/content/html/content/src/nsHTMLVideoElement.cpp +++ b/content/html/content/src/HTMLVideoElement.cpp @@ -8,7 +8,7 @@ #include "nsIDOMHTMLVideoElement.h" #include "nsIDOMHTMLSourceElement.h" -#include "nsHTMLVideoElement.h" +#include "mozilla/dom/HTMLVideoElement.h" #include "nsGenericHTMLElement.h" #include "nsGkAtoms.h" #include "nsSize.h" @@ -32,53 +32,52 @@ #include "MediaError.h" #include "MediaDecoder.h" -using namespace mozilla; -using namespace mozilla::dom; - NS_IMPL_NS_NEW_HTML_ELEMENT(Video) +DOMCI_NODE_DATA(HTMLVideoElement, mozilla::dom::HTMLVideoElement) -NS_IMPL_ADDREF_INHERITED(nsHTMLVideoElement, HTMLMediaElement) -NS_IMPL_RELEASE_INHERITED(nsHTMLVideoElement, HTMLMediaElement) +namespace mozilla { +namespace dom { -DOMCI_NODE_DATA(HTMLVideoElement, nsHTMLVideoElement) +NS_IMPL_ADDREF_INHERITED(HTMLVideoElement, HTMLMediaElement) +NS_IMPL_RELEASE_INHERITED(HTMLVideoElement, HTMLMediaElement) -NS_INTERFACE_TABLE_HEAD(nsHTMLVideoElement) - NS_HTML_CONTENT_INTERFACE_TABLE2(nsHTMLVideoElement, nsIDOMHTMLMediaElement, nsIDOMHTMLVideoElement) - NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLVideoElement, +NS_INTERFACE_TABLE_HEAD(HTMLVideoElement) + NS_HTML_CONTENT_INTERFACE_TABLE2(HTMLVideoElement, nsIDOMHTMLMediaElement, nsIDOMHTMLVideoElement) + NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(HTMLVideoElement, HTMLMediaElement) NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLVideoElement) -NS_IMPL_ELEMENT_CLONE(nsHTMLVideoElement) +NS_IMPL_ELEMENT_CLONE(HTMLVideoElement) // nsIDOMHTMLVideoElement -NS_IMPL_INT_ATTR(nsHTMLVideoElement, Width, width) -NS_IMPL_INT_ATTR(nsHTMLVideoElement, Height, height) +NS_IMPL_INT_ATTR(HTMLVideoElement, Width, width) +NS_IMPL_INT_ATTR(HTMLVideoElement, Height, height) // nsIDOMHTMLVideoElement /* readonly attribute unsigned long videoWidth; */ -NS_IMETHODIMP nsHTMLVideoElement::GetVideoWidth(uint32_t *aVideoWidth) +NS_IMETHODIMP HTMLVideoElement::GetVideoWidth(uint32_t *aVideoWidth) { *aVideoWidth = mMediaSize.width == -1 ? 0 : mMediaSize.width; return NS_OK; } /* readonly attribute unsigned long videoHeight; */ -NS_IMETHODIMP nsHTMLVideoElement::GetVideoHeight(uint32_t *aVideoHeight) +NS_IMETHODIMP HTMLVideoElement::GetVideoHeight(uint32_t *aVideoHeight) { *aVideoHeight = mMediaSize.height == -1 ? 0 : mMediaSize.height; return NS_OK; } -nsHTMLVideoElement::nsHTMLVideoElement(already_AddRefed aNodeInfo) +HTMLVideoElement::HTMLVideoElement(already_AddRefed aNodeInfo) : HTMLMediaElement(aNodeInfo) { } -nsHTMLVideoElement::~nsHTMLVideoElement() +HTMLVideoElement::~HTMLVideoElement() { } -nsresult nsHTMLVideoElement::GetVideoSize(nsIntSize* size) +nsresult HTMLVideoElement::GetVideoSize(nsIntSize* size) { if (mMediaSize.width == -1 && mMediaSize.height == -1) { return NS_ERROR_FAILURE; @@ -90,10 +89,10 @@ nsresult nsHTMLVideoElement::GetVideoSize(nsIntSize* size) } bool -nsHTMLVideoElement::ParseAttribute(int32_t aNamespaceID, - nsIAtom* aAttribute, - const nsAString& aValue, - nsAttrValue& aResult) +HTMLVideoElement::ParseAttribute(int32_t aNamespaceID, + nsIAtom* aAttribute, + const nsAString& aValue, + nsAttrValue& aResult) { if (aAttribute == nsGkAtoms::width || aAttribute == nsGkAtoms::height) { return aResult.ParseSpecialIntValue(aValue); @@ -112,7 +111,7 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes, } NS_IMETHODIMP_(bool) -nsHTMLVideoElement::IsAttributeMapped(const nsIAtom* aAttribute) const +HTMLVideoElement::IsAttributeMapped(const nsIAtom* aAttribute) const { static const MappedAttributeEntry attributes[] = { { &nsGkAtoms::width }, @@ -129,12 +128,12 @@ nsHTMLVideoElement::IsAttributeMapped(const nsIAtom* aAttribute) const } nsMapRuleToAttributesFunc -nsHTMLVideoElement::GetAttributeMappingFunction() const +HTMLVideoElement::GetAttributeMappingFunction() const { return &MapAttributesIntoRule; } -nsresult nsHTMLVideoElement::SetAcceptHeader(nsIHttpChannel* aChannel) +nsresult HTMLVideoElement::SetAcceptHeader(nsIHttpChannel* aChannel) { nsAutoCString value( #ifdef MOZ_WEBM @@ -154,30 +153,30 @@ nsresult nsHTMLVideoElement::SetAcceptHeader(nsIHttpChannel* aChannel) false); } -NS_IMPL_URI_ATTR(nsHTMLVideoElement, Poster, poster) +NS_IMPL_URI_ATTR(HTMLVideoElement, Poster, poster) -NS_IMETHODIMP nsHTMLVideoElement::GetMozParsedFrames(uint32_t *aMozParsedFrames) +NS_IMETHODIMP HTMLVideoElement::GetMozParsedFrames(uint32_t *aMozParsedFrames) { NS_ASSERTION(NS_IsMainThread(), "Should be on main thread."); *aMozParsedFrames = mDecoder ? mDecoder->GetFrameStatistics().GetParsedFrames() : 0; return NS_OK; } -NS_IMETHODIMP nsHTMLVideoElement::GetMozDecodedFrames(uint32_t *aMozDecodedFrames) +NS_IMETHODIMP HTMLVideoElement::GetMozDecodedFrames(uint32_t *aMozDecodedFrames) { NS_ASSERTION(NS_IsMainThread(), "Should be on main thread."); *aMozDecodedFrames = mDecoder ? mDecoder->GetFrameStatistics().GetDecodedFrames() : 0; return NS_OK; } -NS_IMETHODIMP nsHTMLVideoElement::GetMozPresentedFrames(uint32_t *aMozPresentedFrames) +NS_IMETHODIMP HTMLVideoElement::GetMozPresentedFrames(uint32_t *aMozPresentedFrames) { NS_ASSERTION(NS_IsMainThread(), "Should be on main thread."); *aMozPresentedFrames = mDecoder ? mDecoder->GetFrameStatistics().GetPresentedFrames() : 0; return NS_OK; } -NS_IMETHODIMP nsHTMLVideoElement::GetMozPaintedFrames(uint32_t *aMozPaintedFrames) +NS_IMETHODIMP HTMLVideoElement::GetMozPaintedFrames(uint32_t *aMozPaintedFrames) { NS_ASSERTION(NS_IsMainThread(), "Should be on main thread."); layers::ImageContainer* container = GetImageContainer(); @@ -185,7 +184,7 @@ NS_IMETHODIMP nsHTMLVideoElement::GetMozPaintedFrames(uint32_t *aMozPaintedFrame return NS_OK; } -NS_IMETHODIMP nsHTMLVideoElement::GetMozFrameDelay(double *aMozFrameDelay) { +NS_IMETHODIMP HTMLVideoElement::GetMozFrameDelay(double *aMozFrameDelay) { NS_ASSERTION(NS_IsMainThread(), "Should be on main thread."); VideoFrameContainer* container = GetVideoFrameContainer(); *aMozFrameDelay = container ? container->GetFrameDelay() : 0; @@ -194,8 +193,11 @@ NS_IMETHODIMP nsHTMLVideoElement::GetMozFrameDelay(double *aMozFrameDelay) { /* readonly attribute bool mozHasAudio */ -NS_IMETHODIMP nsHTMLVideoElement::GetMozHasAudio(bool *aHasAudio) { +NS_IMETHODIMP HTMLVideoElement::GetMozHasAudio(bool *aHasAudio) { NS_ASSERTION(NS_IsMainThread(), "Should be on main thread."); *aHasAudio = mHasAudio; return NS_OK; } + +} // namespace dom +} // namespace mozilla diff --git a/content/html/content/src/Makefile.in b/content/html/content/src/Makefile.in index b482c0daa707..1be46d4ac54d 100644 --- a/content/html/content/src/Makefile.in +++ b/content/html/content/src/Makefile.in @@ -165,7 +165,7 @@ CPPSRCS += \ MediaError.cpp \ HTMLSourceElement.cpp \ TimeRanges.cpp \ - nsHTMLVideoElement.cpp \ + HTMLVideoElement.cpp \ $(NULL) endif diff --git a/content/media/MediaDecoder.cpp b/content/media/MediaDecoder.cpp index 72917f27d14e..37249434a949 100644 --- a/content/media/MediaDecoder.cpp +++ b/content/media/MediaDecoder.cpp @@ -10,7 +10,7 @@ #include #include "nsNetUtil.h" #include "AudioStream.h" -#include "nsHTMLVideoElement.h" +#include "mozilla/dom/HTMLVideoElement.h" #include "nsIObserver.h" #include "nsIObserverService.h" #include "nsTArray.h" diff --git a/dom/bindings/Bindings.conf b/dom/bindings/Bindings.conf index 404a1f5089d0..d8f377ea3ca4 100644 --- a/dom/bindings/Bindings.conf +++ b/dom/bindings/Bindings.conf @@ -1325,7 +1325,6 @@ def addExternalHTMLElement(element): headerFile=nativeElement + '.h') addExternalHTMLElement('HTMLFormElement') -addExternalHTMLElement('HTMLVideoElement') addExternalIface('ActivityOptions', nativeType='nsIDOMMozActivityOptions', headerFile='nsIDOMActivityOptions.h') addExternalIface('Attr') @@ -1339,6 +1338,7 @@ addExternalIface('DOMStringList') addExternalIface('File') addExternalIface('HitRegionOptions', nativeType='nsISupports') addExternalIface('HTMLCanvasElement', nativeType='mozilla::dom::HTMLCanvasElement') +addExternalIface('HTMLVideoElement', nativeType='mozilla::dom::HTMLVideoElement') addExternalIface('imgINotificationObserver', nativeType='imgINotificationObserver') addExternalIface('imgIRequest', nativeType='imgIRequest', notflattened=True) addExternalIface('LockedFile') diff --git a/js/xpconnect/src/nsDOMQS.h b/js/xpconnect/src/nsDOMQS.h index 6d1589ebf7ec..6465016bf65e 100644 --- a/js/xpconnect/src/nsDOMQS.h +++ b/js/xpconnect/src/nsDOMQS.h @@ -12,7 +12,7 @@ #include "mozilla/dom/HTMLImageElement.h" #include "mozilla/dom/HTMLOptionElement.h" #include "HTMLOptGroupElement.h" -#include "nsHTMLVideoElement.h" +#include "mozilla/dom/HTMLVideoElement.h" #include "nsHTMLDocument.h" #include "nsICSSDeclaration.h" #include "nsSVGElement.h" @@ -175,7 +175,7 @@ DEFINE_UNWRAP_CAST_HTML(form, nsHTMLFormElement) DEFINE_UNWRAP_CAST_HTML(img, mozilla::dom::HTMLImageElement) DEFINE_UNWRAP_CAST_HTML(optgroup, mozilla::dom::HTMLOptGroupElement) DEFINE_UNWRAP_CAST_HTML(option, mozilla::dom::HTMLOptionElement) -DEFINE_UNWRAP_CAST_HTML(video, nsHTMLVideoElement) +DEFINE_UNWRAP_CAST_HTML(video, mozilla::dom::HTMLVideoElement) inline nsISupports* ToSupports(nsContentList *p) diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index ff732fd1eee4..51d2fc11dc8e 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -54,7 +54,7 @@ #include "nsClientRect.h" #include #ifdef MOZ_MEDIA -#include "nsHTMLVideoElement.h" +#include "mozilla/dom/HTMLVideoElement.h" #endif #include "mozilla/dom/HTMLImageElement.h" #include "imgIRequest.h" @@ -4647,7 +4647,7 @@ nsLayoutUtils::SurfaceFromElement(HTMLCanvasElement* aElement, } nsLayoutUtils::SurfaceFromElementResult -nsLayoutUtils::SurfaceFromElement(nsHTMLVideoElement* aElement, +nsLayoutUtils::SurfaceFromElement(HTMLVideoElement* aElement, uint32_t aSurfaceFlags) { SurfaceFromElementResult result; @@ -4712,8 +4712,8 @@ nsLayoutUtils::SurfaceFromElement(dom::Element* aElement, #ifdef MOZ_MEDIA // Maybe it's