diff --git a/accessible/base/nsCoreUtils.cpp b/accessible/base/nsCoreUtils.cpp index 640a5af0b6..27d8b75657 100644 --- a/accessible/base/nsCoreUtils.cpp +++ b/accessible/base/nsCoreUtils.cpp @@ -140,7 +140,7 @@ nsCoreUtils::DispatchMouseEvent(EventMessage aMessage, int32_t aX, int32_t aY, event.mRefPoint = LayoutDeviceIntPoint(aX, aY); - event.clickCount = 1; + event.mClickCount = 1; event.button = WidgetMouseEvent::eLeftButton; event.mTime = PR_IntervalNow(); event.inputSource = nsIDOMMouseEvent::MOZ_SOURCE_UNKNOWN; diff --git a/browser/locales/en-US/chrome/browser/migration/migration.dtd b/browser/locales/en-US/chrome/browser/migration/migration.dtd index 90f4060fe0..b3a4acdcc7 100644 --- a/browser/locales/en-US/chrome/browser/migration/migration.dtd +++ b/browser/locales/en-US/chrome/browser/migration/migration.dtd @@ -10,6 +10,8 @@ + + diff --git a/chrome/RegistryMessageUtils.h b/chrome/RegistryMessageUtils.h index 2d2e7d276b..a9dc813314 100644 --- a/chrome/RegistryMessageUtils.h +++ b/chrome/RegistryMessageUtils.h @@ -78,7 +78,7 @@ struct ParamTraits WriteParam(aMsg, aParam.charset); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { nsCString spec, charset; if (ReadParam(aMsg, aIter, &spec) && @@ -105,7 +105,7 @@ struct ParamTraits WriteParam(aMsg, aParam.flags); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { nsCString package; SerializedURI contentBaseURI, localeBaseURI, skinBaseURI; @@ -147,7 +147,7 @@ struct ParamTraits WriteParam(aMsg, aParam.resolvedURI); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { nsCString scheme, path; SerializedURI resolvedURI; @@ -183,7 +183,7 @@ struct ParamTraits WriteParam(aMsg, aParam.overrideURI); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { SerializedURI originalURI; SerializedURI overrideURI; diff --git a/docshell/base/SerializedLoadContext.h b/docshell/base/SerializedLoadContext.h index 0d6426c314..00e251a719 100644 --- a/docshell/base/SerializedLoadContext.h +++ b/docshell/base/SerializedLoadContext.h @@ -76,7 +76,7 @@ struct ParamTraits WriteParam(aMsg, suffix); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { nsAutoCString suffix; if (!ReadParam(aMsg, aIter, &aResult->mIsNotNull) || diff --git a/dom/asmjscache/AsmJSCache.cpp b/dom/asmjscache/AsmJSCache.cpp index b6f5e28c3c..ebc9b46ffe 100644 --- a/dom/asmjscache/AsmJSCache.cpp +++ b/dom/asmjscache/AsmJSCache.cpp @@ -1848,7 +1848,7 @@ ParamTraits::Write(Message* aMsg, const paramType& aParam) } bool -ParamTraits::Read(const Message* aMsg, void** aIter, +ParamTraits::Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { for (unsigned i = 0; i < Metadata::kNumEntries; i++) { @@ -1887,7 +1887,7 @@ ParamTraits::Write(Message* aMsg, const paramType& aParam) } bool -ParamTraits::Read(const Message* aMsg, void** aIter, +ParamTraits::Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { return ReadParam(aMsg, aIter, &aResult->mSize) && diff --git a/dom/asmjscache/AsmJSCache.h b/dom/asmjscache/AsmJSCache.h index adca4e45b6..92bb7780a7 100644 --- a/dom/asmjscache/AsmJSCache.h +++ b/dom/asmjscache/AsmJSCache.h @@ -169,7 +169,7 @@ struct ParamTraits { typedef mozilla::dom::asmjscache::Metadata paramType; static void Write(Message* aMsg, const paramType& aParam); - static bool Read(const Message* aMsg, void** aIter, paramType* aResult); + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult); static void Log(const paramType& aParam, std::wstring* aLog); }; @@ -178,7 +178,7 @@ struct ParamTraits { typedef mozilla::dom::asmjscache::WriteParams paramType; static void Write(Message* aMsg, const paramType& aParam); - static bool Read(const Message* aMsg, void** aIter, paramType* aResult); + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult); static void Log(const paramType& aParam, std::wstring* aLog); }; diff --git a/dom/base/Element.cpp b/dom/base/Element.cpp index 4a34331c3e..83595153f2 100644 --- a/dom/base/Element.cpp +++ b/dom/base/Element.cpp @@ -2125,14 +2125,14 @@ Element::DispatchClickEvent(nsPresContext* aPresContext, uint16_t inputSource = 0; WidgetMouseEvent* sourceMouseEvent = aSourceEvent->AsMouseEvent(); if (sourceMouseEvent) { - clickCount = sourceMouseEvent->clickCount; + clickCount = sourceMouseEvent->mClickCount; pressure = sourceMouseEvent->pressure; inputSource = sourceMouseEvent->inputSource; } else if (aSourceEvent->mClass == eKeyboardEventClass) { inputSource = nsIDOMMouseEvent::MOZ_SOURCE_KEYBOARD; } event.pressure = pressure; - event.clickCount = clickCount; + event.mClickCount = clickCount; event.inputSource = inputSource; event.mModifiers = aSourceEvent->mModifiers; if (aExtraEventFlags) { @@ -3094,7 +3094,7 @@ Element::PostHandleEventForLinks(EventChainPostVisitor& aVisitor) case eKeyPress: { WidgetKeyboardEvent* keyEvent = aVisitor.mEvent->AsKeyboardEvent(); - if (keyEvent && keyEvent->keyCode == NS_VK_RETURN) { + if (keyEvent && keyEvent->mKeyCode == NS_VK_RETURN) { nsEventStatus status = nsEventStatus_eIgnore; rv = DispatchClickEvent(aVisitor.mPresContext, keyEvent, this, false, nullptr, &status); diff --git a/dom/base/TextInputProcessor.cpp b/dom/base/TextInputProcessor.cpp index 1e0144b56c..2a1a4ee12f 100644 --- a/dom/base/TextInputProcessor.cpp +++ b/dom/base/TextInputProcessor.cpp @@ -738,13 +738,13 @@ TextInputProcessor::PrepareKeyboardEventToDispatch( // If .location is initialized with specific value, using // KEY_KEEP_KEY_LOCATION_STANDARD must be a bug of the caller. // Let's throw an exception for notifying the developer of this bug. - if (NS_WARN_IF(aKeyboardEvent.location)) { + if (NS_WARN_IF(aKeyboardEvent.mLocation)) { return NS_ERROR_INVALID_ARG; } - } else if (!aKeyboardEvent.location) { - // If KeyboardEvent.location is 0, it may be uninitialized. If so, we - // should compute proper location value from its .code value. - aKeyboardEvent.location = + } else if (!aKeyboardEvent.mLocation) { + // If KeyboardEvent.mLocation is 0, it may be uninitialized. If so, we + // should compute proper mLocation value from its .code value. + aKeyboardEvent.mLocation = WidgetKeyboardEvent::ComputeLocationFromCodeValue( aKeyboardEvent.mCodeNameIndex); } @@ -753,16 +753,16 @@ TextInputProcessor::PrepareKeyboardEventToDispatch( // If .keyCode is initialized with specific value, using // KEY_KEEP_KEYCODE_ZERO must be a bug of the caller. Let's throw an // exception for notifying the developer of such bug. - if (NS_WARN_IF(aKeyboardEvent.keyCode)) { + if (NS_WARN_IF(aKeyboardEvent.mKeyCode)) { return NS_ERROR_INVALID_ARG; } - } else if (!aKeyboardEvent.keyCode && + } else if (!aKeyboardEvent.mKeyCode && aKeyboardEvent.mKeyNameIndex > KEY_NAME_INDEX_Unidentified && aKeyboardEvent.mKeyNameIndex < KEY_NAME_INDEX_USE_STRING) { // If KeyboardEvent.keyCode is 0, it may be uninitialized. If so, we may // be able to decide a good .keyCode value if the .key value is a // non-printable key. - aKeyboardEvent.keyCode = + aKeyboardEvent.mKeyCode = WidgetKeyboardEvent::ComputeKeyCodeFromKeyNameIndex( aKeyboardEvent.mKeyNameIndex); } diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp index 5f196a38f3..a186336251 100644 --- a/dom/base/nsContentUtils.cpp +++ b/dom/base/nsContentUtils.cpp @@ -7169,7 +7169,7 @@ nsContentUtils::GetHostOrIPv6WithBrackets(nsIURI* aURI, nsAString& aHost) return NS_OK; } -void +bool nsContentUtils::CallOnAllRemoteChildren(nsIMessageBroadcaster* aManager, CallOnRemoteChildFunction aCallback, void* aArg) @@ -7185,7 +7185,9 @@ nsContentUtils::CallOnAllRemoteChildren(nsIMessageBroadcaster* aManager, nsCOMPtr nonLeafMM = do_QueryInterface(childMM); if (nonLeafMM) { - CallOnAllRemoteChildren(nonLeafMM, aCallback, aArg); + if (CallOnAllRemoteChildren(nonLeafMM, aCallback, aArg)) { + return true; + } continue; } @@ -7197,10 +7199,14 @@ nsContentUtils::CallOnAllRemoteChildren(nsIMessageBroadcaster* aManager, nsFrameLoader* fl = static_cast(cb); TabParent* remote = TabParent::GetFrom(fl); if (remote && aCallback) { - aCallback(remote, aArg); + if (aCallback(remote, aArg)) { + return true; + } } } } + + return false; } void @@ -7687,11 +7693,11 @@ nsContentUtils::SendKeyEvent(nsIWidget* aWidget, event.mModifiers = GetWidgetModifiers(aModifiers); if (msg == eKeyPress) { - event.keyCode = aCharCode ? 0 : aKeyCode; - event.charCode = aCharCode; + event.mKeyCode = aCharCode ? 0 : aKeyCode; + event.mCharCode = aCharCode; } else { - event.keyCode = aKeyCode; - event.charCode = 0; + event.mKeyCode = aKeyCode; + event.mCharCode = 0; } uint32_t locationFlag = (aAdditionalFlags & @@ -7699,16 +7705,16 @@ nsContentUtils::SendKeyEvent(nsIWidget* aWidget, nsIDOMWindowUtils::KEY_FLAG_LOCATION_RIGHT | nsIDOMWindowUtils::KEY_FLAG_LOCATION_NUMPAD)); switch (locationFlag) { case nsIDOMWindowUtils::KEY_FLAG_LOCATION_STANDARD: - event.location = nsIDOMKeyEvent::DOM_KEY_LOCATION_STANDARD; + event.mLocation = nsIDOMKeyEvent::DOM_KEY_LOCATION_STANDARD; break; case nsIDOMWindowUtils::KEY_FLAG_LOCATION_LEFT: - event.location = nsIDOMKeyEvent::DOM_KEY_LOCATION_LEFT; + event.mLocation = nsIDOMKeyEvent::DOM_KEY_LOCATION_LEFT; break; case nsIDOMWindowUtils::KEY_FLAG_LOCATION_RIGHT: - event.location = nsIDOMKeyEvent::DOM_KEY_LOCATION_RIGHT; + event.mLocation = nsIDOMKeyEvent::DOM_KEY_LOCATION_RIGHT; break; case nsIDOMWindowUtils::KEY_FLAG_LOCATION_NUMPAD: - event.location = nsIDOMKeyEvent::DOM_KEY_LOCATION_NUMPAD; + event.mLocation = nsIDOMKeyEvent::DOM_KEY_LOCATION_NUMPAD; break; default: if (locationFlag != 0) { @@ -7732,16 +7738,16 @@ nsContentUtils::SendKeyEvent(nsIWidget* aWidget, case nsIDOMKeyEvent::DOM_VK_SUBTRACT: case nsIDOMKeyEvent::DOM_VK_DECIMAL: case nsIDOMKeyEvent::DOM_VK_DIVIDE: - event.location = nsIDOMKeyEvent::DOM_KEY_LOCATION_NUMPAD; + event.mLocation = nsIDOMKeyEvent::DOM_KEY_LOCATION_NUMPAD; break; case nsIDOMKeyEvent::DOM_VK_SHIFT: case nsIDOMKeyEvent::DOM_VK_CONTROL: case nsIDOMKeyEvent::DOM_VK_ALT: case nsIDOMKeyEvent::DOM_VK_META: - event.location = nsIDOMKeyEvent::DOM_KEY_LOCATION_LEFT; + event.mLocation = nsIDOMKeyEvent::DOM_KEY_LOCATION_LEFT; break; default: - event.location = nsIDOMKeyEvent::DOM_KEY_LOCATION_STANDARD; + event.mLocation = nsIDOMKeyEvent::DOM_KEY_LOCATION_STANDARD; break; } break; @@ -7821,7 +7827,7 @@ nsContentUtils::SendMouseEvent(nsCOMPtr aPresShell, event.buttons = GetButtonsFlagForButton(aButton); event.pressure = aPressure; event.inputSource = aInputSourceArg; - event.clickCount = aClickCount; + event.mClickCount = aClickCount; event.mTime = PR_IntervalNow(); event.mFlags.mIsSynthesizedForTests = aIsSynthesized; @@ -7830,7 +7836,7 @@ nsContentUtils::SendMouseEvent(nsCOMPtr aPresShell, return NS_ERROR_FAILURE; event.mRefPoint = ToWidgetPoint(CSSPoint(aX, aY), offset, presContext); - event.ignoreRootScrollFrame = aIgnoreRootScrollFrame; + event.mIgnoreRootScrollFrame = aIgnoreRootScrollFrame; nsEventStatus status = nsEventStatus_eIgnore; if (aToWindow) { diff --git a/dom/base/nsContentUtils.h b/dom/base/nsContentUtils.h index ed0c19577b..34b9c28db4 100644 --- a/dom/base/nsContentUtils.h +++ b/dom/base/nsContentUtils.h @@ -172,7 +172,7 @@ struct EventNameMapping mozilla::EventClassID mEventClassID; }; -typedef void (*CallOnRemoteChildFunction) (mozilla::dom::TabParent* aTabParent, +typedef bool (*CallOnRemoteChildFunction) (mozilla::dom::TabParent* aTabParent, void* aArg); class nsContentUtils @@ -2375,7 +2375,7 @@ public: /* * Call the given callback on all remote children of the given top-level - * window. + * window. Return true from the callback to stop calling further children. */ static void CallOnAllRemoteChildren(nsPIDOMWindowOuter* aWindow, CallOnRemoteChildFunction aCallback, @@ -2595,7 +2595,7 @@ private: static AutocompleteAttrState InternalSerializeAutocompleteAttribute(const nsAttrValue* aAttrVal, mozilla::dom::AutocompleteInfo& aInfo); - static void CallOnAllRemoteChildren(nsIMessageBroadcaster* aManager, + static bool CallOnAllRemoteChildren(nsIMessageBroadcaster* aManager, CallOnRemoteChildFunction aCallback, void* aArg); diff --git a/dom/base/nsDOMClassInfo.cpp b/dom/base/nsDOMClassInfo.cpp index 16d5749390..9dd5256b66 100644 --- a/dom/base/nsDOMClassInfo.cpp +++ b/dom/base/nsDOMClassInfo.cpp @@ -1772,98 +1772,6 @@ nsWindowSH::GlobalResolve(nsGlobalWindow *aWin, JSContext *cx, nsresult rv = NS_OK; - if (name_struct->mType == nsGlobalNameStruct::eTypeNewDOMBinding || - name_struct->mType == nsGlobalNameStruct::eTypeClassProto || - name_struct->mType == nsGlobalNameStruct::eTypeClassConstructor) { - // Lookup new DOM bindings. - DefineInterface getOrCreateInterfaceObject = - name_struct->mDefineDOMInterface; - if (getOrCreateInterfaceObject) { - if (name_struct->mType == nsGlobalNameStruct::eTypeClassConstructor && - !OldBindingConstructorEnabled(name_struct, aWin, cx)) { - return NS_OK; - } - - ConstructorEnabled* checkEnabledForScope = name_struct->mConstructorEnabled; - // We do the enabled check on the current compartment of cx, but for the - // actual object we pass in the underlying object in the Xray case. That - // way the callee can decide whether to allow access based on the caller - // or the window being touched. - JS::Rooted global(cx, - js::CheckedUnwrap(obj, /* stopAtWindowProxy = */ false)); - if (!global) { - return NS_ERROR_DOM_SECURITY_ERR; - } - if (checkEnabledForScope && !checkEnabledForScope(cx, global)) { - return NS_OK; - } - - // The DOM constructor resolve machinery interacts with Xrays in tricky - // ways, and there are some asymmetries that are important to understand. - // - // In the regular (non-Xray) case, we only want to resolve constructors - // once (so that if they're deleted, they don't reappear). We do this by - // stashing the constructor in a slot on the global, such that we can see - // during resolve whether we've created it already. This is rather - // memory-intensive, so we don't try to maintain these semantics when - // manipulating a global over Xray (so the properties just re-resolve if - // they've been deleted). - // - // Unfortunately, there's a bit of an impedance-mismatch between the Xray - // and non-Xray machinery. The Xray machinery wants an API that returns a - // JS::PropertyDescriptor, so that the resolve hook doesn't have to get - // snared up with trying to define a property on the Xray holder. At the - // same time, the DefineInterface callbacks are set up to define things - // directly on the global. And re-jiggering them to return property - // descriptors is tricky, because some DefineInterface callbacks define - // multiple things (like the Image() alias for HTMLImageElement). - // - // So the setup is as-follows: - // - // * The resolve function takes a JS::PropertyDescriptor, but in the - // non-Xray case, callees may define things directly on the global, and - // set the value on the property descriptor to |undefined| to indicate - // that there's nothing more for the caller to do. We assert against - // this behavior in the Xray case. - // - // * We make sure that we do a non-Xray resolve first, so that all the - // slots are set up. In the Xray case, this means unwrapping and doing - // a non-Xray resolve before doing the Xray resolve. - // - // This all could use some grand refactoring, but for now we just limp - // along. - if (xpc::WrapperFactory::IsXrayWrapper(obj)) { - JS::Rooted interfaceObject(cx); - { - JSAutoCompartment ac(cx, global); - interfaceObject = getOrCreateInterfaceObject(cx, global, id, false); - } - if (NS_WARN_IF(!interfaceObject)) { - return NS_ERROR_FAILURE; - } - if (!JS_WrapObject(cx, &interfaceObject)) { - return NS_ERROR_FAILURE; - } - - FillPropertyDescriptor(desc, obj, 0, JS::ObjectValue(*interfaceObject)); - } else { - JS::Rooted interfaceObject(cx, - getOrCreateInterfaceObject(cx, obj, id, true)); - if (NS_WARN_IF(!interfaceObject)) { - return NS_ERROR_FAILURE; - } - // We've already defined the property. We indicate this to the caller - // by filling a property descriptor with JS::UndefinedValue() as the - // value. We still have to fill in a property descriptor, though, so - // that the caller knows the property is in fact on this object. It - // doesn't matter what we pass for the "readonly" argument here. - FillPropertyDescriptor(desc, obj, JS::UndefinedValue(), false); - } - - return NS_OK; - } - } - if (name_struct->mType == nsGlobalNameStruct::eTypeClassConstructor) { if (!OldBindingConstructorEnabled(name_struct, aWin, cx)) { return NS_OK; diff --git a/dom/base/nsDOMWindowUtils.cpp b/dom/base/nsDOMWindowUtils.cpp index ba86e3f42f..6b11a555a7 100644 --- a/dom/base/nsDOMWindowUtils.cpp +++ b/dom/base/nsDOMWindowUtils.cpp @@ -683,7 +683,7 @@ nsDOMWindowUtils::SendPointerEventCommon(const nsAString& aType, event.tiltX = aTiltX; event.tiltY = aTiltY; event.isPrimary = (nsIDOMMouseEvent::MOZ_SOURCE_MOUSE == aInputSourceArg) ? true : aIsPrimary; - event.clickCount = aClickCount; + event.mClickCount = aClickCount; event.mTime = PR_IntervalNow(); event.mFlags.mIsSynthesizedForTests = aOptionalArgCount >= 10 ? aIsSynthesized : true; @@ -694,7 +694,7 @@ nsDOMWindowUtils::SendPointerEventCommon(const nsAString& aType, event.mRefPoint = nsContentUtils::ToWidgetPoint(CSSPoint(aX, aY), offset, presContext); - event.ignoreRootScrollFrame = aIgnoreRootScrollFrame; + event.mIgnoreRootScrollFrame = aIgnoreRootScrollFrame; nsEventStatus status; if (aToWindow) { diff --git a/dom/base/nsFocusManager.cpp b/dom/base/nsFocusManager.cpp index 31d1a60b52..bf0f50ace0 100644 --- a/dom/base/nsFocusManager.cpp +++ b/dom/base/nsFocusManager.cpp @@ -1110,11 +1110,12 @@ nsFocusManager::EnsureCurrentWidgetFocused() } } -void +bool ActivateOrDeactivateChild(TabParent* aParent, void* aArg) { bool active = static_cast(aArg); Unused << aParent->SendParentActivated(active); + return false; } void diff --git a/dom/base/nsGkAtomList.h b/dom/base/nsGkAtomList.h index 365c0b93eb..cbbaee44f4 100644 --- a/dom/base/nsGkAtomList.h +++ b/dom/base/nsGkAtomList.h @@ -680,6 +680,7 @@ GK_ATOM(ol, "ol") GK_ATOM(omitXmlDeclaration, "omit-xml-declaration") GK_ATOM(ona2dpstatuschanged, "ona2dpstatuschanged") GK_ATOM(onabort, "onabort") +GK_ATOM(onmozaccesskeynotfound, "onmozaccesskeynotfound") GK_ATOM(onactivate, "onactivate") GK_ATOM(onadapteradded, "onadapteradded") GK_ATOM(onadapterremoved, "onadapterremoved") diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index 317b40b102..38ec30adcd 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -230,6 +230,7 @@ #include "mozilla/dom/ImageBitmap.h" #include "mozilla/dom/ServiceWorkerRegistration.h" #include "mozilla/dom/U2F.h" +#include "mozilla/dom/WebIDLGlobalNameHash.h" #ifdef HAVE_SIDEBAR #include "mozilla/dom/ExternalBinding.h" #endif @@ -4496,6 +4497,15 @@ nsGlobalWindow::DoResolve(JSContext* aCx, JS::Handle aObj, return true; } + bool found; + if (!WebIDLGlobalNameHash::DefineIfEnabled(aCx, aObj, aId, aDesc, &found)) { + return false; + } + + if (found) { + return true; + } + nsresult rv = nsWindowSH::GlobalResolve(this, aCx, aObj, aId, aDesc); if (NS_FAILED(rv)) { return Throw(aCx, rv); @@ -4524,6 +4534,10 @@ nsGlobalWindow::MayResolve(jsid aId) return true; } + if (WebIDLGlobalNameHash::MayResolve(aId)) { + return true; + } + nsScriptNameSpaceManager *nameSpaceManager = PeekNameSpaceManager(); if (!nameSpaceManager) { // Really shouldn't happen. Fail safe. @@ -4547,12 +4561,13 @@ nsGlobalWindow::GetOwnPropertyNames(JSContext* aCx, nsTArray& aNames, nsScriptNameSpaceManager* nameSpaceManager = GetNameSpaceManager(); if (nameSpaceManager) { JS::Rooted wrapper(aCx, GetWrapper()); + + WebIDLGlobalNameHash::GetNames(aCx, wrapper, aNames); + for (auto i = nameSpaceManager->GlobalNameIter(); !i.Done(); i.Next()) { const GlobalNameMapEntry* entry = i.Get(); if (nsWindowSH::NameStructEnabled(aCx, this, entry->mKey, - entry->mGlobalName) && - (!entry->mGlobalName.mConstructorEnabled || - entry->mGlobalName.mConstructorEnabled(aCx, wrapper))) { + entry->mGlobalName)) { aNames.AppendElement(entry->mKey); } } diff --git a/dom/base/nsScriptNameSpaceManager.cpp b/dom/base/nsScriptNameSpaceManager.cpp index 13fc938921..28765d38d6 100644 --- a/dom/base/nsScriptNameSpaceManager.cpp +++ b/dom/base/nsScriptNameSpaceManager.cpp @@ -25,7 +25,8 @@ #include "nsCRT.h" #include "nsIObserverService.h" #include "nsISimpleEnumerator.h" - +#include "mozilla/dom/BindingUtils.h" +#include "mozilla/dom/WebIDLGlobalNameHash.h" #include "mozilla/MemoryReporting.h" #include "mozilla/Preferences.h" #include "mozilla/Services.h" @@ -34,6 +35,7 @@ #define NS_DOM_INTERFACE_PREFIX "nsIDOM" using namespace mozilla; +using namespace mozilla::dom; static PLDHashNumber GlobalNameHashHashKey(const void *key) @@ -95,7 +97,7 @@ static const PLDHashTableOps hash_table_ops = GlobalNameHashInitEntry }; -#define GLOBALNAME_HASHTABLE_INITIAL_LENGTH 512 +#define GLOBALNAME_HASHTABLE_INITIAL_LENGTH 32 nsScriptNameSpaceManager::nsScriptNameSpaceManager() : mGlobalNames(&hash_table_ops, sizeof(GlobalNameMapEntry), @@ -111,14 +113,17 @@ nsScriptNameSpaceManager::~nsScriptNameSpaceManager() } nsGlobalNameStruct * -nsScriptNameSpaceManager::AddToHash(const nsAString *aKey, +nsScriptNameSpaceManager::AddToHash(const char *aKey, const char16_t **aClassName) { - auto entry = static_cast(mGlobalNames.Add(aKey, fallible)); + NS_ConvertASCIItoUTF16 key(aKey); + auto entry = static_cast(mGlobalNames.Add(&key, fallible)); if (!entry) { return nullptr; } + WebIDLGlobalNameHash::Remove(aKey, key.Length()); + if (aClassName) { *aClassName = entry->mKey.get(); } @@ -230,8 +235,7 @@ nsScriptNameSpaceManager::RegisterClassName(const char *aClassName, return NS_OK; } - NS_ASSERTION(s->mType == nsGlobalNameStruct::eTypeNotInitialized || - s->mType == nsGlobalNameStruct::eTypeNewDOMBinding, + NS_ASSERTION(s->mType == nsGlobalNameStruct::eTypeNotInitialized, "Whaaa, JS environment name clash!"); s->mType = nsGlobalNameStruct::eTypeClassConstructor; @@ -254,8 +258,7 @@ nsScriptNameSpaceManager::RegisterClassProto(const char *aClassName, nsGlobalNameStruct *s = AddToHash(aClassName); NS_ENSURE_TRUE(s, NS_ERROR_OUT_OF_MEMORY); - if (s->mType != nsGlobalNameStruct::eTypeNotInitialized && - s->mType != nsGlobalNameStruct::eTypeNewDOMBinding) { + if (s->mType != nsGlobalNameStruct::eTypeNotInitialized) { *aFoundOld = true; return NS_OK; @@ -349,8 +352,7 @@ nsScriptNameSpaceManager::OperateCategoryEntryHash(nsICategoryManager* aCategory nsGlobalNameStruct *s = AddToHash(categoryEntry.get()); NS_ENSURE_TRUE(s, NS_ERROR_OUT_OF_MEMORY); - if (s->mType == nsGlobalNameStruct::eTypeNotInitialized || - s->mType == nsGlobalNameStruct::eTypeNewDOMBinding) { + if (s->mType == nsGlobalNameStruct::eTypeNotInitialized) { s->mType = type; s->mCID = cid; s->mChromeOnly = @@ -414,21 +416,6 @@ nsScriptNameSpaceManager::Observe(nsISupports* aSubject, const char* aTopic, return NS_OK; } -void -nsScriptNameSpaceManager::RegisterDefineDOMInterface(const nsAFlatString& aName, - mozilla::dom::DefineInterface aDefineDOMInterface, - mozilla::dom::ConstructorEnabled* aConstructorEnabled) -{ - nsGlobalNameStruct *s = AddToHash(&aName); - if (s) { - if (s->mType == nsGlobalNameStruct::eTypeNotInitialized) { - s->mType = nsGlobalNameStruct::eTypeNewDOMBinding; - } - s->mDefineDOMInterface = aDefineDOMInterface; - s->mConstructorEnabled = aConstructorEnabled; - } -} - MOZ_DEFINE_MALLOC_SIZE_OF(ScriptNameSpaceManagerMallocSizeOf) NS_IMETHODIMP diff --git a/dom/base/nsScriptNameSpaceManager.h b/dom/base/nsScriptNameSpaceManager.h index 139081067f..3817e2c9c7 100644 --- a/dom/base/nsScriptNameSpaceManager.h +++ b/dom/base/nsScriptNameSpaceManager.h @@ -33,35 +33,24 @@ #include "nsWeakReference.h" #include "xpcpublic.h" - struct nsGlobalNameStruct { enum nametype { eTypeNotInitialized, - eTypeNewDOMBinding, eTypeProperty, eTypeExternalConstructor, eTypeClassConstructor, eTypeClassProto, } mType; - // mChromeOnly is only used for structs that define non-WebIDL things - // (possibly in addition to WebIDL ones). In particular, it's not even - // initialized for eTypeNewDOMBinding structs. bool mChromeOnly : 1; bool mAllowXBL : 1; union { int32_t mDOMClassInfoID; // eTypeClassConstructor nsIID mIID; // eTypeClassProto - nsCID mCID; // All other types except eTypeNewDOMBinding + nsCID mCID; // All other types }; - - // For new style DOM bindings. - mozilla::dom::DefineInterface mDefineDOMInterface; - - // May be null if enabled unconditionally - mozilla::dom::ConstructorEnabled* mConstructorEnabled; }; class GlobalNameMapEntry : public PLDHashEntryHdr @@ -112,19 +101,6 @@ public: const nsIID *aConstructorProtoIID, bool *aFoundOld); - void RegisterDefineDOMInterface(const nsAFlatString& aName, - mozilla::dom::DefineInterface aDefineDOMInterface, - mozilla::dom::ConstructorEnabled* aConstructorEnabled); - template - void RegisterDefineDOMInterface(const char16_t (&aKey)[N], - mozilla::dom::DefineInterface aDefineDOMInterface, - mozilla::dom::ConstructorEnabled* aConstructorEnabled) - { - nsLiteralString key(aKey); - return RegisterDefineDOMInterface(key, aDefineDOMInterface, - aConstructorEnabled); - } - class NameIterator : public PLDHashTable::Iterator { public: @@ -155,22 +131,14 @@ private: // that aKey will be mapped to. If mType in the returned // nsGlobalNameStruct is != eTypeNotInitialized, an entry for aKey // already existed. - nsGlobalNameStruct *AddToHash(const nsAString *aKey, - const char16_t **aClassName = nullptr); nsGlobalNameStruct *AddToHash(const char *aKey, - const char16_t **aClassName = nullptr) - { - NS_ConvertASCIItoUTF16 key(aKey); - return AddToHash(&key, aClassName); - } + const char16_t **aClassName = nullptr); + // Removes an existing entry from the hash. void RemoveFromHash(const nsAString *aKey); nsresult FillHash(nsICategoryManager *aCategoryManager, const char *aCategory); - nsresult RegisterInterface(const char* aIfName, - const nsIID *aIfIID, - bool* aFoundOld); /** * Add a new category entry into the hash table. diff --git a/dom/bindings/BindingUtils.cpp b/dom/bindings/BindingUtils.cpp index fe83ffe9cc..237e736820 100644 --- a/dom/bindings/BindingUtils.cpp +++ b/dom/bindings/BindingUtils.cpp @@ -45,6 +45,7 @@ #include "mozilla/dom/HTMLAppletElementBinding.h" #include "mozilla/dom/Promise.h" #include "mozilla/dom/ResolveSystemBinding.h" +#include "mozilla/dom/WebIDLGlobalNameHash.h" #include "mozilla/dom/WorkerPrivate.h" #include "mozilla/dom/WorkerScope.h" #include "mozilla/jsipc/CrossProcessObjectWrappers.h" @@ -172,7 +173,7 @@ ErrorResult::SerializeMessage(IPC::Message* aMsg) const } bool -ErrorResult::DeserializeMessage(const IPC::Message* aMsg, void** aIter) +ErrorResult::DeserializeMessage(const IPC::Message* aMsg, PickleIterator* aIter) { using namespace IPC; nsAutoPtr readMessage(new Message()); @@ -294,7 +295,7 @@ ErrorResult::SerializeDOMExceptionInfo(IPC::Message* aMsg) const } bool -ErrorResult::DeserializeDOMExceptionInfo(const IPC::Message* aMsg, void** aIter) +ErrorResult::DeserializeDOMExceptionInfo(const IPC::Message* aMsg, PickleIterator* aIter) { using namespace IPC; nsCString message; @@ -2936,20 +2937,15 @@ RegisterDOMNames() return NS_OK; } + // Register new DOM bindings + WebIDLGlobalNameHash::Init(); + nsresult rv = nsDOMClassInfo::Init(); if (NS_FAILED(rv)) { NS_ERROR("Could not initialize nsDOMClassInfo"); return rv; } - // Register new DOM bindings - nsScriptNameSpaceManager* nameSpaceManager = GetNameSpaceManager(); - if (!nameSpaceManager) { - NS_ERROR("Could not initialize nsScriptNameSpaceManager"); - return NS_ERROR_FAILURE; - } - mozilla::dom::Register(nameSpaceManager); - sRegisteredDOMNames = true; return NS_OK; diff --git a/dom/bindings/Codegen.py b/dom/bindings/Codegen.py index 2f2ae4f7ff..4891ae9c22 100644 --- a/dom/bindings/Codegen.py +++ b/dom/bindings/Codegen.py @@ -12056,14 +12056,14 @@ class CGDescriptor(CGThing): if descriptor.interface.hasInterfacePrototypeObject(): cgThings.append(CGPrototypeJSClass(descriptor, properties)) - if descriptor.interface.hasInterfaceObject(): - cgThings.append(CGDefineDOMInterfaceMethod(descriptor)) - if ((descriptor.interface.hasInterfaceObject() or descriptor.interface.isNavigatorProperty()) and not descriptor.interface.isExternal() and descriptor.isExposedConditionally()): cgThings.append(CGConstructorEnabled(descriptor)) + if descriptor.registersGlobalNamesOnWindow: + cgThings.append(CGDefineDOMInterfaceMethod(descriptor)) + if (descriptor.interface.hasMembersInSlots() and descriptor.interface.hasChildInterfaces()): raise TypeError("We don't support members in slots on " @@ -13056,48 +13056,53 @@ class CGResolveSystemBinding(CGAbstractMethod): "\n").define() -class CGRegisterProtos(CGAbstractMethod): +def getGlobalNames(config): + names = [] + for desc in config.getDescriptors(registersGlobalNamesOnWindow=True): + names.append((desc.name, desc)) + names.extend((n.identifier.name, desc) for n in desc.interface.namedConstructors) + return names + +class CGGlobalNamesString(CGGeneric): def __init__(self, config): - CGAbstractMethod.__init__(self, None, 'Register', 'void', - [Argument('nsScriptNameSpaceManager*', 'aNameSpaceManager')]) + globalNames = getGlobalNames(config) + currentOffset = 0 + strings = [] + for (name, _) in globalNames: + strings.append('/* %i */ "%s\\0"' % (currentOffset, name)) + currentOffset += len(name) + 1 # Add trailing null. + define = fill(""" + const uint32_t WebIDLGlobalNameHash::sCount = ${count}; + + const char WebIDLGlobalNameHash::sNames[] = + $*{strings} + + """, + count=len(globalNames), + strings="\n".join(strings) + ";\n") + + CGGeneric.__init__(self, define=define) + + +class CGRegisterGlobalNames(CGAbstractMethod): + def __init__(self, config): + CGAbstractMethod.__init__(self, None, 'RegisterWebIDLGlobalNames', + 'void', []) self.config = config - def _defineMacro(self): - return dedent(""" - #define REGISTER_PROTO(_dom_class, _ctor_check) \\ - aNameSpaceManager->RegisterDefineDOMInterface(MOZ_UTF16(#_dom_class), _dom_class##Binding::DefineDOMInterface, _ctor_check); - #define REGISTER_CONSTRUCTOR(_dom_constructor, _dom_class, _ctor_check) \\ - aNameSpaceManager->RegisterDefineDOMInterface(MOZ_UTF16(#_dom_constructor), _dom_class##Binding::DefineDOMInterface, _ctor_check); - """) - - def _undefineMacro(self): - return dedent(""" - #undef REGISTER_CONSTRUCTOR - #undef REGISTER_PROTO - """) - - def _registerProtos(self): + def definition_body(self): def getCheck(desc): if not desc.isExposedConditionally(): return "nullptr" return "%sBinding::ConstructorEnabled" % desc.name - lines = [] - for desc in self.config.getDescriptors(hasInterfaceObject=True, - isExternal=False, - workers=False, - isExposedInWindow=True, - register=True): - lines.append("REGISTER_PROTO(%s, %s);\n" % (desc.name, getCheck(desc))) - lines.extend("REGISTER_CONSTRUCTOR(%s, %s, %s);\n" % (n.identifier.name, desc.name, getCheck(desc)) - for n in desc.interface.namedConstructors) - return ''.join(lines) - def indent_body(self, body): - # Don't indent the body of this method, as it's all preprocessor gunk. - return body - - def definition_body(self): - return "\n" + self._defineMacro() + "\n" + self._registerProtos() + "\n" + self._undefineMacro() + define = "" + currentOffset = 0 + for (name, desc) in getGlobalNames(self.config): + length = len(name) + define += "WebIDLGlobalNameHash::Register(%i, %i, %sBinding::DefineDOMInterface, %s);\n" % (currentOffset, length, desc.name, getCheck(desc)) + currentOffset += length + 1 # Add trailing null. + return define def dependencySortObjects(objects, dependencyGetter, nameGetter): @@ -16194,7 +16199,7 @@ class GlobalGenRoots(): @staticmethod def RegisterBindings(config): - curr = CGRegisterProtos(config) + curr = CGList([CGGlobalNamesString(config), CGRegisterGlobalNames(config)]) # Wrap all of that in our namespaces. curr = CGNamespace.build(['mozilla', 'dom'], @@ -16207,7 +16212,7 @@ class GlobalGenRoots(): workers=False, isExposedInWindow=True, register=True)] - defineIncludes.append('nsScriptNameSpaceManager.h') + defineIncludes.append('mozilla/dom/WebIDLGlobalNameHash.h') defineIncludes.extend([CGHeaders.getDeclarationFilename(desc.interface) for desc in config.getDescriptors(isNavigatorProperty=True, workers=False, diff --git a/dom/bindings/Configuration.py b/dom/bindings/Configuration.py index b52167deef..e2c504479f 100644 --- a/dom/bindings/Configuration.py +++ b/dom/bindings/Configuration.py @@ -824,6 +824,14 @@ class Descriptor(DescriptorProvider): iface = iface.parent return True + @property + def registersGlobalNamesOnWindow(self): + return (not self.interface.isExternal() and + self.interface.hasInterfaceObject() and + not self.workers and + self.interface.isExposedInWindow() and + self.register) + # Some utility methods def getTypesFromDescriptor(descriptor): diff --git a/dom/bindings/ErrorIPCUtils.h b/dom/bindings/ErrorIPCUtils.h index 6e680a1bfa..0e60d8174b 100644 --- a/dom/bindings/ErrorIPCUtils.h +++ b/dom/bindings/ErrorIPCUtils.h @@ -50,7 +50,7 @@ struct ParamTraits } } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { paramType readValue; if (!ReadParam(aMsg, aIter, &readValue.mResult)) { diff --git a/dom/bindings/ErrorResult.h b/dom/bindings/ErrorResult.h index 41d8863db3..e8bf05ed88 100644 --- a/dom/bindings/ErrorResult.h +++ b/dom/bindings/ErrorResult.h @@ -36,6 +36,7 @@ namespace IPC { class Message; template struct ParamTraits; } // namespace IPC +class PickleIterator; namespace mozilla { @@ -307,10 +308,10 @@ private: friend struct IPC::ParamTraits; void SerializeMessage(IPC::Message* aMsg) const; - bool DeserializeMessage(const IPC::Message* aMsg, void** aIter); + bool DeserializeMessage(const IPC::Message* aMsg, PickleIterator* aIter); void SerializeDOMExceptionInfo(IPC::Message* aMsg) const; - bool DeserializeDOMExceptionInfo(const IPC::Message* aMsg, void** aIter); + bool DeserializeDOMExceptionInfo(const IPC::Message* aMsg, PickleIterator* aIter); // Helper method that creates a new Message for this ErrorResult, // and returns the arguments array from that Message. diff --git a/dom/bindings/WebIDLGlobalNameHash.cpp b/dom/bindings/WebIDLGlobalNameHash.cpp new file mode 100644 index 0000000000..2c69f28e0f --- /dev/null +++ b/dom/bindings/WebIDLGlobalNameHash.cpp @@ -0,0 +1,313 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "WebIDLGlobalNameHash.h" +#include "js/GCAPI.h" +#include "mozilla/HashFunctions.h" +#include "mozilla/Maybe.h" +#include "mozilla/dom/DOMJSProxyHandler.h" +#include "mozilla/dom/RegisterBindings.h" +#include "nsIMemoryReporter.h" +#include "nsTHashtable.h" + +namespace mozilla { +namespace dom { + +struct MOZ_STACK_CLASS WebIDLNameTableKey +{ + explicit WebIDLNameTableKey(JSFlatString* aJSString) + : mLength(js::GetFlatStringLength(aJSString)) + { + mNogc.emplace(); + JSLinearString* jsString = js::FlatStringToLinearString(aJSString); + if (js::LinearStringHasLatin1Chars(jsString)) { + mLatin1String = reinterpret_cast( + js::GetLatin1LinearStringChars(*mNogc, jsString)); + mTwoBytesString = nullptr; + mHash = mLatin1String ? HashString(mLatin1String, mLength) : 0; + } else { + mLatin1String = nullptr; + mTwoBytesString = js::GetTwoByteLinearStringChars(*mNogc, jsString); + mHash = mTwoBytesString ? HashString(mTwoBytesString, mLength) : 0; + } + } + explicit WebIDLNameTableKey(const char* aString, size_t aLength) + : mLatin1String(aString), + mTwoBytesString(nullptr), + mLength(aLength), + mHash(HashString(aString, aLength)) + { + MOZ_ASSERT(aString[aLength] == '\0'); + } + + Maybe mNogc; + const char* mLatin1String; + const char16_t* mTwoBytesString; + size_t mLength; + uint32_t mHash; +}; + +struct WebIDLNameTableEntry : public PLDHashEntryHdr +{ + typedef const WebIDLNameTableKey& KeyType; + typedef const WebIDLNameTableKey* KeyTypePointer; + + explicit WebIDLNameTableEntry(KeyTypePointer aKey) + {} + WebIDLNameTableEntry(WebIDLNameTableEntry&& aEntry) + : mNameOffset(aEntry.mNameOffset), + mNameLength(aEntry.mNameLength), + mDefine(aEntry.mDefine), + mEnabled(aEntry.mEnabled) + {} + ~WebIDLNameTableEntry() + {} + + bool KeyEquals(KeyTypePointer aKey) const + { + if (mNameLength != aKey->mLength) { + return false; + } + + const char* name = WebIDLGlobalNameHash::sNames + mNameOffset; + + if (aKey->mLatin1String) { + return PodEqual(aKey->mLatin1String, name, aKey->mLength); + } + + return nsCharTraits::compareASCII(aKey->mTwoBytesString, name, + aKey->mLength) == 0; + } + + static KeyTypePointer KeyToPointer(KeyType aKey) + { + return &aKey; + } + + static PLDHashNumber HashKey(KeyTypePointer aKey) + { + return aKey->mHash; + } + + enum { ALLOW_MEMMOVE = true }; + + uint16_t mNameOffset; + uint16_t mNameLength; + WebIDLGlobalNameHash::DefineGlobalName mDefine; + // May be null if enabled unconditionally + WebIDLGlobalNameHash::ConstructorEnabled* mEnabled; +}; + +static nsTHashtable* sWebIDLGlobalNames; + +class WebIDLGlobalNamesHashReporter final : public nsIMemoryReporter +{ + MOZ_DEFINE_MALLOC_SIZE_OF(MallocSizeOf) + + ~WebIDLGlobalNamesHashReporter() {} + +public: + NS_DECL_ISUPPORTS + + NS_IMETHOD CollectReports(nsIHandleReportCallback* aHandleReport, + nsISupports* aData, bool aAnonymize) override + { + int64_t amount = + sWebIDLGlobalNames ? + sWebIDLGlobalNames->ShallowSizeOfIncludingThis(MallocSizeOf) : 0; + + return MOZ_COLLECT_REPORT("explicit/dom/webidl-globalnames", KIND_HEAP, + UNITS_BYTES, amount, + "Memory used by the hash table for WebIDL's " + "global names."); + } +}; + +NS_IMPL_ISUPPORTS(WebIDLGlobalNamesHashReporter, nsIMemoryReporter) + +/* static */ +void +WebIDLGlobalNameHash::Init() +{ + sWebIDLGlobalNames = new nsTHashtable(sCount); + RegisterWebIDLGlobalNames(); + + RegisterStrongMemoryReporter(new WebIDLGlobalNamesHashReporter()); +} + +/* static */ +void +WebIDLGlobalNameHash::Shutdown() +{ + delete sWebIDLGlobalNames; +} + +/* static */ +void +WebIDLGlobalNameHash::Register(uint16_t aNameOffset, uint16_t aNameLength, + DefineGlobalName aDefine, + ConstructorEnabled* aEnabled) +{ + const char* name = sNames + aNameOffset; + WebIDLNameTableKey key(name, aNameLength); + WebIDLNameTableEntry* entry = sWebIDLGlobalNames->PutEntry(key); + entry->mNameOffset = aNameOffset; + entry->mNameLength = aNameLength; + entry->mDefine = aDefine; + entry->mEnabled = aEnabled; +} + +/* static */ +void +WebIDLGlobalNameHash::Remove(const char* aName, uint32_t aLength) +{ + WebIDLNameTableKey key(aName, aLength); + sWebIDLGlobalNames->RemoveEntry(key); +} + +/* static */ +bool +WebIDLGlobalNameHash::DefineIfEnabled(JSContext* aCx, + JS::Handle aObj, + JS::Handle aId, + JS::MutableHandle aDesc, + bool* aFound) +{ + MOZ_ASSERT(JSID_IS_STRING(aId), "Check for string id before calling this!"); + + const WebIDLNameTableEntry* entry; + { + WebIDLNameTableKey key(JSID_TO_FLAT_STRING(aId)); + // Rooting analysis thinks nsTHashtable<...>::GetEntry may GC because it + // ends up calling through PLDHashTableOps' matchEntry function pointer, but + // we know WebIDLNameTableEntry::KeyEquals can't cause a GC. + JS::AutoSuppressGCAnalysis suppress; + entry = sWebIDLGlobalNames->GetEntry(key); + } + + if (!entry) { + *aFound = false; + return true; + } + + *aFound = true; + + ConstructorEnabled* checkEnabledForScope = entry->mEnabled; + // We do the enabled check on the current compartment of aCx, but for the + // actual object we pass in the underlying object in the Xray case. That + // way the callee can decide whether to allow access based on the caller + // or the window being touched. + JS::Rooted global(aCx, + js::CheckedUnwrap(aObj, /* stopAtWindowProxy = */ false)); + if (!global) { + return Throw(aCx, NS_ERROR_DOM_SECURITY_ERR); + } + + { + DebugOnly win; + MOZ_ASSERT(NS_SUCCEEDED(UNWRAP_OBJECT(Window, global, win))); + } + + if (checkEnabledForScope && !checkEnabledForScope(aCx, global)) { + return true; + } + + // The DOM constructor resolve machinery interacts with Xrays in tricky + // ways, and there are some asymmetries that are important to understand. + // + // In the regular (non-Xray) case, we only want to resolve constructors + // once (so that if they're deleted, they don't reappear). We do this by + // stashing the constructor in a slot on the global, such that we can see + // during resolve whether we've created it already. This is rather + // memory-intensive, so we don't try to maintain these semantics when + // manipulating a global over Xray (so the properties just re-resolve if + // they've been deleted). + // + // Unfortunately, there's a bit of an impedance-mismatch between the Xray + // and non-Xray machinery. The Xray machinery wants an API that returns a + // JS::PropertyDescriptor, so that the resolve hook doesn't have to get + // snared up with trying to define a property on the Xray holder. At the + // same time, the DefineInterface callbacks are set up to define things + // directly on the global. And re-jiggering them to return property + // descriptors is tricky, because some DefineInterface callbacks define + // multiple things (like the Image() alias for HTMLImageElement). + // + // So the setup is as-follows: + // + // * The resolve function takes a JS::PropertyDescriptor, but in the + // non-Xray case, callees may define things directly on the global, and + // set the value on the property descriptor to |undefined| to indicate + // that there's nothing more for the caller to do. We assert against + // this behavior in the Xray case. + // + // * We make sure that we do a non-Xray resolve first, so that all the + // slots are set up. In the Xray case, this means unwrapping and doing + // a non-Xray resolve before doing the Xray resolve. + // + // This all could use some grand refactoring, but for now we just limp + // along. + if (xpc::WrapperFactory::IsXrayWrapper(aObj)) { + JS::Rooted interfaceObject(aCx); + { + JSAutoCompartment ac(aCx, global); + interfaceObject = entry->mDefine(aCx, global, aId, false); + } + if (NS_WARN_IF(!interfaceObject)) { + return Throw(aCx, NS_ERROR_FAILURE); + } + if (!JS_WrapObject(aCx, &interfaceObject)) { + return Throw(aCx, NS_ERROR_FAILURE); + } + + FillPropertyDescriptor(aDesc, aObj, 0, JS::ObjectValue(*interfaceObject)); + return true; + } + + JS::Rooted interfaceObject(aCx, + entry->mDefine(aCx, aObj, aId, true)); + if (NS_WARN_IF(!interfaceObject)) { + return Throw(aCx, NS_ERROR_FAILURE); + } + + // We've already defined the property. We indicate this to the caller + // by filling a property descriptor with JS::UndefinedValue() as the + // value. We still have to fill in a property descriptor, though, so + // that the caller knows the property is in fact on this object. It + // doesn't matter what we pass for the "readonly" argument here. + FillPropertyDescriptor(aDesc, aObj, JS::UndefinedValue(), false); + + return true; +} + +/* static */ +bool +WebIDLGlobalNameHash::MayResolve(jsid aId) +{ + WebIDLNameTableKey key(JSID_TO_FLAT_STRING(aId)); + // Rooting analysis thinks nsTHashtable<...>::Contains may GC because it ends + // up calling through PLDHashTableOps' matchEntry function pointer, but we + // know WebIDLNameTableEntry::KeyEquals can't cause a GC. + JS::AutoSuppressGCAnalysis suppress; + return sWebIDLGlobalNames->Contains(key); +} + +/* static */ +void +WebIDLGlobalNameHash::GetNames(JSContext* aCx, JS::Handle aObj, + nsTArray& aNames) +{ + for (auto iter = sWebIDLGlobalNames->Iter(); !iter.Done(); iter.Next()) { + const WebIDLNameTableEntry* entry = iter.Get(); + if (!entry->mEnabled || entry->mEnabled(aCx, aObj)) { + AppendASCIItoUTF16(nsDependentCString(sNames + entry->mNameOffset, + entry->mNameLength), + *aNames.AppendElement()); + } + } +} + +} // namespace dom +} // namespace mozilla diff --git a/dom/bindings/WebIDLGlobalNameHash.h b/dom/bindings/WebIDLGlobalNameHash.h new file mode 100644 index 0000000000..bbe0153950 --- /dev/null +++ b/dom/bindings/WebIDLGlobalNameHash.h @@ -0,0 +1,70 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_dom_WebIDLGlobalNameHash_h__ +#define mozilla_dom_WebIDLGlobalNameHash_h__ + +#include "js/RootingAPI.h" +#include "nsTArray.h" + +namespace mozilla { +namespace dom { + +struct WebIDLNameTableEntry; + +class WebIDLGlobalNameHash +{ +public: + static void Init(); + static void Shutdown(); + + typedef JSObject* + (*DefineGlobalName)(JSContext* cx, JS::Handle global, + JS::Handle id, bool defineOnGlobal); + + // Check whether a constructor should be enabled for the given object. + // Note that the object should NOT be an Xray, since Xrays will end up + // defining constructors on the underlying object. + // This is a typedef for the function type itself, not the function + // pointer, so it's more obvious that pointers to a ConstructorEnabled + // can be null. + typedef bool + (ConstructorEnabled)(JSContext* cx, JS::Handle obj); + + static void Register(uint16_t aNameOffset, uint16_t aNameLength, + DefineGlobalName aDefine, ConstructorEnabled* aEnabled); + + static void Remove(const char* aName, uint32_t aLength); + + // Returns false if something failed. aFound is set to true if the name is in + // the hash, whether it's enabled or not. + static bool DefineIfEnabled(JSContext* aCx, JS::Handle aObj, + JS::Handle aId, + JS::MutableHandle aDesc, + bool* aFound); + + static bool MayResolve(jsid aId); + + static void GetNames(JSContext* aCx, JS::Handle aObj, + nsTArray& aNames); + +private: + friend struct WebIDLNameTableEntry; + + // The total number of names that we will add to the hash. + // The value of sCount is generated by Codegen.py in RegisterBindings.cpp. + static const uint32_t sCount; + + // The names that will be registered in the hash, concatenated as one big + // string with \0 as a separator between names. + // The value of sNames is generated by Codegen.py in RegisterBindings.cpp. + static const char sNames[]; +}; + +} // namespace dom +} // namespace mozilla + +#endif // mozilla_dom_WebIDLGlobalNameHash_h__ diff --git a/dom/bindings/moz.build b/dom/bindings/moz.build index 008d40590a..770ec1a2cf 100644 --- a/dom/bindings/moz.build +++ b/dom/bindings/moz.build @@ -39,6 +39,7 @@ EXPORTS.mozilla.dom += [ 'ToJSValue.h', 'TypedArray.h', 'UnionMember.h', + 'WebIDLGlobalNameHash.h', ] # Generated bindings reference *Binding.h, not mozilla/dom/*Binding.h. And, @@ -89,6 +90,7 @@ UNIFIED_SOURCES += [ 'IterableIterator.cpp', 'SimpleGlobalObject.cpp', 'ToJSValue.cpp', + 'WebIDLGlobalNameHash.cpp', ] SOURCES += [ diff --git a/dom/bluetooth/ipc/BluetoothMessageUtils.h b/dom/bluetooth/ipc/BluetoothMessageUtils.h index b48b405e77..f9592af479 100644 --- a/dom/bluetooth/ipc/BluetoothMessageUtils.h +++ b/dom/bluetooth/ipc/BluetoothMessageUtils.h @@ -24,7 +24,7 @@ struct ParamTraits } } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { for (size_t i = 0; i < MOZ_ARRAY_LENGTH(aResult->mAddr); ++i) { if (!ReadParam(aMsg, aIter, aResult->mAddr + i)) { @@ -61,7 +61,7 @@ struct ParamTraits } } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { if (!ReadParam(aMsg, aIter, &aResult->mLength)) { return false; @@ -97,7 +97,7 @@ struct ParamTraits } } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { if (!ReadParam(aMsg, aIter, &aResult->mLength)) { return false; @@ -158,7 +158,7 @@ struct ParamTraits } } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { for (uint8_t i = 0; i < 16; i++) { if (!ReadParam(aMsg, aIter, &(aResult->mUuid[i]))) { @@ -181,7 +181,7 @@ struct ParamTraits WriteParam(aMsg, aParam.mInstanceId); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { if (!ReadParam(aMsg, aIter, &(aResult->mUuid)) || !ReadParam(aMsg, aIter, &(aResult->mInstanceId))) { @@ -203,7 +203,7 @@ struct ParamTraits WriteParam(aMsg, aParam.mIsPrimary); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { if (!ReadParam(aMsg, aIter, &(aResult->mId)) || !ReadParam(aMsg, aIter, &(aResult->mIsPrimary))) { @@ -226,7 +226,7 @@ struct ParamTraits WriteParam(aMsg, aParam.mWriteType); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { if (!ReadParam(aMsg, aIter, &(aResult->mId)) || !ReadParam(aMsg, aIter, &(aResult->mProperties)) || @@ -248,7 +248,7 @@ struct ParamTraits WriteParam(aMsg, aParam.mHandle); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { if (!ReadParam(aMsg, aIter, &(aResult->mHandle))) { return false; @@ -279,7 +279,7 @@ struct ParamTraits } } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { if (!ReadParam(aMsg, aIter, &(aResult->mHandle)) || !ReadParam(aMsg, aIter, &(aResult->mOffset)) || @@ -312,7 +312,7 @@ struct ParamTraits WriteParam(aMsg, static_cast(aParam)); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { uint8_t value; if (!ReadParam(aMsg, aIter, &value)) { @@ -352,7 +352,7 @@ struct ParamTraits WriteParam(aMsg, aParam.mServiceUuids); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { if (!ReadParam(aMsg, aIter, &(aResult->mAppearance)) || !ReadParam(aMsg, aIter, &(aResult->mIncludeDevName)) || diff --git a/dom/events/Event.cpp b/dom/events/Event.cpp index c26d88298f..126c4e95d1 100644 --- a/dom/events/Event.cpp +++ b/dom/events/Event.cpp @@ -747,11 +747,11 @@ Event::GetEventPopupControlState(WidgetEvent* aEvent, nsIDOMEvent* aDOMEvent) break; case eKeyboardEventClass: if (aEvent->IsTrusted()) { - uint32_t key = aEvent->AsKeyboardEvent()->keyCode; + uint32_t key = aEvent->AsKeyboardEvent()->mKeyCode; switch(aEvent->mMessage) { case eKeyPress: // return key on focused button. see note at eMouseClick. - if (key == nsIDOMKeyEvent::DOM_VK_RETURN) { + if (key == NS_VK_RETURN) { abuse = openAllowed; } else if (PopupAllowedForEvent("keypress")) { abuse = openControlled; @@ -759,7 +759,7 @@ Event::GetEventPopupControlState(WidgetEvent* aEvent, nsIDOMEvent* aDOMEvent) break; case eKeyUp: // space key on focused button. see note at eMouseClick. - if (key == nsIDOMKeyEvent::DOM_VK_SPACE) { + if (key == NS_VK_SPACE) { abuse = openAllowed; } else if (PopupAllowedForEvent("keyup")) { abuse = openControlled; @@ -1156,7 +1156,7 @@ Event::Serialize(IPC::Message* aMsg, bool aSerializeInterfaceType) } NS_IMETHODIMP_(bool) -Event::Deserialize(const IPC::Message* aMsg, void** aIter) +Event::Deserialize(const IPC::Message* aMsg, PickleIterator* aIter) { nsString type; NS_ENSURE_TRUE(IPC::ReadParam(aMsg, aIter, &type), false); diff --git a/dom/events/EventNameList.h b/dom/events/EventNameList.h index b1b8610a4a..06d37c0e40 100644 --- a/dom/events/EventNameList.h +++ b/dom/events/EventNameList.h @@ -270,6 +270,10 @@ NON_IDL_EVENT(mozbrowserafterkeyup, eAfterKeyUp, EventNameType_None, eBeforeAfterKeyboardEventClass) +NON_IDL_EVENT(mozaccesskeynotfound, + eAccessKeyNotFound, + EventNameType_None, + eKeyboardEventClass) EVENT(loadeddata, eLoadedData, EventNameType_HTML, diff --git a/dom/events/EventStateManager.cpp b/dom/events/EventStateManager.cpp index 112380e149..1d9474d0b5 100644 --- a/dom/events/EventStateManager.cpp +++ b/dom/events/EventStateManager.cpp @@ -608,16 +608,16 @@ EventStateManager::PreHandleEvent(nsPresContext* aPresContext, switch (mouseEvent->button) { case WidgetMouseEvent::eLeftButton: BeginTrackingDragGesture(aPresContext, mouseEvent, aTargetFrame); - mLClickCount = mouseEvent->clickCount; + mLClickCount = mouseEvent->mClickCount; SetClickCount(mouseEvent, aStatus); sNormalLMouseEventInProcess = true; break; case WidgetMouseEvent::eMiddleButton: - mMClickCount = mouseEvent->clickCount; + mMClickCount = mouseEvent->mClickCount; SetClickCount(mouseEvent, aStatus); break; case WidgetMouseEvent::eRightButton: - mRClickCount = mouseEvent->clickCount; + mRClickCount = mouseEvent->mClickCount; SetClickCount(mouseEvent, aStatus); break; } @@ -669,12 +669,12 @@ EventStateManager::PreHandleEvent(nsPresContext* aPresContext, // If the event is not a top-level window exit, then it's not // really an exit --- we may have traversed widget boundaries but // we're still in our toplevel window. - if (mouseEvent->exit != WidgetMouseEvent::eTopLevel) { + if (mouseEvent->mExitFrom != WidgetMouseEvent::eTopLevel) { // Treat it as a synthetic move so we don't generate spurious // "exit" or "move" events. Any necessary "out" or "over" events // will be generated by GenerateMouseEnterExit mouseEvent->mMessage = eMouseMove; - mouseEvent->reason = WidgetMouseEvent::eSynthesized; + mouseEvent->mReason = WidgetMouseEvent::eSynthesized; // then fall through... } else { if (sPointerEventEnabled) { @@ -734,15 +734,18 @@ EventStateManager::PreHandleEvent(nsPresContext* aPresContext, modifierMask |= NS_MODIFIER_OS; // Prevent keyboard scrolling while an accesskey modifier is in use. - if (modifierMask && - (modifierMask == Prefs::ChromeAccessModifierMask() || - modifierMask == Prefs::ContentAccessModifierMask())) { - AutoTArray accessCharCodes; - keyEvent->GetAccessKeyCandidates(accessCharCodes); + if (modifierMask) { + bool matchesContentAccessKey = (modifierMask == Prefs::ContentAccessModifierMask()); + + if (modifierMask == Prefs::ChromeAccessModifierMask() || + matchesContentAccessKey) { + AutoTArray accessCharCodes; + keyEvent->GetAccessKeyCandidates(accessCharCodes); - if (HandleAccessKey(aPresContext, accessCharCodes, - keyEvent->IsTrusted(), modifierMask)) { - *aStatus = nsEventStatus_eConsumeNoDefault; + if (HandleAccessKey(keyEvent, aPresContext, accessCharCodes, + modifierMask, matchesContentAccessKey)) { + *aStatus = nsEventStatus_eConsumeNoDefault; + } } } } @@ -1038,21 +1041,21 @@ EventStateManager::GetAccessKeyLabelPrefix(Element* aElement, nsAString& aPrefix } } -struct AccessKeyInfo +struct MOZ_STACK_CLASS AccessKeyInfo { + WidgetKeyboardEvent* event; nsTArray& charCodes; - bool isTrusted; int32_t modifierMask; - AccessKeyInfo(nsTArray& aCharCodes, bool aIsTrusted, int32_t aModifierMask) - : charCodes(aCharCodes) - , isTrusted(aIsTrusted) + AccessKeyInfo(WidgetKeyboardEvent* aEvent, nsTArray& aCharCodes, int32_t aModifierMask) + : event(aEvent) + , charCodes(aCharCodes) , modifierMask(aModifierMask) { } }; -static void +static bool HandleAccessKeyInRemoteChild(TabParent* aTabParent, void* aArg) { AccessKeyInfo* accessKeyInfo = static_cast(aArg); @@ -1061,15 +1064,21 @@ HandleAccessKeyInRemoteChild(TabParent* aTabParent, void* aArg) bool active; aTabParent->GetDocShellIsActive(&active); if (active) { - aTabParent->HandleAccessKey(accessKeyInfo->charCodes, accessKeyInfo->isTrusted, + accessKeyInfo->event->mAccessKeyForwardedToChild = true; + aTabParent->HandleAccessKey(*accessKeyInfo->event, + accessKeyInfo->charCodes, accessKeyInfo->modifierMask); + return true; } + + return false; } bool -EventStateManager::HandleAccessKey(nsPresContext* aPresContext, +EventStateManager::HandleAccessKey(WidgetKeyboardEvent* aEvent, + nsPresContext* aPresContext, nsTArray& aAccessCharCodes, - bool aIsTrusted, + bool aMatchesContentAccessKey, nsIDocShellTreeItem* aBubbledFrom, ProcessingAccessKeyState aAccessKeyState, int32_t aModifierMask) @@ -1084,7 +1093,7 @@ EventStateManager::HandleAccessKey(nsPresContext* aPresContext, if (mAccessKeys.Count() > 0 && aModifierMask == GetAccessModifierMaskFor(docShell)) { // Someone registered an accesskey. Find and activate it. - if (ExecuteAccessKey(aAccessCharCodes, aIsTrusted)) { + if (ExecuteAccessKey(aAccessCharCodes, aEvent->IsTrusted())) { return true; } } @@ -1117,7 +1126,8 @@ EventStateManager::HandleAccessKey(nsPresContext* aPresContext, static_cast(subPC->EventStateManager()); if (esm && - esm->HandleAccessKey(subPC, aAccessCharCodes, aIsTrusted, nullptr, + esm->HandleAccessKey(aEvent, subPC, aAccessCharCodes, + aMatchesContentAccessKey, nullptr, eAccessKeyProcessingDown, aModifierMask)) { return true; } @@ -1139,22 +1149,27 @@ EventStateManager::HandleAccessKey(nsPresContext* aPresContext, EventStateManager* esm = static_cast(parentPC->EventStateManager()); if (esm && - esm->HandleAccessKey(parentPC, aAccessCharCodes, aIsTrusted, docShell, - eAccessKeyProcessingUp, aModifierMask)) { + esm->HandleAccessKey(aEvent, parentPC, aAccessCharCodes, + aMatchesContentAccessKey, docShell, + eAccessKeyProcessingDown, aModifierMask)) { return true; } } }// if end. bubble up process - // Now try remote children - if (mDocument && mDocument->GetWindow()) { + // If the content access key modifier is pressed, try remote children + if (aMatchesContentAccessKey && mDocument && mDocument->GetWindow()) { // If the focus is currently on a node with a TabParent, the key event will // get forwarded to the child process and HandleAccessKey called from there. // If focus is somewhere else, then we need to check the remote children. nsFocusManager* fm = nsFocusManager::GetFocusManager(); nsIContent* focusedContent = fm ? fm->GetFocusedContent() : nullptr; - if (!TabParent::GetFrom(focusedContent)) { - AccessKeyInfo accessKeyInfo(aAccessCharCodes, aIsTrusted, aModifierMask); + if (TabParent::GetFrom(focusedContent)) { + // A remote child process is focused. The key event should get sent to + // the child process. + aEvent->mAccessKeyForwardedToChild = true; + } else { + AccessKeyInfo accessKeyInfo(aEvent, aAccessCharCodes, aModifierMask); nsContentUtils::CallOnAllRemoteChildren(mDocument->GetWindow(), HandleAccessKeyInRemoteChild, &accessKeyInfo); } @@ -1532,7 +1547,7 @@ EventStateManager::FireContextClick() // init the event while mCurrentTarget is still good WidgetMouseEvent event(true, eContextMenu, targetWidget, WidgetMouseEvent::eReal); - event.clickCount = 1; + event.mClickCount = 1; FillInEventFromGestureDown(&event); // stop selection tracking, we're in control now @@ -2827,7 +2842,7 @@ EventStateManager::PostHandleKeyboardEvent(WidgetKeyboardEvent* aKeyboardEvent, // XXX Currently, our automated tests don't support mKeyNameIndex. // Therefore, we still need to handle this with keyCode. - switch(aKeyboardEvent->keyCode) { + switch(aKeyboardEvent->mKeyCode) { case NS_VK_TAB: case NS_VK_F6: // This is to prevent keyboard scrolling while alt modifier in use. @@ -2846,7 +2861,7 @@ EventStateManager::PostHandleKeyboardEvent(WidgetKeyboardEvent* aKeyboardEvent, if (fm && mDocument) { // Shift focus forward or back depending on shift key bool isDocMove = - aKeyboardEvent->IsControl() || aKeyboardEvent->keyCode == NS_VK_F6; + aKeyboardEvent->IsControl() || aKeyboardEvent->mKeyCode == NS_VK_F6; uint32_t dir = aKeyboardEvent->IsShift() ? (isDocMove ? static_cast(nsIFocusManager::MOVEFOCUS_BACKWARDDOC) : static_cast(nsIFocusManager::MOVEFOCUS_BACKWARD)) : @@ -3944,7 +3959,7 @@ EventStateManager::DispatchMouseOrPointerEvent(WidgetMouseEvent* aMouseEvent, nsAutoPtr remoteEvent; CreateMouseOrPointerWidgetEvent(aMouseEvent, eMouseExitFromWidget, aRelatedContent, remoteEvent); - remoteEvent->exit = WidgetMouseEvent::eTopLevel; + remoteEvent->mExitFrom = WidgetMouseEvent::eTopLevel; // mCurrentTarget is set to the new target, so we must reset it to the // old target and then dispatch a cross-process event. (mCurrentTarget @@ -4382,6 +4397,9 @@ EventStateManager::SetPointerLock(nsIWidget* aWidget, // pre-pointerlock position, so that the synthetic mouse event reports // no movement. sLastRefPoint = mPreLockPoint; + // Reset SynthCenteringPoint to invalid so that next time we start + // locking pointer, it has its initial value. + sSynthCenteringPoint = kInvalidRefPoint; if (aWidget) { aWidget->SynthesizeNativeMouseMove( mPreLockPoint + aWidget->WidgetToScreenOffset(), nullptr); @@ -4575,10 +4593,10 @@ EventStateManager::SetClickCount(WidgetMouseEvent* aEvent, if (mLastLeftMouseDownContent == mouseContent || mLastLeftMouseDownContentParent == mouseContent || mLastLeftMouseDownContent == mouseContentParent) { - aEvent->clickCount = mLClickCount; + aEvent->mClickCount = mLClickCount; mLClickCount = 0; } else { - aEvent->clickCount = 0; + aEvent->mClickCount = 0; } mLastLeftMouseDownContent = nullptr; mLastLeftMouseDownContentParent = nullptr; @@ -4593,10 +4611,10 @@ EventStateManager::SetClickCount(WidgetMouseEvent* aEvent, if (mLastMiddleMouseDownContent == mouseContent || mLastMiddleMouseDownContentParent == mouseContent || mLastMiddleMouseDownContent == mouseContentParent) { - aEvent->clickCount = mMClickCount; + aEvent->mClickCount = mMClickCount; mMClickCount = 0; } else { - aEvent->clickCount = 0; + aEvent->mClickCount = 0; } mLastMiddleMouseDownContent = nullptr; mLastMiddleMouseDownContentParent = nullptr; @@ -4611,10 +4629,10 @@ EventStateManager::SetClickCount(WidgetMouseEvent* aEvent, if (mLastRightMouseDownContent == mouseContent || mLastRightMouseDownContentParent == mouseContent || mLastRightMouseDownContent == mouseContentParent) { - aEvent->clickCount = mRClickCount; + aEvent->mClickCount = mRClickCount; mRClickCount = 0; } else { - aEvent->clickCount = 0; + aEvent->mClickCount = 0; } mLastRightMouseDownContent = nullptr; mLastRightMouseDownContentParent = nullptr; @@ -4638,7 +4656,7 @@ EventStateManager::InitAndDispatchClickEvent(WidgetMouseEvent* aEvent, aEvent->mWidget, WidgetMouseEvent::eReal); event.mRefPoint = aEvent->mRefPoint; - event.clickCount = aEvent->clickCount; + event.mClickCount = aEvent->mClickCount; event.mModifiers = aEvent->mModifiers; event.buttons = aEvent->buttons; event.mTime = aEvent->mTime; @@ -4659,7 +4677,7 @@ EventStateManager::CheckForAndDispatchClick(WidgetMouseEvent* aEvent, //If mouse is still over same element, clickcount will be > 1. //If it has moved it will be zero, so no click. - if (0 != aEvent->clickCount) { + if (aEvent->mClickCount) { //Check that the window isn't disabled before firing a click //(see bug 366544). if (aEvent->mWidget && !aEvent->mWidget->IsEnabled()) { @@ -4693,7 +4711,7 @@ EventStateManager::CheckForAndDispatchClick(WidgetMouseEvent* aEvent, presShell, mouseContent, currentTarget, notDispatchToContents); - if (NS_SUCCEEDED(ret) && aEvent->clickCount == 2 && + if (NS_SUCCEEDED(ret) && aEvent->mClickCount == 2 && mouseContent && mouseContent->IsInComposedDoc()) { // fire double click ret = InitAndDispatchClickEvent(aEvent, aStatus, eMouseDoubleClick, diff --git a/dom/events/EventStateManager.h b/dom/events/EventStateManager.h index 3811b95499..e7252bd29b 100644 --- a/dom/events/EventStateManager.h +++ b/dom/events/EventStateManager.h @@ -183,13 +183,15 @@ public: static void GetAccessKeyLabelPrefix(dom::Element* aElement, nsAString& aPrefix); - bool HandleAccessKey(nsPresContext* aPresContext, + bool HandleAccessKey(WidgetKeyboardEvent* aEvent, + nsPresContext* aPresContext, nsTArray& aAccessCharCodes, - bool aIsTrusted, - int32_t aModifierMask) + int32_t aModifierMask, + bool aMatchesContentAccessKey) { - return HandleAccessKey(aPresContext, aAccessCharCodes, aIsTrusted, - nullptr, eAccessKeyProcessingNormal, aModifierMask); + return HandleAccessKey(aEvent, aPresContext, aAccessCharCodes, + aMatchesContentAccessKey, nullptr, + eAccessKeyProcessingNormal, aModifierMask); } nsresult SetCursor(int32_t aCursor, imgIContainer* aContainer, @@ -442,9 +444,10 @@ protected: * on descendant docshells first, then on the ancestor (with |aBubbledFrom| * set to the docshell associated with |this|), until something matches. * + * @param aEvent the keyboard event triggering the acccess key * @param aPresContext the presentation context * @param aAccessCharCodes list of charcode candidates - * @param aIsTrusted true if triggered by a trusted key event + * @param aMatchesContentAccessKey true if the content accesskey modifier is pressed * @param aBubbledFrom is used by an ancestor to avoid calling HandleAccessKey() * on the child the call originally came from, i.e. this is the child * that recursively called us in its Up phase. The initial caller @@ -454,15 +457,16 @@ protected: * processing children and Up when recursively calling its ancestor. * @param aModifierMask modifier mask for the key event */ - bool HandleAccessKey(nsPresContext* aPresContext, - nsTArray& aAccessCharCodes, - bool aIsTrusted, - nsIDocShellTreeItem* aBubbledFrom, - ProcessingAccessKeyState aAccessKeyState, - int32_t aModifierMask); + bool HandleAccessKey(WidgetKeyboardEvent* aEvent, + nsPresContext* aPresContext, + nsTArray& aAccessCharCodes, + bool aMatchesContentAccessKey, + nsIDocShellTreeItem* aBubbledFrom, + ProcessingAccessKeyState aAccessKeyState, + int32_t aModifierMask); bool ExecuteAccessKey(nsTArray& aAccessCharCodes, - bool aIsTrustedEvent); + bool aIsTrustedEvent); //--------------------------------------------- // DocShell Focus Traversal Methods diff --git a/dom/events/KeyboardEvent.cpp b/dom/events/KeyboardEvent.cpp index 10e0213f52..75f9f2f9c7 100644 --- a/dom/events/KeyboardEvent.cpp +++ b/dom/events/KeyboardEvent.cpp @@ -184,7 +184,7 @@ KeyboardEvent::CharCode() { // If this event is initialized with ctor, we shouldn't check event type. if (mInitializedByCtor) { - return mEvent->AsKeyboardEvent()->charCode; + return mEvent->AsKeyboardEvent()->mCharCode; } switch (mEvent->mMessage) { @@ -198,7 +198,8 @@ KeyboardEvent::CharCode() case eAfterKeyUp: return 0; case eKeyPress: - return mEvent->AsKeyboardEvent()->charCode; + case eAccessKeyNotFound: + return mEvent->AsKeyboardEvent()->mCharCode; default: break; } @@ -218,11 +219,11 @@ KeyboardEvent::KeyCode() { // If this event is initialized with ctor, we shouldn't check event type. if (mInitializedByCtor) { - return mEvent->AsKeyboardEvent()->keyCode; + return mEvent->AsKeyboardEvent()->mKeyCode; } if (mEvent->HasKeyEventMessage()) { - return mEvent->AsKeyboardEvent()->keyCode; + return mEvent->AsKeyboardEvent()->mKeyCode; } return 0; } @@ -249,7 +250,7 @@ KeyboardEvent::Which() //Special case for 4xp bug 62878. Try to make value of which //more closely mirror the values that 4.x gave for RETURN and BACKSPACE { - uint32_t keyCode = mEvent->AsKeyboardEvent()->keyCode; + uint32_t keyCode = mEvent->AsKeyboardEvent()->mKeyCode; if (keyCode == NS_VK_RETURN || keyCode == NS_VK_BACK) { return keyCode; } @@ -274,7 +275,7 @@ KeyboardEvent::GetLocation(uint32_t* aLocation) uint32_t KeyboardEvent::Location() { - return mEvent->AsKeyboardEvent()->location; + return mEvent->AsKeyboardEvent()->mLocation; } // static @@ -309,7 +310,7 @@ KeyboardEvent::InitWithKeyboardEventInit(EventTarget* aOwner, mInitializedWhichValue = aParam.mWhich; WidgetKeyboardEvent* internalEvent = mEvent->AsKeyboardEvent(); - internalEvent->location = aParam.mLocation; + internalEvent->mLocation = aParam.mLocation; internalEvent->mIsRepeat = aParam.mRepeat; internalEvent->mIsComposing = aParam.mIsComposing; internalEvent->mKeyNameIndex = @@ -340,8 +341,8 @@ KeyboardEvent::InitKeyEvent(const nsAString& aType, WidgetKeyboardEvent* keyEvent = mEvent->AsKeyboardEvent(); keyEvent->InitBasicModifiers(aCtrlKey, aAltKey, aShiftKey, aMetaKey); - keyEvent->keyCode = aKeyCode; - keyEvent->charCode = aCharCode; + keyEvent->mKeyCode = aKeyCode; + keyEvent->mCharCode = aCharCode; return NS_OK; } diff --git a/dom/events/MouseEvent.cpp b/dom/events/MouseEvent.cpp index 2a1d056f92..e8656ec915 100644 --- a/dom/events/MouseEvent.cpp +++ b/dom/events/MouseEvent.cpp @@ -37,9 +37,9 @@ MouseEvent::MouseEvent(EventTarget* aOwner, } if (mouseEvent) { - MOZ_ASSERT(mouseEvent->reason != WidgetMouseEvent::eSynthesized, + MOZ_ASSERT(mouseEvent->mReason != WidgetMouseEvent::eSynthesized, "Don't dispatch DOM events from synthesized mouse events"); - mDetail = mouseEvent->clickCount; + mDetail = mouseEvent->mClickCount; } } @@ -87,7 +87,7 @@ MouseEvent::InitMouseEvent(const nsAString& aType, WidgetMouseEvent* mouseEvent = mEvent->AsMouseEvent(); if (mouseEvent) { - mouseEvent->clickCount = aDetail; + mouseEvent->mClickCount = aDetail; } break; } diff --git a/dom/events/NotifyPaintEvent.cpp b/dom/events/NotifyPaintEvent.cpp index 35ff2af808..bc3537db9d 100644 --- a/dom/events/NotifyPaintEvent.cpp +++ b/dom/events/NotifyPaintEvent.cpp @@ -140,7 +140,7 @@ NotifyPaintEvent::Serialize(IPC::Message* aMsg, } NS_IMETHODIMP_(bool) -NotifyPaintEvent::Deserialize(const IPC::Message* aMsg, void** aIter) +NotifyPaintEvent::Deserialize(const IPC::Message* aMsg, PickleIterator* aIter) { NS_ENSURE_TRUE(Event::Deserialize(aMsg, aIter), false); diff --git a/dom/events/NotifyPaintEvent.h b/dom/events/NotifyPaintEvent.h index 001795ed1e..e73a453d79 100644 --- a/dom/events/NotifyPaintEvent.h +++ b/dom/events/NotifyPaintEvent.h @@ -43,7 +43,7 @@ public: return Event::DuplicatePrivateData(); } NS_IMETHOD_(void) Serialize(IPC::Message* aMsg, bool aSerializeInterfaceType) override; - NS_IMETHOD_(bool) Deserialize(const IPC::Message* aMsg, void** aIter) override; + NS_IMETHOD_(bool) Deserialize(const IPC::Message* aMsg, PickleIterator* aIter) override; virtual JSObject* WrapObjectInternal(JSContext* aCx, JS::Handle aGivenProto) override { diff --git a/dom/events/ScrollAreaEvent.cpp b/dom/events/ScrollAreaEvent.cpp index 4b66fe1445..ccae6d64c6 100644 --- a/dom/events/ScrollAreaEvent.cpp +++ b/dom/events/ScrollAreaEvent.cpp @@ -60,7 +60,7 @@ ScrollAreaEvent::Serialize(IPC::Message* aMsg, } NS_IMETHODIMP_(bool) -ScrollAreaEvent::Deserialize(const IPC::Message* aMsg, void** aIter) +ScrollAreaEvent::Deserialize(const IPC::Message* aMsg, PickleIterator* aIter) { NS_ENSURE_TRUE(Event::Deserialize(aMsg, aIter), false); diff --git a/dom/events/ScrollAreaEvent.h b/dom/events/ScrollAreaEvent.h index 18e8832726..d91070351d 100644 --- a/dom/events/ScrollAreaEvent.h +++ b/dom/events/ScrollAreaEvent.h @@ -33,7 +33,7 @@ public: return Event::DuplicatePrivateData(); } NS_IMETHOD_(void) Serialize(IPC::Message* aMsg, bool aSerializeInterfaceType) override; - NS_IMETHOD_(bool) Deserialize(const IPC::Message* aMsg, void** aIter) override; + NS_IMETHOD_(bool) Deserialize(const IPC::Message* aMsg, PickleIterator* aIter) override; virtual JSObject* WrapObjectInternal(JSContext* aCx, JS::Handle aGivenProto) override { diff --git a/dom/events/UIEvent.cpp b/dom/events/UIEvent.cpp index f6f88089c9..4b517a53d5 100644 --- a/dom/events/UIEvent.cpp +++ b/dom/events/UIEvent.cpp @@ -352,7 +352,7 @@ bool UIEvent::IsChar() const { WidgetKeyboardEvent* keyEvent = mEvent->AsKeyboardEvent(); - return keyEvent ? keyEvent->isChar : false; + return keyEvent ? keyEvent->mIsChar : false; } mozilla::dom::Event* @@ -398,7 +398,7 @@ UIEvent::Serialize(IPC::Message* aMsg, bool aSerializeInterfaceType) } NS_IMETHODIMP_(bool) -UIEvent::Deserialize(const IPC::Message* aMsg, void** aIter) +UIEvent::Deserialize(const IPC::Message* aMsg, PickleIterator* aIter) { NS_ENSURE_TRUE(Event::Deserialize(aMsg, aIter), false); NS_ENSURE_TRUE(IPC::ReadParam(aMsg, aIter, &mDetail), false); diff --git a/dom/events/UIEvent.h b/dom/events/UIEvent.h index 3972ac1a8f..8f160935f9 100644 --- a/dom/events/UIEvent.h +++ b/dom/events/UIEvent.h @@ -38,7 +38,7 @@ public: NS_FORWARD_TO_EVENT_NO_SERIALIZATION_NO_DUPLICATION NS_IMETHOD DuplicatePrivateData() override; NS_IMETHOD_(void) Serialize(IPC::Message* aMsg, bool aSerializeInterfaceType) override; - NS_IMETHOD_(bool) Deserialize(const IPC::Message* aMsg, void** aIter) override; + NS_IMETHOD_(bool) Deserialize(const IPC::Message* aMsg, PickleIterator* aIter) override; static already_AddRefed Constructor(const GlobalObject& aGlobal, @@ -139,7 +139,7 @@ protected: UIEvent::Serialize(aMsg, aSerializeInterfaceType); \ } \ NS_IMETHOD_(bool) Deserialize(const IPC::Message* aMsg, \ - void** aIter) override \ + PickleIterator* aIter) override \ { \ return UIEvent::Deserialize(aMsg, aIter); \ } diff --git a/dom/geolocation/nsGeoPositionIPCSerialiser.h b/dom/geolocation/nsGeoPositionIPCSerialiser.h index aa3780d4e3..3965ef1920 100644 --- a/dom/geolocation/nsGeoPositionIPCSerialiser.h +++ b/dom/geolocation/nsGeoPositionIPCSerialiser.h @@ -53,7 +53,7 @@ struct ParamTraits } // Function to de-serialize a geoposition - static bool Read(const Message* aMsg, void **aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { // Check if it is the null pointer we have transfered bool isNull; @@ -119,7 +119,7 @@ struct ParamTraits } // Function to de-serialize a geoposition - static bool Read(const Message* aMsg, void **aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { // Check if it is the null pointer we have transfered bool isNull; diff --git a/dom/html/HTMLButtonElement.cpp b/dom/html/HTMLButtonElement.cpp index 229af9c483..1172c123c4 100644 --- a/dom/html/HTMLButtonElement.cpp +++ b/dom/html/HTMLButtonElement.cpp @@ -293,9 +293,9 @@ HTMLButtonElement::PostHandleEvent(EventChainPostVisitor& aVisitor) // For backwards compat, trigger buttons with space or enter // (bug 25300) WidgetKeyboardEvent* keyEvent = aVisitor.mEvent->AsKeyboardEvent(); - if ((keyEvent->keyCode == NS_VK_RETURN && + if ((keyEvent->mKeyCode == NS_VK_RETURN && eKeyPress == aVisitor.mEvent->mMessage) || - (keyEvent->keyCode == NS_VK_SPACE && + (keyEvent->mKeyCode == NS_VK_SPACE && eKeyUp == aVisitor.mEvent->mMessage)) { DispatchSimulatedClick(this, aVisitor.mEvent->IsTrusted(), aVisitor.mPresContext); diff --git a/dom/html/HTMLInputElement.cpp b/dom/html/HTMLInputElement.cpp index 09497ed478..2993e7848b 100644 --- a/dom/html/HTMLInputElement.cpp +++ b/dom/html/HTMLInputElement.cpp @@ -3423,7 +3423,8 @@ HTMLInputElement::PreHandleEvent(EventChainPreVisitor& aVisitor) } } else if (aVisitor.mEvent->mMessage == eKeyUp) { WidgetKeyboardEvent* keyEvent = aVisitor.mEvent->AsKeyboardEvent(); - if ((keyEvent->keyCode == NS_VK_UP || keyEvent->keyCode == NS_VK_DOWN) && + if ((keyEvent->mKeyCode == NS_VK_UP || + keyEvent->mKeyCode == NS_VK_DOWN) && !(keyEvent->IsShift() || keyEvent->IsControl() || keyEvent->IsAlt() || keyEvent->IsMeta() || keyEvent->IsAltGraph() || keyEvent->IsFn() || @@ -3893,7 +3894,7 @@ HTMLInputElement::PostHandleEvent(EventChainPostVisitor& aVisitor) if (mType == NS_FORM_INPUT_NUMBER && keyEvent && keyEvent->mMessage == eKeyPress && aVisitor.mEvent->IsTrusted() && - (keyEvent->keyCode == NS_VK_UP || keyEvent->keyCode == NS_VK_DOWN) && + (keyEvent->mKeyCode == NS_VK_UP || keyEvent->mKeyCode == NS_VK_DOWN) && !(keyEvent->IsShift() || keyEvent->IsControl() || keyEvent->IsAlt() || keyEvent->IsMeta() || keyEvent->IsAltGraph() || keyEvent->IsFn() || @@ -3910,7 +3911,7 @@ HTMLInputElement::PostHandleEvent(EventChainPostVisitor& aVisitor) // just ignore aVisitor.mEventStatus here and go ahead and handle the // event to increase/decrease the value of the number control. if (!aVisitor.mEvent->DefaultPreventedByContent() && IsMutable()) { - StepNumberControlForUserEvent(keyEvent->keyCode == NS_VK_UP ? 1 : -1); + StepNumberControlForUserEvent(keyEvent->mKeyCode == NS_VK_UP ? 1 : -1); aVisitor.mEventStatus = nsEventStatus_eConsumeNoDefault; } } else if (nsEventStatus_eIgnore == aVisitor.mEventStatus) { @@ -3948,15 +3949,15 @@ HTMLInputElement::PostHandleEvent(EventChainPostVisitor& aVisitor) // space or enter (bug 25300) WidgetKeyboardEvent* keyEvent = aVisitor.mEvent->AsKeyboardEvent(); if ((aVisitor.mEvent->mMessage == eKeyPress && - keyEvent->keyCode == NS_VK_RETURN) || + keyEvent->mKeyCode == NS_VK_RETURN) || (aVisitor.mEvent->mMessage == eKeyUp && - keyEvent->keyCode == NS_VK_SPACE)) { + keyEvent->mKeyCode == NS_VK_SPACE)) { switch(mType) { case NS_FORM_INPUT_CHECKBOX: case NS_FORM_INPUT_RADIO: { // Checkbox and Radio try to submit on Enter press - if (keyEvent->keyCode != NS_VK_SPACE) { + if (keyEvent->mKeyCode != NS_VK_SPACE) { MaybeSubmitForm(aVisitor.mPresContext); break; // If we are submitting, do not send click event @@ -3980,7 +3981,7 @@ HTMLInputElement::PostHandleEvent(EventChainPostVisitor& aVisitor) mType == NS_FORM_INPUT_RADIO && !keyEvent->IsAlt() && !keyEvent->IsControl() && !keyEvent->IsMeta()) { bool isMovingBack = false; - switch (keyEvent->keyCode) { + switch (keyEvent->mKeyCode) { case NS_VK_UP: case NS_VK_LEFT: isMovingBack = true; @@ -4023,7 +4024,7 @@ HTMLInputElement::PostHandleEvent(EventChainPostVisitor& aVisitor) */ if (aVisitor.mEvent->mMessage == eKeyPress && - keyEvent->keyCode == NS_VK_RETURN && + keyEvent->mKeyCode == NS_VK_RETURN && (IsSingleLineTextControl(false, mType) || mType == NS_FORM_INPUT_NUMBER || IsExperimentalMobileType(mType))) { @@ -4035,14 +4036,14 @@ HTMLInputElement::PostHandleEvent(EventChainPostVisitor& aVisitor) if (aVisitor.mEvent->mMessage == eKeyPress && mType == NS_FORM_INPUT_RANGE && !keyEvent->IsAlt() && !keyEvent->IsControl() && !keyEvent->IsMeta() && - (keyEvent->keyCode == NS_VK_LEFT || - keyEvent->keyCode == NS_VK_RIGHT || - keyEvent->keyCode == NS_VK_UP || - keyEvent->keyCode == NS_VK_DOWN || - keyEvent->keyCode == NS_VK_PAGE_UP || - keyEvent->keyCode == NS_VK_PAGE_DOWN || - keyEvent->keyCode == NS_VK_HOME || - keyEvent->keyCode == NS_VK_END)) { + (keyEvent->mKeyCode == NS_VK_LEFT || + keyEvent->mKeyCode == NS_VK_RIGHT || + keyEvent->mKeyCode == NS_VK_UP || + keyEvent->mKeyCode == NS_VK_DOWN || + keyEvent->mKeyCode == NS_VK_PAGE_UP || + keyEvent->mKeyCode == NS_VK_PAGE_DOWN || + keyEvent->mKeyCode == NS_VK_HOME || + keyEvent->mKeyCode == NS_VK_END)) { Decimal minimum = GetMinimum(); Decimal maximum = GetMaximum(); MOZ_ASSERT(minimum.isFinite() && maximum.isFinite()); @@ -4054,7 +4055,7 @@ HTMLInputElement::PostHandleEvent(EventChainPostVisitor& aVisitor) } MOZ_ASSERT(value.isFinite() && step.isFinite()); Decimal newValue; - switch (keyEvent->keyCode) { + switch (keyEvent->mKeyCode) { case NS_VK_LEFT: newValue = value + (GetComputedDirectionality() == eDir_RTL ? step : -step); @@ -4301,7 +4302,7 @@ HTMLInputElement::PostHandleEventForRangeThumb(EventChainPostVisitor& aVisitor) case eKeyPress: if (mIsDraggingRange && - aVisitor.mEvent->AsKeyboardEvent()->keyCode == NS_VK_ESCAPE) { + aVisitor.mEvent->AsKeyboardEvent()->mKeyCode == NS_VK_ESCAPE) { CancelRangeThumbDrag(); } break; diff --git a/dom/html/HTMLLabelElement.cpp b/dom/html/HTMLLabelElement.cpp index 87c7f43f19..891ad3eb3d 100644 --- a/dom/html/HTMLLabelElement.cpp +++ b/dom/html/HTMLLabelElement.cpp @@ -161,7 +161,7 @@ HTMLLabelElement::PostHandleEvent(EventChainPostVisitor& aVisitor) } // Only set focus on the first click of multiple clicks to prevent // to prevent immediate de-focus. - if (mouseEvent->clickCount <= 1) { + if (mouseEvent->mClickCount <= 1) { nsIFocusManager* fm = nsFocusManager::GetFocusManager(); if (fm) { // Use FLAG_BYMOVEFOCUS here so that the label is scrolled to. diff --git a/dom/html/HTMLSummaryElement.cpp b/dom/html/HTMLSummaryElement.cpp index 8aeb705898..ee3c07b20b 100644 --- a/dom/html/HTMLSummaryElement.cpp +++ b/dom/html/HTMLSummaryElement.cpp @@ -77,16 +77,16 @@ HTMLSummaryElement::PostHandleEvent(EventChainPostVisitor& aVisitor) switch (event->mMessage) { case eKeyPress: - if (keyboardEvent->charCode == nsIDOMKeyEvent::DOM_VK_SPACE) { + if (keyboardEvent->mCharCode == ' ') { // Consume 'space' key to prevent scrolling the page down. aVisitor.mEventStatus = nsEventStatus_eConsumeNoDefault; } - dispatchClick = keyboardEvent->keyCode == nsIDOMKeyEvent::DOM_VK_RETURN; + dispatchClick = keyboardEvent->mKeyCode == NS_VK_RETURN; break; case eKeyUp: - dispatchClick = keyboardEvent->keyCode == nsIDOMKeyEvent::DOM_VK_SPACE; + dispatchClick = keyboardEvent->mKeyCode == NS_VK_SPACE; break; default: diff --git a/dom/indexedDB/SerializationHelpers.h b/dom/indexedDB/SerializationHelpers.h index 29e2d84480..aeafb1880b 100644 --- a/dom/indexedDB/SerializationHelpers.h +++ b/dom/indexedDB/SerializationHelpers.h @@ -26,7 +26,7 @@ struct ParamTraits WriteParam(aMsg, aParam.mBuffer); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { return ReadParam(aMsg, aIter, &aResult->mBuffer); } @@ -55,7 +55,7 @@ struct ParamTraits WriteParam(aMsg, aParam.mStrings); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { return ReadParam(aMsg, aIter, &aResult->mType) && ReadParam(aMsg, aIter, &aResult->mStrings); diff --git a/dom/interfaces/events/nsIDOMEvent.idl b/dom/interfaces/events/nsIDOMEvent.idl index 786884022c..6784e40f38 100644 --- a/dom/interfaces/events/nsIDOMEvent.idl +++ b/dom/interfaces/events/nsIDOMEvent.idl @@ -11,6 +11,7 @@ interface nsIDOMEventTarget; [ptr] native DOMEventPtr(mozilla::dom::Event); [ptr] native IPCMessagePtr(IPC::Message); [ptr] native ConstIPCMessagePtr(const IPC::Message); +[ptr] native PickleIterator(PickleIterator); [ptr] native EventTargetPtr(mozilla::dom::EventTarget); %{C++ #ifdef ERROR @@ -23,6 +24,7 @@ class nsInvalidateRequestList; namespace IPC { class Message; } +class PickleIterator; namespace mozilla { namespace dom { class Event; @@ -211,7 +213,7 @@ interface nsIDOMEvent : nsISupports [noscript,notxpcom] void SetTrusted(in boolean aTrusted); [notxpcom] void Serialize(in IPCMessagePtr aMsg, in boolean aSerializeInterfaceType); - [notxpcom] boolean Deserialize(in ConstIPCMessagePtr aMsg, out voidPtr aIter); + [notxpcom] boolean Deserialize(in ConstIPCMessagePtr aMsg, in PickleIterator aIter); [noscript,notxpcom] void SetOwner(in EventTargetPtr aOwner); [notxpcom] DOMEventPtr InternalDOMEvent(); [noscript] void stopCrossProcessForwarding(); diff --git a/dom/ipc/IdType.h b/dom/ipc/IdType.h index 2bef2b8bd4..b683178eb7 100644 --- a/dom/ipc/IdType.h +++ b/dom/ipc/IdType.h @@ -62,7 +62,7 @@ struct ParamTraits> WriteParam(aMsg, aParam.mId); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { return ReadParam(aMsg, aIter, &aResult->mId); } diff --git a/dom/ipc/PBrowser.ipdl b/dom/ipc/PBrowser.ipdl index 083d6df99a..75aa49c7f3 100644 --- a/dom/ipc/PBrowser.ipdl +++ b/dom/ipc/PBrowser.ipdl @@ -491,6 +491,8 @@ parent: */ sync GetTabCount() returns (uint32_t value); + async AccessKeyNotHandled(WidgetKeyboardEvent event); + child: async NativeSynthesisResponse(uint64_t aObserverId, nsCString aResponse); @@ -731,11 +733,12 @@ child: * A potential accesskey was just pressed. Look for accesskey targets * using the list of provided charCodes. * - * @param charCode array of potential character codes + * @param event keyboard event * @param isTrusted true if triggered by a trusted key event * @param modifierMask indicates which accesskey modifiers are pressed */ - async HandleAccessKey(uint32_t[] charCodes, bool isTrusted, int32_t modifierMask); + async HandleAccessKey(WidgetKeyboardEvent event, + uint32_t[] charCodes, int32_t modifierMask); /** * Propagate a refresh to the child process diff --git a/dom/ipc/PermissionMessageUtils.cpp b/dom/ipc/PermissionMessageUtils.cpp index bd923f70b8..445124b0a6 100644 --- a/dom/ipc/PermissionMessageUtils.cpp +++ b/dom/ipc/PermissionMessageUtils.cpp @@ -37,7 +37,7 @@ ParamTraits::Write(Message* aMsg, const paramType& aParam) { } bool -ParamTraits::Read(const Message* aMsg, void** aIter, paramType* aResult) +ParamTraits::Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { bool isNull; if (!ReadParam(aMsg, aIter, &isNull)) { diff --git a/dom/ipc/PermissionMessageUtils.h b/dom/ipc/PermissionMessageUtils.h index fe299b71a8..10b8b1c440 100644 --- a/dom/ipc/PermissionMessageUtils.h +++ b/dom/ipc/PermissionMessageUtils.h @@ -39,7 +39,7 @@ struct ParamTraits { typedef Principal paramType; static void Write(Message* aMsg, const paramType& aParam); - static bool Read(const Message* aMsg, void** aIter, paramType* aResult); + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult); }; } // namespace IPC diff --git a/dom/ipc/StructuredCloneData.cpp b/dom/ipc/StructuredCloneData.cpp index 2c19a23c31..6b3d6c60fc 100644 --- a/dom/ipc/StructuredCloneData.cpp +++ b/dom/ipc/StructuredCloneData.cpp @@ -105,7 +105,7 @@ StructuredCloneData::WriteIPCParams(IPC::Message* aMsg) const bool StructuredCloneData::ReadIPCParams(const IPC::Message* aMsg, - void** aIter) + PickleIterator* aIter) { MOZ_ASSERT(!Data()); diff --git a/dom/ipc/StructuredCloneData.h b/dom/ipc/StructuredCloneData.h index 80ff5dcc58..849bc8a956 100644 --- a/dom/ipc/StructuredCloneData.h +++ b/dom/ipc/StructuredCloneData.h @@ -15,6 +15,7 @@ namespace IPC { class Message; } +class PickleIterator; namespace mozilla { namespace dom { @@ -137,7 +138,7 @@ public: // For IPC serialization void WriteIPCParams(IPC::Message* aMessage) const; - bool ReadIPCParams(const IPC::Message* aMessage, void** aIter); + bool ReadIPCParams(const IPC::Message* aMessage, PickleIterator* aIter); private: uint64_t* MOZ_NON_OWNING_REF mExternalData; diff --git a/dom/ipc/TabChild.cpp b/dom/ipc/TabChild.cpp index 36317b7b5c..89a866a92d 100644 --- a/dom/ipc/TabChild.cpp +++ b/dom/ipc/TabChild.cpp @@ -2072,10 +2072,17 @@ TabChild::RecvRealKeyEvent(const WidgetKeyboardEvent& event, mIgnoreKeyPressEvent = status == nsEventStatus_eConsumeNoDefault; } + // If a response is desired from the content process, resend the key event. + // If mAccessKeyForwardedToChild is set, then don't resend the key event yet + // as RecvHandleAccessKey will do this. if (localEvent.mFlags.mWantReplyFromContentProcess) { SendReplyKeyEvent(localEvent); } + if (localEvent.mAccessKeyForwardedToChild) { + SendAccessKeyNotHandled(localEvent); + } + if (PresShell::BeforeAfterKeyboardEventEnabled()) { SendDispatchAfterKeyboardEvent(localEvent); } @@ -2338,8 +2345,8 @@ TabChild::RecvSwappedWithOtherRemoteLoader(const IPCTabContext& aContext) } bool -TabChild::RecvHandleAccessKey(nsTArray&& aCharCodes, - const bool& aIsTrusted, +TabChild::RecvHandleAccessKey(const WidgetKeyboardEvent& aEvent, + nsTArray&& aCharCodes, const int32_t& aModifierMask) { nsCOMPtr document(GetDocument()); @@ -2347,7 +2354,16 @@ TabChild::RecvHandleAccessKey(nsTArray&& aCharCodes, if (presShell) { nsPresContext* pc = presShell->GetPresContext(); if (pc) { - pc->EventStateManager()->HandleAccessKey(pc, aCharCodes, aIsTrusted, aModifierMask); + if (!pc->EventStateManager()-> + HandleAccessKey(&(const_cast(aEvent)), + pc, aCharCodes, + aModifierMask, true)) { + // If no accesskey was found, inform the parent so that accesskeys on + // menus can be handled. + WidgetKeyboardEvent localEvent(aEvent); + localEvent.mWidget = mPuppetWidget; + SendAccessKeyNotHandled(localEvent); + } } } diff --git a/dom/ipc/TabChild.h b/dom/ipc/TabChild.h index da3491e00b..1825d28209 100644 --- a/dom/ipc/TabChild.h +++ b/dom/ipc/TabChild.h @@ -566,8 +566,8 @@ public: virtual bool RecvThemeChanged(nsTArray&& aLookAndFeelIntCache) override; - virtual bool RecvHandleAccessKey(nsTArray&& aCharCodes, - const bool& aIsTrusted, + virtual bool RecvHandleAccessKey(const WidgetKeyboardEvent& aEvent, + nsTArray&& aCharCodes, const int32_t& aModifierMask) override; virtual bool RecvAudioChannelChangeNotification(const uint32_t& aAudioChannel, diff --git a/dom/ipc/TabMessageUtils.cpp b/dom/ipc/TabMessageUtils.cpp index 6949d1b367..5085a7e95e 100644 --- a/dom/ipc/TabMessageUtils.cpp +++ b/dom/ipc/TabMessageUtils.cpp @@ -13,7 +13,7 @@ namespace mozilla { namespace dom { bool -ReadRemoteEvent(const IPC::Message* aMsg, void** aIter, +ReadRemoteEvent(const IPC::Message* aMsg, PickleIterator* aIter, RemoteDOMEvent* aResult) { aResult->mEvent = nullptr; diff --git a/dom/ipc/TabMessageUtils.h b/dom/ipc/TabMessageUtils.h index 24a5aaf114..aced369d4b 100644 --- a/dom/ipc/TabMessageUtils.h +++ b/dom/ipc/TabMessageUtils.h @@ -24,7 +24,7 @@ struct RemoteDOMEvent nsCOMPtr mEvent; }; -bool ReadRemoteEvent(const IPC::Message* aMsg, void** aIter, +bool ReadRemoteEvent(const IPC::Message* aMsg, PickleIterator* aIter, mozilla::dom::RemoteDOMEvent* aResult); #ifdef MOZ_CRASHREPORTER @@ -49,7 +49,7 @@ struct ParamTraits aParam.mEvent->Serialize(aMsg, true); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { return mozilla::dom::ReadRemoteEvent(aMsg, aIter, aResult); } @@ -75,7 +75,7 @@ struct ParamTraits WriteParam(aMsg, (uint32_t)aValue); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { uint32_t value; if(!ReadParam(aMsg, aIter, &value) || diff --git a/dom/ipc/TabParent.cpp b/dom/ipc/TabParent.cpp index 1f7c7d3154..d601c8c8ac 100644 --- a/dom/ipc/TabParent.cpp +++ b/dom/ipc/TabParent.cpp @@ -932,12 +932,12 @@ TabParent::ThemeChanged() } void -TabParent::HandleAccessKey(nsTArray& aCharCodes, - const bool& aIsTrusted, +TabParent::HandleAccessKey(const WidgetKeyboardEvent& aEvent, + nsTArray& aCharCodes, const int32_t& aModifierMask) { if (!mIsDestroyed) { - Unused << SendHandleAccessKey(aCharCodes, aIsTrusted, aModifierMask); + Unused << SendHandleAccessKey(aEvent, aCharCodes, aModifierMask); } } @@ -1191,7 +1191,7 @@ bool TabParent::SendRealMouseEvent(WidgetMouseEvent& event) ApzAwareEventRoutingToChild(&guid, &blockId, nullptr); if (eMouseMove == event.mMessage) { - if (event.reason == WidgetMouseEvent::eSynthesized) { + if (event.mReason == WidgetMouseEvent::eSynthesized) { return SendSynthMouseMoveEvent(event, guid, blockId); } else { return SendRealMouseMoveEvent(event, guid, blockId); @@ -2074,6 +2074,31 @@ TabParent::RecvDispatchAfterKeyboardEvent(const WidgetKeyboardEvent& aEvent) return true; } +bool +TabParent::RecvAccessKeyNotHandled(const WidgetKeyboardEvent& aEvent) +{ + NS_ENSURE_TRUE(mFrameElement, true); + + WidgetKeyboardEvent localEvent(aEvent); + localEvent.mMessage = eAccessKeyNotFound; + localEvent.mAccessKeyForwardedToChild = false; + + // Here we convert the WidgetEvent that we received to an nsIDOMEvent + // to be able to dispatch it to the element as the target element. + nsIDocument* doc = mFrameElement->OwnerDoc(); + nsIPresShell* presShell = doc->GetShell(); + NS_ENSURE_TRUE(presShell, true); + + if (presShell->CanDispatchEvent()) { + nsPresContext* presContext = presShell->GetPresContext(); + NS_ENSURE_TRUE(presContext, true); + + EventDispatcher::Dispatch(mFrameElement, presContext, &localEvent); + } + + return true; +} + bool TabParent::HandleQueryContentEvent(WidgetQueryContentEvent& aEvent) { diff --git a/dom/ipc/TabParent.h b/dom/ipc/TabParent.h index cbc8e05713..7f35e4a477 100644 --- a/dom/ipc/TabParent.h +++ b/dom/ipc/TabParent.h @@ -168,6 +168,9 @@ public: virtual bool RecvDispatchAfterKeyboardEvent(const WidgetKeyboardEvent& aEvent) override; + virtual bool + RecvAccessKeyNotHandled(const WidgetKeyboardEvent& aEvent) override; + virtual bool RecvBrowserFrameOpenWindow(PBrowserParent* aOpener, PRenderFrameParent* aRenderFrame, const nsString& aURL, @@ -358,8 +361,8 @@ public: void ThemeChanged(); - void HandleAccessKey(nsTArray& aCharCodes, - const bool& aIsTrusted, + void HandleAccessKey(const WidgetKeyboardEvent& aEvent, + nsTArray& aCharCodes, const int32_t& aModifierMask); void Activate(); diff --git a/dom/media/MP3Decoder.cpp b/dom/media/MP3Decoder.cpp index c3cfd229ad..8d82d4b122 100644 --- a/dom/media/MP3Decoder.cpp +++ b/dom/media/MP3Decoder.cpp @@ -9,7 +9,6 @@ #include "MediaDecoderStateMachine.h" #include "MediaFormatReader.h" #include "MP3Demuxer.h" -#include "mozilla/Preferences.h" #include "PDMFactory.h" namespace mozilla { diff --git a/dom/media/MediaFormatReader.cpp b/dom/media/MediaFormatReader.cpp index 09b91eac76..a6a79b8857 100644 --- a/dom/media/MediaFormatReader.cpp +++ b/dom/media/MediaFormatReader.cpp @@ -168,8 +168,6 @@ MediaFormatReader::InitLayersBackendType() mLayersBackendType = layerManager->GetCompositorBackendType(); } -static bool sIsEMEEnabled = false; - nsresult MediaFormatReader::Init() { @@ -183,12 +181,6 @@ MediaFormatReader::Init() mVideo.mTaskQueue = new FlushableTaskQueue(GetMediaThreadPool(MediaThreadType::PLATFORM_DECODER)); - static bool sSetupPrefCache = false; - if (!sSetupPrefCache) { - sSetupPrefCache = true; - Preferences::AddBoolVarCache(&sIsEMEEnabled, "media.eme.enabled", false); - } - return NS_OK; } diff --git a/dom/media/MediaManager.cpp b/dom/media/MediaManager.cpp index 04ba1c7069..ba2eda31ad 100644 --- a/dom/media/MediaManager.cpp +++ b/dom/media/MediaManager.cpp @@ -43,7 +43,6 @@ #include "mozilla/dom/MediaStreamTrackBinding.h" #include "mozilla/dom/GetUserMediaRequestBinding.h" #include "mozilla/dom/Promise.h" -#include "mozilla/Preferences.h" #include "mozilla/Base64.h" #include "mozilla/ipc/BackgroundChild.h" #include "mozilla/media/MediaChild.h" diff --git a/dom/media/MediaPrefs.cpp b/dom/media/MediaPrefs.cpp new file mode 100644 index 0000000000..426c545836 --- /dev/null +++ b/dom/media/MediaPrefs.cpp @@ -0,0 +1,72 @@ +/* -*- Mode: C++; tab-width: 20; 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/. */ + +#include "MediaPrefs.h" + +#include "mozilla/ClearOnShutdown.h" +#include "mozilla/Preferences.h" +#include "mozilla/StaticPtr.h" +#include "MainThreadUtils.h" + +namespace mozilla { + +StaticAutoPtr MediaPrefs::sInstance; + +MediaPrefs& +MediaPrefs::GetSingleton() +{ + if (!sInstance) { + sInstance = new MediaPrefs; + ClearOnShutdown(&sInstance); + } + MOZ_ASSERT(SingletonExists()); + return *sInstance; +} + +bool +MediaPrefs::SingletonExists() +{ + return sInstance != nullptr; +} + +MediaPrefs::MediaPrefs() +{ + MediaPrefs::AssertMainThread(); +} + +void MediaPrefs::AssertMainThread() +{ + MOZ_ASSERT(NS_IsMainThread(), "this code must be run on the main thread"); +} + +void MediaPrefs::PrefAddVarCache(bool* aVariable, + const char* aPref, + bool aDefault) +{ + Preferences::AddBoolVarCache(aVariable, aPref, aDefault); +} + +void MediaPrefs::PrefAddVarCache(int32_t* aVariable, + const char* aPref, + int32_t aDefault) +{ + Preferences::AddIntVarCache(aVariable, aPref, aDefault); +} + +void MediaPrefs::PrefAddVarCache(uint32_t* aVariable, + const char* aPref, + uint32_t aDefault) +{ + Preferences::AddUintVarCache(aVariable, aPref, aDefault); +} + +void MediaPrefs::PrefAddVarCache(float* aVariable, + const char* aPref, + float aDefault) +{ + Preferences::AddFloatVarCache(aVariable, aPref, aDefault); +} + +} // namespace mozilla diff --git a/dom/media/MediaPrefs.h b/dom/media/MediaPrefs.h new file mode 100644 index 0000000000..a6cb83a1c7 --- /dev/null +++ b/dom/media/MediaPrefs.h @@ -0,0 +1,140 @@ +/* -*- Mode: C++; tab-width: 20; 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/. */ + +#ifndef MEDIA_PREFS_H +#define MEDIA_PREFS_H + +// First time MediaPrefs::GetSingleton() needs to be called on the main thread, +// before any of the methods accessing the values are used, but after +// the Preferences system has been initialized. + +// The static methods to access the preference value are safe to call +// from any thread after that first call. + +// To register a preference, you need to add a line in this file using +// the DECL_MEDIA_PREF macro. +// +// For example this line in the .h: +// DECL_MEDIA_PREF("media.resampling.enabled",AudioSinkResampling,bool,false); +// means that you can call +// const bool& var = MediaPrefs::AudioSinkResampling(); +// from any thread, you will get the most up to date preference value of +// "media.resampling.enabled". If the value is not set, the default would be +// false. + +#define DECL_MEDIA_PREF(Pref, Name, Type, Default) \ +public: \ +static const Type& Name() { MOZ_ASSERT(SingletonExists()); return GetSingleton().mPref##Name.mValue; } \ +private: \ +static const char* Get##Name##PrefName() { return Pref; } \ +static Type Get##Name##PrefDefault() { return Default; } \ +PrefTemplate mPref##Name + +// Custom Definitions. +#define GMP_DEFAULT_ASYNC_SHUTDOWN_TIMEOUT 3000 +#define TEST_PREFERENCE_FAKE_RECOGNITION_SERVICE "media.webspeech.test.fake_recognition_service" + +namespace mozilla { + +template class StaticAutoPtr; + +class MediaPrefs final +{ + +private: + // Since we cannot use const char*, use a function that returns it. + template + class PrefTemplate + { + public: + PrefTemplate() + : mValue(Default()) + { + Register(Pref()); + } + T mValue; + private: + void Register(const char* aPreference) + { + AssertMainThread(); + PrefAddVarCache(&mValue, aPreference, mValue); + } + }; + + // This is where DECL_MEDIA_PREF for each of the preferences should go. + + // AudioSink + DECL_MEDIA_PREF("accessibility.monoaudio.enable", MonoAudio, bool, false); + DECL_MEDIA_PREF("media.resampling.enabled", AudioSinkResampling, bool, false); + DECL_MEDIA_PREF("media.resampling.rate", AudioSinkResampleRate, uint32_t, 48000); + DECL_MEDIA_PREF("media.forcestereo.enabled", AudioSinkForceStereo, bool, true); + + // PlatformDecoderModule + DECL_MEDIA_PREF("media.apple.forcevda", AppleForceVDA, bool, false); + DECL_MEDIA_PREF("media.gmp.insecure.allow", GMPAllowInsecure, bool, false); + DECL_MEDIA_PREF("media.gmp.async-shutdown-timeout", GMPAsyncShutdownTimeout, uint32_t, GMP_DEFAULT_ASYNC_SHUTDOWN_TIMEOUT); + DECL_MEDIA_PREF("media.eme.enabled", EMEEnabled, bool, false); + DECL_MEDIA_PREF("media.use-blank-decoder", PDMUseBlankDecoder, bool, false); +#ifdef MOZ_GONK_MEDIACODEC + DECL_MEDIA_PREF("media.gonk.enabled", PDMGonkDecoderEnabled, bool, true); +#endif +#ifdef MOZ_WIDGET_ANDROID + DECL_MEDIA_PREF("media.android-media-codec.enabled", PDMAndroidMediaCodecEnabled, bool, false); + DECL_MEDIA_PREF("media.android-media-codec.preferred", PDMAndroidMediaCodecPreferred, bool, false); +#endif +#ifdef MOZ_FFMPEG + DECL_MEDIA_PREF("media.ffmpeg.enabled", PDMFFmpegEnabled, bool, true); +#endif +#ifdef MOZ_FFVPX + DECL_MEDIA_PREF("media.ffvpx.enabled", PDMFFVPXEnabled, bool, true); +#endif +#ifdef XP_WIN + DECL_MEDIA_PREF("media.wmf.enabled", PDMWMFEnabled, bool, true); + DECL_MEDIA_PREF("media.webm.intel_decoder.enabled", PDMWMFIntelDecoderEnabled, bool, false); + DECL_MEDIA_PREF("media.wmf.low-latency.enabled", PDMWMFLowLatencyEnabled, bool, false); + DECL_MEDIA_PREF("media.wmf.decoder.thread-count", PDMWMFThreadCount, int32_t, -1); +#endif + DECL_MEDIA_PREF("media.decoder.fuzzing.enabled", PDMFuzzingEnabled, bool, false); + DECL_MEDIA_PREF("media.decoder.fuzzing.video-output-minimum-interval-ms", PDMFuzzingInterval, uint32_t, 0); + DECL_MEDIA_PREF("media.decoder.fuzzing.dont-delay-inputexhausted", PDMFuzzingDelayInputExhausted, bool, true); + DECL_MEDIA_PREF("media.gmp.decoder.enabled", PDMGMPEnabled, bool, true); + DECL_MEDIA_PREF("media.gmp.decoder.aac", GMPAACPreferred, uint32_t, 0); + DECL_MEDIA_PREF("media.gmp.decoder.h264", GMPH264Preferred, uint32_t, 0); + + // WebSpeech + DECL_MEDIA_PREF("media.webspeech.synth.force_global_queue", WebSpeechForceGlobal, bool, false); + DECL_MEDIA_PREF("media.webspeech.test.enable", WebSpeechTestEnabled, bool, false); + DECL_MEDIA_PREF("media.webspeech.test.fake_fsm_events", WebSpeechFakeFSMEvents, bool, false); + DECL_MEDIA_PREF(TEST_PREFERENCE_FAKE_RECOGNITION_SERVICE, WebSpeechFakeRecognitionService, bool, false); + DECL_MEDIA_PREF("media.webspeech.recognition.enable", WebSpeechRecognitionEnabled, bool, false); + DECL_MEDIA_PREF("media.webspeech.recognition.force_enable", WebSpeechRecognitionForceEnabled, bool, false); + +public: + // Manage the singleton: + static MediaPrefs& GetSingleton(); + static bool SingletonExists(); + +private: + template friend class StaticAutoPtr; + static StaticAutoPtr sInstance; + + // Creating these to avoid having to include Preferences.h in the .h + static void PrefAddVarCache(bool*, const char*, bool); + static void PrefAddVarCache(int32_t*, const char*, int32_t); + static void PrefAddVarCache(uint32_t*, const char*, uint32_t); + static void PrefAddVarCache(float*, const char*, float); + + static void AssertMainThread(); + + MediaPrefs(); + MediaPrefs(const MediaPrefs&) = delete; + MediaPrefs& operator=(const MediaPrefs&) = delete; +}; + +#undef DECL_MEDIA_PREF /* Don't need it outside of this file */ + +} // namespace mozilla + +#endif /* MEDIA_PREFS_H */ diff --git a/dom/media/gmp/GMPMessageUtils.h b/dom/media/gmp/GMPMessageUtils.h index 62f053d87e..ad4e903132 100644 --- a/dom/media/gmp/GMPMessageUtils.h +++ b/dom/media/gmp/GMPMessageUtils.h @@ -132,7 +132,7 @@ struct ParamTraits WriteParam(aMsg, aParam.mQPMax); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { if (ReadParam(aMsg, aIter, &(aResult->mWidth)) && ReadParam(aMsg, aIter, &(aResult->mHeight)) && @@ -181,7 +181,7 @@ struct ParamTraits WriteParam(aMsg, aParam.mMode); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { // NOTE: make sure this matches any versions supported if (!ReadParam(aMsg, aIter, &(aResult->mGMPApiVersion)) || diff --git a/dom/media/gmp/GMPParent.cpp b/dom/media/gmp/GMPParent.cpp index a68a72f1e9..e08ec3168c 100644 --- a/dom/media/gmp/GMPParent.cpp +++ b/dom/media/gmp/GMPParent.cpp @@ -22,6 +22,7 @@ #include "mozilla/SandboxInfo.h" #endif #include "GMPContentParent.h" +#include "MediaPrefs.h" #ifdef XP_WIN #include "WMFDecoderModule.h" @@ -257,7 +258,7 @@ GMPParent::EnsureAsyncShutdownTimeoutSet() return rv; } - int32_t timeout = GMP_DEFAULT_ASYNC_SHUTDONW_TIMEOUT; + int32_t timeout = MediaPrefs::GMPAsyncShutdownTimeout(); RefPtr service = GeckoMediaPluginServiceParent::GetSingleton(); if (service) { diff --git a/dom/media/gmp/GMPService.cpp b/dom/media/gmp/GMPService.cpp index 72ce9deadc..4f779d1c36 100644 --- a/dom/media/gmp/GMPService.cpp +++ b/dom/media/gmp/GMPService.cpp @@ -13,7 +13,6 @@ #include "GMPVideoDecoderParent.h" #include "nsIObserverService.h" #include "GeckoChildProcessHost.h" -#include "mozilla/Preferences.h" #include "mozilla/ClearOnShutdown.h" #include "mozilla/SyncRunnable.h" #include "nsXPCOMPrivate.h" @@ -24,7 +23,6 @@ #include "GMPDecryptorParent.h" #include "GMPAudioDecoderParent.h" #include "nsComponentManagerUtils.h" -#include "mozilla/Preferences.h" #include "runnable_utils.h" #include "VideoUtils.h" #if defined(XP_LINUX) && defined(MOZ_GMP_SANDBOX) diff --git a/dom/media/gmp/GMPService.h b/dom/media/gmp/GMPService.h index 6b5113621e..4ca717a269 100644 --- a/dom/media/gmp/GMPService.h +++ b/dom/media/gmp/GMPService.h @@ -31,8 +31,6 @@ namespace gmp { class GetGMPContentParentCallback; -#define GMP_DEFAULT_ASYNC_SHUTDONW_TIMEOUT 3000 - class GeckoMediaPluginService : public mozIGeckoMediaPluginService , public nsIObserver { diff --git a/dom/media/gmp/GMPServiceChild.h b/dom/media/gmp/GMPServiceChild.h index 35a9075706..95fa6763a3 100644 --- a/dom/media/gmp/GMPServiceChild.h +++ b/dom/media/gmp/GMPServiceChild.h @@ -15,8 +15,6 @@ namespace mozilla { namespace gmp { -#define GMP_DEFAULT_ASYNC_SHUTDONW_TIMEOUT 3000 - class GMPContentParent; class GMPServiceChild; diff --git a/dom/media/gmp/GMPServiceParent.cpp b/dom/media/gmp/GMPServiceParent.cpp index 450ac20261..ba59c82ce8 100644 --- a/dom/media/gmp/GMPServiceParent.cpp +++ b/dom/media/gmp/GMPServiceParent.cpp @@ -22,7 +22,6 @@ #include "GMPDecryptorParent.h" #include "GMPAudioDecoderParent.h" #include "nsComponentManagerUtils.h" -#include "mozilla/Preferences.h" #include "runnable_utils.h" #include "VideoUtils.h" #if defined(XP_LINUX) && defined(MOZ_GMP_SANDBOX) @@ -41,6 +40,7 @@ #include "nsIXULRuntime.h" #include "GMPDecoderModule.h" #include +#include "MediaPrefs.h" namespace mozilla { @@ -80,10 +80,6 @@ NS_IMPL_ISUPPORTS_INHERITED(GeckoMediaPluginServiceParent, GeckoMediaPluginService, mozIGeckoMediaPluginChromeService) -static int32_t sMaxAsyncShutdownWaitMs = 0; -static bool sAllowInsecureGMP = false; -static bool sHaveSetGMPServiceParentPrefCaches = false; - GeckoMediaPluginServiceParent::GeckoMediaPluginServiceParent() : mShuttingDown(false) #ifdef MOZ_CRASHREPORTER @@ -95,14 +91,6 @@ GeckoMediaPluginServiceParent::GeckoMediaPluginServiceParent() , mLoadPluginsFromDiskComplete(false) { MOZ_ASSERT(NS_IsMainThread()); - if (!sHaveSetGMPServiceParentPrefCaches) { - sHaveSetGMPServiceParentPrefCaches = true; - Preferences::AddIntVarCache(&sMaxAsyncShutdownWaitMs, - "media.gmp.async-shutdown-timeout", - GMP_DEFAULT_ASYNC_SHUTDONW_TIMEOUT); - Preferences::AddBoolVarCache(&sAllowInsecureGMP, - "media.gmp.insecure.allow", false); - } mInitPromise.SetMonitor(&mInitPromiseMonitor); } @@ -115,8 +103,7 @@ GeckoMediaPluginServiceParent::~GeckoMediaPluginServiceParent() int32_t GeckoMediaPluginServiceParent::AsyncShutdownTimeoutMs() { - MOZ_ASSERT(sHaveSetGMPServiceParentPrefCaches); - return sMaxAsyncShutdownWaitMs; + return MediaPrefs::GMPAsyncShutdownTimeout(); } nsresult @@ -1029,7 +1016,7 @@ CreateGMPParent() { #if defined(XP_LINUX) && defined(MOZ_GMP_SANDBOX) if (!SandboxInfo::Get().CanSandboxMedia()) { - if (!sAllowInsecureGMP) { + if (!MediaPrefs::GMPAllowInsecure()) { NS_WARNING("Denying media plugin load due to lack of sandboxing."); return nullptr; } diff --git a/dom/media/gmp/GMPServiceParent.h b/dom/media/gmp/GMPServiceParent.h index 5f456c4c1a..439fbabf1b 100644 --- a/dom/media/gmp/GMPServiceParent.h +++ b/dom/media/gmp/GMPServiceParent.h @@ -23,8 +23,6 @@ namespace gmp { class GMPParent; -#define GMP_DEFAULT_ASYNC_SHUTDONW_TIMEOUT 3000 - class GeckoMediaPluginServiceParent final : public GeckoMediaPluginService , public mozIGeckoMediaPluginChromeService { diff --git a/dom/media/gtest/TestGMPCrossOrigin.cpp b/dom/media/gtest/TestGMPCrossOrigin.cpp index ead44cf6ed..47a048ae8a 100644 --- a/dom/media/gtest/TestGMPCrossOrigin.cpp +++ b/dom/media/gtest/TestGMPCrossOrigin.cpp @@ -13,6 +13,7 @@ #include "GMPVideoEncoderProxy.h" #include "GMPDecryptorProxy.h" #include "GMPServiceParent.h" +#include "MediaPrefs.h" #include "nsAppDirectoryServiceDefs.h" #include "nsIFile.h" #include "nsISimpleEnumerator.h" @@ -33,6 +34,7 @@ struct GMPTestRunner { NS_INLINE_DECL_THREADSAFE_REFCOUNTING(GMPTestRunner) + GMPTestRunner() { MediaPrefs::GetSingleton(); } void DoTest(void (GMPTestRunner::*aTestMethod)(GMPTestMonitor&)); void RunTestGMPTestCodec1(GMPTestMonitor& aMonitor); void RunTestGMPTestCodec2(GMPTestMonitor& aMonitor); diff --git a/dom/media/gtest/TestGMPRemoveAndDelete.cpp b/dom/media/gtest/TestGMPRemoveAndDelete.cpp index ffedf4d30e..3711c83771 100644 --- a/dom/media/gtest/TestGMPRemoveAndDelete.cpp +++ b/dom/media/gtest/TestGMPRemoveAndDelete.cpp @@ -16,6 +16,7 @@ #include "GMPService.h" #include "GMPUtils.h" #include "mozilla/StaticPtr.h" +#include "MediaPrefs.h" #define GMP_DIR_NAME NS_LITERAL_STRING("gmp-fakeopenh264") #define GMP_OLD_VERSION NS_LITERAL_STRING("1.0") @@ -227,6 +228,8 @@ GMPRemoveTest::~GMPRemoveTest() void GMPRemoveTest::Setup() { + // Initialize media preferences. + MediaPrefs::GetSingleton(); GeneratePlugin(); GetService()->GetThread(getter_AddRefs(mGMPThread)); diff --git a/dom/media/gtest/TestGMPUtils.cpp b/dom/media/gtest/TestGMPUtils.cpp index c745e21969..75d7eba53e 100644 --- a/dom/media/gtest/TestGMPUtils.cpp +++ b/dom/media/gtest/TestGMPUtils.cpp @@ -7,6 +7,7 @@ #include "gtest/gtest.h" #include "GMPUtils.h" #include "nsString.h" +#include "MediaPrefs.h" #include #include @@ -19,6 +20,8 @@ void TestSplitAt(const char* aInput, size_t aNumExpectedTokens, const char* aExpectedTokens[]) { + // Initialize media preferences. + MediaPrefs::GetSingleton(); nsCString input(aInput); nsTArray tokens; SplitAt(aDelims, input, tokens); diff --git a/dom/media/mediasink/DecodedAudioDataSink.cpp b/dom/media/mediasink/DecodedAudioDataSink.cpp index 85a9520e00..975eda4505 100644 --- a/dom/media/mediasink/DecodedAudioDataSink.cpp +++ b/dom/media/mediasink/DecodedAudioDataSink.cpp @@ -12,7 +12,7 @@ #include "mozilla/CheckedInt.h" #include "mozilla/DebugOnly.h" -#include "gfxPrefs.h" +#include "MediaPrefs.h" namespace mozilla { @@ -53,10 +53,10 @@ DecodedAudioDataSink::DecodedAudioDataSink(AbstractThread* aThread, , mLastEndTime(0) , mIsAudioDataAudible(false) { - bool resampling = gfxPrefs::AudioSinkResampling(); + bool resampling = MediaPrefs::AudioSinkResampling(); if (resampling) { - mOutputRate = gfxPrefs::AudioSinkResampleRate(); + mOutputRate = MediaPrefs::AudioSinkResampleRate(); } else if (mInfo.mRate == 44100 || mInfo.mRate == 48000) { // The original rate is of good quality and we want to minimize unecessary // resampling. The common scenario being that the sampling rate is one or @@ -69,10 +69,10 @@ DecodedAudioDataSink::DecodedAudioDataSink(AbstractThread* aThread, } MOZ_DIAGNOSTIC_ASSERT(mOutputRate, "output rate can't be 0."); - bool monoAudioEnabled = gfxPrefs::MonoAudio(); + bool monoAudioEnabled = MediaPrefs::MonoAudio(); mOutputChannels = monoAudioEnabled - ? 1 : (gfxPrefs::AudioSinkForceStereo() ? 2 : mInfo.mChannels); + ? 1 : (MediaPrefs::AudioSinkForceStereo() ? 2 : mInfo.mChannels); } DecodedAudioDataSink::~DecodedAudioDataSink() diff --git a/dom/media/mediasource/MediaSourceDecoder.cpp b/dom/media/mediasource/MediaSourceDecoder.cpp index aaf436fd1b..1fb4522f34 100644 --- a/dom/media/mediasource/MediaSourceDecoder.cpp +++ b/dom/media/mediasource/MediaSourceDecoder.cpp @@ -7,7 +7,6 @@ #include "mozilla/Logging.h" #include "mozilla/dom/HTMLMediaElement.h" -#include "mozilla/Preferences.h" #include "MediaDecoderStateMachine.h" #include "MediaSource.h" #include "MediaSourceResource.h" diff --git a/dom/media/moz.build b/dom/media/moz.build index beccfee011..72e056dd63 100644 --- a/dom/media/moz.build +++ b/dom/media/moz.build @@ -116,6 +116,7 @@ EXPORTS += [ 'MediaFormatReader.h', 'MediaInfo.h', 'MediaMetadataManager.h', + 'MediaPrefs.h', 'MediaQueue.h', 'MediaRecorder.h', 'MediaResource.h', @@ -227,6 +228,7 @@ UNIFIED_SOURCES += [ 'MediaFormatReader.cpp', 'MediaInfo.cpp', 'MediaManager.cpp', + 'MediaPrefs.cpp', 'MediaRecorder.cpp', 'MediaResource.cpp', 'MediaShutdownManager.cpp', diff --git a/dom/media/omx/OmxDecoder.cpp b/dom/media/omx/OmxDecoder.cpp index fc2466c35e..3c670014f0 100644 --- a/dom/media/omx/OmxDecoder.cpp +++ b/dom/media/omx/OmxDecoder.cpp @@ -27,7 +27,6 @@ #include "mozilla/layers/GrallocTextureClient.h" #include "mozilla/layers/TextureClient.h" -#include "mozilla/Preferences.h" #include "mozilla/Types.h" #include "mozilla/Monitor.h" #include "nsMimeTypes.h" diff --git a/dom/media/platforms/PDMFactory.cpp b/dom/media/platforms/PDMFactory.cpp index 4de443d69d..bae41e0b66 100644 --- a/dom/media/platforms/PDMFactory.cpp +++ b/dom/media/platforms/PDMFactory.cpp @@ -26,12 +26,12 @@ #endif #include "GMPDecoderModule.h" -#include "mozilla/Preferences.h" #include "mozilla/TaskQueue.h" #include "mozilla/SharedThreadPool.h" #include "MediaInfo.h" +#include "MediaPrefs.h" #include "FuzzingWrapper.h" #include "H264Converter.h" @@ -49,29 +49,6 @@ namespace mozilla { extern already_AddRefed CreateAgnosticDecoderModule(); extern already_AddRefed CreateBlankDecoderModule(); -bool PDMFactory::sUseBlankDecoder = false; -#ifdef MOZ_GONK_MEDIACODEC -bool PDMFactory::sGonkDecoderEnabled = false; -#endif -#ifdef MOZ_WIDGET_ANDROID -bool PDMFactory::sAndroidMCDecoderEnabled = false; -bool PDMFactory::sAndroidMCDecoderPreferred = false; -#endif -bool PDMFactory::sGMPDecoderEnabled = false; -#ifdef MOZ_FFVPX -bool PDMFactory::sFFVPXDecoderEnabled = false; -#endif -#ifdef MOZ_FFMPEG -bool PDMFactory::sFFmpegDecoderEnabled = false; -#endif -#ifdef XP_WIN -bool PDMFactory::sWMFDecoderEnabled = false; -#endif - -bool PDMFactory::sEnableFuzzingWrapper = false; -uint32_t PDMFactory::sVideoOutputMinimumInterval_ms = 0; -bool PDMFactory::sDontDelayInputExhausted = false; - /* static */ void PDMFactory::Init() @@ -83,40 +60,8 @@ PDMFactory::Init() } alreadyInitialized = true; - Preferences::AddBoolVarCache(&sUseBlankDecoder, - "media.use-blank-decoder", false); -#ifdef MOZ_GONK_MEDIACODEC - Preferences::AddBoolVarCache(&sGonkDecoderEnabled, - "media.gonk.enabled", true); -#endif -#ifdef MOZ_WIDGET_ANDROID - Preferences::AddBoolVarCache(&sAndroidMCDecoderEnabled, - "media.android-media-codec.enabled", false); - Preferences::AddBoolVarCache(&sAndroidMCDecoderPreferred, - "media.android-media-codec.preferred", false); -#endif - - Preferences::AddBoolVarCache(&sGMPDecoderEnabled, - "media.gmp.decoder.enabled", true); -#ifdef MOZ_FFMPEG - Preferences::AddBoolVarCache(&sFFmpegDecoderEnabled, - "media.ffmpeg.enabled", true); -#endif -#ifdef MOZ_FFVPX - Preferences::AddBoolVarCache(&sFFVPXDecoderEnabled, - "media.ffvpx.enabled", true); -#endif -#ifdef XP_WIN - Preferences::AddBoolVarCache(&sWMFDecoderEnabled, - "media.wmf.enabled", true); -#endif - - Preferences::AddBoolVarCache(&sEnableFuzzingWrapper, - "media.decoder.fuzzing.enabled", false); - Preferences::AddUintVarCache(&sVideoOutputMinimumInterval_ms, - "media.decoder.fuzzing.video-output-minimum-interval-ms", 0); - Preferences::AddBoolVarCache(&sDontDelayInputExhausted, - "media.decoder.fuzzing.dont-delay-inputexhausted", false); + // Ensure MediaPrefs are initialized. + MediaPrefs::GetSingleton(); #ifdef XP_WIN WMFDecoderModule::Init(); @@ -222,11 +167,11 @@ PDMFactory::CreateDecoderWithPDM(PlatformDecoderModule* aPDM, MediaDataDecoderCallback* callback = aCallback; RefPtr callbackWrapper; - if (sEnableFuzzingWrapper) { + if (MediaPrefs::PDMFuzzingEnabled()) { callbackWrapper = new DecoderCallbackFuzzingWrapper(aCallback); callbackWrapper->SetVideoOutputMinimumInterval( - TimeDuration::FromMilliseconds(sVideoOutputMinimumInterval_ms)); - callbackWrapper->SetDontDelayInputExhausted(sDontDelayInputExhausted); + TimeDuration::FromMilliseconds(MediaPrefs::PDMFuzzingInterval())); + callbackWrapper->SetDontDelayInputExhausted(!MediaPrefs::PDMFuzzingDelayInputExhausted()); callback = callbackWrapper.get(); } @@ -278,7 +223,7 @@ PDMFactory::CreatePDMs() { RefPtr m; - if (sUseBlankDecoder) { + if (MediaPrefs::PDMUseBlankDecoder()) { m = CreateBlankDecoderModule(); StartupPDM(m); // The Blank PDM SupportsMimeType reports true for all codecs; the creation @@ -288,13 +233,14 @@ PDMFactory::CreatePDMs() } #ifdef MOZ_WIDGET_ANDROID - if(sAndroidMCDecoderPreferred && sAndroidMCDecoderEnabled) { + if(MediaPrefs::PDMAndroidMediaCodecPreferred() && + MediaPrefs::PDMAndroidMediaCodecEnabled()) { m = new AndroidDecoderModule(); StartupPDM(m); } #endif #ifdef XP_WIN - if (sWMFDecoderEnabled) { + if (MediaPrefs::PDMWMFEnabled()) { m = new WMFDecoderModule(); if (!StartupPDM(m)) { mWMFFailedToLoad = true; @@ -302,13 +248,13 @@ PDMFactory::CreatePDMs() } #endif #ifdef MOZ_FFVPX - if (sFFVPXDecoderEnabled) { + if (MediaPrefs::PDMFFVPXEnabled()) { m = FFVPXRuntimeLinker::CreateDecoderModule(); StartupPDM(m); } #endif #ifdef MOZ_FFMPEG - if (sFFmpegDecoderEnabled) { + if (MediaPrefs::PDMFFmpegEnabled()) { m = FFmpegRuntimeLinker::CreateDecoderModule(); if (!StartupPDM(m)) { mFFmpegFailedToLoad = true; @@ -320,13 +266,13 @@ PDMFactory::CreatePDMs() StartupPDM(m); #endif #ifdef MOZ_GONK_MEDIACODEC - if (sGonkDecoderEnabled) { + if (MediaPrefs::PDMGonkDecoderEnabled()) { m = new GonkDecoderModule(); StartupPDM(m); } #endif #ifdef MOZ_WIDGET_ANDROID - if(sAndroidMCDecoderEnabled){ + if(MediaPrefs::PDMAndroidMediaCodecEnabled()){ m = new AndroidDecoderModule(); StartupPDM(m); } @@ -335,7 +281,7 @@ PDMFactory::CreatePDMs() m = new AgnosticDecoderModule(); StartupPDM(m); - if (sGMPDecoderEnabled) { + if (MediaPrefs::PDMGMPEnabled()) { m = new GMPDecoderModule(); if (!StartupPDM(m)) { mGMPPDMFailedToStartup = true; diff --git a/dom/media/platforms/PDMFactory.h b/dom/media/platforms/PDMFactory.h index 92a8fe8785..155f0b5f73 100644 --- a/dom/media/platforms/PDMFactory.h +++ b/dom/media/platforms/PDMFactory.h @@ -69,29 +69,6 @@ private: layers::LayersBackend aLayersBackend, layers::ImageContainer* aImageContainer); - // PDM pref caches... - static bool sUseBlankDecoder; -#ifdef MOZ_GONK_MEDIACODEC - static bool sGonkDecoderEnabled; -#endif -#ifdef MOZ_WIDGET_ANDROID - static bool sAndroidMCDecoderPreferred; - static bool sAndroidMCDecoderEnabled; -#endif - static bool sGMPDecoderEnabled; -#ifdef MOZ_FFVPX - static bool sFFVPXDecoderEnabled; -#endif -#ifdef MOZ_FFMPEG - static bool sFFmpegDecoderEnabled; -#endif -#ifdef XP_WIN - static bool sWMFDecoderEnabled; -#endif - static bool sEnableFuzzingWrapper; - static uint32_t sVideoOutputMinimumInterval_ms; - static bool sDontDelayInputExhausted; - nsTArray> mCurrentPDMs; RefPtr mEMEPDM; diff --git a/dom/media/platforms/agnostic/gmp/GMPDecoderModule.cpp b/dom/media/platforms/agnostic/gmp/GMPDecoderModule.cpp index 510c058894..9c3e8ea8cc 100644 --- a/dom/media/platforms/agnostic/gmp/GMPDecoderModule.cpp +++ b/dom/media/platforms/agnostic/gmp/GMPDecoderModule.cpp @@ -9,9 +9,9 @@ #include "GMPAudioDecoder.h" #include "GMPVideoDecoder.h" #include "MediaDataDecoderProxy.h" +#include "MediaPrefs.h" #include "mozIGeckoMediaPluginService.h" #include "nsServiceManagerUtils.h" -#include "mozilla/Preferences.h" #include "mozilla/StaticMutex.h" #include "gmp-audio-decode.h" #include "gmp-video-decode.h" @@ -174,9 +174,6 @@ GMPDecoderModule::UpdateUsableCodecs() } } -static uint32_t sPreferredAacGmp = 0; -static uint32_t sPreferredH264Gmp = 0; - /* static */ void GMPDecoderModule::Init() @@ -187,11 +184,6 @@ GMPDecoderModule::Init() // SupportsMimeType() we build a table of the codecs which each whitelisted // GMP has and update it when any GMPs are removed or added at runtime. UpdateUsableCodecs(); - - Preferences::AddUintVarCache(&sPreferredAacGmp, - "media.gmp.decoder.aac", 0); - Preferences::AddUintVarCache(&sPreferredH264Gmp, - "media.gmp.decoder.h264", 0); } /* static */ @@ -200,7 +192,7 @@ GMPDecoderModule::PreferredGMP(const nsACString& aMimeType) { Maybe rv; if (aMimeType.EqualsLiteral("audio/mp4a-latm")) { - switch (sPreferredAacGmp) { + switch (MediaPrefs::GMPAACPreferred()) { case 1: rv.emplace(NS_LITERAL_CSTRING("org.w3.clearkey")); break; case 2: rv.emplace(NS_LITERAL_CSTRING("com.adobe.primetime")); break; default: break; @@ -209,7 +201,7 @@ GMPDecoderModule::PreferredGMP(const nsACString& aMimeType) if (aMimeType.EqualsLiteral("video/avc") || aMimeType.EqualsLiteral("video/mp4")) { - switch (sPreferredH264Gmp) { + switch (MediaPrefs::GMPH264Preferred()) { case 1: rv.emplace(NS_LITERAL_CSTRING("org.w3.clearkey")); break; case 2: rv.emplace(NS_LITERAL_CSTRING("com.adobe.primetime")); break; default: break; diff --git a/dom/media/platforms/apple/AppleDecoderModule.cpp b/dom/media/platforms/apple/AppleDecoderModule.cpp index 41feab18e7..8cefd50f07 100644 --- a/dom/media/platforms/apple/AppleDecoderModule.cpp +++ b/dom/media/platforms/apple/AppleDecoderModule.cpp @@ -12,7 +12,7 @@ #include "AppleVTDecoder.h" #include "AppleVTLinker.h" #include "MacIOSurfaceImage.h" -#include "mozilla/Preferences.h" +#include "MediaPrefs.h" #include "mozilla/DebugOnly.h" #include "mozilla/Logging.h" @@ -23,7 +23,6 @@ bool AppleDecoderModule::sIsCoreMediaAvailable = false; bool AppleDecoderModule::sIsVTAvailable = false; bool AppleDecoderModule::sIsVTHWAvailable = false; bool AppleDecoderModule::sIsVDAAvailable = false; -bool AppleDecoderModule::sForceVDA = false; bool AppleDecoderModule::sCanUseHardwareVideoDecoder = true; AppleDecoderModule::AppleDecoderModule() @@ -44,8 +43,6 @@ AppleDecoderModule::Init() return; } - Preferences::AddBoolVarCache(&sForceVDA, "media.apple.forcevda", false); - // Ensure IOSurface framework is loaded. MacIOSurfaceLib::LoadLibrary(); const bool loaded = MacIOSurfaceLib::isInit(); @@ -88,7 +85,7 @@ AppleDecoderModule::CreateVideoDecoder(const VideoInfo& aConfig, { RefPtr decoder; - if (sIsVDAAvailable && (!sIsVTHWAvailable || sForceVDA)) { + if (sIsVDAAvailable && (!sIsVTHWAvailable || MediaPrefs::AppleForceVDA())) { decoder = AppleVDADecoder::CreateVDADecoder(aConfig, aVideoTaskQueue, diff --git a/dom/media/platforms/apple/AppleDecoderModule.h b/dom/media/platforms/apple/AppleDecoderModule.h index 355213597f..2b51476f8d 100644 --- a/dom/media/platforms/apple/AppleDecoderModule.h +++ b/dom/media/platforms/apple/AppleDecoderModule.h @@ -50,7 +50,6 @@ private: static bool sIsVTAvailable; static bool sIsVTHWAvailable; static bool sIsVDAAvailable; - static bool sForceVDA; }; } // namespace mozilla diff --git a/dom/media/platforms/gonk/GonkDecoderModule.cpp b/dom/media/platforms/gonk/GonkDecoderModule.cpp index cf23104f38..8661302acd 100644 --- a/dom/media/platforms/gonk/GonkDecoderModule.cpp +++ b/dom/media/platforms/gonk/GonkDecoderModule.cpp @@ -6,7 +6,6 @@ #include "GonkDecoderModule.h" #include "GonkVideoDecoderManager.h" #include "GonkAudioDecoderManager.h" -#include "mozilla/Preferences.h" #include "mozilla/DebugOnly.h" #include "GonkMediaDataDecoder.h" diff --git a/dom/media/platforms/wmf/WMFDecoderModule.cpp b/dom/media/platforms/wmf/WMFDecoderModule.cpp index 29b4d6c7a4..e161434b8c 100644 --- a/dom/media/platforms/wmf/WMFDecoderModule.cpp +++ b/dom/media/platforms/wmf/WMFDecoderModule.cpp @@ -9,7 +9,6 @@ #include "WMFVideoMFTManager.h" #include "WMFAudioMFTManager.h" #include "MFTDecoder.h" -#include "mozilla/Preferences.h" #include "mozilla/DebugOnly.h" #include "mozilla/Services.h" #include "WMFMediaDataDecoder.h" @@ -21,6 +20,7 @@ #include "GfxDriverInfo.h" #include "gfxWindowsPlatform.h" #include "MediaInfo.h" +#include "MediaPrefs.h" #include "prsystem.h" #include "mozilla/Maybe.h" #include "mozilla/StaticMutex.h" @@ -28,9 +28,6 @@ namespace mozilla { static bool sDXVAEnabled = false; -static int sNumDecoderThreads = -1; -static bool sIsIntelDecoderEnabled = false; -static bool sLowLatencyMFTEnabled = false; WMFDecoderModule::WMFDecoderModule() : mWMFInitialized(false) @@ -45,49 +42,30 @@ WMFDecoderModule::~WMFDecoderModule() } } -static void -SetNumOfDecoderThreads() -{ - MOZ_ASSERT(NS_IsMainThread(), "Preferences can only be read on main thread"); - int32_t numCores = PR_GetNumberOfProcessors(); - - // If we have more than 4 cores, let the decoder decide how many threads. - // On an 8 core machine, WMF chooses 4 decoder threads - const int WMF_DECODER_DEFAULT = -1; - int32_t prefThreadCount = Preferences::GetInt("media.wmf.decoder.thread-count", -1); - if (prefThreadCount != WMF_DECODER_DEFAULT) { - sNumDecoderThreads = std::max(prefThreadCount, 1); - } else if (numCores > 4) { - sNumDecoderThreads = WMF_DECODER_DEFAULT; - } else { - sNumDecoderThreads = std::max(numCores - 1, 1); - } -} - /* static */ void WMFDecoderModule::Init() { MOZ_ASSERT(NS_IsMainThread(), "Must be on main thread."); sDXVAEnabled = gfxPlatform::GetPlatform()->CanUseHardwareVideoDecoding(); - Preferences::AddBoolVarCache(&sIsIntelDecoderEnabled, - "media.webm.intel_decoder.enabled"); - sLowLatencyMFTEnabled = Preferences::GetBool("media.wmf.low-latency.enabled", false); - SetNumOfDecoderThreads(); } /* static */ int WMFDecoderModule::GetNumDecoderThreads() { - return sNumDecoderThreads; -} + int32_t numCores = PR_GetNumberOfProcessors(); -/* static */ -bool -WMFDecoderModule::LowLatencyMFTEnabled() -{ - return sLowLatencyMFTEnabled; + // If we have more than 4 cores, let the decoder decide how many threads. + // On an 8 core machine, WMF chooses 4 decoder threads + const int WMF_DECODER_DEFAULT = -1; + int32_t prefThreadCount = MediaPrefs::PDMWMFThreadCount(); + if (prefThreadCount != WMF_DECODER_DEFAULT) { + return std::max(prefThreadCount, 1); + } else if (numCores > 4) { + return WMF_DECODER_DEFAULT; + } + return std::max(numCores - 1, 1); } nsresult @@ -232,7 +210,7 @@ WMFDecoderModule::SupportsMimeType(const nsACString& aMimeType, CanCreateWMFDecoder()) { return true; } - if (sIsIntelDecoderEnabled && sDXVAEnabled) { + if (MediaPrefs::PDMWMFIntelDecoderEnabled() && sDXVAEnabled) { if (aMimeType.EqualsLiteral("video/webm; codecs=vp8") && CanCreateWMFDecoder()) { return true; diff --git a/dom/media/platforms/wmf/WMFDecoderModule.h b/dom/media/platforms/wmf/WMFDecoderModule.h index d2b73deeeb..b6ae92a5fd 100644 --- a/dom/media/platforms/wmf/WMFDecoderModule.h +++ b/dom/media/platforms/wmf/WMFDecoderModule.h @@ -44,7 +44,6 @@ public: // Called from any thread, must call init first static int GetNumDecoderThreads(); - static bool LowLatencyMFTEnabled(); // Accessors that report whether we have the required MFTs available // on the system to play various codecs. Windows Vista doesn't have the diff --git a/dom/media/platforms/wmf/WMFVideoMFTManager.cpp b/dom/media/platforms/wmf/WMFVideoMFTManager.cpp index 508c34bc6a..3518fd8bfb 100644 --- a/dom/media/platforms/wmf/WMFVideoMFTManager.cpp +++ b/dom/media/platforms/wmf/WMFVideoMFTManager.cpp @@ -7,6 +7,7 @@ #include #include "WMFVideoMFTManager.h" #include "MediaDecoderReader.h" +#include "MediaPrefs.h" #include "WMFUtils.h" #include "ImageContainer.h" #include "VideoUtils.h" @@ -249,7 +250,7 @@ WMFVideoMFTManager::InitInternal(bool aForceD3D9) attr->GetUINT32(MF_SA_D3D_AWARE, &aware); attr->SetUINT32(CODECAPI_AVDecNumWorkerThreads, WMFDecoderModule::GetNumDecoderThreads()); - if (WMFDecoderModule::LowLatencyMFTEnabled()) { + if (MediaPrefs::PDMWMFLowLatencyEnabled()) { hr = attr->SetUINT32(CODECAPI_AVLowLatencyMode, TRUE); if (SUCCEEDED(hr)) { LOG("Enabling Low Latency Mode"); diff --git a/dom/media/webaudio/AudioDestinationNode.cpp b/dom/media/webaudio/AudioDestinationNode.cpp index 55ccba817d..137fb7b9ce 100644 --- a/dom/media/webaudio/AudioDestinationNode.cpp +++ b/dom/media/webaudio/AudioDestinationNode.cpp @@ -9,7 +9,6 @@ #include "AudioContext.h" #include "mozilla/dom/AudioDestinationNodeBinding.h" #include "mozilla/dom/ScriptSettings.h" -#include "mozilla/Preferences.h" #include "mozilla/Services.h" #include "AudioChannelAgent.h" #include "AudioChannelService.h" diff --git a/dom/media/webaudio/BiquadFilterNode.cpp b/dom/media/webaudio/BiquadFilterNode.cpp index 25c86e8516..cd8a583cb6 100644 --- a/dom/media/webaudio/BiquadFilterNode.cpp +++ b/dom/media/webaudio/BiquadFilterNode.cpp @@ -12,7 +12,6 @@ #include "PlayingRefChangeHandler.h" #include "WebAudioUtils.h" #include "blink/Biquad.h" -#include "mozilla/Preferences.h" #include "mozilla/UniquePtr.h" #include "AudioParamTimeline.h" diff --git a/dom/media/webaudio/OscillatorNode.h b/dom/media/webaudio/OscillatorNode.h index 970afd5891..1e17e319e8 100644 --- a/dom/media/webaudio/OscillatorNode.h +++ b/dom/media/webaudio/OscillatorNode.h @@ -11,7 +11,6 @@ #include "AudioParam.h" #include "PeriodicWave.h" #include "mozilla/dom/OscillatorNodeBinding.h" -#include "mozilla/Preferences.h" namespace mozilla { namespace dom { diff --git a/dom/media/webaudio/PannerNode.h b/dom/media/webaudio/PannerNode.h index 8c0b77003c..b2fc1d74c4 100644 --- a/dom/media/webaudio/PannerNode.h +++ b/dom/media/webaudio/PannerNode.h @@ -11,7 +11,6 @@ #include "mozilla/dom/PannerNodeBinding.h" #include "ThreeDPoint.h" #include "mozilla/WeakPtr.h" -#include "mozilla/Preferences.h" #include "WebAudioUtils.h" #include diff --git a/dom/media/webm/WebMDemuxer.cpp b/dom/media/webm/WebMDemuxer.cpp index 4b7d5b6991..fb983ed191 100644 --- a/dom/media/webm/WebMDemuxer.cpp +++ b/dom/media/webm/WebMDemuxer.cpp @@ -13,7 +13,6 @@ #include "gfx2DGlue.h" #include "mozilla/Atomics.h" #include "mozilla/Endian.h" -#include "mozilla/Preferences.h" #include "mozilla/SharedThreadPool.h" #include "MediaDataDemuxer.h" #include "nsAutoRef.h" diff --git a/dom/media/webrtc/WebrtcGlobal.h b/dom/media/webrtc/WebrtcGlobal.h index 3c8ed95cf8..1b09704426 100644 --- a/dom/media/webrtc/WebrtcGlobal.h +++ b/dom/media/webrtc/WebrtcGlobal.h @@ -31,7 +31,7 @@ struct ParamTraits> WriteParam(aMsg, false); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { bool was_passed = false; @@ -61,7 +61,7 @@ struct ParamTraits> WriteParam(aMsg, static_cast&>(aParam)); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { return ReadParam(aMsg, aIter, dynamic_cast*>(aResult)); } @@ -114,7 +114,7 @@ struct ParamTraits WriteParam(aMsg, aParam.mTransportStats); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { if (!ReadParam(aMsg, aIter, &(aResult->mClosed)) || !ReadParam(aMsg, aIter, &(aResult->mCodecStats)) || @@ -147,7 +147,7 @@ static void WriteRTCStats(Message* aMsg, const RTCStats& aParam) WriteParam(aMsg, aParam.mType); } -static bool ReadRTCStats(const Message* aMsg, void** aIter, RTCStats* aResult) +static bool ReadRTCStats(const Message* aMsg, PickleIterator* aIter, RTCStats* aResult) { // RTCStats base class if (!ReadParam(aMsg, aIter, &(aResult->mId)) || @@ -174,7 +174,7 @@ struct ParamTraits WriteRTCStats(aMsg, aParam); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { if (!ReadParam(aMsg, aIter, &(aResult->mChannels)) || !ReadParam(aMsg, aIter, &(aResult->mClockRate)) || @@ -207,7 +207,7 @@ struct ParamTraits WriteRTCStats(aMsg, aParam); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { if (!ReadParam(aMsg, aIter, &(aResult->mComponentId)) || !ReadParam(aMsg, aIter, &(aResult->mLocalCandidateId)) || @@ -242,7 +242,7 @@ struct ParamTraits WriteRTCStats(aMsg, aParam); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { if (!ReadParam(aMsg, aIter, &(aResult->mCandidateId)) || !ReadParam(aMsg, aIter, &(aResult->mCandidateType)) || @@ -274,7 +274,7 @@ struct ParamTraits WriteRTCStats(aMsg, aParam); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { if (!ReadParam(aMsg, aIter, &(aResult->mActiveConnection)) || !ReadParam(aMsg, aIter, &(aResult->mBytesReceived)) || @@ -307,7 +307,7 @@ static void WriteRTCRTPStreamStats( } static bool ReadRTCRTPStreamStats( - const Message* aMsg, void** aIter, + const Message* aMsg, PickleIterator* aIter, mozilla::dom::RTCRTPStreamStats* aResult) { if (!ReadParam(aMsg, aIter, &(aResult->mBitrateMean)) || @@ -346,7 +346,7 @@ struct ParamTraits WriteRTCStats(aMsg, aParam); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { if (!ReadParam(aMsg, aIter, &(aResult->mBytesReceived)) || !ReadParam(aMsg, aIter, &(aResult->mDiscardedPackets)) || @@ -380,7 +380,7 @@ struct ParamTraits WriteRTCStats(aMsg, aParam); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { if (!ReadParam(aMsg, aIter, &(aResult->mBytesSent)) || !ReadParam(aMsg, aIter, &(aResult->mDroppedFrames)) || @@ -407,7 +407,7 @@ struct ParamTraits WriteRTCStats(aMsg, aParam); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { if (!ReadParam(aMsg, aIter, &(aResult->mStreamIdentifier)) || !ReadParam(aMsg, aIter, &(aResult->mTrackIds)) || @@ -431,7 +431,7 @@ struct ParamTraits WriteRTCStats(aMsg, aParam); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { if (!ReadParam(aMsg, aIter, &(aResult->mBytesReceived)) || !ReadParam(aMsg, aIter, &(aResult->mBytesSent)) || @@ -467,7 +467,7 @@ struct ParamTraits WriteRTCStats(aMsg, aParam); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { if (!ReadParam(aMsg, aIter, &(aResult->mAudioLevel)) || !ReadParam(aMsg, aIter, &(aResult->mEchoReturnLoss)) || diff --git a/dom/media/webspeech/recognition/SpeechGrammar.cpp b/dom/media/webspeech/recognition/SpeechGrammar.cpp index cbadbf5bc4..c7e30fdf9c 100644 --- a/dom/media/webspeech/recognition/SpeechGrammar.cpp +++ b/dom/media/webspeech/recognition/SpeechGrammar.cpp @@ -6,7 +6,6 @@ #include "SpeechGrammar.h" -#include "mozilla/Preferences.h" #include "mozilla/dom/SpeechGrammarBinding.h" namespace mozilla { diff --git a/dom/media/webspeech/recognition/SpeechRecognition.cpp b/dom/media/webspeech/recognition/SpeechRecognition.cpp index 0f3bf4d0ec..becc63102c 100644 --- a/dom/media/webspeech/recognition/SpeechRecognition.cpp +++ b/dom/media/webspeech/recognition/SpeechRecognition.cpp @@ -15,6 +15,8 @@ #include "mozilla/dom/MediaStreamTrackBinding.h" #include "mozilla/dom/MediaStreamError.h" #include "mozilla/MediaManager.h" +#include "mozilla/Preferences.h" +#include "MediaPrefs.h" #include "mozilla/Services.h" #include "AudioSegment.h" @@ -70,7 +72,7 @@ GetSpeechRecognitionService(const nsAString& aLang) nsAutoCString speechRecognitionServiceCID; nsAdoptingCString prefValue = - Preferences::GetCString(PREFERENCE_DEFAULT_RECOGNITION_SERVICE); + Preferences::GetCString(PREFERENCE_DEFAULT_RECOGNITION_SERVICE); nsAutoCString speechRecognitionService; if (!aLang.IsEmpty()) { @@ -83,7 +85,7 @@ GetSpeechRecognitionService(const nsAString& aLang) speechRecognitionService = DEFAULT_RECOGNITION_SERVICE; } - if (SpeechRecognition::mTestConfig.mFakeRecognitionService) { + if (MediaPrefs::WebSpeechFakeRecognitionService()) { speechRecognitionServiceCID = NS_SPEECH_RECOGNITION_SERVICE_CONTRACTID_PREFIX "fake"; } else { @@ -107,8 +109,6 @@ NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper) NS_IMPL_ADDREF_INHERITED(SpeechRecognition, DOMEventTargetHelper) NS_IMPL_RELEASE_INHERITED(SpeechRecognition, DOMEventTargetHelper) -struct SpeechRecognition::TestConfig SpeechRecognition::mTestConfig; - SpeechRecognition::SpeechRecognition(nsPIDOMWindowInner* aOwnerWindow) : DOMEventTargetHelper(aOwnerWindow) , mEndpointer(kSAMPLE_RATE) @@ -120,8 +120,7 @@ SpeechRecognition::SpeechRecognition(nsPIDOMWindowInner* aOwnerWindow) { SR_LOG("created SpeechRecognition"); - mTestConfig.Init(); - if (mTestConfig.mEnableTests) { + if (MediaPrefs::WebSpeechTestEnabled()) { nsCOMPtr obs = services::GetObserverService(); obs->AddObserver(this, SPEECH_RECOGNITION_TEST_EVENT_REQUEST_TOPIC, false); obs->AddObserver(this, SPEECH_RECOGNITION_TEST_END_TOPIC, false); @@ -175,10 +174,9 @@ SpeechRecognition::IsAuthorized(JSContext* aCx, JSObject* aGlobal) bool hasPermission = (speechRecognition == nsIPermissionManager::ALLOW_ACTION); - bool enableTests = Preferences::GetBool(TEST_PREFERENCE_ENABLE); - bool enableRecognitionEnable = Preferences::GetBool(TEST_PREFERENCE_RECOGNITION_ENABLE); - bool enableRecognitionForceEnable = Preferences::GetBool(TEST_PREFERENCE_RECOGNITION_FORCE_ENABLE); - return (hasPermission || enableRecognitionForceEnable || enableTests) && enableRecognitionEnable; + return (hasPermission || MediaPrefs::WebSpeechRecognitionForceEnabled() + || MediaPrefs::WebSpeechTestEnabled()) + && MediaPrefs::WebSpeechRecognitionEnabled(); } already_AddRefed @@ -617,7 +615,7 @@ SpeechRecognition::Observe(nsISupports* aSubject, const char* aTopic, nsCOMPtr obs = services::GetObserverService(); obs->RemoveObserver(this, SPEECH_RECOGNITION_TEST_EVENT_REQUEST_TOPIC); obs->RemoveObserver(this, SPEECH_RECOGNITION_TEST_END_TOPIC); - } else if (mTestConfig.mFakeFSMEvents && + } else if (MediaPrefs::WebSpeechFakeFSMEvents() && !strcmp(aTopic, SPEECH_RECOGNITION_TEST_EVENT_REQUEST_TOPIC)) { ProcessTestEventRequest(aSubject, nsDependentString(aData)); } @@ -635,7 +633,7 @@ SpeechRecognition::ProcessTestEventRequest(nsISupports* aSubject, const nsAStrin SpeechRecognitionErrorCode::Audio_capture, // TODO different codes? NS_LITERAL_STRING("AUDIO_ERROR test event")); } else { - NS_ASSERTION(mTestConfig.mFakeRecognitionService, + NS_ASSERTION(MediaPrefs::WebSpeechFakeRecognitionService(), "Got request for fake recognition service event, but " TEST_PREFERENCE_FAKE_RECOGNITION_SERVICE " is unset"); diff --git a/dom/media/webspeech/recognition/SpeechRecognition.h b/dom/media/webspeech/recognition/SpeechRecognition.h index 293d9bba27..84736bd696 100644 --- a/dom/media/webspeech/recognition/SpeechRecognition.h +++ b/dom/media/webspeech/recognition/SpeechRecognition.h @@ -21,7 +21,6 @@ #include "MediaStreamGraph.h" #include "AudioSegment.h" #include "mozilla/WeakPtr.h" -#include "mozilla/Preferences.h" #include "SpeechGrammarList.h" #include "SpeechRecognitionResultList.h" @@ -35,11 +34,6 @@ namespace mozilla { namespace dom { -#define TEST_PREFERENCE_ENABLE "media.webspeech.test.enable" -#define TEST_PREFERENCE_FAKE_FSM_EVENTS "media.webspeech.test.fake_fsm_events" -#define TEST_PREFERENCE_FAKE_RECOGNITION_SERVICE "media.webspeech.test.fake_recognition_service" -#define TEST_PREFERENCE_RECOGNITION_ENABLE "media.webspeech.recognition.enable" -#define TEST_PREFERENCE_RECOGNITION_FORCE_ENABLE "media.webspeech.recognition.force_enable" #define SPEECH_RECOGNITION_TEST_EVENT_REQUEST_TOPIC "SpeechRecognitionTest:RequestEvent" #define SPEECH_RECOGNITION_TEST_END_TOPIC "SpeechRecognitionTest:End" @@ -131,33 +125,6 @@ public: AudioSegment* CreateAudioSegment(nsTArray>& aChunks); void FeedAudioData(already_AddRefed aSamples, uint32_t aDuration, MediaStreamListener* aProvider, TrackRate aTrackRate); - static struct TestConfig - { - public: - bool mEnableTests; - bool mFakeFSMEvents; - bool mFakeRecognitionService; - - void Init() - { - if (mInitialized) { - return; - } - - Preferences::AddBoolVarCache(&mEnableTests, TEST_PREFERENCE_ENABLE); - - if (mEnableTests) { - Preferences::AddBoolVarCache(&mFakeFSMEvents, TEST_PREFERENCE_FAKE_FSM_EVENTS); - Preferences::AddBoolVarCache(&mFakeRecognitionService, TEST_PREFERENCE_FAKE_RECOGNITION_SERVICE); - } - - mInitialized = true; - } - private: - bool mInitialized; - } mTestConfig; - - friend class SpeechEvent; private: virtual ~SpeechRecognition() {}; diff --git a/dom/media/webspeech/recognition/test/FakeSpeechRecognitionService.cpp b/dom/media/webspeech/recognition/test/FakeSpeechRecognitionService.cpp index 97dc9ceef9..97bf4b9987 100644 --- a/dom/media/webspeech/recognition/test/FakeSpeechRecognitionService.cpp +++ b/dom/media/webspeech/recognition/test/FakeSpeechRecognitionService.cpp @@ -7,6 +7,7 @@ #include "nsThreadUtils.h" #include "FakeSpeechRecognitionService.h" +#include "MediaPrefs.h" #include "SpeechRecognition.h" #include "SpeechRecognitionAlternative.h" @@ -66,7 +67,7 @@ FakeSpeechRecognitionService::Abort() NS_IMETHODIMP FakeSpeechRecognitionService::Observe(nsISupports* aSubject, const char* aTopic, const char16_t* aData) { - MOZ_ASSERT(mRecognition->mTestConfig.mFakeRecognitionService, + MOZ_ASSERT(MediaPrefs::WebSpeechFakeRecognitionService(), "Got request to fake recognition service event, but " TEST_PREFERENCE_FAKE_RECOGNITION_SERVICE " is not set"); diff --git a/dom/media/webspeech/synth/cocoa/OSXSpeechSynthesizerModule.cpp b/dom/media/webspeech/synth/cocoa/OSXSpeechSynthesizerModule.cpp index 17370a25a3..bc80eb06e7 100644 --- a/dom/media/webspeech/synth/cocoa/OSXSpeechSynthesizerModule.cpp +++ b/dom/media/webspeech/synth/cocoa/OSXSpeechSynthesizerModule.cpp @@ -20,7 +20,7 @@ using namespace mozilla::dom; NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(OSXSpeechSynthesizerService, OSXSpeechSynthesizerService::GetInstanceForService) -// Defines kSAPISERVICE_CID +// Defines kOSXSERVICE_CID NS_DEFINE_NAMED_CID(OSXSPEECHSYNTHESIZERSERVICE_CID); static const mozilla::Module::CIDEntry kCIDs[] = { @@ -34,7 +34,7 @@ static const mozilla::Module::ContractIDEntry kContracts[] = { }; static const mozilla::Module::CategoryEntry kCategories[] = { - { "profile-after-change", "Sapi Speech Synth", OSXSPEECHSYNTHESIZERSERVICE_CONTRACTID }, + { "speech-synth-started", "OSX Speech Synth", OSXSPEECHSYNTHESIZERSERVICE_CONTRACTID }, { nullptr } }; diff --git a/dom/media/webspeech/synth/nsISpeechService.idl b/dom/media/webspeech/synth/nsISpeechService.idl index c802837155..710686f1ed 100644 --- a/dom/media/webspeech/synth/nsISpeechService.idl +++ b/dom/media/webspeech/synth/nsISpeechService.idl @@ -165,3 +165,9 @@ interface nsISpeechService : nsISupports readonly attribute SpeechServiceType serviceType; }; + +%{C++ +// This is the service category speech services could use to start up as +// a component. +#define NS_SPEECH_SYNTH_STARTED "speech-synth-started" +%} diff --git a/dom/media/webspeech/synth/nsSynthVoiceRegistry.cpp b/dom/media/webspeech/synth/nsSynthVoiceRegistry.cpp index f14594ae5c..27e6744a18 100644 --- a/dom/media/webspeech/synth/nsSynthVoiceRegistry.cpp +++ b/dom/media/webspeech/synth/nsSynthVoiceRegistry.cpp @@ -7,7 +7,9 @@ #include "nsILocaleService.h" #include "nsISpeechService.h" #include "nsServiceManagerUtils.h" +#include "nsCategoryManagerUtils.h" +#include "MediaPrefs.h" #include "SpeechSynthesisUtterance.h" #include "SpeechSynthesisVoice.h" #include "nsSynthVoiceRegistry.h" @@ -18,7 +20,6 @@ #include "mozilla/StaticPtr.h" #include "mozilla/dom/ContentChild.h" #include "mozilla/dom/ContentParent.h" -#include "mozilla/Preferences.h" #include "mozilla/unused.h" #include "SpeechSynthesisChild.h" @@ -136,7 +137,6 @@ public: // nsSynthVoiceRegistry static StaticRefPtr gSynthVoiceRegistry; -static bool sForceGlobalQueue = false; NS_IMPL_ISUPPORTS(nsSynthVoiceRegistry, nsISynthVoiceRegistry) @@ -188,8 +188,11 @@ nsSynthVoiceRegistry::GetInstance() if (!gSynthVoiceRegistry) { gSynthVoiceRegistry = new nsSynthVoiceRegistry(); - Preferences::AddBoolVarCache(&sForceGlobalQueue, - "media.webspeech.synth.force_global_queue"); + if (XRE_IsParentProcess()) { + // Start up all speech synth services. + NS_CreateServicesFromCategory(NS_SPEECH_SYNTH_STARTED, nullptr, + NS_SPEECH_SYNTH_STARTED); + } } return gSynthVoiceRegistry; @@ -336,7 +339,7 @@ nsSynthVoiceRegistry::RemoveVoice(nsISpeechService* aService, mDefaultVoices.RemoveElement(retval); mUriVoiceMap.Remove(aUri); - if (retval->mIsQueued && !sForceGlobalQueue) { + if (retval->mIsQueued && !MediaPrefs::WebSpeechForceGlobal()) { // Check if this is the last queued voice, and disable the global queue if // it is. bool queued = false; @@ -707,7 +710,7 @@ nsSynthVoiceRegistry::Speak(const nsAString& aText, aTask->SetChosenVoiceURI(voice->mUri); - if (mUseGlobalQueue || sForceGlobalQueue) { + if (mUseGlobalQueue || MediaPrefs::WebSpeechForceGlobal()) { LOG(LogLevel::Debug, ("nsSynthVoiceRegistry::Speak queueing text='%s' lang='%s' uri='%s' rate=%f pitch=%f", NS_ConvertUTF16toUTF8(aText).get(), NS_ConvertUTF16toUTF8(aLang).get(), @@ -785,7 +788,8 @@ nsSynthVoiceRegistry::SetIsSpeaking(bool aIsSpeaking) MOZ_ASSERT(XRE_IsParentProcess()); // Only set to 'true' if global queue is enabled. - mIsSpeaking = aIsSpeaking && (mUseGlobalQueue || sForceGlobalQueue); + mIsSpeaking = + aIsSpeaking && (mUseGlobalQueue || MediaPrefs::WebSpeechForceGlobal()); nsTArray ssplist; GetAllSpeechSynthActors(ssplist); diff --git a/dom/media/webspeech/synth/speechd/SpeechDispatcherModule.cpp b/dom/media/webspeech/synth/speechd/SpeechDispatcherModule.cpp index deed7c1d29..a7f7ad5352 100644 --- a/dom/media/webspeech/synth/speechd/SpeechDispatcherModule.cpp +++ b/dom/media/webspeech/synth/speechd/SpeechDispatcherModule.cpp @@ -33,7 +33,7 @@ static const mozilla::Module::ContractIDEntry kContracts[] = { }; static const mozilla::Module::CategoryEntry kCategories[] = { - { "profile-after-change", "SpeechDispatcher Speech Synth", SPEECHDISPATCHERSERVICE_CONTRACTID }, + { "speech-synth-started", "SpeechDispatcher Speech Synth", SPEECHDISPATCHERSERVICE_CONTRACTID }, { nullptr } }; diff --git a/dom/media/webspeech/synth/windows/SapiModule.cpp b/dom/media/webspeech/synth/windows/SapiModule.cpp index 729dabcba3..f9d7c9a89d 100644 --- a/dom/media/webspeech/synth/windows/SapiModule.cpp +++ b/dom/media/webspeech/synth/windows/SapiModule.cpp @@ -34,7 +34,7 @@ static const mozilla::Module::ContractIDEntry kContracts[] = { }; static const mozilla::Module::CategoryEntry kCategories[] = { - { "profile-after-change", "Sapi Speech Synth", SAPISERVICE_CONTRACTID }, + { "speech-synth-started", "Sapi Speech Synth", SAPISERVICE_CONTRACTID }, { nullptr } }; diff --git a/dom/mobileconnection/ipc/MobileConnectionIPCSerializer.h b/dom/mobileconnection/ipc/MobileConnectionIPCSerializer.h index 100f7982f3..f7ee3b6ab1 100644 --- a/dom/mobileconnection/ipc/MobileConnectionIPCSerializer.h +++ b/dom/mobileconnection/ipc/MobileConnectionIPCSerializer.h @@ -97,7 +97,7 @@ struct ParamTraits } // Function to de-serialize a MobileCallForwardingOptions. - static bool Read(const Message *aMsg, void **aIter, paramType* aResult) + static bool Read(const Message *aMsg, PickleIterator* aIter, paramType* aResult) { // Check if is the null pointer we have transfered. bool isNull; @@ -176,7 +176,7 @@ struct ParamTraits } // Function to de-serialize a MobileNetworkInfo. - static bool Read(const Message *aMsg, void **aIter, paramType* aResult) + static bool Read(const Message *aMsg, PickleIterator* aIter, paramType* aResult) { // Check if is the null pointer we have transfered. bool isNull; @@ -263,7 +263,7 @@ struct ParamTraits } // Function to de-serialize a MobileCellInfo. - static bool Read(const Message *aMsg, void **aIter, paramType* aResult) + static bool Read(const Message *aMsg, PickleIterator* aIter, paramType* aResult) { // Check if is the null pointer we have transfered. bool isNull; @@ -378,7 +378,7 @@ struct ParamTraits } // Function to de-serialize a MobileConectionInfo. - static bool Read(const Message* aMsg, void **aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { // Check if is the null pointer we have transfered. bool isNull; @@ -541,7 +541,7 @@ struct ParamTraits } // Function to de-serialize a MozCallForwardingOptions. - static bool Read(const Message *aMsg, void **aIter, paramType* aResult) + static bool Read(const Message *aMsg, PickleIterator* aIter, paramType* aResult) { bool wasPassed = false; bool isNull = false; diff --git a/dom/nfc/gonk/NfcService.cpp b/dom/nfc/gonk/NfcService.cpp index 34674b927f..f49905a575 100644 --- a/dom/nfc/gonk/NfcService.cpp +++ b/dom/nfc/gonk/NfcService.cpp @@ -6,11 +6,12 @@ #include "NfcService.h" #include -#include #include "mozilla/ClearOnShutdown.h" #include "mozilla/dom/NfcOptionsBinding.h" #include "mozilla/dom/ToJSValue.h" #include "mozilla/dom/RootedDictionary.h" +#include "mozilla/Endian.h" +#include "mozilla/Hal.h" #include "mozilla/ipc/ListenSocket.h" #include "mozilla/ipc/ListenSocketConsumer.h" #include "mozilla/ipc/NfcConnector.h" @@ -31,6 +32,7 @@ using namespace android; using namespace mozilla::dom; using namespace mozilla::ipc; +using namespace mozilla::hal; namespace mozilla { @@ -108,7 +110,7 @@ NfcConsumer::Start() // If we could not cleanup properly before and an old // instance of the daemon is still running, we kill it // here. - Unused << NS_WARN_IF(property_set("ctl.stop", "nfcd") < 0); + StopSystemService("nfcd"); mHandler = new NfcMessageHandler(); @@ -333,10 +335,8 @@ NfcConsumer::Receive(UnixSocketBuffer* aBuffer) while (aBuffer->GetSize()) { const uint8_t* data = aBuffer->GetData(); - uint32_t parcelSize = ((data[0] & 0xff) << 24) | - ((data[1] & 0xff) << 16) | - ((data[2] & 0xff) << 8) | - (data[3] & 0xff); + uint32_t parcelSize = BigEndian::readUint32(data); + MOZ_ASSERT(parcelSize <= aBuffer->GetSize()); // TODO: Zero-copy buffer transfers @@ -378,9 +378,10 @@ NfcConsumer::OnConnectSuccess(int aIndex) switch (aIndex) { case LISTEN_SOCKET: { - nsCString value("nfcd:-S -a "); - value.Append(mListenSocketName); - if (NS_WARN_IF(property_set("ctl.start", value.get()) < 0)) { + nsCString args("-S -a "); + args.Append(mListenSocketName); + nsresult rv = StartSystemService("nfcd", args.get()); + if (NS_FAILED(rv)) { OnConnectError(STREAM_SOCKET); } break; diff --git a/dom/plugins/base/nsPluginInstanceOwner.cpp b/dom/plugins/base/nsPluginInstanceOwner.cpp index 4bb21225c7..e9f786fa7b 100644 --- a/dom/plugins/base/nsPluginInstanceOwner.cpp +++ b/dom/plugins/base/nsPluginInstanceOwner.cpp @@ -2229,7 +2229,7 @@ TranslateToNPCocoaEvent(WidgetGUIEvent* anEvent, nsIFrame* aObjectFrame) default: NS_WARNING("Mouse button we don't know about?"); } - cocoaEvent.data.mouse.clickCount = mouseEvent->clickCount; + cocoaEvent.data.mouse.clickCount = mouseEvent->mClickCount; } else { NS_WARNING("eMouseUp/DOWN is not a WidgetMouseEvent?"); } @@ -2411,7 +2411,7 @@ nsEventStatus nsPluginInstanceOwner::ProcessEvent(const WidgetGUIEvent& anEvent) static const int dblClickMsgs[] = { WM_LBUTTONDBLCLK, WM_MBUTTONDBLCLK, WM_RBUTTONDBLCLK }; const WidgetMouseEvent* mouseEvent = anEvent.AsMouseEvent(); - if (mouseEvent->clickCount == 2) { + if (mouseEvent->mClickCount == 2) { pluginEvent.event = dblClickMsgs[mouseEvent->button]; } else { pluginEvent.event = downMsgs[mouseEvent->button]; @@ -2854,7 +2854,7 @@ nsEventStatus nsPluginInstanceOwner::ProcessEvent(const WidgetGUIEvent& anEvent) { const WidgetKeyboardEvent& keyEvent = *anEvent.AsKeyboardEvent(); LOG("Firing eKeyboardEventClass %d %d\n", - keyEvent.keyCode, keyEvent.charCode); + keyEvent.mKeyCode, keyEvent.mCharCode); // pluginEvent is initialized by nsWindow::InitKeyEvent(). const ANPEvent* pluginEvent = static_cast(keyEvent.mPluginEvent); if (pluginEvent) { diff --git a/dom/plugins/ipc/NPEventAndroid.h b/dom/plugins/ipc/NPEventAndroid.h index 8189f8f3ef..902657da26 100644 --- a/dom/plugins/ipc/NPEventAndroid.h +++ b/dom/plugins/ipc/NPEventAndroid.h @@ -37,7 +37,7 @@ struct ParamTraits aMsg->WriteBytes(&aParam, sizeof(paramType)); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { const char* bytes = 0; diff --git a/dom/plugins/ipc/NPEventOSX.h b/dom/plugins/ipc/NPEventOSX.h index c3a76c9402..ca1736a8a5 100644 --- a/dom/plugins/ipc/NPEventOSX.h +++ b/dom/plugins/ipc/NPEventOSX.h @@ -82,7 +82,7 @@ struct ParamTraits aMsg->WriteDouble(aParam.contentsScaleFactor); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { int type = 0; if (!aMsg->ReadInt(aIter, &type)) { diff --git a/dom/plugins/ipc/NPEventUnix.h b/dom/plugins/ipc/NPEventUnix.h index 24c403af6d..5c3c0c8bf5 100644 --- a/dom/plugins/ipc/NPEventUnix.h +++ b/dom/plugins/ipc/NPEventUnix.h @@ -55,7 +55,7 @@ struct ParamTraits // synonym for XEvent aMsg->WriteBytes(&aParam, sizeof(paramType)); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { const char* bytes = 0; diff --git a/dom/plugins/ipc/NPEventWindows.h b/dom/plugins/ipc/NPEventWindows.h index 79a694b7bd..3e9aba201b 100644 --- a/dom/plugins/ipc/NPEventWindows.h +++ b/dom/plugins/ipc/NPEventWindows.h @@ -130,7 +130,7 @@ struct ParamTraits aMsg->WriteBytes(¶mCopy, sizeof(paramType)); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { const char* bytes = 0; diff --git a/dom/plugins/ipc/PluginMessageUtils.h b/dom/plugins/ipc/PluginMessageUtils.h index 3019ac3231..aab77f7014 100644 --- a/dom/plugins/ipc/PluginMessageUtils.h +++ b/dom/plugins/ipc/PluginMessageUtils.h @@ -280,7 +280,7 @@ struct ParamTraits WriteParam(aMsg, aParam.right); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { uint16_t top, left, bottom, right; if (ReadParam(aMsg, aIter, &top) && @@ -313,7 +313,7 @@ struct ParamTraits aMsg->WriteInt16(int16_t(aParam)); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { int16_t result; if (aMsg->ReadInt16(aIter, &result)) { @@ -352,7 +352,7 @@ struct ParamTraits #endif } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { uint64_t window; int32_t x, y; @@ -443,7 +443,7 @@ struct ParamTraits } } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { bool haveString = false; if (!aMsg->ReadBool(aIter, &haveString)) { @@ -507,7 +507,7 @@ struct ParamTraits free(buffer); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { NSCursorInfo::Type type; if (!aMsg->ReadInt(aIter, (int*)&type)) { @@ -566,7 +566,7 @@ struct ParamTraits static void Write(Message* aMsg, const paramType& aParam) { NS_RUNTIMEABORT("NSCursorInfo isn't meaningful on this platform"); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) { + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { NS_RUNTIMEABORT("NSCursorInfo isn't meaningful on this platform"); return false; } @@ -584,7 +584,7 @@ struct ParamTraits WriteParam(aMsg, aParam.length); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { paramType p; if (ReadParam(aMsg, aIter, &p.offset) && @@ -606,7 +606,7 @@ struct ParamTraits WriteParam(aMsg, int(aParam)); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { int intval; if (ReadParam(aMsg, aIter, &intval)) { @@ -627,7 +627,7 @@ struct ParamTraits WriteParam(aMsg, int(aParam)); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { int intval; if (ReadParam(aMsg, aIter, &intval)) { @@ -653,7 +653,7 @@ struct ParamTraits WriteParam(aMsg, int32_t(aParam)); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { int32_t intval; if (ReadParam(aMsg, aIter, &intval)) { diff --git a/dom/telephony/ipc/TelephonyIPCSerializer.h b/dom/telephony/ipc/TelephonyIPCSerializer.h index a0f22d7418..7461adabc4 100644 --- a/dom/telephony/ipc/TelephonyIPCSerializer.h +++ b/dom/telephony/ipc/TelephonyIPCSerializer.h @@ -83,7 +83,7 @@ struct ParamTraits WriteParam(aMsg, isMergeable); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { // Check if is the null pointer we have transfered. bool isNull; diff --git a/dom/tests/mochitest/pointerlock/file_childIframe.html b/dom/tests/mochitest/pointerlock/file_childIframe.html index 6217f5912f..630f0e5032 100644 --- a/dom/tests/mochitest/pointerlock/file_childIframe.html +++ b/dom/tests/mochitest/pointerlock/file_childIframe.html @@ -108,6 +108,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=633602 secondMove.mozMovementY = e.mozMovementY; parent.removeEventListener("mousemove", secondMoveChild); + addFullscreenChangeContinuation("exit", function() { + runTests(); + SimpleTest.finish(); + }); document.exitFullscreen(); }; @@ -118,21 +122,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=633602 } }, false); - document.addEventListener("mozpointerlockerror", function () { - document.exitFullscreen(); - }, false); - - document.addEventListener("fullscreenchange", function (e) { - if (document.fullscreenElement === parent) { - parent.mozRequestPointerLock(); - } - else { - runTests(); - SimpleTest.finish(); - } - }, false); - function start() { + addFullscreenChangeContinuation("enter", function() { + parent.mozRequestPointerLock(); + }); parent.requestFullscreen(); } diff --git a/dom/tests/mochitest/pointerlock/file_doubleLock.html b/dom/tests/mochitest/pointerlock/file_doubleLock.html index e0ba28e9af..3f7583beb6 100644 --- a/dom/tests/mochitest/pointerlock/file_doubleLock.html +++ b/dom/tests/mochitest/pointerlock/file_doubleLock.html @@ -40,6 +40,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=633602 document.addEventListener("mozpointerlockchange", function (e) { if (document.mozPointerLockElement === div) { if (numberOfLocks === 2) { + addFullscreenChangeContinuation("exit", function() { + runTests(); + SimpleTest.finish(); + }); document.exitFullscreen(); } else { @@ -49,18 +53,11 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=633602 } }, false); - document.addEventListener("fullscreenchange", function (e) { - if (document.fullscreenElement === div) { - div.mozRequestPointerLock(); - } - else { - runTests(); - SimpleTest.finish(); - } - }, false); - function start() { console.log('started'); + addFullscreenChangeContinuation("enter", function() { + div.mozRequestPointerLock(); + }); div.requestFullscreen(); } diff --git a/dom/tests/mochitest/pointerlock/file_escapeKey.html b/dom/tests/mochitest/pointerlock/file_escapeKey.html index 5032f68051..219a24135a 100644 --- a/dom/tests/mochitest/pointerlock/file_escapeKey.html +++ b/dom/tests/mochitest/pointerlock/file_escapeKey.html @@ -29,12 +29,11 @@ , pointerUnLocked = false; function start() { - document.addEventListener("fullscreenchange", enteredFullscreen); + addFullscreenChangeContinuation("enter", enteredFullscreen); div.requestFullscreen(); } function enteredFullscreen(e) { - document.removeEventListener("fullscreenchange", enteredFullscreen); is(document.fullscreenElement, div, "Element #div should entered fullscreen"); ok(!document.mozPointerLockElement, "Pointer shouldn't have been locked"); document.addEventListener("mozpointerlockchange", lockedPointer); @@ -45,7 +44,7 @@ document.removeEventListener("mozpointerlockchange", lockedPointer); is(document.mozPointerLockElement, div, "Pointer should have been locked on #div"); document.addEventListener("mozpointerlockchange", unlockedPointer); - document.addEventListener("fullscreenchange", leavedFullscreen); + addFullscreenChangeContinuation("exit", leavedFullscreen); SimpleTest.executeSoon(() => synthesizeKey("VK_ESCAPE", {})); } @@ -61,7 +60,6 @@ } function leavedFullscreen() { - document.removeEventListener("fullscreenchange", leavedFullscreen); ok(!exitedFullscreen, "Shouldn't have exited fullscreen before"); ok(!document.fullscreenElement, "Should have exited fullscreen now"); exitedFullscreen = true; diff --git a/dom/tests/mochitest/pointerlock/file_infiniteMovement.html b/dom/tests/mochitest/pointerlock/file_infiniteMovement.html index 23fcdd2ca2..6f75b2f3bc 100644 --- a/dom/tests/mochitest/pointerlock/file_infiniteMovement.html +++ b/dom/tests/mochitest/pointerlock/file_infiniteMovement.html @@ -65,6 +65,11 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=633602 totalMovementY = divCenterHeight + ((divCenterHeight / 2) * 3); div.removeEventListener("mousemove", secondMoveListener, false); + addFullscreenChangeContinuation("exit", function() { + info("Got fullscreenchange for exiting"); + runTests(); + SimpleTest.finish(); + }); document.exitFullscreen(); } @@ -84,20 +89,12 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=633602 } }, false); - document.addEventListener("fullscreenchange", function() { - if (document.fullscreenElement === div) { - info("Got fullscreenchange for entering"); - div.mozRequestPointerLock(); - } - else { - info("Got fullscreenchange for exiting"); - runTests(); - SimpleTest.finish(); - } - }, false); - function start() { info("Requesting fullscreen on parent"); + addFullscreenChangeContinuation("enter", function() { + info("Got fullscreenchange for entering"); + div.mozRequestPointerLock(); + }); div.requestFullscreen(); } diff --git a/dom/tests/mochitest/pointerlock/file_locksvgelement.html b/dom/tests/mochitest/pointerlock/file_locksvgelement.html index 38e81fbe9a..d68d4062a7 100644 --- a/dom/tests/mochitest/pointerlock/file_locksvgelement.html +++ b/dom/tests/mochitest/pointerlock/file_locksvgelement.html @@ -41,21 +41,19 @@ elemWasLocked = true; document.mozExitPointerLock(); } else { + addFullscreenChangeContinuation("exit", function() { + ok(elemWasLocked, "Expected SVG elem to become locked."); + SimpleTest.finish(); + }); document.exitFullscreen(); } }, false); - document.addEventListener("fullscreenchange", function (e) { - if (document.fullscreenElement === elem) { - elem.mozRequestPointerLock(); - } else { - ok(elemWasLocked, "Expected SVG elem to become locked."); - SimpleTest.finish(); - } - }, false); - function start() { elem = document.getElementById("svg-elem"); + addFullscreenChangeContinuation("enter", function() { + elem.mozRequestPointerLock(); + }); elem.requestFullscreen(); } diff --git a/dom/tests/mochitest/pointerlock/file_movementXY.html b/dom/tests/mochitest/pointerlock/file_movementXY.html index 28e6f06fdd..bf75249344 100644 --- a/dom/tests/mochitest/pointerlock/file_movementXY.html +++ b/dom/tests/mochitest/pointerlock/file_movementXY.html @@ -82,35 +82,21 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=633602 secondMove.mozMovementY = e.mozMovementY; div.removeEventListener("mousemove", moveMouseAgain, false); - document.exitFullscreen(); - }; - - function fullscreenchange() { - if (document.fullscreenElement === div) { - info("Got fullscreenchange for entering"); - var screenX = window.screenX; - var screenY = window.screenY; - if (screenX != 0 || screenY != 0) { - todo(screenX == 0 && screenY == 0, - "We should only receive fullscreenchange once we've finished fullscreen transition"); - setTimeout(fullscreenchange, 250); - return; - } - info("Finish waiting for fullscreenchange"); - div.addEventListener("mousemove", moveMouse, false); - synthesizeMouseAtCenter(div, {type: "mousemove"}, window); - } - else { + addFullscreenChangeContinuation("exit", function() { info("Got fullscreenchange for exiting"); runTests(); SimpleTest.finish(); - } - } - - document.addEventListener("fullscreenchange", fullscreenchange, false); + }); + document.exitFullscreen(); + }; function start() { info("Requesting fullscreen on parent"); + addFullscreenChangeContinuation("enter", function() { + info("Got fullscreenchange for entering"); + div.addEventListener("mousemove", moveMouse, false); + synthesizeMouseAtCenter(div, {type: "mousemove"}, window); + }); div.requestFullscreen(); } diff --git a/dom/tests/mochitest/pointerlock/file_nestedFullScreen.html b/dom/tests/mochitest/pointerlock/file_nestedFullScreen.html index d946e39de6..30892bc71d 100644 --- a/dom/tests/mochitest/pointerlock/file_nestedFullScreen.html +++ b/dom/tests/mochitest/pointerlock/file_nestedFullScreen.html @@ -49,30 +49,26 @@ document.addEventListener("mozpointerlockchange", function (e) { if (document.mozPointerLockElement === parentDiv) { parentDivLocked = true; + addFullscreenChangeContinuation("enter", function() { + pointerLocked = !!document.mozPointerLockElement; + addFullscreenChangeContinuation("exit", function() { + addFullscreenChangeContinuation("exit", function() { + runTests(); + SimpleTest.finish(); + }); + document.exitFullscreen(); + }); + document.exitFullscreen(); + }); childDiv.requestFullscreen(); } }, false); - document.addEventListener("fullscreenchange", function() { - if (document.fullscreenElement === parentDiv) { - if (parentDivFullScreen === true) { - document.exitFullscreen(); - } else { - parentDivFullScreen = true; - parentDiv.mozRequestPointerLock(); - } - } - else if (document.fullscreenElement === childDiv) { - pointerLocked = !!document.mozPointerLockElement; - document.exitFullscreen(); - } - else { - runTests(); - SimpleTest.finish(); - } - }, false); - function start() { + addFullscreenChangeContinuation("enter", function() { + parentDivFullScreen = true; + parentDiv.mozRequestPointerLock(); + }); parentDiv.requestFullscreen(); } diff --git a/dom/tests/mochitest/pointerlock/file_pointerLockPref.html b/dom/tests/mochitest/pointerlock/file_pointerLockPref.html index 5362bf496b..51dd01f398 100644 --- a/dom/tests/mochitest/pointerlock/file_pointerLockPref.html +++ b/dom/tests/mochitest/pointerlock/file_pointerLockPref.html @@ -52,24 +52,21 @@ document.addEventListener("mozpointerlockerror", function (e) { prefDisabled = true; - document.exitFullscreen(); - }, false); - - document.addEventListener("fullscreenchange", function (e) { - if (document.fullscreenElement === div) { - SpecialPowers.setBoolPref("full-screen-api.pointer-lock.enabled", - true ); - div.mozRequestPointerLock(); - } - else { + addFullscreenChangeContinuation("exit", function() { SpecialPowers.setBoolPref("full-screen-api.pointer-lock.enabled", true ); runTests(); SimpleTest.finish(); - } + }); + document.exitFullscreen(); }, false); function start() { + addFullscreenChangeContinuation("enter", function() { + SpecialPowers.setBoolPref("full-screen-api.pointer-lock.enabled", + true ); + div.mozRequestPointerLock(); + }); div.requestFullscreen(); } diff --git a/dom/tests/mochitest/pointerlock/file_pointerlock-api.html b/dom/tests/mochitest/pointerlock/file_pointerlock-api.html index 3dbea527d2..c1bd905a2b 100644 --- a/dom/tests/mochitest/pointerlock/file_pointerlock-api.html +++ b/dom/tests/mochitest/pointerlock/file_pointerlock-api.html @@ -79,25 +79,23 @@ } else { info("Got mozpointerlockchange for exiting"); pointerUnlocked = true; + addFullscreenChangeContinuation("exit", function() { + info("Got fullscreenchange for exiting"); + runTests(); + SimpleTest.finish(); + }); document.exitFullscreen(); } }, false); - document.addEventListener("fullscreenchange", function(e) { - if (document.fullscreenElement === div) { - info("Got fullscreenchange for entering"); - hasRequestPointerLock = "mozRequestPointerLock" in div; - div.mozRequestPointerLock(); - } else { - info("Got fullscreenchange for exiting"); - runTests(); - SimpleTest.finish(); - } - }, false); - function start() { div = document.getElementById("div"); info("Requesting fullscreen on parent"); + addFullscreenChangeContinuation("enter", function() { + info("Got fullscreenchange for entering"); + hasRequestPointerLock = "mozRequestPointerLock" in div; + div.mozRequestPointerLock(); + }); div.requestFullscreen(); } diff --git a/dom/tests/mochitest/pointerlock/file_removedFromDOM.html b/dom/tests/mochitest/pointerlock/file_removedFromDOM.html index 819a798a37..9c11cb9e92 100644 --- a/dom/tests/mochitest/pointerlock/file_removedFromDOM.html +++ b/dom/tests/mochitest/pointerlock/file_removedFromDOM.html @@ -51,7 +51,7 @@ function checkPointerLockElement(elem) { } function start() { - listenOneDocEvent("fullscreenchange", enteredFullscreen); + addFullscreenChangeContinuation("enter", enteredFullscreen); document.documentElement.requestFullscreen(); } @@ -82,7 +82,7 @@ function lockedPointerOnInner() { function unlockedPointerFromInner() { checkPointerLockElement(null); - listenOneDocEvent("fullscreenchange", exitedFullscreen); + addFullscreenChangeContinuation("exit", exitedFullscreen); document.exitFullscreen(); } diff --git a/dom/tests/mochitest/pointerlock/file_retargetMouseEvents.html b/dom/tests/mochitest/pointerlock/file_retargetMouseEvents.html index c4400cf87f..33855e350b 100644 --- a/dom/tests/mochitest/pointerlock/file_retargetMouseEvents.html +++ b/dom/tests/mochitest/pointerlock/file_retargetMouseEvents.html @@ -171,6 +171,11 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=633602 child.removeEventListener("mousemove", childMoveTest); SimpleTest.executeSoon(function () { info("Exit fullscreen"); + addFullscreenChangeContinuation("exit", function() { + info("Got fullscreenchange for exiting"); + runTests(); + SimpleTest.finish(); + }); document.exitFullscreen(); }); } @@ -188,19 +193,12 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=633602 } }, false); - document.addEventListener("fullscreenchange", function (e) { - if (document.fullscreenElement === parent) { - info("Got fullscreenchange for entering"); - parent.mozRequestPointerLock(); - } else { - info("Got fullscreenchange for exiting"); - runTests(); - SimpleTest.finish(); - } - }, false); - function start() { info("Requesting fullscreen on parent"); + addFullscreenChangeContinuation("enter", function() { + info("Got fullscreenchange for entering"); + parent.mozRequestPointerLock(); + }); parent.requestFullscreen(); } diff --git a/dom/tests/mochitest/pointerlock/file_screenClientXYConst.html b/dom/tests/mochitest/pointerlock/file_screenClientXYConst.html index f040bb12a3..2a5b9c71d8 100644 --- a/dom/tests/mochitest/pointerlock/file_screenClientXYConst.html +++ b/dom/tests/mochitest/pointerlock/file_screenClientXYConst.html @@ -82,6 +82,11 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=633602 clientY: e.clientY }; + addFullscreenChangeContinuation("exit", function() { + info("Got fullscreenchange for exiting"); + runTests(); + SimpleTest.finish(); + }); document.exitFullscreen(); } @@ -98,35 +103,17 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=633602 } }, false); - function fullscreenchange() { - var screenX = window.screenX; - var screenY = window.screenY; - if (document.fullscreenElement === div) { + function start() { + div = document.getElementById("div"); + info("Requesting fullscreen on parent"); + addFullscreenChangeContinuation("enter", function() { info("Got fullscreenchange for entering"); - if (screenX != 0 || screenY != 0) { - todo(screenX == 0 && screenY == 0, - "We should only receive fullscreenchange once we've finished fullscreen transition " + - "window.screenX=" + screenX + " window.screenY=" + screenY); - setTimeout(fullscreenchange, 250); - return; - } - info("Finish waiting for fullscreenchange"); synthesizeNativeMouseMove(div, 0, 0, () => { div.addEventListener("mousemove", moveUnlocked, false); divRect = div.getBoundingClientRect(); synthesizeNativeMouseMove(div, divRect.width / 2, divRect.height / 2); }); - } else { - info("Got fullscreenchange for exiting"); - runTests(); - SimpleTest.finish(); - } - } - document.addEventListener("fullscreenchange", fullscreenchange, false); - - function start() { - div = document.getElementById("div"); - info("Requesting fullscreen on parent"); + }); div.requestFullscreen(); } diff --git a/dom/tests/mochitest/pointerlock/file_suppressSomeMouseEvents.html b/dom/tests/mochitest/pointerlock/file_suppressSomeMouseEvents.html index e286110401..04d145f3e7 100644 --- a/dom/tests/mochitest/pointerlock/file_suppressSomeMouseEvents.html +++ b/dom/tests/mochitest/pointerlock/file_suppressSomeMouseEvents.html @@ -137,23 +137,20 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=633602 synthesizeMouseAtCenter(child, { type: "mousemove" }, window); } else { + addFullscreenChangeContinuation("exit", function() { + runTests(); + SimpleTest.finish(); + }); document.exitFullscreen(); } }, false); - document.addEventListener("fullscreenchange", function() { - if (document.fullscreenElement === parent) { - parent.mozRequestPointerLock(); - } - else { - runTests(); - SimpleTest.finish(); - } - }, false); - function start() { parent = document.getElementById("parent"); child = document.getElementById("child"); + addFullscreenChangeContinuation("enter", function() { + parent.mozRequestPointerLock(); + }); parent.requestFullscreen(); } diff --git a/dom/tests/mochitest/pointerlock/file_targetOutOfFocus.html b/dom/tests/mochitest/pointerlock/file_targetOutOfFocus.html index b4e8cf44e0..c1dd24b5e3 100644 --- a/dom/tests/mochitest/pointerlock/file_targetOutOfFocus.html +++ b/dom/tests/mochitest/pointerlock/file_targetOutOfFocus.html @@ -48,20 +48,18 @@ document.addEventListener("mozpointerlockchange", function (e) { if (document.mozPointerLockElement === div) { divPointerLock = true; + addFullscreenChangeContinuation("exit", function() { + runTests(); + SimpleTest.finish(); + }); document.exitFullscreen(); } }, false); - document.addEventListener("fullscreenchange", function() { - if (document.fullscreenElement === div) { - input.focus(); - } else { - runTests(); - SimpleTest.finish(); - } - }, false); - function start() { + addFullscreenChangeContinuation("enter", function() { + input.focus(); + }); div.requestFullscreen(); } diff --git a/dom/tests/mochitest/pointerlock/mochitest.ini b/dom/tests/mochitest/pointerlock/mochitest.ini index 14a5b627e2..8ff063a343 100644 --- a/dom/tests/mochitest/pointerlock/mochitest.ini +++ b/dom/tests/mochitest/pointerlock/mochitest.ini @@ -21,4 +21,5 @@ support-files = iframe_differentDOM.html [test_pointerlock-api.html] -skip-if = buildapp == 'b2g' || toolkit == 'android' # B2G - window.open focus issues using fullscreen. +tags = fullscreen +skip-if = buildapp == 'b2g' || toolkit == 'android' || os == 'win' # B2G - window.open focus issues using fullscreen. Win: Bug 931445 diff --git a/dom/tests/mochitest/pointerlock/pointerlock_utils.js b/dom/tests/mochitest/pointerlock/pointerlock_utils.js index 825aa75e95..163315822d 100644 --- a/dom/tests/mochitest/pointerlock/pointerlock_utils.js +++ b/dom/tests/mochitest/pointerlock/pointerlock_utils.js @@ -1,62 +1,46 @@ -const isWinXP = navigator.userAgent.indexOf("Windows NT 5.1") != -1; -const isOSXLion = navigator.userAgent.indexOf("Mac OS X 10.7") != -1; +// Get test filename for page being run in popup so errors are more useful +var testName = location.pathname.split('/').pop(); -// If we're running in a child window, shim things so it works the same -// as if we were running stand-alone. -if (window.opener) { - // Get test filename for page being run in popup so errors are more useful - var testName = location.pathname.split('/').pop(); +// Wrap test functions and pass to parent window +window.ok = function(a, msg) { + opener.ok(a, testName + ": " + msg); +}; - // Wrap test functions and pass to parent window - window.ok = function(a, msg) { - opener.ok(a, testName + ": " + msg); - }; +window.is = function(a, b, msg) { + opener.is(a, b, testName + ": " + msg); +}; - window.is = function(a, b, msg) { - opener.is(a, b, testName + ": " + msg); - }; +window.isnot = function(a, b, msg) { + opener.isnot(a, b, testName + ": " + msg); +}; - window.isnot = function(a, b, msg) { - opener.isnot(a, b, testName + ": " + msg); - }; +window.todo = function(a, msg) { + opener.todo(a, testName + ": " + msg); +}; - window.todo = function(a, msg) { - opener.todo(a, testName + ": " + msg); - }; +window.todo_is = function(a, b, msg) { + opener.todo_is(a, b, testName + ": " + msg); +}; - window.todo_is = function(a, b, msg) { - opener.todo_is(a, b, testName + ": " + msg); - }; +window.todo_isnot = function(a, b, msg) { + opener.todo_isnot(a, b, testName + ": " + msg); +}; - window.todo_isnot = function(a, b, msg) { - opener.todo_isnot(a, b, testName + ": " + msg); - }; +window.info = function(msg) { + opener.info(testName + ": " + msg); +}; - window.info = function(msg) { - opener.info(testName + ": " + msg); - }; +// Override bits of SimpleTest so test files work stand-alone +var SimpleTest = SimpleTest || {}; - // Override bits of SimpleTest so test files work stand-alone - var SimpleTest = SimpleTest || {}; +SimpleTest.waitForExplicitFinish = function() { + dump("[POINTERLOCK] Starting " + testName+ "\n"); +}; - SimpleTest.waitForExplicitFinish = function() { - dump("[POINTERLOCK] Starting " + testName+ "\n"); - }; - - SimpleTest.finish = function () { - dump("[POINTERLOCK] Finishing " + testName+ "\n"); - opener.nextTest(); - }; -} else { - // If we're not running in a child window, prefs need to get flipped here, - // otherwise it was already done in the test runner parent. - - // Ensure the full-screen api is enabled, and will be disabled on test exit. - SpecialPowers.setBoolPref("full-screen-api.enabled", true); - - // Disable the requirement for trusted contexts only, so the tests are easier to write. - SpecialPowers.setBoolPref("full-screen-api.allow-trusted-requests-only", false); -} +SimpleTest.finish = function () { + dump("[POINTERLOCK] Finishing " + testName+ "\n"); + opener.nextTest(); +}; addLoadEvent(function() { if (typeof start !== 'undefined') { @@ -64,3 +48,73 @@ addLoadEvent(function() { } }); +// Returns true if the window occupies the entire screen. +// Note this only returns true once the transition from normal to +// fullscreen mode is complete. +function inFullscreenMode(win) { + return win.innerWidth == win.screen.width && + win.innerHeight == win.screen.height; +} + +// Returns true if the window is in normal mode, i.e. non fullscreen mode. +// Note this only returns true once the transition from fullscreen back to +// normal mode is complete. +function inNormalMode(win) { + return win.innerWidth == win.normalSize.w && + win.innerHeight == win.normalSize.h; +} + +// Adds a listener that will be called once a fullscreen transition +// is complete. When type==='enter', callback is called when we've +// received a fullscreenchange event, and the fullscreen transition is +// complete. When type==='exit', callback is called when we've +// received a fullscreenchange event and the window dimensions match +// the window dimensions when the window opened (so don't resize the +// window while running your test!). inDoc is the document which +// the listeners are added on, if absent, the listeners are added to +// the current document. +function addFullscreenChangeContinuation(type, callback, inDoc) { + var doc = inDoc || document; + var topWin = doc.defaultView.top; + // Remember the window size in non-fullscreen mode. + if (!topWin.normalSize) { + topWin.normalSize = { + w: window.innerWidth, + h: window.innerHeight + }; + } + function checkCondition() { + if (type == "enter") { + return inFullscreenMode(topWin); + } else if (type == "exit") { + // If we just revert the state to a previous fullscreen state, + // the window won't back to the normal mode. Hence we check + // fullscreenElement first here. Note that we need to check + // the fullscreen element of the outmost document here instead + // of the current one. + return topWin.document.fullscreenElement || inNormalMode(topWin); + } else { + throw "'type' must be either 'enter', or 'exit'."; + } + } + function invokeCallback(event) { + // Use async call after a paint to workaround unfinished fullscreen + // change even when the window size has changed on Linux. + requestAnimationFrame(() => setTimeout(() => callback(event), 0), 0); + } + function onFullscreenChange(event) { + doc.removeEventListener("fullscreenchange", onFullscreenChange, false); + if (checkCondition()) { + invokeCallback(event); + return; + } + function onResize() { + if (checkCondition()) { + topWin.removeEventListener("resize", onResize, false); + invokeCallback(event); + } + } + topWin.addEventListener("resize", onResize, false); + } + doc.addEventListener("fullscreenchange", onFullscreenChange, false); +} diff --git a/editor/libeditor/nsEditor.cpp b/editor/libeditor/nsEditor.cpp index 575be62448..796d403a79 100644 --- a/editor/libeditor/nsEditor.cpp +++ b/editor/libeditor/nsEditor.cpp @@ -4622,21 +4622,21 @@ nsEditor::HandleKeyPressEvent(nsIDOMKeyEvent* aKeyEvent) if (IsReadonly() || IsDisabled()) { // consume backspace for disabled and readonly textfields, to prevent // back in history, which could be confusing to users - if (nativeKeyEvent->keyCode == nsIDOMKeyEvent::DOM_VK_BACK_SPACE) { + if (nativeKeyEvent->mKeyCode == NS_VK_BACK) { aKeyEvent->AsEvent()->PreventDefault(); } return NS_OK; } - switch (nativeKeyEvent->keyCode) { - case nsIDOMKeyEvent::DOM_VK_META: - case nsIDOMKeyEvent::DOM_VK_WIN: - case nsIDOMKeyEvent::DOM_VK_SHIFT: - case nsIDOMKeyEvent::DOM_VK_CONTROL: - case nsIDOMKeyEvent::DOM_VK_ALT: + switch (nativeKeyEvent->mKeyCode) { + case NS_VK_META: + case NS_VK_WIN: + case NS_VK_SHIFT: + case NS_VK_CONTROL: + case NS_VK_ALT: aKeyEvent->AsEvent()->PreventDefault(); // consumed return NS_OK; - case nsIDOMKeyEvent::DOM_VK_BACK_SPACE: + case NS_VK_BACK: if (nativeKeyEvent->IsControl() || nativeKeyEvent->IsAlt() || nativeKeyEvent->IsMeta() || nativeKeyEvent->IsOS()) { return NS_OK; @@ -4644,7 +4644,7 @@ nsEditor::HandleKeyPressEvent(nsIDOMKeyEvent* aKeyEvent) DeleteSelection(nsIEditor::ePrevious, nsIEditor::eStrip); aKeyEvent->AsEvent()->PreventDefault(); // consumed return NS_OK; - case nsIDOMKeyEvent::DOM_VK_DELETE: + case NS_VK_DELETE: // on certain platforms (such as windows) the shift key // modifies what delete does (cmd_cut in this case). // bailing here to allow the keybindings to do the cut. diff --git a/editor/libeditor/nsHTMLEditor.cpp b/editor/libeditor/nsHTMLEditor.cpp index 05e9325ebc..b6e18cf29e 100644 --- a/editor/libeditor/nsHTMLEditor.cpp +++ b/editor/libeditor/nsHTMLEditor.cpp @@ -625,18 +625,18 @@ nsHTMLEditor::HandleKeyPressEvent(nsIDOMKeyEvent* aKeyEvent) NS_ASSERTION(nativeKeyEvent->mMessage == eKeyPress, "HandleKeyPressEvent gets non-keypress event"); - switch (nativeKeyEvent->keyCode) { - case nsIDOMKeyEvent::DOM_VK_META: - case nsIDOMKeyEvent::DOM_VK_WIN: - case nsIDOMKeyEvent::DOM_VK_SHIFT: - case nsIDOMKeyEvent::DOM_VK_CONTROL: - case nsIDOMKeyEvent::DOM_VK_ALT: - case nsIDOMKeyEvent::DOM_VK_BACK_SPACE: - case nsIDOMKeyEvent::DOM_VK_DELETE: + switch (nativeKeyEvent->mKeyCode) { + case NS_VK_META: + case NS_VK_WIN: + case NS_VK_SHIFT: + case NS_VK_CONTROL: + case NS_VK_ALT: + case NS_VK_BACK: + case NS_VK_DELETE: // These keys are handled on nsEditor, so, we can bypass // nsPlaintextEditor. return nsEditor::HandleKeyPressEvent(aKeyEvent); - case nsIDOMKeyEvent::DOM_VK_TAB: { + case NS_VK_TAB: { if (IsPlaintextEditor()) { // If this works as plain text editor, e.g., mail editor for plain // text, should be handled on nsPlaintextEditor. @@ -687,7 +687,7 @@ nsHTMLEditor::HandleKeyPressEvent(nsIDOMKeyEvent* aKeyEvent) aKeyEvent->AsEvent()->PreventDefault(); return TypedText(NS_LITERAL_STRING("\t"), eTypedText); } - case nsIDOMKeyEvent::DOM_VK_RETURN: + case NS_VK_RETURN: if (nativeKeyEvent->IsControl() || nativeKeyEvent->IsAlt() || nativeKeyEvent->IsMeta() || nativeKeyEvent->IsOS()) { return NS_OK; @@ -703,14 +703,14 @@ nsHTMLEditor::HandleKeyPressEvent(nsIDOMKeyEvent* aKeyEvent) // NOTE: On some keyboard layout, some characters are inputted with Control // key or Alt key, but at that time, widget sets FALSE to these keys. - if (nativeKeyEvent->charCode == 0 || nativeKeyEvent->IsControl() || + if (!nativeKeyEvent->mCharCode || nativeKeyEvent->IsControl() || nativeKeyEvent->IsAlt() || nativeKeyEvent->IsMeta() || nativeKeyEvent->IsOS()) { // we don't PreventDefault() here or keybindings like control-x won't work return NS_OK; } aKeyEvent->AsEvent()->PreventDefault(); - nsAutoString str(nativeKeyEvent->charCode); + nsAutoString str(nativeKeyEvent->mCharCode); return TypedText(str, eTypedText); } diff --git a/editor/libeditor/nsPlaintextEditor.cpp b/editor/libeditor/nsPlaintextEditor.cpp index 0e530c7cde..6b1613716c 100644 --- a/editor/libeditor/nsPlaintextEditor.cpp +++ b/editor/libeditor/nsPlaintextEditor.cpp @@ -366,17 +366,17 @@ nsPlaintextEditor::HandleKeyPressEvent(nsIDOMKeyEvent* aKeyEvent) NS_ASSERTION(nativeKeyEvent->mMessage == eKeyPress, "HandleKeyPressEvent gets non-keypress event"); - switch (nativeKeyEvent->keyCode) { - case nsIDOMKeyEvent::DOM_VK_META: - case nsIDOMKeyEvent::DOM_VK_WIN: - case nsIDOMKeyEvent::DOM_VK_SHIFT: - case nsIDOMKeyEvent::DOM_VK_CONTROL: - case nsIDOMKeyEvent::DOM_VK_ALT: - case nsIDOMKeyEvent::DOM_VK_BACK_SPACE: - case nsIDOMKeyEvent::DOM_VK_DELETE: + switch (nativeKeyEvent->mKeyCode) { + case NS_VK_META: + case NS_VK_WIN: + case NS_VK_SHIFT: + case NS_VK_CONTROL: + case NS_VK_ALT: + case NS_VK_BACK: + case NS_VK_DELETE: // These keys are handled on nsEditor return nsEditor::HandleKeyPressEvent(aKeyEvent); - case nsIDOMKeyEvent::DOM_VK_TAB: { + case NS_VK_TAB: { if (IsTabbable()) { return NS_OK; // let it be used for focus switching } @@ -391,7 +391,7 @@ nsPlaintextEditor::HandleKeyPressEvent(nsIDOMKeyEvent* aKeyEvent) aKeyEvent->AsEvent()->PreventDefault(); return TypedText(NS_LITERAL_STRING("\t"), eTypedText); } - case nsIDOMKeyEvent::DOM_VK_RETURN: + case NS_VK_RETURN: if (IsSingleLineEditor() || nativeKeyEvent->IsControl() || nativeKeyEvent->IsAlt() || nativeKeyEvent->IsMeta() || nativeKeyEvent->IsOS()) { @@ -403,14 +403,14 @@ nsPlaintextEditor::HandleKeyPressEvent(nsIDOMKeyEvent* aKeyEvent) // NOTE: On some keyboard layout, some characters are inputted with Control // key or Alt key, but at that time, widget sets FALSE to these keys. - if (nativeKeyEvent->charCode == 0 || nativeKeyEvent->IsControl() || + if (!nativeKeyEvent->mCharCode || nativeKeyEvent->IsControl() || nativeKeyEvent->IsAlt() || nativeKeyEvent->IsMeta() || nativeKeyEvent->IsOS()) { // we don't PreventDefault() here or keybindings like control-x won't work return NS_OK; } aKeyEvent->AsEvent()->PreventDefault(); - nsAutoString str(nativeKeyEvent->charCode); + nsAutoString str(nativeKeyEvent->mCharCode); return TypedText(str, eTypedText); } diff --git a/gfx/ipc/D3DMessageUtils.cpp b/gfx/ipc/D3DMessageUtils.cpp index d1eb7b3de2..16642fd456 100644 --- a/gfx/ipc/D3DMessageUtils.cpp +++ b/gfx/ipc/D3DMessageUtils.cpp @@ -53,7 +53,7 @@ ParamTraits::Write(Message* aMsg, const paramType& aParam) } bool -ParamTraits::Read(const Message* aMsg, void** aIter, paramType* aResult) +ParamTraits::Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { #if defined(XP_WIN) const char* description = nullptr; diff --git a/gfx/ipc/D3DMessageUtils.h b/gfx/ipc/D3DMessageUtils.h index 1e11487fdf..0dc9b48434 100644 --- a/gfx/ipc/D3DMessageUtils.h +++ b/gfx/ipc/D3DMessageUtils.h @@ -40,7 +40,7 @@ struct ParamTraits { typedef DxgiAdapterDesc paramType; static void Write(Message* aMsg, const paramType& aParam); - static bool Read(const Message* aMsg, void** aIter, paramType* aResult); + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult); }; } // namespace IPC diff --git a/gfx/ipc/GfxMessageUtils.h b/gfx/ipc/GfxMessageUtils.h index 22476cf8bb..92596b79cb 100644 --- a/gfx/ipc/GfxMessageUtils.h +++ b/gfx/ipc/GfxMessageUtils.h @@ -54,7 +54,7 @@ struct ParamTraits WriteParam(aMsg, aParam._32); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { if (ReadParam(aMsg, aIter, &aResult->_11) && ReadParam(aMsg, aIter, &aResult->_12) && @@ -89,7 +89,7 @@ struct ParamTraits #undef Wr } - static bool Read(const Message* msg, void** iter, paramType* result) + static bool Read(const Message* msg, PickleIterator* iter, paramType* result) { #define Rd(_f) ReadParam(msg, iter, &result-> _f) return (Rd(_11) && Rd(_12) && Rd(_13) && Rd(_14) && @@ -116,7 +116,7 @@ struct ParamTraits #undef Wr } - static bool Read(const Message* msg, void** iter, paramType* result) + static bool Read(const Message* msg, PickleIterator* iter, paramType* result) { #define Rd(_f) ReadParam(msg, iter, &result-> _f) return (Rd(_11) && Rd(_12) && Rd(_13) && Rd(_14) && @@ -139,7 +139,7 @@ struct ParamTraits WriteParam(aMsg, aParam.y); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { return (ReadParam(aMsg, aIter, &aResult->x) && ReadParam(aMsg, aIter, &aResult->y)); @@ -157,7 +157,7 @@ struct ParamTraits WriteParam(aMsg, aParam.height); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { if (ReadParam(aMsg, aIter, &aResult->width) && ReadParam(aMsg, aIter, &aResult->height)) @@ -180,7 +180,7 @@ struct ParamTraits WriteParam(aMsg, aParam.height); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { return ReadParam(aMsg, aIter, &aResult->x) && ReadParam(aMsg, aIter, &aResult->y) && @@ -297,7 +297,7 @@ struct ParamTraits WriteParam(msg, param.a); } - static bool Read(const Message* msg, void** iter, paramType* result) + static bool Read(const Message* msg, PickleIterator* iter, paramType* result) { return (ReadParam(msg, iter, &result->r) && ReadParam(msg, iter, &result->g) && @@ -317,7 +317,7 @@ struct ParamTraits WriteParam(msg, param.y); } - static bool Read(const Message* msg, void** iter, paramType* result) + static bool Read(const Message* msg, PickleIterator* iter, paramType* result) { return (ReadParam(msg, iter, &result->x) && ReadParam(msg, iter, &result->y)); @@ -335,7 +335,7 @@ struct ParamTraits WriteParam(msg, param.y); } - static bool Read(const Message* msg, void** iter, paramType* result) + static bool Read(const Message* msg, PickleIterator* iter, paramType* result) { return (ReadParam(msg, iter, &result->x) && ReadParam(msg, iter, &result->y)); @@ -353,7 +353,7 @@ struct ParamTraits > WriteParam(msg, param.height); } - static bool Read(const Message* msg, void** iter, paramType* result) + static bool Read(const Message* msg, PickleIterator* iter, paramType* result) { return (ReadParam(msg, iter, &result->width) && ReadParam(msg, iter, &result->height)); @@ -378,7 +378,7 @@ struct RegionParamTraits WriteParam(msg, Rect()); } - static bool Read(const Message* msg, void** iter, paramType* result) + static bool Read(const Message* msg, PickleIterator* iter, paramType* result) { RegionBuilder builder; Rect rect; @@ -412,7 +412,7 @@ struct ParamTraits WriteParam(msg, param.height); } - static bool Read(const Message* msg, void** iter, paramType* result) + static bool Read(const Message* msg, PickleIterator* iter, paramType* result) { return (ReadParam(msg, iter, &result->width) && ReadParam(msg, iter, &result->height)); @@ -429,7 +429,7 @@ struct ParamTraits< mozilla::gfx::CoordTyped > WriteParam(msg, param.value); } - static bool Read(const Message* msg, void** iter, paramType* result) + static bool Read(const Message* msg, PickleIterator* iter, paramType* result) { return (ReadParam(msg, iter, &result->value)); } @@ -445,7 +445,7 @@ struct ParamTraits< mozilla::gfx::IntCoordTyped > WriteParam(msg, param.value); } - static bool Read(const Message* msg, void** iter, paramType* result) + static bool Read(const Message* msg, PickleIterator* iter, paramType* result) { return (ReadParam(msg, iter, &result->value)); } @@ -461,7 +461,7 @@ struct ParamTraits< mozilla::gfx::ScaleFactor > WriteParam(msg, param.scale); } - static bool Read(const Message* msg, void** iter, paramType* result) + static bool Read(const Message* msg, PickleIterator* iter, paramType* result) { return (ReadParam(msg, iter, &result->scale)); } @@ -478,7 +478,7 @@ struct ParamTraits< mozilla::gfx::ScaleFactors2D > WriteParam(msg, param.yScale); } - static bool Read(const Message* msg, void** iter, paramType* result) + static bool Read(const Message* msg, PickleIterator* iter, paramType* result) { return (ReadParam(msg, iter, &result->xScale) && ReadParam(msg, iter, &result->yScale)); @@ -496,7 +496,7 @@ struct ParamTraits< mozilla::gfx::PointTyped > WriteParam(msg, param.y); } - static bool Read(const Message* msg, void** iter, paramType* result) + static bool Read(const Message* msg, PickleIterator* iter, paramType* result) { return (ReadParam(msg, iter, &result->x) && ReadParam(msg, iter, &result->y)); @@ -515,7 +515,7 @@ struct ParamTraits< mozilla::gfx::Point3DTyped > WriteParam(msg, param.z); } - static bool Read(const Message* msg, void** iter, paramType* result) + static bool Read(const Message* msg, PickleIterator* iter, paramType* result) { return (ReadParam(msg, iter, &result->x) && ReadParam(msg, iter, &result->y) && @@ -534,7 +534,7 @@ struct ParamTraits< mozilla::gfx::IntPointTyped > WriteParam(msg, param.y); } - static bool Read(const Message* msg, void** iter, paramType* result) + static bool Read(const Message* msg, PickleIterator* iter, paramType* result) { return (ReadParam(msg, iter, &result->x) && ReadParam(msg, iter, &result->y)); @@ -552,7 +552,7 @@ struct ParamTraits< mozilla::gfx::SizeTyped > WriteParam(msg, param.height); } - static bool Read(const Message* msg, void** iter, paramType* result) + static bool Read(const Message* msg, PickleIterator* iter, paramType* result) { return (ReadParam(msg, iter, &result->width) && ReadParam(msg, iter, &result->height)); @@ -572,7 +572,7 @@ struct ParamTraits< mozilla::gfx::RectTyped > WriteParam(msg, param.height); } - static bool Read(const Message* msg, void** iter, paramType* result) + static bool Read(const Message* msg, PickleIterator* iter, paramType* result) { return (ReadParam(msg, iter, &result->x) && ReadParam(msg, iter, &result->y) && @@ -594,7 +594,7 @@ struct ParamTraits< mozilla::gfx::IntRectTyped > WriteParam(msg, param.height); } - static bool Read(const Message* msg, void** iter, paramType* result) + static bool Read(const Message* msg, PickleIterator* iter, paramType* result) { return (ReadParam(msg, iter, &result->x) && ReadParam(msg, iter, &result->y) && @@ -616,7 +616,7 @@ struct ParamTraits WriteParam(msg, param.left); } - static bool Read(const Message* msg, void** iter, paramType* result) + static bool Read(const Message* msg, PickleIterator* iter, paramType* result) { return (ReadParam(msg, iter, &result->top) && ReadParam(msg, iter, &result->right) && @@ -638,7 +638,7 @@ struct ParamTraits< mozilla::gfx::MarginTyped > WriteParam(msg, param.left); } - static bool Read(const Message* msg, void** iter, paramType* result) + static bool Read(const Message* msg, PickleIterator* iter, paramType* result) { return (ReadParam(msg, iter, &result->top) && ReadParam(msg, iter, &result->right) && @@ -660,7 +660,7 @@ struct ParamTraits WriteParam(msg, param.height); } - static bool Read(const Message* msg, void** iter, paramType* result) + static bool Read(const Message* msg, PickleIterator* iter, paramType* result) { return (ReadParam(msg, iter, &result->x) && ReadParam(msg, iter, &result->y) && @@ -690,7 +690,7 @@ struct BitfieldHelper // We need this helper because we can't get the address of a bitfield to // pass directly to ReadParam. So instead we read it into a temporary bool // and set the bitfield using a setter function - static bool ReadBoolForBitfield(const Message* aMsg, void** aIter, + static bool ReadBoolForBitfield(const Message* aMsg, PickleIterator* aIter, ParamType* aResult, void (ParamType::*aSetter)(bool)) { bool value; @@ -735,7 +735,7 @@ struct ParamTraits WriteParam(aMsg, aParam.mIsScrollInfoLayer); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { return (ReadParam(aMsg, aIter, &aResult->mScrollId) && ReadParam(aMsg, aIter, &aResult->mPresShellResolution) && @@ -778,7 +778,7 @@ struct ParamTraits WriteParam(aMsg, aParam.mScrollSnapCoordinates); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { return (ReadParam(aMsg, aIter, &aResult->mScrollSnapTypeX) && ReadParam(aMsg, aIter, &aResult->mScrollSnapTypeY) && @@ -789,6 +789,24 @@ struct ParamTraits } }; +template <> +struct ParamTraits +{ + typedef mozilla::layers::LayerClip paramType; + + static void Write(Message* aMsg, const paramType& aParam) + { + WriteParam(aMsg, aParam.mClipRect); + WriteParam(aMsg, aParam.mMaskLayerIndex); + } + + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) + { + return (ReadParam(aMsg, aIter, &aResult->mClipRect) && + ReadParam(aMsg, aIter, &aResult->mMaskLayerIndex)); + } +}; + template <> struct ParamTraits : BitfieldHelper @@ -804,8 +822,7 @@ struct ParamTraits WriteParam(aMsg, aParam.GetContentDescription()); WriteParam(aMsg, aParam.mLineScrollAmount); WriteParam(aMsg, aParam.mPageScrollAmount); - WriteParam(aMsg, aParam.mMaskLayerIndex); - WriteParam(aMsg, aParam.mClipRect); + WriteParam(aMsg, aParam.mScrollClip); WriteParam(aMsg, aParam.mHasScrollgrab); WriteParam(aMsg, aParam.mAllowVerticalScrollWithWheel); WriteParam(aMsg, aParam.mIsLayersIdRoot); @@ -813,7 +830,7 @@ struct ParamTraits WriteParam(aMsg, aParam.mForceDisableApz); } - static bool ReadContentDescription(const Message* aMsg, void** aIter, paramType* aResult) + static bool ReadContentDescription(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { nsCString str; if (!ReadParam(aMsg, aIter, &str)) { @@ -823,7 +840,7 @@ struct ParamTraits return true; } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { return (ReadParam(aMsg, aIter, &aResult->mMetrics) && ReadParam(aMsg, aIter, &aResult->mSnapInfo) && @@ -832,8 +849,7 @@ struct ParamTraits ReadContentDescription(aMsg, aIter, aResult) && ReadParam(aMsg, aIter, &aResult->mLineScrollAmount) && ReadParam(aMsg, aIter, &aResult->mPageScrollAmount) && - ReadParam(aMsg, aIter, &aResult->mMaskLayerIndex) && - ReadParam(aMsg, aIter, &aResult->mClipRect) && + ReadParam(aMsg, aIter, &aResult->mScrollClip) && ReadBoolForBitfield(aMsg, aIter, aResult, ¶mType::SetHasScrollgrab) && ReadBoolForBitfield(aMsg, aIter, aResult, ¶mType::SetAllowVerticalScrollWithWheel) && ReadBoolForBitfield(aMsg, aIter, aResult, ¶mType::SetIsLayersIdRoot) && @@ -856,7 +872,7 @@ struct ParamTraits WriteParam(aMsg, aParam.mSyncHandle); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { bool result = ReadParam(aMsg, aIter, &aResult->mParentBackend) && ReadParam(aMsg, aIter, &aResult->mMaxTextureSize) && @@ -878,7 +894,7 @@ struct ParamTraits WriteParam(aMsg, aParam.mTextureFlags); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { return ReadParam(aMsg, aIter, &aResult->mCompositableType) && ReadParam(aMsg, aIter, &aResult->mTextureFlags); @@ -921,7 +937,7 @@ struct ParamTraits WriteParam(aMsg, aParam.mScrollId); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { return (ReadParam(aMsg, aIter, &aResult->mLayersId) && ReadParam(aMsg, aIter, &aResult->mPresShellId) && @@ -943,7 +959,7 @@ struct ParamTraits WriteParam(aMsg, aParam.mMaxZoom); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { return (ReadParam(aMsg, aIter, &aResult->mAllowZoom) && ReadParam(aMsg, aIter, &aResult->mAllowDoubleTapZoom) && @@ -966,7 +982,7 @@ struct ParamTraits WriteParam(aMsg, aParam.mVerticalPanRegion); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { return (ReadParam(aMsg, aIter, &aResult->mHitRegion) && ReadParam(aMsg, aIter, &aResult->mDispatchToContentHitRegion) && @@ -1021,7 +1037,7 @@ struct ParamTraits } } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { uint32_t count; if (!ReadParam(aMsg, aIter, &count)) { @@ -1100,7 +1116,7 @@ struct ParamTraits WriteParam(aMsg, aParam.Attributes()); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { mozilla::gfx::PrimitiveType type; mozilla::gfx::IntRect primitiveSubregion; @@ -1148,7 +1164,7 @@ struct ParamTraits WriteParam(aMsg, aParam.mPrimitives); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { return (ReadParam(aMsg, aIter, &aResult->mPrimitives)); } @@ -1194,7 +1210,7 @@ struct ParamTraits WriteParam(aMsg, aParam.mDirection); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { return (ReadParam(aMsg, aIter, &aResult->mViewId) && ReadParam(aMsg, aIter, &aResult->mPresShellId) && diff --git a/gfx/layers/FrameMetrics.h b/gfx/layers/FrameMetrics.h index b813b7cc0b..a98b437933 100644 --- a/gfx/layers/FrameMetrics.h +++ b/gfx/layers/FrameMetrics.h @@ -679,6 +679,52 @@ struct ScrollSnapInfo { nsTArray mScrollSnapCoordinates; }; +/** + * A clip that applies to a layer, that may be scrolled by some of the + * scroll frames associated with the layer. + */ +struct LayerClip { + friend struct IPC::ParamTraits; + +public: + LayerClip() + : mClipRect() + , mMaskLayerIndex() + {} + + explicit LayerClip(const ParentLayerIntRect& aClipRect) + : mClipRect(aClipRect) + , mMaskLayerIndex() + {} + + bool operator==(const LayerClip& aOther) const + { + return mClipRect == aOther.mClipRect && + mMaskLayerIndex == aOther.mMaskLayerIndex; + } + + void SetClipRect(const ParentLayerIntRect& aClipRect) { + mClipRect = aClipRect; + } + const ParentLayerIntRect& GetClipRect() const { + return mClipRect; + } + + void SetMaskLayerIndex(const Maybe& aIndex) { + mMaskLayerIndex = aIndex; + } + const Maybe& GetMaskLayerIndex() const { + return mMaskLayerIndex; + } + +private: + ParentLayerIntRect mClipRect; + + // Optionally, specifies a mask layer that's part of the clip. + // This is an index into the MetricsMaskLayers array on the Layer. + Maybe mMaskLayerIndex; +}; + /** * Metadata about a scroll frame that's stored in the layer tree for use by * the compositor (including APZ). This includes the scroll frame's FrameMetrics, @@ -701,8 +747,7 @@ public: , mContentDescription() , mLineScrollAmount(0, 0) , mPageScrollAmount(0, 0) - , mMaskLayerIndex() - , mClipRect() + , mScrollClip() , mHasScrollgrab(false) , mAllowVerticalScrollWithWheel(false) , mIsLayersIdRoot(false) @@ -719,8 +764,7 @@ public: // don't compare mContentDescription mLineScrollAmount == aOther.mLineScrollAmount && mPageScrollAmount == aOther.mPageScrollAmount && - mMaskLayerIndex == aOther.mMaskLayerIndex && - mClipRect == aOther.mClipRect && + mScrollClip == aOther.mScrollClip && mHasScrollgrab == aOther.mHasScrollgrab && mAllowVerticalScrollWithWheel == aOther.mAllowVerticalScrollWithWheel && mIsLayersIdRoot == aOther.mIsLayersIdRoot && @@ -780,26 +824,28 @@ public: void SetPageScrollAmount(const LayoutDeviceIntSize& size) { mPageScrollAmount = size; } - void SetMaskLayerIndex(const Maybe& aIndex) { - mMaskLayerIndex = aIndex; + + void SetScrollClip(const Maybe& aScrollClip) { + mScrollClip = aScrollClip; } - const Maybe& GetMaskLayerIndex() const { - return mMaskLayerIndex; + const Maybe& GetScrollClip() const { + return mScrollClip; + } + bool HasScrollClip() const { + return mScrollClip.isSome(); + } + const LayerClip& ScrollClip() const { + return mScrollClip.ref(); + } + LayerClip& ScrollClip() { + return mScrollClip.ref(); } - void SetClipRect(const Maybe& aClipRect) - { - mClipRect = aClipRect; + bool HasMaskLayer() const { + return HasScrollClip() && ScrollClip().GetMaskLayerIndex(); } - const Maybe& GetClipRect() const - { - return mClipRect; - } - bool HasClipRect() const { - return mClipRect.isSome(); - } - const ParentLayerIntRect& ClipRect() const { - return mClipRect.ref(); + Maybe GetClipRect() const { + return mScrollClip.isSome() ? Some(mScrollClip->GetClipRect()) : Nothing(); } void SetHasScrollgrab(bool aHasScrollgrab) { @@ -856,13 +902,13 @@ private: // The value of GetPageScrollAmount(), for scroll frames. LayoutDeviceIntSize mPageScrollAmount; - // An extra clip mask layer to use when compositing a layer with this - // FrameMetrics. This is an index into the MetricsMaskLayers array on - // the Layer. - Maybe mMaskLayerIndex; - - // The clip rect to use when compositing a layer with this FrameMetrics. - Maybe mClipRect; + // A clip to apply when compositing the layer bearing this ScrollMetadata, + // after applying any transform arising from scrolling this scroll frame. + // Note that, unlike most other fields of ScrollMetadata, this is allowed + // to differ between different layers scrolled by the same scroll frame. + // TODO: Group the fields of ScrollMetadata into sub-structures to separate + // fields with this property better. + Maybe mScrollClip; // Whether or not this frame is for an element marked 'scrollgrab'. bool mHasScrollgrab:1; diff --git a/gfx/layers/Layers.cpp b/gfx/layers/Layers.cpp index 2f8f57242a..fce9bff166 100644 --- a/gfx/layers/Layers.cpp +++ b/gfx/layers/Layers.cpp @@ -1101,16 +1101,7 @@ Layer::GetCombinedClipRect() const Maybe clip = GetClipRect(); for (size_t i = 0; i < mScrollMetadata.Length(); i++) { - if (!mScrollMetadata[i].HasClipRect()) { - continue; - } - - const ParentLayerIntRect& other = mScrollMetadata[i].ClipRect(); - if (clip) { - clip = Some(clip.value().Intersect(other)); - } else { - clip = Some(other); - } + clip = IntersectMaybeRects(clip, mScrollMetadata[i].GetClipRect()); } return clip; diff --git a/gfx/layers/LayersLogging.cpp b/gfx/layers/LayersLogging.cpp index 1d7203807d..3398a9f38b 100644 --- a/gfx/layers/LayersLogging.cpp +++ b/gfx/layers/LayersLogging.cpp @@ -154,8 +154,8 @@ AppendToString(std::stringstream& aStream, const ScrollMetadata& m, if (m.GetScrollParentId() != FrameMetrics::NULL_SCROLL_ID) { AppendToString(aStream, m.GetScrollParentId(), "] [scrollParent="); } - if (m.HasClipRect()) { - AppendToString(aStream, m.ClipRect(), "] [clip="); + if (m.HasScrollClip()) { + AppendToString(aStream, m.ScrollClip().GetClipRect(), "] [clip="); } aStream << "] }" << sfx; } diff --git a/gfx/layers/apz/src/AsyncPanZoomController.cpp b/gfx/layers/apz/src/AsyncPanZoomController.cpp index 9f358aae11..bfbd3342b9 100644 --- a/gfx/layers/apz/src/AsyncPanZoomController.cpp +++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp @@ -3521,8 +3521,7 @@ void AsyncPanZoomController::NotifyLayersUpdated(const ScrollMetadata& aScrollMe mScrollMetadata.SetLineScrollAmount(aScrollMetadata.GetLineScrollAmount()); mScrollMetadata.SetPageScrollAmount(aScrollMetadata.GetPageScrollAmount()); mScrollMetadata.SetSnapInfo(ScrollSnapInfo(aScrollMetadata.GetSnapInfo())); - mScrollMetadata.SetClipRect(aScrollMetadata.GetClipRect()); - mScrollMetadata.SetMaskLayerIndex(aScrollMetadata.GetMaskLayerIndex()); + mScrollMetadata.SetScrollClip(aScrollMetadata.GetScrollClip()); mScrollMetadata.SetIsLayersIdRoot(aScrollMetadata.IsLayersIdRoot()); mScrollMetadata.SetUsesContainerScrolling(aScrollMetadata.UsesContainerScrolling()); mFrameMetrics.SetIsScrollInfoLayer(aLayerMetrics.IsScrollInfoLayer()); diff --git a/gfx/layers/apz/test/gtest/TestHitTesting.cpp b/gfx/layers/apz/test/gtest/TestHitTesting.cpp index c01085fc11..b40606c340 100644 --- a/gfx/layers/apz/test/gtest/TestHitTesting.cpp +++ b/gfx/layers/apz/test/gtest/TestHitTesting.cpp @@ -560,7 +560,7 @@ TEST_F(APZHitTestingTester, HitTestingRespectsScrollClip_Bug1257288) { ScrollMetadata subframeMetadata = BuildScrollMetadata( FrameMetrics::START_SCROLL_ID + 1, CSSRect(0,0,200,200), ParentLayerRect(0,0,200,100)); - subframeMetadata.SetClipRect(Some(ParentLayerIntRect(0,0,200,100))); + subframeMetadata.SetScrollClip(Some(LayerClip(ParentLayerIntRect(0,0,200,100)))); layers[2]->SetScrollMetadata({subframeMetadata, rootMetadata}); layers[2]->SetClipRect(Some(ParentLayerIntRect(0,0,200,200))); SetEventRegionsBasedOnBottommostMetrics(layers[2]); diff --git a/gfx/layers/apz/testutil/APZTestData.h b/gfx/layers/apz/testutil/APZTestData.h index 87ad485cb1..c0cc35b5a1 100644 --- a/gfx/layers/apz/testutil/APZTestData.h +++ b/gfx/layers/apz/testutil/APZTestData.h @@ -143,7 +143,7 @@ struct ParamTraits WriteParam(aMsg, aParam.mRepaintRequests); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { return (ReadParam(aMsg, aIter, &aResult->mPaints) && ReadParam(aMsg, aIter, &aResult->mRepaintRequests)); diff --git a/gfx/layers/apz/util/APZCCallbackHelper.cpp b/gfx/layers/apz/util/APZCCallbackHelper.cpp index 6775d67957..16a2a2a774 100644 --- a/gfx/layers/apz/util/APZCCallbackHelper.cpp +++ b/gfx/layers/apz/util/APZCCallbackHelper.cpp @@ -489,9 +489,9 @@ APZCCallbackHelper::DispatchSynthesizedMouseEvent(EventMessage aMsg, event.mTime = aTime; event.button = WidgetMouseEvent::eLeftButton; event.inputSource = nsIDOMMouseEvent::MOZ_SOURCE_TOUCH; - event.ignoreRootScrollFrame = true; + event.mIgnoreRootScrollFrame = true; if (aMsg != eMouseMove) { - event.clickCount = 1; + event.mClickCount = 1; } event.mModifiers = aModifiers; diff --git a/gfx/layers/composite/AsyncCompositionManager.cpp b/gfx/layers/composite/AsyncCompositionManager.cpp index b947f03799..380ec19c14 100644 --- a/gfx/layers/composite/AsyncCompositionManager.cpp +++ b/gfx/layers/composite/AsyncCompositionManager.cpp @@ -932,8 +932,8 @@ AsyncCompositionManager::ApplyAsyncContentTransformToTree(Layer *aLayer, // Combine the local clip with the ancestor scrollframe clip. This is not // included in the async transform above, since the ancestor clip should not // move with this APZC. - if (scrollMetadata.HasClipRect()) { - ParentLayerIntRect clip = scrollMetadata.ClipRect(); + if (scrollMetadata.HasScrollClip()) { + ParentLayerIntRect clip = scrollMetadata.ScrollClip().GetClipRect(); if (aLayer->GetParent() && aLayer->GetParent()->GetTransformIsPerspective()) { // If our parent layer has a perspective transform, we want to apply // our scroll clip to it instead of to this layer (see bug 1168263). @@ -961,10 +961,13 @@ AsyncCompositionManager::ApplyAsyncContentTransformToTree(Layer *aLayer, } // Append the ancestor mask layer for this scroll frame to ancestorMaskLayers. - if (scrollMetadata.GetMaskLayerIndex()) { - size_t maskLayerIndex = scrollMetadata.GetMaskLayerIndex().value(); - Layer* ancestorMaskLayer = aLayer->GetAncestorMaskLayerAt(maskLayerIndex); - ancestorMaskLayers.AppendElement(ancestorMaskLayer); + if (scrollMetadata.HasScrollClip()) { + const LayerClip& scrollClip = scrollMetadata.ScrollClip(); + if (scrollClip.GetMaskLayerIndex()) { + size_t maskLayerIndex = scrollClip.GetMaskLayerIndex().value(); + Layer* ancestorMaskLayer = aLayer->GetAncestorMaskLayerAt(maskLayerIndex); + ancestorMaskLayers.AppendElement(ancestorMaskLayer); + } } } diff --git a/gfx/layers/composite/FrameUniformityData.h b/gfx/layers/composite/FrameUniformityData.h index f7e175f367..3ff1bdc4a8 100644 --- a/gfx/layers/composite/FrameUniformityData.h +++ b/gfx/layers/composite/FrameUniformityData.h @@ -62,7 +62,7 @@ struct ParamTraits WriteParam(aMsg, aParam.mUniformities); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { return ParamTraitsStd>::Read(aMsg, aIter, &aResult->mUniformities); } diff --git a/gfx/layers/ipc/FenceUtils.cpp b/gfx/layers/ipc/FenceUtils.cpp index f31dc77c2f..b2f07ad0ad 100644 --- a/gfx/layers/ipc/FenceUtils.cpp +++ b/gfx/layers/ipc/FenceUtils.cpp @@ -33,7 +33,7 @@ ParamTraits::Write(Message* aMsg, bool ParamTraits::Read(const Message* aMsg, - void** aIter, paramType* aResult) + PickleIterator* aIter, paramType* aResult) { #if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17 base::FileDescriptor fd; diff --git a/gfx/layers/ipc/FenceUtils.h b/gfx/layers/ipc/FenceUtils.h index f7e42fe5a0..2edf2c43d8 100644 --- a/gfx/layers/ipc/FenceUtils.h +++ b/gfx/layers/ipc/FenceUtils.h @@ -76,7 +76,7 @@ struct ParamTraits { typedef mozilla::layers::FenceHandle paramType; static void Write(Message* aMsg, const paramType& aParam); - static bool Read(const Message* aMsg, void** aIter, paramType* aResult); + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult); }; } // namespace IPC diff --git a/gfx/layers/ipc/GonkNativeHandleUtils.cpp b/gfx/layers/ipc/GonkNativeHandleUtils.cpp index 82f6860e27..8abfd4f69f 100644 --- a/gfx/layers/ipc/GonkNativeHandleUtils.cpp +++ b/gfx/layers/ipc/GonkNativeHandleUtils.cpp @@ -32,7 +32,7 @@ ParamTraits::Write(Message* aMsg, bool ParamTraits::Read(const Message* aMsg, - void** aIter, paramType* aResult) + PickleIterator* aIter, paramType* aResult) { size_t nbytes; const char* data; diff --git a/gfx/layers/ipc/GonkNativeHandleUtils.h b/gfx/layers/ipc/GonkNativeHandleUtils.h index 39ba40fcde..8b23afdab4 100644 --- a/gfx/layers/ipc/GonkNativeHandleUtils.h +++ b/gfx/layers/ipc/GonkNativeHandleUtils.h @@ -20,14 +20,14 @@ struct ParamTraits { typedef mozilla::layers::GonkNativeHandle paramType; static void Write(Message* aMsg, const paramType& aParam); - static bool Read(const Message* aMsg, void** aIter, paramType* aResult); + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult); }; #else template <> struct ParamTraits { typedef mozilla::layers::GonkNativeHandle paramType; static void Write(Message*, const paramType&) {} - static bool Read(const Message*, void**, paramType*) { return false; } + static bool Read(const Message*, PickleIterator*, paramType*) { return false; } }; #endif diff --git a/gfx/layers/ipc/ShadowLayerUtils.h b/gfx/layers/ipc/ShadowLayerUtils.h index 863b5385fc..c93a6b9a90 100644 --- a/gfx/layers/ipc/ShadowLayerUtils.h +++ b/gfx/layers/ipc/ShadowLayerUtils.h @@ -50,7 +50,7 @@ template <> struct ParamTraits { typedef mozilla::layers::SurfaceDescriptorX11 paramType; static void Write(Message*, const paramType&) {} - static bool Read(const Message*, void**, paramType*) { return false; } + static bool Read(const Message*, PickleIterator*, paramType*) { return false; } }; #endif // !defined(MOZ_HAVE_XSURFACEDESCRIPTORX11) @@ -59,14 +59,14 @@ template <> struct ParamTraits { typedef mozilla::layers::MagicGrallocBufferHandle paramType; static void Write(Message*, const paramType&) {} - static bool Read(const Message*, void**, paramType*) { return false; } + static bool Read(const Message*, PickleIterator*, paramType*) { return false; } }; template <> struct ParamTraits { typedef mozilla::layers::GrallocBufferRef paramType; static void Write(Message*, const paramType&) {} - static bool Read(const Message*, void**, paramType*) { return false; } + static bool Read(const Message*, PickleIterator*, paramType*) { return false; } }; #endif // !defined(MOZ_HAVE_XSURFACEDESCRIPTORGRALLOC) diff --git a/gfx/layers/ipc/ShadowLayerUtilsGralloc.cpp b/gfx/layers/ipc/ShadowLayerUtilsGralloc.cpp index 1e3ff8ea67..e77ba8235e 100644 --- a/gfx/layers/ipc/ShadowLayerUtilsGralloc.cpp +++ b/gfx/layers/ipc/ShadowLayerUtilsGralloc.cpp @@ -49,7 +49,7 @@ ParamTraits::Write(Message* aMsg, } bool -ParamTraits::Read(const Message* aMsg, void** aIter, +ParamTraits::Read(const Message* aMsg, PickleIterator* aIter, paramType* aParam) { int owner; @@ -109,7 +109,7 @@ ParamTraits::Write(Message* aMsg, bool ParamTraits::Read(const Message* aMsg, - void** aIter, paramType* aResult) + PickleIterator* aIter, paramType* aResult) { MOZ_ASSERT(!aResult->mGraphicBuffer.get()); MOZ_ASSERT(aResult->mRef.mOwner == 0); diff --git a/gfx/layers/ipc/ShadowLayerUtilsGralloc.h b/gfx/layers/ipc/ShadowLayerUtilsGralloc.h index 6a1aaed5d7..b963e3bd9d 100644 --- a/gfx/layers/ipc/ShadowLayerUtilsGralloc.h +++ b/gfx/layers/ipc/ShadowLayerUtilsGralloc.h @@ -79,14 +79,14 @@ struct ParamTraits { typedef mozilla::layers::MagicGrallocBufferHandle paramType; static void Write(Message* aMsg, const paramType& aParam); - static bool Read(const Message* aMsg, void** aIter, paramType* aResult); + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult); }; template<> struct ParamTraits { typedef mozilla::layers::GrallocBufferRef paramType; static void Write(Message* aMsg, const paramType& aParam); - static bool Read(const Message* aMsg, void** aIter, paramType* aResult); + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult); }; diff --git a/gfx/layers/ipc/ShadowLayerUtilsX11.h b/gfx/layers/ipc/ShadowLayerUtilsX11.h index 78a05059e5..e3b58663a8 100644 --- a/gfx/layers/ipc/ShadowLayerUtilsX11.h +++ b/gfx/layers/ipc/ShadowLayerUtilsX11.h @@ -71,7 +71,7 @@ struct ParamTraits { WriteParam(aMsg, aParam.mGLXPixmap); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) { + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { return (ReadParam(aMsg, aIter, &aResult->mId) && ReadParam(aMsg, aIter, &aResult->mSize) && ReadParam(aMsg, aIter, &aResult->mFormat) && diff --git a/gfx/thebes/gfxPlatform.cpp b/gfx/thebes/gfxPlatform.cpp index 952b58847e..379c458e1a 100644 --- a/gfx/thebes/gfxPlatform.cpp +++ b/gfx/thebes/gfxPlatform.cpp @@ -23,6 +23,7 @@ #include "gfxEnv.h" #include "gfxTextRun.h" #include "gfxConfig.h" +#include "MediaPrefs.h" #ifdef XP_WIN #include @@ -588,6 +589,7 @@ gfxPlatform::Init() // Initialize the preferences by creating the singleton. gfxPrefs::GetSingleton(); + MediaPrefs::GetSingleton(); auto fwd = new CrashStatsLogForwarder("GraphicsCriticalError"); fwd->SetCircularBufferSize(gfxPrefs::GfxLoggingCrashLength()); diff --git a/gfx/thebes/gfxPrefs.h b/gfx/thebes/gfxPrefs.h index 41bffbc4cb..5baa29130a 100644 --- a/gfx/thebes/gfxPrefs.h +++ b/gfx/thebes/gfxPrefs.h @@ -135,12 +135,6 @@ private: // We will keep these in an alphabetical order to make it easier to see if // a method accessing a pref already exists. Just add yours in the list. - // It's a short time fix, and will be removed after landing bug 1206637. - DECL_GFX_PREF(Live, "accessibility.monoaudio.enable", MonoAudio, bool, false); - DECL_GFX_PREF(Live, "media.resampling.enabled", AudioSinkResampling, bool, false); - DECL_GFX_PREF(Live, "media.resampling.rate", AudioSinkResampleRate, uint32_t, 48000); - DECL_GFX_PREF(Live, "media.forcestereo.enabled", AudioSinkForceStereo, bool, true); - // The apz prefs are explained in AsyncPanZoomController.cpp DECL_GFX_PREF(Live, "apz.allow_checkerboarding", APZAllowCheckerboarding, bool, true); DECL_GFX_PREF(Live, "apz.allow_immediate_handoff", APZAllowImmediateHandoff, bool, true); diff --git a/gfx/vr/ipc/VRMessageUtils.h b/gfx/vr/ipc/VRMessageUtils.h index 1a5e8004dd..734cb33979 100644 --- a/gfx/vr/ipc/VRMessageUtils.h +++ b/gfx/vr/ipc/VRMessageUtils.h @@ -37,7 +37,7 @@ struct ParamTraits WriteParam(aMsg, aParam.mSensorState); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { if (!ReadParam(aMsg, aIter, &(aResult->mDeviceInfo)) || !ReadParam(aMsg, aIter, &(aResult->mSensorState))) { @@ -58,7 +58,7 @@ struct ParamTraits WriteParam(aMsg, aParam.mSensorState); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { if (!ReadParam(aMsg, aIter, &(aResult->mDeviceID)) || !ReadParam(aMsg, aIter, &(aResult->mSensorState))) { @@ -92,7 +92,7 @@ struct ParamTraits } } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { if (!ReadParam(aMsg, aIter, &(aResult->mType)) || !ReadParam(aMsg, aIter, &(aResult->mDeviceID)) || @@ -150,7 +150,7 @@ struct ParamTraits WriteParam(aMsg, aParam.linearAcceleration[2]); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { if (!ReadParam(aMsg, aIter, &(aResult->timestamp)) || !ReadParam(aMsg, aIter, &(aResult->inputFrameID)) || @@ -193,7 +193,7 @@ struct ParamTraits WriteParam(aMsg, aParam.leftDegrees); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { if (!ReadParam(aMsg, aIter, &(aResult->upDegrees)) || !ReadParam(aMsg, aIter, &(aResult->rightDegrees)) || diff --git a/ipc/chromium/src/base/at_exit.cc b/ipc/chromium/src/base/at_exit.cc index f6319fbc30..9481f36e2f 100644 --- a/ipc/chromium/src/base/at_exit.cc +++ b/ipc/chromium/src/base/at_exit.cc @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/at_exit.h b/ipc/chromium/src/base/at_exit.h index bea1442b24..5644dfa52e 100644 --- a/ipc/chromium/src/base/at_exit.h +++ b/ipc/chromium/src/base/at_exit.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/atomic_sequence_num.h b/ipc/chromium/src/base/atomic_sequence_num.h index 7bf2778991..cd0ad95603 100644 --- a/ipc/chromium/src/base/atomic_sequence_num.h +++ b/ipc/chromium/src/base/atomic_sequence_num.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/atomicops.h b/ipc/chromium/src/base/atomicops.h index 714e089280..dcb6917100 100644 --- a/ipc/chromium/src/base/atomicops.h +++ b/ipc/chromium/src/base/atomicops.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/atomicops_internals_arm64_gcc.h b/ipc/chromium/src/base/atomicops_internals_arm64_gcc.h index a2b0abc1a4..c5d1a92902 100644 --- a/ipc/chromium/src/base/atomicops_internals_arm64_gcc.h +++ b/ipc/chromium/src/base/atomicops_internals_arm64_gcc.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/atomicops_internals_arm_gcc.h b/ipc/chromium/src/base/atomicops_internals_arm_gcc.h index e838f1bbd8..628eb3d460 100644 --- a/ipc/chromium/src/base/atomicops_internals_arm_gcc.h +++ b/ipc/chromium/src/base/atomicops_internals_arm_gcc.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/atomicops_internals_mips_gcc.h b/ipc/chromium/src/base/atomicops_internals_mips_gcc.h index 80f5feb847..aec4561b2d 100644 --- a/ipc/chromium/src/base/atomicops_internals_mips_gcc.h +++ b/ipc/chromium/src/base/atomicops_internals_mips_gcc.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2012 The Chromium Authors. All rights reserved. // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are diff --git a/ipc/chromium/src/base/atomicops_internals_mutex.cc b/ipc/chromium/src/base/atomicops_internals_mutex.cc index eb9e155650..b129c86e82 100644 --- a/ipc/chromium/src/base/atomicops_internals_mutex.cc +++ b/ipc/chromium/src/base/atomicops_internals_mutex.cc @@ -1,6 +1,5 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * vim: sw=2 ts=8 et : - */ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ diff --git a/ipc/chromium/src/base/atomicops_internals_mutex.h b/ipc/chromium/src/base/atomicops_internals_mutex.h index 5b23a2e4f0..f8fe4c6acb 100644 --- a/ipc/chromium/src/base/atomicops_internals_mutex.h +++ b/ipc/chromium/src/base/atomicops_internals_mutex.h @@ -1,6 +1,5 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * vim: sw=2 ts=8 et : - */ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ @@ -31,7 +30,7 @@ T Locked_CAS(volatile T* ptr, T old_value, T new_value) { T current_value = *ptr; if (current_value == old_value) *ptr = new_value; - + return current_value; } diff --git a/ipc/chromium/src/base/atomicops_internals_ppc_gcc.h b/ipc/chromium/src/base/atomicops_internals_ppc_gcc.h index d5c4231af1..90c01e4a32 100644 --- a/ipc/chromium/src/base/atomicops_internals_ppc_gcc.h +++ b/ipc/chromium/src/base/atomicops_internals_ppc_gcc.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright 2012 the V8 project authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/atomicops_internals_x86_gcc.cc b/ipc/chromium/src/base/atomicops_internals_x86_gcc.cc index 29f8f82f9b..c5b11b31c5 100644 --- a/ipc/chromium/src/base/atomicops_internals_x86_gcc.cc +++ b/ipc/chromium/src/base/atomicops_internals_x86_gcc.cc @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/atomicops_internals_x86_gcc.h b/ipc/chromium/src/base/atomicops_internals_x86_gcc.h index 020e7b72b1..8088e7f6a4 100644 --- a/ipc/chromium/src/base/atomicops_internals_x86_gcc.h +++ b/ipc/chromium/src/base/atomicops_internals_x86_gcc.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/atomicops_internals_x86_macosx.h b/ipc/chromium/src/base/atomicops_internals_x86_macosx.h index 9997da1c7c..c8f3a67af8 100644 --- a/ipc/chromium/src/base/atomicops_internals_x86_macosx.h +++ b/ipc/chromium/src/base/atomicops_internals_x86_macosx.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/atomicops_internals_x86_msvc.h b/ipc/chromium/src/base/atomicops_internals_x86_msvc.h index 5c03346df1..524046935e 100644 --- a/ipc/chromium/src/base/atomicops_internals_x86_msvc.h +++ b/ipc/chromium/src/base/atomicops_internals_x86_msvc.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/basictypes.h b/ipc/chromium/src/base/basictypes.h index 65d8fb5dcc..6afc7e2381 100644 --- a/ipc/chromium/src/base/basictypes.h +++ b/ipc/chromium/src/base/basictypes.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/chrome_application_mac.h b/ipc/chromium/src/base/chrome_application_mac.h index 07fd433918..2f9719438c 100644 --- a/ipc/chromium/src/base/chrome_application_mac.h +++ b/ipc/chromium/src/base/chrome_application_mac.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/command_line.cc b/ipc/chromium/src/base/command_line.cc index 29ed8ea53e..85fd953e19 100644 --- a/ipc/chromium/src/base/command_line.cc +++ b/ipc/chromium/src/base/command_line.cc @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/command_line.h b/ipc/chromium/src/base/command_line.h index 8ae11dabc9..3ce94ed1bc 100644 --- a/ipc/chromium/src/base/command_line.h +++ b/ipc/chromium/src/base/command_line.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/compiler_specific.h b/ipc/chromium/src/base/compiler_specific.h index 50dc6f348a..509dfa4b46 100644 --- a/ipc/chromium/src/base/compiler_specific.h +++ b/ipc/chromium/src/base/compiler_specific.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/condition_variable.h b/ipc/chromium/src/base/condition_variable.h index 28f9352b42..4c95dc0bc2 100644 --- a/ipc/chromium/src/base/condition_variable.h +++ b/ipc/chromium/src/base/condition_variable.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/condition_variable_posix.cc b/ipc/chromium/src/base/condition_variable_posix.cc index 3110b7e3e9..70d2f79378 100644 --- a/ipc/chromium/src/base/condition_variable_posix.cc +++ b/ipc/chromium/src/base/condition_variable_posix.cc @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/condition_variable_win.cc b/ipc/chromium/src/base/condition_variable_win.cc index f48adb6771..b0a3df5fa0 100644 --- a/ipc/chromium/src/base/condition_variable_win.cc +++ b/ipc/chromium/src/base/condition_variable_win.cc @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/cpu.cc b/ipc/chromium/src/base/cpu.cc index 0fef897ae6..919b69bd06 100644 --- a/ipc/chromium/src/base/cpu.cc +++ b/ipc/chromium/src/base/cpu.cc @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/cpu.h b/ipc/chromium/src/base/cpu.h index 15cc668525..8260fdb463 100644 --- a/ipc/chromium/src/base/cpu.h +++ b/ipc/chromium/src/base/cpu.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/dir_reader_bsd.h b/ipc/chromium/src/base/dir_reader_bsd.h index f8962c36ce..35ba6bd153 100644 --- a/ipc/chromium/src/base/dir_reader_bsd.h +++ b/ipc/chromium/src/base/dir_reader_bsd.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/dir_reader_fallback.h b/ipc/chromium/src/base/dir_reader_fallback.h index 398f51b255..788ba32eff 100644 --- a/ipc/chromium/src/base/dir_reader_fallback.h +++ b/ipc/chromium/src/base/dir_reader_fallback.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/dir_reader_linux.h b/ipc/chromium/src/base/dir_reader_linux.h index f1ec4b7144..530fe2e015 100644 --- a/ipc/chromium/src/base/dir_reader_linux.h +++ b/ipc/chromium/src/base/dir_reader_linux.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/dir_reader_posix.h b/ipc/chromium/src/base/dir_reader_posix.h index 524d63aa16..4be04bd531 100644 --- a/ipc/chromium/src/base/dir_reader_posix.h +++ b/ipc/chromium/src/base/dir_reader_posix.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/eintr_wrapper.h b/ipc/chromium/src/base/eintr_wrapper.h index a3fb1e47a6..ea4546d9d7 100644 --- a/ipc/chromium/src/base/eintr_wrapper.h +++ b/ipc/chromium/src/base/eintr_wrapper.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/file_descriptor_posix.h b/ipc/chromium/src/base/file_descriptor_posix.h index 0bcd4b6c69..adbf6234f3 100644 --- a/ipc/chromium/src/base/file_descriptor_posix.h +++ b/ipc/chromium/src/base/file_descriptor_posix.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/file_descriptor_shuffle.cc b/ipc/chromium/src/base/file_descriptor_shuffle.cc index 5cce963fa9..13f0c1e705 100644 --- a/ipc/chromium/src/base/file_descriptor_shuffle.cc +++ b/ipc/chromium/src/base/file_descriptor_shuffle.cc @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/file_descriptor_shuffle.h b/ipc/chromium/src/base/file_descriptor_shuffle.h index 3cf4c5f107..a0a8a325c0 100644 --- a/ipc/chromium/src/base/file_descriptor_shuffle.h +++ b/ipc/chromium/src/base/file_descriptor_shuffle.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/file_path.cc b/ipc/chromium/src/base/file_path.cc index 9af670f018..f901b583d9 100644 --- a/ipc/chromium/src/base/file_path.cc +++ b/ipc/chromium/src/base/file_path.cc @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/file_path.h b/ipc/chromium/src/base/file_path.h index a8317cd4e4..b2e9f9a00d 100644 --- a/ipc/chromium/src/base/file_path.h +++ b/ipc/chromium/src/base/file_path.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/file_util.cc b/ipc/chromium/src/base/file_util.cc index bf121c685c..6f7d92f3ab 100644 --- a/ipc/chromium/src/base/file_util.cc +++ b/ipc/chromium/src/base/file_util.cc @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/file_util.h b/ipc/chromium/src/base/file_util.h index 4374d32602..c6bcc1895c 100644 --- a/ipc/chromium/src/base/file_util.h +++ b/ipc/chromium/src/base/file_util.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/file_util_posix.cc b/ipc/chromium/src/base/file_util_posix.cc index b716a5dd46..d648974049 100644 --- a/ipc/chromium/src/base/file_util_posix.cc +++ b/ipc/chromium/src/base/file_util_posix.cc @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/file_util_win.cc b/ipc/chromium/src/base/file_util_win.cc index 4568e02969..fd3fdbeeb5 100644 --- a/ipc/chromium/src/base/file_util_win.cc +++ b/ipc/chromium/src/base/file_util_win.cc @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/hash_tables.h b/ipc/chromium/src/base/hash_tables.h index 26abc5b60e..956cadb3d4 100644 --- a/ipc/chromium/src/base/hash_tables.h +++ b/ipc/chromium/src/base/hash_tables.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/histogram.cc b/ipc/chromium/src/base/histogram.cc index 5d2a7ac5e7..0cafff5e09 100644 --- a/ipc/chromium/src/base/histogram.cc +++ b/ipc/chromium/src/base/histogram.cc @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -273,7 +275,7 @@ bool Histogram::DeserializeHistogramInfo(const std::string& histogram_info) { int pickle_flags; SampleSet sample; - void* iter = NULL; + PickleIterator iter(pickle); if (!pickle.ReadString(&iter, &histogram_name) || !pickle.ReadInt(&iter, &declared_min) || !pickle.ReadInt(&iter, &declared_max) || @@ -784,7 +786,7 @@ bool Histogram::SampleSet::Serialize(Pickle* pickle) const { return true; } -bool Histogram::SampleSet::Deserialize(void** iter, const Pickle& pickle) { +bool Histogram::SampleSet::Deserialize(PickleIterator* iter, const Pickle& pickle) { OffTheBooksMutexAutoLock locker(mutex_); DCHECK_EQ(counts_.size(), 0u); DCHECK_EQ(sum_, 0); diff --git a/ipc/chromium/src/base/histogram.h b/ipc/chromium/src/base/histogram.h index 6cba6a3887..aeafbd9776 100644 --- a/ipc/chromium/src/base/histogram.h +++ b/ipc/chromium/src/base/histogram.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -53,6 +55,7 @@ #include "base/lock.h" class Pickle; +class PickleIterator; namespace base { @@ -359,7 +362,7 @@ class Histogram { void Add(const SampleSet& other); bool Serialize(Pickle* pickle) const; - bool Deserialize(void** iter, const Pickle& pickle); + bool Deserialize(PickleIterator* iter, const Pickle& pickle); size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf); diff --git a/ipc/chromium/src/base/id_map.h b/ipc/chromium/src/base/id_map.h index 3b74307668..bdd17effd4 100644 --- a/ipc/chromium/src/base/id_map.h +++ b/ipc/chromium/src/base/id_map.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/linked_ptr.h b/ipc/chromium/src/base/linked_ptr.h index 3f2bdb9416..1484bb4a37 100644 --- a/ipc/chromium/src/base/linked_ptr.h +++ b/ipc/chromium/src/base/linked_ptr.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/lock.cc b/ipc/chromium/src/base/lock.cc index 9ff963bfc9..47d3a4de1e 100644 --- a/ipc/chromium/src/base/lock.cc +++ b/ipc/chromium/src/base/lock.cc @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/lock.h b/ipc/chromium/src/base/lock.h index 31ad9a0185..3f8b96a8f2 100644 --- a/ipc/chromium/src/base/lock.h +++ b/ipc/chromium/src/base/lock.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/lock_impl.h b/ipc/chromium/src/base/lock_impl.h index c8460ec80d..aea01bd883 100644 --- a/ipc/chromium/src/base/lock_impl.h +++ b/ipc/chromium/src/base/lock_impl.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/lock_impl_posix.cc b/ipc/chromium/src/base/lock_impl_posix.cc index 355149f260..50fec95db2 100644 --- a/ipc/chromium/src/base/lock_impl_posix.cc +++ b/ipc/chromium/src/base/lock_impl_posix.cc @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/lock_impl_win.cc b/ipc/chromium/src/base/lock_impl_win.cc index 0f0e424311..2a50fb234f 100644 --- a/ipc/chromium/src/base/lock_impl_win.cc +++ b/ipc/chromium/src/base/lock_impl_win.cc @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/logging.cc b/ipc/chromium/src/base/logging.cc index ed7facc96e..d793990de4 100644 --- a/ipc/chromium/src/base/logging.cc +++ b/ipc/chromium/src/base/logging.cc @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/logging.h b/ipc/chromium/src/base/logging.h index b8e3c64d9a..d0950fb99c 100644 --- a/ipc/chromium/src/base/logging.h +++ b/ipc/chromium/src/base/logging.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/mac_util.h b/ipc/chromium/src/base/mac_util.h index 0cf63856ff..6af2bd7032 100644 --- a/ipc/chromium/src/base/mac_util.h +++ b/ipc/chromium/src/base/mac_util.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/message_loop.cc b/ipc/chromium/src/base/message_loop.cc index 02ca8e79d0..8a19bafa7f 100644 --- a/ipc/chromium/src/base/message_loop.cc +++ b/ipc/chromium/src/base/message_loop.cc @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -409,7 +411,7 @@ bool MessageLoop::DoWork() { PendingTask pending_task = Move(work_queue_.front()); work_queue_.pop(); if (!pending_task.delayed_run_time.is_null()) { - // NB: Don't move, because we use this later! + // NB: Don't move, because we use this later! AddToDelayedWorkQueue(pending_task); // If we changed the topmost task, then it is time to re-schedule. if (delayed_work_queue_.top().task == pending_task.task) diff --git a/ipc/chromium/src/base/message_loop.h b/ipc/chromium/src/base/message_loop.h index 37dcfcb0de..2d1a16c2a2 100644 --- a/ipc/chromium/src/base/message_loop.h +++ b/ipc/chromium/src/base/message_loop.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/message_pump.h b/ipc/chromium/src/base/message_pump.h index 9dc9dbf3eb..ffacaa9311 100644 --- a/ipc/chromium/src/base/message_pump.h +++ b/ipc/chromium/src/base/message_pump.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/message_pump_android.cc b/ipc/chromium/src/base/message_pump_android.cc index 1e43ab0a0f..2d8f310d15 100644 --- a/ipc/chromium/src/base/message_pump_android.cc +++ b/ipc/chromium/src/base/message_pump_android.cc @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/message_pump_android.h b/ipc/chromium/src/base/message_pump_android.h index d9645771f3..ac9801843f 100644 --- a/ipc/chromium/src/base/message_pump_android.h +++ b/ipc/chromium/src/base/message_pump_android.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/message_pump_default.cc b/ipc/chromium/src/base/message_pump_default.cc index 0c93f87a97..ef37b6296b 100644 --- a/ipc/chromium/src/base/message_pump_default.cc +++ b/ipc/chromium/src/base/message_pump_default.cc @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/message_pump_default.h b/ipc/chromium/src/base/message_pump_default.h index a0d0e8acb6..98c204e623 100644 --- a/ipc/chromium/src/base/message_pump_default.h +++ b/ipc/chromium/src/base/message_pump_default.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/message_pump_glib.cc b/ipc/chromium/src/base/message_pump_glib.cc index 516f4887ac..36ebfdd69f 100644 --- a/ipc/chromium/src/base/message_pump_glib.cc +++ b/ipc/chromium/src/base/message_pump_glib.cc @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/message_pump_glib.h b/ipc/chromium/src/base/message_pump_glib.h index 59fffd6687..1d0e057096 100644 --- a/ipc/chromium/src/base/message_pump_glib.h +++ b/ipc/chromium/src/base/message_pump_glib.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/message_pump_libevent.cc b/ipc/chromium/src/base/message_pump_libevent.cc index 077f1070a9..d9be402ec3 100644 --- a/ipc/chromium/src/base/message_pump_libevent.cc +++ b/ipc/chromium/src/base/message_pump_libevent.cc @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/message_pump_libevent.h b/ipc/chromium/src/base/message_pump_libevent.h index a239256f8d..224f70932c 100644 --- a/ipc/chromium/src/base/message_pump_libevent.h +++ b/ipc/chromium/src/base/message_pump_libevent.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/message_pump_mac.h b/ipc/chromium/src/base/message_pump_mac.h index 107c29e190..7c8b3625f0 100644 --- a/ipc/chromium/src/base/message_pump_mac.h +++ b/ipc/chromium/src/base/message_pump_mac.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/message_pump_qt.cc b/ipc/chromium/src/base/message_pump_qt.cc index 0435207a31..0fcd685b9d 100644 --- a/ipc/chromium/src/base/message_pump_qt.cc +++ b/ipc/chromium/src/base/message_pump_qt.cc @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/message_pump_qt.h b/ipc/chromium/src/base/message_pump_qt.h index 48a956756f..625b10095a 100644 --- a/ipc/chromium/src/base/message_pump_qt.h +++ b/ipc/chromium/src/base/message_pump_qt.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/message_pump_win.cc b/ipc/chromium/src/base/message_pump_win.cc index 530958b358..407a470650 100644 --- a/ipc/chromium/src/base/message_pump_win.cc +++ b/ipc/chromium/src/base/message_pump_win.cc @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/message_pump_win.h b/ipc/chromium/src/base/message_pump_win.h index 2963045d11..ddb6e0d459 100644 --- a/ipc/chromium/src/base/message_pump_win.h +++ b/ipc/chromium/src/base/message_pump_win.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/object_watcher.cc b/ipc/chromium/src/base/object_watcher.cc index 4768cb41a9..a9bf2c9fbc 100644 --- a/ipc/chromium/src/base/object_watcher.cc +++ b/ipc/chromium/src/base/object_watcher.cc @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/object_watcher.h b/ipc/chromium/src/base/object_watcher.h index a1c4202c38..f3ddf7ef87 100644 --- a/ipc/chromium/src/base/object_watcher.h +++ b/ipc/chromium/src/base/object_watcher.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/observer_list.h b/ipc/chromium/src/base/observer_list.h index c387bd9483..4dce7ae59b 100644 --- a/ipc/chromium/src/base/observer_list.h +++ b/ipc/chromium/src/base/observer_list.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/pickle.cc b/ipc/chromium/src/base/pickle.cc index 3d50784550..0a0118bb4f 100644 --- a/ipc/chromium/src/base/pickle.cc +++ b/ipc/chromium/src/base/pickle.cc @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -91,13 +93,18 @@ struct Copier } }; +} // anonymous namespace + template -void CopyFromIter(T* dest, void** iter) { +void +PickleIterator::CopyFrom(T* dest) { static_assert(mozilla::IsPod::value, "Copied type must be a POD type"); - Copier::Copy(dest, iter); + Copier::Copy(dest, &iter_); } -} // anonymous namespace +PickleIterator::PickleIterator(const Pickle& pickle) + : iter_(const_cast(pickle.payload())) { +} // Payload is sizeof(Pickle::memberAlignmentType) aligned. @@ -143,16 +150,6 @@ Pickle::Pickle(const char* data, int data_len, Ownership ownership) header_ = nullptr; } -Pickle::Pickle(const Pickle& other) - : header_(NULL), - header_size_(other.header_size_), - capacity_(0), - variable_buffer_offset_(other.variable_buffer_offset_) { - uint32_t payload_size = header_size_ + other.header_->payload_size; - Resize(payload_size); - memcpy(header_, other.header_, payload_size); -} - Pickle::Pickle(Pickle&& other) : header_(other.header_), header_size_(other.header_size_), @@ -168,18 +165,6 @@ Pickle::~Pickle() { free(header_); } -Pickle& Pickle::operator=(const Pickle& other) { - if (header_size_ != other.header_size_ && capacity_ != kCapacityReadOnly) { - free(header_); - header_ = NULL; - header_size_ = other.header_size_; - } - Resize(other.header_size_ + other.header_->payload_size); - memcpy(header_, other.header_, header_size_ + other.header_->payload_size); - variable_buffer_offset_ = other.variable_buffer_offset_; - return *this; -} - Pickle& Pickle::operator=(Pickle&& other) { std::swap(header_, other.header_); std::swap(header_size_, other.header_size_); @@ -188,7 +173,7 @@ Pickle& Pickle::operator=(Pickle&& other) { return *this; } -bool Pickle::ReadBool(void** iter, bool* result) const { +bool Pickle::ReadBool(PickleIterator* iter, bool* result) const { DCHECK(iter); int tmp; @@ -199,43 +184,37 @@ bool Pickle::ReadBool(void** iter, bool* result) const { return true; } -bool Pickle::ReadInt16(void** iter, int16_t* result) const { +bool Pickle::ReadInt16(PickleIterator* iter, int16_t* result) const { DCHECK(iter); - if (!*iter) - *iter = const_cast(payload()); if (!IteratorHasRoomFor(*iter, sizeof(*result))) return false; - CopyFromIter(result, iter); + iter->CopyFrom(result); UpdateIter(iter, sizeof(*result)); return true; } -bool Pickle::ReadUInt16(void** iter, uint16_t* result) const { +bool Pickle::ReadUInt16(PickleIterator* iter, uint16_t* result) const { DCHECK(iter); - if (!*iter) - *iter = const_cast(payload()); if (!IteratorHasRoomFor(*iter, sizeof(*result))) return false; - CopyFromIter(result, iter); + iter->CopyFrom(result); UpdateIter(iter, sizeof(*result)); return true; } -bool Pickle::ReadInt(void** iter, int* result) const { +bool Pickle::ReadInt(PickleIterator* iter, int* result) const { DCHECK(iter); - if (!*iter) - *iter = const_cast(payload()); if (!IteratorHasRoomFor(*iter, sizeof(*result))) return false; - CopyFromIter(result, iter); + iter->CopyFrom(result); UpdateIter(iter, sizeof(*result)); return true; @@ -243,16 +222,14 @@ bool Pickle::ReadInt(void** iter, int* result) const { // Always written as a 64-bit value since the size for this type can // differ between architectures. -bool Pickle::ReadLong(void** iter, long* result) const { +bool Pickle::ReadLong(PickleIterator* iter, long* result) const { DCHECK(iter); - if (!*iter) - *iter = const_cast(payload()); int64_t bigResult = 0; if (!IteratorHasRoomFor(*iter, sizeof(bigResult))) return false; - CopyFromIter(&bigResult, iter); + iter->CopyFrom(&bigResult); DCHECK(bigResult <= LONG_MAX && bigResult >= LONG_MIN); *result = static_cast(bigResult); @@ -262,16 +239,14 @@ bool Pickle::ReadLong(void** iter, long* result) const { // Always written as a 64-bit value since the size for this type can // differ between architectures. -bool Pickle::ReadULong(void** iter, unsigned long* result) const { +bool Pickle::ReadULong(PickleIterator* iter, unsigned long* result) const { DCHECK(iter); - if (!*iter) - *iter = const_cast(payload()); uint64_t bigResult = 0; if (!IteratorHasRoomFor(*iter, sizeof(bigResult))) return false; - CopyFromIter(&bigResult, iter); + iter->CopyFrom(&bigResult); DCHECK(bigResult <= ULONG_MAX); *result = static_cast(bigResult); @@ -279,7 +254,7 @@ bool Pickle::ReadULong(void** iter, unsigned long* result) const { return true; } -bool Pickle::ReadLength(void** iter, int* result) const { +bool Pickle::ReadLength(PickleIterator* iter, int* result) const { if (!ReadInt(iter, result)) return false; return ((*result) >= 0); @@ -287,16 +262,14 @@ bool Pickle::ReadLength(void** iter, int* result) const { // Always written as a 64-bit value since the size for this type can // differ between architectures. -bool Pickle::ReadSize(void** iter, size_t* result) const { +bool Pickle::ReadSize(PickleIterator* iter, size_t* result) const { DCHECK(iter); - if (!*iter) - *iter = const_cast(payload()); uint64_t bigResult = 0; if (!IteratorHasRoomFor(*iter, sizeof(bigResult))) return false; - CopyFromIter(&bigResult, iter); + iter->CopyFrom(&bigResult); DCHECK(bigResult <= std::numeric_limits::max()); *result = static_cast(bigResult); @@ -304,71 +277,61 @@ bool Pickle::ReadSize(void** iter, size_t* result) const { return true; } -bool Pickle::ReadInt32(void** iter, int32_t* result) const { +bool Pickle::ReadInt32(PickleIterator* iter, int32_t* result) const { DCHECK(iter); - if (!*iter) - *iter = const_cast(payload()); if (!IteratorHasRoomFor(*iter, sizeof(*result))) return false; - CopyFromIter(result, iter); + iter->CopyFrom(result); UpdateIter(iter, sizeof(*result)); return true; } -bool Pickle::ReadUInt32(void** iter, uint32_t* result) const { +bool Pickle::ReadUInt32(PickleIterator* iter, uint32_t* result) const { DCHECK(iter); - if (!*iter) - *iter = const_cast(payload()); if (!IteratorHasRoomFor(*iter, sizeof(*result))) return false; - CopyFromIter(result, iter); + iter->CopyFrom(result); UpdateIter(iter, sizeof(*result)); return true; } -bool Pickle::ReadInt64(void** iter, int64_t* result) const { +bool Pickle::ReadInt64(PickleIterator* iter, int64_t* result) const { DCHECK(iter); - if (!*iter) - *iter = const_cast(payload()); if (!IteratorHasRoomFor(*iter, sizeof(*result))) return false; - CopyFromIter(result, iter); + iter->CopyFrom(result); UpdateIter(iter, sizeof(*result)); return true; } -bool Pickle::ReadUInt64(void** iter, uint64_t* result) const { +bool Pickle::ReadUInt64(PickleIterator* iter, uint64_t* result) const { DCHECK(iter); - if (!*iter) - *iter = const_cast(payload()); if (!IteratorHasRoomFor(*iter, sizeof(*result))) return false; - CopyFromIter(result, iter); + iter->CopyFrom(result); UpdateIter(iter, sizeof(*result)); return true; } -bool Pickle::ReadDouble(void** iter, double* result) const { +bool Pickle::ReadDouble(PickleIterator* iter, double* result) const { DCHECK(iter); - if (!*iter) - *iter = const_cast(payload()); if (!IteratorHasRoomFor(*iter, sizeof(*result))) return false; - CopyFromIter(result, iter); + iter->CopyFrom(result); UpdateIter(iter, sizeof(*result)); return true; @@ -376,16 +339,14 @@ bool Pickle::ReadDouble(void** iter, double* result) const { // Always written as a 64-bit value since the size for this type can // differ between architectures. -bool Pickle::ReadIntPtr(void** iter, intptr_t* result) const { +bool Pickle::ReadIntPtr(PickleIterator* iter, intptr_t* result) const { DCHECK(iter); - if (!*iter) - *iter = const_cast(payload()); int64_t bigResult = 0; if (!IteratorHasRoomFor(*iter, sizeof(bigResult))) return false; - CopyFromIter(&bigResult, iter); + iter->CopyFrom(&bigResult); DCHECK(bigResult <= std::numeric_limits::max() && bigResult >= std::numeric_limits::min()); *result = static_cast(bigResult); @@ -393,24 +354,20 @@ bool Pickle::ReadIntPtr(void** iter, intptr_t* result) const { return true; } -bool Pickle::ReadUnsignedChar(void** iter, unsigned char* result) const { +bool Pickle::ReadUnsignedChar(PickleIterator* iter, unsigned char* result) const { DCHECK(iter); - if (!*iter) - *iter = const_cast(payload()); if (!IteratorHasRoomFor(*iter, sizeof(*result))) return false; - CopyFromIter(result, iter); + iter->CopyFrom(result); UpdateIter(iter, sizeof(*result)); return true; } -bool Pickle::ReadString(void** iter, std::string* result) const { +bool Pickle::ReadString(PickleIterator* iter, std::string* result) const { DCHECK(iter); - if (!*iter) - *iter = const_cast(payload()); int len; if (!ReadLength(iter, &len)) @@ -418,17 +375,15 @@ bool Pickle::ReadString(void** iter, std::string* result) const { if (!IteratorHasRoomFor(*iter, len)) return false; - char* chars = reinterpret_cast(*iter); + char* chars = reinterpret_cast(iter->iter_); result->assign(chars, len); UpdateIter(iter, len); return true; } -bool Pickle::ReadWString(void** iter, std::wstring* result) const { +bool Pickle::ReadWString(PickleIterator* iter, std::wstring* result) const { DCHECK(iter); - if (!*iter) - *iter = const_cast(payload()); int len; if (!ReadLength(iter, &len)) @@ -439,28 +394,25 @@ bool Pickle::ReadWString(void** iter, std::wstring* result) const { if (!IteratorHasRoomFor(*iter, len * sizeof(wchar_t))) return false; - wchar_t* chars = reinterpret_cast(*iter); + wchar_t* chars = reinterpret_cast(iter->iter_); result->assign(chars, len); UpdateIter(iter, len * sizeof(wchar_t)); return true; } -bool Pickle::ReadBytes(void** iter, const char** data, int length, +bool Pickle::ReadBytes(PickleIterator* iter, const char** data, int length, uint32_t alignment) const { DCHECK(iter); DCHECK(data); DCHECK(alignment == 4 || alignment == 8); DCHECK(intptr_t(header_) % alignment == 0); - if (!*iter) - *iter = const_cast(payload()); - - uint32_t paddingLen = intptr_t(*iter) % alignment; + uint32_t paddingLen = intptr_t(iter->iter_) % alignment; if (paddingLen) { #ifdef DEBUG { - const char* padding = static_cast(*iter); + const char* padding = static_cast(iter->iter_); for (uint32_t i = 0; i < paddingLen; i++) { DCHECK(*(padding + i) == kBytePaddingMarker); } @@ -472,19 +424,17 @@ bool Pickle::ReadBytes(void** iter, const char** data, int length, if (!IteratorHasRoomFor(*iter, length)) return false; - *data = static_cast(*iter) + paddingLen; + *data = static_cast(iter->iter_) + paddingLen; DCHECK(intptr_t(*data) % alignment == 0); UpdateIter(iter, length); return true; } -bool Pickle::ReadData(void** iter, const char** data, int* length) const { +bool Pickle::ReadData(PickleIterator* iter, const char** data, int* length) const { DCHECK(iter); DCHECK(data); DCHECK(length); - if (!*iter) - *iter = const_cast(payload()); if (!ReadLength(iter, length)) return false; @@ -540,7 +490,7 @@ void Pickle::EndWrite(char* dest, int length) { // memory. if (length % sizeof(memberAlignmentType)) memset(dest + length, 0, - sizeof(memberAlignmentType) - (length % sizeof(memberAlignmentType))); + sizeof(memberAlignmentType) - (length % sizeof(memberAlignmentType))); } bool Pickle::WriteBytes(const void* data, int data_len, uint32_t alignment) { @@ -597,23 +547,6 @@ char* Pickle::BeginWriteData(int length) { return data_ptr; } -void Pickle::TrimWriteData(int new_length) { - DCHECK(variable_buffer_offset_ != 0); - - // Fetch the the variable buffer size - int* cur_length = reinterpret_cast( - reinterpret_cast(header_) + variable_buffer_offset_); - - if (new_length < 0 || new_length > *cur_length) { - NOTREACHED() << "Invalid length in TrimWriteData."; - return; - } - - // Update the payload size and variable buffer size - header_->payload_size -= (*cur_length - new_length); - *cur_length = new_length; -} - void Pickle::Resize(uint32_t new_capacity) { new_capacity = ConstantAligner::align(new_capacity); @@ -645,8 +578,8 @@ const char* Pickle::FindNext(uint32_t header_size, // static uint32_t Pickle::GetLength(uint32_t header_size, - const char* start, - const char* end) { + const char* start, + const char* end) { DCHECK(header_size == AlignInt(header_size)); DCHECK(header_size <= static_cast(kPayloadUnit)); diff --git a/ipc/chromium/src/base/pickle.h b/ipc/chromium/src/base/pickle.h index 1df477d069..55b5e7081f 100644 --- a/ipc/chromium/src/base/pickle.h +++ b/ipc/chromium/src/base/pickle.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -13,6 +15,21 @@ #include "mozilla/Attributes.h" +class Pickle; + +class PickleIterator { +public: + explicit PickleIterator(const Pickle& pickle); + +private: + friend class Pickle; + + template + void CopyFrom(T* dest); + + void* iter_; +}; + // This class provides facilities for basic binary value packing and unpacking. // // The Pickle class supports appending primitive values (ints, strings, etc.) @@ -55,13 +72,12 @@ class Pickle { // is writable and will be freed when this Pickle is destroyed. Pickle(const char* data, int data_len, Ownership ownership = BORROWS); - // Initializes a Pickle as a deep copy of another Pickle. - Pickle(const Pickle& other); + Pickle(const Pickle& other) = delete; Pickle(Pickle&& other); // Performs a deep copy. - Pickle& operator=(const Pickle& other); + Pickle& operator=(const Pickle& other) = delete; Pickle& operator=(Pickle&& other); @@ -81,30 +97,34 @@ class Pickle { // the Pickle, initialize *iter to NULL. If successful, these methods return // true. Otherwise, false is returned to indicate that the result could not // be extracted. - MOZ_MUST_USE bool ReadBool(void** iter, bool* result) const; - MOZ_MUST_USE bool ReadInt16(void** iter, int16_t* result) const; - MOZ_MUST_USE bool ReadUInt16(void** iter, uint16_t* result) const; - MOZ_MUST_USE bool ReadShort(void** iter, short* result) const; - MOZ_MUST_USE bool ReadInt(void** iter, int* result) const; - MOZ_MUST_USE bool ReadLong(void** iter, long* result) const; - MOZ_MUST_USE bool ReadULong(void** iter, unsigned long* result) const; - MOZ_MUST_USE bool ReadSize(void** iter, size_t* result) const; - MOZ_MUST_USE bool ReadInt32(void** iter, int32_t* result) const; - MOZ_MUST_USE bool ReadUInt32(void** iter, uint32_t* result) const; - MOZ_MUST_USE bool ReadInt64(void** iter, int64_t* result) const; - MOZ_MUST_USE bool ReadUInt64(void** iter, uint64_t* result) const; - MOZ_MUST_USE bool ReadDouble(void** iter, double* result) const; - MOZ_MUST_USE bool ReadIntPtr(void** iter, intptr_t* result) const; - MOZ_MUST_USE bool ReadUnsignedChar(void** iter, unsigned char* result) const; - MOZ_MUST_USE bool ReadString(void** iter, std::string* result) const; - MOZ_MUST_USE bool ReadWString(void** iter, std::wstring* result) const; - MOZ_MUST_USE bool ReadData(void** iter, const char** data, int* length) const; - MOZ_MUST_USE bool ReadBytes(void** iter, const char** data, int length, - uint32_t alignment = sizeof(memberAlignmentType)) const; + MOZ_MUST_USE bool ReadBool(PickleIterator* iter, bool* result) const; + MOZ_MUST_USE bool ReadInt16(PickleIterator* iter, int16_t* result) const; + MOZ_MUST_USE bool ReadUInt16(PickleIterator* iter, uint16_t* result) const; + MOZ_MUST_USE bool ReadShort(PickleIterator* iter, short* result) const; + MOZ_MUST_USE bool ReadInt(PickleIterator* iter, int* result) const; + MOZ_MUST_USE bool ReadLong(PickleIterator* iter, long* result) const; + MOZ_MUST_USE bool ReadULong(PickleIterator* iter, unsigned long* result) const; + MOZ_MUST_USE bool ReadSize(PickleIterator* iter, size_t* result) const; + MOZ_MUST_USE bool ReadInt32(PickleIterator* iter, int32_t* result) const; + MOZ_MUST_USE bool ReadUInt32(PickleIterator* iter, uint32_t* result) const; + MOZ_MUST_USE bool ReadInt64(PickleIterator* iter, int64_t* result) const; + MOZ_MUST_USE bool ReadUInt64(PickleIterator* iter, uint64_t* result) const; + MOZ_MUST_USE bool ReadDouble(PickleIterator* iter, double* result) const; + MOZ_MUST_USE bool ReadIntPtr(PickleIterator* iter, intptr_t* result) const; + MOZ_MUST_USE bool ReadUnsignedChar(PickleIterator* iter, unsigned char* result) const; + MOZ_MUST_USE bool ReadString(PickleIterator* iter, std::string* result) const; + MOZ_MUST_USE bool ReadWString(PickleIterator* iter, std::wstring* result) const; + MOZ_MUST_USE bool ReadData(PickleIterator* iter, const char** data, int* length) const; + MOZ_MUST_USE bool ReadBytes(PickleIterator* iter, const char** data, int length, + uint32_t alignment = sizeof(memberAlignmentType)) const; // Safer version of ReadInt() checks for the result not being negative. // Use it for reading the object sizes. - MOZ_MUST_USE bool ReadLength(void** iter, int* result) const; + MOZ_MUST_USE bool ReadLength(PickleIterator* iter, int* result) const; + + void EndRead(PickleIterator& iter) const { + DCHECK(iter.iter_ == end_of_payload()); + } // Methods for adding to the payload of the Pickle. These values are // appended to the end of the Pickle's payload. When reading values from a @@ -176,21 +196,6 @@ class Pickle { // on this Pickle. char* BeginWriteData(int length); - // For Pickles which contain variable length buffers (e.g. those created - // with BeginWriteData), the Pickle can - // be 'trimmed' if the amount of data required is less than originally - // requested. For example, you may have created a buffer with 10K of data, - // but decided to only fill 10 bytes of that data. Use this function - // to trim the buffer so that we don't send 9990 bytes of unused data. - // You cannot increase the size of the variable buffer; only shrink it. - // This function assumes that the length of the variable buffer has - // not been changed. - void TrimWriteData(int length); - - void EndRead(void* iter) const { - DCHECK(iter == end_of_payload()); - } - // Payload follows after allocation of Header (header size is customizable). struct Header { uint32_t payload_size; // Specifies the size of the payload. @@ -213,12 +218,12 @@ class Pickle { // Returns true if the given iterator could point to data with the given // length. If there is no room for the given data before the end of the // payload, returns false. - bool IteratorHasRoomFor(const void* iter, int len) const { - if ((len < 0) || (iter < header_) || iter > end_of_payload()) + bool IteratorHasRoomFor(const PickleIterator& iter, int len) const { + if ((len < 0) || (iter.iter_ < header_) || iter.iter_ > end_of_payload()) return false; - const char* end_of_region = reinterpret_cast(iter) + len; + const char* end_of_region = reinterpret_cast(iter.iter_) + len; // Watch out for overflow in pointer calculation, which wraps. - return (iter <= end_of_region) && (end_of_region <= end_of_payload()); + return (iter.iter_ <= end_of_region) && (end_of_region <= end_of_payload()); } typedef uint32_t memberAlignmentType; @@ -266,7 +271,7 @@ class Pickle { template struct ConstantAligner { static uint32_t align(int bytes) { static_assert((alignment & (alignment - 1)) == 0, - "alignment must be a power of two"); + "alignment must be a power of two"); return (bytes + (alignment - 1)) & ~static_cast(alignment - 1); } }; @@ -278,8 +283,8 @@ class Pickle { // Moves the iterator by the given number of bytes, making sure it is aligned. // Pointer (iterator) is NOT aligned, but the change in the pointer // is guaranteed to be a multiple of sizeof(memberAlignmentType). - static void UpdateIter(void** iter, int bytes) { - *iter = static_cast(*iter) + AlignInt(bytes); + static void UpdateIter(PickleIterator* iter, int bytes) { + iter->iter_ = static_cast(iter->iter_) + AlignInt(bytes); } // Find the end of the pickled data that starts at range_start. Returns NULL @@ -298,6 +303,8 @@ class Pickle { static const int kPayloadUnit; private: + friend class PickleIterator; + Header* header_; uint32_t header_size_; uint32_t capacity_; diff --git a/ipc/chromium/src/base/platform_file.h b/ipc/chromium/src/base/platform_file.h index 52484c7d73..326a7a0e17 100644 --- a/ipc/chromium/src/base/platform_file.h +++ b/ipc/chromium/src/base/platform_file.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/platform_file_posix.cc b/ipc/chromium/src/base/platform_file_posix.cc index 763dd91456..4289afbc68 100644 --- a/ipc/chromium/src/base/platform_file_posix.cc +++ b/ipc/chromium/src/base/platform_file_posix.cc @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/platform_file_win.cc b/ipc/chromium/src/base/platform_file_win.cc index 76247981db..a624acd65d 100644 --- a/ipc/chromium/src/base/platform_file_win.cc +++ b/ipc/chromium/src/base/platform_file_win.cc @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/platform_thread.h b/ipc/chromium/src/base/platform_thread.h index ed09afd371..727a13a84c 100644 --- a/ipc/chromium/src/base/platform_thread.h +++ b/ipc/chromium/src/base/platform_thread.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/platform_thread_posix.cc b/ipc/chromium/src/base/platform_thread_posix.cc index be250691a3..6c978336ee 100644 --- a/ipc/chromium/src/base/platform_thread_posix.cc +++ b/ipc/chromium/src/base/platform_thread_posix.cc @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/platform_thread_win.cc b/ipc/chromium/src/base/platform_thread_win.cc index 35f4b90e96..2e76142306 100644 --- a/ipc/chromium/src/base/platform_thread_win.cc +++ b/ipc/chromium/src/base/platform_thread_win.cc @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/port.h b/ipc/chromium/src/base/port.h index 573f5f07bc..d206d2530e 100644 --- a/ipc/chromium/src/base/port.h +++ b/ipc/chromium/src/base/port.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/process.h b/ipc/chromium/src/base/process.h index 3dd009a074..b562771e62 100644 --- a/ipc/chromium/src/base/process.h +++ b/ipc/chromium/src/base/process.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/process_posix.cc b/ipc/chromium/src/base/process_posix.cc index dd0ed31b3f..d8ea644c6b 100644 --- a/ipc/chromium/src/base/process_posix.cc +++ b/ipc/chromium/src/base/process_posix.cc @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/process_util.h b/ipc/chromium/src/base/process_util.h index 4f33a54c3c..ea9f7896a1 100644 --- a/ipc/chromium/src/base/process_util.h +++ b/ipc/chromium/src/base/process_util.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/process_util_bsd.cc b/ipc/chromium/src/base/process_util_bsd.cc index 2e032ae9df..36c366b8ee 100644 --- a/ipc/chromium/src/base/process_util_bsd.cc +++ b/ipc/chromium/src/base/process_util_bsd.cc @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/process_util_linux.cc b/ipc/chromium/src/base/process_util_linux.cc index dc0f0fccda..407ece9143 100644 --- a/ipc/chromium/src/base/process_util_linux.cc +++ b/ipc/chromium/src/base/process_util_linux.cc @@ -1,5 +1,5 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set sw=2 ts=2 autoindent cindent expandtab: */ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/process_util_posix.cc b/ipc/chromium/src/base/process_util_posix.cc index c0acb72d3e..5a4209ccb3 100644 --- a/ipc/chromium/src/base/process_util_posix.cc +++ b/ipc/chromium/src/base/process_util_posix.cc @@ -1,4 +1,5 @@ -//* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/process_util_win.cc b/ipc/chromium/src/base/process_util_win.cc index 7491423d31..34b2f1dd49 100644 --- a/ipc/chromium/src/base/process_util_win.cc +++ b/ipc/chromium/src/base/process_util_win.cc @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/process_win.cc b/ipc/chromium/src/base/process_win.cc index f6494749db..4d0f137c4e 100644 --- a/ipc/chromium/src/base/process_win.cc +++ b/ipc/chromium/src/base/process_win.cc @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/rand_util.cc b/ipc/chromium/src/base/rand_util.cc index d0668c337d..9129786168 100644 --- a/ipc/chromium/src/base/rand_util.cc +++ b/ipc/chromium/src/base/rand_util.cc @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/rand_util.h b/ipc/chromium/src/base/rand_util.h index 6a78431bcf..fd014441f8 100644 --- a/ipc/chromium/src/base/rand_util.h +++ b/ipc/chromium/src/base/rand_util.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/rand_util_posix.cc b/ipc/chromium/src/base/rand_util_posix.cc index 1800f12b96..9a6b0f0ef6 100644 --- a/ipc/chromium/src/base/rand_util_posix.cc +++ b/ipc/chromium/src/base/rand_util_posix.cc @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/rand_util_win.cc b/ipc/chromium/src/base/rand_util_win.cc index d998cb6c2c..ee189f28ee 100644 --- a/ipc/chromium/src/base/rand_util_win.cc +++ b/ipc/chromium/src/base/rand_util_win.cc @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/revocable_store.cc b/ipc/chromium/src/base/revocable_store.cc index 400b2dd5d7..9a586a5a61 100644 --- a/ipc/chromium/src/base/revocable_store.cc +++ b/ipc/chromium/src/base/revocable_store.cc @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/revocable_store.h b/ipc/chromium/src/base/revocable_store.h index c92a033dce..13095728b3 100644 --- a/ipc/chromium/src/base/revocable_store.h +++ b/ipc/chromium/src/base/revocable_store.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/scoped_bstr_win.h b/ipc/chromium/src/base/scoped_bstr_win.h index 89030e6605..86cfb0254d 100644 --- a/ipc/chromium/src/base/scoped_bstr_win.h +++ b/ipc/chromium/src/base/scoped_bstr_win.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/scoped_cftyperef.h b/ipc/chromium/src/base/scoped_cftyperef.h index 7b4f1e6835..703a5130b4 100644 --- a/ipc/chromium/src/base/scoped_cftyperef.h +++ b/ipc/chromium/src/base/scoped_cftyperef.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/scoped_handle.h b/ipc/chromium/src/base/scoped_handle.h index e53b2dd191..f4fc29b66a 100644 --- a/ipc/chromium/src/base/scoped_handle.h +++ b/ipc/chromium/src/base/scoped_handle.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/scoped_handle_win.h b/ipc/chromium/src/base/scoped_handle_win.h index dbd0627d52..d4d8fccc4f 100644 --- a/ipc/chromium/src/base/scoped_handle_win.h +++ b/ipc/chromium/src/base/scoped_handle_win.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/scoped_nsautorelease_pool.h b/ipc/chromium/src/base/scoped_nsautorelease_pool.h index 64bf9e7c96..2136b91275 100644 --- a/ipc/chromium/src/base/scoped_nsautorelease_pool.h +++ b/ipc/chromium/src/base/scoped_nsautorelease_pool.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/scoped_nsobject.h b/ipc/chromium/src/base/scoped_nsobject.h index 2c808c69a0..2041140210 100644 --- a/ipc/chromium/src/base/scoped_nsobject.h +++ b/ipc/chromium/src/base/scoped_nsobject.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/shared_memory.h b/ipc/chromium/src/base/shared_memory.h index 49291cd601..15a0a95fe5 100644 --- a/ipc/chromium/src/base/shared_memory.h +++ b/ipc/chromium/src/base/shared_memory.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/shared_memory_posix.cc b/ipc/chromium/src/base/shared_memory_posix.cc index bc8238555b..b02326df91 100644 --- a/ipc/chromium/src/base/shared_memory_posix.cc +++ b/ipc/chromium/src/base/shared_memory_posix.cc @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/shared_memory_win.cc b/ipc/chromium/src/base/shared_memory_win.cc index 757443a718..042adc834b 100644 --- a/ipc/chromium/src/base/shared_memory_win.cc +++ b/ipc/chromium/src/base/shared_memory_win.cc @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/singleton.h b/ipc/chromium/src/base/singleton.h index 00cd448bc8..9f333af974 100644 --- a/ipc/chromium/src/base/singleton.h +++ b/ipc/chromium/src/base/singleton.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/singleton_objc.h b/ipc/chromium/src/base/singleton_objc.h index ba9fc78f1e..07fc092ab8 100644 --- a/ipc/chromium/src/base/singleton_objc.h +++ b/ipc/chromium/src/base/singleton_objc.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/stack_container.h b/ipc/chromium/src/base/stack_container.h index e8e72741d5..23991c2f90 100644 --- a/ipc/chromium/src/base/stack_container.h +++ b/ipc/chromium/src/base/stack_container.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/stl_util-inl.h b/ipc/chromium/src/base/stl_util-inl.h index ffa1628b28..994263277e 100644 --- a/ipc/chromium/src/base/stl_util-inl.h +++ b/ipc/chromium/src/base/stl_util-inl.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/string16.cc b/ipc/chromium/src/base/string16.cc index baea961c8b..3d4efb0f01 100644 --- a/ipc/chromium/src/base/string16.cc +++ b/ipc/chromium/src/base/string16.cc @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/string16.h b/ipc/chromium/src/base/string16.h index f794850c43..f383114808 100644 --- a/ipc/chromium/src/base/string16.h +++ b/ipc/chromium/src/base/string16.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/string_piece.cc b/ipc/chromium/src/base/string_piece.cc index 9aa7fcb5ab..169d6a49f0 100644 --- a/ipc/chromium/src/base/string_piece.cc +++ b/ipc/chromium/src/base/string_piece.cc @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/string_piece.h b/ipc/chromium/src/base/string_piece.h index d3b63e4ce7..36c39009cb 100644 --- a/ipc/chromium/src/base/string_piece.h +++ b/ipc/chromium/src/base/string_piece.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/string_util.cc b/ipc/chromium/src/base/string_util.cc index 21c1a8d5e8..339b12271b 100644 --- a/ipc/chromium/src/base/string_util.cc +++ b/ipc/chromium/src/base/string_util.cc @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/string_util.h b/ipc/chromium/src/base/string_util.h index ee9c37d93e..430b4a86bb 100644 --- a/ipc/chromium/src/base/string_util.h +++ b/ipc/chromium/src/base/string_util.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/string_util_posix.h b/ipc/chromium/src/base/string_util_posix.h index b503685a84..60c2d58b63 100644 --- a/ipc/chromium/src/base/string_util_posix.h +++ b/ipc/chromium/src/base/string_util_posix.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/string_util_win.h b/ipc/chromium/src/base/string_util_win.h index 0367ec4adf..218bd6466b 100644 --- a/ipc/chromium/src/base/string_util_win.h +++ b/ipc/chromium/src/base/string_util_win.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/sys_info.h b/ipc/chromium/src/base/sys_info.h index ab86f0781c..8c2e116f46 100644 --- a/ipc/chromium/src/base/sys_info.h +++ b/ipc/chromium/src/base/sys_info.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/sys_info_mac.cc b/ipc/chromium/src/base/sys_info_mac.cc index 8f76c06a26..a0f82d0210 100644 --- a/ipc/chromium/src/base/sys_info_mac.cc +++ b/ipc/chromium/src/base/sys_info_mac.cc @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/sys_info_posix.cc b/ipc/chromium/src/base/sys_info_posix.cc index 69a033b697..81ec78053d 100644 --- a/ipc/chromium/src/base/sys_info_posix.cc +++ b/ipc/chromium/src/base/sys_info_posix.cc @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/sys_info_win.cc b/ipc/chromium/src/base/sys_info_win.cc index 7974e73885..5fffd18e3f 100644 --- a/ipc/chromium/src/base/sys_info_win.cc +++ b/ipc/chromium/src/base/sys_info_win.cc @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/sys_string_conversions.h b/ipc/chromium/src/base/sys_string_conversions.h index ed20fcfd6a..e3a51964a7 100644 --- a/ipc/chromium/src/base/sys_string_conversions.h +++ b/ipc/chromium/src/base/sys_string_conversions.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/sys_string_conversions_win.cc b/ipc/chromium/src/base/sys_string_conversions_win.cc index 0e81a27ef5..198a14d212 100644 --- a/ipc/chromium/src/base/sys_string_conversions_win.cc +++ b/ipc/chromium/src/base/sys_string_conversions_win.cc @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/task.h b/ipc/chromium/src/base/task.h index 07787d64b1..10dc9c488b 100644 --- a/ipc/chromium/src/base/task.h +++ b/ipc/chromium/src/base/task.h @@ -1,4 +1,5 @@ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/thread.cc b/ipc/chromium/src/base/thread.cc index e56b3288af..feec3aedf7 100644 --- a/ipc/chromium/src/base/thread.cc +++ b/ipc/chromium/src/base/thread.cc @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/thread.h b/ipc/chromium/src/base/thread.h index 9f16bcccc9..9e2a9bd185 100644 --- a/ipc/chromium/src/base/thread.h +++ b/ipc/chromium/src/base/thread.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/thread_local.h b/ipc/chromium/src/base/thread_local.h index f8fbef7df7..d5c95a8bc4 100644 --- a/ipc/chromium/src/base/thread_local.h +++ b/ipc/chromium/src/base/thread_local.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/thread_local_posix.cc b/ipc/chromium/src/base/thread_local_posix.cc index 4c29263641..050a6e4b92 100644 --- a/ipc/chromium/src/base/thread_local_posix.cc +++ b/ipc/chromium/src/base/thread_local_posix.cc @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/thread_local_storage.h b/ipc/chromium/src/base/thread_local_storage.h index 6e693a05c6..58d4e63560 100644 --- a/ipc/chromium/src/base/thread_local_storage.h +++ b/ipc/chromium/src/base/thread_local_storage.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/thread_local_storage_posix.cc b/ipc/chromium/src/base/thread_local_storage_posix.cc index eac74fddf7..6f8367b661 100644 --- a/ipc/chromium/src/base/thread_local_storage_posix.cc +++ b/ipc/chromium/src/base/thread_local_storage_posix.cc @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/thread_local_storage_win.cc b/ipc/chromium/src/base/thread_local_storage_win.cc index 361167ea26..edd7a05401 100644 --- a/ipc/chromium/src/base/thread_local_storage_win.cc +++ b/ipc/chromium/src/base/thread_local_storage_win.cc @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/thread_local_win.cc b/ipc/chromium/src/base/thread_local_win.cc index 2da3cfd0ec..3f8c465d05 100644 --- a/ipc/chromium/src/base/thread_local_win.cc +++ b/ipc/chromium/src/base/thread_local_win.cc @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/time.cc b/ipc/chromium/src/base/time.cc index 00116aab78..dca9c83d93 100644 --- a/ipc/chromium/src/base/time.cc +++ b/ipc/chromium/src/base/time.cc @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/time.h b/ipc/chromium/src/base/time.h index 98d03654af..55bc7b4512 100644 --- a/ipc/chromium/src/base/time.h +++ b/ipc/chromium/src/base/time.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/time_mac.cc b/ipc/chromium/src/base/time_mac.cc index 94bb31cd14..a5a9a2a6eb 100644 --- a/ipc/chromium/src/base/time_mac.cc +++ b/ipc/chromium/src/base/time_mac.cc @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/time_posix.cc b/ipc/chromium/src/base/time_posix.cc index 3ea00b8057..8ffaff1fd7 100644 --- a/ipc/chromium/src/base/time_posix.cc +++ b/ipc/chromium/src/base/time_posix.cc @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/time_win.cc b/ipc/chromium/src/base/time_win.cc index d781e7c443..54252b1b43 100644 --- a/ipc/chromium/src/base/time_win.cc +++ b/ipc/chromium/src/base/time_win.cc @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/timer.cc b/ipc/chromium/src/base/timer.cc index b1f360ef69..d5b3a923c1 100644 --- a/ipc/chromium/src/base/timer.cc +++ b/ipc/chromium/src/base/timer.cc @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/timer.h b/ipc/chromium/src/base/timer.h index 09f3489a1c..5f5549fdb5 100644 --- a/ipc/chromium/src/base/timer.h +++ b/ipc/chromium/src/base/timer.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/tuple.h b/ipc/chromium/src/base/tuple.h index 4fee745fcd..d7c5a008fd 100644 --- a/ipc/chromium/src/base/tuple.h +++ b/ipc/chromium/src/base/tuple.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/waitable_event.h b/ipc/chromium/src/base/waitable_event.h index 27932fd19c..7ffbebffa8 100644 --- a/ipc/chromium/src/base/waitable_event.h +++ b/ipc/chromium/src/base/waitable_event.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/waitable_event_posix.cc b/ipc/chromium/src/base/waitable_event_posix.cc index 781fe61666..ed137c8454 100644 --- a/ipc/chromium/src/base/waitable_event_posix.cc +++ b/ipc/chromium/src/base/waitable_event_posix.cc @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/waitable_event_watcher.h b/ipc/chromium/src/base/waitable_event_watcher.h index 904ff0ab2b..73860e8eab 100644 --- a/ipc/chromium/src/base/waitable_event_watcher.h +++ b/ipc/chromium/src/base/waitable_event_watcher.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/waitable_event_watcher_posix.cc b/ipc/chromium/src/base/waitable_event_watcher_posix.cc index 856bef8856..883660fc47 100644 --- a/ipc/chromium/src/base/waitable_event_watcher_posix.cc +++ b/ipc/chromium/src/base/waitable_event_watcher_posix.cc @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -60,7 +62,7 @@ class Flag final { class AsyncWaiter final : public WaitableEvent::Waiter { public: AsyncWaiter(MessageLoop* message_loop, - already_AddRefed task, Flag* flag) + already_AddRefed task, Flag* flag) : message_loop_(message_loop), cb_task_(task), flag_(flag) { } diff --git a/ipc/chromium/src/base/waitable_event_watcher_win.cc b/ipc/chromium/src/base/waitable_event_watcher_win.cc index 7619aa46ed..26128e4ab0 100644 --- a/ipc/chromium/src/base/waitable_event_watcher_win.cc +++ b/ipc/chromium/src/base/waitable_event_watcher_win.cc @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/waitable_event_win.cc b/ipc/chromium/src/base/waitable_event_win.cc index 21ee0a9001..fdb54af958 100644 --- a/ipc/chromium/src/base/waitable_event_win.cc +++ b/ipc/chromium/src/base/waitable_event_win.cc @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/win_util.cc b/ipc/chromium/src/base/win_util.cc index 5c49aac13e..9b709ec98e 100644 --- a/ipc/chromium/src/base/win_util.cc +++ b/ipc/chromium/src/base/win_util.cc @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/base/win_util.h b/ipc/chromium/src/base/win_util.h index 860b99362a..b37411f60d 100644 --- a/ipc/chromium/src/base/win_util.h +++ b/ipc/chromium/src/base/win_util.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/build/build_config.h b/ipc/chromium/src/build/build_config.h index dcec00db49..390fa77a8b 100644 --- a/ipc/chromium/src/build/build_config.h +++ b/ipc/chromium/src/build/build_config.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/chrome/common/child_process.cc b/ipc/chromium/src/chrome/common/child_process.cc index 326c7df723..0381126cb6 100644 --- a/ipc/chromium/src/chrome/common/child_process.cc +++ b/ipc/chromium/src/chrome/common/child_process.cc @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/chrome/common/child_process.h b/ipc/chromium/src/chrome/common/child_process.h index 6784f919ae..39758a2d1a 100644 --- a/ipc/chromium/src/chrome/common/child_process.h +++ b/ipc/chromium/src/chrome/common/child_process.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/chrome/common/child_process_host.cc b/ipc/chromium/src/chrome/common/child_process_host.cc index 5465080bbd..11dbf896da 100644 --- a/ipc/chromium/src/chrome/common/child_process_host.cc +++ b/ipc/chromium/src/chrome/common/child_process_host.cc @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/chrome/common/child_process_host.h b/ipc/chromium/src/chrome/common/child_process_host.h index 58e434218e..dd1fb7ced1 100644 --- a/ipc/chromium/src/chrome/common/child_process_host.h +++ b/ipc/chromium/src/chrome/common/child_process_host.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/chrome/common/child_process_info.cc b/ipc/chromium/src/chrome/common/child_process_info.cc index 941c375166..6653299fef 100644 --- a/ipc/chromium/src/chrome/common/child_process_info.cc +++ b/ipc/chromium/src/chrome/common/child_process_info.cc @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/chrome/common/child_process_info.h b/ipc/chromium/src/chrome/common/child_process_info.h index 46aed71729..21bc129997 100644 --- a/ipc/chromium/src/chrome/common/child_process_info.h +++ b/ipc/chromium/src/chrome/common/child_process_info.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/chrome/common/child_thread.cc b/ipc/chromium/src/chrome/common/child_thread.cc index 4948c9ec77..9d160491f0 100644 --- a/ipc/chromium/src/chrome/common/child_thread.cc +++ b/ipc/chromium/src/chrome/common/child_thread.cc @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/chrome/common/child_thread.h b/ipc/chromium/src/chrome/common/child_thread.h index b57779d1e1..2d7d48aeda 100644 --- a/ipc/chromium/src/chrome/common/child_thread.h +++ b/ipc/chromium/src/chrome/common/child_thread.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/chrome/common/chrome_switches.cc b/ipc/chromium/src/chrome/common/chrome_switches.cc index 3e1551b9c6..082d606377 100644 --- a/ipc/chromium/src/chrome/common/chrome_switches.cc +++ b/ipc/chromium/src/chrome/common/chrome_switches.cc @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/chrome/common/chrome_switches.h b/ipc/chromium/src/chrome/common/chrome_switches.h index fe432f58d2..5dd4446a82 100644 --- a/ipc/chromium/src/chrome/common/chrome_switches.h +++ b/ipc/chromium/src/chrome/common/chrome_switches.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/chrome/common/file_descriptor_set_posix.cc b/ipc/chromium/src/chrome/common/file_descriptor_set_posix.cc index 8da57a8eee..9e70ff820a 100644 --- a/ipc/chromium/src/chrome/common/file_descriptor_set_posix.cc +++ b/ipc/chromium/src/chrome/common/file_descriptor_set_posix.cc @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/chrome/common/file_descriptor_set_posix.h b/ipc/chromium/src/chrome/common/file_descriptor_set_posix.h index aacd518fee..b6b153fb16 100644 --- a/ipc/chromium/src/chrome/common/file_descriptor_set_posix.h +++ b/ipc/chromium/src/chrome/common/file_descriptor_set_posix.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/chrome/common/ipc_channel.cc b/ipc/chromium/src/chrome/common/ipc_channel.cc index b13293c7c1..3d24d57b5c 100644 --- a/ipc/chromium/src/chrome/common/ipc_channel.cc +++ b/ipc/chromium/src/chrome/common/ipc_channel.cc @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/chrome/common/ipc_channel.h b/ipc/chromium/src/chrome/common/ipc_channel.h index 94bff82110..d3898a6ff4 100644 --- a/ipc/chromium/src/chrome/common/ipc_channel.h +++ b/ipc/chromium/src/chrome/common/ipc_channel.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -78,7 +80,7 @@ class Channel : public Message::Sender { // Connect to a pre-created channel as |mode|. Clients connect to // the pre-existing server pipe, and servers take over |server_pipe|. Channel(const std::wstring& channel_id, void* server_pipe, - Mode mode, Listener* listener); + Mode mode, Listener* listener); # endif ~Channel(); diff --git a/ipc/chromium/src/chrome/common/ipc_channel_posix.cc b/ipc/chromium/src/chrome/common/ipc_channel_posix.cc index ac7d3cb591..94e972b0f9 100644 --- a/ipc/chromium/src/chrome/common/ipc_channel_posix.cc +++ b/ipc/chromium/src/chrome/common/ipc_channel_posix.cc @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -210,14 +212,14 @@ bool Channel::ChannelImpl::CreatePipe(const std::wstring& channel_id, } // Set both ends to be non-blocking. if (fcntl(pipe_fds[0], F_SETFL, O_NONBLOCK) == -1 || - fcntl(pipe_fds[1], F_SETFL, O_NONBLOCK) == -1) { + fcntl(pipe_fds[1], F_SETFL, O_NONBLOCK) == -1) { HANDLE_EINTR(close(pipe_fds[0])); HANDLE_EINTR(close(pipe_fds[1])); return false; } if (!SetCloseOnExec(pipe_fds[0]) || - !SetCloseOnExec(pipe_fds[1])) { + !SetCloseOnExec(pipe_fds[1])) { HANDLE_EINTR(close(pipe_fds[0])); HANDLE_EINTR(close(pipe_fds[1])); return false; diff --git a/ipc/chromium/src/chrome/common/ipc_channel_posix.h b/ipc/chromium/src/chrome/common/ipc_channel_posix.h index 7e442b8103..a55863f5a4 100644 --- a/ipc/chromium/src/chrome/common/ipc_channel_posix.h +++ b/ipc/chromium/src/chrome/common/ipc_channel_posix.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/chrome/common/ipc_channel_win.cc b/ipc/chromium/src/chrome/common/ipc_channel_win.cc index bfd45071ac..7f2e3647af 100644 --- a/ipc/chromium/src/chrome/common/ipc_channel_win.cc +++ b/ipc/chromium/src/chrome/common/ipc_channel_win.cc @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/chrome/common/ipc_channel_win.h b/ipc/chromium/src/chrome/common/ipc_channel_win.h index 98e3f66da8..68c4670168 100644 --- a/ipc/chromium/src/chrome/common/ipc_channel_win.h +++ b/ipc/chromium/src/chrome/common/ipc_channel_win.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/chrome/common/ipc_message.cc b/ipc/chromium/src/chrome/common/ipc_message.cc index 19df7c1250..02c3dca4f7 100644 --- a/ipc/chromium/src/chrome/common/ipc_message.cc +++ b/ipc/chromium/src/chrome/common/ipc_message.cc @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -78,19 +80,6 @@ Message::Message(const char* data, int data_len, Ownership ownership) InitLoggingVariables(); } -Message::Message(const Message& other) : Pickle(other) { - MOZ_COUNT_CTOR(IPC::Message); - InitLoggingVariables(other.name_); -#if defined(OS_POSIX) - file_descriptor_set_ = other.file_descriptor_set_; -#endif -#ifdef MOZ_TASK_TRACER - header()->source_event_id = other.header()->source_event_id; - header()->parent_task_id = other.header()->parent_task_id; - header()->source_event_type = other.header()->source_event_type; -#endif -} - Message::Message(Message&& other) : Pickle(mozilla::Move(other)) { MOZ_COUNT_CTOR(IPC::Message); InitLoggingVariables(other.name_); @@ -108,20 +97,6 @@ void Message::InitLoggingVariables(const char* const aName) { name_ = aName; } -Message& Message::operator=(const Message& other) { - *static_cast(this) = other; - InitLoggingVariables(other.name_); -#if defined(OS_POSIX) - file_descriptor_set_ = other.file_descriptor_set_; -#endif -#ifdef MOZ_TASK_TRACER - header()->source_event_id = other.header()->source_event_id; - header()->parent_task_id = other.header()->parent_task_id; - header()->source_event_type = other.header()->source_event_type; -#endif - return *this; -} - Message& Message::operator=(Message&& other) { *static_cast(this) = mozilla::Move(other); InitLoggingVariables(other.name_); @@ -151,7 +126,7 @@ bool Message::WriteFileDescriptor(const base::FileDescriptor& descriptor) { } } -bool Message::ReadFileDescriptor(void** iter, +bool Message::ReadFileDescriptor(PickleIterator* iter, base::FileDescriptor* descriptor) const { int descriptor_index; if (!ReadInt(iter, &descriptor_index)) diff --git a/ipc/chromium/src/chrome/common/ipc_message.h b/ipc/chromium/src/chrome/common/ipc_message.h index df7d5033b0..5256cd0827 100644 --- a/ipc/chromium/src/chrome/common/ipc_message.h +++ b/ipc/chromium/src/chrome/common/ipc_message.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -77,9 +79,9 @@ class Message : public Pickle { // the buffer is writable and will be freed when the message is destroyed. Message(const char* data, int data_len, Ownership ownership = BORROWS); - Message(const Message& other); + Message(const Message& other) = delete; Message(Message&& other); - Message& operator=(const Message& other); + Message& operator=(const Message& other) = delete; Message& operator=(Message&& other); PriorityValue priority() const { @@ -258,7 +260,7 @@ class Message : public Pickle { bool WriteFileDescriptor(const base::FileDescriptor& descriptor); // Get a file descriptor from the message. Returns false on error. // iter: a Pickle iterator to the current location in the message. - bool ReadFileDescriptor(void** iter, base::FileDescriptor* descriptor) const; + bool ReadFileDescriptor(PickleIterator* iter, base::FileDescriptor* descriptor) const; #if defined(OS_MACOSX) void set_fd_cookie(uint32_t cookie) { diff --git a/ipc/chromium/src/chrome/common/ipc_message_utils.h b/ipc/chromium/src/chrome/common/ipc_message_utils.h index fa3f5bb1c2..09c9dbd6d6 100644 --- a/ipc/chromium/src/chrome/common/ipc_message_utils.h +++ b/ipc/chromium/src/chrome/common/ipc_message_utils.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -27,7 +29,7 @@ namespace IPC { class MessageIterator { public: - explicit MessageIterator(const Message& m) : msg_(m), iter_(NULL) { + explicit MessageIterator(const Message& m) : msg_(m), iter_(m) { } int NextInt() const { int val; @@ -60,7 +62,7 @@ class MessageIterator { } private: const Message& msg_; - mutable void* iter_; + mutable PickleIterator iter_; }; //----------------------------------------------------------------------------- @@ -115,7 +117,7 @@ static inline void WriteParam(Message* m, const P& p) { } template -static inline bool WARN_UNUSED_RESULT ReadParam(const Message* m, void** iter, +static inline bool WARN_UNUSED_RESULT ReadParam(const Message* m, PickleIterator* iter, P* p) { return ParamTraits

::Read(m, iter, p); } @@ -136,7 +138,7 @@ struct ParamTraitsFundamental { static void Write(Message* m, const param_type& p) { m->WriteBool(p); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, PickleIterator* iter, param_type* r) { return m->ReadBool(iter, r); } static void Log(const param_type& p, std::wstring* l) { @@ -150,7 +152,7 @@ struct ParamTraitsFundamental { static void Write(Message* m, const param_type& p) { m->WriteInt(p); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, PickleIterator* iter, param_type* r) { return m->ReadInt(iter, r); } static void Log(const param_type& p, std::wstring* l) { @@ -164,7 +166,7 @@ struct ParamTraitsFundamental { static void Write(Message* m, const param_type& p) { m->WriteLong(p); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, PickleIterator* iter, param_type* r) { return m->ReadLong(iter, r); } static void Log(const param_type& p, std::wstring* l) { @@ -178,7 +180,7 @@ struct ParamTraitsFundamental { static void Write(Message* m, const param_type& p) { m->WriteULong(p); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, PickleIterator* iter, param_type* r) { return m->ReadULong(iter, r); } static void Log(const param_type& p, std::wstring* l) { @@ -192,7 +194,7 @@ struct ParamTraitsFundamental { static void Write(Message* m, const param_type& p) { m->WriteData(reinterpret_cast(&p), sizeof(param_type)); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, PickleIterator* iter, param_type* r) { const char *data; int data_size = 0; bool result = m->ReadData(iter, &data, &data_size); @@ -215,7 +217,7 @@ struct ParamTraitsFundamental { static void Write(Message* m, const param_type& p) { m->WriteData(reinterpret_cast(&p), sizeof(param_type)); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, PickleIterator* iter, param_type* r) { const char *data; int data_size = 0; bool result = m->ReadData(iter, &data, &data_size); @@ -238,7 +240,7 @@ struct ParamTraitsFundamental { static void Write(Message* m, const param_type& p) { m->WriteData(reinterpret_cast(&p), sizeof(param_type)); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, PickleIterator* iter, param_type* r) { const char *data; int data_size = 0; bool result = m->ReadData(iter, &data, &data_size); @@ -267,7 +269,7 @@ struct ParamTraitsFixed { static void Write(Message* m, const param_type& p) { m->WriteInt16(p); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, PickleIterator* iter, param_type* r) { return m->ReadInt16(iter, r); } static void Log(const param_type& p, std::wstring* l) { @@ -281,7 +283,7 @@ struct ParamTraitsFixed { static void Write(Message* m, const param_type& p) { m->WriteUInt16(p); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, PickleIterator* iter, param_type* r) { return m->ReadUInt16(iter, r); } static void Log(const param_type& p, std::wstring* l) { @@ -295,7 +297,7 @@ struct ParamTraitsFixed { static void Write(Message* m, const param_type& p) { m->WriteUInt32(p); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, PickleIterator* iter, param_type* r) { return m->ReadUInt32(iter, r); } static void Log(const param_type& p, std::wstring* l) { @@ -309,7 +311,7 @@ struct ParamTraitsFixed { static void Write(Message* m, const param_type& p) { m->WriteInt64(p); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, PickleIterator* iter, param_type* r) { return m->ReadInt64(iter, r); } static void Log(const param_type& p, std::wstring* l) { @@ -323,7 +325,7 @@ struct ParamTraitsFixed { static void Write(Message* m, const param_type& p) { m->WriteInt64(static_cast(p)); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, PickleIterator* iter, param_type* r) { return m->ReadInt64(iter, reinterpret_cast(r)); } static void Log(const param_type& p, std::wstring* l) { @@ -342,7 +344,7 @@ struct ParamTraitsLibC { static void Write(Message* m, const param_type& p) { m->WriteSize(p); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, PickleIterator* iter, param_type* r) { return m->ReadSize(iter, r); } static void Log(const param_type& p, std::wstring* l) { @@ -361,7 +363,7 @@ struct ParamTraitsStd { static void Write(Message* m, const param_type& p) { m->WriteString(p); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, PickleIterator* iter, param_type* r) { return m->ReadString(iter, r); } static void Log(const param_type& p, std::wstring* l) { @@ -375,7 +377,7 @@ struct ParamTraitsStd { static void Write(Message* m, const param_type& p) { m->WriteWString(p); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, PickleIterator* iter, param_type* r) { return m->ReadWString(iter, r); } static void Log(const param_type& p, std::wstring* l) { @@ -394,7 +396,7 @@ struct ParamTraitsStd > { WriteParam(m, iter->second); } } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, PickleIterator* iter, param_type* r) { int size; if (!ReadParam(m, iter, &size) || size < 0) return false; @@ -425,7 +427,7 @@ struct ParamTraitsWindows { static void Write(Message* m, const param_type& p) { m->WriteIntPtr(reinterpret_cast(p)); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, PickleIterator* iter, param_type* r) { DCHECK_EQ(sizeof(param_type), sizeof(intptr_t)); return m->ReadIntPtr(iter, reinterpret_cast(r)); } @@ -440,7 +442,7 @@ struct ParamTraitsWindows { static void Write(Message* m, const param_type& p) { m->WriteIntPtr(reinterpret_cast(p)); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, PickleIterator* iter, param_type* r) { DCHECK_EQ(sizeof(param_type), sizeof(intptr_t)); return m->ReadIntPtr(iter, reinterpret_cast(r)); } @@ -484,7 +486,7 @@ struct ParamTraitsIPC { } } } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, PickleIterator* iter, param_type* r) { bool valid; if (!ReadParam(m, iter, &valid)) return false; @@ -515,7 +517,7 @@ struct ParamTraitsIPC { WriteParam(m, p.handle); WriteParam(m, p.sequence_num); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, PickleIterator* iter, param_type* r) { return (ReadParam(m, iter, &r->handle) && ReadParam(m, iter, &r->sequence_num)); } @@ -540,7 +542,7 @@ struct ParamTraitsMozilla { static void Write(Message* m, const param_type& p) { m->WriteUInt32(static_cast(p)); } - static bool Read(const Message* m, void** iter, param_type* r) { + static bool Read(const Message* m, PickleIterator* iter, param_type* r) { return m->ReadUInt32(iter, reinterpret_cast(r)); } static void Log(const param_type& p, std::wstring* l) { diff --git a/ipc/chromium/src/chrome/common/mach_ipc_mac.h b/ipc/chromium/src/chrome/common/mach_ipc_mac.h index 1d4de5f995..b443277656 100644 --- a/ipc/chromium/src/chrome/common/mach_ipc_mac.h +++ b/ipc/chromium/src/chrome/common/mach_ipc_mac.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/chrome/common/mach_message_source_mac.cc b/ipc/chromium/src/chrome/common/mach_message_source_mac.cc index bb13135cd8..7ab2b6074d 100644 --- a/ipc/chromium/src/chrome/common/mach_message_source_mac.cc +++ b/ipc/chromium/src/chrome/common/mach_message_source_mac.cc @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/chrome/common/mach_message_source_mac.h b/ipc/chromium/src/chrome/common/mach_message_source_mac.h index f57539db1a..57e8461ca8 100644 --- a/ipc/chromium/src/chrome/common/mach_message_source_mac.h +++ b/ipc/chromium/src/chrome/common/mach_message_source_mac.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/chrome/common/notification_details.h b/ipc/chromium/src/chrome/common/notification_details.h index f4dffcdb15..39223d207a 100644 --- a/ipc/chromium/src/chrome/common/notification_details.h +++ b/ipc/chromium/src/chrome/common/notification_details.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/chrome/common/notification_observer.h b/ipc/chromium/src/chrome/common/notification_observer.h index b8c9842c48..c0d267d5a4 100644 --- a/ipc/chromium/src/chrome/common/notification_observer.h +++ b/ipc/chromium/src/chrome/common/notification_observer.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/chrome/common/notification_registrar.h b/ipc/chromium/src/chrome/common/notification_registrar.h index c79d732c87..bb9199b14f 100644 --- a/ipc/chromium/src/chrome/common/notification_registrar.h +++ b/ipc/chromium/src/chrome/common/notification_registrar.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/chrome/common/notification_service.cc b/ipc/chromium/src/chrome/common/notification_service.cc index 5ebc6c9273..6c655ebc4e 100644 --- a/ipc/chromium/src/chrome/common/notification_service.cc +++ b/ipc/chromium/src/chrome/common/notification_service.cc @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/chrome/common/notification_service.h b/ipc/chromium/src/chrome/common/notification_service.h index e55a327324..76c11f8bdf 100644 --- a/ipc/chromium/src/chrome/common/notification_service.h +++ b/ipc/chromium/src/chrome/common/notification_service.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/chrome/common/notification_source.h b/ipc/chromium/src/chrome/common/notification_source.h index c3db15320b..5c62fee9fa 100644 --- a/ipc/chromium/src/chrome/common/notification_source.h +++ b/ipc/chromium/src/chrome/common/notification_source.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/chrome/common/notification_type.h b/ipc/chromium/src/chrome/common/notification_type.h index 634d094264..25a9202c38 100644 --- a/ipc/chromium/src/chrome/common/notification_type.h +++ b/ipc/chromium/src/chrome/common/notification_type.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/chrome/common/process_watcher.h b/ipc/chromium/src/chrome/common/process_watcher.h index b4ea20e270..5bc6c02b59 100644 --- a/ipc/chromium/src/chrome/common/process_watcher.h +++ b/ipc/chromium/src/chrome/common/process_watcher.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/chrome/common/process_watcher_posix_sigchld.cc b/ipc/chromium/src/chrome/common/process_watcher_posix_sigchld.cc index b04ad97867..6428e7bed6 100644 --- a/ipc/chromium/src/chrome/common/process_watcher_posix_sigchld.cc +++ b/ipc/chromium/src/chrome/common/process_watcher_posix_sigchld.cc @@ -1,6 +1,5 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * vim: set ts=8 et sw=2 tw=80: - */ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ diff --git a/ipc/chromium/src/chrome/common/process_watcher_win.cc b/ipc/chromium/src/chrome/common/process_watcher_win.cc index 80618193ff..3c3c7d33ed 100644 --- a/ipc/chromium/src/chrome/common/process_watcher_win.cc +++ b/ipc/chromium/src/chrome/common/process_watcher_win.cc @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -71,7 +73,7 @@ class TimerExpiredTask : public mozilla::Runnable, // static void ProcessWatcher::EnsureProcessTerminated(base::ProcessHandle process - , bool force + , bool force ) { DCHECK(process != GetCurrentProcess()); diff --git a/ipc/chromium/src/chrome/common/result_codes.h b/ipc/chromium/src/chrome/common/result_codes.h index 4c0de9dc15..84fe094ab1 100644 --- a/ipc/chromium/src/chrome/common/result_codes.h +++ b/ipc/chromium/src/chrome/common/result_codes.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/chrome/common/transport_dib.h b/ipc/chromium/src/chrome/common/transport_dib.h index e56685b192..b1e5c0fabb 100644 --- a/ipc/chromium/src/chrome/common/transport_dib.h +++ b/ipc/chromium/src/chrome/common/transport_dib.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/chrome/common/transport_dib_mac.cc b/ipc/chromium/src/chrome/common/transport_dib_mac.cc index b8c98a2185..feb78b2073 100644 --- a/ipc/chromium/src/chrome/common/transport_dib_mac.cc +++ b/ipc/chromium/src/chrome/common/transport_dib_mac.cc @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/chrome/common/transport_dib_win.cc b/ipc/chromium/src/chrome/common/transport_dib_win.cc index a2d49da4ca..3ab7898472 100644 --- a/ipc/chromium/src/chrome/common/transport_dib_win.cc +++ b/ipc/chromium/src/chrome/common/transport_dib_win.cc @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/chromium/src/chrome/common/x11_util.h b/ipc/chromium/src/chrome/common/x11_util.h index 1afa230ca1..688178356b 100644 --- a/ipc/chromium/src/chrome/common/x11_util.h +++ b/ipc/chromium/src/chrome/common/x11_util.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ // Copyright (c) 2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ipc/glue/BackgroundUtils.h b/ipc/glue/BackgroundUtils.h index 41908c74c4..dd2610f142 100644 --- a/ipc/glue/BackgroundUtils.h +++ b/ipc/glue/BackgroundUtils.h @@ -29,7 +29,7 @@ struct OriginAttributesParamTraits WriteParam(aMsg, suffix); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { nsAutoCString suffix; return ReadParam(aMsg, aIter, &suffix) && diff --git a/ipc/glue/IPCMessageUtils.h b/ipc/glue/IPCMessageUtils.h index 6fb40ff4e6..4195e653ac 100644 --- a/ipc/glue/IPCMessageUtils.h +++ b/ipc/glue/IPCMessageUtils.h @@ -114,7 +114,7 @@ struct EnumSerializer { WriteParam(aMsg, uintParamType(aValue)); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) { + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { uintParamType value; if (!ReadParam(aMsg, aIter, &value)) { #ifdef MOZ_CRASHREPORTER @@ -230,7 +230,7 @@ struct ParamTraits aMsg->WriteBytes(&aParam, sizeof(aParam)); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { const char* outp; if (!aMsg->ReadBytes(aIter, &outp, sizeof(*aResult))) @@ -251,7 +251,7 @@ struct ParamTraits aMsg->WriteBytes(&aParam, sizeof(aParam)); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { const char* outp; if (!aMsg->ReadBytes(aIter, &outp, sizeof(*aResult))) @@ -271,7 +271,7 @@ struct ParamTraits static void Write(Message* aMsg, const paramType& aParam) { NS_RUNTIMEABORT("FileDescriptor isn't meaningful on this platform"); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) { + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { NS_RUNTIMEABORT("FileDescriptor isn't meaningful on this platform"); return false; } @@ -297,7 +297,7 @@ struct ParamTraits aMsg->WriteBytes(aParam.BeginReading(), length); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { bool isVoid; if (!aMsg->ReadBool(aIter, &isVoid)) @@ -347,7 +347,7 @@ struct ParamTraits aMsg->WriteBytes(aParam.BeginReading(), length * sizeof(char16_t)); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { bool isVoid; if (!aMsg->ReadBool(aIter, &isVoid)) @@ -461,7 +461,7 @@ struct ParamTraits> // This method uses infallible allocation so that an OOM failure will // show up as an OOM crash rather than an IPC FatalError. - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { uint32_t length; if (!ReadParam(aMsg, aIter, &length)) { @@ -518,7 +518,7 @@ struct ParamTraits> } // Deserialize the array infallibly, but return a FallibleTArray. - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { nsTArray temp; if (!ReadParam(aMsg, aIter, &temp)) @@ -550,7 +550,7 @@ struct ParamTraits aMsg->WriteBytes(&aParam, sizeof(paramType)); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { const char* outFloat; if (!aMsg->ReadBytes(aIter, &outFloat, sizeof(float))) @@ -578,7 +578,7 @@ struct ParamTraits typedef mozilla::void_t paramType; static void Write(Message* aMsg, const paramType& aParam) { } static bool - Read(const Message* aMsg, void** aIter, paramType* aResult) + Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { *aResult = paramType(); return true; @@ -591,7 +591,7 @@ struct ParamTraits typedef mozilla::null_t paramType; static void Write(Message* aMsg, const paramType& aParam) { } static bool - Read(const Message* aMsg, void** aIter, paramType* aResult) + Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { *aResult = paramType(); return true; @@ -613,7 +613,7 @@ struct ParamTraits } } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { if(!ReadParam(aMsg, aIter, &(aResult->m0)) || !ReadParam(aMsg, aIter, &(aResult->m1)) || @@ -648,7 +648,7 @@ struct ParamTraits { WriteParam(aMsg, aParam.mValue); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { return ReadParam(aMsg, aIter, &aResult->mValue); }; @@ -662,7 +662,7 @@ struct ParamTraits { WriteParam(aMsg, aParam.mValue); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { return ReadParam(aMsg, aIter, &aResult->mValue); }; @@ -681,7 +681,7 @@ struct ParamTraits WriteParam(aMsg, aParam.mHasQPC); WriteParam(aMsg, aParam.mIsNull); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { return (ReadParam(aMsg, aIter, &aResult->mGTC) && ReadParam(aMsg, aIter, &aResult->mQPC) && @@ -702,7 +702,7 @@ struct ParamTraits aParam.WriteIPCParams(aMsg); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { return aResult->ReadIPCParams(aMsg, aIter); } @@ -723,7 +723,7 @@ struct ParamTraits aParam.WriteIPCParams(aMsg); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { return aResult->ReadIPCParams(aMsg, aIter); } @@ -743,7 +743,7 @@ struct ParamTraits } } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { if (!ReadParam(aMsg, aIter, &aResult->dataLength)) { return false; @@ -792,7 +792,7 @@ struct ParamTraits> } } - static bool Read(const Message* msg, void** iter, paramType* result) + static bool Read(const Message* msg, PickleIterator* iter, paramType* result) { bool isSome; if (!ReadParam(msg, iter, &isSome)) { diff --git a/ipc/glue/MessageChannel.cpp b/ipc/glue/MessageChannel.cpp index 79e1c8cd43..753f945ac1 100644 --- a/ipc/glue/MessageChannel.cpp +++ b/ipc/glue/MessageChannel.cpp @@ -21,6 +21,8 @@ #include "nsISupportsImpl.h" #include "nsContentUtils.h" +using mozilla::Move; + // Undo the damage done by mozzconf.h #undef compress @@ -170,7 +172,7 @@ public: { MOZ_RELEASE_ASSERT(&aOther != this); this->~InterruptFrame(); - new (this) InterruptFrame(mozilla::Move(aOther)); + new (this) InterruptFrame(Move(aOther)); return *this; } @@ -391,22 +393,22 @@ public: return mTransaction; } - void ReceivedReply(const IPC::Message& aMessage) { + void ReceivedReply(IPC::Message&& aMessage) { MOZ_RELEASE_ASSERT(aMessage.seqno() == mSeqno); MOZ_RELEASE_ASSERT(aMessage.transaction_id() == mTransaction); MOZ_RELEASE_ASSERT(!mReply); IPC_LOG("Reply received on worker thread: seqno=%d", mSeqno); - mReply = new IPC::Message(aMessage); + mReply = new IPC::Message(Move(aMessage)); MOZ_RELEASE_ASSERT(IsComplete()); } - void HandleReply(const IPC::Message& aMessage) { + void HandleReply(IPC::Message&& aMessage) { AutoEnterTransaction *cur = mChan->mTransactionStack; MOZ_RELEASE_ASSERT(cur == this); while (cur) { MOZ_RELEASE_ASSERT(cur->mActive); if (aMessage.seqno() == cur->mSeqno) { - cur->ReceivedReply(aMessage); + cur->ReceivedReply(Move(aMessage)); break; } cur = cur->mNext; @@ -892,7 +894,7 @@ MessageChannel::OnMessageReceivedFromLink(Message&& aMsg) MOZ_RELEASE_ASSERT(AwaitingSyncReply()); MOZ_RELEASE_ASSERT(!mTimedOutMessageSeqno); - mTransactionStack->HandleReply(aMsg); + mTransactionStack->HandleReply(Move(aMsg)); NotifyWorkerThread(); return; } @@ -1043,7 +1045,7 @@ MessageChannel::ProcessPendingRequests(AutoEnterTransaction& aTransaction) // loop around to check for more afterwards. for (auto it = toProcess.begin(); it != toProcess.end(); it++) { - ProcessPendingRequest(*it); + ProcessPendingRequest(Move(*it)); } } } @@ -1354,7 +1356,7 @@ MessageChannel::Call(Message* aMsg, Message* aReply) // If the message is not Interrupt, we can dispatch it as normal. if (!recvd.is_interrupt()) { - DispatchMessage(recvd); + DispatchMessage(Move(recvd)); if (!Connected()) { ReportConnectionError("MessageChannel::DispatchMessage"); return false; @@ -1412,7 +1414,7 @@ MessageChannel::Call(Message* aMsg, Message* aReply) MonitorAutoUnlock unlock(*mMonitor); CxxStackFrame frame(*this, IN_MESSAGE, &recvd); - DispatchInterruptMessage(recvd, stackDepth); + DispatchInterruptMessage(Move(recvd), stackDepth); } if (!Connected()) { ReportConnectionError("MessageChannel::DispatchInterruptMessage"); @@ -1468,14 +1470,14 @@ MessageChannel::InterruptEventOccurred() } bool -MessageChannel::ProcessPendingRequest(const Message &aUrgent) +MessageChannel::ProcessPendingRequest(Message &&aUrgent) { AssertWorkerThread(); mMonitor->AssertCurrentThreadOwns(); IPC_LOG("Process pending: seqno=%d, xid=%d", aUrgent.seqno(), aUrgent.transaction_id()); - DispatchMessage(aUrgent); + DispatchMessage(Move(aUrgent)); if (!Connected()) { ReportConnectionError("MessageChannel::ProcessPendingRequest"); return false; @@ -1556,13 +1558,13 @@ MessageChannel::OnMaybeDequeueOne() return false; } - DispatchMessage(recvd); + DispatchMessage(Move(recvd)); return true; } void -MessageChannel::DispatchMessage(const Message &aMsg) +MessageChannel::DispatchMessage(Message &&aMsg) { Maybe nojsapi; if (ScriptSettingsInitialized() && NS_IsMainThread()) @@ -1587,7 +1589,7 @@ MessageChannel::DispatchMessage(const Message &aMsg) if (aMsg.is_sync()) DispatchSyncMessage(aMsg, *getter_Transfers(reply)); else if (aMsg.is_interrupt()) - DispatchInterruptMessage(aMsg, 0); + DispatchInterruptMessage(Move(aMsg), 0); else DispatchAsyncMessage(aMsg); @@ -1657,7 +1659,7 @@ MessageChannel::DispatchAsyncMessage(const Message& aMsg) } void -MessageChannel::DispatchInterruptMessage(const Message& aMsg, size_t stackDepth) +MessageChannel::DispatchInterruptMessage(Message&& aMsg, size_t stackDepth) { AssertWorkerThread(); mMonitor->AssertNotCurrentThreadOwns(); @@ -1705,7 +1707,7 @@ MessageChannel::DispatchInterruptMessage(const Message& aMsg, size_t stackDepth) // We now know the other side's stack has one more frame // than we thought. ++mRemoteStackDepthGuess; // decremented in MaybeProcessDeferred() - mDeferred.push(aMsg); + mDeferred.push(Move(aMsg)); return; } @@ -2234,7 +2236,7 @@ MessageChannel::NotifyChannelClosed() void MessageChannel::DebugAbort(const char* file, int line, const char* cond, const char* why, - bool reply) const + bool reply) { printf_stderr("###!!! [MessageChannel][%s][%s:%d] " "Assertion (%s) failed. %s %s\n", @@ -2253,7 +2255,7 @@ MessageChannel::DebugAbort(const char* file, int line, const char* cond, printf_stderr(" Pending queue size: %" PRIuSIZE ", front to back:\n", mPending.size()); - MessageQueue pending = mPending; + MessageQueue pending = Move(mPending); while (!pending.empty()) { printf_stderr(" [ %s%s ]\n", pending.front().is_interrupt() ? "intr" : diff --git a/ipc/glue/MessageChannel.h b/ipc/glue/MessageChannel.h index 8660f6496c..2ef3232260 100644 --- a/ipc/glue/MessageChannel.h +++ b/ipc/glue/MessageChannel.h @@ -273,7 +273,7 @@ class MessageChannel : HasResultCodes bool HasPendingEvents(); void ProcessPendingRequests(AutoEnterTransaction& aTransaction); - bool ProcessPendingRequest(const Message &aUrgent); + bool ProcessPendingRequest(Message &&aUrgent); void MaybeUndeferIncall(); void EnqueuePendingMessages(); @@ -283,7 +283,7 @@ class MessageChannel : HasResultCodes bool DequeueOne(Message *recvd); // Dispatches an incoming message to its appropriate handler. - void DispatchMessage(const Message &aMsg); + void DispatchMessage(Message &&aMsg); // DispatchMessage will route to one of these functions depending on the // protocol type of the message. @@ -291,7 +291,7 @@ class MessageChannel : HasResultCodes void DispatchUrgentMessage(const Message &aMsg); void DispatchAsyncMessage(const Message &aMsg); void DispatchRPCMessage(const Message &aMsg); - void DispatchInterruptMessage(const Message &aMsg, size_t aStackDepth); + void DispatchInterruptMessage(Message &&aMsg, size_t aStackDepth); // Return true if the wait ended because a notification was received. // @@ -362,7 +362,7 @@ class MessageChannel : HasResultCodes void DebugAbort(const char* file, int line, const char* cond, const char* why, - bool reply=false) const; + bool reply=false); // This method is only safe to call on the worker thread, or in a // debugger with all threads paused. diff --git a/ipc/glue/ProtocolUtils.cpp b/ipc/glue/ProtocolUtils.cpp index 1afeebfef1..cc36595a0e 100644 --- a/ipc/glue/ProtocolUtils.cpp +++ b/ipc/glue/ProtocolUtils.cpp @@ -190,7 +190,7 @@ public: ProcessId* aOtherProcess, ProtocolId* aProtocol) { - void* iter = nullptr; + PickleIterator iter(aMsg); if (!IPC::ReadParam(&aMsg, &iter, aDescriptor) || !IPC::ReadParam(&aMsg, &iter, aOtherProcess) || !IPC::ReadParam(&aMsg, &iter, reinterpret_cast(aProtocol))) { @@ -482,5 +482,47 @@ LogicError(const char* aMsg) NS_RUNTIMEABORT(aMsg); } +void +ActorIdReadError(const char* aActorDescription) +{ + nsPrintfCString message("Error deserializing id for %s", aActorDescription); + NS_RUNTIMEABORT(message.get()); +} + +void +BadActorIdError(const char* aActorDescription) +{ + nsPrintfCString message("bad id for %s", aActorDescription); + ProtocolErrorBreakpoint(message.get()); +} + +void +ActorLookupError(const char* aActorDescription) +{ + nsPrintfCString message("could not lookup id for %s", aActorDescription); + ProtocolErrorBreakpoint(message.get()); +} + +void +MismatchedActorTypeError(const char* aActorDescription) +{ + nsPrintfCString message("actor that should be of type %s has different type", + aActorDescription); + ProtocolErrorBreakpoint(message.get()); +} + +void +UnionTypeReadError(const char* aUnionName) +{ + nsPrintfCString message("error deserializing type of union %s", aUnionName); + NS_RUNTIMEABORT(message.get()); +} + +void ArrayLengthReadError(const char* aElementName) +{ + nsPrintfCString message("error deserializing length of %s[]", aElementName); + NS_RUNTIMEABORT(message.get()); +} + } // namespace ipc } // namespace mozilla diff --git a/ipc/glue/ProtocolUtils.h b/ipc/glue/ProtocolUtils.h index 5c4645b80f..77bb899f91 100644 --- a/ipc/glue/ProtocolUtils.h +++ b/ipc/glue/ProtocolUtils.h @@ -21,6 +21,7 @@ #include "mozilla/ipc/Transport.h" #include "mozilla/ipc/MessageLink.h" #include "mozilla/LinkedList.h" +#include "mozilla/Maybe.h" #include "mozilla/Mutex.h" #include "MainThreadUtils.h" @@ -184,6 +185,9 @@ public: // The implementation of function is generated by code generator. virtual void CloneManagees(ListenerT* aSource, ProtocolCloneContext* aCtx) = 0; + + Maybe ReadActor(const IPC::Message* aMessage, PickleIterator* aIter, bool aNullable, + const char* aActorDescription, int32_t aProtocolTypeId); }; typedef IPCMessageStart ProtocolId; @@ -191,7 +195,7 @@ typedef IPCMessageStart ProtocolId; /** * All RPC protocols should implement this interface. */ -class IProtocol : protected MessageListener +class IProtocol : public MessageListener { public: /** @@ -323,6 +327,24 @@ FatalError(const char* aProtocolName, const char* aMsg, bool aIsParent); MOZ_NEVER_INLINE void LogicError(const char* aMsg); +MOZ_NEVER_INLINE void +ActorIdReadError(const char* aActorDescription); + +MOZ_NEVER_INLINE void +BadActorIdError(const char* aActorDescription); + +MOZ_NEVER_INLINE void +ActorLookupError(const char* aActorDescription); + +MOZ_NEVER_INLINE void +MismatchedActorTypeError(const char* aActorDescription); + +MOZ_NEVER_INLINE void +UnionTypeReadError(const char* aUnionName); + +MOZ_NEVER_INLINE void +ArrayLengthReadError(const char* aElementName); + struct PrivateIPDLInterface {}; nsresult @@ -340,6 +362,40 @@ UnpackChannelOpened(const PrivateIPDLInterface&, const IPC::Message&, TransportDescriptor*, base::ProcessId*, ProtocolId*); +template +Maybe +IProtocolManager::ReadActor(const IPC::Message* aMessage, PickleIterator* aIter, bool aNullable, + const char* aActorDescription, int32_t aProtocolTypeId) +{ + int32_t id; + if (!IPC::ReadParam(aMessage, aIter, &id)) { + ActorIdReadError(aActorDescription); + return Nothing(); + } + + if (id == 1 || (id == 0 && !aNullable)) { + BadActorIdError(aActorDescription); + return Nothing(); + } + + if (id == 0) { + return Some(static_cast(nullptr)); + } + + ListenerT* listener = this->Lookup(id); + if (!listener) { + ActorLookupError(aActorDescription); + return Nothing(); + } + + if (static_cast(listener)->GetProtocolTypeId() != aProtocolTypeId) { + MismatchedActorTypeError(aActorDescription); + return Nothing(); + } + + return Some(listener); +} + #if defined(XP_WIN) // This is a restricted version of Windows' DuplicateHandle() function // that works inside the sandbox and can send handles but not retrieve @@ -558,7 +614,7 @@ struct ParamTraits IPC::WriteParam(aMsg, aParam.mId); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { int id; if (IPC::ReadParam(aMsg, aIter, &id)) { @@ -597,7 +653,7 @@ struct ParamTraits> IPC::WriteParam(aMsg, static_cast(aParam.mProtocolId)); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { MOZ_RELEASE_ASSERT(!aResult->mValid); aResult->mValid = true; diff --git a/ipc/glue/SharedMemory.h b/ipc/glue/SharedMemory.h index 74f9fc881f..f39f856cec 100644 --- a/ipc/glue/SharedMemory.h +++ b/ipc/glue/SharedMemory.h @@ -62,7 +62,7 @@ public: virtual SharedMemoryType Type() const = 0; virtual bool ShareHandle(base::ProcessId aProcessId, IPC::Message* aMessage) = 0; - virtual bool ReadHandle(const IPC::Message* aMessage, void** aIter) = 0; + virtual bool ReadHandle(const IPC::Message* aMessage, PickleIterator* aIter) = 0; void Protect(char* aAddr, size_t aSize, int aRights) @@ -137,7 +137,7 @@ public: return true; } - virtual bool ReadHandle(const IPC::Message* aMessage, void** aIter) override + virtual bool ReadHandle(const IPC::Message* aMessage, PickleIterator* aIter) override { Handle handle; return IPC::ReadParam(aMessage, aIter, &handle) && diff --git a/ipc/glue/Shmem.cpp b/ipc/glue/Shmem.cpp index 31d8af9b3d..496de657bc 100644 --- a/ipc/glue/Shmem.cpp +++ b/ipc/glue/Shmem.cpp @@ -34,7 +34,7 @@ public: } static bool - ReadInfo(const Message* msg, void** iter, + ReadInfo(const Message* msg, PickleIterator* iter, id_t* aIPDLId, size_t* aSize, SharedMemory::SharedMemoryType* aType) @@ -100,7 +100,7 @@ ReadSegment(const IPC::Message& aDescriptor, Shmem::id_t* aId, size_t* aNBytes, return nullptr; } SharedMemory::SharedMemoryType type; - void* iter = nullptr; + PickleIterator iter(aDescriptor); if (!ShmemCreated::ReadInfo(&aDescriptor, &iter, aId, aNBytes, &type)) { return nullptr; } diff --git a/ipc/glue/Shmem.h b/ipc/glue/Shmem.h index afae28aa04..9c1f125f3f 100644 --- a/ipc/glue/Shmem.h +++ b/ipc/glue/Shmem.h @@ -284,7 +284,7 @@ struct ParamTraits WriteParam(aMsg, aParam.mId); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { paramType::id_t id; if (!ReadParam(aMsg, aIter, &id)) diff --git a/ipc/glue/Transport_posix.h b/ipc/glue/Transport_posix.h index f6511d0894..ad43e1bfd2 100644 --- a/ipc/glue/Transport_posix.h +++ b/ipc/glue/Transport_posix.h @@ -33,7 +33,7 @@ struct ParamTraits { WriteParam(aMsg, aParam.mFd); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { return ReadParam(aMsg, aIter, &aResult->mFd); } diff --git a/ipc/glue/Transport_win.cpp b/ipc/glue/Transport_win.cpp index 2873aac975..bb4dd93f06 100644 --- a/ipc/glue/Transport_win.cpp +++ b/ipc/glue/Transport_win.cpp @@ -65,10 +65,8 @@ TransferHandleToProcess(HANDLE source, base::ProcessId pid) DWORD options = DUPLICATE_SAME_ACCESS; bool ok = DuplicateHandle(source, pid, &handleDup, access, options); if (!ok) { - AnnotateSystemError(); - AnnotateProcessInformation(pid); + return nullptr; } - MOZ_RELEASE_ASSERT(ok); // Now close our own copy of the handle (we're supposed to be transferring, // not copying). diff --git a/ipc/glue/Transport_win.h b/ipc/glue/Transport_win.h index 774e47c74e..db9b0b9744 100644 --- a/ipc/glue/Transport_win.h +++ b/ipc/glue/Transport_win.h @@ -12,7 +12,7 @@ #include "base/process.h" #include "ipc/IPCMessageUtils.h" - +#include "nsWindowsHelpers.h" namespace mozilla { namespace ipc { @@ -41,23 +41,68 @@ struct ParamTraits { HANDLE pipe = mozilla::ipc::TransferHandleToProcess(aParam.mServerPipeHandle, aParam.mDestinationProcessId); + DWORD duplicateFromProcessId = 0; + if (!pipe) { + if (XRE_IsParentProcess()) { + // If we are the parent and failed to transfer then there is no hope, + // just close the handle. + ::CloseHandle(aParam.mServerPipeHandle); + } else { + // We are probably sending to parent so it should be able to duplicate. + pipe = aParam.mServerPipeHandle; + duplicateFromProcessId = ::GetCurrentProcessId(); + } + } WriteParam(aMsg, aParam.mPipeName); WriteParam(aMsg, pipe); + WriteParam(aMsg, duplicateFromProcessId); WriteParam(aMsg, aParam.mDestinationProcessId); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { + DWORD duplicateFromProcessId; bool r = (ReadParam(aMsg, aIter, &aResult->mPipeName) && ReadParam(aMsg, aIter, &aResult->mServerPipeHandle) && + ReadParam(aMsg, aIter, &duplicateFromProcessId) && ReadParam(aMsg, aIter, &aResult->mDestinationProcessId)); if (!r) { return r; } - if (aResult->mServerPipeHandle != INVALID_HANDLE_VALUE) { - MOZ_RELEASE_ASSERT(aResult->mDestinationProcessId == base::GetCurrentProcId()); + + MOZ_RELEASE_ASSERT(aResult->mServerPipeHandle, + "Main process failed to duplicate pipe handle to child."); + + // If this is a not the "server" side descriptor, we have finished. + if (aResult->mServerPipeHandle == INVALID_HANDLE_VALUE) { + return true; } - return r; + + MOZ_RELEASE_ASSERT(aResult->mDestinationProcessId == base::GetCurrentProcId()); + + // If the pipe has already been duplicated to us, we have finished. + if (!duplicateFromProcessId) { + return true; + } + + // Otherwise duplicate the handle to us. + nsAutoHandle sourceProcess(::OpenProcess(PROCESS_DUP_HANDLE, FALSE, + duplicateFromProcessId)); + if (!sourceProcess) { + return false; + } + + HANDLE ourHandle; + BOOL duped = ::DuplicateHandle(sourceProcess, aResult->mServerPipeHandle, + ::GetCurrentProcess(), &ourHandle, 0, FALSE, + DUPLICATE_CLOSE_SOURCE | DUPLICATE_SAME_ACCESS); + if (!duped) { + aResult->mServerPipeHandle = INVALID_HANDLE_VALUE; + return false; + } + + aResult->mServerPipeHandle = ourHandle; + return true; } }; diff --git a/ipc/ipdl/ipdl/lower.py b/ipc/ipdl/ipdl/lower.py index 043eb2b5f9..f081245770 100644 --- a/ipc/ipdl/ipdl/lower.py +++ b/ipc/ipdl/ipdl/lower.py @@ -133,6 +133,9 @@ def _actorState(actor): def _backstagePass(): return ExprCall(ExprVar('mozilla::ipc::PrivateIPDLInterface')) +def _iterType(ptr): + return Type('PickleIterator', ptr=ptr) + def _nullState(proto=None): pfx = '' if proto is not None: pfx = proto.name() +'::' @@ -403,6 +406,16 @@ def _logicError(msg): return StmtExpr( ExprCall(ExprVar('mozilla::ipc::LogicError'), args=[ ExprLiteral.String(msg) ])) +def _arrayLengthReadError(elementname): + return StmtExpr( + ExprCall(ExprVar('mozilla::ipc::ArrayLengthReadError'), + args=[ ExprLiteral.String(elementname) ])) + +def _unionTypeReadError(unionname): + return StmtExpr( + ExprCall(ExprVar('mozilla::ipc::UnionTypeReadError'), + args=[ ExprLiteral.String(unionname) ])) + def _killProcess(pid): return ExprCall( ExprVar('base::KillProcess'), @@ -462,6 +475,12 @@ def errfnRecv(msg, errcode=_Result.ValuError): def errfnRead(msg): return [ _fatalError(msg), StmtReturn.FALSE ] +def errfnArrayLength(elementname): + return [ _arrayLengthReadError(elementname), StmtReturn.FALSE ] + +def errfnUnionType(unionname): + return [ _unionTypeReadError(unionname), StmtReturn.FALSE ] + def _destroyMethod(): return ExprVar('ActorDestroy') @@ -956,14 +975,17 @@ class MessageDecl(ipdl.ast.MessageDecl): return cxxparams - def makeCxxArgs(self, params=1, retsems='out', retcallsems='out', + def makeCxxArgs(self, paramsems='in', retsems='out', retcallsems='out', implicit=1): - assert not implicit or params # implicit => params assert not retcallsems or retsems # retcallsems => returnsems cxxargs = [ ] - if params: + if paramsems is 'move': cxxargs.extend([ ExprMove(p.var()) for p in self.params ]) + elif paramsems is 'in': + cxxargs.extend([ p.var() for p in self.params ]) + else: + assert False for ret in self.returns: if retsems is 'in': @@ -3823,9 +3845,7 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor): getchannel.addstmt(StmtReturn(p.channelVar())) cloneprotocol.addstmts([ - _fatalError('Clone() for ' + - p.name + - ' has not yet been implemented'), + _fatalError('Clone() has not yet been implemented'), StmtReturn(ExprLiteral.NULL) ]) @@ -4105,7 +4125,8 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor): itervar = ExprVar('iter') case.addstmts([ StmtDecl(Decl(_shmemIdType(), idvar.name)), - StmtDecl(Decl(Type.VOIDPTR, itervar.name), init=ExprLiteral.NULL) + StmtDecl(Decl(_iterType(ptr=0), itervar.name), init=ExprCall(ExprVar('PickleIterator'), + args=[ self.msgvar ])) ]) failif = StmtIf(ExprNot( @@ -4338,69 +4359,29 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor): read = MethodDefn(self.readMethodDecl(outtype, var)) read.decl.params.append(Decl(Type.BOOL, nullablevar.name)) - # if (!Read(id, msg)) - # return false - # if (FREED_ID == id - # || NULL_ID == id && !nullable) - # return false + actorvar = ExprVar('actor') read.addstmts([ - StmtDecl(Decl(_actorIdType(), idvar.name)), - self.checkedRead(None, ExprAddrOf(idvar), - self.msgvar, self.itervar, errfnRead, - 'id\' for \'' + cxxtype.name), + StmtDecl(Decl(Type('Maybe', T=Type('mozilla::ipc::IProtocol', ptr=1)), actorvar.name), + init=ExprCall(ExprVar('ReadActor'), + args=[ self.msgvar, self.itervar, nullablevar, + ExprLiteral.String(actortype.name()), + _protocolId(actortype) ])), ]) - ifbadid = StmtIf(ExprBinary( - ExprBinary(_FREED_ACTOR_ID, '==', idvar), - '||', - ExprBinary(ExprBinary(_NULL_ACTOR_ID, '==', idvar), - '&&', - ExprNot(nullablevar)))) - ifbadid.addifstmts([ - _protocolErrorBreakpoint('bad ID for '+ self.protocol.name), - StmtReturn.FALSE - ]) - read.addstmts([ ifbadid, Whitespace.NL ]) - - # if (NULL_ID == id) - # *var = null - # return true - outactor = ExprDeref(var) - ifnull = StmtIf(ExprBinary(_NULL_ACTOR_ID, '==', idvar)) - ifnull.addifstmts([ StmtExpr(ExprAssn(outactor, ExprLiteral.NULL)), - StmtReturn.TRUE ]) - read.addstmts([ ifnull, Whitespace.NL ]) - - # Listener* listener = Lookup(id) - # if (!listener) + # if (actor.isNothing()) # return false - listenervar = ExprVar('listener') - read.addstmt(StmtDecl(Decl(Type('ChannelListener', ptr=1), - listenervar.name), - init=_lookupListener(idvar))) - ifnotfound = StmtIf(ExprNot(listenervar)) - ifnotfound.addifstmts([ - _protocolErrorBreakpoint('could not look up '+ actortype.name()), - StmtReturn.FALSE + # + # Reading the actor failed in some way, and the appropriate error was raised. + ifnothing = StmtIf(ExprCall(ExprSelect(actorvar, '.', 'isNothing'))) + ifnothing.addifstmts([ + StmtReturn.FALSE, ]) - read.addstmts([ ifnotfound, Whitespace.NL ]) - # if listener->GetProtocolTypeId() != [expected protocol type] - # return false - ifbadtype = StmtIf(ExprBinary( - _protocolId(actortype), '!=', - ExprCall(ExprSelect(listenervar, '->', 'GetProtocolTypeId')))) - ifbadtype.addifstmts([ - _protocolErrorBreakpoint('actor that should be of type '+ actortype.name() +' has different type'), - StmtReturn.FALSE - ]) - read.addstmts([ ifbadtype, Whitespace.NL ]) + read.addstmts([ ifnothing, Whitespace.NL ]) - # *outactor = static_cast(listener) - # return true read.addstmts([ - StmtExpr(ExprAssn(outactor, - ExprCast(listenervar, cxxtype, static=1))), + StmtExpr(ExprAssn(ExprDeref(var), + ExprCast(ExprCall(ExprSelect(actorvar, '.', 'value')), cxxtype, static=1))), StmtReturn.TRUE ]) @@ -4441,14 +4422,13 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor): forread.addstmt( self.checkedRead(eltipdltype, ExprAddrOf(ExprIndex(favar, ivar)), msgvar, itervar, errfnRead, - eltipdltype.name() + '[i]')) + '\'' + eltipdltype.name() + '[i]\'')) read.addstmts([ StmtDecl(Decl(_cxxArrayType(_cxxBareType(arraytype.basetype, self.side)), favar.name)), StmtDecl(Decl(Type.UINT32, lenvar.name)), self.checkedRead(None, ExprAddrOf(lenvar), - msgvar, itervar, errfnRead, - 'length\' (' + Type.UINT32.name + ') of \'' + - arraytype.name()), + msgvar, itervar, errfnArrayLength, + [ arraytype.name() ]), Whitespace.NL, StmtExpr(_callCxxArraySetLength(favar, lenvar)), forread, @@ -4578,8 +4558,8 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor): return ExprCall(f.getMethod(thisexpr=var, sel=sel)) for f in sd.fields: - desc = f.getMethod().name + '\' (' + f.ipdltype.name() + \ - ') member of \'' + intype.name + desc = '\'' + f.getMethod().name + '\' (' + f.ipdltype.name() + \ + ') member of \'' + intype.name + '\'' writefield = StmtExpr(self.write(f.ipdltype, get('.', f), msgvar)) readfield = self.checkedRead(f.ipdltype, ExprAddrOf(get('->', f)), @@ -4671,8 +4651,8 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor): uniontdef, StmtDecl(Decl(Type.INT, typevar.name)), self.checkedRead( - None, ExprAddrOf(typevar), msgvar, itervar, errfnRead, - typevar.name + '\' (' + Type.INT.name + ') of union \'' + uniontype.name()), + None, ExprAddrOf(typevar), msgvar, itervar, errfnUnionType, + [ uniontype.name() ]), Whitespace.NL, readswitch, ]) @@ -4693,7 +4673,7 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor): params=[ Decl(outtype, var.name), Decl(Type('Message', ptr=1, const=1), self.msgvar.name), - Decl(Type('void', ptrptr=1), self.itervar.name)], + Decl(_iterType(ptr=1), self.itervar.name)], warn_unused=not template, T=template, ret=Type.BOOL) @@ -5170,18 +5150,19 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor): decls = [ StmtDecl(Decl(handletype, handlevar.name)) ] reads = [ self.checkedRead(None, ExprAddrOf(handlevar), msgexpr, ExprAddrOf(self.itervar), - errfn, handletype.name) ] + errfn, "'%s'" % handletype.name) ] start = 1 stmts.extend(( - [ StmtDecl(Decl(Type.VOIDPTR, self.itervar.name), - init=ExprLiteral.NULL) ] + [ StmtDecl(Decl(_iterType(ptr=0), self.itervar.name), + init=ExprCall(ExprVar('PickleIterator'), + args=[ msgvar ])) ] + decls + [ StmtDecl(Decl(p.bareType(side), p.var().name)) for p in md.params ] + [ Whitespace.NL ] + reads + [ self.checkedRead(p.ipdltype, ExprAddrOf(p.var()), msgexpr, ExprAddrOf(itervar), - errfn, p.bareType(side).name) + errfn, "'%s'" % p.bareType(side).name) for p in md.params[start:] ] + [ self.endRead(msgvar, itervar) ])) @@ -5198,12 +5179,13 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor): itervar = self.itervar stmts.extend( [ Whitespace.NL, - StmtDecl(Decl(Type.VOIDPTR, itervar.name), - init=ExprLiteral.NULL) ] + StmtDecl(Decl(_iterType(ptr=0), itervar.name), + init=ExprCall(ExprVar('PickleIterator'), + args=[ self.replyvar ])) ] + [ self.checkedRead(r.ipdltype, r.var(), ExprAddrOf(self.replyvar), ExprAddrOf(self.itervar), - errfn, r.bareType(side).name) + errfn, "'%s'" % r.bareType(side).name) for r in md.returns ] + [ self.endRead(self.replyvar, itervar) ]) @@ -5247,7 +5229,7 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor): def callAllocActor(self, md, retsems, side): return ExprCall( _allocMethod(md.decl.type.constructedType(), side), - args=md.makeCxxArgs(params=1, retsems=retsems, retcallsems='out', + args=md.makeCxxArgs(retsems=retsems, retcallsems='out', implicit=0)) def callActorDestroy(self, actorexpr, why=_DestroyReason.Deletion): @@ -5274,11 +5256,11 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor): def invokeRecvHandler(self, md, implicit=1): failif = StmtIf(ExprNot( ExprCall(md.recvMethod(), - args=md.makeCxxArgs(params=1, - retsems='in', retcallsems='out', + args=md.makeCxxArgs(paramsems='move', retsems='in', + retcallsems='out', implicit=implicit)))) failif.addifstmts([ - _protocolErrorBreakpoint('Handler for '+ md.name +' returned error code'), + _protocolErrorBreakpoint('Handler returned error code!'), StmtReturn(_Result.ProcessingError) ]) return [ failif ] @@ -5356,7 +5338,11 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor): def checkedRead(self, ipdltype, expr, msgexpr, iterexpr, errfn, paramtype): ifbad = StmtIf(ExprNot(self.read(ipdltype, expr, msgexpr, iterexpr))) - ifbad.addifstmts(errfn('Error deserializing \'' + paramtype + '\'')) + if isinstance(paramtype, list): + errorcall = errfn(*paramtype) + else: + errorcall = errfn('Error deserializing ' + paramtype) + ifbad.addifstmts(errorcall) return ifbad def endRead(self, msgexpr, iterexpr): diff --git a/ipc/ipdl/test/cxx/IPDLUnitTestUtils.h b/ipc/ipdl/test/cxx/IPDLUnitTestUtils.h index 7a1809ccd6..ad9da374df 100644 --- a/ipc/ipdl/test/cxx/IPDLUnitTestUtils.h +++ b/ipc/ipdl/test/cxx/IPDLUnitTestUtils.h @@ -19,7 +19,7 @@ struct ParamTraits // Defined in TestActorPunning.cpp. static void Write(Message* aMsg, const paramType& aParam); - static bool Read(const Message* aMsg, void** aIter, paramType* aResult); + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult); }; } // namespace IPC diff --git a/ipc/ipdl/test/cxx/TestActorPunning.cpp b/ipc/ipdl/test/cxx/TestActorPunning.cpp index 796a3b5d09..ab2f2a4091 100644 --- a/ipc/ipdl/test/cxx/TestActorPunning.cpp +++ b/ipc/ipdl/test/cxx/TestActorPunning.cpp @@ -120,7 +120,7 @@ ParamTraits::Write(Message* aMsg, const paramType& aParam) } /*static*/ bool -ParamTraits::Read(const Message* aMsg, void** aIter, paramType* aResult) +ParamTraits::Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { const char* ptr; int len; diff --git a/js/xpconnect/src/xpcpublic.h b/js/xpconnect/src/xpcpublic.h index 0530b33da6..a6955d1614 100644 --- a/js/xpconnect/src/xpcpublic.h +++ b/js/xpconnect/src/xpcpublic.h @@ -583,25 +583,6 @@ void RemoveGCCallback(xpcGCCallback cb); namespace mozilla { namespace dom { -typedef JSObject* -(*DefineInterface)(JSContext* cx, JS::Handle global, - JS::Handle id, bool defineOnGlobal); - -typedef JSObject* -(*ConstructNavigatorProperty)(JSContext* cx, JS::Handle naviObj); - -// Check whether a constructor should be enabled for the given object. -// Note that the object should NOT be an Xray, since Xrays will end up -// defining constructors on the underlying object. -// This is a typedef for the function type itself, not the function -// pointer, so it's more obvious that pointers to a ConstructorEnabled -// can be null. -typedef bool -(ConstructorEnabled)(JSContext* cx, JS::Handle obj); - -void -Register(nsScriptNameSpaceManager* aNameSpaceManager); - /** * A test for whether WebIDL methods that should only be visible to * chrome or XBL scopes should be exposed. diff --git a/layout/base/FrameLayerBuilder.cpp b/layout/base/FrameLayerBuilder.cpp index 438bd3eaae..a08dfe8a11 100644 --- a/layout/base/FrameLayerBuilder.cpp +++ b/layout/base/FrameLayerBuilder.cpp @@ -4577,7 +4577,7 @@ ContainerState::SetupScrollingMetadata(NewLayerEntry* aEntry) // The base FrameMetrics was not computed by the nsIScrollableframe, so it // should not have a mask layer. - MOZ_ASSERT(!aEntry->mBaseScrollMetadata->GetMaskLayerIndex()); + MOZ_ASSERT(!aEntry->mBaseScrollMetadata->HasMaskLayer()); } // Any extra mask layers we need to attach to FrameMetrics. @@ -4614,7 +4614,8 @@ ContainerState::SetupScrollingMetadata(NewLayerEntry* aEntry) RefPtr maskLayer = CreateMaskLayer(aEntry->mLayer, *clip, nextIndex, clip->GetRoundedRectCount()); if (maskLayer) { - metadata->SetMaskLayerIndex(nextIndex); + MOZ_ASSERT(metadata->HasScrollClip()); + metadata->ScrollClip().SetMaskLayerIndex(nextIndex); maskLayers.AppendElement(maskLayer); } } @@ -4627,7 +4628,7 @@ ContainerState::SetupScrollingMetadata(NewLayerEntry* aEntry) aEntry->mLayer->SetAncestorMaskLayers(maskLayers); } -static inline const Maybe& +static inline Maybe GetStationaryClipInContainer(Layer* aLayer) { if (size_t metricsCount = aLayer->GetScrollMetadataCount()) { @@ -4661,7 +4662,7 @@ ContainerState::PostprocessRetainedLayers(nsIntRegion* aOpaqueRegionForContainer if (hideAll) { e->mVisibleRegion.SetEmpty(); } else if (!e->mLayer->IsScrollbarContainer()) { - const Maybe& clipRect = GetStationaryClipInContainer(e->mLayer); + Maybe clipRect = GetStationaryClipInContainer(e->mLayer); if (clipRect && opaqueRegionForContainer >= 0 && opaqueRegions[opaqueRegionForContainer].mOpaqueRegion.Contains(clipRect->ToUnknownRect())) { e->mVisibleRegion.SetEmpty(); diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index 3ecd33e069..045369fec4 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -8932,7 +8932,7 @@ nsLayoutUtils::ComputeScrollMetadata(nsIFrame* aForFrame, ParentLayerRect rect = LayoutDeviceRect::FromAppUnits(*aClipRect, auPerDevPixel) * metrics.GetCumulativeResolution() * layerToParentLayerScale; - metadata.SetClipRect(Some(RoundedToInt(rect))); + metadata.SetScrollClip(Some(LayerClip(RoundedToInt(rect)))); } // For the root scroll frame of the root content document (RCD-RSF), the above calculation @@ -9253,7 +9253,7 @@ nsLayoutUtils::UpdateDisplayPortMarginsFromPendingMessages() { mozilla::dom::ContentChild::GetSingleton()->GetIPCChannel()->PeekMessages( [](const IPC::Message& aMsg) -> bool { if (aMsg.type() == mozilla::layers::PAPZ::Msg_UpdateFrame__ID) { - void* iter = nullptr; + PickleIterator iter(aMsg); FrameMetrics frame; if (!IPC::ReadParam(&aMsg, &iter, &frame)) { MOZ_ASSERT(false); diff --git a/layout/base/nsPresContext.cpp b/layout/base/nsPresContext.cpp index 80590ff9e5..81e8137afa 100644 --- a/layout/base/nsPresContext.cpp +++ b/layout/base/nsPresContext.cpp @@ -1595,10 +1595,11 @@ nsPresContext::ThemeChanged() } } -static void +static bool NotifyThemeChanged(TabParent* aTabParent, void* aArg) { aTabParent->ThemeChanged(); + return false; } void @@ -1951,11 +1952,12 @@ nsPresContext::HandleMediaFeatureValuesChangedEvent() } } -static void +static bool NotifyTabSizeModeChanged(TabParent* aTab, void* aArg) { nsSizeMode* sizeMode = static_cast(aArg); aTab->SizeModeChanged(*sizeMode); + return false; } void diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index ada85e8cae..2dc4043b3f 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -6800,7 +6800,7 @@ PresShell::RecordMouseLocation(WidgetGUIEvent* aEvent) } if ((aEvent->mMessage == eMouseMove && - aEvent->AsMouseEvent()->reason == WidgetMouseEvent::eReal) || + aEvent->AsMouseEvent()->mReason == WidgetMouseEvent::eReal) || aEvent->mMessage == eMouseEnterIntoWidget || aEvent->mMessage == eMouseDown || aEvent->mMessage == eMouseUp) { @@ -7575,7 +7575,7 @@ PresShell::HandleEvent(nsIFrame* aFrame, WidgetMouseEvent* mouseEvent = aEvent->AsMouseEvent(); bool isWindowLevelMouseExit = (aEvent->mMessage == eMouseExitFromWidget) && - (mouseEvent && mouseEvent->exit == WidgetMouseEvent::eTopLevel); + (mouseEvent && mouseEvent->mExitFrom == WidgetMouseEvent::eTopLevel); // Get the frame at the event point. However, don't do this if we're // capturing and retargeting the event because the captured frame will @@ -7677,7 +7677,7 @@ PresShell::HandleEvent(nsIFrame* aFrame, eventPoint = nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent, frame); } if (mouseEvent && mouseEvent->mClass == eMouseEventClass && - mouseEvent->ignoreRootScrollFrame) { + mouseEvent->mIgnoreRootScrollFrame) { flags |= INPUT_IGNORE_ROOT_SCROLL_FRAME; } nsIFrame* target = @@ -8119,7 +8119,7 @@ PresShell::HandleEventInternal(WidgetEvent* aEvent, case eKeyUp: { nsIDocument* doc = GetCurrentEventContent() ? mCurrentEventContent->OwnerDoc() : nullptr; - auto keyCode = aEvent->AsKeyboardEvent()->keyCode; + auto keyCode = aEvent->AsKeyboardEvent()->mKeyCode; if (keyCode == NS_VK_ESCAPE) { nsIDocument* root = nsContentUtils::GetRootDocument(doc); if (root && root->GetFullscreenElement()) { @@ -8199,7 +8199,7 @@ PresShell::HandleEventInternal(WidgetEvent* aEvent, if (aEvent->mMessage == eContextMenu) { WidgetMouseEvent* mouseEvent = aEvent->AsMouseEvent(); - if (mouseEvent->context == WidgetMouseEvent::eContextMenuKey && + if (mouseEvent->IsContextMenuKeyEvent() && !AdjustContextMenuKeyEvent(mouseEvent)) { return NS_OK; } @@ -8269,7 +8269,7 @@ PresShell::HandleEventInternal(WidgetEvent* aEvent, case eKeyPress: case eKeyDown: case eKeyUp: { - if (aEvent->AsKeyboardEvent()->keyCode == NS_VK_ESCAPE) { + if (aEvent->AsKeyboardEvent()->mKeyCode == NS_VK_ESCAPE) { if (aEvent->mMessage == eKeyUp) { // Reset this flag after key up is handled. mIsLastChromeOnlyEscapeKeyConsumed = false; @@ -9871,8 +9871,8 @@ PresShell::DelayedMouseEvent::DelayedMouseEvent(WidgetMouseEvent* aEvent) : new WidgetMouseEvent(aEvent->IsTrusted(), aEvent->mMessage, aEvent->mWidget, - aEvent->reason, - aEvent->context); + aEvent->mReason, + aEvent->mContextMenuTrigger); mouseEvent->AssignMouseEventData(*aEvent, false); mEvent = mouseEvent; } diff --git a/layout/build/nsLayoutStatics.cpp b/layout/build/nsLayoutStatics.cpp index 8c351efa6d..fd51537639 100644 --- a/layout/build/nsLayoutStatics.cpp +++ b/layout/build/nsLayoutStatics.cpp @@ -127,10 +127,12 @@ using namespace mozilla::system; #include "CameraPreferences.h" #include "TouchManager.h" #include "MediaDecoder.h" +#include "MediaPrefs.h" #include "mozilla/layers/CompositorLRU.h" #include "mozilla/dom/devicestorage/DeviceStorageStatics.h" #include "mozilla/ServoBindings.h" #include "mozilla/StaticPresData.h" +#include "mozilla/dom/WebIDLGlobalNameHash.h" #ifdef MOZ_B2G_BT #include "mozilla/dom/BluetoothUUID.h" @@ -309,6 +311,7 @@ nsLayoutStatics::Initialize() #endif MediaDecoder::InitStatics(); + MediaPrefs::GetSingleton(); PromiseDebugging::Init(); @@ -384,6 +387,7 @@ nsLayoutStatics::Shutdown() ShutdownJSEnvironment(); nsGlobalWindow::ShutDown(); nsDOMClassInfo::ShutDown(); + WebIDLGlobalNameHash::Shutdown(); nsListControlFrame::Shutdown(); nsXBLService::Shutdown(); nsAutoCopyListener::Shutdown(); diff --git a/layout/forms/nsListControlFrame.cpp b/layout/forms/nsListControlFrame.cpp index 62483deca1..89238cec95 100644 --- a/layout/forms/nsListControlFrame.cpp +++ b/layout/forms/nsListControlFrame.cpp @@ -1666,10 +1666,11 @@ nsListControlFrame::MouseUp(nsIDOMEvent* aMouseEvent) FireOnChange(); } - mouseEvent->clickCount = 1; + mouseEvent->mClickCount = 1; } else { // the click was out side of the select or its dropdown - mouseEvent->clickCount = IgnoreMouseEventForSelection(aMouseEvent) ? 1 : 0; + mouseEvent->mClickCount = + IgnoreMouseEventForSelection(aMouseEvent) ? 1 : 0; } } else { CaptureMouseEvents(false); @@ -2103,7 +2104,7 @@ nsListControlFrame::KeyDown(nsIDOMEvent* aKeyEvent) "DOM event must have WidgetKeyboardEvent for its internal event"); if (keyEvent->IsAlt()) { - if (keyEvent->keyCode == NS_VK_UP || keyEvent->keyCode == NS_VK_DOWN) { + if (keyEvent->mKeyCode == NS_VK_UP || keyEvent->mKeyCode == NS_VK_DOWN) { DropDownToggleKey(aKeyEvent); } return NS_OK; @@ -2121,23 +2122,23 @@ nsListControlFrame::KeyDown(nsIDOMEvent* aKeyEvent) bool isControlOrMeta = (keyEvent->IsControl() || keyEvent->IsMeta()); // Don't try to handle multiple-select pgUp/pgDown in single-select lists. if (isControlOrMeta && !GetMultiple() && - (keyEvent->keyCode == NS_VK_PAGE_UP || - keyEvent->keyCode == NS_VK_PAGE_DOWN)) { + (keyEvent->mKeyCode == NS_VK_PAGE_UP || + keyEvent->mKeyCode == NS_VK_PAGE_DOWN)) { return NS_OK; } - if (isControlOrMeta && (keyEvent->keyCode == NS_VK_UP || - keyEvent->keyCode == NS_VK_LEFT || - keyEvent->keyCode == NS_VK_DOWN || - keyEvent->keyCode == NS_VK_RIGHT || - keyEvent->keyCode == NS_VK_HOME || - keyEvent->keyCode == NS_VK_END)) { + if (isControlOrMeta && (keyEvent->mKeyCode == NS_VK_UP || + keyEvent->mKeyCode == NS_VK_LEFT || + keyEvent->mKeyCode == NS_VK_DOWN || + keyEvent->mKeyCode == NS_VK_RIGHT || + keyEvent->mKeyCode == NS_VK_HOME || + keyEvent->mKeyCode == NS_VK_END)) { // Don't go into multiple-select mode unless this list can handle it. isControlOrMeta = mControlSelectMode = GetMultiple(); - } else if (keyEvent->keyCode != NS_VK_SPACE) { + } else if (keyEvent->mKeyCode != NS_VK_SPACE) { mControlSelectMode = false; } - switch (keyEvent->keyCode) { + switch (keyEvent->mKeyCode) { case NS_VK_UP: case NS_VK_LEFT: AdjustIndexForDisabledOpt(mEndSelectionIndex, newIndex, @@ -2270,21 +2271,21 @@ nsListControlFrame::KeyPress(nsIDOMEvent* aKeyEvent) // With some keyboard layout, space key causes non-ASCII space. // So, the check in keydown event handler isn't enough, we need to check it // again with keypress event. - if (keyEvent->charCode != ' ') { + if (keyEvent->mCharCode != ' ') { mControlSelectMode = false; } bool isControlOrMeta = (keyEvent->IsControl() || keyEvent->IsMeta()); - if (isControlOrMeta && keyEvent->charCode != ' ') { + if (isControlOrMeta && keyEvent->mCharCode != ' ') { return NS_OK; } - // NOTE: If keyCode of keypress event is not 0, charCode is always 0. + // NOTE: If mKeyCode of keypress event is not 0, mCharCode is always 0. // Therefore, all non-printable keys are not handled after this block. - if (!keyEvent->charCode) { + if (!keyEvent->mCharCode) { // Backspace key will delete the last char in the string. Otherwise, // non-printable keypress should reset incremental search. - if (keyEvent->keyCode == NS_VK_BACK) { + if (keyEvent->mKeyCode == NS_VK_BACK) { incrementalSearchResetter.Cancel(); if (!GetIncrementalString().IsEmpty()) { GetIncrementalString().Truncate(GetIncrementalString().Length() - 1); @@ -2314,10 +2315,10 @@ nsListControlFrame::KeyPress(nsIDOMEvent* aKeyEvent) if (keyEvent->mTime - gLastKeyTime > INCREMENTAL_SEARCH_KEYPRESS_TIME) { // If this is ' ' and we are at the beginning of the string, treat it as // "select this option" (bug 191543) - if (keyEvent->charCode == ' ') { + if (keyEvent->mCharCode == ' ') { // Actually process the new index and let the selection code // do the scrolling for us - PostHandleKeyEvent(mEndSelectionIndex, keyEvent->charCode, + PostHandleKeyEvent(mEndSelectionIndex, keyEvent->mCharCode, keyEvent->IsShift(), isControlOrMeta); return NS_OK; @@ -2329,7 +2330,7 @@ nsListControlFrame::KeyPress(nsIDOMEvent* aKeyEvent) gLastKeyTime = keyEvent->mTime; // Append this keystroke to the search string. - char16_t uniChar = ToLowerCase(static_cast(keyEvent->charCode)); + char16_t uniChar = ToLowerCase(static_cast(keyEvent->mCharCode)); GetIncrementalString().Append(uniChar); // See bug 188199, if all letters in incremental string are same, just try to diff --git a/layout/generic/VisibilityIPC.h b/layout/generic/VisibilityIPC.h index d874a53e14..aa46d8c67b 100644 --- a/layout/generic/VisibilityIPC.h +++ b/layout/generic/VisibilityIPC.h @@ -29,7 +29,7 @@ struct ParamTraits WriteParam(aMsg, uint8_t(aParam)); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { uint8_t valueAsByte; if (ReadParam(aMsg, aIter, &valueAsByte)) { diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp index dacb9adb53..6030f28aba 100644 --- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -3257,7 +3257,7 @@ nsFrame::HandlePress(nsPresContext* aPresContext, #endif RefPtr fc = const_cast(frameselection); - if (mouseEvent->clickCount > 1) { + if (mouseEvent->mClickCount > 1) { // These methods aren't const but can't actually delete anything, // so no need for nsWeakFrame. fc->SetDragState(true); @@ -3456,16 +3456,16 @@ nsFrame::HandleMultiplePress(nsPresContext* aPresContext, return NS_OK; } - if (mouseEvent->clickCount == 4) { + if (mouseEvent->mClickCount == 4) { beginAmount = endAmount = eSelectParagraph; - } else if (mouseEvent->clickCount == 3) { + } else if (mouseEvent->mClickCount == 3) { if (Preferences::GetBool("browser.triple_click_selects_paragraph")) { beginAmount = endAmount = eSelectParagraph; } else { beginAmount = eSelectBeginLine; endAmount = eSelectEndLine; } - } else if (mouseEvent->clickCount == 2) { + } else if (mouseEvent->mClickCount == 2) { // We only want inline frames; PeekBackwardAndForward dislikes blocks beginAmount = endAmount = eSelectWord; } else { diff --git a/layout/generic/nsSelection.cpp b/layout/generic/nsSelection.cpp index 5250fee4f2..0591cbb2e8 100644 --- a/layout/generic/nsSelection.cpp +++ b/layout/generic/nsSelection.cpp @@ -3299,7 +3299,7 @@ nsFrameSelection::SetDelayedCaretData(WidgetMouseEvent* aMouseEvent) if (aMouseEvent) { mDelayedMouseEventValid = true; mDelayedMouseEventIsShift = aMouseEvent->IsShift(); - mDelayedMouseEventClickCount = aMouseEvent->clickCount; + mDelayedMouseEventClickCount = aMouseEvent->mClickCount; } else { mDelayedMouseEventValid = false; } diff --git a/layout/printing/nsPrintPreviewListener.cpp b/layout/printing/nsPrintPreviewListener.cpp index 23d3d542dd..5edc0fb903 100644 --- a/layout/printing/nsPrintPreviewListener.cpp +++ b/layout/printing/nsPrintPreviewListener.cpp @@ -131,16 +131,16 @@ GetActionForEvent(nsIDOMEvent* aEvent) } static const uint32_t kOKKeyCodes[] = { - nsIDOMKeyEvent::DOM_VK_PAGE_UP, nsIDOMKeyEvent::DOM_VK_PAGE_DOWN, - nsIDOMKeyEvent::DOM_VK_UP, nsIDOMKeyEvent::DOM_VK_DOWN, - nsIDOMKeyEvent::DOM_VK_HOME, nsIDOMKeyEvent::DOM_VK_END + NS_VK_PAGE_UP, NS_VK_PAGE_DOWN, + NS_VK_UP, NS_VK_DOWN, + NS_VK_HOME, NS_VK_END }; - if (keyEvent->keyCode == nsIDOMKeyEvent::DOM_VK_TAB) { + if (keyEvent->mKeyCode == NS_VK_TAB) { return keyEvent->IsShift() ? eEventAction_ShiftTab : eEventAction_Tab; } - if (keyEvent->charCode == ' ' || keyEvent->keyCode == NS_VK_SPACE) { + if (keyEvent->mCharCode == ' ' || keyEvent->mKeyCode == NS_VK_SPACE) { return eEventAction_Propagate; } @@ -149,7 +149,7 @@ GetActionForEvent(nsIDOMEvent* aEvent) } for (uint32_t i = 0; i < ArrayLength(kOKKeyCodes); ++i) { - if (keyEvent->keyCode == kOKKeyCodes[i]) { + if (keyEvent->mKeyCode == kOKKeyCodes[i]) { return eEventAction_Propagate; } } diff --git a/layout/xul/nsButtonBoxFrame.cpp b/layout/xul/nsButtonBoxFrame.cpp index 820be708a2..45d9345168 100644 --- a/layout/xul/nsButtonBoxFrame.cpp +++ b/layout/xul/nsButtonBoxFrame.cpp @@ -116,7 +116,7 @@ nsButtonBoxFrame::HandleEvent(nsPresContext* aPresContext, if (!keyEvent) { break; } - if (NS_VK_SPACE == keyEvent->keyCode) { + if (NS_VK_SPACE == keyEvent->mKeyCode) { EventStateManager* esm = aPresContext->EventStateManager(); // :hover:active state esm->SetContentState(mContent, NS_EVENT_STATE_HOVER); @@ -133,7 +133,7 @@ nsButtonBoxFrame::HandleEvent(nsPresContext* aPresContext, if (!keyEvent) { break; } - if (NS_VK_RETURN == keyEvent->keyCode) { + if (NS_VK_RETURN == keyEvent->mKeyCode) { nsCOMPtr buttonEl(do_QueryInterface(mContent)); if (buttonEl) { MouseClicked(aEvent); @@ -149,7 +149,7 @@ nsButtonBoxFrame::HandleEvent(nsPresContext* aPresContext, if (!keyEvent) { break; } - if (NS_VK_SPACE == keyEvent->keyCode) { + if (NS_VK_SPACE == keyEvent->mKeyCode) { mIsHandlingKeyEvent = false; // only activate on keyup if we're already in the :hover:active state NS_ASSERTION(mContent->IsElement(), "How do we have a non-element?"); diff --git a/layout/xul/nsMenuBarFrame.cpp b/layout/xul/nsMenuBarFrame.cpp index cc5813251a..324c5014ee 100644 --- a/layout/xul/nsMenuBarFrame.cpp +++ b/layout/xul/nsMenuBarFrame.cpp @@ -79,6 +79,7 @@ nsMenuBarFrame::Init(nsIContent* aContent, mTarget->AddSystemEventListener(NS_LITERAL_STRING("keypress"), mMenuBarListener, false); mTarget->AddSystemEventListener(NS_LITERAL_STRING("keydown"), mMenuBarListener, false); mTarget->AddSystemEventListener(NS_LITERAL_STRING("keyup"), mMenuBarListener, false); + mTarget->AddSystemEventListener(NS_LITERAL_STRING("mozaccesskeynotfound"), mMenuBarListener, false); // mousedown event should be handled in all phase mTarget->AddEventListener(NS_LITERAL_STRING("mousedown"), mMenuBarListener, true); @@ -416,6 +417,7 @@ nsMenuBarFrame::DestroyFrom(nsIFrame* aDestructRoot) mTarget->RemoveSystemEventListener(NS_LITERAL_STRING("keypress"), mMenuBarListener, false); mTarget->RemoveSystemEventListener(NS_LITERAL_STRING("keydown"), mMenuBarListener, false); mTarget->RemoveSystemEventListener(NS_LITERAL_STRING("keyup"), mMenuBarListener, false); + mTarget->RemoveSystemEventListener(NS_LITERAL_STRING("mozaccesskeynotfound"), mMenuBarListener, false); mTarget->RemoveEventListener(NS_LITERAL_STRING("mousedown"), mMenuBarListener, true); mTarget->RemoveEventListener(NS_LITERAL_STRING("mousedown"), mMenuBarListener, false); diff --git a/layout/xul/nsMenuBarListener.cpp b/layout/xul/nsMenuBarListener.cpp index 0879b2cd5e..5ec74ffe08 100644 --- a/layout/xul/nsMenuBarListener.cpp +++ b/layout/xul/nsMenuBarListener.cpp @@ -199,83 +199,82 @@ nsMenuBarListener::KeyPress(nsIDOMEvent* aKeyEvent) aKeyEvent->GetIsTrusted(&trustedEvent); } - if (!trustedEvent) + if (!trustedEvent) { return NS_OK; + } - nsresult retVal = NS_OK; // default is to not consume event - InitAccessKey(); if (mAccessKey) { - bool preventDefault; - aKeyEvent->GetDefaultPrevented(&preventDefault); - if (!preventDefault) { - nsCOMPtr keyEvent = do_QueryInterface(aKeyEvent); - uint32_t keyCode, charCode; - keyEvent->GetKeyCode(&keyCode); - keyEvent->GetCharCode(&charCode); + // If accesskey handling was forwarded to a child process, wait for + // the mozaccesskeynotfound event before handling accesskeys. + WidgetKeyboardEvent* nativeKeyEvent = + aKeyEvent->WidgetEventPtr()->AsKeyboardEvent(); + if (nativeKeyEvent->mAccessKeyForwardedToChild) { + return NS_OK; + } - bool hasAccessKeyCandidates = charCode != 0; - if (!hasAccessKeyCandidates) { - WidgetKeyboardEvent* nativeKeyEvent = - aKeyEvent->WidgetEventPtr()->AsKeyboardEvent(); - if (nativeKeyEvent) { - AutoTArray keys; - nativeKeyEvent->GetAccessKeyCandidates(keys); - hasAccessKeyCandidates = !keys.IsEmpty(); - } + nsCOMPtr keyEvent = do_QueryInterface(aKeyEvent); + uint32_t keyCode, charCode; + keyEvent->GetKeyCode(&keyCode); + keyEvent->GetCharCode(&charCode); + + bool hasAccessKeyCandidates = charCode != 0; + if (!hasAccessKeyCandidates) { + if (nativeKeyEvent) { + AutoTArray keys; + nativeKeyEvent->GetAccessKeyCandidates(keys); + hasAccessKeyCandidates = !keys.IsEmpty(); } + } - // Cancel the access key flag unless we are pressing the access key. - if (keyCode != (uint32_t)mAccessKey) { - mAccessKeyDownCanceled = true; + // Cancel the access key flag unless we are pressing the access key. + if (keyCode != (uint32_t)mAccessKey) { + mAccessKeyDownCanceled = true; + } + + if (IsAccessKeyPressed(keyEvent) && hasAccessKeyCandidates) { + // Do shortcut navigation. + // A letter was pressed. We want to see if a shortcut gets matched. If + // so, we'll know the menu got activated. + nsMenuFrame* result = mMenuBarFrame->FindMenuWithShortcut(keyEvent); + if (result) { + mMenuBarFrame->SetActiveByKeyboard(); + mMenuBarFrame->SetActive(true); + result->OpenMenu(true); + + // The opened menu will listen next keyup event. + // Therefore, we should clear the keydown flags here. + mAccessKeyDown = mAccessKeyDownCanceled = false; + + aKeyEvent->StopPropagation(); + aKeyEvent->PreventDefault(); } + } +#ifndef XP_MACOSX + // Also need to handle F10 specially on Non-Mac platform. + else if (nativeKeyEvent->mMessage == eKeyPress && keyCode == NS_VK_F10) { + if ((GetModifiersForAccessKey(keyEvent) & ~MODIFIER_CONTROL) == 0) { + // The F10 key just went down by itself or with ctrl pressed. + // In Windows, both of these activate the menu bar. + mMenuBarFrame->SetActiveByKeyboard(); + ToggleMenuActiveState(); - if (IsAccessKeyPressed(keyEvent) && hasAccessKeyCandidates) { - // Do shortcut navigation. - // A letter was pressed. We want to see if a shortcut gets matched. If - // so, we'll know the menu got activated. - nsMenuFrame* result = mMenuBarFrame->FindMenuWithShortcut(keyEvent); - if (result) { - mMenuBarFrame->SetActiveByKeyboard(); - mMenuBarFrame->SetActive(true); - result->OpenMenu(true); - - // The opened menu will listen next keyup event. - // Therefore, we should clear the keydown flags here. - mAccessKeyDown = mAccessKeyDownCanceled = false; - + if (mMenuBarFrame->IsActive()) { +#ifdef MOZ_WIDGET_GTK + // In GTK, this also opens the first menu. + mMenuBarFrame->GetCurrentMenuItem()->OpenMenu(true); +#endif aKeyEvent->StopPropagation(); aKeyEvent->PreventDefault(); - retVal = NS_OK; // I am consuming event - } - } -#ifndef XP_MACOSX - // Also need to handle F10 specially on Non-Mac platform. - else if (keyCode == NS_VK_F10) { - if ((GetModifiersForAccessKey(keyEvent) & ~MODIFIER_CONTROL) == 0) { - // The F10 key just went down by itself or with ctrl pressed. - // In Windows, both of these activate the menu bar. - mMenuBarFrame->SetActiveByKeyboard(); - ToggleMenuActiveState(); - - if (mMenuBarFrame->IsActive()) { -#ifdef MOZ_WIDGET_GTK - // In GTK, this also opens the first menu. - mMenuBarFrame->GetCurrentMenuItem()->OpenMenu(true); -#endif - aKeyEvent->StopPropagation(); - aKeyEvent->PreventDefault(); - return NS_OK; // consume the event - } } } + } #endif // !XP_MACOSX - } } - return retVal; + return NS_OK; } bool @@ -425,6 +424,9 @@ nsMenuBarListener::HandleEvent(nsIDOMEvent* aEvent) if (eventType.EqualsLiteral("keypress")) { return KeyPress(aEvent); } + if (eventType.EqualsLiteral("mozaccesskeynotfound")) { + return KeyPress(aEvent); + } if (eventType.EqualsLiteral("blur")) { return Blur(aEvent); } diff --git a/layout/xul/nsMenuFrame.cpp b/layout/xul/nsMenuFrame.cpp index 7da16ac2ce..3c30917a33 100644 --- a/layout/xul/nsMenuFrame.cpp +++ b/layout/xul/nsMenuFrame.cpp @@ -389,10 +389,10 @@ nsMenuFrame::HandleEvent(nsPresContext* aPresContext, if (aEvent->mMessage == eKeyPress && !IsDisabled()) { WidgetKeyboardEvent* keyEvent = aEvent->AsKeyboardEvent(); - uint32_t keyCode = keyEvent->keyCode; + uint32_t keyCode = keyEvent->mKeyCode; #ifdef XP_MACOSX // On mac, open menulist on either up/down arrow or space (w/o Cmd pressed) - if (!IsOpen() && ((keyEvent->charCode == NS_VK_SPACE && !keyEvent->IsMeta()) || + if (!IsOpen() && ((keyEvent->mCharCode == ' ' && !keyEvent->IsMeta()) || (keyCode == NS_VK_UP || keyCode == NS_VK_DOWN))) { *aEventStatus = nsEventStatus_eConsumeNoDefault; OpenMenu(false); diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js index 4d45233334..87542b29da 100644 --- a/modules/libpref/init/all.js +++ b/modules/libpref/init/all.js @@ -1804,6 +1804,12 @@ pref("network.http.enable-packaged-apps", false); // Set to false if you don't need the signed packaged web app support (i.e. NSec). pref("network.http.signed-packages.enabled", false); +// If it is set to false, headers with empty value will not appear in the header +// array - behavior as it used to be. If it is true: empty headers coming from +// the network will exits in header array as empty string. Call SetHeader with +// an empty value will still delete the header.(Bug 6699259) +pref("network.http.keep_empty_response_headers_as_empty_string", false); + // default values for FTP // in a DSCP environment this should be 40 (0x28, or AF11), per RFC-4594, // Section 4.8 "High-Throughput Data Service Class", and 80 (0x50, or AF22) diff --git a/netwerk/ipc/NeckoMessageUtils.h b/netwerk/ipc/NeckoMessageUtils.h index 8f2986f02f..05def23991 100644 --- a/netwerk/ipc/NeckoMessageUtils.h +++ b/netwerk/ipc/NeckoMessageUtils.h @@ -49,7 +49,7 @@ struct ParamTraits WriteParam(aMsg, aParam.expireTime); } - static bool Read(const Message* aMsg, void** aIter, Permission* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, Permission* aResult) { return ReadParam(aMsg, aIter, &aResult->origin) && ReadParam(aMsg, aIter, &aResult->type) && @@ -96,13 +96,12 @@ struct ParamTraits "https://bugzilla.mozilla.org/show_bug.cgi?id=661158"); aMsg->WriteBytes(aParam.local.path, sizeof(aParam.local.path)); #endif + } else { + NS_RUNTIMEABORT("Unknown socket family"); } - - /* If we get here without hitting any of the cases above, there's not much - * we can do but let the deserializer fail when it gets this message */ } - static bool Read(const Message* aMsg, void** aIter, mozilla::net::NetAddr* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, mozilla::net::NetAddr* aResult) { if (!ReadParam(aMsg, aIter, &aResult->raw.family)) return false; @@ -164,7 +163,7 @@ struct ParamTraits WriteParam(aMsg, aParam.cacheReadEnd); } - static bool Read(const Message* aMsg, void** aIter, mozilla::net::ResourceTimingStruct* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, mozilla::net::ResourceTimingStruct* aResult) { return ReadParam(aMsg, aIter, &aResult->domainLookupStart) && ReadParam(aMsg, aIter, &aResult->domainLookupEnd) && diff --git a/netwerk/protocol/http/HttpBaseChannel.cpp b/netwerk/protocol/http/HttpBaseChannel.cpp index e1ac4f3beb..3706ff42ee 100644 --- a/netwerk/protocol/http/HttpBaseChannel.cpp +++ b/netwerk/protocol/http/HttpBaseChannel.cpp @@ -1658,9 +1658,38 @@ HttpBaseChannel::SetResponseHeader(const nsACString& header, NS_IMETHODIMP HttpBaseChannel::VisitResponseHeaders(nsIHttpHeaderVisitor *visitor) { - if (!mResponseHead) + if (!mResponseHead) { return NS_ERROR_NOT_AVAILABLE; - return mResponseHead->Headers().VisitHeaders(visitor); + } + return mResponseHead->Headers().VisitHeaders(visitor, + nsHttpHeaderArray::eFilterResponse); +} + +NS_IMETHODIMP +HttpBaseChannel::GetOriginalResponseHeader(const nsACString& aHeader, + nsIHttpHeaderVisitor *aVisitor) +{ + if (!mResponseHead) { + return NS_ERROR_NOT_AVAILABLE; + } + + nsHttpAtom atom = nsHttp::ResolveAtom(aHeader); + if (!atom) { + return NS_ERROR_NOT_AVAILABLE; + } + + return mResponseHead->Headers().GetOriginalHeader(atom, aVisitor); +} + +NS_IMETHODIMP +HttpBaseChannel::VisitOriginalResponseHeaders(nsIHttpHeaderVisitor *aVisitor) +{ + if (!mResponseHead) { + return NS_ERROR_NOT_AVAILABLE; + } + + return mResponseHead->Headers().VisitHeaders(aVisitor, + nsHttpHeaderArray::eFilterResponseOriginal); } NS_IMETHODIMP diff --git a/netwerk/protocol/http/HttpBaseChannel.h b/netwerk/protocol/http/HttpBaseChannel.h index 0bd97a9686..e21071f501 100644 --- a/netwerk/protocol/http/HttpBaseChannel.h +++ b/netwerk/protocol/http/HttpBaseChannel.h @@ -155,6 +155,9 @@ public: NS_IMETHOD SetResponseHeader(const nsACString& header, const nsACString& value, bool merge) override; NS_IMETHOD VisitResponseHeaders(nsIHttpHeaderVisitor *visitor) override; + NS_IMETHOD GetOriginalResponseHeader(const nsACString &aHeader, + nsIHttpHeaderVisitor *aVisitor) override; + NS_IMETHOD VisitOriginalResponseHeaders(nsIHttpHeaderVisitor *aVisitor) override; NS_IMETHOD GetAllowPipelining(bool *value) override; NS_IMETHOD SetAllowPipelining(bool value) override; NS_IMETHOD GetAllowSTS(bool *value) override; diff --git a/netwerk/protocol/http/NullHttpChannel.cpp b/netwerk/protocol/http/NullHttpChannel.cpp index 712f6d4104..049c57c219 100644 --- a/netwerk/protocol/http/NullHttpChannel.cpp +++ b/netwerk/protocol/http/NullHttpChannel.cpp @@ -209,6 +209,19 @@ NullHttpChannel::VisitResponseHeaders(nsIHttpHeaderVisitor *aVisitor) return NS_ERROR_NOT_IMPLEMENTED; } +NS_IMETHODIMP +NullHttpChannel::GetOriginalResponseHeader(const nsACString & header, + nsIHttpHeaderVisitor *aVisitor) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +NullHttpChannel::VisitOriginalResponseHeaders(nsIHttpHeaderVisitor *aVisitor) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + NS_IMETHODIMP NullHttpChannel::IsNoStoreResponse(bool *_retval) { diff --git a/netwerk/protocol/http/PHttpChannelParams.h b/netwerk/protocol/http/PHttpChannelParams.h index cb28819dbe..4df5c7832e 100644 --- a/netwerk/protocol/http/PHttpChannelParams.h +++ b/netwerk/protocol/http/PHttpChannelParams.h @@ -54,7 +54,7 @@ struct ParamTraits WriteParam(aMsg, aParam.mEmpty); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { if (!ReadParam(aMsg, aIter, &aResult->mHeader) || !ReadParam(aMsg, aIter, &aResult->mValue) || @@ -79,7 +79,7 @@ struct ParamTraits WriteParam(aMsg, value); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { nsAutoCString value; if (!ReadParam(aMsg, aIter, &value)) @@ -100,14 +100,58 @@ struct ParamTraits { WriteParam(aMsg, aParam.header); WriteParam(aMsg, aParam.value); + switch (aParam.variety) { + case mozilla::net::nsHttpHeaderArray::eVarietyUnknown: + WriteParam(aMsg, (uint8_t)0); + break; + case mozilla::net::nsHttpHeaderArray::eVarietyRequestOverride: + WriteParam(aMsg, (uint8_t)1); + break; + case mozilla::net::nsHttpHeaderArray::eVarietyRequestDefault: + WriteParam(aMsg, (uint8_t)2); + break; + case mozilla::net::nsHttpHeaderArray::eVarietyResponseNetOriginalAndResponse: + WriteParam(aMsg, (uint8_t)3); + break; + case mozilla::net::nsHttpHeaderArray::eVarietyResponseNetOriginal: + WriteParam(aMsg, (uint8_t)4); + break; + case mozilla::net::nsHttpHeaderArray::eVarietyResponse: + WriteParam(aMsg, (uint8_t)5); + } } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { + uint8_t variety; if (!ReadParam(aMsg, aIter, &aResult->header) || - !ReadParam(aMsg, aIter, &aResult->value)) + !ReadParam(aMsg, aIter, &aResult->value) || + !ReadParam(aMsg, aIter, &variety)) return false; + switch (variety) { + case 0: + aResult->variety = mozilla::net::nsHttpHeaderArray::eVarietyUnknown; + break; + case 1: + aResult->variety = mozilla::net::nsHttpHeaderArray::eVarietyRequestOverride; + break; + case 2: + aResult->variety = mozilla::net::nsHttpHeaderArray::eVarietyRequestDefault; + break; + case 3: + aResult->variety = mozilla::net::nsHttpHeaderArray::eVarietyResponseNetOriginalAndResponse; + break; + case 4: + aResult->variety = mozilla::net::nsHttpHeaderArray::eVarietyResponseNetOriginal; + break; + case 5: + aResult->variety = mozilla::net::nsHttpHeaderArray::eVarietyResponse; + break; + default: + return false; + } + return true; } }; @@ -125,7 +169,7 @@ struct ParamTraits WriteParam(aMsg, p.mHeaders); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { if (!ReadParam(aMsg, aIter, &aResult->mHeaders)) return false; @@ -154,7 +198,7 @@ struct ParamTraits WriteParam(aMsg, aParam.mPragmaNoCache); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { if (!ReadParam(aMsg, aIter, &aResult->mHeaders) || !ReadParam(aMsg, aIter, &aResult->mVersion) || diff --git a/netwerk/protocol/http/nsHttpHandler.cpp b/netwerk/protocol/http/nsHttpHandler.cpp index fb8e1cfef4..5d8a35abd6 100644 --- a/netwerk/protocol/http/nsHttpHandler.cpp +++ b/netwerk/protocol/http/nsHttpHandler.cpp @@ -210,6 +210,7 @@ nsHttpHandler::nsHttpHandler() , mTCPKeepaliveLongLivedEnabled(false) , mTCPKeepaliveLongLivedIdleTimeS(600) , mEnforceH1Framing(FRAMECHECK_BARELY) + , mKeepEmptyResponseHeadersAsEmtpyString(false) { LOG(("Creating nsHttpHandler [this=%p].\n", this)); @@ -440,7 +441,7 @@ nsHttpHandler::AddStandardRequestHeaders(nsHttpRequestHead *request, bool isSecu // Add the "User-Agent" header rv = request->SetHeader(nsHttp::User_Agent, UserAgent(), - false, nsHttpHeaderArray::eVarietyDefault); + false, nsHttpHeaderArray::eVarietyRequestDefault); if (NS_FAILED(rv)) return rv; // MIME based content negotiation lives! @@ -448,7 +449,7 @@ nsHttpHandler::AddStandardRequestHeaders(nsHttpRequestHead *request, bool isSecu // service worker expects to see it. The other "default" headers are // hidden from service worker interception. rv = request->SetHeader(nsHttp::Accept, mAccept, - false, nsHttpHeaderArray::eVarietyOverride); + false, nsHttpHeaderArray::eVarietyRequestOverride); if (NS_FAILED(rv)) return rv; // Add the "Accept-Language" header. This header is also exposed to the @@ -456,31 +457,36 @@ nsHttpHandler::AddStandardRequestHeaders(nsHttpRequestHead *request, bool isSecu if (!mAcceptLanguages.IsEmpty()) { // Add the "Accept-Language" header rv = request->SetHeader(nsHttp::Accept_Language, mAcceptLanguages, - false, nsHttpHeaderArray::eVarietyOverride); + false, + nsHttpHeaderArray::eVarietyRequestOverride); if (NS_FAILED(rv)) return rv; } // Add the "Accept-Encoding" header if (isSecure) { rv = request->SetHeader(nsHttp::Accept_Encoding, mHttpsAcceptEncodings, - false, nsHttpHeaderArray::eVarietyDefault); + false, + nsHttpHeaderArray::eVarietyRequestDefault); } else { rv = request->SetHeader(nsHttp::Accept_Encoding, mHttpAcceptEncodings, - false, nsHttpHeaderArray::eVarietyDefault); + false, + nsHttpHeaderArray::eVarietyRequestDefault); } if (NS_FAILED(rv)) return rv; // Add the "Do-Not-Track" header if (mDoNotTrackEnabled) { rv = request->SetHeader(nsHttp::DoNotTrack, NS_LITERAL_CSTRING("1"), - false, nsHttpHeaderArray::eVarietyDefault); + false, + nsHttpHeaderArray::eVarietyRequestDefault); if (NS_FAILED(rv)) return rv; } // add the "Send Hint" header if (mSafeHintEnabled || mParentalControlEnabled) { rv = request->SetHeader(nsHttp::Prefer, NS_LITERAL_CSTRING("safe"), - false, nsHttpHeaderArray::eVarietyDefault); + false, + nsHttpHeaderArray::eVarietyRequestDefault); if (NS_FAILED(rv)) return rv; } return NS_OK; @@ -1644,6 +1650,14 @@ nsHttpHandler::PrefsChanged(nsIPrefBranch *prefs, const char *pref) } } + if (PREF_CHANGED(HTTP_PREF("keep_empty_response_headers_as_empty_string"))) { + rv = prefs->GetBoolPref(HTTP_PREF("keep_empty_response_headers_as_empty_string"), + &cVar); + if (NS_SUCCEEDED(rv)) { + mKeepEmptyResponseHeadersAsEmtpyString = cVar; + } + } + // Enable HTTP response timeout if TCP Keepalives are disabled. mResponseTimeoutEnabled = !mTCPKeepaliveShortLivedEnabled && !mTCPKeepaliveLongLivedEnabled; diff --git a/netwerk/protocol/http/nsHttpHandler.h b/netwerk/protocol/http/nsHttpHandler.h index ebe42dc73f..bf160af823 100644 --- a/netwerk/protocol/http/nsHttpHandler.h +++ b/netwerk/protocol/http/nsHttpHandler.h @@ -357,6 +357,11 @@ public: void ShutdownConnectionManager(); + bool KeepEmptyResponseHeadersAsEmtpyString() const + { + return mKeepEmptyResponseHeadersAsEmtpyString; + } + private: virtual ~nsHttpHandler(); @@ -566,6 +571,13 @@ private: // True if remote newtab content-signature disabled because of the channel. bool mNewTabContentSignaturesDisabled; + // If it is set to false, headers with empty value will not appear in the + // header array - behavior as it used to be. If it is true: empty headers + // coming from the network will exits in header array as empty string. + // Call SetHeader with an empty value will still delete the header. + // (Bug 6699259) + bool mKeepEmptyResponseHeadersAsEmtpyString; + private: // For Rate Pacing Certain Network Events. Only assign this pointer on // socket thread. diff --git a/netwerk/protocol/http/nsHttpHeaderArray.cpp b/netwerk/protocol/http/nsHttpHeaderArray.cpp index ee3baa05e6..9c27724bbf 100644 --- a/netwerk/protocol/http/nsHttpHeaderArray.cpp +++ b/netwerk/protocol/http/nsHttpHeaderArray.cpp @@ -23,6 +23,11 @@ nsHttpHeaderArray::SetHeader(nsHttpAtom header, bool merge, nsHttpHeaderArray::HeaderVariety variety) { + MOZ_ASSERT((variety == eVarietyResponse) || + (variety == eVarietyRequestDefault) || + (variety == eVarietyRequestOverride), + "Net original headers can only be set using SetHeader_internal()."); + nsEntry *entry = nullptr; int32_t index; @@ -31,71 +36,120 @@ nsHttpHeaderArray::SetHeader(nsHttpAtom header, // If an empty value is passed in, then delete the header entry... // unless we are merging, in which case this function becomes a NOP. if (value.IsEmpty()) { - if (!merge && entry) - mHeaders.RemoveElementAt(index); + if (!merge && entry) { + if (entry->variety == eVarietyResponseNetOriginalAndResponse) { + MOZ_ASSERT(variety == eVarietyResponse); + entry->variety = eVarietyResponseNetOriginal; + } else { + mHeaders.RemoveElementAt(index); + } + } return NS_OK; } - MOZ_ASSERT(!entry || variety != eVarietyDefault, + MOZ_ASSERT(!entry || variety != eVarietyRequestDefault, "Cannot set default entry which overrides existing entry!"); if (!entry) { - entry = mHeaders.AppendElement(); // new nsEntry() - if (!entry) - return NS_ERROR_OUT_OF_MEMORY; - entry->header = header; - entry->value = value; - entry->variety = variety; + return SetHeader_internal(header, value, variety); } else if (merge && !IsSingletonHeader(header)) { - MergeHeader(header, entry, value); + return MergeHeader(header, entry, value, variety); } else { // Replace the existing string with the new value - entry->value = value; - entry->variety = eVarietyOverride; + if (entry->variety == eVarietyResponseNetOriginalAndResponse) { + MOZ_ASSERT(variety == eVarietyResponse); + entry->variety = eVarietyResponseNetOriginal; + return SetHeader_internal(header, value, variety); + } else { + entry->value = value; + entry->variety = variety; + } } return NS_OK; } nsresult -nsHttpHeaderArray::SetEmptyHeader(nsHttpAtom header) +nsHttpHeaderArray::SetHeader_internal(nsHttpAtom header, + const nsACString &value, + nsHttpHeaderArray::HeaderVariety variety) { + nsEntry *entry = mHeaders.AppendElement(); + if (!entry) { + return NS_ERROR_OUT_OF_MEMORY; + } + entry->header = header; + entry->value = value; + entry->variety = variety; + return NS_OK; +} + +nsresult +nsHttpHeaderArray::SetEmptyHeader(nsHttpAtom header, HeaderVariety variety) +{ + MOZ_ASSERT((variety == eVarietyResponse) || + (variety == eVarietyRequestDefault) || + (variety == eVarietyRequestOverride), + "Original headers can only be set using SetHeader_internal()."); nsEntry *entry = nullptr; LookupEntry(header, &entry); - if (!entry) { - entry = mHeaders.AppendElement(); // new nsEntry() - if (!entry) - return NS_ERROR_OUT_OF_MEMORY; - entry->header = header; - } else { + if (entry && + entry->variety != eVarietyResponseNetOriginalAndResponse) { entry->value.Truncate(); + return NS_OK; + } else if (entry) { + MOZ_ASSERT(variety == eVarietyResponse); + entry->variety = eVarietyResponseNetOriginal; } - return NS_OK; + return SetHeader_internal(header, EmptyCString(), variety); } nsresult -nsHttpHeaderArray::SetHeaderFromNet(nsHttpAtom header, const nsACString &value) +nsHttpHeaderArray::SetHeaderFromNet(nsHttpAtom header, + const nsACString &value, + bool response) { + // mHeader holds the consolidated (merged or updated) headers. + // mHeader for response header will keep the original heades as well. nsEntry *entry = nullptr; LookupEntry(header, &entry); if (!entry) { if (value.IsEmpty()) { - if (!TrackEmptyHeader(header)) { + if (!gHttpHandler->KeepEmptyResponseHeadersAsEmtpyString() && + !TrackEmptyHeader(header)) { LOG(("Ignoring Empty Header: %s\n", header.get())); + if (response) { + // Set header as original but not as response header. + return SetHeader_internal(header, value, + eVarietyResponseNetOriginal); + } return NS_OK; // ignore empty headers by default } } - entry = mHeaders.AppendElement(); //new nsEntry(header, value); - if (!entry) - return NS_ERROR_OUT_OF_MEMORY; - entry->header = header; - entry->value = value; + HeaderVariety variety = eVarietyRequestOverride; + if (response) { + variety = eVarietyResponseNetOriginalAndResponse; + } + return SetHeader_internal(header, value, variety); + } else if (!IsSingletonHeader(header)) { - MergeHeader(header, entry, value); + HeaderVariety variety = eVarietyRequestOverride; + if (response) { + variety = eVarietyResponse; + } + nsresult rv = MergeHeader(header, entry, value, variety); + if (NS_FAILED(rv)) { + return rv; + } + if (response) { + rv = SetHeader_internal(header, value, + eVarietyResponseNetOriginal); + } + return rv; } else { // Multiple instances of non-mergeable header received from network // - ignore if same value @@ -106,6 +160,11 @@ nsHttpHeaderArray::SetHeaderFromNet(nsHttpAtom header, const nsACString &value) } // else silently drop value: keep value from 1st header seen LOG(("Header %s silently dropped as non mergeable header\n", header.get())); + + } + if (response) { + return SetHeader_internal(header, value, + eVarietyResponseNetOriginal); } } @@ -115,7 +174,15 @@ nsHttpHeaderArray::SetHeaderFromNet(nsHttpAtom header, const nsACString &value) void nsHttpHeaderArray::ClearHeader(nsHttpAtom header) { - mHeaders.RemoveElement(header, nsEntry::MatchHeader()); + nsEntry *entry = nullptr; + int32_t index = LookupEntry(header, &entry); + if (entry) { + if (entry->variety == eVarietyResponseNetOriginalAndResponse) { + entry->variety = eVarietyResponseNetOriginal; + } else { + mHeaders.RemoveElementAt(index); + } + } } const char * @@ -137,6 +204,40 @@ nsHttpHeaderArray::GetHeader(nsHttpAtom header, nsACString &result) const return NS_OK; } +nsresult +nsHttpHeaderArray::GetOriginalHeader(nsHttpAtom aHeader, + nsIHttpHeaderVisitor *aVisitor) +{ + NS_ENSURE_ARG_POINTER(aVisitor); + uint32_t index = 0; + nsresult rv = NS_ERROR_NOT_AVAILABLE; + while (true) { + index = mHeaders.IndexOf(aHeader, index, nsEntry::MatchHeader()); + if (index != UINT32_MAX) { + const nsEntry &entry = mHeaders[index]; + + MOZ_ASSERT((entry.variety == eVarietyResponseNetOriginalAndResponse) || + (entry.variety == eVarietyResponseNetOriginal) || + (entry.variety == eVarietyResponse), + "This must be a response header."); + index++; + if (entry.variety == eVarietyResponse) { + continue; + } + rv = NS_OK; + if (NS_FAILED(aVisitor->VisitHeader(nsDependentCString(entry.header), + entry.value))) { + break; + } + } else { + // if there is no such a header, it will return + // NS_ERROR_NOT_AVAILABLE or NS_OK otherwise. + return rv; + } + } + return NS_OK; +} + bool nsHttpHeaderArray::HasHeader(nsHttpAtom header) const { @@ -152,17 +253,22 @@ nsHttpHeaderArray::VisitHeaders(nsIHttpHeaderVisitor *visitor, nsHttpHeaderArray uint32_t i, count = mHeaders.Length(); for (i = 0; i < count; ++i) { const nsEntry &entry = mHeaders[i]; - if (filter == eFilterSkipDefault && entry.variety == eVarietyDefault) { + if (filter == eFilterSkipDefault && entry.variety == eVarietyRequestDefault) { + continue; + } else if (filter == eFilterResponse && entry.variety == eVarietyResponseNetOriginal) { + continue; + } else if (filter == eFilterResponseOriginal && entry.variety == eVarietyResponse) { continue; } if (NS_FAILED(visitor->VisitHeader(nsDependentCString(entry.header), - entry.value))) + entry.value))) { break; + } } return NS_OK; } -nsresult +/*static*/ nsresult nsHttpHeaderArray::ParseHeaderLine(const char *line, nsHttpAtom *hdr, char **val) @@ -180,17 +286,16 @@ nsHttpHeaderArray::ParseHeaderLine(const char *line, // We skip over mal-formed headers in the hope that we'll still be able to // do something useful with the response. - char *p = (char *) strchr(line, ':'); if (!p) { LOG(("malformed header [%s]: no colon\n", line)); - return NS_OK; + return NS_ERROR_FAILURE; } // make sure we have a valid token for the field-name if (!nsHttp::IsValidToken(line, p)) { LOG(("malformed header [%s]: field-name not a token\n", line)); - return NS_OK; + return NS_ERROR_FAILURE; } *p = 0; // null terminate field-name @@ -198,7 +303,7 @@ nsHttpHeaderArray::ParseHeaderLine(const char *line, nsHttpAtom atom = nsHttp::ResolveAtom(line); if (!atom) { LOG(("failed to resolve atom [%s]\n", line)); - return NS_OK; + return NS_ERROR_FAILURE; } // skip over whitespace @@ -215,39 +320,60 @@ nsHttpHeaderArray::ParseHeaderLine(const char *line, if (hdr) *hdr = atom; if (val) *val = p; - // assign response header - return SetHeaderFromNet(atom, nsDependentCString(p, p2 - p)); + return NS_OK; } void -nsHttpHeaderArray::ParseHeaderSet(char *buffer) -{ - nsHttpAtom hdr; - char *val; - while (buffer) { - char *eof = strchr(buffer, '\r'); - if (!eof) { - break; - } - *eof = '\0'; - ParseHeaderLine(buffer, &hdr, &val); - buffer = eof + 1; - if (*buffer == '\n') { - buffer++; - } - } -} - -void -nsHttpHeaderArray::Flatten(nsACString &buf, bool pruneProxyHeaders) +nsHttpHeaderArray::Flatten(nsACString &buf, bool pruneProxyHeaders, + bool pruneTransients) { uint32_t i, count = mHeaders.Length(); for (i = 0; i < count; ++i) { const nsEntry &entry = mHeaders[i]; - // prune proxy headers if requested - if (pruneProxyHeaders && ((entry.header == nsHttp::Proxy_Authorization) || - (entry.header == nsHttp::Proxy_Connection))) + // Skip original header. + if (entry.variety == eVarietyResponseNetOriginal) { continue; + } + // prune proxy headers if requested + if (pruneProxyHeaders && + ((entry.header == nsHttp::Proxy_Authorization) || + (entry.header == nsHttp::Proxy_Connection))) { + continue; + } + if (pruneTransients && + (entry.value.IsEmpty() || + entry.header == nsHttp::Connection || + entry.header == nsHttp::Proxy_Connection || + entry.header == nsHttp::Keep_Alive || + entry.header == nsHttp::WWW_Authenticate || + entry.header == nsHttp::Proxy_Authenticate || + entry.header == nsHttp::Trailer || + entry.header == nsHttp::Transfer_Encoding || + entry.header == nsHttp::Upgrade || + // XXX this will cause problems when we start honoring + // Cache-Control: no-cache="set-cookie", what to do? + entry.header == nsHttp::Set_Cookie)) { + continue; + } + + buf.Append(entry.header); + buf.AppendLiteral(": "); + buf.Append(entry.value); + buf.AppendLiteral("\r\n"); + } +} + +void +nsHttpHeaderArray::FlattenOriginalHeader(nsACString &buf) +{ + uint32_t i, count = mHeaders.Length(); + for (i = 0; i < count; ++i) { + const nsEntry &entry = mHeaders[i]; + // Skip changed header. + if (entry.variety == eVarietyResponse) { + continue; + } + buf.Append(entry.header); buf.AppendLiteral(": "); buf.Append(entry.value); diff --git a/netwerk/protocol/http/nsHttpHeaderArray.h b/netwerk/protocol/http/nsHttpHeaderArray.h index b3d99c1143..cfb6897e01 100644 --- a/netwerk/protocol/http/nsHttpHeaderArray.h +++ b/netwerk/protocol/http/nsHttpHeaderArray.h @@ -26,24 +26,44 @@ class nsHttpHeaderArray public: const char *PeekHeader(nsHttpAtom header) const; + // For nsHttpResponseHead nsHttpHeaderArray will keep track of the original + // headers as they come from the network and the parse headers used in + // firefox. + // If the original and the firefox header are the same, we will keep just + // one copy and marked it as eVarietyResponseNetOriginalAndResponse. + // If firefox header representation changes a header coming from the + // network (e.g. merged it) or a eVarietyResponseNetOriginalAndResponse + // header has been changed by SetHeader method, we will keep the original + // header as eVarietyResponseNetOriginal and make a copy for the new header + // and mark it as eVarietyResponse. enum HeaderVariety { - eVarietyOverride, - eVarietyDefault, + eVarietyUnknown, + // Used only for request header. + eVarietyRequestOverride, + eVarietyRequestDefault, + // Used only for response header. + eVarietyResponseNetOriginalAndResponse, + eVarietyResponseNetOriginal, + eVarietyResponse }; // Used by internal setters: to set header from network use SetHeaderFromNet nsresult SetHeader(nsHttpAtom header, const nsACString &value, - bool merge = false, HeaderVariety variety = eVarietyOverride); + bool merge, HeaderVariety variety); // Used by internal setters to set an empty header - nsresult SetEmptyHeader(nsHttpAtom header); + nsresult SetEmptyHeader(nsHttpAtom header, HeaderVariety variety); // Merges supported headers. For other duplicate values, determines if error // needs to be thrown or 1st value kept. - nsresult SetHeaderFromNet(nsHttpAtom header, const nsACString &value); + // For the response header we keep the original headers as well. + nsresult SetHeaderFromNet(nsHttpAtom header, const nsACString &value, + bool response); nsresult GetHeader(nsHttpAtom header, nsACString &value) const; + nsresult GetOriginalHeader(nsHttpAtom aHeader, + nsIHttpHeaderVisitor *aVisitor); void ClearHeader(nsHttpAtom h); // Find the location of the given header value, or null if none exists. @@ -65,19 +85,20 @@ public: { eFilterAll, eFilterSkipDefault, + eFilterResponse, + eFilterResponseOriginal }; nsresult VisitHeaders(nsIHttpHeaderVisitor *visitor, VisitorFilter filter = eFilterAll); // parse a header line, return the header atom and a pointer to the // header value (the substring of the header line -- do not free). - nsresult ParseHeaderLine(const char *line, - nsHttpAtom *header=nullptr, - char **value=nullptr); + static nsresult ParseHeaderLine(const char *line, + nsHttpAtom *header=nullptr, + char **value=nullptr); - void Flatten(nsACString &, bool pruneProxyHeaders=false); - - void ParseHeaderSet(char *buffer); + void Flatten(nsACString &, bool pruneProxyHeaders, bool pruneTransients); + void FlattenOriginalHeader(nsACString &); uint32_t Count() const { return mHeaders.Length(); } @@ -90,7 +111,7 @@ public: { nsHttpAtom header; nsCString value; - HeaderVariety variety = eVarietyOverride; + HeaderVariety variety = eVarietyUnknown; struct MatchHeader { bool Equals(const nsEntry &entry, const nsHttpAtom &header) const { @@ -110,9 +131,14 @@ public: } private: + // LookupEntry function will never return eVarietyResponseNetOriginal. + // It will ignore original headers from the network. int32_t LookupEntry(nsHttpAtom header, const nsEntry **) const; int32_t LookupEntry(nsHttpAtom header, nsEntry **); - void MergeHeader(nsHttpAtom header, nsEntry *entry, const nsACString &value); + nsresult MergeHeader(nsHttpAtom header, nsEntry *entry, + const nsACString &value, HeaderVariety variety); + nsresult SetHeader_internal(nsHttpAtom header, const nsACString &value, + HeaderVariety variety); // Header cannot be merged: only one value possible bool IsSingletonHeader(nsHttpAtom header); @@ -139,18 +165,35 @@ private: inline int32_t nsHttpHeaderArray::LookupEntry(nsHttpAtom header, const nsEntry **entry) const { - uint32_t index = mHeaders.IndexOf(header, 0, nsEntry::MatchHeader()); - if (index != UINT32_MAX) - *entry = &mHeaders[index]; + uint32_t index = 0; + while (index != UINT32_MAX) { + index = mHeaders.IndexOf(header, index, nsEntry::MatchHeader()); + if (index != UINT32_MAX) { + if ((&mHeaders[index])->variety != eVarietyResponseNetOriginal) { + *entry = &mHeaders[index]; + return index; + } + index++; + } + } + return index; } inline int32_t nsHttpHeaderArray::LookupEntry(nsHttpAtom header, nsEntry **entry) { - uint32_t index = mHeaders.IndexOf(header, 0, nsEntry::MatchHeader()); - if (index != UINT32_MAX) - *entry = &mHeaders[index]; + uint32_t index = 0; + while (index != UINT32_MAX) { + index = mHeaders.IndexOf(header, index, nsEntry::MatchHeader()); + if (index != UINT32_MAX) { + if ((&mHeaders[index])->variety != eVarietyResponseNetOriginal) { + *entry = &mHeaders[index]; + return index; + } + index++; + } + } return index; } @@ -179,15 +222,17 @@ nsHttpHeaderArray::TrackEmptyHeader(nsHttpAtom header) header == nsHttp::Location; } -inline void +inline nsresult nsHttpHeaderArray::MergeHeader(nsHttpAtom header, nsEntry *entry, - const nsACString &value) + const nsACString &value, + nsHttpHeaderArray::HeaderVariety variety) { if (value.IsEmpty()) - return; // merge of empty header = no-op + return NS_OK; // merge of empty header = no-op - if (!entry->value.IsEmpty()) { + nsCString newValue = entry->value; + if (!newValue.IsEmpty()) { // Append the new value to the existing value if (header == nsHttp::Set_Cookie || header == nsHttp::WWW_Authenticate || @@ -196,14 +241,26 @@ nsHttpHeaderArray::MergeHeader(nsHttpAtom header, // Special case these headers and use a newline delimiter to // delimit the values from one another as commas may appear // in the values of these headers contrary to what the spec says. - entry->value.Append('\n'); + newValue.Append('\n'); } else { // Delimit each value from the others using a comma (per HTTP spec) - entry->value.AppendLiteral(", "); + newValue.AppendLiteral(", "); } } - entry->value.Append(value); - entry->variety = eVarietyOverride; + + newValue.Append(value); + if (entry->variety == eVarietyResponseNetOriginalAndResponse) { + MOZ_ASSERT(variety == eVarietyResponse); + entry->variety = eVarietyResponseNetOriginal; + nsresult rv = SetHeader_internal(header, newValue, eVarietyResponse); + if (NS_FAILED(rv)) { + return rv; + } + } else { + entry->value = newValue; + entry->variety = variety; + } + return NS_OK; } inline bool diff --git a/netwerk/protocol/http/nsHttpRequestHead.cpp b/netwerk/protocol/http/nsHttpRequestHead.cpp index 165163e559..abaf0b8e86 100644 --- a/netwerk/protocol/http/nsHttpRequestHead.cpp +++ b/netwerk/protocol/http/nsHttpRequestHead.cpp @@ -129,7 +129,8 @@ nsHttpRequestHead::SetHeader(nsHttpAtom h, const nsACString &v, bool m /*= false*/) { MutexAutoLock lock(mLock); - return mHeaders.SetHeader(h, v, m); + return mHeaders.SetHeader(h, v, m, + nsHttpHeaderArray::eVarietyRequestOverride); } nsresult @@ -144,7 +145,8 @@ nsresult nsHttpRequestHead::SetEmptyHeader(nsHttpAtom h) { MutexAutoLock lock(mLock); - return mHeaders.SetEmptyHeader(h); + return mHeaders.SetEmptyHeader(h, + nsHttpHeaderArray::eVarietyRequestOverride); } nsresult @@ -189,7 +191,8 @@ nsHttpRequestHead::SetHeaderOnce(nsHttpAtom h, const char *v, { MutexAutoLock lock(mLock); if (!merge || !mHeaders.HasHeaderValue(h, v)) { - return mHeaders.SetHeader(h, nsDependentCString(v), merge); + return mHeaders.SetHeader(h, nsDependentCString(v), merge, + nsHttpHeaderArray::eVarietyRequestOverride); } return NS_OK; } @@ -212,7 +215,24 @@ void nsHttpRequestHead::ParseHeaderSet(char *buffer) { MutexAutoLock lock(mLock); - mHeaders.ParseHeaderSet(buffer); + nsHttpAtom hdr; + char *val; + while (buffer) { + char *eof = strchr(buffer, '\r'); + if (!eof) { + break; + } + *eof = '\0'; + if (NS_SUCCEEDED(nsHttpHeaderArray::ParseHeaderLine(buffer, + &hdr, + &val))) { + mHeaders.SetHeaderFromNet(hdr, nsDependentCString(val), false); + } + buffer = eof + 1; + if (*buffer == '\n') { + buffer++; + } + } } bool @@ -304,7 +324,7 @@ nsHttpRequestHead::Flatten(nsACString &buf, bool pruneProxyHeaders) buf.AppendLiteral("\r\n"); - mHeaders.Flatten(buf, pruneProxyHeaders); + mHeaders.Flatten(buf, pruneProxyHeaders, false); } } // namespace net diff --git a/netwerk/protocol/http/nsHttpResponseHead.cpp b/netwerk/protocol/http/nsHttpResponseHead.cpp index 61ae865848..d0cd568e4e 100644 --- a/netwerk/protocol/http/nsHttpResponseHead.cpp +++ b/netwerk/protocol/http/nsHttpResponseHead.cpp @@ -26,7 +26,8 @@ nsHttpResponseHead::SetHeader(nsHttpAtom hdr, const nsACString &val, bool merge) { - nsresult rv = mHeaders.SetHeader(hdr, val, merge); + nsresult rv = mHeaders.SetHeader(hdr, val, merge, + nsHttpHeaderArray::eVarietyResponse); if (NS_FAILED(rv)) return rv; // respond to changes in these headers. we need to reparse the entire @@ -46,7 +47,10 @@ nsHttpResponseHead::SetContentLength(int64_t len) if (len < 0) mHeaders.ClearHeader(nsHttp::Content_Length); else - mHeaders.SetHeader(nsHttp::Content_Length, nsPrintfCString("%lld", len)); + mHeaders.SetHeader(nsHttp::Content_Length, + nsPrintfCString("%lld", len), + false, + nsHttpHeaderArray::eVarietyResponse); } void @@ -68,37 +72,21 @@ nsHttpResponseHead::Flatten(nsACString &buf, bool pruneTransients) mStatusText + NS_LITERAL_CSTRING("\r\n")); - if (!pruneTransients) { - mHeaders.Flatten(buf, false); + + mHeaders.Flatten(buf, false, pruneTransients); +} + +void +nsHttpResponseHead::FlattenOriginalHeader(nsACString &buf) +{ + if (mVersion == NS_HTTP_VERSION_0_9) { return; } - // otherwise, we need to iterate over the headers and only flatten - // those that are appropriate. - uint32_t i, count = mHeaders.Count(); - for (i=0; iFlatten(headers, false); + mResponseHead->FlattenOriginalHeader(headers); LogHeaders(headers.get()); LOG3(("]\n")); } diff --git a/netwerk/protocol/http/nsIHttpChannel.idl b/netwerk/protocol/http/nsIHttpChannel.idl index b73e51deab..2f808d250e 100644 --- a/netwerk/protocol/http/nsIHttpChannel.idl +++ b/netwerk/protocol/http/nsIHttpChannel.idl @@ -344,6 +344,39 @@ interface nsIHttpChannel : nsIChannel */ void visitResponseHeaders(in nsIHttpHeaderVisitor aVisitor); + /** + * Get the value(s) of a particular response header in the form and order + * it has been received from the remote peer. There can be multiple headers + * with the same name. + * + * @param aHeader + * The case-insensitive name of the response header to query (e.g., + * "Set-Cookie"). + * + * @param aVisitor + * the header visitor instance. + * + * @throws NS_ERROR_NOT_AVAILABLE if called before the response + * has been received (before onStartRequest) or if the header is + * not set in the response. + */ + void getOriginalResponseHeader(in ACString aHeader, + in nsIHttpHeaderVisitor aVisitor); + + /** + * Call this method to visit all response headers in the form and order as + * they have been received from the remote peer. + * Calling setResponseHeader while visiting response headers has undefined + * behavior. Don't do it! + * + * @param aVisitor + * the header visitor instance. + * + * @throws NS_ERROR_NOT_AVAILABLE if called before the response + * has been received (before onStartRequest). + */ + void visitOriginalResponseHeaders(in nsIHttpHeaderVisitor aVisitor); + /** * Returns true if the server sent a "Cache-Control: no-store" response * header. diff --git a/netwerk/protocol/viewsource/nsViewSourceChannel.cpp b/netwerk/protocol/viewsource/nsViewSourceChannel.cpp index 7d96a94477..8805cde7a1 100644 --- a/netwerk/protocol/viewsource/nsViewSourceChannel.cpp +++ b/netwerk/protocol/viewsource/nsViewSourceChannel.cpp @@ -905,6 +905,25 @@ nsViewSourceChannel::VisitResponseHeaders(nsIHttpHeaderVisitor *aVisitor) return NS_OK; } +NS_IMETHODIMP +nsViewSourceChannel::GetOriginalResponseHeader(const nsACString & aHeader, + nsIHttpHeaderVisitor *aVisitor) +{ + nsAutoCString value; + nsresult rv = GetResponseHeader(aHeader, value); + if (NS_FAILED(rv)) { + return rv; + } + aVisitor->VisitHeader(aHeader, value); + return NS_OK; +} + +NS_IMETHODIMP +nsViewSourceChannel::VisitOriginalResponseHeaders(nsIHttpHeaderVisitor *aVisitor) +{ + return VisitResponseHeaders(aVisitor); +} + NS_IMETHODIMP nsViewSourceChannel::IsNoStoreResponse(bool *_retval) { diff --git a/netwerk/protocol/websocket/WebSocketFrame.cpp b/netwerk/protocol/websocket/WebSocketFrame.cpp index 19ef7be73f..b93729b3f6 100644 --- a/netwerk/protocol/websocket/WebSocketFrame.cpp +++ b/netwerk/protocol/websocket/WebSocketFrame.cpp @@ -137,7 +137,7 @@ WebSocketFrameData::WriteIPCParams(IPC::Message* aMessage) const bool WebSocketFrameData::ReadIPCParams(const IPC::Message* aMessage, - void** aIter) + PickleIterator* aIter) { if (!ReadParam(aMessage, aIter, &mTimeStamp)) { return false; diff --git a/netwerk/protocol/websocket/WebSocketFrame.h b/netwerk/protocol/websocket/WebSocketFrame.h index 56f1a27e9a..28c98466ea 100644 --- a/netwerk/protocol/websocket/WebSocketFrame.h +++ b/netwerk/protocol/websocket/WebSocketFrame.h @@ -34,7 +34,7 @@ public: // For IPC serialization void WriteIPCParams(IPC::Message* aMessage) const; - bool ReadIPCParams(const IPC::Message* aMessage, void** aIter); + bool ReadIPCParams(const IPC::Message* aMessage, PickleIterator* aIter); DOMHighResTimeStamp mTimeStamp; diff --git a/netwerk/streamconv/converters/nsMultiMixedConv.cpp b/netwerk/streamconv/converters/nsMultiMixedConv.cpp index 5bb224a65b..0619af5272 100644 --- a/netwerk/streamconv/converters/nsMultiMixedConv.cpp +++ b/netwerk/streamconv/converters/nsMultiMixedConv.cpp @@ -19,6 +19,7 @@ #include "nsHttp.h" #include "nsNetUtil.h" #include "nsIURI.h" +#include "nsHttpHeaderArray.h" // // Helper function for determining the length of data bytes up to @@ -420,7 +421,8 @@ nsPartChannel::VisitResponseHeaders(nsIHttpHeaderVisitor *visitor) { if (!mResponseHead) return NS_ERROR_NOT_AVAILABLE; - return mResponseHead->Headers().VisitHeaders(visitor); + return mResponseHead->Headers().VisitHeaders(visitor, + mozilla::net::nsHttpHeaderArray::eFilterResponse); } // diff --git a/netwerk/test/httpserver/httpd.js b/netwerk/test/httpserver/httpd.js index c72e47f50b..5542adfc2e 100644 --- a/netwerk/test/httpserver/httpd.js +++ b/netwerk/test/httpserver/httpd.js @@ -3701,6 +3701,15 @@ Response.prototype = this._headers.setHeader(name, value, merge); }, + setHeaderNoCheck: function(name, value) + { + if (!this._headers || this._finished || this._powerSeized) + throw Cr.NS_ERROR_NOT_AVAILABLE; + this._ensureAlive(); + + this._headers.setHeaderNoCheck(name, value); + }, + // // see nsIHttpResponse.processAsync // @@ -4989,6 +4998,17 @@ nsHttpHeaders.prototype = } }, + setHeaderNoCheck: function(fieldName, fieldValue) + { + var name = headerUtils.normalizeFieldName(fieldName); + var value = headerUtils.normalizeFieldValue(fieldValue); + if (name in this._headers) { + this._headers[name].push(fieldValue); + } else { + this._headers[name] = [fieldValue]; + } + }, + /** * Returns the value for the header specified by this. * diff --git a/netwerk/test/httpserver/nsIHttpServer.idl b/netwerk/test/httpserver/nsIHttpServer.idl index 6a321f35a7..97192a2d60 100644 --- a/netwerk/test/httpserver/nsIHttpServer.idl +++ b/netwerk/test/httpserver/nsIHttpServer.idl @@ -529,6 +529,12 @@ interface nsIHttpResponse : nsISupports */ void setHeader(in string name, in string value, in boolean merge); + /** + * This is used for testing our header handling, so header will be sent out + * without transformation. There can be multiple headers. + */ + void setHeaderNoCheck(in string name, in string value); + /** * A stream to which data appearing in the body of this response (or in the * totality of the response if seizePower() is called) should be written. diff --git a/security/manager/ssl/tests/unit/test_client_cert/cert_dialog.js b/netwerk/test/unit/client_cert_chooser.js similarity index 72% rename from security/manager/ssl/tests/unit/test_client_cert/cert_dialog.js rename to netwerk/test/unit/client_cert_chooser.js index 96087cccef..228dc86a7e 100644 --- a/security/manager/ssl/tests/unit/test_client_cert/cert_dialog.js +++ b/netwerk/test/unit/client_cert_chooser.js @@ -6,16 +6,6 @@ const { utils: Cu, interfaces: Ci } = Components; const { XPCOMUtils } = Cu.import("resource://gre/modules/XPCOMUtils.jsm", {}); -function CertDialogService() {} -CertDialogService.prototype = { - classID: Components.ID("{a70153f2-3590-4317-93e9-73b3e7ffca5d}"), - QueryInterface: XPCOMUtils.generateQI([Ci.nsICertificateDialogs]), - - getPKCS12FilePassword: function() { - return true; // Simulates entering an empty password - } -}; - let Prompter = { QueryInterface: XPCOMUtils.generateQI([Ci.nsIPrompt]), alert: function() {} // Do nothing when asked to show an alert @@ -32,6 +22,5 @@ WindowWatcherService.prototype = { }; this.NSGetFactory = XPCOMUtils.generateNSGetFactory([ - CertDialogService, WindowWatcherService ]); diff --git a/security/manager/ssl/tests/unit/test_client_cert/cert_dialog.manifest b/netwerk/test/unit/client_cert_chooser.manifest similarity index 50% rename from security/manager/ssl/tests/unit/test_client_cert/cert_dialog.manifest rename to netwerk/test/unit/client_cert_chooser.manifest index 91c2c579f4..e604c92d0e 100644 --- a/security/manager/ssl/tests/unit/test_client_cert/cert_dialog.manifest +++ b/netwerk/test/unit/client_cert_chooser.manifest @@ -1,4 +1,2 @@ -component {a70153f2-3590-4317-93e9-73b3e7ffca5d} cert_dialog.js -contract @mozilla.org/nsCertificateDialogs;1 {a70153f2-3590-4317-93e9-73b3e7ffca5d} component {01ae923c-81bb-45db-b860-d423b0fc4fe1} cert_dialog.js contract @mozilla.org/embedcomp/window-watcher;1 {01ae923c-81bb-45db-b860-d423b0fc4fe1} diff --git a/netwerk/test/unit/test_immutable.js b/netwerk/test/unit/test_immutable.js new file mode 100644 index 0000000000..d3438bbe11 --- /dev/null +++ b/netwerk/test/unit/test_immutable.js @@ -0,0 +1,180 @@ +Cu.import("resource://testing-common/httpd.js"); +Cu.import("resource://gre/modules/NetUtil.jsm"); + +var prefs; +var spdypref; +var http2pref; +var tlspref; +var origin; + +function run_test() { + var env = Cc["@mozilla.org/process/environment;1"].getService(Ci.nsIEnvironment); + var h2Port = env.get("MOZHTTP2_PORT"); + do_check_neq(h2Port, null); + do_check_neq(h2Port, ""); + + // Set to allow the cert presented by our H2 server + do_get_profile(); + prefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch); + + spdypref = prefs.getBoolPref("network.http.spdy.enabled"); + http2pref = prefs.getBoolPref("network.http.spdy.enabled.http2"); + tlspref = prefs.getBoolPref("network.http.spdy.enforce-tls-profile"); + + prefs.setBoolPref("network.http.spdy.enabled", true); + prefs.setBoolPref("network.http.spdy.enabled.http2", true); + prefs.setBoolPref("network.http.spdy.enforce-tls-profile", false); + prefs.setCharPref("network.dns.localDomains", "foo.example.com, bar.example.com"); + + // The moz-http2 cert is for foo.example.com and is signed by CA.cert.der + // so add that cert to the trust list as a signing cert. // the foo.example.com domain name. + let certdb = Cc["@mozilla.org/security/x509certdb;1"] + .getService(Ci.nsIX509CertDB); + addCertFromFile(certdb, "CA.cert.der", "CTu,u,u"); + + origin = "https://foo.example.com:" + h2Port; + dump ("origin - " + origin + "\n"); + doTest1(); +} + +function resetPrefs() { + prefs.setBoolPref("network.http.spdy.enabled", spdypref); + prefs.setBoolPref("network.http.spdy.enabled.http2", http2pref); + prefs.setBoolPref("network.http.spdy.enforce-tls-profile", tlspref); + prefs.clearUserPref("network.dns.localDomains"); +} + +function readFile(file) { + let fstream = Cc["@mozilla.org/network/file-input-stream;1"] + .createInstance(Ci.nsIFileInputStream); + fstream.init(file, -1, 0, 0); + let data = NetUtil.readInputStreamToString(fstream, fstream.available()); + fstream.close(); + return data; +} + +function addCertFromFile(certdb, filename, trustString) { + let certFile = do_get_file(filename, false); + let der = readFile(certFile); + certdb.addCert(der, trustString, null); +} + +function makeChan(origin, path) { + return NetUtil.newChannel({ + uri: origin + path, + loadUsingSystemPrincipal: true + }).QueryInterface(Ci.nsIHttpChannel); +} + +var nextTest; +var expectPass = true; +var expectConditional = false; + +var Listener = function() {}; +Listener.prototype = { + onStartRequest: function testOnStartRequest(request, ctx) { + do_check_true(request instanceof Components.interfaces.nsIHttpChannel); + + if (expectPass) { + if (!Components.isSuccessCode(request.status)) { + do_throw("Channel should have a success code! (" + request.status + ")"); + } + do_check_eq(request.responseStatus, 200); + } else { + do_check_eq(Components.isSuccessCode(request.status), false); + } + }, + + onDataAvailable: function testOnDataAvailable(request, ctx, stream, off, cnt) { + read_stream(stream, cnt); + }, + + onStopRequest: function testOnStopRequest(request, ctx, status) { + if (expectConditional) { + do_check_eq(request.getResponseHeader("x-conditional"), "true"); + } else { + try { do_check_neq(request.getResponseHeader("x-conditional"), "true"); } + catch (e) { do_check_true(true); } + } + nextTest(); + do_test_finished(); + } +}; + +function testsDone() +{ + dump("testDone\n"); + resetPrefs(); +} + +function doTest1() +{ + dump("execute doTest1 - resource without immutable. initial request\n"); + do_test_pending(); + expectConditional = false; + var chan = makeChan(origin, "/immutable-test-without-attribute"); + var listener = new Listener(); + nextTest = doTest2; + chan.asyncOpen2(listener); +} + +function doTest2() +{ + dump("execute doTest2 - resource without immutable. reload\n"); + do_test_pending(); + expectConditional = true; + var chan = makeChan(origin, "/immutable-test-without-attribute"); + var listener = new Listener(); + nextTest = doTest3; + chan.loadFlags = Ci.nsIRequest.VALIDATE_ALWAYS; + chan.asyncOpen2(listener); +} + +function doTest3() +{ + dump("execute doTest3 - resource without immutable. shift reload\n"); + do_test_pending(); + expectConditional = false; + var chan = makeChan(origin, "/immutable-test-without-attribute"); + var listener = new Listener(); + nextTest = doTest4; + chan.loadFlags = Ci.nsIRequest.LOAD_BYPASS_CACHE; + chan.asyncOpen2(listener); +} + +function doTest4() +{ + dump("execute doTest1 - resource with immutable. initial request\n"); + do_test_pending(); + expectConditional = false; + var chan = makeChan(origin, "/immutable-test-with-attribute"); + var listener = new Listener(); + nextTest = doTest5; + chan.asyncOpen2(listener); +} + +function doTest5() +{ + dump("execute doTest5 - resource with immutable. reload\n"); + do_test_pending(); + expectConditional = false; + var chan = makeChan(origin, "/immutable-test-with-attribute"); + var listener = new Listener(); + nextTest = doTest6; + chan.loadFlags = Ci.nsIRequest.VALIDATE_ALWAYS; + chan.asyncOpen2(listener); +} + +function doTest6() +{ + dump("execute doTest3 - resource with immutable. shift reload\n"); + do_test_pending(); + expectConditional = false; + var chan = makeChan(origin, "/immutable-test-with-attribute"); + var listener = new Listener(); + nextTest = testsDone; + chan.loadFlags = Ci.nsIRequest.LOAD_BYPASS_CACHE; + chan.asyncOpen2(listener); +} + + diff --git a/netwerk/test/unit/test_original_sent_received_head.js b/netwerk/test/unit/test_original_sent_received_head.js new file mode 100644 index 0000000000..7187d84dcd --- /dev/null +++ b/netwerk/test/unit/test_original_sent_received_head.js @@ -0,0 +1,189 @@ +// +// HTTP headers test +// Response headers can be changed after they have been received, e.g. empty +// headers are deleted, some duplicate header are merged (if no error is +// thrown), etc. +// +// The "original header" is introduced to hold the header array in the order +// and the form as they have been received from the network. +// Here, the "original headers" are tested. +// + +// Note: sets Cc and Ci variables + +Cu.import("resource://testing-common/httpd.js"); +Cu.import("resource://gre/modules/NetUtil.jsm"); + +XPCOMUtils.defineLazyGetter(this, "URL", function() { + return "http://localhost:" + httpserver.identity.primaryPort; +}); + +var httpserver = new HttpServer(); +var testpath = "/simple"; +var httpbody = "0123456789"; +var channel; +var ios; + +var dbg=1 +if (dbg) { print("============== START =========="); } + +function run_test() { + setup_test(); + do_test_pending(); +} + +function setup_test() { + if (dbg) { print("============== setup_test: in"); } + + httpserver.registerPathHandler(testpath, serverHandler); + httpserver.start(-1); + + channel = setupChannel(testpath); + + // ChannelListener defined in head_channels.js + channel.asyncOpen(new ChannelListener(checkResponse, channel), null); + + if (dbg) { print("============== setup_test: out"); } +} + +function setupChannel(path) { + var chan = NetUtil.newChannel ({ + uri: URL + path, + loadUsingSystemPrincipal: true + }).QueryInterface(Components.interfaces.nsIHttpChannel); + chan.requestMethod = "GET"; + return chan; +} + +function serverHandler(metadata, response) { + if (dbg) { print("============== serverHandler: in"); } + + response.setHeader("Content-Type", "text/plain", false); + response.setStatusLine("1.1", 200, "OK"); + + // Set a empty header. A empty link header will not appear in header list, + // but in the "original headers", it will be still exactly as received. + response.setHeaderNoCheck("Link", "", true); + response.setHeaderNoCheck("Link", "value1"); + response.setHeaderNoCheck("Link", "value2"); + response.setHeaderNoCheck("Location", "loc"); + response.bodyOutputStream.write(httpbody, httpbody.length); + + if (dbg) { print("============== serverHandler: out"); } +} + +function checkResponse(request, data, context) { + if (dbg) { print("============== checkResponse: in"); } + + do_check_eq(channel.responseStatus, 200); + do_check_eq(channel.responseStatusText, "OK"); + do_check_true(channel.requestSucceeded); + + // Response header have only one link header. + var linkHeaderFound = 0; + var locationHeaderFound = 0; + channel.visitResponseHeaders({ + visitHeader: function visit(aName, aValue) { + if (aName == "Link") { + linkHeaderFound++; + do_check_eq(aValue, "value1, value2"); + } + if (aName == "Location") { + locationHeaderFound++; + do_check_eq(aValue, "loc"); + } + } + }); + do_check_eq(linkHeaderFound, 1); + do_check_eq(locationHeaderFound, 1); + + // The "original header" still contains 3 link headers. + var linkOrgHeaderFound = 0; + var locationOrgHeaderFound = 0; + channel.visitOriginalResponseHeaders({ + visitHeader: function visitOrg(aName, aValue) { + if (aName == "Link") { + if (linkOrgHeaderFound == 0) { + do_check_eq(aValue, ""); + } else if (linkOrgHeaderFound == 1 ) { + do_check_eq(aValue, "value1"); + } else { + do_check_eq(aValue, "value2"); + } + linkOrgHeaderFound++; + } + if (aName == "Location") { + locationOrgHeaderFound++; + do_check_eq(aValue, "loc"); + } + } + }); + do_check_eq(linkOrgHeaderFound, 3); + do_check_eq(locationOrgHeaderFound, 1); + + if (dbg) { print("============== Remove headers"); } + // Remove header. + channel.setResponseHeader("Link", "", false); + channel.setResponseHeader("Location", "", false); + + var linkHeaderFound2 = false; + var locationHeaderFound2 = 0; + channel.visitResponseHeaders({ + visitHeader: function visit(aName, aValue) { + if (aName == "Link") { + linkHeaderFound2 = true; + } + if (aName == "Location") { + locationHeaderFound2 = true; + } + } + }); + do_check_false(linkHeaderFound2, "There should be no link header"); + do_check_false(locationHeaderFound2, "There should be no location headers."); + + // The "original header" still contains the empty header. + var linkOrgHeaderFound2 = 0; + var locationOrgHeaderFound2 = 0; + channel.visitOriginalResponseHeaders({ + visitHeader: function visitOrg(aName, aValue) { + if (aName == "Link") { + if (linkOrgHeaderFound2 == 0) { + do_check_eq(aValue, ""); + } else if (linkOrgHeaderFound2 == 1 ) { + do_check_eq(aValue, "value1"); + } else { + do_check_eq(aValue, "value2"); + } + linkOrgHeaderFound2++; + } + if (aName == "Location") { + locationOrgHeaderFound2++; + do_check_eq(aValue, "loc"); + } + } + }); + do_check_true(linkOrgHeaderFound2 == 3, + "Original link header still here."); + do_check_true(locationOrgHeaderFound2 == 1, + "Original location header still here."); + + if (dbg) { print("============== Test GetResponseHeader"); } + var linkOrgHeaderFound3 = 0; + channel.getOriginalResponseHeader("Link",{ + visitHeader: function visitOrg(aName, aValue) { + if (linkOrgHeaderFound3 == 0) { + do_check_eq(aValue, ""); + } else if (linkOrgHeaderFound3 == 1 ) { + do_check_eq(aValue, "value1"); + } else { + do_check_eq(aValue, "value2"); + } + linkOrgHeaderFound3++; + } + }); + do_check_true(linkOrgHeaderFound2 == 3, + "Original link header still here."); + + httpserver.stop(do_test_finished); + if (dbg) { print("============== checkResponse: out"); } +} diff --git a/netwerk/test/unit/test_tls_server.js b/netwerk/test/unit/test_tls_server.js index 06abfdc5bb..38bc13a9a0 100644 --- a/netwerk/test/unit/test_tls_server.js +++ b/netwerk/test/unit/test_tls_server.js @@ -38,7 +38,7 @@ function getCert() { return deferred.promise; } -function startServer(cert) { +function startServer(cert, expectingPeerCert, clientCertificateConfig) { let tlsServer = Cc["@mozilla.org/network/tls-server-socket;1"] .createInstance(Ci.nsITLSServerSocket); tlsServer.init(-1, true, -1); @@ -57,8 +57,12 @@ function startServer(cert) { }, onHandshakeDone: function(socket, status) { do_print("TLS handshake done"); - ok(!!status.peerCert, "Has peer cert"); - ok(status.peerCert.equals(cert), "Peer cert matches expected cert"); + if (expectingPeerCert) { + ok(!!status.peerCert, "Has peer cert"); + ok(status.peerCert.equals(cert), "Peer cert matches expected cert"); + } else { + ok(!status.peerCert, "No peer cert (as expected)"); + } equal(status.tlsVersionUsed, Ci.nsITLSClientStatus.TLS_VERSION_1_2, "Using TLS 1.2"); @@ -84,7 +88,7 @@ function startServer(cert) { tlsServer.setSessionCache(false); tlsServer.setSessionTickets(false); - tlsServer.setRequestClientCertificate(Ci.nsITLSServerSocket.REQUIRE_ALWAYS); + tlsServer.setRequestClientCertificate(clientCertificateConfig); tlsServer.asyncListen(listener); @@ -98,7 +102,9 @@ function storeCertOverride(port, cert) { overrideBits, true); } -function startClient(port, cert) { +function startClient(port, cert, expectingBadCertAlert) { + let SSL_ERROR_BASE = Ci.nsINSSErrorsService.NSS_SSL_ERROR_BASE; + let SSL_ERROR_BAD_CERT_ALERT = SSL_ERROR_BASE + 17; let transport = socketTransportService.createTransport(["ssl"], 1, "127.0.0.1", port, null); let input; @@ -123,22 +129,23 @@ function startClient(port, cert) { output.close(); inputDeferred.resolve(); } catch (e) { - let SEC_ERROR_BASE = Ci.nsINSSErrorsService.NSS_SEC_ERROR_BASE; - let SEC_ERROR_UNKNOWN_ISSUER = SEC_ERROR_BASE + 13; let errorCode = -1 * (e.result & 0xFFFF); - if (errorCode == SEC_ERROR_UNKNOWN_ISSUER) { - do_print("Client doesn't like server cert"); + if (expectingBadCertAlert && errorCode == SSL_ERROR_BAD_CERT_ALERT) { + inputDeferred.resolve(); + } else { + inputDeferred.reject(e); } - inputDeferred.reject(e); } }, onOutputStreamReady: function(output) { try { - // Set the cert we want to avoid any cert UI prompts - let clientSecInfo = transport.securityInfo; - let tlsControl = clientSecInfo.QueryInterface(Ci.nsISSLSocketControl); - tlsControl.clientCert = cert; + // Set the client certificate as appropriate. + if (cert) { + let clientSecInfo = transport.securityInfo; + let tlsControl = clientSecInfo.QueryInterface(Ci.nsISSLSocketControl); + tlsControl.clientCert = cert; + } output.write("HELLO", 5); do_print("Output to server written"); @@ -146,8 +153,6 @@ function startClient(port, cert) { input = transport.openInputStream(0, 0, 0); input.asyncWait(handler, 0, 0, Services.tm.currentThread); } catch (e) { - let SSL_ERROR_BASE = Ci.nsINSSErrorsService.NSS_SSL_ERROR_BASE; - let SSL_ERROR_BAD_CERT_ALERT = SSL_ERROR_BASE + 17; let errorCode = -1 * (e.result & 0xFFFF); if (errorCode == SSL_ERROR_BAD_CERT_ALERT) { do_print("Server doesn't like client cert"); @@ -164,10 +169,53 @@ function startClient(port, cert) { return promise.all([inputDeferred.promise, outputDeferred.promise]); } +// Replace the UI dialog that prompts the user to pick a client certificate. +do_load_manifest("client_cert_chooser.manifest"); + add_task(function*() { let cert = yield getCert(); ok(!!cert, "Got self-signed cert"); - let port = startServer(cert); + let port = startServer(cert, true, Ci.nsITLSServerSocket.REQUIRE_ALWAYS); storeCertOverride(port, cert); - yield startClient(port, cert); + yield startClient(port, cert, false); +}); + +add_task(function*() { + let cert = yield getCert(); + ok(!!cert, "Got self-signed cert"); + let port = startServer(cert, true, Ci.nsITLSServerSocket.REQUIRE_ALWAYS); + storeCertOverride(port, cert); + yield startClient(port, null, true); +}); + +add_task(function*() { + let cert = yield getCert(); + ok(!!cert, "Got self-signed cert"); + let port = startServer(cert, true, Ci.nsITLSServerSocket.REQUEST_ALWAYS); + storeCertOverride(port, cert); + yield startClient(port, cert, false); +}); + +add_task(function*() { + let cert = yield getCert(); + ok(!!cert, "Got self-signed cert"); + let port = startServer(cert, false, Ci.nsITLSServerSocket.REQUEST_ALWAYS); + storeCertOverride(port, cert); + yield startClient(port, null, false); +}); + +add_task(function*() { + let cert = yield getCert(); + ok(!!cert, "Got self-signed cert"); + let port = startServer(cert, false, Ci.nsITLSServerSocket.REQUEST_NEVER); + storeCertOverride(port, cert); + yield startClient(port, cert, false); +}); + +add_task(function*() { + let cert = yield getCert(); + ok(!!cert, "Got self-signed cert"); + let port = startServer(cert, false, Ci.nsITLSServerSocket.REQUEST_NEVER); + storeCertOverride(port, cert); + yield startClient(port, null, false); }); diff --git a/netwerk/test/unit/xpcshell.ini b/netwerk/test/unit/xpcshell.ini index 76afcbd9bc..7b20efa51f 100644 --- a/netwerk/test/unit/xpcshell.ini +++ b/netwerk/test/unit/xpcshell.ini @@ -4,6 +4,8 @@ tail = skip-if = toolkit == 'gonk' support-files = CA.cert.der + client_cert_chooser.js + client_cert_chooser.manifest data/image.png data/system_root.lnk data/test_psl.txt @@ -224,6 +226,9 @@ skip-if = bits != 32 [test_idna2008.js] # IDNA2008 depends on ICU, not available on android skip-if = os == "android" +[test_immutable.js] +skip-if = !hasNode +run-sequentially = node server exceptions dont replay well [test_invalidport.js] [test_localstreams.js] [test_mismatch_last-modified.js] @@ -238,7 +243,7 @@ skip-if = os == "android" skip-if = os == "win" [test_nojsredir.js] [test_offline_status.js] -[test_pac_generator.js] +[test_original_sent_received_head.js] [test_parse_content_type.js] [test_permmgr.js] [test_plaintext_sniff.js] diff --git a/netwerk/test/unit_ipc/test_original_sent_received_head_wrap.js b/netwerk/test/unit_ipc/test_original_sent_received_head_wrap.js new file mode 100644 index 0000000000..91a8a00f09 --- /dev/null +++ b/netwerk/test/unit_ipc/test_original_sent_received_head_wrap.js @@ -0,0 +1,7 @@ +// +// Run test script in content process instead of chrome (xpcshell's default) +// + +function run_test() { + run_test_in_child("../unit/test_original_sent_received_head.js"); +} diff --git a/netwerk/test/unit_ipc/xpcshell.ini b/netwerk/test/unit_ipc/xpcshell.ini index 5f8292ab4b..7f8c8b7201 100644 --- a/netwerk/test/unit_ipc/xpcshell.ini +++ b/netwerk/test/unit_ipc/xpcshell.ini @@ -93,3 +93,4 @@ skip-if = true [test_app_offline_http.js] [test_getHost_wrap.js] [test_app_offline_notifications.js] +[test_original_sent_received_head_wrap.js] diff --git a/security/manager/ssl/tests/unit/test_client_cert.js b/security/manager/ssl/tests/unit/test_client_cert.js deleted file mode 100644 index 6a8d3d006f..0000000000 --- a/security/manager/ssl/tests/unit/test_client_cert.js +++ /dev/null @@ -1,68 +0,0 @@ -// -*- indent-tabs-mode: nil; js-indent-level: 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/. -"use strict"; - -// Tests specifying a particular client cert to use via the nsISSLSocketControl -// |clientCert| attribute prior to connecting to the server. - -function run_test() { - do_get_profile(); - - // Init key token (to prevent password prompt) - const tokenDB = Cc["@mozilla.org/security/pk11tokendb;1"] - .getService(Ci.nsIPK11TokenDB); - let keyToken = tokenDB.getInternalKeyToken(); - if (keyToken.needsUserInit) { - keyToken.initPassword(""); - } - - // Replace the UI dialog that would prompt for the following PKCS #12 file's - // password, as well as an alert that appears after it succeeds. - do_load_manifest("test_client_cert/cert_dialog.manifest"); - - // Load the user cert and look it up in XPCOM format - const certDB = Cc["@mozilla.org/security/x509certdb;1"] - .getService(Ci.nsIX509CertDB); - let clientCertFile = do_get_file("test_client_cert/client-cert.p12", false); - certDB.importPKCS12File(null, clientCertFile); - - // Find the cert by its common name - let clientCert; - let certs = certDB.getCerts().getEnumerator(); - while (certs.hasMoreElements()) { - let cert = certs.getNext().QueryInterface(Ci.nsIX509Cert); - if (cert.certType === Ci.nsIX509Cert.USER_CERT && - cert.commonName === "client-cert") { - clientCert = cert; - break; - } - } - ok(clientCert, "Client cert found"); - - add_tls_server_setup("ClientAuthServer"); - - add_connection_test("noclientauth.example.com", PRErrorCodeSuccess); - - add_connection_test("requestclientauth.example.com", PRErrorCodeSuccess); - add_connection_test("requestclientauth.example.com", PRErrorCodeSuccess, - null, null, transport => { - do_print("Setting client cert on transport"); - let sslSocketControl = transport.securityInfo - .QueryInterface(Ci.nsISSLSocketControl); - sslSocketControl.clientCert = clientCert; - }); - - add_connection_test("requireclientauth.example.com", - SSL_ERROR_BAD_CERT_ALERT); - add_connection_test("requireclientauth.example.com", PRErrorCodeSuccess, - null, null, transport => { - do_print("Setting client cert on transport"); - let sslSocketControl = - transport.securityInfo.QueryInterface(Ci.nsISSLSocketControl); - sslSocketControl.clientCert = clientCert; - }); - - run_next_test(); -} diff --git a/security/manager/ssl/tests/unit/test_client_cert/client-cert.p12 b/security/manager/ssl/tests/unit/test_client_cert/client-cert.p12 deleted file mode 100644 index cb939cb0f4..0000000000 Binary files a/security/manager/ssl/tests/unit/test_client_cert/client-cert.p12 and /dev/null differ diff --git a/security/manager/ssl/tests/unit/test_client_cert/generate.py b/security/manager/ssl/tests/unit/test_client_cert/generate.py deleted file mode 100755 index 7ef0c8658d..0000000000 --- a/security/manager/ssl/tests/unit/test_client_cert/generate.py +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/python -# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*- -# vim: set filetype=python - -# 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/. - -import tempfile, os, sys, random - -libpath = os.path.abspath("../psm_common_py") -sys.path.append(libpath) - -import CertUtils - -dest_dir = os.getcwd() -db = tempfile.mkdtemp() - -serial = random.randint(100, 40000000) -name = "client-cert" -[key, cert] = CertUtils.generate_cert_generic(db, dest_dir, serial, "rsa", - name, "") -CertUtils.generate_pkcs12(db, dest_dir, cert, key, name) - -# Print a blank line and the fingerprint of the cert that ClientAuthServer.cpp -# should be modified with. -print -CertUtils.print_cert_info(cert) -print ('You now MUST update the fingerprint in ClientAuthServer.cpp to match ' + - 'the fingerprint printed above.') - -# Remove unnecessary .der file -os.remove(dest_dir + "/" + name + ".der") diff --git a/security/manager/ssl/tests/unit/tlsserver/cmd/ClientAuthServer.cpp b/security/manager/ssl/tests/unit/tlsserver/cmd/ClientAuthServer.cpp deleted file mode 100644 index 2a7843e290..0000000000 --- a/security/manager/ssl/tests/unit/tlsserver/cmd/ClientAuthServer.cpp +++ /dev/null @@ -1,116 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=2 sw=2 tw=80 et: */ -/* 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/. */ - -// This is a standalone server for testing client cert authentication. -// The client is expected to connect, initiate an SSL handshake (with SNI -// to indicate which "server" to connect to), and verify the certificate. -// If all is good, the client then sends one encrypted byte and receives that -// same byte back. -// This server also has the ability to "call back" another process waiting on -// it. That is, when the server is all set up and ready to receive connections, -// it will connect to a specified port and issue a simple HTTP request. - -#include - -#include "hasht.h" -#include "ScopedNSSTypes.h" -#include "ssl.h" -#include "TLSServer.h" - -using namespace mozilla; -using namespace mozilla::test; - -struct ClientAuthHost -{ - const char *mHostName; - bool mRequestClientAuth; - bool mRequireClientAuth; -}; - -// Hostname, cert nickname pairs. -static const ClientAuthHost sClientAuthHosts[] = -{ - { "noclientauth.example.com", false, false }, - { "requestclientauth.example.com", true, false }, - { "requireclientauth.example.com", true, true }, - { nullptr, false, false } -}; - -static const unsigned char sClientCertFingerprint[] = -{ - 0xD2, 0x2F, 0x00, 0x9A, 0x9E, 0xED, 0x79, 0xDC, - 0x8D, 0x17, 0x98, 0x8E, 0xEC, 0x76, 0x05, 0x91, - 0xA5, 0xF6, 0xC9, 0xFA, 0x16, 0x8B, 0xD2, 0x5F, - 0xE1, 0x52, 0x04, 0x7C, 0xF4, 0x76, 0x42, 0x9D -}; - -SECStatus -AuthCertificateHook(void* arg, PRFileDesc* fd, PRBool checkSig, - PRBool isServer) -{ - ScopedCERTCertificate clientCert(SSL_PeerCertificate(fd)); - - unsigned char certFingerprint[SHA256_LENGTH]; - SECStatus rv = PK11_HashBuf(SEC_OID_SHA256, certFingerprint, - clientCert->derCert.data, - clientCert->derCert.len); - if (rv != SECSuccess) { - return rv; - } - - static_assert(sizeof(sClientCertFingerprint) == SHA256_LENGTH, - "Ensure fingerprint has corrent length"); - bool match = !memcmp(certFingerprint, sClientCertFingerprint, - sizeof(certFingerprint)); - return match ? SECSuccess : SECFailure; -} - -int32_t -DoSNISocketConfig(PRFileDesc* aFd, const SECItem* aSrvNameArr, - uint32_t aSrvNameArrSize, void* aArg) -{ - const ClientAuthHost *host = GetHostForSNI(aSrvNameArr, aSrvNameArrSize, - sClientAuthHosts); - if (!host) { - return SSL_SNI_SEND_ALERT; - } - - if (gDebugLevel >= DEBUG_VERBOSE) { - fprintf(stderr, "found pre-defined host '%s'\n", host->mHostName); - } - - SECStatus srv = ConfigSecureServerWithNamedCert(aFd, DEFAULT_CERT_NICKNAME, - nullptr, nullptr); - if (srv != SECSuccess) { - return SSL_SNI_SEND_ALERT; - } - - SSL_OptionSet(aFd, SSL_REQUEST_CERTIFICATE, host->mRequestClientAuth); - if (host->mRequireClientAuth) { - SSL_OptionSet(aFd, SSL_REQUIRE_CERTIFICATE, SSL_REQUIRE_ALWAYS); - } else { - SSL_OptionSet(aFd, SSL_REQUIRE_CERTIFICATE, SSL_REQUIRE_NEVER); - } - - // Override default client auth hook to just check fingerprint - srv = SSL_AuthCertificateHook(aFd, AuthCertificateHook, nullptr); - if (srv != SECSuccess) { - return SSL_SNI_SEND_ALERT; - } - - return 0; -} - -int -main(int argc, char* argv[]) -{ - if (argc != 2) { - fprintf(stderr, "usage: %s \n", argv[0]); - return 1; - } - - return StartServer(argv[1], DoSNISocketConfig, nullptr); -} diff --git a/security/manager/ssl/tests/unit/tlsserver/cmd/moz.build b/security/manager/ssl/tests/unit/tlsserver/cmd/moz.build index b8529ab812..55da3893d0 100644 --- a/security/manager/ssl/tests/unit/tlsserver/cmd/moz.build +++ b/security/manager/ssl/tests/unit/tlsserver/cmd/moz.build @@ -6,7 +6,6 @@ GeckoSimplePrograms([ 'BadCertServer', - 'ClientAuthServer', 'GenerateOCSPResponse', 'OCSPStaplingServer', ], linkage=None) diff --git a/testing/xpcshell/moz-http2/moz-http2.js b/testing/xpcshell/moz-http2/moz-http2.js index 0f88dab8f2..dbc906528d 100644 --- a/testing/xpcshell/moz-http2/moz-http2.js +++ b/testing/xpcshell/moz-http2/moz-http2.js @@ -709,6 +709,24 @@ function handleRequest(req, res) { Serializer.prototype._transform = newTransform; } + // for use with test_immutable.js + else if (u.pathname === "/immutable-test-without-attribute") { + res.setHeader('Cache-Control', 'max-age=100000'); + res.setHeader('Etag', '1'); + if (req.headers["if-none-match"]) { + res.setHeader("x-conditional", "true"); + } + // default response from here + } + else if (u.pathname === "/immutable-test-with-attribute") { + res.setHeader('Cache-Control', 'max-age=100000, immutable'); + res.setHeader('Etag', '2'); + if (req.headers["if-none-match"]) { + res.setHeader("x-conditional", "true"); + } + // default response from here + } + res.setHeader('Content-Type', 'text/html'); if (req.httpVersionMajor != 2) { res.setHeader('Connection', 'close'); diff --git a/testing/xpcshell/remotexpcshelltests.py b/testing/xpcshell/remotexpcshelltests.py index 359e4ad7d8..d519d86326 100644 --- a/testing/xpcshell/remotexpcshelltests.py +++ b/testing/xpcshell/remotexpcshelltests.py @@ -397,7 +397,6 @@ class XPCShellRemote(xpcshell.XPCShellTests, object): "certutil", "pk12util", "BadCertServer", - "ClientAuthServer", "OCSPStaplingServer", "GenerateOCSPResponse"] for fname in binaries: diff --git a/toolkit/components/alerts/AlertNotificationIPCSerializer.h b/toolkit/components/alerts/AlertNotificationIPCSerializer.h index 9eaefacda5..f503678a2b 100644 --- a/toolkit/components/alerts/AlertNotificationIPCSerializer.h +++ b/toolkit/components/alerts/AlertNotificationIPCSerializer.h @@ -68,7 +68,7 @@ struct ParamTraits WriteParam(aMsg, inPrivateBrowsing); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { bool isNull; NS_ENSURE_TRUE(ReadParam(aMsg, aIter, &isNull), false); diff --git a/toolkit/mozapps/installer/upload-files.mk b/toolkit/mozapps/installer/upload-files.mk index 7e56fddc55..a78ab23104 100644 --- a/toolkit/mozapps/installer/upload-files.mk +++ b/toolkit/mozapps/installer/upload-files.mk @@ -604,7 +604,6 @@ NO_PKG_FILES += \ certutil* \ pk12util* \ BadCertServer* \ - ClientAuthServer* \ OCSPStaplingServer* \ GenerateOCSPResponse* \ chrome/chrome.rdf \ diff --git a/view/nsViewManager.cpp b/view/nsViewManager.cpp index d504df6778..3264e64f9f 100644 --- a/view/nsViewManager.cpp +++ b/view/nsViewManager.cpp @@ -767,7 +767,7 @@ nsViewManager::DispatchEvent(WidgetGUIEvent *aEvent, WidgetMouseEvent* mouseEvent = aEvent->AsMouseEvent(); if ((mouseEvent && // Ignore mouse events that we synthesize. - mouseEvent->reason == WidgetMouseEvent::eReal && + mouseEvent->mReason == WidgetMouseEvent::eReal && // Ignore mouse exit and enter (we'll get moves if the user // is really moving the mouse) since we get them when we // create and destroy widgets. diff --git a/widget/BasicEvents.h b/widget/BasicEvents.h index 97ea284e15..cb3bab111f 100644 --- a/widget/BasicEvents.h +++ b/widget/BasicEvents.h @@ -264,6 +264,59 @@ public: class WidgetEvent : public WidgetEventTime { +private: + void SetDefaultCancelableAndBubbles() + { + switch (mClass) { + case eEditorInputEventClass: + mFlags.mCancelable = false; + mFlags.mBubbles = mFlags.mIsTrusted; + break; + case eMouseEventClass: + mFlags.mCancelable = (mMessage != eMouseEnter && + mMessage != eMouseLeave); + mFlags.mBubbles = (mMessage != eMouseEnter && + mMessage != eMouseLeave); + break; + case ePointerEventClass: + mFlags.mCancelable = (mMessage != ePointerEnter && + mMessage != ePointerLeave && + mMessage != ePointerCancel && + mMessage != ePointerGotCapture && + mMessage != ePointerLostCapture); + mFlags.mBubbles = (mMessage != ePointerEnter && + mMessage != ePointerLeave); + break; + case eDragEventClass: + mFlags.mCancelable = (mMessage != eDragExit && + mMessage != eDragLeave && + mMessage != eDragEnd); + mFlags.mBubbles = true; + break; + case eSMILTimeEventClass: + mFlags.mCancelable = false; + mFlags.mBubbles = false; + break; + case eTransitionEventClass: + case eAnimationEventClass: + case eSVGZoomEventClass: + mFlags.mCancelable = false; + mFlags.mBubbles = true; + break; + case eCompositionEventClass: + // XXX compositionstart is cancelable in draft of DOM3 Events. + // However, it doesn't make sense for us, we cannot cancel + // composition when we send compositionstart event. + mFlags.mCancelable = false; + mFlags.mBubbles = true; + break; + default: + mFlags.mCancelable = true; + mFlags.mBubbles = true; + break; + } + } + protected: WidgetEvent(bool aIsTrusted, EventMessage aMessage, @@ -278,8 +331,7 @@ protected: MOZ_COUNT_CTOR(WidgetEvent); mFlags.Clear(); mFlags.mIsTrusted = aIsTrusted; - mFlags.mCancelable = true; - mFlags.mBubbles = true; + SetDefaultCancelableAndBubbles(); } WidgetEvent() @@ -290,18 +342,8 @@ protected: public: WidgetEvent(bool aIsTrusted, EventMessage aMessage) - : WidgetEventTime() - , mClass(eBasicEventClass) - , mMessage(aMessage) - , mRefPoint(0, 0) - , mLastRefPoint(0, 0) - , mSpecifiedEventType(nullptr) + : WidgetEvent(aIsTrusted, aMessage, eBasicEventClass) { - MOZ_COUNT_CTOR(WidgetEvent); - mFlags.Clear(); - mFlags.mIsTrusted = aIsTrusted; - mFlags.mCancelable = true; - mFlags.mBubbles = true; } virtual ~WidgetEvent() diff --git a/widget/ContentEvents.h b/widget/ContentEvents.h index fe979c7c73..fc83aaa057 100644 --- a/widget/ContentEvents.h +++ b/widget/ContentEvents.h @@ -244,7 +244,6 @@ public: : WidgetEvent(aIsTrusted, aMessage, eTransitionEventClass) , mElapsedTime(0.0) { - mFlags.mCancelable = false; } virtual WidgetEvent* Duplicate() const override @@ -289,7 +288,6 @@ public: : WidgetEvent(aIsTrusted, aMessage, eAnimationEventClass) , mElapsedTime(0.0) { - mFlags.mCancelable = false; } virtual WidgetEvent* Duplicate() const override @@ -330,7 +328,6 @@ public: InternalSVGZoomEvent(bool aIsTrusted, EventMessage aMessage) : WidgetGUIEvent(aIsTrusted, aMessage, nullptr, eSVGZoomEventClass) { - mFlags.mCancelable = false; } virtual WidgetEvent* Duplicate() const override @@ -366,8 +363,6 @@ public: InternalSMILTimeEvent(bool aIsTrusted, EventMessage aMessage) : InternalUIEvent(aIsTrusted, aMessage, eSMILTimeEventClass) { - mFlags.mBubbles = false; - mFlags.mCancelable = false; } virtual WidgetEvent* Duplicate() const override diff --git a/widget/EventForwards.h b/widget/EventForwards.h index 3d5ae180de..8ea6999932 100644 --- a/widget/EventForwards.h +++ b/widget/EventForwards.h @@ -83,7 +83,8 @@ typedef uint16_t Modifiers; #define NS_DEFINE_KEYNAME(aCPPName, aDOMKeyName) \ KEY_NAME_INDEX_##aCPPName, -enum KeyNameIndex +typedef uint16_t KeyNameIndexType; +enum KeyNameIndex : KeyNameIndexType { #include "mozilla/KeyNameList.h" // If a DOM keyboard event is synthesized by script, this is used. Then, @@ -96,7 +97,8 @@ enum KeyNameIndex #define NS_DEFINE_PHYSICAL_KEY_CODE_NAME(aCPPName, aDOMCodeName) \ CODE_NAME_INDEX_##aCPPName, -enum CodeNameIndex +typedef uint8_t CodeNameIndexType; +enum CodeNameIndex : CodeNameIndexType { #include "mozilla/PhysicalKeyCodeNameList.h" // If a DOM keyboard event is synthesized by script, this is used. Then, diff --git a/widget/EventMessageList.h b/widget/EventMessageList.h index 592a26f4e4..04c2fc3104 100644 --- a/widget/EventMessageList.h +++ b/widget/EventMessageList.h @@ -52,6 +52,12 @@ NS_EVENT_MESSAGE(eAfterKeyDown) NS_EVENT_MESSAGE(eBeforeKeyUp) NS_EVENT_MESSAGE(eAfterKeyUp) +// This message is sent after a content process handles a key event or accesskey +// to indicate that an potential accesskey was not found. The parent process may +// then respond by, for example, opening menus and processing other shortcuts. +// It inherits its properties from a keypress event. +NS_EVENT_MESSAGE(eAccessKeyNotFound) + NS_EVENT_MESSAGE(eResize) NS_EVENT_MESSAGE(eScroll) diff --git a/widget/GfxInfoBase.cpp b/widget/GfxInfoBase.cpp index bc9db9ba07..3d81ca2397 100644 --- a/widget/GfxInfoBase.cpp +++ b/widget/GfxInfoBase.cpp @@ -31,6 +31,7 @@ #include "mozilla/dom/ContentChild.h" #include "mozilla/gfx/2D.h" #include "mozilla/gfx/Logging.h" +#include "MediaPrefs.h" #include "gfxPrefs.h" #include "gfxPlatform.h" #include "gfxConfig.h" @@ -713,6 +714,7 @@ GfxInfoBase::Init() { InitGfxDriverInfoShutdownObserver(); gfxPrefs::GetSingleton(); + MediaPrefs::GetSingleton(); nsCOMPtr os = mozilla::services::GetObserverService(); if (os) { diff --git a/widget/InputData.cpp b/widget/InputData.cpp index ebf91d92ec..4989aa7156 100644 --- a/widget/InputData.cpp +++ b/widget/InputData.cpp @@ -161,9 +161,9 @@ MouseInput::ToWidgetMouseEvent(nsIWidget* aWidget) const event.mRefPoint = RoundedToInt(ViewAs(mOrigin, PixelCastJustification::LayoutDeviceIsScreenForUntransformedEvent)); - event.clickCount = clickCount; + event.mClickCount = clickCount; event.inputSource = mInputSource; - event.ignoreRootScrollFrame = true; + event.mIgnoreRootScrollFrame = true; return event; } @@ -294,7 +294,7 @@ MultiTouchInput::ToWidgetMouseEvent(nsIWidget* aWidget) const event.mFlags.mHandledByAPZ = mHandledByAPZ; if (mouseEventMessage != eMouseMove) { - event.clickCount = 1; + event.mClickCount = 1; } return event; diff --git a/widget/MouseEvents.h b/widget/MouseEvents.h index d3b5804324..47c560ee00 100644 --- a/widget/MouseEvents.h +++ b/widget/MouseEvents.h @@ -174,26 +174,30 @@ public: * mozilla::WidgetMouseEvent ******************************************************************************/ -class WidgetMouseEvent : public WidgetMouseEventBase, public WidgetPointerHelper +class WidgetMouseEvent : public WidgetMouseEventBase + , public WidgetPointerHelper { private: - friend class mozilla::dom::PBrowserParent; - friend class mozilla::dom::PBrowserChild; + friend class dom::PBrowserParent; + friend class dom::PBrowserChild; public: - enum reasonType + typedef bool ReasonType; + enum Reason : ReasonType { eReal, eSynthesized }; - enum contextType + typedef bool ContextMenuTriggerType; + enum ContextMenuTrigger : ContextMenuTriggerType { eNormal, eContextMenuKey }; - enum exitType + typedef bool ExitFromType; + enum ExitFrom : ExitFromType { eChild, eTopLevel @@ -201,53 +205,45 @@ public: protected: WidgetMouseEvent() - : acceptActivation(false) - , ignoreRootScrollFrame(false) - , clickCount(0) + : mReason(eReal) + , mContextMenuTrigger(eNormal) + , mExitFrom(eChild) + , mIgnoreRootScrollFrame(false) + , mClickCount(0) { } - WidgetMouseEvent(bool aIsTrusted, EventMessage aMessage, nsIWidget* aWidget, - EventClassID aEventClassID, reasonType aReason) + WidgetMouseEvent(bool aIsTrusted, + EventMessage aMessage, + nsIWidget* aWidget, + EventClassID aEventClassID, + Reason aReason) : WidgetMouseEventBase(aIsTrusted, aMessage, aWidget, aEventClassID) - , acceptActivation(false) - , ignoreRootScrollFrame(false) - , reason(aReason) - , context(eNormal) - , exit(eChild) - , clickCount(0) + , mReason(aReason) + , mContextMenuTrigger(eNormal) + , mExitFrom(eChild) + , mIgnoreRootScrollFrame(false) + , mClickCount(0) { - switch (aMessage) { - case eMouseEnter: - case eMouseLeave: - mFlags.mBubbles = false; - mFlags.mCancelable = false; - break; - default: - break; - } } public: virtual WidgetMouseEvent* AsMouseEvent() override { return this; } - WidgetMouseEvent(bool aIsTrusted, EventMessage aMessage, nsIWidget* aWidget, - reasonType aReason, contextType aContext = eNormal) : - WidgetMouseEventBase(aIsTrusted, aMessage, aWidget, eMouseEventClass), - acceptActivation(false), ignoreRootScrollFrame(false), - reason(aReason), context(aContext), exit(eChild), clickCount(0) + WidgetMouseEvent(bool aIsTrusted, + EventMessage aMessage, + nsIWidget* aWidget, + Reason aReason, + ContextMenuTrigger aContextMenuTrigger = eNormal) + : WidgetMouseEventBase(aIsTrusted, aMessage, aWidget, eMouseEventClass) + , mReason(aReason) + , mContextMenuTrigger(aContextMenuTrigger) + , mExitFrom(eChild) + , mIgnoreRootScrollFrame(false) + , mClickCount(0) { - switch (aMessage) { - case eMouseEnter: - case eMouseLeave: - mFlags.mBubbles = false; - mFlags.mCancelable = false; - break; - case eContextMenu: - button = (context == eNormal) ? eRightButton : eLeftButton; - break; - default: - break; + if (aMessage == eContextMenu) { + button = (mContextMenuTrigger == eNormal) ? eRightButton : eLeftButton; } } @@ -256,7 +252,8 @@ public: { NS_WARN_IF_FALSE(mMessage != eContextMenu || button == - ((context == eNormal) ? eRightButton : eLeftButton), + ((mContextMenuTrigger == eNormal) ? eRightButton : + eLeftButton), "Wrong button set to eContextMenu event?"); } #endif @@ -267,33 +264,44 @@ public: "Duplicate() must be overridden by sub class"); // Not copying widget, it is a weak reference. WidgetMouseEvent* result = - new WidgetMouseEvent(false, mMessage, nullptr, reason, context); + new WidgetMouseEvent(false, mMessage, nullptr, + mReason, mContextMenuTrigger); result->AssignMouseEventData(*this, true); result->mFlags = mFlags; return result; } - // Special return code for MOUSE_ACTIVATE to signal. - // If the target accepts activation (1), or denies it (0). - bool acceptActivation; + // mReason indicates the reason why the event is fired: + // - Representing mouse operation. + // - Synthesized for emulating mousemove event when the content under the + // mouse cursor is scrolled. + Reason mReason; + + // mContextMenuTrigger is valid only when mMessage is eContextMenu. + // This indicates if the context menu event is caused by context menu key or + // other reasons (typically, a click of right mouse button). + ContextMenuTrigger mContextMenuTrigger; + + // mExitFrom is valid only when mMessage is eMouseExitFromWidget. + // This indicates if the mouse cursor exits from a top level widget or + // a child widget. + ExitFrom mExitFrom; + // Whether the event should ignore scroll frame bounds during dispatch. - bool ignoreRootScrollFrame; + bool mIgnoreRootScrollFrame; - reasonType reason : 4; - contextType context : 4; - exitType exit; - - /// The number of mouse clicks. - uint32_t clickCount; + // mClickCount may be non-zero value when mMessage is eMouseDown, eMouseUp, + // eMouseClick or eMouseDoubleClick. The number is count of mouse clicks. + // Otherwise, this must be 0. + uint32_t mClickCount; void AssignMouseEventData(const WidgetMouseEvent& aEvent, bool aCopyTargets) { AssignMouseEventBaseData(aEvent, aCopyTargets); AssignPointerHelperData(aEvent); - acceptActivation = aEvent.acceptActivation; - ignoreRootScrollFrame = aEvent.ignoreRootScrollFrame; - clickCount = aEvent.clickCount; + mIgnoreRootScrollFrame = aEvent.mIgnoreRootScrollFrame; + mClickCount = aEvent.mClickCount; } /** @@ -301,7 +309,7 @@ public: */ bool IsContextMenuKeyEvent() const { - return mMessage == eContextMenu && context == eContextMenuKey; + return mMessage == eContextMenu && mContextMenuTrigger == eContextMenuKey; } /** @@ -310,7 +318,7 @@ public: */ bool IsReal() const { - return reason == eReal; + return mReason == eReal; } }; @@ -337,8 +345,6 @@ public: , mUserCancelled(false) , mDefaultPreventedOnContent(false) { - mFlags.mCancelable = - (aMessage != eDragExit && aMessage != eDragLeave && aMessage != eDragEnd); } virtual WidgetEvent* Duplicate() const override @@ -675,7 +681,6 @@ public: , height(0) , isPrimary(true) { - UpdateFlags(); } explicit WidgetPointerEvent(const WidgetMouseEvent& aEvent) @@ -685,25 +690,6 @@ public: , isPrimary(true) { mClass = ePointerEventClass; - UpdateFlags(); - } - - void UpdateFlags() - { - switch (mMessage) { - case ePointerEnter: - case ePointerLeave: - mFlags.mBubbles = false; - mFlags.mCancelable = false; - break; - case ePointerCancel: - case ePointerGotCapture: - case ePointerLostCapture: - mFlags.mCancelable = false; - break; - default: - break; - } } virtual WidgetEvent* Duplicate() const override diff --git a/widget/TextEventDispatcher.cpp b/widget/TextEventDispatcher.cpp index f63c348113..e444b0a204 100644 --- a/widget/TextEventDispatcher.cpp +++ b/widget/TextEventDispatcher.cpp @@ -466,7 +466,7 @@ TextEventDispatcher::DispatchKeyboardEventInternal( keyEvent.SetCharCode(static_cast(ch)); if (aMessage == eKeyPress) { // keyCode of eKeyPress events of printable keys should be always 0. - keyEvent.keyCode = 0; + keyEvent.mKeyCode = 0; // eKeyPress events are dispatched for every character. // So, each key value of eKeyPress events should be a character. if (ch) { @@ -498,7 +498,7 @@ TextEventDispatcher::DispatchKeyboardEventInternal( // eKeyDown also needs alternative char codes because nsXBLWindowKeyHandler // needs to check if a following keypress event is reserved by chrome for // stopping propagation of its preceding keydown event. - keyEvent.alternativeCharCodes.Clear(); + keyEvent.mAlternativeCharCodes.Clear(); if ((WidgetKeyboardEvent::IsKeyDownOrKeyDownOnPlugin(aMessage) || aMessage == eKeyPress) && (keyEvent.IsControl() || keyEvent.IsAlt() || @@ -511,10 +511,10 @@ TextEventDispatcher::DispatchKeyboardEventInternal( aData); MOZ_ASSERT(keyEvent.mMessage == static_cast(original).mMessage); - MOZ_ASSERT(keyEvent.keyCode == - static_cast(original).keyCode); - MOZ_ASSERT(keyEvent.location == - static_cast(original).location); + MOZ_ASSERT(keyEvent.mKeyCode == + static_cast(original).mKeyCode); + MOZ_ASSERT(keyEvent.mLocation == + static_cast(original).mLocation); MOZ_ASSERT(keyEvent.mIsRepeat == static_cast(original).mIsRepeat); MOZ_ASSERT(keyEvent.mIsComposing == diff --git a/widget/TextEvents.h b/widget/TextEvents.h index 2693f54093..18dab63af8 100644 --- a/widget/TextEvents.h +++ b/widget/TextEvents.h @@ -83,7 +83,7 @@ struct ShortcutKeyCandidate , mIgnoreShift(aIgnoreShift) { } - // The charCode value which must match keyboard shortcut definition. + // The mCharCode value which must match keyboard shortcut definition. uint32_t mCharCode; // true if Shift state can be ignored. Otherwise, Shift key state must // match keyboard shortcut definition. @@ -102,23 +102,24 @@ private: protected: WidgetKeyboardEvent() - : keyCode(0) - , charCode(0) + : mNativeKeyEvent(nullptr) + , mKeyCode(0) + , mCharCode(0) , mPseudoCharCode(0) - , location(nsIDOMKeyEvent::DOM_KEY_LOCATION_STANDARD) - , isChar(false) + , mLocation(nsIDOMKeyEvent::DOM_KEY_LOCATION_STANDARD) + , mAccessKeyForwardedToChild(false) + , mUniqueId(0) +#ifdef XP_MACOSX + , mNativeModifierFlags(0) + , mNativeKeyCode(0) +#endif // #ifdef XP_MACOSX + , mKeyNameIndex(mozilla::KEY_NAME_INDEX_Unidentified) + , mCodeNameIndex(CODE_NAME_INDEX_UNKNOWN) + , mInputMethodAppState(eNotHandled) + , mIsChar(false) , mIsRepeat(false) , mIsComposing(false) , mIsReserved(false) - , mKeyNameIndex(mozilla::KEY_NAME_INDEX_Unidentified) - , mCodeNameIndex(CODE_NAME_INDEX_UNKNOWN) - , mNativeKeyEvent(nullptr) - , mUniqueId(0) -#ifdef XP_MACOSX - , mNativeKeyCode(0) - , mNativeModifierFlags(0) -#endif - , mInputMethodAppState(eNotHandled) , mIsSynthesizedByTIP(false) { } @@ -130,23 +131,24 @@ public: nsIWidget* aWidget, EventClassID aEventClassID = eKeyboardEventClass) : WidgetInputEvent(aIsTrusted, aMessage, aWidget, aEventClassID) - , keyCode(0) - , charCode(0) + , mNativeKeyEvent(nullptr) + , mKeyCode(0) + , mCharCode(0) , mPseudoCharCode(0) - , location(nsIDOMKeyEvent::DOM_KEY_LOCATION_STANDARD) - , isChar(false) + , mLocation(nsIDOMKeyEvent::DOM_KEY_LOCATION_STANDARD) + , mAccessKeyForwardedToChild(false) + , mUniqueId(0) +#ifdef XP_MACOSX + , mNativeModifierFlags(0) + , mNativeKeyCode(0) +#endif // #ifdef XP_MACOSX + , mKeyNameIndex(mozilla::KEY_NAME_INDEX_Unidentified) + , mCodeNameIndex(CODE_NAME_INDEX_UNKNOWN) + , mInputMethodAppState(eNotHandled) + , mIsChar(false) , mIsRepeat(false) , mIsComposing(false) , mIsReserved(false) - , mKeyNameIndex(mozilla::KEY_NAME_INDEX_Unidentified) - , mCodeNameIndex(CODE_NAME_INDEX_UNKNOWN) - , mNativeKeyEvent(nullptr) - , mUniqueId(0) -#ifdef XP_MACOSX - , mNativeKeyCode(0) - , mNativeModifierFlags(0) -#endif - , mInputMethodAppState(eNotHandled) , mIsSynthesizedByTIP(false) { // If this is a keyboard event on a plugin, it shouldn't fired on content. @@ -191,46 +193,45 @@ public: return result; } - // A DOM keyCode value or 0. If a keypress event whose charCode is 0, this - // should be 0. - uint32_t keyCode; - // If the instance is a keypress event of a printable key, this is a UTF-16 - // value of the key. Otherwise, 0. This value must not be a control - // character when some modifiers are active. Then, this value should be an - // unmodified value except Shift and AltGr. - uint32_t charCode; - // mPseudoCharCode is valid only when mMessage is an eKeyDown event. - // This stores charCode value of keypress event which is fired with same - // key value and same modifier state. - uint32_t mPseudoCharCode; - // One of nsIDOMKeyEvent::DOM_KEY_LOCATION_* - uint32_t location; // OS translated Unicode chars which are used for accesskey and accelkey // handling. The handlers will try from first character to last character. - nsTArray alternativeCharCodes; - // Indicates whether the event signifies a printable character - bool isChar; - // Indicates whether the event is generated by auto repeat or not. - // if this is keyup event, always false. - bool mIsRepeat; - // Indicates whether the event is generated during IME (or deadkey) - // composition. This is initialized by EventStateManager. So, key event - // dispatchers don't need to initialize this. - bool mIsComposing; - // Indicates if the key combination is reserved by chrome. This is set by - // nsXBLWindowKeyHandler at capturing phase of the default event group. - bool mIsReserved; - // DOM KeyboardEvent.key - KeyNameIndex mKeyNameIndex; - // DOM KeyboardEvent.code - CodeNameIndex mCodeNameIndex; + nsTArray mAlternativeCharCodes; // DOM KeyboardEvent.key only when mKeyNameIndex is KEY_NAME_INDEX_USE_STRING. nsString mKeyValue; // DOM KeyboardEvent.code only when mCodeNameIndex is // CODE_NAME_INDEX_USE_STRING. nsString mCodeValue; + +#ifdef XP_MACOSX + // Values given by a native NSEvent, for use with Cocoa NPAPI plugins. + nsString mNativeCharacters; + nsString mNativeCharactersIgnoringModifiers; + // If this is non-empty, create a text event for plugins instead of a + // keyboard event. + nsString mPluginTextEventString; +#endif // #ifdef XP_MACOSX + // OS-specific native event can optionally be preserved void* mNativeKeyEvent; + // A DOM keyCode value or 0. If a keypress event whose mCharCode is 0, this + // should be 0. + uint32_t mKeyCode; + // If the instance is a keypress event of a printable key, this is a UTF-16 + // value of the key. Otherwise, 0. This value must not be a control + // character when some modifiers are active. Then, this value should be an + // unmodified value except Shift and AltGr. + uint32_t mCharCode; + // mPseudoCharCode is valid only when mMessage is an eKeyDown event. + // This stores mCharCode value of keypress event which is fired with same + // key value and same modifier state. + uint32_t mPseudoCharCode; + // One of nsIDOMKeyEvent::DOM_KEY_LOCATION_* + uint32_t mLocation; + // True if accesskey handling was forwarded to the child via + // TabParent::HandleAccessKey. In this case, parent process menu access key + // handling should be delayed until it is determined that there exists no + // overriding access key in the content process. + bool mAccessKeyForwardedToChild; // Unique id associated with a keydown / keypress event. Used in identifing // keypress events for removal from async event dispatch queue in metrofx // after preventDefault is called on keydown events. It's ok if this wraps @@ -239,15 +240,14 @@ public: #ifdef XP_MACOSX // Values given by a native NSEvent, for use with Cocoa NPAPI plugins. - uint16_t mNativeKeyCode; uint32_t mNativeModifierFlags; - nsString mNativeCharacters; - nsString mNativeCharactersIgnoringModifiers; - // If this is non-empty, create a text event for plugins instead of a - // keyboard event. - nsString mPluginTextEventString; -#endif + uint16_t mNativeKeyCode; +#endif // #ifdef XP_MACOSX + // DOM KeyboardEvent.key + KeyNameIndex mKeyNameIndex; + // DOM KeyboardEvent.code + CodeNameIndex mCodeNameIndex; // Indicates that the event is being handled by input method app typedef uint8_t InputMethodAppStateType; enum InputMethodAppState : InputMethodAppStateType @@ -258,6 +258,18 @@ public: }; InputMethodAppState mInputMethodAppState; + // Indicates whether the event signifies a printable character + bool mIsChar; + // Indicates whether the event is generated by auto repeat or not. + // if this is keyup event, always false. + bool mIsRepeat; + // Indicates whether the event is generated during IME (or deadkey) + // composition. This is initialized by EventStateManager. So, key event + // dispatchers don't need to initialize this. + bool mIsComposing; + // Indicates if the key combination is reserved by chrome. This is set by + // nsXBLWindowKeyHandler at capturing phase of the default event group. + bool mIsReserved; // Indicates whether the event is synthesized from Text Input Processor // or an actual event from nsAppShell. bool mIsSynthesizedByTIP; @@ -266,19 +278,19 @@ public: // Otherwise, false. bool ShouldCauseKeypressEvents() const; - // charCode value of non-eKeyPress events is always 0. However, if + // mCharCode value of non-eKeyPress events is always 0. However, if // non-eKeyPress event has one or more alternative char code values, - // its first item should be the charCode value of following eKeyPress event. - // PseudoCharCode() returns charCode value for eKeyPress event, + // its first item should be the mCharCode value of following eKeyPress event. + // PseudoCharCode() returns mCharCode value for eKeyPress event, // the first alternative char code value of non-eKeyPress event or 0. uint32_t PseudoCharCode() const { - return mMessage == eKeyPress ? charCode : mPseudoCharCode; + return mMessage == eKeyPress ? mCharCode : mPseudoCharCode; } void SetCharCode(uint32_t aCharCode) { if (mMessage == eKeyPress) { - charCode = aCharCode; + mCharCode = aCharCode; } else { mPseudoCharCode = aCharCode; } @@ -325,14 +337,14 @@ public: static void Shutdown(); /** - * ComputeLocationFromCodeValue() returns one of .location value + * ComputeLocationFromCodeValue() returns one of .mLocation value * (nsIDOMKeyEvent::DOM_KEY_LOCATION_*) which is the most preferred value * for the specified specified code value. */ static uint32_t ComputeLocationFromCodeValue(CodeNameIndex aCodeNameIndex); /** - * ComputeKeyCodeFromKeyNameIndex() return a .keyCode value which can be + * ComputeKeyCodeFromKeyNameIndex() return a .mKeyCode value which can be * mapped from the specified key value. Note that this returns 0 if the * key name index is KEY_NAME_INDEX_Unidentified or KEY_NAME_INDEX_USE_STRING. * This means that this method is useful only for non-printable keys. @@ -365,15 +377,16 @@ public: { AssignInputEventData(aEvent, aCopyTargets); - keyCode = aEvent.keyCode; - charCode = aEvent.charCode; + mKeyCode = aEvent.mKeyCode; + mCharCode = aEvent.mCharCode; mPseudoCharCode = aEvent.mPseudoCharCode; - location = aEvent.location; - alternativeCharCodes = aEvent.alternativeCharCodes; - isChar = aEvent.isChar; + mLocation = aEvent.mLocation; + mAlternativeCharCodes = aEvent.mAlternativeCharCodes; + mIsChar = aEvent.mIsChar; mIsRepeat = aEvent.mIsRepeat; mIsComposing = aEvent.mIsComposing; mIsReserved = aEvent.mIsReserved; + mAccessKeyForwardedToChild = aEvent.mAccessKeyForwardedToChild; mKeyNameIndex = aEvent.mKeyNameIndex; mCodeNameIndex = aEvent.mCodeNameIndex; mKeyValue = aEvent.mKeyValue; @@ -498,10 +511,6 @@ public: , mNativeIMEContext(aWidget) , mOriginalMessage(eVoidEvent) { - // XXX compositionstart is cancelable in draft of DOM3 Events. - // However, it doesn't make sense for us, we cannot cancel composition - // when we send compositionstart event. - mFlags.mCancelable = false; } virtual WidgetEvent* Duplicate() const override @@ -854,14 +863,6 @@ public: : InternalUIEvent(aIsTrusted, aMessage, aWidget, eEditorInputEventClass) , mIsComposing(false) { - if (!aIsTrusted) { - mFlags.mBubbles = false; - mFlags.mCancelable = false; - return; - } - - mFlags.mBubbles = true; - mFlags.mCancelable = false; } virtual WidgetEvent* Duplicate() const override diff --git a/widget/WidgetEventImpl.cpp b/widget/WidgetEventImpl.cpp index aeb8437e1e..23bb6aea54 100644 --- a/widget/WidgetEventImpl.cpp +++ b/widget/WidgetEventImpl.cpp @@ -171,6 +171,7 @@ WidgetEvent::HasKeyEventMessage() const case eBeforeKeyUp: case eAfterKeyDown: case eAfterKeyUp: + case eAccessKeyNotFound: return true; default: return false; @@ -273,7 +274,7 @@ WidgetEvent::IsAllowedToDispatchDOMEvent() const // DOM events. // Synthesized button up events also do not cause DOM events because they // do not have a reliable mRefPoint. - return AsMouseEvent()->reason == WidgetMouseEvent::eReal; + return AsMouseEvent()->mReason == WidgetMouseEvent::eReal; case eWheelEventClass: { // wheel event whose all delta values are zero by user pref applied, it @@ -500,10 +501,10 @@ WidgetKeyboardEvent::GetShortcutKeyCandidates( aCandidates.AppendElement(key); } - uint32_t len = alternativeCharCodes.Length(); + uint32_t len = mAlternativeCharCodes.Length(); if (!IsShift()) { for (uint32_t i = 0; i < len; ++i) { - uint32_t ch = alternativeCharCodes[i].mUnshiftedCharCode; + uint32_t ch = mAlternativeCharCodes[i].mUnshiftedCharCode; if (!ch || ch == pseudoCharCode) { continue; } @@ -516,7 +517,7 @@ WidgetKeyboardEvent::GetShortcutKeyCandidates( // However, the priority should be lowest. if (!HasASCIIDigit(aCandidates)) { for (uint32_t i = 0; i < len; ++i) { - uint32_t ch = alternativeCharCodes[i].mShiftedCharCode; + uint32_t ch = mAlternativeCharCodes[i].mShiftedCharCode; if (ch >= '0' && ch <= '9') { ShortcutKeyCandidate key(ch, false); aCandidates.AppendElement(key); @@ -526,7 +527,7 @@ WidgetKeyboardEvent::GetShortcutKeyCandidates( } } else { for (uint32_t i = 0; i < len; ++i) { - uint32_t ch = alternativeCharCodes[i].mShiftedCharCode; + uint32_t ch = mAlternativeCharCodes[i].mShiftedCharCode; if (!ch) { continue; } @@ -541,7 +542,7 @@ WidgetKeyboardEvent::GetShortcutKeyCandidates( // And checking the charCode is same as unshiftedCharCode too. // E.g., for Ctrl+Shift+(Plus of Numpad) should not run Ctrl+Plus. - uint32_t unshiftCh = alternativeCharCodes[i].mUnshiftedCharCode; + uint32_t unshiftCh = mAlternativeCharCodes[i].mUnshiftedCharCode; if (CharsCaseInsensitiveEqual(ch, unshiftCh)) { continue; } @@ -563,10 +564,11 @@ WidgetKeyboardEvent::GetShortcutKeyCandidates( // Special case for "Space" key. With some keyboard layouts, "Space" with // or without Shift key causes non-ASCII space. For such keyboard layouts, // we should guarantee that the key press works as an ASCII white space key - // press. - if (mCodeNameIndex == CODE_NAME_INDEX_Space && - pseudoCharCode != static_cast(' ')) { - ShortcutKeyCandidate spaceKey(static_cast(' '), false); + // press. However, if the space key is assigned to a function key, it + // shouldn't work as a space key. + if (mKeyNameIndex == KEY_NAME_INDEX_USE_STRING && + mCodeNameIndex == CODE_NAME_INDEX_Space && pseudoCharCode != ' ') { + ShortcutKeyCandidate spaceKey(' ', false); aCandidates.AppendElement(spaceKey); } } @@ -580,17 +582,17 @@ WidgetKeyboardEvent::GetAccessKeyCandidates(nsTArray& aCandidates) // the priority of the charCodes are: // 0: charCode, 1: unshiftedCharCodes[0], 2: shiftedCharCodes[0] // 3: unshiftedCharCodes[1], 4: shiftedCharCodes[1],... - if (charCode) { - uint32_t ch = charCode; + if (mCharCode) { + uint32_t ch = mCharCode; if (IS_IN_BMP(ch)) { ch = ToLowerCase(static_cast(ch)); } aCandidates.AppendElement(ch); } - for (uint32_t i = 0; i < alternativeCharCodes.Length(); ++i) { + for (uint32_t i = 0; i < mAlternativeCharCodes.Length(); ++i) { uint32_t ch[2] = - { alternativeCharCodes[i].mUnshiftedCharCode, - alternativeCharCodes[i].mShiftedCharCode }; + { mAlternativeCharCodes[i].mUnshiftedCharCode, + mAlternativeCharCodes[i].mShiftedCharCode }; for (uint32_t j = 0; j < 2; ++j) { if (!ch[j]) { continue; @@ -598,7 +600,7 @@ WidgetKeyboardEvent::GetAccessKeyCandidates(nsTArray& aCandidates) if (IS_IN_BMP(ch[j])) { ch[j] = ToLowerCase(static_cast(ch[j])); } - // Don't append the charCode that was already appended. + // Don't append the mCharCode that was already appended. if (aCandidates.IndexOf(ch[j]) == aCandidates.NoIndex) { aCandidates.AppendElement(ch[j]); } @@ -607,10 +609,11 @@ WidgetKeyboardEvent::GetAccessKeyCandidates(nsTArray& aCandidates) // Special case for "Space" key. With some keyboard layouts, "Space" with // or without Shift key causes non-ASCII space. For such keyboard layouts, // we should guarantee that the key press works as an ASCII white space key - // press. - if (mCodeNameIndex == CODE_NAME_INDEX_Space && - charCode != static_cast(' ')) { - aCandidates.AppendElement(static_cast(' ')); + // press. However, if the space key is assigned to a function key, it + // shouldn't work as a space key. + if (mKeyNameIndex == KEY_NAME_INDEX_USE_STRING && + mCodeNameIndex == CODE_NAME_INDEX_Space && mCharCode != ' ') { + aCandidates.AppendElement(' '); } return; } diff --git a/widget/WidgetMessageUtils.h b/widget/WidgetMessageUtils.h index 3287296d9f..8ab831a206 100644 --- a/widget/WidgetMessageUtils.h +++ b/widget/WidgetMessageUtils.h @@ -21,7 +21,7 @@ struct ParamTraits WriteParam(aMsg, aParam.value); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { int32_t id, value; if (ReadParam(aMsg, aIter, &id) && @@ -36,4 +36,4 @@ struct ParamTraits } // namespace IPC -#endif // WidgetMessageUtils_h \ No newline at end of file +#endif // WidgetMessageUtils_h diff --git a/widget/cocoa/TextInputHandler.h b/widget/cocoa/TextInputHandler.h index a3df2924dc..7297de9534 100644 --- a/widget/cocoa/TextInputHandler.h +++ b/widget/cocoa/TextInputHandler.h @@ -229,8 +229,8 @@ public: const nsAString *aInsertString = nullptr); /** - * WillDispatchKeyboardEvent() computes aKeyEvent.alternativeCharCodes and - * recompute aKeyEvent.charCode if it's necessary. + * WillDispatchKeyboardEvent() computes aKeyEvent.mAlternativeCharCodes and + * recompute aKeyEvent.mCharCode if it's necessary. * * @param aNativeKeyEvent A native key event for which you want to * dispatch a Gecko key event. diff --git a/widget/cocoa/TextInputHandler.mm b/widget/cocoa/TextInputHandler.mm index cd1f3ca311..5b5b04d07a 100644 --- a/widget/cocoa/TextInputHandler.mm +++ b/widget/cocoa/TextInputHandler.mm @@ -914,12 +914,12 @@ TISInputSourceWrapper::InitKeyEvent(NSEvent *aNativeKeyEvent, } aKeyEvent.mRefPoint = LayoutDeviceIntPoint(0, 0); - aKeyEvent.isChar = false; // XXX not used in XP level + aKeyEvent.mIsChar = false; // XXX not used in XP level UInt32 kbType = GetKbdType(); UInt32 nativeKeyCode = [aNativeKeyEvent keyCode]; - aKeyEvent.keyCode = + aKeyEvent.mKeyCode = ComputeGeckoKeyCode(nativeKeyCode, kbType, aKeyEvent.IsMeta()); switch (nativeKeyCode) { @@ -927,14 +927,14 @@ TISInputSourceWrapper::InitKeyEvent(NSEvent *aNativeKeyEvent, case kVK_Shift: case kVK_Option: case kVK_Control: - aKeyEvent.location = nsIDOMKeyEvent::DOM_KEY_LOCATION_LEFT; + aKeyEvent.mLocation = nsIDOMKeyEvent::DOM_KEY_LOCATION_LEFT; break; case kVK_RightCommand: case kVK_RightShift: case kVK_RightOption: case kVK_RightControl: - aKeyEvent.location = nsIDOMKeyEvent::DOM_KEY_LOCATION_RIGHT; + aKeyEvent.mLocation = nsIDOMKeyEvent::DOM_KEY_LOCATION_RIGHT; break; case kVK_ANSI_Keypad0: @@ -956,11 +956,11 @@ TISInputSourceWrapper::InitKeyEvent(NSEvent *aNativeKeyEvent, case kVK_ANSI_KeypadEnter: case kVK_JIS_KeypadComma: case kVK_Powerbook_KeypadEnter: - aKeyEvent.location = nsIDOMKeyEvent::DOM_KEY_LOCATION_NUMPAD; + aKeyEvent.mLocation = nsIDOMKeyEvent::DOM_KEY_LOCATION_NUMPAD; break; default: - aKeyEvent.location = nsIDOMKeyEvent::DOM_KEY_LOCATION_STANDARD; + aKeyEvent.mLocation = nsIDOMKeyEvent::DOM_KEY_LOCATION_STANDARD; break; } @@ -1061,14 +1061,14 @@ TISInputSourceWrapper::WillDispatchKeyboardEvent( nsAutoString chars; nsCocoaUtils::GetStringForNSString([aNativeKeyEvent characters], chars); NS_ConvertUTF16toUTF8 utf8Chars(chars); - char16_t uniChar = static_cast(aKeyEvent.charCode); + char16_t uniChar = static_cast(aKeyEvent.mCharCode); MOZ_LOG(gLog, LogLevel::Info, ("%p TISInputSourceWrapper::WillDispatchKeyboardEvent, " "aNativeKeyEvent=%p, [aNativeKeyEvent characters]=\"%s\", " - "aKeyEvent={ mMessage=%s, charCode=0x%X(%s) }, kbType=0x%X, " + "aKeyEvent={ mMessage=%s, mCharCode=0x%X(%s) }, kbType=0x%X, " "IsOpenedIMEMode()=%s", this, aNativeKeyEvent, utf8Chars.get(), - GetGeckoKeyEventType(aKeyEvent), aKeyEvent.charCode, + GetGeckoKeyEventType(aKeyEvent), aKeyEvent.mCharCode, uniChar ? NS_ConvertUTF16toUTF8(&uniChar, 1).get() : "", kbType, TrueOrFalse(IsOpenedIMEMode()))); } @@ -1077,20 +1077,20 @@ TISInputSourceWrapper::WillDispatchKeyboardEvent( ComputeInsertStringForCharCode(aNativeKeyEvent, aKeyEvent, aInsertString, insertStringForCharCode); - // The charCode was set from mKeyValue. However, for example, when Ctrl key + // The mCharCode was set from mKeyValue. However, for example, when Ctrl key // is pressed, its value should indicate an ASCII character for backward // compatibility rather than inputting character without the modifiers. - // Therefore, we need to modify charCode value here. + // Therefore, we need to modify mCharCode value here. uint32_t charCode = insertStringForCharCode.IsEmpty() ? 0 : insertStringForCharCode[0]; aKeyEvent.SetCharCode(charCode); // this is not a special key XXX not used in XP - aKeyEvent.isChar = (aKeyEvent.mMessage == eKeyPress); + aKeyEvent.mIsChar = (aKeyEvent.mMessage == eKeyPress); MOZ_LOG(gLog, LogLevel::Info, ("%p TISInputSourceWrapper::WillDispatchKeyboardEvent, " - "aKeyEvent.keyCode=0x%X, aKeyEvent.charCode=0x%X", - this, aKeyEvent.keyCode, aKeyEvent.charCode)); + "aKeyEvent.mKeyCode=0x%X, aKeyEvent.mCharCode=0x%X", + this, aKeyEvent.mKeyCode, aKeyEvent.mCharCode)); TISInputSourceWrapper USLayout("com.apple.keylayout.US"); bool isRomanKeyboardLayout = IsASCIICapable(); @@ -1146,7 +1146,7 @@ TISInputSourceWrapper::WillDispatchKeyboardEvent( if ((unshiftedChar || shiftedChar) && (!aKeyEvent.IsMeta() || !isDvorakQWERTY)) { AlternativeCharCode altCharCodes(unshiftedChar, shiftedChar); - aKeyEvent.alternativeCharCodes.AppendElement(altCharCodes); + aKeyEvent.mAlternativeCharCodes.AppendElement(altCharCodes); } MOZ_LOG(gLog, LogLevel::Info, ("%p TISInputSourceWrapper::WillDispatchKeyboardEvent, " @@ -1165,7 +1165,7 @@ TISInputSourceWrapper::WillDispatchKeyboardEvent( // even though Cmd+SS is 'SS' and Shift+'SS' is '?'. This '/' seems // like a hack to make the Cmd+"?" event look the same as the Cmd+"?" // event on a US keyboard. The user thinks they are typing Cmd+"?", so - // we'll prefer the "?" character, replacing charCode with shiftedChar + // we'll prefer the "?" character, replacing mCharCode with shiftedChar // when Shift is pressed. However, in case there is a layout where the // character unique to Cmd+Shift is the character that the user expects, // we'll send it as an alternative char. @@ -1208,7 +1208,7 @@ TISInputSourceWrapper::WillDispatchKeyboardEvent( if ((cmdedChar || cmdedShiftChar) && isCmdSwitchLayout && (aKeyEvent.IsMeta() || !isDvorakQWERTY)) { AlternativeCharCode altCharCodes(cmdedChar, cmdedShiftChar); - aKeyEvent.alternativeCharCodes.AppendElement(altCharCodes); + aKeyEvent.mAlternativeCharCodes.AppendElement(altCharCodes); } MOZ_LOG(gLog, LogLevel::Info, ("%p TISInputSourceWrapper::WillDispatchKeyboardEvent, " @@ -1220,7 +1220,7 @@ TISInputSourceWrapper::WillDispatchKeyboardEvent( // hasCmdShiftOnlyChar definition for the detail. if (hasCmdShiftOnlyChar && originalCmdedShiftChar) { AlternativeCharCode altCharCodes(0, originalCmdedShiftChar); - aKeyEvent.alternativeCharCodes.AppendElement(altCharCodes); + aKeyEvent.mAlternativeCharCodes.AppendElement(altCharCodes); } MOZ_LOG(gLog, LogLevel::Info, ("%p TISInputSourceWrapper::WillDispatchKeyboardEvent, " @@ -2218,7 +2218,7 @@ TextInputHandler::InsertText(NSAttributedString* aAttrString, // Dispatch keypress event with char instead of compositionchange event WidgetKeyboardEvent keypressEvent(true, eKeyPress, mWidget); - keypressEvent.isChar = IsPrintableChar(str.CharAt(0)); + keypressEvent.mIsChar = IsPrintableChar(str.CharAt(0)); // Don't set other modifiers from the current event, because here in // -insertText: they've already been taken into account in creating @@ -2229,13 +2229,13 @@ TextInputHandler::InsertText(NSAttributedString* aAttrString, InitKeyEvent(keyEvent, keypressEvent, &str); } else { nsCocoaUtils::InitInputEvent(keypressEvent, static_cast(nullptr)); - if (keypressEvent.isChar) { - keypressEvent.charCode = str.CharAt(0); + if (keypressEvent.mIsChar) { + keypressEvent.mCharCode = str.CharAt(0); } // Note that insertText is not called only at key pressing. - if (!keypressEvent.charCode) { - keypressEvent.keyCode = - WidgetUtils::ComputeKeyCodeFromChar(keypressEvent.charCode); + if (!keypressEvent.mCharCode) { + keypressEvent.mKeyCode = + WidgetUtils::ComputeKeyCodeFromChar(keypressEvent.mCharCode); } } @@ -4151,7 +4151,7 @@ TextInputHandlerBase::AttachNativeKeyEvent(WidgetKeyboardEvent& aKeyEvent) MOZ_LOG(gLog, LogLevel::Info, ("%p TextInputHandlerBase::AttachNativeKeyEvent, key=0x%X, char=0x%X, " - "mod=0x%X", this, aKeyEvent.keyCode, aKeyEvent.charCode, + "mod=0x%X", this, aKeyEvent.mKeyCode, aKeyEvent.mCharCode, aKeyEvent.mModifiers)); NSEventType eventType; @@ -4181,12 +4181,12 @@ TextInputHandlerBase::AttachNativeKeyEvent(WidgetKeyboardEvent& aKeyEvent) NSInteger windowNumber = [[mView window] windowNumber]; NSString* characters; - if (aKeyEvent.charCode) { + if (aKeyEvent.mCharCode) { characters = [NSString stringWithCharacters: - reinterpret_cast(&(aKeyEvent.charCode)) length:1]; + reinterpret_cast(&(aKeyEvent.mCharCode)) length:1]; } else { uint32_t cocoaCharCode = - nsCocoaUtils::ConvertGeckoKeyCodeToMacCharCode(aKeyEvent.keyCode); + nsCocoaUtils::ConvertGeckoKeyCodeToMacCharCode(aKeyEvent.mKeyCode); characters = [NSString stringWithCharacters: reinterpret_cast(&cocoaCharCode) length:1]; } diff --git a/widget/cocoa/nsChildView.h b/widget/cocoa/nsChildView.h index 861ce7e8ee..b5576f3ac5 100644 --- a/widget/cocoa/nsChildView.h +++ b/widget/cocoa/nsChildView.h @@ -271,7 +271,7 @@ typedef NSInteger NSEventGestureAxis; - (void)sendMouseEnterOrExitEvent:(NSEvent*)aEvent enter:(BOOL)aEnter - type:(mozilla::WidgetMouseEvent::exitType)aType; + exitFrom:(mozilla::WidgetMouseEvent::ExitFrom)aExitFrom; - (void)updateGLContext; - (void)_surfaceNeedsUpdate:(NSNotification*)notification; diff --git a/widget/cocoa/nsChildView.mm b/widget/cocoa/nsChildView.mm index a29213de91..d5c08de7d1 100644 --- a/widget/cocoa/nsChildView.mm +++ b/widget/cocoa/nsChildView.mm @@ -1786,7 +1786,7 @@ nsChildView::ExecuteNativeKeyBindingRemapped(NativeKeyBindingsType aType, NSEvent *originalEvent = reinterpret_cast(aEvent.mNativeKeyEvent); WidgetKeyboardEvent modifiedEvent(aEvent); - modifiedEvent.keyCode = aGeckoKeyCode; + modifiedEvent.mKeyCode = aGeckoKeyCode; unichar ch = nsCocoaUtils::ConvertGeckoKeyCodeToMacCharCode(aGeckoKeyCode); NSString *chars = @@ -1818,8 +1818,7 @@ nsChildView::ExecuteNativeKeyBinding(NativeKeyBindingsType aType, // vertical writing-mode, we'll remap so that the movement command // generated (in terms of characters/lines) will be appropriate for // the physical direction of the arrow. - if (aEvent.keyCode >= nsIDOMKeyEvent::DOM_VK_LEFT && - aEvent.keyCode <= nsIDOMKeyEvent::DOM_VK_DOWN) { + if (aEvent.mKeyCode >= NS_VK_LEFT && aEvent.mKeyCode <= NS_VK_DOWN) { WidgetQueryContentEvent query(true, eQuerySelectedText, this); DispatchWindowEvent(query); @@ -1827,34 +1826,34 @@ nsChildView::ExecuteNativeKeyBinding(NativeKeyBindingsType aType, uint32_t geckoKey = 0; uint32_t cocoaKey = 0; - switch (aEvent.keyCode) { - case nsIDOMKeyEvent::DOM_VK_LEFT: + switch (aEvent.mKeyCode) { + case NS_VK_LEFT: if (query.mReply.mWritingMode.IsVerticalLR()) { - geckoKey = nsIDOMKeyEvent::DOM_VK_UP; + geckoKey = NS_VK_UP; cocoaKey = kVK_UpArrow; } else { - geckoKey = nsIDOMKeyEvent::DOM_VK_DOWN; + geckoKey = NS_VK_DOWN; cocoaKey = kVK_DownArrow; } break; - case nsIDOMKeyEvent::DOM_VK_RIGHT: + case NS_VK_RIGHT: if (query.mReply.mWritingMode.IsVerticalLR()) { - geckoKey = nsIDOMKeyEvent::DOM_VK_DOWN; + geckoKey = NS_VK_DOWN; cocoaKey = kVK_DownArrow; } else { - geckoKey = nsIDOMKeyEvent::DOM_VK_UP; + geckoKey = NS_VK_UP; cocoaKey = kVK_UpArrow; } break; - case nsIDOMKeyEvent::DOM_VK_UP: - geckoKey = nsIDOMKeyEvent::DOM_VK_LEFT; + case NS_VK_UP: + geckoKey = NS_VK_LEFT; cocoaKey = kVK_LeftArrow; break; - case nsIDOMKeyEvent::DOM_VK_DOWN: - geckoKey = nsIDOMKeyEvent::DOM_VK_RIGHT; + case NS_VK_DOWN: + geckoKey = NS_VK_RIGHT; cocoaKey = kVK_RightArrow; break; } @@ -4550,7 +4549,7 @@ NSEvent* gLastDragMouseDownEvent = nil; // blocked. clickCount--; } - geckoEvent.clickCount = clickCount; + geckoEvent.mClickCount = clickCount; if (modifierFlags & NSControlKeyMask) geckoEvent.button = WidgetMouseEvent::eRightButton; @@ -4607,7 +4606,7 @@ NSEvent* gLastDragMouseDownEvent = nil; - (void)sendMouseEnterOrExitEvent:(NSEvent*)aEvent enter:(BOOL)aEnter - type:(WidgetMouseEvent::exitType)aType + exitFrom:(WidgetMouseEvent::ExitFrom)aExitFrom { if (!mGeckoChild) return; @@ -4619,7 +4618,7 @@ NSEvent* gLastDragMouseDownEvent = nil; WidgetMouseEvent event(true, msg, mGeckoChild, WidgetMouseEvent::eReal); event.mRefPoint = mGeckoChild->CocoaPointsToDevPixels(localEventLocation); - event.exit = aType; + event.mExitFrom = aExitFrom; nsEventStatus status; // ignored mGeckoChild->DispatchEvent(&event, status); @@ -4749,7 +4748,7 @@ NewCGSRegionFromRegion(const LayoutDeviceIntRegion& aRegion, WidgetMouseEvent::eReal); [self convertCocoaMouseEvent:theEvent toGeckoEvent:&geckoEvent]; geckoEvent.button = WidgetMouseEvent::eRightButton; - geckoEvent.clickCount = [theEvent clickCount]; + geckoEvent.mClickCount = [theEvent clickCount]; mGeckoChild->DispatchInputEvent(&geckoEvent); if (!mGeckoChild) @@ -4772,7 +4771,7 @@ NewCGSRegionFromRegion(const LayoutDeviceIntRegion& aRegion, WidgetMouseEvent::eReal); [self convertCocoaMouseEvent:theEvent toGeckoEvent:&geckoEvent]; geckoEvent.button = WidgetMouseEvent::eRightButton; - geckoEvent.clickCount = [theEvent clickCount]; + geckoEvent.mClickCount = [theEvent clickCount]; nsAutoRetainCocoaObject kungFuDeathGrip(self); mGeckoChild->DispatchInputEvent(&geckoEvent); @@ -4812,7 +4811,7 @@ NewCGSRegionFromRegion(const LayoutDeviceIntRegion& aRegion, WidgetMouseEvent::eReal); [self convertCocoaMouseEvent:theEvent toGeckoEvent:&geckoEvent]; geckoEvent.button = WidgetMouseEvent::eMiddleButton; - geckoEvent.clickCount = [theEvent clickCount]; + geckoEvent.mClickCount = [theEvent clickCount]; mGeckoChild->DispatchInputEvent(&geckoEvent); @@ -6319,15 +6318,19 @@ ChildViewMouseTracker::ReEvaluateMouseEnterState(NSEvent* aEvent, ChildView* aOl sLastMouseEventView = ViewForEvent(aEvent); if (sLastMouseEventView != oldView) { // Send enter and / or exit events. - WidgetMouseEvent::exitType type = + WidgetMouseEvent::ExitFrom exitFrom = [sLastMouseEventView window] == [oldView window] ? WidgetMouseEvent::eChild : WidgetMouseEvent::eTopLevel; - [oldView sendMouseEnterOrExitEvent:aEvent enter:NO type:type]; + [oldView sendMouseEnterOrExitEvent:aEvent + enter:NO + exitFrom:exitFrom]; // After the cursor exits the window set it to a visible regular arrow cursor. - if (type == WidgetMouseEvent::eTopLevel) { + if (exitFrom == WidgetMouseEvent::eTopLevel) { [[nsCursorManager sharedInstance] setCursor:eCursor_standard]; } - [sLastMouseEventView sendMouseEnterOrExitEvent:aEvent enter:YES type:type]; + [sLastMouseEventView sendMouseEnterOrExitEvent:aEvent + enter:YES + exitFrom:exitFrom]; } } diff --git a/widget/gonk/nsAppShell.cpp b/widget/gonk/nsAppShell.cpp index 5137a1e52d..9a5f7bf467 100644 --- a/widget/gonk/nsAppShell.cpp +++ b/widget/gonk/nsAppShell.cpp @@ -301,12 +301,12 @@ KeyEventDispatcher::DispatchKeyEventInternal(EventMessage aEventMessage) if (aEventMessage == eKeyPress) { // XXX If the charCode is not a printable character, the charCode // should be computed without Ctrl/Alt/Meta modifiers. - event.charCode = static_cast(mChar); + event.mCharCode = static_cast(mChar); } - if (!event.charCode) { - event.keyCode = mDOMKeyCode; + if (!event.mCharCode) { + event.mKeyCode = mDOMKeyCode; } - event.isChar = !!event.charCode; + event.mIsChar = !!event.mCharCode; event.mIsRepeat = IsRepeat(); event.mKeyNameIndex = mDOMKeyNameIndex; if (mDOMPrintableKeyValue) { @@ -314,7 +314,7 @@ KeyEventDispatcher::DispatchKeyEventInternal(EventMessage aEventMessage) } event.mCodeNameIndex = mDOMCodeNameIndex; event.mModifiers = getDOMModifiers(mData.metaState); - event.location = mDOMKeyLocation; + event.mLocation = mDOMKeyLocation; event.mTime = mData.timeMs; return nsWindow::DispatchKeyInput(event); } diff --git a/widget/gtk/NativeKeyBindings.cpp b/widget/gtk/NativeKeyBindings.cpp index 48478f6000..55a3508e26 100644 --- a/widget/gtk/NativeKeyBindings.cpp +++ b/widget/gtk/NativeKeyBindings.cpp @@ -303,8 +303,8 @@ NativeKeyBindings::Execute(const WidgetKeyboardEvent& aEvent, guint keyval; - if (aEvent.charCode) { - keyval = gdk_unicode_to_keyval(aEvent.charCode); + if (aEvent.mCharCode) { + keyval = gdk_unicode_to_keyval(aEvent.mCharCode); } else { keyval = static_cast(aEvent.mNativeKeyEvent)->keyval; @@ -314,11 +314,11 @@ NativeKeyBindings::Execute(const WidgetKeyboardEvent& aEvent, return true; } - for (uint32_t i = 0; i < aEvent.alternativeCharCodes.Length(); ++i) { + for (uint32_t i = 0; i < aEvent.mAlternativeCharCodes.Length(); ++i) { uint32_t ch = aEvent.IsShift() ? - aEvent.alternativeCharCodes[i].mShiftedCharCode : - aEvent.alternativeCharCodes[i].mUnshiftedCharCode; - if (ch && ch != aEvent.charCode) { + aEvent.mAlternativeCharCodes[i].mShiftedCharCode : + aEvent.mAlternativeCharCodes[i].mUnshiftedCharCode; + if (ch && ch != aEvent.mCharCode) { keyval = gdk_unicode_to_keyval(ch); if (ExecuteInternal(aEvent, aCallback, aCallbackData, keyval)) { return true; diff --git a/widget/gtk/nsGtkKeyUtils.cpp b/widget/gtk/nsGtkKeyUtils.cpp index 708a94ca18..73d15926e7 100644 --- a/widget/gtk/nsGtkKeyUtils.cpp +++ b/widget/gtk/nsGtkKeyUtils.cpp @@ -878,13 +878,13 @@ KeymapWrapper::InitKeyEvent(WidgetKeyboardEvent& aKeyEvent, AppendUCS4ToUTF16(charCode, aKeyEvent.mKeyValue); } } - aKeyEvent.keyCode = ComputeDOMKeyCode(aGdkKeyEvent); + aKeyEvent.mKeyCode = ComputeDOMKeyCode(aGdkKeyEvent); if (aKeyEvent.mKeyNameIndex != KEY_NAME_INDEX_USE_STRING || aKeyEvent.mMessage != eKeyPress) { - aKeyEvent.keyCode = ComputeDOMKeyCode(aGdkKeyEvent); + aKeyEvent.mKeyCode = ComputeDOMKeyCode(aGdkKeyEvent); } else { - aKeyEvent.keyCode = 0; + aKeyEvent.mKeyCode = 0; } // NOTE: The state of given key event indicates adjacent state of @@ -922,7 +922,7 @@ KeymapWrapper::InitKeyEvent(WidgetKeyboardEvent& aKeyEvent, case GDK_Super_L: case GDK_Hyper_L: case GDK_Meta_L: - aKeyEvent.location = nsIDOMKeyEvent::DOM_KEY_LOCATION_LEFT; + aKeyEvent.mLocation = nsIDOMKeyEvent::DOM_KEY_LOCATION_LEFT; break; case GDK_Shift_R: @@ -931,7 +931,7 @@ KeymapWrapper::InitKeyEvent(WidgetKeyboardEvent& aKeyEvent, case GDK_Super_R: case GDK_Hyper_R: case GDK_Meta_R: - aKeyEvent.location = nsIDOMKeyEvent::DOM_KEY_LOCATION_RIGHT; + aKeyEvent.mLocation = nsIDOMKeyEvent::DOM_KEY_LOCATION_RIGHT; break; case GDK_KP_0: @@ -969,11 +969,11 @@ KeymapWrapper::InitKeyEvent(WidgetKeyboardEvent& aKeyEvent, case GDK_KP_Subtract: case GDK_KP_Decimal: case GDK_KP_Divide: - aKeyEvent.location = nsIDOMKeyEvent::DOM_KEY_LOCATION_NUMPAD; + aKeyEvent.mLocation = nsIDOMKeyEvent::DOM_KEY_LOCATION_NUMPAD; break; default: - aKeyEvent.location = nsIDOMKeyEvent::DOM_KEY_LOCATION_STANDARD; + aKeyEvent.mLocation = nsIDOMKeyEvent::DOM_KEY_LOCATION_STANDARD; break; } @@ -1336,23 +1336,23 @@ KeymapWrapper::WillDispatchKeyboardEventInternal(WidgetKeyboardEvent& aKeyEvent, if (!charCode) { MOZ_LOG(gKeymapWrapperLog, LogLevel::Info, ("KeymapWrapper(%p): WillDispatchKeyboardEventInternal, " - "keyCode=0x%02X, charCode=0x%08X", - this, aKeyEvent.keyCode, aKeyEvent.charCode)); + "mKeyCode=0x%02X, charCode=0x%08X", + this, aKeyEvent.mKeyCode, aKeyEvent.mCharCode)); return; } - // The charCode was set from mKeyValue. However, for example, when Ctrl key + // The mCharCode was set from mKeyValue. However, for example, when Ctrl key // is pressed, its value should indicate an ASCII character for backward // compatibility rather than inputting character without the modifiers. - // Therefore, we need to modify charCode value here. + // Therefore, we need to modify mCharCode value here. aKeyEvent.SetCharCode(charCode); gint level = GetKeyLevel(aGdkKeyEvent); if (level != 0 && level != 1) { MOZ_LOG(gKeymapWrapperLog, LogLevel::Info, ("KeymapWrapper(%p): WillDispatchKeyboardEventInternal, " - "keyCode=0x%02X, charCode=0x%08X, level=%d", - this, aKeyEvent.keyCode, aKeyEvent.charCode, level)); + "mKeyCode=0x%02X, mCharCode=0x%08X, level=%d", + this, aKeyEvent.mKeyCode, aKeyEvent.mCharCode, level)); return; } @@ -1362,7 +1362,7 @@ KeymapWrapper::WillDispatchKeyboardEventInternal(WidgetKeyboardEvent& aKeyEvent, GetModifierMask(SUPER) | GetModifierMask(HYPER)); // We shold send both shifted char and unshifted char, all keyboard layout - // users can use all keys. Don't change event.charCode. On some keyboard + // users can use all keys. Don't change event.mCharCode. On some keyboard // layouts, Ctrl/Alt/Meta keys are used for inputting some characters. AlternativeCharCode altCharCodes(0, 0); // unshifted charcode of current keyboard layout. @@ -1376,7 +1376,7 @@ KeymapWrapper::WillDispatchKeyboardEventInternal(WidgetKeyboardEvent& aKeyEvent, aGdkKeyEvent->group); isLatin = isLatin && (altCharCodes.mShiftedCharCode <= 0xFF); if (altCharCodes.mUnshiftedCharCode || altCharCodes.mShiftedCharCode) { - aKeyEvent.alternativeCharCodes.AppendElement(altCharCodes); + aKeyEvent.mAlternativeCharCodes.AppendElement(altCharCodes); } bool needLatinKeyCodes = !isLatin; @@ -1391,9 +1391,9 @@ KeymapWrapper::WillDispatchKeyboardEventInternal(WidgetKeyboardEvent& aKeyEvent, if (!needLatinKeyCodes) { MOZ_LOG(gKeymapWrapperLog, LogLevel::Info, ("KeymapWrapper(%p): WillDispatchKeyboardEventInternal, " - "keyCode=0x%02X, charCode=0x%08X, level=%d, altCharCodes={ " + "mKeyCode=0x%02X, mCharCode=0x%08X, level=%d, altCharCodes={ " "mUnshiftedCharCode=0x%08X, mShiftedCharCode=0x%08X }", - this, aKeyEvent.keyCode, aKeyEvent.charCode, level, + this, aKeyEvent.mKeyCode, aKeyEvent.mCharCode, level, altCharCodes.mUnshiftedCharCode, altCharCodes.mShiftedCharCode)); return; } @@ -1404,10 +1404,10 @@ KeymapWrapper::WillDispatchKeyboardEventInternal(WidgetKeyboardEvent& aKeyEvent, MOZ_LOG(gKeymapWrapperLog, LogLevel::Info, ("KeymapWrapper(%p): WillDispatchKeyboardEventInternal, " "Latin keyboard layout isn't found: " - "keyCode=0x%02X, charCode=0x%08X, level=%d, " + "mKeyCode=0x%02X, mCharCode=0x%08X, level=%d, " "altCharCodes={ mUnshiftedCharCode=0x%08X, " "mShiftedCharCode=0x%08X }", - this, aKeyEvent.keyCode, aKeyEvent.charCode, level, + this, aKeyEvent.mKeyCode, aKeyEvent.mCharCode, level, altCharCodes.mUnshiftedCharCode, altCharCodes.mShiftedCharCode)); return; } @@ -1429,10 +1429,10 @@ KeymapWrapper::WillDispatchKeyboardEventInternal(WidgetKeyboardEvent& aKeyEvent, IsBasicLatinLetterOrNumeral(ch) ? ch : 0; if (altLatinCharCodes.mUnshiftedCharCode || altLatinCharCodes.mShiftedCharCode) { - aKeyEvent.alternativeCharCodes.AppendElement(altLatinCharCodes); + aKeyEvent.mAlternativeCharCodes.AppendElement(altLatinCharCodes); } - // If the charCode is not Latin, and the level is 0 or 1, we should - // replace the charCode to Latin char if Alt and Meta keys are not + // If the mCharCode is not Latin, and the level is 0 or 1, we should + // replace the mCharCode to Latin char if Alt and Meta keys are not // pressed. (Alt should be sent the localized char for accesskey // like handling of Web Applications.) ch = aKeyEvent.IsShift() ? altLatinCharCodes.mShiftedCharCode : @@ -1444,12 +1444,12 @@ KeymapWrapper::WillDispatchKeyboardEventInternal(WidgetKeyboardEvent& aKeyEvent, MOZ_LOG(gKeymapWrapperLog, LogLevel::Info, ("KeymapWrapper(%p): WillDispatchKeyboardEventInternal, " - "keyCode=0x%02X, charCode=0x%08X, level=%d, minGroup=%d, " + "mKeyCode=0x%02X, mCharCode=0x%08X, level=%d, minGroup=%d, " "altCharCodes={ mUnshiftedCharCode=0x%08X, " "mShiftedCharCode=0x%08X } " "altLatinCharCodes={ mUnshiftedCharCode=0x%08X, " "mShiftedCharCode=0x%08X }", - this, aKeyEvent.keyCode, aKeyEvent.charCode, level, minGroup, + this, aKeyEvent.mKeyCode, aKeyEvent.mCharCode, level, minGroup, altCharCodes.mUnshiftedCharCode, altCharCodes.mShiftedCharCode, altLatinCharCodes.mUnshiftedCharCode, altLatinCharCodes.mShiftedCharCode)); diff --git a/widget/gtk/nsWindow.cpp b/widget/gtk/nsWindow.cpp index 28cd86456d..ed541c12ac 100644 --- a/widget/gtk/nsWindow.cpp +++ b/widget/gtk/nsWindow.cpp @@ -2547,7 +2547,7 @@ nsWindow::OnLeaveNotifyEvent(GdkEventCrossing *aEvent) event.mRefPoint = GdkEventCoordsToDevicePixels(aEvent->x, aEvent->y); event.AssignEventTime(GetWidgetEventTime(aEvent->time)); - event.exit = is_top_level_mouse_exit(mGdkWindow, aEvent) + event.mExitFrom = is_top_level_mouse_exit(mGdkWindow, aEvent) ? WidgetMouseEvent::eTopLevel : WidgetMouseEvent::eChild; LOG(("OnLeaveNotify: %p\n", (void *)this)); @@ -2726,14 +2726,14 @@ nsWindow::InitButtonEvent(WidgetMouseEvent& aEvent, switch (aGdkEvent->type) { case GDK_2BUTTON_PRESS: - aEvent.clickCount = 2; + aEvent.mClickCount = 2; break; case GDK_3BUTTON_PRESS: - aEvent.clickCount = 3; + aEvent.mClickCount = 3; break; // default is one click default: - aEvent.clickCount = 1; + aEvent.mClickCount = 1; } } @@ -3116,7 +3116,7 @@ nsWindow::OnKeyPressEvent(GdkEventKey *aEvent) contextMenuEvent.mRefPoint = LayoutDeviceIntPoint(0, 0); contextMenuEvent.AssignEventTime(GetWidgetEventTime(aEvent->time)); - contextMenuEvent.clickCount = 1; + contextMenuEvent.mClickCount = 1; KeymapWrapper::InitInputEvent(contextMenuEvent, aEvent->state); DispatchInputEvent(&contextMenuEvent); } else { @@ -6213,10 +6213,10 @@ get_inner_gdk_window (GdkWindow *aWindow, static inline bool is_context_menu_key(const WidgetKeyboardEvent& aKeyEvent) { - return ((aKeyEvent.keyCode == NS_VK_F10 && aKeyEvent.IsShift() && + return ((aKeyEvent.mKeyCode == NS_VK_F10 && aKeyEvent.IsShift() && !aKeyEvent.IsControl() && !aKeyEvent.IsMeta() && !aKeyEvent.IsAlt()) || - (aKeyEvent.keyCode == NS_VK_CONTEXT_MENU && !aKeyEvent.IsShift() && + (aKeyEvent.mKeyCode == NS_VK_CONTEXT_MENU && !aKeyEvent.IsShift() && !aKeyEvent.IsControl() && !aKeyEvent.IsMeta() && !aKeyEvent.IsAlt())); } @@ -6360,7 +6360,7 @@ nsWindow::ExecuteNativeKeyBindingRemapped(NativeKeyBindingsType aType, uint32_t aNativeKeyCode) { WidgetKeyboardEvent modifiedEvent(aEvent); - modifiedEvent.keyCode = aGeckoKeyCode; + modifiedEvent.mKeyCode = aGeckoKeyCode; static_cast(modifiedEvent.mNativeKeyEvent)->keyval = aNativeKeyCode; @@ -6374,8 +6374,7 @@ nsWindow::ExecuteNativeKeyBinding(NativeKeyBindingsType aType, DoCommandCallback aCallback, void* aCallbackData) { - if (aEvent.keyCode >= nsIDOMKeyEvent::DOM_VK_LEFT && - aEvent.keyCode <= nsIDOMKeyEvent::DOM_VK_DOWN) { + if (aEvent.mKeyCode >= NS_VK_LEFT && aEvent.mKeyCode <= NS_VK_DOWN) { // Check if we're targeting content with vertical writing mode, // and if so remap the arrow keys. @@ -6386,34 +6385,34 @@ nsWindow::ExecuteNativeKeyBinding(NativeKeyBindingsType aType, if (query.mSucceeded && query.mReply.mWritingMode.IsVertical()) { uint32_t geckoCode = 0; uint32_t gdkCode = 0; - switch (aEvent.keyCode) { - case nsIDOMKeyEvent::DOM_VK_LEFT: + switch (aEvent.mKeyCode) { + case NS_VK_LEFT: if (query.mReply.mWritingMode.IsVerticalLR()) { - geckoCode = nsIDOMKeyEvent::DOM_VK_UP; + geckoCode = NS_VK_UP; gdkCode = GDK_Up; } else { - geckoCode = nsIDOMKeyEvent::DOM_VK_DOWN; + geckoCode = NS_VK_DOWN; gdkCode = GDK_Down; } break; - case nsIDOMKeyEvent::DOM_VK_RIGHT: + case NS_VK_RIGHT: if (query.mReply.mWritingMode.IsVerticalLR()) { - geckoCode = nsIDOMKeyEvent::DOM_VK_DOWN; + geckoCode = NS_VK_DOWN; gdkCode = GDK_Down; } else { - geckoCode = nsIDOMKeyEvent::DOM_VK_UP; + geckoCode = NS_VK_UP; gdkCode = GDK_Up; } break; - case nsIDOMKeyEvent::DOM_VK_UP: - geckoCode = nsIDOMKeyEvent::DOM_VK_LEFT; + case NS_VK_UP: + geckoCode = NS_VK_LEFT; gdkCode = GDK_Left; break; - case nsIDOMKeyEvent::DOM_VK_DOWN: - geckoCode = nsIDOMKeyEvent::DOM_VK_RIGHT; + case NS_VK_DOWN: + geckoCode = NS_VK_RIGHT; gdkCode = GDK_Right; break; } diff --git a/widget/nsGUIEventIPC.h b/widget/nsGUIEventIPC.h index 28b5812d8b..adb373e23b 100644 --- a/widget/nsGUIEventIPC.h +++ b/widget/nsGUIEventIPC.h @@ -28,7 +28,7 @@ struct ParamTraits WriteParam(aMsg, static_cast(aParam)); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { mozilla::EventMessageType eventMessage = 0; bool ret = ReadParam(aMsg, aIter, &eventMessage); @@ -47,7 +47,7 @@ struct ParamTraits aMsg->WriteBytes(&aParam, sizeof(aParam)); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { const char* outp; if (!aMsg->ReadBytes(aIter, &outp, sizeof(*aResult))) { @@ -74,7 +74,7 @@ struct ParamTraits WriteParam(aMsg, aParam.mFlags); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { mozilla::EventClassIDType eventClassID = 0; bool ret = ReadParam(aMsg, aIter, &eventClassID) && @@ -98,7 +98,7 @@ struct ParamTraits WriteParam(aMsg, aParam.mBuffer); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { return ReadParam(aMsg, aIter, &aResult->mBuffer); } @@ -115,7 +115,7 @@ struct ParamTraits WriteParam(aMsg, aParam.mPluginEvent); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { return ReadParam(aMsg, aIter, static_cast(aResult)) && ReadParam(aMsg, aIter, &aResult->mPluginEvent); @@ -133,7 +133,7 @@ struct ParamTraits WriteParam(aMsg, aParam.mModifiers); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { return ReadParam(aMsg, aIter, static_cast(aResult)) && @@ -156,7 +156,7 @@ struct ParamTraits WriteParam(aMsg, aParam.inputSource); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { return ReadParam(aMsg, aIter, static_cast(aResult)) && @@ -194,7 +194,7 @@ struct ParamTraits WriteParam(aMsg, aParam.mAllowToOverrideSystemScrollSpeed); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { uint8_t scrollType = 0; bool rv = @@ -230,29 +230,31 @@ struct ParamTraits static void Write(Message* aMsg, const paramType& aParam) { WriteParam(aMsg, static_cast(aParam)); - WriteParam(aMsg, aParam.ignoreRootScrollFrame); - WriteParam(aMsg, (uint8_t) aParam.reason); - WriteParam(aMsg, (uint8_t) aParam.context); - WriteParam(aMsg, (uint8_t) aParam.exit); - WriteParam(aMsg, aParam.clickCount); + WriteParam(aMsg, aParam.mIgnoreRootScrollFrame); + WriteParam(aMsg, static_cast(aParam.mReason)); + WriteParam(aMsg, static_cast( + aParam.mContextMenuTrigger)); + WriteParam(aMsg, static_cast(aParam.mExitFrom)); + WriteParam(aMsg, aParam.mClickCount); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { bool rv; - uint8_t reason = 0, context = 0, exit = 0; + paramType::ReasonType reason = 0; + paramType::ContextMenuTriggerType contextMenuTrigger = 0; + paramType::ExitFromType exitFrom = 0; rv = ReadParam(aMsg, aIter, static_cast(aResult)) && - ReadParam(aMsg, aIter, &aResult->ignoreRootScrollFrame) && + ReadParam(aMsg, aIter, &aResult->mIgnoreRootScrollFrame) && ReadParam(aMsg, aIter, &reason) && - ReadParam(aMsg, aIter, &context) && - ReadParam(aMsg, aIter, &exit) && - ReadParam(aMsg, aIter, &aResult->clickCount); - aResult->reason = - static_cast(reason); - aResult->context = - static_cast(context); - aResult->exit = static_cast(exit); + ReadParam(aMsg, aIter, &contextMenuTrigger) && + ReadParam(aMsg, aIter, &exitFrom) && + ReadParam(aMsg, aIter, &aResult->mClickCount); + aResult->mReason = static_cast(reason); + aResult->mContextMenuTrigger = + static_cast(contextMenuTrigger); + aResult->mExitFrom = static_cast(exitFrom); return rv; } }; @@ -270,7 +272,7 @@ struct ParamTraits WriteParam(aMsg, aParam.mDefaultPreventedOnContent); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { bool rv = ReadParam(aMsg, aIter, static_cast(aResult)) && @@ -296,7 +298,7 @@ struct ParamTraits WriteParam(aMsg, aParam.isPrimary); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { bool rv = ReadParam(aMsg, aIter, static_cast(aResult)) && @@ -332,7 +334,7 @@ struct ParamTraits } } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { paramType::TouchArray::size_type numTouches; if (!ReadParam(aMsg, aIter, @@ -372,7 +374,7 @@ struct ParamTraits WriteParam(aMsg, aParam.mShiftedCharCode); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { return ReadParam(aMsg, aIter, &aResult->mUnshiftedCharCode) && ReadParam(aMsg, aIter, &aResult->mShiftedCharCode); @@ -388,22 +390,25 @@ struct ParamTraits static void Write(Message* aMsg, const paramType& aParam) { WriteParam(aMsg, static_cast(aParam)); - WriteParam(aMsg, static_cast(aParam.mKeyNameIndex)); - WriteParam(aMsg, static_cast(aParam.mCodeNameIndex)); + WriteParam(aMsg, + static_cast(aParam.mKeyNameIndex)); + WriteParam(aMsg, + static_cast(aParam.mCodeNameIndex)); WriteParam(aMsg, aParam.mKeyValue); WriteParam(aMsg, aParam.mCodeValue); - WriteParam(aMsg, aParam.keyCode); - WriteParam(aMsg, aParam.charCode); + WriteParam(aMsg, aParam.mKeyCode); + WriteParam(aMsg, aParam.mCharCode); WriteParam(aMsg, aParam.mPseudoCharCode); - WriteParam(aMsg, aParam.alternativeCharCodes); - WriteParam(aMsg, aParam.isChar); + WriteParam(aMsg, aParam.mAlternativeCharCodes); + WriteParam(aMsg, aParam.mIsChar); WriteParam(aMsg, aParam.mIsRepeat); WriteParam(aMsg, aParam.mIsReserved); - WriteParam(aMsg, aParam.location); + WriteParam(aMsg, aParam.mAccessKeyForwardedToChild); + WriteParam(aMsg, aParam.mLocation); WriteParam(aMsg, aParam.mUniqueId); WriteParam(aMsg, aParam.mIsSynthesizedByTIP); WriteParam(aMsg, - static_cast + static_cast (aParam.mInputMethodAppState)); #ifdef XP_MACOSX WriteParam(aMsg, aParam.mNativeKeyCode); @@ -416,25 +421,26 @@ struct ParamTraits // that cannot be copied across process boundaries. } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { - uint32_t keyNameIndex = 0, codeNameIndex = 0; - mozilla::WidgetKeyboardEvent::InputMethodAppStateType - inputMethodAppState = 0; + mozilla::KeyNameIndexType keyNameIndex = 0; + mozilla::CodeNameIndexType codeNameIndex = 0; + paramType::InputMethodAppStateType inputMethodAppState = 0; if (ReadParam(aMsg, aIter, static_cast(aResult)) && ReadParam(aMsg, aIter, &keyNameIndex) && ReadParam(aMsg, aIter, &codeNameIndex) && ReadParam(aMsg, aIter, &aResult->mKeyValue) && ReadParam(aMsg, aIter, &aResult->mCodeValue) && - ReadParam(aMsg, aIter, &aResult->keyCode) && - ReadParam(aMsg, aIter, &aResult->charCode) && + ReadParam(aMsg, aIter, &aResult->mKeyCode) && + ReadParam(aMsg, aIter, &aResult->mCharCode) && ReadParam(aMsg, aIter, &aResult->mPseudoCharCode) && - ReadParam(aMsg, aIter, &aResult->alternativeCharCodes) && - ReadParam(aMsg, aIter, &aResult->isChar) && + ReadParam(aMsg, aIter, &aResult->mAlternativeCharCodes) && + ReadParam(aMsg, aIter, &aResult->mIsChar) && ReadParam(aMsg, aIter, &aResult->mIsRepeat) && ReadParam(aMsg, aIter, &aResult->mIsReserved) && - ReadParam(aMsg, aIter, &aResult->location) && + ReadParam(aMsg, aIter, &aResult->mAccessKeyForwardedToChild) && + ReadParam(aMsg, aIter, &aResult->mLocation) && ReadParam(aMsg, aIter, &aResult->mUniqueId) && ReadParam(aMsg, aIter, &aResult->mIsSynthesizedByTIP) && ReadParam(aMsg, aIter, &inputMethodAppState) @@ -452,8 +458,7 @@ struct ParamTraits static_cast(codeNameIndex); aResult->mNativeKeyEvent = nullptr; aResult->mInputMethodAppState = - static_cast - (inputMethodAppState); + static_cast(inputMethodAppState); return true; } return false; @@ -472,7 +477,7 @@ struct ParamTraits WriteParam(aMsg, aParam.mEmbeddedCancelled.Value()); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { bool isNull; bool value; @@ -506,7 +511,7 @@ struct ParamTraits WriteParam(aMsg, aParam.mUnderlineColor); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { return ReadParam(aMsg, aIter, &aResult->mDefinedStyles) && ReadParam(aMsg, aIter, &aResult->mLineStyle) && @@ -530,7 +535,7 @@ struct ParamTraits WriteParam(aMsg, aParam.mRangeStyle); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { return ReadParam(aMsg, aIter, &aResult->mStartOffset) && ReadParam(aMsg, aIter, &aResult->mEndOffset) && @@ -552,7 +557,7 @@ struct ParamTraits } } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { paramType::size_type length; if (!ReadParam(aMsg, aIter, &length)) { @@ -587,7 +592,7 @@ struct ParamTraits } } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { bool hasRanges; if (!ReadParam(aMsg, aIter, @@ -622,7 +627,7 @@ struct ParamTraits WriteParam(aMsg, aParam.mFontSize); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { return ReadParam(aMsg, aIter, &aResult->mStartOffset) && ReadParam(aMsg, aIter, &aResult->mFontName) && @@ -653,7 +658,7 @@ struct ParamTraits WriteParam(aMsg, aParam.mReply.mFontRanges); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { return ReadParam(aMsg, aIter, static_cast(aResult)) && @@ -689,7 +694,7 @@ struct ParamTraits WriteParam(aMsg, aParam.mUseNativeLineBreak); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { return ReadParam(aMsg, aIter, static_cast(aResult)) && @@ -712,7 +717,7 @@ struct ParamTraits WriteParam(aMsg, aParam.mWantUpdates); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { return ReadParam(aMsg, aIter, &aResult->mWantUpdates); } @@ -729,7 +734,7 @@ struct ParamTraits WriteParam(aMsg, aParam.mOriginProcessID); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { return ReadParam(aMsg, aIter, &aResult->mRawNativeIMEContext) && ReadParam(aMsg, aIter, &aResult->mOriginProcessID); @@ -747,7 +752,7 @@ struct ParamTraits WriteParam(aMsg, aParam.mY); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { return ReadParam(aMsg, aIter, &aResult->mX) && ReadParam(aMsg, aIter, &aResult->mY); @@ -767,7 +772,7 @@ struct ParamTraits WriteParam(aMsg, aParam.mHeight); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { return ReadParam(aMsg, aIter, &aResult->mX) && ReadParam(aMsg, aIter, &aResult->mY) && @@ -793,7 +798,7 @@ struct ParamTraits WriteParam(aMsg, aParam.mOccurredDuringComposition); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { aResult->mString = new nsString(); return ReadParam(aMsg, aIter, &aResult->mOffset) && @@ -821,7 +826,7 @@ struct ParamTraits WriteParam(aMsg, aParam.mIncludingChangesWithoutComposition); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { return ReadParam(aMsg, aIter, &aResult->mStartOffset) && ReadParam(aMsg, aIter, &aResult->mRemovedEndOffset) && @@ -850,7 +855,7 @@ struct ParamTraits WriteParam(aMsg, aParam.mModifiers); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { return ReadParam(aMsg, aIter, &aResult->mEventMessage) && ReadParam(aMsg, aIter, &aResult->mOffset) && @@ -886,7 +891,7 @@ struct ParamTraits } } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { mozilla::widget::IMEMessageType IMEMessage = 0; if (!ReadParam(aMsg, aIter, &IMEMessage)) { @@ -917,7 +922,7 @@ struct ParamTraits WriteParam(aMsg, aParam.mRetargetToFocusedDocument); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { return ReadParam(aMsg, aIter, static_cast(aResult)) && @@ -935,7 +940,7 @@ struct ParamTraits WriteParam(aMsg, aParam.mWritingMode); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { return ReadParam(aMsg, aIter, &aResult->mWritingMode); } @@ -963,7 +968,7 @@ struct ParamTraits WriteParam(aMsg, aParam.mEditorRect); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { return ReadParam(aMsg, aIter, &aResult->mText) && ReadParam(aMsg, aIter, &aResult->mSelection.mAnchor) && @@ -993,7 +998,7 @@ struct ParamTraits WriteParam(aMsg, aParam.mExcludeRect); } - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { return ReadParam(aMsg, aIter, &aResult->mPoint) && ReadParam(aMsg, aIter, &aResult->mRect) && diff --git a/widget/qt/nsWindow.cpp b/widget/qt/nsWindow.cpp index cd60386a3a..d56b5682a9 100644 --- a/widget/qt/nsWindow.cpp +++ b/widget/qt/nsWindow.cpp @@ -950,7 +950,7 @@ InitMouseEvent(WidgetMouseEvent& aMouseEvent, QMouseEvent* aEvent, aEvent->modifiers() & Qt::AltModifier, aEvent->modifiers() & Qt::ShiftModifier, aEvent->modifiers() & Qt::MetaModifier); - aMouseEvent.clickCount = aClickCount; + aMouseEvent.mClickCount = aClickCount; switch (aEvent->button()) { case Qt::LeftButton: @@ -1112,12 +1112,12 @@ InitKeyEvent(WidgetKeyboardEvent& aEvent, QKeyEvent* aQEvent) } if (aQEvent->text().length() && aQEvent->text()[0].isPrint()) { - aEvent.charCode = (int32_t) aQEvent->text()[0].unicode(); - aEvent.keyCode = 0; + aEvent.mCharCode = static_cast(aQEvent->text()[0].unicode()); + aEvent.mKeyCode = 0; aEvent.mKeyNameIndex = KEY_NAME_INDEX_PrintableKey; } else { - aEvent.charCode = 0; - aEvent.keyCode = QtKeyCodeToDOMKeyCode(aQEvent->key()); + aEvent.mCharCode = 0; + aEvent.mKeyCode = QtKeyCodeToDOMKeyCode(aQEvent->key()); aEvent.mKeyNameIndex = QtKeyCodeToDOMKeyNameIndex(aQEvent->key()); } @@ -1976,7 +1976,7 @@ nsWindow::ProcessMotionEvent() mMoveEvent.modifiers & Qt::AltModifier, mMoveEvent.modifiers & Qt::ShiftModifier, mMoveEvent.modifiers & Qt::MetaModifier); - event.clickCount = 0; + event.mClickCount = 0; DispatchEvent(&event); mMoveEvent.needDispatch = false; diff --git a/widget/uikit/nsWindow.mm b/widget/uikit/nsWindow.mm index 84a8ee98cb..8c98a16594 100644 --- a/widget/uikit/nsWindow.mm +++ b/widget/uikit/nsWindow.mm @@ -144,7 +144,7 @@ private: WidgetMouseEvent::eReal, WidgetMouseEvent::eNormal); event.mRefPoint = aPoint; - event.clickCount = 1; + event.mClickCount = 1; event.button = WidgetMouseEvent::eLeftButton; event.mTime = PR_IntervalNow(); event.inputSource = nsIDOMMouseEvent::MOZ_SOURCE_UNKNOWN; diff --git a/widget/windows/KeyboardLayout.cpp b/widget/windows/KeyboardLayout.cpp index a649e61e87..26b7cfe631 100644 --- a/widget/windows/KeyboardLayout.cpp +++ b/widget/windows/KeyboardLayout.cpp @@ -13,6 +13,9 @@ #include "mozilla/WindowsVersion.h" #include "nsAlgorithm.h" +#ifdef MOZ_CRASHREPORTER +#include "nsExceptionHandler.h" +#endif #include "nsGkAtoms.h" #include "nsIDOMKeyEvent.h" #include "nsIIdleServiceInternal.h" @@ -723,23 +726,6 @@ NativeKey::NativeKey(nsWindowBase* aWidget, case WM_KEYUP: case WM_SYSKEYUP: case MOZ_WM_KEYUP: { - // If the key message is sent from other application like a11y tools, the - // scancode value might not be set proper value. Then, probably the value - // is 0. - // NOTE: If the virtual keycode can be caused by both non-extended key - // and extended key, the API returns the non-extended key's - // scancode. E.g., VK_LEFT causes "4" key on numpad. - // NOTE: Cannot compute scancode from keycode if the key message comes - // from plugin process since active keyboard layout may be - // different. - if (!mScanCode) { - uint16_t scanCodeEx = ComputeScanCodeExFromVirtualKeyCode(mMsg.wParam); - if (scanCodeEx) { - mScanCode = static_cast(scanCodeEx & 0xFF); - uint8_t extended = static_cast((scanCodeEx & 0xFF00) >> 8); - mIsExtended = (extended == 0xE0) || (extended == 0xE1); - } - } // First, resolve the IME converted virtual keycode to its original // keycode. if (mMsg.wParam == VK_PROCESSKEY) { @@ -749,6 +735,21 @@ NativeKey::NativeKey(nsWindowBase* aWidget, mOriginalVirtualKeyCode = static_cast(mMsg.wParam); } + // If the key message is sent from other application like a11y tools, the + // scancode value might not be set proper value. Then, probably the value + // is 0. + // NOTE: If the virtual keycode can be caused by both non-extended key + // and extended key, the API returns the non-extended key's + // scancode. E.g., VK_LEFT causes "4" key on numpad. + if (!mScanCode && mOriginalVirtualKeyCode != VK_PACKET) { + uint16_t scanCodeEx = ComputeScanCodeExFromVirtualKeyCode(mMsg.wParam); + if (scanCodeEx) { + mScanCode = static_cast(scanCodeEx & 0xFF); + uint8_t extended = static_cast((scanCodeEx & 0xFF00) >> 8); + mIsExtended = (extended == 0xE0) || (extended == 0xE1); + } + } + // Most keys are not distinguished as left or right keys. bool isLeftRightDistinguishedKey = false; @@ -892,12 +893,36 @@ NativeKey::NativeKey(nsWindowBase* aWidget, keyboardLayout->IsDeadKey(mOriginalVirtualKeyCode, mModKeyState)); mIsPrintableKey = KeyboardLayout::IsPrintableCharKey(mOriginalVirtualKeyCode); - // Compute some strings which may be inputted by the key with various - // modifier state if this key event won't cause text input actually. - // They will be used for setting alternativeCharCodes in the callback - // method which will be called by TextEventDispatcher. - if (IsKeyDownMessage() && NeedsToHandleWithoutFollowingCharMessages()) { - ComputeInputtingStringWithKeyboardLayout(); + if (IsKeyDownMessage()) { + // Compute some strings which may be inputted by the key with various + // modifier state if this key event won't cause text input actually. + // They will be used for setting mAlternativeCharCodes in the callback + // method which will be called by TextEventDispatcher. + if (NeedsToHandleWithoutFollowingCharMessages()) { + ComputeInputtingStringWithKeyboardLayout(); + } else { + // This message might be sent by SendInput() API to input a Unicode + // character, in such case, we can only know what char will be inputted + // with following WM_CHAR message. + // TODO: We cannot initialize mCommittedCharsAndModifiers for VK_PACKET + // if the message is WM_KEYUP because we don't have preceding + // WM_CHAR message. Therefore, we should dispatch eKeyUp event at + // handling WM_KEYDOWN. + // TODO: Like Edge, we shouldn't dispatch two sets of keyboard events + // for a Unicode character in non-BMP because its key value looks + // broken and not good thing for our editor if only one keydown or + // keypress event's default is prevented. I guess, we should store + // key message information globally and we should wait following + // WM_KEYDOWN if following WM_CHAR is a part of a Unicode character. + MSG followingCharMsg; + if (GetFollowingCharMessage(followingCharMsg, false) && + !IsControlChar(static_cast(followingCharMsg.wParam))) { + mCommittedCharsAndModifiers.Clear(); + mCommittedCharsAndModifiers.Append( + static_cast(followingCharMsg.wParam), + mModKeyState.GetModifiers()); + } + } } } @@ -1005,6 +1030,13 @@ NativeKey::InitWithAppCommand() GetScanCodeWithExtendedFlag()); } +bool +NativeKey::IsControlChar(char16_t aChar) const +{ + static const char16_t U_SPACE = 0x20; + return aChar < U_SPACE; +} + bool NativeKey::IsFollowedByDeadCharMessage() const { @@ -1206,14 +1238,14 @@ NativeKey::InitKeyEvent(WidgetKeyboardEvent& aKeyEvent, switch (aKeyEvent.mMessage) { case eKeyDown: case eKeyDownOnPlugin: - aKeyEvent.keyCode = mDOMKeyCode; + aKeyEvent.mKeyCode = mDOMKeyCode; // Unique id for this keydown event and its associated keypress. sUniqueKeyEventId++; aKeyEvent.mUniqueId = sUniqueKeyEventId; break; case eKeyUp: case eKeyUpOnPlugin: - aKeyEvent.keyCode = mDOMKeyCode; + aKeyEvent.mKeyCode = mDOMKeyCode; // Set defaultPrevented of the key event if the VK_MENU is not a system // key release, so that the menu bar does not trigger. This helps avoid // triggering the menu bar for ALT key accelerators used in assistive @@ -1237,7 +1269,7 @@ NativeKey::InitKeyEvent(WidgetKeyboardEvent& aKeyEvent, } aKeyEvent.mCodeNameIndex = mCodeNameIndex; MOZ_ASSERT(mCodeNameIndex != CODE_NAME_INDEX_USE_STRING); - aKeyEvent.location = GetKeyLocation(); + aKeyEvent.mLocation = GetKeyLocation(); aModKeyState.InitInputEvent(aKeyEvent); NPEvent pluginEvent; @@ -1601,6 +1633,12 @@ NativeKey::HandleKeyDownMessage(bool* aEventDispatched) const return DispatchKeyPressEventForFollowingCharMessage(followingCharMsg); } + // If WM_KEYDOWN of VK_PACKET isn't followed by WM_CHAR, we don't need to + // dispatch keypress events. + if (mVirtualKeyCode == VK_PACKET) { + return false; + } + if (!mModKeyState.IsControl() && !mModKeyState.IsAlt() && !mModKeyState.IsWin() && mIsPrintableKey) { // If this is simple KeyDown event but next message is not WM_CHAR, @@ -1643,7 +1681,6 @@ NativeKey::HandleCharMessage(const MSG& aCharMsg, // should cause composition events because they are not caused // by actual keyboard operation. - static const char16_t U_SPACE = 0x20; static const char16_t U_EQUAL = 0x3D; // First, handle normal text input or non-printable key case here. @@ -1652,10 +1689,10 @@ NativeKey::HandleCharMessage(const MSG& aCharMsg, (mOriginalVirtualKeyCode && !KeyboardLayout::IsPrintableCharKey(mOriginalVirtualKeyCode))) { WidgetKeyboardEvent keypressEvent(true, eKeyPress, mWidget); - if (aCharMsg.wParam >= U_SPACE) { - keypressEvent.charCode = static_cast(aCharMsg.wParam); + if (!IsControlChar(static_cast(aCharMsg.wParam))) { + keypressEvent.mCharCode = static_cast(aCharMsg.wParam); } else { - keypressEvent.keyCode = mDOMKeyCode; + keypressEvent.mKeyCode = mDOMKeyCode; } nsresult rv = mDispatcher->BeginNativeInputTransaction(); if (NS_WARN_IF(NS_FAILED(rv))) { @@ -1686,7 +1723,8 @@ NativeKey::HandleCharMessage(const MSG& aCharMsg, char16_t uniChar; // Ctrl+A Ctrl+Z, see Programming Windows 3.1 page 110 for details - if (mModKeyState.IsControl() && aCharMsg.wParam <= 0x1A) { + if (mModKeyState.IsControl() && + IsControlChar(static_cast(aCharMsg.wParam))) { // Bug 16486: Need to account for shift here. uniChar = aCharMsg.wParam - 1 + (mModKeyState.IsShift() ? 'A' : 'a'); } else if (mModKeyState.IsControl() && aCharMsg.wParam <= 0x1F) { @@ -1695,7 +1733,7 @@ NativeKey::HandleCharMessage(const MSG& aCharMsg, // for some reason the keypress handler need to have the uniChar code set // with the addition of a upper case A not the lower case. uniChar = aCharMsg.wParam - 1 + 'A'; - } else if (aCharMsg.wParam < U_SPACE || + } else if (IsControlChar(static_cast(aCharMsg.wParam)) || (aCharMsg.wParam == U_EQUAL && mModKeyState.IsControl())) { uniChar = 0; } else { @@ -1729,9 +1767,9 @@ NativeKey::HandleCharMessage(const MSG& aCharMsg, } WidgetKeyboardEvent keypressEvent(true, eKeyPress, mWidget); - keypressEvent.charCode = uniChar; - if (!keypressEvent.charCode) { - keypressEvent.keyCode = mDOMKeyCode; + keypressEvent.mCharCode = uniChar; + if (!keypressEvent.mCharCode) { + keypressEvent.mKeyCode = mDOMKeyCode; } nsEventStatus status = InitKeyEvent(keypressEvent, mModKeyState, &aCharMsg); bool dispatched = @@ -1787,6 +1825,12 @@ NativeKey::NeedsToHandleWithoutFollowingCharMessages() const return true; } + // If the keydown message is generated for inputting some Unicode characters + // via SendInput() API, we need to handle it only with WM_*CHAR messages. + if (mVirtualKeyCode == VK_PACKET) { + return false; + } + // Enter and backspace are always handled here to avoid for example the // confusion between ctrl-enter and ctrl-J. if (mDOMKeyCode == NS_VK_RETURN || mDOMKeyCode == NS_VK_BACK) { @@ -1817,6 +1861,61 @@ NativeKey::NeedsToHandleWithoutFollowingCharMessages() const return mIsPrintableKey; } +#ifdef MOZ_CRASHREPORTER + +static nsCString +GetResultOfInSendMessageEx() +{ + DWORD ret = ::InSendMessageEx(nullptr); + if (!ret) { + return NS_LITERAL_CSTRING("ISMEX_NOSEND"); + } + nsAutoCString result; + if (ret & ISMEX_CALLBACK) { + result = "ISMEX_CALLBACK"; + } + if (ret & ISMEX_NOTIFY) { + if (!result.IsEmpty()) { + result += " | "; + } + result += "ISMEX_NOTIFY"; + } + if (ret & ISMEX_REPLIED) { + if (!result.IsEmpty()) { + result += " | "; + } + result += "ISMEX_REPLIED"; + } + if (ret & ISMEX_SEND) { + if (!result.IsEmpty()) { + result += " | "; + } + result += "ISMEX_SEND"; + } + return result; +} + +static const char* +GetMessageName(UINT aMessage) +{ + switch (aMessage) { + case WM_KEYDOWN: return "WM_KEYDOWN"; + case WM_SYSKEYDOWN: return "WM_SYSKEYDOWN"; + case WM_KEYUP: return "WM_KEYUP"; + case WM_SYSKEYUP: return "WM_SYSKEYUP"; + case WM_CHAR: return "WM_CHAR"; + case WM_DEADCHAR: return "WM_DEADCHAR"; + case WM_SYSCHAR: return "WM_SYSCHAR"; + case WM_SYSDEADCHAR: return "WM_SYSDEADCHAR"; + case WM_UNICHAR: return "WM_UNICHAR"; + case WM_QUIT: return "WM_QUIT"; + case WM_NULL: return "WM_NULL"; + default: return "Unknown"; + } +} + +#endif // #ifdef MOZ_CRASHREPORTER + bool NativeKey::MayBeSameCharMessage(const MSG& aCharMsg1, const MSG& aCharMsg2) const @@ -1832,7 +1931,7 @@ NativeKey::MayBeSameCharMessage(const MSG& aCharMsg1, } bool -NativeKey::GetFollowingCharMessage(MSG& aCharMsg) const +NativeKey::GetFollowingCharMessage(MSG& aCharMsg, bool aRemove) const { MOZ_ASSERT(IsKeyDownMessage()); MOZ_ASSERT(!IsKeyMessageOnPlugin()); @@ -1846,7 +1945,7 @@ NativeKey::GetFollowingCharMessage(MSG& aCharMsg) const continue; } MSG charMsg = fakeCharMsg.GetCharMsg(mMsg.hwnd); - fakeCharMsg.mConsumed = true; + fakeCharMsg.mConsumed = aRemove; if (!IsCharMessage(charMsg)) { return false; } @@ -1868,6 +1967,11 @@ NativeKey::GetFollowingCharMessage(MSG& aCharMsg) const return false; } + if (!aRemove) { + aCharMsg = nextKeyMsg; + return true; + } + // On Metrofox, PeekMessage() sometimes returns WM_NULL even if we specify // the message range. So, if it returns WM_NULL, we should retry to get // the following char message it was found above. @@ -1907,6 +2011,45 @@ NativeKey::GetFollowingCharMessage(MSG& aCharMsg) const } if (doCrash) { +#ifdef MOZ_CRASHREPORTER + nsPrintfCString info("\nPeekMessage() failed to remove char message! " + "\nHandling message: %s (0x%08X), wParam: 0x%08X, " + "lParam: 0x%08X, hwnd=0x%p, InSendMessageEx()=%s, \n" + "Found message: %s (0x%08X), wParam: 0x%08X, " + "lParam: 0x%08X, hwnd=0x%p, " + "\nWM_NULL has been removed: %d, " + "\nNext key message in all windows: %s (0x%08X), " + "wParam: 0x%08X, lParam: 0x%08X, hwnd=0x%p, " + "time=%d, ", + GetMessageName(mMsg.message), + mMsg.message, mMsg.wParam, mMsg.lParam, + nextKeyMsg.hwnd, + GetResultOfInSendMessageEx().get(), + GetMessageName(nextKeyMsg.message), + nextKeyMsg.message, nextKeyMsg.wParam, + nextKeyMsg.lParam, nextKeyMsg.hwnd, i, + GetMessageName(nextKeyMsgInAllWindows.message), + nextKeyMsgInAllWindows.message, + nextKeyMsgInAllWindows.wParam, + nextKeyMsgInAllWindows.lParam, + nextKeyMsgInAllWindows.hwnd, + nextKeyMsgInAllWindows.time); + CrashReporter::AppendAppNotesToCrashReport(info); + MSG nextMsg; + if (WinUtils::PeekMessage(&nextMsg, 0, 0, 0, + PM_NOREMOVE | PM_NOYIELD)) { + nsPrintfCString info("\nNext message in all windows: %s (0x%08X), " + "wParam: 0x%08X, lParam: 0x%08X, hwnd=0x%p, " + "time=%d", + GetMessageName(nextMsg.message), + nextMsg.message, nextMsg.wParam, nextMsg.lParam, + nextMsg.hwnd, nextMsg.time); + CrashReporter::AppendAppNotesToCrashReport(info); + } else { + CrashReporter::AppendAppNotesToCrashReport( + NS_LITERAL_CSTRING("\nThere is no message in any window")); + } +#endif // #ifdef MOZ_CRASHREPORTER MOZ_CRASH("We lost the following char message"); } @@ -1926,12 +2069,79 @@ NativeKey::GetFollowingCharMessage(MSG& aCharMsg) const // in lParam may be changed from 0 to something. The changed value // is different from the scan code of handling keydown message. if (!MayBeSameCharMessage(removedMsg, nextKeyMsg)) { +#ifdef MOZ_CRASHREPORTER + nsPrintfCString info("\nPeekMessage() removed unexpcted char message! " + "\nHandling message: %s (0x%08X), wParam: 0x%08X, " + "lParam: 0x%08X, hwnd=0x%p, InSendMessageEx()=%s, " + "\nFound message: %s (0x%08X), wParam: 0x%08X, " + "lParam: 0x%08X, hwnd=0x%p, " + "\nRemoved message: %s (0x%08X), wParam: 0x%08X, " + "lParam: 0x%08X, hwnd=0x%p, ", + GetMessageName(mMsg.message), + mMsg.message, mMsg.wParam, mMsg.lParam, mMsg.hwnd, + GetResultOfInSendMessageEx().get(), + GetMessageName(nextKeyMsg.message), + nextKeyMsg.message, nextKeyMsg.wParam, + nextKeyMsg.lParam, nextKeyMsg.hwnd, + GetMessageName(removedMsg.message), + removedMsg.message, removedMsg.wParam, + removedMsg.lParam, removedMsg.hwnd); + CrashReporter::AppendAppNotesToCrashReport(info); + // What's the next key message? + MSG nextKeyMsgAfter; + if (WinUtils::PeekMessage(&nextKeyMsgAfter, mMsg.hwnd, + WM_KEYFIRST, WM_KEYLAST, + PM_NOREMOVE | PM_NOYIELD)) { + nsPrintfCString info("\nNext key message after unexpected char message " + "removed: %s (0x%08X), wParam: 0x%08X, " + "lParam: 0x%08X, hwnd=0x%p, ", + GetMessageName(nextKeyMsgAfter.message), + nextKeyMsgAfter.message, nextKeyMsgAfter.wParam, + nextKeyMsgAfter.lParam, nextKeyMsgAfter.hwnd); + CrashReporter::AppendAppNotesToCrashReport(info); + } else { + CrashReporter::AppendAppNotesToCrashReport( + NS_LITERAL_CSTRING("\nThere is no key message after unexpected char " + "message removed, ")); + } + // Another window has a key message? + MSG nextKeyMsgInAllWindows; + if (WinUtils::PeekMessage(&nextKeyMsgInAllWindows, 0, + WM_KEYFIRST, WM_KEYLAST, + PM_NOREMOVE | PM_NOYIELD)) { + nsPrintfCString info("\nNext key message in all windows: %s (0x%08X), " + "wParam: 0x%08X, lParam: 0x%08X, hwnd=0x%p.", + GetMessageName(nextKeyMsgInAllWindows.message), + nextKeyMsgInAllWindows.message, + nextKeyMsgInAllWindows.wParam, + nextKeyMsgInAllWindows.lParam, + nextKeyMsgInAllWindows.hwnd); + CrashReporter::AppendAppNotesToCrashReport(info); + } else { + CrashReporter::AppendAppNotesToCrashReport( + NS_LITERAL_CSTRING("\nThere is no key message in any windows.")); + } +#endif // #ifdef MOZ_CRASHREPORTER MOZ_CRASH("PeekMessage() removed unexpected message"); } aCharMsg = removedMsg; return true; } +#ifdef MOZ_CRASHREPORTER + nsPrintfCString info("\nWe lost following char message! " + "\nHandling message: %s (0x%08X), wParam: 0x%08X, " + "lParam: 0x%08X, InSendMessageEx()=%s, \n" + "Found message: %s (0x%08X), wParam: 0x%08X, " + "lParam: 0x%08X, removed a lot of WM_NULL", + GetMessageName(mMsg.message), + mMsg.message, mMsg.wParam, mMsg.lParam, + GetResultOfInSendMessageEx().get(), + GetMessageName(nextKeyMsg.message), + nextKeyMsg.message, nextKeyMsg.wParam, + nextKeyMsg.lParam); + CrashReporter::AppendAppNotesToCrashReport(info); +#endif // #ifdef MOZ_CRASHREPORTER MOZ_CRASH("We lost the following char message"); return false; } @@ -2034,7 +2244,7 @@ NativeKey::ComputeInputtingStringWithKeyboardLayout() mShiftedLatinChar = mUnshiftedLatinChar = 0; } } else if (mUnshiftedLatinChar) { - // If the mShiftedLatinChar is 0, the keyCode doesn't produce + // If the mShiftedLatinChar is 0, the mKeyCode doesn't produce // alphabet character. At that time, the character may be produced // with Shift key. E.g., on French keyboard layout, NS_VK_PERCENT // key produces LATIN SMALL LETTER U WITH GRAVE (U+00F9) without @@ -2051,9 +2261,9 @@ NativeKey::ComputeInputtingStringWithKeyboardLayout() return; } - // If the charCode is not ASCII character, we should replace the - // charCode with ASCII character only when Ctrl is pressed. - // But don't replace the charCode when the charCode is not same as + // If the mCharCode is not ASCII character, we should replace the + // mCharCode with ASCII character only when Ctrl is pressed. + // But don't replace the mCharCode when the mCharCode is not same as // unmodified characters. In such case, Ctrl is sometimes used for a // part of character inputting key combination like Shift. uint32_t ch = @@ -2083,7 +2293,7 @@ NativeKey::DispatchKeyPressEventsWithoutCharMessage() const WidgetKeyboardEvent keypressEvent(true, eKeyPress, mWidget); if (mInputtingStringAndModifiers.IsEmpty() && mShiftedString.IsEmpty() && mUnshiftedString.IsEmpty()) { - keypressEvent.keyCode = mDOMKeyCode; + keypressEvent.mKeyCode = mDOMKeyCode; } nsEventStatus status = InitKeyEvent(keypressEvent, mModKeyState); mDispatcher->MaybeDispatchKeypressEvents(keypressEvent, status, @@ -2105,7 +2315,8 @@ NativeKey::WillDispatchKeyboardEvent(WidgetKeyboardEvent& aKeyboardEvent, return; } - nsTArray& altArray = aKeyboardEvent.alternativeCharCodes; + nsTArray& altArray = + aKeyboardEvent.mAlternativeCharCodes; uint16_t shiftedChar = 0, unshiftedChar = 0; if (skipUniChars <= aIndex) { @@ -2130,10 +2341,10 @@ NativeKey::WillDispatchKeyboardEvent(WidgetKeyboardEvent& aKeyboardEvent, uint16_t uniChar = mInputtingStringAndModifiers.mChars[aIndex - skipUniChars]; - // The charCode was set from mKeyValue. However, for example, when Ctrl key + // The mCharCode was set from mKeyValue. However, for example, when Ctrl key // is pressed, its value should indicate an ASCII character for backward // compatibility rather than inputting character without the modifiers. - // Therefore, we need to modify charCode value here. + // Therefore, we need to modify mCharCode value here. aKeyboardEvent.SetCharCode(uniChar); } @@ -2346,6 +2557,8 @@ KeyboardLayout::InitNativeKey(NativeKey& aNativeKey, return; } + MOZ_ASSERT(virtualKey != VK_PACKET, + "At handling VK_PACKET, we shouldn't refer keyboard layout"); MOZ_ASSERT(aNativeKey.mKeyNameIndex == KEY_NAME_INDEX_USE_STRING, "Printable key's key name index must be KEY_NAME_INDEX_USE_STRING"); @@ -2384,6 +2597,17 @@ KeyboardLayout::InitNativeKey(NativeKey& aNativeKey, int32_t activeDeadKeyIndex = GetKeyIndex(mActiveDeadKey); if (activeDeadKeyIndex < 0 || activeDeadKeyIndex >= NS_NUM_OF_KEYS) { +#if defined(DEBUG) || defined(MOZ_CRASHREPORTER) + nsPrintfCString warning("The virtual key index (%d) of mActiveDeadKey " + "(0x%02X) is not a printable key (virtualKey=" + "0x%02X)", + activeDeadKeyIndex, mActiveDeadKey, virtualKey); + NS_WARNING(warning.get()); +#ifdef MOZ_CRASHREPORTER + CrashReporter::AppendAppNotesToCrashReport( + NS_LITERAL_CSTRING("\n") + warning); +#endif // #ifdef MOZ_CRASHREPORTER +#endif // #if defined(DEBUG) || defined(MOZ_CRASHREPORTER) MOZ_CRASH("Trying to reference out of range of mVirtualKeys"); } UniCharsAndModifiers prevDeadChars = @@ -3004,7 +3228,7 @@ KeyboardLayout::ConvertNativeKeyCodeToDOMKeyCode(UINT aNativeKeyCode) const KeyNameIndex KeyboardLayout::ConvertNativeKeyCodeToKeyNameIndex(uint8_t aVirtualKey) const { - if (IsPrintableCharKey(aVirtualKey)) { + if (IsPrintableCharKey(aVirtualKey) || aVirtualKey == VK_PACKET) { return KEY_NAME_INDEX_USE_STRING; } diff --git a/widget/windows/KeyboardLayout.h b/widget/windows/KeyboardLayout.h index 659ba1b17e..83e03c6ca4 100644 --- a/widget/windows/KeyboardLayout.h +++ b/widget/windows/KeyboardLayout.h @@ -315,6 +315,12 @@ private: void InitWithAppCommand(); + /** + * Returns true if aChar is a control character which shouldn't be inputted + * into focused text editor. + */ + bool IsControlChar(char16_t aChar) const; + /** * Returns true if the key event is caused by auto repeat. */ @@ -420,8 +426,11 @@ private: * * WARNING: Even if this returns true, aCharMsg may be WM_NULL or its * hwnd may be different window. + * + * @param aRemove true if the found message should be removed from the + * queue. Otherwise, false. */ - bool GetFollowingCharMessage(MSG& aCharMsg) const; + bool GetFollowingCharMessage(MSG& aCharMsg, bool aRemove = true) const; /** * Whether the key event can compute virtual keycode from the scancode value. diff --git a/widget/windows/nsWindow.cpp b/widget/windows/nsWindow.cpp index 1ed21fcbab..0ed9681c49 100644 --- a/widget/windows/nsWindow.cpp +++ b/widget/windows/nsWindow.cpp @@ -4101,17 +4101,18 @@ nsWindow::DispatchMouseEvent(EventMessage aEventMessage, WPARAM wParam, } break; case eMouseExitFromWidget: - event.exit = IsTopLevelMouseExit(mWnd) ? - WidgetMouseEvent::eTopLevel : WidgetMouseEvent::eChild; + event.mExitFrom = + IsTopLevelMouseExit(mWnd) ? WidgetMouseEvent::eTopLevel : + WidgetMouseEvent::eChild; break; default: break; } - event.clickCount = sLastClickCount; + event.mClickCount = sLastClickCount; #ifdef NS_DEBUG_XX MOZ_LOG(gWindowsLog, LogLevel::Info, - ("Msg Time: %d Click Count: %d\n", curMsgTime, event.clickCount)); + ("Msg Time: %d Click Count: %d\n", curMsgTime, event.mClickCount)); #endif NPEvent pluginEvent;