From 3cfaa1db238c61a8077188aa2c4a3e658d4cc124 Mon Sep 17 00:00:00 2001 From: Matt Brubeck Date: Wed, 8 Aug 2012 08:14:48 -0700 Subject: [PATCH 01/22] Back out bug 562169 because of Dromaeo DOM regressions Backed out changeset 841cd6e1e585 (bug 562169) Backed out changeset e226e413dd27 (bug 562169) Backed out changeset 9c24b7287c5b (bug 562169) --- content/base/public/DirectionalityUtils.h | 58 ----------- content/base/public/Element.h | 13 --- content/base/public/Makefile.in | 1 - content/base/public/nsIDocument.h | 8 -- content/base/public/nsINode.h | 15 +-- content/base/src/DirectionalityUtils.cpp | 96 ------------------- content/base/src/Makefile.in | 1 - content/base/src/nsDocument.cpp | 14 +-- content/base/src/nsDocument.h | 6 -- content/base/src/nsGenericElement.cpp | 16 ---- content/base/src/nsGkAtomList.h | 1 - content/base/test/Makefile.in | 2 - content/base/test/test_bug562169-1.html | 44 --------- content/base/test/test_bug562169-2.html | 29 ------ content/events/public/nsEventStates.h | 4 - .../html/content/src/nsGenericHTMLElement.cpp | 34 ------- .../html/content/src/nsGenericHTMLElement.h | 4 - .../en-US/chrome/layout/css.properties | 1 - layout/reftests/bidi/562169-1-ref.html | 31 ------ layout/reftests/bidi/562169-1.html | 32 ------- layout/reftests/bidi/562169-1a.html | 46 --------- layout/reftests/bidi/562169-2-ref.html | 29 ------ layout/reftests/bidi/562169-2.html | 30 ------ layout/reftests/bidi/562169-2a.html | 36 ------- layout/reftests/bidi/562169-3-ref.html | 16 ---- layout/reftests/bidi/562169-3.html | 15 --- layout/reftests/bidi/562169-3a.html | 26 ----- layout/reftests/bidi/562169-4-ref.html | 16 ---- layout/reftests/bidi/562169-4.html | 29 ------ layout/reftests/bidi/reftest.list | 7 -- layout/style/nsCSSParser.cpp | 6 +- layout/style/nsCSSPseudoClassList.h | 50 +++------- layout/style/nsCSSPseudoClasses.cpp | 3 +- layout/style/nsCSSRuleProcessor.cpp | 62 ++---------- 34 files changed, 24 insertions(+), 757 deletions(-) delete mode 100644 content/base/public/DirectionalityUtils.h delete mode 100644 content/base/src/DirectionalityUtils.cpp delete mode 100644 content/base/test/test_bug562169-1.html delete mode 100644 content/base/test/test_bug562169-2.html delete mode 100644 layout/reftests/bidi/562169-1-ref.html delete mode 100644 layout/reftests/bidi/562169-1.html delete mode 100644 layout/reftests/bidi/562169-1a.html delete mode 100644 layout/reftests/bidi/562169-2-ref.html delete mode 100644 layout/reftests/bidi/562169-2.html delete mode 100644 layout/reftests/bidi/562169-2a.html delete mode 100644 layout/reftests/bidi/562169-3-ref.html delete mode 100644 layout/reftests/bidi/562169-3.html delete mode 100644 layout/reftests/bidi/562169-3a.html delete mode 100644 layout/reftests/bidi/562169-4-ref.html delete mode 100644 layout/reftests/bidi/562169-4.html diff --git a/content/base/public/DirectionalityUtils.h b/content/base/public/DirectionalityUtils.h deleted file mode 100644 index 0973e7588ded..000000000000 --- a/content/base/public/DirectionalityUtils.h +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef DirectionalityUtils_h___ -#define DirectionalityUtils_h___ - -class nsIContent; -class nsIDocument; -class nsINode; - -namespace mozilla { -namespace dom { -class Element; -} // namespace dom -} // namespace mozilla - -namespace mozilla { - -namespace directionality { - -enum Directionality { - eDir_NotSet = 0, - eDir_RTL = 1, - eDir_LTR = 2 -}; - -void SetDirectionality(mozilla::dom::Element* aElement, Directionality aDir, - bool aNotify = true); - -/** - * Set the directionality of an element according to the algorithm defined at - * http://www.whatwg.org/specs/web-apps/current-work/multipage/elements.html#the-directionality, - * not including elements with auto direction. - * - * @return the directionality that the element was set to - */ -Directionality RecomputeDirectionality(mozilla::dom::Element* aElement, - bool aNotify = true); - -/** - * Set the directionality of any descendants of a node that do not themselves - * have a dir attribute. - * For performance reasons we walk down the descendant tree in the rare case - * of setting the dir attribute, rather than walking up the ancestor tree in - * the much more common case of getting the element's directionality. - */ -void SetDirectionalityOnDescendants(mozilla::dom::Element* aElement, - Directionality aDir, - bool aNotify = true); - -} // end namespace directionality - -} // end namespace mozilla - -#endif /* DirectionalityUtils_h___ */ diff --git a/content/base/public/Element.h b/content/base/public/Element.h index 141d5c5932a7..4d1b51b1acbd 100644 --- a/content/base/public/Element.h +++ b/content/base/public/Element.h @@ -10,7 +10,6 @@ #include "mozilla/dom/FragmentOrElement.h" // for base class #include "nsChangeHint.h" // for enum #include "nsEventStates.h" // for member -#include "mozilla/dom/DirectionalityUtils.h" class nsEventStateManager; class nsFocusManager; @@ -217,18 +216,6 @@ public: */ virtual nsIAtom *GetClassAttributeName() const = 0; - inline mozilla::directionality::Directionality GetDirectionality() const { - if (HasFlag(NODE_HAS_DIRECTION_RTL)) { - return mozilla::directionality::eDir_RTL; - } - - if (HasFlag(NODE_HAS_DIRECTION_LTR)) { - return mozilla::directionality::eDir_LTR; - } - - return mozilla::directionality::eDir_NotSet; - } - protected: /** * Method to get the _intrinsic_ content state of this element. This is the diff --git a/content/base/public/Makefile.in b/content/base/public/Makefile.in index 5d92d5876f2b..49c521897795 100644 --- a/content/base/public/Makefile.in +++ b/content/base/public/Makefile.in @@ -48,7 +48,6 @@ $(NULL) EXPORTS_NAMESPACES = mozilla/dom mozilla EXPORTS_mozilla/dom = \ - DirectionalityUtils.h \ Element.h \ FragmentOrElement.h \ FromParser.h \ diff --git a/content/base/public/nsIDocument.h b/content/base/public/nsIDocument.h index 0845a2954312..16307c8d5cf1 100644 --- a/content/base/public/nsIDocument.h +++ b/content/base/public/nsIDocument.h @@ -23,7 +23,6 @@ #include "nsPIDOMWindow.h" // for use in inline functions #include "nsPropertyTable.h" // for member #include "nsTHashtable.h" // for member -#include "mozilla/dom/DirectionalityUtils.h" class imgIRequest; class nsAString; @@ -398,10 +397,6 @@ public: { mBidiOptions = aBidiOptions; } - - inline mozilla::directionality::Directionality GetDocumentDirectionality() { - return mDirectionality; - } /** * Access HTTP header data (this may also get set from other @@ -1858,9 +1853,6 @@ protected: // defined in nsBidiUtils.h PRUint32 mBidiOptions; - // The root directionality of this document. - mozilla::directionality::Directionality mDirectionality; - nsCString mContentLanguage; private: nsCString mContentType; diff --git a/content/base/public/nsINode.h b/content/base/public/nsINode.h index 189d64265507..0d79acf33736 100644 --- a/content/base/public/nsINode.h +++ b/content/base/public/nsINode.h @@ -145,16 +145,8 @@ enum { // Set if the node has had :hover selectors matched against it NODE_HAS_RELEVANT_HOVER_RULES = 0x00080000U, - // Set if the node has right-to-left directionality - NODE_HAS_DIRECTION_RTL = 0x00100000U, - - // Set if the node has left-to-right directionality - NODE_HAS_DIRECTION_LTR = 0x00200000U, - - NODE_ALL_DIRECTION_FLAGS = NODE_HAS_DIRECTION_LTR | NODE_HAS_DIRECTION_RTL, - // Remaining bits are node type specific. - NODE_TYPE_SPECIFIC_BITS_OFFSET = 22 + NODE_TYPE_SPECIFIC_BITS_OFFSET = 20 }; /** @@ -1287,8 +1279,6 @@ private: NodeIsContent, // Set if the node has animations or transitions ElementHasAnimations, - // Set if node has a dir attribute with a valid value (ltr or rtl) - NodeHasValidDirAttribute, // Guard value BooleanFlagCount }; @@ -1356,9 +1346,6 @@ public: void ClearPointerLock() { ClearBoolFlag(ElementHasPointerLock); } bool MayHaveAnimations() { return GetBoolFlag(ElementHasAnimations); } void SetMayHaveAnimations() { SetBoolFlag(ElementHasAnimations); } - void SetHasValidDir() { SetBoolFlag(NodeHasValidDirAttribute); } - void ClearHasValidDir() { ClearBoolFlag(NodeHasValidDirAttribute); } - bool HasValidDir() const { return GetBoolFlag(NodeHasValidDirAttribute); } protected: void SetParentIsContent(bool aValue) { SetBoolFlag(ParentIsContent, aValue); } void SetInDocument() { SetBoolFlag(IsInDocument); } diff --git a/content/base/src/DirectionalityUtils.cpp b/content/base/src/DirectionalityUtils.cpp deleted file mode 100644 index 29dfb30fd732..000000000000 --- a/content/base/src/DirectionalityUtils.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=2 sw=2 et tw=78: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "mozilla/dom/DirectionalityUtils.h" -#include "nsINode.h" -#include "nsIContent.h" -#include "nsIDocument.h" -#include "mozilla/dom/Element.h" -#include "nsIDOMNodeFilter.h" -#include "nsTreeWalker.h" -#include "nsIDOMHTMLDocument.h" - - -namespace mozilla { - -namespace directionality { - -typedef mozilla::dom::Element Element; - -void -SetDirectionality(Element* aElement, Directionality aDir, bool aNotify) -{ - aElement->UnsetFlags(NODE_ALL_DIRECTION_FLAGS); - switch (aDir) { - case eDir_RTL: - aElement->SetFlags(NODE_HAS_DIRECTION_RTL); - break; - case eDir_LTR: - aElement->SetFlags(NODE_HAS_DIRECTION_LTR); - break; - default: - break; - } - - aElement->UpdateState(aNotify); -} - -Directionality -RecomputeDirectionality(Element* aElement, bool aNotify) -{ - Directionality dir = eDir_LTR; - - if (aElement->HasValidDir()) { - dir = aElement->GetDirectionality(); - } else { - Element* parent = aElement->GetElementParent(); - if (parent) { - // If the element doesn't have an explicit dir attribute with a valid - // value, the directionality is the same as the parent element (but - // don't propagate the parent directionality if it isn't set yet). - Directionality parentDir = parent->GetDirectionality(); - if (parentDir != eDir_NotSet) { - dir = parentDir; - } - } else { - // If there is no parent element, the directionality is the same as the - // document direction. - Directionality documentDir = - aElement->OwnerDoc()->GetDocumentDirectionality(); - if (documentDir != eDir_NotSet) { - dir = documentDir; - } - } - - SetDirectionality(aElement, dir, aNotify); - } - return dir; -} - -void -SetDirectionalityOnDescendants(Element* aElement, Directionality aDir, - bool aNotify) -{ - for (nsIContent* child = aElement->GetFirstChild(); child; ) { - if (!child->IsElement()) { - child = child->GetNextNode(aElement); - continue; - } - - Element* element = child->AsElement(); - if (element->HasValidDir()) { - child = child->GetNextNonChildNode(aElement); - continue; - } - SetDirectionality(element, aDir, aNotify); - child = child->GetNextNode(aElement); - } -} - -} // end namespace directionality - -} // end namespace mozilla - diff --git a/content/base/src/Makefile.in b/content/base/src/Makefile.in index c7c1d95097a6..fdec933a82b7 100644 --- a/content/base/src/Makefile.in +++ b/content/base/src/Makefile.in @@ -53,7 +53,6 @@ LOCAL_INCLUDES = \ $(NULL) CPPSRCS = \ - DirectionalityUtils.cpp \ nsAtomListUtils.cpp \ nsAttrAndChildArray.cpp \ nsAttrValue.cpp \ diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp index aa46e89ffc0f..643fb2e05b44 100644 --- a/content/base/src/nsDocument.cpp +++ b/content/base/src/nsDocument.cpp @@ -91,7 +91,6 @@ #include "nsXMLEventsManager.h" #include "nsBidiUtils.h" -#include "mozilla/dom/DirectionalityUtils.h" #include "nsIDOMUserDataHandler.h" #include "nsIDOMXPathEvaluator.h" @@ -171,7 +170,6 @@ using namespace mozilla; using namespace mozilla::dom; -using namespace mozilla::directionality; typedef nsTArray LinkArray; @@ -1512,8 +1510,7 @@ nsIDocument::nsIDocument() mAllowDNSPrefetch(true), mIsBeingUsedAsImage(false), mHasLinksToUpdate(false), - mPartID(0), - mDirectionality(eDir_LTR) + mPartID(0) { SetInDocument(); } @@ -5586,15 +5583,6 @@ nsDocument::SetDir(const nsAString& aDirection) // No presentation; just set it on ourselves SetBidiOptions(options); } - Directionality dir = elt->mValue == IBMBIDI_TEXTDIRECTION_RTL ? - eDir_RTL : eDir_LTR; - SetDocumentDirectionality(dir); - // Set the directionality of the root element and its descendants, if any - Element* rootElement = GetRootElement(); - if (rootElement) { - SetDirectionality(rootElement, dir, true); - SetDirectionalityOnDescendants(rootElement, dir); - } } break; diff --git a/content/base/src/nsDocument.h b/content/base/src/nsDocument.h index 3ef75fda92b2..bbe012601d80 100644 --- a/content/base/src/nsDocument.h +++ b/content/base/src/nsDocument.h @@ -1048,12 +1048,6 @@ protected: nsIContent* GetFirstBaseNodeWithHref(); nsresult SetFirstBaseNodeWithHref(nsIContent *node); - inline void - SetDocumentDirectionality(mozilla::directionality::Directionality aDir) - { - mDirectionality = aDir; - } - // Get the first element with the given IsNodeOfType type, or // return null if there isn't one nsIContent* GetTitleContent(PRUint32 aNodeType); diff --git a/content/base/src/nsGenericElement.cpp b/content/base/src/nsGenericElement.cpp index a421bd5299f0..e591e7ed11af 100644 --- a/content/base/src/nsGenericElement.cpp +++ b/content/base/src/nsGenericElement.cpp @@ -51,7 +51,6 @@ #include "nsIDOMMutationEvent.h" #include "nsMutationEvent.h" #include "nsNodeUtils.h" -#include "mozilla/dom/DirectionalityUtils.h" #include "nsDocument.h" #include "nsAttrValueOrString.h" #ifdef MOZ_XUL @@ -129,7 +128,6 @@ using namespace mozilla; using namespace mozilla::dom; -using namespace mozilla::directionality; nsEventStates Element::IntrinsicState() const @@ -1360,13 +1358,6 @@ nsGenericElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent, SetSubtreeRootPointer(aParent->SubtreeRoot()); } - // This has to be here, rather than in nsGenericHTMLElement::BindToTree, - // because it has to happen after updating the parent pointer, but before - // recursively binding the kids. - if (IsHTML()) { - RecomputeDirectionality(this, false); - } - // If NODE_FORCE_XBL_BINDINGS was set we might have anonymous children // that also need to be told that they are moving. nsresult rv; @@ -1552,13 +1543,6 @@ nsGenericElement::UnbindFromTree(bool aDeep, bool aNullParent) } } - // This has to be here, rather than in nsGenericHTMLElement::UnbindFromTree, - // because it has to happen after unsetting the parent pointer, but before - // recursively unbinding the kids. - if (IsHTML()) { - RecomputeDirectionality(this, false); - } - if (aDeep) { // Do the kids. Don't call GetChildCount() here since that'll force // XUL to generate template children, which there is no need for since diff --git a/content/base/src/nsGkAtomList.h b/content/base/src/nsGkAtomList.h index 2049e2847306..e2d75736b662 100644 --- a/content/base/src/nsGkAtomList.h +++ b/content/base/src/nsGkAtomList.h @@ -270,7 +270,6 @@ GK_ATOM(dialog, "dialog") GK_ATOM(difference, "difference") GK_ATOM(digit, "digit") GK_ATOM(dir, "dir") -GK_ATOM(directionality, "directionality") GK_ATOM(disableOutputEscaping, "disable-output-escaping") GK_ATOM(disabled, "disabled") GK_ATOM(display, "display") diff --git a/content/base/test/Makefile.in b/content/base/test/Makefile.in index 6e22e1b82727..a73aa0f5fedc 100644 --- a/content/base/test/Makefile.in +++ b/content/base/test/Makefile.in @@ -381,8 +381,6 @@ MOCHITEST_FILES_B = \ test_bug562652.html \ test_bug562137.html \ file_bug562137.txt \ - test_bug562169-1.html \ - test_bug562169-2.html \ test_bug548193.html \ file_bug548193.sjs \ test_html_colors_quirks.html \ diff --git a/content/base/test/test_bug562169-1.html b/content/base/test/test_bug562169-1.html deleted file mode 100644 index e2e9e9da2800..000000000000 --- a/content/base/test/test_bug562169-1.html +++ /dev/null @@ -1,44 +0,0 @@ -<!DOCTYPE HTML> -<html> -<!-- -https://bugzilla.mozilla.org/show_bug.cgi?id=562169 ---> -<head> - <meta charset="utf-8"> - <title>Test for Bug 562169 - - - - -Mozilla Bug 562169 -

