/* static */ gfx3DMatrix nsStyleTransformMatrix::ProcessTranslate3D(const nsCSSValue::Array* aData, nsStyleContext* aContext, nsPresContext* aPresContext, PRBool& aCanStoreInRuleTree, nsRect& aBounds, float aAppUnitsPerMatrixUnit) { NS_PRECONDITION(aData->Count() == 4, "Invalid array!"); gfx3DMatrix temp; ProcessTranslatePart(temp._41, aData->Item(1), aContext, aPresContext, aCanStoreInRuleTree, aBounds.Width(), aAppUnitsPerMatrixUnit); ProcessTranslatePart(temp._42, aData->Item(2), aContext, aPresContext, aCanStoreInRuleTree, aBounds.Height(), aAppUnitsPerMatrixUnit); ProcessTranslatePart(temp._43, aData->Item(3), aContext, aPresContext, aCanStoreInRuleTree, 0, aAppUnitsPerMatrixUnit); return temp; }
/* Helper function to process a translatex function. */ /* static */ gfx3DMatrix nsStyleTransformMatrix::ProcessTranslateX(const nsCSSValue::Array* aData, nsStyleContext* aContext, nsPresContext* aPresContext, PRBool& aCanStoreInRuleTree, nsRect& aBounds, float aAppUnitsPerMatrixUnit) { NS_PRECONDITION(aData->Count() == 2, "Invalid array!"); gfx3DMatrix temp; /* There are two cases. If we have a number, we want our matrix to look * like this: * * | 1 0 0 0 | * | 0 1 0 0 | * | 0 0 1 0 | * | dx 0 0 1 | * So E = value * * Otherwise, we might have a percentage, so we want to set the dX component * to the percent. */ ProcessTranslatePart(temp._41, aData->Item(1), aContext, aPresContext, aCanStoreInRuleTree, aBounds.Width(), aAppUnitsPerMatrixUnit); return temp; }
nsresult nsScreen::GetRect(nsRect& aRect) { // Return window inner rect to prevent fingerprinting. if (ShouldResistFingerprinting()) { return GetWindowInnerRect(aRect); } nsDeviceContext *context = GetDeviceContext(); if (!context) { return NS_ERROR_FAILURE; } context->GetRect(aRect); LayoutDevicePoint screenTopLeftDev = LayoutDevicePixel::FromAppUnits(aRect.TopLeft(), context->AppUnitsPerDevPixel()); DesktopPoint screenTopLeftDesk = screenTopLeftDev / context->GetDesktopToDeviceScale(); aRect.x = NSToIntRound(screenTopLeftDesk.x); aRect.y = NSToIntRound(screenTopLeftDesk.y); aRect.SetHeight(nsPresContext::AppUnitsToIntCSSPixels(aRect.Height())); aRect.SetWidth(nsPresContext::AppUnitsToIntCSSPixels(aRect.Width())); return NS_OK; }
/* Helper function to process a matrix entry. */ /* static */ gfx3DMatrix nsStyleTransformMatrix::ProcessMatrix(const nsCSSValue::Array* aData, nsStyleContext* aContext, nsPresContext* aPresContext, PRBool& aCanStoreInRuleTree, nsRect& aBounds, float aAppUnitsPerMatrixUnit, PRBool *aPercentX, PRBool *aPercentY) { NS_PRECONDITION(aData->Count() == 7, "Invalid array!"); gfx3DMatrix result; /* Take the first four elements out of the array as floats and store * them. */ result._11 = aData->Item(1).GetFloatValue(); result._12 = aData->Item(2).GetFloatValue(); result._21 = aData->Item(3).GetFloatValue(); result._22 = aData->Item(4).GetFloatValue(); /* The last two elements have their length parts stored in aDelta * and their percent parts stored in aX[0] and aY[1]. */ ProcessTranslatePart(result._41, aData->Item(5), aContext, aPresContext, aCanStoreInRuleTree, aBounds.Width(), aAppUnitsPerMatrixUnit); ProcessTranslatePart(result._42, aData->Item(6), aContext, aPresContext, aCanStoreInRuleTree, aBounds.Height(), aAppUnitsPerMatrixUnit); return result; }
/* Helper function to process a matrix entry. */ static void ProcessMatrix(gfx3DMatrix& aMatrix, const nsCSSValue::Array* aData, nsStyleContext* aContext, nsPresContext* aPresContext, bool& aCanStoreInRuleTree, nsRect& aBounds) { NS_PRECONDITION(aData->Count() == 7, "Invalid array!"); gfxMatrix result; /* Take the first four elements out of the array as floats and store * them. */ result._11 = aData->Item(1).GetFloatValue(); result._12 = aData->Item(2).GetFloatValue(); result._21 = aData->Item(3).GetFloatValue(); result._22 = aData->Item(4).GetFloatValue(); /* The last two elements have their length parts stored in aDelta * and their percent parts stored in aX[0] and aY[1]. */ result._31 = ProcessTranslatePart(aData->Item(5), aContext, aPresContext, aCanStoreInRuleTree, aBounds.Width()); result._32 = ProcessTranslatePart(aData->Item(6), aContext, aPresContext, aCanStoreInRuleTree, aBounds.Height()); aMatrix.PreMultiply(result); }
static void ProcessTranslate3D(gfx3DMatrix& aMatrix, const nsCSSValue::Array* aData, nsStyleContext* aContext, nsPresContext* aPresContext, bool& aCanStoreInRuleTree, nsRect& aBounds) { NS_PRECONDITION(aData->Count() == 4, "Invalid array!"); Point3D temp; temp.x = ProcessTranslatePart(aData->Item(1), aContext, aPresContext, aCanStoreInRuleTree, aBounds.Width()); temp.y = ProcessTranslatePart(aData->Item(2), aContext, aPresContext, aCanStoreInRuleTree, aBounds.Height()); temp.z = ProcessTranslatePart(aData->Item(3), aContext, aPresContext, aCanStoreInRuleTree, 0); aMatrix.Translate(temp); }
void AppendToString(std::stringstream& aStream, const nsRect& r, const char* pfx, const char* sfx) { aStream << pfx; aStream << nsPrintfCString( "(x=%d, y=%d, w=%d, h=%d)", r.X(), r.Y(), r.Width(), r.Height()).get(); aStream << sfx; }
static void ProcessMatrix3D(gfx3DMatrix& aMatrix, const nsCSSValue::Array* aData, nsStyleContext* aContext, nsPresContext* aPresContext, bool& aCanStoreInRuleTree, nsRect& aBounds) { NS_PRECONDITION(aData->Count() == 17, "Invalid array!"); gfx3DMatrix temp; temp._11 = aData->Item(1).GetFloatValue(); temp._12 = aData->Item(2).GetFloatValue(); temp._13 = aData->Item(3).GetFloatValue(); temp._14 = aData->Item(4).GetFloatValue(); temp._21 = aData->Item(5).GetFloatValue(); temp._22 = aData->Item(6).GetFloatValue(); temp._23 = aData->Item(7).GetFloatValue(); temp._24 = aData->Item(8).GetFloatValue(); temp._31 = aData->Item(9).GetFloatValue(); temp._32 = aData->Item(10).GetFloatValue(); temp._33 = aData->Item(11).GetFloatValue(); temp._34 = aData->Item(12).GetFloatValue(); temp._44 = aData->Item(16).GetFloatValue(); temp._41 = ProcessTranslatePart(aData->Item(13), aContext, aPresContext, aCanStoreInRuleTree, aBounds.Width()); temp._42 = ProcessTranslatePart(aData->Item(14), aContext, aPresContext, aCanStoreInRuleTree, aBounds.Height()); temp._43 = ProcessTranslatePart(aData->Item(15), aContext, aPresContext, aCanStoreInRuleTree, aBounds.Height()); aMatrix.PreMultiply(temp); }
/* Helper function to process a translate function. */ /* static */ gfx3DMatrix nsStyleTransformMatrix::ProcessTranslate(const nsCSSValue::Array* aData, nsStyleContext* aContext, nsPresContext* aPresContext, PRBool& aCanStoreInRuleTree, nsRect& aBounds, float aAppUnitsPerMatrixUnit) { NS_PRECONDITION(aData->Count() == 2 || aData->Count() == 3, "Invalid array!"); gfx3DMatrix temp; ProcessTranslatePart(temp._41, aData->Item(1), aContext, aPresContext, aCanStoreInRuleTree, aBounds.Width(), aAppUnitsPerMatrixUnit); /* If we read in a Y component, set it appropriately */ if (aData->Count() == 3) { ProcessTranslatePart(temp._42, aData->Item(2), aContext, aPresContext, aCanStoreInRuleTree, aBounds.Height(), aAppUnitsPerMatrixUnit); } return temp; }
/* Helper function to process a translate function. */ static void ProcessTranslate(gfx3DMatrix& aMatrix, const nsCSSValue::Array* aData, nsStyleContext* aContext, nsPresContext* aPresContext, bool& aCanStoreInRuleTree, nsRect& aBounds) { NS_PRECONDITION(aData->Count() == 2 || aData->Count() == 3, "Invalid array!"); Point3D temp; temp.x = ProcessTranslatePart(aData->Item(1), aContext, aPresContext, aCanStoreInRuleTree, aBounds.Width()); /* If we read in a Y component, set it appropriately */ if (aData->Count() == 3) { temp.y = ProcessTranslatePart(aData->Item(2), aContext, aPresContext, aCanStoreInRuleTree, aBounds.Height()); } aMatrix.Translate(temp); }