From 9fd3f3a56a1032c39ea53817745962b01cd7db26 Mon Sep 17 00:00:00 2001 From: Nathan Froyd Date: Mon, 6 May 2013 15:28:13 -0400 Subject: [PATCH] Bug 869073 - make WebIDL enums enum classes instead of plain enums; r=bz --- content/base/public/nsIDocument.h | 2 +- content/base/src/WebSocket.cpp | 6 +-- content/base/src/nsDOMBlobBuilder.cpp | 4 +- content/base/src/nsDOMParser.cpp | 14 ++++-- content/base/src/nsDocument.cpp | 9 ++-- content/base/src/nsXMLHttpRequest.cpp | 6 +-- .../canvas/src/CanvasRenderingContext2D.cpp | 2 +- content/canvas/src/CanvasRenderingContext2D.h | 2 +- content/media/AudioNodeStream.cpp | 10 ++-- content/media/AudioNodeStream.h | 10 ++-- content/media/webaudio/PannerNode.cpp | 18 +++---- dom/base/DOMRequest.cpp | 4 +- dom/base/DOMRequest.h | 4 +- dom/bindings/Codegen.py | 49 ++++++++++--------- dom/file/FileHandle.cpp | 12 ++--- dom/src/notification/Notification.cpp | 30 ++++++------ dom/src/notification/Notification.h | 4 +- dom/workers/XMLHttpRequest.cpp | 6 +-- 18 files changed, 101 insertions(+), 91 deletions(-) diff --git a/content/base/public/nsIDocument.h b/content/base/public/nsIDocument.h index 76019b8bcd9..af046e4b3b9 100644 --- a/content/base/public/nsIDocument.h +++ b/content/base/public/nsIDocument.h @@ -2028,7 +2028,7 @@ public: } bool Hidden() const { - return mVisibilityState != mozilla::dom::VisibilityStateValues::Visible; + return mVisibilityState != mozilla::dom::VisibilityState::Visible; } bool MozHidden() // Not const because of WarnOnceAbout { diff --git a/content/base/src/WebSocket.cpp b/content/base/src/WebSocket.cpp index ae1f6362eae..a4064d77a9d 100644 --- a/content/base/src/WebSocket.cpp +++ b/content/base/src/WebSocket.cpp @@ -453,7 +453,7 @@ WebSocket::WebSocket() mCloseEventCode(nsIWebSocketChannel::CLOSE_ABNORMAL), mReadyState(WebSocket::CONNECTING), mOutgoingBufferedAmount(0), - mBinaryType(BinaryTypeValues::Blob), + mBinaryType(dom::BinaryType::Blob), mScriptLine(0), mInnerWindowID(0) { @@ -888,10 +888,10 @@ WebSocket::CreateAndDispatchMessageEvent(const nsACString& aData, { JSAutoRequest ar(cx); if (isBinary) { - if (mBinaryType == BinaryTypeValues::Blob) { + if (mBinaryType == dom::BinaryType::Blob) { rv = nsContentUtils::CreateBlobBuffer(cx, aData, jsData); NS_ENSURE_SUCCESS(rv, rv); - } else if (mBinaryType == BinaryTypeValues::Arraybuffer) { + } else if (mBinaryType == dom::BinaryType::Arraybuffer) { JSObject* arrayBuf; rv = nsContentUtils::CreateArrayBuffer(cx, aData, &arrayBuf); NS_ENSURE_SUCCESS(rv, rv); diff --git a/content/base/src/nsDOMBlobBuilder.cpp b/content/base/src/nsDOMBlobBuilder.cpp index a68113866c1..431c4f67d27 100644 --- a/content/base/src/nsDOMBlobBuilder.cpp +++ b/content/base/src/nsDOMBlobBuilder.cpp @@ -192,14 +192,14 @@ nsDOMMultipartFile::InitBlob(JSContext* aCx, return NS_ERROR_TYPE_ERR; } mContentType = d.mType; - nativeEOL = d.mEndings == EndingTypesValues::Native; + nativeEOL = d.mEndings == EndingTypes::Native; } else { BlobPropertyBagWorkers d; if (!d.Init(aCx, JS::Handle::fromMarkedLocation(&aArgv[1]))) { return NS_ERROR_TYPE_ERR; } mContentType = d.mType; - nativeEOL = d.mEndings == EndingTypesValues::Native; + nativeEOL = d.mEndings == EndingTypes::Native; } } diff --git a/content/base/src/nsDOMParser.cpp b/content/base/src/nsDOMParser.cpp index b16ae5ee692..0ab06d9c03b 100644 --- a/content/base/src/nsDOMParser.cpp +++ b/content/base/src/nsDOMParser.cpp @@ -41,13 +41,19 @@ NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_1(nsDOMParser, mOwner) NS_IMPL_CYCLE_COLLECTING_ADDREF(nsDOMParser) NS_IMPL_CYCLE_COLLECTING_RELEASE(nsDOMParser) +static const char* +StringFromSupportedType(SupportedType aType) +{ + return SupportedTypeValues::strings[static_cast(aType)].value; +} + already_AddRefed nsDOMParser::ParseFromString(const nsAString& aStr, SupportedType aType, ErrorResult& rv) { nsCOMPtr domDocument; rv = ParseFromString(aStr, - SupportedTypeValues::strings[aType].value, + StringFromSupportedType(aType), getter_AddRefs(domDocument)); nsCOMPtr document(do_QueryInterface(domDocument)); return document.forget(); @@ -121,7 +127,7 @@ nsDOMParser::ParseFromBuffer(const Sequence& aBuf, uint32_t aBufLen, } nsCOMPtr domDocument; rv = nsDOMParser::ParseFromBuffer(aBuf.Elements(), aBufLen, - SupportedTypeValues::strings[aType].value, + StringFromSupportedType(aType), getter_AddRefs(domDocument)); nsCOMPtr document(do_QueryInterface(domDocument)); return document.forget(); @@ -137,7 +143,7 @@ nsDOMParser::ParseFromBuffer(const Uint8Array& aBuf, uint32_t aBufLen, } nsCOMPtr domDocument; rv = nsDOMParser::ParseFromBuffer(aBuf.Data(), aBufLen, - SupportedTypeValues::strings[aType].value, + StringFromSupportedType(aType), getter_AddRefs(domDocument)); nsCOMPtr document(do_QueryInterface(domDocument)); return document.forget(); @@ -175,7 +181,7 @@ nsDOMParser::ParseFromStream(nsIInputStream* aStream, rv = nsDOMParser::ParseFromStream(aStream, NS_ConvertUTF16toUTF8(aCharset).get(), aContentLength, - SupportedTypeValues::strings[aType].value, + StringFromSupportedType(aType), getter_AddRefs(domDocument)); nsCOMPtr document(do_QueryInterface(domDocument)); return document.forget(); diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp index 3773c088f47..a5a8f604b25 100644 --- a/content/base/src/nsDocument.cpp +++ b/content/base/src/nsDocument.cpp @@ -1345,7 +1345,7 @@ nsIDocument::nsIDocument() mCharacterSet(NS_LITERAL_CSTRING("ISO-8859-1")), mNodeInfoManager(nullptr), mCompatMode(eCompatibility_FullStandards), - mVisibilityState(VisibilityStateValues::Hidden), + mVisibilityState(dom::VisibilityState::Hidden), mIsInitialDocumentInWindow(false), mMayStartLayout(true), mVisible(true), @@ -10961,10 +10961,10 @@ nsDocument::GetVisibilityState() const // Otherwise, we're visible. if (!IsVisible() || !mWindow || !mWindow->GetOuterWindow() || mWindow->GetOuterWindow()->IsBackground()) { - return VisibilityStateValues::Hidden; + return dom::VisibilityState::Hidden; } - return VisibilityStateValues::Visible; + return dom::VisibilityState::Visible; } /* virtual */ void @@ -10999,7 +10999,8 @@ nsDocument::GetMozVisibilityState(nsAString& aState) NS_IMETHODIMP nsDocument::GetVisibilityState(nsAString& aState) { - const EnumEntry& entry = VisibilityStateValues::strings[mVisibilityState]; + const EnumEntry& entry = + VisibilityStateValues::strings[static_cast(mVisibilityState)]; aState.AssignASCII(entry.value, entry.length); return NS_OK; } diff --git a/content/base/src/nsXMLHttpRequest.cpp b/content/base/src/nsXMLHttpRequest.cpp index 40423119e9f..8f23c8ac733 100644 --- a/content/base/src/nsXMLHttpRequest.cpp +++ b/content/base/src/nsXMLHttpRequest.cpp @@ -847,8 +847,8 @@ nsXMLHttpRequest::StaticAssertions() { #define ASSERT_ENUM_EQUAL(_lc, _uc) \ MOZ_STATIC_ASSERT(\ - XMLHttpRequestResponseTypeValues::_lc \ - == XMLHttpRequestResponseType(XML_HTTP_RESPONSE_TYPE_ ## _uc), \ + static_cast(XMLHttpRequestResponseType::_lc) \ + == XML_HTTP_RESPONSE_TYPE_ ## _uc, \ #_uc " should match") ASSERT_ENUM_EQUAL(_empty, DEFAULT); @@ -899,7 +899,7 @@ void nsXMLHttpRequest::SetResponseType(XMLHttpRequestResponseType aType, ErrorResult& aRv) { - SetResponseType(ResponseTypeEnum(aType), aRv); + SetResponseType(ResponseTypeEnum(static_cast(aType)), aRv); } void diff --git a/content/canvas/src/CanvasRenderingContext2D.cpp b/content/canvas/src/CanvasRenderingContext2D.cpp index 28386911a98..7f9a0a2bab3 100644 --- a/content/canvas/src/CanvasRenderingContext2D.cpp +++ b/content/canvas/src/CanvasRenderingContext2D.cpp @@ -1872,7 +1872,7 @@ void CanvasRenderingContext2D::EnsureUserSpacePath(const CanvasWindingRule& winding) { FillRule fillRule = CurrentState().fillRule; - if(winding == CanvasWindingRuleValues::Evenodd) + if(winding == CanvasWindingRule::Evenodd) fillRule = FILL_EVEN_ODD; if (!mPath && !mPathBuilder && !mDSPathBuilder) { diff --git a/content/canvas/src/CanvasRenderingContext2D.h b/content/canvas/src/CanvasRenderingContext2D.h index ad9f71cfa7e..86b306e9ada 100644 --- a/content/canvas/src/CanvasRenderingContext2D.h +++ b/content/canvas/src/CanvasRenderingContext2D.h @@ -505,7 +505,7 @@ protected: void EnsureWritablePath(); // Ensures a path in UserSpace is available. - void EnsureUserSpacePath(const CanvasWindingRule& winding = CanvasWindingRuleValues::Nonzero); + void EnsureUserSpacePath(const CanvasWindingRule& winding = CanvasWindingRule::Nonzero); /** * Needs to be called before updating the transform. This makes a call to diff --git a/content/media/AudioNodeStream.cpp b/content/media/AudioNodeStream.cpp index cdf39e2f301..bd374ec6ba4 100644 --- a/content/media/AudioNodeStream.cpp +++ b/content/media/AudioNodeStream.cpp @@ -204,8 +204,8 @@ AudioNodeStream::SetChannelMixingParametersImpl(uint32_t aNumberOfChannels, MOZ_ASSERT(int(aChannelInterpretation) < INT16_MAX); mNumberOfInputChannels = aNumberOfChannels; - mMixingMode.mChannelCountMode = aChannelCountMode; - mMixingMode.mChannelInterpretation = aChannelInterpretation; + mChannelCountMode = aChannelCountMode; + mChannelInterpretation = aChannelInterpretation; } StreamBuffer::Track* @@ -266,7 +266,7 @@ AudioNodeStream::ObtainInputBlock(AudioChunk& aTmpChunk, uint32_t aPortIndex) GetAudioChannelsSuperset(outputChannelCount, chunk->mChannelData.Length()); } - switch (mMixingMode.mChannelCountMode) { + switch (mChannelCountMode) { case ChannelCountMode::Explicit: // Disregard the output channel count that we've calculated, and just use // mNumberOfInputChannels. @@ -303,7 +303,7 @@ AudioNodeStream::ObtainInputBlock(AudioChunk& aTmpChunk, uint32_t aPortIndex) nsAutoTArray channels; channels.AppendElements(chunk->mChannelData); if (channels.Length() < outputChannelCount) { - if (mMixingMode.mChannelInterpretation == ChannelInterpretation::Speakers) { + if (mChannelInterpretation == ChannelInterpretation::Speakers) { AudioChannelsUpMix(&channels, outputChannelCount, nullptr); NS_ASSERTION(outputChannelCount == channels.Length(), "We called GetAudioChannelsSuperset to avoid this"); @@ -314,7 +314,7 @@ AudioNodeStream::ObtainInputBlock(AudioChunk& aTmpChunk, uint32_t aPortIndex) } } } else if (channels.Length() > outputChannelCount) { - if (mMixingMode.mChannelInterpretation == ChannelInterpretation::Speakers) { + if (mChannelInterpretation == ChannelInterpretation::Speakers) { nsAutoTArray outputChannels; outputChannels.SetLength(outputChannelCount); downmixBuffer.SetLength(outputChannelCount * WEBAUDIO_BLOCK_SIZE); diff --git a/content/media/AudioNodeStream.h b/content/media/AudioNodeStream.h index 96120caf631..ac5e7781057 100644 --- a/content/media/AudioNodeStream.h +++ b/content/media/AudioNodeStream.h @@ -55,8 +55,8 @@ public: mMarkAsFinishedAfterThisBlock(false), mAudioParamStream(false) { - mMixingMode.mChannelCountMode = dom::ChannelCountMode::Max; - mMixingMode.mChannelInterpretation = dom::ChannelInterpretation::Speakers; + mChannelCountMode = dom::ChannelCountMode::Max; + mChannelInterpretation = dom::ChannelInterpretation::Speakers; // AudioNodes are always producing data mHasCurrentData = true; MOZ_COUNT_CTOR(AudioNodeStream); @@ -122,10 +122,8 @@ protected: // The number of input channels that this stream requires. 0 means don't care. uint32_t mNumberOfInputChannels; // The mixing modes - struct { - dom::ChannelCountMode mChannelCountMode : 16; - dom::ChannelInterpretation mChannelInterpretation : 16; - } mMixingMode; + dom::ChannelCountMode mChannelCountMode; + dom::ChannelInterpretation mChannelInterpretation; // Whether the stream should be marked as finished as soon // as the current time range has been computed block by block. bool mMarkAsFinishedAfterThisBlock; diff --git a/content/media/webaudio/PannerNode.cpp b/content/media/webaudio/PannerNode.cpp index 23c8767f260..7c5eeaf2ad2 100644 --- a/content/media/webaudio/PannerNode.cpp +++ b/content/media/webaudio/PannerNode.cpp @@ -36,9 +36,9 @@ public: explicit PannerNodeEngine(AudioNode* aNode) : AudioNodeEngine(aNode) // Please keep these default values consistent with PannerNode::PannerNode below. - , mPanningModel(PanningModelTypeValues::HRTF) + , mPanningModel(PanningModelType::HRTF) , mPanningModelFunction(&PannerNodeEngine::HRTFPanningFunction) - , mDistanceModel(DistanceModelTypeValues::Inverse) + , mDistanceModel(DistanceModelType::Inverse) , mDistanceModelFunction(&PannerNodeEngine::InverseGainFunction) , mPosition() , mOrientation(1., 0., 0.) @@ -62,10 +62,10 @@ public: case PannerNode::PANNING_MODEL: mPanningModel = PanningModelType(aParam); switch (mPanningModel) { - case PanningModelTypeValues::Equalpower: + case PanningModelType::Equalpower: mPanningModelFunction = &PannerNodeEngine::EqualPowerPanningFunction; break; - case PanningModelTypeValues::HRTF: + case PanningModelType::HRTF: mPanningModelFunction = &PannerNodeEngine::HRTFPanningFunction; break; } @@ -73,13 +73,13 @@ public: case PannerNode::DISTANCE_MODEL: mDistanceModel = DistanceModelType(aParam); switch (mDistanceModel) { - case DistanceModelTypeValues::Inverse: + case DistanceModelType::Inverse: mDistanceModelFunction = &PannerNodeEngine::InverseGainFunction; break; - case DistanceModelTypeValues::Linear: + case DistanceModelType::Linear: mDistanceModelFunction = &PannerNodeEngine::LinearGainFunction; break; - case DistanceModelTypeValues::Exponential: + case DistanceModelType::Exponential: mDistanceModelFunction = &PannerNodeEngine::ExponentialGainFunction; break; } @@ -175,8 +175,8 @@ PannerNode::PannerNode(AudioContext* aContext) ChannelCountMode::Clamped_max, ChannelInterpretation::Speakers) // Please keep these default values consistent with PannerNodeEngine::PannerNodeEngine above. - , mPanningModel(PanningModelTypeValues::HRTF) - , mDistanceModel(DistanceModelTypeValues::Inverse) + , mPanningModel(PanningModelType::HRTF) + , mDistanceModel(DistanceModelType::Inverse) , mPosition() , mOrientation(1., 0., 0.) , mVelocity() diff --git a/dom/base/DOMRequest.cpp b/dom/base/DOMRequest.cpp index 84bf6e1696c..7251b375f8a 100644 --- a/dom/base/DOMRequest.cpp +++ b/dom/base/DOMRequest.cpp @@ -87,10 +87,10 @@ DOMRequest::GetReadyState(nsAString& aReadyState) { DOMRequestReadyState readyState = ReadyState(); switch (readyState) { - case DOMRequestReadyStateValues::Pending: + case DOMRequestReadyState::Pending: aReadyState.AssignLiteral("pending"); break; - case DOMRequestReadyStateValues::Done: + case DOMRequestReadyState::Done: aReadyState.AssignLiteral("done"); break; default: diff --git a/dom/base/DOMRequest.h b/dom/base/DOMRequest.h index b069ca207c5..97e96875f50 100644 --- a/dom/base/DOMRequest.h +++ b/dom/base/DOMRequest.h @@ -47,8 +47,8 @@ public: // WebIDL Interface DOMRequestReadyState ReadyState() const { - return mDone ? DOMRequestReadyStateValues::Done - : DOMRequestReadyStateValues::Pending; + return mDone ? DOMRequestReadyState::Done + : DOMRequestReadyState::Pending; } JS::Value Result(JSContext* = nullptr) const diff --git a/dom/bindings/Codegen.py b/dom/bindings/Codegen.py index 646e2726476..a6c5b3219f8 100644 --- a/dom/bindings/Codegen.py +++ b/dom/bindings/Codegen.py @@ -22,6 +22,7 @@ CONSTRUCT_HOOK_NAME = '_constructor' LEGACYCALLER_HOOK_NAME = '_legacycaller' HASINSTANCE_HOOK_NAME = '_hasInstance' NEWRESOLVE_HOOK_NAME = '_newResolve' +ENUM_ENTRY_VARIABLE_NAME = 'strings' def replaceFileIfChanged(filename, newContents): """ @@ -3172,7 +3173,7 @@ for (uint32_t i = 0; i < length; ++i) { "%(handleInvalidEnumValueCode)s" " %(enumLoc)s = static_cast<%(enumtype)s>(index);\n" "}" % { "enumtype" : enumName, - "values" : enumName + "Values::strings", + "values" : enumName + "Values::" + ENUM_ENTRY_VARIABLE_NAME, "invalidEnumValueFatal" : toStringBool(invalidEnumValueFatal), "handleInvalidEnumValueCode" : handleInvalidEnumValueCode, "exceptionCode" : CGIndenter(exceptionCodeIndented).define(), @@ -3193,7 +3194,7 @@ for (uint32_t i = 0; i < length; ++i) { else: assert(defaultValue.type.tag() == IDLType.Tags.domstring) template = handleDefault(template, - ("%s = %sValues::%s" % + ("%s = %s::%s" % (enumLoc, enumName, getEnumValueName(defaultValue.value)))) return (template, CGGeneric(declType), None, isOptional) @@ -3803,7 +3804,7 @@ if (!returnArray) { %(exceptionCode)s } """ % { "result" : resultLoc, - "strings" : type.unroll().inner.identifier.name + "Values::strings", + "strings" : type.unroll().inner.identifier.name + "Values::" + ENUM_ENTRY_VARIABLE_NAME, "exceptionCode" : CGIndenter(exceptionCodeIndented).define() } + CGIndenter(CGGeneric(setValue("JS::StringValue(resultStr)"))).define() + "\n}") @@ -5372,24 +5373,35 @@ class CGEnum(CGThing): CGThing.__init__(self) self.enum = enum - def declare(self): - return """ - enum valuelist { - %s - }; + def stringsNamespace(self): + return self.enum.identifier.name + "Values" - extern const EnumEntry strings[%d]; -""" % (",\n ".join(map(getEnumValueName, self.enum.values())), - len(self.enum.values()) + 1) + def nEnumStrings(self): + return len(self.enum.values()) + 1 + + def declare(self): + enumName = self.enum.identifier.name + strings = CGNamespace(self.stringsNamespace(), + CGGeneric(declare="extern const EnumEntry %s[%d];\n" + % (ENUM_ENTRY_VARIABLE_NAME, self.nEnumStrings()))) + + return """ +MOZ_BEGIN_ENUM_CLASS(%s, uint32_t) + %s +MOZ_END_ENUM_CLASS(%s) + +""" % (enumName, ",\n ".join(map(getEnumValueName, self.enum.values())), + enumName) + strings.declare() def define(self): - return """ - const EnumEntry strings[%d] = { + strings = """ + const EnumEntry %s[%d] = { %s, { NULL, 0 } }; -""" % (len(self.enum.values()) + 1, +""" % (ENUM_ENTRY_VARIABLE_NAME, self.nEnumStrings(), ",\n ".join(['{"' + val + '", ' + str(len(val)) + '}' for val in self.enum.values()])) + return CGNamespace(self.stringsNamespace(), CGGeneric(define=strings)).define() def deps(self): return self.enum.getDeps() @@ -7878,14 +7890,7 @@ class CGBindingRoot(CGThing): traitsClasses = None # Do codegen for all the enums - def makeEnum(e): - return CGNamespace.build([e.identifier.name + "Values"], - CGEnum(e)) - def makeEnumTypedef(e): - return CGGeneric(declare=("typedef %sValues::valuelist %s;\n" % - (e.identifier.name, e.identifier.name))) - cgthings = [ fun(e) for e in config.getEnums(webIDLFile) - for fun in [makeEnum, makeEnumTypedef] ] + cgthings = [ CGEnum(e) for e in config.getEnums(webIDLFile) ] # Do codegen for all the dictionaries. We have to be a bit careful # here, because we have to generate these in order from least derived diff --git a/dom/file/FileHandle.cpp b/dom/file/FileHandle.cpp index 3e91a6f1786..e5ca6d96a54 100644 --- a/dom/file/FileHandle.cpp +++ b/dom/file/FileHandle.cpp @@ -86,14 +86,14 @@ FileHandle::Open(const nsAString& aMode, FileMode mode; if (aOptionalArgCount) { if (aMode.EqualsLiteral("readwrite")) { - mode = FileModeValues::Readwrite; + mode = FileMode::Readwrite; } else if (aMode.EqualsLiteral("readonly")) { - mode = FileModeValues::Readonly; + mode = FileMode::Readonly; } else { return NS_ERROR_TYPE_ERR; } } else { - mode = FileModeValues::Readonly; + mode = FileMode::Readonly; } ErrorResult rv; @@ -112,15 +112,15 @@ FileHandle::Open(FileMode aMode, ErrorResult& aError) return nullptr; } - MOZ_STATIC_ASSERT(static_cast(FileModeValues::Readonly) == + MOZ_STATIC_ASSERT(static_cast(FileMode::Readonly) == static_cast(LockedFile::READ_ONLY), "Enum values should match."); - MOZ_STATIC_ASSERT(static_cast(FileModeValues::Readwrite) == + MOZ_STATIC_ASSERT(static_cast(FileMode::Readwrite) == static_cast(LockedFile::READ_WRITE), "Enum values should match."); nsRefPtr lockedFile = - LockedFile::Create(this, static_cast(aMode)); + LockedFile::Create(this, LockedFile::Mode(static_cast(aMode))); if (!lockedFile) { aError.Throw(NS_ERROR_DOM_FILEHANDLE_UNKNOWN_ERR); return nullptr; diff --git a/dom/src/notification/Notification.cpp b/dom/src/notification/Notification.cpp index 2e22714f743..cb8f856d81e 100644 --- a/dom/src/notification/Notification.cpp +++ b/dom/src/notification/Notification.cpp @@ -36,7 +36,7 @@ public: NotificationPermissionRequest(nsIPrincipal* aPrincipal, nsPIDOMWindow* aWindow, NotificationPermissionCallback* aCallback) : mPrincipal(aPrincipal), mWindow(aWindow), - mPermission(NotificationPermissionValues::Default), + mPermission(NotificationPermission::Default), mCallback(aCallback) {} virtual ~NotificationPermissionRequest() {} @@ -111,19 +111,19 @@ NotificationPermissionRequest::Run() bool isFile; uri->SchemeIs("file", &isFile); if (isFile) { - mPermission = NotificationPermissionValues::Granted; + mPermission = NotificationPermission::Granted; } // Grant permission if pref'ed on. if (Preferences::GetBool("notification.prompt.testing", false)) { if (Preferences::GetBool("notification.prompt.testing.allow", true)) { - mPermission = NotificationPermissionValues::Granted; + mPermission = NotificationPermission::Granted; } else { - mPermission = NotificationPermissionValues::Denied; + mPermission = NotificationPermission::Denied; } } - if (mPermission != NotificationPermissionValues::Default) { + if (mPermission != NotificationPermission::Default) { return DispatchCallback(); } @@ -180,14 +180,14 @@ NotificationPermissionRequest::GetElement(nsIDOMElement** aElement) NS_IMETHODIMP NotificationPermissionRequest::Cancel() { - mPermission = NotificationPermissionValues::Denied; + mPermission = NotificationPermission::Denied; return DispatchCallback(); } NS_IMETHODIMP NotificationPermissionRequest::Allow() { - mPermission = NotificationPermissionValues::Granted; + mPermission = NotificationPermission::Granted; return DispatchCallback(); } @@ -320,7 +320,7 @@ Notification::ShowInternal() ErrorResult result; if (GetPermissionInternal(GetOwner(), result) != - NotificationPermissionValues::Granted || !alertService) { + NotificationPermission::Granted || !alertService) { // We do not have permission to show a notification or alert service // is not available. return DispatchTrustedEvent(NS_LITERAL_STRING("error")); @@ -396,7 +396,7 @@ Notification::GetPermissionInternal(nsISupports* aGlobal, ErrorResult& aRv) nsCOMPtr sop = do_QueryInterface(aGlobal); if (!sop) { aRv.Throw(NS_ERROR_UNEXPECTED); - return NotificationPermissionValues::Denied; + return NotificationPermission::Denied; } nsCOMPtr principal = sop->GetPrincipal(); @@ -406,15 +406,15 @@ Notification::GetPermissionInternal(nsISupports* aGlobal, ErrorResult& aRv) bool isFile; uri->SchemeIs("file", &isFile); if (isFile) { - return NotificationPermissionValues::Granted; + return NotificationPermission::Granted; } // We also allow notifications is they are pref'ed on. if (Preferences::GetBool("notification.prompt.testing", false)) { if (Preferences::GetBool("notification.prompt.testing.allow", true)) { - return NotificationPermissionValues::Granted; + return NotificationPermission::Granted; } else { - return NotificationPermissionValues::Denied; + return NotificationPermission::Denied; } } @@ -438,11 +438,11 @@ Notification::GetPermissionInternal(nsISupports* aGlobal, ErrorResult& aRv) // Convert the result to one of the enum types. switch (permission) { case nsIPermissionManager::ALLOW_ACTION: - return NotificationPermissionValues::Granted; + return NotificationPermission::Granted; case nsIPermissionManager::DENY_ACTION: - return NotificationPermissionValues::Denied; + return NotificationPermission::Denied; default: - return NotificationPermissionValues::Default; + return NotificationPermission::Default; } } diff --git a/dom/src/notification/Notification.h b/dom/src/notification/Notification.h index f588c9becb2..83842beb9db 100644 --- a/dom/src/notification/Notification.h +++ b/dom/src/notification/Notification.h @@ -63,9 +63,9 @@ protected: static const nsString DirectionToString(NotificationDirection aDirection) { switch (aDirection) { - case NotificationDirectionValues::Ltr: + case NotificationDirection::Ltr: return NS_LITERAL_STRING("ltr"); - case NotificationDirectionValues::Rtl: + case NotificationDirection::Rtl: return NS_LITERAL_STRING("rtl"); default: return NS_LITERAL_STRING("auto"); diff --git a/dom/workers/XMLHttpRequest.cpp b/dom/workers/XMLHttpRequest.cpp index 1912d989548..201b283a374 100644 --- a/dom/workers/XMLHttpRequest.cpp +++ b/dom/workers/XMLHttpRequest.cpp @@ -263,7 +263,7 @@ ConvertStringToResponseType(const nsAString& aString) } MOZ_NOT_REACHED("Don't know anything about this response type!"); - return _empty; + return XMLHttpRequestResponseType::_empty; } enum @@ -1404,7 +1404,7 @@ Proxy::HandleEvent(nsIDOMEvent* aEvent) XMLHttpRequest::XMLHttpRequest(JSContext* aCx, WorkerPrivate* aWorkerPrivate) : XMLHttpRequestEventTarget(aCx), mJSObject(NULL), mUpload(NULL), mWorkerPrivate(aWorkerPrivate), - mResponseType(XMLHttpRequestResponseTypeValues::Text), mTimeout(0), + mResponseType(XMLHttpRequestResponseType::Text), mTimeout(0), mJSObjectRooted(false), mBackgroundRequest(false), mWithCredentials(false), mCanceled(false), mMozAnon(false), mMozSystem(false) { @@ -2109,7 +2109,7 @@ XMLHttpRequest::SetResponseType(XMLHttpRequestResponseType aResponseType, // "document" is fine for the main thread but not for a worker. Short-circuit // that here. - if (aResponseType == XMLHttpRequestResponseTypeValues::Document) { + if (aResponseType == XMLHttpRequestResponseType::Document) { return; }