- -
-
-
- - diff --git a/content/base/test/test_bug562169-2.html b/content/base/test/test_bug562169-2.html deleted file mode 100644 index b49eed016fb9..000000000000 --- a/content/base/test/test_bug562169-2.html +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - Test for Bug 562169 - - - - -Mozilla Bug 562169 -

- -
-
-
- - diff --git a/content/events/public/nsEventStates.h b/content/events/public/nsEventStates.h index 0a448df69a25..ff36910a30d2 100644 --- a/content/events/public/nsEventStates.h +++ b/content/events/public/nsEventStates.h @@ -248,10 +248,6 @@ private: #define NS_EVENT_STATE_VULNERABLE_NO_UPDATE NS_DEFINE_EVENT_STATE_MACRO(41) // Platform does not support plugin content (some mobile platforms) #define NS_EVENT_STATE_TYPE_UNSUPPORTED_PLATFORM NS_DEFINE_EVENT_STATE_MACRO(42) -// Element is ltr (for :dir pseudo-class) -#define NS_EVENT_STATE_LTR NS_DEFINE_EVENT_STATE_MACRO(43) -// Element is rtl (for :dir pseudo-class) -#define NS_EVENT_STATE_RTL NS_DEFINE_EVENT_STATE_MACRO(44) /** * NOTE: do not go over 63 without updating nsEventStates::InternalType! diff --git a/content/html/content/src/nsGenericHTMLElement.cpp b/content/html/content/src/nsGenericHTMLElement.cpp index da3e83ecd178..2f502f79a2cd 100644 --- a/content/html/content/src/nsGenericHTMLElement.cpp +++ b/content/html/content/src/nsGenericHTMLElement.cpp @@ -53,7 +53,6 @@ #include "nsHTMLParts.h" #include "nsContentUtils.h" -#include "mozilla/dom/DirectionalityUtils.h" #include "nsString.h" #include "nsUnicharUtils.h" #include "nsGkAtoms.h" @@ -97,7 +96,6 @@ using namespace mozilla; using namespace mozilla::dom; -using namespace mozilla::directionality; class nsINodeInfo; class nsIDOMNodeList; @@ -1689,24 +1687,6 @@ nsGenericHTMLElement::UpdateEditableState(bool aNotify) nsStyledElement::UpdateEditableState(aNotify); } -nsEventStates -nsGenericHTMLElement::IntrinsicState() const -{ - nsEventStates state = nsGenericHTMLElementBase::IntrinsicState(); - - if (GetDirectionality() == eDir_RTL) { - state |= NS_EVENT_STATE_RTL; - state &= ~NS_EVENT_STATE_LTR; - } else { // at least for HTML, directionality is exclusively LTR or RTL - NS_ASSERTION(GetDirectionality() == eDir_LTR, - "HTML element's directionality must be either RTL or LTR"); - state |= NS_EVENT_STATE_LTR; - state &= ~NS_EVENT_STATE_RTL; - } - - return state; -} - nsresult nsGenericHTMLElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent, nsIContent* aBindingParent, @@ -1909,20 +1889,6 @@ nsGenericHTMLElement::AfterSetAttr(PRInt32 aNamespaceID, nsIAtom* aName, else if (aNotify && aName == nsGkAtoms::spellcheck) { SyncEditorsOnSubtree(this); } - else if (aName == nsGkAtoms::dir) { - Directionality dir; - if (aValue && - (aValue->Equals(nsGkAtoms::ltr, eIgnoreCase) || - aValue->Equals(nsGkAtoms::rtl, eIgnoreCase))) { - SetHasValidDir(); - dir = aValue->Equals(nsGkAtoms::rtl, eIgnoreCase) ? eDir_RTL : eDir_LTR; - SetDirectionality(this, dir, aNotify); - } else { - ClearHasValidDir(); - dir = RecomputeDirectionality(this, aNotify); - } - SetDirectionalityOnDescendants(this, dir, aNotify); - } } return nsGenericHTMLElementBase::AfterSetAttr(aNamespaceID, aName, diff --git a/content/html/content/src/nsGenericHTMLElement.h b/content/html/content/src/nsGenericHTMLElement.h index a4bbd99db54b..4cd54732ab75 100644 --- a/content/html/content/src/nsGenericHTMLElement.h +++ b/content/html/content/src/nsGenericHTMLElement.h @@ -49,8 +49,6 @@ public: { NS_ASSERTION(mNodeInfo->NamespaceID() == kNameSpaceID_XHTML, "Unexpected namespace"); - AddStatesSilently(NS_EVENT_STATE_LTR); - SetFlags(NODE_HAS_DIRECTION_LTR); } /** Typesafe, non-refcounting cast from nsIContent. Cheaper than QI. **/ @@ -204,8 +202,6 @@ public: virtual void UpdateEditableState(bool aNotify); - virtual nsEventStates IntrinsicState() const; - // Helper for setting our editable flag and notifying void DoSetEditableFlag(bool aEditable, bool aNotify) { SetEditableFlag(aEditable); diff --git a/dom/locales/en-US/chrome/layout/css.properties b/dom/locales/en-US/chrome/layout/css.properties index bec986fd1110..c3aed0a20980 100644 --- a/dom/locales/en-US/chrome/layout/css.properties +++ b/dom/locales/en-US/chrome/layout/css.properties @@ -114,7 +114,6 @@ PEMQExpectedFeatureValue=Found invalid value for media feature. PEBadFontBlockStart=Expected '{' to begin @font-face rule but found '%1$S'. PEBadFontBlockEnd=Expected '}' to end @font-face rule but found '%1$S'. PEAnonBoxNotAlone=Did not expect anonymous box. -PEBadDirValue=Expected 'ltr' or 'rtl' in direction selector but found '%1$S'. PESupportsConditionStartEOF='not' or '(' PESupportsConditionInParensStartEOF='not', '(' or identifier PESupportsConditionNotEOF='not' diff --git a/layout/reftests/bidi/562169-1-ref.html b/layout/reftests/bidi/562169-1-ref.html deleted file mode 100644 index 8aded4f766d6..000000000000 --- a/layout/reftests/bidi/562169-1-ref.html +++ /dev/null @@ -1,31 +0,0 @@ - - - - - dir() selector - - - -
This element has default direction.
-
This element is ltr.
-
This element is rtl.
-
-
This element should inherit ltr.
-
This element is ltr.
-
This element is rtl.
-
Every word in this element should inherit ltr.
-
-
-
This element should inherit rtl.
-
This element is ltr.
-
This element is rtl.
-
Every word in this element should inherit rtl.
-
-
This element has an invalid dir attribute and - should have default direction.
- - diff --git a/layout/reftests/bidi/562169-1.html b/layout/reftests/bidi/562169-1.html deleted file mode 100644 index d6cfe554f802..000000000000 --- a/layout/reftests/bidi/562169-1.html +++ /dev/null @@ -1,32 +0,0 @@ - - - - - dir() selector - - - -
This element has default direction.
-
This element is ltr.
-
This element is rtl.
-
-
This element should inherit ltr.
-
This element is ltr.
-
This element is rtl.
-
Every word in this element should inherit ltr.
-
-
-
This element should inherit rtl.
-
This element is ltr.
-
This element is rtl.
-
Every word in this element should inherit rtl.
-
-
This element has an invalid dir attribute and - should have default direction.
- - diff --git a/layout/reftests/bidi/562169-1a.html b/layout/reftests/bidi/562169-1a.html deleted file mode 100644 index f6102951fd33..000000000000 --- a/layout/reftests/bidi/562169-1a.html +++ /dev/null @@ -1,46 +0,0 @@ - - - - - dir() selector - - - - -
This element has default direction.
-
This element is ltr.
-
This element is rtl.
-
-
This element should inherit ltr.
-
This element is ltr.
-
This element is rtl.
-
Every word in this element should inherit ltr.
-
-
-
This element should inherit rtl.
-
This element is ltr.
-
This element is rtl.
-
Every word in this element should inherit rtl.
-
-
This element has an invalid dir attribute and - should have default direction.
- - diff --git a/layout/reftests/bidi/562169-2-ref.html b/layout/reftests/bidi/562169-2-ref.html deleted file mode 100644 index 0acc957b180f..000000000000 --- a/layout/reftests/bidi/562169-2-ref.html +++ /dev/null @@ -1,29 +0,0 @@ - - - - - dir() selector - - - -
This element has default direction.
-
This element is ltr.
-
This element is rtl.
-
-
This element should inherit ltr.
-
This element is ltr.
-
This element is rtl.
-
-
-
This element should inherit rtl.
-
This element is ltr.
-
This element is rtl.
-
-
This element has an invalid dir attribute and - should have default direction.
- - diff --git a/layout/reftests/bidi/562169-2.html b/layout/reftests/bidi/562169-2.html deleted file mode 100644 index cea59a3fe029..000000000000 --- a/layout/reftests/bidi/562169-2.html +++ /dev/null @@ -1,30 +0,0 @@ - - - - - dir() selector - - - -
This element has default direction.
-
This element is ltr.
-
This element is rtl.
-
-
This element should inherit ltr.
-
This element is ltr.
-
This element is rtl.
-
-
-
This element should inherit rtl.
-
This element is ltr.
-
This element is rtl.
-
-
This element has an invalid dir attribute and - should have default direction.
- - diff --git a/layout/reftests/bidi/562169-2a.html b/layout/reftests/bidi/562169-2a.html deleted file mode 100644 index 3f8044fd0310..000000000000 --- a/layout/reftests/bidi/562169-2a.html +++ /dev/null @@ -1,36 +0,0 @@ - - - - - dir() selector - - - - -
This element has default direction.
-
This element is ltr.
-
This element is rtl.
-
-
This element should inherit ltr.
-
This element is ltr.
-
This element is rtl.
-
-
-
This element should inherit rtl.
-
This element is ltr.
-
This element is rtl.
-
-
This element has an invalid dir attribute and - should have default direction.
- - diff --git a/layout/reftests/bidi/562169-3-ref.html b/layout/reftests/bidi/562169-3-ref.html deleted file mode 100644 index ea848f61a16f..000000000000 --- a/layout/reftests/bidi/562169-3-ref.html +++ /dev/null @@ -1,16 +0,0 @@ - - - - - dir() selector - - - -
This element is rtl.
-
This element has default direction.
- - diff --git a/layout/reftests/bidi/562169-3.html b/layout/reftests/bidi/562169-3.html deleted file mode 100644 index 422e60827668..000000000000 --- a/layout/reftests/bidi/562169-3.html +++ /dev/null @@ -1,15 +0,0 @@ - - - - - dir() selector - - - -
This element is rtl.
-
This element has default direction.
- - diff --git a/layout/reftests/bidi/562169-3a.html b/layout/reftests/bidi/562169-3a.html deleted file mode 100644 index 9df28794a558..000000000000 --- a/layout/reftests/bidi/562169-3a.html +++ /dev/null @@ -1,26 +0,0 @@ - - - - - dir() selector - - - - -
This element is rtl.
-
This element has default direction.
- - diff --git a/layout/reftests/bidi/562169-4-ref.html b/layout/reftests/bidi/562169-4-ref.html deleted file mode 100644 index b5cdada97b6d..000000000000 --- a/layout/reftests/bidi/562169-4-ref.html +++ /dev/null @@ -1,16 +0,0 @@ - - - - - dir() selector - - - -
This element is rtl. This span should - inherit rtl from the parent. This span should inherit rtl - from the grandparent.
- - diff --git a/layout/reftests/bidi/562169-4.html b/layout/reftests/bidi/562169-4.html deleted file mode 100644 index 56075adc2ba8..000000000000 --- a/layout/reftests/bidi/562169-4.html +++ /dev/null @@ -1,29 +0,0 @@ - - - - - dir() selector - - - - -
This element is rtl.
- - diff --git a/layout/reftests/bidi/reftest.list b/layout/reftests/bidi/reftest.list index fcb831c9480b..ab4035ba825e 100644 --- a/layout/reftests/bidi/reftest.list +++ b/layout/reftests/bidi/reftest.list @@ -86,13 +86,6 @@ random-if(winWidget) == 305643-1.html 305643-1-ref.html # depends on windows ver == 503957-1.html 503957-1-ref.html == 525740-1.html 525740-1-ref.html == 536963-1.html 536963-1-ref.html -== 562169-1.html 562169-1-ref.html -== 562169-1a.html 562169-1-ref.html -== 562169-2.html 562169-2-ref.html -== 562169-2a.html 562169-2-ref.html -== 562169-3.html 562169-3-ref.html -== 562169-3a.html 562169-3-ref.html -== 562169-4.html 562169-4-ref.html == 588739-1.html 588739-ref.html == 588739-2.html 588739-ref.html == 588739-3.html 588739-ref.html diff --git a/layout/style/nsCSSParser.cpp b/layout/style/nsCSSParser.cpp index e1a747c18182..7d3f5a28a8e4 100644 --- a/layout/style/nsCSSParser.cpp +++ b/layout/style/nsCSSParser.cpp @@ -3595,12 +3595,10 @@ CSSParserImpl::ParsePseudoClassWithIdentArg(nsCSSSelector& aSelector, return eSelectorParsingStatus_Error; // our caller calls SkipUntil(')') } - // -moz-locale-dir and :dir can only have values of 'ltr' or 'rtl'. - if (aType == nsCSSPseudoClasses::ePseudoClass_mozLocaleDir || - aType == nsCSSPseudoClasses::ePseudoClass_dir) { + // -moz-locale-dir can only have values of 'ltr' or 'rtl'. + if (aType == nsCSSPseudoClasses::ePseudoClass_mozLocaleDir) { if (!mToken.mIdent.EqualsLiteral("ltr") && !mToken.mIdent.EqualsLiteral("rtl")) { - REPORT_UNEXPECTED_TOKEN(PEBadDirValue); return eSelectorParsingStatus_Error; // our caller calls SkipUntil(')') } } diff --git a/layout/style/nsCSSPseudoClassList.h b/layout/style/nsCSSPseudoClassList.h index 23312179cc19..b87ed3ad5185 100644 --- a/layout/style/nsCSSPseudoClassList.h +++ b/layout/style/nsCSSPseudoClassList.h @@ -9,45 +9,27 @@ * This file contains the list of nsIAtoms and their values for CSS * pseudo-classes. It is designed to be used as inline input to * nsCSSPseudoClasses.cpp *only* through the magic of C preprocessing. - * All entries must be enclosed in the macros CSS_PSEUDO_CLASS, - * CSS_STATE_DEPENDENT_PSEUDO_CLASS, or CSS_STATE_PSEUDO_CLASS which - * will have cruel and unusual things done to them. The entries should - * be kept in some sort of logical order. The first argument to - * CSS_PSEUDO_CLASS is the C++ identifier of the atom. The second - * argument is the string value of the atom. - * CSS_STATE_DEPENDENT_PSEUDO_CLASS and CSS_STATE_PSEUDO_CLASS also take - * the name of the state bits that the class corresponds to. Only one - * of the bits needs to match for a CSS_STATE_PSEUDO_CLASS to match; - * CSS_STATE_DEPENDENT_PSEUDO_CLASS matching depends on a customized per-class - * algorithm which should be defined in SelectorMatches() in - * nsCSSRuleProcessor.cpp. - * - * If CSS_STATE_PSEUDO_CLASS is not defined, it'll be automatically - * defined to CSS_STATE_DEPENDENT_PSEUDO_CLASS; - * if CSS_STATE_DEPENDENT_PSEUDO_CLASS is not defined, it'll be - * automatically defined to CSS_PSEUDO_CLASS. + * All entries must be enclosed in the macros CSS_PSEUDO_CLASS or + * CSS_STATE_PSEUDO_CLASS which will have cruel and unusual things + * done to it. The entries should be kept in some sort of logical + * order. The first argument to CSS_PSEUDO_CLASS is the C++ + * identifier of the atom. The second argument is the string value of + * the atom. CSS_STATE_PSEUDO_CLASS also takes the name of the state + * bits that the class corresponds to. Only one of the bits needs to + * match for the pseudo-class to match. If CSS_STATE_PSEUDO_CLASS is + * not defined, it'll be automatically defined to CSS_PSEUDO_CLASS. */ // OUTPUT_CLASS=nsCSSPseudoClasses // MACRO_NAME=CSS_PSEUDO_CLASS -#ifdef DEFINED_CSS_STATE_DEPENDENT_PSEUDO_CLASS -#error "CSS_STATE_DEPENDENT_PSEUDO_CLASS shouldn't be defined" -#endif - -#ifndef CSS_STATE_DEPENDENT_PSEUDO_CLASS -#define CSS_STATE_DEPENDENT_PSEUDO_CLASS(_name, _value, _bit) \ - CSS_PSEUDO_CLASS(_name, _value) -#define DEFINED_CSS_STATE_DEPENDENT_PSEUDO_CLASS -#endif - #ifdef DEFINED_CSS_STATE_PSEUDO_CLASS -#error "CSS_STATE_PSEUDO_CLASS shouldn't be defined" +#error "This shouldn't be defined" #endif #ifndef CSS_STATE_PSEUDO_CLASS #define CSS_STATE_PSEUDO_CLASS(_name, _value, _bit) \ - CSS_STATE_DEPENDENT_PSEUDO_CLASS(_name, _value, _bit) + CSS_PSEUDO_CLASS(_name, _value) #define DEFINED_CSS_STATE_PSEUDO_CLASS #endif @@ -108,11 +90,6 @@ CSS_PSEUDO_CLASS(mozTableBorderNonzero, ":-moz-table-border-nonzero") // it doesn't actually get directly matched on in SelectorMatches. CSS_PSEUDO_CLASS(notPseudo, ":not") -// :dir(ltr) and :dir(rtl) match elements whose resolved directionality -// in the markup language is ltr or rtl respectively -CSS_STATE_DEPENDENT_PSEUDO_CLASS(dir, ":dir", - NS_EVENT_STATE_LTR | NS_EVENT_STATE_RTL) - CSS_STATE_PSEUDO_CLASS(link, ":link", NS_EVENT_STATE_UNVISITED) // what matches :link or :visited CSS_STATE_PSEUDO_CLASS(mozAnyLink, ":-moz-any-link", @@ -201,8 +178,3 @@ CSS_STATE_PSEUDO_CLASS(mozMeterSubSubOptimum, ":-moz-meter-sub-sub-optimum", #undef DEFINED_CSS_STATE_PSEUDO_CLASS #undef CSS_STATE_PSEUDO_CLASS #endif - -#ifdef DEFINED_CSS_STATE_DEPENDENT_PSEUDO_CLASS -#undef DEFINED_CSS_STATE_DEPENDENT_PSEUDO_CLASS -#undef CSS_STATE_DEPENDENT_PSEUDO_CLASS -#endif diff --git a/layout/style/nsCSSPseudoClasses.cpp b/layout/style/nsCSSPseudoClasses.cpp index b2c19e355612..e2046357a049 100644 --- a/layout/style/nsCSSPseudoClasses.cpp +++ b/layout/style/nsCSSPseudoClasses.cpp @@ -42,8 +42,7 @@ nsCSSPseudoClasses::HasStringArg(Type aType) return aType == ePseudoClass_lang || aType == ePseudoClass_mozEmptyExceptChildrenWithLocalname || aType == ePseudoClass_mozSystemMetric || - aType == ePseudoClass_mozLocaleDir || - aType == ePseudoClass_dir; + aType == ePseudoClass_mozLocaleDir; } bool diff --git a/layout/style/nsCSSRuleProcessor.cpp b/layout/style/nsCSSRuleProcessor.cpp index 13f732dc55c3..f6b57039445d 100644 --- a/layout/style/nsCSSRuleProcessor.cpp +++ b/layout/style/nsCSSRuleProcessor.cpp @@ -1308,7 +1308,7 @@ struct NodeMatchContext { // event-state-dependent selector for any value of that event state. // So mStateMask contains the states that should NOT be tested. // - // NOTE: For |mStateMask| to work correctly, it's important that any + // NOTE: For |aStateMask| to work correctly, it's important that any // change that changes multiple state bits include all those state // bits in the notification. Otherwise, if multiple states change but // we do separate notifications then we might determine the style is @@ -1533,21 +1533,7 @@ checkGenericEmptyMatches(Element* aElement, return (child == nullptr); } -// Arrays of the states that are relevant for various pseudoclasses. -static const nsEventStates sPseudoClassStateDependences[] = { -#define CSS_PSEUDO_CLASS(_name, _value) \ - nsEventStates(), -#define CSS_STATE_DEPENDENT_PSEUDO_CLASS(_name, _value, _states) \ - _states, -#include "nsCSSPseudoClassList.h" -#undef CSS_STATE_DEPENDENT_PSEUDO_CLASS -#undef CSS_PSEUDO_CLASS - // Add more entries for our fake values to make sure we can't - // index out of bounds into this array no matter what. - nsEventStates(), - nsEventStates() -}; - +// An array of the states that are relevant for various pseudoclasses. static const nsEventStates sPseudoClassStates[] = { #define CSS_PSEUDO_CLASS(_name, _value) \ nsEventStates(), @@ -1570,7 +1556,7 @@ MOZ_STATIC_ASSERT(NS_ARRAY_LENGTH(sPseudoClassStates) == // * when non-null, it indicates that we're processing a negation, // which is done only when SelectorMatches calls itself recursively // * what it points to should be set to true whenever a test is skipped -// because of aNodeMatchContent.mStateMask +// because of aStateMask static bool SelectorMatches(Element* aElement, nsCSSSelector* aSelector, NodeMatchContext& aNodeMatchContext, @@ -2011,38 +1997,6 @@ static bool SelectorMatches(Element* aElement, } break; - case nsCSSPseudoClasses::ePseudoClass_dir: - { - if (aDependence) { - nsEventStates states - = sPseudoClassStateDependences[pseudoClass->mType]; - if (aNodeMatchContext.mStateMask.HasAtLeastOneOfStates(states)) { - *aDependence = true; - return false; - } - } - - // if we only had to consider HTML, directionality would be exclusively - // LTR or RTL, and this could be just - // - // if (dirString.EqualsLiteral("rtl") != - // aElement->StyleState().HasState(NS_EVENT_STATE_RTL) - // - // However, in markup languages where there is no direction attribute - // we have to consider the possibility that neither dir(rtl) nor - // dir(ltr) matches. - nsEventStates state = aElement->StyleState(); - bool elementIsRTL = state.HasState(NS_EVENT_STATE_RTL); - bool elementIsLTR = state.HasState(NS_EVENT_STATE_LTR); - nsDependentString dirString(pseudoClass->u.mString); - - if ((dirString.EqualsLiteral("rtl") && !elementIsRTL) || - (dirString.EqualsLiteral("ltr") && !elementIsLTR)) { - return false; - } - } - break; - default: NS_ABORT_IF_FALSE(false, "How did that happen?"); } @@ -2174,10 +2128,10 @@ static bool SelectorMatches(Element* aElement, bool dependence = false; result = !SelectorMatches(aElement, negation, aNodeMatchContext, aTreeMatchContext, &dependence); - // If the selector does match due to the dependence on - // aNodeMatchContext.mStateMask, then we want to keep result true - // so that the final result of SelectorMatches is true. Doing so - // tells StateEnumFunc that there is a dependence on the state. + // If the selector does match due to the dependence on aStateMask, + // then we want to keep result true so that the final result of + // SelectorMatches is true. Doing so tells StateEnumFunc that + // there is a dependence on the state. result = result || dependence; } } @@ -2711,7 +2665,7 @@ nsEventStates ComputeSelectorStateDependence(nsCSSSelector& aSelector) if (pseudoClass->mType >= nsCSSPseudoClasses::ePseudoClass_Count) { continue; } - states |= sPseudoClassStateDependences[pseudoClass->mType]; + states |= sPseudoClassStates[pseudoClass->mType]; } return states; } From a66ad991d2a7839bc8f2aa643af69e0c5c017980 Mon Sep 17 00:00:00 2001 From: Kartikaya Gupta Date: Wed, 8 Aug 2012 11:37:46 -0400 Subject: [PATCH 02/22] Bug 780699 - Prevent possible deadlock by reducing the scope of a synchronized block in GLController. r=ajuma --- mobile/android/base/gfx/GLController.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/mobile/android/base/gfx/GLController.java b/mobile/android/base/gfx/GLController.java index 29bc62f29b7f..16363ae40ef3 100644 --- a/mobile/android/base/gfx/GLController.java +++ b/mobile/android/base/gfx/GLController.java @@ -72,10 +72,13 @@ public class GLController { } // This function is invoked by JNI - public synchronized void resumeCompositorIfValid() { - if (mSurfaceValid) { - mView.getListener().compositionResumeRequested(mWidth, mHeight); + public void resumeCompositorIfValid() { + synchronized (this) { + if (!mSurfaceValid) { + return; + } } + mView.getListener().compositionResumeRequested(mWidth, mHeight); } // Wait until we are allowed to use EGL functions on the Surface backing From 4fd04c68e0ad690a014d8c7a1c924e4001e11686 Mon Sep 17 00:00:00 2001 From: Nathan Froyd Date: Wed, 8 Aug 2012 10:51:18 -0400 Subject: [PATCH 03/22] Bug 781152 - make telemetry ping save directory properly readable on Unix-ish platforms; r=taras --- toolkit/components/telemetry/TelemetryPing.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/toolkit/components/telemetry/TelemetryPing.js b/toolkit/components/telemetry/TelemetryPing.js index 3ca24694eebe..c492052e3c38 100644 --- a/toolkit/components/telemetry/TelemetryPing.js +++ b/toolkit/components/telemetry/TelemetryPing.js @@ -28,6 +28,7 @@ const PR_WRONLY = 0x2; const PR_CREATE_FILE = 0x8; const PR_TRUNCATE = 0x20; const RW_OWNER = 0600; +const RWX_OWNER = 0700; // MEM_HISTOGRAMS lists the memory reporters we turn into histograms. // @@ -863,13 +864,16 @@ TelemetryPing.prototype = { directory.append("saved-telemetry-pings"); if (directory.exists()) { if (directory.isDirectory()) { + // We used to wrongly create the directory with mode 0600. + // Fix that. + directory.permissions = RWX_OWNER; return directory; } else { directory.remove(true); } } - directory.create(Ci.nsIFile.DIRECTORY_TYPE, RW_OWNER); + directory.create(Ci.nsIFile.DIRECTORY_TYPE, RWX_OWNER); return directory; }, From 94b7f94a3cf45820d8fa1cd50607be9e03c6bf99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabrice=20Desr=C3=A9?= Date: Wed, 8 Aug 2012 09:41:47 -0700 Subject: [PATCH 04/22] Bug 779935 - nsIAppsService.idl need to get mozIDOMApplication from manifest id [r=mounir] --- dom/apps/src/AppsService.js | 20 +++++++++++++++++ dom/apps/src/Webapps.jsm | 31 +++++++++++++++++++++++++- dom/interfaces/apps/nsIAppsService.idl | 12 +++++++++- 3 files changed, 61 insertions(+), 2 deletions(-) diff --git a/dom/apps/src/AppsService.js b/dom/apps/src/AppsService.js index 6ae20fcaea44..36d20a991f59 100644 --- a/dom/apps/src/AppsService.js +++ b/dom/apps/src/AppsService.js @@ -53,6 +53,26 @@ AppsService.prototype = { } }, + getAppByLocalId: function getAppByLocalId(aLocalId) { + debug("getAppByLocalId( " + aLocalId + " )"); + if (this.inParent) { + return DOMApplicationRegistry.getAppByLocalId(aLocalId); + } else { + return this.cpmm.sendSyncMessage("WebApps:GetAppByLocalId", + { id: aLocalId })[0]; + } + }, + + getManifestURLByLocalId: function getManifestURLByLocalId(aLocalId) { + debug("getManifestURLByLocalId( " + aLocalId + " )"); + if (this.inParent) { + return DOMApplicationRegistry.getManifestURLByLocalId(aLocalId); + } else { + return this.cpmm.sendSyncMessage("WebApps:GetManifestURLByLocalId", + { id: aLocalId })[0]; + } + }, + classID : APPS_SERVICE_CID, QueryInterface : XPCOMUtils.generateQI([Ci.nsIAppsService]) } diff --git a/dom/apps/src/Webapps.jsm b/dom/apps/src/Webapps.jsm index b19dd81de18b..2b7045671c5c 100644 --- a/dom/apps/src/Webapps.jsm +++ b/dom/apps/src/Webapps.jsm @@ -57,7 +57,8 @@ let DOMApplicationRegistry = { "Webapps:GetInstalled", "Webapps:GetNotInstalled", "Webapps:Launch", "Webapps:GetAll", "Webapps:InstallPackage", "Webapps:GetBasePath", - "WebApps:GetAppByManifestURL", "WebApps:GetAppLocalIdByManifestURL"]; + "WebApps:GetAppByManifestURL", "WebApps:GetAppLocalIdByManifestURL", + "WebApps:GetAppByLocalId", "Webapps:GetManifestURLByLocalId"]; this.messages.forEach((function(msgName) { ppmm.addMessageListener(msgName, this); @@ -249,6 +250,12 @@ let DOMApplicationRegistry = { case "WebApps:GetAppLocalIdByManifestURL": return { id: this.getAppLocalIdByManifestURL(msg.url) }; break; + case "WebApps:GetAppByLocalId": + return this.getAppByLocalId(msg.id); + break; + case "WebApps:GetManifestURLByLocalId": + return this.getManifestURLByLocalId(msg.id); + break; } }, @@ -698,6 +705,28 @@ let DOMApplicationRegistry = { return null; }, + getAppByLocalId: function(aLocalId) { + for (let id in this.webapps) { + let app = this.webapps[id]; + if (app.localId == aLocalId) { + return this._cloneAppObject(app); + } + } + + return null; + }, + + getManifestURLByLocalId: function(aLocalId) { + for (let id in this.webapps) { + let app = this.webapps[id]; + if (app.localId == aLocalId) { + return app.manifestURL; + } + } + + return null; + }, + getAppLocalIdByManifestURL: function(aManifestURL) { for (let id in this.webapps) { if (this.webapps[id].manifestURL == aManifestURL) { diff --git a/dom/interfaces/apps/nsIAppsService.idl b/dom/interfaces/apps/nsIAppsService.idl index 67471e7b6ef2..e1559aa0e6ba 100644 --- a/dom/interfaces/apps/nsIAppsService.idl +++ b/dom/interfaces/apps/nsIAppsService.idl @@ -15,7 +15,7 @@ interface mozIDOMApplication; * This service allows accessing some DOMApplicationRegistry methods from * non-javascript code. */ -[scriptable, uuid(1210a0f3-add3-4381-b892-9c102e3afc42)] +[scriptable, uuid(04e4ef3c-1a30-45bc-ab08-291820f13872)] interface nsIAppsService : nsISupports { mozIDOMApplication getAppByManifestURL(in DOMString manifestURL); @@ -27,4 +27,14 @@ interface nsIAppsService : nsISupports * installed manifest URL. */ unsigned long getAppLocalIdByManifestURL(in DOMString manifestURL); + + /** + * Returns the application associated to this localId. + */ + mozIDOMApplication getAppByLocalId(in unsigned long localId); + + /** + * Returns the manifest URL associated to this localId. + */ + DOMString getManifestURLByLocalId(in unsigned long localId); }; From bccf79f0b0295ab4691267a862abc3c5c6d8c0b6 Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Wed, 8 Aug 2012 18:57:22 +0200 Subject: [PATCH 05/22] Bug 781128 - Fix application.ini dependencies after bug 767839 on a CLOSED TREE. r=ted --HG-- extra : transplant_source : N%3F%B1%F9%F7%2A%DC%B3%0C%3C%13%0D%24%17%07%9FP%DE%7D%5B --- build/Makefile.in | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build/Makefile.in b/build/Makefile.in index 88b2aa463539..ea19bbeb8c10 100644 --- a/build/Makefile.in +++ b/build/Makefile.in @@ -132,6 +132,8 @@ leaktest.py: leaktest.py.in GARBAGE += leaktest.py ifdef MOZ_APP_BASENAME +$(FINAL_TARGET)/application.ini: $(APP_INI_DEPS) + ifdef MOZ_APP_STATIC_INI application.ini.h: appini_header.py $(FINAL_TARGET)/application.ini $(PYTHON) $^ > $@ From 894868aa631ca4770819e0ce2abe73c2321324f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabrice=20Desr=C3=A9?= Date: Wed, 8 Aug 2012 10:21:54 -0700 Subject: [PATCH 06/22] Bug 781224 - Rename APP_STATUS_TRUSTED to APP_STATUS_PRIVILEGED in nsIPrincipal [r=mounir] --- caps/idl/nsIPrincipal.idl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/caps/idl/nsIPrincipal.idl b/caps/idl/nsIPrincipal.idl index a0e6d1d6dcc7..2e016a3abf2d 100644 --- a/caps/idl/nsIPrincipal.idl +++ b/caps/idl/nsIPrincipal.idl @@ -21,7 +21,7 @@ interface nsIContentSecurityPolicy; [ptr] native JSPrincipals(JSPrincipals); [ptr] native PrincipalArray(nsTArray >); -[scriptable, uuid(8a74b011-667d-4cfa-b2a2-b27582ba5f38)] +[scriptable, uuid(6df7d16d-5b26-42a1-b1f7-069d46c37aa8)] interface nsIPrincipal : nsISerializable { /** @@ -230,13 +230,13 @@ interface nsIPrincipal : nsISerializable const short APP_STATUS_NOT_INSTALLED = 0; const short APP_STATUS_INSTALLED = 1; - const short APP_STATUS_TRUSTED = 2; + const short APP_STATUS_PRIVILEGED = 2; const short APP_STATUS_CERTIFIED = 3; /** * Shows the status of the app. * Can be: APP_STATUS_NOT_INSTALLED, APP_STATUS_INSTALLED, - * APP_STATUS_TRUSTED or APP_STATUS_CERTIFIED. + * APP_STATUS_PRIVILEGED or APP_STATUS_CERTIFIED. */ readonly attribute unsigned short appStatus; From 11d7f94bbe17f112f43697430676ec889328cd69 Mon Sep 17 00:00:00 2001 From: Kyle Machulis Date: Wed, 8 Aug 2012 10:46:39 -0700 Subject: [PATCH 07/22] Bug 768306 - Patch 1: Fix error handling in unpacking DBus replies, set up DBus blocking call handling thread; r=mrbkap --- dom/bluetooth/BluetoothService.cpp | 36 ++++---- dom/bluetooth/BluetoothService.h | 13 +++ dom/bluetooth/linux/BluetoothDBusService.cpp | 88 ++++++++++++-------- ipc/dbus/DBusUtils.cpp | 5 +- ipc/dbus/DBusUtils.h | 1 + ipc/dbus/RawDBusConnection.h | 4 + 6 files changed, 94 insertions(+), 53 deletions(-) diff --git a/dom/bluetooth/BluetoothService.cpp b/dom/bluetooth/BluetoothService.cpp index b3c75d22e39f..e446388ee08d 100644 --- a/dom/bluetooth/BluetoothService.cpp +++ b/dom/bluetooth/BluetoothService.cpp @@ -22,34 +22,37 @@ using namespace mozilla; USING_BLUETOOTH_NAMESPACE -nsRefPtr gBluetoothService; -nsCOMPtr gToggleBtThread; -int gPendingInitCount = 0; -bool gInShutdown = false; +static nsRefPtr gBluetoothService; +static bool gInShutdown = false; NS_IMPL_ISUPPORTS1(BluetoothService, nsIObserver) class ToggleBtAck : public nsRunnable { public: + ToggleBtAck(bool aEnabled) : + mEnabled(aEnabled) + { + } + NS_IMETHOD Run() { MOZ_ASSERT(NS_IsMainThread()); - gPendingInitCount--; - - if (gPendingInitCount) { - return NS_OK; + + if (!mEnabled || gInShutdown) { + nsCOMPtr t; + gBluetoothService->mBluetoothCommandThread.swap(t); + t->Shutdown(); } if (gInShutdown) { gBluetoothService = nullptr; } - nsCOMPtr t; - gToggleBtThread.swap(t); - t->Shutdown(); return NS_OK; } + + bool mEnabled; }; class ToggleBtTask : public nsRunnable @@ -82,7 +85,7 @@ public: // Always has to be called since this is where we take care of our reference // count for runnables. If there's an error, replyError won't be empty, so // consider our status flipped. - nsCOMPtr ackTask = new ToggleBtAck(); + nsCOMPtr ackTask = new ToggleBtAck(mEnabled); if (NS_FAILED(NS_DispatchToMainThread(ackTask))) { NS_WARNING("Failed to dispatch to main thread!"); } @@ -168,17 +171,16 @@ BluetoothService::StartStopBluetooth(BluetoothReplyRunnable* aResultRunnable, NS_ERROR("Start called while in shutdown!"); return NS_ERROR_FAILURE; } - if (!gToggleBtThread) { - nsresult rv = NS_NewNamedThread("BluetoothCtrl", - getter_AddRefs(gToggleBtThread)); + if (!mBluetoothCommandThread) { + nsresult rv = NS_NewNamedThread("BluetoothCmd", + getter_AddRefs(mBluetoothCommandThread)); NS_ENSURE_SUCCESS(rv, rv); } nsCOMPtr r = new ToggleBtTask(aStart, aResultRunnable); - if (NS_FAILED(gToggleBtThread->Dispatch(r, NS_DISPATCH_NORMAL))) { + if (NS_FAILED(mBluetoothCommandThread->Dispatch(r, NS_DISPATCH_NORMAL))) { NS_WARNING("Cannot dispatch firmware loading task!"); return NS_ERROR_FAILURE; } - gPendingInitCount++; return NS_OK; } diff --git a/dom/bluetooth/BluetoothService.h b/dom/bluetooth/BluetoothService.h index fdeedcb35196..1c687ef61d8d 100644 --- a/dom/bluetooth/BluetoothService.h +++ b/dom/bluetooth/BluetoothService.h @@ -192,6 +192,19 @@ public: const nsAString& aPattern, int aAttributeId) = 0; + /** + * Due to the fact that some operations require multiple calls, a + * CommandThread is created that can run blocking, platform-specific calls + * where either no asynchronous equivilent exists, or else where multiple + * asynchronous calls would require excessive runnable bouncing between main + * thread and IO thread. + * + * For instance, when we retrieve an Adapter object, we would like it to come + * with all of its properties filled in and registered as an agent, which + * requires a minimum of 3 calls to platform specific code on some platforms. + * + */ + nsCOMPtr mBluetoothCommandThread; protected: BluetoothService() { diff --git a/dom/bluetooth/linux/BluetoothDBusService.cpp b/dom/bluetooth/linux/BluetoothDBusService.cpp index 0a3e08c3ca40..bfeac0946606 100644 --- a/dom/bluetooth/linux/BluetoothDBusService.cpp +++ b/dom/bluetooth/linux/BluetoothDBusService.cpp @@ -149,8 +149,14 @@ public: }; bool -IsDBusMessageError(DBusMessage* aMsg, nsAString& aError) +IsDBusMessageError(DBusMessage* aMsg, DBusError* aErr, nsAString& aErrorStr) { + if(aErr && dbus_error_is_set(aErr)) { + aErrorStr = NS_ConvertUTF8toUTF16(aErr->message); + LOG_AND_FREE_DBUS_ERROR(aErr); + return true; + } + DBusError err; dbus_error_init(&err); if (dbus_message_get_type(aMsg) == DBUS_MESSAGE_TYPE_ERROR) { @@ -159,12 +165,15 @@ IsDBusMessageError(DBusMessage* aMsg, nsAString& aError) &error_msg, DBUS_TYPE_INVALID) || !error_msg) { if (dbus_error_is_set(&err)) { - aError = NS_ConvertUTF8toUTF16(err.message); + aErrorStr = NS_ConvertUTF8toUTF16(err.message); LOG_AND_FREE_DBUS_ERROR(&err); return true; + } else { + aErrorStr.AssignLiteral("Unknown Error"); + return true; } } else { - aError = NS_ConvertUTF8toUTF16(error_msg); + aErrorStr = NS_ConvertUTF8toUTF16(error_msg); return true; } } @@ -173,15 +182,14 @@ IsDBusMessageError(DBusMessage* aMsg, nsAString& aError) void DispatchBluetoothReply(BluetoothReplyRunnable* aRunnable, - const BluetoothValue& aValue, const nsAString& aError) + const BluetoothValue& aValue, const nsAString& aErrorStr) { // Reply will be deleted by the runnable after running on main thread BluetoothReply* reply; - if (!aError.IsEmpty()) { - nsString err(aError); + if (!aErrorStr.IsEmpty()) { + nsString err(aErrorStr); reply = new BluetoothReply(BluetoothReplyError(err)); - } - else { + } else { reply = new BluetoothReply(BluetoothReplySuccess(aValue)); } @@ -192,12 +200,12 @@ DispatchBluetoothReply(BluetoothReplyRunnable* aRunnable, } void -UnpackObjectPathMessage(DBusMessage* aMsg, BluetoothValue& aValue, - nsAString& aErrorStr) +UnpackObjectPathMessage(DBusMessage* aMsg, DBusError* aErr, + BluetoothValue& aValue, nsAString& aErrorStr) { DBusError err; dbus_error_init(&err); - if (!IsDBusMessageError(aMsg, aErrorStr)) { + if (!IsDBusMessageError(aMsg, aErr, aErrorStr)) { NS_ASSERTION(dbus_message_get_type(aMsg) == DBUS_MESSAGE_TYPE_METHOD_RETURN, "Got dbus callback that's not a METHOD_RETURN!"); const char* object_path; @@ -214,7 +222,7 @@ UnpackObjectPathMessage(DBusMessage* aMsg, BluetoothValue& aValue, } } -typedef void (*UnpackFunc)(DBusMessage*, BluetoothValue&, nsAString&); +typedef void (*UnpackFunc)(DBusMessage*, DBusError*, BluetoothValue&, nsAString&); void RunDBusCallback(DBusMessage* aMsg, void* aBluetoothReplyRunnable, @@ -228,23 +236,24 @@ RunDBusCallback(DBusMessage* aMsg, void* aBluetoothReplyRunnable, nsString replyError; BluetoothValue v; - aFunc(aMsg, v, replyError); + aFunc(aMsg, nsnull, v, replyError); DispatchBluetoothReply(replyRunnable, v, replyError); } void GetObjectPathCallback(DBusMessage* aMsg, void* aBluetoothReplyRunnable) { - RunDBusCallback(aMsg, aBluetoothReplyRunnable, UnpackObjectPathMessage); + RunDBusCallback(aMsg, aBluetoothReplyRunnable, + UnpackObjectPathMessage); } void -UnpackVoidMessage(DBusMessage* aMsg, BluetoothValue& aValue, +UnpackVoidMessage(DBusMessage* aMsg, DBusError* aErr, BluetoothValue& aValue, nsAString& aErrorStr) { DBusError err; dbus_error_init(&err); - if (!IsDBusMessageError(aMsg, aErrorStr) && + if (!IsDBusMessageError(aMsg, aErr, aErrorStr) && dbus_message_get_type(aMsg) == DBUS_MESSAGE_TYPE_METHOD_RETURN && !dbus_message_get_args(aMsg, &err, DBUS_TYPE_INVALID)) { if (dbus_error_is_set(&err)) { @@ -257,7 +266,8 @@ UnpackVoidMessage(DBusMessage* aMsg, BluetoothValue& aValue, void GetVoidCallback(DBusMessage* aMsg, void* aBluetoothReplyRunnable) { - RunDBusCallback(aMsg, aBluetoothReplyRunnable, UnpackVoidMessage); + RunDBusCallback(aMsg, aBluetoothReplyRunnable, + UnpackVoidMessage); } bool @@ -381,11 +391,13 @@ ParseProperties(DBusMessageIter* aIter, aValue = props; } -void UnpackPropertiesMessage(DBusMessage* aMsg, BluetoothValue& aValue, - nsAString& aErrorStr, Properties* aPropertyTypes, - const int aPropertyTypeLen) +void +UnpackPropertiesMessage(DBusMessage* aMsg, DBusError* aErr, + BluetoothValue& aValue, nsAString& aErrorStr, + Properties* aPropertyTypes, + const int aPropertyTypeLen) { - if (!IsDBusMessageError(aMsg, aErrorStr) && + if (!IsDBusMessageError(aMsg, aErr, aErrorStr) && dbus_message_get_type(aMsg) == DBUS_MESSAGE_TYPE_METHOD_RETURN) { DBusMessageIter iter; if (!dbus_message_iter_init(aMsg, &iter)) { @@ -397,26 +409,32 @@ void UnpackPropertiesMessage(DBusMessage* aMsg, BluetoothValue& aValue, } } -void UnpackAdapterPropertiesMessage(DBusMessage* aMsg, BluetoothValue& aValue, - nsAString& aErrorStr) +void +UnpackAdapterPropertiesMessage(DBusMessage* aMsg, DBusError* aErr, + BluetoothValue& aValue, + nsAString& aErrorStr) { - UnpackPropertiesMessage(aMsg, aValue, aErrorStr, + UnpackPropertiesMessage(aMsg, aErr, aValue, aErrorStr, sAdapterProperties, ArrayLength(sAdapterProperties)); } -void UnpackDevicePropertiesMessage(DBusMessage* aMsg, BluetoothValue& aValue, - nsAString& aErrorStr) +void +UnpackDevicePropertiesMessage(DBusMessage* aMsg, DBusError* aErr, + BluetoothValue& aValue, + nsAString& aErrorStr) { - UnpackPropertiesMessage(aMsg, aValue, aErrorStr, + UnpackPropertiesMessage(aMsg, aErr, aValue, aErrorStr, sDeviceProperties, ArrayLength(sDeviceProperties)); } -void UnpackManagerPropertiesMessage(DBusMessage* aMsg, BluetoothValue& aValue, - nsAString& aErrorStr) +void +UnpackManagerPropertiesMessage(DBusMessage* aMsg, DBusError* aErr, + BluetoothValue& aValue, + nsAString& aErrorStr) { - UnpackPropertiesMessage(aMsg, aValue, aErrorStr, + UnpackPropertiesMessage(aMsg, aErr, aValue, aErrorStr, sManagerProperties, ArrayLength(sManagerProperties)); } @@ -424,19 +442,22 @@ void UnpackManagerPropertiesMessage(DBusMessage* aMsg, BluetoothValue& aValue, void GetManagerPropertiesCallback(DBusMessage* aMsg, void* aBluetoothReplyRunnable) { - RunDBusCallback(aMsg, aBluetoothReplyRunnable, UnpackManagerPropertiesMessage); + RunDBusCallback(aMsg, aBluetoothReplyRunnable, + UnpackManagerPropertiesMessage); } void GetAdapterPropertiesCallback(DBusMessage* aMsg, void* aBluetoothReplyRunnable) { - RunDBusCallback(aMsg, aBluetoothReplyRunnable, UnpackAdapterPropertiesMessage); + RunDBusCallback(aMsg, aBluetoothReplyRunnable, + UnpackAdapterPropertiesMessage); } void GetDevicePropertiesCallback(DBusMessage* aMsg, void* aBluetoothReplyRunnable) { - RunDBusCallback(aMsg, aBluetoothReplyRunnable, UnpackDevicePropertiesMessage); + RunDBusCallback(aMsg, aBluetoothReplyRunnable, + UnpackDevicePropertiesMessage); } static DBusCallback sBluetoothDBusPropCallbacks[] = @@ -611,7 +632,6 @@ BluetoothDBusService::StartInternal() } if (NS_FAILED(EstablishDBusConnection())) { - NS_WARNING("Cannot start DBus connection!"); StopDBus(); return NS_ERROR_FAILURE; } diff --git a/ipc/dbus/DBusUtils.cpp b/ipc/dbus/DBusUtils.cpp index 6f41f7697825..24d1b4e52a08 100644 --- a/ipc/dbus/DBusUtils.cpp +++ b/ipc/dbus/DBusUtils.cpp @@ -199,7 +199,7 @@ DBusMessage * dbus_func_args_timeout_valist(DBusConnection *conn, /* Make the call. */ reply = dbus_connection_send_with_reply_and_block(conn, msg, timeout_ms, err); if (!return_error && dbus_error_is_set(err)) { - //LOG_AND_FREE_DBUS_ERROR_WITH_MSG(err, msg); + LOG_AND_FREE_DBUS_ERROR_WITH_MSG(err, msg); } done: @@ -212,6 +212,7 @@ done: DBusMessage * dbus_func_args_timeout(DBusConnection *conn, int timeout_ms, + DBusError* err, const char *path, const char *ifc, const char *func, @@ -220,7 +221,7 @@ DBusMessage * dbus_func_args_timeout(DBusConnection *conn, DBusMessage *ret; va_list lst; va_start(lst, first_arg_type); - ret = dbus_func_args_timeout_valist(conn, timeout_ms, NULL, + ret = dbus_func_args_timeout_valist(conn, timeout_ms, err, path, ifc, func, first_arg_type, lst); va_end(lst); diff --git a/ipc/dbus/DBusUtils.h b/ipc/dbus/DBusUtils.h index 948f9d18a667..d4d41956080c 100644 --- a/ipc/dbus/DBusUtils.h +++ b/ipc/dbus/DBusUtils.h @@ -90,6 +90,7 @@ DBusMessage* dbus_func_args_error(DBusConnection* conn, DBusMessage* dbus_func_args_timeout(DBusConnection* conn, int timeout_ms, + DBusError* err, const char* path, const char* ifc, const char* func, diff --git a/ipc/dbus/RawDBusConnection.h b/ipc/dbus/RawDBusConnection.h index f407069b76ea..30ad1ef02ec0 100644 --- a/ipc/dbus/RawDBusConnection.h +++ b/ipc/dbus/RawDBusConnection.h @@ -31,6 +31,10 @@ public: RawDBusConnection(); ~RawDBusConnection(); nsresult EstablishDBusConnection(); + DBusConnection* GetConnection() { + return mConnection; + } +protected: Scoped mConnection; }; From 281a66ef4caa0b6bfd9338cb3809947929ced7bb Mon Sep 17 00:00:00 2001 From: Kyle Machulis Date: Wed, 8 Aug 2012 10:47:09 -0700 Subject: [PATCH 08/22] Bug 768306 - Patch 2: Change BluetoothAdapter initialization to get properties via off main thread blocking calls when creating Adapter object; r=mrbkap --- dom/bluetooth/BluetoothAdapter.cpp | 19 ++-- dom/bluetooth/BluetoothAdapter.h | 5 +- dom/bluetooth/BluetoothManager.cpp | 7 +- dom/bluetooth/linux/BluetoothDBusService.cpp | 100 +++++++++++++++++-- 4 files changed, 104 insertions(+), 27 deletions(-) diff --git a/dom/bluetooth/BluetoothAdapter.cpp b/dom/bluetooth/BluetoothAdapter.cpp index 07a155da6d61..0aace261cb7b 100644 --- a/dom/bluetooth/BluetoothAdapter.cpp +++ b/dom/bluetooth/BluetoothAdapter.cpp @@ -62,14 +62,18 @@ NS_INTERFACE_MAP_END_INHERITING(nsDOMEventTargetHelper) NS_IMPL_ADDREF_INHERITED(BluetoothAdapter, nsDOMEventTargetHelper) NS_IMPL_RELEASE_INHERITED(BluetoothAdapter, nsDOMEventTargetHelper) -BluetoothAdapter::BluetoothAdapter(nsPIDOMWindow* aOwner, const nsAString& aPath) +BluetoothAdapter::BluetoothAdapter(nsPIDOMWindow* aOwner, const BluetoothValue& aValue) : BluetoothPropertyContainer(BluetoothObjectType::TYPE_ADAPTER) , mJsUuids(nullptr) , mJsDeviceAddresses(nullptr) , mIsRooted(false) { BindToOwner(aOwner); - mPath = aPath; + const InfallibleTArray& values = + aValue.get_ArrayOfBluetoothNamedValue(); + for (uint32_t i = 0; i < values.Length(); ++i) { + SetPropertyByValue(values[i]); + } } BluetoothAdapter::~BluetoothAdapter() @@ -175,21 +179,16 @@ BluetoothAdapter::SetPropertyByValue(const BluetoothNamedValue& aValue) // static already_AddRefed -BluetoothAdapter::Create(nsPIDOMWindow* aOwner, const nsAString& aPath) +BluetoothAdapter::Create(nsPIDOMWindow* aOwner, const BluetoothValue& aValue) { - // Make sure we at least have a path - NS_ASSERTION(!aPath.IsEmpty(), "Adapter created with empty path!"); - BluetoothService* bs = BluetoothService::Get(); if (!bs) { NS_WARNING("BluetoothService not available!"); return nullptr; } - nsRefPtr adapter = new BluetoothAdapter(aOwner, aPath); - nsString path; - path = adapter->GetPath(); - if (NS_FAILED(bs->RegisterBluetoothSignalHandler(path, adapter))) { + nsRefPtr adapter = new BluetoothAdapter(aOwner, aValue); + if (NS_FAILED(bs->RegisterBluetoothSignalHandler(adapter->GetPath(), adapter))) { NS_WARNING("Failed to register object with observer!"); return nullptr; } diff --git a/dom/bluetooth/BluetoothAdapter.h b/dom/bluetooth/BluetoothAdapter.h index eec181743774..d52290478090 100644 --- a/dom/bluetooth/BluetoothAdapter.h +++ b/dom/bluetooth/BluetoothAdapter.h @@ -20,6 +20,7 @@ BEGIN_BLUETOOTH_NAMESPACE class BluetoothSignal; class BluetoothNamedValue; +class BluetoothValue; class BluetoothAdapter : public nsDOMEventTargetHelper , public nsIDOMBluetoothAdapter @@ -36,7 +37,7 @@ public: nsDOMEventTargetHelper) static already_AddRefed - Create(nsPIDOMWindow* aOwner, const nsAString& name); + Create(nsPIDOMWindow* aOwner, const BluetoothValue& aValue); void Notify(const BluetoothSignal& aParam); @@ -57,7 +58,7 @@ public: virtual void SetPropertyByValue(const BluetoothNamedValue& aValue); private: - BluetoothAdapter(nsPIDOMWindow* aOwner, const nsAString& aPath); + BluetoothAdapter(nsPIDOMWindow* aOwner, const BluetoothValue& aValue); ~BluetoothAdapter(); void Root(); diff --git a/dom/bluetooth/BluetoothManager.cpp b/dom/bluetooth/BluetoothManager.cpp index 1c9abb8d1889..ccfa782a51ab 100644 --- a/dom/bluetooth/BluetoothManager.cpp +++ b/dom/bluetooth/BluetoothManager.cpp @@ -64,10 +64,9 @@ public: nsCOMPtr adapter; *aValue = JSVAL_VOID; - const nsString& path = - mReply->get_BluetoothReplySuccess().value().get_nsString(); - adapter = BluetoothAdapter::Create(mManagerPtr->GetOwner(), - path); + const InfallibleTArray& v = + mReply->get_BluetoothReplySuccess().value().get_ArrayOfBluetoothNamedValue(); + adapter = BluetoothAdapter::Create(mManagerPtr->GetOwner(), v); nsresult rv; nsIScriptContext* sc = mManagerPtr->GetContextForEventHandlers(&rv); diff --git a/dom/bluetooth/linux/BluetoothDBusService.cpp b/dom/bluetooth/linux/BluetoothDBusService.cpp index bfeac0946606..f6469b3899a3 100644 --- a/dom/bluetooth/linux/BluetoothDBusService.cpp +++ b/dom/bluetooth/linux/BluetoothDBusService.cpp @@ -127,6 +127,13 @@ static const char* sBluetoothDBusSignals[] = "type='signal',interface='org.bluez.AudioSink'" }; +/** + * DBus Connection held for the BluetoothCommandThread to use. Should never be + * used by any other thread. + * + */ +static nsAutoPtr gThreadConnection; + class DistributeBluetoothSignalTask : public nsRunnable { BluetoothSignal mSignal; public: @@ -632,6 +639,15 @@ BluetoothDBusService::StartInternal() } if (NS_FAILED(EstablishDBusConnection())) { + NS_WARNING("Cannot start Main Thread DBus connection!"); + StopDBus(); + return NS_ERROR_FAILURE; + } + + gThreadConnection = new RawDBusConnection(); + + if (NS_FAILED(gThreadConnection->EstablishDBusConnection())) { + NS_WARNING("Cannot start Sync Thread DBus connection!"); StopDBus(); return NS_ERROR_FAILURE; } @@ -687,33 +703,95 @@ BluetoothDBusService::StopInternal() dbus_connection_remove_filter(mConnection, EventFilter, nullptr); mConnection = nullptr; + gThreadConnection = nullptr; mBluetoothSignalObserverTable.Clear(); StopDBus(); return NS_OK; } +class DefaultAdapterPropertiesRunnable : public nsRunnable +{ +public: + DefaultAdapterPropertiesRunnable(BluetoothReplyRunnable* aRunnable) + : mRunnable(dont_AddRef(aRunnable)) + { + } + + nsresult + Run() + { + MOZ_ASSERT(!NS_IsMainThread()); + DBusError err; + dbus_error_init(&err); + + BluetoothValue v; + nsString replyError; + + DBusMessage* msg = dbus_func_args_timeout(gThreadConnection->GetConnection(), + 1000, + &err, + "/", + DBUS_MANAGER_IFACE, + "DefaultAdapter", + DBUS_TYPE_INVALID); + UnpackObjectPathMessage(msg, &err, v, replyError); + if(msg) { + dbus_message_unref(msg); + } + if(!replyError.IsEmpty()) { + DispatchBluetoothReply(mRunnable, v, replyError); + return NS_ERROR_FAILURE; + } + + nsString path = v.get_nsString(); + nsCString tmp_path = NS_ConvertUTF16toUTF8(path); + const char* object_path = tmp_path.get(); + + v = InfallibleTArray(); + msg = dbus_func_args_timeout(gThreadConnection->GetConnection(), + 1000, + &err, + object_path, + "org.bluez.Adapter", + "GetProperties", + DBUS_TYPE_INVALID); + UnpackAdapterPropertiesMessage(msg, &err, v, replyError); + + if(!replyError.IsEmpty()) { + DispatchBluetoothReply(mRunnable, v, replyError); + return NS_ERROR_FAILURE; + } + if(msg) { + dbus_message_unref(msg); + } + // We have to manually attach the path to the rest of the elements + v.get_ArrayOfBluetoothNamedValue().AppendElement(BluetoothNamedValue(NS_LITERAL_STRING("Path"), + path)); + DispatchBluetoothReply(mRunnable, v, replyError); + + return NS_OK; + } + +private: + nsRefPtr mRunnable; +}; + nsresult BluetoothDBusService::GetDefaultAdapterPathInternal(BluetoothReplyRunnable* aRunnable) { - if (!mConnection) { + if (!mConnection || !gThreadConnection) { NS_ERROR("Bluetooth service not started yet!"); return NS_ERROR_FAILURE; } NS_ASSERTION(NS_IsMainThread(), "Must be called from main thread!"); - nsRefPtr runnable = aRunnable; - if (!dbus_func_args_async(mConnection, - 1000, - GetObjectPathCallback, - (void*)aRunnable, - "/", - "org.bluez.Manager", - "DefaultAdapter", - DBUS_TYPE_INVALID)) { - NS_WARNING("Could not start async function!"); + nsRefPtr func(new DefaultAdapterPropertiesRunnable(runnable)); + if (NS_FAILED(mBluetoothCommandThread->Dispatch(func, NS_DISPATCH_NORMAL))) { + NS_WARNING("Cannot dispatch firmware loading task!"); return NS_ERROR_FAILURE; } + runnable.forget(); return NS_OK; } From cd006a7563509faf27df7391deef261df077695e Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Wed, 8 Aug 2012 10:51:40 -0700 Subject: [PATCH 09/22] Bug 778067: Disable 735943.html for , for now. r=jlebar --- layout/base/crashtests/crashtests.list | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/layout/base/crashtests/crashtests.list b/layout/base/crashtests/crashtests.list index 7b3dd2382246..6cc7440ceddc 100644 --- a/layout/base/crashtests/crashtests.list +++ b/layout/base/crashtests/crashtests.list @@ -353,7 +353,16 @@ load 707098.html load 722137.html load 725535.html load 727601.html -skip-if(Android&&!browserIsRemote) asserts(0-2) pref(dom.disable_open_during_load,false) load 735943.html # the assertion is bug 735966, for android bug 760271 +# Bug 778067: This test fails when we try to create a popup window in +# , because TabParent::AnswerOpenWindow() can't deal +# with creating a popup window this early during page load. However, +#