Merge m-c to b-i
authorPhil Ringnalda <philringnalda@gmail.com>
Sat, 15 Feb 2014 18:35:10 -0800
changeset 169434 ea3daa796d7009ce85a83047960eb31cac5235bb
parent 169433 5babbad317ea84ba40bd1d9e15d8512b742ec710 (current diff)
parent 169425 252a41942fc746a9e48d24d00dc2320146b4db13 (diff)
child 169435 2bddbd180d2d9fa38ac4138267e1cbfebc6bb5ef
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
milestone30.0a1
Merge m-c to b-i
ipc/testshell/Makefile.in
toolkit/components/alerts/Makefile.in
toolkit/crashreporter/google-breakpad/src/client/Makefile.in
toolkit/crashreporter/google-breakpad/src/client/linux/crash_generation/Makefile.in
toolkit/crashreporter/google-breakpad/src/client/mac/crash_generation/Makefile.in
toolkit/crashreporter/google-breakpad/src/client/mac/handler/Makefile.in
toolkit/crashreporter/google-breakpad/src/client/solaris/handler/Makefile.in
toolkit/crashreporter/google-breakpad/src/common/solaris/Makefile.in
toolkit/crashreporter/google-breakpad/src/processor/Makefile.in
uriloader/prefetch/Makefile.in
--- a/accessible/src/base/TreeWalker.cpp
+++ b/accessible/src/base/TreeWalker.cpp
@@ -4,17 +4,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "TreeWalker.h"
 
 #include "Accessible.h"
 #include "nsAccessibilityService.h"
 #include "DocAccessible.h"
 
-#include "nsINodeList.h"
+#include "mozilla/dom/Element.h"
 
 using namespace mozilla::a11y;
 
 ////////////////////////////////////////////////////////////////////////////////
 // WalkState
 ////////////////////////////////////////////////////////////////////////////////
 
 namespace mozilla {
@@ -34,19 +34,19 @@ struct WalkState
 } // namespace a11y
 } // namespace mozilla
 
 ////////////////////////////////////////////////////////////////////////////////
 // TreeWalker
 ////////////////////////////////////////////////////////////////////////////////
 
 TreeWalker::
-  TreeWalker(Accessible* aContext, nsIContent* aContent, bool aWalkCache) :
+  TreeWalker(Accessible* aContext, nsIContent* aContent, uint32_t aFlags) :
   mDoc(aContext->Document()), mContext(aContext),
-  mWalkCache(aWalkCache), mState(nullptr)
+  mFlags(aFlags), mState(nullptr)
 {
   NS_ASSERTION(aContent, "No node for the accessible tree walker!");
 
   if (aContent)
     mState = new WalkState(aContent);
 
   mChildFilter = mContext->CanHaveAnonChildren() ?
     nsIContent::eAllChildren : nsIContent::eAllButXBL;
@@ -81,52 +81,79 @@ TreeWalker::NextChildInternal(bool aNoWa
   if (mState->childList)
     mState->childList->GetLength(&length);
 
   while (mState->childIdx < length) {
     nsIContent* childNode = mState->childList->Item(mState->childIdx);
     mState->childIdx++;
 
     bool isSubtreeHidden = false;
-    Accessible* accessible = mWalkCache ? mDoc->GetAccessible(childNode) :
+    Accessible* accessible = mFlags & eWalkCache ?
+      mDoc->GetAccessible(childNode) :
       GetAccService()->GetOrCreateAccessible(childNode, mContext,
                                              &isSubtreeHidden);
 
     if (accessible)
       return accessible;
 
     // Walk down into subtree to find accessibles.
     if (!isSubtreeHidden) {
-      if (!PushState(childNode))
-        break;
-
+      PushState(childNode);
       accessible = NextChildInternal(true);
       if (accessible)
         return accessible;
     }
   }
 
   // No more children, get back to the parent.
+  nsIContent* anchorNode = mState->content;
   PopState();
+  if (aNoWalkUp)
+    return nullptr;
+
+  if (mState)
+    return NextChildInternal(false);
+
+  // If we traversed the whole subtree of the anchor node. Move to next node
+  // relative anchor node within the context subtree if possible.
+  if (mFlags != eWalkContextTree)
+    return nullptr;
+
+  while (anchorNode != mContext->GetNode()) {
+    nsINode* parentNode = anchorNode->GetFlattenedTreeParent();
+    if (!parentNode || !parentNode->IsElement())
+      return nullptr;
 
-  return aNoWalkUp ? nullptr : NextChildInternal(false);
+    PushState(parentNode->AsElement());
+    mState->childList = mState->content->GetChildren(mChildFilter);
+    length = 0;
+    if (mState->childList)
+      mState->childList->GetLength(&length);
+
+    while (mState->childIdx < length) {
+      nsIContent* childNode = mState->childList->Item(mState->childIdx);
+      mState->childIdx++;
+      if (childNode == anchorNode)
+        return NextChildInternal(false);
+    }
+    PopState();
+
+    anchorNode = parentNode->AsElement();
+  }
+
+  return nullptr;
 }
 
 void
 TreeWalker::PopState()
 {
   WalkState* prevToLastState = mState->prevState;
   delete mState;
   mState = prevToLastState;
 }
 
-bool
+void
 TreeWalker::PushState(nsIContent* aContent)
 {
   WalkState* nextToLastState = new WalkState(aContent);
-  if (!nextToLastState)
-    return false;
-
   nextToLastState->prevState = mState;
   mState = nextToLastState;
-
-  return true;
 }
--- a/accessible/src/base/TreeWalker.h
+++ b/accessible/src/base/TreeWalker.h
@@ -1,36 +1,52 @@
 /* -*- 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 mozilla_a11y_TreeWalker_h_
 #define mozilla_a11y_TreeWalker_h_
 
+#include "mozilla/Attributes.h"
 #include <stdint.h>
 
 class nsIContent;
 
 namespace mozilla {
 namespace a11y {
 
 class Accessible;
 class DocAccessible;
 
 struct WalkState;
 
 /**
  * This class is used to walk the DOM tree to create accessible tree.
  */
-class TreeWalker
+class TreeWalker MOZ_FINAL
 {
 public:
-  TreeWalker(Accessible* aContext, nsIContent* aNode, bool aWalkCache = false);
-  virtual ~TreeWalker();
+  enum {
+    // used to walk the existing tree of the given node
+    eWalkCache = 1,
+    // used to walk the context tree starting from given node
+    eWalkContextTree = 2 | eWalkCache
+  };
+
+  /**
+   * Constructor
+   *
+   * @param aContext [in] container accessible for the given node, used to
+   *                   define accessible context
+   * @param aNode    [in] the node the search will be prepared relative to
+   * @param aFlags   [in] flags (see enum above)
+   */
+  TreeWalker(Accessible* aContext, nsIContent* aNode, uint32_t aFlags = 0);
+  ~TreeWalker();
 
   /**
    * Return the next child accessible.
    *
    * @note Returned accessible is bound to the document, if the accessible is
    *       rejected during tree creation then the caller should be unbind it
    *       from the document.
    */
@@ -54,26 +70,26 @@ private:
   Accessible* NextChildInternal(bool aNoWalkUp);
 
   /**
    * Create new state for the given node and push it on top of stack.
    *
    * @note State stack is used to navigate up/down the DOM subtree during
    *        accessible children search.
    */
-  bool PushState(nsIContent *aNode);
+  void PushState(nsIContent* aNode);
 
   /**
    * Pop state from stack.
    */
   void PopState();
 
   DocAccessible* mDoc;
   Accessible* mContext;
   int32_t mChildFilter;
-  bool mWalkCache;
+  uint32_t mFlags;
   WalkState* mState;
 };
 
 } // namespace a11y
 } // namespace mozilla
 
 #endif // mozilla_a11y_TreeWalker_h_
--- a/accessible/src/generic/Accessible.cpp
+++ b/accessible/src/generic/Accessible.cpp
@@ -3055,50 +3055,16 @@ Accessible::GetSiblingAtOffset(int32_t a
 
   Accessible* child = mParent->GetChildAt(mIndexInParent + aOffset);
   if (aError && !child)
     *aError = NS_ERROR_UNEXPECTED;
 
   return child;
 }
 
