diff --git a/accessible/atk/InterfaceInitFuncs.h b/accessible/atk/InterfaceInitFuncs.h index 20cab6da9e..805001e822 100644 --- a/accessible/atk/InterfaceInitFuncs.h +++ b/accessible/atk/InterfaceInitFuncs.h @@ -17,8 +17,6 @@ class AccessibleWrap; } // namespace a11y } // namespace mozilla -struct MaiUtilClass; - extern "C" { void actionInterfaceInitCB(AtkActionIface* aIface); void componentInterfaceInitCB(AtkComponentIface* aIface); diff --git a/accessible/base/nsCoreUtils.cpp b/accessible/base/nsCoreUtils.cpp index a564f7b65e..2b427e39ef 100644 --- a/accessible/base/nsCoreUtils.cpp +++ b/accessible/base/nsCoreUtils.cpp @@ -300,7 +300,7 @@ nsCoreUtils::ScrollFrameToPoint(nsIFrame *aScrollableFrame, return; nsPoint point = - aPoint.ToAppUnits(aFrame->PresContext()->AppUnitsPerDevPixel()); + ToAppUnits(aPoint, aFrame->PresContext()->AppUnitsPerDevPixel()); nsRect frameRect = aFrame->GetScreenRectInAppUnits(); nsPoint deltaPoint(point.x - frameRect.x, point.y - frameRect.y); diff --git a/accessible/generic/Accessible.h b/accessible/generic/Accessible.h index f9d909de42..6d9a9cc271 100644 --- a/accessible/generic/Accessible.h +++ b/accessible/generic/Accessible.h @@ -15,15 +15,14 @@ #include "nsString.h" #include "nsTArray.h" #include "nsRefPtrHashtable.h" +#include "nsRect.h" struct nsRoleMapEntry; struct nsRect; class nsIFrame; class nsIAtom; -struct nsIntRect; class nsIPersistentProperties; -class nsView; namespace mozilla { namespace a11y { @@ -39,7 +38,6 @@ class HTMLLIAccessible; class HyperTextAccessible; class ImageAccessible; class KeyBinding; -class MathMLAccessible; class ProxyAccessible; class Relation; class RootAccessible; diff --git a/accessible/generic/DocAccessible.h b/accessible/generic/DocAccessible.h index 4d0a43651f..ad7fd85f98 100644 --- a/accessible/generic/DocAccessible.h +++ b/accessible/generic/DocAccessible.h @@ -23,8 +23,6 @@ class nsAccessiblePivot; -class nsIScrollableView; - const uint32_t kDefaultCacheLength = 128; namespace mozilla { diff --git a/accessible/generic/HyperTextAccessible.cpp b/accessible/generic/HyperTextAccessible.cpp index 7fa9e26d83..cf683c641a 100644 --- a/accessible/generic/HyperTextAccessible.cpp +++ b/accessible/generic/HyperTextAccessible.cpp @@ -977,7 +977,7 @@ HyperTextAccessible::OffsetAtPoint(int32_t aX, int32_t aY, uint32_t aCoordType) nsPresContext* presContext = mDoc->PresContext(); nsPoint coordsInAppUnits = - coords.ToAppUnits(presContext->AppUnitsPerDevPixel()); + ToAppUnits(coords, presContext->AppUnitsPerDevPixel()); nsRect frameScreenRect = hyperFrame->GetScreenRectInAppUnits(); if (!frameScreenRect.Contains(coordsInAppUnits.x, coordsInAppUnits.y)) @@ -1505,7 +1505,7 @@ HyperTextAccessible::ScrollSubstringToPoint(int32_t aStartOffset, nsPresContext* presContext = frame->PresContext(); nsPoint coordsInAppUnits = - coords.ToAppUnits(presContext->AppUnitsPerDevPixel()); + ToAppUnits(coords, presContext->AppUnitsPerDevPixel()); bool initialScrolled = false; nsIFrame *parentFrame = frame; diff --git a/accessible/generic/ImageAccessible.h b/accessible/generic/ImageAccessible.h index c631882370..f2324ae4cd 100644 --- a/accessible/generic/ImageAccessible.h +++ b/accessible/generic/ImageAccessible.h @@ -8,8 +8,6 @@ #include "BaseAccessibles.h" -class nsGenericHTMLElement; - namespace mozilla { namespace a11y { diff --git a/accessible/html/HTMLSelectAccessible.h b/accessible/html/HTMLSelectAccessible.h index 2bdd6e1d9a..42a80330a3 100644 --- a/accessible/html/HTMLSelectAccessible.h +++ b/accessible/html/HTMLSelectAccessible.h @@ -8,8 +8,6 @@ #include "HTMLFormControlAccessible.h" -class nsIMutableArray; - namespace mozilla { namespace a11y { diff --git a/accessible/html/HTMLTableAccessible.h b/accessible/html/HTMLTableAccessible.h index 07ad6864a0..47f6602cb7 100644 --- a/accessible/html/HTMLTableAccessible.h +++ b/accessible/html/HTMLTableAccessible.h @@ -10,7 +10,6 @@ #include "TableAccessible.h" #include "TableCellAccessible.h" -class nsITableLayout; class nsITableCellLayout; namespace mozilla { diff --git a/accessible/interfaces/nsIAccessibilityService.h b/accessible/interfaces/nsIAccessibilityService.h index 6f3e128a81..2eca2578a8 100644 --- a/accessible/interfaces/nsIAccessibilityService.h +++ b/accessible/interfaces/nsIAccessibilityService.h @@ -20,11 +20,7 @@ class Accessible; } // namespace a11y } // namespace mozilla -class nsINode; -class nsIContent; -class nsIFrame; class nsIPresShell; -class nsPluginFrame; // 0e7e6879-854b-4260-bc6e-525b5fb5cf34 #define NS_IACCESSIBILITYSERVICE_IID \ diff --git a/accessible/ipc/PDocAccessible.ipdl b/accessible/ipc/PDocAccessible.ipdl index 689879254d..eddd7e6442 100644 --- a/accessible/ipc/PDocAccessible.ipdl +++ b/accessible/ipc/PDocAccessible.ipdl @@ -8,9 +8,9 @@ include protocol PContent; include "mozilla/GfxMessageUtils.h"; -using struct nsIntPoint from "nsRect.h"; -using struct nsIntRect from "nsRect.h"; +using nsIntRect from "nsRect.h"; using mozilla::gfx::IntSize from "mozilla/gfx/Point.h"; +using mozilla::gfx::IntPoint from "mozilla/gfx/Point.h"; namespace mozilla { namespace a11y { @@ -135,7 +135,7 @@ child: prio(high) sync PasteText(uint64_t aID, int32_t aPosition) returns(bool aValid); - prio(high) sync ImagePosition(uint64_t aID, uint32_t aCoordType) returns(nsIntPoint aRetVal); + prio(high) sync ImagePosition(uint64_t aID, uint32_t aCoordType) returns(IntPoint aRetVal); prio(high) sync ImageSize(uint64_t aID) returns(IntSize aRetVal); prio(high) sync StartOffset(uint64_t aID) returns(uint32_t aRetVal, bool aOk); diff --git a/accessible/mac/RootAccessibleWrap.h b/accessible/mac/RootAccessibleWrap.h index d92034ed2c..ad225399ac 100644 --- a/accessible/mac/RootAccessibleWrap.h +++ b/accessible/mac/RootAccessibleWrap.h @@ -15,8 +15,6 @@ namespace mozilla { namespace a11y { -struct objc_class; - class RootAccessibleWrap : public RootAccessible { public: diff --git a/accessible/windows/msaa/nsWinUtils.h b/accessible/windows/msaa/nsWinUtils.h index 8b17df2e03..ac3a8b699e 100644 --- a/accessible/windows/msaa/nsWinUtils.h +++ b/accessible/windows/msaa/nsWinUtils.h @@ -14,7 +14,6 @@ #include "nsCOMPtr.h" #include "nsRefPtrHashtable.h" -class nsIArray; class nsIContent; namespace mozilla { diff --git a/accessible/xul/XULListboxAccessible.h b/accessible/xul/XULListboxAccessible.h index 42e2d39616..e90f88acec 100644 --- a/accessible/xul/XULListboxAccessible.h +++ b/accessible/xul/XULListboxAccessible.h @@ -14,8 +14,6 @@ #include "XULMenuAccessible.h" #include "XULSelectControlAccessible.h" -class nsIWeakReference; - namespace mozilla { namespace a11y { diff --git a/docshell/base/IHistory.h b/docshell/base/IHistory.h index 9d144f324a..b1f5bb9831 100644 --- a/docshell/base/IHistory.h +++ b/docshell/base/IHistory.h @@ -10,7 +10,6 @@ #include "nsISupports.h" class nsIURI; -class nsString; namespace mozilla { diff --git a/docshell/base/LoadContext.h b/docshell/base/LoadContext.h index 1ab5cba414..22fd28583d 100644 --- a/docshell/base/LoadContext.h +++ b/docshell/base/LoadContext.h @@ -14,8 +14,6 @@ #include "nsIInterfaceRequestor.h" #include "nsILoadContext.h" -class mozIApplication; - namespace mozilla { /** diff --git a/docshell/base/nsDocShell.h b/docshell/base/nsDocShell.h index 18a084e9f7..d74a019e29 100644 --- a/docshell/base/nsDocShell.h +++ b/docshell/base/nsDocShell.h @@ -88,7 +88,6 @@ class nsIURIFixup; class nsIURILoader; class nsIWebBrowserFind; class nsIWidget; -class ProfilerMarkerTracing; /* load commands were moved to nsIDocShell.h */ /* load types were moved to nsDocShellLoadTypes.h */ diff --git a/docshell/base/nsIContentViewer.idl b/docshell/base/nsIContentViewer.idl index c3d8624739..9f774fabfa 100644 --- a/docshell/base/nsIContentViewer.idl +++ b/docshell/base/nsIContentViewer.idl @@ -14,9 +14,9 @@ interface nsIPrintSettings; %{ C++ #include "nsTArray.h" +#include "nsRect.h" class nsIWidget; -struct nsIntRect; class nsIPresShell; class nsPresContext; class nsView; diff --git a/docshell/base/nsILinkHandler.h b/docshell/base/nsILinkHandler.h index 862a6bcb52..797b3fe134 100644 --- a/docshell/base/nsILinkHandler.h +++ b/docshell/base/nsILinkHandler.h @@ -13,7 +13,6 @@ class nsIContent; class nsIDocShell; class nsIInputStream; class nsIRequest; -class nsString; // Interface ID for nsILinkHandler #define NS_ILINKHANDLER_IID \ diff --git a/docshell/shistory/public/nsISHEntry.idl b/docshell/shistory/public/nsISHEntry.idl index f8b8187947..aaafe6c052 100644 --- a/docshell/shistory/public/nsISHEntry.idl +++ b/docshell/shistory/public/nsISHEntry.idl @@ -22,7 +22,7 @@ interface nsIStructuredCloneContainer; interface nsIBFCacheEntry; %{C++ -struct nsIntRect; +#include "nsRect.h" class nsDocShellEditorData; class nsSHEntryShared; %} diff --git a/dom/animation/Animation.cpp b/dom/animation/Animation.cpp index 7626a66824..577e8a341b 100644 --- a/dom/animation/Animation.cpp +++ b/dom/animation/Animation.cpp @@ -282,6 +282,18 @@ Animation::GetAnimationOfProperty(nsCSSProperty aProperty) const return nullptr; } +bool +Animation::HasAnimationOfProperties(const nsCSSProperty* aProperties, + size_t aPropertyCount) const +{ + for (size_t i = 0; i < aPropertyCount; i++) { + if (HasAnimationOfProperty(aProperties[i])) { + return true; + } + } + return false; +} + void Animation::ComposeStyle(nsRefPtr& aStyleRule, nsCSSPropertySet& aSetProperties) diff --git a/dom/animation/Animation.h b/dom/animation/Animation.h index d98f892381..0fe71ad68d 100644 --- a/dom/animation/Animation.h +++ b/dom/animation/Animation.h @@ -116,8 +116,9 @@ public: uint32_t GetSteps() const { return mSteps; } bool operator==(const ComputedTimingFunction& aOther) const { return mType == aOther.mType && - mTimingFunction == aOther.mTimingFunction && - mSteps == aOther.mSteps; + (mType == nsTimingFunction::Function ? + mTimingFunction == aOther.mTimingFunction : + mSteps == aOther.mSteps); } bool operator!=(const ComputedTimingFunction& aOther) const { return !(*this == aOther); @@ -248,7 +249,7 @@ public: return mTiming; } - const nsString& Name() const { + virtual const nsString& Name() const { return mName; } @@ -314,6 +315,8 @@ public: bool HasAnimationOfProperty(nsCSSProperty aProperty) const { return GetAnimationOfProperty(aProperty) != nullptr; } + bool HasAnimationOfProperties(const nsCSSProperty* aProperties, + size_t aPropertyCount) const; const InfallibleTArray& Properties() const { return mProperties; } diff --git a/dom/animation/test/css-transitions/test_animation-effect-name.html b/dom/animation/test/css-transitions/test_animation-effect-name.html index 637e995fee..b764723cfc 100644 --- a/dom/animation/test/css-transitions/test_animation-effect-name.html +++ b/dom/animation/test/css-transitions/test_animation-effect-name.html @@ -16,8 +16,9 @@ test(function(t) { div.style.transition = 'all 100s'; div.style.left = '100px'; - assert_equals(div.getAnimations()[0].source.effect.name, '', - 'Animation effects for transitions have an empty name'); + assert_equals(div.getAnimations()[0].source.effect.name, 'left', + 'The name for the transitions corresponds to the property ' + + 'being transitioned'); }, 'Effect name for transitions'); diff --git a/dom/base/FragmentOrElement.cpp b/dom/base/FragmentOrElement.cpp index 8578a1e674..63d727c0a2 100644 --- a/dom/base/FragmentOrElement.cpp +++ b/dom/base/FragmentOrElement.cpp @@ -456,7 +456,7 @@ FragmentOrElement::Children() if (!slots->mChildrenList) { slots->mChildrenList = new nsContentList(this, kNameSpaceID_Wildcard, - nsGkAtoms::_asterix, nsGkAtoms::_asterix, + nsGkAtoms::_asterisk, nsGkAtoms::_asterisk, false); } diff --git a/dom/base/nsContentList.cpp b/dom/base/nsContentList.cpp index 2f5b08e70f..bbdd806f39 100644 --- a/dom/base/nsContentList.cpp +++ b/dom/base/nsContentList.cpp @@ -405,8 +405,8 @@ nsContentList::nsContentList(nsINode* aRootNode, mFuncMayDependOnAttr(false) { NS_ASSERTION(mRootNode, "Must have root"); - if (nsGkAtoms::_asterix == mHTMLMatchAtom) { - NS_ASSERTION(mXMLMatchAtom == nsGkAtoms::_asterix, "HTML atom and XML atom are not both asterix?"); + if (nsGkAtoms::_asterisk == mHTMLMatchAtom) { + NS_ASSERTION(mXMLMatchAtom == nsGkAtoms::_asterisk, "HTML atom and XML atom are not both asterisk?"); mMatchAll = true; } else { diff --git a/dom/base/nsContentPermissionHelper.cpp b/dom/base/nsContentPermissionHelper.cpp index 918d6c7a1f..48f5148f64 100644 --- a/dom/base/nsContentPermissionHelper.cpp +++ b/dom/base/nsContentPermissionHelper.cpp @@ -2,13 +2,15 @@ * 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 #ifdef MOZ_WIDGET_GONK #include "GonkPermission.h" -#include "mozilla/dom/ContentParent.h" #endif // MOZ_WIDGET_GONK #include "nsCOMPtr.h" #include "nsIDOMElement.h" #include "nsIPrincipal.h" +#include "mozilla/dom/ContentChild.h" +#include "mozilla/dom/ContentParent.h" #include "mozilla/dom/Element.h" #include "mozilla/dom/PContentPermission.h" #include "mozilla/dom/PermissionMessageUtils.h" @@ -24,11 +26,82 @@ #include "nsJSUtils.h" #include "nsISupportsPrimitives.h" #include "nsServiceManagerUtils.h" +#include "nsIDocument.h" +#include "nsIDOMEvent.h" +#include "nsWeakPtr.h" using mozilla::unused; // using namespace mozilla::dom; using namespace mozilla; +#define kVisibilityChange "visibilitychange" + +NS_IMPL_ISUPPORTS(VisibilityChangeListener, nsIDOMEventListener) + +VisibilityChangeListener::VisibilityChangeListener(nsPIDOMWindow* aWindow) +{ + MOZ_ASSERT(aWindow); + + mWindow = do_GetWeakReference(aWindow); + nsCOMPtr doc = aWindow->GetExtantDoc(); + if (doc) { + doc->AddSystemEventListener(NS_LITERAL_STRING(kVisibilityChange), + /* listener */ this, + /* use capture */ true, + /* wants untrusted */ false); + } + +} + +NS_IMETHODIMP +VisibilityChangeListener::HandleEvent(nsIDOMEvent* aEvent) +{ + nsAutoString type; + aEvent->GetType(type); + if (!type.EqualsLiteral(kVisibilityChange)) { + return NS_ERROR_FAILURE; + } + + nsCOMPtr doc = + do_QueryInterface(aEvent->InternalDOMEvent()->GetTarget()); + MOZ_ASSERT(doc); + + if (mCallback) { + mCallback->NotifyVisibility(!doc->Hidden()); + } + + return NS_OK; +} + +void +VisibilityChangeListener::RemoveListener() +{ + nsCOMPtr window = do_QueryReferent(mWindow); + if (!window) { + return; + } + + nsCOMPtr target = do_QueryInterface(window->GetExtantDoc()); + if (target) { + target->RemoveSystemEventListener(NS_LITERAL_STRING(kVisibilityChange), + /* listener */ this, + /* use capture */ true); + } +} + +void +VisibilityChangeListener::SetCallback(nsIContentPermissionRequestCallback *aCallback) +{ + mCallback = aCallback; +} + +already_AddRefed +VisibilityChangeListener::GetCallback() +{ + nsCOMPtr callback = mCallback; + return callback.forget(); +} + namespace mozilla { namespace dom { @@ -49,6 +122,7 @@ class ContentPermissionRequestParent : public PContentPermissionRequestParent private: virtual bool Recvprompt(); + virtual bool RecvNotifyVisibility(const bool& aIsVisible); virtual void ActorDestroy(ActorDestroyReason why); }; @@ -79,6 +153,16 @@ ContentPermissionRequestParent::Recvprompt() return true; } +bool +ContentPermissionRequestParent::RecvNotifyVisibility(const bool& aIsVisible) +{ + if (!mProxy) { + return false; + } + mProxy->NotifyVisibility(aIsVisible); + return true; +} + void ContentPermissionRequestParent::ActorDestroy(ActorDestroyReason why) { @@ -90,10 +174,10 @@ ContentPermissionRequestParent::ActorDestroy(ActorDestroyReason why) bool ContentPermissionRequestParent::IsBeingDestroyed() { - // When TabParent::Destroy() is called, we are being destroyed. It's unsafe - // to send out any message now. - TabParent* tabParent = TabParent::GetFrom(Manager()); - return tabParent->IsDestroyed(); + // When ContentParent::MarkAsDead() is called, we are being destroyed. + // It's unsafe to send out any message now. + ContentParent* contentParent = static_cast(Manager()); + return !contentParent->IsAlive(); } NS_IMPL_ISUPPORTS(ContentPermissionType, nsIContentPermissionType) @@ -205,6 +289,13 @@ nsContentPermissionUtils::ConvertArrayToPermissionRequest(nsIArray* aSrcArray, return len; } +static std::map& +ContentPermissionRequestParentMap() +{ + MOZ_ASSERT(NS_IsMainThread()); + static std::map sPermissionRequestParentMap; + return sPermissionRequestParentMap; +} /* static */ nsresult nsContentPermissionUtils::CreatePermissionArray(const nsACString& aType, @@ -225,9 +316,14 @@ nsContentPermissionUtils::CreatePermissionArray(const nsACString& aType, /* static */ PContentPermissionRequestParent* nsContentPermissionUtils::CreateContentPermissionRequestParent(const nsTArray& aRequests, Element* element, - const IPC::Principal& principal) + const IPC::Principal& principal, + const TabId& aTabId) { - return new ContentPermissionRequestParent(aRequests, element, principal); + PContentPermissionRequestParent* parent = + new ContentPermissionRequestParent(aRequests, element, principal); + ContentPermissionRequestParentMap()[parent] = aTabId; + + return parent; } /* static */ nsresult @@ -259,9 +355,11 @@ nsContentPermissionUtils::AskPermission(nsIContentPermissionRequest* aRequest, n NS_ENSURE_SUCCESS(rv, rv); req->IPDLAddRef(); - child->SendPContentPermissionRequestConstructor(req, - permArray, - IPC::Principal(principal)); + ContentChild::GetSingleton()->SendPContentPermissionRequestConstructor( + req, + permArray, + IPC::Principal(principal), + child->GetTabId()); req->Sendprompt(); return NS_OK; @@ -276,9 +374,139 @@ nsContentPermissionUtils::AskPermission(nsIContentPermissionRequest* aRequest, n return NS_OK; } +/* static */ nsTArray +nsContentPermissionUtils::GetContentPermissionRequestParentById(const TabId& aTabId) +{ + nsTArray parentArray; + for (auto& it : ContentPermissionRequestParentMap()) { + if (it.second == aTabId) { + parentArray.AppendElement(it.first); + } + } + + return Move(parentArray); +} + +/* static */ void +nsContentPermissionUtils::NotifyRemoveContentPermissionRequestParent( + PContentPermissionRequestParent* aParent) +{ + auto it = ContentPermissionRequestParentMap().find(aParent); + MOZ_ASSERT(it != ContentPermissionRequestParentMap().end()); + + ContentPermissionRequestParentMap().erase(it); +} + +NS_IMPL_ISUPPORTS(nsContentPermissionRequester, nsIContentPermissionRequester) + +nsContentPermissionRequester::nsContentPermissionRequester(nsPIDOMWindow* aWindow) + : mWindow(aWindow) +{ + mListener = new VisibilityChangeListener(mWindow); +} + +nsContentPermissionRequester::~nsContentPermissionRequester() +{ + mListener->RemoveListener(); + mListener = nullptr; +} + +NS_IMETHODIMP +nsContentPermissionRequester::GetVisibility(nsIContentPermissionRequestCallback* aCallback) +{ + NS_ENSURE_ARG_POINTER(aCallback); + + if (!mWindow) { + MOZ_ASSERT(false); + return NS_ERROR_FAILURE; + } + + nsCOMPtr docshell = mWindow->GetDocShell(); + if (!docshell) { + return NS_ERROR_FAILURE; + } + + bool isActive = false; + docshell->GetIsActive(&isActive); + aCallback->NotifyVisibility(isActive); + return NS_OK; +} + +NS_IMETHODIMP +nsContentPermissionRequester::SetOnVisibilityChange(nsIContentPermissionRequestCallback* aCallback) +{ + mListener->SetCallback(aCallback); + + if (!aCallback) { + mListener->RemoveListener(); + } + + return NS_OK; +} + +NS_IMETHODIMP +nsContentPermissionRequester::GetOnVisibilityChange(nsIContentPermissionRequestCallback** aCallback) +{ + NS_ENSURE_ARG_POINTER(aCallback); + + nsCOMPtr callback = mListener->GetCallback(); + callback.forget(aCallback); + return NS_OK; +} + } // namespace dom } // namespace mozilla +NS_IMPL_ISUPPORTS(nsContentPermissionRequestProxy::nsContentPermissionRequesterProxy, + nsIContentPermissionRequester) + +NS_IMETHODIMP +nsContentPermissionRequestProxy::nsContentPermissionRequesterProxy + ::GetVisibility(nsIContentPermissionRequestCallback* aCallback) +{ + NS_ENSURE_ARG_POINTER(aCallback); + + mGetCallback = aCallback; + mWaitGettingResult = true; + unused << mParent->SendGetVisibility(); + return NS_OK; +} + +NS_IMETHODIMP +nsContentPermissionRequestProxy::nsContentPermissionRequesterProxy + ::SetOnVisibilityChange(nsIContentPermissionRequestCallback* aCallback) +{ + mOnChangeCallback = aCallback; + return NS_OK; +} + +NS_IMETHODIMP +nsContentPermissionRequestProxy::nsContentPermissionRequesterProxy + ::GetOnVisibilityChange(nsIContentPermissionRequestCallback** aCallback) +{ + NS_ENSURE_ARG_POINTER(aCallback); + + nsCOMPtr callback = mOnChangeCallback; + callback.forget(aCallback); + return NS_OK; +} + +void +nsContentPermissionRequestProxy::nsContentPermissionRequesterProxy + ::NotifyVisibilityResult(const bool& aIsVisible) +{ + if (mWaitGettingResult) { + MOZ_ASSERT(mGetCallback); + mWaitGettingResult = false; + mGetCallback->NotifyVisibility(aIsVisible); + return; + } + + if (mOnChangeCallback) { + mOnChangeCallback->NotifyVisibility(aIsVisible); + } +} + nsContentPermissionRequestProxy::nsContentPermissionRequestProxy() { MOZ_COUNT_CTOR(nsContentPermissionRequestProxy); @@ -296,6 +524,7 @@ nsContentPermissionRequestProxy::Init(const nsTArray& request NS_ASSERTION(parent, "null parent"); mParent = parent; mPermissionRequests = requests; + mRequester = new nsContentPermissionRequesterProxy(mParent); nsCOMPtr prompt = do_GetService(NS_CONTENT_PERMISSION_PROMPT_CONTRACTID); if (!prompt) { @@ -309,6 +538,7 @@ nsContentPermissionRequestProxy::Init(const nsTArray& request void nsContentPermissionRequestProxy::OnParentDestroyed() { + mRequester = nullptr; mParent = nullptr; } @@ -397,12 +627,12 @@ nsContentPermissionRequestProxy::Allow(JS::HandleValue aChoices) if (mPermissionRequests[i].type().EqualsLiteral("audio-capture")) { GonkPermissionService::GetInstance()->addGrantInfo( "android.permission.RECORD_AUDIO", - TabParent::GetFrom(mParent->Manager())->Manager()->AsContentParent()->Pid()); + static_cast(mParent->Manager())->Pid()); } if (mPermissionRequests[i].type().EqualsLiteral("video-capture")) { GonkPermissionService::GetInstance()->addGrantInfo( "android.permission.CAMERA", - TabParent::GetFrom(mParent->Manager())->Manager()->AsContentParent()->Pid()); + static_cast(mParent->Manager())->Pid()); } } #endif @@ -442,9 +672,27 @@ nsContentPermissionRequestProxy::Allow(JS::HandleValue aChoices) return NS_OK; } +void +nsContentPermissionRequestProxy::NotifyVisibility(const bool& aIsVisible) +{ + MOZ_ASSERT(mRequester); + + mRequester->NotifyVisibilityResult(aIsVisible); +} + +NS_IMETHODIMP +nsContentPermissionRequestProxy::GetRequester(nsIContentPermissionRequester** aRequester) +{ + NS_ENSURE_ARG_POINTER(aRequester); + + nsRefPtr requester = mRequester; + requester.forget(aRequester); + return NS_OK; +} + // RemotePermissionRequest -NS_IMPL_ISUPPORTS0(RemotePermissionRequest) +NS_IMPL_ISUPPORTS(RemotePermissionRequest, nsIContentPermissionRequestCallback); RemotePermissionRequest::RemotePermissionRequest( nsIContentPermissionRequest* aRequest, @@ -453,6 +701,8 @@ RemotePermissionRequest::RemotePermissionRequest( , mWindow(aWindow) , mIPCOpen(false) { + mListener = new VisibilityChangeListener(mWindow); + mListener->SetCallback(this); } void @@ -474,6 +724,9 @@ bool RemotePermissionRequest::Recv__delete__(const bool& aAllow, InfallibleTArray&& aChoices) { + mListener->RemoveListener(); + mListener = nullptr; + if (aAllow && mWindow->IsCurrentInnerWindow()) { // Use 'undefined' if no choice is provided. if (aChoices.IsEmpty()) { @@ -507,3 +760,28 @@ RemotePermissionRequest::Recv__delete__(const bool& aAllow, } return true; } + +bool +RemotePermissionRequest::RecvGetVisibility() +{ + nsCOMPtr docshell = mWindow->GetDocShell(); + if (!docshell) { + return false; + } + + bool isActive = false; + docshell->GetIsActive(&isActive); + unused << SendNotifyVisibility(isActive); + return true; +} + +NS_IMETHODIMP +RemotePermissionRequest::NotifyVisibility(bool isVisible) +{ + if (!mIPCOpen) { + return NS_OK; + } + + unused << SendNotifyVisibility(isVisible); + return NS_OK; +} diff --git a/dom/base/nsContentPermissionHelper.h b/dom/base/nsContentPermissionHelper.h index b3b66e0ad9..25c97fd64f 100644 --- a/dom/base/nsContentPermissionHelper.h +++ b/dom/base/nsContentPermissionHelper.h @@ -9,6 +9,9 @@ #include "nsTArray.h" #include "nsIMutableArray.h" #include "mozilla/dom/PContentPermissionRequestChild.h" +#include "mozilla/dom/ipc/IdType.h" +#include "nsIDOMEventListener.h" + // Microsoft's API Name hackery sucks // XXXbz Doing this in a header is a gigantic footgun. See // https://bugzilla.mozilla.org/show_bug.cgi?id=932421#c3 for why. @@ -27,6 +30,25 @@ namespace IPC { class Principal; } // namespace IPC +class VisibilityChangeListener final : public nsIDOMEventListener +{ +public: + NS_DECL_ISUPPORTS + NS_DECL_NSIDOMEVENTLISTENER + + explicit VisibilityChangeListener(nsPIDOMWindow* aWindow); + + void RemoveListener(); + void SetCallback(nsIContentPermissionRequestCallback* aCallback); + already_AddRefed GetCallback(); + +private: + virtual ~VisibilityChangeListener() {} + + nsWeakPtr mWindow; + nsCOMPtr mCallback; +}; + namespace mozilla { namespace dom { @@ -73,44 +95,92 @@ public: static PContentPermissionRequestParent* CreateContentPermissionRequestParent(const nsTArray& aRequests, Element* element, - const IPC::Principal& principal); + const IPC::Principal& principal, + const TabId& aTabId); static nsresult AskPermission(nsIContentPermissionRequest* aRequest, nsPIDOMWindow* aWindow); + + static nsTArray + GetContentPermissionRequestParentById(const TabId& aTabId); + + static void + NotifyRemoveContentPermissionRequestParent(PContentPermissionRequestParent* aParent); +}; + +class nsContentPermissionRequester final : public nsIContentPermissionRequester +{ +public: + NS_DECL_ISUPPORTS + NS_DECL_NSICONTENTPERMISSIONREQUESTER + + explicit nsContentPermissionRequester(nsPIDOMWindow* aWindow); + +private: + virtual ~nsContentPermissionRequester(); + + nsCOMPtr mWindow; + nsRefPtr mListener; }; } // namespace dom } // namespace mozilla +using mozilla::dom::ContentPermissionRequestParent; + class nsContentPermissionRequestProxy : public nsIContentPermissionRequest { - public: +public: NS_DECL_ISUPPORTS NS_DECL_NSICONTENTPERMISSIONREQUEST nsContentPermissionRequestProxy(); nsresult Init(const nsTArray& requests, - mozilla::dom::ContentPermissionRequestParent* parent); + ContentPermissionRequestParent* parent); void OnParentDestroyed(); - private: + void NotifyVisibility(const bool& aIsVisible); + +private: + class nsContentPermissionRequesterProxy final : public nsIContentPermissionRequester { + public: + NS_DECL_ISUPPORTS + NS_DECL_NSICONTENTPERMISSIONREQUESTER + + explicit nsContentPermissionRequesterProxy(ContentPermissionRequestParent* aParent) + : mParent(aParent) + , mWaitGettingResult(false) {} + + void NotifyVisibilityResult(const bool& aIsVisible); + + private: + virtual ~nsContentPermissionRequesterProxy() {} + + ContentPermissionRequestParent* mParent; + bool mWaitGettingResult; + nsCOMPtr mGetCallback; + nsCOMPtr mOnChangeCallback; + }; + virtual ~nsContentPermissionRequestProxy(); // Non-owning pointer to the ContentPermissionRequestParent object which owns this proxy. - mozilla::dom::ContentPermissionRequestParent* mParent; + ContentPermissionRequestParent* mParent; nsTArray mPermissionRequests; + nsRefPtr mRequester; }; /** * RemotePermissionRequest will send a prompt ipdl request to b2g process. */ -class RemotePermissionRequest final : public nsISupports +class RemotePermissionRequest final : public nsIContentPermissionRequestCallback , public mozilla::dom::PContentPermissionRequestChild { public: NS_DECL_ISUPPORTS + NS_DECL_NSICONTENTPERMISSIONREQUESTCALLBACK RemotePermissionRequest(nsIContentPermissionRequest* aRequest, nsPIDOMWindow* aWindow); @@ -119,6 +189,8 @@ public: virtual bool Recv__delete__(const bool &aAllow, InfallibleTArray&& aChoices) override; + virtual bool RecvGetVisibility() override; + void IPDLAddRef() { mIPCOpen = true; @@ -143,6 +215,7 @@ private: nsCOMPtr mRequest; nsCOMPtr mWindow; bool mIPCOpen; + nsRefPtr mListener; }; #endif // nsContentPermissionHelper_h diff --git a/dom/base/nsDocument.cpp b/dom/base/nsDocument.cpp index 105ea094f6..be82055c4a 100644 --- a/dom/base/nsDocument.cpp +++ b/dom/base/nsDocument.cpp @@ -10846,8 +10846,8 @@ nsIDocument::Children() { if (!mChildrenCollection) { mChildrenCollection = new nsContentList(this, kNameSpaceID_Wildcard, - nsGkAtoms::_asterix, - nsGkAtoms::_asterix, + nsGkAtoms::_asterisk, + nsGkAtoms::_asterisk, false); } @@ -12015,6 +12015,8 @@ DispatchPointerLockError(nsIDocument* aTarget) asyncDispatcher->PostDOMEvent(); } +static const uint8_t kPointerLockRequestLimit = 2; + mozilla::StaticRefPtr gPendingPointerLockRequest; class nsPointerLockPermissionRequest : public nsRunnable, @@ -12024,7 +12026,13 @@ public: nsPointerLockPermissionRequest(Element* aElement, bool aUserInputOrChromeCaller) : mElement(do_GetWeakReference(aElement)), mDocument(do_GetWeakReference(aElement->OwnerDoc())), - mUserInputOrChromeCaller(aUserInputOrChromeCaller) {} + mUserInputOrChromeCaller(aUserInputOrChromeCaller) + { + nsCOMPtr doc = do_QueryReferent(mDocument); + if (doc) { + mRequester = new nsContentPermissionRequester(doc->GetInnerWindow()); + } + } NS_DECL_ISUPPORTS_INHERITED NS_DECL_NSICONTENTPERMISSIONREQUEST @@ -12056,7 +12064,7 @@ public: // In non-fullscreen mode user input (or chrome caller) is required! // Also, don't let the page to try to get the permission too many times. if (!mUserInputOrChromeCaller || - doc->mCancelledPointerLockRequests > 2) { + doc->mCancelledPointerLockRequests > kPointerLockRequestLimit) { Handled(); DispatchPointerLockError(d); return NS_OK; @@ -12084,6 +12092,7 @@ public: protected: virtual ~nsPointerLockPermissionRequest() {} + nsCOMPtr mRequester; }; NS_IMPL_ISUPPORTS_INHERITED(nsPointerLockPermissionRequest, @@ -12134,7 +12143,10 @@ nsPointerLockPermissionRequest::Cancel() nsCOMPtr d = do_QueryReferent(mDocument); Handled(); if (d) { - static_cast(d.get())->mCancelledPointerLockRequests++; + auto doc = static_cast(d.get()); + if (doc->mCancelledPointerLockRequests <= kPointerLockRequestLimit) { + doc->mCancelledPointerLockRequests++; + } DispatchPointerLockError(d); } return NS_OK; @@ -12189,6 +12201,16 @@ nsPointerLockPermissionRequest::Allow(JS::HandleValue aChoices) return NS_OK; } +NS_IMETHODIMP +nsPointerLockPermissionRequest::GetRequester(nsIContentPermissionRequester** aRequester) +{ + NS_ENSURE_ARG_POINTER(aRequester); + + nsCOMPtr requester = mRequester; + requester.forget(aRequester); + return NS_OK; +} + void nsDocument::SetApprovedForFullscreen(bool aIsApproved) { diff --git a/dom/base/nsDocument.h b/dom/base/nsDocument.h index 4a8a8b80a3..f34daf7a1c 100644 --- a/dom/base/nsDocument.h +++ b/dom/base/nsDocument.h @@ -1670,7 +1670,9 @@ public: // 'style-sheet-applicable-state-changed' notification. bool mSSApplicableStateNotificationPending:1; - uint32_t mCancelledPointerLockRequests; + // The number of pointer lock requests which are cancelled by the user. + // The value is saturated to kPointerLockRequestLimit+1 = 3. + uint8_t mCancelledPointerLockRequests:2; uint8_t mXMLDeclarationBits; diff --git a/dom/base/nsGkAtomList.h b/dom/base/nsGkAtomList.h index 0ff2559b30..5ce8b74dc6 100644 --- a/dom/base/nsGkAtomList.h +++ b/dom/base/nsGkAtomList.h @@ -50,7 +50,7 @@ GK_ATOM(_moz_original_size, "_moz_original_size") GK_ATOM(_moz_target, "_moz_target") GK_ATOM(menuactive, "_moz-menuactive") GK_ATOM(_poundDefault, "#default") -GK_ATOM(_asterix, "*") +GK_ATOM(_asterisk, "*") GK_ATOM(a, "a") GK_ATOM(abbr, "abbr") GK_ATOM(abort, "abort") diff --git a/dom/camera/DOMCameraManager.cpp b/dom/camera/DOMCameraManager.cpp index d29c1f286c..95c0c1e305 100644 --- a/dom/camera/DOMCameraManager.cpp +++ b/dom/camera/DOMCameraManager.cpp @@ -152,6 +152,7 @@ public: , mCameraId(aCameraId) , mInitialConfig(aInitialConfig) , mPromise(aPromise) + , mRequester(new nsContentPermissionRequester(mWindow)) { } protected: @@ -166,6 +167,7 @@ protected: uint32_t mCameraId; CameraConfiguration mInitialConfig; nsRefPtr mPromise; + nsCOMPtr mRequester; }; NS_IMPL_CYCLE_COLLECTION(CameraPermissionRequest, mWindow, mPromise) @@ -219,6 +221,16 @@ CameraPermissionRequest::Allow(JS::HandleValue aChoices) return DispatchCallback(nsIPermissionManager::ALLOW_ACTION); } +NS_IMETHODIMP +CameraPermissionRequest::GetRequester(nsIContentPermissionRequester** aRequester) +{ + NS_ENSURE_ARG_POINTER(aRequester); + + nsCOMPtr requester = mRequester; + requester.forget(aRequester); + return NS_OK; +} + nsresult CameraPermissionRequest::DispatchCallback(uint32_t aPermission) { diff --git a/dom/canvas/CanvasImageCache.cpp b/dom/canvas/CanvasImageCache.cpp index 2dc049293b..bf3fafafed 100644 --- a/dom/canvas/CanvasImageCache.cpp +++ b/dom/canvas/CanvasImageCache.cpp @@ -299,7 +299,7 @@ CanvasImageCache::Lookup(Element* aImage, gImageCache->MarkUsed(entry->mData); - *aSize = gfx::ToIntSize(entry->mData->mSize); + *aSize = entry->mData->mSize; return entry->mData->mSourceSurface; } diff --git a/dom/canvas/CanvasRenderingContext2D.cpp b/dom/canvas/CanvasRenderingContext2D.cpp index ebf210eaf6..79984a7a06 100644 --- a/dom/canvas/CanvasRenderingContext2D.cpp +++ b/dom/canvas/CanvasRenderingContext2D.cpp @@ -4427,7 +4427,7 @@ CanvasRenderingContext2D::DrawImage(const HTMLImageOrCanvasOrVideoElement& image return; } - imgSize = gfx::ToIntSize(res.mSize); + imgSize = res.mSize; // Scale sw/sh based on aspect ratio if (image.IsHTMLVideoElement()) { diff --git a/dom/devicestorage/nsDeviceStorage.cpp b/dom/devicestorage/nsDeviceStorage.cpp index aa3bdaa7c7..983078ef5f 100644 --- a/dom/devicestorage/nsDeviceStorage.cpp +++ b/dom/devicestorage/nsDeviceStorage.cpp @@ -2175,6 +2175,7 @@ nsDOMDeviceStorageCursor::nsDOMDeviceStorageCursor(nsPIDOMWindow* aWindow, , mSince(aSince) , mFile(aFile) , mPrincipal(aPrincipal) + , mRequester(new nsContentPermissionRequester(GetOwner())) { } @@ -2264,6 +2265,16 @@ nsDOMDeviceStorageCursor::Allow(JS::HandleValue aChoices) return NS_OK; } +NS_IMETHODIMP +nsDOMDeviceStorageCursor::GetRequester(nsIContentPermissionRequester** aRequester) +{ + NS_ENSURE_ARG_POINTER(aRequester); + + nsCOMPtr requester = mRequester; + requester.forget(aRequester); + return NS_OK; +} + void nsDOMDeviceStorageCursor::Continue(ErrorResult& aRv) { @@ -2850,6 +2861,7 @@ public: , mFile(aFile) , mRequest(aRequest) , mDeviceStorage(aDeviceStorage) + , mRequester(new nsContentPermissionRequester(mWindow)) { MOZ_ASSERT(mWindow); MOZ_ASSERT(mPrincipal); @@ -2870,6 +2882,7 @@ public: , mFile(aFile) , mRequest(aRequest) , mBlob(aBlob) + , mRequester(new nsContentPermissionRequester(mWindow)) { MOZ_ASSERT(mWindow); MOZ_ASSERT(mPrincipal); @@ -2889,6 +2902,7 @@ public: , mFile(aFile) , mRequest(aRequest) , mDSFileDescriptor(aDSFileDescriptor) + , mRequester(new nsContentPermissionRequester(mWindow)) { MOZ_ASSERT(mRequestType == DEVICE_STORAGE_REQUEST_CREATEFD); MOZ_ASSERT(mWindow); @@ -3298,6 +3312,15 @@ public: return NS_OK; } + NS_IMETHODIMP GetRequester(nsIContentPermissionRequester** aRequester) + { + NS_ENSURE_ARG_POINTER(aRequester); + + nsCOMPtr requester = mRequester; + requester.forget(aRequester); + return NS_OK; + } + private: ~DeviceStorageRequest() {} @@ -3310,6 +3333,7 @@ private: nsCOMPtr mBlob; nsRefPtr mDeviceStorage; nsRefPtr mDSFileDescriptor; + nsCOMPtr mRequester; }; NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DeviceStorageRequest) diff --git a/dom/devicestorage/nsDeviceStorage.h b/dom/devicestorage/nsDeviceStorage.h index e01602441d..ed1ef85143 100644 --- a/dom/devicestorage/nsDeviceStorage.h +++ b/dom/devicestorage/nsDeviceStorage.h @@ -220,6 +220,7 @@ private: nsRefPtr mFile; nsCOMPtr mPrincipal; + nsCOMPtr mRequester; }; //helpers diff --git a/dom/events/WheelHandlingHelper.h b/dom/events/WheelHandlingHelper.h index 11eb03f62b..7cc3b8e08c 100644 --- a/dom/events/WheelHandlingHelper.h +++ b/dom/events/WheelHandlingHelper.h @@ -11,12 +11,11 @@ #include "mozilla/EventForwards.h" #include "nsCoord.h" #include "nsIFrame.h" +#include "nsPoint.h" class nsIScrollableFrame; class nsITimer; -struct nsIntPoint; - namespace mozilla { class EventStateManager; diff --git a/dom/filesystem/FileSystemPermissionRequest.cpp b/dom/filesystem/FileSystemPermissionRequest.cpp index e3e9001e32..7e0dbfa0e2 100644 --- a/dom/filesystem/FileSystemPermissionRequest.cpp +++ b/dom/filesystem/FileSystemPermissionRequest.cpp @@ -55,6 +55,7 @@ FileSystemPermissionRequest::FileSystemPermissionRequest( } mPrincipal = doc->NodePrincipal(); + mRequester = new nsContentPermissionRequester(mWindow); } FileSystemPermissionRequest::~FileSystemPermissionRequest() @@ -135,5 +136,15 @@ FileSystemPermissionRequest::Run() return NS_OK; } +NS_IMETHODIMP +FileSystemPermissionRequest::GetRequester(nsIContentPermissionRequester** aRequester) +{ + NS_ENSURE_ARG_POINTER(aRequester); + + nsCOMPtr requester = mRequester; + requester.forget(aRequester); + return NS_OK; +} + } /* namespace dom */ } /* namespace mozilla */ diff --git a/dom/filesystem/FileSystemPermissionRequest.h b/dom/filesystem/FileSystemPermissionRequest.h index 6c65b2c7bb..462a71b6b5 100644 --- a/dom/filesystem/FileSystemPermissionRequest.h +++ b/dom/filesystem/FileSystemPermissionRequest.h @@ -42,6 +42,7 @@ private: nsRefPtr mTask; nsCOMPtr mWindow; nsCOMPtr mPrincipal; + nsCOMPtr mRequester; }; } // namespace dom diff --git a/dom/geolocation/nsGeolocation.cpp b/dom/geolocation/nsGeolocation.cpp index 1b95c181c6..f2d3607176 100644 --- a/dom/geolocation/nsGeolocation.cpp +++ b/dom/geolocation/nsGeolocation.cpp @@ -110,6 +110,7 @@ class nsGeolocationRequest final int32_t mWatchId; bool mShutdown; + nsCOMPtr mRequester; }; static PositionOptions* @@ -355,6 +356,13 @@ nsGeolocationRequest::nsGeolocationRequest(Geolocation* aLocator, mWatchId(aWatchId), mShutdown(false) { + nsCOMPtr win = do_QueryReferent(mLocator->GetOwner()); + if (win) { + nsCOMPtr window = do_QueryInterface(win); + if (window) { + mRequester = new nsContentPermissionRequester(window); + } + } } nsGeolocationRequest::~nsGeolocationRequest() @@ -499,6 +507,16 @@ nsGeolocationRequest::Allow(JS::HandleValue aChoices) return NS_OK; } +NS_IMETHODIMP +nsGeolocationRequest::GetRequester(nsIContentPermissionRequester** aRequester) +{ + NS_ENSURE_ARG_POINTER(aRequester); + + nsCOMPtr requester = mRequester; + requester.forget(aRequester); + return NS_OK; +} + void nsGeolocationRequest::SetTimeoutTimer() { diff --git a/dom/interfaces/base/nsIContentPermissionPrompt.idl b/dom/interfaces/base/nsIContentPermissionPrompt.idl index a04b2bc59b..43715e39fe 100644 --- a/dom/interfaces/base/nsIContentPermissionPrompt.idl +++ b/dom/interfaces/base/nsIContentPermissionPrompt.idl @@ -32,12 +32,40 @@ interface nsIContentPermissionType : nsISupports { readonly attribute nsIArray options; // ["choice1", "choice2"] }; +/** + * Interface provides the callback type. + */ +[scriptable, uuid(5fb5bb60-7069-11e4-9803-0800200c9a66)] +interface nsIContentPermissionRequestCallback : nsISupports { + /** + * The callback of the visibility result. + */ + void notifyVisibility(in boolean isVisible); +}; + +/** + * Interface provides the way to get the visibility and + * the notification. + */ +[scriptable, uuid(f8577124-6a5f-486f-ae04-c5bcae911eb5)] +interface nsIContentPermissionRequester : nsISupports { + /** + * The function to get the visibility. + */ + void getVisibility(in nsIContentPermissionRequestCallback callback); + + /** + * The callback to get the notification of visibility change. + */ + attribute nsIContentPermissionRequestCallback onVisibilityChange; +}; + /** * Interface allows access to a content to request * permission to perform a privileged operation such as * geolocation. */ -[scriptable, uuid(69a39d88-d1c4-4ba9-9b19-bafc7a1bb783)] +[scriptable, uuid(408c8fcd-1420-4aff-94d8-39bf74d79219)] interface nsIContentPermissionRequest : nsISupports { /** * The array will include the request types. Elements of this array are @@ -59,6 +87,12 @@ interface nsIContentPermissionRequest : nsISupports { readonly attribute nsIDOMWindow window; readonly attribute nsIDOMElement element; + /** + * The requester to get the required information of + * the window. + */ + readonly attribute nsIContentPermissionRequester requester; + /** * allow or cancel the request */ diff --git a/dom/ipc/ContentChild.cpp b/dom/ipc/ContentChild.cpp index 6acdfaaca6..1b6b8b55b9 100644 --- a/dom/ipc/ContentChild.cpp +++ b/dom/ipc/ContentChild.cpp @@ -99,6 +99,7 @@ #include "nsISystemMessageCache.h" #include "nsDirectoryServiceUtils.h" #include "nsDirectoryServiceDefs.h" +#include "nsContentPermissionHelper.h" #include "IHistory.h" #include "nsNetUtil.h" @@ -2749,6 +2750,23 @@ ContentChild::RecvUpdateWindow(const uintptr_t& aChildId) #endif } +PContentPermissionRequestChild* +ContentChild::AllocPContentPermissionRequestChild(const InfallibleTArray& aRequests, + const IPC::Principal& aPrincipal, + const TabId& aTabId) +{ + NS_RUNTIMEABORT("unused"); + return nullptr; +} + +bool +ContentChild::DeallocPContentPermissionRequestChild(PContentPermissionRequestChild* actor) +{ + auto child = static_cast(actor); + child->IPDLRelease(); + return true; +} + // This code goes here rather than nsGlobalWindow.cpp because nsGlobalWindow.cpp // can't include ContentChild.h since it includes windows.h. diff --git a/dom/ipc/ContentChild.h b/dom/ipc/ContentChild.h index 0347fdc6a0..e96fb79a70 100644 --- a/dom/ipc/ContentChild.h +++ b/dom/ipc/ContentChild.h @@ -449,6 +449,13 @@ public: virtual bool DeallocPOfflineCacheUpdateChild(POfflineCacheUpdateChild* offlineCacheUpdate) override; + virtual PContentPermissionRequestChild* + AllocPContentPermissionRequestChild(const InfallibleTArray& aRequests, + const IPC::Principal& aPrincipal, + const TabId& aTabId) override; + virtual bool + DeallocPContentPermissionRequestChild(PContentPermissionRequestChild* actor) override; + private: virtual void ActorDestroy(ActorDestroyReason why) override; diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp index 0ea3e05d28..5c434d06bc 100755 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -45,6 +45,7 @@ #include "mozilla/dom/FileSystemRequestParent.h" #include "mozilla/dom/GeolocationBinding.h" #include "mozilla/dom/PContentBridgeParent.h" +#include "mozilla/dom/PContentPermissionRequestParent.h" #include "mozilla/dom/PCycleCollectWithLogsParent.h" #include "mozilla/dom/PFMRadioParent.h" #include "mozilla/dom/PMemoryReportRequestParent.h" @@ -98,6 +99,7 @@ #include "nsIAlertsService.h" #include "nsIAppsService.h" #include "nsIClipboard.h" +#include "nsContentPermissionHelper.h" #include "nsICycleCollectorListener.h" #include "nsIDocument.h" #include "nsIDOMGeoGeolocation.h" @@ -2007,6 +2009,18 @@ ContentParent::NotifyTabDestroyed(PBrowserParent* aTab, --mNumDestroyingTabs; } + TabId id = static_cast(aTab)->GetTabId(); + nsTArray parentArray = + nsContentPermissionUtils::GetContentPermissionRequestParentById(id); + + // Need to close undeleted ContentPermissionRequestParents before tab is closed. + for (auto& permissionRequestParent : parentArray) { + nsTArray emptyChoices; + unused << PContentPermissionRequestParent::Send__delete__(permissionRequestParent, + false, + emptyChoices); + } + // There can be more than one PBrowser for a given app process // because of popup windows. When the last one closes, shut // us down. @@ -4732,6 +4746,32 @@ ContentParent::RecvUpdateDropEffect(const uint32_t& aDragAction, return true; } +PContentPermissionRequestParent* +ContentParent::AllocPContentPermissionRequestParent(const InfallibleTArray& aRequests, + const IPC::Principal& aPrincipal, + const TabId& aTabId) +{ + ContentProcessManager* cpm = ContentProcessManager::GetSingleton(); + nsRefPtr tp = cpm->GetTopLevelTabParentByProcessAndTabId(this->ChildID(), + aTabId); + if (!tp) { + return nullptr; + } + + return nsContentPermissionUtils::CreateContentPermissionRequestParent(aRequests, + tp->GetOwnerElement(), + aPrincipal, + aTabId); +} + +bool +ContentParent::DeallocPContentPermissionRequestParent(PContentPermissionRequestParent* actor) +{ + nsContentPermissionUtils::NotifyRemoveContentPermissionRequestParent(actor); + delete actor; + return true; +} + } // namespace dom } // namespace mozilla diff --git a/dom/ipc/ContentParent.h b/dom/ipc/ContentParent.h index e7d07a96c9..87565dbad9 100644 --- a/dom/ipc/ContentParent.h +++ b/dom/ipc/ContentParent.h @@ -361,6 +361,14 @@ public: virtual bool RecvFinishShutdown() override; void MaybeInvokeDragSession(TabParent* aParent); + + virtual PContentPermissionRequestParent* + AllocPContentPermissionRequestParent(const InfallibleTArray& aRequests, + const IPC::Principal& aPrincipal, + const TabId& aTabId) override; + virtual bool + DeallocPContentPermissionRequestParent(PContentPermissionRequestParent* actor) override; + protected: void OnChannelConnected(int32_t pid) override; virtual void ActorDestroy(ActorDestroyReason why) override; diff --git a/dom/ipc/PBrowser.ipdl b/dom/ipc/PBrowser.ipdl index 9e2bab9064..0a8a26587d 100644 --- a/dom/ipc/PBrowser.ipdl +++ b/dom/ipc/PBrowser.ipdl @@ -10,7 +10,6 @@ include protocol PColorPicker; include protocol PContent; include protocol PContentBridge; include protocol PDocumentRenderer; -include protocol PContentPermissionRequest; include protocol PFilePicker; include protocol PIndexedDBPermissionRequest; include protocol PRenderFrame; @@ -18,7 +17,6 @@ include protocol PPluginWidget; include DOMTypes; include JavaScriptTypes; include URIParams; -include PContentPermission; include ServiceWorkerRegistrarTypes; @@ -39,9 +37,9 @@ using nscolor from "nsColor.h"; using class mozilla::WidgetCompositionEvent from "ipc/nsGUIEventIPC.h"; using struct mozilla::widget::IMENotification from "nsIWidget.h"; using struct nsIMEUpdatePreference from "nsIWidget.h"; -using struct nsIntPoint from "nsPoint.h"; -using struct nsIntRect from "nsRect.h"; using mozilla::gfx::IntSize from "mozilla/gfx/Point.h"; +using mozilla::gfx::IntPoint from "mozilla/gfx/Point.h"; +using mozilla::gfx::IntRect from "mozilla/gfx/Rect.h"; using class mozilla::WidgetKeyboardEvent from "ipc/nsGUIEventIPC.h"; using class mozilla::WidgetMouseEvent from "ipc/nsGUIEventIPC.h"; using class mozilla::WidgetWheelEvent from "ipc/nsGUIEventIPC.h"; @@ -103,7 +101,6 @@ prio(normal upto urgent) sync protocol PBrowser manages PColorPicker; manages PDocumentRenderer; - manages PContentPermissionRequest; manages PFilePicker; manages PIndexedDBPermissionRequest; manages PRenderFrame; @@ -384,21 +381,6 @@ parent: */ PColorPicker(nsString title, nsString initialColor); - /** - * Initiates an asynchronous request for permission for the - * provided principal. - * - * @param aRequests - * The array of permissions to request. - * @param aPrincipal - * The principal of the request. - * - * NOTE: The principal is untrusted in the parent process. Only - * principals that can live in the content process should - * provided. - */ - PContentPermissionRequest(PermissionRequest[] aRequests, Principal aPrincipal); - PFilePicker(nsString aTitle, int16_t aMode); /** @@ -506,11 +488,11 @@ parent: uint64_t aObserverId); SynthesizeNativeTouchPoint(uint32_t aPointerId, TouchPointerState aPointerState, - nsIntPoint aPointerScreenPoint, + IntPoint aPointerScreenPoint, double aPointerPressure, uint32_t aPointerOrientation, uint64_t aObserverId); - SynthesizeNativeTouchTap(nsIntPoint aPointerScreenPoint, + SynthesizeNativeTouchTap(IntPoint aPointerScreenPoint, bool aLongTap, uint64_t aObserverId); ClearNativeTouchSequence(uint64_t aObserverId); @@ -566,8 +548,8 @@ child: CacheFileDescriptor(nsString path, FileDescriptor fd); - UpdateDimensions(nsIntRect rect, ScreenIntSize size, ScreenOrientation orientation, - nsIntPoint chromeDisp) compress; + UpdateDimensions(IntRect rect, ScreenIntSize size, ScreenOrientation orientation, + LayoutDeviceIntPoint chromeDisp) compress; UpdateFrame(FrameMetrics frame); diff --git a/dom/ipc/PContent.ipdl b/dom/ipc/PContent.ipdl index dd78c07785..e6297d5517 100644 --- a/dom/ipc/PContent.ipdl +++ b/dom/ipc/PContent.ipdl @@ -12,6 +12,7 @@ include protocol PBrowser; include protocol PCellBroadcast; include protocol PCompositor; include protocol PContentBridge; +include protocol PContentPermissionRequest; include protocol PCycleCollectWithLogs; include protocol PDocAccessible; include protocol PPSMContentDownloader; @@ -54,6 +55,7 @@ include PTabContext; include URIParams; include PluginTypes; include ProtocolTypes; +include PContentPermission; // Workaround to prevent error if PContentChild.cpp & PContentBridgeParent.cpp // are put into different UnifiedProtocolsXX.cpp files. @@ -379,6 +381,7 @@ prio(normal upto urgent) sync protocol PContent manages PBluetooth; manages PBrowser; manages PCellBroadcast; + manages PContentPermissionRequest; manages PCycleCollectWithLogs; manages PDocAccessible; manages PDeviceStorageRequest; @@ -949,6 +952,25 @@ parent: async FinishShutdown(); UpdateDropEffect(uint32_t aDragAction, uint32_t aDropEffect); + + /** + * Initiates an asynchronous request for permission for the + * provided principal. + * + * @param aRequests + * The array of permissions to request. + * @param aPrincipal + * The principal of the request. + * @param tabId + * To identify which tab issues this request. + * + * NOTE: The principal is untrusted in the parent process. Only + * principals that can live in the content process should + * provided. + */ + PContentPermissionRequest(PermissionRequest[] aRequests, Principal aPrincipal, + TabId tabId); + both: AsyncMessage(nsString aMessage, ClonedMessageData aData, CpowEntry[] aCpows, Principal aPrincipal); diff --git a/dom/ipc/PContentPermissionRequest.ipdl b/dom/ipc/PContentPermissionRequest.ipdl index 0640861fad..05f9d5e8e6 100644 --- a/dom/ipc/PContentPermissionRequest.ipdl +++ b/dom/ipc/PContentPermissionRequest.ipdl @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -include protocol PBrowser; +include protocol PContent; include PContentPermission; namespace mozilla { @@ -10,12 +10,14 @@ namespace dom { protocol PContentPermissionRequest { - manager PBrowser; + manager PContent; parent: prompt(); + NotifyVisibility(bool visibility); child: + GetVisibility(); __delete__(bool allow, PermissionChoice[] choices); }; diff --git a/dom/ipc/PPluginWidget.ipdl b/dom/ipc/PPluginWidget.ipdl index 02b86e9c77..174e83cdf2 100644 --- a/dom/ipc/PPluginWidget.ipdl +++ b/dom/ipc/PPluginWidget.ipdl @@ -6,7 +6,7 @@ include protocol PBrowser; include "mozilla/GfxMessageUtils.h"; -using struct nsIntRect from "nsRect.h"; +using nsIntRect from "nsRect.h"; namespace mozilla { namespace plugins { diff --git a/dom/ipc/PScreenManager.ipdl b/dom/ipc/PScreenManager.ipdl index d958993fb0..844821c8f4 100644 --- a/dom/ipc/PScreenManager.ipdl +++ b/dom/ipc/PScreenManager.ipdl @@ -8,7 +8,7 @@ include protocol PContent; include "mozilla/GfxMessageUtils.h"; -using struct nsIntRect from "nsRect.h"; +using nsIntRect from "nsRect.h"; using mozilla::dom::TabId from "mozilla/dom/ipc/IdType.h"; namespace mozilla { diff --git a/dom/ipc/TabChild.cpp b/dom/ipc/TabChild.cpp index dda38bd66a..d0421b41a6 100644 --- a/dom/ipc/TabChild.cpp +++ b/dom/ipc/TabChild.cpp @@ -68,7 +68,6 @@ #include "nsWeakReference.h" #include "nsWindowWatcher.h" #include "PermissionMessageUtils.h" -#include "nsContentPermissionHelper.h" #include "PuppetWidget.h" #include "StructuredCloneUtils.h" #include "nsViewportInfo.h" @@ -1076,7 +1075,7 @@ TabChild::Init() } mWidget->Create( nullptr, 0, // no parents - nsIntRect(nsIntPoint(0, 0), nsIntSize(0, 0)), + gfx::IntRect(gfx::IntPoint(0, 0), gfx::IntSize(0, 0)), nullptr // HandleWidgetEvent ); @@ -2001,7 +2000,7 @@ TabChild::RecvShow(const ScreenIntSize& aSize, bool TabChild::RecvUpdateDimensions(const nsIntRect& rect, const ScreenIntSize& size, - const ScreenOrientation& orientation, const nsIntPoint& chromeDisp) + const ScreenOrientation& orientation, const LayoutDeviceIntPoint& chromeDisp) { if (!mRemoteFrame) { return true; @@ -2612,22 +2611,6 @@ TabChild::DeallocPColorPickerChild(PColorPickerChild* aColorPicker) return true; } -PContentPermissionRequestChild* -TabChild::AllocPContentPermissionRequestChild(const InfallibleTArray& aRequests, - const IPC::Principal& aPrincipal) -{ - NS_RUNTIMEABORT("unused"); - return nullptr; -} - -bool -TabChild::DeallocPContentPermissionRequestChild(PContentPermissionRequestChild* actor) -{ - RemotePermissionRequest* child = static_cast(actor); - child->IPDLRelease(); - return true; -} - PFilePickerChild* TabChild::AllocPFilePickerChild(const nsString&, const int16_t&) { @@ -3190,7 +3173,7 @@ TabChild::CreatePluginWidget(nsIWidget* aParent, nsIWidget** aOut) initData.mUnicode = false; initData.clipChildren = true; initData.clipSiblings = true; - nsresult rv = pluginWidget->Create(aParent, nullptr, nsIntRect(nsIntPoint(0, 0), + nsresult rv = pluginWidget->Create(aParent, nullptr, gfx::IntRect(gfx::IntPoint(0, 0), nsIntSize(0, 0)), &initData); if (NS_FAILED(rv)) { NS_WARNING("Creating native plugin widget on the chrome side failed."); diff --git a/dom/ipc/TabChild.h b/dom/ipc/TabChild.h index ae2b921a80..ff329dd916 100644 --- a/dom/ipc/TabChild.h +++ b/dom/ipc/TabChild.h @@ -320,7 +320,7 @@ public: virtual bool RecvUpdateDimensions(const nsIntRect& rect, const ScreenIntSize& size, const ScreenOrientation& orientation, - const nsIntPoint& chromeDisp) override; + const LayoutDeviceIntPoint& chromeDisp) override; virtual bool RecvUpdateFrame(const layers::FrameMetrics& aFrameMetrics) override; virtual bool RecvRequestFlingSnap(const ViewID& aScrollId, const CSSPoint& aDestination) override; @@ -406,12 +406,6 @@ public: AllocPColorPickerChild(const nsString& title, const nsString& initialColor) override; virtual bool DeallocPColorPickerChild(PColorPickerChild* actor) override; - virtual PContentPermissionRequestChild* - AllocPContentPermissionRequestChild(const InfallibleTArray& aRequests, - const IPC::Principal& aPrincipal) override; - virtual bool - DeallocPContentPermissionRequestChild(PContentPermissionRequestChild* actor) override; - virtual PFilePickerChild* AllocPFilePickerChild(const nsString& aTitle, const int16_t& aMode) override; virtual bool @@ -494,7 +488,7 @@ public: bool DeallocPPluginWidgetChild(PPluginWidgetChild* aActor) override; nsresult CreatePluginWidget(nsIWidget* aParent, nsIWidget** aOut); - nsIntPoint GetChromeDisplacement() { return mChromeDisp; }; + LayoutDeviceIntPoint GetChromeDisplacement() { return mChromeDisp; }; bool ParentIsActive() { @@ -633,7 +627,7 @@ private: bool mHasValidInnerSize; bool mDestroyed; // Position of tab, relative to parent widget (typically the window) - nsIntPoint mChromeDisp; + LayoutDeviceIntPoint mChromeDisp; TabId mUniqueId; float mDPI; double mDefaultScale; diff --git a/dom/ipc/TabParent.cpp b/dom/ipc/TabParent.cpp index 2b4faa8211..39435ec098 100644 --- a/dom/ipc/TabParent.cpp +++ b/dom/ipc/TabParent.cpp @@ -13,7 +13,6 @@ #include "mozilla/BrowserElementParent.h" #include "mozilla/dom/ContentParent.h" #include "mozilla/dom/DataTransfer.h" -#include "mozilla/dom/PContentPermissionRequestParent.h" #include "mozilla/dom/ServiceWorkerRegistrar.h" #include "mozilla/dom/indexedDB/ActorsParent.h" #include "mozilla/plugins/PluginWidgetParent.h" @@ -34,7 +33,6 @@ #include "BlobParent.h" #include "nsCOMPtr.h" #include "nsContentAreaDragDrop.h" -#include "nsContentPermissionHelper.h" #include "nsContentUtils.h" #include "nsDebug.h" #include "nsFocusManager.h" @@ -273,7 +271,6 @@ TabParent::TabParent(nsIContentParent* aManager, , mDefaultScale(0) , mShown(false) , mUpdatedDimensions(false) - , mChromeOffset(0, 0) , mManager(aManager) , mMarkedDestroying(false) , mIsDestroyed(false) @@ -922,7 +919,7 @@ TabParent::UpdateDimensions(const nsIntRect& rect, const ScreenIntSize& size) hal::ScreenConfiguration config; hal::GetCurrentScreenConfiguration(&config); ScreenOrientation orientation = config.orientation(); - nsIntPoint chromeOffset = -LayoutDevicePixel::ToUntyped(GetChildProcessOffset()); + LayoutDeviceIntPoint chromeOffset = -GetChildProcessOffset(); if (!mUpdatedDimensions || mOrientation != orientation || mDimensions != size || !mRect.IsEqualEdges(rect) || @@ -1091,20 +1088,6 @@ TabParent::DeallocPDocumentRendererParent(PDocumentRendererParent* actor) return true; } -PContentPermissionRequestParent* -TabParent::AllocPContentPermissionRequestParent(const InfallibleTArray& aRequests, - const IPC::Principal& aPrincipal) -{ - return nsContentPermissionUtils::CreateContentPermissionRequestParent(aRequests, mFrameElement, aPrincipal); -} - -bool -TabParent::DeallocPContentPermissionRequestParent(PContentPermissionRequestParent* actor) -{ - delete actor; - return true; -} - PFilePickerParent* TabParent::AllocPFilePickerParent(const nsString& aTitle, const int16_t& aMode) { diff --git a/dom/ipc/TabParent.h b/dom/ipc/TabParent.h index 4747701e4a..c6369249fc 100644 --- a/dom/ipc/TabParent.h +++ b/dom/ipc/TabParent.h @@ -330,12 +330,6 @@ public: const nsIntSize& renderSize) override; virtual bool DeallocPDocumentRendererParent(PDocumentRendererParent* actor) override; - virtual PContentPermissionRequestParent* - AllocPContentPermissionRequestParent(const InfallibleTArray& aRequests, - const IPC::Principal& aPrincipal) override; - virtual bool - DeallocPContentPermissionRequestParent(PContentPermissionRequestParent* actor) override; - virtual PFilePickerParent* AllocPFilePickerParent(const nsString& aTitle, const int16_t& aMode) override; @@ -489,7 +483,7 @@ protected: CSSToLayoutDeviceScale mDefaultScale; bool mShown; bool mUpdatedDimensions; - nsIntPoint mChromeOffset; + LayoutDeviceIntPoint mChromeOffset; private: already_AddRefed GetFrameLoader(bool aUseCachedFrameLoaderAfterDestroy = false) const; diff --git a/dom/media/MediaPermissionGonk.cpp b/dom/media/MediaPermissionGonk.cpp index 31f7b00d06..b93188f7e3 100644 --- a/dom/media/MediaPermissionGonk.cpp +++ b/dom/media/MediaPermissionGonk.cpp @@ -130,6 +130,7 @@ private: nsRefPtr mRequest; nsTArray > mAudioDevices; // candidate audio devices nsTArray > mVideoDevices; // candidate video devices + nsCOMPtr mRequester; }; // MediaPermissionRequest @@ -156,6 +157,9 @@ MediaPermissionRequest::MediaPermissionRequest(nsRefPtr window = GetOwner(); + mRequester = new nsContentPermissionRequester(window.get()); } // nsIContentPermissionRequest methods @@ -275,6 +279,16 @@ MediaPermissionRequest::Allow(JS::HandleValue aChoices) return DoAllow(audioDevice, videoDevice); } +NS_IMETHODIMP +MediaPermissionRequest::GetRequester(nsIContentPermissionRequester** aRequester) +{ + NS_ENSURE_ARG_POINTER(aRequester); + + nsCOMPtr requester = mRequester; + requester.forget(aRequester); + return NS_OK; +} + nsresult MediaPermissionRequest::DoAllow(const nsString &audioDevice, const nsString &videoDevice) diff --git a/dom/media/VideoUtils.h b/dom/media/VideoUtils.h index d96e0d0bdb..6a9c940ada 100644 --- a/dom/media/VideoUtils.h +++ b/dom/media/VideoUtils.h @@ -12,6 +12,7 @@ #include "mozilla/CheckedInt.h" #include "nsIThread.h" #include "nsSize.h" +#include "nsRect.h" #if !(defined(XP_WIN) || defined(XP_MACOSX) || defined(LINUX)) || \ defined(MOZ_ASAN) @@ -29,8 +30,6 @@ using mozilla::CheckedUint64; using mozilla::CheckedInt32; using mozilla::CheckedUint32; -struct nsIntRect; - // This file contains stuff we'd rather put elsewhere, but which is // dependent on other changes which we don't want to wait for. We plan to // remove this file in the near future. diff --git a/dom/media/wmf/DXVA2Manager.h b/dom/media/wmf/DXVA2Manager.h index d0fe3002f8..5770e4d338 100644 --- a/dom/media/wmf/DXVA2Manager.h +++ b/dom/media/wmf/DXVA2Manager.h @@ -9,8 +9,7 @@ #include "WMF.h" #include "nsAutoPtr.h" #include "mozilla/Mutex.h" - -struct nsIntRect; +#include "nsRect.h" namespace mozilla { diff --git a/dom/notification/DesktopNotification.cpp b/dom/notification/DesktopNotification.cpp index 07ceba279b..7c865abd77 100644 --- a/dom/notification/DesktopNotification.cpp +++ b/dom/notification/DesktopNotification.cpp @@ -30,12 +30,16 @@ class DesktopNotificationRequest : public nsIContentPermissionRequest { } + nsCOMPtr mRequester; public: NS_DECL_ISUPPORTS_INHERITED NS_DECL_NSICONTENTPERMISSIONREQUEST explicit DesktopNotificationRequest(DesktopNotification* aNotification) - : mDesktopNotification(aNotification) {} + : mDesktopNotification(aNotification) + { + mRequester = new nsContentPermissionRequester(mDesktopNotification->GetOwner()); + } NS_IMETHOD Run() override { @@ -313,6 +317,16 @@ DesktopNotificationRequest::Allow(JS::HandleValue aChoices) return rv; } +NS_IMETHODIMP +DesktopNotificationRequest::GetRequester(nsIContentPermissionRequester** aRequester) +{ + NS_ENSURE_ARG_POINTER(aRequester); + + nsCOMPtr requester = mRequester; + requester.forget(aRequester); + return NS_OK; +} + NS_IMETHODIMP DesktopNotificationRequest::GetTypes(nsIArray** aTypes) { diff --git a/dom/notification/Notification.cpp b/dom/notification/Notification.cpp index a0c1f5327a..483bac98b8 100644 --- a/dom/notification/Notification.cpp +++ b/dom/notification/Notification.cpp @@ -172,7 +172,10 @@ public: NotificationPermissionCallback* aCallback) : mPrincipal(aPrincipal), mWindow(aWindow), mPermission(NotificationPermission::Default), - mCallback(aCallback) {} + mCallback(aCallback) + { + mRequester = new nsContentPermissionRequester(mWindow); + } protected: virtual ~NotificationPermissionRequest() {} @@ -183,6 +186,7 @@ protected: nsCOMPtr mWindow; NotificationPermission mPermission; nsRefPtr mCallback; + nsCOMPtr mRequester; }; class NotificationObserver : public nsIObserver @@ -307,6 +311,16 @@ NotificationPermissionRequest::Allow(JS::HandleValue aChoices) return DispatchCallback(); } +NS_IMETHODIMP +NotificationPermissionRequest::GetRequester(nsIContentPermissionRequester** aRequester) +{ + NS_ENSURE_ARG_POINTER(aRequester); + + nsCOMPtr requester = mRequester; + requester.forget(aRequester); + return NS_OK; +} + inline nsresult NotificationPermissionRequest::DispatchCallback() { diff --git a/dom/plugins/base/nsPluginInstanceOwner.h b/dom/plugins/base/nsPluginInstanceOwner.h index 4ba860fc4d..53b082c61f 100644 --- a/dom/plugins/base/nsPluginInstanceOwner.h +++ b/dom/plugins/base/nsPluginInstanceOwner.h @@ -24,7 +24,6 @@ #endif class nsIInputStream; -struct nsIntRect; class nsPluginDOMContextMenuListener; class nsPluginFrame; class nsDisplayListBuilder; diff --git a/dom/plugins/ipc/PPluginInstance.ipdl b/dom/plugins/ipc/PPluginInstance.ipdl index e972550eb5..9ece419a84 100644 --- a/dom/plugins/ipc/PPluginInstance.ipdl +++ b/dom/plugins/ipc/PPluginInstance.ipdl @@ -26,7 +26,7 @@ using gfxIntSize from "nsSize.h"; using struct mozilla::null_t from "ipc/IPCMessageUtils.h"; using mozilla::plugins::WindowsSharedMemoryHandle from "mozilla/plugins/PluginMessageUtils.h"; using mozilla::layers::SurfaceDescriptorX11 from "gfxipc/ShadowLayerUtils.h"; -using struct nsIntRect from "nsRect.h"; +using nsIntRect from "nsRect.h"; namespace mozilla { namespace plugins { diff --git a/dom/plugins/ipc/PluginInstanceChild.cpp b/dom/plugins/ipc/PluginInstanceChild.cpp index 6966204076..bcaee16328 100644 --- a/dom/plugins/ipc/PluginInstanceChild.cpp +++ b/dom/plugins/ipc/PluginInstanceChild.cpp @@ -114,7 +114,7 @@ CreateDrawTargetForSurface(gfxASurface *aSurface) } RefPtr drawTarget = Factory::CreateDrawTargetForCairoSurface(aSurface->CairoSurface(), - ToIntSize(gfxIntSize(aSurface->GetSize())), + aSurface->GetSize(), &format); aSurface->SetData(&kDrawTarget, drawTarget, nullptr); return drawTarget; diff --git a/dom/plugins/ipc/PluginLibrary.h b/dom/plugins/ipc/PluginLibrary.h index aac31b7c1c..d6f40db7b3 100644 --- a/dom/plugins/ipc/PluginLibrary.h +++ b/dom/plugins/ipc/PluginLibrary.h @@ -15,10 +15,10 @@ #include "nsError.h" #include "mozilla/EventForwards.h" #include "nsSize.h" +#include "nsRect.h" class gfxContext; class nsCString; -struct nsIntRect; class nsNPAPIPlugin; namespace mozilla { diff --git a/dom/plugins/ipc/PluginUtilsOSX.h b/dom/plugins/ipc/PluginUtilsOSX.h index 164efe814d..7abab1efdb 100644 --- a/dom/plugins/ipc/PluginUtilsOSX.h +++ b/dom/plugins/ipc/PluginUtilsOSX.h @@ -9,8 +9,7 @@ #include "npapi.h" #include "mozilla/gfx/QuartzSupport.h" - -struct nsIntRect; +#include "nsRect.h" namespace mozilla { namespace plugins { diff --git a/dom/xslt/xpath/txExprLexer.cpp b/dom/xslt/xpath/txExprLexer.cpp index 1764922dc0..4927afa0f0 100644 --- a/dom/xslt/xpath/txExprLexer.cpp +++ b/dom/xslt/xpath/txExprLexer.cpp @@ -284,7 +284,7 @@ txExprLexer::parse(const nsASingleFragmentString& aPattern) newToken = new Token(mPosition, Token::SUBTRACTION_OP); ++mPosition; break; - case ASTERIX: + case ASTERISK: if (nextIsOperatorToken(prevToken)) { newToken = new Token(mPosition, Token::MULTIPLY_OP); } diff --git a/dom/xslt/xpath/txExprLexer.h b/dom/xslt/xpath/txExprLexer.h index 28e56771d8..7497ca5052 100644 --- a/dom/xslt/xpath/txExprLexer.h +++ b/dom/xslt/xpath/txExprLexer.h @@ -178,7 +178,7 @@ public: R_ANGLE = '>', COMMA = ',', PERIOD = '.', - ASTERIX = '*', + ASTERISK = '*', FORWARD_SLASH = '/', EQUAL = '=', BANG = '!', diff --git a/dom/xslt/xpath/txNameTest.cpp b/dom/xslt/xpath/txNameTest.cpp index 7b3987c83b..8330e075de 100644 --- a/dom/xslt/xpath/txNameTest.cpp +++ b/dom/xslt/xpath/txNameTest.cpp @@ -35,7 +35,7 @@ bool txNameTest::matches(const txXPathNode& aNode, txIMatchContext* aContext) } // Totally wild? - if (mLocalName == nsGkAtoms::_asterix && !mPrefix) + if (mLocalName == nsGkAtoms::_asterisk && !mPrefix) return true; // Compare namespaces @@ -46,7 +46,7 @@ bool txNameTest::matches(const txXPathNode& aNode, txIMatchContext* aContext) return false; // Name wild? - if (mLocalName == nsGkAtoms::_asterix) + if (mLocalName == nsGkAtoms::_asterisk) return true; // Compare local-names @@ -58,7 +58,7 @@ bool txNameTest::matches(const txXPathNode& aNode, txIMatchContext* aContext) */ double txNameTest::getDefaultPriority() { - if (mLocalName == nsGkAtoms::_asterix) { + if (mLocalName == nsGkAtoms::_asterisk) { if (!mPrefix) return -0.5; return -0.25; diff --git a/dom/xslt/xpath/txXPathOptimizer.cpp b/dom/xslt/xpath/txXPathOptimizer.cpp index a31e44a6d4..57d265ebc5 100644 --- a/dom/xslt/xpath/txXPathOptimizer.cpp +++ b/dom/xslt/xpath/txXPathOptimizer.cpp @@ -128,7 +128,7 @@ txXPathOptimizer::optimizeStep(Expr* aInExpr, Expr** aOutExpr) if (!step->getSubExprAt(0) && step->getNodeTest()->getType() == txNameTest::NAME_TEST && (nameTest = static_cast(step->getNodeTest()))-> - mLocalName != nsGkAtoms::_asterix) { + mLocalName != nsGkAtoms::_asterisk) { *aOutExpr = new txNamedAttributeStep(nameTest->mNamespace, nameTest->mPrefix, diff --git a/dom/xslt/xslt/txStylesheetCompileHandlers.cpp b/dom/xslt/xslt/txStylesheetCompileHandlers.cpp index dc380543a7..803cda136b 100644 --- a/dom/xslt/xslt/txStylesheetCompileHandlers.cpp +++ b/dom/xslt/xslt/txStylesheetCompileHandlers.cpp @@ -1062,7 +1062,7 @@ txFnStartStripSpace(int32_t aNamespaceID, } prefix = localName; } - localName = nsGkAtoms::_asterix; + localName = nsGkAtoms::_asterisk; } if (prefix) { ns = aState.mElementContext->mMappings->lookupNamespace(prefix); diff --git a/dom/xslt/xslt/txXSLTNumber.cpp b/dom/xslt/xslt/txXSLTNumber.cpp index 62df4399ac..d6f16e0e72 100644 --- a/dom/xslt/xslt/txXSLTNumber.cpp +++ b/dom/xslt/xslt/txXSLTNumber.cpp @@ -156,7 +156,7 @@ txXSLTNumber::getValueList(Expr* aValueExpr, txPattern* aCountPattern, { // this won't match anything as we walk up the tree // but it's what the spec says to do - nodeTest = new txNameTest(0, nsGkAtoms::_asterix, 0, + nodeTest = new txNameTest(0, nsGkAtoms::_asterisk, 0, nodeType); break; } diff --git a/dom/xul/XULDocument.cpp b/dom/xul/XULDocument.cpp index d1d0a0ba7c..a9e389a6ff 100644 --- a/dom/xul/XULDocument.cpp +++ b/dom/xul/XULDocument.cpp @@ -969,7 +969,7 @@ XULDocument::AttributeChanged(nsIDocument* aDocument, static_cast(entry->mListeners[i]); if ((bl->mAttribute == aAttribute) || - (bl->mAttribute == nsGkAtoms::_asterix)) { + (bl->mAttribute == nsGkAtoms::_asterisk)) { nsCOMPtr listenerEl = do_QueryReferent(bl->mListener); if (listenerEl) { @@ -4148,7 +4148,7 @@ XULDocument::BroadcastAttributeChangeFromOverlay(nsIContent* aNode, (entry->mListeners[i]); if ((bl->mAttribute != aAttribute) && - (bl->mAttribute != nsGkAtoms::_asterix)) + (bl->mAttribute != nsGkAtoms::_asterisk)) continue; nsCOMPtr l = do_QueryReferent(bl->mListener); diff --git a/dom/xul/templates/nsContentTestNode.h b/dom/xul/templates/nsContentTestNode.h index e39c7114ac..ebea5bcf61 100644 --- a/dom/xul/templates/nsContentTestNode.h +++ b/dom/xul/templates/nsContentTestNode.h @@ -12,6 +12,8 @@ #include "nsIAtom.h" #include "nsIDOMDocument.h" +class nsXULTemplateQueryProcessorRDF; + /** * The nsContentTestNode is always the top node in a query's rule network. It * exists so that Constrain can filter out resources that aren't part of a diff --git a/dom/xul/templates/nsRDFQuery.h b/dom/xul/templates/nsRDFQuery.h index 2a3bafd1d6..56679f2304 100644 --- a/dom/xul/templates/nsRDFQuery.h +++ b/dom/xul/templates/nsRDFQuery.h @@ -15,6 +15,8 @@ {0x8929ff60, 0x1c9c, 0x4d87, \ { 0xac, 0x02, 0x09, 0x14, 0x15, 0x3b, 0x48, 0xc4 }} +class nsXULTemplateQueryProcessorRDF; + /** * A compiled query in the RDF query processor. This interface should not be * used directly outside of the RDF query processor. diff --git a/dom/xul/templates/nsRuleNetwork.h b/dom/xul/templates/nsRuleNetwork.h index 39fda00418..f382a3244f 100644 --- a/dom/xul/templates/nsRuleNetwork.h +++ b/dom/xul/templates/nsRuleNetwork.h @@ -38,7 +38,6 @@ #include "nsIRDFNode.h" class nsXULTemplateResultSetRDF; -class nsXULTemplateQueryProcessorRDF; //---------------------------------------------------------------------- diff --git a/editor/libeditor/PlaceholderTxn.h b/editor/libeditor/PlaceholderTxn.h index 93f24c3d01..95923373d5 100644 --- a/editor/libeditor/PlaceholderTxn.h +++ b/editor/libeditor/PlaceholderTxn.h @@ -15,8 +15,6 @@ #include "nsWeakReference.h" #include "nsAutoPtr.h" -class nsHTMLEditor; - namespace mozilla { namespace dom { class IMETextTxn; diff --git a/editor/libeditor/nsEditor.h b/editor/libeditor/nsEditor.h index 393f7914cb..034ec7f5d0 100644 --- a/editor/libeditor/nsEditor.h +++ b/editor/libeditor/nsEditor.h @@ -33,10 +33,7 @@ class EditAggregateTxn; class RemoveStyleSheetTxn; class nsIAtom; class nsIContent; -class nsIDOMCharacterData; -class nsIDOMDataTransfer; class nsIDOMDocument; -class nsIDOMElement; class nsIDOMEvent; class nsIDOMEventListener; class nsIDOMEventTarget; diff --git a/editor/libeditor/nsHTMLCSSUtils.h b/editor/libeditor/nsHTMLCSSUtils.h index be2b94b2d4..c02cbfffaf 100644 --- a/editor/libeditor/nsHTMLCSSUtils.h +++ b/editor/libeditor/nsHTMLCSSUtils.h @@ -26,7 +26,6 @@ class Element; } // namespace mozilla class nsHTMLEditor; -class nsIDOMWindow; typedef void (*nsProcessValueFunc)(const nsAString * aInputString, nsAString & aOutputString, const char * aDefaultValueString, diff --git a/editor/libeditor/nsHTMLEditor.h b/editor/libeditor/nsHTMLEditor.h index 88d946a709..d2a52fbd54 100644 --- a/editor/libeditor/nsHTMLEditor.h +++ b/editor/libeditor/nsHTMLEditor.h @@ -43,11 +43,9 @@ class nsIDOMKeyEvent; class nsITransferable; -class nsIDocumentEncoder; class nsIClipboard; class TypeInState; class nsIContentFilter; -class nsIURL; class nsILinkHandler; class nsTableOuterFrame; class nsIDOMRange; diff --git a/editor/libeditor/nsHTMLEditorEventListener.h b/editor/libeditor/nsHTMLEditorEventListener.h index 6c386a19d9..9b660878f3 100644 --- a/editor/libeditor/nsHTMLEditorEventListener.h +++ b/editor/libeditor/nsHTMLEditorEventListener.h @@ -11,7 +11,6 @@ class nsEditor; class nsHTMLEditor; -class nsIDOMEvent; class nsHTMLEditorEventListener : public nsEditorEventListener { diff --git a/editor/libeditor/nsIAbsorbingTransaction.h b/editor/libeditor/nsIAbsorbingTransaction.h index 0346b94511..900d29cccd 100644 --- a/editor/libeditor/nsIAbsorbingTransaction.h +++ b/editor/libeditor/nsIAbsorbingTransaction.h @@ -20,7 +20,6 @@ Transaction interface to outside world {0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32} } class nsSelectionState; -class nsIEditor; class nsIAtom; /** diff --git a/editor/libeditor/nsPlaintextEditor.h b/editor/libeditor/nsPlaintextEditor.h index 741a582b6c..63ea3baf48 100644 --- a/editor/libeditor/nsPlaintextEditor.h +++ b/editor/libeditor/nsPlaintextEditor.h @@ -16,11 +16,9 @@ #include "nscore.h" class nsIContent; -class nsIDOMDataTransfer; class nsIDOMDocument; class nsIDOMElement; class nsIDOMEvent; -class nsIDOMEventTarget; class nsIDOMKeyEvent; class nsIDOMNode; class nsIDocumentEncoder; diff --git a/editor/libeditor/nsTextEditUtils.h b/editor/libeditor/nsTextEditUtils.h index 441b845704..2fc613a619 100644 --- a/editor/libeditor/nsTextEditUtils.h +++ b/editor/libeditor/nsTextEditUtils.h @@ -8,12 +8,6 @@ #include "nscore.h" -namespace mozilla { -namespace dom { -class Element; -} // namespace dom -} // namespace mozilla - class nsIDOMNode; class nsINode; class nsPlaintextEditor; diff --git a/editor/libeditor/nsWSRunObject.h b/editor/libeditor/nsWSRunObject.h index 21c60bf2d0..a43a37130c 100644 --- a/editor/libeditor/nsWSRunObject.h +++ b/editor/libeditor/nsWSRunObject.h @@ -14,7 +14,6 @@ #include "mozilla/dom/Text.h" class nsHTMLEditor; -class nsIDOMDocument; class nsIDOMNode; struct DOMPoint; diff --git a/editor/txmgr/nsTransactionManager.h b/editor/txmgr/nsTransactionManager.h index 2b244f4827..17d21819f3 100644 --- a/editor/txmgr/nsTransactionManager.h +++ b/editor/txmgr/nsTransactionManager.h @@ -18,7 +18,6 @@ class nsITransaction; class nsITransactionListener; -class nsTransactionItem; /** implementation of a transaction manager object. * diff --git a/embedding/browser/nsWebBrowser.h b/embedding/browser/nsWebBrowser.h index 88eeb413fa..08dbcbb51c 100644 --- a/embedding/browser/nsWebBrowser.h +++ b/embedding/browser/nsWebBrowser.h @@ -41,8 +41,6 @@ #include "nsTArray.h" #include "nsWeakPtr.h" -class nsIContentViewerFile; - class nsWebBrowserInitInfo { public: diff --git a/embedding/components/find/nsFind.h b/embedding/components/find/nsFind.h index d22853bc85..7b0667152c 100644 --- a/embedding/components/find/nsFind.h +++ b/embedding/components/find/nsFind.h @@ -16,7 +16,6 @@ #include "nsIContentIterator.h" #include "nsIWordBreaker.h" -class nsIAtom; class nsIContent; #define NS_FIND_CONTRACTID "@mozilla.org/embedcomp/rangefind;1" diff --git a/embedding/components/printingui/mac/nsPrintingPromptService.h b/embedding/components/printingui/mac/nsPrintingPromptService.h index 469f762e38..0334db2230 100644 --- a/embedding/components/printingui/mac/nsPrintingPromptService.h +++ b/embedding/components/printingui/mac/nsPrintingPromptService.h @@ -21,10 +21,6 @@ #include "nsPrintProgress.h" #include "nsIWebProgressListener.h" - -class nsIDOMWindow; -class nsIDialogParamBlock; - class nsPrintingPromptService: public nsIPrintingPromptService, public nsIWebProgressListener { diff --git a/embedding/components/windowwatcher/nsWindowWatcher.h b/embedding/components/windowwatcher/nsWindowWatcher.h index 18f365ca6b..f7fd6701ba 100644 --- a/embedding/components/windowwatcher/nsWindowWatcher.h +++ b/embedding/components/windowwatcher/nsWindowWatcher.h @@ -23,10 +23,7 @@ class nsIURI; class nsIDocShellTreeItem; class nsIDocShellTreeOwner; class nsPIDOMWindow; -class nsIWebBrowserChrome; -class nsString; class nsWatcherWindowEnumerator; -class nsIScriptContext; class nsPromptService; struct nsWatcherWindowEntry; struct SizeSpec; diff --git a/extensions/spellcheck/src/mozInlineSpellChecker.h b/extensions/spellcheck/src/mozInlineSpellChecker.h index ad4317cf6e..dfbc932e7d 100644 --- a/extensions/spellcheck/src/mozInlineSpellChecker.h +++ b/extensions/spellcheck/src/mozInlineSpellChecker.h @@ -24,7 +24,6 @@ #undef KeyPress #endif -class nsIDOMMouseEventListener; class mozInlineSpellWordUtil; class mozInlineSpellChecker; class mozInlineSpellResume; diff --git a/gfx/2d/2D.h b/gfx/2d/2D.h index 7d6976beec..de18265904 100644 --- a/gfx/2d/2D.h +++ b/gfx/2d/2D.h @@ -43,7 +43,6 @@ struct ID2D1Device; struct IDWriteRenderingParams; class GrContext; -struct GrGLInterface; struct CGContext; typedef struct CGContext *CGContextRef; diff --git a/gfx/2d/DrawTargetD2D1.h b/gfx/2d/DrawTargetD2D1.h index 9aa5934e17..2d80decfc6 100644 --- a/gfx/2d/DrawTargetD2D1.h +++ b/gfx/2d/DrawTargetD2D1.h @@ -23,8 +23,6 @@ namespace mozilla { namespace gfx { class SourceSurfaceD2D1; -class GradientStopsD2D; -class ScaledFontDWrite; const int32_t kLayerCacheSize1 = 5; diff --git a/gfx/2d/PathCairo.h b/gfx/2d/PathCairo.h index 2b82b7c33c..8ee76ad95b 100644 --- a/gfx/2d/PathCairo.h +++ b/gfx/2d/PathCairo.h @@ -13,7 +13,6 @@ namespace mozilla { namespace gfx { -class DrawTargetCairo; class PathCairo; class PathBuilderCairo : public PathBuilder diff --git a/gfx/2d/QuartzSupport.h b/gfx/2d/QuartzSupport.h index a85c8e2d90..60a5b9c299 100644 --- a/gfx/2d/QuartzSupport.h +++ b/gfx/2d/QuartzSupport.h @@ -20,7 +20,6 @@ CGColorSpaceRef CreateSystemColorSpace(); // Manages a CARenderer -struct _CGLPBufferObject; struct _CGLContextObject; enum AllowOfflineRendererEnum { ALLOW_OFFLINE_RENDERER, DISALLOW_OFFLINE_RENDERER }; diff --git a/gfx/2d/Rect.h b/gfx/2d/Rect.h index f8eba74e92..c9c664fa1d 100644 --- a/gfx/2d/Rect.h +++ b/gfx/2d/Rect.h @@ -8,6 +8,7 @@ #include "BaseRect.h" #include "BaseMargin.h" +#include "NumericTools.h" #include "Point.h" #include "Tools.h" @@ -105,6 +106,21 @@ struct IntRectTyped : { return IntRectTyped::IsEqualEdges(aRect); } + + void InflateToMultiple(const IntSizeTyped& aTileSize) + { + int32_t yMost = this->YMost(); + int32_t xMost = this->XMost(); + + this->x = RoundDownToMultiple(this->x, aTileSize.width); + this->y = RoundDownToMultiple(this->y, aTileSize.height); + xMost = RoundUpToMultiple(xMost, aTileSize.width); + yMost = RoundUpToMultiple(yMost, aTileSize.height); + + this->width = xMost - this->x; + this->height = yMost - this->y; + } + }; typedef IntRectTyped IntRect; diff --git a/gfx/2d/ScaledFontBase.h b/gfx/2d/ScaledFontBase.h index 05577795d0..31630a9165 100644 --- a/gfx/2d/ScaledFontBase.h +++ b/gfx/2d/ScaledFontBase.h @@ -21,8 +21,6 @@ #include "cairo.h" #endif -class gfxFont; - namespace mozilla { namespace gfx { diff --git a/gfx/2d/SourceSurfaceSkia.h b/gfx/2d/SourceSurfaceSkia.h index c9e0108793..567b2e77d1 100644 --- a/gfx/2d/SourceSurfaceSkia.h +++ b/gfx/2d/SourceSurfaceSkia.h @@ -11,8 +11,6 @@ #include "skia/include/core/SkCanvas.h" #include "skia/include/core/SkBitmap.h" -class GrContext; - namespace mozilla { namespace gfx { diff --git a/gfx/gl/AndroidSurfaceTexture.h b/gfx/gl/AndroidSurfaceTexture.h index 6221bae6fa..3099a6e259 100644 --- a/gfx/gl/AndroidSurfaceTexture.h +++ b/gfx/gl/AndroidSurfaceTexture.h @@ -18,8 +18,6 @@ #include "SurfaceTexture.h" #include "AndroidNativeWindow.h" -class gfxASurface; - namespace mozilla { namespace gfx { class Matrix4x4; diff --git a/gfx/gl/GLContext.h b/gfx/gl/GLContext.h index 51ae8dd5e1..fee55db6a9 100644 --- a/gfx/gl/GLContext.h +++ b/gfx/gl/GLContext.h @@ -51,10 +51,6 @@ #include "gfx2DGlue.h" #include "GeckoProfiler.h" -class nsIntRegion; -class nsIRunnable; -class nsIThread; - namespace android { class GraphicBuffer; } // namespace android diff --git a/gfx/gl/GLContextProviderCGL.mm b/gfx/gl/GLContextProviderCGL.mm index b3b1e93437..a03ef35a9d 100644 --- a/gfx/gl/GLContextProviderCGL.mm +++ b/gfx/gl/GLContextProviderCGL.mm @@ -310,10 +310,8 @@ GLContextProviderCGL::CreateOffscreen(const gfxIntSize& size, bool requireCompatProfile) { nsRefPtr glContext = CreateHeadless(requireCompatProfile); - if (!glContext->InitOffscreen(ToIntSize(size), caps)) { - NS_WARNING("Failed during InitOffscreen."); + if (!glContext->InitOffscreen(size, caps)) return nullptr; - } return glContext.forget(); } diff --git a/gfx/gl/GLContextProviderEGL.cpp b/gfx/gl/GLContextProviderEGL.cpp index 72d1a19ad0..ef5a1e0e02 100644 --- a/gfx/gl/GLContextProviderEGL.cpp +++ b/gfx/gl/GLContextProviderEGL.cpp @@ -902,7 +902,7 @@ GLContextProviderEGL::CreateOffscreen(const gfxIntSize& size, if (!glContext) return nullptr; - if (!glContext->InitOffscreen(ToIntSize(size), caps)) + if (!glContext->InitOffscreen(size, caps)) return nullptr; return glContext.forget(); diff --git a/gfx/gl/GLContextProviderGLX.cpp b/gfx/gl/GLContextProviderGLX.cpp index e10bc21d3b..f54c187045 100644 --- a/gfx/gl/GLContextProviderGLX.cpp +++ b/gfx/gl/GLContextProviderGLX.cpp @@ -1229,7 +1229,7 @@ GLContextProviderGLX::CreateOffscreen(const gfxIntSize& size, if (!glContext) return nullptr; - if (!glContext->InitOffscreen(ToIntSize(size), caps)) + if (!glContext->InitOffscreen(size, caps)) return nullptr; return glContext.forget(); diff --git a/gfx/gl/GLContextProviderWGL.cpp b/gfx/gl/GLContextProviderWGL.cpp index cc33ef6abb..6082c18843 100644 --- a/gfx/gl/GLContextProviderWGL.cpp +++ b/gfx/gl/GLContextProviderWGL.cpp @@ -635,7 +635,7 @@ GLContextProviderWGL::CreateHeadless(bool) } already_AddRefed -GLContextProviderWGL::CreateOffscreen(const gfxIntSize& size, +GLContextProviderWGL::CreateOffscreen(const IntSize& size, const SurfaceCaps& caps, bool requireCompatProfile) { @@ -643,7 +643,7 @@ GLContextProviderWGL::CreateOffscreen(const gfxIntSize& size, if (!glContext) return nullptr; - if (!glContext->InitOffscreen(ToIntSize(size), caps)) + if (!glContext->InitOffscreen(size, caps)) return nullptr; return glContext.forget(); diff --git a/gfx/gl/GLTextureImage.cpp b/gfx/gl/GLTextureImage.cpp index 0bce892163..40a484828e 100644 --- a/gfx/gl/GLTextureImage.cpp +++ b/gfx/gl/GLTextureImage.cpp @@ -79,7 +79,7 @@ TextureImage::UpdateFromDataSource(gfx::DataSourceSurface *aSurface, const gfx::IntPoint* aSrcPoint) { nsIntRegion destRegion = aDestRegion ? *aDestRegion - : nsIntRect(0, 0, + : IntRect(0, 0, aSurface->GetSize().width, aSurface->GetSize().height); gfx::IntPoint srcPoint = aSrcPoint ? *aSrcPoint @@ -120,13 +120,13 @@ BasicTextureImage::BeginUpdate(nsIntRegion& aRegion) if (CanUploadSubTextures(mGLContext)) { GetUpdateRegion(aRegion); } else { - aRegion = nsIntRect(nsIntPoint(0, 0), mSize); + aRegion = IntRect(IntPoint(0, 0), mSize); } mUpdateRegion = aRegion; - nsIntRect rgnSize = mUpdateRegion.GetBounds(); - if (!nsIntRect(nsIntPoint(0, 0), mSize).Contains(rgnSize)) { + IntRect rgnSize = mUpdateRegion.GetBounds(); + if (!IntRect(IntPoint(0, 0), mSize).Contains(rgnSize)) { NS_ERROR("update outside of image"); return nullptr; } @@ -147,7 +147,7 @@ BasicTextureImage::GetUpdateRegion(nsIntRegion& aForRegion) // changed, we need to recreate our backing surface and force the // client to paint everything if (mTextureState != Valid) { - aForRegion = nsIntRect(nsIntPoint(0, 0), mSize); + aForRegion = IntRect(IntPoint(0, 0), mSize); } } @@ -169,7 +169,7 @@ BasicTextureImage::EndUpdate() mUpdateRegion, mTexture, mTextureState == Created, - mUpdateOffset, + ToIntPoint(mUpdateOffset), relative); FinishedSurfaceUpload(); @@ -205,10 +205,10 @@ BasicTextureImage::FinishedSurfaceUpload() bool BasicTextureImage::DirectUpdate(gfx::DataSourceSurface* aSurf, const nsIntRegion& aRegion, const gfx::IntPoint& aFrom /* = gfx::IntPoint(0, 0) */) { - nsIntRect bounds = aRegion.GetBounds(); + IntRect bounds = aRegion.GetBounds(); nsIntRegion region; if (mTextureState != Valid) { - bounds = nsIntRect(0, 0, mSize.width, mSize.height); + bounds = IntRect(0, 0, mSize.width, mSize.height); region = nsIntRegion(bounds); } else { region = aRegion; @@ -220,7 +220,7 @@ BasicTextureImage::DirectUpdate(gfx::DataSourceSurface* aSurf, const nsIntRegion region, mTexture, mTextureState == Created, - bounds.TopLeft() + nsIntPoint(aFrom.x, aFrom.y), + bounds.TopLeft() + IntPoint(aFrom.x, aFrom.y), false); mTextureState = Valid; return true; @@ -345,7 +345,7 @@ TiledTextureImage::DirectUpdate(gfx::DataSourceSurface* aSurf, const nsIntRegion nsIntRegion region; if (mTextureState != Valid) { - nsIntRect bounds = nsIntRect(0, 0, mSize.width, mSize.height); + IntRect bounds = IntRect(0, 0, mSize.width, mSize.height); region = nsIntRegion(bounds); } else { region = aRegion; @@ -355,7 +355,7 @@ TiledTextureImage::DirectUpdate(gfx::DataSourceSurface* aSurf, const nsIntRegion int oldCurrentImage = mCurrentImage; BeginBigImageIteration(); do { - nsIntRect tileRect = ThebesIntRect(GetSrcTileRect()); + IntRect tileRect = ThebesIntRect(GetSrcTileRect()); int xPos = tileRect.x; int yPos = tileRect.y; @@ -400,7 +400,7 @@ TiledTextureImage::GetUpdateRegion(nsIntRegion& aForRegion) // if the texture hasn't been initialized yet, or something important // changed, we need to recreate our backing surface and force the // client to paint everything - aForRegion = nsIntRect(nsIntPoint(0, 0), mSize); + aForRegion = IntRect(IntPoint(0, 0), mSize); return; } @@ -411,7 +411,7 @@ TiledTextureImage::GetUpdateRegion(nsIntRegion& aForRegion) for (unsigned i = 0; i < mImages.Length(); i++) { int xPos = (i % mColumns) * mTileSize; int yPos = (i / mColumns) * mTileSize; - nsIntRect imageRect = nsIntRect(nsIntPoint(xPos,yPos), + IntRect imageRect = IntRect(IntPoint(xPos,yPos), mImages[i]->GetSize()); if (aForRegion.Intersects(imageRect)) { @@ -446,16 +446,16 @@ TiledTextureImage::BeginUpdate(nsIntRegion& aRegion) // if the texture hasn't been initialized yet, or something important // changed, we need to recreate our backing surface and force the // client to paint everything - aRegion = nsIntRect(nsIntPoint(0, 0), mSize); + aRegion = IntRect(IntPoint(0, 0), mSize); } - nsIntRect bounds = aRegion.GetBounds(); + IntRect bounds = aRegion.GetBounds(); for (unsigned i = 0; i < mImages.Length(); i++) { int xPos = (i % mColumns) * mTileSize; int yPos = (i / mColumns) * mTileSize; nsIntRegion imageRegion = - nsIntRegion(nsIntRect(nsIntPoint(xPos,yPos), + nsIntRegion(IntRect(IntPoint(xPos,yPos), mImages[i]->GetSize())); // a single Image can handle this update request @@ -510,8 +510,7 @@ TiledTextureImage::EndUpdate() for (unsigned i = 0; i < mImages.Length(); i++) { int xPos = (i % mColumns) * mTileSize; int yPos = (i / mColumns) * mTileSize; - nsIntRect imageRect = nsIntRect(nsIntPoint(xPos,yPos), - mImages[i]->GetSize()); + IntRect imageRect = IntRect(IntPoint(xPos,yPos), mImages[i]->GetSize()); nsIntRegion subregion; subregion.And(mUpdateRegion, imageRect); diff --git a/gfx/gl/GLUploadHelpers.cpp b/gfx/gl/GLUploadHelpers.cpp index e3e78dfb08..78867db529 100644 --- a/gfx/gl/GLUploadHelpers.cpp +++ b/gfx/gl/GLUploadHelpers.cpp @@ -50,7 +50,7 @@ NextPowerOfTwo(int aNumber) } static unsigned int -DataOffset(const nsIntPoint &aPoint, int32_t aStride, SurfaceFormat aFormat) +DataOffset(const IntPoint &aPoint, int32_t aStride, SurfaceFormat aFormat) { unsigned int data = aPoint.y * aStride; data += aPoint.x * BytesPerPixel(aFormat); @@ -502,10 +502,10 @@ UploadImageDataToTexture(GLContext* gl, } nsIntRegionRectIterator iter(paintRegion); - const nsIntRect *iterRect; + const IntRect *iterRect; // Top left point of the region's bounding rectangle. - nsIntPoint topLeft = paintRegion.GetBounds().TopLeft(); + IntPoint topLeft = paintRegion.GetBounds().TopLeft(); while ((iterRect = iter.Next())) { // The inital data pointer is at the top left point of the region's @@ -556,7 +556,7 @@ UploadSurfaceToTexture(GLContext* gl, const nsIntRegion& aDstRegion, GLuint& aTexture, bool aOverwrite, - const nsIntPoint& aSrcPoint, + const gfx::IntPoint& aSrcPoint, bool aPixelBuffer, GLenum aTextureUnit, GLenum aTextureTarget) diff --git a/gfx/gl/GLUploadHelpers.h b/gfx/gl/GLUploadHelpers.h index 1e7f8f6149..5ce7875fc2 100644 --- a/gfx/gl/GLUploadHelpers.h +++ b/gfx/gl/GLUploadHelpers.h @@ -74,7 +74,7 @@ UploadSurfaceToTexture(GLContext* gl, const nsIntRegion& aDstRegion, GLuint& aTexture, bool aOverwrite = false, - const nsIntPoint& aSrcPoint = nsIntPoint(0, 0), + const gfx::IntPoint& aSrcPoint = gfx::IntPoint(0, 0), bool aPixelBuffer = false, GLenum aTextureUnit = LOCAL_GL_TEXTURE0, GLenum aTextureTarget = LOCAL_GL_TEXTURE_2D); diff --git a/gfx/gl/TextureImageCGL.h b/gfx/gl/TextureImageCGL.h index bc73e74a61..10d94755f1 100644 --- a/gfx/gl/TextureImageCGL.h +++ b/gfx/gl/TextureImageCGL.h @@ -11,8 +11,6 @@ #include "nsAutoPtr.h" #include "nsSize.h" -class gfxASurface; - namespace mozilla { namespace gl { diff --git a/gfx/gl/TextureImageEGL.cpp b/gfx/gl/TextureImageEGL.cpp index fec61f467e..bcc2b9ffd9 100644 --- a/gfx/gl/TextureImageEGL.cpp +++ b/gfx/gl/TextureImageEGL.cpp @@ -102,7 +102,7 @@ TextureImageEGL::GetUpdateRegion(nsIntRegion& aForRegion) if (mTextureState != Valid) { // if the texture hasn't been initialized yet, force the // client to paint everything - aForRegion = nsIntRect(nsIntPoint(0, 0), mSize); + aForRegion = gfx::IntRect(gfx::IntPoint(0, 0), mSize); } // We can only draw a rectangle, not subregions due to @@ -122,7 +122,7 @@ TextureImageEGL::BeginUpdate(nsIntRegion& aRegion) mUpdateRect = aRegion.GetBounds(); //printf_stderr("BeginUpdate with updateRect [%d %d %d %d]\n", mUpdateRect.x, mUpdateRect.y, mUpdateRect.width, mUpdateRect.height); - if (!nsIntRect(nsIntPoint(0, 0), mSize).Contains(mUpdateRect)) { + if (!gfx::IntRect(gfx::IntPoint(0, 0), mSize).Contains(mUpdateRect)) { NS_ERROR("update outside of image"); return nullptr; } @@ -198,11 +198,11 @@ TextureImageEGL::EndUpdate() bool TextureImageEGL::DirectUpdate(gfx::DataSourceSurface* aSurf, const nsIntRegion& aRegion, const gfx::IntPoint& aFrom /* = gfx::IntPoint(0,0) */) { - nsIntRect bounds = aRegion.GetBounds(); + gfx::IntRect bounds = aRegion.GetBounds(); nsIntRegion region; if (mTextureState != Valid) { - bounds = nsIntRect(0, 0, mSize.width, mSize.height); + bounds = gfx::IntRect(0, 0, mSize.width, mSize.height); region = nsIntRegion(bounds); } else { region = aRegion; @@ -214,7 +214,7 @@ TextureImageEGL::DirectUpdate(gfx::DataSourceSurface* aSurf, const nsIntRegion& region, mTexture, mTextureState == Created, - bounds.TopLeft() + nsIntPoint(aFrom.x, aFrom.y), + bounds.TopLeft() + gfx::IntPoint(aFrom.x, aFrom.y), false); mTextureState = Valid; diff --git a/gfx/ipc/GfxMessageUtils.h b/gfx/ipc/GfxMessageUtils.h index 2ff02e1834..6f8f3f8382 100644 --- a/gfx/ipc/GfxMessageUtils.h +++ b/gfx/ipc/GfxMessageUtils.h @@ -391,28 +391,6 @@ struct ParamTraits > } }; -template<> -struct ParamTraits -{ - typedef nsIntRect paramType; - - static void Write(Message* msg, const paramType& param) - { - WriteParam(msg, param.x); - WriteParam(msg, param.y); - WriteParam(msg, param.width); - WriteParam(msg, param.height); - } - - static bool Read(const Message* msg, void** iter, paramType* result) - { - return (ReadParam(msg, iter, &result->x) && - ReadParam(msg, iter, &result->y) && - ReadParam(msg, iter, &result->width) && - ReadParam(msg, iter, &result->height)); - } -}; - template struct RegionParamTraits { diff --git a/gfx/layers/Compositor.h b/gfx/layers/Compositor.h index 5f8113d433..cabe3b0914 100644 --- a/gfx/layers/Compositor.h +++ b/gfx/layers/Compositor.h @@ -120,7 +120,6 @@ namespace layers { struct Effect; struct EffectChain; class Image; -class ISurfaceAllocator; class Layer; class TextureSource; class DataTextureSource; diff --git a/gfx/layers/CopyableCanvasLayer.h b/gfx/layers/CopyableCanvasLayer.h index 340f7b3c4a..f8cf20d5a7 100644 --- a/gfx/layers/CopyableCanvasLayer.h +++ b/gfx/layers/CopyableCanvasLayer.h @@ -21,9 +21,12 @@ #include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, etc namespace mozilla { -namespace layers { -class CanvasClientWebGL; +namespace gl { +class SharedSurface; +} + +namespace layers { /** * A shared CanvasLayer implementation that supports copying diff --git a/gfx/layers/ImageContainer.h b/gfx/layers/ImageContainer.h index f46d7ad7a9..53251f42e8 100644 --- a/gfx/layers/ImageContainer.h +++ b/gfx/layers/ImageContainer.h @@ -95,7 +95,6 @@ typedef void* HANDLE; namespace mozilla { -class CrossProcessMutex; namespace layers { @@ -103,8 +102,6 @@ class ImageClient; class SharedPlanarYCbCrImage; class TextureClient; class CompositableClient; -class CompositableForwarder; -class SurfaceDescriptor; class GrallocImage; struct ImageBackendData diff --git a/gfx/layers/LayerMetricsWrapper.h b/gfx/layers/LayerMetricsWrapper.h index 5c39f3b05d..4c35b7bbc1 100644 --- a/gfx/layers/LayerMetricsWrapper.h +++ b/gfx/layers/LayerMetricsWrapper.h @@ -309,6 +309,16 @@ public: return EventRegions(); } + bool HasTransformAnimation() const + { + MOZ_ASSERT(IsValid()); + + if (AtBottomLayer()) { + return mLayer->HasTransformAnimation(); + } + return false; + } + RefLayer* AsRefLayer() const { MOZ_ASSERT(IsValid()); diff --git a/gfx/layers/LayerTreeInvalidation.cpp b/gfx/layers/LayerTreeInvalidation.cpp index 56a8f08bf0..c0f4768466 100644 --- a/gfx/layers/LayerTreeInvalidation.cpp +++ b/gfx/layers/LayerTreeInvalidation.cpp @@ -21,8 +21,7 @@ #include "nsDebug.h" // for NS_ASSERTION #include "nsHashKeys.h" // for nsPtrHashKey #include "nsISupportsImpl.h" // for Layer::AddRef, etc -#include "nsPoint.h" // for nsIntPoint -#include "nsRect.h" // for nsIntRect +#include "nsRect.h" // for IntRect #include "nsTArray.h" // for nsAutoTArray, nsTArray_Impl using namespace mozilla::gfx; @@ -33,20 +32,20 @@ namespace layers { struct LayerPropertiesBase; UniquePtr CloneLayerTreePropertiesInternal(Layer* aRoot, bool aIsMask = false); -static nsIntRect -TransformRect(const nsIntRect& aRect, const Matrix4x4& aTransform) +static IntRect +TransformRect(const IntRect& aRect, const Matrix4x4& aTransform) { if (aRect.IsEmpty()) { - return nsIntRect(); + return IntRect(); } Rect rect(aRect.x, aRect.y, aRect.width, aRect.height); rect = aTransform.TransformBounds(rect); rect.RoundOut(); - nsIntRect intRect; + IntRect intRect; if (!gfxUtils::GfxRectToIntRect(ThebesRect(rect), &intRect)) { - return nsIntRect(); + return IntRect(); } return intRect; @@ -56,7 +55,7 @@ static void AddTransformedRegion(nsIntRegion& aDest, const nsIntRegion& aSource, const Matrix4x4& aTransform) { nsIntRegionRectIterator iter(aSource); - const nsIntRect *r; + const IntRect *r; while ((r = iter.Next())) { aDest.Or(aDest, TransformRect(*r, aTransform)); } @@ -127,12 +126,12 @@ struct LayerPropertiesBase : public LayerProperties { MOZ_COUNT_DTOR(LayerPropertiesBase); } - - virtual nsIntRegion ComputeDifferences(Layer* aRoot, + + virtual nsIntRegion ComputeDifferences(Layer* aRoot, NotifySubDocInvalidationFunc aCallback, bool* aGeometryChanged); - virtual void MoveBy(const nsIntPoint& aOffset); + virtual void MoveBy(const IntPoint& aOffset); nsIntRegion ComputeChange(NotifySubDocInvalidationFunc aCallback, bool& aGeometryChanged) @@ -176,12 +175,12 @@ struct LayerPropertiesBase : public LayerProperties return result; } - nsIntRect NewTransformedBounds() + IntRect NewTransformedBounds() { return TransformRect(mLayer->GetVisibleRegion().GetBounds(), mLayer->GetLocalTransform()); } - nsIntRect OldTransformedBounds() + IntRect OldTransformedBounds() { return TransformRect(mVisibleRegion.GetBounds(), mTransform); } @@ -189,7 +188,7 @@ struct LayerPropertiesBase : public LayerProperties virtual nsIntRegion ComputeChangeInternal(NotifySubDocInvalidationFunc aCallback, bool& aGeometryChanged) { - return nsIntRect(); + return IntRect(); } nsRefPtr mLayer; @@ -351,7 +350,7 @@ struct ColorLayerProperties : public LayerPropertiesBase } gfxRGBA mColor; - nsIntRect mBounds; + IntRect mBounds; }; struct ImageLayerProperties : public LayerPropertiesBase @@ -373,7 +372,7 @@ struct ImageLayerProperties : public LayerPropertiesBase if (!imageLayer->GetVisibleRegion().IsEqual(mVisibleRegion)) { aGeometryChanged = true; - nsIntRect result = NewTransformedBounds(); + IntRect result = NewTransformedBounds(); result = result.Union(OldTransformedBounds()); return result; } @@ -389,7 +388,7 @@ struct ImageLayerProperties : public LayerPropertiesBase // Mask layers have an empty visible region, so we have to // use the image size instead. IntSize size = container->GetCurrentSize(); - nsIntRect rect(0, 0, size.width, size.height); + IntRect rect(0, 0, size.width, size.height); return TransformRect(rect, mLayer->GetLocalTransform()); } else { @@ -397,7 +396,7 @@ struct ImageLayerProperties : public LayerPropertiesBase } } - return nsIntRect(); + return IntRect(); } nsRefPtr mContainer; @@ -466,7 +465,7 @@ LayerPropertiesBase::ComputeDifferences(Layer* aRoot, NotifySubDocInvalidationFu } else { ClearInvalidations(aRoot); } - nsIntRect result = TransformRect(aRoot->GetVisibleRegion().GetBounds(), + IntRect result = TransformRect(aRoot->GetVisibleRegion().GetBounds(), aRoot->GetLocalTransform()); result = result.Union(OldTransformedBounds()); if (aGeometryChanged != nullptr) { @@ -484,7 +483,7 @@ LayerPropertiesBase::ComputeDifferences(Layer* aRoot, NotifySubDocInvalidationFu } void -LayerPropertiesBase::MoveBy(const nsIntPoint& aOffset) +LayerPropertiesBase::MoveBy(const IntPoint& aOffset) { mTransform.PostTranslate(aOffset.x, aOffset.y, 0); } diff --git a/gfx/layers/LayerTreeInvalidation.h b/gfx/layers/LayerTreeInvalidation.h index ab71b65e55..d262480380 100644 --- a/gfx/layers/LayerTreeInvalidation.h +++ b/gfx/layers/LayerTreeInvalidation.h @@ -8,9 +8,7 @@ #include "nsRegion.h" // for nsIntRegion #include "mozilla/UniquePtr.h" // for UniquePtr - -class nsPresContext; -struct nsIntPoint; +#include "mozilla/gfx/Point.h" namespace mozilla { namespace layers { @@ -59,12 +57,11 @@ struct LayerProperties * are invalidated. * @return Painted area changed by the layer tree changes. */ - virtual nsIntRegion ComputeDifferences(Layer* aRoot, + virtual nsIntRegion ComputeDifferences(Layer* aRoot, NotifySubDocInvalidationFunc aCallback, bool* aGeometryChanged = nullptr) = 0; - - - virtual void MoveBy(const nsIntPoint& aOffset) = 0; + + virtual void MoveBy(const gfx::IntPoint& aOffset) = 0; }; } // namespace layers diff --git a/gfx/layers/Layers.cpp b/gfx/layers/Layers.cpp index daa5dc5cac..6e39d39122 100644 --- a/gfx/layers/Layers.cpp +++ b/gfx/layers/Layers.cpp @@ -764,6 +764,17 @@ Layer::GetLocalTransform() return transform; } +bool +Layer::HasTransformAnimation() const +{ + for (uint32_t i = 0; i < mAnimations.Length(); i++) { + if (mAnimations[i].property() == eCSSProperty_transform) { + return true; + } + } + return false; +} + void Layer::ApplyPendingUpdatesForThisTransaction() { diff --git a/gfx/layers/Layers.h b/gfx/layers/Layers.h index c418f124d6..144d3066cb 100644 --- a/gfx/layers/Layers.h +++ b/gfx/layers/Layers.h @@ -57,11 +57,9 @@ namespace mozilla { class ComputedTimingFunction; class FrameLayerBuilder; class StyleAnimationValue; -class WebGLContext; namespace gl { class GLContext; -class SharedSurface; } namespace gfx { @@ -78,7 +76,6 @@ class Animation; class AnimationData; class AsyncPanZoomController; class ClientLayerManager; -class CommonLayerAttributes; class Layer; class LayerMetricsWrapper; class PaintedLayer; @@ -95,10 +92,7 @@ class ShadowableLayer; class ShadowLayerForwarder; class LayerManagerComposite; class SpecificLayerAttributes; -class SurfaceDescriptor; class Compositor; -struct TextureFactoryIdentifier; -struct EffectMask; namespace layerscope { class LayersPacket; @@ -1285,6 +1279,8 @@ public: uint64_t GetAnimationGeneration() { return mAnimationGeneration; } void SetAnimationGeneration(uint64_t aCount) { mAnimationGeneration = aCount; } + bool HasTransformAnimation() const; + /** * Returns the local transform for this layer: either mTransform or, * for shadow layers, GetShadowTransform() diff --git a/gfx/layers/LayersLogging.h b/gfx/layers/LayersLogging.h index 241b1a2100..ef8a60849a 100644 --- a/gfx/layers/LayersLogging.h +++ b/gfx/layers/LayersLogging.h @@ -17,8 +17,6 @@ #include "nscore.h" // for nsACString, etc struct gfxRGBA; -struct nsIntPoint; -struct nsIntRect; namespace mozilla { namespace gfx { @@ -52,10 +50,6 @@ void AppendToString(std::stringstream& aStream, const nsRect& r, const char* pfx="", const char* sfx=""); -void -AppendToString(std::stringstream& aStream, const nsIntPoint& p, - const char* pfx="", const char* sfx=""); - template void AppendToString(std::stringstream& aStream, const mozilla::gfx::PointTyped& p, @@ -72,10 +66,6 @@ AppendToString(std::stringstream& aStream, const mozilla::gfx::IntPointTyped& aStream << pfx << p << sfx; } -void -AppendToString(std::stringstream& aStream, const nsIntRect& r, - const char* pfx="", const char* sfx=""); - template void AppendToString(std::stringstream& aStream, const mozilla::gfx::RectTyped& r, diff --git a/gfx/layers/ReadbackLayer.h b/gfx/layers/ReadbackLayer.h index 6253eaa51c..a8dfd17d4e 100644 --- a/gfx/layers/ReadbackLayer.h +++ b/gfx/layers/ReadbackLayer.h @@ -9,14 +9,13 @@ #include // for uint64_t #include "Layers.h" // for Layer, etc #include "gfxColor.h" // for gfxRGBA -#include "gfxRect.h" // for gfxRect +#include "mozilla/gfx/Rect.h" // for gfxRect +#include "mozilla/gfx/Point.h" // for gfxRect #include "mozilla/mozalloc.h" // for operator delete #include "nsAutoPtr.h" // for nsAutoPtr #include "nsCOMPtr.h" // for already_AddRefed #include "nsDebug.h" // for NS_ASSERTION #include "nsPoint.h" // for nsIntPoint -#include "nsRect.h" // for nsIntRect -#include "nsSize.h" // for nsIntSize #include "nscore.h" // for nsACString class gfxContext; @@ -61,14 +60,14 @@ public: * first BeginUpdate after a SetUnknown will have the complete background. */ virtual already_AddRefed - BeginUpdate(const nsIntRect& aRect, uint64_t aSequenceNumber) = 0; + BeginUpdate(const gfx::IntRect& aRect, uint64_t aSequenceNumber) = 0; /** * EndUpdate must be called immediately after BeginUpdate, without returning * to the event loop. * @param aContext the context returned by BeginUpdate * Implicitly Restore()s the state of aContext. */ - virtual void EndUpdate(gfxContext* aContext, const nsIntRect& aRect) = 0; + virtual void EndUpdate(gfxContext* aContext, const gfx::IntRect& aRect) = 0; }; /** @@ -122,13 +121,13 @@ public: * has its top-left at 0,0 and has size aSize. * Can only be called while the sink is null! */ - void SetSize(const nsIntSize& aSize) + void SetSize(const gfx::IntSize& aSize) { NS_ASSERTION(!mSink, "Should have no sink while changing size!"); mSize = aSize; } - const nsIntSize& GetSize() { return mSize; } - nsIntRect GetRect() { return nsIntRect(nsIntPoint(0, 0), mSize); } + const gfx::IntSize& GetSize() { return mSize; } + gfx::IntRect GetRect() { return gfx::IntRect(gfx::IntPoint(0, 0), mSize); } bool IsBackgroundKnown() { @@ -180,7 +179,7 @@ protected: uint64_t mSequenceCounter; nsAutoPtr mSink; - nsIntSize mSize; + gfx::IntSize mSize; // This can refer to any (earlier) sibling PaintedLayer. That PaintedLayer // must have mUsedForReadback set on it. If the PaintedLayer is removed diff --git a/gfx/layers/RotatedBuffer.cpp b/gfx/layers/RotatedBuffer.cpp index 32ce3143f9..16494525ad 100644 --- a/gfx/layers/RotatedBuffer.cpp +++ b/gfx/layers/RotatedBuffer.cpp @@ -34,12 +34,12 @@ using namespace gfx; namespace layers { -nsIntRect +IntRect RotatedBuffer::GetQuadrantRectangle(XSide aXSide, YSide aYSide) const { // quadrantTranslation is the amount we translate the top-left // of the quadrant by to get coordinates relative to the layer - nsIntPoint quadrantTranslation = -mBufferRotation; + IntPoint quadrantTranslation = -mBufferRotation; quadrantTranslation.x += aXSide == LEFT ? mBufferRect.width : 0; quadrantTranslation.y += aYSide == TOP ? mBufferRect.height : 0; return mBufferRect + quadrantTranslation; @@ -89,8 +89,8 @@ RotatedBuffer::DrawBufferQuadrant(gfx::DrawTarget* aTarget, // render the buffer at mBufferRect + quadrantTranslation to get the // pixels in the right place, but we're only going to paint within // mBufferRect - nsIntRect quadrantRect = GetQuadrantRectangle(aXSide, aYSide); - nsIntRect fillRect; + IntRect quadrantRect = GetQuadrantRectangle(aXSide, aYSide); + IntRect fillRect; if (!fillRect.IntersectRect(mBufferRect, quadrantRect)) return; @@ -241,11 +241,11 @@ RotatedContentBuffer::DrawTo(PaintedLayer* aLayer, } DrawTarget* -RotatedContentBuffer::BorrowDrawTargetForQuadrantUpdate(const nsIntRect& aBounds, +RotatedContentBuffer::BorrowDrawTargetForQuadrantUpdate(const IntRect& aBounds, ContextSource aSource, DrawIterator* aIter) { - nsIntRect bounds = aBounds; + IntRect bounds = aBounds; if (aIter) { // If an iterator was provided, then BeginPaint must have been run with // PAINT_CAN_DRAW_ROTATED, and the draw region might cover multiple quadrants. @@ -254,7 +254,7 @@ RotatedContentBuffer::BorrowDrawTargetForQuadrantUpdate(const nsIntRect& aBounds // quadrants we have considered across multiple calls to this function. aIter->mDrawRegion.SetEmpty(); while (aIter->mCount < 4) { - nsIntRect quadrant = GetQuadrantRectangle((aIter->mCount & 1) ? LEFT : RIGHT, + IntRect quadrant = GetQuadrantRectangle((aIter->mCount & 1) ? LEFT : RIGHT, (aIter->mCount & 2) ? TOP : BOTTOM); aIter->mDrawRegion.And(aBounds, quadrant); aIter->mCount++; @@ -294,7 +294,7 @@ RotatedContentBuffer::BorrowDrawTargetForQuadrantUpdate(const nsIntRect& aBounds int32_t yBoundary = mBufferRect.YMost() - mBufferRotation.y; XSide sideX = bounds.XMost() <= xBoundary ? RIGHT : LEFT; YSide sideY = bounds.YMost() <= yBoundary ? BOTTOM : TOP; - nsIntRect quadrantRect = GetQuadrantRectangle(sideX, sideY); + IntRect quadrantRect = GetQuadrantRectangle(sideX, sideY); NS_ASSERTION(quadrantRect.Contains(bounds), "Messed up quadrants"); mLoanedTransform = mLoanedDrawTarget->GetTransform(); @@ -390,10 +390,10 @@ WrapRotationAxis(int32_t* aRotationPoint, int32_t aSize) } } -static nsIntRect -ComputeBufferRect(const nsIntRect& aRequestedRect) +static IntRect +ComputeBufferRect(const IntRect& aRequestedRect) { - nsIntRect rect(aRequestedRect); + IntRect rect(aRequestedRect); // Set a minimum width to guarantee a minimum size of buffers we // allocate (and work around problems on some platforms with smaller // dimensions). 64 is the magic number needed to work around the @@ -447,7 +447,7 @@ RotatedContentBuffer::BeginPaint(PaintedLayer* aLayer, SurfaceMode mode; nsIntRegion neededRegion; - nsIntRect destBufferRect; + IntRect destBufferRect; bool canReuseBuffer = HaveBuffer(); @@ -464,7 +464,7 @@ RotatedContentBuffer::BeginPaint(PaintedLayer* aLayer, } else if (neededRegion.GetBounds().Size() <= mBufferRect.Size()) { // The buffer's big enough but doesn't contain everything that's // going to be visible. We'll move it. - destBufferRect = nsIntRect(neededRegion.GetBounds().TopLeft(), mBufferRect.Size()); + destBufferRect = IntRect(neededRegion.GetBounds().TopLeft(), mBufferRect.Size()); } else { destBufferRect = neededRegion.GetBounds(); } @@ -555,7 +555,7 @@ RotatedContentBuffer::BeginPaint(PaintedLayer* aLayer, FinalizeFrame(result.mRegionToDraw); } - nsIntRect drawBounds = result.mRegionToDraw.GetBounds(); + IntRect drawBounds = result.mRegionToDraw.GetBounds(); RefPtr destDTBuffer; RefPtr destDTBufferOnWhite; uint32_t bufferFlags = 0; @@ -566,40 +566,38 @@ RotatedContentBuffer::BeginPaint(PaintedLayer* aLayer, if (!EnsureBuffer()) { return result; } - nsIntRect keepArea; + IntRect keepArea; if (keepArea.IntersectRect(destBufferRect, mBufferRect)) { // Set mBufferRotation so that the pixels currently in mDTBuffer // will still be rendered in the right place when mBufferRect // changes to destBufferRect. - nsIntPoint newRotation = mBufferRotation + + IntPoint newRotation = mBufferRotation + (destBufferRect.TopLeft() - mBufferRect.TopLeft()); WrapRotationAxis(&newRotation.x, mBufferRect.width); WrapRotationAxis(&newRotation.y, mBufferRect.height); - NS_ASSERTION(nsIntRect(nsIntPoint(0,0), mBufferRect.Size()).Contains(newRotation), + NS_ASSERTION(gfx::IntRect(gfx::IntPoint(0,0), mBufferRect.Size()).Contains(newRotation), "newRotation out of bounds"); int32_t xBoundary = destBufferRect.XMost() - newRotation.x; int32_t yBoundary = destBufferRect.YMost() - newRotation.y; bool drawWrapsBuffer = (drawBounds.x < xBoundary && xBoundary < drawBounds.XMost()) || (drawBounds.y < yBoundary && yBoundary < drawBounds.YMost()); if ((drawWrapsBuffer && !(aFlags & PAINT_CAN_DRAW_ROTATED)) || - (newRotation != nsIntPoint(0,0) && !canHaveRotation)) { + (newRotation != IntPoint(0,0) && !canHaveRotation)) { // The stuff we need to redraw will wrap around an edge of the // buffer (and the caller doesn't know how to support that), so // move the pixels we can keep into a position that lets us // redraw in just one quadrant. - if (mBufferRotation == nsIntPoint(0,0)) { - nsIntRect srcRect(nsIntPoint(0, 0), mBufferRect.Size()); - nsIntPoint dest = mBufferRect.TopLeft() - destBufferRect.TopLeft(); + if (mBufferRotation == IntPoint(0,0)) { + IntRect srcRect(IntPoint(0, 0), mBufferRect.Size()); + IntPoint dest = mBufferRect.TopLeft() - destBufferRect.TopLeft(); MOZ_ASSERT(mDTBuffer); - mDTBuffer->CopyRect(IntRect(srcRect.x, srcRect.y, srcRect.width, srcRect.height), - IntPoint(dest.x, dest.y)); + mDTBuffer->CopyRect(srcRect, dest); if (mode == SurfaceMode::SURFACE_COMPONENT_ALPHA) { if (!EnsureBufferOnWhite()) { return result; } MOZ_ASSERT(mDTBufferOnWhite); - mDTBufferOnWhite->CopyRect(IntRect(srcRect.x, srcRect.y, srcRect.width, srcRect.height), - IntPoint(dest.x, dest.y)); + mDTBufferOnWhite->CopyRect(srcRect, dest); } result.mDidSelfCopy = true; mDidSelfCopy = true; @@ -641,7 +639,7 @@ RotatedContentBuffer::BeginPaint(PaintedLayer* aLayer, result.mDidSelfCopy = true; mDidSelfCopy = true; mBufferRect = destBufferRect; - mBufferRotation = nsIntPoint(0, 0); + mBufferRotation = IntPoint(0, 0); } if (!result.mDidSelfCopy) { @@ -664,7 +662,7 @@ RotatedContentBuffer::BeginPaint(PaintedLayer* aLayer, // will be redrawn, so we don't need to copy anything, so we don't // set destBuffer. mBufferRect = destBufferRect; - mBufferRotation = nsIntPoint(0,0); + mBufferRotation = IntPoint(0,0); } } else { // The buffer's not big enough, so allocate a new one @@ -687,7 +685,7 @@ RotatedContentBuffer::BeginPaint(PaintedLayer* aLayer, if (destDTBuffer) { if (!isClear && (mode != SurfaceMode::SURFACE_COMPONENT_ALPHA || HaveBufferOnWhite())) { // Copy the bits - nsIntPoint offset = -destBufferRect.TopLeft(); + IntPoint offset = -destBufferRect.TopLeft(); Matrix mat = Matrix::Translation(offset.x, offset.y); destDTBuffer->SetTransform(mat); if (!EnsureBuffer()) { @@ -711,9 +709,9 @@ RotatedContentBuffer::BeginPaint(PaintedLayer* aLayer, mDTBuffer = destDTBuffer.forget(); mDTBufferOnWhite = destDTBufferOnWhite.forget(); mBufferRect = destBufferRect; - mBufferRotation = nsIntPoint(0,0); + mBufferRotation = IntPoint(0,0); } - NS_ASSERTION(canHaveRotation || mBufferRotation == nsIntPoint(0,0), + NS_ASSERTION(canHaveRotation || mBufferRotation == IntPoint(0,0), "Rotation disabled, but we have nonzero rotation?"); nsIntRegion invalidate; @@ -759,7 +757,7 @@ RotatedContentBuffer::BorrowDrawTargetForPainting(PaintState& aPaintState, return nullptr; } nsIntRegionRectIterator iter(*drawPtr); - const nsIntRect *iterRect; + const IntRect *iterRect; while ((iterRect = iter.Next())) { mDTBuffer->FillRect(Rect(iterRect->x, iterRect->y, iterRect->width, iterRect->height), ColorPattern(Color(0.0, 0.0, 0.0, 1.0))); @@ -769,7 +767,7 @@ RotatedContentBuffer::BorrowDrawTargetForPainting(PaintState& aPaintState, } else if (aPaintState.mContentType == gfxContentType::COLOR_ALPHA && HaveBuffer()) { // HaveBuffer() => we have an existing buffer that we must clear nsIntRegionRectIterator iter(*drawPtr); - const nsIntRect *iterRect; + const IntRect *iterRect; while ((iterRect = iter.Next())) { result->ClearRect(Rect(iterRect->x, iterRect->y, iterRect->width, iterRect->height)); } diff --git a/gfx/layers/RotatedBuffer.h b/gfx/layers/RotatedBuffer.h index c13f3432a8..0e2ecaaf3d 100644 --- a/gfx/layers/RotatedBuffer.h +++ b/gfx/layers/RotatedBuffer.h @@ -16,8 +16,6 @@ #include "nsCOMPtr.h" // for already_AddRefed #include "nsDebug.h" // for NS_RUNTIMEABORT #include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, etc -#include "nsPoint.h" // for nsIntPoint -#include "nsRect.h" // for nsIntRect #include "nsRegion.h" // for nsIntRegion #include "LayersTypes.h" @@ -50,8 +48,8 @@ class RotatedBuffer { public: typedef gfxContentType ContentType; - RotatedBuffer(const nsIntRect& aBufferRect, - const nsIntPoint& aBufferRotation) + RotatedBuffer(const gfx::IntRect& aBufferRect, + const gfx::IntPoint& aBufferRotation) : mBufferRect(aBufferRect) , mBufferRotation(aBufferRotation) , mDidSelfCopy(false) @@ -81,8 +79,8 @@ public: * RotatedBuffer covers. That is what DrawBufferWithRotation() * will paint when it's called. */ - const nsIntRect& BufferRect() const { return mBufferRect; } - const nsIntPoint& BufferRotation() const { return mBufferRotation; } + const gfx::IntRect& BufferRect() const { return mBufferRect; } + const gfx::IntPoint& BufferRotation() const { return mBufferRotation; } virtual bool HaveBuffer() const = 0; virtual bool HaveBufferOnWhite() const = 0; @@ -97,7 +95,7 @@ protected: enum YSide { TOP, BOTTOM }; - nsIntRect GetQuadrantRectangle(XSide aXSide, YSide aYSide) const; + gfx::IntRect GetQuadrantRectangle(XSide aXSide, YSide aYSide) const; gfx::Rect GetSourceRectangle(XSide aXSide, YSide aYSide) const; @@ -114,7 +112,7 @@ protected: const gfx::Matrix* aMaskTransform) const; /** The area of the PaintedLayer that is covered by the buffer as a whole */ - nsIntRect mBufferRect; + gfx::IntRect mBufferRect; /** * The x and y rotation of the buffer. Conceptually the buffer * has its origin translated to mBufferRect.TopLeft() - mBufferRotation, @@ -125,7 +123,7 @@ protected: * where items falling off the end of the buffer are returned to the * buffer at the other end, not 2D rotation! */ - nsIntPoint mBufferRotation; + gfx::IntPoint mBufferRotation; // When this is true it means that all pixels have moved inside the buffer. // It's not possible to sync with another buffer without a full copy. bool mDidSelfCopy; @@ -135,8 +133,8 @@ class SourceRotatedBuffer : public RotatedBuffer { public: SourceRotatedBuffer(gfx::SourceSurface* aSource, gfx::SourceSurface* aSourceOnWhite, - const nsIntRect& aBufferRect, - const nsIntPoint& aBufferRotation) + const gfx::IntRect& aBufferRect, + const gfx::IntPoint& aBufferRotation) : RotatedBuffer(aBufferRect, aBufferRotation) , mSource(aSource) , mSourceOnWhite(aSourceOnWhite) @@ -310,7 +308,7 @@ public: * will be used. */ virtual void - CreateBuffer(ContentType aType, const nsIntRect& aRect, uint32_t aFlags, + CreateBuffer(ContentType aType, const gfx::IntRect& aRect, uint32_t aFlags, RefPtr* aBlackDT, RefPtr* aWhiteDT) = 0; /** @@ -375,7 +373,7 @@ protected: * draw target, if necessary. */ gfx::DrawTarget* - BorrowDrawTargetForQuadrantUpdate(const nsIntRect& aBounds, + BorrowDrawTargetForQuadrantUpdate(const gfx::IntRect& aBounds, ContextSource aSource, DrawIterator* aIter); diff --git a/gfx/layers/TextureDIB.cpp b/gfx/layers/TextureDIB.cpp index e35966a1bc..bff213a0f9 100644 --- a/gfx/layers/TextureDIB.cpp +++ b/gfx/layers/TextureDIB.cpp @@ -126,7 +126,7 @@ DIBTextureHost::DIBTextureHost(TextureFlags aFlags, dont_AddRef(reinterpret_cast(aDescriptor.surface())); MOZ_ASSERT(mSurface); - mSize = ToIntSize(mSurface->GetSize()); + mSize = mSurface->GetSize(); mFormat = ImageFormatToSurfaceFormat( gfxPlatform::GetPlatform()->OptimalFormatForContent(mSurface->GetContentType())); } diff --git a/gfx/layers/YCbCrImageDataSerializer.cpp b/gfx/layers/YCbCrImageDataSerializer.cpp index e0653e71e8..afe535aec0 100644 --- a/gfx/layers/YCbCrImageDataSerializer.cpp +++ b/gfx/layers/YCbCrImageDataSerializer.cpp @@ -5,7 +5,6 @@ #include "mozilla/layers/YCbCrImageDataSerializer.h" #include // for memcpy -#include "gfx2DGlue.h" // for ToIntSize #include "mozilla/gfx/2D.h" // for DataSourceSurface, Factory #include "mozilla/gfx/BaseSize.h" // for BaseSize #include "mozilla/gfx/Logging.h" // for gfxDebug diff --git a/gfx/layers/apz/src/APZCTreeManager.h b/gfx/layers/apz/src/APZCTreeManager.h index 2b68154502..3abafa1d8e 100644 --- a/gfx/layers/apz/src/APZCTreeManager.h +++ b/gfx/layers/apz/src/APZCTreeManager.h @@ -41,7 +41,6 @@ enum AllowedTouchBehavior { class Layer; class AsyncPanZoomController; class CompositorParent; -class APZPaintLogHelper; class OverscrollHandoffChain; struct OverscrollHandoffState; class LayerMetricsWrapper; diff --git a/gfx/layers/apz/src/InputQueue.h b/gfx/layers/apz/src/InputQueue.h index a48afb28dd..cb8ef196be 100644 --- a/gfx/layers/apz/src/InputQueue.h +++ b/gfx/layers/apz/src/InputQueue.h @@ -20,7 +20,6 @@ class ScrollWheelInput; namespace layers { class AsyncPanZoomController; -class OverscrollHandoffChain; class CancelableBlockState; class TouchBlockState; class WheelBlockState; diff --git a/gfx/layers/apz/test/apz_test_native_event_utils.js b/gfx/layers/apz/test/apz_test_native_event_utils.js new file mode 100644 index 0000000000..ea4fcb28d5 --- /dev/null +++ b/gfx/layers/apz/test/apz_test_native_event_utils.js @@ -0,0 +1,75 @@ +// Utilities for synthesizing of native events. + +function getPlatform() { + if (navigator.platform.indexOf("Win") == 0) { + return "windows"; + } + if (navigator.platform.indexOf("Mac") == 0) { + return "mac"; + } + if (navigator.platform.indexOf("Linux") == 0) { + return "linux"; + } + return "unknown"; +} + +function nativeVerticalWheelEventMsg() { + switch (getPlatform()) { + case "windows": return 0x020A; // WM_MOUSEWHEEL + case "mac": return 0; // value is unused, can be anything + case "linux": return 4; // value is unused, pass GDK_SCROLL_SMOOTH anyway + } + throw "Native wheel events not supported on platform " + getPlatform(); +} + +function nativeHorizontalWheelEventMsg() { + switch (getPlatform()) { + case "windows": return 0x020E; // WM_MOUSEHWHEEL + case "mac": return 0; // value is unused, can be anything + case "linux": return 4; // value is unused, pass GDK_SCROLL_SMOOTH anyway + } + throw "Native wheel events not supported on platform " + getPlatform(); +} + +// Synthesizes a native mousewheel event and returns immediately. This does not +// guarantee anything; you probably want to use one of the other functions below +// which actually wait for results. +// aX and aY are relative to |window|'s top-left. aDeltaX and aDeltaY +// are pixel deltas, and aObserver can be left undefined if not needed. +function synthesizeNativeWheel(aElement, aX, aY, aDeltaX, aDeltaY, aObserver) { + aX += window.mozInnerScreenX; + aY += window.mozInnerScreenY; + if (aDeltaX && aDeltaY) { + throw "Simultaneous wheeling of horizontal and vertical is not supported on all platforms."; + } + var msg = aDeltaX ? nativeHorizontalWheelEventMsg() : nativeVerticalWheelEventMsg(); + _getDOMWindowUtils().sendNativeMouseScrollEvent(aX, aY, msg, aDeltaX, aDeltaY, 0, 0, 0, aElement, aObserver); + return true; +} + +// Synthesizes a native mousewheel event and invokes the callback once the +// request has been successfully made to the OS. This does not necessarily +// guarantee that the OS generates the event we requested. See +// synthesizeNativeWheel for details on the parameters. +function synthesizeNativeWheelAndWaitForObserver(aElement, aX, aY, aDeltaX, aDeltaY, aCallback) { + var observer = { + observe: function(aSubject, aTopic, aData) { + if (aCallback && aTopic == "mousescrollevent") { + setTimeout(aCallback, 0); + } + } + }; + return synthesizeNativeWheel(aElement, aX, aY, aDeltaX, aDeltaY, observer); +} + +// Synthesizes a native mousewheel event and invokes the callback once the +// wheel event is dispatched to the window. See synthesizeNativeWheel for +// details on the parameters. +function synthesizeNativeWheelAndWaitForEvent(aElement, aX, aY, aDeltaX, aDeltaY, aCallback) { + window.addEventListener("wheel", function wheelWaiter(e) { + window.removeEventListener("wheel", wheelWaiter); + setTimeout(aCallback, 0); + }); + return synthesizeNativeWheel(aElement, aX, aY, aDeltaX, aDeltaY); +} + diff --git a/gfx/layers/apz/test/mochitest.ini b/gfx/layers/apz/test/mochitest.ini index 3dc9e92f15..d49848641f 100644 --- a/gfx/layers/apz/test/mochitest.ini +++ b/gfx/layers/apz/test/mochitest.ini @@ -2,3 +2,5 @@ skip-if = toolkit != 'gonk' # bug 991198 support-files = helper_bug982141.html +[test_wheel_scroll.html] +skip-if = (os == 'android') || (os == 'b2g') # wheel events not supported diff --git a/gfx/layers/apz/test/test_wheel_scroll.html b/gfx/layers/apz/test/test_wheel_scroll.html new file mode 100644 index 0000000000..0210b0cb0a --- /dev/null +++ b/gfx/layers/apz/test/test_wheel_scroll.html @@ -0,0 +1,117 @@ + + + + + Test for Bug 1013412 + + + + + + + +Mozilla Bug 1161206 +

+
+

Scrolling the page should be async, but scrolling over the dark circle should not scroll the page and instead rotate the white ball.

+
+
+
+
+
+
+
+
+
+ + + + diff --git a/gfx/layers/apz/util/ActiveElementManager.h b/gfx/layers/apz/util/ActiveElementManager.h index 68ccc13b4f..1b357da3f2 100644 --- a/gfx/layers/apz/util/ActiveElementManager.h +++ b/gfx/layers/apz/util/ActiveElementManager.h @@ -9,7 +9,6 @@ #include "nsCOMPtr.h" #include "nsISupportsImpl.h" -class inIDOMUtils; class CancelableTask; namespace mozilla { diff --git a/gfx/layers/apz/util/ChromeProcessController.h b/gfx/layers/apz/util/ChromeProcessController.h index 340e4a2ab3..1366b62a7f 100644 --- a/gfx/layers/apz/util/ChromeProcessController.h +++ b/gfx/layers/apz/util/ChromeProcessController.h @@ -22,7 +22,6 @@ namespace mozilla { namespace layers { class APZEventState; -class CompositorParent; // A ChromeProcessController is attached to the root of a compositor's layer // tree. diff --git a/gfx/layers/basic/BasicCanvasLayer.h b/gfx/layers/basic/BasicCanvasLayer.h index 1fcc8786e2..3e5d4a19d4 100644 --- a/gfx/layers/basic/BasicCanvasLayer.h +++ b/gfx/layers/basic/BasicCanvasLayer.h @@ -13,8 +13,6 @@ #include "nsDebug.h" // for NS_ASSERTION #include "nsRegion.h" // for nsIntRegion -class gfxContext; - namespace mozilla { namespace layers { diff --git a/gfx/layers/basic/BasicCompositor.h b/gfx/layers/basic/BasicCompositor.h index b534adb0bf..b5910396cf 100644 --- a/gfx/layers/basic/BasicCompositor.h +++ b/gfx/layers/basic/BasicCompositor.h @@ -11,8 +11,6 @@ #include "mozilla/gfx/2D.h" #include "nsAutoPtr.h" -class gfxContext; - namespace mozilla { namespace layers { diff --git a/gfx/layers/basic/BasicContainerLayer.cpp b/gfx/layers/basic/BasicContainerLayer.cpp index 58c8d6da2c..8609f6534b 100644 --- a/gfx/layers/basic/BasicContainerLayer.cpp +++ b/gfx/layers/basic/BasicContainerLayer.cpp @@ -14,7 +14,6 @@ #include "nsCOMPtr.h" // for already_AddRefed #include "nsISupportsImpl.h" // for Layer::AddRef, etc #include "nsPoint.h" // for nsIntPoint -#include "nsRect.h" // for nsIntRect #include "nsRegion.h" // for nsIntRegion #include "ReadbackProcessor.h" @@ -78,7 +77,7 @@ BasicContainerLayer::ComputeEffectiveTransforms(const Matrix4x4& aTransformToSur } bool -BasicContainerLayer::ChildrenPartitionVisibleRegion(const nsIntRect& aInRect) +BasicContainerLayer::ChildrenPartitionVisibleRegion(const gfx::IntRect& aInRect) { Matrix transform; if (!GetEffectiveTransform().CanDraw2D(&transform) || @@ -86,7 +85,7 @@ BasicContainerLayer::ChildrenPartitionVisibleRegion(const nsIntRect& aInRect) return false; nsIntPoint offset(int32_t(transform._31), int32_t(transform._32)); - nsIntRect rect = aInRect.Intersect(GetEffectiveVisibleRegion().GetBounds() + offset); + gfx::IntRect rect = aInRect.Intersect(GetEffectiveVisibleRegion().GetBounds() + offset); nsIntRegion covered; for (Layer* l = mFirstChild; l; l = l->GetNextSibling()) { diff --git a/gfx/layers/basic/BasicContainerLayer.h b/gfx/layers/basic/BasicContainerLayer.h index d4f649daa8..beca21da3f 100644 --- a/gfx/layers/basic/BasicContainerLayer.h +++ b/gfx/layers/basic/BasicContainerLayer.h @@ -12,7 +12,7 @@ #include "nsDebug.h" // for NS_ASSERTION #include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR #include "nsISupportsUtils.h" // for NS_ADDREF, NS_RELEASE -struct nsIntRect; +#include "mozilla/gfx/Rect.h" namespace mozilla { namespace layers { @@ -77,7 +77,7 @@ public: * This method can be conservative; it's OK to return false under any * circumstances. */ - bool ChildrenPartitionVisibleRegion(const nsIntRect& aInRect); + bool ChildrenPartitionVisibleRegion(const gfx::IntRect& aInRect); void ForceIntermediateSurface() { mUseIntermediateSurface = true; } diff --git a/gfx/layers/basic/BasicImplData.h b/gfx/layers/basic/BasicImplData.h index 92778bb207..f127121de1 100644 --- a/gfx/layers/basic/BasicImplData.h +++ b/gfx/layers/basic/BasicImplData.h @@ -15,7 +15,6 @@ namespace mozilla { namespace layers { class ReadbackProcessor; -class SurfaceDescriptor; /** * This is the ImplData for all Basic layers. It also exposes methods diff --git a/gfx/layers/basic/BasicLayerManager.cpp b/gfx/layers/basic/BasicLayerManager.cpp index 1b22d7190e..79098f5aa4 100644 --- a/gfx/layers/basic/BasicLayerManager.cpp +++ b/gfx/layers/basic/BasicLayerManager.cpp @@ -639,7 +639,7 @@ Transform(const gfxImageSurface* aDest, return; } - IntSize destSize = ToIntSize(aDest->GetSize()); + IntSize destSize = aDest->GetSize(); SkImageInfo destInfo = SkImageInfo::Make(destSize.width, destSize.height, kBGRA_8888_SkColorType, @@ -697,7 +697,7 @@ Transform(const gfxImageSurface* aDest, const gfx3DMatrix& aTransform, gfxPoint aDestOffset) { - IntSize destSize = ToIntSize(aDest->GetSize()); + IntSize destSize = aDest->GetSize(); pixman_image_t* dest = pixman_image_create_bits(aDest->Format() == gfxImageFormat::ARGB32 ? PIXMAN_a8r8g8b8 : PIXMAN_x8r8g8b8, destSize.width, destSize.height, diff --git a/gfx/layers/basic/BasicLayers.h b/gfx/layers/basic/BasicLayers.h index b58f14229e..6450e6a1d0 100644 --- a/gfx/layers/basic/BasicLayers.h +++ b/gfx/layers/basic/BasicLayers.h @@ -20,18 +20,15 @@ #include "nsRegion.h" // for nsIntRegion #include "nscore.h" // for nsAString, etc -class gfxPattern; class nsIWidget; namespace mozilla { namespace layers { -class BasicShadowableLayer; class ImageFactory; class ImageLayer; class PaintLayerContext; class ReadbackLayer; -class ReadbackProcessor; /** * This is a cairo/Thebes-only, main-thread-only implementation of layers. diff --git a/gfx/layers/basic/BasicLayersImpl.h b/gfx/layers/basic/BasicLayersImpl.h index af9799be25..2bafd068b4 100644 --- a/gfx/layers/basic/BasicLayersImpl.h +++ b/gfx/layers/basic/BasicLayersImpl.h @@ -25,7 +25,6 @@ class DrawTarget; namespace layers { class AutoMoz2DMaskData; -class BasicContainerLayer; class Layer; class AutoSetOperator { diff --git a/gfx/layers/basic/TextureClientX11.cpp b/gfx/layers/basic/TextureClientX11.cpp index a5bb5b85fd..31388fec11 100644 --- a/gfx/layers/basic/TextureClientX11.cpp +++ b/gfx/layers/basic/TextureClientX11.cpp @@ -144,7 +144,7 @@ TextureClientX11::BorrowDrawTarget() } if (!mDrawTarget) { - IntSize size = ToIntSize(mSurface->GetSize()); + IntSize size = mSurface->GetSize(); mDrawTarget = Factory::CreateDrawTargetForCairoSurface(mSurface->CairoSurface(), size); } diff --git a/gfx/layers/basic/X11TextureSourceBasic.cpp b/gfx/layers/basic/X11TextureSourceBasic.cpp index 4eb0689082..62b09b4b97 100644 --- a/gfx/layers/basic/X11TextureSourceBasic.cpp +++ b/gfx/layers/basic/X11TextureSourceBasic.cpp @@ -21,7 +21,7 @@ X11TextureSourceBasic::X11TextureSourceBasic(BasicCompositor* aCompositor, gfxXl IntSize X11TextureSourceBasic::GetSize() const { - return ToIntSize(mSurface->GetSize()); + return mSurface->GetSize(); } SurfaceFormat diff --git a/gfx/layers/client/ClientPaintedLayer.h b/gfx/layers/client/ClientPaintedLayer.h index 55c0663129..670a1c75fd 100644 --- a/gfx/layers/client/ClientPaintedLayer.h +++ b/gfx/layers/client/ClientPaintedLayer.h @@ -18,8 +18,6 @@ #include "nsRegion.h" // for nsIntRegion #include "mozilla/layers/PLayerTransaction.h" // for PaintedLayerAttributes -class gfxContext; - namespace mozilla { namespace layers { diff --git a/gfx/layers/client/ClientTiledPaintedLayer.cpp b/gfx/layers/client/ClientTiledPaintedLayer.cpp index 81f8eb887f..4ba1fa9dfc 100644 --- a/gfx/layers/client/ClientTiledPaintedLayer.cpp +++ b/gfx/layers/client/ClientTiledPaintedLayer.cpp @@ -18,12 +18,15 @@ #include "mozilla/layers/LayersMessages.h" #include "mozilla/mozalloc.h" // for operator delete, etc #include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, etc -#include "nsRect.h" // for nsIntRect #include "LayersLogging.h" namespace mozilla { namespace layers { +using gfx::Rect; +using gfx::IntRect; +using gfx::IntSize; + ClientTiledPaintedLayer::ClientTiledPaintedLayer(ClientLayerManager* const aManager, ClientLayerManager::PaintedLayerCreationHint aCreationHint) : PaintedLayer(aManager, static_cast(this), aCreationHint) @@ -91,11 +94,14 @@ GetTransformToAncestorsParentLayer(Layer* aStart, const LayerMetricsWrapper& aAn void ClientTiledPaintedLayer::GetAncestorLayers(LayerMetricsWrapper* aOutScrollAncestor, - LayerMetricsWrapper* aOutDisplayPortAncestor) + LayerMetricsWrapper* aOutDisplayPortAncestor, + bool* aOutHasTransformAnimation) { LayerMetricsWrapper scrollAncestor; LayerMetricsWrapper displayPortAncestor; + bool hasTransformAnimation = false; for (LayerMetricsWrapper ancestor(this, LayerMetricsWrapper::StartAt::BOTTOM); ancestor; ancestor = ancestor.GetParent()) { + hasTransformAnimation |= ancestor.HasTransformAnimation(); const FrameMetrics& metrics = ancestor.Metrics(); if (!scrollAncestor && metrics.GetScrollId() != FrameMetrics::NULL_SCROLL_ID) { scrollAncestor = ancestor; @@ -113,6 +119,9 @@ ClientTiledPaintedLayer::GetAncestorLayers(LayerMetricsWrapper* aOutScrollAncest if (aOutDisplayPortAncestor) { *aOutDisplayPortAncestor = displayPortAncestor; } + if (aOutHasTransformAnimation) { + *aOutHasTransformAnimation = hasTransformAnimation; + } } void @@ -134,7 +143,8 @@ ClientTiledPaintedLayer::BeginPaint() // with a displayport. LayerMetricsWrapper scrollAncestor; LayerMetricsWrapper displayPortAncestor; - GetAncestorLayers(&scrollAncestor, &displayPortAncestor); + bool hasTransformAnimation; + GetAncestorLayers(&scrollAncestor, &displayPortAncestor, &hasTransformAnimation); if (!displayPortAncestor || !scrollAncestor) { // No displayport or scroll ancestor, so we can't do progressive rendering. @@ -146,8 +156,8 @@ ClientTiledPaintedLayer::BeginPaint() return; } - TILING_LOG("TILING %p: Found scrollAncestor %p and displayPortAncestor %p\n", this, - scrollAncestor.GetLayer(), displayPortAncestor.GetLayer()); + TILING_LOG("TILING %p: Found scrollAncestor %p, displayPortAncestor %p, transform %d\n", this, + scrollAncestor.GetLayer(), displayPortAncestor.GetLayer(), hasTransformAnimation); const FrameMetrics& scrollMetrics = scrollAncestor.Metrics(); const FrameMetrics& displayportMetrics = displayPortAncestor.Metrics(); @@ -159,12 +169,17 @@ ClientTiledPaintedLayer::BeginPaint() transformDisplayPortToLayer.Invert(); // Compute the critical display port that applies to this layer in the - // LayoutDevice space of this layer. - ParentLayerRect criticalDisplayPort = - (displayportMetrics.GetCriticalDisplayPort() * displayportMetrics.GetZoom()) - + displayportMetrics.mCompositionBounds.TopLeft(); - mPaintData.mCriticalDisplayPort = RoundedOut( - ApplyParentLayerToLayerTransform(transformDisplayPortToLayer, criticalDisplayPort)); + // LayoutDevice space of this layer, but only if there is no OMT animation + // on this layer. If there is an OMT animation then we need to draw the whole + // visible region of this layer as determined by layout, because we don't know + // what parts of it might move into view in the compositor. + if (!hasTransformAnimation) { + ParentLayerRect criticalDisplayPort = + (displayportMetrics.GetCriticalDisplayPort() * displayportMetrics.GetZoom()) + + displayportMetrics.mCompositionBounds.TopLeft(); + mPaintData.mCriticalDisplayPort = RoundedToInt( + ApplyParentLayerToLayerTransform(transformDisplayPortToLayer, criticalDisplayPort)); + } TILING_LOG("TILING %p: Critical displayport %s\n", this, Stringify(mPaintData.mCriticalDisplayPort).c_str()); // Store the resolution from the displayport ancestor layer. Because this is Goanna-side, @@ -216,52 +231,47 @@ ClientTiledPaintedLayer::IsScrollingOnCompositor(const FrameMetrics& aParentMetr COORDINATE_EPSILON); } -bool -ClientTiledPaintedLayer::UseFastPath() -{ - // The fast path doesn't allow rendering at low resolution. It will draw the low-res - // area at full resolution and cause OOM. - if (gfxPrefs::UseLowPrecisionBuffer()) { - return false; - } - - LayerMetricsWrapper scrollAncestor; - GetAncestorLayers(&scrollAncestor, nullptr); - if (!scrollAncestor) { - return true; - } - const FrameMetrics& parentMetrics = scrollAncestor.Metrics(); - - bool multipleTransactionsNeeded = gfxPlatform::GetPlatform()->UseProgressivePaint() - || !parentMetrics.GetCriticalDisplayPort().IsEmpty(); - bool isFixed = GetIsFixedPosition() || GetParent()->GetIsFixedPosition(); - bool isScrollable = parentMetrics.IsScrollable(); - - return !multipleTransactionsNeeded || isFixed || !isScrollable; -} - bool ClientTiledPaintedLayer::UseProgressiveDraw() { - // Don't draw progressively in a reftest scenario (that's what the HasShadowTarget() check is for). - if (!gfxPlatform::GetPlatform()->UseProgressivePaint() || ClientManager()->HasShadowTarget()) { + if (!gfxPlatform::GetPlatform()->UseProgressivePaint()) { + // pref is disabled, so never do progressive return false; } - // XXX We probably want to disable progressive drawing for non active APZ layers in the future - // but we should wait for a proper test case before making this change. - -#if 0 //!defined(MOZ_WIDGET_ANDROID) || defined(MOZ_ANDROID_APZ) - LayerMetricsWrapper scrollAncestor; - GetAncestorLayers(&scrollAncestor, nullptr); - if (!scrollAncestor) { - return true; + if (ClientManager()->HasShadowTarget()) { + // This condition is true when we are in a reftest scenario. We don't want + // to draw progressively here because it can cause intermittent reftest + // failures because the harness won't wait for all the tiles to be drawn. + return false; + } + + if (mPaintData.mCriticalDisplayPort.IsEmpty()) { + // This catches three scenarios: + // 1) This layer doesn't have a scrolling ancestor + // 2) This layer is subject to OMTA transforms + // 3) Low-precision painting is disabled + // In all of these cases, we don't want to draw this layer progressively. + return false; + } + + if (GetIsFixedPosition() || GetParent()->GetIsFixedPosition()) { + // This layer is fixed-position and so even if it does have a scrolling + // ancestor it will likely be entirely on-screen all the time, so we + // should draw it all at once + return false; + } + + if (gfxPrefs::AsyncPanZoomEnabled()) { + LayerMetricsWrapper scrollAncestor; + GetAncestorLayers(&scrollAncestor, nullptr, nullptr); + MOZ_ASSERT(scrollAncestor); // because mPaintData.mCriticalDisplayPort is non-empty + const FrameMetrics& parentMetrics = scrollAncestor.Metrics(); + if (!IsScrollingOnCompositor(parentMetrics)) { + return false; + } } - const FrameMetrics& parentMetrics = scrollAncestor.Metrics(); - return !IsScrollingOnCompositor(parentMetrics); -#else return true; -#endif } bool @@ -306,6 +316,7 @@ ClientTiledPaintedLayer::RenderHighPrecision(nsIntRegion& aInvalidRegion, mContentClient->mTiledBuffer.SetFrameResolution(mPaintData.mResolution); mContentClient->mTiledBuffer.PaintThebes(mValidRegion, aInvalidRegion, aCallback, aCallbackData); + mPaintData.mPaintFinished = true; return true; } @@ -416,12 +427,12 @@ ClientTiledPaintedLayer::RenderLayer() // outside of our texture coords. Make the visible region a single rect, // and pad it out by 1 pixel (restricted to tile boundaries) so that // we always have valid content or transparent pixels to sample from. - nsIntRect bounds = neededRegion.GetBounds(); - nsIntRect wholeTiles = bounds; - wholeTiles.Inflate(nsIntSize( + IntRect bounds = neededRegion.GetBounds(); + IntRect wholeTiles = bounds; + wholeTiles.InflateToMultiple(IntSize( gfxPlatform::GetPlatform()->GetTileWidth(), gfxPlatform::GetPlatform()->GetTileHeight())); - nsIntRect padded = bounds; + IntRect padded = bounds; padded.Inflate(1); padded.IntersectRect(padded, wholeTiles); neededRegion = padded; @@ -441,16 +452,6 @@ ClientTiledPaintedLayer::RenderLayer() ToClientLayer(GetMaskLayer())->RenderLayer(); } - // In some cases we can take a fast path and just be done with it. - if (UseFastPath()) { - TILING_LOG("TILING %p: Taking fast-path\n", this); - mValidRegion = neededRegion; - mContentClient->mTiledBuffer.PaintThebes(mValidRegion, invalidRegion, callback, data); - ClientManager()->Hold(this); - mContentClient->UseTiledLayerBuffer(TiledContentClient::TILED_BUFFER); - return; - } - // For more complex cases we need to calculate a bunch of metrics before we // can do the paint. BeginPaint(); diff --git a/gfx/layers/client/ClientTiledPaintedLayer.h b/gfx/layers/client/ClientTiledPaintedLayer.h index 9920f121b4..db7538de01 100644 --- a/gfx/layers/client/ClientTiledPaintedLayer.h +++ b/gfx/layers/client/ClientTiledPaintedLayer.h @@ -12,8 +12,6 @@ #include "nsDebug.h" // for NS_RUNTIMEABORT #include "nsRegion.h" // for nsIntRegion -class gfxContext; - namespace mozilla { namespace layers { @@ -81,7 +79,8 @@ public: * which hold the return values; the values passed in may be null. */ void GetAncestorLayers(LayerMetricsWrapper* aOutScrollAncestor, - LayerMetricsWrapper* aOutDisplayPortAncestor); + LayerMetricsWrapper* aOutDisplayPortAncestor, + bool* aOutHasTransformAnimation); private: ClientLayerManager* ClientManager() @@ -95,12 +94,6 @@ private: */ void BeginPaint(); - /** - * Determine if we can use a fast path to just do a single high-precision, - * non-progressive paint. - */ - bool UseFastPath(); - /** * Check if the layer is being scrolled by APZ on the compositor. */ diff --git a/gfx/layers/client/CompositableClient.h b/gfx/layers/client/CompositableClient.h index a73cfb51ee..04688ab75d 100644 --- a/gfx/layers/client/CompositableClient.h +++ b/gfx/layers/client/CompositableClient.h @@ -27,7 +27,6 @@ class BufferTextureClient; class ImageBridgeChild; class CompositableForwarder; class CompositableChild; -class SurfaceDescriptor; class PCompositableChild; /** diff --git a/gfx/layers/client/ContentClient.h b/gfx/layers/client/ContentClient.h index 7a97708a7e..99d5a95547 100644 --- a/gfx/layers/client/ContentClient.h +++ b/gfx/layers/client/ContentClient.h @@ -28,8 +28,6 @@ #include "nsRegion.h" // for nsIntRegion #include "nsTArray.h" // for nsTArray -class gfxContext; - namespace mozilla { namespace gfx { class DrawTarget; @@ -37,7 +35,6 @@ class DrawTarget; namespace layers { -class BasicLayerManager; class PaintedLayer; /** diff --git a/gfx/layers/client/TextureClient.h b/gfx/layers/client/TextureClient.h index 546868d14f..5975631683 100644 --- a/gfx/layers/client/TextureClient.h +++ b/gfx/layers/client/TextureClient.h @@ -29,7 +29,6 @@ #include "nsISupportsImpl.h" // for TextureImage::AddRef, etc #include "GfxTexturesReporter.h" -class gfxReusableSurfaceWrapper; class gfxImageSurface; namespace mozilla { @@ -47,11 +46,9 @@ class SharedSurface; namespace layers { class AsyncTransactionTracker; -class ContentClient; class CompositableForwarder; class ISurfaceAllocator; class CompositableClient; -class PlanarYCbCrImage; struct PlanarYCbCrData; class Image; class PTextureChild; diff --git a/gfx/layers/client/TiledContentClient.cpp b/gfx/layers/client/TiledContentClient.cpp index d7235df394..274a0d05e7 100644 --- a/gfx/layers/client/TiledContentClient.cpp +++ b/gfx/layers/client/TiledContentClient.cpp @@ -1362,7 +1362,7 @@ ClientTiledLayerBuffer::ComputeProgressiveUpdateRegion(const nsIntRegion& aInval TILING_LOG("TILING %p: Progressive update stale region %s\n", mPaintedLayer, Stringify(staleRegion).c_str()); LayerMetricsWrapper scrollAncestor; - mPaintedLayer->GetAncestorLayers(&scrollAncestor, nullptr); + mPaintedLayer->GetAncestorLayers(&scrollAncestor, nullptr, nullptr); // Find out the current view transform to determine which tiles to draw // first, and see if we should just abort this paint. Aborting is usually diff --git a/gfx/layers/client/TiledContentClient.h b/gfx/layers/client/TiledContentClient.h index 19649f0acf..e9e66358ed 100644 --- a/gfx/layers/client/TiledContentClient.h +++ b/gfx/layers/client/TiledContentClient.h @@ -41,7 +41,6 @@ namespace mozilla { namespace layers { -class BasicTileDescriptor; class ClientTiledPaintedLayer; class ClientLayerManager; diff --git a/gfx/layers/composite/CanvasLayerComposite.cpp b/gfx/layers/composite/CanvasLayerComposite.cpp index 0f6e90638f..1e5cb7f04c 100644 --- a/gfx/layers/composite/CanvasLayerComposite.cpp +++ b/gfx/layers/composite/CanvasLayerComposite.cpp @@ -17,7 +17,6 @@ #include "nsAString.h" #include "mozilla/nsRefPtr.h" // for nsRefPtr #include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, etc -#include "nsPoint.h" // for nsIntPoint #include "nsString.h" // for nsAutoCString #include "gfxVR.h" diff --git a/gfx/layers/composite/CanvasLayerComposite.h b/gfx/layers/composite/CanvasLayerComposite.h index 90c3008dbe..589d472fe0 100644 --- a/gfx/layers/composite/CanvasLayerComposite.h +++ b/gfx/layers/composite/CanvasLayerComposite.h @@ -14,7 +14,6 @@ #include "nsDebug.h" // for NS_RUNTIMEABORT #include "nsRect.h" // for nsIntRect #include "nscore.h" // for nsACString -struct nsIntPoint; namespace mozilla { namespace layers { diff --git a/gfx/layers/composite/ColorLayerComposite.cpp b/gfx/layers/composite/ColorLayerComposite.cpp index 5258cc88d0..824803f3ba 100644 --- a/gfx/layers/composite/ColorLayerComposite.cpp +++ b/gfx/layers/composite/ColorLayerComposite.cpp @@ -14,20 +14,18 @@ #include "mozilla/layers/CompositorTypes.h" // for DiagnosticFlags::COLOR #include "mozilla/layers/Effects.h" // for Effect, EffectChain, etc #include "mozilla/mozalloc.h" // for operator delete, etc -#include "nsPoint.h" // for nsIntPoint -#include "nsRect.h" // for nsIntRect namespace mozilla { namespace layers { void -ColorLayerComposite::RenderLayer(const nsIntRect& aClipRect) +ColorLayerComposite::RenderLayer(const gfx::IntRect& aClipRect) { EffectChain effects(this); GenEffectChain(effects); - nsIntRect boundRect = GetBounds(); + gfx::IntRect boundRect = GetBounds(); LayerManagerComposite::AutoAddMaskEffect autoMaskEffect(GetMaskLayer(), effects); diff --git a/gfx/layers/composite/ColorLayerComposite.h b/gfx/layers/composite/ColorLayerComposite.h index d1ea6d6e31..fb019f74f3 100644 --- a/gfx/layers/composite/ColorLayerComposite.h +++ b/gfx/layers/composite/ColorLayerComposite.h @@ -11,9 +11,6 @@ #include "mozilla/layers/LayerManagerComposite.h" // for LayerComposite, etc #include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, etc -struct nsIntPoint; -struct nsIntRect; - namespace mozilla { namespace layers { @@ -50,7 +47,7 @@ public: virtual void Destroy() override { mDestroyed = true; } - virtual void RenderLayer(const nsIntRect& aClipRect) override; + virtual void RenderLayer(const gfx::IntRect& aClipRect) override; virtual void CleanupResources() override {}; virtual void GenEffectChain(EffectChain& aEffect) override; diff --git a/gfx/layers/composite/CompositableHost.h b/gfx/layers/composite/CompositableHost.h index 7e35fc39c9..d1daf82b42 100644 --- a/gfx/layers/composite/CompositableHost.h +++ b/gfx/layers/composite/CompositableHost.h @@ -28,9 +28,6 @@ #include "nscore.h" // for nsACString #include "Units.h" // for CSSToScreenScale -struct nsIntPoint; -struct nsIntRect; - namespace mozilla { namespace gfx { class Matrix4x4; @@ -40,9 +37,7 @@ class DataSourceSurface; namespace layers { class Layer; -class SurfaceDescriptor; class Compositor; -class ISurfaceAllocator; class ThebesBufferData; class TiledLayerComposer; class CompositableParentManager; @@ -108,7 +103,7 @@ public: virtual LayerRenderState GetRenderState() = 0; - virtual void SetPictureRect(const nsIntRect& aPictureRect) + virtual void SetPictureRect(const gfx::IntRect& aPictureRect) { MOZ_ASSERT(false, "Should have been overridden"); } diff --git a/gfx/layers/composite/ContainerLayerComposite.cpp b/gfx/layers/composite/ContainerLayerComposite.cpp index f103e06058..769d0c0a13 100755 --- a/gfx/layers/composite/ContainerLayerComposite.cpp +++ b/gfx/layers/composite/ContainerLayerComposite.cpp @@ -29,8 +29,6 @@ #include "nsDebug.h" // for NS_ASSERTION #include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, etc #include "nsISupportsUtils.h" // for NS_ADDREF, NS_RELEASE -#include "nsPoint.h" // for nsIntPoint -#include "nsRect.h" // for nsIntRect #include "nsRegion.h" // for nsIntRegion #include "nsTArray.h" // for nsAutoTArray #include "TextRenderer.h" // for TextRenderer @@ -82,8 +80,8 @@ static void DrawLayerInfo(const RenderTargetIntRect& aClipRect, uint32_t maxWidth = std::min(visibleRegion.GetBounds().width, 500); - nsIntPoint topLeft = visibleRegion.GetBounds().TopLeft(); - aManager->GetTextRenderer()->RenderText(ss.str().c_str(), gfx::IntPoint(topLeft.x, topLeft.y), + IntPoint topLeft = visibleRegion.GetBounds().TopLeft(); + aManager->GetTextRenderer()->RenderText(ss.str().c_str(), topLeft, aLayer->GetEffectiveTransform(), 16, maxWidth); } @@ -91,9 +89,7 @@ static void DrawLayerInfo(const RenderTargetIntRect& aClipRect, template static gfx::IntRect ContainerVisibleRect(ContainerT* aContainer) { - nsIntRect visibleRect = aContainer->GetEffectiveVisibleRegion().GetBounds(); - gfx::IntRect surfaceRect = gfx::IntRect(visibleRect.x, visibleRect.y, - visibleRect.width, visibleRect.height); + gfx::IntRect surfaceRect = aContainer->GetEffectiveVisibleRegion().GetBounds(); return surfaceRect; } @@ -114,7 +110,7 @@ struct PreparedLayer template void ContainerRenderVR(ContainerT* aContainer, LayerManagerComposite* aManager, - const nsIntRect& aClipRect, + const gfx::IntRect& aClipRect, gfx::VRHMDInfo* aHMD) { RefPtr surface; @@ -123,7 +119,7 @@ ContainerRenderVR(ContainerT* aContainer, RefPtr previousTarget = compositor->GetCurrentRenderTarget(); - nsIntRect visibleRect = aContainer->GetEffectiveVisibleRegion().GetBounds(); + gfx::IntRect visibleRect = aContainer->GetEffectiveVisibleRegion().GetBounds(); float opacity = aContainer->GetEffectiveOpacity(); @@ -153,7 +149,7 @@ ContainerRenderVR(ContainerT* aContainer, /** * Render this container's contents. */ - nsIntRect surfaceClipRect(0, 0, surfaceRect.width, surfaceRect.height); + gfx::IntRect surfaceClipRect(0, 0, surfaceRect.width, surfaceRect.height); RenderTargetIntRect rtClipRect(0, 0, surfaceRect.width, surfaceRect.height); for (uint32_t i = 0; i < children.Length(); i++) { LayerComposite* layerToRender = static_cast(children.ElementAt(i)->ImplData()); @@ -329,7 +325,7 @@ RenderLayers(ContainerT* aContainer, // intersect areas in different coordinate spaces. So we do this a little more permissively // and only fill in the background when we know there is checkerboard, which in theory // should only occur transiently. - nsIntRect layerBounds = layer->GetLayerBounds(); + gfx::IntRect layerBounds = layer->GetLayerBounds(); EffectChain effectChain(layer); effectChain.mPrimaryEffect = new EffectSolidColor(ToColor(color)); aManager->GetCompositor()->DrawQuad(gfx::Rect(layerBounds.x, layerBounds.y, layerBounds.width, layerBounds.height), @@ -342,12 +338,12 @@ RenderLayers(ContainerT* aContainer, // Composer2D will compose this layer so skip GPU composition // this time & reset composition flag for next composition phase layerToRender->SetLayerComposited(false); - nsIntRect clearRect = layerToRender->GetClearRect(); + gfx::IntRect clearRect = layerToRender->GetClearRect(); if (!clearRect.IsEmpty()) { // Clear layer's visible rect on FrameBuffer with transparent pixels gfx::Rect fbRect(clearRect.x, clearRect.y, clearRect.width, clearRect.height); compositor->ClearRect(fbRect); - layerToRender->SetClearRect(nsIntRect(0, 0, 0, 0)); + layerToRender->SetClearRect(gfx::IntRect(0, 0, 0, 0)); } } else { layerToRender->RenderLayer(RenderTargetPixel::ToUntyped(clipRect)); @@ -413,7 +409,7 @@ CreateTemporaryTargetAndCopyFromBackground(ContainerT* aContainer, LayerManagerComposite* aManager) { Compositor* compositor = aManager->GetCompositor(); - nsIntRect visibleRect = aContainer->GetEffectiveVisibleRegion().GetBounds(); + gfx::IntRect visibleRect = aContainer->GetEffectiveVisibleRegion().GetBounds(); RefPtr previousTarget = compositor->GetCurrentRenderTarget(); gfx::IntRect surfaceRect = gfx::IntRect(visibleRect.x, visibleRect.y, visibleRect.width, visibleRect.height); @@ -433,7 +429,7 @@ CreateTemporaryTargetAndCopyFromBackground(ContainerT* aContainer, template void RenderIntermediate(ContainerT* aContainer, LayerManagerComposite* aManager, - const nsIntRect& aClipRect, + const gfx::IntRect& aClipRect, RefPtr surface) { Compositor* compositor = aManager->GetCompositor(); @@ -453,7 +449,7 @@ RenderIntermediate(ContainerT* aContainer, template void ContainerRender(ContainerT* aContainer, LayerManagerComposite* aManager, - const nsIntRect& aClipRect) + const gfx::IntRect& aClipRect) { MOZ_ASSERT(aContainer->mPrepared); @@ -483,7 +479,7 @@ ContainerRender(ContainerT* aContainer, float opacity = aContainer->GetEffectiveOpacity(); - nsIntRect visibleRect = aContainer->GetEffectiveVisibleRegion().GetBounds(); + gfx::IntRect visibleRect = aContainer->GetEffectiveVisibleRegion().GetBounds(); #ifdef MOZ_DUMP_PAINTING if (gfxUtils::sDumpPainting) { RefPtr surf = surface->Dump(aManager->GetCompositor()); @@ -582,7 +578,7 @@ ContainerLayerComposite::GetFirstChildComposite() } void -ContainerLayerComposite::RenderLayer(const nsIntRect& aClipRect) +ContainerLayerComposite::RenderLayer(const gfx::IntRect& aClipRect) { ContainerRender(this, mCompositeManager, aClipRect); } @@ -633,7 +629,7 @@ RefLayerComposite::GetFirstChildComposite() } void -RefLayerComposite::RenderLayer(const nsIntRect& aClipRect) +RefLayerComposite::RenderLayer(const gfx::IntRect& aClipRect) { ContainerRender(this, mCompositeManager, aClipRect); } diff --git a/gfx/layers/composite/ContainerLayerComposite.h b/gfx/layers/composite/ContainerLayerComposite.h index b8440eadf3..656e33b2f8 100644 --- a/gfx/layers/composite/ContainerLayerComposite.h +++ b/gfx/layers/composite/ContainerLayerComposite.h @@ -10,9 +10,7 @@ #include "mozilla/Attributes.h" // for override #include "mozilla/UniquePtr.h" // for UniquePtr #include "mozilla/layers/LayerManagerComposite.h" - -struct nsIntPoint; -struct nsIntRect; +#include "mozilla/gfx/Rect.h" namespace mozilla { namespace layers { @@ -39,7 +37,7 @@ class ContainerLayerComposite : public ContainerLayer, template friend void RenderIntermediate(ContainerT* aContainer, LayerManagerComposite* aManager, - const nsIntRect& aClipRect, + const gfx::IntRect& aClipRect, RefPtr surface); template friend RefPtr @@ -77,7 +75,7 @@ public: LayerComposite* GetFirstChildComposite() override; - virtual void RenderLayer(const nsIntRect& aClipRect) override; + virtual void RenderLayer(const gfx::IntRect& aClipRect) override; virtual void Prepare(const RenderTargetIntRect& aClipRect) override; virtual void ComputeEffectiveTransforms(const gfx::Matrix4x4& aTransformToSurface) override @@ -126,26 +124,26 @@ class RefLayerComposite : public RefLayer, template friend void ContainerRender(ContainerT* aContainer, LayerManagerComposite* aManager, - const nsIntRect& aClipRect); + const gfx::IntRect& aClipRect); template friend void RenderLayers(ContainerT* aContainer, LayerManagerComposite* aManager, - const nsIntRect& aClipRect); + const gfx::IntRect& aClipRect); template friend void RenderIntermediate(ContainerT* aContainer, LayerManagerComposite* aManager, - const nsIntRect& aClipRect, + const gfx::IntRect& aClipRect, RefPtr surface); template friend RefPtr CreateTemporaryTargetAndCopyFromBackground(ContainerT* aContainer, LayerManagerComposite* aManager, - const nsIntRect& aClipRect); + const gfx::IntRect& aClipRect); template friend RefPtr CreateTemporaryTarget(ContainerT* aContainer, LayerManagerComposite* aManager, - const nsIntRect& aClipRect); + const gfx::IntRect& aClipRect); public: explicit RefLayerComposite(LayerManagerComposite *aManager); @@ -161,7 +159,7 @@ public: LayerComposite* GetFirstChildComposite() override; - virtual void RenderLayer(const nsIntRect& aClipRect) override; + virtual void RenderLayer(const gfx::IntRect& aClipRect) override; virtual void Prepare(const RenderTargetIntRect& aClipRect) override; virtual void ComputeEffectiveTransforms(const gfx::Matrix4x4& aTransformToSurface) override diff --git a/gfx/layers/composite/ContentHost.cpp b/gfx/layers/composite/ContentHost.cpp index db892208b6..a2a1a904d6 100644 --- a/gfx/layers/composite/ContentHost.cpp +++ b/gfx/layers/composite/ContentHost.cpp @@ -327,7 +327,7 @@ ContentHostSingleBuffered::UpdateThebes(const ThebesBufferData& aData, // Select only the pixels that are still within the buffer. nsIntRegion finalRegion; - finalRegion.And(nsIntRect(nsIntPoint(), bufferSize), destRegion); + finalRegion.And(IntRect(IntPoint(), bufferSize), destRegion); // For each of the overlap areas (right, bottom-right, bottom), select those // pixels and wrap them around to the opposite edge of the buffer rect. diff --git a/gfx/layers/composite/ContentHost.h b/gfx/layers/composite/ContentHost.h index 6cbc9c2457..a3346e43a0 100644 --- a/gfx/layers/composite/ContentHost.h +++ b/gfx/layers/composite/ContentHost.h @@ -42,7 +42,6 @@ class Compositor; class ThebesBufferData; class TiledLayerComposer; struct EffectChain; -class TextureImageTextureSourceOGL; struct TexturedEffect; diff --git a/gfx/layers/composite/FPSCounter.h b/gfx/layers/composite/FPSCounter.h index 4b669ffc74..bf594093db 100644 --- a/gfx/layers/composite/FPSCounter.h +++ b/gfx/layers/composite/FPSCounter.h @@ -16,13 +16,9 @@ #include "prio.h" // for NSPR file i/o namespace mozilla { -namespace gl { -class GLContext; -} namespace layers { class DataTextureSource; -class ShaderProgramOGL; class Compositor; // Dump the FPS histogram every 10 seconds or kMaxFrameFPS diff --git a/gfx/layers/composite/ImageHost.h b/gfx/layers/composite/ImageHost.h index 4a125104b0..b7176d876f 100644 --- a/gfx/layers/composite/ImageHost.h +++ b/gfx/layers/composite/ImageHost.h @@ -31,7 +31,6 @@ class Matrix4x4; namespace layers { class Compositor; -class ISurfaceAllocator; struct EffectChain; /** diff --git a/gfx/layers/composite/ImageLayerComposite.cpp b/gfx/layers/composite/ImageLayerComposite.cpp index e739f0e453..95064a8aab 100644 --- a/gfx/layers/composite/ImageLayerComposite.cpp +++ b/gfx/layers/composite/ImageLayerComposite.cpp @@ -21,8 +21,6 @@ #include "mozilla/nsRefPtr.h" // for nsRefPtr #include "nsDebug.h" // for NS_ASSERTION #include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, etc -#include "nsPoint.h" // for nsIntPoint -#include "nsRect.h" // for nsIntRect #include "nsString.h" // for nsAutoCString namespace mozilla { @@ -82,7 +80,7 @@ ImageLayerComposite::GetLayer() } void -ImageLayerComposite::RenderLayer(const nsIntRect& aClipRect) +ImageLayerComposite::RenderLayer(const IntRect& aClipRect) { if (!mImageHost || !mImageHost->IsAttached()) { return; diff --git a/gfx/layers/composite/ImageLayerComposite.h b/gfx/layers/composite/ImageLayerComposite.h index a5ffb53f57..d6b8c31e6a 100644 --- a/gfx/layers/composite/ImageLayerComposite.h +++ b/gfx/layers/composite/ImageLayerComposite.h @@ -9,6 +9,7 @@ #include "GLTextureImage.h" // for TextureImage #include "ImageLayers.h" // for ImageLayer #include "mozilla/Attributes.h" // for override +#include "mozilla/gfx/Rect.h" #include "mozilla/RefPtr.h" // for RefPtr #include "mozilla/layers/LayerManagerComposite.h" // for LayerComposite, etc #include "mozilla/layers/LayersTypes.h" // for LayerRenderState, etc @@ -16,9 +17,6 @@ #include "nscore.h" // for nsACString #include "CompositableHost.h" // for CompositableHost -struct nsIntPoint; -struct nsIntRect; - namespace mozilla { namespace layers { @@ -54,7 +52,7 @@ public: } } - virtual void RenderLayer(const nsIntRect& aClipRect) override; + virtual void RenderLayer(const gfx::IntRect& aClipRect) override; virtual void ComputeEffectiveTransforms(const mozilla::gfx::Matrix4x4& aTransformToSurface) override; diff --git a/gfx/layers/composite/LayerManagerComposite.h b/gfx/layers/composite/LayerManagerComposite.h index 3ace89817c..a1f052f83f 100644 --- a/gfx/layers/composite/LayerManagerComposite.h +++ b/gfx/layers/composite/LayerManagerComposite.h @@ -43,10 +43,6 @@ namespace gfx { class DrawTarget; } // namespace gfx -namespace gl { -class GLContext; -class TextureImage; -} namespace layers { @@ -60,7 +56,6 @@ class ImageLayer; class ImageLayerComposite; class LayerComposite; class RefLayerComposite; -class SurfaceDescriptor; class PaintedLayerComposite; class TiledLayerComposer; class TextRenderer; diff --git a/gfx/layers/composite/PaintedLayerComposite.cpp b/gfx/layers/composite/PaintedLayerComposite.cpp index e7da2232aa..6aae61f364 100644 --- a/gfx/layers/composite/PaintedLayerComposite.cpp +++ b/gfx/layers/composite/PaintedLayerComposite.cpp @@ -22,9 +22,6 @@ #include "mozilla/nsRefPtr.h" // for nsRefPtr #include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, etc #include "nsMathUtils.h" // for NS_lround -#include "nsPoint.h" // for nsIntPoint -#include "nsRect.h" // for nsIntRect -#include "nsSize.h" // for nsIntSize #include "nsString.h" // for nsAutoCString #include "TextRenderer.h" #include "GeckoProfiler.h" @@ -114,7 +111,7 @@ PaintedLayerComposite::GetRenderState() } void -PaintedLayerComposite::RenderLayer(const nsIntRect& aClipRect) +PaintedLayerComposite::RenderLayer(const gfx::IntRect& aClipRect) { if (!mBuffer || !mBuffer->IsAttached()) { return; diff --git a/gfx/layers/composite/PaintedLayerComposite.h b/gfx/layers/composite/PaintedLayerComposite.h index 5f87f47f0c..01cd5bf471 100644 --- a/gfx/layers/composite/PaintedLayerComposite.h +++ b/gfx/layers/composite/PaintedLayerComposite.h @@ -7,7 +7,7 @@ #define GFX_PaintedLayerComposite_H #include "Layers.h" // for Layer (ptr only), etc -#include "gfxRect.h" // for gfxRect +#include "mozilla/gfx/Rect.h" #include "mozilla/Attributes.h" // for override #include "mozilla/RefPtr.h" // for RefPtr #include "mozilla/layers/LayerManagerComposite.h" // for LayerComposite, etc @@ -16,9 +16,6 @@ #include "nsRegion.h" // for nsIntRegion #include "nscore.h" // for nsACString -struct nsIntPoint; -struct nsIntRect; - namespace mozilla { namespace layers { @@ -57,7 +54,7 @@ public: virtual TiledLayerComposer* GetTiledLayerComposer() override; - virtual void RenderLayer(const nsIntRect& aClipRect) override; + virtual void RenderLayer(const gfx::IntRect& aClipRect) override; virtual void CleanupResources() override; diff --git a/gfx/layers/composite/TextureHost.cpp b/gfx/layers/composite/TextureHost.cpp index f10a10cf35..dbcf36079e 100644 --- a/gfx/layers/composite/TextureHost.cpp +++ b/gfx/layers/composite/TextureHost.cpp @@ -7,7 +7,6 @@ #include "CompositableHost.h" // for CompositableHost #include "LayersLogging.h" // for AppendToString -#include "gfx2DGlue.h" // for ToIntSize #include "mozilla/gfx/2D.h" // for DataSourceSurface, Factory #include "mozilla/ipc/Shmem.h" // for Shmem #include "mozilla/layers/CompositableTransactionParent.h" // for CompositableParentManager @@ -59,8 +58,6 @@ #define RECYCLE_LOG(...) do { } while (0) #endif -struct nsIntPoint; - namespace mozilla { namespace layers { diff --git a/gfx/layers/composite/TextureHost.h b/gfx/layers/composite/TextureHost.h index 0b3dbf707a..36e0781401 100644 --- a/gfx/layers/composite/TextureHost.h +++ b/gfx/layers/composite/TextureHost.h @@ -28,9 +28,7 @@ #include "nsTraceRefcnt.h" // for MOZ_COUNT_CTOR, etc #include "nscore.h" // for nsACString #include "mozilla/layers/AtomicRefCountedWithFinalize.h" - -class gfxReusableSurfaceWrapper; -struct nsIntRect; +#include "mozilla/gfx/Rect.h" namespace mozilla { namespace gl { @@ -43,7 +41,6 @@ class Shmem; namespace layers { class Compositor; -class CompositableHost; class CompositableParentManager; class SurfaceDescriptor; class SharedSurfaceDescriptor; @@ -70,7 +67,7 @@ class BigImageIterator public: virtual void BeginBigImageIteration() = 0; virtual void EndBigImageIteration() {}; - virtual nsIntRect GetTileRect() = 0; + virtual gfx::IntRect GetTileRect() = 0; virtual size_t GetTileCount() = 0; virtual bool NextTile() = 0; }; diff --git a/gfx/layers/composite/TiledContentHost.cpp b/gfx/layers/composite/TiledContentHost.cpp index 74cfd6e166..df4cfee886 100644 --- a/gfx/layers/composite/TiledContentHost.cpp +++ b/gfx/layers/composite/TiledContentHost.cpp @@ -13,9 +13,9 @@ #include "mozilla/layers/TextureHostOGL.h" // for TextureHostOGL #include "nsAString.h" #include "nsDebug.h" // for NS_WARNING -#include "nsPoint.h" // for nsIntPoint +#include "nsPoint.h" // for IntPoint #include "nsPrintfCString.h" // for nsPrintfCString -#include "nsRect.h" // for nsIntRect +#include "nsRect.h" // for IntRect #include "nsSize.h" // for nsIntSize #include "mozilla/layers/TiledContentClient.h" @@ -171,7 +171,7 @@ TiledLayerBufferComposite::Upload() TileHost TiledLayerBufferComposite::ValidateTile(TileHost aTile, - const nsIntPoint& aTileOrigin, + const IntPoint& aTileOrigin, const nsIntRegion& aDirtyRect) { if (aTile.IsPlaceholderTile()) { @@ -482,7 +482,7 @@ TiledContentHost::RenderTile(const TileHost& aTile, const gfx::Filter& aFilter, const gfx::Rect& aClipRect, const nsIntRegion& aScreenRegion, - const nsIntPoint& aTextureOffset, + const IntPoint& aTextureOffset, const nsIntSize& aTextureBounds) { if (aTile.IsPlaceholderTile()) { @@ -494,7 +494,7 @@ TiledContentHost::RenderTile(const TileHost& aTile, if (aBackgroundColor) { aEffectChain.mPrimaryEffect = new EffectSolidColor(ToColor(*aBackgroundColor)); nsIntRegionRectIterator it(aScreenRegion); - for (const nsIntRect* rect = it.Next(); rect != nullptr; rect = it.Next()) { + for (const IntRect* rect = it.Next(); rect != nullptr; rect = it.Next()) { Rect graphicsRect(rect->x, rect->y, rect->width, rect->height); mCompositor->DrawQuad(graphicsRect, aClipRect, aEffectChain, 1.0, aTransform); } @@ -524,7 +524,7 @@ TiledContentHost::RenderTile(const TileHost& aTile, aEffectChain.mPrimaryEffect = effect; nsIntRegionRectIterator it(aScreenRegion); - for (const nsIntRect* rect = it.Next(); rect != nullptr; rect = it.Next()) { + for (const IntRect* rect = it.Next(); rect != nullptr; rect = it.Next()) { Rect graphicsRect(rect->x, rect->y, rect->width, rect->height); Rect textureRect(rect->x - aTextureOffset.x, rect->y - aTextureOffset.y, rect->width, rect->height); @@ -591,7 +591,7 @@ TiledContentHost::RenderLayerBuffer(TiledLayerBufferComposite& aLayerBuffer, uint32_t rowCount = 0; uint32_t tileX = 0; - nsIntRect visibleRect = aVisibleRegion.GetBounds(); + IntRect visibleRect = aVisibleRegion.GetBounds(); gfx::IntSize scaledTileSize = aLayerBuffer.GetScaledTileSize(); for (int32_t x = visibleRect.x; x < visibleRect.x + visibleRect.width;) { rowCount++; @@ -609,17 +609,17 @@ TiledContentHost::RenderLayerBuffer(TiledLayerBufferComposite& aLayerBuffer, } TileHost tileTexture = aLayerBuffer. - GetTile(nsIntPoint(aLayerBuffer.RoundDownToTileEdge(x, scaledTileSize.width), - aLayerBuffer.RoundDownToTileEdge(y, scaledTileSize.height))); + GetTile(IntPoint(aLayerBuffer.RoundDownToTileEdge(x, scaledTileSize.width), + aLayerBuffer.RoundDownToTileEdge(y, scaledTileSize.height))); if (tileTexture != aLayerBuffer.GetPlaceholderTile()) { nsIntRegion tileDrawRegion; - tileDrawRegion.And(nsIntRect(x, y, w, h), aLayerBuffer.GetValidRegion()); + tileDrawRegion.And(IntRect(x, y, w, h), aLayerBuffer.GetValidRegion()); tileDrawRegion.And(tileDrawRegion, aVisibleRegion); tileDrawRegion.Sub(tileDrawRegion, maskRegion); if (!tileDrawRegion.IsEmpty()) { tileDrawRegion.ScaleRoundOut(resolution, resolution); - nsIntPoint tileOffset((x - tileStartX) * resolution, + IntPoint tileOffset((x - tileStartX) * resolution, (y - tileStartY) * resolution); gfx::IntSize tileSize = aLayerBuffer.GetTileSize(); RenderTile(tileTexture, aBackgroundColor, aEffectChain, aOpacity, aTransform, diff --git a/gfx/layers/composite/TiledContentHost.h b/gfx/layers/composite/TiledContentHost.h index b5efd4d78d..e3f05821d1 100644 --- a/gfx/layers/composite/TiledContentHost.h +++ b/gfx/layers/composite/TiledContentHost.h @@ -31,10 +31,6 @@ #include #endif -class gfxReusableSurfaceWrapper; -struct nsIntPoint; -struct nsIntRect; - namespace mozilla { namespace gfx { class Matrix4x4; @@ -164,7 +160,7 @@ public: protected: TileHost ValidateTile(TileHost aTile, - const nsIntPoint& aTileRect, + const gfx::IntPoint& aTileRect, const nsIntRegion& dirtyRect); // do nothing, the desctructor in the texture host takes care of releasing resources @@ -303,7 +299,7 @@ private: const gfx::Filter& aFilter, const gfx::Rect& aClipRect, const nsIntRegion& aScreenRegion, - const nsIntPoint& aTextureOffset, + const gfx::IntPoint& aTextureOffset, const gfx::IntSize& aTextureBounds); void EnsureTileStore() {} diff --git a/gfx/layers/composite/X11TextureHost.cpp b/gfx/layers/composite/X11TextureHost.cpp index 240e4ac1b0..a63e6e148a 100644 --- a/gfx/layers/composite/X11TextureHost.cpp +++ b/gfx/layers/composite/X11TextureHost.cpp @@ -83,7 +83,7 @@ X11TextureHost::GetFormat() const IntSize X11TextureHost::GetSize() const { - return ToIntSize(mSurface->GetSize()); + return mSurface->GetSize(); } } diff --git a/gfx/layers/d3d11/CompositorD3D11.cpp b/gfx/layers/d3d11/CompositorD3D11.cpp index 4d22a3bcd0..8363aebb3b 100644 --- a/gfx/layers/d3d11/CompositorD3D11.cpp +++ b/gfx/layers/d3d11/CompositorD3D11.cpp @@ -1034,7 +1034,7 @@ CompositorD3D11::BeginFrame(const nsIntRegion& aInvalidRegion, UINT offset = 0; mContext->IASetVertexBuffers(0, 1, &buffer, &size, &offset); - nsIntRect intRect = nsIntRect(nsIntPoint(0, 0), mSize); + nsIntRect intRect = IntRect(IntPoint(0, 0), mSize); // Sometimes the invalid region is larger than we want to draw. nsIntRegion invalidRegionSafe; diff --git a/gfx/layers/d3d11/CompositorD3D11.h b/gfx/layers/d3d11/CompositorD3D11.h index 0f06b14616..4227512095 100644 --- a/gfx/layers/d3d11/CompositorD3D11.h +++ b/gfx/layers/d3d11/CompositorD3D11.h @@ -167,7 +167,7 @@ private: void SetPSForEffect(Effect *aEffect, MaskType aMaskType, gfx::SurfaceFormat aFormat); void PaintToTarget(); - virtual gfx::IntSize GetWidgetSize() const override { return gfx::ToIntSize(mSize); } + virtual gfx::IntSize GetWidgetSize() const override { return mSize; } RefPtr mContext; RefPtr mDevice; @@ -179,7 +179,7 @@ private: nsIWidget* mWidget; - nsIntSize mSize; + gfx::IntSize mSize; HWND mHwnd; diff --git a/gfx/layers/d3d11/TextureD3D11.h b/gfx/layers/d3d11/TextureD3D11.h index 18faf913d6..6bfd0cf7de 100644 --- a/gfx/layers/d3d11/TextureD3D11.h +++ b/gfx/layers/d3d11/TextureD3D11.h @@ -14,8 +14,6 @@ #include #include -class gfxD2DSurface; - namespace mozilla { namespace layers { diff --git a/gfx/layers/d3d9/CompositorD3D9.h b/gfx/layers/d3d9/CompositorD3D9.h index 404b760075..c6aba0e9c1 100644 --- a/gfx/layers/d3d9/CompositorD3D9.h +++ b/gfx/layers/d3d9/CompositorD3D9.h @@ -152,7 +152,7 @@ private: virtual gfx::IntSize GetWidgetSize() const override { - return gfx::ToIntSize(mSize); + return mSize; } /* Device manager instance for this compositor */ diff --git a/gfx/layers/d3d9/DeviceManagerD3D9.cpp b/gfx/layers/d3d9/DeviceManagerD3D9.cpp index 8b22d40b6e..4395041ad7 100644 --- a/gfx/layers/d3d9/DeviceManagerD3D9.cpp +++ b/gfx/layers/d3d9/DeviceManagerD3D9.cpp @@ -132,7 +132,7 @@ SwapChainD3D9::PrepareForRendering() } void -SwapChainD3D9::Present(const nsIntRect &aRect) +SwapChainD3D9::Present(const gfx::IntRect &aRect) { RECT r; r.left = aRect.x; diff --git a/gfx/layers/d3d9/DeviceManagerD3D9.h b/gfx/layers/d3d9/DeviceManagerD3D9.h index d5662ae5f2..6b8cb7c526 100644 --- a/gfx/layers/d3d9/DeviceManagerD3D9.h +++ b/gfx/layers/d3d9/DeviceManagerD3D9.h @@ -12,14 +12,12 @@ #include "nsTArray.h" #include "mozilla/layers/CompositorTypes.h" #include "mozilla/RefPtr.h" - -struct nsIntRect; +#include "mozilla/gfx/Rect.h" namespace mozilla { namespace layers { class DeviceManagerD3D9; -class LayerD3D9; class Nv3DVUtils; class Layer; class TextureSourceD3D9; @@ -102,7 +100,7 @@ public: * This function will present the selected rectangle of the swap chain to * its associated window. */ - void Present(const nsIntRect &aRect); + void Present(const gfx::IntRect &aRect); void Present(); private: diff --git a/gfx/layers/d3d9/TextureD3D9.cpp b/gfx/layers/d3d9/TextureD3D9.cpp index d12d598227..9193b10156 100644 --- a/gfx/layers/d3d9/TextureD3D9.cpp +++ b/gfx/layers/d3d9/TextureD3D9.cpp @@ -448,7 +448,7 @@ DataTextureSourceD3D9::Update(gfxWindowsSurface* aSurface) NS_WARNING("No D3D device to update the texture."); return false; } - mSize = ToIntSize(aSurface->GetSize()); + mSize = aSurface->GetSize(); uint32_t bpp = 0; diff --git a/gfx/layers/ipc/CompositableForwarder.h b/gfx/layers/ipc/CompositableForwarder.h index e38894891e..44dd6f7f24 100644 --- a/gfx/layers/ipc/CompositableForwarder.h +++ b/gfx/layers/ipc/CompositableForwarder.h @@ -15,9 +15,7 @@ #include "mozilla/layers/LayersTypes.h" // for LayersBackend #include "mozilla/layers/TextureClient.h" // for TextureClient #include "nsRegion.h" // for nsIntRegion - -struct nsIntPoint; -struct nsIntRect; +#include "mozilla/gfx/Rect.h" namespace mozilla { namespace layers { @@ -28,7 +26,6 @@ struct TextureFactoryIdentifier; class SurfaceDescriptor; class SurfaceDescriptorTiles; class ThebesBufferData; -class ClientTiledLayerBuffer; class PTextureChild; /** @@ -79,7 +76,7 @@ public: * Communicate the picture rect of a YUV image in aLayer to the compositor */ virtual void UpdatePictureRect(CompositableClient* aCompositable, - const nsIntRect& aRect) = 0; + const gfx::IntRect& aRect) = 0; #ifdef MOZ_WIDGET_GONK virtual void UseOverlaySource(CompositableClient* aCompositabl, diff --git a/gfx/layers/ipc/CompositableTransactionParent.h b/gfx/layers/ipc/CompositableTransactionParent.h index b5ddc898aa..773d963157 100644 --- a/gfx/layers/ipc/CompositableTransactionParent.h +++ b/gfx/layers/ipc/CompositableTransactionParent.h @@ -18,7 +18,6 @@ namespace mozilla { namespace layers { class CompositableHost; -class PTextureChild; typedef std::vector EditReplyVector; diff --git a/gfx/layers/ipc/CompositorChild.h b/gfx/layers/ipc/CompositorChild.h index 670f007550..22022dc25f 100644 --- a/gfx/layers/ipc/CompositorChild.h +++ b/gfx/layers/ipc/CompositorChild.h @@ -20,8 +20,6 @@ #include "ThreadSafeRefcountingWithMainThreadDestruction.h" #include "nsWeakReference.h" -class nsIObserver; - namespace mozilla { namespace dom { diff --git a/gfx/layers/ipc/CompositorParent.cpp b/gfx/layers/ipc/CompositorParent.cpp index be079c1fce..ea0c483c3b 100644 --- a/gfx/layers/ipc/CompositorParent.cpp +++ b/gfx/layers/ipc/CompositorParent.cpp @@ -27,6 +27,7 @@ #include "mozilla/DebugOnly.h" // for DebugOnly #include "mozilla/gfx/2D.h" // for DrawTarget #include "mozilla/gfx/Point.h" // for IntSize +#include "mozilla/gfx/Rect.h" // for IntSize #include "mozilla/ipc/Transport.h" // for Transport #include "mozilla/layers/APZCTreeManager.h" // for APZCTreeManager #include "mozilla/layers/AsyncCompositionManager.h" @@ -47,7 +48,6 @@ #include "nsDebug.h" // for NS_ASSERTION, etc #include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, etc #include "nsIWidget.h" // for nsIWidget -#include "nsRect.h" // for nsIntRect #include "nsTArray.h" // for nsTArray #include "nsThreadUtils.h" // for NS_IsMainThread #include "nsXULAppAPI.h" // for XRE_GetIOMessageLoop @@ -566,7 +566,7 @@ CompositorParent::RecvResume() bool CompositorParent::RecvMakeSnapshot(const SurfaceDescriptor& aInSnapshot, - const nsIntRect& aRect) + const gfx::IntRect& aRect) { RefPtr target = GetDrawTargetForDescriptor(aInSnapshot, gfx::BackendType::CAIRO); ForceComposeToTarget(target, &aRect); @@ -917,7 +917,7 @@ CompositorParent::SetShadowProperties(Layer* aLayer) } void -CompositorParent::CompositeToTarget(DrawTarget* aTarget, const nsIntRect* aRect) +CompositorParent::CompositeToTarget(DrawTarget* aTarget, const gfx::IntRect* aRect) { profiler_tracing("Paint", "Composite", TRACING_INTERVAL_START); PROFILER_LABEL("CompositorParent", "Composite", @@ -1012,7 +1012,7 @@ CompositorParent::CompositeToTarget(DrawTarget* aTarget, const nsIntRect* aRect) } void -CompositorParent::ForceComposeToTarget(DrawTarget* aTarget, const nsIntRect* aRect) +CompositorParent::ForceComposeToTarget(DrawTarget* aTarget, const gfx::IntRect* aRect) { PROFILER_LABEL("CompositorParent", "ForceComposeToTarget", js::ProfileEntry::Category::GRAPHICS); @@ -1233,7 +1233,7 @@ CompositorParent::AllocPLayerTransactionParent(const nsTArray& aB // mWidget doesn't belong to the compositor thread, so it should be set to // nullptr before returning from this method, to avoid accessing it elsewhere. - nsIntRect rect; + gfx::IntRect rect; mWidget->GetClientBounds(rect); InitializeLayerManager(aBackendHints); mWidget = nullptr; @@ -1478,7 +1478,7 @@ public: virtual bool RecvNotifyChildCreated(const uint64_t& child) override; virtual bool RecvAdoptChild(const uint64_t& child) override { return false; } virtual bool RecvMakeSnapshot(const SurfaceDescriptor& aInSnapshot, - const nsIntRect& aRect) override + const gfx::IntRect& aRect) override { return true; } virtual bool RecvFlushRendering() override { return true; } virtual bool RecvNotifyRegionInvalidated(const nsIntRegion& aRegion) override { return true; } diff --git a/gfx/layers/ipc/CompositorParent.h b/gfx/layers/ipc/CompositorParent.h index ed378ef8f4..f5689109ab 100644 --- a/gfx/layers/ipc/CompositorParent.h +++ b/gfx/layers/ipc/CompositorParent.h @@ -39,7 +39,6 @@ class CancelableTask; class MessageLoop; -class gfxContext; class nsIWidget; namespace mozilla { @@ -166,7 +165,7 @@ public: virtual bool RecvNotifyChildCreated(const uint64_t& child) override; virtual bool RecvAdoptChild(const uint64_t& child) override; virtual bool RecvMakeSnapshot(const SurfaceDescriptor& aInSnapshot, - const nsIntRect& aRect) override; + const gfx::IntRect& aRect) override; virtual bool RecvFlushRendering() override; virtual bool RecvGetTileSize(int32_t* aWidth, int32_t* aHeight) override; @@ -356,8 +355,8 @@ protected: virtual bool DeallocPLayerTransactionParent(PLayerTransactionParent* aLayers) override; virtual void ScheduleTask(CancelableTask*, int); void CompositeCallback(TimeStamp aScheduleTime); - void CompositeToTarget(gfx::DrawTarget* aTarget, const nsIntRect* aRect = nullptr); - void ForceComposeToTarget(gfx::DrawTarget* aTarget, const nsIntRect* aRect = nullptr); + void CompositeToTarget(gfx::DrawTarget* aTarget, const gfx::IntRect* aRect = nullptr); + void ForceComposeToTarget(gfx::DrawTarget* aTarget, const gfx::IntRect* aRect = nullptr); void SetEGLSurfaceSize(int width, int height); diff --git a/gfx/layers/ipc/ISurfaceAllocator.h b/gfx/layers/ipc/ISurfaceAllocator.h index 4f1c30d0a6..d233790645 100644 --- a/gfx/layers/ipc/ISurfaceAllocator.h +++ b/gfx/layers/ipc/ISurfaceAllocator.h @@ -30,12 +30,6 @@ #define MOZ_HAVE_SURFACEDESCRIPTORGRALLOC #endif -class gfxSharedImageSurface; - -namespace base { -class Thread; -} - namespace mozilla { namespace ipc { class Shmem; @@ -47,8 +41,6 @@ class DataSourceSurface; namespace layers { class MaybeMagicGrallocBufferHandle; -class MemoryTextureClient; -class MemoryTextureHost; enum BufferCapabilities { DEFAULT_BUFFER_CAPS = 0, diff --git a/gfx/layers/ipc/ImageBridgeChild.cpp b/gfx/layers/ipc/ImageBridgeChild.cpp index 9c02bcced2..2657498c27 100644 --- a/gfx/layers/ipc/ImageBridgeChild.cpp +++ b/gfx/layers/ipc/ImageBridgeChild.cpp @@ -38,8 +38,6 @@ #include "mozilla/StaticPtr.h" // for StaticRefPtr #include "mozilla/layers/TextureClient.h" -struct nsIntRect; - namespace mozilla { namespace ipc { class Shmem; @@ -182,7 +180,7 @@ ImageBridgeChild::SendFenceHandle(AsyncTransactionTracker* aTracker, void ImageBridgeChild::UpdatePictureRect(CompositableClient* aCompositable, - const nsIntRect& aRect) + const gfx::IntRect& aRect) { MOZ_ASSERT(aCompositable); MOZ_ASSERT(aCompositable->GetIPDLActor()); diff --git a/gfx/layers/ipc/ImageBridgeChild.h b/gfx/layers/ipc/ImageBridgeChild.h index 0f09619a9f..774ae49ebc 100644 --- a/gfx/layers/ipc/ImageBridgeChild.h +++ b/gfx/layers/ipc/ImageBridgeChild.h @@ -17,10 +17,9 @@ #include "mozilla/layers/PImageBridgeChild.h" #include "nsDebug.h" // for NS_RUNTIMEABORT #include "nsRegion.h" // for nsIntRegion +#include "mozilla/gfx/Rect.h" class MessageLoop; -struct nsIntPoint; -struct nsIntRect; namespace base { class Thread; @@ -33,7 +32,6 @@ class Shmem; namespace layers { -class ClientTiledLayerBuffer; class AsyncTransactionTracker; class ImageClient; class ImageContainer; @@ -252,7 +250,7 @@ public: * Communicate the picture rect of a YUV image in aLayer to the compositor */ virtual void UpdatePictureRect(CompositableClient* aCompositable, - const nsIntRect& aRect) override; + const gfx::IntRect& aRect) override; virtual void UpdateTextureRegion(CompositableClient* aCompositable, diff --git a/gfx/layers/ipc/LayersMessages.ipdlh b/gfx/layers/ipc/LayersMessages.ipdlh index b844acfbd8..83d916ab67 100644 --- a/gfx/layers/ipc/LayersMessages.ipdlh +++ b/gfx/layers/ipc/LayersMessages.ipdlh @@ -19,9 +19,9 @@ include "ImageLayers.h"; using mozilla::GraphicsFilterType from "mozilla/GfxMessageUtils.h"; using struct gfxRGBA from "gfxColor.h"; using struct mozilla::gfx::Point3D from "mozilla/gfx/Point.h"; +using mozilla::gfx::IntPoint from "mozilla/gfx/Point.h"; using class mozilla::gfx::Matrix4x4 from "mozilla/gfx/Matrix.h"; using nscoord from "nsCoord.h"; -using struct nsIntPoint from "nsPoint.h"; using struct nsRect from "nsRect.h"; using struct nsPoint from "nsPoint.h"; using class mozilla::TimeDuration from "mozilla/TimeStamp.h"; @@ -48,7 +48,7 @@ namespace mozilla { namespace layers { struct TargetConfig { - nsIntRect naturalBounds; + IntRect naturalBounds; ScreenRotation rotation; ScreenOrientation orientation; nsIntRegion clearRegion; @@ -73,8 +73,8 @@ struct OpAttachAsyncCompositable { }; struct ThebesBufferData { - nsIntRect rect; - nsIntPoint rotation; + IntRect rect; + IntPoint rotation; }; struct CubicBezierFunction { @@ -196,7 +196,7 @@ struct Animation { // Change a layer's attributes struct CommonLayerAttributes { - nsIntRect layerBounds; + IntRect layerBounds; nsIntRegion visibleRegion; EventRegions eventRegions; TransformMatrix transform; @@ -241,8 +241,8 @@ struct ContainerLayerAttributes { // cross process at some point by passing the HMDConfig uint64_t hmdInfo; }; -struct ColorLayerAttributes { LayerColor color; nsIntRect bounds; }; -struct CanvasLayerAttributes { GraphicsFilterType filter; nsIntRect bounds; }; +struct ColorLayerAttributes { LayerColor color; IntRect bounds; }; +struct CanvasLayerAttributes { GraphicsFilterType filter; IntRect bounds; }; struct RefLayerAttributes { int64_t id; // TODO: Once bug 1132895 is fixed we shouldn't need to propagate the override @@ -269,8 +269,8 @@ struct LayerAttributes { // See nsIWidget Configurations struct PluginWindowData { uintptr_t windowId; - nsIntRect[] clip; - nsIntRect bounds; + IntRect[] clip; + IntRect bounds; bool visible; }; @@ -348,7 +348,7 @@ struct OpPaintTextureRegion { struct OpUpdatePictureRect { PCompositable compositable; - nsIntRect picture; + IntRect picture; }; /** diff --git a/gfx/layers/ipc/LayersSurfaces.ipdlh b/gfx/layers/ipc/LayersSurfaces.ipdlh index 6a3dd29314..0ef312d736 100644 --- a/gfx/layers/ipc/LayersSurfaces.ipdlh +++ b/gfx/layers/ipc/LayersSurfaces.ipdlh @@ -3,7 +3,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ using struct gfxPoint from "gfxPoint.h"; -using struct nsIntRect from "nsRect.h"; using nsIntRegion from "nsRegion.h"; using struct mozilla::layers::MagicGrallocBufferHandle from "gfxipc/ShadowLayerUtils.h"; using struct mozilla::layers::GrallocBufferRef from "gfxipc/ShadowLayerUtils.h"; @@ -11,6 +10,7 @@ using struct mozilla::layers::SurfaceDescriptorX11 from "gfxipc/ShadowLayerUtils using struct mozilla::null_t from "ipc/IPCMessageUtils.h"; using mozilla::WindowsHandle from "ipc/IPCMessageUtils.h"; using mozilla::gfx::SurfaceFormat from "mozilla/gfx/Types.h"; +using mozilla::gfx::IntRect from "mozilla/gfx/Rect.h"; using mozilla::gfx::IntSize from "mozilla/gfx/Point.h"; using gfxImageFormat from "gfxTypes.h"; diff --git a/gfx/layers/ipc/PCompositor.ipdl b/gfx/layers/ipc/PCompositor.ipdl index 312e2cbee9..ba3620506b 100644 --- a/gfx/layers/ipc/PCompositor.ipdl +++ b/gfx/layers/ipc/PCompositor.ipdl @@ -60,7 +60,7 @@ child: * application on the widgets. Used on Windows and Linux in managing * plugin widgets. */ - async UpdatePluginConfigurations(nsIntPoint aContentOffset, + async UpdatePluginConfigurations(IntPoint aContentOffset, nsIntRegion aVisibleRegion, PluginWindowData[] aPlugins); @@ -95,7 +95,7 @@ parent: // // NB: this message will result in animations, transforms, effects, // and so forth being interpolated. That's what we want to happen. - sync MakeSnapshot(SurfaceDescriptor inSnapshot, nsIntRect dirtyRect); + sync MakeSnapshot(SurfaceDescriptor inSnapshot, IntRect dirtyRect); // Make sure any pending composites are started immediately and // block until they are completed. diff --git a/gfx/layers/ipc/ShadowLayerParent.h b/gfx/layers/ipc/ShadowLayerParent.h index 73029c5c28..01d24df730 100644 --- a/gfx/layers/ipc/ShadowLayerParent.h +++ b/gfx/layers/ipc/ShadowLayerParent.h @@ -18,7 +18,6 @@ namespace layers { class ContainerLayer; class Layer; -class LayerManager; class CanvasLayerComposite; class ColorLayerComposite; diff --git a/gfx/layers/ipc/ShadowLayerUtilsGralloc.h b/gfx/layers/ipc/ShadowLayerUtilsGralloc.h index 0200af9e86..6a1aaed5d7 100644 --- a/gfx/layers/ipc/ShadowLayerUtilsGralloc.h +++ b/gfx/layers/ipc/ShadowLayerUtilsGralloc.h @@ -22,7 +22,6 @@ namespace layers { class MaybeMagicGrallocBufferHandle; class SurfaceDescriptor; -class TextureHost; struct GrallocBufferRef { base::ProcessId mOwner; diff --git a/gfx/layers/ipc/ShadowLayers.cpp b/gfx/layers/ipc/ShadowLayers.cpp index c7fbeb0e62..974ebb364e 100644 --- a/gfx/layers/ipc/ShadowLayers.cpp +++ b/gfx/layers/ipc/ShadowLayers.cpp @@ -28,14 +28,11 @@ #include "mozilla/layers/TextureClient.h" // for TextureClient #include "mozilla/mozalloc.h" // for operator new, etc #include "nsAutoPtr.h" // for nsRefPtr, getter_AddRefs, etc -#include "nsRect.h" // for nsIntRect #include "nsSize.h" // for nsIntSize #include "nsTArray.h" // for nsAutoTArray, nsTArray, etc #include "nsXULAppAPI.h" // for XRE_GetProcessType, etc #include "mozilla/ReentrantMonitor.h" -struct nsIntPoint; - namespace mozilla { namespace ipc { class Shmem; @@ -62,7 +59,7 @@ public: , mRotationChanged(false) {} - void Begin(const nsIntRect& aTargetBounds, ScreenRotation aRotation, + void Begin(const gfx::IntRect& aTargetBounds, ScreenRotation aRotation, dom::ScreenOrientation aOrientation) { mOpen = true; @@ -139,7 +136,7 @@ public: EditVector mCset; EditVector mPaints; ShadowableLayerSet mMutants; - nsIntRect mTargetBounds; + gfx::IntRect mTargetBounds; ScreenRotation mTargetRotation; dom::ScreenOrientation mTargetOrientation; bool mSwapRequired; @@ -185,7 +182,7 @@ ShadowLayerForwarder::~ShadowLayerForwarder() } void -ShadowLayerForwarder::BeginTransaction(const nsIntRect& aTargetBounds, +ShadowLayerForwarder::BeginTransaction(const gfx::IntRect& aTargetBounds, ScreenRotation aRotation, dom::ScreenOrientation aOrientation) { @@ -354,7 +351,7 @@ ShadowLayerForwarder::UpdateTextureRegion(CompositableClient* aCompositable, void ShadowLayerForwarder::UpdatePictureRect(CompositableClient* aCompositable, - const nsIntRect& aRect) + const gfx::IntRect& aRect) { MOZ_ASSERT(aCompositable); MOZ_ASSERT(aCompositable->GetIPDLActor()); diff --git a/gfx/layers/ipc/ShadowLayers.h b/gfx/layers/ipc/ShadowLayers.h index 915e70a6af..bc5d8d7059 100644 --- a/gfx/layers/ipc/ShadowLayers.h +++ b/gfx/layers/ipc/ShadowLayers.h @@ -12,6 +12,7 @@ #include // for uint64_t #include "gfxTypes.h" #include "mozilla/Attributes.h" // for override +#include "mozilla/gfx/Rect.h" #include "mozilla/WidgetUtils.h" // for ScreenRotation #include "mozilla/dom/ScreenOrientation.h" // for ScreenOrientation #include "mozilla/ipc/SharedMemory.h" // for SharedMemory, etc @@ -22,39 +23,19 @@ #include "nsTArrayForwardDeclare.h" // for InfallibleTArray #include "nsIWidget.h" -struct nsIntPoint; -struct nsIntRect; - namespace mozilla { namespace layers { -class ClientTiledLayerBuffer; -class CanvasClient; -class CanvasLayerComposite; -class CanvasSurface; -class ColorLayerComposite; -class CompositableChild; -class ContainerLayerComposite; -class ContentClient; -class ContentClientRemote; class EditReply; -class ImageClient; -class ImageLayerComposite; class Layer; -class OptionalThebesBuffer; class PLayerChild; class PLayerTransactionChild; -class PLayerTransactionParent; class LayerTransactionChild; -class RefLayerComposite; class ShadowableLayer; -class ShmemTextureClient; class SurfaceDescriptor; class TextureClient; -class PaintedLayerComposite; class ThebesBuffer; class ThebesBufferData; -class TiledLayerComposer; class Transaction; @@ -170,7 +151,7 @@ public: * Begin recording a transaction to be forwarded atomically to a * LayerManagerComposite. */ - void BeginTransaction(const nsIntRect& aTargetBounds, + void BeginTransaction(const gfx::IntRect& aTargetBounds, ScreenRotation aRotation, mozilla::dom::ScreenOrientation aOrientation); @@ -258,7 +239,7 @@ public: * Communicate the picture rect of an image to the compositor */ void UpdatePictureRect(CompositableClient* aCompositable, - const nsIntRect& aRect) override; + const gfx::IntRect& aRect) override; /** * See CompositableForwarder::UpdatedTexture diff --git a/gfx/layers/ipc/SharedPlanarYCbCrImage.h b/gfx/layers/ipc/SharedPlanarYCbCrImage.h index d9a21690f1..b8b4162c73 100644 --- a/gfx/layers/ipc/SharedPlanarYCbCrImage.h +++ b/gfx/layers/ipc/SharedPlanarYCbCrImage.h @@ -20,8 +20,6 @@ namespace layers { class BufferTextureClient; class ImageClient; -class ISurfaceAllocator; -class SurfaceDescriptor; class TextureClient; class SharedPlanarYCbCrImage : public PlanarYCbCrImage diff --git a/gfx/layers/ipc/SharedRGBImage.cpp b/gfx/layers/ipc/SharedRGBImage.cpp index 719019b262..49f39b8a5b 100644 --- a/gfx/layers/ipc/SharedRGBImage.cpp +++ b/gfx/layers/ipc/SharedRGBImage.cpp @@ -49,8 +49,7 @@ CreateSharedRGBImage(ImageContainer *aImageContainer, } nsRefPtr rgbImage = static_cast(image.get()); - if (!rgbImage->Allocate(gfx::ToIntSize(aSize), - gfx::ImageFormatToSurfaceFormat(aImageFormat))) { + if (!rgbImage->Allocate(aSize, gfx::ImageFormatToSurfaceFormat(aImageFormat))) { NS_WARNING("Failed to allocate a shared image"); return nullptr; } diff --git a/gfx/layers/ipc/SharedRGBImage.h b/gfx/layers/ipc/SharedRGBImage.h index 2e871a24c0..70a4305b84 100644 --- a/gfx/layers/ipc/SharedRGBImage.h +++ b/gfx/layers/ipc/SharedRGBImage.h @@ -16,17 +16,11 @@ #include "nsCOMPtr.h" // for already_AddRefed namespace mozilla { -namespace ipc { -class Shmem; -} - namespace layers { class BufferTextureClient; class ImageClient; -class ISurfaceAllocator; class TextureClient; -class SurfaceDescriptor; already_AddRefed CreateSharedRGBImage(ImageContainer* aImageContainer, nsIntSize aSize, diff --git a/gfx/layers/opengl/Composer2D.h b/gfx/layers/opengl/Composer2D.h index 998cf0251d..72fd8ab200 100644 --- a/gfx/layers/opengl/Composer2D.h +++ b/gfx/layers/opengl/Composer2D.h @@ -27,11 +27,6 @@ */ namespace mozilla { - -namespace gfx { -class Matrix; -} - namespace layers { class Layer; diff --git a/gfx/layers/opengl/CompositorOGL.h b/gfx/layers/opengl/CompositorOGL.h index 5f5255c188..385dfabadd 100644 --- a/gfx/layers/opengl/CompositorOGL.h +++ b/gfx/layers/opengl/CompositorOGL.h @@ -40,7 +40,6 @@ class nsIWidget; namespace mozilla { -class TimeStamp; namespace gfx { class Matrix4x4; @@ -306,7 +305,7 @@ public: private: virtual gfx::IntSize GetWidgetSize() const override { - return gfx::ToIntSize(mWidgetSize); + return mWidgetSize; } bool InitializeVR(); @@ -320,7 +319,7 @@ private: /** Widget associated with this compositor */ nsIWidget *mWidget; - nsIntSize mWidgetSize; + gfx::IntSize mWidgetSize; nsRefPtr mGLContext; UniquePtr mBlitTextureImageHelper; gfx::Matrix4x4 mProjMatrix; diff --git a/gfx/layers/opengl/GLBlitTextureImageHelper.cpp b/gfx/layers/opengl/GLBlitTextureImageHelper.cpp index 0b178eacaa..d8805c993d 100644 --- a/gfx/layers/opengl/GLBlitTextureImageHelper.cpp +++ b/gfx/layers/opengl/GLBlitTextureImageHelper.cpp @@ -37,8 +37,8 @@ GLBlitTextureImageHelper::~GLBlitTextureImageHelper() } void -GLBlitTextureImageHelper::BlitTextureImage(TextureImage *aSrc, const nsIntRect& aSrcRect, - TextureImage *aDst, const nsIntRect& aDstRect) +GLBlitTextureImageHelper::BlitTextureImage(TextureImage *aSrc, const gfx::IntRect& aSrcRect, + TextureImage *aDst, const gfx::IntRect& aDstRect) { GLContext *gl = mCompositor->gl(); NS_ASSERTION(!aSrc->InUpdate(), "Source texture is in update!"); @@ -61,8 +61,8 @@ GLBlitTextureImageHelper::BlitTextureImage(TextureImage *aSrc, const nsIntRect& aDst->BeginBigImageIteration(); do { // calculate portion of the tile that is going to be painted to - nsIntRect dstSubRect; - nsIntRect dstTextureRect = ThebesIntRect(aDst->GetTileRect()); + gfx::IntRect dstSubRect; + gfx::IntRect dstTextureRect = ThebesIntRect(aDst->GetTileRect()); dstSubRect.IntersectRect(aDstRect, dstTextureRect); // this tile is not part of the destination rectangle aDstRect @@ -70,7 +70,7 @@ GLBlitTextureImageHelper::BlitTextureImage(TextureImage *aSrc, const nsIntRect& continue; // (*) transform the rect of this tile into the rectangle defined by aSrcRect... - nsIntRect dstInSrcRect(dstSubRect); + gfx::IntRect dstInSrcRect(dstSubRect); dstInSrcRect.MoveBy(-aDstRect.TopLeft()); // ...which might be of different size, hence scale accordingly dstInSrcRect.ScaleRoundOut(1.0f / blitScaleX, 1.0f / blitScaleY); @@ -83,8 +83,8 @@ GLBlitTextureImageHelper::BlitTextureImage(TextureImage *aSrc, const nsIntRect& // now iterate over all tiles in the source Image... do { // calculate portion of the source tile that is in the source rect - nsIntRect srcSubRect; - nsIntRect srcTextureRect = ThebesIntRect(aSrc->GetTileRect()); + gfx::IntRect srcSubRect; + gfx::IntRect srcTextureRect = ThebesIntRect(aSrc->GetTileRect()); srcSubRect.IntersectRect(aSrcRect, srcTextureRect); // this tile is not part of the source rect @@ -104,7 +104,7 @@ GLBlitTextureImageHelper::BlitTextureImage(TextureImage *aSrc, const nsIntRect& // and the desired destination rectange // in destination space. // We need to transform this back into destination space, inverting the transform from (*) - nsIntRect srcSubInDstRect(srcSubRect); + gfx::IntRect srcSubInDstRect(srcSubRect); srcSubInDstRect.MoveBy(-aSrcRect.TopLeft()); srcSubInDstRect.ScaleRoundOut(blitScaleX, blitScaleY); srcSubInDstRect.MoveBy(aDstRect.TopLeft()); diff --git a/gfx/layers/opengl/GLBlitTextureImageHelper.h b/gfx/layers/opengl/GLBlitTextureImageHelper.h index a9fda5784f..91cb1bf857 100644 --- a/gfx/layers/opengl/GLBlitTextureImageHelper.h +++ b/gfx/layers/opengl/GLBlitTextureImageHelper.h @@ -10,8 +10,7 @@ #include "mozilla/Attributes.h" #include "GLContextTypes.h" #include "GLConsts.h" - -struct nsIntRect; +#include "mozilla/gfx/Rect.h" namespace mozilla { namespace gl { @@ -62,8 +61,8 @@ public: * - active texture (will be 0) * - texture 0 binding */ - void BlitTextureImage(gl::TextureImage *aSrc, const nsIntRect& aSrcRect, - gl::TextureImage *aDst, const nsIntRect& aDstRect); + void BlitTextureImage(gl::TextureImage *aSrc, const gfx::IntRect& aSrcRect, + gl::TextureImage *aDst, const gfx::IntRect& aDstRect); }; } // namespace layers diff --git a/gfx/layers/opengl/OGLShaderProgram.h b/gfx/layers/opengl/OGLShaderProgram.h index d03f500fc9..ffa4822e0f 100644 --- a/gfx/layers/opengl/OGLShaderProgram.h +++ b/gfx/layers/opengl/OGLShaderProgram.h @@ -21,7 +21,6 @@ #include struct gfxRGBA; -struct nsIntRect; namespace mozilla { namespace layers { diff --git a/gfx/layers/opengl/TextureClientOGL.h b/gfx/layers/opengl/TextureClientOGL.h index fd33b2c054..dd0dd7729b 100644 --- a/gfx/layers/opengl/TextureClientOGL.h +++ b/gfx/layers/opengl/TextureClientOGL.h @@ -20,8 +20,6 @@ namespace mozilla { namespace layers { -class CompositableForwarder; - class EGLImageTextureClient : public TextureClient { public: diff --git a/gfx/layers/opengl/TextureHostOGL.cpp b/gfx/layers/opengl/TextureHostOGL.cpp index 49fb8d0275..a79055e6fd 100644 --- a/gfx/layers/opengl/TextureHostOGL.cpp +++ b/gfx/layers/opengl/TextureHostOGL.cpp @@ -22,7 +22,6 @@ #include "mozilla/layers/ISurfaceAllocator.h" #include "mozilla/layers/YCbCrImageDataSerializer.h" #include "mozilla/layers/GrallocTextureHost.h" -#include "nsPoint.h" // for nsIntPoint #include "nsRegion.h" // for nsIntRegion #include "AndroidSurfaceTexture.h" #include "GfxTexturesReporter.h" // for GfxTexturesReporter @@ -258,7 +257,7 @@ TextureImageTextureSourceOGL::Update(gfx::DataSourceSurface* aSurface, if (aDestRegion && !aSrcOffset && - !aDestRegion->IsEqual(nsIntRect(0, 0, size.width, size.height))) { + !aDestRegion->IsEqual(gfx::IntRect(0, 0, size.width, size.height))) { // UpdateFromDataSource will ignore our specified aDestRegion since the texture // hasn't been allocated with glTexImage2D yet. Call Resize() to force the // allocation (full size, but no upload), and then we'll only upload the pixels @@ -292,9 +291,9 @@ TextureImageTextureSourceOGL::EnsureBuffer(const nsIntSize& aSize, } void -TextureImageTextureSourceOGL::CopyTo(const nsIntRect& aSourceRect, +TextureImageTextureSourceOGL::CopyTo(const gfx::IntRect& aSourceRect, DataTextureSource *aDest, - const nsIntRect& aDestRect) + const gfx::IntRect& aDestRect) { MOZ_ASSERT(aDest->AsSourceOGL(), "Incompatible destination type!"); TextureImageTextureSourceOGL *dest = @@ -341,7 +340,7 @@ TextureImageTextureSourceOGL::GetFormat() const return gfx::SurfaceFormat::UNKNOWN; } -nsIntRect TextureImageTextureSourceOGL::GetTileRect() +gfx::IntRect TextureImageTextureSourceOGL::GetTileRect() { return ThebesIntRect(mTexImage->GetTileRect()); } diff --git a/gfx/layers/opengl/TextureHostOGL.h b/gfx/layers/opengl/TextureHostOGL.h index 7137d099de..47be55b39a 100644 --- a/gfx/layers/opengl/TextureHostOGL.h +++ b/gfx/layers/opengl/TextureHostOGL.h @@ -37,10 +37,7 @@ #endif #endif -class gfxReusableSurfaceWrapper; class nsIntRegion; -struct nsIntPoint; -struct nsIntRect; namespace mozilla { namespace gfx { @@ -56,7 +53,6 @@ namespace layers { class Compositor; class CompositorOGL; class TextureImageTextureSourceOGL; -class TextureSharedDataGonkOGL; class GLTextureSource; inline void ApplyFilterToBoundTexture(gl::GLContext* aGL, @@ -204,9 +200,9 @@ public: void EnsureBuffer(const gfx::IntSize& aSize, gfxContentType aContentType); - void CopyTo(const nsIntRect& aSourceRect, - DataTextureSource* aDest, - const nsIntRect& aDestRect); + void CopyTo(const gfx::IntRect& aSourceRect, + DataTextureSource* aDest, + const gfx::IntRect& aDestRect); virtual TextureImageTextureSourceOGL* AsTextureImageTextureSource() override { return this; } @@ -250,7 +246,7 @@ public: mIterating = false; } - virtual nsIntRect GetTileRect() override; + virtual gfx::IntRect GetTileRect() override; virtual size_t GetTileCount() override { diff --git a/gfx/layers/opengl/X11TextureSourceOGL.cpp b/gfx/layers/opengl/X11TextureSourceOGL.cpp index b744e92b37..42caad2f2e 100644 --- a/gfx/layers/opengl/X11TextureSourceOGL.cpp +++ b/gfx/layers/opengl/X11TextureSourceOGL.cpp @@ -60,7 +60,7 @@ X11TextureSourceOGL::BindTexture(GLenum aTextureUnit, gfx::Filter aFilter) IntSize X11TextureSourceOGL::GetSize() const { - return ToIntSize(mSurface->GetSize()); + return mSurface->GetSize(); } SurfaceFormat diff --git a/gfx/src/FilterSupport.h b/gfx/src/FilterSupport.h index 207a928db8..baaf898c57 100644 --- a/gfx/src/FilterSupport.h +++ b/gfx/src/FilterSupport.h @@ -158,7 +158,6 @@ enum AttributeName { class DrawTarget; class SourceSurface; -class FilterNode; struct FilterAttribute; enum class AttributeType { diff --git a/gfx/src/nsColor.h b/gfx/src/nsColor.h index ca6603fc32..24769542e7 100644 --- a/gfx/src/nsColor.h +++ b/gfx/src/nsColor.h @@ -13,7 +13,6 @@ class nsAString; class nsString; -class nsCString; // A color is a 32 bit unsigned integer with four components: R, G, B // and A. diff --git a/gfx/src/nsITheme.h b/gfx/src/nsITheme.h index ff46778683..79572d30c4 100644 --- a/gfx/src/nsITheme.h +++ b/gfx/src/nsITheme.h @@ -12,18 +12,14 @@ #include "nsISupports.h" #include "nsCOMPtr.h" #include "nsColor.h" -#include "nsSize.h" +#include "Units.h" struct nsRect; -struct nsIntRect; -class nsIntRegion; -struct nsFont; struct nsIntMargin; class nsPresContext; class nsRenderingContext; class nsDeviceContext; class nsIFrame; -class nsIContent; class nsIAtom; class nsIWidget; @@ -116,7 +112,7 @@ public: NS_IMETHOD GetMinimumWidgetSize(nsPresContext* aPresContext, nsIFrame* aFrame, uint8_t aWidgetType, - nsIntSize* aResult, + mozilla::LayoutDeviceIntSize* aResult, bool* aIsOverridable)=0; diff --git a/gfx/src/nsPoint.h b/gfx/src/nsPoint.h index 4a621d4ced..88dacf6c44 100644 --- a/gfx/src/nsPoint.h +++ b/gfx/src/nsPoint.h @@ -10,8 +10,12 @@ #include "mozilla/gfx/BaseSize.h" #include "mozilla/gfx/BasePoint.h" #include "nsSize.h" +#include "mozilla/gfx/Point.h" -struct nsIntPoint; +// nsIntPoint represents a point in one of the types of pixels. +// Uses of nsIntPoint should eventually be converted to CSSIntPoint, +// LayoutDeviceIntPoint, etc. (see layout/base/Units.h). +typedef mozilla::gfx::IntPoint nsIntPoint; // nsPoint represents a point in app units. @@ -35,19 +39,7 @@ struct nsPoint : public mozilla::gfx::BasePoint { ScaleToOtherAppUnits(int32_t aFromAPP, int32_t aToAPP) const; }; -// nsIntPoint represents a point in one of the types of pixels. -// Uses of nsIntPoint should eventually be converted to CSSIntPoint, -// LayoutDeviceIntPoint, etc. (see layout/base/Units.h). - -struct nsIntPoint : public mozilla::gfx::BasePoint { - typedef mozilla::gfx::BasePoint Super; - - nsIntPoint() : Super() {} - nsIntPoint(const nsIntPoint& aPoint) : Super(aPoint) {} - nsIntPoint(int32_t aX, int32_t aY) : Super(aX, aY) {} - - inline nsPoint ToAppUnits(nscoord aAppUnitsPerPixel) const; -}; +inline nsPoint ToAppUnits(const nsIntPoint& aPoint, nscoord aAppUnitsPerPixel); inline nsIntPoint nsPoint::ScaleToNearestPixels(float aXScale, float aYScale, @@ -78,10 +70,10 @@ nsPoint::ScaleToOtherAppUnits(int32_t aFromAPP, int32_t aToAPP) const // app units are integer multiples of pixels, so no rounding needed inline nsPoint -nsIntPoint::ToAppUnits(nscoord aAppUnitsPerPixel) const +ToAppUnits(const nsIntPoint& aPoint, nscoord aAppUnitsPerPixel) { - return nsPoint(NSIntPixelsToAppUnits(x, aAppUnitsPerPixel), - NSIntPixelsToAppUnits(y, aAppUnitsPerPixel)); + return nsPoint(NSIntPixelsToAppUnits(aPoint.x, aAppUnitsPerPixel), + NSIntPixelsToAppUnits(aPoint.y, aAppUnitsPerPixel)); } #endif /* NSPOINT_H */ diff --git a/gfx/src/nsRect.cpp b/gfx/src/nsRect.cpp index 41a0315039..d1a3dd6391 100644 --- a/gfx/src/nsRect.cpp +++ b/gfx/src/nsRect.cpp @@ -15,6 +15,20 @@ static_assert((int(NS_SIDE_TOP) == 0) && (int(NS_SIDE_LEFT) == 3), "The mozilla::css::Side sequence must match the nsMargin nscoord sequence"); +nsRect +ToAppUnits(const nsIntRect& aRect, nscoord aAppUnitsPerPixel) +{ + return nsRect(NSIntPixelsToAppUnits(aRect.x, aAppUnitsPerPixel), + NSIntPixelsToAppUnits(aRect.y, aAppUnitsPerPixel), + NSIntPixelsToAppUnits(aRect.width, aAppUnitsPerPixel), + NSIntPixelsToAppUnits(aRect.height, aAppUnitsPerPixel)); +} + +const nsIntRect& GetMaxSizedIntRect() { + static const nsIntRect r(0, 0, INT32_MAX, INT32_MAX); + return r; +} + #ifdef DEBUG // Diagnostics diff --git a/gfx/src/nsRect.h b/gfx/src/nsRect.h index e424cefd1d..c840386dc2 100644 --- a/gfx/src/nsRect.h +++ b/gfx/src/nsRect.h @@ -13,18 +13,18 @@ #include "nsDebug.h" // for NS_WARNING #include "gfxCore.h" // for NS_GFX #include "mozilla/Likely.h" // for MOZ_UNLIKELY -#include "mozilla/gfx/BaseRect.h" // for BaseRect -#include "mozilla/gfx/NumericTools.h" // for RoundUpToMultiple, RoundDownToMultiple +#include "mozilla/gfx/Rect.h" #include "nsCoord.h" // for nscoord, etc #include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, etc #include "nsPoint.h" // for nsIntPoint, nsPoint #include "nsSize.h" // for nsIntSize, nsSize #include "nscore.h" // for NS_BUILD_REFCNT_LOGGING -struct nsIntRect; struct nsMargin; struct nsIntMargin; +typedef mozilla::gfx::IntRect nsIntRect; + struct NS_GFX nsRect : public mozilla::gfx::BaseRect { typedef mozilla::gfx::BaseRect Super; @@ -179,56 +179,6 @@ struct NS_GFX nsRect : } }; -struct NS_GFX nsIntRect : - public mozilla::gfx::BaseRect { - typedef mozilla::gfx::BaseRect Super; - - // Constructors - nsIntRect() : Super() - { - } - nsIntRect(const nsIntRect& aRect) : Super(aRect) - { - } - nsIntRect(const nsIntPoint& aOrigin, const nsIntSize &aSize) : Super(aOrigin, aSize) - { - } - nsIntRect(int32_t aX, int32_t aY, int32_t aWidth, int32_t aHeight) : - Super(aX, aY, aWidth, aHeight) - { - } - - MOZ_WARN_UNUSED_RESULT inline nsRect - ToAppUnits(nscoord aAppUnitsPerPixel) const; - - // Returns a special nsIntRect that's used in some places to signify - // "all available space". - static const nsIntRect& GetMaxSizedIntRect() { - static const nsIntRect r(0, 0, INT32_MAX, INT32_MAX); - return r; - } - - void InflateToMultiple(const nsIntSize& aTileSize) - { - int32_t xMost = XMost(); - int32_t yMost = YMost(); - - x = RoundDownToMultiple(x, aTileSize.width); - y = RoundDownToMultiple(y, aTileSize.height); - xMost = RoundUpToMultiple(xMost, aTileSize.width); - yMost = RoundUpToMultiple(yMost, aTileSize.height); - - width = xMost - x; - height = yMost - y; - } - - // This is here only to keep IPDL-generated code happy. DO NOT USE. - bool operator==(const nsIntRect& aRect) const - { - return IsEqualEdges(aRect); - } -}; - /* * App Unit/Pixel conversions */ @@ -335,15 +285,11 @@ nsRect::ToInsidePixels(nscoord aAppUnitsPerPixel) const return ScaleToInsidePixels(1.0f, 1.0f, aAppUnitsPerPixel); } +const nsIntRect& GetMaxSizedIntRect(); + // app units are integer multiples of pixels, so no rounding needed -inline nsRect -nsIntRect::ToAppUnits(nscoord aAppUnitsPerPixel) const -{ - return nsRect(NSIntPixelsToAppUnits(x, aAppUnitsPerPixel), - NSIntPixelsToAppUnits(y, aAppUnitsPerPixel), - NSIntPixelsToAppUnits(width, aAppUnitsPerPixel), - NSIntPixelsToAppUnits(height, aAppUnitsPerPixel)); -} +nsRect +ToAppUnits(const nsIntRect& aRect, nscoord aAppUnitsPerPixel); #ifdef DEBUG // Diagnostics diff --git a/gfx/src/nsRegion.h b/gfx/src/nsRegion.h index 632398d62e..05dca175ca 100644 --- a/gfx/src/nsRegion.h +++ b/gfx/src/nsRegion.h @@ -699,7 +699,7 @@ public: RectIterator rgnIter(*this); const Rect* currentRect; while ((currentRect = rgnIter.Next())) { - nsRect appRect = currentRect->ToAppUnits(aAppUnitsPerPixel); + nsRect appRect = ::ToAppUnits(*currentRect, aAppUnitsPerPixel); result.Or(result, appRect); } return result; diff --git a/gfx/tests/gtest/TestTextures.cpp b/gfx/tests/gtest/TestTextures.cpp index 6d36ac2f49..10a640ec9f 100644 --- a/gfx/tests/gtest/TestTextures.cpp +++ b/gfx/tests/gtest/TestTextures.cpp @@ -148,7 +148,7 @@ void TestTextureClientSurface(TextureClient* texture, gfxImageSurface* surface) // client allocation ASSERT_TRUE(texture->CanExposeDrawTarget()); - texture->AllocateForSurface(ToIntSize(surface->GetSize())); + texture->AllocateForSurface(surface->GetSize()); ASSERT_TRUE(texture->IsAllocated()); ASSERT_TRUE(texture->Lock(OpenMode::OPEN_READ_WRITE)); diff --git a/gfx/thebes/gfx2DGlue.h b/gfx/thebes/gfx2DGlue.h index 1a500017b9..c2178226e0 100644 --- a/gfx/thebes/gfx2DGlue.h +++ b/gfx/thebes/gfx2DGlue.h @@ -16,14 +16,6 @@ #include "mozilla/gfx/2D.h" #include "gfxColor.h" -namespace mozilla { -namespace gfx { -class DrawTarget; -class SourceSurface; -class ScaledFont; -} -} - namespace mozilla { namespace gfx { @@ -76,16 +68,21 @@ inline IntPoint ToIntPoint(const nsIntPoint &aPoint) return IntPoint(aPoint.x, aPoint.y); } +inline IntMargin ToIntMargin(const nsIntMargin& aMargin) +{ + return IntMargin(aMargin.top, aMargin.right, aMargin.bottom, aMargin.left); +} + +inline nsIntPoint ThebesIntPoint(const IntPoint &aPoint) +{ + return nsIntPoint(aPoint.x, aPoint.y); +} + inline Size ToSize(const gfxSize &aSize) { return Size(Float(aSize.width), Float(aSize.height)); } -inline IntSize ToIntSize(const gfxIntSize &aSize) -{ - return IntSize(aSize.width, aSize.height); -} - inline Filter ToFilter(GraphicsFilter aFilter) { switch (aFilter) { diff --git a/gfx/thebes/gfxASurface.h b/gfx/thebes/gfxASurface.h index 42ffd44385..d61ee65adb 100644 --- a/gfx/thebes/gfxASurface.h +++ b/gfx/thebes/gfxASurface.h @@ -12,6 +12,7 @@ #include "gfxTypes.h" #include "nscore.h" #include "nsSize.h" +#include "mozilla/gfx/Rect.h" #ifdef MOZILLA_INTERNAL_API #include "nsStringFwd.h" @@ -20,8 +21,6 @@ #endif class gfxImageSurface; -struct nsIntPoint; -struct nsIntRect; struct gfxRect; struct gfxPoint; diff --git a/gfx/thebes/gfxAlphaRecovery.h b/gfx/thebes/gfxAlphaRecovery.h index 0122d9c83e..9fed1681e9 100644 --- a/gfx/thebes/gfxAlphaRecovery.h +++ b/gfx/thebes/gfxAlphaRecovery.h @@ -8,9 +8,8 @@ #include "mozilla/SSE.h" #include "gfxTypes.h" -#include "nsRect.h" +#include "mozilla/gfx/Rect.h" -struct nsIntRect; class gfxImageSurface; class gfxAlphaRecovery { @@ -53,11 +52,11 @@ public: * * The returned rect is always a superset of |aRect|. */ - static nsIntRect AlignRectForSubimageRecovery(const nsIntRect& aRect, - gfxImageSurface* aSurface); + static mozilla::gfx::IntRect AlignRectForSubimageRecovery(const mozilla::gfx::IntRect& aRect, + gfxImageSurface* aSurface); #else - static nsIntRect AlignRectForSubimageRecovery(const nsIntRect& aRect, - gfxImageSurface*) + static mozilla::gfx::IntRect AlignRectForSubimageRecovery(const mozilla::gfx::IntRect& aRect, + gfxImageSurface*) { return aRect; } #endif diff --git a/gfx/thebes/gfxAlphaRecoverySSE2.cpp b/gfx/thebes/gfxAlphaRecoverySSE2.cpp index a395cee6b7..a65dc9a445 100644 --- a/gfx/thebes/gfxAlphaRecoverySSE2.cpp +++ b/gfx/thebes/gfxAlphaRecoverySSE2.cpp @@ -5,7 +5,6 @@ #include "gfxAlphaRecovery.h" #include "gfxImageSurface.h" -#include "nsRect.h" #include // This file should only be compiled on x86 and x64 systems. Additionally, @@ -137,8 +136,8 @@ ByteAlignment(int32_t aAlignToLog2, int32_t aX, int32_t aY=0, int32_t aStride=1) return (aX + aStride * aY) & ((1 << aAlignToLog2) - 1); } -/*static*/ nsIntRect -gfxAlphaRecovery::AlignRectForSubimageRecovery(const nsIntRect& aRect, +/*static*/ mozilla::gfx::IntRect +gfxAlphaRecovery::AlignRectForSubimageRecovery(const mozilla::gfx::IntRect& aRect, gfxImageSurface* aSurface) { NS_ASSERTION(gfxImageFormat::ARGB32 == aSurface->Format(), @@ -229,8 +228,8 @@ gfxAlphaRecovery::AlignRectForSubimageRecovery(const nsIntRect& aRect, return aRect; FOUND_SOLUTION: - nsIntRect solution = nsIntRect(x - dx, y - dy, w + dr + dx, h + dy); - MOZ_ASSERT(nsIntRect(0, 0, sw, surfaceSize.height).Contains(solution), + mozilla::gfx::IntRect solution = mozilla::gfx::IntRect(x - dx, y - dy, w + dr + dx, h + dy); + MOZ_ASSERT(mozilla::gfx::IntRect(0, 0, sw, surfaceSize.height).Contains(solution), "'Solution' extends outside surface bounds!"); return solution; } diff --git a/gfx/thebes/gfxAndroidPlatform.h b/gfx/thebes/gfxAndroidPlatform.h index 47ecf6b168..b35c256d06 100644 --- a/gfx/thebes/gfxAndroidPlatform.h +++ b/gfx/thebes/gfxAndroidPlatform.h @@ -12,8 +12,6 @@ #include "nsCOMPtr.h" #include "nsTArray.h" -class nsIMemoryReporter; - namespace mozilla { namespace dom { class FontListEntry; diff --git a/gfx/thebes/gfxBlur.h b/gfx/thebes/gfxBlur.h index ff65e1836c..4c7b95c5ca 100644 --- a/gfx/thebes/gfxBlur.h +++ b/gfx/thebes/gfxBlur.h @@ -16,7 +16,6 @@ class gfxContext; struct gfxRect; struct gfxRGBA; -class gfxMatrix; namespace mozilla { namespace gfx { diff --git a/gfx/thebes/gfxD2DSurface.cpp b/gfx/thebes/gfxD2DSurface.cpp index 96f2a425f3..6d37a7997e 100644 --- a/gfx/thebes/gfxD2DSurface.cpp +++ b/gfx/thebes/gfxD2DSurface.cpp @@ -57,7 +57,7 @@ gfxD2DSurface::Present() } void -gfxD2DSurface::Scroll(const nsIntPoint &aDelta, const nsIntRect &aClip) +gfxD2DSurface::Scroll(const nsIntPoint &aDelta, const mozilla::gfx::IntRect &aClip) { cairo_rectangle_t rect; rect.x = aClip.x; @@ -80,7 +80,7 @@ gfxD2DSurface::GetDC(bool aRetainContents) } void -gfxD2DSurface::ReleaseDC(const nsIntRect *aUpdatedRect) +gfxD2DSurface::ReleaseDC(const mozilla::gfx::IntRect *aUpdatedRect) { if (!aUpdatedRect) { return cairo_d2d_release_dc(CairoSurface(), nullptr); diff --git a/gfx/thebes/gfxD2DSurface.h b/gfx/thebes/gfxD2DSurface.h index 10687e6403..fccb25cbb1 100644 --- a/gfx/thebes/gfxD2DSurface.h +++ b/gfx/thebes/gfxD2DSurface.h @@ -12,7 +12,6 @@ #include struct ID3D10Texture2D; -struct nsIntRect; class gfxD2DSurface : public gfxASurface { public: @@ -32,14 +31,14 @@ public: virtual ~gfxD2DSurface(); void Present(); - void Scroll(const nsIntPoint &aDelta, const nsIntRect &aClip); + void Scroll(const nsIntPoint &aDelta, const mozilla::gfx::IntRect &aClip); - virtual const gfxIntSize GetSize() const; + virtual const mozilla::gfx::IntSize GetSize() const; ID3D10Texture2D *GetTexture(); HDC GetDC(bool aRetainContents); - void ReleaseDC(const nsIntRect *aUpdatedRect); + void ReleaseDC(const mozilla::gfx::IntRect *aUpdatedRect); }; #endif /* GFX_D2DSURFACE_H */ diff --git a/gfx/thebes/gfxDrawable.h b/gfx/thebes/gfxDrawable.h index 703aff4f99..306771200e 100644 --- a/gfx/thebes/gfxDrawable.h +++ b/gfx/thebes/gfxDrawable.h @@ -12,7 +12,6 @@ #include "GraphicsFilter.h" #include "mozilla/gfx/2D.h" -class gfxASurface; class gfxContext; class gfxPattern; diff --git a/gfx/thebes/gfxPattern.h b/gfx/thebes/gfxPattern.h index 5ceea203b6..00837c71be 100644 --- a/gfx/thebes/gfxPattern.h +++ b/gfx/thebes/gfxPattern.h @@ -17,8 +17,6 @@ #include "nsAutoPtr.h" #include "nsTArray.h" -class gfxContext; -class gfxASurface; struct gfxRGBA; typedef struct _cairo_pattern cairo_pattern_t; diff --git a/gfx/thebes/gfxPlatform.cpp b/gfx/thebes/gfxPlatform.cpp index 4cee11a345..9421095b1b 100644 --- a/gfx/thebes/gfxPlatform.cpp +++ b/gfx/thebes/gfxPlatform.cpp @@ -885,7 +885,7 @@ gfxPlatform::GetSourceSurfaceForSurface(DrawTarget *aTarget, gfxASurface *aSurfa surf.mFormat = format; surf.mType = NativeSurfaceType::CAIRO_SURFACE; surf.mSurface = aSurface->CairoSurface(); - surf.mSize = ToIntSize(aSurface->GetSize()); + surf.mSize = aSurface->GetSize(); // We return here regardless of whether CreateSourceSurfaceFromNativeSurface // succeeds or not since we don't expect to be able to do any better below // if it fails. @@ -910,7 +910,7 @@ gfxPlatform::GetSourceSurfaceForSurface(DrawTarget *aTarget, gfxASurface *aSurfa surf.mFormat = format; surf.mType = NativeSurfaceType::D3D10_TEXTURE; surf.mSurface = static_cast(aSurface)->GetTexture(); - surf.mSize = ToIntSize(aSurface->GetSize()); + surf.mSize = aSurface->GetSize(); mozilla::gfx::DrawTarget *dt = static_cast(aSurface->GetData(&kDrawTarget)); if (dt) { dt->Flush(); @@ -958,7 +958,7 @@ gfxPlatform::GetSourceSurfaceForSurface(DrawTarget *aTarget, gfxASurface *aSurfa surf.mFormat = format; surf.mType = NativeSurfaceType::CAIRO_SURFACE; surf.mSurface = aSurface->CairoSurface(); - surf.mSize = ToIntSize(aSurface->GetSize()); + surf.mSize = aSurface->GetSize(); RefPtr drawTarget = Factory::CreateDrawTarget(BackendType::CAIRO, IntSize(1, 1), format); if (!drawTarget) { @@ -1004,7 +1004,7 @@ gfxPlatform::GetWrappedDataSourceSurface(gfxASurface* aSurface) RefPtr result = Factory::CreateWrappingDataSourceSurface(image->Data(), image->Stride(), - ToIntSize(image->GetSize()), + image->GetSize(), ImageFormatToSurfaceFormat(image->Format())); if (!result) { diff --git a/gfx/thebes/gfxPlatform.h b/gfx/thebes/gfxPlatform.h index 9759cae77b..520bb447d3 100644 --- a/gfx/thebes/gfxPlatform.h +++ b/gfx/thebes/gfxPlatform.h @@ -38,11 +38,9 @@ class nsIURI; class nsIAtom; class nsIObserver; class SRGBOverrideObserver; -struct gfxRGBA; namespace mozilla { namespace gl { -class GLContext; class SkiaGLGlue; } // namespace gl namespace gfx { diff --git a/gfx/thebes/gfxQtNativeRenderer.h b/gfx/thebes/gfxQtNativeRenderer.h index da11d9f1c1..1b58caa1a2 100644 --- a/gfx/thebes/gfxQtNativeRenderer.h +++ b/gfx/thebes/gfxQtNativeRenderer.h @@ -9,9 +9,7 @@ #include "gfxColor.h" #include "gfxContext.h" #include "gfxXlibSurface.h" - -class QRect; -struct nsIntRect; +#include "mozilla/gfx/Rect.h" /** * This class lets us take code that draws into an Xlib surface drawable and lets us @@ -31,8 +29,9 @@ public: */ virtual nsresult DrawWithXlib(cairo_surface_t* surface, nsIntPoint offset, - nsIntRect* clipRects, uint32_t numClipRects) = 0; - + mozilla::gfx::IntRect* clipRects, + uint32_t numClipRects) = 0; + enum { // If set, then Draw() is opaque, i.e., every pixel in the intersection // of the clipRect and (offset.x,offset.y,bounds.width,bounds.height) diff --git a/gfx/thebes/gfxUtils.cpp b/gfx/thebes/gfxUtils.cpp index f1d9373b28..e5e15bcc40 100644 --- a/gfx/thebes/gfxUtils.cpp +++ b/gfx/thebes/gfxUtils.cpp @@ -443,8 +443,7 @@ CreateSamplingRestrictedDrawable(gfxDrawable* aDrawable, gfxIntSize size(int32_t(needed.Width()), int32_t(needed.Height())); RefPtr target = - gfxPlatform::GetPlatform()->CreateOffscreenContentDrawTarget(ToIntSize(size), - aFormat); + gfxPlatform::GetPlatform()->CreateOffscreenContentDrawTarget(size, aFormat); if (!target) { return nullptr; } @@ -693,7 +692,7 @@ PathFromRegionInternal(gfxContext* aContext, const nsIntRegion& aRegion) { aContext->NewPath(); nsIntRegionRectIterator iter(aRegion); - const nsIntRect* r; + const IntRect* r; while ((r = iter.Next()) != nullptr) { aContext->Rectangle(gfxRect(r->x, r->y, r->width, r->height)); } @@ -712,7 +711,7 @@ PathFromRegionInternal(DrawTarget* aTarget, const nsIntRegion& aRegion) RefPtr pb = aTarget->CreatePathBuilder(); nsIntRegionRectIterator iter(aRegion); - const nsIntRect* r; + const IntRect* r; while ((r = iter.Next()) != nullptr) { pb->MoveTo(Point(r->x, r->y)); pb->LineTo(Point(r->XMost(), r->y)); @@ -727,7 +726,7 @@ static void ClipToRegionInternal(DrawTarget* aTarget, const nsIntRegion& aRegion) { if (!aRegion.IsComplex()) { - nsIntRect rect = aRegion.GetBounds(); + IntRect rect = aRegion.GetBounds(); aTarget->PushClipRect(Rect(rect.x, rect.y, rect.width, rect.height)); return; } @@ -849,9 +848,9 @@ gfxUtils::TransformRectToRect(const gfxRect& aFrom, const IntPoint& aToTopLeft, * to ints then convert those ints back to doubles to make sure that * they equal the doubles that we got in. */ bool -gfxUtils::GfxRectToIntRect(const gfxRect& aIn, nsIntRect* aOut) +gfxUtils::GfxRectToIntRect(const gfxRect& aIn, IntRect* aOut) { - *aOut = nsIntRect(int32_t(aIn.X()), int32_t(aIn.Y()), + *aOut = IntRect(int32_t(aIn.X()), int32_t(aIn.Y()), int32_t(aIn.Width()), int32_t(aIn.Height())); return gfxRect(aOut->x, aOut->y, aOut->width, aOut->height).IsEqualEdges(aIn); } @@ -870,7 +869,7 @@ gfxUtils::GetYCbCrToRGBDestFormatAndSize(const PlanarYCbCrData& aData, // 'prescale' is true if the scaling is to be done as part of the // YCbCr to RGB conversion rather than on the RGB data when rendered. bool prescale = aSuggestedSize.width > 0 && aSuggestedSize.height > 0 && - ToIntSize(aSuggestedSize) != aData.mPicSize; + aSuggestedSize != aData.mPicSize; if (aSuggestedFormat == gfxImageFormat::RGB16_565) { #if defined(HAVE_YCBCR_TO_RGB565) @@ -906,7 +905,7 @@ gfxUtils::GetYCbCrToRGBDestFormatAndSize(const PlanarYCbCrData& aData, prescale = false; } if (!prescale) { - ToIntSize(aSuggestedSize) = aData.mPicSize; + aSuggestedSize = aData.mPicSize; } } @@ -930,7 +929,7 @@ gfxUtils::ConvertYCbCrToRGB(const PlanarYCbCrData& aData, aData.mCbCrSize.height); // Convert from YCbCr to RGB now, scaling the image if needed. - if (ToIntSize(aDestSize) != aData.mPicSize) { + if (aDestSize != aData.mPicSize) { #if defined(HAVE_YCBCR_TO_RGB565) if (aDestFormat == gfxImageFormat::RGB16_565) { ScaleYCbCrToRGB565(aData.mYChannel, @@ -997,7 +996,7 @@ gfxUtils::ConvertYCbCrToRGB(const PlanarYCbCrData& aData, } /* static */ void gfxUtils::ClearThebesSurface(gfxASurface* aSurface, - nsIntRect* aRect, + IntRect* aRect, const gfxRGBA& aColor) { if (aSurface->CairoStatus()) { @@ -1010,11 +1009,11 @@ gfxUtils::ConvertYCbCrToRGB(const PlanarYCbCrData& aData, cairo_t* ctx = cairo_create(surf); cairo_set_source_rgba(ctx, aColor.r, aColor.g, aColor.b, aColor.a); cairo_set_operator(ctx, CAIRO_OPERATOR_SOURCE); - nsIntRect bounds; + IntRect bounds; if (aRect) { bounds = *aRect; } else { - bounds = nsIntRect(nsIntPoint(0, 0), aSurface->GetSize()); + bounds = IntRect(nsIntPoint(0, 0), aSurface->GetSize()); } cairo_rectangle(ctx, bounds.x, bounds.y, bounds.width, bounds.height); cairo_fill(ctx); diff --git a/gfx/thebes/gfxUtils.h b/gfx/thebes/gfxUtils.h index e8c00b465f..bc50a0c0a1 100644 --- a/gfx/thebes/gfxUtils.h +++ b/gfx/thebes/gfxUtils.h @@ -14,14 +14,13 @@ #include "mozilla/RefPtr.h" #include "nsColor.h" #include "nsPrintfCString.h" +#include "mozilla/gfx/Rect.h" class gfxASurface; class gfxDrawable; class nsIntRegion; class nsIPresShell; -struct nsIntRect; - namespace mozilla { namespace layers { struct PlanarYCbCrData; @@ -121,11 +120,11 @@ public: const IntPoint& aToBottomRight); /** - * If aIn can be represented exactly using an nsIntRect (i.e. + * If aIn can be represented exactly using an gfx::IntRect (i.e. * integer-aligned edges and coordinates in the int32_t range) then we * set aOut to that rectangle, otherwise return failure. */ - static bool GfxRectToIntRect(const gfxRect& aIn, nsIntRect* aOut); + static bool GfxRectToIntRect(const gfxRect& aIn, mozilla::gfx::IntRect* aOut); /** * Return the smallest power of kScaleResolution (2) greater than or equal to @@ -163,7 +162,7 @@ public: * Clears surface to aColor (which defaults to transparent black). */ static void ClearThebesSurface(gfxASurface* aSurface, - nsIntRect* aRect = nullptr, + mozilla::gfx::IntRect* aRect = nullptr, const gfxRGBA& aColor = gfxRGBA(0.0, 0.0, 0.0, 0.0)); /** diff --git a/gfx/thebes/gfxWindowsNativeDrawing.cpp b/gfx/thebes/gfxWindowsNativeDrawing.cpp index b2c97dbee1..ec1575b42b 100644 --- a/gfx/thebes/gfxWindowsNativeDrawing.cpp +++ b/gfx/thebes/gfxWindowsNativeDrawing.cpp @@ -272,7 +272,7 @@ gfxWindowsNativeDrawing::PaintToContext() RefPtr source = Factory::CreateWrappingDataSourceSurface(black->Data(), black->Stride(), - ToIntSize(black->GetSize()), + black->GetSize(), SurfaceFormat::B8G8R8A8); mContext->Save(); diff --git a/gfx/thebes/gfxWindowsPlatform.h b/gfx/thebes/gfxWindowsPlatform.h index e8dbbd72ff..a84da7da8f 100644 --- a/gfx/thebes/gfxWindowsPlatform.h +++ b/gfx/thebes/gfxWindowsPlatform.h @@ -57,8 +57,6 @@ struct IDirect3DDevice9; struct ID3D11Device; struct IDXGIAdapter1; -class nsIMemoryReporter; - /** * Utility to get a Windows HDC from a Moz2D DrawTarget. If the DrawTarget is * not backed by a HDC this will get the HDC for the screen device context diff --git a/gfx/thebes/gfxXlibNativeRenderer.cpp b/gfx/thebes/gfxXlibNativeRenderer.cpp index 75883f1ba9..c7f6cec50a 100644 --- a/gfx/thebes/gfxXlibNativeRenderer.cpp +++ b/gfx/thebes/gfxXlibNativeRenderer.cpp @@ -69,9 +69,9 @@ _convert_coord_to_int (double coord, int32_t *v) static bool _get_rectangular_clip (cairo_t *cr, - const nsIntRect& bounds, + const IntRect& bounds, bool *need_clip, - nsIntRect *rectangles, int max_rectangles, + IntRect *rectangles, int max_rectangles, int *num_rectangles) { cairo_rectangle_list_t *cliplist; @@ -90,8 +90,8 @@ _get_rectangular_clip (cairo_t *cr, clips = cliplist->rectangles; for (i = 0; i < cliplist->num_rectangles; ++i) { - - nsIntRect rect; + + IntRect rect; if (!_convert_coord_to_int (clips[i].x, &rect.x) || !_convert_coord_to_int (clips[i].y, &rect.y) || !_convert_coord_to_int (clips[i].width, &rect.width) || @@ -106,7 +106,7 @@ _get_rectangular_clip (cairo_t *cr, /* the bounds are entirely inside the clip region so we don't need to clip. */ *need_clip = false; goto FINISH; - } + } NS_ASSERTION(bounds.Contains(rect), "Was expecting to be clipped to bounds"); @@ -176,7 +176,7 @@ gfxXlibNativeRenderer::DrawCairo(cairo_t* cr, nsIntSize size, NS_ASSERTION(int32_t(device_offset_x) == device_offset_x && int32_t(device_offset_y) == device_offset_y, "Expected integer device offsets"); - nsIntPoint offset(NS_lroundf(matrix.x0 + device_offset_x), + IntPoint offset(NS_lroundf(matrix.x0 + device_offset_x), NS_lroundf(matrix.y0 + device_offset_y)); int max_rectangles = 0; @@ -189,14 +189,14 @@ gfxXlibNativeRenderer::DrawCairo(cairo_t* cr, nsIntSize size, /* The client won't draw outside the surface so consider this when analysing clip rectangles. */ - nsIntRect bounds(offset, size); + IntRect bounds(offset, size); bounds.IntersectRect(bounds, - nsIntRect(0, 0, + IntRect(0, 0, cairo_xlib_surface_get_width(target), cairo_xlib_surface_get_height(target))); bool needs_clip = true; - nsIntRect rectangles[MAX_STATIC_CLIP_RECTANGLES]; + IntRect rectangles[MAX_STATIC_CLIP_RECTANGLES]; int rect_count = 0; /* Check that the clip is rectangular and aligned on unit boundaries. */ @@ -360,7 +360,7 @@ CreateTempXlibSurface (cairo_surface_t* cairoTarget, } else { target_format = gfxXlibSurface::FindRenderFormat(dpy, imageFormat); - } + } } if (supportsAlternateVisual && @@ -436,7 +436,7 @@ CreateTempXlibSurface (cairo_surface_t* cairoTarget, bool gfxXlibNativeRenderer::DrawOntoTempSurface(cairo_surface_t *tempXlibSurface, - nsIntPoint offset) + IntPoint offset) { cairo_surface_flush(tempXlibSurface); /* no clipping is needed because the callback can't draw outside the native @@ -506,7 +506,7 @@ gfxXlibNativeRenderer::Draw(gfxContext* ctx, nsIntSize size, return; } - nsIntRect drawingRect(nsIntPoint(0, 0), size); + IntRect drawingRect(IntPoint(0, 0), size); // Drawing need only be performed within the clip extents // (and padding for the filter). if (!matrixIsIntegerTranslation) { @@ -516,7 +516,7 @@ gfxXlibNativeRenderer::Draw(gfxContext* ctx, nsIntSize size, } clipExtents.RoundOut(); - nsIntRect intExtents(int32_t(clipExtents.X()), + IntRect intExtents(int32_t(clipExtents.X()), int32_t(clipExtents.Y()), int32_t(clipExtents.Width()), int32_t(clipExtents.Height())); @@ -573,7 +573,7 @@ gfxXlibNativeRenderer::Draw(gfxContext* ctx, nsIntSize size, native.mFormat = moz2DFormat; native.mType = NativeSurfaceType::CAIRO_SURFACE; native.mSurface = tempXlibSurface; - native.mSize = ToIntSize(size); + native.mSize = size; RefPtr sourceSurface = drawTarget->CreateSourceSurfaceFromNativeSurface(native); if (sourceSurface) { @@ -615,7 +615,7 @@ gfxXlibNativeRenderer::Draw(gfxContext* ctx, nsIntSize size, native.mFormat = moz2DFormat; native.mType = NativeSurfaceType::CAIRO_SURFACE; native.mSurface = paintSurface->CairoSurface(); - native.mSize = ToIntSize(size); + native.mSize = size; RefPtr sourceSurface = drawTarget->CreateSourceSurfaceFromNativeSurface(native); if (sourceSurface) { diff --git a/gfx/thebes/gfxXlibNativeRenderer.h b/gfx/thebes/gfxXlibNativeRenderer.h index e355fe62e4..4c3a08ef4e 100644 --- a/gfx/thebes/gfxXlibNativeRenderer.h +++ b/gfx/thebes/gfxXlibNativeRenderer.h @@ -8,6 +8,8 @@ #include "nsPoint.h" #include "nsRect.h" +#include "mozilla/gfx/Rect.h" +#include "mozilla/gfx/Point.h" #include namespace mozilla { @@ -18,8 +20,6 @@ namespace gfx { class gfxASurface; class gfxContext; -struct nsIntRect; -struct nsIntPoint; typedef struct _cairo cairo_t; typedef struct _cairo_surface cairo_surface_t; @@ -45,8 +45,9 @@ public: * no clipping is required. */ virtual nsresult DrawWithXlib(cairo_surface_t* surface, - nsIntPoint offset, - nsIntRect* clipRects, uint32_t numClipRects) = 0; + mozilla::gfx::IntPoint offset, + mozilla::gfx::IntRect* clipRects, + uint32_t numClipRects) = 0; enum { // If set, then Draw() is opaque, i.e., every pixel in the intersection @@ -93,11 +94,11 @@ private: void DrawFallback(mozilla::gfx::DrawTarget* dt, gfxContext* ctx, gfxASurface* aSurface, mozilla::gfx::IntSize& size, - nsIntRect& drawingRect, bool canDrawOverBackground, + mozilla::gfx::IntRect& drawingRect, bool canDrawOverBackground, uint32_t flags, Screen* screen, Visual* visual); bool DrawOntoTempSurface(cairo_surface_t *tempXlibSurface, - nsIntPoint offset); + mozilla::gfx::IntPoint offset); }; diff --git a/hal/sandbox/PHal.ipdl b/hal/sandbox/PHal.ipdl index f45d232ed2..829fc64219 100644 --- a/hal/sandbox/PHal.ipdl +++ b/hal/sandbox/PHal.ipdl @@ -16,7 +16,7 @@ using mozilla::hal::WakeLockControl from "mozilla/HalTypes.h"; using mozilla::hal::SwitchState from "mozilla/HalTypes.h"; using mozilla::hal::SwitchDevice from "mozilla/HalTypes.h"; using mozilla::hal::ProcessPriority from "mozilla/HalTypes.h"; -using struct nsIntRect from "nsRect.h"; +using nsIntRect from "nsRect.h"; using PRTime from "prtime.h"; using mozilla::hal::FMRadioCountry from "mozilla/HalTypes.h"; using mozilla::hal::FMRadioOperation from "mozilla/HalTypes.h"; diff --git a/image/Decoder.cpp b/image/Decoder.cpp index 864fa24c24..b1ed2134c6 100644 --- a/image/Decoder.cpp +++ b/image/Decoder.cpp @@ -625,7 +625,7 @@ Decoder::PostFrameStop(Opacity aFrameOpacity /* = Opacity::TRANSPARENT */, // here when the first frame is complete. if (!mSendPartialInvalidations && !mIsAnimated) { mInvalidRect.UnionRect(mInvalidRect, - nsIntRect(nsIntPoint(0, 0), GetSize())); + gfx::IntRect(gfx::IntPoint(0, 0), GetSize())); } } diff --git a/image/ImageOps.h b/image/ImageOps.h index 36e6bd3f49..d080a54e4d 100644 --- a/image/ImageOps.h +++ b/image/ImageOps.h @@ -8,10 +8,10 @@ #define mozilla_image_ImageOps_h #include "nsCOMPtr.h" +#include "nsRect.h" class gfxDrawable; class imgIContainer; -struct nsIntRect; namespace mozilla { namespace image { diff --git a/image/MultipartImage.cpp b/image/MultipartImage.cpp index d0f274959b..dc20006ead 100644 --- a/image/MultipartImage.cpp +++ b/image/MultipartImage.cpp @@ -182,7 +182,7 @@ void MultipartImage::FinishTransition() // Finally, send all the notifications for the new current part and send a // FRAME_UPDATE notification so that observers know to redraw. mTracker->SyncNotifyProgress(newCurrentPartTracker->GetProgress(), - nsIntRect::GetMaxSizedIntRect()); + GetMaxSizedIntRect()); } already_AddRefed diff --git a/image/OrientedImage.cpp b/image/OrientedImage.cpp index 15ead36dcd..653405fdde 100644 --- a/image/OrientedImage.cpp +++ b/image/OrientedImage.cpp @@ -98,7 +98,7 @@ OrientedImage::GetFrame(uint32_t aWhichFrame, // Create a surface to draw into. RefPtr target = gfxPlatform::GetPlatform()-> - CreateOffscreenContentDrawTarget(ToIntSize(size), surfaceFormat); + CreateOffscreenContentDrawTarget(size, surfaceFormat); if (!target) { NS_ERROR("Could not create a DrawTarget"); return nullptr; diff --git a/image/ProgressTracker.cpp b/image/ProgressTracker.cpp index 8d15681974..25bd03f681 100644 --- a/image/ProgressTracker.cpp +++ b/image/ProgressTracker.cpp @@ -392,7 +392,7 @@ ProgressTracker::SyncNotify(IProgressObserver* aObserver) if (NS_FAILED(mImage->GetWidth(&rect.width)) || NS_FAILED(mImage->GetHeight(&rect.height))) { // Either the image has no intrinsic size, or it has an error. - rect = nsIntRect::GetMaxSizedIntRect(); + rect = GetMaxSizedIntRect(); } } diff --git a/image/RasterImage.cpp b/image/RasterImage.cpp index d65a587449..858ad4bfd1 100644 --- a/image/RasterImage.cpp +++ b/image/RasterImage.cpp @@ -125,7 +125,7 @@ class ScaleRunner : public nsRunnable public: ScaleRunner(RasterImage* aImage, uint32_t aImageFlags, - const nsIntSize& aSize, + const IntSize& aSize, RawAccessFrameRef&& aSrcRef) : mImage(aImage) , mSrcRef(Move(aSrcRef)) @@ -238,7 +238,7 @@ private: WeakPtr mImage; RawAccessFrameRef mSrcRef; RawAccessFrameRef mDstRef; - const nsIntSize mDstSize; + const IntSize mDstSize; uint32_t mImageFlags; ScaleState mState; }; @@ -514,7 +514,7 @@ RasterImage::LookupFrameInternal(uint32_t aFrameNum, DrawableFrameRef RasterImage::LookupFrame(uint32_t aFrameNum, - const nsIntSize& aSize, + const IntSize& aSize, uint32_t aFlags) { MOZ_ASSERT(NS_IsMainThread()); @@ -578,7 +578,7 @@ RasterImage::GetRequestedFrameIndex(uint32_t aWhichFrame) const return aWhichFrame == FRAME_FIRST ? 0 : GetCurrentFrameIndex(); } -nsIntRect +IntRect RasterImage::GetFirstFrameRect() { if (mAnim) { @@ -586,7 +586,7 @@ RasterImage::GetFirstFrameRect() } // Fall back to our size. This is implicitly zero-size if !mHasSize. - return nsIntRect(nsIntPoint(0,0), mSize); + return IntRect(IntPoint(0,0), mSize); } NS_IMETHODIMP_(bool) @@ -707,7 +707,7 @@ RasterImage::CopyFrame(uint32_t aWhichFrame, uint32_t aFlags) return nullptr; } - nsIntRect intFrameRect = frameRef->GetRect(); + IntRect intFrameRect = frameRef->GetRect(); Rect rect(intFrameRect.x, intFrameRect.y, intFrameRect.width, intFrameRect.height); if (frameRef->IsSinglePixel()) { @@ -766,7 +766,7 @@ RasterImage::GetFrameInternal(uint32_t aWhichFrame, uint32_t aFlags) // If this frame covers the entire image, we can just reuse its existing // surface. RefPtr frameSurf; - nsIntRect frameRect = frameRef->GetRect(); + IntRect frameRect = frameRef->GetRect(); if (frameRect.x == 0 && frameRect.y == 0 && frameRect.width == mSize.width && frameRect.height == mSize.height) { @@ -910,7 +910,7 @@ class OnAddedFrameRunnable : public nsRunnable public: OnAddedFrameRunnable(RasterImage* aImage, uint32_t aNewFrameCount, - const nsIntRect& aNewRefreshArea) + const IntRect& aNewRefreshArea) : mImage(aImage) , mNewFrameCount(aNewFrameCount) , mNewRefreshArea(aNewRefreshArea) @@ -927,12 +927,12 @@ public: private: nsRefPtr mImage; uint32_t mNewFrameCount; - nsIntRect mNewRefreshArea; + IntRect mNewRefreshArea; }; void RasterImage::OnAddedFrame(uint32_t aNewFrameCount, - const nsIntRect& aNewRefreshArea) + const IntRect& aNewRefreshArea) { if (!NS_IsMainThread()) { nsCOMPtr runnable = @@ -1144,8 +1144,8 @@ RasterImage::SetLoopCount(int32_t aLoopCount) } } -NS_IMETHODIMP_(nsIntRect) -RasterImage::GetImageSpaceInvalidationRect(const nsIntRect& aRect) +NS_IMETHODIMP_(IntRect) +RasterImage::GetImageSpaceInvalidationRect(const IntRect& aRect) { return aRect; } @@ -1345,7 +1345,7 @@ RasterImage::CanDiscard() { // Sets up a decoder for this image. already_AddRefed -RasterImage::CreateDecoder(const Maybe& aSize, uint32_t aFlags) +RasterImage::CreateDecoder(const Maybe& aSize, uint32_t aFlags) { // Make sure we actually get size before doing a full decode. if (aSize) { @@ -1493,7 +1493,7 @@ RasterImage::StartDecoding() } NS_IMETHODIMP -RasterImage::RequestDecodeForSize(const nsIntSize& aSize, uint32_t aFlags) +RasterImage::RequestDecodeForSize(const IntSize& aSize, uint32_t aFlags) { MOZ_ASSERT(NS_IsMainThread()); @@ -1508,7 +1508,7 @@ RasterImage::RequestDecodeForSize(const nsIntSize& aSize, uint32_t aFlags) // Fall back to our intrinsic size if we don't support // downscale-during-decode. - nsIntSize targetSize = mDownscaleDuringDecode ? aSize : mSize; + IntSize targetSize = mDownscaleDuringDecode ? aSize : mSize; // Decide whether to sync decode images we can decode quickly. Here we are // explicitly trading off flashing for responsiveness in the case that we're @@ -1528,7 +1528,7 @@ RasterImage::RequestDecodeForSize(const nsIntSize& aSize, uint32_t aFlags) } NS_IMETHODIMP -RasterImage::Decode(const Maybe& aSize, uint32_t aFlags) +RasterImage::Decode(const Maybe& aSize, uint32_t aFlags) { MOZ_ASSERT(!aSize || NS_IsMainThread()); @@ -1591,7 +1591,7 @@ RasterImage::Decode(const Maybe& aSize, uint32_t aFlags) } void -RasterImage::RecoverFromLossOfFrames(const nsIntSize& aSize, uint32_t aFlags) +RasterImage::RecoverFromLossOfFrames(const IntSize& aSize, uint32_t aFlags) { if (!mHasSize) { return; @@ -1616,7 +1616,7 @@ RasterImage::RecoverFromLossOfFrames(const nsIntSize& aSize, uint32_t aFlags) bool RasterImage::CanScale(GraphicsFilter aFilter, - const nsIntSize& aSize, + const IntSize& aSize, uint32_t aFlags) { #ifndef MOZ_ENABLE_SKIA @@ -1676,7 +1676,7 @@ RasterImage::CanScale(GraphicsFilter aFilter, } bool -RasterImage::CanDownscaleDuringDecode(const nsIntSize& aSize, uint32_t aFlags) +RasterImage::CanDownscaleDuringDecode(const IntSize& aSize, uint32_t aFlags) { // Check basic requirements: downscale-during-decode is enabled for this // image, we have all the source data and know our size, the flags allow us to @@ -1714,13 +1714,13 @@ RasterImage::NotifyNewScaledFrame() { // Send an invalidation so observers will repaint and can take advantage of // the new scaled frame if possible. - NotifyProgress(NoProgress, nsIntRect(0, 0, mSize.width, mSize.height)); + NotifyProgress(NoProgress, IntRect(0, 0, mSize.width, mSize.height)); } void RasterImage::RequestScale(imgFrame* aFrame, uint32_t aFlags, - const nsIntSize& aSize) + const IntSize& aSize) { // We don't scale frames which aren't fully decoded. if (!aFrame->IsImageComplete()) { @@ -1753,7 +1753,7 @@ RasterImage::RequestScale(imgFrame* aFrame, DrawResult RasterImage::DrawWithPreDownscaleIfNeeded(DrawableFrameRef&& aFrameRef, gfxContext* aContext, - const nsIntSize& aSize, + const IntSize& aSize, const ImageRegion& aRegion, GraphicsFilter aFilter, uint32_t aFlags) @@ -1819,14 +1819,14 @@ RasterImage::DrawWithPreDownscaleIfNeeded(DrawableFrameRef&& aFrameRef, * in gfxGraphicsFilter aFilter, * [const] in gfxMatrix aUserSpaceToImageSpace, * [const] in gfxRect aFill, - * [const] in nsIntRect aSubimage, - * [const] in nsIntSize aViewportSize, + * [const] in IntRect aSubimage, + * [const] in IntSize aViewportSize, * [const] in SVGImageContext aSVGContext, * in uint32_t aWhichFrame, * in uint32_t aFlags); */ NS_IMETHODIMP_(DrawResult) RasterImage::Draw(gfxContext* aContext, - const nsIntSize& aSize, + const IntSize& aSize, const ImageRegion& aRegion, uint32_t aWhichFrame, GraphicsFilter aFilter, @@ -2041,7 +2041,7 @@ RasterImage::GetFramesNotified(uint32_t *aFramesNotified) void RasterImage::NotifyProgress(Progress aProgress, - const nsIntRect& aInvalidRect /* = nsIntRect() */, + const IntRect& aInvalidRect /* = IntRect() */, uint32_t aFlags /* = DECODE_FLAGS_DEFAULT */) { MOZ_ASSERT(NS_IsMainThread()); @@ -2131,7 +2131,7 @@ RasterImage::Unwrap() return self.forget(); } -nsIntSize +IntSize RasterImage::OptimalImageSizeForDest(const gfxSize& aDest, uint32_t aWhichFrame, GraphicsFilter aFilter, uint32_t aFlags) { @@ -2140,10 +2140,10 @@ RasterImage::OptimalImageSizeForDest(const gfxSize& aDest, uint32_t aWhichFrame, "Unexpected destination size"); if (mSize.IsEmpty() || aDest.IsEmpty()) { - return nsIntSize(0, 0); + return IntSize(0, 0); } - nsIntSize destSize(ceil(aDest.width), ceil(aDest.height)); + IntSize destSize(ceil(aDest.width), ceil(aDest.height)); if (aFilter == GraphicsFilter::FILTER_GOOD && CanDownscaleDuringDecode(destSize, aFlags)) { diff --git a/image/SVGDocumentWrapper.cpp b/image/SVGDocumentWrapper.cpp index cd42029e8b..5f290ba92a 100644 --- a/image/SVGDocumentWrapper.cpp +++ b/image/SVGDocumentWrapper.cpp @@ -86,7 +86,7 @@ SVGDocumentWrapper::UpdateViewportBounds(const nsIntSize& aViewportSize) // If the bounds have changed, we need to do a layout flush. if (currentBounds.Size() != aViewportSize) { - mViewer->SetBounds(nsIntRect(nsIntPoint(0, 0), aViewportSize)); + mViewer->SetBounds(IntRect(IntPoint(0, 0), aViewportSize)); FlushLayout(); } diff --git a/image/VectorImage.cpp b/image/VectorImage.cpp index 111add5852..6ad35dbcdc 100644 --- a/image/VectorImage.cpp +++ b/image/VectorImage.cpp @@ -247,7 +247,7 @@ NS_IMPL_ISUPPORTS(SVGLoadEventListener, nsIDOMEventListener) class SVGDrawingCallback : public gfxDrawingCallback { public: SVGDrawingCallback(SVGDocumentWrapper* aSVGDocumentWrapper, - const nsIntRect& aViewport, + const IntRect& aViewport, const IntSize& aSize, uint32_t aImageFlags) : mSVGDocumentWrapper(aSVGDocumentWrapper) @@ -261,7 +261,7 @@ public: const gfxMatrix& aTransform); private: nsRefPtr mSVGDocumentWrapper; - const nsIntRect mViewport; + const IntRect mViewport; const IntSize mSize; uint32_t mImageFlags; }; @@ -540,12 +540,12 @@ VectorImage::SendInvalidationNotifications() if (mProgressTracker) { SurfaceCache::RemoveImage(ImageKey(this)); mProgressTracker->SyncNotifyProgress(FLAG_FRAME_COMPLETE, - nsIntRect::GetMaxSizedIntRect()); + GetMaxSizedIntRect()); } } -NS_IMETHODIMP_(nsIntRect) -VectorImage::GetImageSpaceInvalidationRect(const nsIntRect& aRect) +NS_IMETHODIMP_(IntRect) +VectorImage::GetImageSpaceInvalidationRect(const IntRect& aRect) { return aRect; } @@ -855,7 +855,7 @@ VectorImage::CreateSurfaceAndShow(const SVGDrawingParameters& aParams) nsRefPtr cb = new SVGDrawingCallback(mSVGDocumentWrapper, - nsIntRect(nsIntPoint(0, 0), aParams.viewportSize), + IntRect(IntPoint(0, 0), aParams.viewportSize), aParams.size, aParams.flags); @@ -937,7 +937,7 @@ VectorImage::CreateSurfaceAndShow(const SVGDrawingParameters& aParams) // Send out an invalidation so that surfaces that are still in use get // re-locked. See the discussion of the UnlockSurfaces call above. mProgressTracker->SyncNotifyProgress(FLAG_FRAME_COMPLETE, - nsIntRect::GetMaxSizedIntRect()); + GetMaxSizedIntRect()); } @@ -1198,7 +1198,7 @@ VectorImage::OnSVGDocumentLoaded() FLAG_FRAME_COMPLETE | FLAG_DECODE_COMPLETE | FLAG_ONLOAD_UNBLOCKED, - nsIntRect::GetMaxSizedIntRect()); + GetMaxSizedIntRect()); } EvaluateAnimation(); diff --git a/image/imgFrame.cpp b/image/imgFrame.cpp index cdf8ec871a..eabef801a4 100644 --- a/image/imgFrame.cpp +++ b/image/imgFrame.cpp @@ -680,7 +680,7 @@ imgFrame::ImageUpdatedInternal(const nsIntRect& aUpdateRect) // clamp to bounds, in case someone sends a bogus updateRect (I'm looking at // you, gif decoder) - nsIntRect boundsRect(mOffset, nsIntSize(mSize.width, mSize.height)); + nsIntRect boundsRect(gfx::ToIntPoint(mOffset), gfx::IntSize(mSize.width, mSize.height)); mDecoded.IntersectRect(mDecoded, boundsRect); // If the image is now complete, wake up anyone who's waiting. @@ -712,7 +712,7 @@ imgFrame::Finish(Opacity aFrameOpacity /* = Opacity::SOME_TRANSPARENCY */, nsIntRect imgFrame::GetRect() const { - return nsIntRect(mOffset, nsIntSize(mSize.width, mSize.height)); + return gfx::IntRect(gfx::ToIntPoint(mOffset), gfx::IntSize(mSize.width, mSize.height)); } int32_t diff --git a/image/imgRequestProxy.cpp b/image/imgRequestProxy.cpp index fa2f431396..b275cf7a5c 100644 --- a/image/imgRequestProxy.cpp +++ b/image/imgRequestProxy.cpp @@ -776,7 +776,7 @@ NotificationTypeToString(int32_t aType) } void -imgRequestProxy::Notify(int32_t aType, const nsIntRect* aRect) +imgRequestProxy::Notify(int32_t aType, const mozilla::gfx::IntRect* aRect) { MOZ_ASSERT(aType != imgINotificationObserver::LOAD_COMPLETE, "Should call OnLoadComplete"); diff --git a/image/imgRequestProxy.h b/image/imgRequestProxy.h index 41408ef1f0..5f55e1a414 100644 --- a/image/imgRequestProxy.h +++ b/image/imgRequestProxy.h @@ -17,6 +17,7 @@ #include "nsAutoPtr.h" #include "nsThreadUtils.h" #include "mozilla/TimeStamp.h" +#include "mozilla/gfx/Rect.h" #include "imgRequest.h" #include "IProgressObserver.h" @@ -32,7 +33,6 @@ class imgINotificationObserver; class imgRequestNotifyRunnable; class imgStatusNotifyRunnable; -struct nsIntRect; class ProxyBehaviour; namespace mozilla { @@ -97,7 +97,7 @@ public: // imgINotificationObserver methods: virtual void Notify(int32_t aType, - const nsIntRect* aRect = nullptr) override; + const mozilla::gfx::IntRect* aRect = nullptr) override; virtual void OnLoadComplete(bool aLastPart) override; // imgIOnloadBlocker methods: diff --git a/layout/base/ActiveLayerTracker.cpp b/layout/base/ActiveLayerTracker.cpp index 925d093b00..2e19ceefea 100644 --- a/layout/base/ActiveLayerTracker.cpp +++ b/layout/base/ActiveLayerTracker.cpp @@ -4,6 +4,7 @@ #include "ActiveLayerTracker.h" +#include "mozilla/ArrayUtils.h" #include "nsExpirationTracker.h" #include "nsContainerFrame.h" #include "nsIContent.h" @@ -288,7 +289,7 @@ ActiveLayerTracker::IsStyleAnimated(nsDisplayListBuilder* aBuilder, } nsIContent* content = aFrame->GetContent(); if (content) { - return nsLayoutUtils::HasCurrentAnimationsForProperty(content, aProperty); + return nsLayoutUtils::HasCurrentAnimationsForProperties(content, &aProperty, 1); } return false; @@ -310,6 +311,11 @@ ActiveLayerTracker::IsOffsetOrMarginStyleAnimated(nsIFrame* aFrame) return true; } } + // We should also check for running CSS animations of these properties once + // bug 1009693 is fixed. Until that happens, layerization isn't useful for + // animations of these properties because we'll invalidate the layer contents + // on every change anyway. + // See bug 1151346 for a patch that adds a check for CSS animations. return false; } diff --git a/layout/base/DisplayItemClip.h b/layout/base/DisplayItemClip.h index 28d3bbde0e..9afca38b84 100644 --- a/layout/base/DisplayItemClip.h +++ b/layout/base/DisplayItemClip.h @@ -12,7 +12,6 @@ #include "nsStyleConsts.h" class gfxContext; -class nsDisplayItem; class nsPresContext; class nsRegion; diff --git a/layout/base/FrameLayerBuilder.cpp b/layout/base/FrameLayerBuilder.cpp index c2d349a107..da2126ff44 100644 --- a/layout/base/FrameLayerBuilder.cpp +++ b/layout/base/FrameLayerBuilder.cpp @@ -2218,7 +2218,7 @@ ContainerState::FindOpaqueBackgroundColorInLayer(const PaintedLayerData* aData, // Scan the candidate's display items. nsIntRect deviceRect = aRect; - nsRect appUnitRect = deviceRect.ToAppUnits(mAppUnitsPerDevPixel); + nsRect appUnitRect = ToAppUnits(deviceRect, mAppUnitsPerDevPixel); appUnitRect.ScaleInverseRoundOut(mParameters.mXScale, mParameters.mYScale); for (auto& assignedItem : Reversed(aData->mAssignedDisplayItems)) { @@ -4857,7 +4857,7 @@ FrameLayerBuilder::BuildContainerLayerFor(nsDisplayListBuilder* aBuilder, // we won't paint if (aChildren->IsOpaque() && !aChildren->NeedsTransparentSurface()) { bounds.ScaleRoundIn(scaleParameters.mXScale, scaleParameters.mYScale); - if (bounds.Contains(pixBounds.ToAppUnits(appUnitsPerDevPixel))) { + if (bounds.Contains(ToAppUnits(pixBounds, appUnitsPerDevPixel))) { // Clear CONTENT_COMPONENT_ALPHA and add CONTENT_OPAQUE instead. flags &= ~Layer::CONTENT_COMPONENT_ALPHA; flags |= Layer::CONTENT_OPAQUE; @@ -5105,7 +5105,7 @@ FrameLayerBuilder::PaintItems(nsTArray& aItems, DrawTarget& aDrawTarget = *aRC->GetDrawTarget(); int32_t appUnitsPerDevPixel = aPresContext->AppUnitsPerDevPixel(); - nsRect boundRect = aRect.ToAppUnits(appUnitsPerDevPixel); + nsRect boundRect = ToAppUnits(aRect, appUnitsPerDevPixel); boundRect.MoveBy(NSIntPixelsToAppUnits(aOffset.x, appUnitsPerDevPixel), NSIntPixelsToAppUnits(aOffset.y, appUnitsPerDevPixel)); boundRect.ScaleInverseRoundOut(aXScale, aYScale); diff --git a/layout/base/FrameLayerBuilder.h b/layout/base/FrameLayerBuilder.h index 705fa92577..3f2ae9a661 100644 --- a/layout/base/FrameLayerBuilder.h +++ b/layout/base/FrameLayerBuilder.h @@ -50,8 +50,6 @@ public: bool mIsInfinite; }; -struct NewLayerEntry; - struct ContainerLayerParameters { ContainerLayerParameters() : mXScale(1) diff --git a/layout/base/GeometryUtils.h b/layout/base/GeometryUtils.h index 4398400df7..5cefbafd17 100644 --- a/layout/base/GeometryUtils.h +++ b/layout/base/GeometryUtils.h @@ -16,7 +16,6 @@ */ class nsINode; -class nsIDocument; namespace mozilla { diff --git a/layout/base/SelectionCarets.h b/layout/base/SelectionCarets.h index 8c4406c7e0..68ea99653f 100644 --- a/layout/base/SelectionCarets.h +++ b/layout/base/SelectionCarets.h @@ -17,16 +17,11 @@ #include "mozilla/EventForwards.h" #include "mozilla/WeakPtr.h" -class nsCanvasFrame; class nsDocShell; class nsFrameSelection; class nsIContent; -class nsIDocument; -class nsIFrame; class nsIPresShell; class nsITimer; -class nsIWidget; -class nsPresContext; namespace mozilla { diff --git a/layout/base/nsCSSFrameConstructor.h b/layout/base/nsCSSFrameConstructor.h index 299b2d1313..8eecb303f2 100644 --- a/layout/base/nsCSSFrameConstructor.h +++ b/layout/base/nsCSSFrameConstructor.h @@ -24,10 +24,8 @@ #include "ScrollbarStyles.h" struct nsFrameItems; -struct nsAbsoluteItems; class nsStyleContext; struct nsStyleDisplay; -class nsIDOMHTMLSelectElement; struct nsGenConInitializer; class nsContainerFrame; @@ -38,7 +36,6 @@ struct PendingBinding; class nsGenericDOMDataNode; class nsFrameConstructorState; -class nsFrameConstructorSaveState; namespace mozilla { diff --git a/layout/base/nsIDocumentViewerPrint.h b/layout/base/nsIDocumentViewerPrint.h index 3ca6251624..2c753c9933 100644 --- a/layout/base/nsIDocumentViewerPrint.h +++ b/layout/base/nsIDocumentViewerPrint.h @@ -11,7 +11,6 @@ class nsIDocument; class nsStyleSet; class nsIPresShell; class nsPresContext; -class nsIWidget; class nsViewManager; // {c6f255cf-cadd-4382-b57f-cd2a9874169b} diff --git a/layout/base/nsIPresShell.h b/layout/base/nsIPresShell.h index 68e59ead77..212abfbe86 100644 --- a/layout/base/nsIPresShell.h +++ b/layout/base/nsIPresShell.h @@ -33,6 +33,7 @@ #include "nsColor.h" #include "nsCompatibility.h" #include "nsFrameManagerBase.h" +#include "nsRect.h" #include "mozFlushType.h" #include "nsWeakReference.h" #include // for FILE definition @@ -79,8 +80,6 @@ class nsDisplayListBuilder; class nsPIDOMWindow; struct nsPoint; class nsINode; -struct nsIntPoint; -struct nsIntRect; struct nsRect; class nsRegion; class nsRefreshDriver; @@ -94,7 +93,6 @@ class DocAccessible; } // namespace a11y } // namespace mozilla #endif -class nsIWidget; struct nsArenaMemoryStats; class nsITimer; diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index 46206539b9..650731573a 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -418,8 +418,9 @@ nsLayoutUtils::HasCurrentAnimations(nsIContent* aContent, } bool -nsLayoutUtils::HasCurrentAnimationsForProperty(nsIContent* aContent, - nsCSSProperty aProperty) +nsLayoutUtils::HasCurrentAnimationsForProperties(nsIContent* aContent, + const nsCSSProperty* aProperties, + size_t aPropertyCount) { if (!aContent->MayHaveAnimations()) return false; @@ -430,8 +431,11 @@ nsLayoutUtils::HasCurrentAnimationsForProperty(nsIContent* aContent, for (nsIAtom* const* animProp = sAnimProps; *animProp; animProp++) { AnimationPlayerCollection* collection = static_cast(aContent->GetProperty(*animProp)); - if (collection && collection->HasCurrentAnimationsForProperty(aProperty)) + if (collection && + collection->HasCurrentAnimationsForProperties(aProperties, + aPropertyCount)) { return true; + } } return false; @@ -4520,7 +4524,7 @@ nsLayoutUtils::IntrinsicForContainer(nsRenderingContext *aRenderingContext, const nsStyleDisplay *disp = aFrame->StyleDisplay(); if (aFrame->IsThemed(disp)) { - nsIntSize size(0, 0); + LayoutDeviceIntSize size; bool canOverride = true; nsPresContext *presContext = aFrame->PresContext(); presContext->GetTheme()-> diff --git a/layout/base/nsLayoutUtils.h b/layout/base/nsLayoutUtils.h index 88f3e2e206..d6083ed43d 100644 --- a/layout/base/nsLayoutUtils.h +++ b/layout/base/nsLayoutUtils.h @@ -34,7 +34,6 @@ #include #include -class nsIFormControlFrame; class nsPresContext; class nsIContent; class nsIAtom; @@ -80,7 +79,6 @@ struct RectCornerRadii; } // namespace gfx namespace layers { class Layer; -class ClientLayerManager; } } @@ -2145,10 +2143,11 @@ public: /** * Returns true if the content node has any current animations or transitions - * for the specified property. + * for any of the specified properties. */ - static bool HasCurrentAnimationsForProperty(nsIContent* aContent, - nsCSSProperty aProperty); + static bool HasCurrentAnimationsForProperties(nsIContent* aContent, + const nsCSSProperty* aProperties, + size_t aPropertyCount); /** * Checks if off-main-thread animations are enabled. diff --git a/layout/base/nsPresContext.h b/layout/base/nsPresContext.h index c8a4a70661..f30487ffd0 100644 --- a/layout/base/nsPresContext.h +++ b/layout/base/nsPresContext.h @@ -39,7 +39,6 @@ #include "nsIMessageManager.h" #include "mozilla/RestyleLogging.h" -class nsBidiPresUtils; class nsAString; class nsIPrintSettings; class nsDocShell; @@ -52,14 +51,10 @@ class nsIFrame; class nsFrameManager; class nsILinkHandler; class nsIAtom; -class nsICSSPseudoComparator; -struct nsStyleBackground; -struct nsStyleBorder; class nsIRunnable; class gfxUserFontEntry; class gfxUserFontSet; class gfxTextPerfMetrics; -struct nsFontFaceRuleContainer; class nsPluginFrame; class nsTransitionManager; class nsAnimationManager; diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index 0c64042c7e..2bfef5c33a 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -5304,7 +5304,7 @@ PresShell::RenderNode(nsIDOMNode* aNode, // combine the area with the supplied region nsIntRect rrectPixels = aRegion->GetBounds(); - nsRect rrect = rrectPixels.ToAppUnits(nsPresContext::AppUnitsPerCSSPixel()); + nsRect rrect = ToAppUnits(rrectPixels, nsPresContext::AppUnitsPerCSSPixel()); area.IntersectRect(area, rrect); nsPresContext* pc = GetPresContext(); diff --git a/layout/base/nsPresShell.h b/layout/base/nsPresShell.h index c847d50ae8..a2df16dcf8 100644 --- a/layout/base/nsPresShell.h +++ b/layout/base/nsPresShell.h @@ -38,7 +38,6 @@ #include "mozilla/MemoryReporting.h" class nsRange; -class nsIDragService; struct RangePaintInfo; struct nsCallbackEventRequest; diff --git a/layout/base/nsRefreshDriver.h b/layout/base/nsRefreshDriver.h index 429a5d5779..fc87f51b00 100644 --- a/layout/base/nsRefreshDriver.h +++ b/layout/base/nsRefreshDriver.h @@ -28,7 +28,6 @@ class nsPresContext; class nsIPresShell; class nsIDocument; class imgIRequest; -class nsIRunnable; namespace mozilla { class RefreshDriverTimer; diff --git a/layout/build/nsContentDLF.h b/layout/build/nsContentDLF.h index b03876c60e..957400bc42 100644 --- a/layout/build/nsContentDLF.h +++ b/layout/build/nsContentDLF.h @@ -11,8 +11,6 @@ class nsIChannel; class nsIContentViewer; -class nsIFile; -class nsIInputStream; class nsILoadGroup; class nsIStreamListener; diff --git a/layout/forms/nsFileControlFrame.h b/layout/forms/nsFileControlFrame.h index 274a9eed39..60748f5c55 100644 --- a/layout/forms/nsFileControlFrame.h +++ b/layout/forms/nsFileControlFrame.h @@ -13,7 +13,6 @@ #include "nsIAnonymousContentCreator.h" #include "nsCOMPtr.h" -class nsTextControlFrame; class nsIDOMDataTransfer; class nsFileControlFrame : public nsBlockFrame, diff --git a/layout/forms/nsListControlFrame.h b/layout/forms/nsListControlFrame.h index e83e92a82c..53133c9e10 100644 --- a/layout/forms/nsListControlFrame.h +++ b/layout/forms/nsListControlFrame.h @@ -29,8 +29,6 @@ #undef KeyPress #endif -class nsIDOMHTMLSelectElement; -class nsIDOMHTMLOptionsCollection; class nsIComboboxControlFrame; class nsPresContext; class nsListEventListener; diff --git a/layout/forms/nsProgressFrame.h b/layout/forms/nsProgressFrame.h index 0171303023..349d76ae38 100644 --- a/layout/forms/nsProgressFrame.h +++ b/layout/forms/nsProgressFrame.h @@ -11,8 +11,6 @@ #include "nsIAnonymousContentCreator.h" #include "nsCOMPtr.h" -class nsBaseContentList; - class nsProgressFrame : public nsContainerFrame, public nsIAnonymousContentCreator { diff --git a/layout/forms/nsRangeFrame.cpp b/layout/forms/nsRangeFrame.cpp index 5722e8b9a7..21d195bef3 100644 --- a/layout/forms/nsRangeFrame.cpp +++ b/layout/forms/nsRangeFrame.cpp @@ -517,7 +517,7 @@ nsRangeFrame::GetValueAtEventPoint(WidgetGUIEvent* aEvent) // We need to get the size of the thumb from the theme. nsPresContext *presContext = PresContext(); bool notUsedCanOverride; - nsIntSize size; + LayoutDeviceIntSize size; presContext->GetTheme()-> GetMinimumWidgetSize(presContext, this, NS_THEME_RANGE_THUMB, &size, ¬UsedCanOverride); diff --git a/layout/forms/nsRangeFrame.h b/layout/forms/nsRangeFrame.h index 85460ffb8a..32dba33df3 100644 --- a/layout/forms/nsRangeFrame.h +++ b/layout/forms/nsRangeFrame.h @@ -14,7 +14,6 @@ #include "nsIDOMEventListener.h" #include "nsCOMPtr.h" -class nsBaseContentList; class nsDisplayRangeFocusRing; class nsRangeFrame : public nsContainerFrame, diff --git a/layout/generic/ScrollbarActivity.h b/layout/generic/ScrollbarActivity.h index b390fefbfc..c3c94840f6 100644 --- a/layout/generic/ScrollbarActivity.h +++ b/layout/generic/ScrollbarActivity.h @@ -15,7 +15,6 @@ class nsIContent; class nsIScrollbarMediator; class nsITimer; -class nsIAtom; namespace mozilla { namespace layout { diff --git a/layout/generic/TextOverflow.h b/layout/generic/TextOverflow.h index b8d5056744..2156c069f4 100644 --- a/layout/generic/TextOverflow.h +++ b/layout/generic/TextOverflow.h @@ -15,7 +15,6 @@ #include class nsIScrollableFrame; -class gfxTextRun; class nsLineBox; namespace mozilla { diff --git a/layout/generic/nsBlockFrame.h b/layout/generic/nsBlockFrame.h index 13abfb1998..411437ff98 100644 --- a/layout/generic/nsBlockFrame.h +++ b/layout/generic/nsBlockFrame.h @@ -44,7 +44,6 @@ enum LineReflowStatus { class nsBlockReflowState; class nsBlockInFlowLineIterator; class nsBulletFrame; -class nsFirstLineFrame; /** * Some invariants: diff --git a/layout/generic/nsBlockReflowContext.h b/layout/generic/nsBlockReflowContext.h index d0c1018df4..7afec5ae3a 100644 --- a/layout/generic/nsBlockReflowContext.h +++ b/layout/generic/nsBlockReflowContext.h @@ -16,8 +16,6 @@ class nsBlockReflowState; struct nsHTMLReflowState; class nsLineBox; class nsPresContext; -class nsLineLayout; -struct nsBlockHorizontalAlign; /** * An encapsulation of the state and algorithm for reflowing block frames. diff --git a/layout/generic/nsFlexContainerFrame.cpp b/layout/generic/nsFlexContainerFrame.cpp index 94f485d556..3241fc5be4 100644 --- a/layout/generic/nsFlexContainerFrame.cpp +++ b/layout/generic/nsFlexContainerFrame.cpp @@ -179,14 +179,14 @@ public: nscoord GetMainComponent(const nsSize& aSize) const { return GET_MAIN_COMPONENT(*this, aSize.width, aSize.height); } - int32_t GetMainComponent(const nsIntSize& aIntSize) const { + int32_t GetMainComponent(const LayoutDeviceIntSize& aIntSize) const { return GET_MAIN_COMPONENT(*this, aIntSize.width, aIntSize.height); } nscoord GetCrossComponent(const nsSize& aSize) const { return GET_CROSS_COMPONENT(*this, aSize.width, aSize.height); } - int32_t GetCrossComponent(const nsIntSize& aIntSize) const { + int32_t GetCrossComponent(const LayoutDeviceIntSize& aIntSize) const { return GET_CROSS_COMPONENT(*this, aIntSize.width, aIntSize.height); } @@ -1042,7 +1042,7 @@ nsFlexContainerFrame::GenerateFlexItemForChild( bool isFixedSizeWidget = false; const nsStyleDisplay* disp = aChildFrame->StyleDisplay(); if (aChildFrame->IsThemed(disp)) { - nsIntSize widgetMinSize(0, 0); + LayoutDeviceIntSize widgetMinSize; bool canOverride = true; aPresContext->GetTheme()-> GetMinimumWidgetSize(aPresContext, aChildFrame, diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp index 332e79f039..183ab10870 100644 --- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -16,6 +16,7 @@ #include "mozilla/DebugOnly.h" #include "mozilla/gfx/2D.h" #include "mozilla/gfx/PathHelpers.h" +#include "gfx2DGlue.h" #include "nsCOMPtr.h" #include "nsFrameList.h" @@ -4329,7 +4330,7 @@ nsFrame::ComputeSize(nsRenderingContext *aRenderingContext, const nsStyleDisplay *disp = StyleDisplay(); if (IsThemed(disp)) { - nsIntSize widget(0, 0); + LayoutDeviceIntSize widget; bool canOverride = true; nsPresContext *presContext = PresContext(); presContext->GetTheme()-> @@ -4946,7 +4947,7 @@ nsIFrame::GetTransformMatrix(const nsIFrame* aStopAtAncestor, widget->GetClientBounds(screenBounds); nsIntRect toplevelScreenBounds; toplevel->GetClientBounds(toplevelScreenBounds); - nsIntPoint translation = screenBounds.TopLeft() - toplevelScreenBounds.TopLeft(); + nsIntPoint translation = gfx::ThebesIntPoint(screenBounds.TopLeft() - toplevelScreenBounds.TopLeft()); Matrix4x4 transformToTop; transformToTop._41 = translation.x; diff --git a/layout/generic/nsFrame.h b/layout/generic/nsFrame.h index 34babc951a..f40ebf84c8 100644 --- a/layout/generic/nsFrame.h +++ b/layout/generic/nsFrame.h @@ -97,7 +97,6 @@ //---------------------------------------------------------------------- struct nsBoxLayoutMetrics; -class nsDisplayBackgroundImage; struct nsRect; /** diff --git a/layout/generic/nsFrameSelection.h b/layout/generic/nsFrameSelection.h index 364f941fa4..60690d0330 100644 --- a/layout/generic/nsFrameSelection.h +++ b/layout/generic/nsFrameSelection.h @@ -20,7 +20,6 @@ #include "nsBidiPresUtils.h" class nsRange; -class nsTableOuterFrame; // IID for the nsFrameSelection interface // 3c6ae2d0-4cf1-44a1-9e9d-2411867f19c6 diff --git a/layout/generic/nsGfxScrollFrame.cpp b/layout/generic/nsGfxScrollFrame.cpp index d5f2507b0b..93d37876b3 100644 --- a/layout/generic/nsGfxScrollFrame.cpp +++ b/layout/generic/nsGfxScrollFrame.cpp @@ -1039,7 +1039,7 @@ ScrollFrameHelper::GetNondisappearingScrollbarWidth(nsBoxLayoutState* aState) theme->ThemeSupportsWidget(aState->PresContext(), mVScrollbarBox, NS_THEME_SCROLLBAR_NON_DISAPPEARING)) { - nsIntSize size; + LayoutDeviceIntSize size; bool canOverride = true; theme->GetMinimumWidgetSize(aState->PresContext(), mVScrollbarBox, diff --git a/layout/generic/nsGfxScrollFrame.h b/layout/generic/nsGfxScrollFrame.h index a90e6588d1..fa92cf37cc 100644 --- a/layout/generic/nsGfxScrollFrame.h +++ b/layout/generic/nsGfxScrollFrame.h @@ -27,7 +27,6 @@ class nsPresContext; class nsIPresShell; class nsIContent; class nsIAtom; -class nsIScrollFrameInternal; class nsPresState; class nsIScrollPositionListener; struct ScrollReflowState; diff --git a/layout/generic/nsHTMLParts.h b/layout/generic/nsHTMLParts.h index 8dd1fbdf26..6dd5d39a3a 100644 --- a/layout/generic/nsHTMLParts.h +++ b/layout/generic/nsHTMLParts.h @@ -14,14 +14,12 @@ class nsIAtom; class nsNodeInfoManager; class nsIContent; -class nsIContentIterator; class nsIDocument; class nsIFrame; class nsIHTMLContentSink; class nsIFragmentContentSink; class nsStyleContext; class nsIURI; -class nsString; class nsIPresShell; class nsIChannel; class nsTableColFrame; diff --git a/layout/generic/nsIAnonymousContentCreator.h b/layout/generic/nsIAnonymousContentCreator.h index a2a2f716ce..69d08867a8 100644 --- a/layout/generic/nsIAnonymousContentCreator.h +++ b/layout/generic/nsIAnonymousContentCreator.h @@ -15,7 +15,6 @@ #include "nsStyleContext.h" #include "nsTArrayForwardDeclare.h" -class nsBaseContentList; class nsIContent; class nsIFrame; diff --git a/layout/generic/nsIFrame.h b/layout/generic/nsIFrame.h index 7115c4c0a8..81defbb2a6 100644 --- a/layout/generic/nsIFrame.h +++ b/layout/generic/nsIFrame.h @@ -59,14 +59,12 @@ */ struct nsHTMLReflowState; -class nsHTMLReflowCommand; class nsIAtom; class nsPresContext; class nsIPresShell; class nsRenderingContext; class nsView; class nsIWidget; -class nsIDOMRange; class nsISelectionController; class nsBoxLayoutState; class nsBoxLayout; diff --git a/layout/generic/nsImageFrame.cpp b/layout/generic/nsImageFrame.cpp index b09049564b..86f893ace7 100644 --- a/layout/generic/nsImageFrame.cpp +++ b/layout/generic/nsImageFrame.cpp @@ -614,7 +614,7 @@ nsImageFrame::OnFrameUpdate(imgIRequest* aRequest, const nsIntRect* aRect) ? mImage->GetImageSpaceInvalidationRect(*aRect) : *aRect; - if (layerInvalidRect.IsEqualInterior(nsIntRect::GetMaxSizedIntRect())) { + if (layerInvalidRect.IsEqualInterior(GetMaxSizedIntRect())) { // Invalidate our entire area. InvalidateSelf(nullptr, nullptr); return NS_OK; diff --git a/layout/generic/nsPluginFrame.h b/layout/generic/nsPluginFrame.h index ce850d84d0..9427aaa2e2 100644 --- a/layout/generic/nsPluginFrame.h +++ b/layout/generic/nsPluginFrame.h @@ -29,7 +29,6 @@ class nsPresContext; class nsRootPresContext; class nsDisplayPlugin; -class nsIOSurface; class PluginBackgroundSink; class nsPluginInstanceOwner; diff --git a/layout/generic/nsRubyFrame.h b/layout/generic/nsRubyFrame.h index 5cfd340503..ab84de7326 100644 --- a/layout/generic/nsRubyFrame.h +++ b/layout/generic/nsRubyFrame.h @@ -12,7 +12,6 @@ #include "nsInlineFrame.h" class nsRubyBaseContainerFrame; -class nsRubyTextContainerFrame; typedef nsInlineFrame nsRubyFrameSuper; diff --git a/layout/inspector/inLayoutUtils.h b/layout/inspector/inLayoutUtils.h index a5bf333389..e86e7d71c7 100644 --- a/layout/inspector/inLayoutUtils.h +++ b/layout/inspector/inLayoutUtils.h @@ -10,10 +10,6 @@ class nsIDocument; class nsIDOMDocument; class nsIDOMElement; class nsIDOMNode; -class nsIDOMWindow; -class nsIFrame; -class nsIPresShell; -class nsISupports; namespace mozilla { class EventStateManager; diff --git a/layout/inspector/nsFontFace.h b/layout/inspector/nsFontFace.h index 89d801513d..3da0d98be5 100644 --- a/layout/inspector/nsFontFace.h +++ b/layout/inspector/nsFontFace.h @@ -10,7 +10,6 @@ class gfxFontEntry; class gfxFontGroup; -class nsCSSFontFaceRule; class nsFontFace : public nsIDOMFontFace { diff --git a/layout/printing/nsPrintEngine.h b/layout/printing/nsPrintEngine.h index 1d99c08b34..e893a8c90a 100644 --- a/layout/printing/nsPrintEngine.h +++ b/layout/printing/nsPrintEngine.h @@ -25,13 +25,11 @@ // Classes class nsPagePrintTimer; class nsIDocShell; -class nsDeviceContext; class nsIDocument; class nsIDocumentViewerPrint; class nsPrintObject; class nsIDocShell; class nsIPageSequenceFrame; -class nsIWeakReference; //------------------------------------------------------------------------ // nsPrintEngine Class diff --git a/layout/reftests/first-letter/399941-5-ref.html b/layout/reftests/first-letter/399941-5-ref.html index d0e25accc8..5a5baac1e8 100644 --- a/layout/reftests/first-letter/399941-5-ref.html +++ b/layout/reftests/first-letter/399941-5-ref.html @@ -12,6 +12,6 @@ -

"*" is an asterix

+

"*" is an asterisk

diff --git a/layout/reftests/first-letter/399941-5.html b/layout/reftests/first-letter/399941-5.html index b70abd461f..2e8fe8caab 100644 --- a/layout/reftests/first-letter/399941-5.html +++ b/layout/reftests/first-letter/399941-5.html @@ -12,6 +12,6 @@ -

"*" is an asterix

+

"*" is an asterisk

diff --git a/layout/style/AnimationCommon.cpp b/layout/style/AnimationCommon.cpp index b5876d7807..889893fe92 100644 --- a/layout/style/AnimationCommon.cpp +++ b/layout/style/AnimationCommon.cpp @@ -924,15 +924,16 @@ AnimationPlayerCollection::HasCurrentAnimations() const } bool -AnimationPlayerCollection::HasCurrentAnimationsForProperty(nsCSSProperty - aProperty) const +AnimationPlayerCollection::HasCurrentAnimationsForProperties( + const nsCSSProperty* aProperties, + size_t aPropertyCount) const { for (size_t playerIdx = mPlayers.Length(); playerIdx-- != 0; ) { const AnimationPlayer& player = *mPlayers[playerIdx]; const Animation* anim = player.GetSource(); if (anim && anim->IsCurrent(player) && - anim->HasAnimationOfProperty(aProperty)) { + anim->HasAnimationOfProperties(aProperties, aPropertyCount)) { return true; } } diff --git a/layout/style/AnimationCommon.h b/layout/style/AnimationCommon.h index b074b544ac..fec40c5c8c 100644 --- a/layout/style/AnimationCommon.h +++ b/layout/style/AnimationCommon.h @@ -28,7 +28,6 @@ class nsIFrame; class nsPresContext; -class nsStyleChangeList; namespace mozilla { @@ -417,9 +416,10 @@ struct AnimationPlayerCollection : public PRCList // Returns true if there is an animation that has yet to finish. bool HasCurrentAnimations() const; - // Returns true if there is an animation of the specified property that - // has yet to finish. - bool HasCurrentAnimationsForProperty(nsCSSProperty aProperty) const; + // Returns true if there is an animation of any of the specified properties + // that has yet to finish. + bool HasCurrentAnimationsForProperties(const nsCSSProperty* aProperties, + size_t aPropertyCount) const; // The refresh time associated with mStyleRule. TimeStamp mStyleRuleRefreshTime; diff --git a/layout/style/CSSStyleSheet.h b/layout/style/CSSStyleSheet.h index b82197d653..d798952252 100644 --- a/layout/style/CSSStyleSheet.h +++ b/layout/style/CSSStyleSheet.h @@ -29,7 +29,6 @@ class CSSRuleListImpl; class nsCSSRuleProcessor; -class nsICSSRuleList; class nsIPrincipal; class nsIURI; class nsMediaList; diff --git a/layout/style/CSSValue.h b/layout/style/CSSValue.h index 0f6df035cc..ecba05e847 100644 --- a/layout/style/CSSValue.h +++ b/layout/style/CSSValue.h @@ -12,7 +12,6 @@ #include "nsWrapperCache.h" #include "nsStringFwd.h" -class nsIDOMCSSValue; class nsROCSSPrimitiveValue; namespace mozilla { class ErrorResult; diff --git a/layout/style/CounterStyleManager.h b/layout/style/CounterStyleManager.h index 38ac538f08..124a86cf92 100644 --- a/layout/style/CounterStyleManager.h +++ b/layout/style/CounterStyleManager.h @@ -17,7 +17,6 @@ #include "nsCSSValue.h" class nsPresContext; -class nsCSSCounterStyleRule; namespace mozilla { diff --git a/layout/style/Loader.h b/layout/style/Loader.h index bfd641ffe2..691cfa5f2e 100644 --- a/layout/style/Loader.h +++ b/layout/style/Loader.h @@ -23,14 +23,11 @@ #include "mozilla/MemoryReporting.h" #include "mozilla/net/ReferrerPolicy.h" -class nsIAtom; class nsICSSLoaderObserver; class nsIContent; class nsIDocument; -class nsCSSParser; class nsMediaList; class nsIStyleSheetLinkingElement; -class nsCycleCollectionTraversalCallback; namespace mozilla { class CSSStyleSheet; diff --git a/layout/style/Rule.h b/layout/style/Rule.h index 77c4e21560..093543c56d 100644 --- a/layout/style/Rule.h +++ b/layout/style/Rule.h @@ -13,7 +13,6 @@ #include "nsIStyleRule.h" #include "nsIDOMCSSRule.h" -class nsIStyleSheet; class nsIDocument; struct nsRuleData; template struct already_AddRefed; diff --git a/layout/style/SVGAttrAnimationRuleProcessor.h b/layout/style/SVGAttrAnimationRuleProcessor.h index 8749bca103..7a3fb65144 100644 --- a/layout/style/SVGAttrAnimationRuleProcessor.h +++ b/layout/style/SVGAttrAnimationRuleProcessor.h @@ -14,7 +14,6 @@ #include "nsIStyleRuleProcessor.h" -class nsIDocument; class nsRuleWalker; namespace mozilla { diff --git a/layout/style/StyleRule.h b/layout/style/StyleRule.h index efa2d3be1f..6bce38497e 100644 --- a/layout/style/StyleRule.h +++ b/layout/style/StyleRule.h @@ -22,7 +22,6 @@ class nsIAtom; struct nsCSSSelectorList; -class nsCSSCompressedDataBlock; namespace mozilla { class CSSStyleSheet; diff --git a/layout/style/nsAnimationManager.h b/layout/style/nsAnimationManager.h index bd62b8e020..d49cb7b130 100644 --- a/layout/style/nsAnimationManager.h +++ b/layout/style/nsAnimationManager.h @@ -13,7 +13,6 @@ #include "mozilla/MemoryReporting.h" #include "mozilla/TimeStamp.h" -class nsCSSKeyframesRule; class nsStyleContext; namespace mozilla { diff --git a/layout/style/nsCSSRuleProcessor.h b/layout/style/nsCSSRuleProcessor.h index 0d6cd63aa2..5ccbda211f 100644 --- a/layout/style/nsCSSRuleProcessor.h +++ b/layout/style/nsCSSRuleProcessor.h @@ -22,8 +22,10 @@ #include "mozilla/UniquePtr.h" struct CascadeEnumData; +struct ElementDependentRuleProcessorData; struct nsCSSSelector; struct nsCSSSelectorList; +struct nsFontFaceRuleContainer; struct RuleCascadeData; struct TreeMatchContext; class nsCSSKeyframesRule; diff --git a/layout/style/nsComputedDOMStyle.h b/layout/style/nsComputedDOMStyle.h index 73ff28234b..d0e387b0f3 100644 --- a/layout/style/nsComputedDOMStyle.h +++ b/layout/style/nsComputedDOMStyle.h @@ -34,33 +34,12 @@ class nsDOMCSSValueList; struct nsMargin; class nsROCSSPrimitiveValue; struct nsStyleBackground; -struct nsStyleBorder; -struct nsStyleContent; -struct nsStyleColumn; -struct nsStyleColor; class nsStyleCoord; class nsStyleCorners; -struct nsStyleDisplay; struct nsStyleFilter; -struct nsStyleFont; class nsStyleGradient; struct nsStyleImage; -struct nsStyleList; -struct nsStyleMargin; -struct nsStyleOutline; -struct nsStylePadding; -struct nsStylePosition; -struct nsStyleQuotes; class nsStyleSides; -struct nsStyleSVG; -struct nsStyleSVGReset; -struct nsStyleTable; -struct nsStyleText; -struct nsStyleTextReset; -class nsStyleTimingFunction; -struct nsStyleUIReset; -struct nsStyleVisibility; -struct nsStyleXUL; struct nsTimingFunction; class gfx3DMatrix; diff --git a/layout/style/nsFontFaceLoader.h b/layout/style/nsFontFaceLoader.h index 858a2aa508..e47b12088f 100644 --- a/layout/style/nsFontFaceLoader.h +++ b/layout/style/nsFontFaceLoader.h @@ -18,7 +18,6 @@ #include "nsTHashtable.h" #include "nsCSSRules.h" -class nsPresContext; class nsIPrincipal; class nsFontFaceLoader : public nsIStreamLoaderObserver diff --git a/layout/style/nsICSSPseudoComparator.h b/layout/style/nsICSSPseudoComparator.h index 20b3f5cb10..0ea2078916 100644 --- a/layout/style/nsICSSPseudoComparator.h +++ b/layout/style/nsICSSPseudoComparator.h @@ -8,7 +8,6 @@ #ifndef nsICSSPseudoComparator_h___ #define nsICSSPseudoComparator_h___ -class nsIAtom; struct nsCSSSelector; class nsICSSPseudoComparator diff --git a/layout/style/nsIStyleRuleProcessor.h b/layout/style/nsIStyleRuleProcessor.h index 6132549c94..00182dd380 100644 --- a/layout/style/nsIStyleRuleProcessor.h +++ b/layout/style/nsIStyleRuleProcessor.h @@ -17,7 +17,6 @@ #include "nsChangeHint.h" struct RuleProcessorData; -struct ElementDependentRuleProcessorData; struct ElementRuleProcessorData; struct PseudoElementRuleProcessorData; struct AnonBoxRuleProcessorData; diff --git a/layout/style/nsRuleNode.h b/layout/style/nsRuleNode.h index b7c6ac2ae3..9cb38eabda 100644 --- a/layout/style/nsRuleNode.h +++ b/layout/style/nsRuleNode.h @@ -20,7 +20,6 @@ class nsIStyleRule; struct nsCSSValueList; class nsCSSPropertySet; class nsCSSValue; -struct nsCSSRect; class nsStyleCoord; struct nsCSSValuePairList; diff --git a/layout/style/nsRuleProcessorData.h b/layout/style/nsRuleProcessorData.h index 60da99188c..67dbd9ad2c 100644 --- a/layout/style/nsRuleProcessorData.h +++ b/layout/style/nsRuleProcessorData.h @@ -23,11 +23,9 @@ #include "mozilla/EventStates.h" #include "mozilla/GuardObjects.h" -class nsAttrValue; class nsIAtom; class nsIContent; class nsICSSPseudoComparator; -class nsIStyleSheet; struct TreeMatchContext; /** diff --git a/layout/style/nsStyleSet.h b/layout/style/nsStyleSet.h index 0b38a6dfd5..713dc218ee 100644 --- a/layout/style/nsStyleSet.h +++ b/layout/style/nsStyleSet.h @@ -26,13 +26,14 @@ #include "nsCSSPseudoElements.h" class gfxFontFeatureValueSet; -class nsCSSFontFaceRule; class nsCSSKeyframesRule; class nsCSSFontFeatureValuesRule; class nsCSSPageRule; class nsCSSCounterStyleRule; +class nsICSSPseudoComparator; class nsRuleWalker; struct ElementDependentRuleProcessorData; +struct nsFontFaceRuleContainer; struct TreeMatchContext; namespace mozilla { diff --git a/layout/style/nsTransitionManager.cpp b/layout/style/nsTransitionManager.cpp index 7c17b8832e..af54a2d5e8 100644 --- a/layout/style/nsTransitionManager.cpp +++ b/layout/style/nsTransitionManager.cpp @@ -24,6 +24,7 @@ #include "nsIFrame.h" #include "Layers.h" #include "FrameLayerBuilder.h" +#include "nsCSSProps.h" #include "nsDisplayList.h" #include "nsStyleChangeList.h" #include "nsStyleSet.h" @@ -39,6 +40,16 @@ using namespace mozilla; using namespace mozilla::layers; using namespace mozilla::css; +const nsString& +ElementPropertyTransition::Name() const +{ + if (!mName.Length()) { + const_cast(this)->mName = + NS_ConvertUTF8toUTF16(nsCSSProps::GetStringValue(TransitionProperty())); + } + return dom::Animation::Name(); +} + double ElementPropertyTransition::CurrentValuePortion() const { @@ -424,13 +435,12 @@ nsTransitionManager::ConsiderStartingTransition( if (aElementTransitions) { AnimationPlayerPtrArray& players = aElementTransitions->mPlayers; for (size_t i = 0, i_end = players.Length(); i < i_end; ++i) { - MOZ_ASSERT(players[i]->GetSource() && - players[i]->GetSource()->Properties().Length() == 1, - "Should have one animation property for a transition"); - if (players[i]->GetSource()->Properties()[0].mProperty == aProperty) { + const ElementPropertyTransition *iPt = + players[i]->GetSource()->AsTransition(); + if (iPt->TransitionProperty() == aProperty) { haveCurrentTransition = true; currentIndex = i; - oldPT = players[currentIndex]->GetSource()->AsTransition(); + oldPT = iPt; break; } } @@ -576,13 +586,11 @@ nsTransitionManager::ConsiderStartingTransition( AnimationPlayerPtrArray& players = aElementTransitions->mPlayers; #ifdef DEBUG for (size_t i = 0, i_end = players.Length(); i < i_end; ++i) { - MOZ_ASSERT(players[i]->GetSource() && - players[i]->GetSource()->Properties().Length() == 1, - "Should have one animation property for a transition"); MOZ_ASSERT( i == currentIndex || (players[i]->GetSource() && - players[i]->GetSource()->Properties()[0].mProperty != aProperty), + players[i]->GetSource()->AsTransition()->TransitionProperty() + != aProperty), "duplicate transitions for property"); } #endif @@ -807,9 +815,8 @@ nsTransitionManager::FlushTransitions(FlushFlags aFlags) ComputedTiming computedTiming = player->GetSource()->GetComputedTiming(); if (computedTiming.mPhase == ComputedTiming::AnimationPhase_After) { - MOZ_ASSERT(player->GetSource()->Properties().Length() == 1, - "Should have one animation property for a transition"); - nsCSSProperty prop = player->GetSource()->Properties()[0].mProperty; + nsCSSProperty prop = + player->GetSource()->AsTransition()->TransitionProperty(); TimeDuration duration = player->GetSource()->Timing().mIterationDuration; events.AppendElement( diff --git a/layout/style/nsTransitionManager.h b/layout/style/nsTransitionManager.h index 347e5806cd..a0c6630056 100644 --- a/layout/style/nsTransitionManager.h +++ b/layout/style/nsTransitionManager.h @@ -18,7 +18,6 @@ class nsStyleContext; class nsPresContext; class nsCSSPropertySet; -struct ElementDependentRuleProcessorData; namespace mozilla { struct StyleTransition; @@ -42,6 +41,15 @@ struct ElementPropertyTransition : public dom::Animation virtual ElementPropertyTransition* AsTransition() { return this; } virtual const ElementPropertyTransition* AsTransition() const { return this; } + virtual const nsString& Name() const; + + nsCSSProperty TransitionProperty() const { + MOZ_ASSERT(Properties().Length() == 1, + "Transitions should have exactly one animation property. " + "Perhaps we are using an un-initialized transition?"); + return Properties()[0].mProperty; + } + // This is the start value to be used for a check for whether a // transition is being reversed. Normally the same as // mProperties[0].mSegments[0].mFromValue, except when this transition diff --git a/layout/svg/nsCSSFilterInstance.h b/layout/svg/nsCSSFilterInstance.h index 16ae115984..5d60eb3e77 100644 --- a/layout/svg/nsCSSFilterInstance.h +++ b/layout/svg/nsCSSFilterInstance.h @@ -13,7 +13,6 @@ #include "mozilla/gfx/Types.h" #include "nsColor.h" -class nsIFrame; struct nsStyleFilter; template class nsTArray; diff --git a/layout/svg/nsFilterInstance.cpp b/layout/svg/nsFilterInstance.cpp index 43f66a5f6d..858bfd8c1c 100644 --- a/layout/svg/nsFilterInstance.cpp +++ b/layout/svg/nsFilterInstance.cpp @@ -353,7 +353,7 @@ nsFilterInstance::BuildSourcePaint(SourceInfo *aSource, RefPtr offscreenDT = gfxPlatform::GetPlatform()->CreateOffscreenContentDrawTarget( - ToIntSize(neededRect.Size()), SurfaceFormat::B8G8R8A8); + neededRect.Size(), SurfaceFormat::B8G8R8A8); if (!offscreenDT) { return NS_ERROR_OUT_OF_MEMORY; } @@ -368,7 +368,7 @@ nsFilterInstance::BuildSourcePaint(SourceInfo *aSource, gfx->Save(); gfx->Multiply(mPaintTransform * deviceToFilterSpace * - gfxMatrix::Translation(-neededRect.TopLeft())); + gfxMatrix::Translation(ThebesIntPoint(-neededRect.TopLeft()))); GeneralPattern pattern; if (aSource == &mFillPaint) { nsSVGUtils::MakeFillPatternFor(mTargetFrame, gfx, &pattern); @@ -417,7 +417,7 @@ nsFilterInstance::BuildSourceImage(DrawTarget* aTargetDT) RefPtr offscreenDT = gfxPlatform::GetPlatform()->CreateOffscreenContentDrawTarget( - ToIntSize(neededRect.Size()), SurfaceFormat::B8G8R8A8); + neededRect.Size(), SurfaceFormat::B8G8R8A8); if (!offscreenDT) { return NS_ERROR_OUT_OF_MEMORY; } @@ -445,7 +445,7 @@ nsFilterInstance::BuildSourceImage(DrawTarget* aTargetDT) } nsRefPtr ctx = new gfxContext(offscreenDT); ctx->SetMatrix( - ctx->CurrentMatrix().Translate(-neededRect.TopLeft()). + ctx->CurrentMatrix().Translate(ThebesIntPoint(-neededRect.TopLeft())). PreMultiply(deviceToFilterSpace)); mPaintCallback->Paint(*ctx, mTargetFrame, mPaintTransform, &dirty); diff --git a/layout/svg/nsISVGChildFrame.h b/layout/svg/nsISVGChildFrame.h index 8ebdb54f78..9451f94a38 100644 --- a/layout/svg/nsISVGChildFrame.h +++ b/layout/svg/nsISVGChildFrame.h @@ -14,9 +14,7 @@ class gfxMatrix; class nsIFrame; class SVGBBox; -struct nsPoint; struct nsRect; -struct nsIntRect; namespace mozilla { class SVGAnimatedLengthList; diff --git a/layout/svg/nsSVGContainerFrame.h b/layout/svg/nsSVGContainerFrame.h index 567a65e688..1f059fcd39 100644 --- a/layout/svg/nsSVGContainerFrame.h +++ b/layout/svg/nsSVGContainerFrame.h @@ -21,9 +21,7 @@ class nsIContent; class nsIPresShell; class nsStyleContext; -struct nsPoint; struct nsRect; -struct nsIntRect; typedef nsContainerFrame nsSVGContainerFrameBase; diff --git a/layout/svg/nsSVGFilterFrame.h b/layout/svg/nsSVGFilterFrame.h index 23fe1117a0..b0e334d466 100644 --- a/layout/svg/nsSVGFilterFrame.h +++ b/layout/svg/nsSVGFilterFrame.h @@ -17,7 +17,6 @@ class nsIContent; class nsIFrame; class nsIPresShell; class nsStyleContext; -class nsSVGIntegerPair; class nsSVGLength2; struct nsRect; diff --git a/layout/svg/nsSVGFilterInstance.h b/layout/svg/nsSVGFilterInstance.h index f955b25776..ab37e78405 100644 --- a/layout/svg/nsSVGFilterInstance.h +++ b/layout/svg/nsSVGFilterInstance.h @@ -13,7 +13,6 @@ #include "nsSVGNumberPair.h" #include "nsTArray.h" -class nsIFrame; class nsSVGFilterFrame; struct nsStyleFilter; diff --git a/layout/svg/nsSVGFilterPaintCallback.h b/layout/svg/nsSVGFilterPaintCallback.h index 370e3cf2cc..3320507c87 100644 --- a/layout/svg/nsSVGFilterPaintCallback.h +++ b/layout/svg/nsSVGFilterPaintCallback.h @@ -6,11 +6,11 @@ #ifndef __NS_SVGFILTERPAINTCALLBACK_H__ #define __NS_SVGFILTERPAINTCALLBACK_H__ +#include "nsRect.h" + class nsIFrame; class gfxContext; -struct nsIntRect; - class nsSVGFilterPaintCallback { public: /** diff --git a/layout/svg/nsSVGForeignObjectFrame.h b/layout/svg/nsSVGForeignObjectFrame.h index 077de2964d..ef3c9d419e 100644 --- a/layout/svg/nsSVGForeignObjectFrame.h +++ b/layout/svg/nsSVGForeignObjectFrame.h @@ -14,7 +14,6 @@ #include "nsSVGUtils.h" class gfxContext; -class nsSVGOuterSVGFrame; typedef nsContainerFrame nsSVGForeignObjectFrameBase; diff --git a/layout/svg/nsSVGImageFrame.cpp b/layout/svg/nsSVGImageFrame.cpp index fb48f4388c..22ab25516f 100644 --- a/layout/svg/nsSVGImageFrame.cpp +++ b/layout/svg/nsSVGImageFrame.cpp @@ -349,7 +349,7 @@ nsSVGImageFrame::PaintSVG(gfxContext& aContext, NS_ASSERTION(!NS_SVGDisplayListPaintingEnabled() || (mState & NS_FRAME_IS_NONDISPLAY), "Display lists handle dirty rect intersection test"); - dirtyRect = aDirtyRect->ToAppUnits(appUnitsPerDevPx); + dirtyRect = ToAppUnits(*aDirtyRect, appUnitsPerDevPx); // Adjust dirtyRect to match our local coordinate system. nsRect rootRect = nsSVGUtils::TransformFrameRectToOuterSVG(mRect, aTransform, diff --git a/layout/svg/nsSVGIntegrationUtils.h b/layout/svg/nsSVGIntegrationUtils.h index 2efde2e3ae..a2e3c60305 100644 --- a/layout/svg/nsSVGIntegrationUtils.h +++ b/layout/svg/nsSVGIntegrationUtils.h @@ -19,7 +19,6 @@ class nsIFrame; class nsIntRegion; struct nsRect; -struct nsIntRect; namespace mozilla { namespace gfx { diff --git a/layout/svg/nsSVGMaskFrame.cpp b/layout/svg/nsSVGMaskFrame.cpp index e03de86d23..9421e66b6f 100644 --- a/layout/svg/nsSVGMaskFrame.cpp +++ b/layout/svg/nsSVGMaskFrame.cpp @@ -242,8 +242,7 @@ nsSVGMaskFrame::GetMaskForMaskedFrame(gfxContext* aContext, bool resultOverflows; IntSize maskSurfaceSize = - ToIntSize(nsSVGUtils::ConvertToSurfaceSize(maskSurfaceRect.Size(), - &resultOverflows)); + nsSVGUtils::ConvertToSurfaceSize(maskSurfaceRect.Size(), &resultOverflows); if (resultOverflows || maskSurfaceSize.IsEmpty()) { // XXXjwatt we should return an empty surface so we don't paint aMaskedFrame! diff --git a/layout/svg/nsSVGPathGeometryFrame.h b/layout/svg/nsSVGPathGeometryFrame.h index 144dcd7fde..ac895db9c3 100644 --- a/layout/svg/nsSVGPathGeometryFrame.h +++ b/layout/svg/nsSVGPathGeometryFrame.h @@ -30,9 +30,7 @@ class nsStyleContext; class nsSVGMarkerFrame; class nsSVGMarkerProperty; -struct nsPoint; struct nsRect; -struct nsIntRect; typedef nsFrame nsSVGPathGeometryFrameBase; diff --git a/layout/svg/nsSVGPatternFrame.h b/layout/svg/nsSVGPatternFrame.h index c7cbcbdf0a..ed832a591c 100644 --- a/layout/svg/nsSVGPatternFrame.h +++ b/layout/svg/nsSVGPatternFrame.h @@ -12,10 +12,7 @@ #include "mozilla/RefPtr.h" #include "nsSVGPaintServerFrame.h" -class gfxASurface; -class gfxContext; class nsIFrame; -class nsSVGElement; class nsSVGLength2; class nsSVGPathGeometryFrame; class nsSVGViewBox; diff --git a/layout/svg/nsSVGUtils.h b/layout/svg/nsSVGUtils.h index c8d2b270c5..ab3009de61 100644 --- a/layout/svg/nsSVGUtils.h +++ b/layout/svg/nsSVGUtils.h @@ -28,15 +28,12 @@ #include class gfxContext; -class gfxPattern; class nsFrameList; class nsIContent; class nsIDocument; class nsIFrame; class nsPresContext; class nsStyleContext; -class nsStyleCoord; -class nsSVGClipPathFrame; class nsSVGDisplayContainerFrame; class nsSVGElement; class nsSVGEnum; @@ -49,12 +46,8 @@ class gfxTextContextPaint; struct nsStyleSVG; struct nsStyleSVGPaint; struct nsRect; -struct nsIntRect; -struct nsPoint; namespace mozilla { -class SVGAnimatedPreserveAspectRatio; -class SVGPreserveAspectRatio; namespace dom { class Element; class UserSpaceMetrics; @@ -62,7 +55,6 @@ class UserSpaceMetrics; namespace gfx { class DrawTarget; class GeneralPattern; -class SourceSurface; } } // namespace mozilla diff --git a/layout/tables/SpanningCellSorter.h b/layout/tables/SpanningCellSorter.h index b83e8acf80..de8c214345 100644 --- a/layout/tables/SpanningCellSorter.h +++ b/layout/tables/SpanningCellSorter.h @@ -15,8 +15,6 @@ #include "nsDebug.h" #include "StackArena.h" -class nsIPresShell; - /** * The SpanningCellSorter is responsible for accumulating lists of cells * with colspans so that those cells can later be enumerated, sorted diff --git a/layout/tables/nsCellMap.h b/layout/tables/nsCellMap.h index 5751de5a43..6fe38ddc47 100644 --- a/layout/tables/nsCellMap.h +++ b/layout/tables/nsCellMap.h @@ -12,11 +12,11 @@ #include "nsCOMPtr.h" #include "nsAlgorithm.h" #include "nsAutoPtr.h" +#include "nsRect.h" #include #undef DEBUG_TABLE_CELLMAP -class nsTableColFrame; class nsTableCellFrame; class nsTableRowFrame; class nsTableRowGroupFrame; @@ -24,7 +24,6 @@ class nsTableFrame; class nsCellMap; class nsPresContext; class nsCellMapColumnIterator; -struct nsIntRect; struct nsColInfo { diff --git a/layout/tables/nsTableColFrame.h b/layout/tables/nsTableColFrame.h index 33e254df97..65dbb77d94 100644 --- a/layout/tables/nsTableColFrame.h +++ b/layout/tables/nsTableColFrame.h @@ -11,8 +11,6 @@ #include "nsContainerFrame.h" #include "nsTArray.h" -class nsTableCellFrame; - enum nsTableColType { eColContent = 0, // there is real col content associated eColAnonymousCol = 1, // the result of a span on a col diff --git a/layout/tables/nsTableFrame.h b/layout/tables/nsTableFrame.h index 7d84e8611d..6cc8a7c889 100644 --- a/layout/tables/nsTableFrame.h +++ b/layout/tables/nsTableFrame.h @@ -21,7 +21,6 @@ class nsTableCellFrame; class nsTableCellMap; class nsTableColFrame; -class nsColGroupFrame; class nsTableRowGroupFrame; class nsTableRowFrame; class nsTableColGroupFrame; @@ -29,7 +28,6 @@ class nsITableLayoutStrategy; class nsStyleContext; struct nsTableReflowState; -struct nsStylePosition; struct BCPropertyData; static inline bool IS_TABLE_CELL(nsIAtom* frameType) { diff --git a/layout/tables/nsTableRowGroupFrame.h b/layout/tables/nsTableRowGroupFrame.h index 4ecdd3dfdb..9616227046 100644 --- a/layout/tables/nsTableRowGroupFrame.h +++ b/layout/tables/nsTableRowGroupFrame.h @@ -15,7 +15,6 @@ class nsTableFrame; class nsTableRowFrame; -class nsTableCellFrame; struct nsRowGroupReflowState { const nsHTMLReflowState& reflowState; // Our reflow state diff --git a/layout/xul/BoxObject.h b/layout/xul/BoxObject.h index 6fdc32b0cf..ac3df420b6 100644 --- a/layout/xul/BoxObject.h +++ b/layout/xul/BoxObject.h @@ -17,10 +17,9 @@ #include "nsInterfaceHashtable.h" #include "nsCycleCollectionParticipant.h" #include "nsWrapperCache.h" +#include "nsRect.h" class nsIFrame; -class nsIDocShell; -struct nsIntRect; class nsIPresShell; namespace mozilla { diff --git a/layout/xul/PopupBoxObject.cpp b/layout/xul/PopupBoxObject.cpp index 56c657722e..04a76360ef 100644 --- a/layout/xul/PopupBoxObject.cpp +++ b/layout/xul/PopupBoxObject.cpp @@ -271,7 +271,7 @@ PopupBoxObject::GetOuterScreenRect() widget->GetScreenBounds(screenRect); int32_t pp = menuPopupFrame->PresContext()->AppUnitsPerDevPixel(); - rect->SetLayoutRect(screenRect.ToAppUnits(pp)); + rect->SetLayoutRect(ToAppUnits(screenRect, pp)); } } return rect.forget(); diff --git a/layout/xul/grid/nsGrid.h b/layout/xul/grid/nsGrid.h index 7be0944c6d..b21700ed28 100644 --- a/layout/xul/grid/nsGrid.h +++ b/layout/xul/grid/nsGrid.h @@ -11,8 +11,6 @@ #include "nsIGridPart.h" #include "nsCOMPtr.h" -class nsGridRowGroupLayout; -class nsGridRowLayout; class nsBoxLayoutState; class nsGridCell; diff --git a/layout/xul/grid/nsGridLayout2.h b/layout/xul/grid/nsGridLayout2.h index 04e231e279..9fb9c67e63 100644 --- a/layout/xul/grid/nsGridLayout2.h +++ b/layout/xul/grid/nsGridLayout2.h @@ -13,12 +13,10 @@ #include "nsCoord.h" #include "nsGrid.h" -class nsIPresContext; class nsGridRowGroupLayout; class nsGridRowLayout; class nsGridRow; class nsBoxLayoutState; -class nsGridCell; /** * The nsBoxLayout implementation for a grid. diff --git a/layout/xul/grid/nsGridRow.h b/layout/xul/grid/nsGridRow.h index 86b983ba50..e2eadeb7e9 100644 --- a/layout/xul/grid/nsGridRow.h +++ b/layout/xul/grid/nsGridRow.h @@ -15,8 +15,6 @@ #include "nsCoord.h" -class nsGridLayout2; -class nsBoxLayoutState; class nsIFrame; /** diff --git a/layout/xul/nsBox.cpp b/layout/xul/nsBox.cpp index 471c3507b4..bbf0467ecb 100644 --- a/layout/xul/nsBox.cpp +++ b/layout/xul/nsBox.cpp @@ -681,7 +681,7 @@ nsIFrame::AddCSSMinSize(nsBoxLayoutState& aState, nsIFrame* aBox, nsSize& aSize, if (display->mAppearance) { nsITheme *theme = aState.PresContext()->GetTheme(); if (theme && theme->ThemeSupportsWidget(aState.PresContext(), aBox, display->mAppearance)) { - nsIntSize size; + LayoutDeviceIntSize size; theme->GetMinimumWidgetSize(aState.PresContext(), aBox, display->mAppearance, &size, &canOverride); if (size.width) { diff --git a/layout/xul/nsBoxLayoutState.h b/layout/xul/nsBoxLayoutState.h index cf07e64094..9375b75b45 100644 --- a/layout/xul/nsBoxLayoutState.h +++ b/layout/xul/nsBoxLayoutState.h @@ -18,11 +18,7 @@ #include "nsIPresShell.h" class nsRenderingContext; -class nsCalculatedBoxInfo; -class nsHTMLReflowMetrics; struct nsHTMLReflowState; -class nsString; -class nsHTMLReflowCommand; class MOZ_STACK_CLASS nsBoxLayoutState { diff --git a/layout/xul/nsIScrollbarMediator.h b/layout/xul/nsIScrollbarMediator.h index f673008166..24a01179f9 100644 --- a/layout/xul/nsIScrollbarMediator.h +++ b/layout/xul/nsIScrollbarMediator.h @@ -10,7 +10,6 @@ #include "nsCoord.h" class nsScrollbarFrame; -class nsIDOMEventTarget; class nsIFrame; class nsIScrollbarMediator : public nsQueryFrame diff --git a/layout/xul/nsLeafBoxFrame.h b/layout/xul/nsLeafBoxFrame.h index 7631ae353c..f0c51e4720 100644 --- a/layout/xul/nsLeafBoxFrame.h +++ b/layout/xul/nsLeafBoxFrame.h @@ -9,8 +9,6 @@ #include "nsLeafFrame.h" #include "nsBox.h" -class nsAccessKeyInfo; - class nsLeafBoxFrame : public nsLeafFrame { public: diff --git a/layout/xul/nsMenuFrame.h b/layout/xul/nsMenuFrame.h index 0dc31c949d..32d3eb6d03 100644 --- a/layout/xul/nsMenuFrame.h +++ b/layout/xul/nsMenuFrame.h @@ -25,7 +25,6 @@ nsIFrame* NS_NewMenuFrame(nsIPresShell* aPresShell, nsStyleContext* aContext); nsIFrame* NS_NewMenuItemFrame(nsIPresShell* aPresShell, nsStyleContext* aContext); class nsIContent; -class nsMenuBarFrame; #define NS_STATE_ACCELTEXT_IS_DERIVED NS_STATE_BOX_CHILD_RESERVED diff --git a/layout/xul/nsMenuPopupFrame.cpp b/layout/xul/nsMenuPopupFrame.cpp index d1a8db4990..9c00ebe6ff 100644 --- a/layout/xul/nsMenuPopupFrame.cpp +++ b/layout/xul/nsMenuPopupFrame.cpp @@ -1499,7 +1499,7 @@ nsMenuPopupFrame::GetConstraintRect(const nsRect& aAnchorRect, } } - nsRect screenRect = screenRectPixels.ToAppUnits(presContext->AppUnitsPerDevPixel()); + nsRect screenRect = ToAppUnits(screenRectPixels, presContext->AppUnitsPerDevPixel()); if (mInContentShell) { // for content shells, clip to the client area rather than the screen area screenRect.IntersectRect(screenRect, aRootScreenRect); diff --git a/layout/xul/nsMenuPopupFrame.h b/layout/xul/nsMenuPopupFrame.h index 2d32c193b8..d68ed46dff 100644 --- a/layout/xul/nsMenuPopupFrame.h +++ b/layout/xul/nsMenuPopupFrame.h @@ -125,7 +125,6 @@ enum FlipType { nsIFrame* NS_NewMenuPopupFrame(nsIPresShell* aPresShell, nsStyleContext* aContext); -class nsViewManager; class nsView; class nsMenuPopupFrame; diff --git a/layout/xul/nsResizerFrame.cpp b/layout/xul/nsResizerFrame.cpp index 4c72e9d3bf..ea353a7be0 100644 --- a/layout/xul/nsResizerFrame.cpp +++ b/layout/xul/nsResizerFrame.cpp @@ -238,7 +238,7 @@ nsResizerFrame::HandleEvent(nsPresContext* aPresContext, // direction, don't allow the new size to be less that the resizer's // size. This ensures that content isn't resized too small as to make // the resizer invisible. - nsRect appUnitsRect = LayoutDevicePixel::ToUntyped(rect).ToAppUnits(aPresContext->AppUnitsPerDevPixel()); + nsRect appUnitsRect = ToAppUnits(LayoutDevicePixel::ToUntyped(rect), aPresContext->AppUnitsPerDevPixel()); if (appUnitsRect.width < mRect.width && mouseMove.x) appUnitsRect.width = mRect.width; if (appUnitsRect.height < mRect.height && mouseMove.y) diff --git a/layout/xul/nsResizerFrame.h b/layout/xul/nsResizerFrame.h index e69f5a7c8b..a339573b0e 100644 --- a/layout/xul/nsResizerFrame.h +++ b/layout/xul/nsResizerFrame.h @@ -10,7 +10,6 @@ #include "nsTitleBarFrame.h" class nsIBaseWindow; -class nsMenuPopupFrame; class nsResizerFrame : public nsTitleBarFrame { diff --git a/layout/xul/nsScrollbarButtonFrame.h b/layout/xul/nsScrollbarButtonFrame.h index dbc4685689..017f42fd99 100644 --- a/layout/xul/nsScrollbarButtonFrame.h +++ b/layout/xul/nsScrollbarButtonFrame.h @@ -18,8 +18,6 @@ #include "nsITimer.h" #include "nsRepeatService.h" -class nsSliderFrame; - class nsScrollbarButtonFrame : public nsButtonBoxFrame { public: diff --git a/layout/xul/nsScrollbarFrame.cpp b/layout/xul/nsScrollbarFrame.cpp index 1267918370..70c7c01ee5 100644 --- a/layout/xul/nsScrollbarFrame.cpp +++ b/layout/xul/nsScrollbarFrame.cpp @@ -175,7 +175,7 @@ nsScrollbarFrame::GetMargin(nsMargin& aMargin) nsPresContext* presContext = PresContext(); nsITheme* theme = presContext->GetTheme(); if (theme) { - nsIntSize size; + LayoutDeviceIntSize size; bool isOverridable; theme->GetMinimumWidgetSize(presContext, this, NS_THEME_SCROLLBAR, &size, &isOverridable); diff --git a/layout/xul/nsSliderFrame.cpp b/layout/xul/nsSliderFrame.cpp index 4093da5c80..f609f6afd3 100644 --- a/layout/xul/nsSliderFrame.cpp +++ b/layout/xul/nsSliderFrame.cpp @@ -690,7 +690,7 @@ nsSliderFrame::CurrentPositionChanged() // avoid putting the scroll thumb at subpixel positions which cause needless invalidations nscoord appUnitsPerPixel = PresContext()->AppUnitsPerDevPixel(); - nsRect snappedThumbRect = newThumbRect.ToNearestPixels(appUnitsPerPixel).ToAppUnits(appUnitsPerPixel); + nsRect snappedThumbRect = ToAppUnits(newThumbRect.ToNearestPixels(appUnitsPerPixel), appUnitsPerPixel); if (IsHorizontal()) { newThumbRect.x = snappedThumbRect.x; newThumbRect.width = snappedThumbRect.width; diff --git a/layout/xul/nsSliderFrame.h b/layout/xul/nsSliderFrame.h index 79fb3867a3..df180a03be 100644 --- a/layout/xul/nsSliderFrame.h +++ b/layout/xul/nsSliderFrame.h @@ -14,7 +14,6 @@ #include "nsITimer.h" #include "nsIDOMEventListener.h" -class nsString; class nsITimer; class nsSliderFrame; diff --git a/layout/xul/tree/nsTreeBodyFrame.cpp b/layout/xul/tree/nsTreeBodyFrame.cpp index f068b547b0..5fe8e38b3f 100644 --- a/layout/xul/tree/nsTreeBodyFrame.cpp +++ b/layout/xul/tree/nsTreeBodyFrame.cpp @@ -2087,7 +2087,7 @@ nsTreeBodyFrame::GetTwistyRect(int32_t aRowIndex, } if (useTheme) { - nsIntSize minTwistySizePx(0,0); + LayoutDeviceIntSize minTwistySizePx; bool canOverride = true; theme->GetMinimumWidgetSize(aPresContext, this, twistyDisplayData->mAppearance, &minTwistySizePx, &canOverride); diff --git a/parser/html/nsHtml5TreeBuilderCppSupplement.h b/parser/html/nsHtml5TreeBuilderCppSupplement.h index faecc546a6..14c0664380 100644 --- a/parser/html/nsHtml5TreeBuilderCppSupplement.h +++ b/parser/html/nsHtml5TreeBuilderCppSupplement.h @@ -10,8 +10,6 @@ #include "nsIFrame.h" #include "mozilla/Likely.h" -class nsPresContext; - nsHtml5TreeBuilder::nsHtml5TreeBuilder(nsHtml5OplessBuilder* aBuilder) : scriptingEnabled(false) , fragment(false) diff --git a/parser/html/nsHtml5TreeOpExecutor.h b/parser/html/nsHtml5TreeOpExecutor.h index ec922c1bea..aaaabc4d92 100644 --- a/parser/html/nsHtml5TreeOpExecutor.h +++ b/parser/html/nsHtml5TreeOpExecutor.h @@ -25,8 +25,6 @@ #include "mozilla/net/ReferrerPolicy.h" class nsHtml5Parser; -class nsHtml5TreeBuilder; -class nsHtml5Tokenizer; class nsHtml5StreamParser; class nsIContent; class nsIDocument; diff --git a/parser/html/nsHtml5TreeOperation.h b/parser/html/nsHtml5TreeOperation.h index c2a4f2b08b..f40209d8eb 100644 --- a/parser/html/nsHtml5TreeOperation.h +++ b/parser/html/nsHtml5TreeOperation.h @@ -12,7 +12,6 @@ class nsIContent; class nsHtml5TreeOpExecutor; -class nsHtml5StateSnapshot; class nsHtml5DocumentBuilder; enum eHtml5TreeOperation { diff --git a/parser/htmlparser/CNavDTD.h b/parser/htmlparser/CNavDTD.h index 8817b591b1..ae08c337c7 100644 --- a/parser/htmlparser/CNavDTD.h +++ b/parser/htmlparser/CNavDTD.h @@ -11,9 +11,6 @@ #include "nsISupports.h" #include "nsCOMPtr.h" -// This class is no longer useful. -class nsIHTMLContentSink; - #ifdef _MSC_VER #pragma warning( disable : 4275 ) #endif diff --git a/parser/htmlparser/nsIDTD.h b/parser/htmlparser/nsIDTD.h index 628c5378c0..cbae4d5071 100644 --- a/parser/htmlparser/nsIDTD.h +++ b/parser/htmlparser/nsIDTD.h @@ -46,8 +46,6 @@ enum nsDTDMode { }; -class nsIParser; -class nsIURI; class nsIContentSink; class CParserContext; diff --git a/parser/htmlparser/nsParser.h b/parser/htmlparser/nsParser.h index 858ee23d70..bd9fcb26bb 100644 --- a/parser/htmlparser/nsParser.h +++ b/parser/htmlparser/nsParser.h @@ -54,7 +54,6 @@ #include "nsWeakReference.h" class nsIDTD; -class nsScanner; class nsIRunnable; #ifdef _MSC_VER diff --git a/parser/htmlparser/nsScanner.h b/parser/htmlparser/nsScanner.h index f4e79aaed6..728383cf7c 100644 --- a/parser/htmlparser/nsScanner.h +++ b/parser/htmlparser/nsScanner.h @@ -25,8 +25,6 @@ #include "nsIUnicodeDecoder.h" #include "nsScannerString.h" -class nsParser; - class nsReadEndCondition { public: const char16_t *mChars; diff --git a/rdf/base/nsRDFXMLSerializer.h b/rdf/base/nsRDFXMLSerializer.h index f6ad9a4551..b31a088cd0 100644 --- a/rdf/base/nsRDFXMLSerializer.h +++ b/rdf/base/nsRDFXMLSerializer.h @@ -16,7 +16,6 @@ #include "nsDataHashtable.h" #include "rdfITripleVisitor.h" -class nsString; class nsIOutputStream; class nsIRDFContainerUtils; diff --git a/rdf/base/rdfutil.h b/rdf/base/rdfutil.h index 284f8e57ae..c11581a4a4 100644 --- a/rdf/base/rdfutil.h +++ b/rdf/base/rdfutil.h @@ -25,8 +25,6 @@ class nsACString; class nsCString; -class nsString; -class nsIURI; nsresult rdf_MakeRelativeRef(const nsCSubstring& aBaseURI, nsCString& aURI); diff --git a/storage/src/StorageBaseStatementInternal.h b/storage/src/StorageBaseStatementInternal.h index 77793c6d1a..20b289fc1b 100644 --- a/storage/src/StorageBaseStatementInternal.h +++ b/storage/src/StorageBaseStatementInternal.h @@ -13,7 +13,6 @@ struct sqlite3; struct sqlite3_stmt; -class mozIStorageError; class mozIStorageBindingParamsArray; class mozIStorageBindingParams; class mozIStorageStatementCallback; diff --git a/storage/src/mozStorageAsyncStatement.h b/storage/src/mozStorageAsyncStatement.h index 72534d0770..565d612703 100644 --- a/storage/src/mozStorageAsyncStatement.h +++ b/storage/src/mozStorageAsyncStatement.h @@ -19,7 +19,6 @@ #include "mozilla/Attributes.h" class nsIXPConnectJSObjectHolder; -struct sqlite3_stmt; namespace mozilla { namespace storage { diff --git a/storage/src/mozStorageAsyncStatementParams.h b/storage/src/mozStorageAsyncStatementParams.h index 71f53dab65..f753c6399f 100644 --- a/storage/src/mozStorageAsyncStatementParams.h +++ b/storage/src/mozStorageAsyncStatementParams.h @@ -11,8 +11,6 @@ #include "nsIXPCScriptable.h" #include "mozilla/Attributes.h" -class mozIStorageAsyncStatement; - namespace mozilla { namespace storage { diff --git a/storage/src/mozStorageConnection.h b/storage/src/mozStorageConnection.h index 598646f017..91abed60af 100644 --- a/storage/src/mozStorageConnection.h +++ b/storage/src/mozStorageConnection.h @@ -27,7 +27,6 @@ #include "sqlite3.h" -struct PRLock; class nsIFile; class nsIFileURL; class nsIEventTarget; diff --git a/storage/src/mozStoragePrivateHelpers.h b/storage/src/mozStoragePrivateHelpers.h index 92bd2c6c1b..718ad402c1 100644 --- a/storage/src/mozStoragePrivateHelpers.h +++ b/storage/src/mozStoragePrivateHelpers.h @@ -19,8 +19,6 @@ #include "Variant.h" class mozIStorageCompletionCallback; -class mozIStorageBaseStatement; -class mozIStorageBindingParams; class nsIRunnable; namespace mozilla { diff --git a/testing/gtest/gtest/include/gtest/gtest.h b/testing/gtest/gtest/include/gtest/gtest.h index cd01c7ba74..3332982284 100644 --- a/testing/gtest/gtest/include/gtest/gtest.h +++ b/testing/gtest/gtest/include/gtest/gtest.h @@ -151,7 +151,6 @@ class AssertHelper; class DefaultGlobalTestPartResultReporter; class ExecDeathTest; class NoExecDeathTest; -class FinalSuccessChecker; class GTestFlagSaver; class TestResultAccessor; class TestEventListenersAccessor; diff --git a/toolkit/devtools/LayoutHelpers.jsm b/toolkit/devtools/LayoutHelpers.jsm index cc4bae2fa9..7b82e844da 100644 --- a/toolkit/devtools/LayoutHelpers.jsm +++ b/toolkit/devtools/LayoutHelpers.jsm @@ -604,12 +604,13 @@ LayoutHelpers.isShadowAnonymous = function(node) { * Container windows are used as a weakmap key to store the corresponding * nsIDOMWindowUtils instance to avoid querying it every time. * - * @param {DOMNode} The node for which the zoom factor should be calculated + * @param {DOMNode|DOMWindow} The node for which the zoom factor should be + * calculated, or its owner window. * @return {Number} */ let windowUtils = new WeakMap; -LayoutHelpers.getCurrentZoom = function(node, map = z=>z) { - let win = node.ownerDocument.defaultView; +LayoutHelpers.getCurrentZoom = function(node) { + let win = node.self === node ? node : node.ownerDocument.defaultView; let utils = windowUtils.get(win); if (utils) { return utils.fullZoom; diff --git a/toolkit/devtools/animationinspector/animation-controller.js b/toolkit/devtools/animationinspector/animation-controller.js index 6a7835bce7..da66096cfa 100644 --- a/toolkit/devtools/animationinspector/animation-controller.js +++ b/toolkit/devtools/animationinspector/animation-controller.js @@ -99,8 +99,13 @@ let AnimationsController = { let target = gToolbox.target; this.animationsFront = new AnimationsFront(target.client, target.form); - // Not all server versions provide a way to pause all animations at once. + + // Expose actor capabilities. this.hasToggleAll = yield target.actorHasMethod("animations", "toggleAll"); + this.hasSetCurrentTime = yield target.actorHasMethod("animationplayer", + "setCurrentTime"); + this.hasMutationEvents = yield target.actorHasMethod("animations", + "stopAnimationPlayerUpdates"); this.onPanelVisibilityChange = this.onPanelVisibilityChange.bind(this); this.onNewNodeFront = this.onNewNodeFront.bind(this); @@ -223,6 +228,12 @@ let AnimationsController = { }, destroyAnimationPlayers: Task.async(function*() { + // Let the server know that we're not interested in receiving updates about + // players for the current node. We're either being destroyed or a new node + // has been selected. + if (this.hasMutationEvents) { + yield this.animationsFront.stopAnimationPlayerUpdates(); + } this.stopAllAutoRefresh(); for (let front of this.animationPlayers) { yield front.release(); diff --git a/toolkit/devtools/animationinspector/animation-panel.js b/toolkit/devtools/animationinspector/animation-panel.js index 06c78072fb..6a39202a4e 100644 --- a/toolkit/devtools/animationinspector/animation-panel.js +++ b/toolkit/devtools/animationinspector/animation-panel.js @@ -184,6 +184,9 @@ function PlayerWidget(player, containerEl) { this.onStateChanged = this.onStateChanged.bind(this); this.onPlayPauseBtnClick = this.onPlayPauseBtnClick.bind(this); + this.onRewindBtnClick = this.onRewindBtnClick.bind(this); + this.onFastForwardBtnClick = this.onFastForwardBtnClick.bind(this); + this.onCurrentTimeChanged = this.onCurrentTimeChanged.bind(this); this.metaDataComponent = new PlayerMetaDataHeader(); } @@ -210,18 +213,29 @@ PlayerWidget.prototype = { this.metaDataComponent.destroy(); this.el.remove(); - this.playPauseBtnEl = this.currentTimeEl = this.timeDisplayEl = null; + this.playPauseBtnEl = this.rewindBtnEl = this.fastForwardBtnEl = null; + this.currentTimeEl = this.timeDisplayEl = null; this.containerEl = this.el = this.player = null; }), startListeners: function() { this.player.on(this.player.AUTO_REFRESH_EVENT, this.onStateChanged); this.playPauseBtnEl.addEventListener("click", this.onPlayPauseBtnClick); + if (AnimationsController.hasSetCurrentTime) { + this.rewindBtnEl.addEventListener("click", this.onRewindBtnClick); + this.fastForwardBtnEl.addEventListener("click", this.onFastForwardBtnClick); + this.currentTimeEl.addEventListener("input", this.onCurrentTimeChanged); + } }, stopListeners: function() { this.player.off(this.player.AUTO_REFRESH_EVENT, this.onStateChanged); this.playPauseBtnEl.removeEventListener("click", this.onPlayPauseBtnClick); + if (AnimationsController.hasSetCurrentTime) { + this.rewindBtnEl.removeEventListener("click", this.onRewindBtnClick); + this.fastForwardBtnEl.removeEventListener("click", this.onFastForwardBtnClick); + this.currentTimeEl.removeEventListener("input", this.onCurrentTimeChanged); + } }, createMarkup: function() { @@ -252,8 +266,7 @@ PlayerWidget.prototype = { } }); - // Control buttons (when currentTime becomes settable, rewind and - // fast-forward can be added here). + // Control buttons. this.playPauseBtnEl = createNode({ parent: playbackControlsEl, nodeType: "button", @@ -262,6 +275,24 @@ PlayerWidget.prototype = { } }); + if (AnimationsController.hasSetCurrentTime) { + this.rewindBtnEl = createNode({ + parent: playbackControlsEl, + nodeType: "button", + attributes: { + "class": "rw devtools-button" + } + }); + + this.fastForwardBtnEl = createNode({ + parent: playbackControlsEl, + nodeType: "button", + attributes: { + "class": "ff devtools-button" + } + }); + } + // Sliders container. let slidersContainerEl = createNode({ parent: timelineEl, @@ -288,12 +319,14 @@ PlayerWidget.prototype = { "min": "0", "max": max, "step": "10", - "value": "0", - // The currentTime isn't settable yet, so disable the timeline slider - "disabled": "true" + "value": "0" } }); + if (!AnimationsController.hasSetCurrentTime) { + this.currentTimeEl.setAttribute("disabled", "true"); + } + // Time display this.timeDisplayEl = createNode({ parent: timelineEl, @@ -323,6 +356,28 @@ PlayerWidget.prototype = { } }, + onRewindBtnClick: function() { + this.setCurrentTime(0, true); + }, + + onFastForwardBtnClick: function() { + let state = this.player.state; + + let time = state.duration; + if (state.iterationCount) { + time = state.iterationCount * state.duration; + } + this.setCurrentTime(time, true); + }, + + /** + * Executed when the current-time range input is changed. + */ + onCurrentTimeChanged: function(e) { + let time = e.target.value; + this.setCurrentTime(parseFloat(time), true); + }, + /** * Whenever a player state update is received. */ @@ -347,6 +402,33 @@ PlayerWidget.prototype = { } }, + /** + * Set the current time of the animation. + * @param {Number} time. + * @param {Boolean} shouldPause Should the player be paused too. + * @return {Promise} Resolves when the current time has been set. + */ + setCurrentTime: Task.async(function*(time, shouldPause) { + if (!AnimationsController.hasSetCurrentTime) { + throw new Error("This server version doesn't support setting animations' currentTime"); + } + + if (shouldPause) { + this.stopTimelineAnimation(); + yield this.pause(); + } + + if (this.player.state.delay) { + time += this.player.state.delay; + } + + // Set the time locally first so it feels instant, even if the request to + // actually set the time is async. + this.displayTime(time); + + yield this.player.setCurrentTime(time); + }), + /** * Pause the animation player via this widget. * @return {Promise} Resolves when the player is paused, the button is @@ -467,7 +549,7 @@ PlayerMetaDataHeader.prototype = { } }); - // Animation name (value hidden by default since transitions don't have names). + // Animation name. this.nameLabel = createNode({ parent: this.el, nodeType: "span" @@ -551,12 +633,12 @@ PlayerMetaDataHeader.prototype = { // Update the name if needed. if (state.name !== this.state.name) { if (state.name) { - // Css animations have names. + // Animations (and transitions since bug 1122414) have names. this.nameLabel.textContent = L10N.getStr("player.animationNameLabel"); this.nameValue.style.display = "inline"; this.nameValue.textContent = state.name; } else { - // Css transitions don't. + // With older actors, Css transitions don't have names. this.nameLabel.textContent = L10N.getStr("player.transitionNameLabel"); this.nameValue.style.display = "none"; } diff --git a/toolkit/devtools/animationinspector/test/browser.ini b/toolkit/devtools/animationinspector/test/browser.ini index 85195cd2e0..65fe5a3425 100644 --- a/toolkit/devtools/animationinspector/test/browser.ini +++ b/toolkit/devtools/animationinspector/test/browser.ini @@ -14,12 +14,15 @@ support-files = [browser_animation_playerWidgets_destroy.js] [browser_animation_playerWidgets_disables_on_finished.js] [browser_animation_playerWidgets_dont_show_time_after_duration.js] +[browser_animation_playerWidgets_have_control_buttons.js] [browser_animation_playerWidgets_meta_data.js] [browser_animation_playerWidgets_state_after_pause.js] [browser_animation_refresh_when_active.js] [browser_animation_same_nb_of_playerWidgets_and_playerFronts.js] +[browser_animation_setting_currentTime_works_and_pauses.js] [browser_animation_shows_player_on_valid_node.js] [browser_animation_timeline_animates.js] +[browser_animation_timeline_is_enabled.js] [browser_animation_timeline_waits_for_delay.js] [browser_animation_toggle_button_resets_on_navigate.js] [browser_animation_toggle_button_toggles_animations.js] @@ -27,3 +30,4 @@ support-files = [browser_animation_toolbar_exists.js] [browser_animation_ui_updates_when_animation_changes.js] [browser_animation_ui_updates_when_animation_data_changes.js] +[browser_animation_ui_updates_when_animation_time_changes.js] diff --git a/toolkit/devtools/animationinspector/test/browser_animation_playerWidgets_disables_on_finished.js b/toolkit/devtools/animationinspector/test/browser_animation_playerWidgets_disables_on_finished.js index e10066c34a..7b3ac0fbd4 100644 --- a/toolkit/devtools/animationinspector/test/browser_animation_playerWidgets_disables_on_finished.js +++ b/toolkit/devtools/animationinspector/test/browser_animation_playerWidgets_disables_on_finished.js @@ -11,7 +11,11 @@ add_task(function*() { let {inspector, panel, controller} = yield openAnimationInspector(); info("Apply 2 finite animations to the test node"); - getNode(".still").classList.add("multi-finite"); + yield executeInContent("devtools:test:setAttribute", { + selector: ".still", + attributeName: "class", + attributeValue: "ball still multi-finite" + }); info("Select the test node"); yield selectNode(".still", inspector); diff --git a/toolkit/devtools/animationinspector/test/browser_animation_playerWidgets_dont_show_time_after_duration.js b/toolkit/devtools/animationinspector/test/browser_animation_playerWidgets_dont_show_time_after_duration.js index 9808d3d961..94e2c1f9bc 100644 --- a/toolkit/devtools/animationinspector/test/browser_animation_playerWidgets_dont_show_time_after_duration.js +++ b/toolkit/devtools/animationinspector/test/browser_animation_playerWidgets_dont_show_time_after_duration.js @@ -15,7 +15,11 @@ add_task(function*() { let {inspector, panel} = yield openAnimationInspector(); info("Start an animation on the test node"); - getNode(".still").classList.add("short"); + yield executeInContent("devtools:test:setAttribute", { + selector: ".still", + attributeName: "class", + attributeValue: "ball still short" + }); info("Select the node"); yield selectNode(".still", inspector); diff --git a/toolkit/devtools/animationinspector/test/browser_animation_playerWidgets_have_control_buttons.js b/toolkit/devtools/animationinspector/test/browser_animation_playerWidgets_have_control_buttons.js new file mode 100644 index 0000000000..61f65dbb6a --- /dev/null +++ b/toolkit/devtools/animationinspector/test/browser_animation_playerWidgets_have_control_buttons.js @@ -0,0 +1,49 @@ +/* vim: set ts=2 et sw=2 tw=80: */ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +// Test that playerWidgets have control buttons: play/pause, rewind, fast-forward. + +add_task(function*() { + yield addTab(TEST_URL_ROOT + "doc_simple_animation.html"); + let {controller, inspector, panel} = yield openAnimationInspector(); + + info("Select the simple animated node"); + yield selectNode(".animated", inspector); + + let widget = panel.playerWidgets[0]; + let container = widget.el.querySelector(".playback-controls"); + + ok(container, "The control buttons container exists"); + is(container.querySelectorAll("button").length, 3, + "The container contains 3 buttons"); + ok(container.children[0].classList.contains("toggle"), + "The first button is the play/pause button"); + ok(container.children[1].classList.contains("rw"), + "The second button is the rewind button"); + ok(container.children[2].classList.contains("ff"), + "The third button is the fast-forward button"); + + info("Faking an older server version by setting " + + "AnimationsController.hasSetCurrentTime to false"); + + yield selectNode("body", inspector); + controller.hasSetCurrentTime = false; + + info("Selecting the animated node again"); + yield selectNode(".animated", inspector); + + widget = panel.playerWidgets[0]; + container = widget.el.querySelector(".playback-controls"); + + ok(container, "The control buttons container still exists"); + is(container.querySelectorAll("button").length, 1, + "The container only contains 1 button"); + ok(container.children[0].classList.contains("toggle"), + "The first button is the play/pause button"); + + yield selectNode("body", inspector); + controller.hasSetCurrentTime = true; +}); diff --git a/toolkit/devtools/animationinspector/test/browser_animation_setting_currentTime_works_and_pauses.js b/toolkit/devtools/animationinspector/test/browser_animation_setting_currentTime_works_and_pauses.js new file mode 100644 index 0000000000..cfecfdde4c --- /dev/null +++ b/toolkit/devtools/animationinspector/test/browser_animation_setting_currentTime_works_and_pauses.js @@ -0,0 +1,63 @@ +/* vim: set ts=2 et sw=2 tw=80: */ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +// Test that setting an animation's current time by clicking in the input[range] +// or rewind or fast-forward buttons pauses the animation and sets it to the +// right time. + +add_task(function*() { + yield addTab(TEST_URL_ROOT + "doc_simple_animation.html"); + let {toolbox, inspector, panel} = yield openAnimationInspector(); + + info("Select an animated node"); + yield selectNode(".animated", inspector); + + info("Get the player widget for this node"); + let widget = panel.playerWidgets[0]; + let input = widget.currentTimeEl; + let rwBtn = widget.rewindBtnEl; + let ffBtn = widget.fastForwardBtnEl; + let win = input.ownerDocument.defaultView; + + info("Click at the center of the input") + EventUtils.synthesizeMouseAtCenter(input, {type: "mousedown"}, win); + + yield checkPausedAt(widget, 1000); + + info("Resume the player and wait for an auto-refresh event"); + yield widget.player.play(); + yield onceNextPlayerRefresh(widget.player); + + info("Click on the rewind button"); + EventUtils.sendMouseEvent({type: "click"}, rwBtn, win); + + yield checkPausedAt(widget, 0); + + info("Click on the fast-forward button"); + EventUtils.sendMouseEvent({type: "click"}, ffBtn, win); + + yield checkPausedAt(widget, 2000); +}); + +function* checkPausedAt(widget, time) { + info("Wait for the next auto-update"); + + let onPaused = promise.defer(); + widget.player.on(widget.player.AUTO_REFRESH_EVENT, function onRefresh() { + info("Still waiting for the player to pause"); + if (widget.player.state.playState === "paused") { + ok(true, "The player's playState is paused"); + widget.player.off(widget.player.AUTO_REFRESH_EVENT, onRefresh); + onPaused.resolve(); + } + }); + yield onPaused.promise; + + ok(widget.el.classList.contains("paused"), "The widget is in paused mode"); + is(widget.player.state.currentTime, time, + "The player front's currentTime was set to " + time); + is(widget.currentTimeEl.value, time, "The input's value was set to " + time); +} diff --git a/toolkit/devtools/animationinspector/test/browser_animation_timeline_animates.js b/toolkit/devtools/animationinspector/test/browser_animation_timeline_animates.js index 5716209b27..dcccd25506 100644 --- a/toolkit/devtools/animationinspector/test/browser_animation_timeline_animates.js +++ b/toolkit/devtools/animationinspector/test/browser_animation_timeline_animates.js @@ -18,7 +18,7 @@ add_task(function*() { let widget = panel.playerWidgets[0]; let timeline = widget.currentTimeEl; - yield widget.player.once(widget.player.AUTO_REFRESH_EVENT); + yield onceNextPlayerRefresh(widget.player); ok(widget.rafID, "The widget is updating the timeline with a rAF loop"); info("Pause the animation"); diff --git a/toolkit/devtools/animationinspector/test/browser_animation_timeline_is_enabled.js b/toolkit/devtools/animationinspector/test/browser_animation_timeline_is_enabled.js new file mode 100644 index 0000000000..2865df247b --- /dev/null +++ b/toolkit/devtools/animationinspector/test/browser_animation_timeline_is_enabled.js @@ -0,0 +1,41 @@ +/* vim: set ts=2 et sw=2 tw=80: */ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +// Test that the currentTime timeline widget is enabled and that the associated +// player front supports setting the current time. + +add_task(function*() { + yield addTab(TEST_URL_ROOT + "doc_simple_animation.html"); + let {controller, inspector, panel} = yield openAnimationInspector(); + + info("Select the animated node"); + yield selectNode(".animated", inspector); + + info("Get the player widget's timeline element"); + let widget = panel.playerWidgets[0]; + let timeline = widget.currentTimeEl; + + ok(!timeline.hasAttribute("disabled"), "The timeline input[range] is enabled"); + ok(widget.setCurrentTime, "The widget has the setCurrentTime method"); + ok(widget.player.setCurrentTime, "The associated player front has the setCurrentTime method"); + + info("Faking an older server version by setting " + + "AnimationsController.hasSetCurrentTime to false"); + + yield selectNode("body", inspector); + controller.hasSetCurrentTime = false; + + yield selectNode(".animated", inspector); + + info("Get the player widget's timeline element"); + widget = panel.playerWidgets[0]; + timeline = widget.currentTimeEl; + + ok(timeline.hasAttribute("disabled"), "The timeline input[range] is disabled"); + + yield selectNode("body", inspector); + controller.hasSetCurrentTime = true; +}); diff --git a/toolkit/devtools/animationinspector/test/browser_animation_ui_updates_when_animation_changes.js b/toolkit/devtools/animationinspector/test/browser_animation_ui_updates_when_animation_changes.js index cd54316bdd..b5d213f4f5 100644 --- a/toolkit/devtools/animationinspector/test/browser_animation_ui_updates_when_animation_changes.js +++ b/toolkit/devtools/animationinspector/test/browser_animation_ui_updates_when_animation_changes.js @@ -23,10 +23,9 @@ add_task(function*() { info("Pause the animation via the content DOM"); yield executeInContent("Test:ToggleAnimationPlayer", { + selector: ".animated", animationIndex: 0, pause: true - }, { - node: getNode(".animated") }); yield onPaused; @@ -40,10 +39,9 @@ add_task(function*() { info("Play the animation via the content DOM"); yield executeInContent("Test:ToggleAnimationPlayer", { + selector: ".animated", animationIndex: 0, pause: false - }, { - node: getNode(".animated") }); yield onRunning; diff --git a/toolkit/devtools/animationinspector/test/browser_animation_ui_updates_when_animation_data_changes.js b/toolkit/devtools/animationinspector/test/browser_animation_ui_updates_when_animation_data_changes.js index ea7a90c875..b6af2e4d73 100644 --- a/toolkit/devtools/animationinspector/test/browser_animation_ui_updates_when_animation_data_changes.js +++ b/toolkit/devtools/animationinspector/test/browser_animation_ui_updates_when_animation_data_changes.js @@ -33,13 +33,12 @@ add_task(function*() { function* setStyle(widget, name, value) { info("Change the animation style via the content DOM. Setting " + name + " to " + value); - yield executeInContent("Test:SetNodeStyle", { + yield executeInContent("devtools:test:setStyle", { + selector: ".animated", propertyName: name, propertyValue: value - }, { - node: getNode(".animated") }); info("Wait for the next state update"); - yield widget.player.once(widget.player.AUTO_REFRESH_EVENT); + yield onceNextPlayerRefresh(widget.player); } diff --git a/toolkit/devtools/animationinspector/test/browser_animation_ui_updates_when_animation_time_changes.js b/toolkit/devtools/animationinspector/test/browser_animation_ui_updates_when_animation_time_changes.js new file mode 100644 index 0000000000..bd5f39e951 --- /dev/null +++ b/toolkit/devtools/animationinspector/test/browser_animation_ui_updates_when_animation_time_changes.js @@ -0,0 +1,52 @@ +/* vim: set ts=2 et sw=2 tw=80: */ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +// Test that setting an animation's currentTime via the WebAnimations API (from +// content), actually changes the time in the corresponding widget too. + +let L10N = new ViewHelpers.L10N(); + +add_task(function*() { + yield addTab(TEST_URL_ROOT + "doc_simple_animation.html"); + let {inspector, panel} = yield openAnimationInspector(); + + info("Selecting the test node"); + yield selectNode(".animated", inspector); + + info("Get the player widget"); + let widget = panel.playerWidgets[0]; + + info("Pause the player so we can compare times easily"); + yield executeInContent("Test:ToggleAnimationPlayer", { + selector: ".animated", + animationIndex: 0, + pause: true + }); + yield onceNextPlayerRefresh(widget.player); + + ok(widget.el.classList.contains("paused"), "The widget is in pause mode"); + + info("Change the animation's currentTime via the content DOM"); + yield executeInContent("Test:SetAnimationPlayerCurrentTime", { + selector: ".animated", + animationIndex: 0, + currentTime: 0 + }); + yield onceNextPlayerRefresh(widget.player); + + is(widget.currentTimeEl.value, 0, "The currentTime slider's value was changed"); + + info("Change the animation's currentTime again via the content DOM"); + yield executeInContent("Test:SetAnimationPlayerCurrentTime", { + selector: ".animated", + animationIndex: 0, + currentTime: 300 + }); + yield onceNextPlayerRefresh(widget.player); + + is(widget.currentTimeEl.value, 300, + "The currentTime slider's value was changed again"); +}); diff --git a/toolkit/devtools/animationinspector/test/doc_frame_script.js b/toolkit/devtools/animationinspector/test/doc_frame_script.js index 51fc720a7d..06101bdf51 100644 --- a/toolkit/devtools/animationinspector/test/doc_frame_script.js +++ b/toolkit/devtools/animationinspector/test/doc_frame_script.js @@ -9,13 +9,17 @@ /** * Toggle (play or pause) one of the animation players of a given node. * @param {Object} data + * - {String} selector The CSS selector to get the node (can be a "super" + * selector). * - {Number} animationIndex The index of the node's animationPlayers to play or pause - * @param {Object} objects - * - {DOMNode} node The node to use + * - {Boolean} pause True to pause the animation, false to play. */ addMessageListener("Test:ToggleAnimationPlayer", function(msg) { - let {animationIndex, pause} = msg.data; - let {node} = msg.objects; + let {selector, animationIndex, pause} = msg.data; + let node = superQuerySelector(selector); + if (!node) { + return; + } let player = node.getAnimationPlayers()[animationIndex]; if (pause) { @@ -28,36 +32,68 @@ addMessageListener("Test:ToggleAnimationPlayer", function(msg) { }); /** - * Set a given style property value on a node. This is useful to dynamically - * change an animation's duration or delay for instance. + * Change the currentTime of one of the animation players of a given node. * @param {Object} data - * - {String} propertyName The name of the property to set. - * - {String} propertyValue The value for the property. - * @param {Object} objects - * - {DOMNode} node The node to use + * - {String} selector The CSS selector to get the node (can be a "super" + * selector). + * - {Number} animationIndex The index of the node's animationPlayers to change. + * - {Number} currentTime The current time to set. */ -addMessageListener("Test:SetNodeStyle", function(msg) { - let {propertyName, propertyValue} = msg.data; - let {node} = msg.objects; +addMessageListener("Test:SetAnimationPlayerCurrentTime", function(msg) { + let {selector, animationIndex, currentTime} = msg.data; + let node = superQuerySelector(selector); + if (!node) { + return; + } - node.style[propertyName] = propertyValue; + let player = node.getAnimationPlayers()[animationIndex]; + player.currentTime = currentTime; - sendAsyncMessage("Test:SetNodeStyle"); + sendAsyncMessage("Test:SetAnimationPlayerCurrentTime"); }); /** * Get the current playState of an animation player on a given node. * @param {Object} data + * - {String} selector The CSS selector to get the node (can be a "super" + * selector). * - {Number} animationIndex The index of the node's animationPlayers to check - * @param {Object} objects - * - {DOMNode} node The node to check */ addMessageListener("Test:GetAnimationPlayerState", function(msg) { - let {animationIndex} = msg.data; - let {node} = msg.objects; + let {selector, animationIndex} = msg.data; + let node = superQuerySelector(selector); + if (!node) { + return; + } let player = node.getAnimationPlayers()[animationIndex]; player.ready.then(() => { sendAsyncMessage("Test:GetAnimationPlayerState", player.playState); }); }); + +/** + * Like document.querySelector but can go into iframes too. + * ".container iframe || .sub-container div" will first try to find the node + * matched by ".container iframe" in the root document, then try to get the + * content document inside it, and then try to match ".sub-container div" inside + * this document. + * Any selector coming before the || separator *MUST* match a frame node. + * @param {String} superSelector. + * @return {DOMNode} The node, or null if not found. + */ +function superQuerySelector(superSelector, root=content.document) { + let frameIndex = superSelector.indexOf("||"); + if (frameIndex === -1) { + return root.querySelector(superSelector); + } else { + let rootSelector = superSelector.substring(0, frameIndex).trim(); + let childSelector = superSelector.substring(frameIndex+2).trim(); + root = root.querySelector(rootSelector); + if (!root || !root.contentWindow) { + return null; + } + + return superQuerySelector(childSelector, root.contentWindow.document); + } +} diff --git a/toolkit/devtools/animationinspector/test/head.js b/toolkit/devtools/animationinspector/test/head.js index 9dba9be78a..5e894b4a8b 100644 --- a/toolkit/devtools/animationinspector/test/head.js +++ b/toolkit/devtools/animationinspector/test/head.js @@ -84,20 +84,6 @@ function reloadTab() { return executeInContent("devtools:test:reload", {}, {}, false); } -/** - * Simple DOM node accesor function that takes either a node or a string css - * selector as argument and returns the corresponding node - * @param {String|DOMNode} nodeOrSelector - * @return {DOMNode|CPOW} Note that in e10s mode a CPOW object is returned which - * doesn't implement *all* of the DOMNode's properties - */ -function getNode(nodeOrSelector) { - info("Getting the node for '" + nodeOrSelector + "'"); - return typeof nodeOrSelector === "string" ? - content.document.querySelector(nodeOrSelector) : - nodeOrSelector; -} - /** * Get the NodeFront for a given css selector, via the protocol * @param {String} selector @@ -273,6 +259,12 @@ function executeInContent(name, data={}, objects={}, expectResponse=true) { } } +function onceNextPlayerRefresh(player) { + let onRefresh = promise.defer(); + player.once(player.AUTO_REFRESH_EVENT, onRefresh.resolve); + return onRefresh.promise; +} + /** * Simulate a click on the playPause button of a playerWidget. */ @@ -361,8 +353,7 @@ let checkPausedAt = Task.async(function*(widget, time) { */ let getAnimationPlayerState = Task.async(function*(selector, animationIndex=0) { let playState = yield executeInContent("Test:GetAnimationPlayerState", - {animationIndex}, - {node: getNode(selector)}); + {selector, animationIndex}); return playState; }); diff --git a/toolkit/devtools/inspector/test/browser.ini b/toolkit/devtools/inspector/test/browser.ini index 85fc9db229..2d8eba3a70 100644 --- a/toolkit/devtools/inspector/test/browser.ini +++ b/toolkit/devtools/inspector/test/browser.ini @@ -8,6 +8,8 @@ support-files = doc_inspector_gcli-inspect-command.html doc_inspector_highlight_after_transition.html doc_inspector_highlighter-comments.html + doc_inspector_highlighter-geometry_01.html + doc_inspector_highlighter-geometry_02.html doc_inspector_highlighter_csstransform.html doc_inspector_highlighter.html doc_inspector_highlighter_inline.html @@ -41,6 +43,11 @@ skip-if = e10s # GCLI isn't e10s compatible. See bug 1128988. [browser_inspector_highlighter-comments.js] [browser_inspector_highlighter-csstransform_01.js] [browser_inspector_highlighter-csstransform_02.js] +[browser_inspector_highlighter-geometry_01.js] +[browser_inspector_highlighter-geometry_02.js] +[browser_inspector_highlighter-geometry_03.js] +[browser_inspector_highlighter-geometry_04.js] +[browser_inspector_highlighter-geometry_05.js] [browser_inspector_highlighter-hover_01.js] [browser_inspector_highlighter-hover_02.js] [browser_inspector_highlighter-hover_03.js] diff --git a/toolkit/devtools/inspector/test/browser_inspector_highlighter-geometry_01.js b/toolkit/devtools/inspector/test/browser_inspector_highlighter-geometry_01.js new file mode 100644 index 0000000000..3125d0cc6f --- /dev/null +++ b/toolkit/devtools/inspector/test/browser_inspector_highlighter-geometry_01.js @@ -0,0 +1,104 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +"use strict"; + +// Test the creation of the geometry highlighter elements. + +const TEST_URL = "data:text/html;charset=utf-8," + + "" + + "
" + + "
"; +const ID = "geometry-editor-"; +const SIDES = ["left", "right", "top", "bottom"]; +const SIZES = ["width", "height"]; + +add_task(function*() { + let {inspector, toolbox} = yield openInspectorForURL(TEST_URL); + let front = inspector.inspector; + + let highlighter = yield front.getHighlighterByType("GeometryEditorHighlighter"); + + yield hasArrowsAndLabels(highlighter, inspector); + yield isHiddenForNonPositionedNonSizedElement(highlighter, inspector); + yield sideArrowsAreDisplayedForPositionedNode(highlighter, inspector); + yield sizeLabelIsDisplayedForSizedNode(highlighter, inspector); + + yield highlighter.finalize(); +}); + +function* hasArrowsAndLabels(highlighterFront, inspector) { + info("Checking that the highlighter has the expected arrows and labels"); + + for (let name of [...SIDES]) { + let value = yield getHighlighterNodeAttribute(highlighterFront, + ID + "arrow-" + name, "class"); + is(value, ID + "arrow " + name, "The " + name + " arrow exists"); + + value = yield getHighlighterNodeAttribute(highlighterFront, + ID + "label-text-" + name, "class"); + is(value, ID + "label-text", "The " + name + " label exists"); + } + + let value = yield getHighlighterNodeAttribute(highlighterFront, + ID + "label-text-size", "class"); + is(value, ID + "label-text", "The size label exists"); +} + +function* isHiddenForNonPositionedNonSizedElement(highlighterFront, inspector) { + info("Asking to show the highlighter on an inline, non positioned element"); + + let node = yield getNodeFront("#inline", inspector); + yield highlighterFront.show(node); + + for (let name of [...SIDES]) { + let hidden = yield getHighlighterNodeAttribute(highlighterFront, + ID + "arrow-" + name, "hidden"); + is(hidden, "true", "The " + name + " arrow is hidden"); + } + + let hidden = yield getHighlighterNodeAttribute(highlighterFront, + ID + "label-size", "hidden"); + is(hidden, "true", "The size label is hidden"); +} + +function* sideArrowsAreDisplayedForPositionedNode(highlighterFront, inspector) { + info("Asking to show the highlighter on the positioned node"); + + let node = yield getNodeFront("#positioned", inspector); + yield highlighterFront.show(node); + + for (let name of SIDES) { + let hidden = yield getHighlighterNodeAttribute(highlighterFront, + ID + "arrow-" + name, "hidden"); + ok(!hidden, "The " + name + " arrow is visible for the positioned node"); + } + + let hidden = yield getHighlighterNodeAttribute(highlighterFront, + ID + "label-size", "hidden"); + is(hidden, "true", "The size label is hidden"); + + info("Hiding the highlighter"); + yield highlighterFront.hide(); +} + +function* sizeLabelIsDisplayedForSizedNode(highlighterFront, inspector) { + info("Asking to show the highlighter on the sized node"); + + let node = yield getNodeFront("#sized", inspector); + yield highlighterFront.show(node); + + let hidden = yield getHighlighterNodeAttribute(highlighterFront, + ID + "label-size", "hidden"); + ok(!hidden, "The size label is visible"); + + for (let name of SIDES) { + let hidden = yield getHighlighterNodeAttribute(highlighterFront, + ID + "arrow-" + name, "hidden"); + is(hidden, "true", "The " + name + " arrow is hidden for the sized node"); + } + + info("Hiding the highlighter"); + yield highlighterFront.hide(); +} diff --git a/toolkit/devtools/inspector/test/browser_inspector_highlighter-geometry_02.js b/toolkit/devtools/inspector/test/browser_inspector_highlighter-geometry_02.js new file mode 100644 index 0000000000..4247751fa1 --- /dev/null +++ b/toolkit/devtools/inspector/test/browser_inspector_highlighter-geometry_02.js @@ -0,0 +1,142 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +"use strict"; + +// Test that the geometry highlighter labels are correct. + +const TEST_URL = "data:text/html;charset=utf-8," + + "
" + + "
test element
" + + "
" + + "
relative
" + + "
" + + "
wow
"; +const ID = "geometry-editor-"; + +const POSITIONED_ELEMENT_TESTS = [{ + selector: "#positioned", + expectedLabels: [ + {side: "left", visible: true, label: "5rem"}, + {side: "top", visible: true, label: "30px"}, + {side: "right", visible: true, label: "300px"}, + {side: "bottom", visible: true, label: "10em"} + ] +}, { + selector: "#positioned2", + expectedLabels: [ + {side: "left", visible: false}, + {side: "top", visible: true, label: "5vmin"}, + {side: "right", visible: true, label: "10%"}, + {side: "bottom", visible: false} + ] +}, { + selector: "#sized", + expectedLabels: [ + {side: "left", visible: false}, + {side: "top", visible: false}, + {side: "right", visible: false}, + {side: "bottom", visible: false} + ] +}, { + selector: "#relative", + expectedLabels: [ + {side: "left", visible: true, label: "20px"}, + {side: "top", visible: true, label: "10px"}, + {side: "right", visible: false}, + {side: "bottom", visible: false} + ] +}, { + selector: "#relative2", + expectedLabels: [ + {side: "left", visible: false}, + {side: "top", visible: true, label: "0px"}, + {side: "right", visible: false}, + {side: "bottom", visible: false} + ] +}]; + +const SIZED_ELEMENT_TESTS = [{ + selector: "#positioned", + visible: false +}, { + selector: "#sized", + visible: true, + expected: "\u2194 5em \u2195 50%" +}, { + selector: "#relative", + visible: true, + expected: "\u2194 100px \u2195 100px" +}, { + selector: "#relative2", + visible: true, + expected: "\u2195 3em" +}, { + selector: "#sized2", + visible: true, + expected: "\u2194 40px" +}]; + +add_task(function*() { + let {inspector, toolbox} = yield openInspectorForURL(TEST_URL); + let front = inspector.inspector; + + let highlighter = yield front.getHighlighterByType("GeometryEditorHighlighter"); + + yield positionLabelsAreCorrect(highlighter, inspector); + yield sizeLabelIsCorrect(highlighter, inspector); + + yield highlighter.finalize(); +}); + +function* positionLabelsAreCorrect(highlighterFront, inspector) { + info("Highlight nodes and check position labels"); + + for (let {selector, expectedLabels} of POSITIONED_ELEMENT_TESTS) { + info("Testing node " + selector); + let node = yield getNodeFront(selector, inspector); + yield highlighterFront.show(node); + + for (let {side, visible, label} of expectedLabels) { + let id = ID + "label-" + side; + + let hidden = yield getHighlighterNodeAttribute(highlighterFront, id, "hidden"); + if (visible) { + ok(!hidden, "The " + side + " label is visible"); + + let value = yield getHighlighterNodeTextContent(highlighterFront, id); + is(value, label, "The " + side + " label textcontent is correct"); + } else { + is(hidden, "true", "The " + side + " label is hidden"); + } + } + + info("Hiding the highlighter"); + yield highlighterFront.hide(); + } +} + +function* sizeLabelIsCorrect(highlighterFront, inspector) { + info("Highlight nodes and check size labels"); + + let id = ID + "label-size"; + for (let {selector, visible, expected} of SIZED_ELEMENT_TESTS) { + info("Testing node " + selector); + let node = yield getNodeFront(selector, inspector); + yield highlighterFront.show(node); + + let hidden = yield getHighlighterNodeAttribute(highlighterFront, id, "hidden"); + if (!visible) { + is(hidden, "true", "The size label is hidden"); + } else { + ok(!hidden, "The size label is visible"); + + let label = yield getHighlighterNodeTextContent(highlighterFront, id); + is(label, expected, "The size label textcontent is correct"); + } + + info("Hiding the highlighter"); + yield highlighterFront.hide(); + } +} diff --git a/toolkit/devtools/inspector/test/browser_inspector_highlighter-geometry_03.js b/toolkit/devtools/inspector/test/browser_inspector_highlighter-geometry_03.js new file mode 100644 index 0000000000..c86984f97f --- /dev/null +++ b/toolkit/devtools/inspector/test/browser_inspector_highlighter-geometry_03.js @@ -0,0 +1,63 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +"use strict"; + +// Test that the right arrows/labels are shown even when the css properties are +// in several different css rules. + +const TEST_URL = TEST_URL_ROOT + "doc_inspector_highlighter-geometry_01.html"; +const ID = "geometry-editor-"; +const PROPS = ["left", "right", "top", "bottom"]; + +add_task(function*() { + let {inspector, toolbox} = yield openInspectorForURL(TEST_URL); + let front = inspector.inspector; + + let highlighter = yield front.getHighlighterByType("GeometryEditorHighlighter"); + + yield checkArrowsLabels("#node1", ["size"], + highlighter, inspector); + + yield checkArrowsLabels("#node2", ["top", "left", "bottom", "right"], + highlighter, inspector); + + yield checkArrowsLabels("#node3", ["top", "left", "size"], + highlighter, inspector); + + yield highlighter.finalize(); +}); + +function* checkArrowsLabels(selector, expectedProperties, highlighterFront, inspector) { + info("Getting node " + selector + " from the page"); + let node = yield getNodeFront(selector, inspector); + + info("Highlighting the node"); + yield highlighterFront.show(node); + + for (let name of expectedProperties) { + let hidden; + if (name === "size") { + hidden = yield getHighlighterNodeAttribute(highlighterFront, + ID + "label-size", "hidden"); + } else { + hidden = yield getHighlighterNodeAttribute(highlighterFront, + ID + "arrow-" + name, "hidden"); + } + ok(!hidden, "The " + name + " arrow/label is visible for node " + selector); + } + + // Testing that the other arrows are hidden + for (let name of PROPS) { + if (expectedProperties.indexOf(name) !== -1) { + continue; + } + let hidden = yield getHighlighterNodeAttribute(highlighterFront, + ID + "arrow-" + name, "hidden"); + is(hidden, "true", "The " + name + " arrow is hidden for node " + selector); + } + + info("Hiding the highlighter"); + yield highlighterFront.hide(); +} diff --git a/toolkit/devtools/inspector/test/browser_inspector_highlighter-geometry_04.js b/toolkit/devtools/inspector/test/browser_inspector_highlighter-geometry_04.js new file mode 100644 index 0000000000..9182aee143 --- /dev/null +++ b/toolkit/devtools/inspector/test/browser_inspector_highlighter-geometry_04.js @@ -0,0 +1,56 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +"use strict"; + +// Test that the arrows are positioned correctly and have the right size. + +const TEST_URL = TEST_URL_ROOT + "doc_inspector_highlighter-geometry_01.html"; +const ID = "geometry-editor-"; + +add_task(function*() { + let {inspector, toolbox} = yield openInspectorForURL(TEST_URL); + let front = inspector.inspector; + + let highlighter = yield front.getHighlighterByType("GeometryEditorHighlighter"); + + yield checkArrows(highlighter, inspector, ".absolute-all-4", { + "top": {x1: 506, y1: 51, x2: 506, y2: 61}, + "bottom": {x1: 506, y1: 451, x2: 506, y2: 251}, + "left": {x1: 401, y1: 156, x2: 411, y2: 156}, + "right": {x1: 901, y1: 156, x2: 601, y2: 156} + }); + + yield checkArrows(highlighter, inspector, ".relative", { + "top": {x1: 901, y1: 51, x2: 901, y2: 91}, + "left": {x1: 401, y1: 97, x2: 651, y2: 97} + }); + + yield checkArrows(highlighter, inspector, ".fixed", { + "top": {x1: 25, y1: 0, x2: 25, y2: 400}, + "left": {x1: 0, y1: 425, x2: 0, y2: 425} + }); + + info("Hiding the highlighter"); + yield highlighter.hide(); + yield highlighter.finalize(); +}); + +function* checkArrows(highlighter, inspector, selector, arrows) { + info("Highlighting the test node " + selector); + let node = yield getNodeFront(selector, inspector); + yield highlighter.show(node); + + for (let side in arrows) { + yield checkArrow(highlighter, side, arrows[side]); + } +} + +function* checkArrow(highlighter, name, expectedCoordinates) { + for (let coordinate in expectedCoordinates) { + let value = yield getHighlighterNodeAttribute(highlighter, ID + "arrow-" + name, coordinate); + is(Math.floor(value), expectedCoordinates[coordinate], + coordinate + " coordinate for arrow " + name + " is correct"); + } +} diff --git a/toolkit/devtools/inspector/test/browser_inspector_highlighter-geometry_05.js b/toolkit/devtools/inspector/test/browser_inspector_highlighter-geometry_05.js new file mode 100644 index 0000000000..a7df2de95c --- /dev/null +++ b/toolkit/devtools/inspector/test/browser_inspector_highlighter-geometry_05.js @@ -0,0 +1,138 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +"use strict"; + +// Test that the arrows and offsetparent and currentnode elements of the +// geometry highlighter only appear when needed. + +const TEST_URL = TEST_URL_ROOT + "doc_inspector_highlighter-geometry_02.html"; +const ID = "geometry-editor-"; + +const TEST_DATA = [{ + selector: "body", + isOffsetParentVisible: false, + isCurrentNodeVisible: false, + hasVisibleArrows: false, + isSizeVisible: false +}, { + selector: "h1", + isOffsetParentVisible: false, + isCurrentNodeVisible: false, + hasVisibleArrows: false, + isSizeVisible: false +}, { + selector: ".absolute", + isOffsetParentVisible: false, + isCurrentNodeVisible: true, + hasVisibleArrows: true, + isSizeVisible: false +}, { + selector: "#absolute-container", + isOffsetParentVisible: false, + isCurrentNodeVisible: true, + hasVisibleArrows: false, + isSizeVisible: true +}, { + selector: ".absolute-bottom-right", + isOffsetParentVisible: true, + isCurrentNodeVisible: true, + hasVisibleArrows: true, + isSizeVisible: false +}, { + selector: ".absolute-width-margin", + isOffsetParentVisible: true, + isCurrentNodeVisible: true, + hasVisibleArrows: true, + isSizeVisible: true +}, { + selector: ".absolute-all-4", + isOffsetParentVisible: true, + isCurrentNodeVisible: true, + hasVisibleArrows: true, + isSizeVisible: false +}, { + selector: ".relative", + isOffsetParentVisible: true, + isCurrentNodeVisible: true, + hasVisibleArrows: true, + isSizeVisible: false +}, { + selector: ".static", + isOffsetParentVisible: false, + isCurrentNodeVisible: false, + hasVisibleArrows: false, + isSizeVisible: false +}, { + selector: ".static-size", + isOffsetParentVisible: false, + isCurrentNodeVisible: true, + hasVisibleArrows: false, + isSizeVisible: true +}, { + selector: ".fixed", + isOffsetParentVisible: false, + isCurrentNodeVisible: true, + hasVisibleArrows: true, + isSizeVisible: false +}]; + +add_task(function*() { + let {inspector, toolbox} = yield openInspectorForURL(TEST_URL); + let front = inspector.inspector; + + let highlighter = yield front.getHighlighterByType("GeometryEditorHighlighter"); + + for (let data of TEST_DATA) { + yield testNode(inspector, highlighter, data); + } + + info("Hiding the highlighter"); + yield highlighter.hide(); + yield highlighter.finalize(); +}); + +function* testNode(inspector, highlighter, data) { + info("Highlighting the test node " + data.selector); + let node = yield getNodeFront(data.selector, inspector); + yield highlighter.show(node); + + is((yield isOffsetParentVisible(highlighter)), data.isOffsetParentVisible, + "The offset-parent highlighter visibility is correct for node " + data.selector); + is((yield isCurrentNodeVisible(highlighter)), data.isCurrentNodeVisible, + "The current-node highlighter visibility is correct for node " + data.selector); + is((yield hasVisibleArrows(highlighter)), data.hasVisibleArrows, + "The arrows visibility is correct for node " + data.selector); + is((yield isSizeVisible(highlighter)), data.isSizeVisible, + "The size label visibility is correct for node " + data.selector); +} + +function* isOffsetParentVisible(highlighter) { + let hidden = yield getHighlighterNodeAttribute(highlighter, + ID + "offset-parent", "hidden"); + return !hidden; +} + +function* isCurrentNodeVisible(highlighter) { + let hidden = yield getHighlighterNodeAttribute(highlighter, + ID + "current-node", "hidden"); + return !hidden; +} + +function* hasVisibleArrows(highlighter) { + for (let side of ["top", "left", "bottom", "right"]) { + let hidden = yield getHighlighterNodeAttribute(highlighter, + ID + "arrow-" + side, "hidden"); + if (!hidden) { + return true; + } + } + return false; +} + +function* isSizeVisible(highlighter) { + let hidden = yield getHighlighterNodeAttribute(highlighter, + ID + "label-size", "hidden"); + return !hidden; +} diff --git a/toolkit/devtools/inspector/test/doc_inspector_highlighter-geometry_01.html b/toolkit/devtools/inspector/test/doc_inspector_highlighter-geometry_01.html new file mode 100644 index 0000000000..8ba164a31a --- /dev/null +++ b/toolkit/devtools/inspector/test/doc_inspector_highlighter-geometry_01.html @@ -0,0 +1,90 @@ + + + + + geometry highlighter test page + + + +
+
+
+
+
+ +
+
+
+
+ +
+ + diff --git a/toolkit/devtools/inspector/test/doc_inspector_highlighter-geometry_02.html b/toolkit/devtools/inspector/test/doc_inspector_highlighter-geometry_02.html new file mode 100644 index 0000000000..4392c90427 --- /dev/null +++ b/toolkit/devtools/inspector/test/doc_inspector_highlighter-geometry_02.html @@ -0,0 +1,120 @@ + + + + +

Positioning playground

+

A demo of various positioning schemes: http://dev.w3.org/csswg/css-position/#pos-sch.

+

absolute, static, fixed, relative, sticky

+ +

Absolute positioning

+
+ Absolute child with no relative parent +
+
+
+ Absolute child with a relative parent +
+
+ Absolute child with a relative parent, positioned from the bottom right +
+
+ Absolute child with a relative parent, with all 4 positions +
+
+ Absolute child with a relative parent, with negative positions +
+
+ Absolute child with a relative parent, size, margin +
+
+ +

Relative positioning

+
+
+ Relative child +
+
+
+ Relative inline child, across multiple lines +
+
+
+
+ Relative child, in a positioned parent +
+
+
+ +

Fixed positioning

+
+
+ Fixed child +
+
+ Fixed child, bottom right +
+
+ +

Static positioning

+
+
+ Static child with no width/height +
+
+ Static child with width/height +
+
+ + \ No newline at end of file diff --git a/toolkit/devtools/server/actors/animation.js b/toolkit/devtools/server/actors/animation.js index 3594461941..26ceadc3df 100644 --- a/toolkit/devtools/server/actors/animation.js +++ b/toolkit/devtools/server/actors/animation.js @@ -29,9 +29,8 @@ const {Promise: promise} = Cu.import("resource://gre/modules/Promise.jsm", {}); const {Task} = Cu.import("resource://gre/modules/Task.jsm", {}); const {setInterval, clearInterval} = require("sdk/timers"); const protocol = require("devtools/server/protocol"); -const {ActorClass, Actor, FrontClass, Front, Arg, method, RetVal} = protocol; +const {ActorClass, Actor, FrontClass, Front, Arg, method, RetVal, types} = protocol; const {NodeActor} = require("devtools/server/actors/inspector"); -const EventEmitter = require("devtools/toolkit/event-emitter"); const events = require("sdk/event/core"); const PLAYER_DEFAULT_AUTO_REFRESH_TIMEOUT = 500; // ms @@ -43,7 +42,7 @@ const PLAYER_DEFAULT_AUTO_REFRESH_TIMEOUT = 500; // ms * Since the state of a player changes as the animation progresses it is often * useful to call getCurrentState at regular intervals to get the current state. * - * This actor also allows playing and pausing the animation. + * This actor also allows playing, pausing and seeking the animation. */ let AnimationPlayerActor = ActorClass({ typeName: "animationplayer", @@ -51,19 +50,18 @@ let AnimationPlayerActor = ActorClass({ /** * @param {AnimationsActor} The main AnimationsActor instance * @param {AnimationPlayer} The player object returned by getAnimationPlayers - * @param {DOMNode} The node targeted by this player * @param {Number} Temporary work-around used to retrieve duration and * iteration count from computed-style rather than from waapi. This is needed * to know which duration to get, in case there are multiple css animations * applied to the same node. */ - initialize: function(animationsActor, player, node, playerIndex) { + initialize: function(animationsActor, player, playerIndex) { Actor.prototype.initialize.call(this, animationsActor.conn); this.player = player; - this.node = node; + this.node = player.source.target; this.playerIndex = playerIndex; - this.styles = node.ownerDocument.defaultView.getComputedStyle(node); + this.styles = this.node.ownerDocument.defaultView.getComputedStyle(this.node); }, destroy: function() { @@ -208,6 +206,7 @@ let AnimationPlayerActor = ActorClass({ startTime: this.player.startTime, currentTime: this.player.currentTime, playState: this.player.playState, + playbackRate: this.player.playbackRate, name: this.player.source.effect.name, duration: this.getDuration(), delay: this.getDelay(), @@ -284,6 +283,30 @@ let AnimationPlayerActor = ActorClass({ }, { request: {}, response: {} + }), + + /** + * Set the current time of the animation player. + */ + setCurrentTime: method(function(currentTime) { + this.player.currentTime = currentTime; + }, { + request: { + currentTime: Arg(0, "number") + }, + response: {} + }), + + /** + * Set the playback rate of the animation player. + */ + setPlaybackRate: method(function(playbackRate) { + this.player.playbackRate = playbackRate; + }, { + request: { + currentTime: Arg(0, "number") + }, + response: {} }) }); @@ -291,7 +314,6 @@ let AnimationPlayerFront = FrontClass(AnimationPlayerActor, { AUTO_REFRESH_EVENT: "updated-state", initialize: function(conn, form, detail, ctx) { - EventEmitter.decorate(this); Front.prototype.initialize.call(this, conn, form, detail, ctx); this.state = {}; @@ -320,6 +342,7 @@ let AnimationPlayerFront = FrontClass(AnimationPlayerActor, { startTime: this._form.startTime, currentTime: this._form.currentTime, playState: this._form.playState, + playbackRate: this._form.playbackRate, name: this._form.name, duration: this._form.duration, delay: this._form.delay, @@ -388,7 +411,7 @@ let AnimationPlayerFront = FrontClass(AnimationPlayerActor, { if (this.currentStateHasChanged) { this.state = data; - this.emit(this.AUTO_REFRESH_EVENT, this.state); + events.emit(this, this.AUTO_REFRESH_EVENT, this.state); } }), @@ -413,25 +436,50 @@ let AnimationPlayerFront = FrontClass(AnimationPlayerActor, { }), }); +/** + * Sent with the 'mutations' event as part of an array of changes, used to + * inform fronts of the type of change that occured. + */ +types.addDictType("animationMutationChange", { + // The type of change ("added" or "removed"). + type: "string", + // The changed AnimationPlayerActor. + player: "animationplayer" +}); + /** * The Animations actor lists animation players for a given node. */ let AnimationsActor = exports.AnimationsActor = ActorClass({ typeName: "animations", + events: { + "mutations" : { + type: "mutations", + changes: Arg(0, "array:animationMutationChange") + } + }, + initialize: function(conn, tabActor) { Actor.prototype.initialize.call(this, conn); this.tabActor = tabActor; - this.allAnimationsPaused = false; + this.onWillNavigate = this.onWillNavigate.bind(this); this.onNavigate = this.onNavigate.bind(this); + this.onAnimationMutation = this.onAnimationMutation.bind(this); + + this.allAnimationsPaused = false; + events.on(this.tabActor, "will-navigate", this.onWillNavigate); events.on(this.tabActor, "navigate", this.onNavigate); }, destroy: function() { Actor.prototype.destroy.call(this); + events.off(this.tabActor, "will-navigate", this.onWillNavigate); events.off(this.tabActor, "navigate", this.onNavigate); - this.tabActor = null; + + this.stopAnimationPlayerUpdates(); + this.tabActor = this.observer = this.actors = null; }, /** @@ -451,14 +499,26 @@ let AnimationsActor = exports.AnimationsActor = ActorClass({ getAnimationPlayersForNode: method(function(nodeActor) { let animations = nodeActor.rawNode.getAnimations(); - let actors = []; + // No care is taken here to destroy the previously stored actors because it + // is assumed that the client is responsible for lifetimes of actors. + this.actors = []; for (let i = 0; i < animations.length; i ++) { // XXX: for now the index is passed along as the AnimationPlayerActor uses // it to retrieve animation information from CSS. - actors.push(AnimationPlayerActor(this, animations[i], nodeActor.rawNode, i)); + let actor = AnimationPlayerActor(this, animations[i], i); + this.actors.push(actor); } - return actors; + // When a front requests the list of players for a node, start listening + // for animation mutations on this node to send updates to the front, until + // either getAnimationPlayersForNode is called again or + // stopAnimationPlayerUpdates is called. + this.stopAnimationPlayerUpdates(); + let win = nodeActor.rawNode.ownerDocument.defaultView; + this.observer = new win.MutationObserver(this.onAnimationMutation); + this.observer.observe(nodeActor.rawNode, {animations: true}); + + return this.actors; }, { request: { actorID: Arg(0, "domnode") @@ -468,6 +528,63 @@ let AnimationsActor = exports.AnimationsActor = ActorClass({ } }), + onAnimationMutation: function(mutations) { + let eventData = []; + + for (let {addedAnimations, changedAnimations, removedAnimations} of mutations) { + for (let player of removedAnimations) { + // Note that animations are reported as removed either when they are + // actually removed from the node (e.g. css class removed) or when they + // are finished and don't have forwards animation-fill-mode. + // In the latter case, we don't send an event, because the corresponding + // animation can still be seeked/resumed, so we want the client to keep + // its reference to the AnimationPlayerActor. + if (player.playState !== "idle") { + continue; + } + let index = this.actors.findIndex(a => a.player === player); + eventData.push({ + type: "removed", + player: this.actors[index] + }); + this.actors.splice(index, 1); + } + + for (let player of addedAnimations) { + // If the added player already exists, it means we previously filtered + // it out when it was reported as removed. So filter it out here too. + if (this.actors.find(a => a.player === player)) { + continue; + } + let actor = AnimationPlayerActor( + this, player, player.source.target.getAnimations().indexOf(player)); + this.actors.push(actor); + eventData.push({ + type: "added", + player: actor + }); + } + } + + if (eventData.length) { + events.emit(this, "mutations", eventData); + } + }, + + /** + * After the client has called getAnimationPlayersForNode for a given DOM node, + * the actor starts sending animation mutations for this node. If the client + * doesn't want this to happen anymore, it should call this method. + */ + stopAnimationPlayerUpdates: method(function() { + if (this.observer && !Cu.isDeadWrapper(this.observer)) { + this.observer.disconnect(); + } + }, { + request: {}, + response: {} + }), + /** * Iterates through all nodes in all of the tabActor's window documents and * finds all existing animation players. @@ -492,6 +609,12 @@ let AnimationsActor = exports.AnimationsActor = ActorClass({ return animations; }, + onWillNavigate: function({isTopLevel}) { + if (isTopLevel) { + this.stopAnimationPlayerUpdates(); + } + }, + onNavigate: function({isTopLevel}) { if (isTopLevel) { this.allAnimationsPaused = false; diff --git a/toolkit/devtools/server/actors/highlighter.css b/toolkit/devtools/server/actors/highlighter.css index 033c218c66..172d0c89db 100644 --- a/toolkit/devtools/server/actors/highlighter.css +++ b/toolkit/devtools/server/actors/highlighter.css @@ -14,10 +14,15 @@ */ :-moz-native-anonymous .highlighter-container { - pointer-events: none; position: absolute; width: 100%; height: 100%; + /* The container for all highlighters doesn't react to pointer-events by + default. This is because most highlighters cover the whole viewport but + don't contain UIs that need to be accessed. + If your highlighter has UI that needs to be interacted with, add + 'pointer-events:auto;' on its container element. */ + pointer-events: none; } :-moz-native-anonymous .highlighter-container [hidden] { @@ -57,7 +62,7 @@ :-moz-native-anonymous .box-model-guide-right, :-moz-native-anonymous .box-model-guide-bottom, :-moz-native-anonymous .box-model-guide-left { - stroke: #08C; + stroke: #08c; stroke-dasharray: 5 3; shape-rendering: crispEdges; } @@ -166,7 +171,7 @@ :-moz-native-anonymous .css-transform-transformed, :-moz-native-anonymous .css-transform-untransformed, :-moz-native-anonymous .css-transform-line { - stroke: #08C; + stroke: #08c; stroke-dasharray: 5 3; stroke-width: 2; } @@ -178,3 +183,43 @@ background: #80d4ff; opacity: 0.8; } + +/* Element geometry highlighter */ + +:-moz-native-anonymous .geometry-editor-root { + /* The geometry editor can be interacted with, so it needs to react to + pointer events */ + pointer-events: auto; +} + +:-moz-native-anonymous .geometry-editor-offset-parent { + stroke: #08c; + shape-rendering: crispEdges; + stroke-dasharray: 5 3; + fill: transparent; +} + +:-moz-native-anonymous .geometry-editor-current-node { + stroke: #08c; + shape-rendering: crispEdges; + fill: #87ceeb; + opacity: 0.6; +} + +:-moz-native-anonymous .geometry-editor-arrow { + stroke: #08c; + shape-rendering: crispEdges; +} + +:-moz-native-anonymous .geometry-editor-label-bubble { + fill: hsl(214,13%,24%); + shape-rendering: crispEdges; +} + +:-moz-native-anonymous .geometry-editor-label-text { + fill: hsl(216,33%,97%); + font: message-box; + font-size: 10px; + text-anchor: middle; + dominant-baseline: middle; +} diff --git a/toolkit/devtools/server/actors/highlighter.js b/toolkit/devtools/server/actors/highlighter.js index 4c0cc454b3..5143cb33d0 100644 --- a/toolkit/devtools/server/actors/highlighter.js +++ b/toolkit/devtools/server/actors/highlighter.js @@ -46,6 +46,9 @@ const SIMPLE_OUTLINE_SHEET = ".__fx-devtools-hide-shortcut__ {" + " outline: 2px dashed #F06!important;" + " outline-offset: -2px!important;" + "}"; +// Distance of the width or height handles from the node's edge. +const GEOMETRY_SIZE_ARROW_OFFSET = .25; // 25% +const GEOMETRY_LABEL_SIZE = 6; /** * The registration mechanism for highlighters provide a quick way to @@ -126,6 +129,7 @@ let HighlighterActor = exports.HighlighterActor = protocol.ActorClass({ this._highlighterHidden = this._highlighterHidden.bind(this); this._onNavigate = this._onNavigate.bind(this); + this._layoutHelpers = new LayoutHelpers(this._tabActor.window); this._createHighlighter(); // Listen to navigation events to switch from the BoxModelHighlighter to the @@ -180,6 +184,7 @@ let HighlighterActor = exports.HighlighterActor = protocol.ActorClass({ this._inspector = null; this._walker = null; this._tabActor = null; + this._layoutHelpers = null; }, /** @@ -279,25 +284,8 @@ let HighlighterActor = exports.HighlighterActor = protocol.ActorClass({ return this._walker.attachElement(node); }, - /** - * Get the right target for listening to mouse events while in pick mode. - * - On a firefox desktop content page: tabActor is a BrowserTabActor from - * which the browser property will give us a target we can use to listen to - * events, even in nested iframes. - * - On B2G: tabActor is a ContentActor which doesn't have a browser but - * since it overrides BrowserTabActor, it does get a browser property - * anyway, which points to its window object. - * - When using the Browser Toolbox (to inspect firefox desktop): tabActor is - * the RootActor, in which case, the window property can be used to listen - * to events - */ - _getPickerListenerTarget: function() { - let actor = this._tabActor; - return actor.isRootActor ? actor.window : actor.chromeEventHandler; - }, - _startPickerListeners: function() { - let target = this._getPickerListenerTarget(); + let target = getPageListenerTarget(this._tabActor); target.addEventListener("mousemove", this._onHovered, true); target.addEventListener("click", this._onPick, true); target.addEventListener("mousedown", this._preventContentEvent, true); @@ -306,7 +294,7 @@ let HighlighterActor = exports.HighlighterActor = protocol.ActorClass({ }, _stopPickerListeners: function() { - let target = this._getPickerListenerTarget(); + let target = getPageListenerTarget(this._tabActor); target.removeEventListener("mousemove", this._onHovered, true); target.removeEventListener("click", this._onPick, true); target.removeEventListener("mousedown", this._preventContentEvent, true); @@ -462,8 +450,12 @@ function CanvasFrameAnonymousContentHelper(tabActor, nodeBuilder) { this._onNavigate = this._onNavigate.bind(this); events.on(this.tabActor, "navigate", this._onNavigate); + + this.listeners = new Map(); } +exports.CanvasFrameAnonymousContentHelper = CanvasFrameAnonymousContentHelper; + CanvasFrameAnonymousContentHelper.prototype = { destroy: function() { try { @@ -477,6 +469,8 @@ CanvasFrameAnonymousContentHelper.prototype = { this.tabActor = this.nodeBuilder = this._content = null; this.anonymousContentDocument = null; this.anonymousContentGlobal = null; + + this._removeAllListeners(); }, _insert: function() { @@ -513,7 +507,9 @@ CanvasFrameAnonymousContentHelper.prototype = { _onNavigate: function({isTopLevel}) { if (isTopLevel) { + this._removeAllListeners(); this._insert(); + this.anonymousContentDocument = this.tabActor.window.document; } }, @@ -549,6 +545,146 @@ CanvasFrameAnonymousContentHelper.prototype = { } }, + /** + * Add an event listener to one of the elements inserted in the canvasFrame + * native anonymous container. + * Like other methods in this helper, this requires the ID of the element to + * be passed in. + * + * Note that if the content page navigates, the event listeners won't be + * added again. + * + * Also note that unlike traditional DOM events, the events handled by + * listeners added here will propagate through the document only through + * bubbling phase, so the useCapture parameter isn't supported. + * It is possible however to call e.stopPropagation() to stop the bubbling. + * + * IMPORTANT: the chrome-only canvasFrame insertion API takes great care of + * not leaking references to inserted elements to chrome JS code. That's + * because otherwise, chrome JS code could freely modify native anon elements + * inside the canvasFrame and probably change things that are assumed not to + * change by the C++ code managing this frame. + * See https://wiki.mozilla.org/DevTools/Highlighter#The_AnonymousContent_API + * Unfortunately, the inserted nodes are still available via + * event.originalTarget, and that's what the event handler here uses to check + * that the event actually occured on the right element, but that also means + * consumers of this code would be able to access the inserted elements. + * Therefore, the originalTarget property will be nullified before the event + * is passed to your handler. + * + * IMPL DETAIL: A single event listener is added per event types only, at + * browser level and if the event originalTarget is found to have the provided + * ID, the callback is executed (and then IDs of parent nodes of the + * originalTarget are checked too). + * + * @param {String} id + * @param {String} type + * @param {Function} handler + */ + addEventListenerForElement: function(id, type, handler) { + if (typeof id !== "string") { + throw new Error("Expected a string ID in addEventListenerForElement but" + + " got: " + id); + } + + // If no one is listening for this type of event yet, add one listener. + if (!this.listeners.has(type)) { + let target = getPageListenerTarget(this.tabActor); + target.addEventListener(type, this, true); + // Each type entry in the map is a map of ids:handlers. + this.listeners.set(type, new Map); + } + + let listeners = this.listeners.get(type); + listeners.set(id, handler); + }, + + /** + * Remove an event listener from one of the elements inserted in the + * canvasFrame native anonymous container. + * @param {String} id + * @param {String} type + * @param {Function} handler + */ + removeEventListenerForElement: function(id, type, handler) { + let listeners = this.listeners.get(type); + if (!listeners) { + return; + } + listeners.delete(id); + + // If no one is listening for event type anymore, remove the listener. + if (!this.listeners.has(type)) { + let target = getPageListenerTarget(this.tabActor); + target.removeEventListener(type, this, true); + } + }, + + handleEvent: function(event) { + let listeners = this.listeners.get(event.type); + if (!listeners) { + return; + } + + // Hide the originalTarget property to avoid exposing references to native + // anonymous elements. See addEventListenerForElement's comment. + let isPropagationStopped = false; + let eventProxy = new Proxy(event, { + get: (obj, name) => { + if (name === "originalTarget") { + return null; + } else if (name === "stopPropagation") { + return () => { + isPropagationStopped = true; + }; + } else { + return obj[name]; + } + } + }); + + // Start at originalTarget, bubble through ancestors and call handlers when + // needed. + let node = event.originalTarget; + while (node) { + let handler = listeners.get(node.id); + if (handler) { + handler(eventProxy, node.id); + if (isPropagationStopped) { + break; + } + } + node = node.parentNode; + } + }, + + _removeAllListeners: function() { + if (this.tabActor) { + let target = getPageListenerTarget(this.tabActor); + for (let [type] of this.listeners) { + target.removeEventListener(type, this, true); + } + } + this.listeners.clear(); + }, + + getElement: function(id) { + let self = this; + return { + getTextContent: () => self.getTextContentForElement(id), + setTextContent: text => self.setTextContentForElement(id, text), + setAttribute: (name, value) => self.setAttributeForElement(id, name, value), + getAttribute: name => self.getAttributeForElement(id, name), + removeAttribute: name => self.removeAttributeForElement(id, name), + addEventListener: (type, handler) => { + return self.addEventListenerForElement(id, type, handler); + }, + removeEventListener: (type, handler) => { + return self.removeEventListenerForElement(id, type, handler); + } + }; + }, + get content() { if (!this._content || Cu.isDeadWrapper(this._content)) { return null; @@ -762,7 +898,7 @@ AutoRefreshHighlighter.prototype = { }, _startRefreshLoop: function() { - let win = this.currentNode.ownerDocument.defaultView; + let win = getWindow(this.currentNode); this.rafID = win.requestAnimationFrame(this._startRefreshLoop.bind(this)); this.rafWin = win; this.update(); @@ -860,11 +996,6 @@ BoxModelHighlighter.prototype = Heritage.extend(AutoRefreshHighlighter.prototype ID_CLASS_PREFIX: "box-model-", - get zoom() { - return this.win.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIDOMWindowUtils).fullZoom; - }, - get currentNode() { return this._currentNode; }, @@ -899,7 +1030,6 @@ BoxModelHighlighter.prototype = Heritage.extend(AutoRefreshHighlighter.prototype "id": "elements", "width": "100%", "height": "100%", - "style": "width:100%;height:100%;", "hidden": "true" }, prefix: this.ID_CLASS_PREFIX @@ -1027,6 +1157,10 @@ BoxModelHighlighter.prototype = Heritage.extend(AutoRefreshHighlighter.prototype this._currentNode = null; }, + getElement: function(id) { + return this.markup.getElement(this.ID_CLASS_PREFIX + id); + }, + /** * Show the highlighter on a given node */ @@ -1046,7 +1180,7 @@ BoxModelHighlighter.prototype = Heritage.extend(AutoRefreshHighlighter.prototype */ _trackMutations: function() { if (isNodeValid(this.currentNode)) { - let win = this.currentNode.ownerDocument.defaultView; + let win = getWindow(this.currentNode); this.currentNodeObserver = new win.MutationObserver(this.update); this.currentNodeObserver.observe(this.currentNode, {attributes: true}); } @@ -1099,16 +1233,14 @@ BoxModelHighlighter.prototype = Heritage.extend(AutoRefreshHighlighter.prototype * Hide the infobar */ _hideInfobar: function() { - this.markup.setAttributeForElement( - this.ID_CLASS_PREFIX + "nodeinfobar-container", "hidden", "true"); + this.getElement("nodeinfobar-container").setAttribute("hidden", "true"); }, /** * Show the infobar */ _showInfobar: function() { - this.markup.removeAttributeForElement( - this.ID_CLASS_PREFIX + "nodeinfobar-container", "hidden"); + this.getElement("nodeinfobar-container").removeAttribute("hidden"); this._updateInfobar(); }, @@ -1116,16 +1248,14 @@ BoxModelHighlighter.prototype = Heritage.extend(AutoRefreshHighlighter.prototype * Hide the box model */ _hideBoxModel: function() { - this.markup.setAttributeForElement(this.ID_CLASS_PREFIX + "elements", - "hidden", "true"); + this.getElement("elements").setAttribute("hidden", "true"); }, /** * Show the box model */ _showBoxModel: function() { - this.markup.removeAttributeForElement(this.ID_CLASS_PREFIX + "elements", - "hidden"); + this.getElement("elements").removeAttribute("hidden"); }, /** @@ -1195,12 +1325,12 @@ BoxModelHighlighter.prototype = Heritage.extend(AutoRefreshHighlighter.prototype if (this._nodeNeedsHighlighting()) { for (let boxType of BOX_MODEL_REGIONS) { + let box = this.getElement(boxType); + if (this.regionFill[boxType]) { - this.markup.setAttributeForElement(this.ID_CLASS_PREFIX + boxType, - "style", "fill:" + this.regionFill[boxType]); + box.setAttribute("style", "fill:" + this.regionFill[boxType]); } else { - this.markup.setAttributeForElement(this.ID_CLASS_PREFIX + boxType, - "style", ""); + box.setAttribute("style", ""); } if (!this.options.showOnly || this.options.showOnly === boxType) { @@ -1213,10 +1343,9 @@ BoxModelHighlighter.prototype = Heritage.extend(AutoRefreshHighlighter.prototype "L" + p4.x + "," + p4.y); } - this.markup.setAttributeForElement(this.ID_CLASS_PREFIX + boxType, - "d", path.join(" ")); + box.setAttribute("d", path.join(" ")); } else { - this.markup.removeAttributeForElement(this.ID_CLASS_PREFIX + boxType, "d"); + box.removeAttribute("d"); } if (boxType === this.options.region && !this.options.hideGuides) { @@ -1246,7 +1375,7 @@ BoxModelHighlighter.prototype = Heritage.extend(AutoRefreshHighlighter.prototype Cu.isDeadWrapper(this.currentNode) || this.currentNode.nodeType !== Ci.nsIDOMNode.ELEMENT_NODE || !this.currentNode.ownerDocument || - !this.currentNode.ownerDocument.defaultView || + !getWindow(this.currentNode) || hasNoQuads) { return false; } @@ -1323,8 +1452,7 @@ BoxModelHighlighter.prototype = Heritage.extend(AutoRefreshHighlighter.prototype _hideGuides: function() { for (let side of BOX_MODEL_SIDES) { - this.markup.setAttributeForElement( - this.ID_CLASS_PREFIX + "guide-" + side, "hidden", "true"); + this.getElement("guide-" + side).setAttribute("hidden", "true"); } }, @@ -1338,26 +1466,26 @@ BoxModelHighlighter.prototype = Heritage.extend(AutoRefreshHighlighter.prototype * x or y co-ordinate. If this is undefined we hide the guide. */ _updateGuide: function(side, point=-1) { - let guideId = this.ID_CLASS_PREFIX + "guide-" + side; + let guide = this.getElement("guide-" + side); if (point <= 0) { - this.markup.setAttributeForElement(guideId, "hidden", "true"); + guide.setAttribute("hidden", "true"); return false; } if (side === "top" || side === "bottom") { - this.markup.setAttributeForElement(guideId, "x1", "0"); - this.markup.setAttributeForElement(guideId, "y1", point + ""); - this.markup.setAttributeForElement(guideId, "x2", "100%"); - this.markup.setAttributeForElement(guideId, "y2", point + ""); + guide.setAttribute("x1", "0"); + guide.setAttribute("y1", point + ""); + guide.setAttribute("x2", "100%"); + guide.setAttribute("y2", point + ""); } else { - this.markup.setAttributeForElement(guideId, "x1", point + ""); - this.markup.setAttributeForElement(guideId, "y1", "0"); - this.markup.setAttributeForElement(guideId, "x2", point + ""); - this.markup.setAttributeForElement(guideId, "y2", "100%"); + guide.setAttribute("x1", point + ""); + guide.setAttribute("y1", "0"); + guide.setAttribute("x2", point + ""); + guide.setAttribute("y2", "100%"); } - this.markup.removeAttributeForElement(guideId, "hidden"); + guide.removeAttribute("hidden"); return true; }, @@ -1397,12 +1525,11 @@ BoxModelHighlighter.prototype = Heritage.extend(AutoRefreshHighlighter.prototype " \u00D7 " + parseFloat((height / zoom).toPrecision(6)); - let elementId = this.ID_CLASS_PREFIX + "nodeinfobar-"; - this.markup.setTextContentForElement(elementId + "tagname", tagName); - this.markup.setTextContentForElement(elementId + "id", id); - this.markup.setTextContentForElement(elementId + "classes", classList); - this.markup.setTextContentForElement(elementId + "pseudo-classes", pseudos); - this.markup.setTextContentForElement(elementId + "dimensions", dim); + this.getElement("nodeinfobar-tagname").setTextContent(tagName); + this.getElement("nodeinfobar-id").setTextContent(id); + this.getElement("nodeinfobar-classes").setTextContent(classList); + this.getElement("nodeinfobar-pseudo-classes").setTextContent(pseudos); + this.getElement("nodeinfobar-dimensions").setTextContent(dim); this._moveInfobar(); }, @@ -1412,14 +1539,14 @@ BoxModelHighlighter.prototype = Heritage.extend(AutoRefreshHighlighter.prototype */ _moveInfobar: function() { let bounds = this._getOuterBounds(); - let winHeight = this.win.innerHeight * this.zoom; - let winWidth = this.win.innerWidth * this.zoom; + let winHeight = this.win.innerHeight * LayoutHelpers.getCurrentZoom(this.win); + let winWidth = this.win.innerWidth * LayoutHelpers.getCurrentZoom(this.win); // Ensure that containerBottom and containerTop are at least zero to avoid // showing tooltips outside the viewport. let containerBottom = Math.max(0, bounds.bottom) + NODE_INFOBAR_ARROW_SIZE; let containerTop = Math.min(winHeight, bounds.top); - let containerId = this.ID_CLASS_PREFIX + "nodeinfobar-container"; + let container = this.getElement("nodeinfobar-container"); // Can the bar be above the node? let top; @@ -1428,16 +1555,16 @@ BoxModelHighlighter.prototype = Heritage.extend(AutoRefreshHighlighter.prototype if (containerBottom + NODE_INFOBAR_HEIGHT > winHeight) { // No. Let's move it inside. top = containerTop; - this.markup.setAttributeForElement(containerId, "position", "overlap"); + container.setAttribute("position", "overlap"); } else { // Yes. Let's move it under the node. top = containerBottom; - this.markup.setAttributeForElement(containerId, "position", "bottom"); + container.setAttribute("position", "bottom"); } } else { // Yes. Let's move it on top of the node. top = containerTop - NODE_INFOBAR_HEIGHT; - this.markup.setAttributeForElement(containerId, "position", "top"); + container.setAttribute("position", "top"); } // Align the bar with the box's center if possible. @@ -1446,16 +1573,16 @@ BoxModelHighlighter.prototype = Heritage.extend(AutoRefreshHighlighter.prototype let buffer = 100; if (left < buffer) { left = buffer; - this.markup.setAttributeForElement(containerId, "hide-arrow", "true"); + container.setAttribute("hide-arrow", "true"); } else if (left > winWidth - buffer) { left = winWidth - buffer; - this.markup.setAttributeForElement(containerId, "hide-arrow", "true"); + container.setAttribute("hide-arrow", "true"); } else { - this.markup.removeAttributeForElement(containerId, "hide-arrow"); + container.removeAttribute("hide-arrow"); } let style = "top:" + top + "px;left:" + left + "px;"; - this.markup.setAttributeForElement(containerId, "style", style); + container.setAttribute("style", style); } }); register(BoxModelHighlighter); @@ -1586,6 +1713,10 @@ CssTransformHighlighter.prototype = Heritage.extend(AutoRefreshHighlighter.proto this.markup.destroy(); }, + getElement: function(id) { + return this.markup.getElement(this.ID_CLASS_PREFIX + id); + }, + /** * Show the highlighter on a given node * @param {DOMNode} node @@ -1612,23 +1743,21 @@ CssTransformHighlighter.prototype = Heritage.extend(AutoRefreshHighlighter.proto for (let point of ["p1", "p2", "p3", "p4"]) { points.push(quad[point].x + "," + quad[point].y); } - this.markup.setAttributeForElement(this.ID_CLASS_PREFIX + id, - "points", - points.join(" ")); + this.getElement(id).setAttribute("points", points.join(" ")); }, _setLinePoints: function(p1, p2, id) { - this.markup.setAttributeForElement(this.ID_CLASS_PREFIX + id, "x1", p1.x); - this.markup.setAttributeForElement(this.ID_CLASS_PREFIX + id, "y1", p1.y); - this.markup.setAttributeForElement(this.ID_CLASS_PREFIX + id, "x2", p2.x); - this.markup.setAttributeForElement(this.ID_CLASS_PREFIX + id, "y2", p2.y); + let line = this.getElement(id); + line.setAttribute("x1", p1.x); + line.setAttribute("y1", p1.y); + line.setAttribute("x2", p2.x); + line.setAttribute("y2", p2.y); let dist = Math.sqrt(Math.pow(p2.x - p1.x, 2) + Math.pow(p2.y - p1.y, 2)); if (dist < ARROW_LINE_MIN_DISTANCE) { - this.markup.removeAttributeForElement(this.ID_CLASS_PREFIX + id, "marker-end"); + line.removeAttribute("marker-end"); } else { - this.markup.setAttributeForElement(this.ID_CLASS_PREFIX + id, "marker-end", - "url(#" + this.markerId + ")"); + line.setAttribute("marker-end", "url(#" + this.markerId + ")"); } }, @@ -1677,19 +1806,16 @@ CssTransformHighlighter.prototype = Heritage.extend(AutoRefreshHighlighter.proto }, _hideShapes: function() { - this.markup.setAttributeForElement(this.ID_CLASS_PREFIX + "elements", - "hidden", "true"); + this.getElement("elements").setAttribute("hidden", "true"); }, _showShapes: function() { - this.markup.removeAttributeForElement(this.ID_CLASS_PREFIX + "elements", - "hidden"); + this.getElement("elements").removeAttribute("hidden"); } }); register(CssTransformHighlighter); exports.CssTransformHighlighter = CssTransformHighlighter; - /** * The SelectorHighlighter runs a given selector through querySelectorAll on the * document of the provided context node and then uses the BoxModelHighlighter @@ -1702,6 +1828,7 @@ function SelectorHighlighter(tabActor) { SelectorHighlighter.prototype = { typeName: "SelectorHighlighter", + /** * Show BoxModelHighlighter on each node that matches that provided selector. * @param {DOMNode} node A context node that is used to get the document on @@ -1811,6 +1938,10 @@ RectHighlighter.prototype = { this.markup.destroy(); }, + getElement: function(id) { + return this.markup.getElement(id); + }, + _hasValidOptions: function(options) { let isValidNb = n => typeof n === "number" && n >= 0 && isFinite(n); return options && options.rect && @@ -1856,17 +1987,606 @@ RectHighlighter.prototype = { } // Set the coordinates of the highlighter and show it - this.markup.setAttributeForElement("highlighted-rect", "style", style); - this.markup.removeAttributeForElement("highlighted-rect", "hidden"); + let rect = this.getElement("highlighted-rect"); + rect.setAttribute("style", style); + rect.removeAttribute("hidden"); }, hide: function() { - this.markup.setAttributeForElement("highlighted-rect", "hidden", "true"); + this.getElement("highlighted-rect").setAttribute("hidden", "true"); } }; register(RectHighlighter); exports.RectHighlighter = RectHighlighter; +/** + * Element geometry properties helper that gives names of position and size + * properties. + */ +let GeoProp = { + SIDES: ["top", "right", "bottom", "left"], + SIZES: ["width", "height"], + + allProps: function() { + return [...this.SIDES, ...this.SIZES]; + }, + + isSide: function(name) { + return this.SIDES.indexOf(name) !== -1; + }, + + isSize: function(name) { + return this.SIZES.indexOf(name) !== -1; + }, + + containsSide: function(names) { + return names.some(name => this.SIDES.indexOf(name) !== -1); + }, + + containsSize: function(names) { + return names.some(name => this.SIZES.indexOf(name) !== -1); + }, + + isHorizontal: function(name) { + return name === "left" || name === "right" || name === "width"; + }, + + isInverted: function(name) { + return name === "right" || name === "bottom"; + }, + + mainAxisStart: function(name) { + return this.isHorizontal(name) ? "left" : "top"; + }, + + crossAxisStart: function(name) { + return this.isHorizontal(name) ? "top" : "left"; + }, + + mainAxisSize: function(name) { + return this.isHorizontal(name) ? "width" : "height"; + }, + + crossAxisSize: function(name) { + return this.isHorizontal(name) ? "height" : "width"; + }, + + axis: function(name) { + return this.isHorizontal(name) ? "x" : "y"; + }, + + crossAxis: function(name) { + return this.isHorizontal(name) ? "y" : "x"; + } +}; + +/** + * The GeometryEditor highlights an elements's top, left, bottom, right, width + * and height dimensions, when they are set. + * + * To determine if an element has a set size and position, the highlighter lists + * the CSS rules that apply to the element and checks for the top, left, bottom, + * right, width and height properties. + * The highlighter won't be shown if the element doesn't have any of these + * properties set, but will be shown when at least 1 property is defined. + * + * The highlighter displays lines and labels for each of the defined properties + * in and around the element (relative to the offset parent when one exists). + * The highlighter also highlights the element itself and its offset parent if + * there is one. + * + * Note that the class name contains the word Editor because the aim is for the + * handles to be draggable in content to make the geometry editable. + */ +function GeometryEditorHighlighter(tabActor) { + AutoRefreshHighlighter.call(this, tabActor); + + // The list of element geometry properties that can be set. + this.definedProperties = new Map(); + + this.markup = new CanvasFrameAnonymousContentHelper(tabActor, + this._buildMarkup.bind(this)); +} + +GeometryEditorHighlighter.prototype = Heritage.extend(AutoRefreshHighlighter.prototype, { + typeName: "GeometryEditorHighlighter", + + ID_CLASS_PREFIX: "geometry-editor-", + + _buildMarkup: function() { + let container = createNode(this.win, { + attributes: {"class": "highlighter-container"} + }); + + let root = createNode(this.win, { + parent: container, + attributes: { + "id": "root", + "class": "root" + }, + prefix: this.ID_CLASS_PREFIX + }); + + let svg = createSVGNode(this.win, { + nodeType: "svg", + parent: root, + attributes: { + "id": "elements", + "width": "100%", + "height": "100%" + }, + prefix: this.ID_CLASS_PREFIX + }); + + // Offset parent node highlighter. + createSVGNode(this.win, { + nodeType: "polygon", + parent: svg, + attributes: { + "class": "offset-parent", + "id": "offset-parent", + "hidden": "true" + }, + prefix: this.ID_CLASS_PREFIX + }); + + // Current node highlighter (margin box). + createSVGNode(this.win, { + nodeType: "polygon", + parent: svg, + attributes: { + "class": "current-node", + "id": "current-node", + "hidden": "true" + }, + prefix: this.ID_CLASS_PREFIX + }); + + // Build the 4 side arrows and labels. + for (let name of GeoProp.SIDES) { + createSVGNode(this.win, { + nodeType: "line", + parent: svg, + attributes: { + "class": "arrow " + name, + "id": "arrow-" + name, + "hidden": "true" + }, + prefix: this.ID_CLASS_PREFIX + }); + + // Labels are positioned by using a translated . This group contains + // a path and text that are themselves positioned using another translated + // . This is so that the label arrow points at the 0,0 coordinates of + // parent . + let labelG = createSVGNode(this.win, { + nodeType: "g", + parent: svg, + attributes: { + "id": "label-" + name, + "hidden": "true" + }, + prefix: this.ID_CLASS_PREFIX + }); + + let subG = createSVGNode(this.win, { + nodeType: "g", + parent: labelG, + attributes: { + "transform": GeoProp.isHorizontal(name) + ? "translate(-30 -30)" + : "translate(5 -10)" + } + }); + + createSVGNode(this.win, { + nodeType: "path", + parent: subG, + attributes: { + "class": "label-bubble", + "d": GeoProp.isHorizontal(name) + ? "M0 0 L60 0 L60 20 L35 20 L30 25 L25 20 L0 20z" + : "M5 0 L65 0 L65 20 L5 20 L5 15 L0 10 L5 5z" + }, + prefix: this.ID_CLASS_PREFIX + }); + + createSVGNode(this.win, { + nodeType: "text", + parent: subG, + attributes: { + "class": "label-text", + "id": "label-text-" + name, + "x": GeoProp.isHorizontal(name) ? "30" : "35", + "y": "10" + }, + prefix: this.ID_CLASS_PREFIX + }); + } + + // Build the width/height label and resize handle. + let labelSizeG = createSVGNode(this.win, { + nodeType: "g", + parent: svg, + attributes: { + "id": "label-size", + "hidden": "true" + }, + prefix: this.ID_CLASS_PREFIX + }); + + let subSizeG = createSVGNode(this.win, { + nodeType: "g", + parent: labelSizeG, + attributes: { + "transform": "translate(-50 -10)" + } + }); + + createSVGNode(this.win, { + nodeType: "path", + parent: subSizeG, + attributes: { + "class": "label-bubble", + "d": "M0 0 L100 0 L100 20 L0 20z" + }, + prefix: this.ID_CLASS_PREFIX + }); + + createSVGNode(this.win, { + nodeType: "text", + parent: subSizeG, + attributes: { + "class": "label-text", + "id": "label-text-size", + "x": "50", + "y": "10" + }, + prefix: this.ID_CLASS_PREFIX + }); + + return container; + }, + + destroy: function() { + AutoRefreshHighlighter.prototype.destroy.call(this); + + this.markup.destroy(); + this.definedProperties.clear(); + this.definedProperties = null; + this.offsetParent = null; + }, + + getElement: function(id) { + return this.markup.getElement(this.ID_CLASS_PREFIX + id); + }, + + /** + * Get the list of geometry properties that are actually set on the current + * node. + * @return {Map} A map indexed by property name and where the value is an + * object having the cssRule property. + */ + getDefinedGeometryProperties: function() { + let props = new Map(); + if (!this.currentNode) { + return props; + } + + // Get the list of css rules applying to the current node. + let cssRules = DOMUtils.getCSSStyleRules(this.currentNode); + for (let i = 0; i < cssRules.Count(); i++) { + let rule = cssRules.GetElementAt(i); + for (let name of GeoProp.allProps()) { + let value = rule.style.getPropertyValue(name); + if (value && value !== "auto") { + // getCSSStyleRules returns rules ordered from least-specific to + // most-specific, so just override any previous properties we have set. + props.set(name, { + cssRule: rule + }); + } + } + } + + // Go through the inline styles last. + for (let name of GeoProp.allProps()) { + let value = this.currentNode.style.getPropertyValue(name); + if (value && value !== "auto") { + props.set(name, { + // There's no cssRule to store here, so store the node instead since + // node.style exists. + cssRule: this.currentNode + }); + } + } + + // Post-process the list for invalid properties. This is done after the fact + // because of cases like relative positioning with both top and bottom where + // only top will actually be used, but both exists in css rules and computed + // styles. + for (let [name] of props) { + let pos = this.computedStyle.position; + + // Top/left/bottom/right on static positioned elements have no effect. + if (pos === "static" && GeoProp.SIDES.indexOf(name) !== -1) { + props.delete(name); + } + + // Bottom/right on relative positioned elements are only used if top/left + // are not defined. + let hasRightAndLeft = name === "right" && props.has("left"); + let hasBottomAndTop = name === "bottom" && props.has("top"); + if (pos === "relative" && (hasRightAndLeft || hasBottomAndTop)) { + props.delete(name); + } + } + + return props; + }, + + _show: function() { + this.computedStyle = CssLogic.getComputedStyle(this.currentNode); + let pos = this.computedStyle.position; + // XXX: sticky positioning is ignored for now. To be implemented next. + if (pos === "sticky") { + this.hide(); + return; + } + + let hasUpdated = this._update(); + if (!hasUpdated) { + this.hide(); + } + }, + + _update: function() { + // At each update, the position or/and size may have changed, so get the + // list of defined properties, and re-position the arrows and highlighters. + this.definedProperties = this.getDefinedGeometryProperties(); + + let isStatic = this.computedStyle.position === "static"; + let hasSizes = GeoProp.containsSize([...this.definedProperties.keys()]); + + if (!this.definedProperties.size) { + console.warn("The element does not have editable geometry properties"); + return false; + } + + setIgnoreLayoutChanges(true); + + // Update the highlighters and arrows. + this.updateOffsetParent(); + this.updateCurrentNode(); + this.updateArrows(); + this.updateSize(); + + // Avoid zooming the arrows when content is zoomed. + this.markup.scaleRootElement(this.currentNode, this.ID_CLASS_PREFIX + "root"); + + setIgnoreLayoutChanges(false, this.currentNode.ownerDocument.documentElement); + return true; + }, + + /** + * Update the offset parent rectangle. + * There are 3 different cases covered here: + * - the node is absolutely/fixed positioned, and an offsetParent is defined + * (i.e. it's not just positioned in the viewport): the offsetParent node + * is highlighted (i.e. the rectangle is shown), + * - the node is relatively positioned: the rectangle is shown where the node + * would originally have been (because that's where the relative positioning + * is calculated from), + * - the node has no offset parent at all: the offsetParent rectangle is + * hidden. + */ + updateOffsetParent: function() { + // Get the offsetParent, if any. + this.offsetParent = getOffsetParent(this.currentNode); + // And the offsetParent quads. + this.parentQuads = this.layoutHelpers + .getAdjustedQuads(this.offsetParent.element, "padding"); + + let el = this.getElement("offset-parent"); + + let isPositioned = this.computedStyle.position === "absolute" || + this.computedStyle.position === "fixed"; + let isRelative = this.computedStyle.position === "relative"; + let isHighlighted = false; + + if (this.offsetParent.element && isPositioned) { + let {p1, p2, p3, p4} = this.parentQuads; + let points = p1.x + "," + p1.y + " " + + p2.x + "," + p2.y + " " + + p3.x + "," + p3.y + " " + + p4.x + "," + p4.y; + el.setAttribute("points", points); + isHighlighted = true; + } else if (isRelative) { + let xDelta = parseFloat(this.computedStyle.left); + let yDelta = parseFloat(this.computedStyle.top); + if (xDelta || yDelta) { + let {p1, p2, p3, p4} = this.currentQuads.margin[0]; + let points = (p1.x - xDelta) + "," + (p1.y - yDelta) + " " + + (p2.x - xDelta) + "," + (p2.y - yDelta) + " " + + (p3.x - xDelta) + "," + (p3.y - yDelta) + " " + + (p4.x - xDelta) + "," + (p4.y - yDelta); + el.setAttribute("points", points); + isHighlighted = true; + } + } + + if (isHighlighted) { + el.removeAttribute("hidden"); + } else { + el.setAttribute("hidden", "true"); + } + }, + + updateCurrentNode: function() { + let box = this.getElement("current-node"); + let {p1, p2, p3, p4} = this.currentQuads.margin[0]; + let attr = p1.x + "," + p1.y + " " + + p2.x + "," + p2.y + " " + + p3.x + "," + p3.y + " " + + p4.x + "," + p4.y; + box.setAttribute("points", attr); + box.removeAttribute("hidden"); + }, + + _hide: function() { + setIgnoreLayoutChanges(true); + + this.getElement("current-node").setAttribute("hidden", "true"); + this.getElement("offset-parent").setAttribute("hidden", "true"); + this.hideArrows(); + this.hideSize(); + + this.definedProperties.clear(); + + setIgnoreLayoutChanges(false, this.currentNode.ownerDocument.documentElement); + }, + + hideArrows: function() { + for (let side of GeoProp.SIDES) { + this.getElement("arrow-" + side).setAttribute("hidden", "true"); + this.getElement("label-" + side).setAttribute("hidden", "true"); + } + }, + + hideSize: function() { + this.getElement("label-size").setAttribute("hidden", "true"); + }, + + updateSize: function() { + this.hideSize(); + + let labels = []; + let width = this.definedProperties.get("width"); + let height = this.definedProperties.get("height"); + + if (width) { + labels.push("↔ " + width.cssRule.style.getPropertyValue("width")); + } + if (height) { + labels.push("↕ " + height.cssRule.style.getPropertyValue("height")); + } + + if (labels.length) { + let labelEl = this.getElement("label-size"); + let labelTextEl = this.getElement("label-text-size"); + + let {bounds} = this.currentQuads.margin[0]; + + labelEl.setAttribute("transform", "translate(" + + (bounds.left + bounds.width/2) + " " + + (bounds.top + bounds.height/2) + ")"); + labelEl.removeAttribute("hidden"); + labelTextEl.setTextContent(labels.join(" ")); + } + }, + + updateArrows: function() { + this.hideArrows(); + + // Position arrows always end at the node's margin box. + let marginBox = this.currentQuads.margin.bounds[0]; + // But size arrows are displayed in the box that corresponds to the current + // box-sizing. + let boxSizing = this.computedStyle.boxSizing.split("-")[0]; + let box = this.currentQuads[boxSizing].bounds[0]; + + // Position the side arrows which need to be visible. + // Arrows always start at the offsetParent edge, and end at the middle + // position of the node's margin edge. + // Note that for relative positioning, the offsetParent is considered to be + // the node itself, where it would have been originally. + // +------------------+----------------+ + // | offsetparent | top | + // | or viewport | | + // | +--------+--------+ | + // | | node | | + // +---------+ +-------+ + // | left | | right | + // | +--------+--------+ | + // | | bottom | + // +------------------+----------------+ + let getSideArrowStartPos = side => { + // In case an offsetParent exists and is highlighted. + if (this.parentQuads && this.parentQuads.length) { + return this.parentQuads[0].bounds[side]; + } + + // In case of relative positioning. + if (this.computedStyle.position === "relative") { + if (GeoProp.isInverted(side)) { + return marginBox[side] + parseFloat(this.computedStyle[side]); + } else { + return marginBox[side] - parseFloat(this.computedStyle[side]); + } + } + + // In case the element is positioned in the viewport. + if (GeoProp.isInverted(side)) { + return this.offsetParent.dimension[GeoProp.mainAxisSize(side)]; + } else { + return -1 * getWindow(this.currentNode)["scroll" + + GeoProp.axis(side).toUpperCase()]; + } + }; + + for (let side of GeoProp.SIDES) { + let sideProp = this.definedProperties.get(side); + if (!sideProp) { + continue; + } + + let mainAxisStartPos = getSideArrowStartPos(side); + let mainAxisEndPos = marginBox[side]; + let crossAxisPos = marginBox[GeoProp.crossAxisStart(side)] + + marginBox[GeoProp.crossAxisSize(side)] / 2; + + this.updateArrow(side, mainAxisStartPos, mainAxisEndPos, crossAxisPos, + sideProp.cssRule.style.getPropertyValue(side)); + } + }, + + updateArrow: function(side, mainStart, mainEnd, crossPos, labelValue) { + let arrowEl = this.getElement("arrow-" + side); + let labelEl = this.getElement("label-" + side); + let labelTextEl = this.getElement("label-text-" + side); + + // Position the arrow . + arrowEl.setAttribute(GeoProp.axis(side) + "1", mainStart); + arrowEl.setAttribute(GeoProp.crossAxis(side) + "1", crossPos); + arrowEl.setAttribute(GeoProp.axis(side) + "2", mainEnd); + arrowEl.setAttribute(GeoProp.crossAxis(side) + "2", crossPos); + arrowEl.removeAttribute("hidden"); + + // Position the label in the middle of the arrow (making sure it's + // not hidden below the fold). + let capitalize = str => str.substring(0, 1).toUpperCase() + str.substring(1); + let winMain = this.win["inner" + capitalize(GeoProp.mainAxisSize(side))] + let labelMain = mainStart + (mainEnd - mainStart) / 2; + if ((mainStart > 0 && mainStart < winMain) || + (mainEnd > 0 && mainEnd < winMain)) { + if (labelMain < GEOMETRY_LABEL_SIZE) { + labelMain = GEOMETRY_LABEL_SIZE; + } else if (labelMain > winMain - GEOMETRY_LABEL_SIZE) { + labelMain = winMain - GEOMETRY_LABEL_SIZE; + } + } + let labelCross = crossPos; + labelEl.setAttribute("transform", GeoProp.isHorizontal(side) + ? "translate(" + labelMain + " " + labelCross + ")" + : "translate(" + labelCross + " " + labelMain + ")"); + labelEl.removeAttribute("hidden"); + labelTextEl.setTextContent(labelValue); + } +}); +register(GeometryEditorHighlighter); +exports.GeometryEditorHighlighter = GeometryEditorHighlighter; + /** * The SimpleOutlineHighlighter is a class that has the same API than the * BoxModelHighlighter, but adds a pseudo-class on the target element itself @@ -1895,7 +2615,7 @@ SimpleOutlineHighlighter.prototype = { if (!this.currentNode || node !== this.currentNode) { this.hide(); this.currentNode = node; - installHelperSheet(node.ownerDocument.defaultView, SIMPLE_OUTLINE_SHEET); + installHelperSheet(getWindow(node), SIMPLE_OUTLINE_SHEET); DOMUtils.addPseudoClassLock(node, HIGHLIGHTED_PSEUDO_CLASS); } }, @@ -2017,6 +2737,64 @@ function createNode(win, options) { return node; } +/** + * Get the right target for listening to events on the page (while picking an + * element for instance). + * - On a firefox desktop content page: tabActor is a BrowserTabActor from + * which the browser property will give us a target we can use to listen to + * events, even in nested iframes. + * - On B2G: tabActor is a ContentActor which doesn't have a browser but + * since it overrides BrowserTabActor, it does get a browser property + * anyway, which points to its window object. + * - When using the Browser Toolbox (to inspect firefox desktop): tabActor is + * the RootActor, in which case, the window property can be used to listen + * to events + */ +function getPageListenerTarget(tabActor) { + return tabActor.isRootActor ? tabActor.window : tabActor.chromeEventHandler; +} + +/** + * Get a node's owner window. + */ +function getWindow(node) { + return node.ownerDocument.defaultView; +} + +/** + * Get the provided node's offsetParent dimensions. + * Returns an object with the {parent, dimension} properties. + * Note that the returned parent will be null if the offsetParent is the + * default, non-positioned, body or html node. + * + * node.offsetParent returns the nearest positioned ancestor but if it is + * non-positioned itself, we just return null to let consumers know the node is + * actually positioned relative to the viewport. + * + * @return {Object} + */ +function getOffsetParent(node) { + let offsetParent = node.offsetParent; + if (offsetParent && + CssLogic.getComputedStyle(offsetParent).position === "static") { + offsetParent = null; + } + + let width, height; + if (!offsetParent) { + height = getWindow(node).innerHeight; + width = getWindow(node).innerWidth; + } else { + height = offsetParent.offsetHeight; + width = offsetParent.offsetWidth; + } + + return { + element: offsetParent, + dimension: {width, height} + }; +} + XPCOMUtils.defineLazyGetter(this, "DOMUtils", function () { return Cc["@mozilla.org/inspector/dom-utils;1"].getService(Ci.inIDOMUtils) }); diff --git a/toolkit/devtools/server/tests/browser/browser.ini b/toolkit/devtools/server/tests/browser/browser.ini index c994ddb2e4..d75e7452ba 100644 --- a/toolkit/devtools/server/tests/browser/browser.ini +++ b/toolkit/devtools/server/tests/browser/browser.ini @@ -25,6 +25,16 @@ support-files = [browser_animation_actors_08.js] [browser_animation_actors_09.js] [browser_animation_actors_10.js] +[browser_animation_actors_11.js] +[browser_animation_actors_12.js] +[browser_animation_actors_13.js] +[browser_animation_actors_14.js] +[browser_canvasframe_helper_01.js] +[browser_canvasframe_helper_02.js] +[browser_canvasframe_helper_03.js] +[browser_canvasframe_helper_04.js] +[browser_canvasframe_helper_05.js] +[browser_canvasframe_helper_06.js] [browser_navigateEvents.js] [browser_storage_dynamic_windows.js] [browser_storage_listings.js] diff --git a/toolkit/devtools/server/tests/browser/browser_animation_actors_03.js b/toolkit/devtools/server/tests/browser/browser_animation_actors_03.js index 600d2dcae6..81cd174ef1 100644 --- a/toolkit/devtools/server/tests/browser/browser_animation_actors_03.js +++ b/toolkit/devtools/server/tests/browser/browser_animation_actors_03.js @@ -34,6 +34,7 @@ function* playerHasAnInitialState(walker, front) { ok("startTime" in player.initialState, "Player's state has startTime"); ok("currentTime" in player.initialState, "Player's state has currentTime"); ok("playState" in player.initialState, "Player's state has playState"); + ok("playbackRate" in player.initialState, "Player's state has playbackRate"); ok("name" in player.initialState, "Player's state has name"); ok("duration" in player.initialState, "Player's state has duration"); ok("delay" in player.initialState, "Player's state has delay"); @@ -50,15 +51,17 @@ function* playerStateIsCorrect(walker, front) { // null = infinite count is(state.iterationCount, null, "Iteration count is correct"); is(state.playState, "running", "PlayState is correct"); + is(state.playbackRate, 1, "PlaybackRate is correct"); info("Checking the state of the transition"); state = yield getAnimationStateForNode(walker, front, ".transition", 0); - is(state.name, "", "Transition has no name"); + is(state.name, "width", "Transition name matches transition property"); is(state.duration, 5000, "Transition duration is correct"); // transitions run only once is(state.iterationCount, 1, "Transition iteration count is correct"); is(state.playState, "running", "Transition playState is correct"); + is(state.playbackRate, 1, "Transition playbackRate is correct"); info("Checking the state of one of multiple animations on a node"); @@ -68,6 +71,7 @@ function* playerStateIsCorrect(walker, front) { is(state.duration, 1000, "The 2nd animation's duration is correct"); is(state.iterationCount, 5, "The 2nd animation's iteration count is correct"); is(state.playState, "running", "The 2nd animation's playState is correct"); + is(state.playbackRate, 1, "The 2nd animation's playbackRate is correct"); info("Checking the state of an animation with delay"); diff --git a/toolkit/devtools/server/tests/browser/browser_animation_actors_05.js b/toolkit/devtools/server/tests/browser/browser_animation_actors_05.js index 59f91a6e18..092c4bea5e 100644 --- a/toolkit/devtools/server/tests/browser/browser_animation_actors_05.js +++ b/toolkit/devtools/server/tests/browser/browser_animation_actors_05.js @@ -34,7 +34,7 @@ add_task(function*() { let onAllEventsReceived = new Promise(resolve => { let expected = 5; let previousState = player.initialState; - let onNewState = (e, state) => { + let onNewState = state => { ok(state.currentTime !== previousState.currentTime, "The time has changed since the last update"); expected --; diff --git a/toolkit/devtools/server/tests/browser/browser_animation_actors_11.js b/toolkit/devtools/server/tests/browser/browser_animation_actors_11.js new file mode 100644 index 0000000000..9172ebd93b --- /dev/null +++ b/toolkit/devtools/server/tests/browser/browser_animation_actors_11.js @@ -0,0 +1,49 @@ +/* vim: set ft=javascript ts=2 et sw=2 tw=80: */ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +// Check that a player's currentTime can be changed. + +const {AnimationsFront} = require("devtools/server/actors/animation"); +const {InspectorFront} = require("devtools/server/actors/inspector"); + +add_task(function*() { + let doc = yield addTab(MAIN_DOMAIN + "animation.html"); + + initDebuggerServer(); + let client = new DebuggerClient(DebuggerServer.connectPipe()); + let form = yield connectDebuggerClient(client); + let inspector = InspectorFront(client, form); + let walker = yield inspector.getWalker(); + let animations = AnimationsFront(client, form); + + info("Retrieve an animated node"); + let node = yield walker.querySelector(walker.rootNode, ".simple-animation"); + + info("Retrieve the animation player for the node"); + let [player] = yield animations.getAnimationPlayersForNode(node); + + ok(player.setCurrentTime, "Player has the setCurrentTime method"); + + info("Set the current time to currentTime + 5s"); + yield player.setCurrentTime(player.initialState.currentTime + 5000); + + // We're not really interested in making sure the currentTime is set precisely + // and doing this could lead to intermittents, so only check that the new time + // is now above the initial time. + let state = yield player.getCurrentState(); + ok(state.currentTime > player.initialState.currentTime, + "The currentTime was updated to +5s"); + + info("Set the current time to currentTime - 2s"); + yield player.setCurrentTime(state.currentTime - 2000); + + let newState = yield player.getCurrentState(); + ok(newState.currentTime < state.currentTime, + "The currentTime was updated to -2s"); + + yield closeDebuggerClient(client); + gBrowser.removeCurrentTab(); +}); diff --git a/toolkit/devtools/server/tests/browser/browser_animation_actors_12.js b/toolkit/devtools/server/tests/browser/browser_animation_actors_12.js new file mode 100644 index 0000000000..79a5137f07 --- /dev/null +++ b/toolkit/devtools/server/tests/browser/browser_animation_actors_12.js @@ -0,0 +1,46 @@ +/* vim: set ft=javascript ts=2 et sw=2 tw=80: */ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +// Check that a player's playbackRate can be changed. + +const {AnimationsFront} = require("devtools/server/actors/animation"); +const {InspectorFront} = require("devtools/server/actors/inspector"); + +add_task(function*() { + let doc = yield addTab(MAIN_DOMAIN + "animation.html"); + + initDebuggerServer(); + let client = new DebuggerClient(DebuggerServer.connectPipe()); + let form = yield connectDebuggerClient(client); + let inspector = InspectorFront(client, form); + let walker = yield inspector.getWalker(); + let animations = AnimationsFront(client, form); + + info("Retrieve an animated node"); + let node = yield walker.querySelector(walker.rootNode, ".simple-animation"); + + info("Retrieve the animation player for the node"); + let [player] = yield animations.getAnimationPlayersForNode(node); + + ok(player.setPlaybackRate, "Player has the setPlaybackRate method"); + + info("Change the rate to 10"); + yield player.setPlaybackRate(10); + + info("Query the state again"); + let state = yield player.getCurrentState(); + is(state.playbackRate, 10, "The playbackRate was updated"); + + info("Change the rate back to 1"); + yield player.setPlaybackRate(1); + + info("Query the state again"); + state = yield player.getCurrentState(); + is(state.playbackRate, 1, "The playbackRate was changed back"); + + yield closeDebuggerClient(client); + gBrowser.removeCurrentTab(); +}); diff --git a/toolkit/devtools/server/tests/browser/browser_animation_actors_13.js b/toolkit/devtools/server/tests/browser/browser_animation_actors_13.js new file mode 100644 index 0000000000..43d30f85c8 --- /dev/null +++ b/toolkit/devtools/server/tests/browser/browser_animation_actors_13.js @@ -0,0 +1,71 @@ +/* vim: set ft=javascript ts=2 et sw=2 tw=80: */ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +// Test that the AnimationsActor emits events about changed animations on a +// node after getAnimationPlayersForNode was called on that node. + +const {AnimationsFront} = require("devtools/server/actors/animation"); +const {InspectorFront} = require("devtools/server/actors/inspector"); + +add_task(function*() { + let doc = yield addTab(MAIN_DOMAIN + "animation.html"); + + initDebuggerServer(); + let client = new DebuggerClient(DebuggerServer.connectPipe()); + let form = yield connectDebuggerClient(client); + let inspector = InspectorFront(client, form); + let walker = yield inspector.getWalker(); + let animations = AnimationsFront(client, form); + + info("Retrieve a non-animated node"); + let node = yield walker.querySelector(walker.rootNode, ".not-animated"); + + info("Retrieve the animation player for the node"); + let players = yield animations.getAnimationPlayersForNode(node); + is(players.length, 0, "The node has no animation players"); + + info("Listen for new animations"); + let onMutations = once(animations, "mutations"); + + info("Add a couple of animation on the node"); + yield node.modifyAttributes([ + {attributeName: "class", newValue: "multiple-animations"} + ]); + let changes = yield onMutations; + + ok(true, "The mutations event was emitted"); + is(changes.length, 2, "There are 2 changes in the mutation event"); + ok(changes.every(({type}) => type === "added"), "Both changes are additions"); + is(changes[0].player.initialState.name, "move", + "The first added animation is 'move'"); + is(changes[1].player.initialState.name, "glow", + "The first added animation is 'glow'"); + + info("Store the 2 new players for comparing later"); + let p1 = changes[0].player; + let p2 = changes[1].player; + + info("Listen for removed animations"); + onMutations = once(animations, "mutations"); + + info("Remove the animation css class on the node"); + yield node.modifyAttributes([ + {attributeName: "class", newValue: "not-animated"} + ]); + + changes = yield onMutations; + + ok(true, "The mutations event was emitted"); + is(changes.length, 2, "There are 2 changes in the mutation event"); + ok(changes.every(({type}) => type === "removed"), "Both changes are removals"); + ok(changes[0].player === p1 || changes[0].player === p2, + "The first removed player was one of the previously added players"); + ok(changes[1].player === p1 || changes[1].player === p2, + "The second removed player was one of the previously added players"); + + yield closeDebuggerClient(client); + gBrowser.removeCurrentTab(); +}); diff --git a/toolkit/devtools/server/tests/browser/browser_animation_actors_14.js b/toolkit/devtools/server/tests/browser/browser_animation_actors_14.js new file mode 100644 index 0000000000..5155306d93 --- /dev/null +++ b/toolkit/devtools/server/tests/browser/browser_animation_actors_14.js @@ -0,0 +1,60 @@ +/* vim: set ft=javascript ts=2 et sw=2 tw=80: */ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +// Test that the AnimationsActor doesn't report finished animations as removed. +// Indeed, animations that only have the "finished" playState can be modified +// still, so we want the AnimationsActor to preserve the corresponding +// AnimationPlayerActor. + +const {AnimationsFront} = require("devtools/server/actors/animation"); +const {InspectorFront} = require("devtools/server/actors/inspector"); + +add_task(function*() { + let doc = yield addTab(MAIN_DOMAIN + "animation.html"); + + initDebuggerServer(); + let client = new DebuggerClient(DebuggerServer.connectPipe()); + let form = yield connectDebuggerClient(client); + let inspector = InspectorFront(client, form); + let walker = yield inspector.getWalker(); + let animations = AnimationsFront(client, form); + + info("Retrieve a non-animated node"); + let node = yield walker.querySelector(walker.rootNode, ".not-animated"); + + info("Retrieve the animation player for the node"); + let players = yield animations.getAnimationPlayersForNode(node); + is(players.length, 0, "The node has no animation players"); + + info("Listen for new animations"); + let reportedMutations = []; + function onMutations(mutations) { + reportedMutations = [...reportedMutations, ...mutations]; + } + animations.on("mutations", onMutations); + + info("Add a short animation on the node"); + yield node.modifyAttributes([ + {attributeName: "class", newValue: "short-animation"} + ]); + + info("Wait for longer than the animation's duration"); + yield wait(2000); + + is(reportedMutations.length, 1, "Only one mutation was reported"); + is(reportedMutations[0].type, "added", "The mutation was an addition"); + + animations.off("mutations", onMutations); + + yield closeDebuggerClient(client); + gBrowser.removeCurrentTab(); +}); + +function wait(ms) { + return new Promise(resolve => { + setTimeout(resolve, ms); + }); +} diff --git a/toolkit/devtools/server/tests/browser/browser_canvasframe_helper_01.js b/toolkit/devtools/server/tests/browser/browser_canvasframe_helper_01.js new file mode 100644 index 0000000000..2b765a9efe --- /dev/null +++ b/toolkit/devtools/server/tests/browser/browser_canvasframe_helper_01.js @@ -0,0 +1,82 @@ +/* vim: set ft=javascript ts=2 et sw=2 tw=80: */ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +// Simple CanvasFrameAnonymousContentHelper tests. + +// This makes sure the 'domnode' protocol actor type is known when importing +// highlighter. +require("devtools/server/actors/inspector"); +const {CanvasFrameAnonymousContentHelper} = require("devtools/server/actors/highlighter"); +const TEST_URL = "data:text/html;charset=utf-8,CanvasFrameAnonymousContentHelper test"; + +add_task(function*() { + let doc = yield addTab(TEST_URL); + + let nodeBuilder = () => { + let root = doc.createElement("div"); + let child = doc.createElement("div"); + child.style = "width:200px;height:200px;background:red;"; + child.id = "child-element"; + child.className = "child-element"; + child.textContent = "test element"; + root.appendChild(child); + return root; + }; + + info("Building the helper"); + let helper = new CanvasFrameAnonymousContentHelper( + getMockTabActor(doc.defaultView), nodeBuilder); + + ok(helper.content instanceof AnonymousContent, + "The helper owns the AnonymousContent object"); + ok(helper.getTextContentForElement, + "The helper has the getTextContentForElement method"); + ok(helper.setTextContentForElement, + "The helper has the setTextContentForElement method"); + ok(helper.setAttributeForElement, + "The helper has the setAttributeForElement method"); + ok(helper.getAttributeForElement, + "The helper has the getAttributeForElement method"); + ok(helper.removeAttributeForElement, + "The helper has the removeAttributeForElement method"); + ok(helper.addEventListenerForElement, + "The helper has the addEventListenerForElement method"); + ok(helper.removeEventListenerForElement, + "The helper has the removeEventListenerForElement method"); + ok(helper.getElement, + "The helper has the getElement method"); + ok(helper.scaleRootElement, + "The helper has the scaleRootElement method"); + + is(helper.getTextContentForElement("child-element"), "test element", + "The text content was retrieve correctly"); + is(helper.getAttributeForElement("child-element", "id"), "child-element", + "The ID attribute was retrieve correctly"); + is(helper.getAttributeForElement("child-element", "class"), "child-element", + "The class attribute was retrieve correctly"); + + let el = helper.getElement("child-element"); + ok(el, "The DOMNode-like element was created"); + + is(el.getTextContent(), "test element", + "The text content was retrieve correctly"); + is(el.getAttribute("id"), "child-element", + "The ID attribute was retrieve correctly"); + is(el.getAttribute("class"), "child-element", + "The class attribute was retrieve correctly"); + + info("Destroying the helper"); + helper.destroy(); + + ok(!helper.getTextContentForElement("child-element"), + "No text content was retrieved after the helper was destroyed"); + ok(!helper.getAttributeForElement("child-element", "id"), + "No ID attribute was retrieved after the helper was destroyed"); + ok(!helper.getAttributeForElement("child-element", "class"), + "No class attribute was retrieved after the helper was destroyed"); + + gBrowser.removeCurrentTab(); +}); diff --git a/toolkit/devtools/server/tests/browser/browser_canvasframe_helper_02.js b/toolkit/devtools/server/tests/browser/browser_canvasframe_helper_02.js new file mode 100644 index 0000000000..e0ce0956c6 --- /dev/null +++ b/toolkit/devtools/server/tests/browser/browser_canvasframe_helper_02.js @@ -0,0 +1,38 @@ +/* vim: set ft=javascript ts=2 et sw=2 tw=80: */ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +// Test that the CanvasFrameAnonymousContentHelper does not insert content in +// XUL windows. + +// This makes sure the 'domnode' protocol actor type is known when importing +// highlighter. +require("devtools/server/actors/inspector"); +const {CanvasFrameAnonymousContentHelper} = require("devtools/server/actors/highlighter"); + +add_task(function*() { + let doc = yield addTab("about:preferences"); + + let nodeBuilder = () => { + let root = doc.createElement("div"); + let child = doc.createElement("div"); + child.style = "width:200px;height:200px;background:red;"; + child.id = "child-element"; + child.className = "child-element"; + child.textContent = "test element"; + root.appendChild(child); + return root; + }; + + info("Building the helper"); + let helper = new CanvasFrameAnonymousContentHelper( + getMockTabActor(doc.defaultView), nodeBuilder); + + ok(!helper.content, "The AnonymousContent was not inserted in the window"); + ok(!helper.getTextContentForElement("child-element"), + "No text content is returned"); + + gBrowser.removeCurrentTab(); +}); diff --git a/toolkit/devtools/server/tests/browser/browser_canvasframe_helper_03.js b/toolkit/devtools/server/tests/browser/browser_canvasframe_helper_03.js new file mode 100644 index 0000000000..27add7787d --- /dev/null +++ b/toolkit/devtools/server/tests/browser/browser_canvasframe_helper_03.js @@ -0,0 +1,93 @@ +/* vim: set ft=javascript ts=2 et sw=2 tw=80: */ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +// Test the CanvasFrameAnonymousContentHelper event handling mechanism. + +// This makes sure the 'domnode' protocol actor type is known when importing +// highlighter. +require("devtools/server/actors/inspector"); +const {CanvasFrameAnonymousContentHelper} = require("devtools/server/actors/highlighter"); +const TEST_URL = "data:text/html;charset=utf-8,CanvasFrameAnonymousContentHelper test"; + +add_task(function*() { + let doc = yield addTab(TEST_URL); + + let nodeBuilder = () => { + let root = doc.createElement("div"); + let child = doc.createElement("div"); + child.style = "pointer-events:auto;width:200px;height:200px;background:red;"; + child.id = "child-element"; + child.className = "child-element"; + root.appendChild(child); + return root; + }; + + info("Building the helper"); + let helper = new CanvasFrameAnonymousContentHelper( + getMockTabActor(doc.defaultView), nodeBuilder); + + let el = helper.getElement("child-element"); + + info("Adding an event listener on the inserted element"); + let mouseDownHandled = 0; + function onMouseDown(e, id) { + is(id, "child-element", "The mousedown event was triggered on the element"); + ok(!e.originalTarget, "The originalTarget property isn't available"); + mouseDownHandled ++; + } + el.addEventListener("mousedown", onMouseDown); + + info("Synthesizing an event on the inserted element"); + let onDocMouseDown = once(doc, "mousedown"); + synthesizeMouseDown(100, 100, doc.defaultView); + yield onDocMouseDown; + + is(mouseDownHandled, 1, "The mousedown event was handled once on the element"); + + info("Synthesizing an event somewhere else"); + onDocMouseDown = once(doc, "mousedown"); + synthesizeMouseDown(400, 400, doc.defaultView); + yield onDocMouseDown; + + is(mouseDownHandled, 1, "The mousedown event was not handled on the element"); + + info("Removing the event listener"); + el.removeEventListener("mousedown", onMouseDown); + + info("Synthesizing another event after the listener has been removed"); + // Using a document event listener to know when the event has been synthesized. + onDocMouseDown = once(doc, "mousedown"); + synthesizeMouseDown(100, 100, doc.defaultView); + yield onDocMouseDown; + + is(mouseDownHandled, 1, + "The mousedown event hasn't been handled after the listener was removed"); + + info("Adding again the event listener"); + el.addEventListener("mousedown", onMouseDown); + + info("Destroying the helper"); + helper.destroy(); + + info("Synthesizing another event after the helper has been destroyed"); + // Using a document event listener to know when the event has been synthesized. + onDocMouseDown = once(doc, "mousedown"); + synthesizeMouseDown(100, 100, doc.defaultView); + yield onDocMouseDown; + + is(mouseDownHandled, 1, + "The mousedown event hasn't been handled after the helper was destroyed"); + + gBrowser.removeCurrentTab(); +}); + +function synthesizeMouseDown(x, y, win) { + // We need to make sure the inserted anonymous content can be targeted by the + // event right after having been inserted, and so we need to force a sync + // reflow. + let forceReflow = win.document.documentElement.offsetWidth; + EventUtils.synthesizeMouseAtPoint(x, y, {type: "mousedown"}, win); +} diff --git a/toolkit/devtools/server/tests/browser/browser_canvasframe_helper_04.js b/toolkit/devtools/server/tests/browser/browser_canvasframe_helper_04.js new file mode 100644 index 0000000000..c04c3b7dce --- /dev/null +++ b/toolkit/devtools/server/tests/browser/browser_canvasframe_helper_04.js @@ -0,0 +1,93 @@ +/* vim: set ft=javascript ts=2 et sw=2 tw=80: */ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +// Test the CanvasFrameAnonymousContentHelper re-inserts the content when the +// page reloads. + +// This makes sure the 'domnode' protocol actor type is known when importing +// highlighter. +require("devtools/server/actors/inspector"); +const {CanvasFrameAnonymousContentHelper} = require("devtools/server/actors/highlighter"); +const events = require("sdk/event/core"); +const TEST_URL_1 = "data:text/html;charset=utf-8,CanvasFrameAnonymousContentHelper test 1"; +const TEST_URL_2 = "data:text/html;charset=utf-8,CanvasFrameAnonymousContentHelper test 2"; + +add_task(function*() { + let doc = yield addTab(TEST_URL_2); + + let tabActor = getMockTabActor(doc.defaultView); + + let nodeBuilder = () => { + let root = doc.createElement("div"); + let child = doc.createElement("div"); + child.style = "pointer-events:auto;width:200px;height:200px;background:red;"; + child.id = "child-element"; + child.className = "child-element"; + child.textContent= "test content"; + root.appendChild(child); + return root; + }; + + info("Building the helper"); + let helper = new CanvasFrameAnonymousContentHelper(tabActor, nodeBuilder); + + info("Get an element from the helper"); + let el = helper.getElement("child-element"); + + info("Try to access the element"); + is(el.getAttribute("class"), "child-element", + "The attribute is correct before navigation"); + is(el.getTextContent(), "test content", + "The text content is correct before navigation"); + + info("Add an event listener on the element"); + let mouseDownHandled = 0; + function onMouseDown(e, id) { + is(id, "child-element", "The mousedown event was triggered on the element"); + mouseDownHandled ++; + } + el.addEventListener("mousedown", onMouseDown); + + info("Synthesizing an event on the element"); + let onDocMouseDown = once(doc, "mousedown"); + synthesizeMouseDown(100, 100, doc.defaultView); + yield onDocMouseDown; + is(mouseDownHandled, 1, "The mousedown event was handled once before navigation"); + + info("Navigating to a new page"); + let loaded = once(gBrowser.selectedBrowser, "load", true); + content.location = TEST_URL_2; + yield loaded; + doc = gBrowser.selectedBrowser.contentWindow.document; + + info("And faking the 'navigate' event on the tabActor"); + events.emit(tabActor, "navigate", tabActor); + + info("Try to access the element again"); + is(el.getAttribute("class"), "child-element", + "The attribute is correct after navigation"); + is(el.getTextContent(), "test content", + "The text content is correct after navigation"); + + info("Synthesizing an event on the element again"); + onDocMouseDown = once(doc, "mousedown"); + synthesizeMouseDown(100, 100, doc.defaultView); + yield onDocMouseDown; + is(mouseDownHandled, 1, "The mousedown event was not handled after navigation"); + + info("Destroying the helper"); + helper.destroy(); + + gBrowser.removeCurrentTab(); +}); + +function synthesizeMouseDown(x, y, win) { + // We need to make sure the inserted anonymous content can be targeted by the + // event right after having been inserted, and so we need to force a sync + // reflow. + let forceReflow = win.document.documentElement.offsetWidth; + EventUtils.synthesizeMouseAtPoint(x, y, {type: "mousedown"}, win); +} diff --git a/toolkit/devtools/server/tests/browser/browser_canvasframe_helper_05.js b/toolkit/devtools/server/tests/browser/browser_canvasframe_helper_05.js new file mode 100644 index 0000000000..277ba8b2b0 --- /dev/null +++ b/toolkit/devtools/server/tests/browser/browser_canvasframe_helper_05.js @@ -0,0 +1,101 @@ +/* vim: set ft=javascript ts=2 et sw=2 tw=80: */ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +// Test some edge cases of the CanvasFrameAnonymousContentHelper event handling +// mechanism. + +// This makes sure the 'domnode' protocol actor type is known when importing +// highlighter. +require("devtools/server/actors/inspector"); +const {CanvasFrameAnonymousContentHelper} = require("devtools/server/actors/highlighter"); +const TEST_URL = "data:text/html;charset=utf-8,CanvasFrameAnonymousContentHelper test"; + +add_task(function*() { + let doc = yield addTab(TEST_URL); + + let nodeBuilder = () => { + let root = doc.createElement("div"); + + let parent = doc.createElement("div"); + parent.style = "pointer-events:auto;width:300px;height:300px;background:yellow;"; + parent.id = "parent-element"; + root.appendChild(parent); + + let child = doc.createElement("div"); + child.style = "pointer-events:auto;width:200px;height:200px;background:red;"; + child.id = "child-element"; + parent.appendChild(child); + + return root; + }; + + info("Building the helper"); + let helper = new CanvasFrameAnonymousContentHelper( + getMockTabActor(doc.defaultView), nodeBuilder); + + info("Getting the parent and child elements"); + let parentEl = helper.getElement("parent-element"); + let childEl = helper.getElement("child-element"); + + info("Adding an event listener on both elements"); + let mouseDownHandled = []; + function onMouseDown(e, id) { + mouseDownHandled.push(id); + } + parentEl.addEventListener("mousedown", onMouseDown); + childEl.addEventListener("mousedown", onMouseDown); + + info("Synthesizing an event on the child element"); + let onDocMouseDown = once(doc, "mousedown"); + synthesizeMouseDown(100, 100, doc.defaultView); + yield onDocMouseDown; + + is(mouseDownHandled.length, 2, "The mousedown event was handled twice"); + is(mouseDownHandled[0], "child-element", + "The mousedown event was handled on the child element"); + is(mouseDownHandled[1], "parent-element", + "The mousedown event was handled on the parent element"); + + info("Synthesizing an event on the parent, outside of the child element"); + mouseDownHandled = []; + onDocMouseDown = once(doc, "mousedown"); + synthesizeMouseDown(250, 250, doc.defaultView); + yield onDocMouseDown; + + is(mouseDownHandled.length, 1, "The mousedown event was handled only once"); + is(mouseDownHandled[0], "parent-element", + "The mousedown event was handled on the parent element"); + + info("Removing the event listener"); + parentEl.removeEventListener("mousedown", onMouseDown); + childEl.removeEventListener("mousedown", onMouseDown); + + info("Adding an event listener on the parent element only"); + mouseDownHandled = []; + parentEl.addEventListener("mousedown", onMouseDown); + + info("Synthesizing an event on the child element"); + onDocMouseDown = once(doc, "mousedown"); + synthesizeMouseDown(100, 100, doc.defaultView); + yield onDocMouseDown; + + is(mouseDownHandled.length, 1, "The mousedown event was handled once"); + is(mouseDownHandled[0], "parent-element", + "The mousedown event did bubble to the parent element"); + + info("Removing the parent listener"); + parentEl.removeEventListener("mousedown", onMouseDown); + + gBrowser.removeCurrentTab(); +}); + +function synthesizeMouseDown(x, y, win) { + // We need to make sure the inserted anonymous content can be targeted by the + // event right after having been inserted, and so we need to force a sync + // reflow. + let forceReflow = win.document.documentElement.offsetWidth; + EventUtils.synthesizeMouseAtPoint(x, y, {type: "mousedown"}, win); +} diff --git a/toolkit/devtools/server/tests/browser/browser_canvasframe_helper_06.js b/toolkit/devtools/server/tests/browser/browser_canvasframe_helper_06.js new file mode 100644 index 0000000000..2a857e7eef --- /dev/null +++ b/toolkit/devtools/server/tests/browser/browser_canvasframe_helper_06.js @@ -0,0 +1,89 @@ +/* vim: set ft=javascript ts=2 et sw=2 tw=80: */ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +// Test support for event propagation stop in the +// CanvasFrameAnonymousContentHelper event handling mechanism. + +// This makes sure the 'domnode' protocol actor type is known when importing +// highlighter. +require("devtools/server/actors/inspector"); +const {CanvasFrameAnonymousContentHelper} = require("devtools/server/actors/highlighter"); +const TEST_URL = "data:text/html;charset=utf-8,CanvasFrameAnonymousContentHelper test"; + +add_task(function*() { + let doc = yield addTab(TEST_URL); + + let nodeBuilder = () => { + let root = doc.createElement("div"); + + let parent = doc.createElement("div"); + parent.style = "pointer-events:auto;width:300px;height:300px;background:yellow;"; + parent.id = "parent-element"; + root.appendChild(parent); + + let child = doc.createElement("div"); + child.style = "pointer-events:auto;width:200px;height:200px;background:red;"; + child.id = "child-element"; + parent.appendChild(child); + + return root; + }; + + info("Building the helper"); + let helper = new CanvasFrameAnonymousContentHelper( + getMockTabActor(doc.defaultView), nodeBuilder); + + info("Getting the parent and child elements"); + let parentEl = helper.getElement("parent-element"); + let childEl = helper.getElement("child-element"); + + info("Adding an event listener on both elements"); + let mouseDownHandled = []; + + function onParentMouseDown(e, id) { + mouseDownHandled.push(id); + } + parentEl.addEventListener("mousedown", onParentMouseDown); + + function onChildMouseDown(e, id) { + mouseDownHandled.push(id); + e.stopPropagation(); + } + childEl.addEventListener("mousedown", onChildMouseDown); + + info("Synthesizing an event on the child element"); + let onDocMouseDown = once(doc, "mousedown"); + synthesizeMouseDown(100, 100, doc.defaultView); + yield onDocMouseDown; + + is(mouseDownHandled.length, 1, "The mousedown event was handled only once"); + is(mouseDownHandled[0], "child-element", + "The mousedown event was handled on the child element"); + + info("Synthesizing an event on the parent, outside of the child element"); + mouseDownHandled = []; + onDocMouseDown = once(doc, "mousedown"); + synthesizeMouseDown(250, 250, doc.defaultView); + yield onDocMouseDown; + + is(mouseDownHandled.length, 1, "The mousedown event was handled only once"); + is(mouseDownHandled[0], "parent-element", + "The mousedown event was handled on the parent element"); + + info("Removing the event listener"); + parentEl.removeEventListener("mousedown", onParentMouseDown); + childEl.removeEventListener("mousedown", onChildMouseDown); + + gBrowser.removeCurrentTab(); +}); + +function synthesizeMouseDown(x, y, win) { + // We need to make sure the inserted anonymous content can be targeted by the + // event right after having been inserted, and so we need to force a sync + // reflow. + let forceReflow = win.document.documentElement.offsetWidth; + EventUtils.synthesizeMouseAtPoint(x, y, {type: "mousedown"}, win); +} diff --git a/toolkit/devtools/server/tests/browser/head.js b/toolkit/devtools/server/tests/browser/head.js index 774d1f66f2..f2a927d51f 100644 --- a/toolkit/devtools/server/tests/browser/head.js +++ b/toolkit/devtools/server/tests/browser/head.js @@ -118,6 +118,20 @@ function forceCollections() { Cu.forceShrinkingGC(); } +/** + * Get a mock tabActor from a given window. + * This is sometimes useful to test actors or classes that use the tabActor in + * isolation. + * @param {DOMWindow} win + * @return {Object} + */ +function getMockTabActor(win) { + return { + window: win, + isRootActor: true + }; +} + registerCleanupFunction(function tearDown() { while (gBrowser.tabs.length > 1) { gBrowser.removeCurrentTab(); diff --git a/toolkit/devtools/shared/frame-script-utils.js b/toolkit/devtools/shared/frame-script-utils.js index a2236a715d..108a52945d 100644 --- a/toolkit/devtools/shared/frame-script-utils.js +++ b/toolkit/devtools/shared/frame-script-utils.js @@ -112,3 +112,69 @@ addMessageListener("devtools:test:eval", function ({ data }) { addEventListener("load", function() { sendAsyncMessage("devtools:test:load"); }, true); + +/** + * Set a given style property value on a node. + * @param {Object} data + * - {String} selector The CSS selector to get the node (can be a "super" + * selector). + * - {String} propertyName The name of the property to set. + * - {String} propertyValue The value for the property. + */ +addMessageListener("devtools:test:setStyle", function(msg) { + let {selector, propertyName, propertyValue} = msg.data; + let node = superQuerySelector(selector); + if (!node) { + return; + } + + node.style[propertyName] = propertyValue; + + sendAsyncMessage("devtools:test:setStyle"); +}); + +/** + * Set a given attribute value on a node. + * @param {Object} data + * - {String} selector The CSS selector to get the node (can be a "super" + * selector). + * - {String} attributeName The name of the attribute to set. + * - {String} attributeValue The value for the attribute. + */ +addMessageListener("devtools:test:setAttribute", function(msg) { + let {selector, attributeName, attributeValue} = msg.data; + let node = superQuerySelector(selector); + if (!node) { + return; + } + + node.setAttribute(attributeName, attributeValue); + + sendAsyncMessage("devtools:test:setAttribute"); +}); + +/** + * Like document.querySelector but can go into iframes too. + * ".container iframe || .sub-container div" will first try to find the node + * matched by ".container iframe" in the root document, then try to get the + * content document inside it, and then try to match ".sub-container div" inside + * this document. + * Any selector coming before the || separator *MUST* match a frame node. + * @param {String} superSelector. + * @return {DOMNode} The node, or null if not found. + */ +function superQuerySelector(superSelector, root=content.document) { + let frameIndex = superSelector.indexOf("||"); + if (frameIndex === -1) { + return root.querySelector(superSelector); + } else { + let rootSelector = superSelector.substring(0, frameIndex).trim(); + let childSelector = superSelector.substring(frameIndex+2).trim(); + root = root.querySelector(rootSelector); + if (!root || !root.contentWindow) { + return null; + } + + return superQuerySelector(childSelector, root.contentWindow.document); + } +} diff --git a/toolkit/themes/linux/global/jar.mn b/toolkit/themes/linux/global/jar.mn index 3d8043aec5..a45dcfab5f 100644 --- a/toolkit/themes/linux/global/jar.mn +++ b/toolkit/themes/linux/global/jar.mn @@ -129,6 +129,10 @@ toolkit.jar: + skin/classic/global/devtools/debugger-pause@2x.png (../../shared/devtools/images/debugger-pause@2x.png) + skin/classic/global/devtools/debugger-play.png (../../shared/devtools/images/debugger-play.png) + skin/classic/global/devtools/debugger-play@2x.png (../../shared/devtools/images/debugger-play@2x.png) ++ skin/classic/global/devtools/fast-forward.png (../../shared/devtools/images/fast-forward.png) ++ skin/classic/global/devtools/fast-forward@2x.png (../../shared/devtools/images/fast-forward@2x.png) ++ skin/classic/global/devtools/rewind.png (../../shared/devtools/images/rewind.png) ++ skin/classic/global/devtools/rewind@2x.png (../../shared/devtools/images/rewind@2x.png) + skin/classic/global/devtools/debugger-step-in.png (../../shared/devtools/images/debugger-step-in.png) + skin/classic/global/devtools/debugger-step-in@2x.png (../../shared/devtools/images/debugger-step-in@2x.png) + skin/classic/global/devtools/debugger-step-out.png (../../shared/devtools/images/debugger-step-out.png) diff --git a/toolkit/themes/osx/global/jar.mn b/toolkit/themes/osx/global/jar.mn index 0de3eb69ff..41844e33ae 100644 --- a/toolkit/themes/osx/global/jar.mn +++ b/toolkit/themes/osx/global/jar.mn @@ -179,6 +179,10 @@ toolkit.jar: skin/classic/global/devtools/debugger-pause@2x.png (../../shared/devtools/images/debugger-pause@2x.png) skin/classic/global/devtools/debugger-play.png (../../shared/devtools/images/debugger-play.png) skin/classic/global/devtools/debugger-play@2x.png (../../shared/devtools/images/debugger-play@2x.png) + skin/classic/global/devtools/fast-forward.png (../../shared/devtools/images/fast-forward.png) + skin/classic/global/devtools/fast-forward@2x.png (../../shared/devtools/images/fast-forward@2x.png) + skin/classic/global/devtools/rewind.png (../../shared/devtools/images/rewind.png) + skin/classic/global/devtools/rewind@2x.png (../../shared/devtools/images/rewind@2x.png) skin/classic/global/devtools/debugger-step-in.png (../../shared/devtools/images/debugger-step-in.png) skin/classic/global/devtools/debugger-step-in@2x.png (../../shared/devtools/images/debugger-step-in@2x.png) skin/classic/global/devtools/debugger-step-out.png (../../shared/devtools/images/debugger-step-out.png) diff --git a/toolkit/themes/shared/devtools/animationinspector.css b/toolkit/themes/shared/devtools/animationinspector.css index a7c74147cd..e00ba86174 100644 --- a/toolkit/themes/shared/devtools/animationinspector.css +++ b/toolkit/themes/shared/devtools/animationinspector.css @@ -135,7 +135,6 @@ body { } .timeline .playback-controls { - width: 50px; display: flex; flex-direction: row; } @@ -147,8 +146,6 @@ body { border-width: 0 1px 0 0; } -/* Play/pause button */ - .timeline .toggle::before { background-image: url(debugger-pause.png); } @@ -158,6 +155,14 @@ body { background-image: url(debugger-play.png); } +.timeline .ff::before { + background-image: url(fast-forward.png); +} + +.timeline .rw::before { + background-image: url(rewind.png); +} + @media (min-resolution: 2dppx) { .timeline .toggle::before { background-image: url(debugger-pause@2x.png); @@ -167,6 +172,14 @@ body { .finished .timeline .toggle::before { background-image: url(debugger-play@2x.png); } + + .timeline .ff::before { + background-image: url(fast-forward@2x.png); + } + + .timeline .rw::before { + background-image: url(rewind@2x.png); + } } /* Slider (input type range) container */ diff --git a/toolkit/themes/shared/devtools/images/fast-forward.png b/toolkit/themes/shared/devtools/images/fast-forward.png new file mode 100644 index 0000000000..f2c6c52b9e Binary files /dev/null and b/toolkit/themes/shared/devtools/images/fast-forward.png differ diff --git a/toolkit/themes/shared/devtools/images/fast-forward@2x.png b/toolkit/themes/shared/devtools/images/fast-forward@2x.png new file mode 100644 index 0000000000..4c3cf88fb9 Binary files /dev/null and b/toolkit/themes/shared/devtools/images/fast-forward@2x.png differ diff --git a/toolkit/themes/shared/devtools/images/rewind.png b/toolkit/themes/shared/devtools/images/rewind.png new file mode 100644 index 0000000000..098e256ab8 Binary files /dev/null and b/toolkit/themes/shared/devtools/images/rewind.png differ diff --git a/toolkit/themes/shared/devtools/images/rewind@2x.png b/toolkit/themes/shared/devtools/images/rewind@2x.png new file mode 100644 index 0000000000..eaac45d943 Binary files /dev/null and b/toolkit/themes/shared/devtools/images/rewind@2x.png differ diff --git a/toolkit/themes/windows/global/jar.mn b/toolkit/themes/windows/global/jar.mn index e4176d1767..f1375e2456 100644 --- a/toolkit/themes/windows/global/jar.mn +++ b/toolkit/themes/windows/global/jar.mn @@ -182,6 +182,10 @@ toolkit.jar: skin/classic/global/devtools/debugger-pause@2x.png (../../shared/devtools/images/debugger-pause@2x.png) skin/classic/global/devtools/debugger-play.png (../../shared/devtools/images/debugger-play.png) skin/classic/global/devtools/debugger-play@2x.png (../../shared/devtools/images/debugger-play@2x.png) + skin/classic/global/devtools/fast-forward.png (../../shared/devtools/images/fast-forward.png) + skin/classic/global/devtools/fast-forward@2x.png (../../shared/devtools/images/fast-forward@2x.png) + skin/classic/global/devtools/rewind.png (../../shared/devtools/images/rewind.png) + skin/classic/global/devtools/rewind@2x.png (../../shared/devtools/images/rewind@2x.png) skin/classic/global/devtools/debugger-step-in.png (../../shared/devtools/images/debugger-step-in.png) skin/classic/global/devtools/debugger-step-in@2x.png (../../shared/devtools/images/debugger-step-in@2x.png) skin/classic/global/devtools/debugger-step-out.png (../../shared/devtools/images/debugger-step-out.png) diff --git a/tools/profiler/GeckoProfilerImpl.h b/tools/profiler/GeckoProfilerImpl.h index 15a758a9d3..a5d7437418 100644 --- a/tools/profiler/GeckoProfilerImpl.h +++ b/tools/profiler/GeckoProfilerImpl.h @@ -34,7 +34,6 @@ #endif class TableTicker; -class JSCustomObject; namespace mozilla { class TimeStamp; diff --git a/tools/profiler/PseudoStack.h b/tools/profiler/PseudoStack.h index ac69ad6270..011467f2f0 100644 --- a/tools/profiler/PseudoStack.h +++ b/tools/profiler/PseudoStack.h @@ -75,8 +75,6 @@ class ProfilerMarkerPayload; template class ProfilerLinkedList; class JSStreamWriter; -class JSCustomArray; -class ThreadProfile; class ProfilerMarker { friend class ProfilerLinkedList; public: diff --git a/view/nsView.cpp b/view/nsView.cpp index e5280e6834..b7c2ef84fc 100644 --- a/view/nsView.cpp +++ b/view/nsView.cpp @@ -772,9 +772,9 @@ void nsView::List(FILE* out, int32_t aIndent) const nscoord p2a = mViewManager->AppUnitsPerDevPixel(); nsIntRect rect; mWindow->GetClientBounds(rect); - nsRect windowBounds = rect.ToAppUnits(p2a); + nsRect windowBounds = ToAppUnits(rect, p2a); mWindow->GetBounds(rect); - nsRect nonclientBounds = rect.ToAppUnits(p2a); + nsRect nonclientBounds = ToAppUnits(rect, p2a); nsrefcnt widgetRefCnt = mWindow.get()->AddRef() - 1; mWindow.get()->Release(); int32_t Z = mWindow->GetZIndex(); diff --git a/view/nsViewManager.cpp b/view/nsViewManager.cpp index e253a61c3a..db60dae177 100644 --- a/view/nsViewManager.cpp +++ b/view/nsViewManager.cpp @@ -473,7 +473,7 @@ void nsViewManager::FlushDirtyRegionToWidget(nsView* aView) // If we draw the frame counter we need to make sure we invalidate the area // for it to make it on screen if (gfxPrefs::DrawFrameCounter()) { - nsRect counterBounds = gfxPlatform::FrameCounterBounds().ToAppUnits(AppUnitsPerDevPixel()); + nsRect counterBounds = ToAppUnits(gfxPlatform::FrameCounterBounds(), AppUnitsPerDevPixel()); r = r.Or(r, counterBounds); } @@ -568,9 +568,8 @@ nsViewManager::InvalidateWidgetArea(nsView *aWidgetView, nsTArray clipRects; childWidget->GetWindowClipRegion(&clipRects); for (uint32_t i = 0; i < clipRects.Length(); ++i) { - nsRect rr = (clipRects[i] + bounds.TopLeft()). - ToAppUnits(AppUnitsPerDevPixel()); - children.Or(children, rr - aWidgetView->ViewToWidgetOffset()); + nsRect rr = ToAppUnits(clipRects[i] + bounds.TopLeft(), AppUnitsPerDevPixel()); + children.Or(children, rr - aWidgetView->ViewToWidgetOffset()); children.SimplifyInward(20); } #endif diff --git a/widget/PuppetWidget.cpp b/widget/PuppetWidget.cpp index 17f36cd7cf..d79e919350 100644 --- a/widget/PuppetWidget.cpp +++ b/widget/PuppetWidget.cpp @@ -1109,7 +1109,7 @@ PuppetWidget::GetChromeDimensions() NS_WARNING("PuppetWidget without Tab does not have chrome information."); return nsIntPoint(); } - return GetOwningTabChild()->GetChromeDisplacement(); + return LayoutDeviceIntPoint::ToUntyped(GetOwningTabChild()->GetChromeDisplacement()); } nsIntPoint @@ -1126,7 +1126,7 @@ PuppetWidget::GetWindowPosition() NS_METHOD PuppetWidget::GetScreenBounds(nsIntRect &aRect) { - aRect.MoveTo(LayoutDeviceIntPoint::ToUntyped(WidgetToScreenOffset())); + aRect.MoveTo(gfx::ToIntPoint(LayoutDeviceIntPoint::ToUntyped(WidgetToScreenOffset()))); aRect.SizeTo(mBounds.Size()); return NS_OK; } diff --git a/widget/PuppetWidget.h b/widget/PuppetWidget.h index 9b6606e0d2..22641a8fcb 100644 --- a/widget/PuppetWidget.h +++ b/widget/PuppetWidget.h @@ -24,8 +24,6 @@ #include "mozilla/Attributes.h" #include "mozilla/EventForwards.h" -class gfxASurface; - namespace mozilla { namespace dom { diff --git a/widget/cocoa/nsAppShell.h b/widget/cocoa/nsAppShell.h index 931b83e4d7..10655376ec 100644 --- a/widget/cocoa/nsAppShell.h +++ b/widget/cocoa/nsAppShell.h @@ -11,8 +11,6 @@ #ifndef nsAppShell_h_ #define nsAppShell_h_ -class nsCocoaWindow; - #include "nsBaseAppShell.h" #include "nsTArray.h" diff --git a/widget/cocoa/nsChildView.h b/widget/cocoa/nsChildView.h index 7235ebefea..0554503eca 100644 --- a/widget/cocoa/nsChildView.h +++ b/widget/cocoa/nsChildView.h @@ -33,7 +33,6 @@ #import #import -class gfxASurface; class nsChildView; class nsCocoaWindow; diff --git a/widget/cocoa/nsChildView.mm b/widget/cocoa/nsChildView.mm index c801a37c31..7ca3179b31 100644 --- a/widget/cocoa/nsChildView.mm +++ b/widget/cocoa/nsChildView.mm @@ -2635,7 +2635,7 @@ RectTextureImage::BeginUpdate(const nsIntSize& aNewSize, mUpdateRegion = aDirtyRegion; if (aNewSize != mUsedSize) { mUsedSize = aNewSize; - mUpdateRegion = nsIntRect(nsIntPoint(0, 0), aNewSize); + mUpdateRegion = gfx::IntRect(gfx::IntPoint(0, 0), aNewSize); } if (mUpdateRegion.IsEmpty()) { @@ -2682,7 +2682,7 @@ RectTextureImage::EndUpdate(bool aKeepSurface) } if (overwriteTexture || !CanUploadSubtextures()) { - updateRegion = nsIntRect(nsIntPoint(0, 0), mTextureSize); + updateRegion = gfx::IntRect(gfx::IntPoint(0, 0), mTextureSize); } RefPtr snapshot = mUpdateDrawTarget->Snapshot(); diff --git a/widget/cocoa/nsCocoaUtils.mm b/widget/cocoa/nsCocoaUtils.mm index 147fb3584d..f85b3dbc8e 100644 --- a/widget/cocoa/nsCocoaUtils.mm +++ b/widget/cocoa/nsCocoaUtils.mm @@ -484,8 +484,7 @@ nsresult nsCocoaUtils::CreateNSImageFromImageContainer(imgIContainer *aImage, ui ceil(height * scaleFactor)); RefPtr drawTarget = gfxPlatform::GetPlatform()-> - CreateOffscreenContentDrawTarget(ToIntSize(scaledSize), - SurfaceFormat::B8G8R8A8); + CreateOffscreenContentDrawTarget(scaledSize, SurfaceFormat::B8G8R8A8); if (!drawTarget) { NS_ERROR("Failed to create DrawTarget"); return NS_ERROR_FAILURE; diff --git a/widget/cocoa/nsMenuBarX.h b/widget/cocoa/nsMenuBarX.h index dfe99a4068..ea9295e79f 100644 --- a/widget/cocoa/nsMenuBarX.h +++ b/widget/cocoa/nsMenuBarX.h @@ -17,7 +17,6 @@ class nsMenuX; class nsMenuBarX; -class nsMenuItemX; class nsIWidget; class nsIContent; diff --git a/widget/cocoa/nsMenuGroupOwnerX.h b/widget/cocoa/nsMenuGroupOwnerX.h index caed9a50cc..5972fa9ddc 100644 --- a/widget/cocoa/nsMenuGroupOwnerX.h +++ b/widget/cocoa/nsMenuGroupOwnerX.h @@ -16,12 +16,10 @@ #include "nsString.h" -class nsMenuX; class nsMenuItemX; class nsChangeObserver; class nsIWidget; class nsIContent; -class nsIDocument; class nsMenuGroupOwnerX : public nsMenuObjectX, public nsIMutationObserver { diff --git a/widget/cocoa/nsNativeThemeCocoa.h b/widget/cocoa/nsNativeThemeCocoa.h index 7961091aed..ba9f12ae0b 100644 --- a/widget/cocoa/nsNativeThemeCocoa.h +++ b/widget/cocoa/nsNativeThemeCocoa.h @@ -65,7 +65,7 @@ public: NS_IMETHOD GetMinimumWidgetSize(nsPresContext* aPresContext, nsIFrame* aFrame, uint8_t aWidgetType, - nsIntSize* aResult, bool* aIsOverridable) override; + mozilla::LayoutDeviceIntSize* aResult, bool* aIsOverridable) override; NS_IMETHOD WidgetStateChanged(nsIFrame* aFrame, uint8_t aWidgetType, nsIAtom* aAttribute, bool* aShouldRepaint) override; NS_IMETHOD ThemeChanged() override; diff --git a/widget/cocoa/nsNativeThemeCocoa.mm b/widget/cocoa/nsNativeThemeCocoa.mm index c719f3792d..67d056667d 100644 --- a/widget/cocoa/nsNativeThemeCocoa.mm +++ b/widget/cocoa/nsNativeThemeCocoa.mm @@ -3149,7 +3149,7 @@ NS_IMETHODIMP nsNativeThemeCocoa::GetMinimumWidgetSize(nsPresContext* aPresContext, nsIFrame* aFrame, uint8_t aWidgetType, - nsIntSize* aResult, + LayoutDeviceIntSize* aResult, bool* aIsOverridable) { NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT; diff --git a/widget/gonk/HwcComposer2D.cpp b/widget/gonk/HwcComposer2D.cpp index 98e705ae37..fc8926e7ba 100644 --- a/widget/gonk/HwcComposer2D.cpp +++ b/widget/gonk/HwcComposer2D.cpp @@ -148,7 +148,7 @@ HwcComposer2D::Init(hwc_display_t dpy, hwc_surface_t sur, gl::GLContext* aGLCont ANativeWindow *win = GetGonkDisplay()->GetNativeWindow(); win->query(win, NATIVE_WINDOW_WIDTH, &screenSize.width); win->query(win, NATIVE_WINDOW_HEIGHT, &screenSize.height); - mScreenRect = nsIntRect(nsIntPoint(0, 0), screenSize); + mScreenRect = gfx::IntRect(gfx::IntPoint(0, 0), screenSize); #if ANDROID_VERSION >= 17 int supported = 0; diff --git a/widget/gonk/HwcComposer2D.h b/widget/gonk/HwcComposer2D.h index 96c2380802..9263848b88 100644 --- a/widget/gonk/HwcComposer2D.h +++ b/widget/gonk/HwcComposer2D.h @@ -38,7 +38,6 @@ namespace gl { namespace layers { class CompositorParent; -class ContainerLayer; class Layer; } diff --git a/widget/gonk/libdisplay/FramebufferSurface.h b/widget/gonk/libdisplay/FramebufferSurface.h index 1528c6eaa3..fbe47ccada 100644 --- a/widget/gonk/libdisplay/FramebufferSurface.h +++ b/widget/gonk/libdisplay/FramebufferSurface.h @@ -28,7 +28,6 @@ namespace android { class Rect; class String8; -class HWComposer; #if ANDROID_VERSION >= 21 typedef IGraphicBufferConsumer StreamConsumer; diff --git a/widget/gonk/libdisplay/GonkDisplay.h b/widget/gonk/libdisplay/GonkDisplay.h index 37666e4d12..8748419115 100644 --- a/widget/gonk/libdisplay/GonkDisplay.h +++ b/widget/gonk/libdisplay/GonkDisplay.h @@ -21,10 +21,6 @@ namespace mozilla { -namespace layers { -class Layer; -} - typedef void * EGLDisplay; typedef void * EGLSurface; diff --git a/widget/gonk/nativewindow/GonkBufferQueueLL/GonkBufferQueueProducer.h b/widget/gonk/nativewindow/GonkBufferQueueLL/GonkBufferQueueProducer.h index ef3b70a413..46bd9512e3 100644 --- a/widget/gonk/nativewindow/GonkBufferQueueLL/GonkBufferQueueProducer.h +++ b/widget/gonk/nativewindow/GonkBufferQueueLL/GonkBufferQueueProducer.h @@ -23,8 +23,6 @@ namespace android { -class GonkBufferSlot; - class GonkBufferQueueProducer : public BnGraphicBufferProducer, private IBinder::DeathRecipient { public: diff --git a/widget/gonk/nsWindow.cpp b/widget/gonk/nsWindow.cpp index 3ffbe50c23..3ce292b18a 100644 --- a/widget/gonk/nsWindow.cpp +++ b/widget/gonk/nsWindow.cpp @@ -153,7 +153,7 @@ nsWindow::nsWindow() win->query(win, NATIVE_WINDOW_HEIGHT, &screenSize.height)) { NS_RUNTIMEABORT("Failed to get native window size, aborting..."); } - gScreenBounds = nsIntRect(nsIntPoint(0, 0), screenSize); + gScreenBounds = gfx::IntRect(gfx::IntPoint(0, 0), screenSize); char propValue[PROPERTY_VALUE_MAX]; property_get("ro.sf.hwrotation", propValue, "0"); diff --git a/widget/gonk/nsWindow.h b/widget/gonk/nsWindow.h index 63ac1db78d..a2f4dfd00a 100644 --- a/widget/gonk/nsWindow.h +++ b/widget/gonk/nsWindow.h @@ -23,22 +23,8 @@ #include "Units.h" extern nsIntRect gScreenBounds; - -namespace mozilla { -namespace gl { -class GLContext; -} -namespace layers { -class LayersManager; -} -} - class ANativeWindowBuffer; -namespace android { -class FramebufferNativeWindow; -} - namespace widget { struct InputContext; struct InputContextAction; diff --git a/widget/gtk/nsNativeThemeGTK.cpp b/widget/gtk/nsNativeThemeGTK.cpp index e5e1867db7..6e194d0404 100644 --- a/widget/gtk/nsNativeThemeGTK.cpp +++ b/widget/gtk/nsNativeThemeGTK.cpp @@ -7,6 +7,7 @@ #include "nsThemeConstants.h" #include "gtkdrawing.h" +#include "gfx2DGlue.h" #include "nsIObserverService.h" #include "nsIServiceManager.h" #include "nsIFrame.h" @@ -824,7 +825,7 @@ nsNativeThemeGTK::DrawWidgetBackground(nsRenderingContext* aContext, nsIntRect overflowRect(widgetRect); nsIntMargin extraSize; if (GetExtraSizeForWidget(aFrame, aWidgetType, &extraSize)) { - overflowRect.Inflate(extraSize); + overflowRect.Inflate(gfx::ToIntMargin(extraSize)); } // This is the rectangle that will actually be drawn, in gdk pixels @@ -1065,7 +1066,8 @@ nsNativeThemeGTK::GetWidgetOverflow(nsDeviceContext* aContext, NS_IMETHODIMP nsNativeThemeGTK::GetMinimumWidgetSize(nsPresContext* aPresContext, nsIFrame* aFrame, uint8_t aWidgetType, - nsIntSize* aResult, bool* aIsOverridable) + LayoutDeviceIntSize* aResult, + bool* aIsOverridable) { aResult->width = aResult->height = 0; *aIsOverridable = true; @@ -1528,9 +1530,15 @@ nsNativeThemeGTK::GetWidgetTransparency(nsIFrame* aFrame, uint8_t aWidgetType) case NS_THEME_MENUPOPUP: case NS_THEME_WINDOW: case NS_THEME_DIALOG: - // Tooltips use gtk_paint_flat_box(). - case NS_THEME_TOOLTIP: return eOpaque; + // Tooltips use gtk_paint_flat_box() on Gtk2 + // but are shaped on Gtk3 + case NS_THEME_TOOLTIP: +#if (MOZ_WIDGET_GTK == 2) + return eOpaque; +#else + return eTransparent; +#endif } return eUnknownTransparency; diff --git a/widget/gtk/nsNativeThemeGTK.h b/widget/gtk/nsNativeThemeGTK.h index 3c14d10f93..112503709b 100644 --- a/widget/gtk/nsNativeThemeGTK.h +++ b/widget/gtk/nsNativeThemeGTK.h @@ -45,7 +45,7 @@ public: NS_IMETHOD GetMinimumWidgetSize(nsPresContext* aPresContext, nsIFrame* aFrame, uint8_t aWidgetType, - nsIntSize* aResult, + mozilla::LayoutDeviceIntSize* aResult, bool* aIsOverridable) override; NS_IMETHOD WidgetStateChanged(nsIFrame* aFrame, uint8_t aWidgetType, diff --git a/widget/gtk/nsPSPrinters.h b/widget/gtk/nsPSPrinters.h index e47b31eef5..b584ef715a 100644 --- a/widget/gtk/nsPSPrinters.h +++ b/widget/gtk/nsPSPrinters.h @@ -10,8 +10,6 @@ #include "nsString.h" #include "nsTArray.h" -class nsCUPSShim; - class nsPSPrinterList { public: nsPSPrinterList(); diff --git a/widget/gtk/nsWindow.cpp b/widget/gtk/nsWindow.cpp index a1caa52bcc..6682d468fb 100644 --- a/widget/gtk/nsWindow.cpp +++ b/widget/gtk/nsWindow.cpp @@ -2380,7 +2380,7 @@ nsWindow::UpdateAlpha(gfxPattern* aPattern, nsIntRect aBoundsRect) int32_t bufferSize = stride * aBoundsRect.height; nsAutoArrayPtr imageBuffer(new (std::nothrow) uint8_t[bufferSize]); RefPtr drawTarget = gfxPlatform::GetPlatform()-> - CreateDrawTargetForData(imageBuffer, ToIntSize(aBoundsRect.Size()), + CreateDrawTargetForData(imageBuffer, aBoundsRect.Size(), stride, SurfaceFormat::A8); if (drawTarget) { @@ -6592,3 +6592,63 @@ nsWindow::SynthesizeNativeMouseEvent(LayoutDeviceIntPoint aPoint, return NS_OK; } + +nsresult +nsWindow::SynthesizeNativeMouseScrollEvent(mozilla::LayoutDeviceIntPoint aPoint, + uint32_t aNativeMessage, + double aDeltaX, + double aDeltaY, + double aDeltaZ, + uint32_t aModifierFlags, + uint32_t aAdditionalFlags, + nsIObserver* aObserver) +{ + AutoObserverNotifier notifier(aObserver, "mousescrollevent"); + + if (!mGdkWindow) { + return NS_OK; + } + + GdkEvent event; + memset(&event, 0, sizeof(GdkEvent)); + event.type = GDK_SCROLL; + event.scroll.window = mGdkWindow; + event.scroll.time = GDK_CURRENT_TIME; +#if (MOZ_WIDGET_GTK == 3) + // Get device for event source + GdkDisplay* display = gdk_window_get_display(mGdkWindow); + GdkDeviceManager *device_manager = gdk_display_get_device_manager(display); + event.scroll.device = gdk_device_manager_get_client_pointer(device_manager); +#endif + event.scroll.x_root = aPoint.x; + event.scroll.y_root = aPoint.y; + + LayoutDeviceIntPoint pointInWindow = aPoint - WidgetToScreenOffset(); + event.scroll.x = pointInWindow.x; + event.scroll.y = pointInWindow.y; + + // The delta values are backwards on Linux compared to Windows and Cocoa, + // hence the negation. +#if GTK_CHECK_VERSION(3,4,0) + // TODO: is this correct? I don't have GTK 3.4+ so I can't check + event.scroll.direction = GDK_SCROLL_SMOOTH; + event.scroll.delta_x = -aDeltaX; + event.scroll.delta_y = -aDeltaY; +#else + if (aDeltaX < 0) { + event.scroll.direction = GDK_SCROLL_RIGHT; + } else if (aDeltaX > 0) { + event.scroll.direction = GDK_SCROLL_LEFT; + } else if (aDeltaY < 0) { + event.scroll.direction = GDK_SCROLL_DOWN; + } else if (aDeltaY > 0) { + event.scroll.direction = GDK_SCROLL_UP; + } else { + return NS_OK; + } +#endif + + gdk_event_put(&event); + + return NS_OK; +} diff --git a/widget/gtk/nsWindow.h b/widget/gtk/nsWindow.h index df817a4fe6..5ec18c1782 100644 --- a/widget/gtk/nsWindow.h +++ b/widget/gtk/nsWindow.h @@ -61,7 +61,6 @@ extern PRLogModuleInfo *gWidgetDrawLog; class gfxASurface; class gfxPattern; -class nsDragService; class nsPluginNativeWindowGtk; #if defined(MOZ_X11) && defined(MOZ_HAVE_SHAREDMEMORYSYSV) # define MOZ_HAVE_SHMIMAGE @@ -307,6 +306,15 @@ public: nsIObserver* aObserver) override { return SynthesizeNativeMouseEvent(aPoint, GDK_MOTION_NOTIFY, 0, aObserver); } + virtual nsresult SynthesizeNativeMouseScrollEvent(mozilla::LayoutDeviceIntPoint aPoint, + uint32_t aNativeMessage, + double aDeltaX, + double aDeltaY, + double aDeltaZ, + uint32_t aModifierFlags, + uint32_t aAdditionalFlags, + nsIObserver* aObserver) override; + protected: virtual ~nsWindow(); diff --git a/widget/nsBaseClipboard.h b/widget/nsBaseClipboard.h index c45f02840d..92d5a7c250 100644 --- a/widget/nsBaseClipboard.h +++ b/widget/nsBaseClipboard.h @@ -12,7 +12,6 @@ #include "nsAutoPtr.h" class nsITransferable; -class nsDataObj; class nsIClipboardOwner; class nsIWidget; diff --git a/widget/nsBaseDragService.cpp b/widget/nsBaseDragService.cpp index 79dde7287a..bb8333398d 100644 --- a/widget/nsBaseDragService.cpp +++ b/widget/nsBaseDragService.cpp @@ -520,7 +520,7 @@ nsBaseDragService::DrawDrag(nsIDOMNode* aDOMNode, if (rootFrame && *aPresContext) { nsIntRect dragRect; aRegion->GetBoundingBox(&dragRect.x, &dragRect.y, &dragRect.width, &dragRect.height); - dragRect = dragRect.ToAppUnits(nsPresContext::AppUnitsPerCSSPixel()). + dragRect = ToAppUnits(dragRect, nsPresContext::AppUnitsPerCSSPixel()). ToOutsidePixels((*aPresContext)->AppUnitsPerDevPixel()); nsIntRect screenRect = rootFrame->GetScreenRectExternal(); diff --git a/widget/nsBaseDragService.h b/widget/nsBaseDragService.h index 265b578dc0..bccc9b71ae 100644 --- a/widget/nsBaseDragService.h +++ b/widget/nsBaseDragService.h @@ -24,10 +24,8 @@ class nsIContent; class nsIDOMNode; -class nsIFrame; class nsPresContext; class nsIImageLoadingContent; -class nsICanvasElementExternal; namespace mozilla { namespace gfx { diff --git a/widget/nsIPluginWidget.h b/widget/nsIPluginWidget.h index 7f95a70b98..3ddf79d39f 100644 --- a/widget/nsIPluginWidget.h +++ b/widget/nsIPluginWidget.h @@ -4,12 +4,12 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "nsISupports.h" +#include "nsPoint.h" #define NS_IPLUGINWIDGET_IID \ { 0xEB9207E0, 0xD8F1, 0x44B9, \ { 0xB7, 0x52, 0xAF, 0x8E, 0x9F, 0x8E, 0xBD, 0xF7 } } -struct nsIntPoint; class nsIPluginInstanceOwner; /** diff --git a/widget/nsIRollupListener.h b/widget/nsIRollupListener.h index efb8e331a4..83c2dd1426 100644 --- a/widget/nsIRollupListener.h +++ b/widget/nsIRollupListener.h @@ -8,10 +8,10 @@ #define __nsIRollupListener_h__ #include "nsTArray.h" +#include "nsPoint.h" class nsIContent; class nsIWidget; -struct nsIntPoint; class nsIRollupListener { public: diff --git a/widget/nsIWidget.h b/widget/nsIWidget.h index 1148080049..7c6a1c2467 100644 --- a/widget/nsIWidget.h +++ b/widget/nsIWidget.h @@ -29,9 +29,6 @@ #include "Units.h" // forward declarations -class nsFontMetrics; -class nsDeviceContext; -struct nsFont; class nsIRollupListener; class imgIContainer; class nsIContent; diff --git a/widget/nsPrintOptionsImpl.h b/widget/nsPrintOptionsImpl.h index 262518b5ec..8b2616907b 100644 --- a/widget/nsPrintOptionsImpl.h +++ b/widget/nsPrintOptionsImpl.h @@ -15,7 +15,6 @@ #include "nsFont.h" class nsIPrintSettings; -class nsIWebBrowserPrint; /** * Class nsPrintOptions diff --git a/widget/nsTransferable.h b/widget/nsTransferable.h index da94ed27f6..135f0411d3 100644 --- a/widget/nsTransferable.h +++ b/widget/nsTransferable.h @@ -14,7 +14,6 @@ #include "nsWeakPtr.h" class nsString; -class nsDataObj; // // DataStruct diff --git a/widget/qt/nsWindow.cpp b/widget/qt/nsWindow.cpp index 69ee6d5227..ad38431b2a 100644 --- a/widget/qt/nsWindow.cpp +++ b/widget/qt/nsWindow.cpp @@ -1499,7 +1499,7 @@ void find_first_visible_parent(QWindow* aItem, QWindow*& aVisibleItem) NS_IMETHODIMP nsWindow::GetScreenBounds(nsIntRect &aRect) { - aRect = nsIntRect(nsIntPoint(0, 0), mBounds.Size()); + aRect = gfx::IntRect(gfx::IntPoint(0, 0), mBounds.Size()); if (mIsTopLevel) { QPoint pos = mWidget->position(); aRect.MoveTo(pos.x(), pos.y()); diff --git a/widget/qt/nsWindow.h b/widget/qt/nsWindow.h index 445cf70bd2..de4efb176a 100644 --- a/widget/qt/nsWindow.h +++ b/widget/qt/nsWindow.h @@ -59,7 +59,6 @@ extern PRLogModuleInfo *gWidgetDrawLog; #endif /* MOZ_LOGGING */ -class nsIdleService; class QCloseEvent; class QFocusEvent; class QHideEvent; diff --git a/widget/windows/KeyboardLayout.h b/widget/windows/KeyboardLayout.h index a154b8e9ee..e06b38c133 100644 --- a/widget/windows/KeyboardLayout.h +++ b/widget/windows/KeyboardLayout.h @@ -37,7 +37,6 @@ #define VK_OEM_CLEAR 0xFE class nsIIdleServiceInternal; -struct nsModifierKeyState; namespace mozilla { namespace widget { diff --git a/widget/windows/WinMouseScrollHandler.h b/widget/windows/WinMouseScrollHandler.h index 2e506d44b8..2120b240bc 100644 --- a/widget/windows/WinMouseScrollHandler.h +++ b/widget/windows/WinMouseScrollHandler.h @@ -14,9 +14,9 @@ #include "mozilla/TimeStamp.h" #include "Units.h" #include +#include "nsPoint.h" class nsWindowBase; -struct nsIntPoint; namespace mozilla { namespace widget { diff --git a/widget/windows/WinUtils.h b/widget/windows/WinUtils.h index 6dc6207401..0a4ae9daa7 100644 --- a/widget/windows/WinUtils.h +++ b/widget/windows/WinUtils.h @@ -22,6 +22,7 @@ #include "nsAutoPtr.h" #include "nsString.h" #include "nsRegion.h" +#include "nsRect.h" #include "nsIRunnable.h" #include "nsICryptoHash.h" @@ -75,7 +76,6 @@ public: class nsWindow; class nsWindowBase; struct KeyPair; -struct nsIntRect; namespace mozilla { namespace widget { diff --git a/widget/windows/nsClipboard.h b/widget/windows/nsClipboard.h index 041af8fc75..05da23f9fd 100644 --- a/widget/windows/nsClipboard.h +++ b/widget/windows/nsClipboard.h @@ -11,7 +11,6 @@ #include class nsITransferable; -class nsIClipboardOwner; class nsIWidget; class nsIFile; struct IDataObject; diff --git a/widget/windows/nsDataObjCollection.h b/widget/windows/nsDataObjCollection.h index 5a1cd3315b..35f1429dbf 100644 --- a/widget/windows/nsDataObjCollection.h +++ b/widget/windows/nsDataObjCollection.h @@ -14,8 +14,6 @@ #include "nsDataObj.h" #include "mozilla/Attributes.h" -class CEnumFormatEtc; - #define MULTI_MIME "Mozilla/IDataObjectCollectionFormat" EXTERN_C const IID IID_IDataObjCollection; diff --git a/widget/windows/nsDragService.h b/widget/windows/nsDragService.h index 236910adae..eb165da6e9 100644 --- a/widget/windows/nsDragService.h +++ b/widget/windows/nsDragService.h @@ -10,11 +10,8 @@ #include #include -struct IDropSource; struct IDataObject; -class nsNativeDragTarget; class nsDataObjCollection; -class nsString; /** * Native Win32 DragService wrapper diff --git a/widget/windows/nsIMM32Handler.h b/widget/windows/nsIMM32Handler.h index 20d1240caf..5145636ed4 100644 --- a/widget/windows/nsIMM32Handler.h +++ b/widget/windows/nsIMM32Handler.h @@ -13,9 +13,9 @@ #include "nsTArray.h" #include "nsIWidget.h" #include "mozilla/EventForwards.h" +#include "nsRect.h" class nsWindow; -struct nsIntRect; namespace mozilla { namespace widget { diff --git a/widget/windows/nsNativeDragTarget.h b/widget/windows/nsNativeDragTarget.h index 40fb48950f..2dc4cfe07a 100644 --- a/widget/windows/nsNativeDragTarget.h +++ b/widget/windows/nsNativeDragTarget.h @@ -20,8 +20,6 @@ class nsIDragService; class nsIWidget; -struct IDataObject; - /* * nsNativeDragTarget implements the IDropTarget interface and gets most of its * behavior from the associated adapter (m_dragDrop). diff --git a/widget/windows/nsNativeThemeWin.cpp b/widget/windows/nsNativeThemeWin.cpp index 9defd8d683..f0d98e86a0 100644 --- a/widget/windows/nsNativeThemeWin.cpp +++ b/widget/windows/nsNativeThemeWin.cpp @@ -351,7 +351,7 @@ static CaptionButtonPadding buttonData[3] = { // Adds "hot" caption button padding to minimum widget size. static void -AddPaddingRect(nsIntSize* aSize, CaptionButton button) { +AddPaddingRect(LayoutDeviceIntSize* aSize, CaptionButton button) { if (!aSize) return; RECT offset; @@ -2255,7 +2255,7 @@ nsNativeThemeWin::GetWidgetOverflow(nsDeviceContext* aContext, NS_IMETHODIMP nsNativeThemeWin::GetMinimumWidgetSize(nsPresContext* aPresContext, nsIFrame* aFrame, uint8_t aWidgetType, - nsIntSize* aResult, bool* aIsOverridable) + LayoutDeviceIntSize* aResult, bool* aIsOverridable) { (*aResult).width = (*aResult).height = 0; *aIsOverridable = true; @@ -2918,7 +2918,7 @@ nsNativeThemeWin::ClassicGetWidgetPadding(nsDeviceContext* aContext, nsresult nsNativeThemeWin::ClassicGetMinimumWidgetSize(nsPresContext* aPresContext, nsIFrame* aFrame, uint8_t aWidgetType, - nsIntSize* aResult, bool* aIsOverridable) + LayoutDeviceIntSize* aResult, bool* aIsOverridable) { (*aResult).width = (*aResult).height = 0; *aIsOverridable = true; diff --git a/widget/windows/nsNativeThemeWin.h b/widget/windows/nsNativeThemeWin.h index 53a1545612..9c1e027982 100644 --- a/widget/windows/nsNativeThemeWin.h +++ b/widget/windows/nsNativeThemeWin.h @@ -16,8 +16,6 @@ #include "mozilla/TimeStamp.h" #include "nsSize.h" -struct nsIntRect; - class nsNativeThemeWin : private nsNativeTheme, public nsITheme { virtual ~nsNativeThemeWin(); @@ -52,7 +50,7 @@ public: NS_IMETHOD GetMinimumWidgetSize(nsPresContext* aPresContext, nsIFrame* aFrame, uint8_t aWidgetType, - nsIntSize* aResult, + mozilla::LayoutDeviceIntSize* aResult, bool* aIsOverridable); virtual Transparency GetWidgetTransparency(nsIFrame* aFrame, uint8_t aWidgetType); @@ -105,7 +103,7 @@ protected: nsIntMargin* aResult); nsresult ClassicGetMinimumWidgetSize(nsPresContext* aPresContext, nsIFrame* aFrame, uint8_t aWidgetType, - nsIntSize* aResult, + mozilla::LayoutDeviceIntSize* aResult, bool* aIsOverridable); bool ClassicThemeSupportsWidget(nsPresContext* aPresContext, nsIFrame* aFrame, diff --git a/widget/windows/nsTextStore.h b/widget/windows/nsTextStore.h index 96a5f7f22d..7dd5dfe9b4 100644 --- a/widget/windows/nsTextStore.h +++ b/widget/windows/nsTextStore.h @@ -38,10 +38,6 @@ struct ITfDocumentMgr; struct ITfDisplayAttributeMgr; struct ITfCategoryMgr; class nsWindow; -#ifdef MOZ_METRO -class MetroWidget; -#endif -class TSFStaticSink; namespace mozilla { namespace widget { diff --git a/widget/windows/nsWindow.cpp b/widget/windows/nsWindow.cpp index 24ac3c5187..f6f28df68d 100644 --- a/widget/windows/nsWindow.cpp +++ b/widget/windows/nsWindow.cpp @@ -6914,7 +6914,7 @@ void nsWindow::SetupTranslucentWindowMemoryBitmap(nsTransparencyMode aMode) void nsWindow::ClearTranslucentWindow() { if (mTransparentSurface) { - IntSize size = ToIntSize(mTransparentSurface->GetSize()); + IntSize size = mTransparentSurface->GetSize(); RefPtr drawTarget = gfxPlatform::GetPlatform()-> CreateDrawTargetForSurface(mTransparentSurface, size); drawTarget->ClearRect(Rect(0, 0, size.width, size.height)); diff --git a/widget/windows/nsWindow.h b/widget/windows/nsWindow.h index 1e7e26e44c..f597c6385a 100644 --- a/widget/windows/nsWindow.h +++ b/widget/windows/nsWindow.h @@ -49,14 +49,12 @@ class nsNativeDragTarget; class nsIRollupListener; -class nsIFile; class nsIntRegion; class imgIContainer; namespace mozilla { namespace widget { class NativeKey; -class ModifierKeyState; struct MSGResult; } // namespace widget } // namespacw mozilla; diff --git a/xpcom/base/nsMemoryInfoDumper.h b/xpcom/base/nsMemoryInfoDumper.h index 39ed8f62ce..6bba176f2d 100644 --- a/xpcom/base/nsMemoryInfoDumper.h +++ b/xpcom/base/nsMemoryInfoDumper.h @@ -10,8 +10,6 @@ #include "nsIMemoryInfoDumper.h" #include -class nsACString; - /** * This class facilitates dumping information about our memory usage to disk. * diff --git a/xpcom/build/Omnijar.h b/xpcom/build/Omnijar.h index 777115b6d6..56198eabb6 100644 --- a/xpcom/build/Omnijar.h +++ b/xpcom/build/Omnijar.h @@ -12,8 +12,6 @@ #include "nsIFile.h" #include "nsZipArchive.h" -class nsIURI; - namespace mozilla { class Omnijar diff --git a/xpcom/build/nsXPCOMPrivate.h b/xpcom/build/nsXPCOMPrivate.h index a037efbc44..3bf6bcb708 100644 --- a/xpcom/build/nsXPCOMPrivate.h +++ b/xpcom/build/nsXPCOMPrivate.h @@ -14,7 +14,6 @@ class nsStringContainer; class nsCStringContainer; -class nsIComponentLoader; class nsPurpleBufferEntry; /** diff --git a/xpcom/components/ManifestParser.h b/xpcom/components/ManifestParser.h index cb4f310c1b..053af7dff6 100644 --- a/xpcom/components/ManifestParser.h +++ b/xpcom/components/ManifestParser.h @@ -12,8 +12,6 @@ #endif // !defined(MOZILLA_XPCOMRT_API) #include "mozilla/FileLocation.h" -class nsIFile; - void ParseManifest(NSLocationType aType, mozilla::FileLocation& aFile, char* aBuf, bool aChromeOnly, bool aXPTOnly = false); diff --git a/xpcom/ds/nsObserverList.h b/xpcom/ds/nsObserverList.h index 14ad789d09..521dda911c 100644 --- a/xpcom/ds/nsObserverList.h +++ b/xpcom/ds/nsObserverList.h @@ -16,10 +16,6 @@ #include "nsISimpleEnumerator.h" #include "mozilla/Attributes.h" -namespace mozilla { -class ObserverServiceReporter; -} // namespace mozilla - struct ObserverRef { ObserverRef(const ObserverRef& aO) : isWeakRef(aO.isWeakRef), ref(aO.ref) {} diff --git a/xpcom/glue/nsCOMPtr.h b/xpcom/glue/nsCOMPtr.h index 3cf561c5c6..7e867c08c3 100644 --- a/xpcom/glue/nsCOMPtr.h +++ b/xpcom/glue/nsCOMPtr.h @@ -110,9 +110,6 @@ #endif namespace mozilla { - -struct unused_t; - namespace dom { template class OwningNonNull; } // namespace dom diff --git a/xpcom/reflect/xptinfo/ShimInterfaceInfo.h b/xpcom/reflect/xptinfo/ShimInterfaceInfo.h index f025297aaa..868f503a59 100644 --- a/xpcom/reflect/xptinfo/ShimInterfaceInfo.h +++ b/xpcom/reflect/xptinfo/ShimInterfaceInfo.h @@ -19,7 +19,6 @@ namespace mozilla { namespace dom { -struct ConstantSpec; struct NativePropertyHooks; } // namespace dom } // namespace mozilla diff --git a/xpcom/reflect/xptinfo/xptinfo.h b/xpcom/reflect/xptinfo/xptinfo.h index b107583352..5e1981607e 100644 --- a/xpcom/reflect/xptinfo/xptinfo.h +++ b/xpcom/reflect/xptinfo/xptinfo.h @@ -11,8 +11,6 @@ #include "nscore.h" #include "xpt_struct.h" -class nsIInterfaceInfoManager; - // Flyweight wrapper classes for xpt_struct.h structs. // Everything here is dependent upon - and sensitive to changes in - // xpcom/typelib/xpt/xpt_struct.h! diff --git a/xpfe/appshell/nsAppShellService.cpp b/xpfe/appshell/nsAppShellService.cpp index 0b52f29f42..9375a09742 100644 --- a/xpfe/appshell/nsAppShellService.cpp +++ b/xpfe/appshell/nsAppShellService.cpp @@ -393,7 +393,7 @@ nsAppShellService::CreateWindowlessBrowser(bool aIsChrome, nsIWebNavigation **aR NS_ERROR("Couldn't create instance of PuppetWidget"); return NS_ERROR_FAILURE; } - widget->Create(nullptr, 0, nsIntRect(nsIntPoint(0, 0), nsIntSize(0, 0)), + widget->Create(nullptr, 0, gfx::IntRect(gfx::IntPoint(0, 0), gfx::IntSize(0, 0)), nullptr); nsCOMPtr window = do_QueryInterface(navigation); window->InitWindow(0, widget, 0, 0, 0, 0);