mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 19:04:45 +00:00
Merge places to mozilla-central.
This commit is contained in:
commit
2b666b27ef
@ -519,15 +519,21 @@ __try {
|
||||
nsAutoString roleString;
|
||||
if (msaaRole != ROLE_SYSTEM_CLIENT &&
|
||||
!content->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::role, roleString)) {
|
||||
nsIDocument * document = content->GetCurrentDoc();
|
||||
if (!document)
|
||||
return E_FAIL;
|
||||
|
||||
nsINodeInfo *nodeInfo = content->NodeInfo();
|
||||
nodeInfo->GetName(roleString);
|
||||
nsAutoString nameSpaceURI;
|
||||
nodeInfo->GetNamespaceURI(nameSpaceURI);
|
||||
if (!nameSpaceURI.IsEmpty()) {
|
||||
// Only append name space if different from that of current document
|
||||
|
||||
// Only append name space if different from that of current document.
|
||||
if (!nodeInfo->NamespaceEquals(document->GetDefaultNamespaceID())) {
|
||||
nsAutoString nameSpaceURI;
|
||||
nodeInfo->GetNamespaceURI(nameSpaceURI);
|
||||
roleString += NS_LITERAL_STRING(", ") + nameSpaceURI;
|
||||
}
|
||||
}
|
||||
|
||||
if (!roleString.IsEmpty()) {
|
||||
pvarRole->vt = VT_BSTR;
|
||||
pvarRole->bstrVal = ::SysAllocString(roleString.get());
|
||||
|
@ -4975,20 +4975,20 @@ function middleMousePaste(event)
|
||||
*/
|
||||
|
||||
var contentAreaDNDObserver = {
|
||||
onDragOver: function (aEvent)
|
||||
{
|
||||
var types = aEvent.dataTransfer.types;
|
||||
if (types.contains("application/x-moz-file") ||
|
||||
types.contains("text/x-moz-url") ||
|
||||
types.contains("text/uri-list") ||
|
||||
types.contains("text/plain"))
|
||||
aEvent.preventDefault();
|
||||
},
|
||||
onDrop: function (aEvent)
|
||||
{
|
||||
if (aEvent.getPreventDefault())
|
||||
return;
|
||||
|
||||
var types = aEvent.dataTransfer.types;
|
||||
if (!types.contains("application/x-moz-file") &&
|
||||
!types.contains("text/x-moz-url") &&
|
||||
!types.contains("text/uri-list") &&
|
||||
!types.contains("text/plain")) {
|
||||
aEvent.preventDefault();
|
||||
return;
|
||||
}
|
||||
|
||||
let [url, name] = browserDragAndDrop.getDragURLFromDataTransfer(aEvent.dataTransfer);
|
||||
|
||||
// valid urls don't contain spaces ' '; if we have a space it
|
||||
|
@ -4,13 +4,17 @@
|
||||
|
||||
let testPage1 = "data:text/html,<html id='tab1'><body><button id='button1'>Tab 1</button></body></html>";
|
||||
let testPage2 = "data:text/html,<html id='tab2'><body><button id='button2'>Tab 2</button></body></html>";
|
||||
let testPage3 = "data:text/html,<html id='tab3'><body><button id='button3'>Tab 3</button></body></html>";
|
||||
|
||||
var browser1;
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
|
||||
var tab1 = gBrowser.addTab();
|
||||
browser1 = gBrowser.getBrowserForTab(tab1);
|
||||
|
||||
var tab2 = gBrowser.addTab();
|
||||
var browser1 = gBrowser.getBrowserForTab(tab1);
|
||||
var browser2 = gBrowser.getBrowserForTab(tab2);
|
||||
|
||||
gURLBar.focus();
|
||||
@ -119,10 +123,15 @@ function test() {
|
||||
expectFocusShift(function () gBrowser.selectedTab = tab1,
|
||||
browser1.contentWindow, null, true,
|
||||
"focusedWindow after tab switch from no focus to no focus");
|
||||
|
||||
gBrowser.removeCurrentTab();
|
||||
gBrowser.removeCurrentTab();
|
||||
finish();
|
||||
|
||||
window.addEventListener("focus", _browser_tabfocus_test_eventOccured, true);
|
||||
window.addEventListener("blur", _browser_tabfocus_test_eventOccured, true);
|
||||
|
||||
// next, check whether navigating forward, focusing the urlbar and then
|
||||
// navigating back maintains the focus in the urlbar.
|
||||
browser1.addEventListener("pageshow", _browser_tabfocus_navigation_test_eventOccured, true);
|
||||
button1.focus();
|
||||
browser1.contentWindow.location = testPage3;
|
||||
}
|
||||
|
||||
browser1.addEventListener("load", check, true);
|
||||
@ -152,6 +161,24 @@ function _browser_tabfocus_test_eventOccured(event)
|
||||
_browser_tabfocus_test_events += event.type + ": " + id;
|
||||
}
|
||||
|
||||
function _browser_tabfocus_navigation_test_eventOccured(event)
|
||||
{
|
||||
if (event.target instanceof Document) {
|
||||
var contentwin = event.target.defaultView;
|
||||
if (contentwin.location.toString().indexOf("3") > 0) {
|
||||
// just moved forward, so focus the urlbar and go back
|
||||
gURLBar.focus();
|
||||
setTimeout(function () contentwin.history.back(), 0);
|
||||
}
|
||||
else if (contentwin.location.toString().indexOf("2") > 0) {
|
||||
is(window.document.activeElement, gURLBar.inputField, "urlbar still focused after navigating back");
|
||||
gBrowser.removeCurrentTab();
|
||||
gBrowser.removeCurrentTab();
|
||||
finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getId(element)
|
||||
{
|
||||
return (element.localName == "input") ? "urlbar" : element.id;
|
||||
|
@ -67,6 +67,8 @@ else
|
||||
while [ -h "$progname" ]; do
|
||||
bn=`basename "$progname"`
|
||||
cd `dirname "$progname"`
|
||||
# Resolve symlink of dirname
|
||||
cd `/bin/pwd`
|
||||
progname=`/bin/ls -l "$bn" | sed -e 's/^.* -> //' `
|
||||
progbase=`basename "$progname"`
|
||||
if [ ! -x "$progname" ]; then
|
||||
@ -76,7 +78,7 @@ else
|
||||
run_moz="$curdir/run-mozilla.sh"
|
||||
if [ -x "$run_moz" ]; then
|
||||
cd "$curdir"
|
||||
dist_bin=`pwd`
|
||||
dist_bin=`/bin/pwd`
|
||||
run_moz="$dist_bin/run-mozilla.sh"
|
||||
found=1
|
||||
break
|
||||
|
@ -110,12 +110,12 @@ moz_get_debugger()
|
||||
done="no"
|
||||
for d in $debuggers
|
||||
do
|
||||
moz_test_binary /bin/type
|
||||
moz_test_binary /bin/which
|
||||
if [ $? -eq 1 ]
|
||||
then
|
||||
dpath=`LC_MESSAGES=C type ${d} | awk '{print $3;}' | sed -e 's/\.$//'`
|
||||
else
|
||||
dpath=`which ${d}`
|
||||
else
|
||||
dpath=`LC_MESSAGES=C type ${d} | awk '{print $3;}' | sed -e 's/\.$//'`
|
||||
fi
|
||||
if [ -x "$dpath" ]
|
||||
then
|
||||
@ -156,12 +156,12 @@ moz_debug_program()
|
||||
fi
|
||||
if [ -n "$moz_debugger" ]
|
||||
then
|
||||
moz_test_binary /bin/type
|
||||
moz_test_binary /bin/which
|
||||
if [ $? -eq 1 ]
|
||||
then
|
||||
debugger=`LC_MESSAGES=C type $moz_debugger | awk '{print $3;}' | sed -e 's/\.$//'`
|
||||
else
|
||||
debugger=`which $moz_debugger`
|
||||
else
|
||||
debugger=`LC_MESSAGES=C type $moz_debugger | awk '{print $3;}' | sed -e 's/\.$//'`
|
||||
fi
|
||||
else
|
||||
debugger=`moz_get_debugger`
|
||||
|
@ -139,8 +139,8 @@ endif
|
||||
testxpcobjdir = $(DEPTH)/_tests/xpcshell
|
||||
|
||||
# Test file installation
|
||||
ifeq (WINNT,$(HOST_OS_ARCH))
|
||||
# Windows nsinstall can't recursively copy directories, so use nsinstall.py
|
||||
ifneq (,$(filter WINNT os2-emx,$(HOST_OS_ARCH)))
|
||||
# Windows and OS/2 nsinstall can't recursively copy directories, so use nsinstall.py
|
||||
TEST_INSTALLER = $(PYTHON) $(topsrcdir)/config/nsinstall.py
|
||||
else
|
||||
TEST_INSTALLER = $(INSTALL)
|
||||
|
@ -768,16 +768,14 @@ nsAttrAndChildArray::GrowBy(PRUint32 aGrowSize)
|
||||
size = PR_BIT(PR_CeilingLog2(minSize));
|
||||
}
|
||||
|
||||
Impl* newImpl = static_cast<Impl*>
|
||||
(mImpl ? PR_Realloc(mImpl, size * sizeof(void*)) :
|
||||
PR_Malloc(size * sizeof(void*)));
|
||||
PRBool needToInitialize = !mImpl;
|
||||
Impl* newImpl = static_cast<Impl*>(PR_Realloc(mImpl, size * sizeof(void*)));
|
||||
NS_ENSURE_TRUE(newImpl, PR_FALSE);
|
||||
|
||||
Impl* oldImpl = mImpl;
|
||||
mImpl = newImpl;
|
||||
|
||||
// Set initial counts if we didn't have a buffer before
|
||||
if (!oldImpl) {
|
||||
if (needToInitialize) {
|
||||
mImpl->mMappedAttrs = nsnull;
|
||||
SetAttrSlotAndChildCount(0, 0);
|
||||
}
|
||||
|
@ -3719,25 +3719,25 @@ nsEventStateManager::CheckForAndDispatchClick(nsPresContext* aPresContext,
|
||||
NS_IMETHODIMP
|
||||
nsEventStateManager::GetEventTarget(nsIFrame **aFrame)
|
||||
{
|
||||
if (!mCurrentTarget && mCurrentTargetContent) {
|
||||
if (mPresContext) {
|
||||
nsIPresShell *shell = mPresContext->GetPresShell();
|
||||
if (shell) {
|
||||
mCurrentTarget = shell->GetPrimaryFrameFor(mCurrentTargetContent);
|
||||
}
|
||||
nsIPresShell *shell;
|
||||
if (mCurrentTarget ||
|
||||
!mPresContext ||
|
||||
!(shell = mPresContext->GetPresShell())) {
|
||||
*aFrame = mCurrentTarget;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (mCurrentTargetContent) {
|
||||
mCurrentTarget = shell->GetPrimaryFrameFor(mCurrentTargetContent);
|
||||
if (mCurrentTarget) {
|
||||
*aFrame = mCurrentTarget;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
if (!mCurrentTarget) {
|
||||
nsIPresShell *presShell = mPresContext->GetPresShell();
|
||||
if (presShell) {
|
||||
nsIFrame* frame = nsnull;
|
||||
presShell->GetEventTargetFrame(&frame);
|
||||
mCurrentTarget = frame;
|
||||
}
|
||||
}
|
||||
|
||||
*aFrame = mCurrentTarget;
|
||||
nsIFrame* frame = nsnull;
|
||||
shell->GetEventTargetFrame(&frame);
|
||||
*aFrame = mCurrentTarget = frame;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
12
content/html/content/crashtests/504183-1.html
Normal file
12
content/html/content/crashtests/504183-1.html
Normal file
@ -0,0 +1,12 @@
|
||||
<html class="reftest-wait">
|
||||
<input id="a" type="file">
|
||||
<script>
|
||||
function doe() {
|
||||
var elem = document.getElementById('a');
|
||||
elem.style.display = "none";
|
||||
elem.focus();
|
||||
document.documentElement.className = "";
|
||||
}
|
||||
setTimeout(doe, 0);
|
||||
</script>
|
||||
</html>
|
@ -9,3 +9,4 @@ load 382568-1.html
|
||||
load 423371-1.html
|
||||
load 451123-1.html
|
||||
load 453406-1.html
|
||||
load 504183-1.html
|
||||
|
@ -1368,6 +1368,7 @@ nsHTMLInputElement::Focus()
|
||||
nsIFocusManager* fm = nsFocusManager::GetFocusManager();
|
||||
if (fm && element)
|
||||
fm->SetFocus(element, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
childFrame = childFrame->GetNextSibling();
|
||||
|
@ -508,9 +508,7 @@ nsHTMLOptionElement::Initialize(nsISupports* aOwner,
|
||||
if (argc > 2) {
|
||||
// The third (optional) parameter is the defaultSelected value
|
||||
JSBool defaultSelected;
|
||||
if (!JS_ValueToBoolean(aContext, argv[2], &defaultSelected)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
JS_ValueToBoolean(aContext, argv[2], &defaultSelected);
|
||||
if (defaultSelected) {
|
||||
result = SetAttr(kNameSpaceID_None, nsGkAtoms::selected,
|
||||
EmptyString(), PR_FALSE);
|
||||
@ -520,9 +518,7 @@ nsHTMLOptionElement::Initialize(nsISupports* aOwner,
|
||||
// XXX This is *untested* behavior. Should work though.
|
||||
if (argc > 3) {
|
||||
JSBool selected;
|
||||
if (!JS_ValueToBoolean(aContext, argv[3], &selected)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
JS_ValueToBoolean(aContext, argv[3], &selected);
|
||||
|
||||
return SetSelected(selected);
|
||||
}
|
||||
|
@ -926,13 +926,14 @@ void nsOggDecodeStateMachine::PlayFrame() {
|
||||
if (time == prevTime)
|
||||
break;
|
||||
prevTime = time;
|
||||
if (time < frame->mTime) {
|
||||
mon.Wait(PR_MillisecondsToInterval(PRInt64((frame->mTime - time)*1000)));
|
||||
if (mState == DECODER_STATE_SHUTDOWN)
|
||||
return;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
// Is it time for the next frame? Using an integer here avoids f.p.
|
||||
// rounding errors that can cause multiple 0ms waits (Bug 495352)
|
||||
PRInt64 wait = PRInt64((frame->mTime - time)*1000);
|
||||
if (wait <= 0)
|
||||
break;
|
||||
mon.Wait(PR_MillisecondsToInterval(wait));
|
||||
if (mState == DECODER_STATE_SHUTDOWN)
|
||||
return;
|
||||
}
|
||||
|
||||
mDecodedFrames.Pop();
|
||||
|
@ -607,13 +607,11 @@ nsSMILAnimationFunction::ScaleIntervalProgress(double& aProgress,
|
||||
if (!HasAttr(nsGkAtoms::keySplines))
|
||||
return;
|
||||
|
||||
NS_ASSERTION(aIntervalIndex >= 0 &&
|
||||
aIntervalIndex < (PRUint32)mKeySplines.Length(),
|
||||
NS_ASSERTION(aIntervalIndex < (PRUint32)mKeySplines.Length(),
|
||||
"Invalid interval index.");
|
||||
NS_ASSERTION(aNumIntervals >= 1, "Invalid number of intervals.");
|
||||
|
||||
if (aIntervalIndex < 0 ||
|
||||
aIntervalIndex >= (PRUint32)mKeySplines.Length() ||
|
||||
if (aIntervalIndex >= (PRUint32)mKeySplines.Length() ||
|
||||
aNumIntervals < 1)
|
||||
return;
|
||||
|
||||
|
@ -932,8 +932,8 @@ nsSVGElement::GetOwnerSVGElement(nsIDOMSVGSVGElement * *aOwnerSVGElement)
|
||||
NS_IMETHODIMP
|
||||
nsSVGElement::GetViewportElement(nsIDOMSVGElement * *aViewportElement)
|
||||
{
|
||||
nsSVGUtils::GetNearestViewportElement(this, aViewportElement);
|
||||
return NS_OK; // we can't throw exceptions from this API.
|
||||
*aViewportElement = nsSVGUtils::GetNearestViewportElement(this).get();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -57,6 +57,7 @@
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "gfxContext.h"
|
||||
#include "gfxMatrix.h"
|
||||
#include "nsSVGLengthList.h"
|
||||
#include "nsIDOMSVGURIReference.h"
|
||||
#include "nsImageLoadingContent.h"
|
||||
@ -64,7 +65,6 @@
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsSVGPreserveAspectRatio.h"
|
||||
#include "nsIInterfaceRequestorUtils.h"
|
||||
#include "nsSVGMatrix.h"
|
||||
#include "nsSVGFilterElement.h"
|
||||
#include "nsSVGString.h"
|
||||
|
||||
@ -5392,17 +5392,19 @@ nsSVGFEImageElement::Filter(nsSVGFilterInstance *instance,
|
||||
imageContainer->GetWidth(&nativeWidth);
|
||||
imageContainer->GetHeight(&nativeHeight);
|
||||
|
||||
nsCOMPtr<nsIDOMSVGMatrix> trans;
|
||||
const gfxRect& filterSubregion = aTarget->mFilterPrimitiveSubregion;
|
||||
trans = nsSVGUtils::GetViewBoxTransform(filterSubregion.Width(), filterSubregion.Height(),
|
||||
0, 0, nativeWidth, nativeHeight,
|
||||
mPreserveAspectRatio);
|
||||
nsCOMPtr<nsIDOMSVGMatrix> xy, fini;
|
||||
NS_NewSVGMatrix(getter_AddRefs(xy), 1, 0, 0, 1, filterSubregion.X(), filterSubregion.Y());
|
||||
xy->Multiply(trans, getter_AddRefs(fini));
|
||||
|
||||
gfxMatrix viewBoxTM =
|
||||
nsSVGUtils::GetViewBoxTransform(filterSubregion.Width(), filterSubregion.Height(),
|
||||
0,0, nativeWidth, nativeHeight,
|
||||
mPreserveAspectRatio);
|
||||
|
||||
gfxMatrix xyTM = gfxMatrix().Translate(gfxPoint(filterSubregion.X(), filterSubregion.Y()));
|
||||
|
||||
gfxMatrix TM = viewBoxTM * xyTM;
|
||||
|
||||
gfxContext ctx(aTarget->mImage);
|
||||
nsSVGUtils::CompositePatternMatrix(&ctx, thebesPattern, fini, nativeWidth, nativeHeight, 1.0);
|
||||
nsSVGUtils::CompositePatternMatrix(&ctx, thebesPattern, TM, nativeWidth, nativeHeight, 1.0);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -117,25 +117,6 @@ nsSVGForeignObjectElement::PrependLocalTransformTo(const gfxMatrix &aMatrix)
|
||||
return gfxMatrix().Translate(gfxPoint(x, y)) * matrix;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsSVGForeignObjectElement::AppendTransform(nsIDOMSVGMatrix *aCTM,
|
||||
nsIDOMSVGMatrix **_retval)
|
||||
{
|
||||
nsresult rv;
|
||||
// foreignObject is one of establishing-viewport elements.
|
||||
// so we are translated by foreignObject's x and y attribs.
|
||||
float x, y;
|
||||
GetAnimatedLengthValues(&x, &y, nsnull);
|
||||
nsCOMPtr<nsIDOMSVGMatrix> translate;
|
||||
rv = NS_NewSVGMatrix(getter_AddRefs(translate), 1, 0, 0, 1, x, y);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsCOMPtr<nsIDOMSVGMatrix> tmp;
|
||||
rv = aCTM->Multiply(translate, getter_AddRefs(tmp));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return nsSVGGraphicElement::AppendTransform(tmp, _retval);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsIContent methods
|
||||
|
||||
|
@ -74,9 +74,6 @@ public:
|
||||
|
||||
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
|
||||
|
||||
// public helpers
|
||||
nsresult AppendTransform(nsIDOMSVGMatrix *aCTM,
|
||||
nsIDOMSVGMatrix **_retval);
|
||||
protected:
|
||||
|
||||
virtual LengthAttributesInfo GetLengthInfo();
|
||||
|
@ -75,14 +75,15 @@ nsSVGGraphicElement::nsSVGGraphicElement(nsINodeInfo *aNodeInfo)
|
||||
/* readonly attribute nsIDOMSVGElement nearestViewportElement; */
|
||||
NS_IMETHODIMP nsSVGGraphicElement::GetNearestViewportElement(nsIDOMSVGElement * *aNearestViewportElement)
|
||||
{
|
||||
nsSVGUtils::GetNearestViewportElement(this, aNearestViewportElement);
|
||||
return NS_OK; // we can't throw exceptions from this API.
|
||||
*aNearestViewportElement = nsSVGUtils::GetNearestViewportElement(this).get();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nsIDOMSVGElement farthestViewportElement; */
|
||||
NS_IMETHODIMP nsSVGGraphicElement::GetFarthestViewportElement(nsIDOMSVGElement * *aFarthestViewportElement)
|
||||
{
|
||||
return nsSVGUtils::GetFarthestViewportElement(this, aFarthestViewportElement);
|
||||
*aFarthestViewportElement = nsSVGUtils::GetFarthestViewportElement(this).get();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsIDOMSVGRect getBBox (); */
|
||||
@ -102,41 +103,20 @@ NS_IMETHODIMP nsSVGGraphicElement::GetBBox(nsIDOMSVGRect **_retval)
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
/* Helper for GetCTM and GetScreenCTM */
|
||||
nsresult
|
||||
nsSVGGraphicElement::AppendTransform(nsIDOMSVGMatrix *aCTM,
|
||||
nsIDOMSVGMatrix **_retval)
|
||||
{
|
||||
if (!mTransforms) {
|
||||
*_retval = aCTM;
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// append our local transformations
|
||||
nsCOMPtr<nsIDOMSVGTransformList> transforms;
|
||||
mTransforms->GetAnimVal(getter_AddRefs(transforms));
|
||||
NS_ENSURE_TRUE(transforms, NS_ERROR_FAILURE);
|
||||
nsCOMPtr<nsIDOMSVGMatrix> matrix =
|
||||
nsSVGTransformList::GetConsolidationMatrix(transforms);
|
||||
if (!matrix) {
|
||||
*_retval = aCTM;
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
return aCTM->Multiply(matrix, _retval); // addrefs, so we don't
|
||||
}
|
||||
|
||||
/* nsIDOMSVGMatrix getCTM (); */
|
||||
NS_IMETHODIMP nsSVGGraphicElement::GetCTM(nsIDOMSVGMatrix * *aCTM)
|
||||
{
|
||||
return nsSVGUtils::GetCTM(this, aCTM);
|
||||
gfxMatrix m = nsSVGUtils::GetCTM(this, PR_FALSE);
|
||||
*aCTM = m.IsSingular() ? nsnull : NS_NewSVGMatrix(m).get();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsIDOMSVGMatrix getScreenCTM (); */
|
||||
NS_IMETHODIMP nsSVGGraphicElement::GetScreenCTM(nsIDOMSVGMatrix * *aCTM)
|
||||
{
|
||||
return nsSVGUtils::GetScreenCTM(this, aCTM);
|
||||
gfxMatrix m = nsSVGUtils::GetCTM(this, PR_TRUE);
|
||||
*aCTM = m.IsSingular() ? nsnull : NS_NewSVGMatrix(m).get();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsIDOMSVGMatrix getTransformToElement (in nsIDOMSVGElement element); */
|
||||
|
@ -64,9 +64,6 @@ public:
|
||||
|
||||
virtual gfxMatrix PrependLocalTransformTo(const gfxMatrix &aMatrix);
|
||||
|
||||
// public helpers
|
||||
virtual nsresult AppendTransform(nsIDOMSVGMatrix *aCTM,
|
||||
nsIDOMSVGMatrix **_retval);
|
||||
protected:
|
||||
// nsSVGElement overrides
|
||||
virtual PRBool IsEventName(nsIAtom* aName);
|
||||
|
@ -38,7 +38,6 @@
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsSVGLength.h"
|
||||
#include "nsIDOMSVGMatrix.h"
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsSVGValue.h"
|
||||
#include "nsTextFormatter.h"
|
||||
|
@ -42,6 +42,7 @@
|
||||
#include "nsDOMError.h"
|
||||
#include "nsSVGUtils.h"
|
||||
#include "nsSVGMarkerElement.h"
|
||||
#include "gfxMatrix.h"
|
||||
|
||||
nsSVGElement::LengthInfo nsSVGMarkerElement::sLengthInfo[4] =
|
||||
{
|
||||
@ -376,10 +377,9 @@ nsSVGMarkerElement::GetPreserveAspectRatio()
|
||||
//----------------------------------------------------------------------
|
||||
// public helpers
|
||||
|
||||
nsresult
|
||||
gfxMatrix
|
||||
nsSVGMarkerElement::GetMarkerTransform(float aStrokeWidth,
|
||||
float aX, float aY, float aAngle,
|
||||
nsIDOMSVGMatrix **_retval)
|
||||
float aX, float aY, float aAngle)
|
||||
{
|
||||
float scale = 1.0;
|
||||
if (mEnumAttributes[MARKERUNITS].GetAnimValue() ==
|
||||
@ -390,22 +390,14 @@ nsSVGMarkerElement::GetMarkerTransform(float aStrokeWidth,
|
||||
aAngle = mAngleAttributes[ORIENT].GetAnimValue();
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMSVGMatrix> matrix;
|
||||
NS_NewSVGMatrix(getter_AddRefs(matrix),
|
||||
cos(aAngle) * scale, sin(aAngle) * scale,
|
||||
-sin(aAngle) * scale, cos(aAngle) * scale,
|
||||
aX, aY);
|
||||
|
||||
*_retval = matrix;
|
||||
NS_IF_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
return gfxMatrix(cos(aAngle) * scale, sin(aAngle) * scale,
|
||||
-sin(aAngle) * scale, cos(aAngle) * scale,
|
||||
aX, aY);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsSVGMarkerElement::GetViewboxToViewportTransform(nsIDOMSVGMatrix **_retval)
|
||||
gfxMatrix
|
||||
nsSVGMarkerElement::GetViewBoxTransform()
|
||||
{
|
||||
*_retval = nsnull;
|
||||
|
||||
if (!mViewBoxToViewportTransform) {
|
||||
float viewportWidth =
|
||||
mLengthAttributes[MARKERWIDTH].GetAnimValue(mCoordCtx);
|
||||
@ -415,32 +407,27 @@ nsSVGMarkerElement::GetViewboxToViewportTransform(nsIDOMSVGMatrix **_retval)
|
||||
const nsSVGViewBoxRect& viewbox = mViewBox.GetAnimValue();
|
||||
|
||||
if (viewbox.width <= 0.0f || viewbox.height <= 0.0f) {
|
||||
return NS_ERROR_FAILURE; // invalid - don't paint element
|
||||
return gfxMatrix(0.0, 0.0, 0.0, 0.0, 0.0, 0.0); // invalid - don't paint element
|
||||
}
|
||||
|
||||
float refX = mLengthAttributes[REFX].GetAnimValue(mCoordCtx);
|
||||
float refY = mLengthAttributes[REFY].GetAnimValue(mCoordCtx);
|
||||
|
||||
nsCOMPtr<nsIDOMSVGMatrix> vb2vp =
|
||||
gfxMatrix viewBoxTM =
|
||||
nsSVGUtils::GetViewBoxTransform(viewportWidth, viewportHeight,
|
||||
viewbox.x, viewbox.y,
|
||||
viewbox.width, viewbox.height,
|
||||
mPreserveAspectRatio,
|
||||
PR_TRUE);
|
||||
NS_ENSURE_TRUE(vb2vp, NS_ERROR_OUT_OF_MEMORY);
|
||||
gfxPoint ref = nsSVGUtils::ConvertSVGMatrixToThebes(vb2vp).
|
||||
Transform(gfxPoint(refX, refY));
|
||||
|
||||
nsCOMPtr<nsIDOMSVGMatrix> translate;
|
||||
NS_NewSVGMatrix(getter_AddRefs(translate),
|
||||
1.0f, 0.0f, 0.0f, 1.0f, -ref.x, -ref.y);
|
||||
NS_ENSURE_TRUE(translate, NS_ERROR_OUT_OF_MEMORY);
|
||||
translate->Multiply(vb2vp, getter_AddRefs(mViewBoxToViewportTransform));
|
||||
gfxPoint ref = viewBoxTM.Transform(gfxPoint(refX, refY));
|
||||
|
||||
gfxMatrix TM = viewBoxTM * gfxMatrix().Translate(gfxPoint(-ref.x, -ref.y));
|
||||
|
||||
mViewBoxToViewportTransform = NS_NewSVGMatrix(TM);
|
||||
}
|
||||
|
||||
*_retval = mViewBoxToViewportTransform;
|
||||
NS_IF_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
return nsSVGUtils::ConvertSVGMatrixToThebes(mViewBoxToViewportTransform);
|
||||
}
|
||||
|
||||
|
||||
|
@ -131,10 +131,9 @@ public:
|
||||
virtual void DidChangePreserveAspectRatio(PRBool aDoSetAttr);
|
||||
|
||||
// public helpers
|
||||
nsresult GetMarkerTransform(float aStrokeWidth,
|
||||
float aX, float aY, float aAngle,
|
||||
nsIDOMSVGMatrix **_retval);
|
||||
nsresult GetViewboxToViewportTransform(nsIDOMSVGMatrix **_retval);
|
||||
gfxMatrix GetMarkerTransform(float aStrokeWidth,
|
||||
float aX, float aY, float aAngle);
|
||||
gfxMatrix GetViewBoxTransform();
|
||||
|
||||
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
|
||||
|
||||
|
@ -102,7 +102,7 @@ nsSVGPathElement::GetTotalLength(float *_retval)
|
||||
{
|
||||
*_retval = 0;
|
||||
|
||||
nsRefPtr<gfxFlattenedPath> flat = GetFlattenedPath(nsnull);
|
||||
nsRefPtr<gfxFlattenedPath> flat = GetFlattenedPath(gfxMatrix());
|
||||
|
||||
if (!flat)
|
||||
return NS_ERROR_FAILURE;
|
||||
@ -118,7 +118,7 @@ nsSVGPathElement::GetPointAtLength(float distance, nsIDOMSVGPoint **_retval)
|
||||
{
|
||||
NS_ENSURE_FINITE(distance, NS_ERROR_ILLEGAL_VALUE);
|
||||
|
||||
nsRefPtr<gfxFlattenedPath> flat = GetFlattenedPath(nsnull);
|
||||
nsRefPtr<gfxFlattenedPath> flat = GetFlattenedPath(gfxMatrix());
|
||||
if (!flat)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
@ -494,16 +494,12 @@ nsSVGPathElement::DidModifySVGObservable(nsISVGValue* observable,
|
||||
}
|
||||
|
||||
already_AddRefed<gfxFlattenedPath>
|
||||
nsSVGPathElement::GetFlattenedPath(nsIDOMSVGMatrix *aMatrix)
|
||||
nsSVGPathElement::GetFlattenedPath(const gfxMatrix &aMatrix)
|
||||
{
|
||||
gfxContext ctx(nsSVGUtils::GetThebesComputationalSurface());
|
||||
|
||||
if (aMatrix) {
|
||||
ctx.SetMatrix(nsSVGUtils::ConvertSVGMatrixToThebes(aMatrix));
|
||||
}
|
||||
|
||||
ctx.SetMatrix(aMatrix);
|
||||
mPathData.Playback(&ctx);
|
||||
|
||||
ctx.IdentityMatrix();
|
||||
|
||||
return ctx.GetFlattenedPath();
|
||||
|
@ -104,7 +104,7 @@ public:
|
||||
virtual void GetMarkPoints(nsTArray<nsSVGMark> *aMarks);
|
||||
virtual void ConstructPath(gfxContext *aCtx);
|
||||
|
||||
virtual already_AddRefed<gfxFlattenedPath> GetFlattenedPath(nsIDOMSVGMatrix *aMatrix);
|
||||
virtual already_AddRefed<gfxFlattenedPath> GetFlattenedPath(const gfxMatrix &aMatrix);
|
||||
|
||||
// nsIContent interface
|
||||
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
|
||||
|
@ -67,7 +67,7 @@ nsSVGPathGeometryElement::GetMarkPoints(nsTArray<nsSVGMark> *aMarks)
|
||||
}
|
||||
|
||||
already_AddRefed<gfxFlattenedPath>
|
||||
nsSVGPathGeometryElement::GetFlattenedPath(nsIDOMSVGMatrix *aMatrix)
|
||||
nsSVGPathGeometryElement::GetFlattenedPath(const gfxMatrix &aMatrix)
|
||||
{
|
||||
return nsnull;
|
||||
}
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include "nsSVGGraphicElement.h"
|
||||
#include "nsTArray.h"
|
||||
#include "gfxPath.h"
|
||||
#include "gfxMatrix.h"
|
||||
|
||||
struct nsSVGMark {
|
||||
float x, y, angle;
|
||||
@ -47,7 +48,6 @@ struct nsSVGMark {
|
||||
x(aX), y(aY), angle(aAngle) {}
|
||||
};
|
||||
|
||||
class nsIDOMSVGMatrix;
|
||||
class gfxContext;
|
||||
|
||||
typedef nsSVGGraphicElement nsSVGPathGeometryElementBase;
|
||||
@ -61,7 +61,7 @@ public:
|
||||
virtual PRBool IsMarkable();
|
||||
virtual void GetMarkPoints(nsTArray<nsSVGMark> *aMarks);
|
||||
virtual void ConstructPath(gfxContext *aCtx) = 0;
|
||||
virtual already_AddRefed<gfxFlattenedPath> GetFlattenedPath(nsIDOMSVGMatrix *aMatrix);
|
||||
virtual already_AddRefed<gfxFlattenedPath> GetFlattenedPath(const gfxMatrix &aMatrix);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -40,7 +40,6 @@
|
||||
#include "nsSVGAnimatedTransformList.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsSVGMatrix.h"
|
||||
#include "nsSVGPatternElement.h"
|
||||
#include "nsIFrame.h"
|
||||
|
||||
|
@ -746,15 +746,16 @@ nsSVGSVGElement::GetPreserveAspectRatio(nsIDOMSVGAnimatedPreserveAspectRatio
|
||||
NS_IMETHODIMP
|
||||
nsSVGSVGElement::GetNearestViewportElement(nsIDOMSVGElement * *aNearestViewportElement)
|
||||
{
|
||||
nsSVGUtils::GetNearestViewportElement(this, aNearestViewportElement);
|
||||
return NS_OK; // we can't throw exceptions from this API.
|
||||
*aNearestViewportElement = nsSVGUtils::GetNearestViewportElement(this).get();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nsIDOMSVGElement farthestViewportElement; */
|
||||
NS_IMETHODIMP
|
||||
nsSVGSVGElement::GetFarthestViewportElement(nsIDOMSVGElement * *aFarthestViewportElement)
|
||||
{
|
||||
return nsSVGUtils::GetFarthestViewportElement(this, aFarthestViewportElement);
|
||||
*aFarthestViewportElement = nsSVGUtils::GetFarthestViewportElement(this).get();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsIDOMSVGRect getBBox (); */
|
||||
@ -775,68 +776,22 @@ nsSVGSVGElement::GetBBox(nsIDOMSVGRect **_retval)
|
||||
return NS_ERROR_NOT_IMPLEMENTED; // XXX: outer svg
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsSVGSVGElement::AppendTransform(nsIDOMSVGMatrix *aCTM,
|
||||
nsIDOMSVGMatrix **_retval)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
// first check what are our parents and calculate offsets accordingly.
|
||||
|
||||
float s=1, x=0, y=0;
|
||||
nsIContent *ancestor = nsSVGUtils::GetParentElement(this);
|
||||
if (ancestor && ancestor->GetNameSpaceID() == kNameSpaceID_SVG &&
|
||||
ancestor->Tag() == nsGkAtoms::foreignObject) {
|
||||
// this is a nested <svg> element. immediate parent is an <foreignObject> element.
|
||||
// we ignore this <svg> element's x and y attribs in layout so do the same.
|
||||
} else {
|
||||
nsCOMPtr<nsIDOMSVGElement> nearestViewportElement;
|
||||
rv = nsSVGUtils::GetNearestViewportElement(this, getter_AddRefs(nearestViewportElement));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (!nearestViewportElement) {
|
||||
if (IsRoot()) {
|
||||
// we're the root element. get our currentScale and currentTranslate vals
|
||||
s = mCurrentScale;
|
||||
x = mCurrentTranslate.GetX();
|
||||
y = mCurrentTranslate.GetY();
|
||||
} else {
|
||||
// we're inline in some non-SVG content. get our offset from the root
|
||||
GetOffsetToAncestor(nsnull, x, y);
|
||||
}
|
||||
} else {
|
||||
// this is a nested <svg> element.
|
||||
GetAnimatedLengthValues(&x, &y, nsnull);
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMSVGMatrix> local;
|
||||
rv = NS_NewSVGMatrix(getter_AddRefs(local), s, 0, 0, s, x, y);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// finally append our viewbox transform
|
||||
|
||||
nsCOMPtr<nsIDOMSVGMatrix> viewbox;
|
||||
rv = GetViewboxToViewportTransform(getter_AddRefs(viewbox));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsCOMPtr<nsIDOMSVGMatrix> tmp;
|
||||
rv = local->Multiply(viewbox, getter_AddRefs(tmp)); // addrefs, so we don't
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
return aCTM->Multiply(tmp, _retval); // addrefs, so we don't
|
||||
}
|
||||
|
||||
/* nsIDOMSVGMatrix getCTM (); */
|
||||
NS_IMETHODIMP
|
||||
nsSVGSVGElement::GetCTM(nsIDOMSVGMatrix * *aCTM)
|
||||
{
|
||||
return nsSVGUtils::GetCTM(this, aCTM);
|
||||
gfxMatrix m = nsSVGUtils::GetCTM(this, PR_FALSE);
|
||||
*aCTM = m.IsSingular() ? nsnull : NS_NewSVGMatrix(m).get();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsIDOMSVGMatrix getScreenCTM (); */
|
||||
NS_IMETHODIMP
|
||||
nsSVGSVGElement::GetScreenCTM(nsIDOMSVGMatrix **aCTM)
|
||||
{
|
||||
return nsSVGUtils::GetScreenCTM(this, aCTM);
|
||||
gfxMatrix m = nsSVGUtils::GetCTM(this, PR_TRUE);
|
||||
*aCTM = m.IsSingular() ? nsnull : NS_NewSVGMatrix(m).get();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsIDOMSVGMatrix getTransformToElement (in nsIDOMSVGElement element); */
|
||||
@ -1027,43 +982,36 @@ nsSVGSVGElement::IsEventName(nsIAtom* aName)
|
||||
//----------------------------------------------------------------------
|
||||
// public helpers:
|
||||
|
||||
nsresult
|
||||
nsSVGSVGElement::GetViewboxToViewportTransform(nsIDOMSVGMatrix **_retval)
|
||||
gfxMatrix
|
||||
nsSVGSVGElement::GetViewBoxTransform()
|
||||
{
|
||||
*_retval = nsnull;
|
||||
|
||||
float viewportWidth, viewportHeight;
|
||||
nsSVGSVGElement *ctx = GetCtx();
|
||||
if (!ctx) {
|
||||
// outer svg
|
||||
viewportWidth = mViewportWidth;
|
||||
viewportHeight = mViewportHeight;
|
||||
} else {
|
||||
if (nsSVGUtils::IsInnerSVG(this)) {
|
||||
nsSVGSVGElement *ctx = GetCtx();
|
||||
viewportWidth = mLengthAttributes[WIDTH].GetAnimValue(ctx);
|
||||
viewportHeight = mLengthAttributes[HEIGHT].GetAnimValue(ctx);
|
||||
}
|
||||
|
||||
nsSVGViewBoxRect viewbox;
|
||||
if (mViewBox.IsValid()) {
|
||||
viewbox = mViewBox.GetAnimValue();
|
||||
} else {
|
||||
viewbox.x = viewbox.y = 0.0f;
|
||||
viewbox.width = viewportWidth;
|
||||
viewbox.height = viewportHeight;
|
||||
viewportWidth = mViewportWidth;
|
||||
viewportHeight = mViewportHeight;
|
||||
}
|
||||
|
||||
if (viewbox.width <= 0.0f || viewbox.height <= 0.0f) {
|
||||
return NS_ERROR_FAILURE; // invalid - don't paint element
|
||||
nsSVGViewBoxRect viewBox;
|
||||
if (mViewBox.IsValid()) {
|
||||
viewBox = mViewBox.GetAnimValue();
|
||||
} else {
|
||||
viewBox.x = viewBox.y = 0.0f;
|
||||
viewBox.width = viewportWidth;
|
||||
viewBox.height = viewportHeight;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMSVGMatrix> xform =
|
||||
nsSVGUtils::GetViewBoxTransform(viewportWidth, viewportHeight,
|
||||
viewbox.x, viewbox.y,
|
||||
viewbox.width, viewbox.height,
|
||||
mPreserveAspectRatio);
|
||||
xform.swap(*_retval);
|
||||
if (viewBox.width <= 0.0f || viewBox.height <= 0.0f) {
|
||||
return gfxMatrix(0.0, 0.0, 0.0, 0.0, 0.0, 0.0); // singular
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
return nsSVGUtils::GetViewBoxTransform(viewportWidth, viewportHeight,
|
||||
viewBox.x, viewBox.y,
|
||||
viewBox.width, viewBox.height,
|
||||
mPreserveAspectRatio);
|
||||
}
|
||||
|
||||
#ifdef MOZ_SMIL
|
||||
@ -1124,43 +1072,6 @@ nsSVGSVGElement::UnbindFromTree(PRBool aDeep, PRBool aNullParent)
|
||||
//----------------------------------------------------------------------
|
||||
// implementation helpers
|
||||
|
||||
// if an ancestor isn't specified, obtains offset from root frame
|
||||
void nsSVGSVGElement::GetOffsetToAncestor(nsIContent* ancestor,
|
||||
float &x, float &y)
|
||||
{
|
||||
x = 0.0f;
|
||||
y = 0.0f;
|
||||
|
||||
nsIDocument *document = GetCurrentDoc();
|
||||
if (!document) return;
|
||||
|
||||
// Flush all pending notifications so that our frames are uptodate
|
||||
// Make sure to do this before we start grabbing layout objects like
|
||||
// presshells.
|
||||
document->FlushPendingNotifications(Flush_Layout);
|
||||
|
||||
nsIPresShell *presShell = document->GetPrimaryShell();
|
||||
if (!presShell) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsPresContext *context = presShell->GetPresContext();
|
||||
if (!context) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsIFrame* frame = presShell->GetPrimaryFrameFor(this);
|
||||
nsIFrame* ancestorFrame = ancestor ?
|
||||
presShell->GetPrimaryFrameFor(ancestor) :
|
||||
presShell->GetRootFrame();
|
||||
|
||||
if (frame && ancestorFrame) {
|
||||
nsPoint point = frame->GetOffsetTo(ancestorFrame);
|
||||
x = nsPresContext::AppUnitsToFloatCSSPixels(point.x);
|
||||
y = nsPresContext::AppUnitsToFloatCSSPixels(point.y);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef MOZ_SMIL
|
||||
PRBool
|
||||
nsSVGSVGElement::WillBeOutermostSVG(nsIContent* aParent,
|
||||
@ -1261,19 +1172,21 @@ nsSVGSVGElement::GetMMPerPx(PRUint8 aCtxType)
|
||||
/* virtual */ gfxMatrix
|
||||
nsSVGSVGElement::PrependLocalTransformTo(const gfxMatrix &aMatrix)
|
||||
{
|
||||
NS_ASSERTION(GetCtx(), "Should not be called on outer-<svg>");
|
||||
|
||||
float x, y;
|
||||
GetAnimatedLengthValues(&x, &y, nsnull);
|
||||
gfxMatrix matrix = aMatrix;
|
||||
matrix.PreMultiply(gfxMatrix().Translate(gfxPoint(x, y)));
|
||||
|
||||
nsCOMPtr<nsIDOMSVGMatrix> viewBoxTM;
|
||||
nsresult res = GetViewboxToViewportTransform(getter_AddRefs(viewBoxTM));
|
||||
if (NS_FAILED(res)) {
|
||||
return gfxMatrix(0.0, 0.0, 0.0, 0.0, 0.0, 0.0); // singular
|
||||
if (nsSVGUtils::IsInnerSVG(this)) {
|
||||
float x, y;
|
||||
GetAnimatedLengthValues(&x, &y, nsnull);
|
||||
return GetViewBoxTransform() * gfxMatrix().Translate(gfxPoint(x, y)) * aMatrix;
|
||||
}
|
||||
return matrix.PreMultiply(nsSVGUtils::ConvertSVGMatrixToThebes(viewBoxTM));
|
||||
|
||||
if (IsRoot()) {
|
||||
gfxMatrix zoomPanTM;
|
||||
zoomPanTM.Translate(gfxPoint(mCurrentTranslate.GetX(), mCurrentTranslate.GetY()));
|
||||
zoomPanTM.Scale(mCurrentScale, mCurrentScale);
|
||||
return GetViewBoxTransform() * zoomPanTM * aMatrix;
|
||||
}
|
||||
|
||||
// outer-<svg>, but inline in some other content:
|
||||
return GetViewBoxTransform() * aMatrix;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -199,9 +199,7 @@ public:
|
||||
float GetMMPerPx(PRUint8 mCtxType = 0);
|
||||
|
||||
// public helpers:
|
||||
nsresult GetViewboxToViewportTransform(nsIDOMSVGMatrix **_retval);
|
||||
nsresult AppendTransform(nsIDOMSVGMatrix *aCTM,
|
||||
nsIDOMSVGMatrix **_retval);
|
||||
gfxMatrix GetViewBoxTransform();
|
||||
|
||||
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
|
||||
|
||||
@ -226,7 +224,6 @@ protected:
|
||||
#endif // MOZ_SMIL
|
||||
|
||||
// implementation helpers:
|
||||
void GetOffsetToAncestor(nsIContent* ancestor, float &x, float &y);
|
||||
|
||||
PRBool IsRoot() {
|
||||
NS_ASSERTION((IsInDoc() && !GetParent()) ==
|
||||
|
@ -360,8 +360,7 @@ nsXBLWindowKeyHandler::WalkHandlers(nsIDOMKeyEvent* aKeyEvent, nsIAtom* aEventTy
|
||||
|
||||
WalkHandlersInternal(aKeyEvent, aEventType, mHandler);
|
||||
|
||||
nsINativeKeyBindings *nativeBindings;
|
||||
if (isEditor && (nativeBindings = GetEditorKeyBindings())) {
|
||||
if (isEditor && GetEditorKeyBindings()) {
|
||||
nsNativeKeyEvent nativeEvent;
|
||||
// get the DOM window we're attached to
|
||||
nsCOMPtr<nsIControllers> controllers;
|
||||
|
@ -7340,15 +7340,11 @@ nsEventReceiverSH::AddEventListenerHelper(JSContext *cx, JSObject *obj,
|
||||
}
|
||||
|
||||
JSBool useCapture;
|
||||
if (!JS_ValueToBoolean(cx, argv[2], &useCapture)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
JS_ValueToBoolean(cx, argv[2], &useCapture);
|
||||
|
||||
if (argc == 4) {
|
||||
JSBool wantsUntrusted;
|
||||
if (!JS_ValueToBoolean(cx, argv[3], &wantsUntrusted)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
JS_ValueToBoolean(cx, argv[3], &wantsUntrusted);
|
||||
|
||||
nsCOMPtr<nsIDOMNSEventTarget> eventTarget = do_QueryWrapper(cx, obj, &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
|
@ -1429,11 +1429,6 @@ public:
|
||||
nsLocation *aLocation,
|
||||
nsIXPConnectJSObjectHolder *aOuterProto);
|
||||
|
||||
// Get the contents of focus memory when the state was saved
|
||||
// (if the focus was inside of this window).
|
||||
nsIDOMElement* GetFocusedElement() { return mFocusedElement; }
|
||||
nsIDOMWindowInternal* GetFocusedWindow() { return mFocusedWindow; }
|
||||
|
||||
nsGlobalWindow* GetInnerWindow() { return mInnerWindow; }
|
||||
nsISupports* GetInnerWindowHolder(PRUint32 aScriptTypeID)
|
||||
{ return mInnerWindowHolders[NS_STID_INDEX(aScriptTypeID)]; }
|
||||
@ -1464,8 +1459,6 @@ protected:
|
||||
nsCOMPtr<nsISupports> mInnerWindowHolders[NS_STID_ARRAY_UBOUND];
|
||||
nsRefPtr<nsNavigator> mNavigator;
|
||||
nsRefPtr<nsLocation> mLocation;
|
||||
nsCOMPtr<nsIDOMElement> mFocusedElement;
|
||||
nsCOMPtr<nsIDOMWindowInternal> mFocusedWindow;
|
||||
nsCOMPtr<nsIXPConnectJSObjectHolder> mOuterProto;
|
||||
};
|
||||
|
||||
@ -1489,33 +1482,6 @@ WindowStateHolder::WindowStateHolder(nsGlobalWindow *aWindow,
|
||||
mInnerWindowHolders[lang_ndx] = aHolders[lang_ndx];
|
||||
}
|
||||
|
||||
nsIFocusManager* fm = nsFocusManager::GetFocusManager();
|
||||
if (fm) {
|
||||
// We want to save the focused element/window only if they are inside of
|
||||
// this window.
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> window;
|
||||
fm->GetFocusedWindow(getter_AddRefs(window));
|
||||
nsCOMPtr<nsPIDOMWindow> focusedWindow = do_QueryInterface(window);
|
||||
|
||||
// The outer window is used for focus purposes, so make sure that's what
|
||||
// we're looking for.
|
||||
nsPIDOMWindow *targetWindow = aWindow->GetOuterWindow();
|
||||
|
||||
while (focusedWindow) {
|
||||
if (focusedWindow == targetWindow) {
|
||||
mFocusedWindow = do_QueryInterface(window);
|
||||
fm->GetFocusedElement(getter_AddRefs(mFocusedElement));
|
||||
break;
|
||||
}
|
||||
|
||||
focusedWindow =
|
||||
static_cast<nsGlobalWindow*>
|
||||
(static_cast<nsPIDOMWindow*>
|
||||
(focusedWindow))->GetPrivateParent();
|
||||
}
|
||||
}
|
||||
|
||||
aWindow->SuspendTimeouts();
|
||||
}
|
||||
|
||||
@ -8521,17 +8487,8 @@ nsGlobalWindow::RestoreWindowState(nsISupports *aState)
|
||||
printf("restoring window state, state = %p\n", (void*)holder);
|
||||
#endif
|
||||
|
||||
nsGlobalWindow *inner = GetCurrentInnerWindowInternal();
|
||||
|
||||
nsIFocusManager* fm = nsFocusManager::GetFocusManager();
|
||||
nsIDOMElement *focusedElement = holder->GetFocusedElement();
|
||||
nsIDOMWindowInternal *focusedWindow = holder->GetFocusedWindow();
|
||||
if (fm && focusedElement)
|
||||
fm->SetFocus(focusedElement, nsIFocusManager::FLAG_NOSCROLL);
|
||||
else if (focusedWindow)
|
||||
focusedWindow->Focus();
|
||||
|
||||
// And we're ready to go!
|
||||
nsGlobalWindow *inner = GetCurrentInnerWindowInternal();
|
||||
inner->Thaw();
|
||||
|
||||
holder->DidRestoreWindow();
|
||||
|
@ -3012,8 +3012,7 @@ SetOptionsProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
if (((optbit & (optbit - 1)) == 0 && optbit <= JSOPTION_WERROR) ||
|
||||
optbit == JSOPTION_RELIMIT) {
|
||||
JSBool optval;
|
||||
if (! ::JS_ValueToBoolean(cx, *vp, &optval))
|
||||
return JS_FALSE;
|
||||
JS_ValueToBoolean(cx, *vp, &optval);
|
||||
|
||||
uint32 optset = ::JS_GetOptions(cx);
|
||||
if (optval)
|
||||
|
@ -86,7 +86,6 @@ nsDOMStorageMemoryDB::GetItemsTable(nsDOMStorage* aStorage,
|
||||
if (!storageData)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
storageData->mUsageDelta = 0;
|
||||
if (!storageData->mTable.Init()) {
|
||||
delete storageData;
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
@ -66,7 +66,7 @@ public:
|
||||
nsStorageItemsTable mTable;
|
||||
PRInt32 mUsageDelta;
|
||||
|
||||
nsInMemoryStorage() { mTable.Init(20); }
|
||||
nsInMemoryStorage() : mUsageDelta(0) { mTable.Init(20); }
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -69,7 +69,7 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(IMETextTxn)
|
||||
*aInstancePtr = (void*)(IMETextTxn*)this;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
} else
|
||||
NS_INTERFACE_MAP_END_INHERITING(EditTxn)
|
||||
|
||||
NS_IMETHODIMP IMETextTxn::Init(nsIDOMCharacterData *aElement,
|
||||
|
@ -64,7 +64,7 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(InsertTextTxn)
|
||||
*aInstancePtr = (void*)(InsertTextTxn*)this;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
} else
|
||||
NS_INTERFACE_MAP_END_INHERITING(EditTxn)
|
||||
|
||||
NS_IMETHODIMP InsertTextTxn::Init(nsIDOMCharacterData *aElement,
|
||||
|
@ -782,69 +782,67 @@ void
|
||||
nsHTMLCSSUtils::GetCSSPropertyAtom(nsCSSEditableProperty aProperty, nsIAtom ** aAtom)
|
||||
{
|
||||
*aAtom = nsnull;
|
||||
if (0 < aProperty) {
|
||||
switch (aProperty) {
|
||||
case eCSSEditableProperty_background_color:
|
||||
*aAtom = nsEditProperty::cssBackgroundColor;
|
||||
break;
|
||||
case eCSSEditableProperty_background_image:
|
||||
*aAtom = nsEditProperty::cssBackgroundImage;
|
||||
break;
|
||||
case eCSSEditableProperty_border:
|
||||
*aAtom = nsEditProperty::cssBorder;
|
||||
break;
|
||||
case eCSSEditableProperty_caption_side:
|
||||
*aAtom = nsEditProperty::cssCaptionSide;
|
||||
break;
|
||||
case eCSSEditableProperty_color:
|
||||
*aAtom = nsEditProperty::cssColor;
|
||||
break;
|
||||
case eCSSEditableProperty_float:
|
||||
*aAtom = nsEditProperty::cssFloat;
|
||||
break;
|
||||
case eCSSEditableProperty_font_family:
|
||||
*aAtom = nsEditProperty::cssFontFamily;
|
||||
break;
|
||||
case eCSSEditableProperty_font_size:
|
||||
*aAtom = nsEditProperty::cssFontSize;
|
||||
break;
|
||||
case eCSSEditableProperty_font_style:
|
||||
*aAtom = nsEditProperty::cssFontStyle;
|
||||
break;
|
||||
case eCSSEditableProperty_font_weight:
|
||||
*aAtom = nsEditProperty::cssFontWeight;
|
||||
break;
|
||||
case eCSSEditableProperty_height:
|
||||
*aAtom = nsEditProperty::cssHeight;
|
||||
break;
|
||||
case eCSSEditableProperty_list_style_type:
|
||||
*aAtom = nsEditProperty::cssListStyleType;
|
||||
break;
|
||||
case eCSSEditableProperty_margin_left:
|
||||
*aAtom = nsEditProperty::cssMarginLeft;
|
||||
break;
|
||||
case eCSSEditableProperty_margin_right:
|
||||
*aAtom = nsEditProperty::cssMarginRight;
|
||||
break;
|
||||
case eCSSEditableProperty_text_align:
|
||||
*aAtom = nsEditProperty::cssTextAlign;
|
||||
break;
|
||||
case eCSSEditableProperty_text_decoration:
|
||||
*aAtom = nsEditProperty::cssTextDecoration;
|
||||
break;
|
||||
case eCSSEditableProperty_vertical_align:
|
||||
*aAtom = nsEditProperty::cssVerticalAlign;
|
||||
break;
|
||||
case eCSSEditableProperty_whitespace:
|
||||
*aAtom = nsEditProperty::cssWhitespace;
|
||||
break;
|
||||
case eCSSEditableProperty_width:
|
||||
*aAtom = nsEditProperty::cssWidth;
|
||||
break;
|
||||
case eCSSEditableProperty_NONE:
|
||||
// intentionally empty
|
||||
break;
|
||||
}
|
||||
switch (aProperty) {
|
||||
case eCSSEditableProperty_background_color:
|
||||
*aAtom = nsEditProperty::cssBackgroundColor;
|
||||
break;
|
||||
case eCSSEditableProperty_background_image:
|
||||
*aAtom = nsEditProperty::cssBackgroundImage;
|
||||
break;
|
||||
case eCSSEditableProperty_border:
|
||||
*aAtom = nsEditProperty::cssBorder;
|
||||
break;
|
||||
case eCSSEditableProperty_caption_side:
|
||||
*aAtom = nsEditProperty::cssCaptionSide;
|
||||
break;
|
||||
case eCSSEditableProperty_color:
|
||||
*aAtom = nsEditProperty::cssColor;
|
||||
break;
|
||||
case eCSSEditableProperty_float:
|
||||
*aAtom = nsEditProperty::cssFloat;
|
||||
break;
|
||||
case eCSSEditableProperty_font_family:
|
||||
*aAtom = nsEditProperty::cssFontFamily;
|
||||
break;
|
||||
case eCSSEditableProperty_font_size:
|
||||
*aAtom = nsEditProperty::cssFontSize;
|
||||
break;
|
||||
case eCSSEditableProperty_font_style:
|
||||
*aAtom = nsEditProperty::cssFontStyle;
|
||||
break;
|
||||
case eCSSEditableProperty_font_weight:
|
||||
*aAtom = nsEditProperty::cssFontWeight;
|
||||
break;
|
||||
case eCSSEditableProperty_height:
|
||||
*aAtom = nsEditProperty::cssHeight;
|
||||
break;
|
||||
case eCSSEditableProperty_list_style_type:
|
||||
*aAtom = nsEditProperty::cssListStyleType;
|
||||
break;
|
||||
case eCSSEditableProperty_margin_left:
|
||||
*aAtom = nsEditProperty::cssMarginLeft;
|
||||
break;
|
||||
case eCSSEditableProperty_margin_right:
|
||||
*aAtom = nsEditProperty::cssMarginRight;
|
||||
break;
|
||||
case eCSSEditableProperty_text_align:
|
||||
*aAtom = nsEditProperty::cssTextAlign;
|
||||
break;
|
||||
case eCSSEditableProperty_text_decoration:
|
||||
*aAtom = nsEditProperty::cssTextDecoration;
|
||||
break;
|
||||
case eCSSEditableProperty_vertical_align:
|
||||
*aAtom = nsEditProperty::cssVerticalAlign;
|
||||
break;
|
||||
case eCSSEditableProperty_whitespace:
|
||||
*aAtom = nsEditProperty::cssWhitespace;
|
||||
break;
|
||||
case eCSSEditableProperty_width:
|
||||
*aAtom = nsEditProperty::cssWidth;
|
||||
break;
|
||||
case eCSSEditableProperty_NONE:
|
||||
// intentionally empty
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -227,7 +227,7 @@ EmbedPrompter::Create(PromptType aType, GtkWindow* aParentWindow)
|
||||
|
||||
if (aType == TYPE_UNIVERSAL) {
|
||||
// Create buttons based on the flags passed in.
|
||||
for (int i = EMBED_MAX_BUTTONS; i >= 0; --i) {
|
||||
for (PRUint32 i = EMBED_MAX_BUTTONS; i-- > 0; ) {
|
||||
if (!mButtonLabels[i].IsEmpty())
|
||||
gtk_dialog_add_button(GTK_DIALOG(mWindow),
|
||||
mButtonLabels[i].get(), i);
|
||||
|
@ -261,7 +261,7 @@ NS_IMETHODIMP nsWebBrowser::AddWebBrowserListener(nsIWeakReference *aListener, c
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsWebBrowser::BindListener(nsISupports *aListener, const nsIID& aIID) {
|
||||
NS_ASSERTION(aListener, "invalid args");
|
||||
NS_ENSURE_ARG_POINTER(aListener);
|
||||
NS_ASSERTION(mWebProgress, "this should only be called after we've retrieved a progress iface");
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
@ -269,6 +269,7 @@ NS_IMETHODIMP nsWebBrowser::BindListener(nsISupports *aListener, const nsIID& aI
|
||||
if (aIID.Equals(NS_GET_IID(nsIWebProgressListener))) {
|
||||
nsCOMPtr<nsIWebProgressListener> listener = do_QueryInterface(aListener, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
NS_ENSURE_STATE(mWebProgress);
|
||||
rv = mWebProgress->AddProgressListener(listener, nsIWebProgress::NOTIFY_ALL);
|
||||
}
|
||||
else if (aIID.Equals(NS_GET_IID(nsISHistoryListener))) {
|
||||
@ -325,7 +326,7 @@ NS_IMETHODIMP nsWebBrowser::RemoveWebBrowserListener(nsIWeakReference *aListener
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsWebBrowser::UnBindListener(nsISupports *aListener, const nsIID& aIID) {
|
||||
NS_ASSERTION(aListener, "invalid args");
|
||||
NS_ENSURE_ARG_POINTER(aListener);
|
||||
NS_ASSERTION(mWebProgress, "this should only be called after we've retrieved a progress iface");
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
@ -333,6 +334,7 @@ NS_IMETHODIMP nsWebBrowser::UnBindListener(nsISupports *aListener, const nsIID&
|
||||
if (aIID.Equals(NS_GET_IID(nsIWebProgressListener))) {
|
||||
nsCOMPtr<nsIWebProgressListener> listener = do_QueryInterface(aListener, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
NS_ENSURE_STATE(mWebProgress);
|
||||
rv = mWebProgress->RemoveProgressListener(listener);
|
||||
}
|
||||
else if (aIID.Equals(NS_GET_IID(nsISHistoryListener))) {
|
||||
@ -353,14 +355,7 @@ NS_IMETHODIMP nsWebBrowser::EnableGlobalHistory(PRBool aEnable)
|
||||
nsCOMPtr<nsIDocShellHistory> dsHistory(do_QueryInterface(mDocShell, &rv));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (aEnable) {
|
||||
rv = dsHistory->SetUseGlobalHistory(PR_TRUE);
|
||||
}
|
||||
else {
|
||||
rv = dsHistory->SetUseGlobalHistory(PR_FALSE);
|
||||
}
|
||||
|
||||
return rv;
|
||||
return dsHistory->SetUseGlobalHistory(aEnable);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsWebBrowser::GetContainerWindow(nsIWebBrowserChrome** aTopWindow)
|
||||
@ -972,7 +967,7 @@ NS_IMETHODIMP nsWebBrowser::SaveURI(
|
||||
// Create a throwaway persistence object to do the work
|
||||
nsresult rv;
|
||||
mPersist = do_CreateInstance(NS_WEBBROWSERPERSIST_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
mPersist->SetProgressListener(this);
|
||||
mPersist->SetPersistFlags(mPersistFlags);
|
||||
mPersist->GetCurrentState(&mPersistCurrentState);
|
||||
@ -1006,7 +1001,7 @@ NS_IMETHODIMP nsWebBrowser::SaveChannel(
|
||||
// Create a throwaway persistence object to do the work
|
||||
nsresult rv;
|
||||
mPersist = do_CreateInstance(NS_WEBBROWSERPERSIST_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
mPersist->SetProgressListener(this);
|
||||
mPersist->SetPersistFlags(mPersistFlags);
|
||||
mPersist->GetCurrentState(&mPersistCurrentState);
|
||||
@ -1058,7 +1053,7 @@ NS_IMETHODIMP nsWebBrowser::SaveDocument(
|
||||
// Create a throwaway persistence object to do the work
|
||||
nsresult rv;
|
||||
mPersist = do_CreateInstance(NS_WEBBROWSERPERSIST_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
mPersist->SetProgressListener(this);
|
||||
mPersist->SetPersistFlags(mPersistFlags);
|
||||
mPersist->GetCurrentState(&mPersistCurrentState);
|
||||
@ -1119,13 +1114,15 @@ NS_IMETHODIMP nsWebBrowser::Create()
|
||||
{
|
||||
NS_ENSURE_STATE(!mDocShell && (mParentNativeWindow || mParentWidget));
|
||||
|
||||
NS_ENSURE_SUCCESS(EnsureDocShellTreeOwner(), NS_ERROR_FAILURE);
|
||||
nsresult rv = EnsureDocShellTreeOwner();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIWidget> docShellParentWidget(mParentWidget);
|
||||
if(!mParentWidget) // We need to create a widget
|
||||
{
|
||||
// Create the widget
|
||||
NS_ENSURE_TRUE(mInternalWidget = do_CreateInstance(kChildCID), NS_ERROR_FAILURE);
|
||||
mInternalWidget = do_CreateInstance(kChildCID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
docShellParentWidget = mInternalWidget;
|
||||
nsWidgetInitData widgetInit;
|
||||
@ -1142,12 +1139,15 @@ NS_IMETHODIMP nsWebBrowser::Create()
|
||||
nsnull, nsnull, nsnull, &widgetInit);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDocShell> docShell(do_CreateInstance("@mozilla.org/docshell;1"));
|
||||
NS_ENSURE_SUCCESS(SetDocShell(docShell), NS_ERROR_FAILURE);
|
||||
nsCOMPtr<nsIDocShell> docShell(do_CreateInstance("@mozilla.org/docshell;1", &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = SetDocShell(docShell);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// get the system default window background colour
|
||||
{
|
||||
nsCOMPtr<nsILookAndFeel> laf = do_GetService(kLookAndFeelCID);
|
||||
if (laf)
|
||||
laf->GetColor(nsILookAndFeel::eColor_WindowBackground, mBackgroundColor);
|
||||
}
|
||||
|
||||
@ -1202,18 +1202,19 @@ NS_IMETHODIMP nsWebBrowser::Create()
|
||||
// events from subframes. To solve that we install our own chrome event handler
|
||||
// that always gets called (even for subframes) for any bubbling event.
|
||||
|
||||
if(!mInitInfo->sessionHistory)
|
||||
mInitInfo->sessionHistory = do_CreateInstance(NS_SHISTORY_CONTRACTID);
|
||||
NS_ENSURE_TRUE(mInitInfo->sessionHistory, NS_ERROR_FAILURE);
|
||||
if (!mInitInfo->sessionHistory) {
|
||||
mInitInfo->sessionHistory = do_CreateInstance(NS_SHISTORY_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
mDocShellAsNav->SetSessionHistory(mInitInfo->sessionHistory);
|
||||
|
||||
// Hook up global history. Do not fail if we can't - just warn.
|
||||
nsresult rv = EnableGlobalHistory(mShouldEnableHistory);
|
||||
rv = EnableGlobalHistory(mShouldEnableHistory);
|
||||
NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "EnableGlobalHistory() failed");
|
||||
|
||||
NS_ENSURE_SUCCESS(mDocShellAsWin->Create(), NS_ERROR_FAILURE);
|
||||
|
||||
// Hook into the OnSecurirtyChange() notification for lock/unlock icon
|
||||
// Hook into the OnSecurityChange() notification for lock/unlock icon
|
||||
// updates
|
||||
nsCOMPtr<nsIDOMWindow> domWindow;
|
||||
rv = GetContentDOMWindow(getter_AddRefs(domWindow));
|
||||
@ -1224,7 +1225,8 @@ NS_IMETHODIMP nsWebBrowser::Create()
|
||||
// and calls docShell->SetSecurityUI(this);
|
||||
nsCOMPtr<nsISecureBrowserUI> securityUI =
|
||||
do_CreateInstance(NS_SECURE_BROWSER_UI_CONTRACTID, &rv);
|
||||
if (NS_SUCCEEDED(rv)) securityUI->Init(domWindow);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
securityUI->Init(domWindow);
|
||||
}
|
||||
|
||||
mDocShellTreeOwner->AddToWatcher(); // evil twin of Remove in SetDocShell(0)
|
||||
@ -1827,6 +1829,9 @@ NS_IMETHODIMP nsWebBrowser::OpenStream(nsIURI *aBaseURI, const nsACString& aCont
|
||||
|
||||
if (!mStream) {
|
||||
mStream = new nsEmbedStream();
|
||||
if (!mStream)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
mStreamGuard = do_QueryInterface(mStream);
|
||||
mStream->InitOwner(this);
|
||||
rv = mStream->Init();
|
||||
|
@ -200,7 +200,7 @@ struct tag_index {
|
||||
static struct tag_index read_tag_table(qcms_profile *profile, struct mem_source *mem)
|
||||
{
|
||||
struct tag_index index = {0, NULL};
|
||||
int i;
|
||||
unsigned int i;
|
||||
|
||||
index.count = read_u32(mem, 128);
|
||||
if (index.count > MAX_TAG_COUNT) {
|
||||
@ -297,7 +297,7 @@ qcms_bool qcms_profile_is_bogus(qcms_profile *profile)
|
||||
|
||||
static struct tag *find_tag(struct tag_index index, uint32_t tag_id)
|
||||
{
|
||||
int i;
|
||||
unsigned int i;
|
||||
struct tag *tag = NULL;
|
||||
for (i = 0; i < index.count; i++) {
|
||||
if (index.tags[i].signature == tag_id) {
|
||||
@ -314,7 +314,7 @@ static struct tag *find_tag(struct tag_index index, uint32_t tag_id)
|
||||
|
||||
static struct XYZNumber read_tag_XYZType(struct mem_source *src, struct tag_index index, uint32_t tag_id)
|
||||
{
|
||||
struct XYZNumber num = {0};
|
||||
struct XYZNumber num = {0, 0, 0};
|
||||
struct tag *tag = find_tag(index, tag_id);
|
||||
if (tag) {
|
||||
uint32_t offset = tag->offset;
|
||||
@ -339,7 +339,7 @@ static struct curveType *read_tag_curveType(struct mem_source *src, struct tag_i
|
||||
uint32_t offset = tag->offset;
|
||||
uint32_t type = read_u32(src, offset);
|
||||
uint32_t count = read_u32(src, offset+8);
|
||||
int i;
|
||||
unsigned int i;
|
||||
|
||||
if (type != CURVE_TYPE) {
|
||||
invalid_source(src, "unexpected type, expected CURV");
|
||||
|
@ -651,7 +651,7 @@ static void qcms_transform_data_rgb_out_pow(qcms_transform *transform, unsigned
|
||||
|
||||
static void qcms_transform_data_gray_out_lut(qcms_transform *transform, unsigned char *src, unsigned char *dest, size_t length)
|
||||
{
|
||||
int i;
|
||||
unsigned int i;
|
||||
for (i = 0; i < length; i++) {
|
||||
float out_device_r, out_device_g, out_device_b;
|
||||
unsigned char device = *src++;
|
||||
@ -676,7 +676,7 @@ static void qcms_transform_data_gray_out_lut(qcms_transform *transform, unsigned
|
||||
|
||||
static void qcms_transform_data_graya_out_lut(qcms_transform *transform, unsigned char *src, unsigned char *dest, size_t length)
|
||||
{
|
||||
int i;
|
||||
unsigned int i;
|
||||
for (i = 0; i < length; i++) {
|
||||
float out_device_r, out_device_g, out_device_b;
|
||||
unsigned char device = *src++;
|
||||
@ -698,7 +698,7 @@ static void qcms_transform_data_graya_out_lut(qcms_transform *transform, unsigne
|
||||
|
||||
static void qcms_transform_data_gray_out_precache(qcms_transform *transform, unsigned char *src, unsigned char *dest, size_t length)
|
||||
{
|
||||
int i;
|
||||
unsigned int i;
|
||||
for (i = 0; i < length; i++) {
|
||||
unsigned char device = *src++;
|
||||
uint16_t gray;
|
||||
@ -716,7 +716,7 @@ static void qcms_transform_data_gray_out_precache(qcms_transform *transform, uns
|
||||
|
||||
static void qcms_transform_data_graya_out_precache(qcms_transform *transform, unsigned char *src, unsigned char *dest, size_t length)
|
||||
{
|
||||
int i;
|
||||
unsigned int i;
|
||||
for (i = 0; i < length; i++) {
|
||||
unsigned char device = *src++;
|
||||
unsigned char alpha = *src++;
|
||||
@ -806,7 +806,7 @@ void qcms_transform_data_rgb_out_lut_sse_intrin(qcms_transform *transform, unsig
|
||||
|
||||
static void qcms_transform_data_rgb_out_lut_sse(qcms_transform *transform, unsigned char *src, unsigned char *dest, size_t length)
|
||||
{
|
||||
int i;
|
||||
unsigned int i;
|
||||
float (*mat)[4] = transform->matrix;
|
||||
char input_back[32];
|
||||
/* Ensure we have a buffer that's 16 byte aligned regardless of the original
|
||||
@ -944,7 +944,7 @@ static void qcms_transform_data_rgb_out_lut_sse(qcms_transform *transform, unsig
|
||||
|
||||
static void qcms_transform_data_rgba_out_lut_sse(qcms_transform *transform, unsigned char *src, unsigned char *dest, size_t length)
|
||||
{
|
||||
int i;
|
||||
unsigned int i;
|
||||
float (*mat)[4] = transform->matrix;
|
||||
char input_back[32];
|
||||
/* align input on 16 byte boundary */
|
||||
@ -1082,7 +1082,7 @@ static void qcms_transform_data_rgba_out_lut_sse(qcms_transform *transform, unsi
|
||||
|
||||
static void qcms_transform_data_rgb_out_lut_precache(qcms_transform *transform, unsigned char *src, unsigned char *dest, size_t length)
|
||||
{
|
||||
int i;
|
||||
unsigned int i;
|
||||
float (*mat)[4] = transform->matrix;
|
||||
for (i = 0; i < length; i++) {
|
||||
unsigned char device_r = *src++;
|
||||
@ -1115,7 +1115,7 @@ static void qcms_transform_data_rgb_out_lut_precache(qcms_transform *transform,
|
||||
|
||||
static void qcms_transform_data_rgba_out_lut_precache(qcms_transform *transform, unsigned char *src, unsigned char *dest, size_t length)
|
||||
{
|
||||
int i;
|
||||
unsigned int i;
|
||||
float (*mat)[4] = transform->matrix;
|
||||
for (i = 0; i < length; i++) {
|
||||
unsigned char device_r = *src++;
|
||||
@ -1150,7 +1150,7 @@ static void qcms_transform_data_rgba_out_lut_precache(qcms_transform *transform,
|
||||
|
||||
static void qcms_transform_data_rgb_out_lut(qcms_transform *transform, unsigned char *src, unsigned char *dest, size_t length)
|
||||
{
|
||||
int i;
|
||||
unsigned int i;
|
||||
float (*mat)[4] = transform->matrix;
|
||||
for (i = 0; i < length; i++) {
|
||||
unsigned char device_r = *src++;
|
||||
@ -1182,7 +1182,7 @@ static void qcms_transform_data_rgb_out_lut(qcms_transform *transform, unsigned
|
||||
|
||||
static void qcms_transform_data_rgba_out_lut(qcms_transform *transform, unsigned char *src, unsigned char *dest, size_t length)
|
||||
{
|
||||
int i;
|
||||
unsigned int i;
|
||||
float (*mat)[4] = transform->matrix;
|
||||
for (i = 0; i < length; i++) {
|
||||
unsigned char device_r = *src++;
|
||||
|
@ -292,6 +292,14 @@ public:
|
||||
|
||||
#define TRUETYPE_TAG(a, b, c, d) ((a) << 24 | (b) << 16 | (c) << 8 | (d))
|
||||
|
||||
// used for overlaying name changes without touching original font data
|
||||
struct FontDataOverlay {
|
||||
// overlaySrc != 0 ==> use overlay
|
||||
PRUint32 overlaySrc; // src offset from start of font data
|
||||
PRUint32 overlaySrcLen; // src length
|
||||
PRUint32 overlayDest; // dest offset from start of font data
|
||||
};
|
||||
|
||||
class THEBES_API gfxFontUtils {
|
||||
|
||||
public:
|
||||
@ -332,6 +340,7 @@ public:
|
||||
PRPackedBool& aUnicodeFont, PRPackedBool& aSymbolFont);
|
||||
|
||||
#ifdef XP_WIN
|
||||
|
||||
// given a TrueType/OpenType data file, produce a EOT-format header
|
||||
// for use with Windows T2Embed API AddFontResource type API's
|
||||
// effectively hide existing fonts with matching names aHeaderLen is
|
||||
@ -339,7 +348,7 @@ public:
|
||||
// EOT header on output
|
||||
static nsresult
|
||||
MakeEOTHeader(const PRUint8 *aFontData, PRUint32 aFontDataLength,
|
||||
nsTArray<PRUint8> *aHeader);
|
||||
nsTArray<PRUint8> *aHeader, FontDataOverlay *aOverlay);
|
||||
#endif
|
||||
|
||||
// checks for valid SFNT table structure, returns true if valid
|
||||
|
@ -1372,13 +1372,15 @@ DumpEOTHeader(PRUint8 *aHeader, PRUint32 aHeaderLen)
|
||||
|
||||
nsresult
|
||||
gfxFontUtils::MakeEOTHeader(const PRUint8 *aFontData, PRUint32 aFontDataLength,
|
||||
nsTArray<PRUint8> *aHeader)
|
||||
nsTArray<PRUint8> *aHeader, FontDataOverlay *aOverlay)
|
||||
{
|
||||
|
||||
NS_ASSERTION(aFontData && aFontDataLength != 0, "null font data");
|
||||
NS_ASSERTION(aHeader, "null header");
|
||||
NS_ASSERTION(aHeader->Length() == 0, "non-empty header passed in");
|
||||
NS_ASSERTION(aOverlay, "null font overlay struct passed in");
|
||||
|
||||
aOverlay->overlaySrc = 0;
|
||||
|
||||
if (!aHeader->AppendElements(sizeof(EOTFixedHeader)))
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
@ -1481,6 +1483,7 @@ gfxFontUtils::MakeEOTHeader(const PRUint8 *aFontData, PRUint32 aFontDataLength,
|
||||
|
||||
// -- first, read name table header
|
||||
const NameHeader *nameHeader = reinterpret_cast<const NameHeader*>(aFontData + nameOffset);
|
||||
PRUint32 nameStringsBase = PRUint32(nameHeader->stringOffset);
|
||||
|
||||
PRUint32 nameCount = nameHeader->count;
|
||||
|
||||
@ -1542,7 +1545,7 @@ gfxFontUtils::MakeEOTHeader(const PRUint8 *aFontData, PRUint32 aFontDataLength,
|
||||
if (needNames != 0)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
// -- expand buffer if needed to include variable-length portion
|
||||
PRUint32 eotVariableLength = 0;
|
||||
@ -1566,10 +1569,12 @@ gfxFontUtils::MakeEOTHeader(const PRUint8 *aFontData, PRUint32 aFontDataLength,
|
||||
PRUint32 nameoff = names[i].offset; // offset from base of string storage
|
||||
|
||||
// sanity check the name string location
|
||||
if (PRUint64(nameOffset) + PRUint64(PRUint32(nameHeader->stringOffset)) + PRUint64(nameoff) + PRUint64(namelen) > dataLength)
|
||||
if (PRUint64(nameOffset) + PRUint64(nameStringsBase) + PRUint64(nameoff)
|
||||
+ PRUint64(namelen) > dataLength) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
strOffset = nameOffset + PRUint32(nameHeader->stringOffset) + nameoff + namelen;
|
||||
strOffset = nameOffset + nameStringsBase + nameoff + namelen;
|
||||
|
||||
// output 2-byte str size
|
||||
strLen = namelen & (~1); // UTF-16 string len must be even
|
||||
@ -1599,6 +1604,23 @@ gfxFontUtils::MakeEOTHeader(const PRUint8 *aFontData, PRUint32 aFontDataLength,
|
||||
NS_ASSERTION(eotEnd == aHeader->Elements() + aHeader->Length(),
|
||||
"header length calculation incorrect");
|
||||
|
||||
// bug 496573 -- fonts with a fullname that does not begin with the
|
||||
// family name cause the EOT font loading API to hiccup
|
||||
PRUint32 famOff = names[EOTFixedHeader::EOT_FAMILY_NAME_INDEX].offset;
|
||||
PRUint32 famLen = names[EOTFixedHeader::EOT_FAMILY_NAME_INDEX].length;
|
||||
PRUint32 fullOff = names[EOTFixedHeader::EOT_FULL_NAME_INDEX].offset;
|
||||
PRUint32 fullLen = names[EOTFixedHeader::EOT_FULL_NAME_INDEX].length;
|
||||
|
||||
const PRUint8 *nameStrings = aFontData + nameOffset + nameStringsBase;
|
||||
|
||||
// assure that the start of the fullname matches the family name
|
||||
if (famLen <= fullLen
|
||||
&& memcmp(nameStrings + famOff, nameStrings + fullOff, famLen)) {
|
||||
aOverlay->overlaySrc = nameOffset + nameStringsBase + famOff;
|
||||
aOverlay->overlaySrcLen = famLen;
|
||||
aOverlay->overlayDest = nameOffset + nameStringsBase + fullOff;
|
||||
}
|
||||
|
||||
// -- OS/2 table data
|
||||
const OS2Table *os2Data = reinterpret_cast<const OS2Table*>(aFontData + os2Offset);
|
||||
|
||||
|
@ -100,6 +100,7 @@ static cairo_scaled_font_t *CreateScaledFont(FcPattern *aPattern);
|
||||
|
||||
static PangoFontMap *gPangoFontMap;
|
||||
static PangoFontMap *GetPangoFontMap();
|
||||
static PRBool gPangoFontHasFontMapProperty;
|
||||
|
||||
static FT_Library gFTLibrary;
|
||||
static nsILanguageAtomService* gLangService;
|
||||
@ -644,11 +645,24 @@ struct gfxPangoFcFont {
|
||||
FcPatternReference(aRequestedPattern);
|
||||
font->mRequestedPattern = aRequestedPattern;
|
||||
|
||||
// PangoFcFont::get_coverage wants an FcFontMap. (PangoFcFontMap
|
||||
// usually sets this after calling PangoFcFontMap::create_font().)
|
||||
// PangoFcFont::get_coverage wants a PangoFcFontMap. (PangoFcFontMap
|
||||
// would usually set this after calling PangoFcFontMap::create_font()
|
||||
// or new_font().)
|
||||
PangoFontMap *fontmap = GetPangoFontMap();
|
||||
// In Pango-1.24, this is a property; by setting the property, the
|
||||
// PangoFcFont base class manages the pointer (as a weak reference).
|
||||
PangoFcFont *fc_font = &font->parent_instance;
|
||||
fc_font->fontmap = GetPangoFontMap();
|
||||
g_object_ref(fc_font->fontmap);
|
||||
if (gPangoFontHasFontMapProperty) {
|
||||
g_object_set(font, "fontmap", fontmap, NULL);
|
||||
} else {
|
||||
// In Pango versions up to 1.20.5, the parent class will decrement
|
||||
// the reference count of the fontmap during shutdown() or
|
||||
// finalize() of the font. In Pango 1.22.x versions this no
|
||||
// longer happens, so we'll end up leaking the (singleton)
|
||||
// fontmap.
|
||||
fc_font->fontmap = fontmap;
|
||||
g_object_ref(fc_font->fontmap);
|
||||
}
|
||||
|
||||
return nsReturnRef<PangoFont>(PANGO_FONT(font));
|
||||
}
|
||||
@ -725,8 +739,6 @@ gfx_pango_fc_font_finalize(GObject *object)
|
||||
pango_coverage_unref(self->mCoverage);
|
||||
NS_IF_RELEASE(self->mGfxFont);
|
||||
|
||||
// The parent class removes the reference to parent_instance->fontmap.
|
||||
|
||||
G_OBJECT_CLASS(gfx_pango_fc_font_parent_class)->finalize(object);
|
||||
}
|
||||
|
||||
@ -921,6 +933,10 @@ gfx_pango_fc_font_class_init (gfxPangoFcFontClass *klass)
|
||||
fc_font_class->lock_face = gfx_pango_fc_font_lock_face;
|
||||
fc_font_class->unlock_face = gfx_pango_fc_font_unlock_face;
|
||||
fc_font_class->get_glyph = gfx_pango_fc_font_get_glyph;
|
||||
|
||||
gPangoFontHasFontMapProperty =
|
||||
g_object_class_find_property(G_OBJECT_CLASS(gfx_pango_fc_font_parent_class),
|
||||
"fontmap") != NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2105,7 +2121,8 @@ gfxPangoFontGroup::Shutdown()
|
||||
if (gPangoFontMap) {
|
||||
if (PANGO_IS_FC_FONT_MAP (gPangoFontMap)) {
|
||||
// This clears circular references from the fontmap to itself
|
||||
// through its fonts.
|
||||
// through its fonts. (This is actually unnecessary with Pango
|
||||
// versions >= 1.22.)
|
||||
pango_fc_font_map_shutdown(PANGO_FC_FONT_MAP(gPangoFontMap));
|
||||
}
|
||||
g_object_unref(gPangoFontMap);
|
||||
|
@ -411,13 +411,13 @@ void FontEntry::InitializeFontEmbeddingProcs()
|
||||
|
||||
class WinUserFontData : public gfxUserFontData {
|
||||
public:
|
||||
WinUserFontData(HANDLE aFontRef, PRBool aIsCFF)
|
||||
: mFontRef(aFontRef), mIsCFF(aIsCFF)
|
||||
WinUserFontData(HANDLE aFontRef, PRBool aIsEmbeddedFont)
|
||||
: mFontRef(aFontRef), mIsEmbeddedFont(aIsEmbeddedFont)
|
||||
{ }
|
||||
|
||||
virtual ~WinUserFontData()
|
||||
{
|
||||
if (mIsCFF) {
|
||||
if (!mIsEmbeddedFont) {
|
||||
RemoveFontMemResourceEx(mFontRef);
|
||||
} else {
|
||||
ULONG pulStatus;
|
||||
@ -426,7 +426,7 @@ public:
|
||||
}
|
||||
|
||||
HANDLE mFontRef;
|
||||
PRPackedBool mIsCFF;
|
||||
PRPackedBool mIsEmbeddedFont;
|
||||
};
|
||||
|
||||
// used to control stream read by Windows TTLoadEmbeddedFont API
|
||||
@ -434,12 +434,36 @@ public:
|
||||
class EOTFontStreamReader {
|
||||
public:
|
||||
EOTFontStreamReader(const PRUint8 *aFontData, PRUint32 aLength, PRUint8 *aEOTHeader,
|
||||
PRUint32 aEOTHeaderLen)
|
||||
: mInHeader(PR_TRUE), mHeaderOffset(0), mEOTHeader(aEOTHeader),
|
||||
mEOTHeaderLen(aEOTHeaderLen), mFontData(aFontData), mFontDataLen(aLength),
|
||||
mFontDataOffset(0)
|
||||
PRUint32 aEOTHeaderLen, FontDataOverlay *aNameOverlay)
|
||||
: mCurrentChunk(0), mChunkOffset(0)
|
||||
{
|
||||
|
||||
NS_ASSERTION(aFontData, "null font data ptr passed in");
|
||||
NS_ASSERTION(aEOTHeader, "null EOT header ptr passed in");
|
||||
NS_ASSERTION(aNameOverlay, "null name overlay struct passed in");
|
||||
|
||||
if (aNameOverlay->overlaySrc) {
|
||||
mNumChunks = 4;
|
||||
// 0 : EOT header
|
||||
mDataChunks[0].mData = aEOTHeader;
|
||||
mDataChunks[0].mLength = aEOTHeaderLen;
|
||||
// 1 : start of font data to overlayDest
|
||||
mDataChunks[1].mData = aFontData;
|
||||
mDataChunks[1].mLength = aNameOverlay->overlayDest;
|
||||
// 2 : overlay data
|
||||
mDataChunks[2].mData = aFontData + aNameOverlay->overlaySrc;
|
||||
mDataChunks[2].mLength = aNameOverlay->overlaySrcLen;
|
||||
// 3 : rest of font data
|
||||
mDataChunks[3].mData = aFontData + aNameOverlay->overlayDest + aNameOverlay->overlaySrcLen;
|
||||
mDataChunks[3].mLength = aLength - aNameOverlay->overlayDest - aNameOverlay->overlaySrcLen;
|
||||
} else {
|
||||
mNumChunks = 2;
|
||||
// 0 : EOT header
|
||||
mDataChunks[0].mData = aEOTHeader;
|
||||
mDataChunks[0].mLength = aEOTHeaderLen;
|
||||
// 1 : font data
|
||||
mDataChunks[1].mData = aFontData;
|
||||
mDataChunks[1].mLength = aLength;
|
||||
}
|
||||
}
|
||||
|
||||
~EOTFontStreamReader()
|
||||
@ -447,37 +471,36 @@ public:
|
||||
|
||||
}
|
||||
|
||||
PRPackedBool mInHeader;
|
||||
PRUint32 mHeaderOffset;
|
||||
PRUint8 *mEOTHeader;
|
||||
PRUint32 mEOTHeaderLen;
|
||||
const PRUint8 *mFontData;
|
||||
PRUint32 mFontDataLen;
|
||||
PRUint32 mFontDataOffset;
|
||||
struct FontDataChunk {
|
||||
const PRUint8 *mData;
|
||||
PRUint32 mLength;
|
||||
};
|
||||
|
||||
PRUint32 mNumChunks;
|
||||
FontDataChunk mDataChunks[4];
|
||||
PRUint32 mCurrentChunk;
|
||||
PRUint32 mChunkOffset;
|
||||
|
||||
unsigned long Read(void *outBuffer, const unsigned long aBytesToRead)
|
||||
{
|
||||
PRUint32 bytesLeft = aBytesToRead;
|
||||
PRUint32 bytesLeft = aBytesToRead; // bytes left in the out buffer
|
||||
PRUint8 *out = static_cast<PRUint8*> (outBuffer);
|
||||
|
||||
// read from EOT header
|
||||
if (mInHeader) {
|
||||
PRUint32 toCopy = PR_MIN(aBytesToRead, mEOTHeaderLen - mHeaderOffset);
|
||||
memcpy(out, mEOTHeader + mHeaderOffset, toCopy);
|
||||
bytesLeft -= toCopy;
|
||||
mHeaderOffset += toCopy;
|
||||
out += toCopy;
|
||||
if (mHeaderOffset == mEOTHeaderLen)
|
||||
mInHeader = PR_FALSE;
|
||||
}
|
||||
while (mCurrentChunk < mNumChunks && bytesLeft) {
|
||||
FontDataChunk& currentChunk = mDataChunks[mCurrentChunk];
|
||||
PRUint32 bytesToCopy = PR_MIN(bytesLeft,
|
||||
currentChunk.mLength - mChunkOffset);
|
||||
memcpy(out, currentChunk.mData + mChunkOffset, bytesToCopy);
|
||||
bytesLeft -= bytesToCopy;
|
||||
mChunkOffset += bytesToCopy;
|
||||
out += bytesToCopy;
|
||||
|
||||
if (bytesLeft) {
|
||||
PRInt32 bytesRead = PR_MIN(bytesLeft, mFontDataLen - mFontDataOffset);
|
||||
memcpy(out, mFontData, bytesRead);
|
||||
mFontData += bytesRead;
|
||||
mFontDataOffset += bytesRead;
|
||||
if (bytesRead > 0)
|
||||
bytesLeft -= bytesRead;
|
||||
NS_ASSERTION(mChunkOffset <= currentChunk.mLength, "oops, buffer overrun");
|
||||
|
||||
if (mChunkOffset == currentChunk.mLength) {
|
||||
mCurrentChunk++;
|
||||
mChunkOffset = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return aBytesToRead - bytesLeft;
|
||||
@ -507,17 +530,55 @@ FontEntry::LoadFont(const gfxProxyFontEntry &aProxyEntry,
|
||||
return nsnull;
|
||||
|
||||
nsresult rv;
|
||||
HANDLE fontRef;
|
||||
HANDLE fontRef = nsnull;
|
||||
PRBool isEmbedded = PR_FALSE;
|
||||
|
||||
nsAutoString uniqueName;
|
||||
rv = gfxFontUtils::MakeUniqueUserFontName(uniqueName);
|
||||
if (NS_FAILED(rv))
|
||||
return nsnull;
|
||||
|
||||
if (isCFF) {
|
||||
// for TTF fonts, first try using the t2embed library
|
||||
if (!isCFF) {
|
||||
// TrueType-style glyphs, use EOT library
|
||||
nsAutoTArray<PRUint8,2048> eotHeader;
|
||||
PRUint8 *buffer;
|
||||
PRUint32 eotlen;
|
||||
|
||||
isEmbedded = PR_TRUE;
|
||||
PRUint32 nameLen = PR_MIN(uniqueName.Length(), LF_FACESIZE - 1);
|
||||
nsPromiseFlatString fontName(Substring(uniqueName, 0, nameLen));
|
||||
|
||||
FontDataOverlay overlayNameData = {0, 0, 0};
|
||||
|
||||
rv = gfxFontUtils::MakeEOTHeader(aFontData, aLength, &eotHeader,
|
||||
&overlayNameData);
|
||||
if (NS_FAILED(rv))
|
||||
return nsnull;
|
||||
|
||||
// load in embedded font data
|
||||
eotlen = eotHeader.Length();
|
||||
buffer = reinterpret_cast<PRUint8*> (eotHeader.Elements());
|
||||
|
||||
PRInt32 ret;
|
||||
ULONG privStatus, pulStatus;
|
||||
EOTFontStreamReader eotReader(aFontData, aLength, buffer, eotlen,
|
||||
&overlayNameData);
|
||||
|
||||
ret = TTLoadEmbeddedFontPtr(&fontRef, TTLOAD_PRIVATE, &privStatus,
|
||||
LICENSE_PREVIEWPRINT, &pulStatus,
|
||||
EOTFontStreamReader::ReadEOTStream,
|
||||
&eotReader, (PRUnichar*)(fontName.get()), 0, 0);
|
||||
if (ret != E_NONE)
|
||||
fontRef = nsnull;
|
||||
}
|
||||
|
||||
// load CFF fonts or fonts that failed with t2embed loader
|
||||
if (fontRef == nsnull) {
|
||||
// Postscript-style glyphs, swizzle name table, load directly
|
||||
nsTArray<PRUint8> newFontData;
|
||||
|
||||
isEmbedded = PR_FALSE;
|
||||
rv = gfxFontUtils::RenameFont(uniqueName, aFontData, aLength, &newFontData);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
@ -542,37 +603,10 @@ FontEntry::LoadFont(const gfxProxyFontEntry &aProxyEntry,
|
||||
RemoveFontMemResourceEx(fontRef);
|
||||
return nsnull;
|
||||
}
|
||||
} else {
|
||||
// TrueType-style glyphs, use EOT library
|
||||
nsAutoTArray<PRUint8,2048> eotHeader;
|
||||
PRUint8 *buffer;
|
||||
PRUint32 eotlen;
|
||||
|
||||
PRUint32 nameLen = PR_MIN(uniqueName.Length(), LF_FACESIZE - 1);
|
||||
nsPromiseFlatString fontName(Substring(uniqueName, 0, nameLen));
|
||||
|
||||
rv = gfxFontUtils::MakeEOTHeader(aFontData, aLength, &eotHeader);
|
||||
if (NS_FAILED(rv))
|
||||
return nsnull;
|
||||
|
||||
// load in embedded font data
|
||||
eotlen = eotHeader.Length();
|
||||
buffer = reinterpret_cast<PRUint8*> (eotHeader.Elements());
|
||||
|
||||
PRInt32 ret;
|
||||
ULONG privStatus, pulStatus;
|
||||
EOTFontStreamReader eotReader(aFontData, aLength, buffer, eotlen);
|
||||
|
||||
ret = TTLoadEmbeddedFontPtr(&fontRef, TTLOAD_PRIVATE, &privStatus,
|
||||
LICENSE_PREVIEWPRINT, &pulStatus,
|
||||
EOTFontStreamReader::ReadEOTStream,
|
||||
&eotReader, (PRUnichar*)(fontName.get()), 0, 0);
|
||||
if (ret != E_NONE)
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
// make a new font entry using the unique name
|
||||
WinUserFontData *winUserFontData = new WinUserFontData(fontRef, isCFF);
|
||||
WinUserFontData *winUserFontData = new WinUserFontData(fontRef, isEmbedded);
|
||||
PRUint16 w = (aProxyEntry.mWeight == 0 ? 400 : aProxyEntry.mWeight);
|
||||
|
||||
FontEntry *fe = FontEntry::CreateFontEntry(uniqueName,
|
||||
@ -583,6 +617,7 @@ FontEntry::LoadFont(const gfxProxyFontEntry &aProxyEntry,
|
||||
if (!fe)
|
||||
return fe;
|
||||
|
||||
// Uniscribe doesn't place CFF fonts loaded privately via AddFontMemResourceEx
|
||||
if (isCFF)
|
||||
fe->mForceGDI = PR_TRUE;
|
||||
|
||||
@ -2610,7 +2645,10 @@ gfxWindowsFontGroup::InitTextRunUniscribe(gfxContext *aContext, gfxTextRun *aRun
|
||||
|
||||
if (SUCCEEDED(rv)) {
|
||||
rv = item->Place();
|
||||
NS_ASSERTION(SUCCEEDED(rv), "Failed to place -- this is pretty bad.");
|
||||
if (FAILED(rv)) {
|
||||
// crap fonts may fail when placing (e.g. funky free fonts)
|
||||
NS_WARNING("Failed to place with font -- this is pretty bad.");
|
||||
}
|
||||
}
|
||||
|
||||
if (FAILED(rv)) {
|
||||
|
0
js/src/build/autoconf/acoutput-fast.pl
Executable file → Normal file
0
js/src/build/autoconf/acoutput-fast.pl
Executable file → Normal file
0
js/src/build/win32/pgomerge.py
Executable file → Normal file
0
js/src/build/win32/pgomerge.py
Executable file → Normal file
@ -139,8 +139,8 @@ endif
|
||||
testxpcobjdir = $(DEPTH)/_tests/xpcshell
|
||||
|
||||
# Test file installation
|
||||
ifeq (WINNT,$(HOST_OS_ARCH))
|
||||
# Windows nsinstall can't recursively copy directories, so use nsinstall.py
|
||||
ifneq (,$(filter WINNT os2-emx,$(HOST_OS_ARCH)))
|
||||
# Windows and OS/2 nsinstall can't recursively copy directories, so use nsinstall.py
|
||||
TEST_INSTALLER = $(PYTHON) $(topsrcdir)/config/nsinstall.py
|
||||
else
|
||||
TEST_INSTALLER = $(INSTALL)
|
||||
|
0
js/src/correct.sh
Executable file → Normal file
0
js/src/correct.sh
Executable file → Normal file
@ -451,7 +451,8 @@ extern const uint16 js_PrimitiveTestFlags[];
|
||||
JSFUN_THISP_TEST(JSFUN_THISP_FLAGS((fun)->flags), \
|
||||
js_PrimitiveTestFlags[JSVAL_TAG(thisv) - 1]))
|
||||
|
||||
static inline JSObject *
|
||||
#ifdef __cplusplus /* Aargh, libgjs, bug 492720. */
|
||||
static JS_INLINE JSObject *
|
||||
js_ComputeThisForFrame(JSContext *cx, JSStackFrame *fp)
|
||||
{
|
||||
if (fp->flags & JSFRAME_COMPUTED_THIS)
|
||||
@ -463,6 +464,7 @@ js_ComputeThisForFrame(JSContext *cx, JSStackFrame *fp)
|
||||
fp->flags |= JSFRAME_COMPUTED_THIS;
|
||||
return obj;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* NB: js_Invoke requires that cx is currently running JS (i.e., that cx->fp
|
||||
|
@ -603,12 +603,14 @@ js_CheckForStringIndex(jsid id);
|
||||
extern void
|
||||
js_PurgeScopeChainHelper(JSContext *cx, JSObject *obj, jsid id);
|
||||
|
||||
#ifdef __cplusplus /* Aargh, libgjs, bug 492720. */
|
||||
static JS_INLINE void
|
||||
js_PurgeScopeChain(JSContext *cx, JSObject *obj, jsid id)
|
||||
{
|
||||
if (OBJ_IS_DELEGATE(cx, obj))
|
||||
js_PurgeScopeChainHelper(cx, obj, id);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Find or create a property named by id in obj's scope, with the given getter
|
||||
|
@ -1889,8 +1889,7 @@ Tracing(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
case JSTYPE_NUMBER:
|
||||
case JSTYPE_BOOLEAN: {
|
||||
JSBool bval;
|
||||
if (!JS_ValueToBoolean(cx, argv[0], &bval))
|
||||
goto bad_argument;
|
||||
JS_ValueToBoolean(cx, argv[0], &bval);
|
||||
file = bval ? stderr : NULL;
|
||||
break;
|
||||
}
|
||||
@ -2795,8 +2794,10 @@ sandbox_enumerate(JSContext *cx, JSObject *obj)
|
||||
jsval v;
|
||||
JSBool b;
|
||||
|
||||
if (!JS_GetProperty(cx, obj, "lazy", &v) || !JS_ValueToBoolean(cx, v, &b))
|
||||
if (!JS_GetProperty(cx, obj, "lazy", &v))
|
||||
return JS_FALSE;
|
||||
|
||||
JS_ValueToBoolean(cx, v, &b);
|
||||
return !b || JS_EnumerateStandardClasses(cx, obj);
|
||||
}
|
||||
|
||||
@ -2807,8 +2808,10 @@ sandbox_resolve(JSContext *cx, JSObject *obj, jsval id, uintN flags,
|
||||
jsval v;
|
||||
JSBool b, resolved;
|
||||
|
||||
if (!JS_GetProperty(cx, obj, "lazy", &v) || !JS_ValueToBoolean(cx, v, &b))
|
||||
if (!JS_GetProperty(cx, obj, "lazy", &v))
|
||||
return JS_FALSE;
|
||||
|
||||
JS_ValueToBoolean(cx, v, &b);
|
||||
if (b && (flags & JSRESOLVE_ASSIGNING) == 0) {
|
||||
if (!JS_ResolveStandardClass(cx, obj, id, &resolved))
|
||||
return JS_FALSE;
|
||||
@ -4069,9 +4072,9 @@ its_setProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
|
||||
str = JS_GetStringBytes(JSVAL_TO_STRING(id));
|
||||
if (!strcmp(str, "noisy"))
|
||||
return JS_ValueToBoolean(cx, *vp, &its_noisy);
|
||||
JS_ValueToBoolean(cx, *vp, &its_noisy);
|
||||
else if (!strcmp(str, "enum_fail"))
|
||||
return JS_ValueToBoolean(cx, *vp, &its_enum_fail);
|
||||
JS_ValueToBoolean(cx, *vp, &its_enum_fail);
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
@ -394,8 +394,7 @@ argumentUnboxingTemplates = {
|
||||
|
||||
'boolean':
|
||||
" PRBool ${name};\n"
|
||||
" if (!JS_ValueToBoolean(cx, ${argVal}, &${name}))\n"
|
||||
" return JS_FALSE;\n",
|
||||
" JS_ValueToBoolean(cx, ${argVal}, &${name});\n",
|
||||
|
||||
'[astring]':
|
||||
" xpc_qsAString ${name}(cx, ${argPtr});\n"
|
||||
|
@ -583,8 +583,7 @@ XPCConvert::JSData2Native(XPCCallContext& ccx, void* d, jsval s,
|
||||
return JS_FALSE;
|
||||
break;
|
||||
case nsXPTType::T_BOOL :
|
||||
if(!JS_ValueToBoolean(cx, s, (JSBool*)d))
|
||||
return JS_FALSE;
|
||||
JS_ValueToBoolean(cx, s, (JSBool*)d);
|
||||
break;
|
||||
case nsXPTType::T_CHAR :
|
||||
{
|
||||
|
@ -1099,11 +1099,13 @@ XPCJSRuntime::XPCJSRuntime(nsXPConnect* aXPConnect)
|
||||
xpc_InstallJSDebuggerKeywordHandler(mJSRuntime);
|
||||
#endif
|
||||
|
||||
AutoLockJSGC lock(mJSRuntime);
|
||||
if (mWatchdogWakeup) {
|
||||
AutoLockJSGC lock(mJSRuntime);
|
||||
|
||||
mWatchdogThread = PR_CreateThread(PR_USER_THREAD, WatchdogMain, this,
|
||||
PR_PRIORITY_NORMAL, PR_LOCAL_THREAD,
|
||||
PR_UNJOINABLE_THREAD, 0);
|
||||
mWatchdogThread = PR_CreateThread(PR_USER_THREAD, WatchdogMain, this,
|
||||
PR_PRIORITY_NORMAL, PR_LOCAL_THREAD,
|
||||
PR_UNJOINABLE_THREAD, 0);
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
|
@ -300,11 +300,18 @@ MySecMan::CanAccess(PRUint32 aAction, nsAXPCNativeCallContext *aCallContext, JSC
|
||||
}
|
||||
|
||||
/**********************************************/
|
||||
static void
|
||||
EvaluateScript(JSContext* jscontext, JSObject* glob, MySecMan* sm, MySecMan::Mode mode, const char* msg, const char* t, jsval &rval)
|
||||
{
|
||||
sm->SetMode(mode);
|
||||
printf(msg);
|
||||
JSAutoRequest ar(jscontext);
|
||||
JS_EvaluateScript(jscontext, glob, t, strlen(t), "builtin", 1, &rval);
|
||||
}
|
||||
|
||||
static void
|
||||
TestSecurityManager(JSContext* jscontext, JSObject* glob, nsIXPConnect* xpc)
|
||||
{
|
||||
const char* t;
|
||||
jsval rval;
|
||||
JSBool success = JS_TRUE;
|
||||
MySecMan* sm = new MySecMan();
|
||||
@ -318,7 +325,10 @@ TestSecurityManager(JSContext* jscontext, JSObject* glob, nsIXPConnect* xpc)
|
||||
}
|
||||
|
||||
rval = JSVAL_FALSE;
|
||||
JS_SetProperty(jscontext, glob, "failed", &rval);
|
||||
{
|
||||
JSAutoRequest ar(jscontext);
|
||||
JS_SetProperty(jscontext, glob, "failed", &rval);
|
||||
}
|
||||
printf("Individual SecurityManager tests...\n");
|
||||
if(NS_FAILED(xpc->SetSecurityManagerForJSContext(jscontext, sm,
|
||||
nsIXPCSecurityManager::HOOK_ALL)))
|
||||
@ -357,6 +367,7 @@ TestSecurityManager(JSContext* jscontext, JSObject* glob, nsIXPConnect* xpc)
|
||||
if(NS_SUCCEEDED(holder->GetJSObject(&obj)))
|
||||
{
|
||||
rval = OBJECT_TO_JSVAL(obj);
|
||||
JSAutoRequest ar(jscontext);
|
||||
JS_SetProperty(jscontext, glob, "foo", &rval);
|
||||
}
|
||||
|
||||
@ -368,62 +379,65 @@ TestSecurityManager(JSContext* jscontext, JSObject* glob, nsIXPConnect* xpc)
|
||||
printf("FAILED\n");
|
||||
}
|
||||
|
||||
sm->SetMode(MySecMan::OK_ALL);
|
||||
printf(" getService no veto: ");
|
||||
t = "try{Components.classes['@mozilla.org/js/xpc/XPConnect;1'].getService(); print('passed');}catch(e){failed = true; print('FAILED');}";
|
||||
JS_EvaluateScript(jscontext, glob, t, strlen(t), "builtin", 1, &rval);
|
||||
EvaluateScript(jscontext, glob, sm, MySecMan::OK_ALL,
|
||||
" getService no veto: ",
|
||||
"try{Components.classes['@mozilla.org/js/xpc/XPConnect;1'].getService(); print('passed');}catch(e){failed = true; print('FAILED');}",
|
||||
rval);
|
||||
|
||||
sm->SetMode(MySecMan::VETO_ALL);
|
||||
printf(" getService with veto: ");
|
||||
t = "try{Components.classes['@mozilla.org/js/xpc/XPConnect;1'].getService(); failed = true; print('FAILED');}catch(e){print('passed');}";
|
||||
JS_EvaluateScript(jscontext, glob, t, strlen(t), "builtin", 1, &rval);
|
||||
EvaluateScript(jscontext, glob, sm, MySecMan::VETO_ALL,
|
||||
" getService with veto: ",
|
||||
"try{Components.classes['@mozilla.org/js/xpc/XPConnect;1'].getService(); failed = true; print('FAILED');}catch(e){print('passed');}",
|
||||
rval);
|
||||
|
||||
|
||||
sm->SetMode(MySecMan::OK_ALL);
|
||||
printf(" createInstance no veto: ");
|
||||
t = "try{Components.classes['@mozilla.org/js/xpc/ID;1'].createInstance(Components.interfaces.nsIJSID); print('passed');}catch(e){failed = true; print('FAILED');}";
|
||||
JS_EvaluateScript(jscontext, glob, t, strlen(t), "builtin", 1, &rval);
|
||||
EvaluateScript(jscontext, glob, sm, MySecMan::OK_ALL,
|
||||
" createInstance no veto: ",
|
||||
"try{Components.classes['@mozilla.org/js/xpc/ID;1'].createInstance(Components.interfaces.nsIJSID); print('passed');}catch(e){failed = true; print('FAILED');}",
|
||||
rval);
|
||||
|
||||
sm->SetMode(MySecMan::VETO_ALL);
|
||||
printf(" getService with veto: ");
|
||||
t = "try{Components.classes['@mozilla.org/js/xpc/ID;1'].createInstance(Components.interfaces.nsIJSID); failed = true; print('FAILED');}catch(e){print('passed');}";
|
||||
JS_EvaluateScript(jscontext, glob, t, strlen(t), "builtin", 1, &rval);
|
||||
EvaluateScript(jscontext, glob, sm, MySecMan::VETO_ALL,
|
||||
" getService with veto: ",
|
||||
"try{Components.classes['@mozilla.org/js/xpc/ID;1'].createInstance(Components.interfaces.nsIJSID); failed = true; print('FAILED');}catch(e){print('passed');}",
|
||||
rval);
|
||||
|
||||
|
||||
sm->SetMode(MySecMan::OK_ALL);
|
||||
printf(" call method no veto: ");
|
||||
t = "try{foo.Test2(); print(' : passed');}catch(e){failed = true; print(' : FAILED');}";
|
||||
JS_EvaluateScript(jscontext, glob, t, strlen(t), "builtin", 1, &rval);
|
||||
EvaluateScript(jscontext, glob, sm, MySecMan::OK_ALL,
|
||||
" call method no veto: ",
|
||||
"try{foo.Test2(); print(' : passed');}catch(e){failed = true; print(' : FAILED');}",
|
||||
rval);
|
||||
|
||||
sm->SetMode(MySecMan::VETO_ALL);
|
||||
printf(" call method with veto: ");
|
||||
t = "try{foo.Test2(); failed = true; print(' : FAILED');}catch(e){print(' : passed');}";
|
||||
JS_EvaluateScript(jscontext, glob, t, strlen(t), "builtin", 1, &rval);
|
||||
EvaluateScript(jscontext, glob, sm, MySecMan::VETO_ALL,
|
||||
" call method with veto: ",
|
||||
"try{foo.Test2(); failed = true; print(' : FAILED');}catch(e){print(' : passed');}",
|
||||
rval);
|
||||
|
||||
|
||||
sm->SetMode(MySecMan::OK_ALL);
|
||||
printf(" get attribute no veto: ");
|
||||
t = "try{foo.Foo; print(' : passed');}catch(e){failed = true; print(' : FAILED');}";
|
||||
JS_EvaluateScript(jscontext, glob, t, strlen(t), "builtin", 1, &rval);
|
||||
EvaluateScript(jscontext, glob, sm, MySecMan::OK_ALL,
|
||||
" get attribute no veto: ",
|
||||
"try{foo.Foo; print(' : passed');}catch(e){failed = true; print(' : FAILED');}",
|
||||
rval);
|
||||
|
||||
sm->SetMode(MySecMan::VETO_ALL);
|
||||
printf(" get attribute with veto: ");
|
||||
t = "try{foo.Foo; failed = true; print(' : FAILED');}catch(e){print(' : passed');}";
|
||||
JS_EvaluateScript(jscontext, glob, t, strlen(t), "builtin", 1, &rval);
|
||||
EvaluateScript(jscontext, glob, sm, MySecMan::VETO_ALL,
|
||||
" get attribute with veto: ",
|
||||
"try{foo.Foo; failed = true; print(' : FAILED');}catch(e){print(' : passed');}",
|
||||
rval);
|
||||
|
||||
|
||||
sm->SetMode(MySecMan::OK_ALL);
|
||||
printf(" set attribute no veto: ");
|
||||
t = "try{foo.Foo = 0; print(' : passed');}catch(e){failed = true; print(' : FAILED');}";
|
||||
JS_EvaluateScript(jscontext, glob, t, strlen(t), "builtin", 1, &rval);
|
||||
EvaluateScript(jscontext, glob, sm, MySecMan::OK_ALL,
|
||||
" set attribute no veto: ",
|
||||
"try{foo.Foo = 0; print(' : passed');}catch(e){failed = true; print(' : FAILED');}",
|
||||
rval);
|
||||
|
||||
sm->SetMode(MySecMan::VETO_ALL);
|
||||
printf(" set attribute with veto: ");
|
||||
t = "try{foo.Foo = 0; failed = true; print(' : FAILED');}catch(e){print(' : passed');}";
|
||||
JS_EvaluateScript(jscontext, glob, t, strlen(t), "builtin", 1, &rval);
|
||||
EvaluateScript(jscontext, glob, sm, MySecMan::VETO_ALL,
|
||||
" set attribute with veto: ",
|
||||
"try{foo.Foo = 0; failed = true; print(' : FAILED');}catch(e){print(' : passed');}",
|
||||
rval);
|
||||
|
||||
sm_test_done:
|
||||
success = success && JS_GetProperty(jscontext, glob, "failed", &rval) && JSVAL_TRUE != rval;
|
||||
{
|
||||
JSAutoRequest ar(jscontext);
|
||||
success = success && JS_GetProperty(jscontext, glob, "failed", &rval) && JSVAL_TRUE != rval;
|
||||
}
|
||||
printf("SecurityManager tests : %s\n", success ? "passed" : "FAILED");
|
||||
NS_IF_RELEASE(foo);
|
||||
xpc->SetSecurityManagerForJSContext(jscontext, nsnull, 0);
|
||||
@ -433,9 +447,17 @@ sm_test_done:
|
||||
/***************************************************************************/
|
||||
// arg formatter test...
|
||||
|
||||
#define TAF_CHECK(cond, msg) \
|
||||
if (!cond) { \
|
||||
printf(msg); \
|
||||
ok = JS_FALSE; \
|
||||
break; \
|
||||
}
|
||||
|
||||
static void
|
||||
TestArgFormatter(JSContext* jscontext, JSObject* glob, nsIXPConnect* xpc)
|
||||
{
|
||||
JSBool ok = JS_TRUE;
|
||||
jsval* argv;
|
||||
void* mark;
|
||||
|
||||
@ -463,66 +485,40 @@ TestArgFormatter(JSContext* jscontext, JSObject* glob, nsIXPConnect* xpc)
|
||||
return;
|
||||
}
|
||||
|
||||
argv = JS_PushArguments(jscontext, &mark, "s %ip %iv %is s",
|
||||
a_in,
|
||||
&NS_GET_IID(nsITestXPCFoo2), b_in.get(),
|
||||
c_in.get(),
|
||||
static_cast<const nsAString*>(&d_in),
|
||||
e_in);
|
||||
|
||||
if(!argv)
|
||||
{
|
||||
printf(" could not convert from native to JS -- FAILED!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if(!JS_ConvertArguments(jscontext, 5, argv, "s %ip %iv %is s",
|
||||
&a_out,
|
||||
static_cast<nsISupports**>(getter_AddRefs(b_out)),
|
||||
static_cast<nsIVariant**>(getter_AddRefs(c_out)),
|
||||
static_cast<nsAString*>(&d_out),
|
||||
&e_out))
|
||||
{
|
||||
printf(" could not convert from JS to native -- FAILED!\n");
|
||||
do {
|
||||
JSAutoRequest ar(jscontext);
|
||||
argv = JS_PushArguments(jscontext, &mark, "s %ip %iv %is s",
|
||||
a_in,
|
||||
&NS_GET_IID(nsITestXPCFoo2), b_in.get(),
|
||||
c_in.get(),
|
||||
static_cast<const nsAString*>(&d_in),
|
||||
e_in);
|
||||
|
||||
if(!argv)
|
||||
{
|
||||
printf(" could not convert from native to JS -- FAILED!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
ok = JS_ConvertArguments(jscontext, 5, argv, "s %ip %iv %is s",
|
||||
&a_out,
|
||||
static_cast<nsISupports**>(getter_AddRefs(b_out)),
|
||||
static_cast<nsIVariant**>(getter_AddRefs(c_out)),
|
||||
static_cast<nsAString*>(&d_out),
|
||||
&e_out);
|
||||
TAF_CHECK(ok, " could not convert from JS to native -- FAILED!\n");
|
||||
TAF_CHECK(b_out, " JS to native for %%ip returned NULL -- FAILED!\n");
|
||||
|
||||
specified = do_QueryInterface(b_out);
|
||||
TAF_CHECK(specified, " could not QI value JS to native returned -- FAILED!\n");
|
||||
ok = specified.get() == b_in.get();
|
||||
TAF_CHECK(ok, " JS to native returned wrong value -- FAILED!\n");
|
||||
TAF_CHECK(c_out, " JS to native for %%iv returned NULL -- FAILED!\n");
|
||||
TAF_CHECK(NS_SUCCEEDED(c_out->GetAsInt32(&val)) && val == 5, " JS to native for %%iv holds wrong value -- FAILED!\n");
|
||||
TAF_CHECK(d_in.Equals(d_out), " JS to native for %%is returned the wrong value -- FAILED!\n");
|
||||
} while (0);
|
||||
if (!ok)
|
||||
goto out;
|
||||
}
|
||||
|
||||
if(!b_out)
|
||||
{
|
||||
printf(" JS to native for %%ip returned NULL -- FAILED!\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
specified = do_QueryInterface(b_out);
|
||||
if(!specified)
|
||||
{
|
||||
printf(" could not QI value JS to native returned -- FAILED!\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
if(specified.get() != b_in.get())
|
||||
{
|
||||
printf(" JS to native returned wrong value -- FAILED!\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
if(!c_out)
|
||||
{
|
||||
printf(" JS to native for %%iv returned NULL -- FAILED!\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
if(NS_FAILED(c_out->GetAsInt32(&val)) || val != 5)
|
||||
{
|
||||
printf(" JS to native for %%iv holds wrong value -- FAILED!\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
if(!d_in.Equals(d_out))
|
||||
{
|
||||
printf(" JS to native for %%is returned the wrong value -- FAILED!\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
if(!strcmp(a_in, a_out) && !strcmp(e_in, e_out))
|
||||
printf("passed\n");
|
||||
@ -530,6 +526,7 @@ TestArgFormatter(JSContext* jscontext, JSObject* glob, nsIXPConnect* xpc)
|
||||
printf(" conversion OK, but surrounding was mangled -- FAILED!\n");
|
||||
|
||||
out:
|
||||
JSAutoRequest ar(jscontext);
|
||||
JS_PopArguments(jscontext, mark);
|
||||
}
|
||||
|
||||
@ -744,15 +741,18 @@ int main()
|
||||
// as the global object. The old TextXPC did this. The support for this
|
||||
// is not working now in the new xpconnect code.
|
||||
|
||||
glob = JS_NewObject(jscontext, &global_class, NULL, NULL);
|
||||
if (!glob)
|
||||
DIE("FAILED to create global object");
|
||||
if (!JS_InitStandardClasses(jscontext, glob))
|
||||
DIE("FAILED to init standard classes");
|
||||
if (!JS_DefineFunctions(jscontext, glob, glob_functions))
|
||||
DIE("FAILED to define global functions");
|
||||
if (NS_FAILED(xpc->InitClasses(jscontext, glob)))
|
||||
DIE("FAILED to init xpconnect classes");
|
||||
{
|
||||
JSAutoRequest ar(jscontext);
|
||||
glob = JS_NewObject(jscontext, &global_class, NULL, NULL);
|
||||
if (!glob)
|
||||
DIE("FAILED to create global object");
|
||||
if (!JS_InitStandardClasses(jscontext, glob))
|
||||
DIE("FAILED to init standard classes");
|
||||
if (!JS_DefineFunctions(jscontext, glob, glob_functions))
|
||||
DIE("FAILED to define global functions");
|
||||
if (NS_FAILED(xpc->InitClasses(jscontext, glob)))
|
||||
DIE("FAILED to init xpconnect classes");
|
||||
}
|
||||
|
||||
/**********************************************/
|
||||
// run the tests...
|
||||
@ -767,9 +767,12 @@ int main()
|
||||
if(NS_FAILED(cxstack->Pop(nsnull)))
|
||||
DIE("FAILED to pop the current jscontext from the nsThreadJSContextStack service!\n");
|
||||
|
||||
JS_ClearScope(jscontext, glob);
|
||||
JS_GC(jscontext);
|
||||
JS_GC(jscontext);
|
||||
{
|
||||
JSAutoRequest ar(jscontext);
|
||||
JS_ClearScope(jscontext, glob);
|
||||
JS_GC(jscontext);
|
||||
JS_GC(jscontext);
|
||||
}
|
||||
JS_DestroyContext(jscontext);
|
||||
xpc->DebugDump(4);
|
||||
|
||||
|
11
layout/base/crashtests/399994-1.html
Normal file
11
layout/base/crashtests/399994-1.html
Normal file
@ -0,0 +1,11 @@
|
||||
<html class="reftest-print">
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div style="display: table; position: fixed;">
|
||||
<div style="display: table-row; page-break-after: always;"></div>
|
||||
<div style="display: table-row;"></div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -171,6 +171,7 @@ load 399687-1.html
|
||||
load 399940-1.xhtml
|
||||
load 399946-1.xhtml
|
||||
load 399951-1.html
|
||||
load 399994-1.html
|
||||
load 400185-1.xul
|
||||
load 400445-1.xhtml
|
||||
load 400904-1.xhtml
|
||||
|
@ -2481,6 +2481,11 @@ nsCSSFrameConstructor::ConstructDocElementFrame(nsIContent* aDocEle
|
||||
|
||||
*aNewFrame = nsnull;
|
||||
|
||||
// Make sure to call PropagateScrollToViewport before
|
||||
// SetUpDocElementContainingBlock, since it sets up our scrollbar state
|
||||
// properly.
|
||||
nsIContent* propagatedScrollFrom = PropagateScrollToViewport();
|
||||
|
||||
SetUpDocElementContainingBlock(aDocElement);
|
||||
|
||||
NS_ASSERTION(mDocElementContainingBlock, "Should have parent by now");
|
||||
@ -2531,12 +2536,9 @@ nsCSSFrameConstructor::ConstructDocElementFrame(nsIContent* aDocEle
|
||||
// --------- IF SCROLLABLE WRAP IN SCROLLFRAME --------
|
||||
|
||||
#ifdef DEBUG
|
||||
PRBool propagatedScrollToViewport =
|
||||
PropagateScrollToViewport() == aDocElement;
|
||||
|
||||
NS_ASSERTION(!display->IsScrollableOverflow() ||
|
||||
state.mPresContext->IsPaginated() ||
|
||||
propagatedScrollToViewport,
|
||||
propagatedScrollFrom == aDocElement,
|
||||
"Scrollbars should have been propagated to the viewport");
|
||||
#endif
|
||||
|
||||
|
@ -2036,6 +2036,19 @@ PresShell::Destroy()
|
||||
mFrameConstructor->WillDestroyFrameTree();
|
||||
FrameManager()->Destroy();
|
||||
|
||||
// Destroy all frame properties (whose destruction was suppressed
|
||||
// while destroying the frame tree, but which might contain more
|
||||
// frames within the properties.
|
||||
if (mPresContext) {
|
||||
// Clear out the prescontext's property table -- since our frame tree is
|
||||
// now dead, we shouldn't be looking up any more properties in that table.
|
||||
// We want to do this before we call SetShell() on the prescontext, so
|
||||
// property destructors can usefully call GetPresShell() on the
|
||||
// prescontext.
|
||||
mPresContext->PropertyTable()->DeleteAllProperties();
|
||||
}
|
||||
|
||||
|
||||
NS_WARN_IF_FALSE(!mWeakFrames, "Weak frames alive after destroying FrameManager");
|
||||
while (mWeakFrames) {
|
||||
mWeakFrames->Clear(this);
|
||||
@ -2045,13 +2058,6 @@ PresShell::Destroy()
|
||||
mStyleSet->Shutdown(mPresContext);
|
||||
|
||||
if (mPresContext) {
|
||||
// Clear out the prescontext's property table -- since our frame tree is
|
||||
// now dead, we shouldn't be looking up any more properties in that table.
|
||||
// We want to do this before we call SetShell() on the prescontext, so
|
||||
// property destructors can usefully call GetPresShell() on the
|
||||
// prescontext.
|
||||
mPresContext->PropertyTable()->DeleteAllProperties();
|
||||
|
||||
// We hold a reference to the pres context, and it holds a weak link back
|
||||
// to us. To avoid the pres context having a dangling reference, set its
|
||||
// pres shell to NULL
|
||||
|
@ -100,6 +100,7 @@ protected:
|
||||
|
||||
PRBool IsFileBrowseButton(PRInt32 type); // Browse button of file input
|
||||
|
||||
virtual PRBool IsInput() { return PR_TRUE; }
|
||||
private:
|
||||
nsSize mSuggestedSize;
|
||||
nsCOMPtr<nsIContent> mTextContent;
|
||||
|
@ -132,26 +132,6 @@ nsHTMLButtonControlFrame::GetType() const
|
||||
return nsGkAtoms::HTMLButtonControlFrame;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsHTMLButtonControlFrame::IsReset(PRInt32 type)
|
||||
{
|
||||
if (NS_FORM_BUTTON_RESET == type) {
|
||||
return PR_TRUE;
|
||||
} else {
|
||||
return PR_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsHTMLButtonControlFrame::IsSubmit(PRInt32 type)
|
||||
{
|
||||
if (NS_FORM_BUTTON_SUBMIT == type) {
|
||||
return PR_TRUE;
|
||||
} else {
|
||||
return PR_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsHTMLButtonControlFrame::SetFocus(PRBool aOn, PRBool aRepaint)
|
||||
{
|
||||
@ -197,19 +177,19 @@ nsHTMLButtonControlFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
||||
// Put the foreground outline and focus rects on top of the children
|
||||
set.Content()->AppendToTop(&onTop);
|
||||
|
||||
// XXX This is temporary
|
||||
// clips to its size minus the border
|
||||
// but the real problem is the FirstChild (the AreaFrame)
|
||||
// isn't being constrained properly
|
||||
// Bug #17474
|
||||
nsMargin border = GetStyleBorder()->GetActualBorder();
|
||||
nsRect rect(aBuilder->ToReferenceFrame(this), GetSize());
|
||||
rect.Deflate(border);
|
||||
// clips to our padding box for <input>s but not <button>s.
|
||||
if (IsInput()) {
|
||||
nsMargin border = GetStyleBorder()->GetActualBorder();
|
||||
nsRect rect(aBuilder->ToReferenceFrame(this), GetSize());
|
||||
rect.Deflate(border);
|
||||
|
||||
nsresult rv = OverflowClip(aBuilder, set, aLists, rect);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsresult rv = OverflowClip(aBuilder, set, aLists, rect);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
} else {
|
||||
set.MoveTo(aLists);
|
||||
}
|
||||
|
||||
rv = DisplayOutline(aBuilder, aLists);
|
||||
nsresult rv = DisplayOutline(aBuilder, aLists);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// to draw border when selected in editor
|
||||
|
@ -135,8 +135,7 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual PRBool IsReset(PRInt32 type);
|
||||
virtual PRBool IsSubmit(PRInt32 type);
|
||||
virtual PRBool IsInput() { return PR_FALSE; }
|
||||
void ReflowButtonContents(nsPresContext* aPresContext,
|
||||
nsHTMLReflowMetrics& aDesiredSize,
|
||||
const nsHTMLReflowState& aReflowState,
|
||||
|
5
layout/reftests/bugs/491180-1-ref.html
Normal file
5
layout/reftests/bugs/491180-1-ref.html
Normal file
@ -0,0 +1,5 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<div style="padding: 0; margin: 0; border: none; background: transparent; -moz-appearance: none; width: 0; height: 0; font: inherit; padding: 1px 3px">
|
||||
Some text <div style="background: green; width: 100px; height: 100px"></div>
|
||||
</div>
|
6
layout/reftests/bugs/491180-1.html
Normal file
6
layout/reftests/bugs/491180-1.html
Normal file
@ -0,0 +1,6 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<button style="padding: 0; margin: 0; border: none; background: transparent; -moz-appearance: none; width: 0; height: 0; font: inherit">
|
||||
Some text <div style="background: green; width: 100px; height: 100px"></div>
|
||||
</button>
|
||||
</div>
|
4
layout/reftests/bugs/491180-2-ref.html
Normal file
4
layout/reftests/bugs/491180-2-ref.html
Normal file
@ -0,0 +1,4 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<div style="padding: 0; margin: 0; border: none; background: transparent; -moz-appearance: none; width: 14px; font: inherit; padding: 1px 3px; white-space: pre; overflow: hidden">Some text</div>
|
||||
</div>
|
4
layout/reftests/bugs/491180-2.html
Normal file
4
layout/reftests/bugs/491180-2.html
Normal file
@ -0,0 +1,4 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<input type="button" style="padding: 0; margin: 0; border: none; background: transparent; -moz-appearance: none; width: 20px; font: inherit" value="Some text">
|
||||
</div>
|
6
layout/reftests/bugs/502447-1-ref.html
Normal file
6
layout/reftests/bugs/502447-1-ref.html
Normal file
@ -0,0 +1,6 @@
|
||||
<!DOCTYPE html>
|
||||
<iframe src="data:text/html,<html style='height: 100%'>
|
||||
<body style='margin: 0; padding: 0; height: 100%'>
|
||||
<div style='width: 200%; height: 200%'></div>
|
||||
</body>
|
||||
</html>"></iframe>
|
9
layout/reftests/bugs/502447-1.html
Normal file
9
layout/reftests/bugs/502447-1.html
Normal file
@ -0,0 +1,9 @@
|
||||
<!DOCTYPE html>
|
||||
<iframe src="data:text/html,<html style='height: 100%'>
|
||||
<body style='margin: 0; padding: 0; height: 100%'
|
||||
onload='document.documentElement.style.overflow = "hidden";
|
||||
document.body.offsetWidth;
|
||||
document.documentElement.style.overflow=""'>
|
||||
<div style='width: 200%; height: 200%'></div>
|
||||
</body>
|
||||
</html>"></iframe>
|
@ -1245,12 +1245,14 @@ fails-if(MOZ_WIDGET_TOOLKIT=="gtk2") == 481948-3.html 481948-3-ref.html # differ
|
||||
== 488649-1.html 488649-1-ref.html
|
||||
== 488685-1.html 488685-1-ref.html
|
||||
fails-if(MOZ_WIDGET_TOOLKIT!="cocoa") == 488692-1.html 488692-1-ref.html # needs EXTEND_PAD on non-Mac for correct scaling behaviour
|
||||
== 492661-1.html 492661-1-ref.html
|
||||
== 490182-1a.html 490182-1-ref.html
|
||||
== 490182-1b.html 490182-1-ref.html
|
||||
== 490173-1.html 490173-1-ref.html
|
||||
== 490173-2.html 490173-2-ref.html
|
||||
== 491180-1.html 491180-1-ref.html
|
||||
== 491180-2.html 491180-2-ref.html
|
||||
== 491323-1.xul 491323-1-ref.xul
|
||||
== 492661-1.html 492661-1-ref.html
|
||||
== 493968-1.html 493968-1-ref.html
|
||||
== 494667-1.html 494667-1-ref.html
|
||||
== 494667-2.html 494667-2-ref.html
|
||||
@ -1275,6 +1277,7 @@ fails-if(MOZ_WIDGET_TOOLKIT!="cocoa") == 488692-1.html 488692-1-ref.html # needs
|
||||
== 495385-5.html 495385-5-ref.html
|
||||
== 498228-1.xul 498228-1-ref.xul
|
||||
== 496032-1.html 496032-1-ref.html
|
||||
== 502447-1.html 502447-1-ref.html
|
||||
== 502795-1.html 502795-1-ref.html
|
||||
== 503364-1a.html 503364-1-ref.html
|
||||
== 503364-1b.html 503364-1-ref.html
|
||||
|
35
layout/reftests/font-face/load-badfullname-ref.html
Normal file
35
layout/reftests/font-face/load-badfullname-ref.html
Normal file
@ -0,0 +1,35 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test of fonts with funky fullnames</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
@font-face {
|
||||
font-family: test;
|
||||
src: url(../fonts/markA.ttf);
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 50px;
|
||||
font-size: 12pt;
|
||||
font-family: Gill Sans, Futura, sans-serif;
|
||||
}
|
||||
|
||||
p.test1 { font-size: 48pt; font-family: test, Futura, sans-serif; }
|
||||
p.test2 { font-size: 48pt; font-family: test, Futura, sans-serif; }
|
||||
|
||||
</style>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Letter A should <strong>not</strong> appear below:</p>
|
||||
|
||||
<p class="test1">A</p>
|
||||
|
||||
<p class="test2">A</p>
|
||||
|
||||
</body>
|
||||
</html>
|
40
layout/reftests/font-face/load-badfullname.html
Normal file
40
layout/reftests/font-face/load-badfullname.html
Normal file
@ -0,0 +1,40 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test of fonts with funky fullnames</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
@font-face {
|
||||
font-family: test1;
|
||||
src: url(../fonts/markA-badfullname.ttf);
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: test2;
|
||||
src: url(../fonts/markA-shortfullname.ttf);
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 50px;
|
||||
font-size: 12pt;
|
||||
font-family: Gill Sans, Futura, sans-serif;
|
||||
}
|
||||
|
||||
p.test1 { font-size: 48pt; font-family: test1, Futura, sans-serif; }
|
||||
p.test2 { font-size: 48pt; font-family: test2, Futura, sans-serif; }
|
||||
|
||||
</style>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Letter A should <strong>not</strong> appear below:</p>
|
||||
|
||||
<p class="test1">A</p>
|
||||
|
||||
<p class="test2">A</p>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -91,3 +91,7 @@ HTTP(..) load 486974-1.html
|
||||
|
||||
# compare fonts with and without bad head checksum
|
||||
HTTP(..) == load-badchecksum.html load-badchecksum-ref.html
|
||||
|
||||
# t2embed lib on windows is picky about fullname
|
||||
HTTP(..) == load-badfullname.html load-badfullname-ref.html
|
||||
|
||||
|
@ -1076,7 +1076,6 @@ nsCSSScanner::ParseNumber(PRInt32 c, nsCSSToken& aToken)
|
||||
{
|
||||
NS_PRECONDITION(c == '.' || c == '+' || c == '-' || IsDigit(c),
|
||||
"Why did we get called?");
|
||||
PRBool gotDot = (c == '.');
|
||||
aToken.mHasSign = (c == '+' || c == '-');
|
||||
|
||||
// Our sign.
|
||||
@ -1091,10 +1090,6 @@ nsCSSScanner::ParseNumber(PRInt32 c, nsCSSToken& aToken)
|
||||
// truncating down (as we would if fracPart were a float and we just
|
||||
// effectively lost the last several digits).
|
||||
double fracPart = 0;
|
||||
// Power of ten by which we need to divide our next digit; this is 1
|
||||
// unless we're parsing the fractional part of the mantissa (so
|
||||
// unless gotDot is true).
|
||||
float divisor = 1;
|
||||
// Absolute value of the power of 10 that we should multiply by (only
|
||||
// relevant for numbers in scientific notation). Has to be a signed integer,
|
||||
// because multiplication of signed by unsigned converts the unsigned to
|
||||
@ -1102,66 +1097,69 @@ nsCSSScanner::ParseNumber(PRInt32 c, nsCSSToken& aToken)
|
||||
PRInt32 exponent = 0;
|
||||
// Sign of the exponent.
|
||||
PRInt32 expSign = 1;
|
||||
|
||||
if (gotDot) {
|
||||
divisor = 10;
|
||||
} else if (!aToken.mHasSign) {
|
||||
// We got our first digit
|
||||
intPart += CHAR_TO_DIGIT(c);
|
||||
|
||||
if (aToken.mHasSign) {
|
||||
NS_ASSERTION(c != '.', "How did that happen?");
|
||||
c = Read();
|
||||
}
|
||||
|
||||
// Gather up characters that make up the number
|
||||
PRBool gotE = PR_FALSE;
|
||||
for (;;) {
|
||||
c = Read();
|
||||
if (c < 0) break;
|
||||
PRBool gotDot = (c == '.');
|
||||
|
||||
// If gotE is true, then gotDot is no longer relevant for deciding
|
||||
// what to do with 'c', nor will it change.
|
||||
if (NS_UNLIKELY(gotE)) {
|
||||
if (!IsDigit(c)) {
|
||||
break;
|
||||
}
|
||||
exponent = 10*exponent + CHAR_TO_DIGIT(c);
|
||||
}
|
||||
#ifdef MOZ_SVG
|
||||
else if (NS_UNLIKELY(IsSVGMode() && (c == 'e' || c == 'E'))) {
|
||||
PRInt32 nextChar = Peek();
|
||||
PRInt32 expSignChar = 0;
|
||||
if (nextChar == '-' || nextChar == '+') {
|
||||
expSignChar = Read();
|
||||
nextChar = Peek();
|
||||
}
|
||||
if (IsDigit(nextChar)) {
|
||||
gotE = PR_TRUE;
|
||||
if (expSignChar == '-') {
|
||||
expSign = -1;
|
||||
}
|
||||
} else {
|
||||
if (expSignChar) {
|
||||
Pushback(expSignChar);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
else if (gotDot) {
|
||||
// We're in the fractional part, and c is not 'e' or 'E'
|
||||
if (!IsDigit(c)) {
|
||||
break;
|
||||
}
|
||||
if (!gotDot) {
|
||||
// Parse the integer part of the mantisssa
|
||||
NS_ASSERTION(IsDigit(c), "Why did we get called?");
|
||||
do {
|
||||
intPart = 10*intPart + CHAR_TO_DIGIT(c);
|
||||
c = Read();
|
||||
// The IsDigit check will do the right thing even if Read() returns < 0
|
||||
} while (IsDigit(c));
|
||||
|
||||
gotDot = (c == '.') && IsDigit(Peek());
|
||||
}
|
||||
|
||||
if (gotDot) {
|
||||
// Parse the fractional part of the mantissa.
|
||||
c = Read();
|
||||
NS_ASSERTION(IsDigit(c), "How did we get here?");
|
||||
// Power of ten by which we need to divide our next digit
|
||||
float divisor = 10;
|
||||
do {
|
||||
fracPart += CHAR_TO_DIGIT(c) / divisor;
|
||||
divisor *= 10;
|
||||
} else if (c == '.' && IsDigit(Peek())) {
|
||||
gotDot = PR_TRUE;
|
||||
divisor = 10;
|
||||
} else if (IsDigit(c)) {
|
||||
intPart = 10*intPart + CHAR_TO_DIGIT(c);
|
||||
c = Read();
|
||||
// The IsDigit check will do the right thing even if Read() returns < 0
|
||||
} while (IsDigit(c));
|
||||
}
|
||||
|
||||
PRBool gotE = PR_FALSE;
|
||||
#ifdef MOZ_SVG
|
||||
if (IsSVGMode() && (c == 'e' || c == 'E')) {
|
||||
PRInt32 nextChar = Peek();
|
||||
PRInt32 expSignChar = 0;
|
||||
if (nextChar == '-' || nextChar == '+') {
|
||||
expSignChar = Read();
|
||||
nextChar = Peek();
|
||||
}
|
||||
if (IsDigit(nextChar)) {
|
||||
gotE = PR_TRUE;
|
||||
if (expSignChar == '-') {
|
||||
expSign = -1;
|
||||
}
|
||||
|
||||
c = Read();
|
||||
NS_ASSERTION(IsDigit(c), "Peek() must have lied");
|
||||
do {
|
||||
exponent = 10*exponent + CHAR_TO_DIGIT(c);
|
||||
c = Read();
|
||||
// The IsDigit check will do the right thing even if Read() returns < 0
|
||||
} while (IsDigit(c));
|
||||
} else {
|
||||
// Don't know what to do with this char; stop consuming the number
|
||||
break;
|
||||
if (expSignChar) {
|
||||
Pushback(expSignChar);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
nsCSSTokenType type = eCSSToken_Number;
|
||||
|
||||
|
@ -48,7 +48,6 @@
|
||||
|
||||
class gfxContext;
|
||||
class nsPresContext;
|
||||
class nsIDOMSVGMatrix;
|
||||
class nsSVGRenderState;
|
||||
|
||||
class nsISVGChildFrame : public nsQueryFrame
|
||||
|
@ -56,7 +56,7 @@ NS_NewSVGClipPathFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
||||
nsresult
|
||||
nsSVGClipPathFrame::ClipPaint(nsSVGRenderState* aContext,
|
||||
nsIFrame* aParent,
|
||||
nsIDOMSVGMatrix *aMatrix)
|
||||
const gfxMatrix &aMatrix)
|
||||
{
|
||||
// If the flag is set when we get here, it means this clipPath frame
|
||||
// has already been used painting the current clip, and the document
|
||||
@ -68,7 +68,7 @@ nsSVGClipPathFrame::ClipPaint(nsSVGRenderState* aContext,
|
||||
AutoClipPathReferencer clipRef(this);
|
||||
|
||||
mClipParent = aParent,
|
||||
mClipParentMatrix = aMatrix;
|
||||
mClipParentMatrix = NS_NewSVGMatrix(aMatrix);
|
||||
|
||||
PRBool isTrivial = IsTrivial();
|
||||
|
||||
@ -97,7 +97,7 @@ nsSVGClipPathFrame::ClipPaint(nsSVGRenderState* aContext,
|
||||
|
||||
PRBool
|
||||
nsSVGClipPathFrame::ClipHitTest(nsIFrame* aParent,
|
||||
nsIDOMSVGMatrix *aMatrix,
|
||||
const gfxMatrix &aMatrix,
|
||||
const nsPoint &aPoint)
|
||||
{
|
||||
// If the flag is set when we get here, it means this clipPath frame
|
||||
@ -110,7 +110,7 @@ nsSVGClipPathFrame::ClipHitTest(nsIFrame* aParent,
|
||||
AutoClipPathReferencer clipRef(this);
|
||||
|
||||
mClipParent = aParent,
|
||||
mClipParentMatrix = aMatrix;
|
||||
mClipParentMatrix = NS_NewSVGMatrix(aMatrix);
|
||||
|
||||
for (nsIFrame* kid = mFrames.FirstChild(); kid;
|
||||
kid = kid->GetNextSibling()) {
|
||||
@ -169,18 +169,12 @@ nsSVGClipPathFrame::GetType() const
|
||||
gfxMatrix
|
||||
nsSVGClipPathFrame::GetCanvasTM()
|
||||
{
|
||||
NS_ASSERTION(mClipParentMatrix, "null parent matrix");
|
||||
|
||||
nsSVGClipPathElement *content = static_cast<nsSVGClipPathElement*>(mContent);
|
||||
|
||||
gfxMatrix tm = content->PrependLocalTransformTo(
|
||||
nsSVGUtils::ConvertSVGMatrixToThebes(mClipParentMatrix));
|
||||
|
||||
nsCOMPtr<nsIDOMSVGMatrix> canvasTM = NS_NewSVGMatrix(tm);
|
||||
nsCOMPtr<nsIDOMSVGMatrix> fini =
|
||||
nsSVGUtils::AdjustMatrixForUnits(canvasTM,
|
||||
return nsSVGUtils::AdjustMatrixForUnits(tm,
|
||||
&content->mEnumAttributes[nsSVGClipPathElement::CLIPPATHUNITS],
|
||||
mClipParent);
|
||||
|
||||
return nsSVGUtils::ConvertSVGMatrixToThebes(fini);
|
||||
}
|
||||
|
@ -56,10 +56,10 @@ public:
|
||||
// nsSVGClipPathFrame methods:
|
||||
nsresult ClipPaint(nsSVGRenderState* aContext,
|
||||
nsIFrame* aParent,
|
||||
nsIDOMSVGMatrix *aMatrix);
|
||||
const gfxMatrix &aMatrix);
|
||||
|
||||
PRBool ClipHitTest(nsIFrame* aParent,
|
||||
nsIDOMSVGMatrix *aMatrix,
|
||||
const gfxMatrix &aMatrix,
|
||||
const nsPoint &aPoint);
|
||||
|
||||
// Check if this clipPath is made up of more than one geometry object.
|
||||
|
@ -39,7 +39,6 @@
|
||||
|
||||
#include "nsContainerFrame.h"
|
||||
#include "nsISVGChildFrame.h"
|
||||
#include "nsIDOMSVGMatrix.h"
|
||||
#include "nsSVGSVGElement.h"
|
||||
#include "gfxRect.h"
|
||||
#include "gfxMatrix.h"
|
||||
|
@ -36,7 +36,6 @@
|
||||
|
||||
#include "nsSVGFilterFrame.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsSVGMatrix.h"
|
||||
#include "nsSVGOuterSVGFrame.h"
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsSVGUtils.h"
|
||||
@ -141,8 +140,7 @@ nsAutoFilterInstance::nsAutoFilterInstance(nsIFrame *aTarget,
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMSVGMatrix> userToDeviceSpace =
|
||||
NS_NewSVGMatrix(nsSVGUtils::GetCanvasTM(aTarget));
|
||||
gfxMatrix userToDeviceSpace = nsSVGUtils::GetCanvasTM(aTarget);
|
||||
|
||||
// Calculate filterRes (the width and height of the pixel buffer of the
|
||||
// temporary offscreen surface that we'll paint into):
|
||||
@ -183,16 +181,14 @@ nsAutoFilterInstance::nsAutoFilterInstance(nsIFrame *aTarget,
|
||||
|
||||
// Convert the dirty rects to filter space, and create our nsSVGFilterInstance:
|
||||
|
||||
nsCOMPtr<nsIDOMSVGMatrix> filterToUserSpace, filterToDeviceSpace;
|
||||
NS_NewSVGMatrix(getter_AddRefs(filterToUserSpace),
|
||||
filterRegion.Width() / filterRes.width, 0.0f,
|
||||
0.0f, filterRegion.Height() / filterRes.height,
|
||||
filterRegion.X(), filterRegion.Y());
|
||||
userToDeviceSpace->Multiply(filterToUserSpace, getter_AddRefs(filterToDeviceSpace));
|
||||
gfxMatrix filterToUserSpace(filterRegion.Width() / filterRes.width, 0.0f,
|
||||
0.0f, filterRegion.Height() / filterRes.height,
|
||||
filterRegion.X(), filterRegion.Y());
|
||||
gfxMatrix filterToDeviceSpace = filterToUserSpace * userToDeviceSpace;
|
||||
|
||||
// filterToDeviceSpace is always invertible
|
||||
gfxMatrix deviceToFilterSpace
|
||||
= nsSVGUtils::ConvertSVGMatrixToThebes(filterToDeviceSpace).Invert();
|
||||
gfxMatrix deviceToFilterSpace = filterToDeviceSpace;
|
||||
deviceToFilterSpace.Invert();
|
||||
|
||||
nsIntRect dirtyOutputRect =
|
||||
MapDeviceRectToFilterSpace(deviceToFilterSpace, filterRes, aDirtyOutputRect);
|
||||
@ -234,8 +230,7 @@ nsSVGFilterFrame::FilterPaint(nsSVGRenderState *aContext,
|
||||
static nsresult
|
||||
TransformFilterSpaceToDeviceSpace(nsSVGFilterInstance *aInstance, nsIntRect *aRect)
|
||||
{
|
||||
gfxMatrix m = nsSVGUtils::ConvertSVGMatrixToThebes(
|
||||
aInstance->GetFilterSpaceToDeviceSpaceTransform());
|
||||
gfxMatrix m = aInstance->GetFilterSpaceToDeviceSpaceTransform();
|
||||
gfxRect r(aRect->x, aRect->y, aRect->width, aRect->height);
|
||||
r = m.TransformBounds(r);
|
||||
r.RoundOut();
|
||||
|
@ -37,7 +37,6 @@
|
||||
#include "nsSVGFilterInstance.h"
|
||||
#include "nsSVGUtils.h"
|
||||
#include "nsIDOMSVGUnitTypes.h"
|
||||
#include "nsSVGMatrix.h"
|
||||
#include "gfxPlatform.h"
|
||||
#include "nsSVGFilterPaintCallback.h"
|
||||
#include "nsSVGFilterElement.h"
|
||||
@ -96,18 +95,14 @@ nsSVGFilterInstance::UserSpaceToFilterSpace(const gfxRect& aRect) const
|
||||
return r;
|
||||
}
|
||||
|
||||
already_AddRefed<nsIDOMSVGMatrix>
|
||||
gfxMatrix
|
||||
nsSVGFilterInstance::GetUserSpaceToFilterSpaceTransform() const
|
||||
{
|
||||
nsCOMPtr<nsIDOMSVGMatrix> filterTransform;
|
||||
gfxFloat widthScale = mFilterSpaceSize.width / mFilterRect.Width();
|
||||
gfxFloat heightScale = mFilterSpaceSize.height / mFilterRect.Height();
|
||||
NS_NewSVGMatrix(getter_AddRefs(filterTransform),
|
||||
widthScale, 0.0f,
|
||||
0.0f, heightScale,
|
||||
-mFilterRect.X() * widthScale,
|
||||
-mFilterRect.Y() * heightScale);
|
||||
return filterTransform.forget();
|
||||
return gfxMatrix(widthScale, 0.0f,
|
||||
0.0f, heightScale,
|
||||
-mFilterRect.X() * widthScale, -mFilterRect.Y() * heightScale);
|
||||
}
|
||||
|
||||
void
|
||||
@ -341,12 +336,7 @@ nsSVGFilterInstance::BuildSourceImages()
|
||||
offscreen->SetDeviceOffset(gfxPoint(-mSurfaceRect.x, -mSurfaceRect.y));
|
||||
|
||||
nsSVGRenderState tmpState(offscreen);
|
||||
nsCOMPtr<nsIDOMSVGMatrix> userSpaceToFilterSpaceTransform
|
||||
= GetUserSpaceToFilterSpaceTransform();
|
||||
if (!userSpaceToFilterSpaceTransform)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
gfxMatrix userSpaceToFilterSpace =
|
||||
nsSVGUtils::ConvertSVGMatrixToThebes(userSpaceToFilterSpaceTransform);
|
||||
gfxMatrix userSpaceToFilterSpace = GetUserSpaceToFilterSpaceTransform();
|
||||
|
||||
gfxRect r(neededRect.x, neededRect.y, neededRect.width, neededRect.height);
|
||||
gfxMatrix m = userSpaceToFilterSpace;
|
||||
@ -369,8 +359,7 @@ nsSVGFilterInstance::BuildSourceImages()
|
||||
// space to device space and back again). However, that would make the
|
||||
// code more complex while being hard to get right without introducing
|
||||
// subtle bugs, and in practice it probably makes no real difference.)
|
||||
gfxMatrix deviceToFilterSpace =
|
||||
nsSVGUtils::ConvertSVGMatrixToThebes(GetFilterSpaceToDeviceSpaceTransform()).Invert();
|
||||
gfxMatrix deviceToFilterSpace = GetFilterSpaceToDeviceSpaceTransform().Invert();
|
||||
tmpState.GetGfxContext()->Multiply(deviceToFilterSpace);
|
||||
mPaintCallback->Paint(&tmpState, mTargetFrame, &dirty);
|
||||
|
||||
|
@ -72,7 +72,7 @@ public:
|
||||
const gfxRect &aTargetBBox,
|
||||
const gfxRect& aFilterRect,
|
||||
const nsIntSize& aFilterSpaceSize,
|
||||
nsIDOMSVGMatrix *aFilterSpaceToDeviceSpaceTransform,
|
||||
const gfxMatrix &aFilterSpaceToDeviceSpaceTransform,
|
||||
const nsIntRect& aDirtyOutputRect,
|
||||
const nsIntRect& aDirtyInputRect,
|
||||
PRUint16 aPrimitiveUnits) :
|
||||
@ -107,9 +107,9 @@ public:
|
||||
nsresult ComputeSourceNeededRect(nsIntRect* aDirty);
|
||||
nsresult ComputeOutputBBox(nsIntRect* aBBox);
|
||||
|
||||
already_AddRefed<nsIDOMSVGMatrix> GetUserSpaceToFilterSpaceTransform() const;
|
||||
nsIDOMSVGMatrix* GetFilterSpaceToDeviceSpaceTransform() const {
|
||||
return mFilterSpaceToDeviceSpaceTransform.get();
|
||||
gfxMatrix GetUserSpaceToFilterSpaceTransform() const;
|
||||
gfxMatrix GetFilterSpaceToDeviceSpaceTransform() const {
|
||||
return mFilterSpaceToDeviceSpaceTransform;
|
||||
}
|
||||
|
||||
private:
|
||||
@ -185,7 +185,7 @@ private:
|
||||
nsSVGFilterPaintCallback* mPaintCallback;
|
||||
nsSVGFilterElement* mFilterElement;
|
||||
gfxRect mTargetBBox;
|
||||
nsCOMPtr<nsIDOMSVGMatrix> mFilterSpaceToDeviceSpaceTransform;
|
||||
gfxMatrix mFilterSpaceToDeviceSpaceTransform;
|
||||
gfxRect mFilterRect;
|
||||
nsIntSize mFilterSpaceSize;
|
||||
nsIntRect mDirtyOutputRect;
|
||||
|
@ -35,7 +35,6 @@
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsSVGPathGeometryFrame.h"
|
||||
#include "nsIDOMSVGMatrix.h"
|
||||
#include "imgIContainer.h"
|
||||
#include "nsStubImageDecoderObserver.h"
|
||||
#include "nsImageLoadingContent.h"
|
||||
@ -43,8 +42,8 @@
|
||||
#include "nsLayoutUtils.h"
|
||||
#include "nsSVGImageElement.h"
|
||||
#include "nsSVGUtils.h"
|
||||
#include "nsSVGMatrix.h"
|
||||
#include "gfxContext.h"
|
||||
#include "gfxMatrix.h"
|
||||
#include "nsIInterfaceRequestorUtils.h"
|
||||
|
||||
class nsSVGImageFrame;
|
||||
@ -111,7 +110,7 @@ public:
|
||||
#endif
|
||||
|
||||
private:
|
||||
already_AddRefed<nsIDOMSVGMatrix> GetImageTransform();
|
||||
gfxMatrix GetImageTransform();
|
||||
|
||||
nsCOMPtr<imgIDecoderObserver> mListener;
|
||||
|
||||
@ -186,11 +185,9 @@ nsSVGImageFrame::AttributeChanged(PRInt32 aNameSpaceID,
|
||||
aAttribute, aModType);
|
||||
}
|
||||
|
||||
already_AddRefed<nsIDOMSVGMatrix>
|
||||
gfxMatrix
|
||||
nsSVGImageFrame::GetImageTransform()
|
||||
{
|
||||
nsCOMPtr<nsIDOMSVGMatrix> ctm = NS_NewSVGMatrix(GetCanvasTM());
|
||||
|
||||
float x, y, width, height;
|
||||
nsSVGImageElement *element = static_cast<nsSVGImageElement*>(mContent);
|
||||
element->GetAnimatedLengthValues(&x, &y, &width, &height, nsnull);
|
||||
@ -199,17 +196,12 @@ nsSVGImageFrame::GetImageTransform()
|
||||
mImageContainer->GetWidth(&nativeWidth);
|
||||
mImageContainer->GetHeight(&nativeHeight);
|
||||
|
||||
nsCOMPtr<nsIDOMSVGMatrix> trans, ctmXY, fini;
|
||||
trans = nsSVGUtils::GetViewBoxTransform(width, height,
|
||||
0, 0,
|
||||
nativeWidth, nativeHeight,
|
||||
element->mPreserveAspectRatio);
|
||||
ctm->Translate(x, y, getter_AddRefs(ctmXY));
|
||||
ctmXY->Multiply(trans, getter_AddRefs(fini));
|
||||
gfxMatrix viewBoxTM =
|
||||
nsSVGUtils::GetViewBoxTransform(width, height,
|
||||
0, 0, nativeWidth, nativeHeight,
|
||||
element->mPreserveAspectRatio);
|
||||
|
||||
nsIDOMSVGMatrix *retval = nsnull;
|
||||
fini.swap(retval);
|
||||
return retval;
|
||||
return viewBoxTM * gfxMatrix().Translate(gfxPoint(x, y)) * GetCanvasTM();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -264,8 +256,6 @@ nsSVGImageFrame::PaintSVG(nsSVGRenderState *aContext,
|
||||
nsSVGUtils::SetClipRect(gfx, GetCanvasTM(), clipRect);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMSVGMatrix> fini = GetImageTransform();
|
||||
|
||||
// fill-opacity doesn't affect <image>, so if we're allowed to
|
||||
// optimize group opacity, the opacity used for compositing the
|
||||
// image into the current canvas is just the group opacity.
|
||||
@ -278,7 +268,8 @@ nsSVGImageFrame::PaintSVG(nsSVGRenderState *aContext,
|
||||
mImageContainer->GetWidth(&nativeWidth);
|
||||
mImageContainer->GetHeight(&nativeHeight);
|
||||
|
||||
nsSVGUtils::CompositePatternMatrix(gfx, thebesPattern, fini, nativeWidth, nativeHeight, opacity);
|
||||
nsSVGUtils::CompositePatternMatrix(gfx, thebesPattern, GetImageTransform(),
|
||||
nativeWidth, nativeHeight, opacity);
|
||||
|
||||
if (GetStyleDisplay()->IsScrollableOverflow())
|
||||
gfx->Restore();
|
||||
@ -295,9 +286,7 @@ nsSVGImageFrame::GetFrameForPoint(const nsPoint &aPoint)
|
||||
mImageContainer->GetWidth(&nativeWidth);
|
||||
mImageContainer->GetHeight(&nativeHeight);
|
||||
|
||||
nsCOMPtr<nsIDOMSVGMatrix> fini = GetImageTransform();
|
||||
|
||||
if (!nsSVGUtils::HitTestRect(fini,
|
||||
if (!nsSVGUtils::HitTestRect(GetImageTransform(),
|
||||
0, 0, nativeWidth, nativeHeight,
|
||||
PresContext()->AppUnitsToDevPixels(aPoint.x),
|
||||
PresContext()->AppUnitsToDevPixels(aPoint.y))) {
|
||||
|
@ -159,17 +159,13 @@ NS_IMETHODIMP_(nsIFrame*)
|
||||
nsSVGInnerSVGFrame::GetFrameForPoint(const nsPoint &aPoint)
|
||||
{
|
||||
if (GetStyleDisplay()->IsScrollableOverflow()) {
|
||||
nsSVGElement *content = static_cast<nsSVGElement*>(mContent);
|
||||
nsSVGContainerFrame *parent = static_cast<nsSVGContainerFrame*>(mParent);
|
||||
|
||||
float clipX, clipY, clipWidth, clipHeight;
|
||||
nsCOMPtr<nsIDOMSVGMatrix> clipTransform;
|
||||
content->GetAnimatedLengthValues(&clipX, &clipY, &clipWidth, &clipHeight, nsnull);
|
||||
|
||||
nsSVGElement *svg = static_cast<nsSVGElement*>(mContent);
|
||||
svg->GetAnimatedLengthValues(&clipX, &clipY, &clipWidth, &clipHeight, nsnull);
|
||||
|
||||
nsSVGContainerFrame *parent = static_cast<nsSVGContainerFrame*>
|
||||
(mParent);
|
||||
clipTransform = NS_NewSVGMatrix(parent->GetCanvasTM());
|
||||
|
||||
if (!nsSVGUtils::HitTestRect(clipTransform,
|
||||
if (!nsSVGUtils::HitTestRect(parent->GetCanvasTM(),
|
||||
clipX, clipY, clipWidth, clipHeight,
|
||||
PresContext()->AppUnitsToDevPixels(aPoint.x),
|
||||
PresContext()->AppUnitsToDevPixels(aPoint.y))) {
|
||||
|
@ -42,7 +42,6 @@
|
||||
#include "nsRegion.h"
|
||||
#include "nsLayoutUtils.h"
|
||||
#include "nsDisplayList.h"
|
||||
#include "nsSVGMatrix.h"
|
||||
#include "nsSVGFilterPaintCallback.h"
|
||||
#include "nsSVGFilterFrame.h"
|
||||
#include "nsSVGClipPathFrame.h"
|
||||
@ -284,7 +283,7 @@ nsSVGIntegrationUtils::PaintFramesWithEffects(nsIRenderingContext* aCtx,
|
||||
userSpaceRect = userSpaceRect.ToNearestPixels(appUnitsPerDevPixel).ToAppUnits(appUnitsPerDevPixel);
|
||||
aCtx->Translate(userSpaceRect.x, userSpaceRect.y);
|
||||
|
||||
nsCOMPtr<nsIDOMSVGMatrix> matrix = GetInitialMatrix(aEffectsFrame);
|
||||
gfxMatrix matrix = GetInitialMatrix(aEffectsFrame);
|
||||
|
||||
PRBool complexEffects = PR_FALSE;
|
||||
/* Check if we need to do additional operations on this child's
|
||||
@ -359,19 +358,18 @@ nsSVGIntegrationUtils::PaintFramesWithEffects(nsIRenderingContext* aCtx,
|
||||
gfx->SetMatrix(savedCTM);
|
||||
}
|
||||
|
||||
already_AddRefed<nsIDOMSVGMatrix>
|
||||
gfxMatrix
|
||||
nsSVGIntegrationUtils::GetInitialMatrix(nsIFrame* aNonSVGFrame)
|
||||
{
|
||||
NS_ASSERTION(!aNonSVGFrame->IsFrameOfType(nsIFrame::eSVG),
|
||||
"SVG frames should not get here");
|
||||
PRInt32 appUnitsPerDevPixel = aNonSVGFrame->PresContext()->AppUnitsPerDevPixel();
|
||||
nsCOMPtr<nsIDOMSVGMatrix> matrix;
|
||||
float devPxPerCSSPx =
|
||||
1 / nsPresContext::AppUnitsToFloatCSSPixels(appUnitsPerDevPixel);
|
||||
NS_NewSVGMatrix(getter_AddRefs(matrix),
|
||||
devPxPerCSSPx, 0.0f,
|
||||
0.0f, devPxPerCSSPx);
|
||||
return matrix.forget();
|
||||
|
||||
return gfxMatrix(devPxPerCSSPx, 0.0,
|
||||
0.0, devPxPerCSSPx,
|
||||
0.0, 0.0);
|
||||
}
|
||||
|
||||
gfxRect
|
||||
|
@ -41,12 +41,12 @@
|
||||
#include "nsPoint.h"
|
||||
#include "nsRect.h"
|
||||
#include "gfxRect.h"
|
||||
#include "gfxMatrix.h"
|
||||
|
||||
class nsIFrame;
|
||||
class nsDisplayListBuilder;
|
||||
class nsDisplayList;
|
||||
class nsIRenderingContext;
|
||||
class nsIDOMSVGMatrix;
|
||||
|
||||
/***** Integration of SVG effects with regular frame painting *****/
|
||||
|
||||
@ -97,7 +97,7 @@ public:
|
||||
nsDisplayListBuilder* aBuilder,
|
||||
nsDisplayList* aInnerList);
|
||||
|
||||
static already_AddRefed<nsIDOMSVGMatrix>
|
||||
static gfxMatrix
|
||||
GetInitialMatrix(nsIFrame* aNonSVGFrame);
|
||||
/**
|
||||
* Returns aNonSVGFrame's rect in CSS pixel units. This is the union
|
||||
|
@ -39,7 +39,6 @@
|
||||
#include "nsIDocument.h"
|
||||
#include "nsSVGMarkerFrame.h"
|
||||
#include "nsSVGPathGeometryFrame.h"
|
||||
#include "nsSVGMatrix.h"
|
||||
#include "nsSVGEffects.h"
|
||||
#include "nsSVGMarkerElement.h"
|
||||
#include "nsSVGPathGeometryElement.h"
|
||||
@ -113,18 +112,10 @@ nsSVGMarkerFrame::GetCanvasTM()
|
||||
gfxMatrix markedTM = mMarkedFrame->GetCanvasTM();
|
||||
mInUse2 = PR_FALSE;
|
||||
|
||||
nsCOMPtr<nsIDOMSVGMatrix> markerTM;
|
||||
content->GetMarkerTransform(mStrokeWidth, mX, mY, mAngle, getter_AddRefs(markerTM));
|
||||
gfxMatrix markerTM = content->GetMarkerTransform(mStrokeWidth, mX, mY, mAngle);
|
||||
gfxMatrix viewBoxTM = content->GetViewBoxTransform();
|
||||
|
||||
nsCOMPtr<nsIDOMSVGMatrix> viewBoxTM;
|
||||
nsresult res = content->GetViewboxToViewportTransform(getter_AddRefs(viewBoxTM));
|
||||
if (NS_FAILED(res)) {
|
||||
return gfxMatrix(0.0, 0.0, 0.0, 0.0, 0.0, 0.0); // singular
|
||||
}
|
||||
|
||||
markedTM.PreMultiply(nsSVGUtils::ConvertSVGMatrixToThebes(markerTM));
|
||||
markedTM.PreMultiply(nsSVGUtils::ConvertSVGMatrixToThebes(viewBoxTM));
|
||||
return markedTM;
|
||||
return viewBoxTM * markerTM * markedTM;
|
||||
}
|
||||
|
||||
|
||||
|
@ -41,6 +41,7 @@
|
||||
#include "nsIDOMSVGMatrix.h"
|
||||
#include "gfxContext.h"
|
||||
#include "gfxImageSurface.h"
|
||||
#include "nsSVGMatrix.h"
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Implementation
|
||||
@ -54,7 +55,7 @@ NS_NewSVGMaskFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
||||
already_AddRefed<gfxPattern>
|
||||
nsSVGMaskFrame::ComputeMaskAlpha(nsSVGRenderState *aContext,
|
||||
nsIFrame* aParent,
|
||||
nsIDOMSVGMatrix* aMatrix,
|
||||
const gfxMatrix &aMatrix,
|
||||
float aOpacity)
|
||||
{
|
||||
// If the flag is set when we get here, it means this mask frame
|
||||
@ -84,11 +85,11 @@ nsSVGMaskFrame::ComputeMaskAlpha(nsSVGRenderState *aContext,
|
||||
&mask->mLengthAttributes[nsSVGMaskElement::X], bbox, aParent);
|
||||
|
||||
gfx->Save();
|
||||
nsSVGUtils::SetClipRect(gfx, nsSVGUtils::ConvertSVGMatrixToThebes(aMatrix), maskArea);
|
||||
nsSVGUtils::SetClipRect(gfx, aMatrix, maskArea);
|
||||
}
|
||||
|
||||
mMaskParent = aParent;
|
||||
mMaskParentMatrix = aMatrix;
|
||||
mMaskParentMatrix = NS_NewSVGMatrix(aMatrix);
|
||||
|
||||
for (nsIFrame* kid = mFrames.FirstChild(); kid;
|
||||
kid = kid->GetNextSibling()) {
|
||||
@ -185,11 +186,8 @@ nsSVGMaskFrame::GetCanvasTM()
|
||||
|
||||
nsSVGMaskElement *mask = static_cast<nsSVGMaskElement*>(mContent);
|
||||
|
||||
nsCOMPtr<nsIDOMSVGMatrix> matrix =
|
||||
nsSVGUtils::AdjustMatrixForUnits(mMaskParentMatrix,
|
||||
return nsSVGUtils::AdjustMatrixForUnits(nsSVGUtils::ConvertSVGMatrixToThebes(mMaskParentMatrix),
|
||||
&mask->mEnumAttributes[nsSVGMaskElement::MASKCONTENTUNITS],
|
||||
mMaskParent);
|
||||
|
||||
return nsSVGUtils::ConvertSVGMatrixToThebes(matrix);
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ public:
|
||||
// nsSVGMaskFrame method:
|
||||
already_AddRefed<gfxPattern> ComputeMaskAlpha(nsSVGRenderState *aContext,
|
||||
nsIFrame* aParent,
|
||||
nsIDOMSVGMatrix* aMatrix,
|
||||
const gfxMatrix &aMatrix,
|
||||
float aOpacity = 1.0f);
|
||||
|
||||
#ifdef DEBUG
|
||||
|
@ -741,41 +741,23 @@ gfxMatrix
|
||||
nsSVGOuterSVGFrame::GetCanvasTM()
|
||||
{
|
||||
if (!mCanvasTM) {
|
||||
nsSVGSVGElement *svgElement = static_cast<nsSVGSVGElement*>(mContent);
|
||||
nsSVGSVGElement *content = static_cast<nsSVGSVGElement*>(mContent);
|
||||
|
||||
float devPxPerCSSPx =
|
||||
1 / PresContext()->AppUnitsToFloatCSSPixels(
|
||||
1.0f / PresContext()->AppUnitsToFloatCSSPixels(
|
||||
PresContext()->AppUnitsPerDevPixel());
|
||||
nsCOMPtr<nsIDOMSVGMatrix> devPxToCSSPxMatrix;
|
||||
NS_NewSVGMatrix(getter_AddRefs(devPxToCSSPxMatrix),
|
||||
devPxPerCSSPx, 0.0f,
|
||||
0.0f, devPxPerCSSPx);
|
||||
|
||||
nsCOMPtr<nsIDOMSVGMatrix> viewBoxTM;
|
||||
nsresult res =
|
||||
svgElement->GetViewboxToViewportTransform(getter_AddRefs(viewBoxTM));
|
||||
if (NS_SUCCEEDED(res) && viewBoxTM) {
|
||||
// PRE-multiply px conversion!
|
||||
devPxToCSSPxMatrix->Multiply(viewBoxTM, getter_AddRefs(mCanvasTM));
|
||||
} else {
|
||||
NS_WARNING("We should propagate the fact that the viewBox is invalid.");
|
||||
mCanvasTM = devPxToCSSPxMatrix;
|
||||
}
|
||||
gfxMatrix viewBoxTM = content->GetViewBoxTransform();
|
||||
|
||||
// our content is the document element so we must premultiply the values
|
||||
// of its currentScale and currentTranslate properties
|
||||
gfxMatrix zoomPanTM;
|
||||
if (mIsRootContent) {
|
||||
nsCOMPtr<nsIDOMSVGMatrix> zoomPanMatrix;
|
||||
nsCOMPtr<nsIDOMSVGMatrix> temp;
|
||||
float scale = svgElement->GetCurrentScale();
|
||||
const nsSVGTranslatePoint& translate = svgElement->GetCurrentTranslate();
|
||||
|
||||
svgElement->CreateSVGMatrix(getter_AddRefs(zoomPanMatrix));
|
||||
zoomPanMatrix->Translate(translate.GetX(), translate.GetY(), getter_AddRefs(temp));
|
||||
temp->Scale(scale, getter_AddRefs(zoomPanMatrix));
|
||||
zoomPanMatrix->Multiply(mCanvasTM, getter_AddRefs(temp));
|
||||
temp.swap(mCanvasTM);
|
||||
const nsSVGTranslatePoint& translate = content->GetCurrentTranslate();
|
||||
zoomPanTM.Translate(gfxPoint(translate.GetX(), translate.GetY()));
|
||||
zoomPanTM.Scale(content->GetCurrentScale(), content->GetCurrentScale());
|
||||
}
|
||||
|
||||
gfxMatrix TM = viewBoxTM * zoomPanTM * gfxMatrix().Scale(devPxPerCSSPx, devPxPerCSSPx);
|
||||
mCanvasTM = NS_NewSVGMatrix(TM);
|
||||
}
|
||||
return nsSVGUtils::ConvertSVGMatrixToThebes(mCanvasTM);
|
||||
}
|
||||
|
@ -39,7 +39,6 @@
|
||||
#include "nsSVGPathGeometryFrame.h"
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsSVGMarkerFrame.h"
|
||||
#include "nsSVGMatrix.h"
|
||||
#include "nsSVGUtils.h"
|
||||
#include "nsSVGEffects.h"
|
||||
#include "nsSVGGraphicElement.h"
|
||||
|
@ -48,7 +48,6 @@
|
||||
#include "gfxMatrix.h"
|
||||
|
||||
class nsPresContext;
|
||||
class nsIDOMSVGMatrix;
|
||||
class nsSVGMarkerFrame;
|
||||
class nsSVGMarkerProperty;
|
||||
|
||||
|
@ -54,6 +54,7 @@
|
||||
#include "gfxContext.h"
|
||||
#include "gfxPlatform.h"
|
||||
#include "gfxPattern.h"
|
||||
#include "gfxMatrix.h"
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -197,16 +198,19 @@ nsSVGPatternFrame::PaintPattern(gfxASurface** surface,
|
||||
// the geometry that is being rendered with a pattern
|
||||
nsSVGElement *callerContent;
|
||||
gfxRect callerBBox;
|
||||
nsCOMPtr<nsIDOMSVGMatrix> callerCTM;
|
||||
if (NS_FAILED(GetTargetGeometry(getter_AddRefs(callerCTM),
|
||||
gfxMatrix callerCTM;
|
||||
if (NS_FAILED(GetTargetGeometry(&callerCTM,
|
||||
&callerBBox,
|
||||
&callerContent, aSource)))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// Construct the CTM that we will provide to our children when we
|
||||
// render them into the tile.
|
||||
if (NS_FAILED(ConstructCTM(getter_AddRefs(mCTM), callerBBox, callerCTM)))
|
||||
gfxMatrix ctm = ConstructCTM(callerBBox, callerCTM);
|
||||
if (ctm.IsSingular()) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
mCTM = NS_NewSVGMatrix(ctm);
|
||||
|
||||
// Get the bounding box of the pattern. This will be used to determine
|
||||
// the size of the surface, and will also be used to define the bounding
|
||||
@ -474,7 +478,7 @@ nsSVGPatternFrame::GetPatternWithAttr(nsIAtom *aAttrName, nsIContent *aDefault)
|
||||
|
||||
gfxRect
|
||||
nsSVGPatternFrame::GetPatternRect(const gfxRect &aTargetBBox,
|
||||
nsIDOMSVGMatrix *aTargetCTM,
|
||||
const gfxMatrix &aTargetCTM,
|
||||
nsSVGElement *aTarget)
|
||||
{
|
||||
// Get our type
|
||||
@ -512,52 +516,42 @@ GetLengthValue(const nsSVGLength2 *aLength)
|
||||
return aLength->GetAnimValue(static_cast<nsSVGSVGElement*>(nsnull));
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsSVGPatternFrame::ConstructCTM(nsIDOMSVGMatrix **aCTM,
|
||||
const gfxRect &callerBBox,
|
||||
nsIDOMSVGMatrix *callerCTM)
|
||||
gfxMatrix
|
||||
nsSVGPatternFrame::ConstructCTM(const gfxRect &callerBBox,
|
||||
const gfxMatrix &callerCTM)
|
||||
{
|
||||
nsCOMPtr<nsIDOMSVGMatrix> tCTM, tempTM;
|
||||
gfxMatrix tCTM;
|
||||
|
||||
// Begin by handling the objectBoundingBox conversion since
|
||||
// this must be handled in the CTM
|
||||
PRUint16 type = GetPatternContentUnits();
|
||||
|
||||
if (type == nsIDOMSVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) {
|
||||
NS_NewSVGMatrix(getter_AddRefs(tCTM), callerBBox.Width(), 0.0f, 0.0f,
|
||||
callerBBox.Height(), 0.0f, 0.0f);
|
||||
// The objectBoundingBox conversion must be handled in the CTM:
|
||||
if (GetPatternContentUnits() ==
|
||||
nsIDOMSVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) {
|
||||
tCTM.Scale(callerBBox.Width(), callerBBox.Height());
|
||||
} else {
|
||||
float scale = nsSVGUtils::MaxExpansion(callerCTM);
|
||||
NS_NewSVGMatrix(getter_AddRefs(tCTM), scale, 0, 0, scale, 0, 0);
|
||||
tCTM.Scale(scale, scale);
|
||||
}
|
||||
|
||||
gfxMatrix viewBoxTM;
|
||||
const nsSVGViewBoxRect viewBox = GetViewBox().GetAnimValue();
|
||||
|
||||
if (viewBox.height > 0.0f && viewBox.width > 0.0f) {
|
||||
|
||||
float viewportWidth = GetLengthValue(GetWidth());
|
||||
float viewportHeight = GetLengthValue(GetHeight());
|
||||
float refX = GetLengthValue(GetX());
|
||||
float refY = GetLengthValue(GetY());
|
||||
|
||||
tempTM = nsSVGUtils::GetViewBoxTransform(viewportWidth, viewportHeight,
|
||||
viewBox.x + refX, viewBox.y + refY,
|
||||
viewBox.width, viewBox.height,
|
||||
GetPreserveAspectRatio(),
|
||||
PR_TRUE);
|
||||
|
||||
} else {
|
||||
// No viewBox, construct from the (modified) parent matrix
|
||||
NS_NewSVGMatrix(getter_AddRefs(tempTM));
|
||||
viewBoxTM = nsSVGUtils::GetViewBoxTransform(viewportWidth, viewportHeight,
|
||||
viewBox.x + refX, viewBox.y + refY,
|
||||
viewBox.width, viewBox.height,
|
||||
GetPreserveAspectRatio(),
|
||||
PR_TRUE);
|
||||
}
|
||||
tCTM->Multiply(tempTM, aCTM);
|
||||
return NS_OK;
|
||||
return viewBoxTM * tCTM;
|
||||
}
|
||||
|
||||
gfxMatrix
|
||||
nsSVGPatternFrame::GetPatternMatrix(const gfxRect &bbox,
|
||||
const gfxRect &callerBBox,
|
||||
nsIDOMSVGMatrix *callerCTM)
|
||||
const gfxMatrix &callerCTM)
|
||||
{
|
||||
// Get the pattern transform
|
||||
gfxMatrix patternTransform = GetPatternTransform();
|
||||
@ -580,12 +574,11 @@ nsSVGPatternFrame::GetPatternMatrix(const gfxRect &bbox,
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsSVGPatternFrame::GetTargetGeometry(nsIDOMSVGMatrix **aCTM,
|
||||
nsSVGPatternFrame::GetTargetGeometry(gfxMatrix *aCTM,
|
||||
gfxRect *aBBox,
|
||||
nsSVGElement **aTargetContent,
|
||||
nsSVGGeometryFrame *aTarget)
|
||||
{
|
||||
*aCTM = nsnull;
|
||||
*aTargetContent = nsnull;
|
||||
|
||||
// Make sure the callerContent is an SVG element. If we are attempting
|
||||
@ -618,7 +611,7 @@ nsSVGPatternFrame::GetTargetGeometry(nsIDOMSVGMatrix **aCTM,
|
||||
}
|
||||
|
||||
// Get the transformation matrix from our calling geometry
|
||||
*aCTM = NS_NewSVGMatrix(aTarget->GetCanvasTM()).get();
|
||||
*aCTM = aTarget->GetCanvasTM();
|
||||
|
||||
// OK, now fix up the bounding box to reflect user coordinates
|
||||
// We handle device unit scaling in pattern matrix
|
||||
|
@ -129,15 +129,14 @@ protected:
|
||||
|
||||
NS_IMETHOD GetPatternFirstChild(nsIFrame **kid);
|
||||
gfxRect GetPatternRect(const gfxRect &bbox,
|
||||
nsIDOMSVGMatrix *callerCTM,
|
||||
const gfxMatrix &callerCTM,
|
||||
nsSVGElement *content);
|
||||
gfxMatrix GetPatternMatrix(const gfxRect &bbox,
|
||||
const gfxRect &callerBBox,
|
||||
nsIDOMSVGMatrix *callerCTM);
|
||||
nsresult ConstructCTM(nsIDOMSVGMatrix **ctm,
|
||||
const gfxRect &callerBBox,
|
||||
nsIDOMSVGMatrix *callerCTM);
|
||||
nsresult GetTargetGeometry(nsIDOMSVGMatrix **aCTM,
|
||||
const gfxMatrix &callerCTM);
|
||||
gfxMatrix ConstructCTM(const gfxRect &callerBBox,
|
||||
const gfxMatrix &callerCTM);
|
||||
nsresult GetTargetGeometry(gfxMatrix *aCTM,
|
||||
gfxRect *aBBox,
|
||||
nsSVGElement **aTargetContent,
|
||||
nsSVGGeometryFrame *aTarget);
|
||||
|
@ -41,7 +41,6 @@
|
||||
#include "nsSVGUtils.h"
|
||||
#include "nsSVGTextFrame.h"
|
||||
#include "nsSVGOuterSVGFrame.h"
|
||||
#include "nsSVGMatrix.h"
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Implementation
|
||||
|
@ -37,7 +37,6 @@
|
||||
#include "nsSVGContainerFrame.h"
|
||||
#include "nsSVGTextFrame.h"
|
||||
#include "nsSVGUtils.h"
|
||||
#include "nsSVGMatrix.h"
|
||||
#include "nsSVGOuterSVGFrame.h"
|
||||
#include "nsIDOMSVGTextElement.h"
|
||||
#include "nsIDOMSVGAnimatedLengthList.h"
|
||||
|
@ -42,7 +42,6 @@
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsSVGPathElement.h"
|
||||
#include "nsSVGTextPathElement.h"
|
||||
#include "nsSVGMatrix.h"
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Implementation
|
||||
@ -153,13 +152,11 @@ already_AddRefed<gfxFlattenedPath>
|
||||
nsSVGTextPathFrame::GetFlattenedPath(nsIFrame *path)
|
||||
{
|
||||
NS_PRECONDITION(path, "Unexpected null path");
|
||||
nsSVGPathGeometryElement *element = static_cast<nsSVGPathGeometryElement*>
|
||||
(path->GetContent());
|
||||
|
||||
nsCOMPtr<nsIDOMSVGMatrix> localTM =
|
||||
NS_NewSVGMatrix(element->PrependLocalTransformTo(gfxMatrix()));
|
||||
nsSVGPathGeometryElement *element =
|
||||
static_cast<nsSVGPathGeometryElement*>(path->GetContent());
|
||||
|
||||
return element->GetFlattenedPath(localTM);
|
||||
return element->GetFlattenedPath(element->PrependLocalTransformTo(gfxMatrix()));
|
||||
}
|
||||
|
||||
gfxFloat
|
||||
|
@ -36,7 +36,6 @@
|
||||
|
||||
#include "nsSVGGFrame.h"
|
||||
#include "nsIAnonymousContentCreator.h"
|
||||
#include "nsSVGMatrix.h"
|
||||
#include "nsIDOMSVGUseElement.h"
|
||||
#include "nsIDOMSVGTransformable.h"
|
||||
#include "nsSVGElement.h"
|
||||
|
@ -436,124 +436,111 @@ nsSVGUtils::CoordToFloat(nsPresContext *aPresContext,
|
||||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsSVGUtils::GetNearestViewportElement(nsIContent *aContent,
|
||||
nsIDOMSVGElement * *aNearestViewportElement)
|
||||
PRBool
|
||||
nsSVGUtils::EstablishesViewport(nsIContent *aContent)
|
||||
{
|
||||
*aNearestViewportElement = nsnull;
|
||||
return aContent && aContent->GetNameSpaceID() == kNameSpaceID_SVG &&
|
||||
(aContent->Tag() == nsGkAtoms::svg ||
|
||||
aContent->Tag() == nsGkAtoms::image ||
|
||||
aContent->Tag() == nsGkAtoms::foreignObject ||
|
||||
aContent->Tag() == nsGkAtoms::symbol);
|
||||
}
|
||||
|
||||
already_AddRefed<nsIDOMSVGElement>
|
||||
nsSVGUtils::GetNearestViewportElement(nsIContent *aContent)
|
||||
{
|
||||
nsIContent *element = GetParentElement(aContent);
|
||||
|
||||
while (element && element->GetNameSpaceID() == kNameSpaceID_SVG) {
|
||||
if (EstablishesViewport(element)) {
|
||||
if (element->Tag() == nsGkAtoms::foreignObject) {
|
||||
return nsnull;
|
||||
}
|
||||
return nsCOMPtr<nsIDOMSVGElement>(do_QueryInterface(element)).forget();
|
||||
}
|
||||
element = GetParentElement(element);
|
||||
}
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
already_AddRefed<nsIDOMSVGElement>
|
||||
nsSVGUtils::GetFarthestViewportElement(nsIContent *aContent)
|
||||
{
|
||||
nsIContent *element = nsnull;
|
||||
nsIContent *ancestor = GetParentElement(aContent);
|
||||
|
||||
while (ancestor && ancestor->GetNameSpaceID() == kNameSpaceID_SVG &&
|
||||
ancestor->Tag() != nsGkAtoms::foreignObject) {
|
||||
|
||||
nsCOMPtr<nsIDOMSVGFitToViewBox> fitToViewBox = do_QueryInterface(ancestor);
|
||||
|
||||
if (fitToViewBox) {
|
||||
// right interface
|
||||
nsCOMPtr<nsIDOMSVGElement> element = do_QueryInterface(ancestor);
|
||||
element.swap(*aNearestViewportElement);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
ancestor = GetParentElement(ancestor);
|
||||
ancestor->Tag() != nsGkAtoms::foreignObject) {
|
||||
element = ancestor;
|
||||
ancestor = GetParentElement(element);
|
||||
}
|
||||
if (ancestor && ancestor->GetNameSpaceID() == kNameSpaceID_SVG &&
|
||||
ancestor->Tag() == nsGkAtoms::foreignObject )
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
return NS_OK;
|
||||
if (element && element->Tag() == nsGkAtoms::svg) {
|
||||
return nsCOMPtr<nsIDOMSVGElement>(do_QueryInterface(element)).forget();
|
||||
}
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsSVGUtils::AppendTransformUptoElement(nsIContent *aContent, nsIDOMSVGElement *aElement, nsIDOMSVGMatrix * *aCTM){
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIDOMSVGElement> element = do_QueryInterface(aContent);
|
||||
nsIContent *ancestor = GetParentElement(aContent);
|
||||
if (!aElement) {
|
||||
// calculating GetScreenCTM(): traverse upto the root or non-SVG content.
|
||||
if (ancestor && ancestor->GetNameSpaceID() == kNameSpaceID_SVG) {
|
||||
if (ancestor->Tag() == nsGkAtoms::foreignObject && aContent->Tag() != nsGkAtoms::svg)
|
||||
return NS_ERROR_FAILURE;
|
||||
rv = AppendTransformUptoElement(ancestor, aElement, aCTM);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
} else if (element != aElement) { // calculating GetCTM(): stop at aElement.
|
||||
NS_ASSERTION(ancestor != nsnull, "ancestor shouldn't be null.");
|
||||
if (!ancestor)
|
||||
return NS_ERROR_FAILURE;
|
||||
rv = AppendTransformUptoElement(ancestor, aElement, aCTM);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMSVGMatrix> tmp;
|
||||
if (nsCOMPtr<nsIDOMSVGSVGElement>(do_QueryInterface(aContent))) {
|
||||
nsSVGSVGElement *svgElement = static_cast<nsSVGSVGElement*>(aContent);
|
||||
rv = svgElement->AppendTransform(*aCTM, getter_AddRefs(tmp));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
} else if (nsCOMPtr<nsIDOMSVGTransformable>(do_QueryInterface(aContent))) {
|
||||
nsSVGGraphicElement *graphicElement = static_cast<nsSVGGraphicElement*>(aContent);
|
||||
rv = graphicElement->AppendTransform(*aCTM, getter_AddRefs(tmp));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
} else {
|
||||
//XXX aContent may be other type of viewport-establising elements
|
||||
// (e.g. <use> and <symbol>) and handle them?
|
||||
}
|
||||
if (tmp)
|
||||
tmp.swap(*aCTM);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsSVGUtils::GetCTM(nsIContent *aContent, nsIDOMSVGMatrix * *aCTM)
|
||||
gfxMatrix
|
||||
nsSVGUtils::GetCTM(nsSVGElement *aElement, PRBool aScreenCTM)
|
||||
{
|
||||
nsresult rv;
|
||||
nsIDocument* currentDoc = aContent->GetCurrentDoc();
|
||||
nsIDocument* currentDoc = aElement->GetCurrentDoc();
|
||||
if (currentDoc) {
|
||||
// Flush all pending notifications so that our frames are uptodate
|
||||
// Flush all pending notifications so that our frames are up to date
|
||||
currentDoc->FlushPendingNotifications(Flush_Layout);
|
||||
}
|
||||
|
||||
*aCTM = nsnull;
|
||||
nsCOMPtr<nsIDOMSVGElement> nearestViewportElement;
|
||||
rv = GetNearestViewportElement(aContent, getter_AddRefs(nearestViewportElement));
|
||||
// According to the spec(http://www.w3.org/TR/SVG11/types.html#InterfaceSVGLocatable),
|
||||
// GetCTM is strictly defined to be the CTM for nearestViewportElement,
|
||||
// Thus, if it is null, this is null, too.
|
||||
if (NS_FAILED(rv) || !nearestViewportElement)
|
||||
return NS_OK; // we can't throw exceptions from this API.
|
||||
gfxMatrix matrix = aElement->PrependLocalTransformTo(gfxMatrix());
|
||||
nsSVGElement *element = aElement;
|
||||
nsIContent *ancestor = GetParentElement(aElement);
|
||||
|
||||
nsCOMPtr<nsIDOMSVGMatrix> tmp;
|
||||
rv = NS_NewSVGMatrix(getter_AddRefs(tmp), 1, 0, 0, 1, 0, 0);
|
||||
if (NS_FAILED(rv)) return NS_OK; // we can't throw exceptions from this API.
|
||||
tmp.swap(*aCTM);
|
||||
rv = AppendTransformUptoElement(aContent, nearestViewportElement, aCTM);
|
||||
if (NS_FAILED(rv))
|
||||
tmp.swap(*aCTM);
|
||||
return NS_OK; // we can't throw exceptions from this API.
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsSVGUtils::GetScreenCTM(nsIContent *aContent, nsIDOMSVGMatrix * *aCTM)
|
||||
{
|
||||
nsresult rv;
|
||||
nsIDocument* currentDoc = aContent->GetCurrentDoc();
|
||||
if (currentDoc) {
|
||||
// Flush all pending notifications so that our frames are uptodate
|
||||
currentDoc->FlushPendingNotifications(Flush_Layout);
|
||||
while (ancestor && ancestor->GetNameSpaceID() == kNameSpaceID_SVG &&
|
||||
ancestor->Tag() != nsGkAtoms::foreignObject) {
|
||||
element = static_cast<nsSVGElement*>(ancestor);
|
||||
matrix *= element->PrependLocalTransformTo(gfxMatrix()); // i.e. *A*ppend
|
||||
if (!aScreenCTM && EstablishesViewport(element)) {
|
||||
if (!element->NodeInfo()->Equals(nsGkAtoms::svg, kNameSpaceID_SVG) &&
|
||||
!element->NodeInfo()->Equals(nsGkAtoms::symbol, kNameSpaceID_SVG)) {
|
||||
NS_ERROR("New (SVG > 1.1) SVG viewport establishing element?");
|
||||
return gfxMatrix(0.0, 0.0, 0.0, 0.0, 0.0, 0.0); // singular
|
||||
}
|
||||
// XXX spec seems to say x,y translation should be undone for IsInnerSVG
|
||||
return matrix;
|
||||
}
|
||||
ancestor = GetParentElement(element);
|
||||
}
|
||||
|
||||
*aCTM = nsnull;
|
||||
|
||||
nsCOMPtr<nsIDOMSVGMatrix> tmp;
|
||||
rv = NS_NewSVGMatrix(getter_AddRefs(tmp), 1, 0, 0, 1, 0, 0);
|
||||
if (NS_FAILED(rv)) return NS_OK; // we can't throw exceptions from this API.
|
||||
tmp.swap(*aCTM);
|
||||
rv = AppendTransformUptoElement(aContent, nsnull, aCTM);
|
||||
if (NS_FAILED(rv))
|
||||
tmp.swap(*aCTM);
|
||||
return NS_OK; // we can't throw exceptions from this API.
|
||||
if (!aScreenCTM) {
|
||||
// didn't find a nearestViewportElement
|
||||
return gfxMatrix(0.0, 0.0, 0.0, 0.0, 0.0, 0.0); // singular
|
||||
}
|
||||
if (!ancestor || !ancestor->IsNodeOfType(nsINode::eELEMENT)) {
|
||||
return matrix;
|
||||
}
|
||||
if (ancestor->GetNameSpaceID() == kNameSpaceID_SVG) {
|
||||
if (element->Tag() != nsGkAtoms::svg) {
|
||||
return gfxMatrix(0.0, 0.0, 0.0, 0.0, 0.0, 0.0); // singular
|
||||
}
|
||||
return matrix * GetCTM(static_cast<nsSVGElement*>(ancestor), PR_TRUE);
|
||||
}
|
||||
// XXX this does not take into account CSS transform, or that the non-SVG
|
||||
// content that we've hit may itself be inside an SVG foreignObject higher up
|
||||
float x = 0.0f, y = 0.0f;
|
||||
if (element->NodeInfo()->Equals(nsGkAtoms::svg, kNameSpaceID_SVG)) {
|
||||
nsIPresShell *presShell = currentDoc->GetPrimaryShell();
|
||||
if (element && presShell) {
|
||||
nsPresContext *context = presShell->GetPresContext();
|
||||
if (context) {
|
||||
nsIFrame* frame = presShell->GetPrimaryFrameFor(element);
|
||||
nsIFrame* ancestorFrame = presShell->GetRootFrame();
|
||||
if (frame && ancestorFrame) {
|
||||
nsPoint point = frame->GetOffsetTo(ancestorFrame);
|
||||
x = nsPresContext::AppUnitsToFloatCSSPixels(point.x);
|
||||
y = nsPresContext::AppUnitsToFloatCSSPixels(point.y);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return matrix * gfxMatrix().Translate(gfxPoint(x, y));
|
||||
}
|
||||
|
||||
nsSVGDisplayContainerFrame*
|
||||
@ -574,33 +561,6 @@ nsSVGUtils::GetNearestSVGViewport(nsIFrame *aFrame)
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsSVGUtils::GetFarthestViewportElement(nsIContent *aContent,
|
||||
nsIDOMSVGElement * *aFarthestViewportElement)
|
||||
{
|
||||
*aFarthestViewportElement = nsnull;
|
||||
|
||||
nsIContent *ancestor = GetParentElement(aContent);
|
||||
nsCOMPtr<nsIDOMSVGElement> element;
|
||||
|
||||
while (ancestor && ancestor->GetNameSpaceID() == kNameSpaceID_SVG &&
|
||||
ancestor->Tag() != nsGkAtoms::foreignObject) {
|
||||
|
||||
nsCOMPtr<nsIDOMSVGFitToViewBox> fitToViewBox = do_QueryInterface(ancestor);
|
||||
|
||||
if (fitToViewBox) {
|
||||
// right interface
|
||||
element = do_QueryInterface(ancestor);
|
||||
}
|
||||
|
||||
ancestor = GetParentElement(ancestor);
|
||||
}
|
||||
|
||||
element.swap(*aFarthestViewportElement);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsRect
|
||||
nsSVGUtils::FindFilterInvalidation(nsIFrame *aFrame, const nsRect& aRect)
|
||||
{
|
||||
@ -805,7 +765,7 @@ nsSVGUtils::GetOuterSVGFrameAndCoveredRegion(nsIFrame* aFrame, nsRect* aRect)
|
||||
return GetOuterSVGFrame(aFrame);
|
||||
}
|
||||
|
||||
already_AddRefed<nsIDOMSVGMatrix>
|
||||
gfxMatrix
|
||||
nsSVGUtils::GetViewBoxTransform(float aViewportWidth, float aViewportHeight,
|
||||
float aViewboxX, float aViewboxY,
|
||||
float aViewboxWidth, float aViewboxHeight,
|
||||
@ -891,9 +851,7 @@ nsSVGUtils::GetViewBoxTransform(float aViewportWidth, float aViewportHeight,
|
||||
if (aViewboxX) e += -a * aViewboxX;
|
||||
if (aViewboxY) f += -d * aViewboxY;
|
||||
|
||||
nsIDOMSVGMatrix *retval;
|
||||
NS_NewSVGMatrix(&retval, a, 0.0f, 0.0f, d, e, f);
|
||||
return retval;
|
||||
return gfxMatrix(a, 0.0f, 0.0f, d, e, f);
|
||||
}
|
||||
|
||||
gfxMatrix
|
||||
@ -902,8 +860,7 @@ nsSVGUtils::GetCanvasTM(nsIFrame *aFrame)
|
||||
// XXX yuck, we really need a common interface for GetCanvasTM
|
||||
|
||||
if (!aFrame->IsFrameOfType(nsIFrame::eSVG)) {
|
||||
nsCOMPtr<nsIDOMSVGMatrix> matrix = nsSVGIntegrationUtils::GetInitialMatrix(aFrame);
|
||||
return ConvertSVGMatrixToThebes(matrix);
|
||||
return nsSVGIntegrationUtils::GetInitialMatrix(aFrame);
|
||||
}
|
||||
|
||||
nsIAtom* type = aFrame->GetType();
|
||||
@ -1038,8 +995,9 @@ nsSVGUtils::PaintFrameWithEffects(nsSVGRenderState *aContext,
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMSVGMatrix> matrix =
|
||||
(clipPathFrame || maskFrame) ? NS_NewSVGMatrix(GetCanvasTM(aFrame)) : nsnull;
|
||||
gfxMatrix matrix;
|
||||
if (clipPathFrame || maskFrame)
|
||||
matrix = GetCanvasTM(aFrame);
|
||||
|
||||
/* Check if we need to do additional operations on this child's
|
||||
* rendering, which necessitates rendering into another surface. */
|
||||
@ -1122,8 +1080,7 @@ nsSVGUtils::HitTestClip(nsIFrame *aFrame, const nsPoint &aPoint)
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMSVGMatrix> matrix = NS_NewSVGMatrix(GetCanvasTM(aFrame));
|
||||
return clipPathFrame->ClipHitTest(aFrame, matrix, aPoint);
|
||||
return clipPathFrame->ClipHitTest(aFrame, GetCanvasTM(aFrame), aPoint);
|
||||
}
|
||||
|
||||
nsIFrame *
|
||||
@ -1274,25 +1231,19 @@ nsSVGUtils::ConvertSVGMatrixToThebes(nsIDOMSVGMatrix *aMatrix)
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsSVGUtils::HitTestRect(nsIDOMSVGMatrix *aMatrix,
|
||||
nsSVGUtils::HitTestRect(const gfxMatrix &aMatrix,
|
||||
float aRX, float aRY, float aRWidth, float aRHeight,
|
||||
float aX, float aY)
|
||||
{
|
||||
PRBool result = PR_TRUE;
|
||||
|
||||
if (aMatrix) {
|
||||
gfxContext ctx(GetThebesComputationalSurface());
|
||||
ctx.SetMatrix(ConvertSVGMatrixToThebes(aMatrix));
|
||||
|
||||
ctx.NewPath();
|
||||
ctx.Rectangle(gfxRect(aRX, aRY, aRWidth, aRHeight));
|
||||
ctx.IdentityMatrix();
|
||||
|
||||
if (!ctx.PointInFill(gfxPoint(aX, aY)))
|
||||
result = PR_FALSE;
|
||||
if (aMatrix.IsSingular()) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
return result;
|
||||
gfxContext ctx(GetThebesComputationalSurface());
|
||||
ctx.SetMatrix(aMatrix);
|
||||
ctx.NewPath();
|
||||
ctx.Rectangle(gfxRect(aRX, aRY, aRWidth, aRHeight));
|
||||
ctx.IdentityMatrix();
|
||||
return ctx.PointInFill(gfxPoint(aX, aY));
|
||||
}
|
||||
|
||||
gfxRect
|
||||
@ -1339,40 +1290,31 @@ nsSVGUtils::GetClipRectForFrame(nsIFrame *aFrame,
|
||||
void
|
||||
nsSVGUtils::CompositeSurfaceMatrix(gfxContext *aContext,
|
||||
gfxASurface *aSurface,
|
||||
nsIDOMSVGMatrix *aCTM, float aOpacity)
|
||||
const gfxMatrix &aCTM, float aOpacity)
|
||||
{
|
||||
gfxMatrix matrix = ConvertSVGMatrixToThebes(aCTM);
|
||||
if (matrix.IsSingular())
|
||||
if (aCTM.IsSingular())
|
||||
return;
|
||||
|
||||
aContext->Save();
|
||||
|
||||
aContext->Multiply(matrix);
|
||||
|
||||
aContext->Multiply(aCTM);
|
||||
aContext->SetSource(aSurface);
|
||||
aContext->Paint(aOpacity);
|
||||
|
||||
aContext->Restore();
|
||||
}
|
||||
|
||||
void
|
||||
nsSVGUtils::CompositePatternMatrix(gfxContext *aContext,
|
||||
gfxPattern *aPattern,
|
||||
nsIDOMSVGMatrix *aCTM, float aWidth, float aHeight, float aOpacity)
|
||||
const gfxMatrix &aCTM, float aWidth, float aHeight, float aOpacity)
|
||||
{
|
||||
gfxMatrix matrix = ConvertSVGMatrixToThebes(aCTM);
|
||||
if (matrix.IsSingular())
|
||||
if (aCTM.IsSingular())
|
||||
return;
|
||||
|
||||
aContext->Save();
|
||||
|
||||
SetClipRect(aContext, ConvertSVGMatrixToThebes(aCTM), gfxRect(0, 0, aWidth, aHeight));
|
||||
|
||||
aContext->Multiply(matrix);
|
||||
|
||||
SetClipRect(aContext, aCTM, gfxRect(0, 0, aWidth, aHeight));
|
||||
aContext->Multiply(aCTM);
|
||||
aContext->SetPattern(aPattern);
|
||||
aContext->Paint(aOpacity);
|
||||
|
||||
aContext->Restore();
|
||||
}
|
||||
|
||||
@ -1461,40 +1403,34 @@ nsSVGUtils::CanOptimizeOpacity(nsIFrame *aFrame)
|
||||
}
|
||||
|
||||
float
|
||||
nsSVGUtils::MaxExpansion(nsIDOMSVGMatrix *aMatrix)
|
||||
nsSVGUtils::MaxExpansion(const gfxMatrix &aMatrix)
|
||||
{
|
||||
float a, b, c, d;
|
||||
aMatrix->GetA(&a);
|
||||
aMatrix->GetB(&b);
|
||||
aMatrix->GetC(&c);
|
||||
aMatrix->GetD(&d);
|
||||
|
||||
// maximum expansion derivation from
|
||||
// http://lists.cairographics.org/archives/cairo/2004-October/001980.html
|
||||
float f = (a * a + b * b + c * c + d * d) / 2;
|
||||
float g = (a * a + b * b - c * c - d * d) / 2;
|
||||
float h = a * c + b * d;
|
||||
// and also implemented in cairo_matrix_transformed_circle_major_axis
|
||||
double a = aMatrix.xx;
|
||||
double b = aMatrix.yx;
|
||||
double c = aMatrix.xy;
|
||||
double d = aMatrix.yy;
|
||||
double f = (a * a + b * b + c * c + d * d) / 2;
|
||||
double g = (a * a + b * b - c * c - d * d) / 2;
|
||||
double h = a * c + b * d;
|
||||
return sqrt(f + sqrt(g * g + h * h));
|
||||
}
|
||||
|
||||
already_AddRefed<nsIDOMSVGMatrix>
|
||||
nsSVGUtils::AdjustMatrixForUnits(nsIDOMSVGMatrix *aMatrix,
|
||||
gfxMatrix
|
||||
nsSVGUtils::AdjustMatrixForUnits(const gfxMatrix &aMatrix,
|
||||
nsSVGEnum *aUnits,
|
||||
nsIFrame *aFrame)
|
||||
{
|
||||
nsCOMPtr<nsIDOMSVGMatrix> fini = aMatrix;
|
||||
|
||||
if (aFrame &&
|
||||
aUnits->GetAnimValue() == nsIDOMSVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) {
|
||||
gfxRect bbox = GetBBox(aFrame);
|
||||
nsCOMPtr<nsIDOMSVGMatrix> tmp;
|
||||
aMatrix->Translate(bbox.X(), bbox.Y(), getter_AddRefs(tmp));
|
||||
tmp->ScaleNonUniform(bbox.Width(), bbox.Height(), getter_AddRefs(fini));
|
||||
return gfxMatrix().Scale(bbox.Width(), bbox.Height()) *
|
||||
gfxMatrix().Translate(gfxPoint(bbox.X(), bbox.Y())) *
|
||||
aMatrix;
|
||||
}
|
||||
|
||||
nsIDOMSVGMatrix* retval = fini.get();
|
||||
NS_IF_ADDREF(retval);
|
||||
return retval;
|
||||
return aMatrix;
|
||||
}
|
||||
|
||||
nsIFrame*
|
||||
@ -1567,6 +1503,17 @@ nsSVGUtils::PathExtentsToMaxStrokeExtents(const gfxRect& aPathExtents,
|
||||
return strokeExtents;
|
||||
}
|
||||
|
||||
/* static */ PRBool
|
||||
nsSVGUtils::IsInnerSVG(nsIContent* aContent)
|
||||
{
|
||||
if (!aContent->NodeInfo()->Equals(nsGkAtoms::svg, kNameSpaceID_SVG)) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
nsIContent *ancestor = GetParentElement(aContent);
|
||||
return ancestor && ancestor->GetNameSpaceID() == kNameSpaceID_SVG &&
|
||||
ancestor->Tag() != nsGkAtoms::foreignObject;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
nsSVGRenderState::nsSVGRenderState(nsIRenderingContext *aContext) :
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user