-Accessible* 
-Accessible::GetFirstAvailableAccessible(nsINode *aStartNode) const
-{
-  Accessible* accessible = mDoc->GetAccessible(aStartNode);
-  if (accessible)
-    return accessible;
-
-  nsCOMPtr<nsIDocument> doc = aStartNode->OwnerDoc();
-
-  nsCOMPtr<nsINode> currentNode = aStartNode;
-  ErrorResult rv;
-  nsRefPtr<dom::TreeWalker> walker =
-    doc->CreateTreeWalker(*GetNode(),
-                          nsIDOMNodeFilter::SHOW_ELEMENT | nsIDOMNodeFilter::SHOW_TEXT,
-                          nullptr, rv);
-  NS_ENSURE_TRUE(walker, nullptr);
-
-  walker->SetCurrentNode(*currentNode, rv);
-  if (rv.Failed())
-    return nullptr;
-
-  while (true) {
-    currentNode = walker->NextNode(rv);
-    if (!currentNode || rv.Failed())
-      return nullptr;
-
-    Accessible* accessible = mDoc->GetAccessible(currentNode);
-    if (accessible)
-      return accessible;
-  }
-
-  return nullptr;
-}
-
 double
 Accessible::AttrNumericValue(nsIAtom* aAttr) const
 {
   if (!mRoleMapEntry || mRoleMapEntry->valueRule == eNoValue)
     return UnspecifiedNaN();
 
   nsAutoString attrValue;
   if (!mContent->GetAttr(kNameSpaceID_None, aAttr, attrValue))
--- a/accessible/src/generic/Accessible.h
+++ b/accessible/src/generic/Accessible.h
@@ -883,26 +883,16 @@ protected:
    * Return the name for XUL element.
    */
   static void XULElmName(DocAccessible* aDocument,
                          nsIContent* aElm, nsString& aName);
 
   // helper method to verify frames
   static nsresult GetFullKeyName(const nsAString& aModifierName, const nsAString& aKeyName, nsAString& aStringOut);
 
-  /**
-   * Return an accessible for the given DOM node, or if that node isn't
-   * accessible, return the accessible for the next DOM node which has one
-   * (based on forward depth first search).
-   *
-   * @param  aStartNode  [in] the DOM node to start from
-   * @return              the resulting accessible
-   */
-  Accessible* GetFirstAvailableAccessible(nsINode* aStartNode) const;
-
   //////////////////////////////////////////////////////////////////////////////
   // Action helpers
 
   /**
    * Prepares click action that will be invoked in timeout.
    *
    * @note  DoCommand() prepares an action in timeout because when action
    *  command opens a modal dialog/window, it won't return until the
--- a/accessible/src/generic/DocAccessible.cpp
+++ b/accessible/src/generic/DocAccessible.cpp
@@ -1778,17 +1778,17 @@ DocAccessible::UpdateTree(Accessible* aC
 #endif
 
   nsRefPtr<AccReorderEvent> reorderEvent = new AccReorderEvent(aContainer);
 
   if (child) {
     updateFlags |= UpdateTreeInternal(child, aIsInsert, reorderEvent);
   } else {
     if (aIsInsert) {
-      TreeWalker walker(aContainer, aChildNode, true);
+      TreeWalker walker(aContainer, aChildNode, TreeWalker::eWalkCache);
 
       while ((child = walker.NextChild()))
         updateFlags |= UpdateTreeInternal(child, aIsInsert, reorderEvent);
     } else {
       // aChildNode may not coorespond to a particular accessible, to handle
       // this we go through all the children of aContainer.  Then if a child
       // has aChildNode as an ancestor, or does not have the node for
       // aContainer as an ancestor remove that child of aContainer.  Note that
--- a/accessible/src/generic/HyperTextAccessible.cpp
+++ b/accessible/src/generic/HyperTextAccessible.cpp
@@ -297,17 +297,26 @@ HyperTextAccessible::DOMPointToOffset(ns
         findContent->NodeInfo()->Equals(nsGkAtoms::br) &&
         findContent->AttrValueIs(kNameSpaceID_None,
                                  nsGkAtoms::mozeditorbogusnode,
                                  nsGkAtoms::_true,
                                  eIgnoreCase)) {
       // This <br> is the hacky "bogus node" used when there is no text in a control
       return 0;
     }
-    descendant = GetFirstAvailableAccessible(findNode);
+
+    descendant = mDoc->GetAccessible(findNode);
+    if (!descendant && findNode->IsContent()) {
+      Accessible* container = mDoc->GetContainerAccessible(findNode);
+      if (container) {
+        TreeWalker walker(container, findNode->AsContent(),
+                          TreeWalker::eWalkContextTree);
+        descendant = walker.NextChild();
+      }
+    }
   }
 
   return TransformOffset(descendant, offset, aIsEndOffset);
 }
 
 int32_t
 HyperTextAccessible::TransformOffset(Accessible* aDescendant,
                                      int32_t aOffset, bool aIsEndOffset) const
--- a/accessible/tests/mochitest/text/test_hypertext.html
+++ b/accessible/tests/mochitest/text/test_hypertext.html
@@ -53,17 +53,17 @@
       testText(IDs, 0, 13, "hello " + kEmbedChar + " see " + kEmbedChar);
 
       ////////////////////////////////////////////////////////////////////////
       // getTextAtOffset line boundary
 
       testTextAtOffset(0, BOUNDARY_LINE_START, "line ", 0, 5,
                        "hypertext3", kOk, kOk, kOk);
 
-      // XXX: see bug 638684.
+      // XXX: see bug 634202.
       testTextAtOffset(0, BOUNDARY_LINE_START, "line ", 0, 5,
                        "hypertext4", kTodo, kOk, kTodo);
 
       //////////////////////////////////////////////////////////////////////////
       // list
       //////////////////////////////////////////////////////////////////////////
 
       IDs = [ "list" ];
--- a/accessible/tests/mochitest/textselection/test_general.html
+++ b/accessible/tests/mochitest/textselection/test_general.html
@@ -104,16 +104,54 @@
       }
 
       this.getID = function removeSelection_getID()
       {
         return "nsIAccessibleText::removeSelection test for " + aID;
       }
     }
 
+    function changeDOMSelection(aID, aNodeID1, aNodeOffset1,
+                                aNodeID2, aNodeOffset2,
+                                aStartOffset, aEndOffset)
+    {
+      this.hyperText = getAccessible(aID, [ nsIAccessibleText ]);
+
+      this.eventSeq = [
+        new invokerChecker(EVENT_TEXT_SELECTION_CHANGED, aID)
+      ];
+
+      this.invoke = function changeDOMSelection_invoke()
+      {
+        var sel = window.getSelection();
+        var range = document.createRange();
+        range.setStart(getNode(aNodeID1), aNodeOffset1);
+        range.setEnd(getNode(aNodeID2), aNodeOffset2);
+        sel.addRange(range);
+      }
+
+      this.finalCheck = function changeDOMSelection_finalCheck()
+      {
+        is(this.hyperText.selectionCount, 1,
+           "setSelectionBounds: Wrong selection count for " + aID);
+        var startOffset = {}, endOffset = {};
+        this.hyperText.getSelectionBounds(0, startOffset, endOffset);
+
+        is(startOffset.value, aStartOffset,
+           "setSelectionBounds: Wrong start offset for " + aID);
+        is(endOffset.value, aEndOffset,
+           "setSelectionBounds: Wrong end offset for " + aID);
+      }
+
+      this.getID = function changeDOMSelection_getID()
+      {
+        return "DOM selection change for " + aID;
+      }
+    }
+
     function onfocusEventSeq(aID)
     {
       var caretMovedChecker =
         new invokerChecker(EVENT_TEXT_CARET_MOVED, aID);
       var selChangedChecker =
         new invokerChecker(EVENT_TEXT_SELECTION_CHANGED, aID);
       selChangedChecker.unexpected = true;
 
@@ -136,16 +174,17 @@
       gQueue.push(new removeSelection("paragraph"));
 
       gQueue.push(new synthFocus("textbox", onfocusEventSeq("textbox")));
       gQueue.push(new changeSelection("textbox", 1, 3));
 
       gQueue.push(new synthFocus("textarea", onfocusEventSeq("textarea")));
       gQueue.push(new changeSelection("textarea", 1, 3));
 
+      gQueue.push(new changeDOMSelection("c1", "c1_span1", 0, "c1_span2", 0, 2, 2));
       gQueue.invoke(); // Will call SimpleTest.finish();
     }
 
     SimpleTest.waitForExplicitFinish();
     addA11yLoadEvent(doTests);
   </script>
 </head>
 
@@ -164,11 +203,12 @@
   <p id="display"></p>
   <div id="content" style="display: none"></div>
   <pre id="test">
   </pre>
 
   <p id="paragraph">hello</p>
   <input id="textbox" value="hello"/>
   <textarea id="textarea">hello</textarea>
+  <div id="c1">hi<span id="c1_span1"></span><span id="c1_span2"></span>hi</div>
 
 </body>
 </html>
--- a/extensions/spellcheck/hunspell/src/Makefile.in
+++ b/extensions/spellcheck/hunspell/src/Makefile.in
@@ -5,11 +5,8 @@
 include $(topsrcdir)/config/rules.mk
 
 ifdef MOZ_NATIVE_HUNSPELL
 # MOZ_HUNSPELL_CFLAGS is extracted through pkgconfig during configure,
 # even though the variable doesn't show up in configure.in.
 CXXFLAGS += $(MOZ_HUNSPELL_CFLAGS)
 endif
 
-LOCAL_INCLUDES += \
-	-I$(topsrcdir)/editor/libeditor/base \
-	$(NULL)
--- a/extensions/spellcheck/hunspell/src/moz.build
+++ b/extensions/spellcheck/hunspell/src/moz.build
@@ -28,8 +28,12 @@ if not CONFIG['MOZ_NATIVE_HUNSPELL']:
     DEFINES['HUNSPELL_STATIC'] = True
 
 FINAL_LIBRARY = 'spellchecker'
 
 LOCAL_INCLUDES += [
     '/extensions/spellcheck/src',
 ]
 
+LOCAL_INCLUDES += [
+    '/editor/libeditor/base',
+]
+
--- a/gfx/tests/gtest/TestAsyncPanZoomController.cpp
+++ b/gfx/tests/gtest/TestAsyncPanZoomController.cpp
@@ -19,16 +19,18 @@
 
 using namespace mozilla;
 using namespace mozilla::gfx;
 using namespace mozilla::layers;
 using ::testing::_;
 using ::testing::NiceMock;
 using ::testing::AtLeast;
 using ::testing::AtMost;
+using ::testing::MockFunction;
+using ::testing::InSequence;
 
 class Task;
 
 class MockContentController : public GeckoContentController {
 public:
   MOCK_METHOD1(RequestContentRepaint, void(const FrameMetrics&));
   MOCK_METHOD2(AcknowledgeScrollUpdate, void(const FrameMetrics::ViewID&, const uint32_t& aScrollGeneration));
   MOCK_METHOD3(HandleDoubleTap, void(const CSSIntPoint&, int32_t, const ScrollableLayerGuid&));
@@ -141,62 +143,72 @@ FrameMetrics TestFrameMetrics() {
   return fm;
 }
 
 /*
  * Dispatches mock touch events to the apzc and checks whether apzc properly
  * consumed them and triggered scrolling behavior.
  */
 static
-void ApzcPan(AsyncPanZoomController* apzc, TestAPZCTreeManager* aTreeManager, int& aTime, int aTouchStartY, int aTouchEndY, bool expectIgnoredPan = false) {
+void ApzcPan(AsyncPanZoomController* apzc, TestAPZCTreeManager* aTreeManager, int& aTime, int aTouchStartY, int aTouchEndY, bool expectIgnoredPan = false, bool hasTouchListeners = false) {
 
   const int TIME_BETWEEN_TOUCH_EVENT = 100;
   const int OVERCOME_TOUCH_TOLERANCE = 100;
   MultiTouchInput mti;
   nsEventStatus status;
 
   // Since we're passing inputs directly to the APZC instead of going through
   // the tree manager, we need to build the overscroll handoff chain explicitly
   // for panning to work correctly.
   aTreeManager->BuildOverscrollHandoffChain(apzc);
 
+  nsEventStatus touchStartStatus;
+  if (hasTouchListeners) {
+    // APZC shouldn't consume the start event now, instead queueing it up
+    // waiting for content's response.
+    touchStartStatus = nsEventStatus_eIgnore;
+  } else {
+    // APZC should go into the touching state and therefore consume the event.
+    touchStartStatus = nsEventStatus_eConsumeNoDefault;
+  }
+
   mti = MultiTouchInput(MultiTouchInput::MULTITOUCH_START, aTime, 0);
   aTime += TIME_BETWEEN_TOUCH_EVENT;
   // Make sure the move is large enough to not be handled as a tap
   mti.mTouches.AppendElement(SingleTouchData(0, ScreenIntPoint(10, aTouchStartY+OVERCOME_TOUCH_TOLERANCE), ScreenSize(0, 0), 0, 0));
-  status = apzc->HandleInputEvent(mti);
-  EXPECT_EQ(status, nsEventStatus_eConsumeNoDefault);
+  status = apzc->ReceiveInputEvent(mti);
+  EXPECT_EQ(status, touchStartStatus);
   // APZC should be in TOUCHING state
 
   nsEventStatus touchMoveStatus;
   if (expectIgnoredPan) {
     // APZC should ignore panning, be in TOUCHING state and therefore return eIgnore.
     // The same applies to all consequent touch move events.
     touchMoveStatus = nsEventStatus_eIgnore;
   } else {
     // APZC should go into the panning state and therefore consume the event.
     touchMoveStatus = nsEventStatus_eConsumeNoDefault;
   }
 
   mti = MultiTouchInput(MultiTouchInput::MULTITOUCH_MOVE, aTime, 0);
   aTime += TIME_BETWEEN_TOUCH_EVENT;
   mti.mTouches.AppendElement(SingleTouchData(0, ScreenIntPoint(10, aTouchStartY), ScreenSize(0, 0), 0, 0));
-  status = apzc->HandleInputEvent(mti);
+  status = apzc->ReceiveInputEvent(mti);
   EXPECT_EQ(status, touchMoveStatus);
 
   mti = MultiTouchInput(MultiTouchInput::MULTITOUCH_MOVE, aTime, 0);
   aTime += TIME_BETWEEN_TOUCH_EVENT;
   mti.mTouches.AppendElement(SingleTouchData(0, ScreenIntPoint(10, aTouchEndY), ScreenSize(0, 0), 0, 0));
-  status = apzc->HandleInputEvent(mti);
+  status = apzc->ReceiveInputEvent(mti);
   EXPECT_EQ(status, touchMoveStatus);
 
   mti = MultiTouchInput(MultiTouchInput::MULTITOUCH_END, aTime, 0);
   aTime += TIME_BETWEEN_TOUCH_EVENT;
   mti.mTouches.AppendElement(SingleTouchData(0, ScreenIntPoint(10, aTouchEndY), ScreenSize(0, 0), 0, 0));
-  status = apzc->HandleInputEvent(mti);
+  status = apzc->ReceiveInputEvent(mti);
 }
 
 static
 void DoPanTest(bool aShouldTriggerScroll, bool aShouldUseTouchAction, uint32_t aBehavior)
 {
   TimeStamp testStartTime = TimeStamp::Now();
   AsyncPanZoomController::SetFrameTime(testStartTime);
 
@@ -553,16 +565,54 @@ TEST(AsyncPanZoomController, PanWithTouc
 TEST(AsyncPanZoomController, PanWithTouchActionPanX) {
   DoPanTest(false, true, mozilla::layers::AllowedTouchBehavior::HORIZONTAL_PAN);
 }
 
 TEST(AsyncPanZoomController, PanWithTouchActionPanY) {
   DoPanTest(true, true, mozilla::layers::AllowedTouchBehavior::VERTICAL_PAN);
 }
 
+TEST(AsyncPanZoomController, PanWithPreventDefault) {
+  TimeStamp testStartTime = TimeStamp::Now();
+  AsyncPanZoomController::SetFrameTime(testStartTime);
+
+  nsRefPtr<MockContentController> mcc = new NiceMock<MockContentController>();
+  nsRefPtr<TestAPZCTreeManager> tm = new TestAPZCTreeManager();
+  nsRefPtr<TestAsyncPanZoomController> apzc = new TestAsyncPanZoomController(0, mcc, tm);
+
+  FrameMetrics frameMetrics(TestFrameMetrics());
+  frameMetrics.mMayHaveTouchListeners = true;
+
+  apzc->SetFrameMetrics(frameMetrics);
+  apzc->NotifyLayersUpdated(frameMetrics, true);
+
+  int time = 0;
+  int touchStart = 50;
+  int touchEnd = 10;
+  ScreenPoint pointOut;
+  ViewTransform viewTransformOut;
+
+  // Pan down
+  nsTArray<uint32_t> values;
+  values.AppendElement(mozilla::layers::AllowedTouchBehavior::VERTICAL_PAN);
+  apzc->SetTouchActionEnabled(true);
+  apzc->SetAllowedTouchBehavior(values);
+  ApzcPan(apzc, tm, time, touchStart, touchEnd, true, true);
+
+  // Send the signal that content has handled and preventDefaulted the touch
+  // events. This flushes the event queue.
+  apzc->ContentReceivedTouch(true);
+
+  apzc->SampleContentTransformForFrame(testStartTime, &viewTransformOut, pointOut);
+  EXPECT_EQ(pointOut, ScreenPoint());
+  EXPECT_EQ(viewTransformOut, ViewTransform());
+
+  apzc->Destroy();
+}
+
 TEST(AsyncPanZoomController, Fling) {
   TimeStamp testStartTime = TimeStamp::Now();
   AsyncPanZoomController::SetFrameTime(testStartTime);
 
   nsRefPtr<MockContentController> mcc = new NiceMock<MockContentController>();
   nsRefPtr<TestAPZCTreeManager> tm = new TestAPZCTreeManager();
   nsRefPtr<TestAsyncPanZoomController> apzc = new TestAsyncPanZoomController(0, mcc, tm);
 
@@ -673,33 +723,123 @@ TEST(AsyncPanZoomController, LongPress) 
   apzc->NotifyLayersUpdated(TestFrameMetrics(), true);
   apzc->UpdateZoomConstraints(ZoomConstraints(false, CSSToScreenScale(1.0), CSSToScreenScale(1.0)));
 
   int time = 0;
 
   nsEventStatus status = ApzcDown(apzc, 10, 10, time);
   EXPECT_EQ(nsEventStatus_eConsumeNoDefault, status);
 
+  MockFunction<void(std::string checkPointName)> check;
+
+  {
+    InSequence s;
+
+    EXPECT_CALL(check, Call("preHandleLongTap"));
+    EXPECT_CALL(*mcc, HandleLongTap(CSSIntPoint(10, 10), 0, apzc->GetGuid())).Times(1);
+    EXPECT_CALL(check, Call("postHandleLongTap"));
+
+    EXPECT_CALL(check, Call("preHandleLongTapUp"));
+    EXPECT_CALL(*mcc, HandleLongTapUp(CSSIntPoint(10, 10), 0, apzc->GetGuid())).Times(1);
+    EXPECT_CALL(check, Call("postHandleLongTapUp"));
+  }
+
   mcc->CheckHasDelayedTask();
-  EXPECT_CALL(*mcc, HandleLongTap(CSSIntPoint(10, 10), 0, apzc->GetGuid())).Times(1);
 
   // Manually invoke the longpress while the touch is currently down.
+  check.Call("preHandleLongTap");
   mcc->RunDelayedTask();
+  check.Call("postHandleLongTap");
 
   time += 1000;
 
   status = ApzcUp(apzc, 10, 10, time);
   EXPECT_EQ(nsEventStatus_eIgnore, status);
 
-  EXPECT_CALL(*mcc, HandleLongTapUp(CSSIntPoint(10, 10), 0, apzc->GetGuid())).Times(1);
-
   // To get a LongTapUp event, we must kick APZC to flush its event queue. This
   // would normally happen if we had a (Tab|RenderFrame)(Parent|Child)
   // mechanism.
+  check.Call("preHandleLongTapUp");
   apzc->ContentReceivedTouch(false);
+  check.Call("postHandleLongTapUp");
+
+  apzc->Destroy();
+}
+
+TEST(AsyncPanZoomController, LongPressPreventDefault) {
+  // We have to initialize both an integer time and TimeStamp time because
+  // TimeStamp doesn't have any ToXXX() functions for converting back to
+  // primitives.
+  TimeStamp testStartTime = TimeStamp::Now();
+  int time = 0;
+  AsyncPanZoomController::SetFrameTime(testStartTime);
+
+  nsRefPtr<MockContentControllerDelayed> mcc = new MockContentControllerDelayed();
+  nsRefPtr<TestAPZCTreeManager> tm = new TestAPZCTreeManager();
+  nsRefPtr<TestAsyncPanZoomController> apzc = new TestAsyncPanZoomController(
+    0, mcc, tm, AsyncPanZoomController::USE_GESTURE_DETECTOR);
+
+  apzc->SetFrameMetrics(TestFrameMetrics());
+  apzc->NotifyLayersUpdated(TestFrameMetrics(), true);
+  apzc->UpdateZoomConstraints(ZoomConstraints(false, CSSToScreenScale(1.0), CSSToScreenScale(1.0)));
+
+  EXPECT_CALL(*mcc, SendAsyncScrollDOMEvent(_,_,_)).Times(0);
+  EXPECT_CALL(*mcc, RequestContentRepaint(_)).Times(0);
+
+  int touchX = 10,
+      touchStartY = 10,
+      touchEndY = 50;
+
+  nsEventStatus status = ApzcDown(apzc, touchX, touchStartY, time);
+  EXPECT_EQ(nsEventStatus_eConsumeNoDefault, status);
+
+  MockFunction<void(std::string checkPointName)> check;
+
+  {
+    InSequence s;
+
+    EXPECT_CALL(check, Call("preHandleLongTap"));
+    EXPECT_CALL(*mcc, HandleLongTap(CSSIntPoint(touchX, touchStartY), 0, apzc->GetGuid())).Times(1);
+    EXPECT_CALL(check, Call("postHandleLongTap"));
+  }
+
+  mcc->CheckHasDelayedTask();
+
+  // Manually invoke the longpress while the touch is currently down.
+  check.Call("preHandleLongTap");
+  mcc->RunDelayedTask();
+  check.Call("postHandleLongTap");
+
+  // Clear the waiting-for-content timeout task, then send the signal that
+  // content has handled this long tap. This takes the place of the
+  // "contextmenu" event.
+  mcc->ClearDelayedTask();
+  apzc->ContentReceivedTouch(true);
+
+  time += 1000;
+
+  MultiTouchInput mti = MultiTouchInput(MultiTouchInput::MULTITOUCH_MOVE, time, 0);
+  mti.mTouches.AppendElement(SingleTouchData(0, ScreenIntPoint(touchX, touchEndY), ScreenSize(0, 0), 0, 0));
+  status = apzc->ReceiveInputEvent(mti);
+  EXPECT_EQ(status, nsEventStatus_eIgnore);
+
+  status = ApzcUp(apzc, touchX, touchEndY, time);
+  EXPECT_EQ(nsEventStatus_eIgnore, status);
+
+  // Flush the event queue. Once the "contextmenu" event is handled, any touch
+  // events that come from the same series of start->n*move->end events should
+  // be discarded, even if only the "contextmenu" event is preventDefaulted.
+  apzc->ContentReceivedTouch(false);
+
+  ScreenPoint pointOut;
+  ViewTransform viewTransformOut;
+  apzc->SampleContentTransformForFrame(testStartTime, &viewTransformOut, pointOut);
+
+  EXPECT_EQ(pointOut, ScreenPoint());
+  EXPECT_EQ(viewTransformOut, ViewTransform());
 
   apzc->Destroy();
 }
 
 // Layer tree for HitTesting1
 static already_AddRefed<mozilla::layers::Layer>
 CreateTestLayerTree1(nsRefPtr<LayerManager>& aLayerManager, nsTArray<nsRefPtr<Layer> >& aLayers) {
   const char* layerTreeSyntax = "c(ttcc)";
--- a/ipc/ipdl/test/cxx/app/Makefile.in
+++ b/ipc/ipdl/test/cxx/app/Makefile.in
@@ -1,17 +1,14 @@
 # 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/.
 
 NSDISTMODE = copy
 
-LOCAL_INCLUDES += -I$(topsrcdir)/toolkit/xre
-LOCAL_INCLUDES += -I$(topsrcdir)/xpcom/base
-
 LIBS = \
   $(DIST)/lib/$(LIB_PREFIX)xpcomglue_s.$(LIB_SUFFIX) \
   $(LIBXUL_LIBS) \
   $(NSPR_LIBS) \
   $(NULL)
 
 include $(topsrcdir)/config/config.mk
 
--- a/ipc/ipdl/test/cxx/app/moz.build
+++ b/ipc/ipdl/test/cxx/app/moz.build
@@ -6,8 +6,13 @@
 
 PROGRAM = 'ipdlunittest'
 
 SOURCES += [
     'TestIPDL.cpp',
 ]
 include('/ipc/chromium/chromium-config.mozbuild')
 
+LOCAL_INCLUDES += [
+    '/toolkit/xre',
+    '/xpcom/base',
+]
+
deleted file mode 100644
--- a/ipc/testshell/Makefile.in
+++ /dev/null
@@ -1,11 +0,0 @@
-# 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/.
-
-# For xpcshell error messages and nsDependentJSString
-LOCAL_INCLUDES += \
-  -I$(topsrcdir)/js/xpconnect/src \
-  -I$(topsrcdir)/dom/base \
-  $(NULL)
-
-include $(topsrcdir)/config/rules.mk
--- a/ipc/testshell/moz.build
+++ b/ipc/testshell/moz.build
@@ -25,8 +25,15 @@ IPDL_SOURCES = [
     'PTestShellCommand.ipdl',
 ]
 
 FAIL_ON_WARNINGS = True
 
 include('/ipc/chromium/chromium-config.mozbuild')
 
 FINAL_LIBRARY = 'xul'
+
+# For xpcshell error messages and nsDependentJSString
+LOCAL_INCLUDES += [
+    '/dom/base',
+    '/js/xpconnect/src',
+]
+
--- a/js/src/builtin/TestingFunctions.cpp
+++ b/js/src/builtin/TestingFunctions.cpp
@@ -306,17 +306,20 @@ GCParameter(JSContext *cx, unsigned argc
 
     if (param == JSGC_NUMBER || param == JSGC_BYTES) {
         JS_ReportError(cx, "Attempt to change read-only parameter %s",
                        paramMap[paramIndex].name);
         return false;
     }
 
     uint32_t value;
-    if (!ToUint32(cx, args[1], &value)) {
+    if (!ToUint32(cx, args[1], &value))
+        return false;
+
+    if (!value) {
         JS_ReportError(cx, "the second argument must be convertable to uint32_t "
                            "with non-zero value");
         return false;
     }
 
     if (param == JSGC_MAX_BYTES) {
         uint32_t gcBytes = JS_GetGCParameter(cx->runtime(), JSGC_BYTES);
         if (value < gcBytes) {
--- a/layout/base/nsCSSFrameConstructor.cpp
+++ b/layout/base/nsCSSFrameConstructor.cpp
@@ -2410,16 +2410,22 @@ nsCSSFrameConstructor::ConstructDocEleme
                                nullptr, extraRef.forget(), true, nullptr);
 
     nsFrameItems frameItems;
     contentFrame = ConstructOuterSVG(state, item, mDocElementContainingBlock,
                                      styleContext->StyleDisplay(),
                                      frameItems);
     newFrame = frameItems.FirstChild();
     NS_ASSERTION(frameItems.OnlyChild(), "multiple root element frames");
+  } else if (display->mDisplay == NS_STYLE_DISPLAY_FLEX) {
+    contentFrame = NS_NewFlexContainerFrame(mPresShell, styleContext);
+    InitAndRestoreFrame(state, aDocElement, mDocElementContainingBlock,
+                        contentFrame);
+    newFrame = contentFrame;
+    processChildren = true;
   } else if (display->mDisplay == NS_STYLE_DISPLAY_TABLE) {
     // We're going to call the right function ourselves, so no need to give a
     // function to this FrameConstructionData.
 
     // XXXbz on the other hand, if we converted this whole function to
     // FrameConstructionData/Item, then we'd need the right function
     // here... but would probably be able to get away with less code in this
     // function in general.
@@ -2433,16 +2439,18 @@ nsCSSFrameConstructor::ConstructDocEleme
     nsFrameItems frameItems;
     // if the document is a table then just populate it.
     contentFrame = ConstructTable(state, item, mDocElementContainingBlock,
                                   styleContext->StyleDisplay(),
                                   frameItems);
     newFrame = frameItems.FirstChild();
     NS_ASSERTION(frameItems.OnlyChild(), "multiple root element frames");
   } else {
+    MOZ_ASSERT(display->mDisplay == NS_STYLE_DISPLAY_BLOCK,
+               "Unhandled display type for root element");
     contentFrame = NS_NewBlockFormattingContext(mPresShell, styleContext);
     nsFrameItems frameItems;
     // Use a null PendingBinding, since our binding is not in fact pending.
     ConstructBlock(state, display, aDocElement,
                    state.GetGeometricParent(display,
                                             mDocElementContainingBlock),
                    mDocElementContainingBlock, styleContext,
                    &contentFrame, frameItems,
new file mode 100644
--- /dev/null
+++ b/layout/reftests/flexbox/flexbox-styling-on-svg-1-ref.svg
@@ -0,0 +1,10 @@
+<!--
+     Any copyright is dedicated to the Public Domain.
+     http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<svg xmlns="http://www.w3.org/2000/svg"
+     width="100%" height="100%">
+
+  <rect width="100%" height="100%" fill="lime"/>
+
+</svg>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/flexbox/flexbox-styling-on-svg-1.svg
@@ -0,0 +1,15 @@
+<!--
+     Any copyright is dedicated to the Public Domain.
+     http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<svg xmlns="http://www.w3.org/2000/svg"
+     style="display:flex"
+     width="100%" height="100%">
+
+  <title>Test that we ignore "display:flex" on a root SVG node</title>
+
+  <!-- From https://bugzilla.mozilla.org/show_bug.cgi?id=969460 -->
+
+  <rect width="100%" height="100%" fill="lime"/>
+
+</svg>
--- a/layout/reftests/flexbox/reftest.list
+++ b/layout/reftests/flexbox/reftest.list
@@ -128,13 +128,16 @@ fails == flexbox-inlinecontent-horiz-1b.
 == flexbox-intrinsic-sizing-horiz-2b.xhtml flexbox-intrinsic-sizing-horiz-2-ref.xhtml
 
 # Tests for invalidation after dynamic modifications
 == flexbox-invalidation-1.html flexbox-invalidation-1-ref.html
 
 # Tests for flexbox in an iframe that gets resized.
 skip-if(B2G) == flexbox-resizeviewport-1.xhtml flexbox-resizeviewport-1-ref.xhtml
 
+# Tests for flexbox styling on things that don't support it
+== flexbox-styling-on-svg-1.svg flexbox-styling-on-svg-1-ref.svg
+
 # Tests with widgets as flex items
 fuzzy-if(gtk2Widget,1,66) == flexbox-widget-flex-items-1.html flexbox-widget-flex-items-1-ref.html
 fuzzy-if(gtk2Widget,1,74) == flexbox-widget-flex-items-2.html flexbox-widget-flex-items-2-ref.html
 fuzzy-if(gtk2Widget,1,58) == flexbox-widget-flex-items-3.html flexbox-widget-flex-items-3-ref.html
 fuzzy-if(gtk2Widget,1,31) == flexbox-widget-flex-items-4.html flexbox-widget-flex-items-4-ref.html
--- a/layout/reftests/svg/smil/anim-path-d-01-ref.svg
+++ b/layout/reftests/svg/smil/anim-path-d-01-ref.svg
@@ -1,11 +1,12 @@
 <svg xmlns="http://www.w3.org/2000/svg">
   <style type="text/css">
-    path { fill: none; stroke: blue; stroke-width: 1px; }
+    path { fill: none; stroke: blue; stroke-width: 1px;
+           shape-rendering: crispEdges; }
   </style>
 
   <path d="M10,10
            L26,10
            l-16,32
            H26
            V10
            h16
--- a/layout/reftests/svg/smil/anim-path-d-01.svg
+++ b/layout/reftests/svg/smil/anim-path-d-01.svg
@@ -3,17 +3,18 @@
 -->
 <svg xmlns="http://www.w3.org/2000/svg"
      xmlns:xlink="http://www.w3.org/1999/xlink"
      class="reftest-wait"
      onload="setTimeAndSnapshot(1, true)">
   <title>Test animation of the 'd' attribute on the 'path' element</title>
   <script xlink:href="smil-util.js" type="text/javascript"/>
   <style type="text/css">
-    path { fill: none; stroke: blue; stroke-width: 1px; }
+    path { fill: none; stroke: blue; stroke-width: 1px;
+           shape-rendering: crispEdges; }
   </style>
 
 
   <!-- The difference between respective numbers in the effective 'from' and
        'to' path data below is carefully designed to be a factor of 3. That way
        our reference file (which checks against a one third complete animation)
        can contain whole numbers, which is necessary to avoid failure due to
        hard coded rounded numbers in the reference not matching platform
--- a/layout/reftests/svg/smil/reftest.list
+++ b/layout/reftests/svg/smil/reftest.list
@@ -122,17 +122,17 @@ skip-if(B2G) random-if(/^Windows\x20NT\x
 skip-if(B2G) == anim-marker-orient-01.svg lime.svg # bug 773482
 skip-if(B2G) == anim-marker-orient-02.svg lime.svg # bug 773482
 
 #animate points list:
 skip-if(B2G) == anim-polygon-points-01.svg anim-polygon-points-01-ref.svg
 == anim-polyline-points-01.svg anim-polyline-points-01-ref.svg
 
 # animate path data:
-skip-if(B2G) fuzzy-if(/^Windows\x20NT\x205\.1/.test(http.oscpu),2,1) fuzzy-if(cocoaWidget&&layersGPUAccelerated,1,13) == anim-path-d-01.svg anim-path-d-01-ref.svg # Bug 726400 # bug 773482
+== anim-path-d-01.svg anim-path-d-01-ref.svg
 
 # animate some enumeration attributes:
 skip-if(B2G) == anim-feComposite-operator-01.svg lime.svg
 == anim-filter-filterUnits-01.svg lime.svg
 
 # animate some boolean attributes:
 skip-if(B2G) == anim-feConvolveMatrix-preserveAlpha-01.svg lime.svg # bug 773482
 
new file mode 100644
--- /dev/null
+++ b/layout/reftests/w3c-css/submitted/flexbox/flexbox-root-node-1-ref.html
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<!--
+     Any copyright is dedicated to the Public Domain.
+     http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<html style="display: flex; justify-content: center">
+<head>
+ <title>CSS Reftest Reference</title>
+ <link rel="author" title="Daniel Holbert" href="mailto:dholbert@mozilla.com">
+  <style>
+    div {
+      display: flex;
+      justify-content: center;
+    }
+  </style>
+</head>
+<body>
+  <div>centered</div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/w3c-css/submitted/flexbox/flexbox-root-node-1a.html
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<!--
+     Any copyright is dedicated to the Public Domain.
+     http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<!-- This testcase checks that we correctly handle 'display:flex' property on
+     the root <html> element, with the <body> as the sole flex item. -->
+<html style="display: flex; justify-content: center">
+<head>
+  <title>CSS Test: Testing 'display:flex' on root node</title>
+  <link rel="author" title="Daniel Holbert" href="mailto:dholbert@mozilla.com">
+  <link rel="help" href="http://www.w3.org/TR/css3-flexbox/#flex-containers">
+  <link rel="match" href="flexbox-root-node-1-ref.html">
+  <style>
+    html {
+      display: flex;
+      justify-content: center;
+    }
+  </style>
+</head>
+<body>
+  centered
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/w3c-css/submitted/flexbox/flexbox-root-node-1b.html
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<!--
+     Any copyright is dedicated to the Public Domain.
+     http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<!-- This testcase checks that we correctly handle 'display:flex' property on
+     the root <html> element, with no explicit <body>. -->
+<html style="display: flex; justify-content: center">
+<head>
+  <title>CSS Test: Testing 'display:flex' on root node</title>
+  <link rel="author" title="Daniel Holbert" href="mailto:dholbert@mozilla.com">
+  <link rel="help" href="http://www.w3.org/TR/css3-flexbox/#flex-containers">
+  <link rel="match" href="flexbox-root-node-1-ref.html">
+  <style>
+    html {
+      display: flex;
+      justify-content: center;
+    }
+  </style>
+</head>
+centered
+</html>
--- a/layout/reftests/w3c-css/submitted/flexbox/reftest.list
+++ b/layout/reftests/w3c-css/submitted/flexbox/reftest.list
@@ -135,16 +135,20 @@ fuzzy-if(Android,158,32) == flexbox-alig
 == flexbox-overflow-vert-3.html flexbox-overflow-vert-3-ref.html
 == flexbox-overflow-vert-4.html flexbox-overflow-vert-4-ref.html
 == flexbox-overflow-vert-5.html flexbox-overflow-vert-5-ref.html
 
 # Tests for the order in which we paint flex items
 == flexbox-paint-ordering-1.xhtml flexbox-paint-ordering-1-ref.xhtml
 == flexbox-paint-ordering-2.xhtml flexbox-paint-ordering-2-ref.xhtml
 
+# Tests for "display:flex" on root node
+== flexbox-root-node-1a.html flexbox-root-node-1-ref.html
+== flexbox-root-node-1b.html flexbox-root-node-1-ref.html
+
 # Tests for sizing of flex containers, e.g. under min/max size constraints
 == flexbox-sizing-horiz-1.xhtml flexbox-sizing-horiz-1-ref.xhtml
 == flexbox-sizing-horiz-2.xhtml flexbox-sizing-horiz-2-ref.xhtml
 == flexbox-sizing-vert-1.xhtml  flexbox-sizing-vert-1-ref.xhtml
 == flexbox-sizing-vert-2.xhtml  flexbox-sizing-vert-2-ref.xhtml
 
 # Tests for table-fixup on flex items
 == flexbox-table-fixup-1a.xhtml flexbox-table-fixup-1-ref.xhtml
--- a/layout/style/nsCSSValue.cpp
+++ b/layout/style/nsCSSValue.cpp
@@ -1256,17 +1256,18 @@ nsCSSValue::AppendToString(nsCSSProperty
       }
       aResult.AppendLiteral(", ");
     }
 
     aResult.AppendLiteral(")");
   } else if (eCSSUnit_TokenStream == unit) {
     nsCSSProperty shorthand = mValue.mTokenStream->mShorthandPropertyID;
     if (shorthand == eCSSProperty_UNKNOWN ||
-        nsCSSProps::PropHasFlags(shorthand, CSS_PROPERTY_IS_ALIAS)) {
+        nsCSSProps::PropHasFlags(shorthand, CSS_PROPERTY_IS_ALIAS) ||
+        aProperty == eCSSProperty__x_system_font) {
       // We treat serialization of aliases like '-moz-transform' as a special
       // case, since it really wants to be serialized as if it were a longhand
       // even though it is implemented as a shorthand.
       aResult.Append(mValue.mTokenStream->mTokenStream);
     }
   } else if (eCSSUnit_Pair == unit) {
     if (eCSSProperty_font_variant_alternates == aProperty) {
       int32_t intValue = GetPairValue().mXValue.GetIntValue();
--- a/layout/style/nsRuleNode.cpp
+++ b/layout/style/nsRuleNode.cpp
@@ -122,27 +122,39 @@ nsRuleNode::ChildrenHashOps = {
   nullptr
 };
 
 
 // EnsureBlockDisplay:
 //  - if the display value (argument) is not a block-type
 //    then we set it to a valid block display value
 //  - For enforcing the floated/positioned element CSS2 rules
+//  - We allow the behavior of "list-item" to be customized.
+//    CSS21 says that position/float do not convert 'list-item' to 'block',
+//    but it explicitly does not define whether 'list-item' should be
+//    converted to block *on the root node*. To allow for flexibility
+//    (so that we don't have to support a list-item root node), this method
+//    lets the caller pick either behavior, using the 'aConvertListItem' arg.
+//    Reference: http://www.w3.org/TR/CSS21/visuren.html#dis-pos-flo
 /* static */
 void
-nsRuleNode::EnsureBlockDisplay(uint8_t& display)
+nsRuleNode::EnsureBlockDisplay(uint8_t& display,
+                               bool aConvertListItem /* = false */)
 {
   // see if the display value is already a block
   switch (display) {
+  case NS_STYLE_DISPLAY_LIST_ITEM :
+    if (aConvertListItem) {
+      display = NS_STYLE_DISPLAY_BLOCK;
+      break;
+    } // else, fall through to share the 'break' for non-changing display vals
   case NS_STYLE_DISPLAY_NONE :
     // never change display:none *ever*
   case NS_STYLE_DISPLAY_TABLE :
   case NS_STYLE_DISPLAY_BLOCK :
-  case NS_STYLE_DISPLAY_LIST_ITEM :
   case NS_STYLE_DISPLAY_FLEX :
     // do not muck with these at all - already blocks
     // This is equivalent to nsStyleDisplay::IsBlockOutside.  (XXX Maybe we
     // should just call that?)
     // This needs to match the check done in
     // nsCSSFrameConstructor::FindMathMLData for <math>.
     break;
 
--- a/layout/style/nsRuleNode.h
+++ b/layout/style/nsRuleNode.h
@@ -659,17 +659,19 @@ protected:
 
 private:
   nsRuleNode(nsPresContext* aPresContext, nsRuleNode* aParent,
              nsIStyleRule* aRule, uint8_t aLevel, bool aIsImportant);
   ~nsRuleNode();
 
 public:
   static nsRuleNode* CreateRootNode(nsPresContext* aPresContext);
-  static void EnsureBlockDisplay(uint8_t& display);
+
+  static void EnsureBlockDisplay(uint8_t& display,
+                                 bool aConvertListItem = false);
 
   // Transition never returns null; on out of memory it'll just return |this|.
   nsRuleNode* Transition(nsIStyleRule* aRule, uint8_t aLevel,
                          bool aIsImportantRule);
   nsRuleNode* GetParent() const { return mParent; }
   bool IsRoot() const { return mParent == nullptr; }
 
   // These uint8_ts are really nsStyleSet::sheetType values.
--- a/layout/style/nsStyleContext.cpp
+++ b/layout/style/nsStyleContext.cpp
@@ -333,32 +333,29 @@ nsStyleContext::ApplyStyleFixups(bool aS
   // CSS2.1 section 9.2.4 specifies fixups for the 'display' property of
   // the root element.  We can't implement them in nsRuleNode because we
   // don't want to store all display structs that aren't 'block',
   // 'inline', or 'table' in the style context tree on the off chance
   // that the root element has its style reresolved later.  So do them
   // here if needed, by changing the style data, so that other code
   // doesn't get confused by looking at the style data.
   if (!mParent) {
-    if (disp->mDisplay != NS_STYLE_DISPLAY_NONE &&
-        disp->mDisplay != NS_STYLE_DISPLAY_BLOCK &&
-        disp->mDisplay != NS_STYLE_DISPLAY_TABLE) {
-      nsStyleDisplay *mutable_display = static_cast<nsStyleDisplay*>
-                                                   (GetUniqueStyleData(eStyleStruct_Display));
+    uint8_t displayVal = disp->mDisplay;
+    nsRuleNode::EnsureBlockDisplay(displayVal, true);
+    if (displayVal != disp->mDisplay) {
+      nsStyleDisplay *mutable_display =
+        static_cast<nsStyleDisplay*>(GetUniqueStyleData(eStyleStruct_Display));
+
       // If we're in this code, then mOriginalDisplay doesn't matter
       // for purposes of the cascade (because this nsStyleDisplay
       // isn't living in the ruletree anyway), and for determining
       // hypothetical boxes it's better to have mOriginalDisplay
       // matching mDisplay here.
-      if (mutable_display->mDisplay == NS_STYLE_DISPLAY_INLINE_TABLE)
-        mutable_display->mOriginalDisplay = mutable_display->mDisplay =
-          NS_STYLE_DISPLAY_TABLE;
-      else
-        mutable_display->mOriginalDisplay = mutable_display->mDisplay =
-          NS_STYLE_DISPLAY_BLOCK;
+      mutable_display->mOriginalDisplay = mutable_display->mDisplay =
+        displayVal;
     }
   }
 
   // Adjust the "display" values of flex items (but not for raw text,
   // placeholders, or table-parts). CSS3 Flexbox section 4 says:
   //   # The computed 'display' of a flex item is determined
   //   # by applying the table in CSS 2.1 Chapter 9.7.
   // ...which converts inline-level elements to their block-level equivalents.
--- a/layout/style/test/mochitest.ini
+++ b/layout/style/test/mochitest.ini
@@ -156,16 +156,17 @@ skip-if = toolkit == 'android'
 support-files = file_position_sticky.html
 [test_priority_preservation.html]
 [test_property_syntax_errors.html]
 [test_pseudoelement_state.html]
 [test_pseudoelement_parsing.html]
 [test_redundant_font_download.html]
 support-files = redundant_font_download.sjs
 [test_rem_unit.html]
+[test_root_node_display.html]
 [test_rule_insertion.html]
 [test_rule_serialization.html]
 [test_rules_out_of_sheets.html]
 [test_selectors.html]
 skip-if = toolkit == 'android' #bug 775227
 [test_selectors_on_anonymous_content.html]
 [test_shorthand_property_getters.html]
 [test_specified_value_serialization.html]
new file mode 100644
--- /dev/null
+++ b/layout/style/test/test_root_node_display.html
@@ -0,0 +1,62 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=969460
+-->
+<head>
+  <meta charset="utf-8">
+  <title>Test for Bug 969460</title>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="text/javascript" src="property_database.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=969460">Mozilla Bug 969460</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+  <div id="float" style="float: left"></div>
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 969460: Test that "display" on the root node is computed
+    using the same conversion that we use for display on floated elements **/
+
+function test_display_value(val)
+{
+  var floatElem = document.getElementById("float");
+  floatElem.style.display = val;
+  var floatConversion = window.getComputedStyle(floatElem, null).display;
+  floatElem.style.display = "";
+
+  var rootNode = document.documentElement;
+  rootNode.style.display = val;
+  rootNode.offsetHeight; // (Flush layout, to be sure layout can handle 'val')
+  var rootConversion = window.getComputedStyle(rootNode, null).display;
+  rootNode.style.display = "";
+
+  // Special case: "display:list-item" does not get modified by 'float',
+  // but the spec allows us to convert it to 'block' on the root node
+  // (and we do convert it, so that we don't have to support documents whose
+  // root node is a list-item).
+  if (val == "list-item") {
+    is(floatConversion, val, "'float' shouldn't affect 'display:list-item'");
+    is(rootConversion, "block",
+       "We traditionally convert 'display:list-item' on the root node to " +
+       "'display:block' (though if that changes, it's not technically a bug, " +
+       "as long as we support it properly).");
+  } else {
+    is(rootConversion, floatConversion,
+       "root node should make 'display:" + val + "' compute to the same " +
+       "value that it computes to on a floated element");
+  }
+}
+
+var displayInfo = gCSSProperties["display"];
+displayInfo.initial_values.forEach(test_display_value);
+displayInfo.other_values.forEach(test_display_value);
+
+</script>
+</pre>
+</body>
+</html>
--- a/media/mtransport/test/Makefile.in
+++ b/media/mtransport/test/Makefile.in
@@ -12,42 +12,16 @@ LIBS = \
   $(DEPTH)/media/mtransport/third_party/nrappkit/nrappkit_nrappkit/$(LIB_PREFIX)nrappkit.$(LIB_SUFFIX) \
   $(DEPTH)/media/webrtc/trunk/testing/gtest_gtest/$(LIB_PREFIX)gtest.$(LIB_SUFFIX) \
   $(NULL)
 
 ifdef MOZ_SCTP
 LIBS += $(DEPTH)/netwerk/sctp/src/$(LIB_PREFIX)nksctp_s.$(LIB_SUFFIX)
 endif
 
-LOCAL_INCLUDES += \
-  -I. \
-  -I$(topsrcdir)/media/webrtc/trunk/testing/gtest/include/ \
-  -I$(topsrcdir)/media/mtransport/ \
-  -I$(topsrcdir)/netwerk/sctp/src/ \
- $(NULL)
-
-LOCAL_INCLUDES += \
- -I. \
- -I$(topsrcdir)/media/mtransport/third_party/ \
- -I$(topsrcdir)/media/mtransport/third_party/ \
- -I$(topsrcdir)/media/mtransport/third_party/nICEr/src/crypto \
- -I$(topsrcdir)/media/mtransport/third_party/nICEr/src/ice \
- -I$(topsrcdir)/media/mtransport/third_party/nICEr/src/net \
- -I$(topsrcdir)/media/mtransport/third_party/nICEr/src/stun \
- -I$(topsrcdir)/media/mtransport/third_party/nICEr/src/util \
- -I$(topsrcdir)/media/mtransport/third_party/nrappkit/src/share \
- -I$(topsrcdir)/media/mtransport/third_party/nrappkit/src/util/ \
- -I$(topsrcdir)/media/mtransport/third_party/nrappkit/src/util/libekr \
- -I$(topsrcdir)/media/mtransport/third_party/nrappkit/src/log \
- -I$(topsrcdir)/media/mtransport/third_party/nrappkit/src/registry \
- -I$(topsrcdir)/media/mtransport/third_party/nrappkit/src/stats \
- -I$(topsrcdir)/media/mtransport/third_party/nrappkit/src/plugin \
- -I$(topsrcdir)/media/mtransport/third_party/nrappkit/src/event \
- $(NULL)
-
 ifneq (,$(filter Darwin DragonFly FreeBSD NetBSD OpenBSD,$(OS_TARGET)))
 LOCAL_INCLUDES +=  -I$(topsrcdir)/media/mtransport/third_party/nrappkit/src/port/darwin/include
 ifneq (,$(filter DragonFly FreeBSD NetBSD OpenBSD,$(OS_TARGET)))
 LOCAL_INCLUDES +=  -I$(topsrcdir)/media/mtransport/third_party/nrappkit/src/port/generic/include
 endif
 endif
 
 ifeq ($(OS_TARGET), Linux)
--- a/media/mtransport/test/moz.build
+++ b/media/mtransport/test/moz.build
@@ -35,8 +35,29 @@ if CONFIG['OS_TARGET'] != 'Android':
 if CONFIG['OS_TARGET'] == 'WINNT':
     DEFINES['__Userspace_os_Windows'] = 1
 else:
     # Works for Darwin, Linux, Android. Probably doesn't work for others.
     DEFINES['__Userspace_os_%s' % CONFIG['OS_TARGET']] = 1
 
 if CONFIG['OS_TARGET'] in ('Darwin', 'Android'):
     DEFINES['GTEST_USE_OWN_TR1_TUPLE'] = 1
+
+LOCAL_INCLUDES += [
+    '/media/mtransport/',
+    '/media/mtransport/third_party/',
+    '/media/mtransport/third_party/nICEr/src/crypto',
+    '/media/mtransport/third_party/nICEr/src/ice',
+    '/media/mtransport/third_party/nICEr/src/net',
+    '/media/mtransport/third_party/nICEr/src/stun',
+    '/media/mtransport/third_party/nICEr/src/util',
+    '/media/mtransport/third_party/nrappkit/src/event',
+    '/media/mtransport/third_party/nrappkit/src/log',
+    '/media/mtransport/third_party/nrappkit/src/plugin',
+    '/media/mtransport/third_party/nrappkit/src/registry',
+    '/media/mtransport/third_party/nrappkit/src/share',
+    '/media/mtransport/third_party/nrappkit/src/stats',
+    '/media/mtransport/third_party/nrappkit/src/util/',
+    '/media/mtransport/third_party/nrappkit/src/util/libekr',
+    '/media/webrtc/trunk/testing/gtest/include/',
+    '/netwerk/sctp/src/',
+]
+
--- a/memory/mozjemalloc/Makefile.in
+++ b/memory/mozjemalloc/Makefile.in
@@ -6,9 +6,8 @@
 ifndef MOZ_JEMALLOC3
 ifeq ($(OS_ARCH),SunOS)
 ifndef GNU_CC
 MODULE_OPTIMIZE_FLAGS = -xO5
 endif
 endif
 endif
 
-LOCAL_INCLUDES += -I$(topsrcdir)/memory/build
--- a/memory/mozjemalloc/moz.build
+++ b/memory/mozjemalloc/moz.build
@@ -26,8 +26,13 @@ if CONFIG['MOZ_REPLACE_MALLOC']:
     DEFINES['MOZ_REPLACE_MALLOC'] = True
 
 DEFINES['MOZ_JEMALLOC_IMPL'] = True
 
 #XXX: PGO on Linux causes problems here
 # See bug 419470
 if CONFIG['OS_TARGET'] == 'Linux':
     NO_PGO = True
+
+LOCAL_INCLUDES += [
+    '/memory/build',
+]
+
--- a/mobile/android/app/mobile.js
+++ b/mobile/android/app/mobile.js
@@ -812,17 +812,17 @@ pref("browser.snippets.updateInterval", 
 
 // URL used to check for user's country code
 pref("browser.snippets.geoUrl", "https://geo.mozilla.org/country.json");
 
 // URL used to ping metrics with stats about which snippets have been shown
 pref("browser.snippets.statsUrl", "https://snippets-stats.mozilla.org/mobile");
 
 // These prefs require a restart to take effect.
-pref("browser.snippets.enabled", false);
+pref("browser.snippets.enabled", true);
 pref("browser.snippets.syncPromo.enabled", false);
 
 #ifdef MOZ_ANDROID_SYNTHAPKS
 // The URL of the APK factory from which we obtain APKs for webapps.
 // This currently points to the development server.
 pref("browser.webapps.apkFactoryUrl", "http://dapk.net/application.apk");
 
 // How frequently to check for webapp updates, in seconds (86400 is daily).
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -2975,36 +2975,21 @@ Tab.prototype = {
     }
 
     // Only reload the page for http/https schemes
     let currentURI = this.browser.currentURI;
     if (!currentURI.schemeIs("http") && !currentURI.schemeIs("https"))
       return;
 
     let url = currentURI.spec;
-    let flags = Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_CACHE;
+    let flags = Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_CACHE |
+                Ci.nsIWebNavigation.LOAD_FLAGS_REPLACE_HISTORY;
     if (this.originalURI && !this.originalURI.equals(currentURI)) {
       // We were redirected; reload the original URL
       url = this.originalURI.spec;
-      flags |= Ci.nsIWebNavigation.LOAD_FLAGS_REPLACE_HISTORY;
-    } else {
-      // Many sites use mobile-specific URLs, such as:
-      //   http://m.yahoo.com
-      //   http://www.google.com/m
-      // If the user clicks "Request Desktop Site" while on a mobile site, it
-      // will appear to do nothing since the mobile URL is still being
-      // requested. To address this, we do the following:
-      //   1) Remove the path from the URL (http://www.google.com/m?q=query -> http://www.google.com)
-      //   2) If a host subdomain is "m", remove it (http://en.m.wikipedia.org -> http://en.wikipedia.org)
-      // This means the user is sent to site's home page, but this is better
-      // than the setting having no effect at all.
-      if (aDesktopMode)
-        url = currentURI.prePath.replace(/([\/\.])m\./g, "$1");
-      else
-        flags |= Ci.nsIWebNavigation.LOAD_FLAGS_REPLACE_HISTORY;
     }
 
     this.browser.docShell.loadURI(url, flags, null, null, null);
   },
 
   destroy: function() {
     if (!this.browser)
       return;
--- a/mobile/android/components/Snippets.js
+++ b/mobile/android/components/Snippets.js
@@ -317,16 +317,20 @@ function Snippets() {}
 
 Snippets.prototype = {
   QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver, Ci.nsITimerCallback]),
   classID: Components.ID("{a78d7e59-b558-4321-a3d6-dffe2f1e76dd}"),
 
   observe: function(subject, topic, data) {
     switch(topic) {
       case "profile-after-change":
+        Services.obs.addObserver(this, "browser-delayed-startup-finished", false);
+        break;
+      case "browser-delayed-startup-finished":
+        Services.obs.removeObserver(this, "browser-delayed-startup-finished", false);
         if (Services.prefs.getBoolPref("browser.snippets.syncPromo.enabled")) {
           loadSyncPromoBanner();
         }
 
         if (Services.prefs.getBoolPref("browser.snippets.enabled")) {
           loadSnippetsFromCache();
         }
         break;
--- a/modules/libmar/sign/Makefile.in
+++ b/modules/libmar/sign/Makefile.in
@@ -1,17 +1,12 @@
 # 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 makefile just builds support for reading archives.
-LOCAL_INCLUDES += -I$(srcdir)/../src \
-  -I$(srcdir)/../verify \
-  -I$(topsrcdir)/dist/include \
-  $(NULL)
-
 CFLAGS += -DMAR_NSS
 
 include $(topsrcdir)/config/rules.mk
 
 # The intermediate (.ii/.s) files for host and target can have the same name...
 # disable parallel builds
 .NOTPARALLEL:
--- a/modules/libmar/sign/moz.build
+++ b/modules/libmar/sign/moz.build
@@ -8,10 +8,16 @@ LIBRARY_NAME = 'signmar'
 
 UNIFIED_SOURCES += [
     'mar_sign.c',
     'nss_secutil.c',
 ]
 
 FORCE_STATIC_LIB = True
 
+LOCAL_INCLUDES += [
+    '../src',
+    '../verify',
+]
+
+
 if CONFIG['OS_ARCH'] == 'WINNT':
     USE_STATIC_LIBS = True
--- a/modules/libmar/verify/Makefile.in
+++ b/modules/libmar/verify/Makefile.in
@@ -1,15 +1,13 @@
 # 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 makefile just builds support for reading archives.
-LOCAL_INCLUDES += -I$(srcdir)/../src
-
 ifneq ($(OS_ARCH),WINNT)
 LOCAL_INCLUDES += -I$(srcdir)/../sign
 endif
 
 include $(topsrcdir)/config/rules.mk
 
 # The intermediate (.ii/.s) files for host and target can have the same name...
 # disable parallel builds
--- a/modules/libmar/verify/moz.build
+++ b/modules/libmar/verify/moz.build
@@ -12,8 +12,13 @@ UNIFIED_SOURCES += [
 ]
 
 FORCE_STATIC_LIB = True
 
 if CONFIG['OS_ARCH'] == 'WINNT':
     USE_STATIC_LIBS = True
 else:
     DEFINES['MAR_NSS'] = True
+
+LOCAL_INCLUDES += [
+    '../src',
+]
+
--- a/other-licenses/bsdiff/Makefile.in
+++ b/other-licenses/bsdiff/Makefile.in
@@ -30,13 +30,11 @@ HOST_LIBS += $(MOZ_BZ2_LIBS)
 else
 HOST_LIBS += $(DIST)/host/lib/$(LIB_PREFIX)hostbz2.$(LIB_SUFFIX)
 endif
 
 ifeq ($(HOST_OS_ARCH),WINNT)
 HOST_EXTRA_LIBS += $(call EXPAND_LIBNAME,Ws2_32)
 endif
 
-LOCAL_INCLUDES += -I$(topsrcdir)/toolkit/mozapps/update/updater
-
 include $(topsrcdir)/config/rules.mk
 
 HOST_CXXFLAGS += $(MOZ_BZ2_CFLAGS)
--- a/other-licenses/bsdiff/moz.build
+++ b/other-licenses/bsdiff/moz.build
@@ -4,8 +4,13 @@
 # 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/.
 
 HOST_SOURCES += [
     'bsdiff.c',
 ]
 
 HOST_PROGRAM = 'mbsdiff'
+
+LOCAL_INCLUDES += [
+    '/toolkit/mozapps/update/updater',
+]
+
--- a/profile/dirserviceprovider/standalone/Makefile.in
+++ b/profile/dirserviceprovider/standalone/Makefile.in
@@ -1,9 +1,7 @@
 # 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 $(topsrcdir)/config/rules.mk
 
-LOCAL_INCLUDES = -I$(srcdir)/../src
-
 STL_FLAGS =
--- a/profile/dirserviceprovider/standalone/moz.build
+++ b/profile/dirserviceprovider/standalone/moz.build
@@ -8,8 +8,13 @@ include('../src/objs.mozbuild')
 
 UNIFIED_SOURCES += modules_profiledirservice_src_csrcs
 
 LIBRARY_NAME = 'profdirserviceprovidersa_s'
 
 FORCE_STATIC_LIB = True
 
 DEFINES['XPCOM_GLUE'] = 1
+
+LOCAL_INCLUDES += [
+    '../src',
+]
+
--- a/security/manager/ssl/tests/gtest/Makefile.in
+++ b/security/manager/ssl/tests/gtest/Makefile.in
@@ -3,13 +3,9 @@
 # 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 $(DEPTH)/config/autoconf.mk
 
 EXPORT_LIBRARY = 1
 
-LOCAL_INCLUDES = \
-  -I$(topsrcdir)/security/manager/ssl/src \
-  $(NULL)
-
 include $(topsrcdir)/config/rules.mk
--- a/security/manager/ssl/tests/gtest/moz.build
+++ b/security/manager/ssl/tests/gtest/moz.build
@@ -12,8 +12,13 @@ SOURCES += [
 	'TLSIntoleranceTest.cpp',
 ]
 
 LOCAL_INCLUDES += [
     '../../../../insanity/include',
 ]
 
 include('/ipc/chromium/chromium-config.mozbuild')
+
+LOCAL_INCLUDES += [
+    '/security/manager/ssl/src',
+]
+
--- a/security/manager/ssl/tests/unit/tlsserver/cmd/Makefile.in
+++ b/security/manager/ssl/tests/unit/tlsserver/cmd/Makefile.in
@@ -10,11 +10,8 @@ LIBS = \
   $(NSPR_LIBS) \
   $(NSS_LIBS) \
   $(MOZALLOC_LIB) \
   ../lib/$(LIB_PREFIX)tlsserver.$(LIB_SUFFIX) \
   $(NULL)
 
 DEFINES += $(TK_CFLAGS)
 
-LOCAL_INCLUDES += \
-   -I$(srcdir)/../lib \
-   $(NULL)
--- a/security/manager/ssl/tests/unit/tlsserver/cmd/moz.build
+++ b/security/manager/ssl/tests/unit/tlsserver/cmd/moz.build
@@ -10,8 +10,13 @@ SIMPLE_PROGRAMS = [
     'BadCertServer',
     'GenerateOCSPResponse',
     'OCSPStaplingServer',
 ]
 
 SOURCES += [
     '%s.cpp' % s for s in SIMPLE_PROGRAMS
 ]
+
+LOCAL_INCLUDES += [
+    '../lib',
+]
+
--- a/security/sandbox/win/src/sandboxbroker/Makefile.in
+++ b/security/sandbox/win/src/sandboxbroker/Makefile.in
@@ -1,19 +1,13 @@
 # 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/.
 #
 MOZ_GLUE_LDFLAGS =
 STL_FLAGS =
 
-LOCAL_INCLUDES += \
-    -I$(topsrcdir)/security \
-    -I$(topsrcdir)/security/sandbox \
-    -I$(topsrcdir)/security/sandbox/chromium \
-    $(NULL)
-
 SHARED_LIBRARY_LIBS += \
 	../../../$(LIB_PREFIX)sandbox_s.$(LIB_SUFFIX) \
 	$(NSPR_LIBS) \
 	$(NULL)
 
 OS_LIBS += $(call EXPAND_LIBNAME,dbghelp)
--- a/security/sandbox/win/src/sandboxbroker/moz.build
+++ b/security/sandbox/win/src/sandboxbroker/moz.build
@@ -15,8 +15,15 @@ EXPORTS += [
     'sandboxBroker.h',
 ]
 
 FORCE_SHARED_LIB = True
 
 for var in ('UNICODE', '_UNICODE', 'NS_NO_XPCOM', 'NOMINMAX',
             'SANDBOX_EXPORTS'):
     DEFINES[var] = True
+
+LOCAL_INCLUDES += [
+    '/security',
+    '/security/sandbox',
+    '/security/sandbox/chromium',
+]
+
--- a/testing/gtest/Makefile.in
+++ b/testing/gtest/Makefile.in
@@ -1,22 +1,15 @@
 # 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/.
 
 # Avoid recursive make to avoid having to add files to the gtest/ subdirectory
 # (which is third-party code), and to make the build faster.
 
-LOCAL_INCLUDES += \
-  -I$(srcdir)/gtest \
-  -I$(srcdir)/gtest/include \
-  -I$(srcdir)/gmock \
-  -I$(srcdir)/gmock/include \
-  $(NULL)
-
 include $(topsrcdir)/config/rules.mk
 
 ifeq (browser,$(MOZ_BUILD_APP))
 # Disable because of metro linking error bug 883339:
 # LNK1181: cannot open input file 'runtimeobject.lib'
 # And non metro linking error bug 886656:
 # LNK1112: module machine type 'x64' conflicts with target machine type 'X86'
 ifneq ($(OS_ARCH),WINNT)
--- a/testing/gtest/moz.build
+++ b/testing/gtest/moz.build
@@ -62,8 +62,15 @@ LIBRARY_NAME = 'gtest'
 SOURCES += [
     'mozilla/SanityTest.cpp',
 ]
 
 LIBXUL_LIBRARY = True
 
 EXPORT_LIBRARY = True
 
+LOCAL_INCLUDES += [
+    'gmock',
+    'gmock/include',
+    'gtest',
+    'gtest/include',
+]
+
deleted file mode 100644
--- a/toolkit/components/alerts/Makefile.in
+++ /dev/null
@@ -1,7 +0,0 @@
-# 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/.
-
-LOCAL_INCLUDES += -I$(topsrcdir)/toolkit/components/build/
-
-include $(topsrcdir)/config/rules.mk
--- a/toolkit/components/ctypes/tests/Makefile.in
+++ b/toolkit/components/ctypes/tests/Makefile.in
@@ -1,16 +1,12 @@
 # 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/.
 
-LOCAL_INCLUDES = \
-    -I$(topsrcdir)/js/src/ctypes \
-    $(NULL)
-
 EXTRA_DSO_LDOPTS += $(MOZALLOC_LIB)
 
 xpctestdir = $(testxpcobjdir)/$(relativesrcdir)/unit
 
 chrometestdir = \
   $(DEPTH)/_tests/testing/mochitest/chrome/toolkit/components/$(relativesrcdir)
 
 # should be MOCHITEST_CHROME_FILES, see bug 770938
--- a/toolkit/components/ctypes/tests/moz.build
+++ b/toolkit/components/ctypes/tests/moz.build
@@ -11,8 +11,13 @@ UNIFIED_SOURCES += [
     'jsctypes-test-errno.cpp',
     'jsctypes-test-finalizer.cpp',
     'jsctypes-test.cpp',
 ]
 
 LIBRARY_NAME = 'jsctypes-test'
 
 FORCE_SHARED_LIB = True
+
+LOCAL_INCLUDES += [
+    '/js/src/ctypes',
+]
+
--- a/toolkit/components/downloads/Makefile.in
+++ b/toolkit/components/downloads/Makefile.in
@@ -2,11 +2,8 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 include $(topsrcdir)/config/rules.mk
 
 CXXFLAGS += $(TK_CFLAGS) -DGOOGLE_PROTOBUF_NO_RTTI
 
-LOCAL_INCLUDES += \
-  -I$(srcdir)/../protobuf \
-  $(NULL)
--- a/toolkit/components/downloads/moz.build
+++ b/toolkit/components/downloads/moz.build
@@ -47,8 +47,13 @@ if not CONFIG['MOZ_SUITE']:
     EXTRA_COMPONENTS += [
         'nsDownloadManagerUI.js',
         'nsDownloadManagerUI.manifest',
     ]
 
 FAIL_ON_WARNINGS = True
 
 FINAL_LIBRARY = 'toolkitcomps'
+
+LOCAL_INCLUDES += [
+    '../protobuf',
+]
+
--- a/toolkit/components/maintenanceservice/Makefile.in
+++ b/toolkit/components/maintenanceservice/Makefile.in
@@ -33,13 +33,8 @@ MOZ_WINCONSOLE = 0
 endif
 endif
 
 include $(topsrcdir)/config/rules.mk
 
 ifdef _MSC_VER
 WIN32_EXE_LDFLAGS += -ENTRY:wmainCRTStartup
 endif
-
-# Pick up nsWindowsRestart.cpp
-LOCAL_INCLUDES += -I$(topsrcdir)/toolkit/xre \
-  -I$(topsrcdir)/toolkit/mozapps/update/common \
-  $(NULL)
--- a/toolkit/components/maintenanceservice/moz.build
+++ b/toolkit/components/maintenanceservice/moz.build
@@ -17,9 +17,16 @@ SOURCES += [
 
 # For debugging purposes only
 #DEFINES['DISABLE_UPDATER_AUTHENTICODE_CHECK'] = True
 
 DEFINES['UNICODE'] = True
 DEFINES['_UNICODE'] = True
 DEFINES['NS_NO_XPCOM'] = True
 
+# Pick up nsWindowsRestart.cpp
+LOCAL_INCLUDES += [
+    '/toolkit/mozapps/update/common',
+    '/toolkit/xre',
+]
+
+
 USE_STATIC_LIBS = True
--- a/toolkit/components/telemetry/Makefile.in
+++ b/toolkit/components/telemetry/Makefile.in
@@ -1,19 +1,16 @@
 #
 # 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_RCS_MK := 1
 include $(topsrcdir)/config/makefiles/rcs.mk
 
-LOCAL_INCLUDES += -I$(topsrcdir)/xpcom/build
-LOCAL_INCLUDES += -I$(topsrcdir)/xpcom/threads
-
 DEFINES += -DMOZ_APP_VERSION='"$(MOZ_APP_VERSION)"'
 
 MOZ_HISTOGRAMS_VERSION ?= $(call getSourceRepo)/rev/$(firstword $(shell hg -R $(topsrcdir) parent --template='{node|short}\n' 2>/dev/null))
 ifdef MOZ_HISTOGRAMS_VERSION
 DEFINES += -DHISTOGRAMS_FILE_VERSION='$(MOZ_HISTOGRAMS_VERSION)'
 endif
 
 INSTALL_TARGETS += histoenums
--- a/toolkit/components/telemetry/moz.build
+++ b/toolkit/components/telemetry/moz.build
@@ -47,8 +47,14 @@ include('/ipc/chromium/chromium-config.m
 FINAL_LIBRARY = 'xul'
 
 GENERATED_FILES = [
     'TelemetryHistogramData.inc',
 ]
 
 if CONFIG['MOZILLA_OFFICIAL']:
     DEFINES['MOZILLA_OFFICIAL'] = True
+
+LOCAL_INCLUDES += [
+    '/xpcom/build',
+    '/xpcom/threads',
+]
+
--- a/toolkit/components/url-classifier/Makefile.in
+++ b/toolkit/components/url-classifier/Makefile.in
@@ -1,10 +1,9 @@
 # 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 $(topsrcdir)/config/rules.mk
 
-LOCAL_INCLUDES = \
-  -I$(srcdir)/../build \
-  -I$(topsrcdir)/ipc/chromium/src \
+CXXFLAGS += \
   $(SQLITE_CFLAGS) \
   $(NULL)
--- a/toolkit/components/url-classifier/moz.build
+++ b/toolkit/components/url-classifier/moz.build
@@ -60,8 +60,14 @@ EXPORTS += [
     'nsUrlClassifierPrefixSet.h',
 ]
 
 FAIL_ON_WARNINGS = True
 
 MSVC_ENABLE_PGO = True
 
 FINAL_LIBRARY = 'toolkitcomps'
+
+LOCAL_INCLUDES += [
+    '../build',
+    '/ipc/chromium/src',
+]
+
--- a/toolkit/crashreporter/Makefile.in
+++ b/toolkit/crashreporter/Makefile.in
@@ -4,14 +4,12 @@
 
 ifeq ($(OS_TARGET),Android)
 # NDK5 workarounds
 TARGET_LOCAL_INCLUDES = \
   -I$(topsrcdir)/toolkit/crashreporter/google-breakpad/src/common/android/include/ \
   $(NULL)
 endif
 
-LOCAL_INCLUDES += -I$(srcdir)/google-breakpad/src
-
 include $(topsrcdir)/config/rules.mk
 
 check::
 	$(PYTHON) $(srcdir)/tools/unit-symbolstore.py
--- a/toolkit/crashreporter/client/Makefile.in
+++ b/toolkit/crashreporter/client/Makefile.in
@@ -10,53 +10,46 @@ STL_FLAGS =
 ifneq ($(OS_TARGET),Android)
 DIST_PROGRAM = crashreporter$(BIN_SUFFIX)
 
 # Don't link the updater against libmozglue.
 MOZ_GLUE_LDFLAGS =
 MOZ_GLUE_PROGRAM_LDFLAGS =
 endif
 
-LOCAL_INCLUDES = -I$(srcdir)/../google-breakpad/src
-
 ifeq ($(OS_ARCH),WINNT)
 LIBS += \
   $(DEPTH)/toolkit/crashreporter/breakpad-windows-libxul/$(LIB_PREFIX)google_breakpad_libxul_s.$(LIB_SUFFIX)
   $(NULL)
-LOCAL_INCLUDES += -I$(srcdir)
 RCINCLUDE = crashreporter.rc
 OS_LIBS += $(call EXPAND_LIBNAME,comctl32 shell32 wininet shlwapi)
 MOZ_WINCONSOLE = 0
 endif
 
 ifeq ($(OS_ARCH),Darwin)
 OS_LIBS += -framework Cocoa
 LIBS += \
   $(DEPTH)/toolkit/crashreporter/google-breakpad/src/common/$(LIB_PREFIX)breakpad_common_s.$(LIB_SUFFIX) \
   $(DEPTH)/toolkit/crashreporter/google-breakpad/src/common/mac/$(LIB_PREFIX)breakpad_mac_common_s.$(LIB_SUFFIX) \
   $(NULL)
-
-LOCAL_INCLUDES += -I$(srcdir) -I$(srcdir)/../google-breakpad/src/common/mac/
 endif
 
 ifdef MOZ_WIDGET_GTK
 
 LIBS += \
   $(DEPTH)/toolkit/crashreporter/google-breakpad/src/common/linux/$(LIB_PREFIX)breakpad_linux_common_s.$(LIB_SUFFIX) \
   $(NULL)
-LOCAL_INCLUDES += -I$(srcdir)
 OS_CXXFLAGS += $(TK_CFLAGS) $(MOZ_GTHREAD_CFLAGS)
 OS_LIBS += $(TK_LIBS) $(MOZ_GTHREAD_LIBS)
 endif
 
 ifeq ($(OS_ARCH),SunOS)
 LIBS += \
   $(DEPTH)/toolkit/crashreporter/google-breakpad/src/common/solaris/$(LIB_PREFIX)breakpad_solaris_common_s.$(LIB_SUFFIX) \
   $(NULL)
-LOCAL_INCLUDES += -I$(srcdir)
 OS_CXXFLAGS += $(MOZ_GTK2_CFLAGS) $(MOZ_GTHREAD_CFLAGS)
 OS_LIBS += $(MOZ_GTK2_LIBS) $(MOZ_GTHREAD_LIBS)
 endif
 
 include $(topsrcdir)/config/rules.mk
 
 ifeq ($(OS_ARCH),Darwin)
 libs::
--- a/toolkit/crashreporter/client/moz.build
+++ b/toolkit/crashreporter/client/moz.build
@@ -7,35 +7,39 @@
 if CONFIG['OS_TARGET'] != 'Android':
     PROGRAM = 'crashreporter'
 # The xpcshell test case here verifies that the CA certificate list
 
 UNIFIED_SOURCES += [
     'crashreporter.cpp',
 ]
 
+LOCAL_INCLUDES += [
+    '../google-breakpad/src',
+]
+
 if CONFIG['OS_ARCH'] == 'WINNT':
     UNIFIED_SOURCES += [
         'crashreporter_win.cpp',
     ]
     DEFINES['UNICODE'] = True
     DEFINES['_UNICODE'] = True
 elif CONFIG['OS_ARCH'] == 'Darwin':
     UNIFIED_SOURCES += [
+        'crashreporter_osx.mm',
         'crashreporter_unix_common.cpp',
     ]
+    LOCAL_INCLUDES += [
+        '../google-breakpad/src/common/mac',
+    ]
 elif CONFIG['OS_ARCH'] == 'SunOS':
     SOURCES += [
         'crashreporter_linux.cpp',
         'crashreporter_unix.cpp',
     ]
 
 if CONFIG['MOZ_ENABLE_GTK']:
     UNIFIED_SOURCES += [
         'crashreporter_gtk_common.cpp',
         'crashreporter_linux.cpp',
         'crashreporter_unix_common.cpp'
-        ]
+    ]
 
-if CONFIG['OS_ARCH'] == 'Darwin':
-    UNIFIED_SOURCES += [
-        'crashreporter_osx.mm',
-    ]
deleted file mode 100644
--- a/toolkit/crashreporter/google-breakpad/src/client/Makefile.in
+++ /dev/null
@@ -1,5 +0,0 @@
-# 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/.
-
-LOCAL_INCLUDES 	= -I$(srcdir)/..
deleted file mode 100644
--- a/toolkit/crashreporter/google-breakpad/src/client/linux/crash_generation/Makefile.in
+++ /dev/null
@@ -1,13 +0,0 @@
-# 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/.
-
-LOCAL_INCLUDES = \
-  -I$(topsrcdir)/toolkit/crashreporter/google-breakpad/src \
-  $(NULL)
-
-include $(topsrcdir)/config/rules.mk
-
-ifeq ($(OS_TARGET),Android)
-LOCAL_INCLUDES += -I$(topsrcdir)/toolkit/crashreporter/google-breakpad/src/common/android/include/
-endif
--- a/toolkit/crashreporter/google-breakpad/src/client/linux/crash_generation/moz.build
+++ b/toolkit/crashreporter/google-breakpad/src/client/linux/crash_generation/moz.build
@@ -5,8 +5,17 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 UNIFIED_SOURCES += [
     'crash_generation_client.cc',
     'crash_generation_server.cc',
 ]
 
 FINAL_LIBRARY = 'xulapp_s'
+
+LOCAL_INCLUDES += [
+    '/toolkit/crashreporter/google-breakpad/src',
+]
+
+if CONFIG['OS_TARGET'] == 'Android':
+    LOCAL_INCLUDES += [
+        '/toolkit/crashreporter/google-breakpad/src/common/android/include',
+    ]
--- a/toolkit/crashreporter/google-breakpad/src/client/linux/handler/Makefile.in
+++ b/toolkit/crashreporter/google-breakpad/src/client/linux/handler/Makefile.in
@@ -10,17 +10,8 @@ ifdef MOZ_THUMB2 #{
 # r7 with no complaint from gcc, but the sys_clone() function marks r7
 # as a clobbered register yet gcc error's.  The generated assembly for
 # sys_clone() looks OK, so we chalk this up to a gcc/gas quirk and
 # work around it by telling gcc that the THUMB frame pointer is a
 # vanilla callee-save register.
 OS_CXXFLAGS += -fomit-frame-pointer
 MOZ_FRAMEPTR_FLAGS := -fomit-frame-pointer
 endif #}
-
-LOCAL_INCLUDES = \
-  -I$(topsrcdir)/toolkit/crashreporter/google-breakpad/src \
-  $(NULL)
-
-ifeq ($(OS_TARGET),Android)
-# NDK5 workarounds
-LOCAL_INCLUDES += -I$(topsrcdir)/toolkit/crashreporter/google-breakpad/src/common/android/include/
-endif
--- a/toolkit/crashreporter/google-breakpad/src/client/linux/handler/moz.build
+++ b/toolkit/crashreporter/google-breakpad/src/client/linux/handler/moz.build
@@ -13,8 +13,16 @@ UNIFIED_SOURCES += [
 XPI_NAME = 'crashreporter'
 
 FINAL_LIBRARY = 'xulapp_s'
 
 if CONFIG['OS_TARGET'] == 'Android':
     # NDK5 workarounds
     DEFINES['_STLP_CONST_CONSTRUCTOR_BUG'] = True
     DEFINES['_STLP_NO_MEMBER_TEMPLATES'] = True
+    LOCAL_INCLUDES += [
+        '/toolkit/crashreporter/google-breakpad/src/common/android/include',
+    ]
+
+LOCAL_INCLUDES += [
+    '/toolkit/crashreporter/google-breakpad/src',
+]
+
deleted file mode 100644
--- a/toolkit/crashreporter/google-breakpad/src/client/mac/crash_generation/Makefile.in
+++ /dev/null
@@ -1,5 +0,0 @@
-# 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/.
-
-LOCAL_INCLUDES 	= -I$(srcdir)/../../..
--- a/toolkit/crashreporter/google-breakpad/src/client/mac/crash_generation/moz.build
+++ b/toolkit/crashreporter/google-breakpad/src/client/mac/crash_generation/moz.build
@@ -7,8 +7,13 @@
 UNIFIED_SOURCES += [
     'crash_generation_client.cc',
     'crash_generation_server.cc',
 ]
 
 XPI_NAME = 'crashreporter'
 
 FINAL_LIBRARY = 'xulapp_s'
+
+LOCAL_INCLUDES += [
+    '../../..',
+]
+
deleted file mode 100644
--- a/toolkit/crashreporter/google-breakpad/src/client/mac/handler/Makefile.in
+++ /dev/null
@@ -1,5 +0,0 @@
-# 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/.
-
-LOCAL_INCLUDES 	= -I$(srcdir)/../../..
--- a/toolkit/crashreporter/google-breakpad/src/client/mac/handler/moz.build
+++ b/toolkit/crashreporter/google-breakpad/src/client/mac/handler/moz.build
@@ -9,8 +9,13 @@ UNIFIED_SOURCES += [
     'dynamic_images.cc',
     'exception_handler.cc',
     'minidump_generator.cc',
 ]
 
 XPI_NAME = 'crashreporter'
 
 FINAL_LIBRARY = 'xulapp_s'
+
+LOCAL_INCLUDES += [
+    '../../..',
+]
+
--- a/toolkit/crashreporter/google-breakpad/src/client/moz.build
+++ b/toolkit/crashreporter/google-breakpad/src/client/moz.build
@@ -6,8 +6,13 @@
 
 SOURCES += [
     'minidump_file_writer.cc',
 ]
 
 XPI_NAME = 'crashreporter'
 
 FINAL_LIBRARY = 'xulapp_s'
+
+LOCAL_INCLUDES += [
+    '..',
+]
+
deleted file mode 100644
--- a/toolkit/crashreporter/google-breakpad/src/client/solaris/handler/Makefile.in
+++ /dev/null
@@ -1,5 +0,0 @@
-# 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/.
-
-LOCAL_INCLUDES 	= -I$(srcdir)/../../..
--- a/toolkit/crashreporter/google-breakpad/src/client/solaris/handler/moz.build
+++ b/toolkit/crashreporter/google-breakpad/src/client/solaris/handler/moz.build
@@ -8,8 +8,13 @@ SOURCES += [
     'exception_handler.cc',
     'minidump_generator.cc',
     'solaris_lwp.cc',
 ]
 
 XPI_NAME = 'crashreporter'
 
 FINAL_LIBRARY = 'xulapp_s'
+
+LOCAL_INCLUDES += [
+    '../../..',
+]
+
--- a/toolkit/crashreporter/google-breakpad/src/common/Makefile.in
+++ b/toolkit/crashreporter/google-breakpad/src/common/Makefile.in
@@ -2,18 +2,16 @@
 # 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/.
 
 ifneq (WINNT,$(OS_TARGET))
 ifdef MOZ_CRASHREPORTER
 endif
 endif
 
-LOCAL_INCLUDES 	= -I$(srcdir)/..
-
 ifeq ($(OS_TARGET),Android)
 TARGET_LOCAL_INCLUDES += -I$(topsrcdir)/toolkit/crashreporter/google-breakpad/src/common/android/include/
 endif
 
 # This kind of sucks.
 ifeq (Linux,$(OS_ARCH))
 HOST_CXXFLAGS += -DHAVE_A_OUT_H
 OS_CXXFLAGS += -DHAVE_A_OUT_H
--- a/toolkit/crashreporter/google-breakpad/src/common/dwarf/Makefile.in
+++ b/toolkit/crashreporter/google-breakpad/src/common/dwarf/Makefile.in
@@ -1,13 +1,7 @@
 # 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/.
 
-ifdef MOZ_CRASHREPORTER
-
-LOCAL_INCLUDES 	= -I$(srcdir)/../..
-
-endif
-
 # This code is only compiled for build-time tools,
 # so enabling RTTI should be fine.
 HOST_CXXFLAGS += -funsigned-char -frtti
--- a/toolkit/crashreporter/google-breakpad/src/common/dwarf/moz.build
+++ b/toolkit/crashreporter/google-breakpad/src/common/dwarf/moz.build
@@ -7,11 +7,14 @@
 if CONFIG['MOZ_CRASHREPORTER']:
     HOST_LIBRARY_NAME = 'host_breakpad_dwarf_s'
     HOST_SOURCES += [
         'bytereader.cc',
         'dwarf2diehandler.cc',
         'dwarf2reader.cc',
         'functioninfo.cc',
     ]
+    LOCAL_INCLUDES += [
+        '../..',
+    ]
 
 # need static lib
 FORCE_STATIC_LIB = True
--- a/toolkit/crashreporter/google-breakpad/src/common/linux/Makefile.in
+++ b/toolkit/crashreporter/google-breakpad/src/common/linux/Makefile.in
@@ -1,16 +1,12 @@
 # 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/.
 
-LOCAL_INCLUDES = \
-  -I$(topsrcdir)/toolkit/crashreporter/google-breakpad/src \
-  $(NULL)
-
 ifneq (Android,$(OS_TARGET))
 else
 TARGET_LOCAL_INCLUDES += -I$(topsrcdir)/toolkit/crashreporter/google-breakpad/src/common/android/include/
 endif
 
 include $(topsrcdir)/config/rules.mk
 
 # See https://bugzilla.mozilla.org/show_bug.cgi?id=741348#c11
--- a/toolkit/crashreporter/google-breakpad/src/common/linux/moz.build
+++ b/toolkit/crashreporter/google-breakpad/src/common/linux/moz.build
@@ -37,8 +37,13 @@ if CONFIG['MOZ_CRASHREPORTER']:
 LIBRARY_NAME = 'breakpad_linux_common_s'
 
 FINAL_LIBRARY = 'xulapp_s'
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
     DEFINES['ELFSIZE'] = 32
 
 DEFINES['NO_STABS_SUPPORT'] = True
+
+LOCAL_INCLUDES += [
+    '/toolkit/crashreporter/google-breakpad/src',
+]
+
--- a/toolkit/crashreporter/google-breakpad/src/common/mac/Makefile.in
+++ b/toolkit/crashreporter/google-breakpad/src/common/mac/Makefile.in
@@ -1,9 +1,7 @@
 # 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/.
 
-LOCAL_INCLUDES 	= -I$(srcdir)/../..
-
 include $(topsrcdir)/config/rules.mk
 
 COMPILE_CMFLAGS += -std=c99
--- a/toolkit/crashreporter/google-breakpad/src/common/mac/moz.build
+++ b/toolkit/crashreporter/google-breakpad/src/common/mac/moz.build
@@ -28,8 +28,13 @@ if CONFIG['MOZ_CRASHREPORTER']:
 SOURCES += [
     'HTTPMultipartUpload.m',
     'MachIPC.mm',
 ]
 
 LIBRARY_NAME = 'breakpad_mac_common_s'
 
 FINAL_LIBRARY = 'xulapp_s'
+
+LOCAL_INCLUDES += [
+    '../..',
+]
+
--- a/toolkit/crashreporter/google-breakpad/src/common/moz.build
+++ b/toolkit/crashreporter/google-breakpad/src/common/moz.build
@@ -82,8 +82,13 @@ MSVC_ENABLE_PGO = True
 
 FINAL_LIBRARY = 'xulapp_s'
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
     DEFINES['ELFSIZE'] = 32
 
 if CONFIG['OS_TARGET'] == 'Android':
     DEFINES['NO_STABS_SUPPORT'] = True
+
+LOCAL_INCLUDES += [
+    '..',
+]
+
deleted file mode 100644
--- a/toolkit/crashreporter/google-breakpad/src/common/solaris/Makefile.in
+++ /dev/null
@@ -1,5 +0,0 @@
-# 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/.
-
-LOCAL_INCLUDES 	= -I$(srcdir)/../..
--- a/toolkit/crashreporter/google-breakpad/src/common/solaris/moz.build
+++ b/toolkit/crashreporter/google-breakpad/src/common/solaris/moz.build
@@ -18,8 +18,13 @@ LIBRARY_NAME = 'breakpad_solaris_common_
 # since it depends on libcurl
 HOST_SOURCES += [
     'dump_symbols.cc',
     'file_id.cc',
     'guid_creator.cc',
 ]
 
 FINAL_LIBRARY = 'xulapp_s'
+
+LOCAL_INCLUDES += [
+    '../..',
+]
+
deleted file mode 100644
--- a/toolkit/crashreporter/google-breakpad/src/processor/Makefile.in
+++ /dev/null
@@ -1,5 +0,0 @@
-# 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/.
-
-LOCAL_INCLUDES 	= -I$(srcdir)/../.. -I$(srcdir)/..
--- a/toolkit/crashreporter/google-breakpad/src/processor/moz.build
+++ b/toolkit/crashreporter/google-breakpad/src/processor/moz.build
@@ -17,8 +17,14 @@ UNIFIED_SOURCES += [
     'stackwalker_arm.cc',
     'stackwalker_ppc.cc',
     'stackwalker_sparc.cc',
     'stackwalker_x86.cc',
     'tokenize.cc',
 ]
 
 FINAL_LIBRARY = 'xulapp_s'
+
+LOCAL_INCLUDES += [
+    '..',
+    '../..',
+]
+
--- a/toolkit/crashreporter/google-breakpad/src/tools/linux/dump_syms/Makefile.in
+++ b/toolkit/crashreporter/google-breakpad/src/tools/linux/dump_syms/Makefile.in
@@ -1,14 +1,9 @@
 # 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/.
 
-LOCAL_INCLUDES 	= \
-  -I$(srcdir)/../../.. \
-  -I$(srcdir)/../../../common/linux \
-  $(NULL)
-
 HOST_LIBS += \
   $(DEPTH)/toolkit/crashreporter/google-breakpad/src/common/linux/$(LIB_PREFIX)host_breakpad_linux_common_s.$(LIB_SUFFIX) \
   $(DEPTH)/toolkit/crashreporter/google-breakpad/src/common/$(LIB_PREFIX)host_breakpad_common_s.$(LIB_SUFFIX) \
   $(DEPTH)/toolkit/crashreporter/google-breakpad/src/common/dwarf/$(LIB_PREFIX)host_breakpad_dwarf_s.$(LIB_SUFFIX) \
   $(NULL)
--- a/toolkit/crashreporter/google-breakpad/src/tools/linux/dump_syms/moz.build
+++ b/toolkit/crashreporter/google-breakpad/src/tools/linux/dump_syms/moz.build
@@ -4,8 +4,14 @@
 # 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/.
 
 HOST_SOURCES += [
     'dump_syms.cc',
 ]
 
 HOST_PROGRAM = 'dump_syms'
+
+LOCAL_INCLUDES += [
+    '../../..',
+    '../../../common/linux',
+]
+
--- a/toolkit/crashreporter/google-breakpad/src/tools/mac/dump_syms/Makefile.in
+++ b/toolkit/crashreporter/google-breakpad/src/tools/mac/dump_syms/Makefile.in
@@ -1,17 +1,12 @@
 # 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/.
 
-LOCAL_INCLUDES 	= \
-  -I$(srcdir)/../../.. \
-  -I$(srcdir)/../../../common/mac \
-  $(NULL)
-
 HOST_LIBS += \
   $(DEPTH)/toolkit/crashreporter/google-breakpad/src/common/dwarf/$(LIB_PREFIX)host_breakpad_dwarf_s.$(LIB_SUFFIX) \
   $(DEPTH)/toolkit/crashreporter/google-breakpad/src/common/mac/$(LIB_PREFIX)host_breakpad_mac_common_s.$(LIB_SUFFIX) \
   $(DEPTH)/toolkit/crashreporter/google-breakpad/src/common/$(LIB_PREFIX)host_breakpad_common_s.$(LIB_SUFFIX) \
   $(NULL)
 
 HOST_LDFLAGS += \
   -framework Foundation \
--- a/toolkit/crashreporter/google-breakpad/src/tools/mac/dump_syms/moz.build
+++ b/toolkit/crashreporter/google-breakpad/src/tools/mac/dump_syms/moz.build
@@ -5,8 +5,13 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 HOST_SOURCES += [
     'dump_syms_tool.mm',
 ]
 
 HOST_PROGRAM = 'dump_syms'
 
+LOCAL_INCLUDES += [
+    '../../..',
+    '../../../common/mac',
+]
+
--- a/toolkit/crashreporter/google-breakpad/src/tools/solaris/dump_syms/Makefile.in
+++ b/toolkit/crashreporter/google-breakpad/src/tools/solaris/dump_syms/Makefile.in
@@ -1,15 +1,10 @@
 # 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/.
 
-LOCAL_INCLUDES 	= \
-  -I$(srcdir)/../../.. \
-  -I$(srcdir)/../../../common/solaris \
-  $(NULL)
-
 HOST_LIBS += \
   $(DEPTH)/toolkit/crashreporter/google-breakpad/src/common/solaris/$(LIB_PREFIX)host_breakpad_solaris_common_s.$(LIB_SUFFIX) \
   $(DEPTH)/toolkit/crashreporter/google-breakpad/src/common/$(LIB_PREFIX)host_breakpad_common_s.$(LIB_SUFFIX) \
   $(NULL)
 
 HOST_LDFLAGS += -lelf -ldemangle
--- a/toolkit/crashreporter/google-breakpad/src/tools/solaris/dump_syms/moz.build
+++ b/toolkit/crashreporter/google-breakpad/src/tools/solaris/dump_syms/moz.build
@@ -4,8 +4,14 @@
 # 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/.
 
 HOST_SOURCES += [
     'dump_syms.cc',
 ]
   
 HOST_PROGRAM = 'dump_syms'
+
+LOCAL_INCLUDES += [
+    '../../..',
+    '../../../common/solaris',
+]
+
--- a/toolkit/crashreporter/injector/Makefile.in
+++ b/toolkit/crashreporter/injector/Makefile.in
@@ -2,14 +2,13 @@
 # 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/.
 
 STL_FLAGS =
 MOZ_GLUE_LDFLAGS =
 
 include $(topsrcdir)/config/rules.mk
 
-LOCAL_INCLUDES += -I$(topsrcdir)/toolkit/crashreporter/google-breakpad/src
 ifndef GNU_CC
 LDFLAGS += -ENTRY:DummyEntryPoint
 else
 LDFLAGS += -Wl,-e,_DummyEntryPoint@12
 endif
--- a/toolkit/crashreporter/injector/moz.build
+++ b/toolkit/crashreporter/injector/moz.build
@@ -9,9 +9,14 @@ SOURCES += [
 ]
 
 LIBRARY_NAME = 'breakpadinjector'
 
 include('/ipc/chromium/chromium-config.mozbuild')
 
 FORCE_SHARED_LIB = True
 
+LOCAL_INCLUDES += [
+    '/toolkit/crashreporter/google-breakpad/src',
+]
+
+
 USE_STATIC_LIBS = True
--- a/toolkit/crashreporter/moz.build
+++ b/toolkit/crashreporter/moz.build
@@ -92,9 +92,14 @@ if CONFIG['OS_TARGET'] == 'Android':
 
 if CONFIG['OS_ARCH'] == 'SunOS':
     # there's no define for this normally
     DEFINES['XP_SOLARIS'] = True
 
 DEFINES['UNICODE'] = True
 DEFINES['_UNICODE'] = True
 
-JAR_MANIFESTS += ['jar.mn']
\ No newline at end of file
+JAR_MANIFESTS += ['jar.mn']
+
+LOCAL_INCLUDES += [
+    'google-breakpad/src',
+]
+
--- a/toolkit/crashreporter/test/Makefile.in
+++ b/toolkit/crashreporter/test/Makefile.in
@@ -1,16 +1,13 @@
 #
 # 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/.
 
-LOCAL_INCLUDES += \
-  -I$(srcdir)/../google-breakpad/src/ \
-  $(NULL)
 EXTRA_DSO_LDOPTS += $(LIBS_DIR) $(MOZ_COMPONENT_LIBS) $(XPCOM_GLUE_LDOPTS)
 
 UNIT_FILES = $(SHARED_LIBRARY) $(EXTRA_JS_MODULES)
 UNIT_DEST = $(DEPTH)/_tests/xpcshell/$(relativesrcdir)/unit/
 INSTALL_TARGETS += UNIT
 
 UNIT_IPC_FILES = $(UNIT_FILES)
 UNIT_IPC_DEST = $(DEPTH)/_tests/xpcshell/$(relativesrcdir)/unit_ipc/
--- a/toolkit/crashreporter/test/moz.build
+++ b/toolkit/crashreporter/test/moz.build
@@ -27,8 +27,13 @@ FORCE_SHARED_LIB = True
 
 DEFINES['SHARED_LIBRARY'] = '%s%s%s' % (
     CONFIG['DLL_PREFIX'],
     LIBRARY_NAME,
     CONFIG['DLL_SUFFIX']
 )
 
 DEFINES['NOMINMAX'] = True
+
+LOCAL_INCLUDES += [
+    '../google-breakpad/src/',
+]
+
--- a/toolkit/devtools/pretty-fast/pretty-fast.js
+++ b/toolkit/devtools/pretty-fast/pretty-fast.js
@@ -189,17 +189,17 @@
     "(": true
   };
 
   /**
    * Determines if Automatic Semicolon Insertion (ASI) occurs between these
    * tokens.
    *
    * @param Object token
-   *        The token we want to determine if it is an array literal.
+   *        The current token.
    * @param Object lastToken
    *        The last token we added to the pretty printed results.
    *
    * @returns Boolean
    *          True if we believe ASI occurs.
    */
   function isASI(token, lastToken) {
     if (!lastToken) {
@@ -213,16 +213,40 @@
     }
     if (PREVENT_ASI_BEFORE_TOKENS[token.type.type || token.type.keyword]) {
       return false;
     }
     return true;
   }
 
   /**
+   * Determine if we have encountered a getter or setter.
+   *
+   * @param Object token
+   *        The current token. If this is a getter or setter, it would be the
+   *        property name.
+   * @param Object lastToken
+   *        The last token we added to the pretty printed results. If this is a
+   *        getter or setter, it would be the `get` or `set` keyword
+   *        respectively.
+   * @param Array stack
+   *        The stack of open parens/curlies/brackets/etc.
+   *
+   * @returns Boolean
+   *          True if this is a getter or setter.
+   */
+  function isGetterOrSetter(token, lastToken, stack) {
+    return stack[stack.length - 1] == "{"
+      && lastToken
+      && lastToken.type.type == "name"
+      && (lastToken.value == "get" || lastToken.value == "set")
+      && token.type.type == "name";
+  }
+
+  /**
    * Determine if we should add a newline after the given token.
    *
    * @param Object token
    *        The token we are looking at.
    * @param Array stack
    *        The stack of open parens/curlies/brackets/etc.
    *
    * @returns Boolean
@@ -354,22 +378,23 @@
    * @param Array stack
    *        The stack of open curlies, brackets, etc.
    */
   function prependWhiteSpace(token, lastToken, addedNewline, write, options,
                              indentLevel, stack) {
     var ttk = token.type.keyword;
     var ttt = token.type.type;
     var newlineAdded = addedNewline;
+    var ltt = lastToken ? lastToken.type.type : null;
 
     // Handle whitespace and newlines after "}" here instead of in
     // `isLineDelimiter` because it is only a line delimiter some of the
     // time. For example, we don't want to put "else if" on a new line after
     // the first if's block.
-    if (lastToken && lastToken.type.type == "}") {
+    if (lastToken && ltt == "}") {
       if (ttk == "while" && stack[stack.length - 1] == "do") {
         write(" ",
               lastToken.startLoc.line,
               lastToken.startLoc.column);
       } else if (ttk == "else" ||
                  ttk == "catch" ||
                  ttk == "finally") {
         write(" ",
@@ -382,23 +407,29 @@
                  ttt != ".") {
         write("\n",
               lastToken.startLoc.line,
               lastToken.startLoc.column);
         newlineAdded = true;
       }
     }
 
+    if (isGetterOrSetter(token, lastToken, stack)) {
+      write(" ",
+            lastToken.startLoc.line,
+            lastToken.startLoc.column);
+    }
+
     if (ttt == ":" && stack[stack.length - 1] == "?") {
       write(" ",
             lastToken.startLoc.line,
             lastToken.startLoc.column);
     }
 
-    if (lastToken && lastToken.type.type != "}" && ttk == "else") {
+    if (lastToken && ltt != "}" && ttk == "else") {
       write(" ",
             lastToken.startLoc.line,
             lastToken.startLoc.column);
     }
 
     function ensureNewline() {
       if (!newlineAdded) {
         write("\n",
--- a/toolkit/devtools/pretty-fast/tests/unit/test.js
+++ b/toolkit/devtools/pretty-fast/tests/unit/test.js
@@ -1,16 +1,17 @@
 /*
  * Copyright 2013 Mozilla Foundation and contributors
  * Licensed under the New BSD license. See LICENSE.md or:
  * http://opensource.org/licenses/BSD-2-Clause
  */
 var prettyFast = this.prettyFast || require("./pretty-fast");
 
 var testCases = [
+
   {
     name: "Simple function",
     input: "function foo() { bar(); }",
     output: "function foo() {\n" +
             "  bar();\n" +
             "}\n",
     mappings: [
       // function foo() {
@@ -426,16 +427,29 @@ var testCases = [
 
   {
     name: "Non-ASI new",
     input: "new\n" +
            "F()",
     output: "new F()\n"
   },
 
+  {
+    name: "Getter and setter literals",
+    input: "var obj={get foo(){return this._foo},set foo(v){this._foo=v}}",
+    output: "var obj = {\n" +
+            "  get foo() {\n" +
+            "    return this._foo\n" +
+            "  },\n" +
+            "  set foo(v) {\n" +
+            "    this._foo = v\n" +
+            "  }\n" +
+            "}\n"
+  },
+
 ];
 
 var sourceMap = this.sourceMap || require("source-map");
 
 function run_test() {
   testCases.forEach(function (test) {
     console.log(test.name);
 
@@ -463,11 +477,12 @@ function run_test() {
     }
   });
   console.log("✓ All tests pass!");
 }
 
 // Only run the tests if this is node and we are running this file
 // directly. (Firefox's test runner will import this test file, and then call
 // run_test itself.)
-if (typeof exports == "object") {
+if (typeof require == "function" && typeof module == "object"
+    && require.main === module) {
   run_test();
 }
--- a/toolkit/mozapps/update/tests/Makefile.in
+++ b/toolkit/mozapps/update/tests/Makefile.in
@@ -60,22 +60,16 @@ chrome-data_DEST    := $(CHROMETESTROOT)
 chrome-data_FILES   := $(addprefix $(srcdir)/data/,$(_CHROME_DATA))
 
 INI_TEST_FILES = \
   TestAUSReadStrings1.ini \
   TestAUSReadStrings2.ini \
   TestAUSReadStrings3.ini \
   $(NULL)
 
-LOCAL_INCLUDES += \
-  -I$(srcdir) \
-  -I$(topsrcdir)/toolkit/mozapps/update \
-  -I$(topsrcdir)/toolkit/mozapps/update/common \
-  $(NULL)
-
 MOZ_WINCONSOLE = 1
 
 ifeq ($(OS_ARCH),WINNT)
 LIBS += $(call EXPAND_LIBNAME_PATH,updatecommon-standalone,../common-standalone)
 else
 LIBS += $(call EXPAND_LIBNAME_PATH,updatecommon,../common)
 endif
 
--- a/toolkit/mozapps/update/tests/moz.build
+++ b/toolkit/mozapps/update/tests/moz.build
@@ -17,16 +17,21 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'andr
         'TestAUSHelper',
         'TestAUSReadStrings',
     ]
 
     SOURCES += [
         '%s.cpp' % s for s in SIMPLE_PROGRAMS
     ]
 
+    LOCAL_INCLUDES += [
+        '/toolkit/mozapps/update',
+        '/toolkit/mozapps/update/common',
+    ]
+
 for var in ('MOZ_APP_NAME', 'MOZ_APP_BASENAME', 'MOZ_APP_DISPLAYNAME',
             'MOZ_APP_VENDOR', 'BIN_SUFFIX', 'MOZ_DEBUG'):
     DEFINES[var] = CONFIG[var]
 
 DEFINES['NS_NO_XPCOM'] = True
 
 if CONFIG['MOZ_MAINTENANCE_SERVICE']:
     DEFINES['MOZ_MAINTENANCE_SERVICE'] = CONFIG['MOZ_MAINTENANCE_SERVICE']
--- a/toolkit/mozapps/update/updater/Makefile.in
+++ b/toolkit/mozapps/update/updater/Makefile.in
@@ -2,21 +2,16 @@
 # 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/.
 
 # Don't link the updater against libmozglue. See bug 687139
 MOZ_GLUE_LDFLAGS =
 MOZ_GLUE_PROGRAM_LDFLAGS =
 
-LOCAL_INCLUDES += \
-  -I$(srcdir)/../common \
-  -I$(topsrcdir)/xpcom/glue \
-  $(NULL)
-
 ifeq ($(OS_ARCH),WINNT)
 LIBS += $(call EXPAND_LIBNAME_PATH,updatecommon-standalone,../common-standalone)
 else
 LIBS += $(call EXPAND_LIBNAME_PATH,updatecommon,../common)
 endif
 
 LIBS += \
   $(call EXPAND_LIBNAME_PATH,mar,$(DEPTH)/modules/libmar/src) \
@@ -77,21 +72,16 @@ libs::
 	rsync -a -C --exclude '*.in' $(srcdir)/macbuild/Contents $(DIST)/bin/updater.app 
 	sed -e 's/%APP_NAME%/$(MOZ_APP_DISPLAYNAME)/' $(srcdir)/macbuild/Contents/Resources/English.lproj/InfoPlist.strings.in | \
 	  iconv -f UTF-8 -t UTF-16 > $(DIST)/bin/updater.app/Contents/Resources/English.lproj/InfoPlist.strings
 	$(NSINSTALL) -D $(DIST)/bin/updater.app/Contents/MacOS
 	$(NSINSTALL) $(DIST)/bin/updater $(DIST)/bin/updater.app/Contents/MacOS
 	rm -f $(DIST)/bin/updater
 endif
 
-ifeq (,$(filter-out WINNT,$(OS_ARCH)))
-# Pick up nsWindowsRestart.cpp
-LOCAL_INCLUDES += -I$(topsrcdir)/toolkit/xre
-endif
-
 ifeq ($(OS_ARCH),WINNT)
 EXTRA_LIBS += $(call EXPAND_LIBNAME,crypt32)
 EXTRA_LIBS += $(call EXPAND_LIBNAME,advapi32)
 endif
 
 CXXFLAGS += $(MOZ_BZ2_CFLAGS)
 
 ifneq (,$(filter beta release esr,$(MOZ_UPDATE_CHANNEL)))
--- a/toolkit/mozapps/update/updater/moz.build
+++ b/toolkit/mozapps/update/updater/moz.build
@@ -19,16 +19,21 @@ if CONFIG['OS_ARCH'] == 'WINNT':
         'loaddlls.cpp',
         'progressui_win.cpp',
         'win_dirent.cpp',
     ]
     DEFINES['UNICODE'] = True
     DEFINES['_UNICODE'] = True
     USE_STATIC_LIBS = True
 
+    # Pick up nsWindowsRestart.cpp
+    LOCAL_INCLUDES += [
+        '/toolkit/xre',
+    ]
+
 if CONFIG['MOZ_ENABLE_GTK']:
     have_progressui = 1
     SOURCES += [
         'progressui_gtk.cpp',
     ]
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
     have_progressui = 1
@@ -49,13 +54,19 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'coco
         'launchchild_osx.mm',
         'progressui_osx.mm',
     ]
 
 DEFINES['NS_NO_XPCOM'] = True
 for var in ('MAR_CHANNEL_ID', 'MOZ_APP_VERSION'):
     DEFINES[var] = '"%s"' % CONFIG[var]
 
+LOCAL_INCLUDES += [
+    '../common',
+    '/xpcom/glue',
+]
+
+
 DELAYLOAD_DLLS += [
     'crypt32.dll',
     'userenv.dll',
     'wsock32.dll',
 ]
--- a/toolkit/system/gnome/Makefile.in
+++ b/toolkit/system/gnome/Makefile.in
@@ -8,18 +8,16 @@ EXTRA_DSO_LDOPTS += \
 		$(NSPR_LIBS) \
 		$(MOZ_GCONF_LIBS) \
 		$(MOZ_GNOMEVFS_LIBS) \
 		$(GLIB_LIBS) \
 		$(MOZ_GIO_LIBS) \
 		$(MOZ_DBUS_GLIB_LIBS) \
 		$(NULL)
 
-LOCAL_INCLUDES += -I$(topsrcdir)/toolkit/components/build/
-
 include $(topsrcdir)/config/rules.mk
 
 CXXFLAGS += \
 	$(MOZ_GCONF_CFLAGS) \
 	$(MOZ_GNOMEVFS_CFLAGS) \
 	$(MOZ_GIO_CFLAGS) \
 	$(GLIB_CFLAGS) \
 	$(MOZ_DBUS_GLIB_CFLAGS) \
--- a/toolkit/system/gnome/moz.build
+++ b/toolkit/system/gnome/moz.build
@@ -25,8 +25,13 @@ if CONFIG['MOZ_ENABLE_GIO']:
     ]
 
 LIBRARY_NAME = 'mozgnome'
 
 FAIL_ON_WARNINGS = True
 IS_COMPONENT = True
 
 FORCE_SHARED_LIB = True
+
+LOCAL_INCLUDES += [
+    '/toolkit/components/build/',
+]
+
--- a/toolkit/xre/Makefile.in
+++ b/toolkit/xre/Makefile.in
@@ -5,32 +5,18 @@
 # 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_RCS_MK=1
 include $(topsrcdir)/config/makefiles/makeutils.mk
 
 milestone_txt = $(topsrcdir)/config/milestone.txt
 
-ifdef MOZ_ENABLE_XREMOTE
-LOCAL_INCLUDES += -I$(topsrcdir)/widget/xremoteclient
-endif
-
 include $(topsrcdir)/config/rules.mk
 
-LOCAL_INCLUDES += \
-  -I$(topsrcdir)/testing/gtest/mozilla \
-  -I$(srcdir)/../profile \
-  -I$(topsrcdir)/dom/ipc \
-  -I$(topsrcdir)/toolkit/crashreporter \
-  -I$(topsrcdir)/dom/base \
-  -I$(topsrcdir)/xpcom/build \
-  -I$(topsrcdir)/config \
-  $(NULL)
-
 CXXFLAGS += $(TK_CFLAGS) $(MOZ_DBUS_CFLAGS) $(MOZ_DBUS_GLIB_CFLAGS)
 
 ifdef MOZ_WIDGET_GTK
 CXXFLAGS += $(MOZ_PANGO_CFLAGS)
 endif
 
 # Should version be optional or required ?
 TOOLKIT_EM_VERSION=$(shell $(PERL) $(topsrcdir)/config/milestone.pl --topsrcdir=$(topsrcdir))
--- a/toolkit/xre/moz.build
+++ b/toolkit/xre/moz.build
@@ -138,8 +138,24 @@ if CONFIG['OS_ARCH'] == 'Linux' and 'lib
 
 DEFINES['GRE_MILESTONE'] = CONFIG['GRE_MILESTONE']
 
 for var in ('APP_VERSION', 'APP_ID'):
     DEFINES[var] = CONFIG['MOZ_%s' % var]
 
 if CONFIG['MOZILLA_OFFICIAL']:
     DEFINES['MOZILLA_OFFICIAL'] = True
+
+LOCAL_INCLUDES += [
+    '../profile',
+    '/config',
+    '/dom/base',
+    '/dom/ipc',
+    '/testing/gtest/mozilla',
+    '/toolkit/crashreporter',
+    '/xpcom/build',
+]
+
+if CONFIG['MOZ_ENABLE_XREMOTE']:
+    LOCAL_INCLUDES += [
+        '/widget/xremoteclient',
+    ]
+
--- a/toolkit/xre/test/win/Makefile.in
+++ b/toolkit/xre/test/win/Makefile.in
@@ -1,20 +1,14 @@
 # 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/.
 
 OS_LIBS += $(call EXPAND_LIBNAME,comctl32 ws2_32 shell32)
 
-LOCAL_INCLUDES += \
-  -I$(srcdir) \
-  -I$(topsrcdir)/toolkit/xre \
-  -I$(topsrcdir)/config \
-  $(NULL)
-
 MOZ_WINCONSOLE = 1
 
 include $(topsrcdir)/config/rules.mk
 
 libs:: TestXREMakeCommandLineWin.ini
 	$(INSTALL) $^ $(FINAL_TARGET)/
 
 check::
--- a/toolkit/xre/test/win/moz.build
+++ b/toolkit/xre/test/win/moz.build
@@ -10,9 +10,15 @@ SIMPLE_PROGRAMS = [
 ]
 
 SOURCES += [
     '%s.cpp' % s for s in SIMPLE_PROGRAMS
 ]
 
 DEFINES['NS_NO_XPCOM'] = True
 
+LOCAL_INCLUDES += [
+    '/config',
+    '/toolkit/xre',
+]
+
+
 USE_STATIC_LIBS = True
--- a/uriloader/exthandler/Makefile.in
+++ b/uriloader/exthandler/Makefile.in
@@ -1,22 +1,13 @@
 #
 # 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/.
 
-LOCAL_INCLUDES = -I$(srcdir)
-
-LOCAL_INCLUDES += -I$(topsrcdir)/dom/base \
-            -I$(topsrcdir)/dom/events \
-            -I$(topsrcdir)/dom/ipc \
-            -I$(topsrcdir)/content/base/src \
-            -I$(topsrcdir)/netwerk/base/src \
-            -I$(topsrcdir)/netwerk/protocol/http
-
 ifeq ($(MOZ_WIDGET_TOOLKIT),windows)
 LOCAL_INCLUDES += -I$(srcdir)/win
 endif
 
 ifdef MOZ_ENABLE_DBUS
 OS_INCLUDES   += $(TK_CFLAGS) $(MOZ_DBUS_CFLAGS)
 endif
 
--- a/uriloader/exthandler/moz.build
+++ b/uriloader/exthandler/moz.build
@@ -131,8 +131,18 @@ IPDL_SOURCES += [
     'PExternalHelperApp.ipdl',
 ]
 
 FAIL_ON_WARNINGS = True
 
 include('/ipc/chromium/chromium-config.mozbuild')
 
 FINAL_LIBRARY = 'xul'
+
+LOCAL_INCLUDES += [
+    '/content/base/src',
+    '/dom/base',
+    '/dom/events',
+    '/dom/ipc',
+    '/netwerk/base/src',
+    '/netwerk/protocol/http',
+]
+
deleted file mode 100644
--- a/uriloader/prefetch/Makefile.in
+++ /dev/null
@@ -1,13 +0,0 @@
-#
-# 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/.
-
-LOCAL_INCLUDES = \
-		-I$(topsrcdir)/content/base/src \
-		-I$(topsrcdir)/dom/events \
-		$(NULL)
-
-include $(topsrcdir)/config/rules.mk
-
-# vim: ts=4 sw=4 noexpandtab
--- a/uriloader/prefetch/moz.build
+++ b/uriloader/prefetch/moz.build
@@ -37,8 +37,14 @@ IPDL_SOURCES += [
     'POfflineCacheUpdate.ipdl',
 ]
 
 FAIL_ON_WARNINGS = True
 
 include('/ipc/chromium/chromium-config.mozbuild')
 
 FINAL_LIBRARY = 'xul'
+
+LOCAL_INCLUDES += [
+    '/content/base/src',
+    '/dom/events',
+]
+
--- a/xulrunner/app/Makefile.in
+++ b/xulrunner/app/Makefile.in
@@ -5,23 +5,16 @@
 
 PREF_JS_EXPORTS = $(srcdir)/xulrunner.js
 GARBAGE += $(addprefix $(DIST)/bin/defaults/pref/,xulrunner.js)
 
 DEFINES += -DAB_CD=$(AB_CD)
 
 STL_FLAGS=
 
-LOCAL_INCLUDES += \
-  -I$(topsrcdir)/toolkit/xre \
-  -I$(topsrcdir)/toolkit/profile \
-  -I$(topsrcdir)/xpcom/base \
-  -I$(topsrcdir)/xpcom/build \
-  $(NULL)
-
 ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 TK_LIBS := -framework Cocoa $(TK_LIBS)
 endif
 
 LIBS += \
   $(XPCOM_STANDALONE_GLUE_LDOPTS) \
   $(NULL)
 
--- a/xulrunner/app/moz.build
+++ b/xulrunner/app/moz.build
@@ -12,8 +12,16 @@ SOURCES += [
     'nsXULRunnerApp.cpp',
 ]
 
 DEFINES['XULRUNNER_PROGNAME'] = '"xulrunner"'
 DEFINES['XPCOM_GLUE'] = True
 
 if CONFIG['TARGET_XPCOM_ABI']:
     DEFINES['TARGET_XPCOM_ABI'] = '"%s"' % CONFIG['TARGET_XPCOM_ABI']
+
+LOCAL_INCLUDES += [
+    '/toolkit/profile',
+    '/toolkit/xre',
+    '/xpcom/base',
+    '/xpcom/build',
+]
+
--- a/xulrunner/stub/Makefile.in
+++ b/xulrunner/stub/Makefile.in
@@ -1,20 +1,15 @@
 # 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/.
 
 # Don't create a dependency on mozglue
 MOZ_GLUE_LDFLAGS =
 
-LOCAL_INCLUDES = \
-  -I$(topsrcdir)/xpcom/build \
-  -I$(topsrcdir)/xpcom/base \
-  $(NULL)
-
 STL_FLAGS=
 
 LIBS = \
   $(XPCOM_STANDALONE_STATICRUNTIME_GLUE_LDOPTS) \
   $(NULL)
 
 # Need to link with CoreFoundation on Mac
 ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
--- a/xulrunner/stub/moz.build
+++ b/xulrunner/stub/moz.build
@@ -14,10 +14,16 @@ SOURCES += [
     'nsXULStub.cpp',
 ]
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
     FINAL_TARGET = 'dist/XUL.framework/Versions/%(MOZILLA_VERSION)s' % CONFIG
 
 DEFINES['XPCOM_GLUE'] = True
 
+LOCAL_INCLUDES += [
+    '/xpcom/base',
+    '/xpcom/build',
+]
+
+
 # Statically link against the RTL on windows
 USE_STATIC_LIBS = True