merge fx-team to m-c

This commit is contained in:
Rob Campbell 2011-11-22 10:29:39 -04:00
commit a41b0d26ee
152 changed files with 3075 additions and 1213 deletions

View File

@ -3931,14 +3931,13 @@ var FullScreen = {
// full-screen. Only add listeners and show warning etc when the event we
// receive is targeted at the chrome document, i.e. only once every time
// we enter DOM full-screen mode.
let targetDoc = event.target.ownerDocument ? event.target.ownerDocument : event.target;
if (targetDoc != document) {
if (event.target != document) {
// However, if we receive a "mozfullscreenchange" event for a document
// which is not a subdocument of the currently selected tab, we know that
// we've switched tabs since the request to enter full-screen was made,
// so we should exit full-screen since the "full-screen document" isn't
// acutally visible.
if (targetDoc.defaultView.top != gBrowser.contentWindow) {
if (event.target.defaultView.top != gBrowser.contentWindow) {
document.mozCancelFullScreen();
}
return;

View File

@ -113,6 +113,6 @@ endif # WIN32_REDIST_DIR
# run the binscope tool to make sure the binary and all libraries
# are using all available Windows OS-level security mechanisms
check::
$(PYTHON) $(srcdir)/autobinscope.py $(DIST)/bin/firefox.exe $(DIST)/crashreporter-symbols/
$(PYTHON) $(srcdir)/autobinscope.py $(DIST)/bin/$(MOZ_APP_NAME)$(BIN_SUFFIX) $(DIST)/crashreporter-symbols/
$(PYTHON) $(srcdir)/autobinscope.py $(DIST)/bin/plugin-container.exe $(DIST)/crashreporter-symbols/

View File

@ -144,6 +144,8 @@ netscape_security_isPrivilegeEnabled(JSContext *cx, uintN argc, jsval *vp)
if (NS_FAILED(rv))
result = JS_FALSE;
}
} else {
return JS_FALSE;
}
JS_SET_RVAL(cx, vp, BOOLEAN_TO_JSVAL(result));
return JS_TRUE;

View File

@ -66,6 +66,7 @@ endif
JAVAC_FLAGS = \
-target $(JAVA_VERSION) \
-source $(JAVA_VERSION) \
-classpath $(JAVA_CLASSPATH) \
-bootclasspath $(JAVA_BOOTCLASSPATH) \
-encoding ascii \

View File

@ -2350,7 +2350,10 @@ case "$target" in
MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
MOZ_OPTIMIZE_FLAGS="-O3"
_PEDANTIC=
MOZ_MEMORY=1
# Statically disable jemalloc on 10.5 and 32-bit 10.6. See bug 702250.
if test "$HAVE_64BIT_OS"; then
MOZ_MEMORY=1
fi
CFLAGS="$CFLAGS -fno-common"
CXXFLAGS="$CXXFLAGS -fno-common"
DLL_SUFFIX=".dylib"
@ -4684,7 +4687,7 @@ MOZ_USE_NATIVE_POPUP_WINDOWS=
MOZ_ANDROID_HISTORY=
case "${target}" in
*android*|*darwin*)
*darwin*)
ACCESSIBILITY=
;;
*)

View File

@ -88,6 +88,11 @@ namespace dom {
class Link;
// IID for the dom::Element interface
#define NS_ELEMENT_IID \
{ 0xa1588efb, 0x5a84, 0x49cd, \
{ 0x99, 0x1a, 0xac, 0x84, 0x9d, 0x92, 0x05, 0x0f } }
class Element : public nsIContent
{
public:
@ -98,6 +103,8 @@ public:
{}
#endif // MOZILLA_INTERNAL_API
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ELEMENT_IID)
NS_DECL_AND_IMPL_DOM_MEMORY_REPORTER_SIZEOF(Element, nsIContent)
/**
@ -187,6 +194,8 @@ private:
nsEventStates mState;
};
NS_DEFINE_STATIC_IID_ACCESSOR(Element, NS_ELEMENT_IID)
} // namespace dom
} // namespace mozilla

View File

@ -144,6 +144,7 @@ class nsAutoScriptBlockerSuppressNodeRemoved;
struct nsIntMargin;
class nsPIDOMWindow;
class nsIDocumentLoaderFactory;
class nsIDOMHTMLInputElement;
namespace mozilla {
@ -1109,7 +1110,7 @@ public:
* @param aPrincipal Prinicpal of the document. Must not be null.
* @param aScriptObject The object from which the context for event handling
* can be got.
* @param aSVGDocument Force SVG Document creation.
* @param aFlavor Select the kind of document to create.
* @param aResult [out] The document that was created.
*/
static nsresult CreateDocument(const nsAString& aNamespaceURI,
@ -1119,7 +1120,7 @@ public:
nsIURI* aBaseURI,
nsIPrincipal* aPrincipal,
nsIScriptGlobalObject* aScriptObject,
bool aSVGDocument,
DocumentFlavor aFlavor,
nsIDOMDocument** aResult);
/**
@ -1847,7 +1848,18 @@ public:
static nsresult Atob(const nsAString& aAsciiString,
nsAString& aBinaryData);
/**
* Returns whether the input element passed in parameter has the autocomplete
* functionnality enabled. It is taking into account the form owner.
* NOTE: the caller has to make sure autocomplete makes sense for the
* element's type.
*
* @param aInput the input element to check. NOTE: aInput can't be null.
* @return whether the input element has autocomplete enabled.
*/
static bool IsAutocompleteEnabled(nsIDOMHTMLInputElement* aInput);
private:
static bool InitializeEventTable();

View File

@ -130,6 +130,13 @@ class Element;
// Flag for AddStyleSheet().
#define NS_STYLESHEET_FROM_CATALOG (1 << 0)
// Enum for requesting a particular type of document when creating a doc
enum DocumentFlavor {
DocumentFlavorLegacyGuess, // compat with old code until made HTML5-compliant
DocumentFlavorHTML, // HTMLDocument with HTMLness bit set to true
DocumentFlavorSVG // SVGDocument
};
// Document states
// RTL locale: specific to the XUL localedir attribute
@ -1891,7 +1898,7 @@ NS_NewDOMDocument(nsIDOMDocument** aInstancePtrResult,
nsIPrincipal* aPrincipal,
bool aLoadedAsData,
nsIScriptGlobalObject* aEventObject,
bool aSVGDocument);
DocumentFlavor aFlavor);
// This is used only for xbl documents created from the startup cache.
// Non-cached documents are created in the same manner as xml documents.

View File

@ -178,6 +178,7 @@ static NS_DEFINE_CID(kXTFServiceCID, NS_XTFSERVICE_CID);
#include "nsICategoryManager.h"
#include "nsIViewManager.h"
#include "nsEventStateManager.h"
#include "nsIDOMHTMLInputElement.h"
#ifdef IBMBIDI
#include "nsIBidiKeyboard.h"
@ -649,6 +650,27 @@ nsContentUtils::Atob(const nsAString& aAsciiBase64String,
return rv;
}
bool
nsContentUtils::IsAutocompleteEnabled(nsIDOMHTMLInputElement* aInput)
{
NS_PRECONDITION(aInput, "aInput should not be null!");
nsAutoString autocomplete;
aInput->GetAutocomplete(autocomplete);
if (autocomplete.IsEmpty()) {
nsCOMPtr<nsIDOMHTMLFormElement> form;
aInput->GetForm(getter_AddRefs(form));
if (!form) {
return true;
}
form->GetAutocomplete(autocomplete);
}
return autocomplete.EqualsLiteral("on");
}
/**
* Access a cached parser service. Don't addref. We need only one
* reference to it and this class has that one.
@ -3706,12 +3728,12 @@ nsContentUtils::CreateDocument(const nsAString& aNamespaceURI,
nsIURI* aDocumentURI, nsIURI* aBaseURI,
nsIPrincipal* aPrincipal,
nsIScriptGlobalObject* aEventObject,
bool aSVGDocument,
DocumentFlavor aFlavor,
nsIDOMDocument** aResult)
{
nsresult rv = NS_NewDOMDocument(aResult, aNamespaceURI, aQualifiedName,
aDoctype, aDocumentURI, aBaseURI, aPrincipal,
true, aEventObject, aSVGDocument);
true, aEventObject, aFlavor);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDocument> document = do_QueryInterface(*aResult);

View File

@ -188,7 +188,9 @@ nsDOMParser::ParseFromStream(nsIInputStream *stream,
rv = nsContentUtils::CreateDocument(EmptyString(), EmptyString(), nsnull,
mDocumentURI, mBaseURI,
mOriginalPrincipal,
scriptHandlingObject, svg,
scriptHandlingObject,
svg ? DocumentFlavorSVG :
DocumentFlavorLegacyGuess,
getter_AddRefs(domDocument));
NS_ENSURE_SUCCESS(rv, rv);

View File

@ -1447,7 +1447,9 @@ nsDOMImplementation::CreateDocument(const nsAString& aNamespaceURI,
return nsContentUtils::CreateDocument(aNamespaceURI, aQualifiedName, aDoctype,
mDocumentURI, mBaseURI,
mOwner->NodePrincipal(),
scriptHandlingObject, false, aReturn);
scriptHandlingObject,
DocumentFlavorLegacyGuess,
aReturn);
}
NS_IMETHODIMP
@ -1479,7 +1481,8 @@ nsDOMImplementation::CreateHTMLDocument(const nsAString& aTitle,
rv = nsContentUtils::CreateDocument(EmptyString(), EmptyString(),
doctype, mDocumentURI, mBaseURI,
mOwner->NodePrincipal(),
scriptHandlingObject, false,
scriptHandlingObject,
DocumentFlavorLegacyGuess,
getter_AddRefs(document));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDocument> doc = do_QueryInterface(document);
@ -8603,6 +8606,8 @@ public:
void
nsDocument::AsyncRequestFullScreen(Element* aElement)
{
NS_ASSERTION(aElement,
"Must pass non-null element to nsDocument::AsyncRequestFullScreen");
if (!aElement) {
return;
}
@ -8611,20 +8616,48 @@ nsDocument::AsyncRequestFullScreen(Element* aElement)
NS_DispatchToCurrentThread(event);
}
static void
LogFullScreenDenied(bool aLogFailure, const char* aMessage, nsIDocument* aDoc)
{
if (!aLogFailure) {
return;
}
nsRefPtr<nsPLDOMEvent> e =
new nsPLDOMEvent(aDoc,
NS_LITERAL_STRING("mozfullscreenerror"),
true,
false);
e->PostDOMEvent();
nsContentUtils::ReportToConsole(nsContentUtils::eDOM_PROPERTIES,
aMessage,
nsnull, 0, nsnull,
EmptyString(), 0, 0,
nsIScriptError::warningFlag,
"DOM", aDoc);
}
void
nsDocument::RequestFullScreen(Element* aElement, bool aWasCallerChrome)
{
if (!aElement ||
!aElement->IsInDoc() ||
aElement->OwnerDoc() != this ||
!IsFullScreenEnabled(aWasCallerChrome) ||
!GetWindow()) {
nsRefPtr<nsPLDOMEvent> e =
new nsPLDOMEvent(this,
NS_LITERAL_STRING("mozfullscreenerror"),
true,
false);
e->PostDOMEvent();
NS_ASSERTION(aElement,
"Must pass non-null element to nsDocument::RequestFullScreen");
if (!aElement) {
return;
}
if (!aElement->IsInDoc()) {
LogFullScreenDenied(true, "FullScreenDeniedNotInDocument", this);
return;
}
if (aElement->OwnerDoc() != this) {
LogFullScreenDenied(true, "FullScreenDeniedMovedDocument", this);
return;
}
if (!GetWindow()) {
LogFullScreenDenied(true, "FullScreenDeniedLostWindow", this);
return;
}
if (!IsFullScreenEnabled(aWasCallerChrome, true)) {
// IsFullScreenEnabled calls LogFullScreenDenied, no need to log.
return;
}
@ -8719,12 +8752,12 @@ NS_IMETHODIMP
nsDocument::GetMozFullScreenEnabled(bool *aFullScreen)
{
NS_ENSURE_ARG_POINTER(aFullScreen);
*aFullScreen = IsFullScreenEnabled(nsContentUtils::IsCallerChrome());
*aFullScreen = IsFullScreenEnabled(nsContentUtils::IsCallerChrome(), false);
return NS_OK;
}
bool
nsDocument::IsFullScreenEnabled(bool aCallerIsChrome)
nsDocument::IsFullScreenEnabled(bool aCallerIsChrome, bool aLogFailure)
{
if (nsContentUtils::IsFullScreenApiEnabled() && aCallerIsChrome) {
// Chrome code can always use the full-screen API, provided it's not
@ -8734,9 +8767,16 @@ nsDocument::IsFullScreenEnabled(bool aCallerIsChrome)
return true;
}
if (!nsContentUtils::IsFullScreenApiEnabled() ||
nsContentUtils::HasPluginWithUncontrolledEventDispatch(this) ||
!IsVisible()) {
if (!nsContentUtils::IsFullScreenApiEnabled()) {
LogFullScreenDenied(aLogFailure, "FullScreenDeniedDisabled", this);
return false;
}
if (nsContentUtils::HasPluginWithUncontrolledEventDispatch(this)) {
LogFullScreenDenied(aLogFailure, "FullScreenDeniedPlugins", this);
return false;
}
if (!IsVisible()) {
LogFullScreenDenied(aLogFailure, "FullScreenDeniedHidden", this);
return false;
}
@ -8750,6 +8790,7 @@ nsDocument::IsFullScreenEnabled(bool aCallerIsChrome)
// The node requesting fullscreen, or one of its crossdoc ancestors,
// is an iframe which doesn't have the "mozalllowfullscreen" attribute.
// This request is not authorized by the parent document.
LogFullScreenDenied(aLogFailure, "FullScreenDeniedIframeDisallowed", this);
return false;
}
node = nsContentUtils::GetCrossDocParentNode(node);

View File

@ -978,7 +978,9 @@ protected:
// doc tree, and if the document is visible, and if the api is not
// disabled by pref. aIsCallerChrome must contain the return value of
// nsContentUtils::IsCallerChrome() from the context we're checking.
bool IsFullScreenEnabled(bool aIsCallerChrome);
// If aLogFailure is true, an appropriate warning message is logged to the
// console, and a "mozfullscreenerror" event is dispatched to this document.
bool IsFullScreenEnabled(bool aIsCallerChrome, bool aLogFailure);
/**
* Check that aId is not empty and log a message to the console

View File

@ -3067,6 +3067,12 @@ nsGenericElement::UnbindFromTree(bool aDeep, bool aNullParent)
if (IsFullScreenAncestor(this)) {
// The element being removed is an ancestor of the full-screen element,
// exit full-screen state.
nsContentUtils::ReportToConsole(nsContentUtils::eDOM_PROPERTIES,
"RemovedFullScreenElement",
nsnull, 0, nsnull,
EmptyString(), 0, 0,
nsIScriptError::warningFlag,
"DOM", OwnerDoc());
OwnerDoc()->CancelFullScreen();
}
if (GetParent()) {
@ -4343,6 +4349,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_INTERFACE_MAP_BEGIN(nsGenericElement)
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
NS_INTERFACE_MAP_ENTRIES_CYCLE_COLLECTION(nsGenericElement)
NS_INTERFACE_MAP_ENTRY(Element)
NS_INTERFACE_MAP_ENTRY(nsIContent)
NS_INTERFACE_MAP_ENTRY(nsINode)
NS_INTERFACE_MAP_ENTRY(nsIDOMEventTarget)

View File

@ -259,7 +259,6 @@ GK_ATOM(crop, "crop")
GK_ATOM(crossorigin, "crossorigin")
GK_ATOM(curpos, "curpos")
GK_ATOM(current, "current")
GK_ATOM(currentloop, "currentloop")
GK_ATOM(cycler, "cycler")
GK_ATOM(data, "data")
GK_ATOM(datalist, "datalist")
@ -533,8 +532,6 @@ GK_ATOM(localName, "local-name")
GK_ATOM(longdesc, "longdesc")
#ifdef MOZ_MEDIA
GK_ATOM(loop, "loop")
GK_ATOM(loopend, "loopend")
GK_ATOM(loopstart, "loopstart")
#endif
GK_ATOM(low, "low")
GK_ATOM(lowerFirst, "lower-first")
@ -781,14 +778,10 @@ GK_ATOM(percent, "percent")
GK_ATOM(persist, "persist")
GK_ATOM(phase, "phase")
GK_ATOM(ping, "ping")
#ifdef MOZ_MEDIA
GK_ATOM(pixelratio, "pixelratio")
#endif
GK_ATOM(placeholder, "placeholder")
GK_ATOM(plaintext, "plaintext")
#ifdef MOZ_MEDIA
GK_ATOM(playbackrate, "playbackrate")
GK_ATOM(playcount, "playcount")
#endif
GK_ATOM(pointSize, "point-size")
GK_ATOM(poly, "poly")
@ -1783,6 +1776,10 @@ GK_ATOM(XULLabelFrame, "XULLabelFrame")
GK_ATOM(svgAFrame, "SVGAFrame")
GK_ATOM(svgClipPathFrame, "SVGClipPathFrame")
GK_ATOM(svgDefsFrame, "SVGDefsFrame")
GK_ATOM(svgFEContainerFrame, "SVGFEContainerFrame")
GK_ATOM(svgFEImageFrame, "SVGFEImageFrame")
GK_ATOM(svgFELeafFrame, "SVGFELeafFrame")
GK_ATOM(svgFEUnstyledLeafFrame, "SVGFEUnstyledLeafFrame")
GK_ATOM(svgFilterFrame, "SVGFilterFrame")
GK_ATOM(svgForeignObjectFrame, "SVGForeignObjectFrame")
GK_ATOM(svgGenericContainerFrame, "SVGGenericContainerFrame")

View File

@ -244,8 +244,6 @@ nsIAtom** const kAttributesHTML[] = {
&nsGkAtoms::longdesc,
#ifdef MOZ_MEDIA
&nsGkAtoms::loop,
&nsGkAtoms::loopend,
&nsGkAtoms::loopstart,
#endif
&nsGkAtoms::low,
&nsGkAtoms::max,
@ -263,13 +261,9 @@ nsIAtom** const kAttributesHTML[] = {
&nsGkAtoms::open,
&nsGkAtoms::optimum,
&nsGkAtoms::pattern,
#ifdef MOZ_MEDIA
&nsGkAtoms::pixelratio,
#endif
&nsGkAtoms::placeholder,
#ifdef MOZ_MEDIA
&nsGkAtoms::playbackrate,
&nsGkAtoms::playcount,
#endif
&nsGkAtoms::pointSize,
#ifdef MOZ_MEDIA

View File

@ -70,7 +70,6 @@
#include "nsCExternalHandlerService.h"
#include "nsIVariant.h"
#include "xpcprivate.h"
#include "nsIParser.h"
#include "XPCQuickStubs.h"
#include "nsStringStream.h"
#include "nsIStreamConverterService.h"
@ -156,6 +155,8 @@ using namespace mozilla;
#define NS_PROGRESS_EVENT_INTERVAL 50
NS_IMPL_ISUPPORTS1(nsXHRParseEndListener, nsIDOMEventListener)
class nsResumeTimeoutsEvent : public nsRunnable
{
public:
@ -431,7 +432,11 @@ nsXMLHttpRequest::nsXMLHttpRequest()
mUploadProgress(0), mUploadProgressMax(0),
mErrorLoad(false), mTimerIsActive(false),
mProgressEventWasDelayed(false),
mLoadLengthComputable(false), mLoadTotal(0),
mLoadLengthComputable(false),
mIsHtml(false),
mWarnAboutMultipartHtml(false),
mWarnAboutSyncHtml(false),
mLoadTotal(0),
mFirstStartRequestSeen(false),
mInLoadProgressEvent(false),
mResultJSON(JSVAL_VOID),
@ -721,7 +726,34 @@ nsXMLHttpRequest::GetResponseXML(nsIDOMDocument **aResponseXML)
*aResponseXML = mResponseXML;
NS_ADDREF(*aResponseXML);
}
if (mWarnAboutMultipartHtml) {
mWarnAboutMultipartHtml = false;
nsContentUtils::ReportToConsole(nsContentUtils::eDOM_PROPERTIES,
"HTMLMultipartXHRWarning",
nsnull,
0,
nsnull, // Response URL not kept around
EmptyString(),
0,
0,
nsIScriptError::warningFlag,
"DOM",
mOwner->WindowID());
}
if (mWarnAboutSyncHtml) {
mWarnAboutSyncHtml = false;
nsContentUtils::ReportToConsole(nsContentUtils::eDOM_PROPERTIES,
"HTMLSyncXHRWarning",
nsnull,
0,
nsnull, // Response URL not kept around
EmptyString(),
0,
0,
nsIScriptError::warningFlag,
"DOM",
mOwner->WindowID());
}
return NS_OK;
}
@ -852,7 +884,7 @@ NS_IMETHODIMP nsXMLHttpRequest::GetResponseText(nsAString& aResponseText)
// We only decode text lazily if we're also parsing to a doc.
// Also, if we've decoded all current data already, then no need to decode
// more.
if (!mResponseXML ||
if (IsWaitingForHTMLCharset() || !mResponseXML ||
mResponseBodyDecodedPos == mResponseBody.Length()) {
aResponseText = mResponseText;
return NS_OK;
@ -1182,16 +1214,16 @@ nsXMLHttpRequest::Abort()
XML_HTTP_REQUEST_OPENED |
XML_HTTP_REQUEST_DONE))) {
ChangeState(XML_HTTP_REQUEST_DONE, true);
}
if (!(mState & XML_HTTP_REQUEST_SYNCLOOPING)) {
NS_NAMED_LITERAL_STRING(abortStr, ABORT_STR);
DispatchProgressEvent(this, abortStr, mLoadLengthComputable, responseLength,
mLoadTotal);
if (mUpload && !mUploadComplete) {
mUploadComplete = true;
DispatchProgressEvent(mUpload, abortStr, true, mUploadTransferred,
mUploadTotal);
if (!(mState & XML_HTTP_REQUEST_SYNCLOOPING)) {
NS_NAMED_LITERAL_STRING(abortStr, ABORT_STR);
DispatchProgressEvent(this, abortStr, mLoadLengthComputable, responseLength,
mLoadTotal);
if (mUpload && !mUploadComplete) {
mUploadComplete = true;
DispatchProgressEvent(mUpload, abortStr, true, mUploadTransferred,
mUploadTotal);
}
}
}
@ -1441,6 +1473,16 @@ nsXMLHttpRequest::IsSystemXHR()
return !!nsContentUtils::IsSystemPrincipal(mPrincipal);
}
bool
nsXMLHttpRequest::IsWaitingForHTMLCharset()
{
if (!mIsHtml) {
return false;
}
nsCOMPtr<nsIDocument> doc = do_QueryInterface(mResponseXML);
return doc->GetDocumentCharacterSetSource() < kCharsetFromDocTypeDefault;
}
nsresult
nsXMLHttpRequest::CheckChannelForCrossSiteRequest(nsIChannel* aChannel)
{
@ -1875,6 +1917,9 @@ nsXMLHttpRequest::OnStartRequest(nsIRequest *request, nsISupports *ctxt)
parseBody = !method.EqualsLiteral("HEAD");
}
mIsHtml = false;
mWarnAboutMultipartHtml = false;
mWarnAboutSyncHtml = false;
if (parseBody && NS_SUCCEEDED(status)) {
// We can gain a huge performance win by not even trying to
// parse non-XML data. This also protects us from the situation
@ -1883,7 +1928,30 @@ nsXMLHttpRequest::OnStartRequest(nsIRequest *request, nsISupports *ctxt)
nsCAutoString type;
channel->GetContentType(type);
if (type.Find("xml") == kNotFound) {
if (type.EqualsLiteral("text/html")) {
if (!(mState & XML_HTTP_REQUEST_ASYNC)) {
// We don't make cool new features available in the bad synchronous
// mode. The synchronous mode is for legacy only.
mWarnAboutSyncHtml = true;
mState &= ~XML_HTTP_REQUEST_PARSEBODY;
} else if (mState & XML_HTTP_REQUEST_MULTIPART) {
// HTML parsing is supported only for non-multipart responses. The
// multipart implementation assumes that it's OK to start the next part
// immediately after the last part. That doesn't work with the HTML
// parser, because when OnStopRequest for one part has fired, the
// parser thread still hasn't posted back the runnables that make the
// parsing appear finished.
//
// On the other hand, multipart support seems to be a legacy feature,
// so it isn't clear that use cases justify adding support for deferring
// the multipart stream events between parts to accommodate the
// asynchronous nature of the HTML parser.
mWarnAboutMultipartHtml = true;
mState &= ~XML_HTTP_REQUEST_PARSEBODY;
} else {
mIsHtml = true;
}
} else if (type.Find("xml") == kNotFound) {
mState &= ~XML_HTTP_REQUEST_PARSEBODY;
}
} else {
@ -1908,7 +1976,9 @@ nsXMLHttpRequest::OnStartRequest(nsIRequest *request, nsISupports *ctxt)
const nsAString& emptyStr = EmptyString();
nsCOMPtr<nsIScriptGlobalObject> global = do_QueryInterface(mOwner);
rv = nsContentUtils::CreateDocument(emptyStr, emptyStr, nsnull, docURI,
baseURI, mPrincipal, global, false,
baseURI, mPrincipal, global,
mIsHtml ? DocumentFlavorHTML :
DocumentFlavorLegacyGuess,
getter_AddRefs(mResponseXML));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDocument> responseDoc = do_QueryInterface(mResponseXML);
@ -1993,12 +2063,8 @@ nsXMLHttpRequest::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult
return NS_OK;
}
nsCOMPtr<nsIParser> parser;
// Is this good enough here?
if (mState & XML_HTTP_REQUEST_PARSEBODY && mXMLParserStreamListener) {
parser = do_QueryInterface(mXMLParserStreamListener);
NS_ABORT_IF_FALSE(parser, "stream listener was expected to be a parser");
mXMLParserStreamListener->OnStopRequest(request, ctxt, status);
}
@ -2007,8 +2073,11 @@ nsXMLHttpRequest::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult
mContext = nsnull;
// If we're received data since the last progress event, make sure to fire
// an event for it.
MaybeDispatchProgressEvents(true);
// an event for it, except in the HTML case, defer the last progress event
// until the parser is done.
if (!mIsHtml) {
MaybeDispatchProgressEvents(true);
}
nsCOMPtr<nsIChannel> channel(do_QueryInterface(request));
NS_ENSURE_TRUE(channel, NS_ERROR_UNEXPECTED);
@ -2053,9 +2122,6 @@ nsXMLHttpRequest::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult
mResponseXML = nsnull;
}
NS_ASSERTION(!parser || parser->IsParserEnabled(),
"Parser blocked somehow?");
// If we're uninitialized at this point, we encountered an error
// earlier and listeners have already been notified. Also we do
// not want to do this if we already completed.
@ -2064,18 +2130,42 @@ nsXMLHttpRequest::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult
return NS_OK;
}
if (!mResponseXML) {
ChangeStateToDone();
return NS_OK;
}
if (mIsHtml) {
NS_ASSERTION(!(mState & XML_HTTP_REQUEST_SYNCLOOPING),
"We weren't supposed to support HTML parsing with XHR!");
nsCOMPtr<nsIDOMEventTarget> eventTarget = do_QueryInterface(mResponseXML);
nsEventListenerManager* manager = eventTarget->GetListenerManager(true);
manager->AddEventListenerByType(new nsXHRParseEndListener(this),
NS_LITERAL_STRING("DOMContentLoaded"),
NS_EVENT_FLAG_BUBBLE |
NS_EVENT_FLAG_SYSTEM_EVENT);
return NS_OK;
}
// We might have been sent non-XML data. If that was the case,
// we should null out the document member. The idea in this
// check here is that if there is no document element it is not
// an XML document. We might need a fancier check...
if (mResponseXML) {
nsCOMPtr<nsIDOMElement> root;
mResponseXML->GetDocumentElement(getter_AddRefs(root));
if (!root) {
mResponseXML = nsnull;
}
nsCOMPtr<nsIDOMElement> root;
mResponseXML->GetDocumentElement(getter_AddRefs(root));
if (!root) {
mResponseXML = nsnull;
}
ChangeStateToDone();
return NS_OK;
}
void
nsXMLHttpRequest::ChangeStateToDone()
{
if (mIsHtml) {
// In the HTML case, this has to be deferred, because the parser doesn't
// do it's job synchronously.
MaybeDispatchProgressEvents(true);
}
ChangeState(XML_HTTP_REQUEST_DONE, true);
NS_NAMED_LITERAL_STRING(errorStr, ERROR_STR);
@ -2101,8 +2191,6 @@ nsXMLHttpRequest::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult
// We're a multipart request, so we're not done. Reset to opened.
ChangeState(XML_HTTP_REQUEST_OPENED);
}
return NS_OK;
}
NS_IMETHODIMP
@ -3050,11 +3138,13 @@ nsXMLHttpRequest::MaybeDispatchProgressEvents(bool aFinalProgress)
mLoadTotal = mLoadTransferred;
mLoadLengthComputable = true;
}
mInLoadProgressEvent = true;
DispatchProgressEvent(this, NS_LITERAL_STRING(PROGRESS_STR),
true, mLoadLengthComputable, mLoadTransferred,
mLoadTotal, mLoadTransferred, mLoadTotal);
mInLoadProgressEvent = false;
if (aFinalProgress || !IsWaitingForHTMLCharset()) {
mInLoadProgressEvent = true;
DispatchProgressEvent(this, NS_LITERAL_STRING(PROGRESS_STR),
true, mLoadLengthComputable, mLoadTransferred,
mLoadTotal, mLoadTransferred, mLoadTotal);
mInLoadProgressEvent = false;
}
if (mResponseType == XML_HTTP_RESPONSE_TYPE_CHUNKED_TEXT ||
mResponseType == XML_HTTP_RESPONSE_TYPE_CHUNKED_ARRAYBUFFER) {
mResponseBody.Truncate();

View File

@ -123,6 +123,7 @@ class nsXMLHttpRequest : public nsXHREventTarget,
public nsIJSNativeInitializer,
public nsITimerCallback
{
friend class nsXHRParseEndListener;
public:
nsXMLHttpRequest();
virtual ~nsXMLHttpRequest();
@ -235,6 +236,10 @@ protected:
bool IsSystemXHR();
bool IsWaitingForHTMLCharset();
void ChangeStateToDone();
/**
* Check if aChannel is ok for a cross-site request by making sure no
* inappropriate headers are set, and no username/password is set.
@ -347,6 +352,9 @@ protected:
bool mTimerIsActive;
bool mProgressEventWasDelayed;
bool mLoadLengthComputable;
bool mIsHtml;
bool mWarnAboutMultipartHtml;
bool mWarnAboutSyncHtml;
PRUint64 mLoadTotal; // 0 if not known.
PRUint64 mLoadTransferred;
nsCOMPtr<nsITimer> mProgressNotifier;
@ -432,4 +440,24 @@ protected:
PRUint64 mMaxProgress;
};
class nsXHRParseEndListener : public nsIDOMEventListener
{
public:
NS_DECL_ISUPPORTS
NS_IMETHOD HandleEvent(nsIDOMEvent *event)
{
nsCOMPtr<nsIXMLHttpRequest> xhr = do_QueryReferent(mXHR);
if (xhr) {
static_cast<nsXMLHttpRequest*>(xhr.get())->ChangeStateToDone();
}
mXHR = nsnull;
return NS_OK;
}
nsXHRParseEndListener(nsIXMLHttpRequest* aXHR)
: mXHR(do_GetWeakReference(aXHR)) {}
virtual ~nsXHRParseEndListener() {}
private:
nsWeakPtr mXHR;
};
#endif

View File

@ -505,6 +505,12 @@ _TEST_FILES2 = \
somedatas.resource \
somedatas.resource^headers^ \
delayedServerEvents.sjs \
test_html_in_xhr.html \
file_html_in_xhr.html \
file_html_in_xhr2.html \
file_html_in_xhr3.html \
file_html_in_xhr.sjs \
file_html_in_xhr_slow.sjs \
test_bug664916.html \
test_bug666604.html \
test_bug675121.html \
@ -522,6 +528,7 @@ _TEST_FILES2 = \
file_bug692434.xml \
test_bug693875.html \
test_nodelist_holes.html \
test_xhr_abort_after_load.html \
$(NULL)
_CHROME_FILES = \

View File

@ -0,0 +1,16 @@
<!DOCTYPE html>
<html><!-- Þ -->
<meta charset="Windows-1251">
<script>
document.documentElement.setAttribute("data-fail", "FAIL");
</script>
<script src="file_html_in_xhr.sjs"></script>
<script src="file_html_in_xhr.sjs" defer></script>
<script src="file_html_in_xhr.sjs" async></script>
<link type="stylesheet" href="file_html_in_xhr.sjs">
<body onload='document.documentElement.setAttribute("data-fail", "FAIL");'>
<img src="file_html_in_xhr.sjs">
<iframe src="file_html_in_xhr.sjs"></iframe>
<video poster="file_html_in_xhr.sjs" src="file_html_in_xhr.sjs"></video>
<object data="file_html_in_xhr.sjs"></object>
<noscript><div></div></noscript>

View File

@ -0,0 +1,15 @@
function handleRequest(request, response)
{
response.setHeader("Content-Type", "text/javascript", false);
if (request.queryString.indexOf("report") != -1) {
if (getState("loaded") == "loaded") {
response.write("ok(false, 'This script was not supposed to get fetched.'); continueAfterReport();");
} else {
response.write("ok(true, 'This script was not supposed to get fetched.'); continueAfterReport();");
}
} else {
setState("loaded", "loaded");
response.write('document.documentElement.setAttribute("data-fail", "FAIL");');
}
}

View File

@ -0,0 +1 @@
<meta charset="windows-1251">Þ

View File

@ -0,0 +1 @@
SUCCESS

View File

@ -0,0 +1,24 @@
var timer;
function handleRequest(request, response)
{
var converter = Components.classes["@mozilla.org/intl/scriptableunicodeconverter"]
.createInstance(Components.interfaces.nsIScriptableUnicodeConverter);
converter.charset = "windows-1251";
var stream = converter.convertToInputStream("\u042E");
var out = response.bodyOutputStream;
response.setHeader("Cache-Control", "no-cache", false);
response.setHeader("Content-Type", "text/html", false);
out.writeFrom(stream, 1);
var firstPart = "<meta charset='windows";
out.write(firstPart, firstPart.length);
out.flush();
response.processAsync();
timer = Components.classes["@mozilla.org/timer;1"]
.createInstance(Components.interfaces.nsITimer);
timer.initWithCallback(function() {
response.write("-1251'>");
response.finish();
}, 500, Components.interfaces.nsITimer.TYPE_ONE_SHOT);
}

View File

@ -27,32 +27,29 @@ function testCancelInPhase4() {
// First request - should be loaded from server
var xhr = new XMLHttpRequest();
xhr.addEventListener("readystatechange", function(e) {
if (xhr.readyState >= 4) {
xhr.addEventListener("abort", function() {
setTimeout(function() {
// This request was cancelled, so the responseText should be empty string
is(xhr.responseText, "", "Expected empty response to cancelled request");
if (xhr.readyState < xhr.DONE) return;
is(xhr.readyState, xhr.DONE, "wrong readyState");
xhr.abort();
SimpleTest.executeSoon(function() {
// This request was cancelled, so the responseText should be empty string
is(xhr.responseText, "", "Expected empty response to cancelled request");
// Second request - should be found in cache
var xhr2 = new XMLHttpRequest();
// Second request - should be found in cache
var xhr2 = new XMLHttpRequest();
xhr2.addEventListener("load", function() {
is(xhr2.responseText, "0", "Received fresh value for second request");
SimpleTest.finish();
}, false);
xhr2.open("GET", url);
xhr2.setRequestHeader("X-Request", "1", false);
try { xhr2.send(); }
catch(e) {
is(xhr2.status, "200", "Exception!");
}
}, 0);
xhr2.addEventListener("load", function() {
is(xhr2.responseText, "0", "Received fresh value for second request");
SimpleTest.finish();
}, false);
xhr.abort();
}
xhr2.open("GET", url);
xhr2.setRequestHeader("X-Request", "1", false);
try { xhr2.send(); }
catch(e) {
is(xhr2.status, "200", "Exception!");
}
});
}, false);
xhr.open("GET", url, true);

View File

@ -0,0 +1,113 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=651072
-->
<head>
<title>Test for Bug 651072</title>
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body onload=runTest();>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=651072">Mozilla Bug 651072</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
/** Test for Bug 651072 **/
SimpleTest.waitForExplicitFinish();
var xhr = new XMLHttpRequest();
function runTest() {
xhr.onreadystatechange = function() {
if (this.readyState == 4) {
ok(this.responseXML, "Should have gotten responseXML");
is(this.responseXML.characterSet, "windows-1251", "Wrong character encoding");
is(this.responseXML.documentElement.firstChild.data, " \u042E ", "Decoded using the wrong encoding.");
is(this.responseText.indexOf("\u042E"), 27, "Bad responseText");
is(this.responseXML.getElementsByTagName("div").length, 1, "There should be one div.");
ok(!this.responseXML.documentElement.hasAttribute("data-fail"), "Should not have a data-fail attribute.");
var scripts = this.responseXML.getElementsByTagName("script");
is(scripts.length, 4, "Unexpected number of scripts.");
while (scripts.length) {
// These should not run when moved to another doc
document.body.appendChild(scripts[0]);
}
var s = document.createElement("script");
s.src = "file_html_in_xhr.sjs?report=1";
document.body.appendChild(s);
}
}
xhr.open("GET", "file_html_in_xhr.html", true);
xhr.send();
}
function continueAfterReport() {
ok(!document.documentElement.hasAttribute("data-fail"), "Should not have a data-fail attribute on mochitest doc.");
xhr = new XMLHttpRequest();
xhr.onprogress = function() {
ok(this.responseText, "Got falsy responseText");
if (this.responseText) {
ok(this.responseText.length, "Got zero-length responseText");
if (this.responseText.length) {
is(this.responseText.charCodeAt(0), 0x042E, "Wrong character encoding for slow text");
}
}
}
xhr.onreadystatechange = function() {
if (this.readyState == 4) {
testNonParsingText();
}
}
xhr.open("GET", "file_html_in_xhr_slow.sjs");
xhr.send();
}
function testNonParsingText() {
xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (this.readyState == 4) {
is(this.responseText.indexOf("\u042E"), -1, "Honored meta in text mode.");
is(this.responseText.indexOf("\uFFFD"), 29, "Honored meta in text mode 2.");
testChunkedText();
}
}
xhr.open("GET", "file_html_in_xhr2.html");
xhr.responseType = "text";
xhr.send();
}
function testChunkedText() {
xhr = new XMLHttpRequest();
xhr.onprogress = function() {
is(this.responseText.indexOf("\u042E"), -1, "Honored meta in chunked text mode.");
}
xhr.onreadystatechange = function() {
if (this.readyState == 4) {
testSyncXHR();
}
}
xhr.open("GET", "file_html_in_xhr2.html");
xhr.responseType = "moz-chunked-text";
xhr.send();
}
function testSyncXHR() {
xhr = new XMLHttpRequest();
xhr.open("GET", "file_html_in_xhr3.html", false);
xhr.send();
is(xhr.responseText, "SUCCESS\n", "responseText should be ready by now");
is(xhr.responseXML, null, "responseXML should be null in the sync case");
SimpleTest.finish();
}
</script>
</pre>
</body>
</html>

View File

@ -0,0 +1,95 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test bug 482935</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href=" /tests/SimpleTest/test.css" />
</head>
<body onload="onWindowLoad()">
<script class="testbody" type="text/javascript">"use strict";
SimpleTest.waitForExplicitFinish();
var url = "file_XHR_pass1.xml";
function onWindowLoad() {
runTest();
}
function runTest() {
var testFunctions = [
startTest1,
startTest2,
startTest3,
];
function nextTest() {
if (testFunctions.length == 0) {
SimpleTest.finish();
}
(testFunctions.shift())();
}
nextTest();
var xhr;
function startTest1() {
xhr = new XMLHttpRequest();
xhr.onload = onLoad1;
xhr.open("GET", url);
xhr.send();
}
function onLoad1() {
is(xhr.readyState, xhr.DONE, "readyState should be DONE");
xhr.onabort = onAbort1;
xhr.abort();
function onAbort1(e) {
ok(false, e.type + " event should not be fired!");
}
is(xhr.readyState, xhr.UNSENT, "readyState should be UNSENT");
nextTest();
}
function startTest2() {
xhr = new XMLHttpRequest();
xhr.onloadstart = onAfterSend;
xhr.open("GET", url);
xhr.send();
}
function startTest3() {
xhr = new XMLHttpRequest();
xhr.open("GET", url);
xhr.send();
onAfterSend();
}
function onAfterSend() {
is(xhr.readyState, xhr.OPENED, "readyState should be OPENED");
var sent = false;
try {
xhr.send();
} catch (e) {
sent = true;
}
ok(sent, "send() flag should be set");
var aborted = false;
xhr.onabort = onAbort2;
xhr.abort();
function onAbort2() {
is(xhr.readyState, xhr.DONE, "readyState should be DONE");
aborted = true;
}
ok(aborted, "abort event should be fired");
is(xhr.readyState, xhr.UNSENT, "readyState should be UNSENT");
nextTest();
}
}
</script>
</body>
</html>

View File

@ -68,8 +68,6 @@
#include "nsIDOMXULControlElement.h"
#include "nsINameSpaceManager.h"
#include "nsIBaseWindow.h"
#include "nsIView.h"
#include "nsIViewManager.h"
#include "nsISelection.h"
#include "nsFrameSelection.h"
#include "nsIPrivateDOMEvent.h"
@ -1030,8 +1028,7 @@ nsresult
nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext,
nsEvent *aEvent,
nsIFrame* aTargetFrame,
nsEventStatus* aStatus,
nsIView* aView)
nsEventStatus* aStatus)
{
NS_ENSURE_ARG_POINTER(aStatus);
NS_ENSURE_ARG(aPresContext);
@ -3029,8 +3026,7 @@ nsresult
nsEventStateManager::PostHandleEvent(nsPresContext* aPresContext,
nsEvent *aEvent,
nsIFrame* aTargetFrame,
nsEventStatus* aStatus,
nsIView* aView)
nsEventStatus* aStatus)
{
NS_ENSURE_ARG(aPresContext);
NS_ENSURE_ARG_POINTER(aStatus);

View File

@ -106,8 +106,7 @@ public:
nsresult PreHandleEvent(nsPresContext* aPresContext,
nsEvent *aEvent,
nsIFrame* aTargetFrame,
nsEventStatus* aStatus,
nsIView* aView);
nsEventStatus* aStatus);
/* The PostHandleEvent method should contain all system processing which
* should occur conditionally based on DOM or frame processing. It should
@ -117,8 +116,7 @@ public:
nsresult PostHandleEvent(nsPresContext* aPresContext,
nsEvent *aEvent,
nsIFrame* aTargetFrame,
nsEventStatus* aStatus,
nsIView* aView);
nsEventStatus* aStatus);
void NotifyDestroyPresContext(nsPresContext* aPresContext);
void SetPresContext(nsPresContext* aPresContext);

View File

@ -42,7 +42,6 @@
#include "nsCOMPtr.h"
#include "nsIWidget.h"
#include "nsIViewManager.h"
#include "nsIViewObserver.h"
#include "nsIPresShell.h"
#include "nsISupports.h"
#include "nsPIDOMWindow.h"
@ -331,7 +330,9 @@ nsIMEStateManager::SetIMEState(PRUint32 aState,
context.mActionHint.Assign(willSubmit ? control->GetType() == NS_FORM_INPUT_SEARCH
? NS_LITERAL_STRING("search")
: NS_LITERAL_STRING("go")
: NS_LITERAL_STRING("next"));
: formElement
? NS_LITERAL_STRING("next")
: EmptyString());
}
}

View File

@ -118,6 +118,7 @@
#include "nsHTMLFieldSetElement.h"
#include "nsHTMLMenuElement.h"
#include "nsPLDOMEvent.h"
#include "nsIScriptError.h"
#include "mozilla/Preferences.h"
#include "mozilla/dom/FromParser.h"
@ -3468,6 +3469,12 @@ nsresult nsGenericHTMLElement::MozRequestFullScreen()
// and it also makes it harder for bad guys' script to go full-screen and
// spoof the browser chrome/window and phish logins etc.
if (!nsContentUtils::IsRequestFullScreenAllowed()) {
nsContentUtils::ReportToConsole(nsContentUtils::eDOM_PROPERTIES,
"FullScreenDeniedNotInputDriven",
nsnull, 0, nsnull,
EmptyString(), 0, 0,
nsIScriptError::warningFlag,
"DOM", OwnerDoc());
nsRefPtr<nsPLDOMEvent> e =
new nsPLDOMEvent(OwnerDoc(),
NS_LITERAL_STRING("mozfullscreenerror"),

View File

@ -396,6 +396,7 @@ NS_INTERFACE_MAP_END_INHERITING(nsGenericHTMLElement)
NS_IMPL_URI_ATTR(nsHTMLMediaElement, Src, src)
NS_IMPL_BOOL_ATTR(nsHTMLMediaElement, Controls, controls)
NS_IMPL_BOOL_ATTR(nsHTMLMediaElement, Autoplay, autoplay)
NS_IMPL_BOOL_ATTR(nsHTMLMediaElement, Loop, loop)
NS_IMPL_ENUM_ATTR_DEFAULT_VALUE(nsHTMLMediaElement, Preload, preload, NULL)
/* readonly attribute nsIDOMHTMLMediaElement mozAutoplayEnabled; */
@ -1422,12 +1423,6 @@ bool nsHTMLMediaElement::ParseAttribute(PRInt32 aNamespaceID,
};
if (aNamespaceID == kNameSpaceID_None) {
if (aAttribute == nsGkAtoms::loopstart ||
aAttribute == nsGkAtoms::loopend ||
aAttribute == nsGkAtoms::start ||
aAttribute == nsGkAtoms::end) {
return aResult.ParseDoubleValue(aValue);
}
if (ParseImageAttribute(aAttribute, aValue, aResult)) {
return true;
}
@ -2082,6 +2077,11 @@ void nsHTMLMediaElement::PlaybackEnded()
DispatchAsyncEvent(NS_LITERAL_STRING("durationchange"));
}
if (HasAttr(kNameSpaceID_None, nsGkAtoms::loop)) {
SetCurrentTime(0);
return;
}
FireTimeUpdate(false);
DispatchAsyncEvent(NS_LITERAL_STRING("ended"));
}

View File

@ -49,6 +49,7 @@
#include "nsThreadUtils.h"
#include "nsIDOMGetSVGDocument.h"
#include "nsIDOMSVGDocument.h"
#include "nsIScriptError.h"
using namespace mozilla;
using namespace mozilla::dom;
@ -297,6 +298,12 @@ nsHTMLSharedObjectElement::BindToTree(nsIDocument *aDocument,
// to prevent phishing attacks.
NS_DispatchToCurrentThread(
NS_NewRunnableMethod(aDocument, &nsIDocument::CancelFullScreen));
nsContentUtils::ReportToConsole(nsContentUtils::eDOM_PROPERTIES,
"AddedWindowedPluginWhileFullScreen",
nsnull, 0, nsnull,
EmptyString(), 0, 0,
nsIScriptError::warningFlag,
"DOM", aDocument);
}
#endif
return NS_OK;

View File

@ -699,7 +699,7 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand,
}
// TODO: Proper about:blank treatment is bug 543435
if (loadAsHtml5 && !viewSource) {
if (loadAsHtml5 && aCommand && !nsCRT::strcmp(aCommand, "view")) {
// mDocumentURI hasn't been set, yet, so get the URI from the channel
nsCOMPtr<nsIURI> uri;
aChannel->GetOriginalURI(getter_AddRefs(uri));
@ -771,9 +771,6 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand,
// and parentContentViewer
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(aContainer));
// No support yet for docshell-less HTML
NS_ENSURE_TRUE(docShell || !IsHTML(), NS_ERROR_FAILURE);
nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(docShell));
nsCOMPtr<nsIDocShellTreeItem> parentAsItem;
@ -810,9 +807,6 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand,
}
}
nsCAutoString scheme;
uri->GetScheme(scheme);
nsCAutoString urlSpec;
uri->GetSpec(urlSpec);
#ifdef DEBUG_charset
@ -830,8 +824,9 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand,
nsCOMPtr<nsIWyciwygChannel> wyciwygChannel;
if (!IsHTML()) {
charsetSource = kCharsetFromDocTypeDefault;
if (!IsHTML() || !docShell) { // no docshell for text/html XHR
charsetSource = IsHTML() ? kCharsetFromWeakDocTypeDefault
: kCharsetFromDocTypeDefault;
charset.AssignLiteral("UTF-8");
TryChannelCharset(aChannel, charsetSource, charset);
parserCharsetSource = charsetSource;
@ -946,6 +941,7 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand,
"not nsICachingChannel");
rv = cachingChan->SetCacheTokenCachedCharset(charset);
NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "cannot SetMetaDataElement");
rv = NS_OK; // don't propagate error
}
// Set the parser as the stream listener for the document loader...

View File

@ -121,6 +121,7 @@ _TEST_FILES = \
test_load.html \
test_load_candidates.html \
test_load_source.html \
test_loop.html \
test_media_selection.html \
test_mozLoadFrom.html \
test_networkState.html \

View File

@ -0,0 +1,56 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test looping support</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
<script type="text/javascript" src="manifest.js"></script>
</head>
<body>
<pre id="test">
<script class="testbody" type="text/javascript">
var manager = new MediaTestManager;
function startTest(test, token) {
manager.started(token);
var v = document.createElement('video');
v.token = token;
v.src = test.name;
v.name = test.name;
v.playCount = 0;
v.seekingCount = 0;
v.seekedCount = 0;
v.loop = true;
v.addEventListener("play", function (e) {
e.target.playCount += 1;
ok(e.target.playCount == 1, "Should get exactly one play event.");
}, false);
v.addEventListener("seeking", function (e) {
e.target.seekingCount += 1;
}, false);
v.addEventListener("seeked", function (e) {
e.target.seekedCount += 1;
if (e.target.seekedCount == 3) {
ok(e.target.seekingCount == 3, "Expect matched pairs of seeking/seeked events.");
e.target.loop = false;
}
}, false);
v.addEventListener("ended", function (e) {
ok(!e.target.loop, "Shouldn't get ended event while looping.");
e.target.parentNode.removeChild(v);
manager.finished(e.target.token);
}, false);
document.body.appendChild(v);
v.play();
}
manager.runTests(gSmallTests, startTest);
</script>
</pre>
</body>
</html>

View File

@ -59,11 +59,8 @@
#include "nsIFrame.h"
#include "gfxContext.h"
#include "gfxMatrix.h"
#include "nsIDOMSVGURIReference.h"
#include "nsImageLoadingContent.h"
#include "imgIContainer.h"
#include "nsNetUtil.h"
#include "SVGAnimatedPreserveAspectRatio.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsSVGFilterElement.h"
#include "nsSVGString.h"
@ -251,6 +248,18 @@ nsSVGFE::GetSourceImageNames(nsTArray<nsSVGStringInfo>& aSources)
{
}
bool
nsSVGFE::AttributeAffectsRendering(PRInt32 aNameSpaceID,
nsIAtom* aAttribute) const
{
return aNameSpaceID == kNameSpaceID_None &&
(aAttribute == nsGkAtoms::x ||
aAttribute == nsGkAtoms::y ||
aAttribute == nsGkAtoms::width ||
aAttribute == nsGkAtoms::height ||
aAttribute == nsGkAtoms::result);
}
//----------------------------------------------------------------------
// nsIDOMSVGFilterPrimitiveStandardAttributes methods
@ -308,85 +317,6 @@ nsSVGFE::GetLengthInfo()
ArrayLength(sLengthInfo));
}
inline static void DidAnimateAttr(Element *aFilterPrimitive)
{
// nsSVGLeafFrame doesn't implement AttributeChanged.
nsIFrame* frame = aFilterPrimitive->GetPrimaryFrame();
if (frame) {
nsSVGEffects::InvalidateRenderingObservers(frame);
}
}
inline static void DidAnimateAttrViaParent(Element *aFilterPrimitive)
{
// No frame, use parent's
NS_ASSERTION(!aFilterPrimitive->GetPrimaryFrame(), "Not expecting a frame");
nsIContent *parent = aFilterPrimitive->GetFlattenedTreeParent();
if (parent && parent->IsElement()) {
DidAnimateAttr(parent->AsElement());
}
}
void
nsSVGFE::DidAnimateLength(PRUint8 aAttrEnum)
{
DidAnimateAttr(this);
}
void
nsSVGFE::DidAnimateNumber(PRUint8 aAttrEnum)
{
DidAnimateAttr(this);
}
void
nsSVGFE::DidAnimateNumberPair(PRUint8 aAttrEnum)
{
DidAnimateAttr(this);
}
void
nsSVGFE::DidAnimateNumberList(PRUint8 aAttrEnum)
{
DidAnimateAttr(this);
}
void
nsSVGFE::DidAnimateInteger(PRUint8 aAttrEnum)
{
DidAnimateAttr(this);
}
void
nsSVGFE::DidAnimateIntegerPair(PRUint8 aAttrEnum)
{
DidAnimateAttr(this);
}
void
nsSVGFE::DidAnimateEnum(PRUint8 aAttrEnum)
{
DidAnimateAttr(this);
}
void
nsSVGFE::DidAnimatePreserveAspectRatio()
{
DidAnimateAttr(this);
}
void
nsSVGFE::DidAnimateBoolean(PRUint8 aAttrEnum)
{
DidAnimateAttr(this);
}
void
nsSVGFE::DidAnimateString(PRUint8 aAttrEnum)
{
DidAnimateAttr(this);
}
//---------------------Gaussian Blur------------------------
typedef nsSVGFE nsSVGFEGaussianBlurElementBase;
@ -411,6 +341,8 @@ public:
const nsTArray<const Image*>& aSources,
const Image* aTarget,
const nsIntRect& aDataRect);
virtual bool AttributeAffectsRendering(
PRInt32 aNameSpaceID, nsIAtom* aAttribute) const;
virtual nsSVGString& GetResultImageName() { return mStringAttributes[RESULT]; }
virtual void GetSourceImageNames(nsTArray<nsSVGStringInfo >& aSources);
virtual nsIntRect ComputeTargetBBox(const nsTArray<nsIntRect>& aSourceBBoxes,
@ -800,6 +732,16 @@ nsSVGFEGaussianBlurElement::Filter(nsSVGFilterInstance* aInstance,
return NS_OK;
}
bool
nsSVGFEGaussianBlurElement::AttributeAffectsRendering(PRInt32 aNameSpaceID,
nsIAtom* aAttribute) const
{
return nsSVGFEGaussianBlurElementBase::AttributeAffectsRendering(aNameSpaceID, aAttribute) ||
(aNameSpaceID == kNameSpaceID_None &&
(aAttribute == nsGkAtoms::in ||
aAttribute == nsGkAtoms::stdDeviation));
}
void
nsSVGFEGaussianBlurElement::GetSourceImageNames(nsTArray<nsSVGStringInfo>& aSources)
{
@ -881,6 +823,8 @@ public:
const nsTArray<const Image*>& aSources,
const Image* aTarget,
const nsIntRect& aDataRect);
virtual bool AttributeAffectsRendering(
PRInt32 aNameSpaceID, nsIAtom* aAttribute) const;
virtual nsSVGString& GetResultImageName() { return mStringAttributes[RESULT]; }
virtual void GetSourceImageNames(nsTArray<nsSVGStringInfo>& aSources);
@ -1035,6 +979,17 @@ nsSVGFEBlendElement::Filter(nsSVGFilterInstance* aInstance,
return NS_OK;
}
bool
nsSVGFEBlendElement::AttributeAffectsRendering(PRInt32 aNameSpaceID,
nsIAtom* aAttribute) const
{
return nsSVGFEBlendElementBase::AttributeAffectsRendering(aNameSpaceID, aAttribute) ||
(aNameSpaceID == kNameSpaceID_None &&
(aAttribute == nsGkAtoms::in ||
aAttribute == nsGkAtoms::in2 ||
aAttribute == nsGkAtoms::mode));
}
void
nsSVGFEBlendElement::GetSourceImageNames(nsTArray<nsSVGStringInfo>& aSources)
{
@ -1083,6 +1038,8 @@ public:
const nsTArray<const Image*>& aSources,
const Image* aTarget,
const nsIntRect& aDataRect);
virtual bool AttributeAffectsRendering(
PRInt32 aNameSpaceID, nsIAtom* aAttribute) const;
virtual nsSVGString& GetResultImageName() { return mStringAttributes[RESULT]; }
virtual void GetSourceImageNames(nsTArray<nsSVGStringInfo>& aSources);
@ -1338,6 +1295,17 @@ nsSVGFEColorMatrixElement::Filter(nsSVGFilterInstance *instance,
return NS_OK;
}
bool
nsSVGFEColorMatrixElement::AttributeAffectsRendering(PRInt32 aNameSpaceID,
nsIAtom* aAttribute) const
{
return nsSVGFEColorMatrixElementBase::AttributeAffectsRendering(aNameSpaceID, aAttribute) ||
(aNameSpaceID == kNameSpaceID_None &&
(aAttribute == nsGkAtoms::in ||
aAttribute == nsGkAtoms::type ||
aAttribute == nsGkAtoms::values));
}
//----------------------------------------------------------------------
// nsSVGElement methods
@ -1386,6 +1354,8 @@ public:
const nsTArray<const Image*>& aSources,
const Image* aTarget,
const nsIntRect& aDataRect);
virtual bool AttributeAffectsRendering(
PRInt32 aNameSpaceID, nsIAtom* aAttribute) const;
virtual nsSVGString& GetResultImageName() { return mStringAttributes[RESULT]; }
virtual void GetSourceImageNames(nsTArray<nsSVGStringInfo>& aSources);
virtual nsIntRect ComputeTargetBBox(const nsTArray<nsIntRect>& aSourceBBoxes,
@ -1597,6 +1567,21 @@ nsSVGFECompositeElement::Filter(nsSVGFilterInstance *instance,
return NS_OK;
}
bool
nsSVGFECompositeElement::AttributeAffectsRendering(PRInt32 aNameSpaceID,
nsIAtom* aAttribute) const
{
return nsSVGFECompositeElementBase::AttributeAffectsRendering(aNameSpaceID, aAttribute) ||
(aNameSpaceID == kNameSpaceID_None &&
(aAttribute == nsGkAtoms::in ||
aAttribute == nsGkAtoms::in2 ||
aAttribute == nsGkAtoms::k1 ||
aAttribute == nsGkAtoms::k2 ||
aAttribute == nsGkAtoms::k3 ||
aAttribute == nsGkAtoms::k4 ||
aAttribute == nsGkAtoms::_operator));
}
void
nsSVGFECompositeElement::GetSourceImageNames(nsTArray<nsSVGStringInfo>& aSources)
{
@ -1680,6 +1665,8 @@ public:
const nsTArray<const Image*>& aSources,
const Image* aTarget,
const nsIntRect& aDataRect);
virtual bool AttributeAffectsRendering(
PRInt32 aNameSpaceID, nsIAtom* aAttribute) const;
virtual nsSVGString& GetResultImageName() { return mStringAttributes[RESULT]; }
virtual void GetSourceImageNames(nsTArray<nsSVGStringInfo>& aSources);
@ -1760,7 +1747,7 @@ nsSVGFEComponentTransferElement::GetStringInfo()
{ 0xafab106d, 0xbc18, 0x4f7f, \
{ 0x9e, 0x29, 0xfe, 0xb4, 0xb0, 0x16, 0x5f, 0xf4 } }
typedef nsSVGElement nsSVGComponentTransferFunctionElementBase;
typedef SVGFEUnstyledElement nsSVGComponentTransferFunctionElementBase;
class nsSVGComponentTransferFunctionElement : public nsSVGComponentTransferFunctionElementBase
{
@ -1777,22 +1764,16 @@ public:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIDOMSVGCOMPONENTTRANSFERFUNCTIONELEMENT
virtual bool AttributeAffectsRendering(
PRInt32 aNameSpaceID, nsIAtom* aAttribute) const;
virtual PRInt32 GetChannel() = 0;
void GenerateLookupTable(PRUint8* aTable);
protected:
virtual NumberAttributesInfo GetNumberInfo();
virtual void DidAnimateNumber(PRUint8 aAttrEnum) {
DidAnimateAttrViaParent(this);
}
virtual EnumAttributesInfo GetEnumInfo();
virtual void DidAnimateEnum(PRUint8 aAttrEnum) {
DidAnimateAttrViaParent(this);
}
virtual NumberListAttributesInfo GetNumberListInfo();
virtual void DidAnimateNumberList(PRUint8 aAttrEnum) {
DidAnimateAttrViaParent(this);
}
// nsIDOMSVGComponentTransferFunctionElement properties:
enum { TABLEVALUES };
@ -1851,6 +1832,15 @@ nsSVGFEComponentTransferElement::Filter(nsSVGFilterInstance *instance,
return NS_OK;
}
bool
nsSVGFEComponentTransferElement::AttributeAffectsRendering(PRInt32 aNameSpaceID,
nsIAtom* aAttribute) const
{
return nsSVGFEComponentTransferElementBase::AttributeAffectsRendering(aNameSpaceID, aAttribute) ||
(aNameSpaceID == kNameSpaceID_None &&
aAttribute == nsGkAtoms::in);
}
void
nsSVGFEComponentTransferElement::GetSourceImageNames(nsTArray<nsSVGStringInfo>& aSources)
{
@ -1910,6 +1900,23 @@ NS_INTERFACE_MAP_BEGIN(nsSVGComponentTransferFunctionElement)
NS_INTERFACE_MAP_END_INHERITING(nsSVGComponentTransferFunctionElementBase)
//----------------------------------------------------------------------
// nsFEUnstyledElement methods
bool
nsSVGComponentTransferFunctionElement::AttributeAffectsRendering(PRInt32 aNameSpaceID,
nsIAtom* aAttribute) const
{
return aNameSpaceID == kNameSpaceID_None &&
(aAttribute == nsGkAtoms::tableValues ||
aAttribute == nsGkAtoms::slope ||
aAttribute == nsGkAtoms::intercept ||
aAttribute == nsGkAtoms::amplitude ||
aAttribute == nsGkAtoms::exponent ||
aAttribute == nsGkAtoms::offset ||
aAttribute == nsGkAtoms::type);
}
//----------------------------------------------------------------------
// nsIDOMSVGComponentTransferFunctionElement methods
@ -2286,7 +2293,7 @@ protected:
static StringInfo sStringInfo[1];
};
typedef nsSVGStylableElement nsSVGFEMergeNodeElementBase;
typedef SVGFEUnstyledElement nsSVGFEMergeNodeElementBase;
#define NS_SVG_FE_MERGE_NODE_CID \
{ 0x413687ec, 0x77fd, 0x4077, \
@ -2316,6 +2323,9 @@ public:
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
virtual bool AttributeAffectsRendering(
PRInt32 aNameSpaceID, nsIAtom* aAttribute) const;
const nsSVGString* In1() { return &mStringAttributes[IN1]; }
operator nsISupports*() { return static_cast<nsIContent*>(this); }
@ -2432,6 +2442,16 @@ NS_INTERFACE_MAP_END_INHERITING(nsSVGFEMergeNodeElementBase)
NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGFEMergeNodeElement)
//----------------------------------------------------------------------
// nsFEUnstyledElement methods
bool
nsSVGFEMergeNodeElement::AttributeAffectsRendering(PRInt32 aNameSpaceID,
nsIAtom* aAttribute) const
{
return aNameSpaceID == kNameSpaceID_None && aAttribute == nsGkAtoms::in;
}
//----------------------------------------------------------------------
// nsIDOMSVGFEMergeNodeElement methods
@ -2475,6 +2495,8 @@ public:
const nsTArray<const Image*>& aSources,
const Image* aTarget,
const nsIntRect& aDataRect);
virtual bool AttributeAffectsRendering(
PRInt32 aNameSpaceID, nsIAtom* aAttribute) const;
virtual nsSVGString& GetResultImageName() { return mStringAttributes[RESULT]; }
virtual void GetSourceImageNames(nsTArray<nsSVGStringInfo>& aSources);
virtual nsIntRect ComputeTargetBBox(const nsTArray<nsIntRect>& aSourceBBoxes,
@ -2596,6 +2618,17 @@ nsSVGFEOffsetElement::Filter(nsSVGFilterInstance *instance,
return NS_OK;
}
bool
nsSVGFEOffsetElement::AttributeAffectsRendering(PRInt32 aNameSpaceID,
nsIAtom* aAttribute) const
{
return nsSVGFEOffsetElementBase::AttributeAffectsRendering(aNameSpaceID, aAttribute) ||
(aNameSpaceID == kNameSpaceID_None &&
(aAttribute == nsGkAtoms::in ||
aAttribute == nsGkAtoms::dx ||
aAttribute == nsGkAtoms::dy));
}
void
nsSVGFEOffsetElement::GetSourceImageNames(nsTArray<nsSVGStringInfo>& aSources)
{
@ -2807,6 +2840,8 @@ public:
const nsTArray<const Image*>& aSources,
const Image* aTarget,
const nsIntRect& aDataRect);
virtual bool AttributeAffectsRendering(
PRInt32 aNameSpaceID, nsIAtom* aAttribute) const;
virtual nsSVGString& GetResultImageName() { return mStringAttributes[RESULT]; }
virtual void GetSourceImageNames(nsTArray<nsSVGStringInfo>& aSources);
virtual nsIntRect ComputeTargetBBox(const nsTArray<nsIntRect>& aSourceBBoxes,
@ -2962,6 +2997,15 @@ nsSVGFETileElement::Filter(nsSVGFilterInstance *instance,
return NS_OK;
}
bool
nsSVGFETileElement::AttributeAffectsRendering(PRInt32 aNameSpaceID,
nsIAtom* aAttribute) const
{
return nsSVGFETileElementBase::AttributeAffectsRendering(aNameSpaceID, aAttribute) ||
(aNameSpaceID == kNameSpaceID_None &&
aAttribute == nsGkAtoms::in);
}
//----------------------------------------------------------------------
// nsSVGElement methods
@ -2998,6 +3042,8 @@ public:
const nsTArray<const Image*>& aSources,
const Image* aTarget,
const nsIntRect& aDataRect);
virtual bool AttributeAffectsRendering(
PRInt32 aNameSpaceID, nsIAtom* aAttribute) const;
virtual nsSVGString& GetResultImageName() { return mStringAttributes[RESULT]; }
virtual nsIntRect ComputeTargetBBox(const nsTArray<nsIntRect>& aSourceBBoxes,
const nsSVGFilterInstance& aInstance);
@ -3301,6 +3347,19 @@ nsSVGFETurbulenceElement::Filter(nsSVGFilterInstance *instance,
return NS_OK;
}
bool
nsSVGFETurbulenceElement::AttributeAffectsRendering(PRInt32 aNameSpaceID,
nsIAtom* aAttribute) const
{
return nsSVGFETurbulenceElementBase::AttributeAffectsRendering(aNameSpaceID, aAttribute) ||
(aNameSpaceID == kNameSpaceID_None &&
(aAttribute == nsGkAtoms::seed ||
aAttribute == nsGkAtoms::baseFrequency ||
aAttribute == nsGkAtoms::numOctaves ||
aAttribute == nsGkAtoms::type ||
aAttribute == nsGkAtoms::stitchTiles));
}
void
nsSVGFETurbulenceElement::InitSeed(PRInt32 aSeed)
{
@ -3525,6 +3584,8 @@ public:
const nsTArray<const Image*>& aSources,
const Image* aTarget,
const nsIntRect& aDataRect);
virtual bool AttributeAffectsRendering(
PRInt32 aNameSpaceID, nsIAtom* aAttribute) const;
virtual nsSVGString& GetResultImageName() { return mStringAttributes[RESULT]; }
virtual void GetSourceImageNames(nsTArray<nsSVGStringInfo>& aSources);
virtual nsIntRect ComputeTargetBBox(const nsTArray<nsIntRect>& aSourceBBoxes,
@ -3798,6 +3859,17 @@ nsSVGFEMorphologyElement::Filter(nsSVGFilterInstance *instance,
return NS_OK;
}
bool
nsSVGFEMorphologyElement::AttributeAffectsRendering(PRInt32 aNameSpaceID,
nsIAtom* aAttribute) const
{
return nsSVGFEMorphologyElementBase::AttributeAffectsRendering(aNameSpaceID, aAttribute) ||
(aNameSpaceID == kNameSpaceID_None &&
(aAttribute == nsGkAtoms::in ||
aAttribute == nsGkAtoms::radius ||
aAttribute == nsGkAtoms::_operator));
}
//----------------------------------------------------------------------
// nsSVGElement methods
@ -3846,6 +3918,8 @@ public:
const nsTArray<const Image*>& aSources,
const Image* aTarget,
const nsIntRect& aDataRect);
virtual bool AttributeAffectsRendering(
PRInt32 aNameSpaceID, nsIAtom* aAttribute) const;
virtual nsSVGString& GetResultImageName() { return mStringAttributes[RESULT]; }
virtual void GetSourceImageNames(nsTArray<nsSVGStringInfo>& aSources);
virtual nsIntRect ComputeTargetBBox(const nsTArray<nsIntRect>& aSourceBBoxes,
@ -4256,6 +4330,24 @@ nsSVGFEConvolveMatrixElement::Filter(nsSVGFilterInstance *instance,
return NS_OK;
}
bool
nsSVGFEConvolveMatrixElement::AttributeAffectsRendering(PRInt32 aNameSpaceID,
nsIAtom* aAttribute) const
{
return nsSVGFEConvolveMatrixElementBase::AttributeAffectsRendering(aNameSpaceID, aAttribute) ||
(aNameSpaceID == kNameSpaceID_None &&
(aAttribute == nsGkAtoms::in ||
aAttribute == nsGkAtoms::divisor ||
aAttribute == nsGkAtoms::bias ||
aAttribute == nsGkAtoms::kernelUnitLength ||
aAttribute == nsGkAtoms::targetX ||
aAttribute == nsGkAtoms::targetY ||
aAttribute == nsGkAtoms::order ||
aAttribute == nsGkAtoms::preserveAlpha||
aAttribute == nsGkAtoms::edgeMode ||
aAttribute == nsGkAtoms::kernelMatrix));
}
//----------------------------------------------------------------------
// nsSVGElement methods
@ -4317,7 +4409,7 @@ nsSVGFEConvolveMatrixElement::GetNumberListInfo()
//---------------------DistantLight------------------------
typedef nsSVGElement nsSVGFEDistantLightElementBase;
typedef SVGFEUnstyledElement nsSVGFEDistantLightElementBase;
class nsSVGFEDistantLightElement : public nsSVGFEDistantLightElementBase,
public nsIDOMSVGFEDistantLightElement
@ -4337,14 +4429,14 @@ public:
NS_FORWARD_NSIDOMNODE(nsSVGFEDistantLightElementBase::)
NS_FORWARD_NSIDOMELEMENT(nsSVGFEDistantLightElementBase::)
virtual bool AttributeAffectsRendering(
PRInt32 aNameSpaceID, nsIAtom* aAttribute) const;
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
virtual nsXPCClassInfo* GetClassInfo();
protected:
virtual NumberAttributesInfo GetNumberInfo();
virtual void DidAnimateNumber(PRUint8 aAttrEnum) {
DidAnimateAttrViaParent(this);
}
enum { AZIMUTH, ELEVATION };
nsSVGNumber2 mNumberAttributes[2];
@ -4379,6 +4471,18 @@ NS_INTERFACE_MAP_END_INHERITING(nsSVGFEDistantLightElementBase)
NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGFEDistantLightElement)
//----------------------------------------------------------------------
// nsFEUnstyledElement methods
bool
nsSVGFEDistantLightElement::AttributeAffectsRendering(PRInt32 aNameSpaceID,
nsIAtom* aAttribute) const
{
return aNameSpaceID == kNameSpaceID_None &&
(aAttribute == nsGkAtoms::azimuth ||
aAttribute == nsGkAtoms::elevation);
}
//----------------------------------------------------------------------
// nsIDOMSVGFEDistantLightElement methods
@ -4408,7 +4512,7 @@ nsSVGFEDistantLightElement::GetNumberInfo()
//---------------------PointLight------------------------
typedef nsSVGElement nsSVGFEPointLightElementBase;
typedef SVGFEUnstyledElement nsSVGFEPointLightElementBase;
class nsSVGFEPointLightElement : public nsSVGFEPointLightElementBase,
public nsIDOMSVGFEPointLightElement
@ -4428,14 +4532,14 @@ public:
NS_FORWARD_NSIDOMNODE(nsSVGFEPointLightElementBase::)
NS_FORWARD_NSIDOMELEMENT(nsSVGFEPointLightElementBase::)
virtual bool AttributeAffectsRendering(
PRInt32 aNameSpaceID, nsIAtom* aAttribute) const;
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
virtual nsXPCClassInfo* GetClassInfo();
protected:
virtual NumberAttributesInfo GetNumberInfo();
virtual void DidAnimateNumber(PRUint8 aAttrEnum) {
DidAnimateAttrViaParent(this);
}
enum { X, Y, Z };
nsSVGNumber2 mNumberAttributes[3];
@ -4471,6 +4575,19 @@ NS_INTERFACE_MAP_END_INHERITING(nsSVGFEPointLightElementBase)
NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGFEPointLightElement)
//----------------------------------------------------------------------
// nsFEUnstyledElement methods
bool
nsSVGFEPointLightElement::AttributeAffectsRendering(PRInt32 aNameSpaceID,
nsIAtom* aAttribute) const
{
return aNameSpaceID == kNameSpaceID_None &&
(aAttribute == nsGkAtoms::x ||
aAttribute == nsGkAtoms::y ||
aAttribute == nsGkAtoms::z);
}
//----------------------------------------------------------------------
// nsIDOMSVGFEPointLightElement methods
@ -4504,7 +4621,7 @@ nsSVGFEPointLightElement::GetNumberInfo()
//---------------------SpotLight------------------------
typedef nsSVGElement nsSVGFESpotLightElementBase;
typedef SVGFEUnstyledElement nsSVGFESpotLightElementBase;
class nsSVGFESpotLightElement : public nsSVGFESpotLightElementBase,
public nsIDOMSVGFESpotLightElement
@ -4525,14 +4642,14 @@ public:
NS_FORWARD_NSIDOMNODE(nsSVGFESpotLightElementBase::)
NS_FORWARD_NSIDOMELEMENT(nsSVGFESpotLightElementBase::)
virtual bool AttributeAffectsRendering(
PRInt32 aNameSpaceID, nsIAtom* aAttribute) const;
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
virtual nsXPCClassInfo* GetClassInfo();
protected:
virtual NumberAttributesInfo GetNumberInfo();
virtual void DidAnimateNumber(PRUint8 aAttrEnum) {
DidAnimateAttrViaParent(this);
}
enum { X, Y, Z, POINTS_AT_X, POINTS_AT_Y, POINTS_AT_Z,
SPECULAR_EXPONENT, LIMITING_CONE_ANGLE };
@ -4574,6 +4691,24 @@ NS_INTERFACE_MAP_END_INHERITING(nsSVGFESpotLightElementBase)
NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGFESpotLightElement)
//----------------------------------------------------------------------
// nsFEUnstyledElement methods
bool
nsSVGFESpotLightElement::AttributeAffectsRendering(PRInt32 aNameSpaceID,
nsIAtom* aAttribute) const
{
return aNameSpaceID == kNameSpaceID_None &&
(aAttribute == nsGkAtoms::x ||
aAttribute == nsGkAtoms::y ||
aAttribute == nsGkAtoms::z ||
aAttribute == nsGkAtoms::pointsAtX ||
aAttribute == nsGkAtoms::pointsAtY ||
aAttribute == nsGkAtoms::pointsAtZ ||
aAttribute == nsGkAtoms::specularExponent ||
aAttribute == nsGkAtoms::limitingConeAngle);
}
//----------------------------------------------------------------------
// nsIDOMSVGFESpotLightElement methods
@ -4658,6 +4793,8 @@ public:
const nsTArray<const Image*>& aSources,
const Image* aTarget,
const nsIntRect& aDataRect);
virtual bool AttributeAffectsRendering(
PRInt32 aNameSpaceID, nsIAtom* aAttribute) const;
virtual nsSVGString& GetResultImageName() { return mStringAttributes[RESULT]; }
virtual void GetSourceImageNames(nsTArray<nsSVGStringInfo>& aSources);
// XXX shouldn't we have ComputeTargetBBox here, since the output can
@ -4985,6 +5122,17 @@ nsSVGFELightingElement::Filter(nsSVGFilterInstance *instance,
return NS_OK;
}
bool
nsSVGFELightingElement::AttributeAffectsRendering(PRInt32 aNameSpaceID,
nsIAtom* aAttribute) const
{
return nsSVGFELightingElementBase::AttributeAffectsRendering(aNameSpaceID, aAttribute) ||
(aNameSpaceID == kNameSpaceID_None &&
(aAttribute == nsGkAtoms::in ||
aAttribute == nsGkAtoms::surfaceScale ||
aAttribute == nsGkAtoms::kernelUnitLength));
}
//----------------------------------------------------------------------
// nsSVGElement methods
@ -5034,6 +5182,9 @@ public:
NS_FORWARD_NSIDOMNODE(nsSVGFEDiffuseLightingElementBase::)
NS_FORWARD_NSIDOMELEMENT(nsSVGFEDiffuseLightingElementBase::)
virtual bool AttributeAffectsRendering(
PRInt32 aNameSpaceID, nsIAtom* aAttribute) const;
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
virtual nsXPCClassInfo* GetClassInfo();
@ -5105,6 +5256,15 @@ nsSVGFEDiffuseLightingElement::GetKernelUnitLengthY(nsIDOMSVGAnimatedNumber **aK
this);
}
bool
nsSVGFEDiffuseLightingElement::AttributeAffectsRendering(PRInt32 aNameSpaceID,
nsIAtom* aAttribute) const
{
return nsSVGFEDiffuseLightingElementBase::AttributeAffectsRendering(aNameSpaceID, aAttribute) ||
(aNameSpaceID == kNameSpaceID_None &&
aAttribute == nsGkAtoms::diffuseConstant);
}
//----------------------------------------------------------------------
// nsSVGElement methods
@ -5162,6 +5322,8 @@ public:
const nsTArray<const Image*>& aSources,
const Image* aTarget,
const nsIntRect& aDataRect);
virtual bool AttributeAffectsRendering(
PRInt32 aNameSpaceID, nsIAtom* aAttribute) const;
virtual nsXPCClassInfo* GetClassInfo();
protected:
@ -5257,6 +5419,15 @@ nsSVGFESpecularLightingElement::Filter(nsSVGFilterInstance *instance,
return nsSVGFESpecularLightingElementBase::Filter(instance, aSources, aTarget, rect);
}
bool
nsSVGFESpecularLightingElement::AttributeAffectsRendering(PRInt32 aNameSpaceID,
nsIAtom* aAttribute) const
{
return nsSVGFESpecularLightingElementBase::AttributeAffectsRendering(aNameSpaceID, aAttribute) ||
(aNameSpaceID == kNameSpaceID_None &&
(aAttribute == nsGkAtoms::specularConstant ||
aAttribute == nsGkAtoms::specularExponent));
}
void
nsSVGFESpecularLightingElement::LightPixel(const float *N, const float *L,
@ -5296,90 +5467,6 @@ nsSVGFESpecularLightingElement::LightPixel(const float *N, const float *L,
//---------------------Image------------------------
typedef nsSVGFE nsSVGFEImageElementBase;
class nsSVGFEImageElement : public nsSVGFEImageElementBase,
public nsIDOMSVGFEImageElement,
public nsIDOMSVGURIReference,
public nsImageLoadingContent
{
protected:
friend nsresult NS_NewSVGFEImageElement(nsIContent **aResult,
already_AddRefed<nsINodeInfo> aNodeInfo);
nsSVGFEImageElement(already_AddRefed<nsINodeInfo> aNodeInfo);
virtual ~nsSVGFEImageElement();
public:
virtual bool SubregionIsUnionOfRegions() { return false; }
// interfaces:
NS_DECL_ISUPPORTS_INHERITED
// FE Base
NS_FORWARD_NSIDOMSVGFILTERPRIMITIVESTANDARDATTRIBUTES(nsSVGFEImageElementBase::)
virtual nsresult Filter(nsSVGFilterInstance* aInstance,
const nsTArray<const Image*>& aSources,
const Image* aTarget,
const nsIntRect& aDataRect);
virtual nsSVGString& GetResultImageName() { return mStringAttributes[RESULT]; }
virtual nsIntRect ComputeTargetBBox(const nsTArray<nsIntRect>& aSourceBBoxes,
const nsSVGFilterInstance& aInstance);
NS_DECL_NSIDOMSVGFEIMAGEELEMENT
NS_DECL_NSIDOMSVGURIREFERENCE
NS_FORWARD_NSIDOMSVGELEMENT(nsSVGFEImageElementBase::)
NS_FORWARD_NSIDOMNODE(nsSVGFEImageElementBase::)
NS_FORWARD_NSIDOMELEMENT(nsSVGFEImageElementBase::)
// nsIContent
NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const;
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
virtual nsresult AfterSetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
const nsAString* aValue, bool aNotify);
virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
nsIContent* aBindingParent,
bool aCompileEventHandlers);
virtual nsEventStates IntrinsicState() const;
// imgIDecoderObserver
NS_IMETHOD OnStopDecode(imgIRequest *aRequest, nsresult status,
const PRUnichar *statusArg);
// imgIContainerObserver
NS_IMETHOD FrameChanged(imgIContainer *aContainer,
const nsIntRect *aDirtyRect);
// imgIContainerObserver
NS_IMETHOD OnStartContainer(imgIRequest *aRequest,
imgIContainer *aContainer);
void MaybeLoadSVGImage();
virtual nsXPCClassInfo* GetClassInfo();
private:
// Invalidate users of the filter containing this element.
void Invalidate();
nsresult LoadSVGImage(bool aForce, bool aNotify);
protected:
virtual bool OperatesOnSRGB(nsSVGFilterInstance*,
PRInt32, Image*) { return true; }
virtual SVGAnimatedPreserveAspectRatio *GetPreserveAspectRatio();
virtual StringAttributesInfo GetStringInfo();
virtual void DidAnimateString(PRUint8 aAttrEnum);
enum { RESULT, HREF };
nsSVGString mStringAttributes[2];
static StringInfo sStringInfo[2];
SVGAnimatedPreserveAspectRatio mPreserveAspectRatio;
};
nsSVGElement::StringInfo nsSVGFEImageElement::sStringInfo[2] =
{
{ &nsGkAtoms::result, kNameSpaceID_None, true },
@ -5468,10 +5555,22 @@ nsSVGFEImageElement::AfterSetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
const nsAString* aValue, bool aNotify)
{
if (aNamespaceID == kNameSpaceID_XLink && aName == nsGkAtoms::href) {
if (aValue) {
LoadSVGImage(true, aNotify);
} else {
CancelImageRequests(aNotify);
// If there isn't a frame we still need to load the image in case
// the frame is created later e.g. by attaching to a document.
// If there is a frame then it should deal with loading as the image
// url may be animated.
if (!GetPrimaryFrame()) {
// Prevent setting image.src by exiting early
if (nsContentUtils::IsImageSrcSetDisabled()) {
return NS_OK;
}
if (aValue) {
LoadSVGImage(true, aNotify);
} else {
CancelImageRequests(aNotify);
}
}
}
@ -5591,6 +5690,17 @@ nsSVGFEImageElement::Filter(nsSVGFilterInstance *instance,
return NS_OK;
}
bool
nsSVGFEImageElement::AttributeAffectsRendering(PRInt32 aNameSpaceID,
nsIAtom* aAttribute) const
{
// nsGkAtoms::href is deliberately omitted as the frame has special
// handling to load the image
return nsSVGFEImageElementBase::AttributeAffectsRendering(aNameSpaceID, aAttribute) ||
(aNameSpaceID == kNameSpaceID_None &&
aAttribute == nsGkAtoms::preserveAspectRatio);
}
nsIntRect
nsSVGFEImageElement::ComputeTargetBBox(const nsTArray<nsIntRect>& aSourceBBoxes,
const nsSVGFilterInstance& aInstance)
@ -5617,17 +5727,6 @@ nsSVGFEImageElement::GetStringInfo()
ArrayLength(sStringInfo));
}
void
nsSVGFEImageElement::DidAnimateString(PRUint8 aAttrEnum)
{
if (aAttrEnum == HREF) {
LoadSVGImage(true, false);
return;
}
nsSVGFEImageElementBase::DidAnimateString(aAttrEnum);
}
//----------------------------------------------------------------------
// imgIDecoderObserver methods
@ -5704,6 +5803,8 @@ public:
const nsTArray<const Image*>& aSources,
const Image* aTarget,
const nsIntRect& aDataRect);
virtual bool AttributeAffectsRendering(
PRInt32 aNameSpaceID, nsIAtom* aAttribute) const;
virtual nsSVGString& GetResultImageName() { return mStringAttributes[RESULT]; }
virtual void GetSourceImageNames(nsTArray<nsSVGStringInfo>& aSources);
virtual nsIntRect ComputeTargetBBox(const nsTArray<nsIntRect>& aSourceBBoxes,
@ -5903,6 +6004,19 @@ nsSVGFEDisplacementMapElement::Filter(nsSVGFilterInstance *instance,
return NS_OK;
}
bool
nsSVGFEDisplacementMapElement::AttributeAffectsRendering(PRInt32 aNameSpaceID,
nsIAtom* aAttribute) const
{
return nsSVGFEDisplacementMapElementBase::AttributeAffectsRendering(aNameSpaceID, aAttribute) ||
(aNameSpaceID == kNameSpaceID_None &&
(aAttribute == nsGkAtoms::in ||
aAttribute == nsGkAtoms::in2 ||
aAttribute == nsGkAtoms::scale ||
aAttribute == nsGkAtoms::xChannelSelector ||
aAttribute == nsGkAtoms::yChannelSelector));
}
void
nsSVGFEDisplacementMapElement::GetSourceImageNames(nsTArray<nsSVGStringInfo>& aSources)
{

View File

@ -39,13 +39,16 @@
#include "nsSVGStylableElement.h"
#include "nsSVGLength2.h"
#include "nsSVGString.h"
#include "nsIFrame.h"
#include "gfxRect.h"
#include "gfxImageSurface.h"
#include "nsIDOMSVGFilters.h"
#include "nsImageLoadingContent.h"
#include "nsIDOMSVGURIReference.h"
#include "SVGAnimatedPreserveAspectRatio.h"
class nsSVGFilterResource;
class nsSVGString;
class nsSVGNumberPair;
class nsSVGFilterInstance;
@ -64,6 +67,11 @@ typedef nsSVGStylableElement nsSVGFEBase;
{ 0x60483958, 0xd229, 0x4a77, \
{ 0x96, 0xb2, 0x62, 0x3e, 0x69, 0x95, 0x1e, 0x0e } }
/**
* Base class for filter primitive elements
* Children of those elements e.g. feMergeNode
* derive from SVGFEUnstyledElement instead
*/
class nsSVGFE : public nsSVGFEBase
//, public nsIDOMSVGFilterPrimitiveStandardAttributes
{
@ -194,6 +202,11 @@ public:
const Image* aTarget,
const nsIntRect& aDataRect) = 0;
// returns true if changes to the attribute should cause us to
// repaint the filter
virtual bool AttributeAffectsRendering(
PRInt32 aNameSpaceID, nsIAtom* aAttribute) const;
static nsIntRect GetMaxRect() {
// Try to avoid overflow errors dealing with this rect. It will
// be intersected with some other reasonable-sized rect eventually.
@ -220,16 +233,6 @@ protected:
// nsSVGElement specializations:
virtual LengthAttributesInfo GetLengthInfo();
virtual void DidAnimateLength(PRUint8 aAttrEnum);
virtual void DidAnimateNumber(PRUint8 aAttrEnum);
virtual void DidAnimateNumberPair(PRUint8 aAttrEnum);
virtual void DidAnimateNumberList(PRUint8 aAttrEnum);
virtual void DidAnimateInteger(PRUint8 aAttrEnum);
virtual void DidAnimateIntegerPair(PRUint8 aAttrEnum);
virtual void DidAnimateEnum(PRUint8 aAttrEnum);
virtual void DidAnimateBoolean(PRUint8 aAttrEnum);
virtual void DidAnimatePreserveAspectRatio();
virtual void DidAnimateString(PRUint8 aAttrEnum);
// nsIDOMSVGFitlerPrimitiveStandardAttributes values
enum { X, Y, WIDTH, HEIGHT };
@ -237,4 +240,106 @@ protected:
static LengthInfo sLengthInfo[4];
};
typedef nsSVGFE nsSVGFEImageElementBase;
class nsSVGFEImageElement : public nsSVGFEImageElementBase,
public nsIDOMSVGFEImageElement,
public nsIDOMSVGURIReference,
public nsImageLoadingContent
{
friend class SVGFEImageFrame;
protected:
friend nsresult NS_NewSVGFEImageElement(nsIContent **aResult,
already_AddRefed<nsINodeInfo> aNodeInfo);
nsSVGFEImageElement(already_AddRefed<nsINodeInfo> aNodeInfo);
virtual ~nsSVGFEImageElement();
public:
virtual bool SubregionIsUnionOfRegions() { return false; }
// interfaces:
NS_DECL_ISUPPORTS_INHERITED
// FE Base
NS_FORWARD_NSIDOMSVGFILTERPRIMITIVESTANDARDATTRIBUTES(nsSVGFEImageElementBase::)
virtual nsresult Filter(nsSVGFilterInstance* aInstance,
const nsTArray<const Image*>& aSources,
const Image* aTarget,
const nsIntRect& aDataRect);
virtual bool AttributeAffectsRendering(
PRInt32 aNameSpaceID, nsIAtom* aAttribute) const;
virtual nsSVGString& GetResultImageName() { return mStringAttributes[RESULT]; }
virtual nsIntRect ComputeTargetBBox(const nsTArray<nsIntRect>& aSourceBBoxes,
const nsSVGFilterInstance& aInstance);
NS_DECL_NSIDOMSVGFEIMAGEELEMENT
NS_DECL_NSIDOMSVGURIREFERENCE
NS_FORWARD_NSIDOMSVGELEMENT(nsSVGFEImageElementBase::)
NS_FORWARD_NSIDOMNODE(nsSVGFEImageElementBase::)
NS_FORWARD_NSIDOMELEMENT(nsSVGFEImageElementBase::)
// nsIContent
NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const;
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
virtual nsresult AfterSetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
const nsAString* aValue, bool aNotify);
virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
nsIContent* aBindingParent,
bool aCompileEventHandlers);
virtual nsEventStates IntrinsicState() const;
// imgIDecoderObserver
NS_IMETHOD OnStopDecode(imgIRequest *aRequest, nsresult status,
const PRUnichar *statusArg);
// imgIContainerObserver
NS_IMETHOD FrameChanged(imgIContainer *aContainer,
const nsIntRect *aDirtyRect);
// imgIContainerObserver
NS_IMETHOD OnStartContainer(imgIRequest *aRequest,
imgIContainer *aContainer);
void MaybeLoadSVGImage();
virtual nsXPCClassInfo* GetClassInfo();
private:
// Invalidate users of the filter containing this element.
void Invalidate();
nsresult LoadSVGImage(bool aForce, bool aNotify);
protected:
virtual bool OperatesOnSRGB(nsSVGFilterInstance*,
PRInt32, Image*) { return true; }
virtual SVGAnimatedPreserveAspectRatio *GetPreserveAspectRatio();
virtual StringAttributesInfo GetStringInfo();
enum { RESULT, HREF };
nsSVGString mStringAttributes[2];
static StringInfo sStringInfo[2];
SVGAnimatedPreserveAspectRatio mPreserveAspectRatio;
};
typedef nsSVGElement SVGFEUnstyledElementBase;
class SVGFEUnstyledElement : public SVGFEUnstyledElementBase
{
protected:
SVGFEUnstyledElement(already_AddRefed<nsINodeInfo> aNodeInfo)
: SVGFEUnstyledElementBase(aNodeInfo) {}
public:
// returns true if changes to the attribute should cause us to
// repaint the filter
virtual bool AttributeAffectsRendering(
PRInt32 aNameSpaceID, nsIAtom* aAttribute) const = 0;
};
#endif

View File

@ -173,7 +173,10 @@ nsSVGImageElement::AfterSetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
{
if (aNamespaceID == kNameSpaceID_XLink && aName == nsGkAtoms::href) {
// If there's a frame it will deal
// If there isn't a frame we still need to load the image in case
// the frame is created later e.g. by attaching to a document.
// If there is a frame then it should deal with loading as the image
// url may be animated
if (!GetPrimaryFrame()) {
// Prevent setting image.src by exiting early

View File

@ -427,16 +427,24 @@ nsSVGPathElement::ConstructPath(gfxContext *aCtx)
}
gfxFloat
nsSVGPathElement::GetPathLengthScale()
nsSVGPathElement::GetPathLengthScale(PathLengthScaleForType aFor)
{
NS_ABORT_IF_FALSE(aFor == eForTextPath || aFor == eForStroking,
"Unknown enum");
if (mPathLength.IsExplicitlySet()) {
nsRefPtr<gfxFlattenedPath> flat =
GetFlattenedPath(PrependLocalTransformTo(gfxMatrix()));
float pathLength = mPathLength.GetAnimValue();
if (flat && pathLength != 0) {
return flat->GetLength() / pathLength;
float authorsPathLengthEstimate = mPathLength.GetAnimValue();
if (authorsPathLengthEstimate > 0) {
gfxMatrix matrix;
if (aFor == eForTextPath) {
// For textPath, a transform on the referenced path affects the
// textPath layout, so when calculating the actual path length
// we need to take that into account.
matrix = PrependLocalTransformTo(gfxMatrix());
}
nsRefPtr<gfxFlattenedPath> path = GetFlattenedPath(matrix);
if (path) {
return path->GetLength() / authorsPathLengthEstimate;
}
}
}
return 1.0;

View File

@ -98,12 +98,17 @@ public:
return nsGkAtoms::d;
}
enum PathLengthScaleForType {
eForTextPath,
eForStroking
};
/**
* Gets the ratio of the actual path length to the content author's estimated
* length (as provided by the <path> element's 'pathLength' attribute). This
* is used to scale stroke dashing, and to scale offsets along a textPath.
*/
gfxFloat GetPathLengthScale();
gfxFloat GetPathLengthScale(PathLengthScaleForType aFor);
protected:

View File

@ -69,7 +69,7 @@ nsXBLProtoImplField::nsXBLProtoImplField(const PRUnichar* aName, const PRUnichar
}
nsXBLProtoImplField::nsXBLProtoImplField(bool aIsReadOnly)
nsXBLProtoImplField::nsXBLProtoImplField(const bool aIsReadOnly)
: mNext(nsnull),
mFieldText(nsnull),
mFieldTextLength(0),

View File

@ -55,7 +55,7 @@ public:
const PRUnichar* aSetter,
const PRUnichar* aReadOnly);
nsXBLProtoImplProperty(const PRUnichar* aName, bool aIsReadOnly);
nsXBLProtoImplProperty(const PRUnichar* aName, const bool aIsReadOnly);
virtual ~nsXBLProtoImplProperty();

View File

@ -105,7 +105,7 @@ NS_NewDOMDocument(nsIDOMDocument** aInstancePtrResult,
nsIPrincipal* aPrincipal,
bool aLoadedAsData,
nsIScriptGlobalObject* aEventObject,
bool aSVGDocument)
DocumentFlavor aFlavor)
{
// Note: can't require that aDocumentURI/aBaseURI/aPrincipal be non-null,
// since at least one caller (XMLHttpRequest) doesn't have decent args to
@ -118,8 +118,11 @@ NS_NewDOMDocument(nsIDOMDocument** aInstancePtrResult,
nsCOMPtr<nsIDocument> d;
bool isHTML = false;
bool isXHTML = false;
if (aSVGDocument) {
if (aFlavor == DocumentFlavorSVG) {
rv = NS_NewSVGDocument(getter_AddRefs(d));
} else if (aFlavor == DocumentFlavorHTML) {
rv = NS_NewHTMLDocument(getter_AddRefs(d));
isHTML = true;
} else if (aDoctype) {
nsAutoString publicId, name;
aDoctype->GetPublicId(publicId);
@ -229,7 +232,7 @@ NS_NewXBLDocument(nsIDOMDocument** aInstancePtrResult,
NS_LITERAL_STRING("http://www.mozilla.org/xbl"),
NS_LITERAL_STRING("bindings"), nsnull,
aDocumentURI, aBaseURI, aPrincipal, false,
nsnull, false);
nsnull, DocumentFlavorLegacyGuess);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDocument> idoc = do_QueryInterface(*aInstancePtrResult);

View File

@ -113,7 +113,7 @@ NS_INTERFACE_MAP_BEGIN(Navigator)
NS_INTERFACE_MAP_ENTRY(nsIDOMNavigator)
NS_INTERFACE_MAP_ENTRY(nsIDOMClientInformation)
NS_INTERFACE_MAP_ENTRY(nsIDOMNavigatorGeolocation)
NS_INTERFACE_MAP_ENTRY(nsIDOMNavigatorBattery)
NS_INTERFACE_MAP_ENTRY(nsIDOMMozNavigatorBattery)
NS_INTERFACE_MAP_ENTRY(nsIDOMNavigatorDesktopNotification)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(Navigator)
NS_INTERFACE_MAP_END
@ -746,11 +746,25 @@ NS_IMETHODIMP Navigator::GetMozNotification(nsIDOMDesktopNotificationCenter** aR
//*****************************************************************************
NS_IMETHODIMP
Navigator::GetMozBattery(nsIDOMBatteryManager** aBattery)
Navigator::GetMozBattery(nsIDOMMozBatteryManager** aBattery)
{
if (!mBatteryManager) {
*aBattery = nsnull;
nsCOMPtr<nsPIDOMWindow> window = do_GetInterface(mDocShell);
NS_ENSURE_TRUE(window, NS_OK);
nsCOMPtr<nsIDocument> document = do_GetInterface(mDocShell);
NS_ENSURE_TRUE(document, NS_OK);
nsIScriptGlobalObject* sgo = document->GetScopeObject();
NS_ENSURE_TRUE(sgo, NS_OK);
nsIScriptContext* scx = sgo->GetContext();
NS_ENSURE_TRUE(scx, NS_OK);
mBatteryManager = new battery::BatteryManager();
mBatteryManager->Init();
mBatteryManager->Init(window->GetCurrentInnerWindow(), scx);
}
NS_ADDREF(*aBattery = mBatteryManager);

View File

@ -71,7 +71,7 @@ class Navigator : public nsIDOMNavigator,
public nsIDOMClientInformation,
public nsIDOMNavigatorGeolocation,
public nsIDOMNavigatorDesktopNotification,
public nsIDOMNavigatorBattery
public nsIDOMMozNavigatorBattery
{
public:
Navigator(nsIDocShell *aDocShell);
@ -82,7 +82,7 @@ public:
NS_DECL_NSIDOMCLIENTINFORMATION
NS_DECL_NSIDOMNAVIGATORGEOLOCATION
NS_DECL_NSIDOMNAVIGATORDESKTOPNOTIFICATION
NS_DECL_NSIDOMNAVIGATORBATTERY
NS_DECL_NSIDOMMOZNAVIGATORBATTERY
static void Init();

View File

@ -1385,7 +1385,7 @@ static nsDOMClassInfoData sClassInfoData[] = {
NS_DEFINE_CLASSINFO_DATA(GeoPositionError, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(BatteryManager, nsDOMGenericSH,
NS_DEFINE_CLASSINFO_DATA(MozBatteryManager, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(CSSFontFaceRule, nsDOMGenericSH,
@ -2287,7 +2287,7 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_MAP_CONDITIONAL_ENTRY(nsIDOMNavigatorDesktopNotification,
Navigator::HasDesktopNotificationSupport())
DOM_CLASSINFO_MAP_ENTRY(nsIDOMClientInformation)
DOM_CLASSINFO_MAP_CONDITIONAL_ENTRY(nsIDOMNavigatorBattery,
DOM_CLASSINFO_MAP_CONDITIONAL_ENTRY(nsIDOMMozNavigatorBattery,
battery::BatteryManager::HasSupport())
DOM_CLASSINFO_MAP_END
@ -3866,8 +3866,8 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_MAP_ENTRY(nsIDOMGeoPositionError)
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(BatteryManager, nsIDOMBatteryManager)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMBatteryManager)
DOM_CLASSINFO_MAP_BEGIN(MozBatteryManager, nsIDOMMozBatteryManager)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozBatteryManager)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
DOM_CLASSINFO_MAP_END

View File

@ -426,7 +426,7 @@ DOMCI_CLASS(GeoPositionCoords)
DOMCI_CLASS(GeoPositionAddress)
DOMCI_CLASS(GeoPositionError)
DOMCI_CLASS(BatteryManager)
DOMCI_CLASS(MozBatteryManager)
// @font-face in CSS
DOMCI_CLASS(CSSFontFaceRule)

View File

@ -68,7 +68,6 @@
#include "gfxImageSurface.h"
#include "nsLayoutUtils.h"
#include "nsComputedDOMStyle.h"
#include "nsIViewObserver.h"
#include "nsIPresShell.h"
#include "nsStyleAnimation.h"
#include "nsCSSProps.h"
@ -475,12 +474,9 @@ nsDOMWindowUtils::SendMouseEventCommon(const nsAString& aType,
nsEventStatus status;
if (aToWindow) {
nsIPresShell* presShell = presContext->PresShell();
nsCOMPtr<nsIPresShell> presShell = presContext->PresShell();
if (!presShell)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIViewObserver> vo = do_QueryInterface(presShell);
if (!vo)
return NS_ERROR_FAILURE;
nsIViewManager* viewManager = presShell->GetViewManager();
if (!viewManager)
return NS_ERROR_FAILURE;
@ -489,7 +485,7 @@ nsDOMWindowUtils::SendMouseEventCommon(const nsAString& aType,
return NS_ERROR_FAILURE;
status = nsEventStatus_eIgnore;
return vo->HandleEvent(view, &event, false, &status);
return presShell->HandleEvent(view->GetFrame(), &event, false, &status);
}
return widget->DispatchEvent(&event, status);
}

View File

@ -52,7 +52,7 @@
#define DISCHARGINGTIMECHANGE_EVENT_NAME NS_LITERAL_STRING("dischargingtimechange")
#define CHARGINGTIMECHANGE_EVENT_NAME NS_LITERAL_STRING("chargingtimechange")
DOMCI_DATA(BatteryManager, mozilla::dom::battery::BatteryManager)
DOMCI_DATA(MozBatteryManager, mozilla::dom::battery::BatteryManager)
namespace mozilla {
namespace dom {
@ -61,26 +61,28 @@ namespace battery {
NS_IMPL_CYCLE_COLLECTION_CLASS(BatteryManager)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(BatteryManager,
nsDOMEventTargetHelper)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mOnLevelChangeListener)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mOnChargingChangeListener)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mOnDischargingTimeChangeListener)
nsDOMEventTargetWrapperCache)
NS_CYCLE_COLLECTION_TRAVERSE_EVENT_HANDLER(levelchange)
NS_CYCLE_COLLECTION_TRAVERSE_EVENT_HANDLER(chargingchange)
NS_CYCLE_COLLECTION_TRAVERSE_EVENT_HANDLER(chargingtimechange)
NS_CYCLE_COLLECTION_TRAVERSE_EVENT_HANDLER(dischargingtimechange)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(BatteryManager,
nsDOMEventTargetHelper)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mOnLevelChangeListener)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mOnChargingChangeListener)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mOnDischargingTimeChangeListener)
nsDOMEventTargetWrapperCache)
NS_CYCLE_COLLECTION_UNLINK_EVENT_HANDLER(levelchange)
NS_CYCLE_COLLECTION_UNLINK_EVENT_HANDLER(chargingchange)
NS_CYCLE_COLLECTION_UNLINK_EVENT_HANDLER(chargingtimechange)
NS_CYCLE_COLLECTION_UNLINK_EVENT_HANDLER(dischargingtimechange)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(BatteryManager)
NS_INTERFACE_MAP_ENTRY(nsIDOMBatteryManager)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(BatteryManager)
NS_INTERFACE_MAP_END_INHERITING(nsDOMEventTargetHelper)
NS_INTERFACE_MAP_ENTRY(nsIDOMMozBatteryManager)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(MozBatteryManager)
NS_INTERFACE_MAP_END_INHERITING(nsDOMEventTargetWrapperCache)
NS_IMPL_ADDREF_INHERITED(BatteryManager, nsDOMEventTargetHelper)
NS_IMPL_RELEASE_INHERITED(BatteryManager, nsDOMEventTargetHelper)
NS_IMPL_ADDREF_INHERITED(BatteryManager, nsDOMEventTargetWrapperCache)
NS_IMPL_RELEASE_INHERITED(BatteryManager, nsDOMEventTargetWrapperCache)
BatteryManager::BatteryManager()
: mLevel(kDefaultLevel)
@ -97,8 +99,12 @@ BatteryManager::~BatteryManager()
}
void
BatteryManager::Init()
BatteryManager::Init(nsPIDOMWindow *aWindow, nsIScriptContext* aScriptContext)
{
// Those vars come from nsDOMEventTargetHelper.
mOwner = aWindow;
mScriptContext = aScriptContext;
hal::RegisterBatteryObserver(this);
hal::BatteryInformation* batteryInfo = new hal::BatteryInformation();
@ -157,61 +163,10 @@ BatteryManager::GetChargingTime(double* aChargingTime)
return NS_OK;
}
NS_IMETHODIMP
BatteryManager::GetOnlevelchange(nsIDOMEventListener** aOnlevelchange)
{
return GetInnerEventListener(mOnLevelChangeListener, aOnlevelchange);
}
NS_IMETHODIMP
BatteryManager::SetOnlevelchange(nsIDOMEventListener* aOnlevelchange)
{
return RemoveAddEventListener(LEVELCHANGE_EVENT_NAME, mOnLevelChangeListener,
aOnlevelchange);
}
NS_IMETHODIMP
BatteryManager::GetOnchargingchange(nsIDOMEventListener** aOnchargingchange)
{
return GetInnerEventListener(mOnChargingChangeListener, aOnchargingchange);
}
NS_IMETHODIMP
BatteryManager::SetOnchargingchange(nsIDOMEventListener* aOnchargingchange)
{
return RemoveAddEventListener(CHARGINGCHANGE_EVENT_NAME,
mOnChargingChangeListener, aOnchargingchange);
}
NS_IMETHODIMP
BatteryManager::GetOndischargingtimechange(nsIDOMEventListener** aOndischargingtimechange)
{
return GetInnerEventListener(mOnDischargingTimeChangeListener,
aOndischargingtimechange);
}
NS_IMETHODIMP
BatteryManager::SetOndischargingtimechange(nsIDOMEventListener* aOndischargingtimechange)
{
return RemoveAddEventListener(DISCHARGINGTIMECHANGE_EVENT_NAME,
mOnDischargingTimeChangeListener,
aOndischargingtimechange);
}
NS_IMETHODIMP
BatteryManager::GetOnchargingtimechange(nsIDOMEventListener** aOnchargingtimechange)
{
return GetInnerEventListener(mOnChargingTimeChangeListener,
aOnchargingtimechange);
}
NS_IMETHODIMP
BatteryManager::SetOnchargingtimechange(nsIDOMEventListener* aOnchargingtimechange)
{
return RemoveAddEventListener(CHARGINGTIMECHANGE_EVENT_NAME,
mOnChargingTimeChangeListener,
aOnchargingtimechange);
}
NS_IMPL_EVENT_HANDLER(BatteryManager, levelchange)
NS_IMPL_EVENT_HANDLER(BatteryManager, chargingchange)
NS_IMPL_EVENT_HANDLER(BatteryManager, chargingtimechange)
NS_IMPL_EVENT_HANDLER(BatteryManager, dischargingtimechange)
nsresult
BatteryManager::DispatchTrustedEventToSelf(const nsAString& aEventName)

View File

@ -39,11 +39,14 @@
#define mozilla_dom_battery_BatteryManager_h
#include "nsIDOMBatteryManager.h"
#include "nsDOMEventTargetHelper.h"
#include "nsDOMEventTargetWrapperCache.h"
#include "nsCycleCollectionParticipant.h"
#include "mozilla/Observer.h"
#include "Types.h"
class nsPIDOMWindow;
class nsIScriptContext;
namespace mozilla {
namespace hal {
@ -53,26 +56,26 @@ class BatteryInformation;
namespace dom {
namespace battery {
class BatteryManager : public nsIDOMBatteryManager
, public nsDOMEventTargetHelper
class BatteryManager : public nsDOMEventTargetWrapperCache
, public nsIDOMMozBatteryManager
, public BatteryObserver
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIDOMBATTERYMANAGER
NS_FORWARD_NSIDOMEVENTTARGET(nsDOMEventTargetHelper::)
NS_DECL_NSIDOMMOZBATTERYMANAGER
NS_FORWARD_NSIDOMEVENTTARGET(nsDOMEventTargetWrapperCache::)
BatteryManager();
virtual ~BatteryManager();
void Init();
void Init(nsPIDOMWindow *aWindow, nsIScriptContext* aScriptContext);
void Shutdown();
// For IObserver.
void Notify(const hal::BatteryInformation& aBatteryInfo);
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(BatteryManager,
nsDOMEventTargetHelper)
nsDOMEventTargetWrapperCache)
/**
* Returns whether the battery api is supported (ie. not disabled by the user)
@ -101,10 +104,10 @@ private:
*/
double mRemainingTime;
nsRefPtr<nsDOMEventListenerWrapper> mOnLevelChangeListener;
nsRefPtr<nsDOMEventListenerWrapper> mOnChargingChangeListener;
nsRefPtr<nsDOMEventListenerWrapper> mOnDischargingTimeChangeListener;
nsRefPtr<nsDOMEventListenerWrapper> mOnChargingTimeChangeListener;
NS_DECL_EVENT_HANDLER(levelchange);
NS_DECL_EVENT_HANDLER(chargingchange);
NS_DECL_EVENT_HANDLER(chargingtimechange);
NS_DECL_EVENT_HANDLER(dischargingtimechange);
};
} // namespace battery

View File

@ -38,8 +38,8 @@
interface nsIDOMEventListener;
[scriptable, function, uuid(6dcb803b-e968-4c02-88f5-049a3f2a2efb)]
interface nsIDOMBatteryManager : nsIDOMEventTarget
[scriptable, function, uuid(98b6237b-9654-43de-97e0-acf4b091b4e7)]
interface nsIDOMMozBatteryManager : nsIDOMEventTarget
{
readonly attribute double level;
readonly attribute boolean charging;

View File

@ -36,10 +36,10 @@
#include "nsISupports.idl"
interface nsIDOMBatteryManager;
interface nsIDOMMozBatteryManager;
[scriptable, uuid(a19eedd7-6c26-4676-bd34-7ca74ca5f565)]
interface nsIDOMNavigatorBattery : nsISupports
[scriptable, uuid(c295f049-be3d-4f83-9f7c-5c3e91d6ecb9)]
interface nsIDOMMozNavigatorBattery : nsISupports
{
readonly attribute nsIDOMBatteryManager mozBattery;
readonly attribute nsIDOMMozBatteryManager mozBattery;
};

View File

@ -14,6 +14,12 @@
/** Test for Battery API **/
// Testing prefixing.
ok(!("NavigatorBattery" in window), "NavigatorBattery shouldn't be visible");
ok(("MozNavigatorBattery" in window), "MozNavigatorBattery should be visible");
ok(!("BatteryManager" in window), "BatteryManager shouldn't be visible");
ok(("MozBatteryManager" in window), "MozBatteryManager should be visible");
ok('mozBattery' in navigator, "navigator.mozBattery should exist");
var battery = navigator.mozBattery;

View File

@ -512,6 +512,10 @@ IDBDatabase::CreateObjectStore(const nsAString& aName,
autoIncrement = !!boolVal;
}
if (!IDBObjectStore::IsValidKeyPath(aCx, keyPath)) {
return NS_ERROR_DOM_SYNTAX_ERR;
}
nsAutoPtr<ObjectStoreInfo> newInfo(new ObjectStoreInfo());
newInfo->name = aName;

View File

@ -43,6 +43,7 @@
#include "jsclone.h"
#include "mozilla/storage.h"
#include "nsCharSeparatedTokenizer.h"
#include "nsContentUtils.h"
#include "nsDOMClassInfo.h"
#include "nsEventDispatcher.h"
@ -411,24 +412,51 @@ private:
};
inline
nsresult
GetKeyFromObject(JSContext* aCx,
JSObject* aObj,
const nsString& aKeyPath,
Key& aKey)
bool
IgnoreWhitespace(PRUnichar c)
{
NS_PRECONDITION(aCx && aObj, "Null pointers!");
NS_ASSERTION(!aKeyPath.IsVoid(), "This will explode!");
return false;
}
const jschar* keyPathChars = reinterpret_cast<const jschar*>(aKeyPath.get());
const size_t keyPathLen = aKeyPath.Length();
typedef nsCharSeparatedTokenizerTemplate<IgnoreWhitespace> KeyPathTokenizer;
jsval key;
JSBool ok = JS_GetUCProperty(aCx, aObj, keyPathChars, keyPathLen, &key);
NS_ENSURE_TRUE(ok, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
inline
nsresult
GetKeyFromValue(JSContext* aCx,
jsval aVal,
const nsAString& aKeyPath,
Key& aKey)
{
NS_ASSERTION(aCx, "Null pointer!");
NS_ASSERTION(!JSVAL_IS_PRIMITIVE(aVal), "Why are we here!?");
NS_ASSERTION(IDBObjectStore::IsValidKeyPath(aCx, aKeyPath),
"This will explode!");
nsresult rv = aKey.SetFromJSVal(aCx, key);
NS_ENSURE_SUCCESS(rv, rv);
KeyPathTokenizer tokenizer(aKeyPath, '.');
jsval intermediate = aVal;
while (tokenizer.hasMoreTokens()) {
nsString token(tokenizer.nextToken());
if (!token.Length()) {
return NS_ERROR_DOM_SYNTAX_ERR;
}
const jschar* keyPathChars = token.get();
const size_t keyPathLen = token.Length();
if (JSVAL_IS_PRIMITIVE(intermediate)) {
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
JSBool ok = JS_GetUCProperty(aCx, JSVAL_TO_OBJECT(intermediate),
keyPathChars, keyPathLen, &intermediate);
NS_ENSURE_TRUE(ok, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
}
if (NS_FAILED(aKey.SetFromJSVal(aCx, intermediate))) {
aKey.Unset();
}
return NS_OK;
}
@ -502,6 +530,46 @@ IDBObjectStore::Create(IDBTransaction* aTransaction,
return objectStore.forget();
}
// static
bool
IDBObjectStore::IsValidKeyPath(JSContext* aCx,
const nsAString& aKeyPath)
{
NS_ASSERTION(!aKeyPath.IsVoid(), "What?");
KeyPathTokenizer tokenizer(aKeyPath, '.');
while (tokenizer.hasMoreTokens()) {
nsString token(tokenizer.nextToken());
if (!token.Length()) {
return false;
}
jsval stringVal;
if (!xpc_qsStringToJsval(aCx, token, &stringVal)) {
return false;
}
NS_ASSERTION(JSVAL_IS_STRING(stringVal), "This should never happen");
JSString* str = JSVAL_TO_STRING(stringVal);
JSBool isIdentifier = JS_FALSE;
if (!JS_IsIdentifier(aCx, str, &isIdentifier) || !isIdentifier) {
return false;
}
}
// If the very last character was a '.', the tokenizer won't give us an empty
// token, but the keyPath is still invalid.
if (!aKeyPath.IsEmpty() &&
aKeyPath.CharAt(aKeyPath.Length() - 1) == '.') {
return false;
}
return true;
}
// static
nsresult
IDBObjectStore::GetKeyPathValueFromStructuredData(const PRUint8* aData,
@ -530,22 +598,8 @@ IDBObjectStore::GetKeyPathValueFromStructuredData(const PRUint8* aData,
return NS_OK;
}
JSObject* obj = JSVAL_TO_OBJECT(clone);
const jschar* keyPathChars =
reinterpret_cast<const jschar*>(aKeyPath.BeginReading());
const size_t keyPathLen = aKeyPath.Length();
jsval keyVal;
JSBool ok = JS_GetUCProperty(aCx, obj, keyPathChars, keyPathLen, &keyVal);
NS_ENSURE_TRUE(ok, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
nsresult rv = aValue.SetFromJSVal(aCx, keyVal);
if (NS_FAILED(rv)) {
// If the object doesn't have a value that we can use for our index then we
// leave it unset.
aValue.Unset();
}
nsresult rv = GetKeyFromValue(aCx, clone, aKeyPath, aValue);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
}
@ -566,23 +620,14 @@ IDBObjectStore::GetIndexUpdateInfo(ObjectStoreInfo* aObjectStoreInfo,
return NS_ERROR_OUT_OF_MEMORY;
}
cloneObj = JSVAL_TO_OBJECT(aObject);
for (PRUint32 indexesIndex = 0; indexesIndex < count; indexesIndex++) {
const IndexInfo& indexInfo = aObjectStoreInfo->indexes[indexesIndex];
const jschar* keyPathChars =
reinterpret_cast<const jschar*>(indexInfo.keyPath.BeginReading());
const size_t keyPathLen = indexInfo.keyPath.Length();
jsval keyPathValue;
JSBool ok = JS_GetUCProperty(aCx, cloneObj, keyPathChars, keyPathLen,
&keyPathValue);
NS_ENSURE_TRUE(ok, NS_ERROR_FAILURE);
Key value;
nsresult rv = value.SetFromJSVal(aCx, keyPathValue);
if (NS_FAILED(rv) || value.IsUnset()) {
nsresult rv = GetKeyFromValue(aCx, aObject, indexInfo.keyPath, value);
NS_ENSURE_SUCCESS(rv, rv);
if (value.IsUnset()) {
// Not a value we can do anything with, ignore it.
continue;
}
@ -850,7 +895,7 @@ IDBObjectStore::GetAddInfo(JSContext* aCx,
return NS_ERROR_DOM_INDEXEDDB_DATA_ERR;
}
rv = GetKeyFromObject(aCx, JSVAL_TO_OBJECT(aValue), mKeyPath, aKey);
rv = GetKeyFromValue(aCx, aValue, mKeyPath, aKey);
NS_ENSURE_SUCCESS(rv, rv);
}
@ -1269,6 +1314,10 @@ IDBObjectStore::CreateIndex(const nsAString& aName,
return NS_ERROR_DOM_INDEXEDDB_NON_TRANSIENT_ERR;
}
if (!IsValidKeyPath(aCx, aKeyPath)) {
return NS_ERROR_DOM_SYNTAX_ERR;
}
IDBTransaction* transaction = AsyncConnectionHelper::GetCurrentTransaction();
if (!transaction ||

View File

@ -72,6 +72,9 @@ public:
Create(IDBTransaction* aTransaction,
const ObjectStoreInfo* aInfo);
static bool
IsValidKeyPath(JSContext* aCx, const nsAString& aKeyPath);
static nsresult
GetKeyPathValueFromStructuredData(const PRUint8* aData,
PRUint32 aDataLength,

View File

@ -59,6 +59,7 @@ TEST_FILES = \
test_bfcache.html \
test_clear.html \
test_cmp.html \
test_complex_keyPaths.html \
test_count.html \
test_create_index.html \
test_create_index_with_integer_keys.html \

View File

@ -0,0 +1,175 @@
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/
-->
<html>
<head>
<title>Indexed Database Property Test</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script type="text/javascript;version=1.7">
function testSteps()
{
const nsIIDBObjectStore = Components.interfaces.nsIIDBObjectStore;
const nsIIDBTransaction = Components.interfaces.nsIIDBTransaction;
// Test object stores
const name = window.location.pathname;
const objectStoreInfo = [
{ name: "a", options: { keyPath: "id"} },
{ name: "b", options: { keyPath: "foo.id"} },
{ name: "c", options: { keyPath: ""} },
{ name: "d", options: { keyPath: "foo..id"}, exception: true },
{ name: "e", options: { keyPath: "foo."}, exception: true },
{ name: "f", options: { keyPath: "foo.bar" } },
{ name: "g", options: { keyPath: "fo o" }, exception: true},
{ name: "h", options: { keyPath: "foo " }, exception: true},
{ name: "i", options: { keyPath: "foo[bar]" }, exception: true },
{ name: "j", options: { keyPath: "$('id').stuff" }, exception: true },
{ name: "k", options: { keyPath: "foo.2.bar" }, exception: true }
];
const indexInfo = [
{ name: "1", keyPath: "id" },
{ name: "2", keyPath: "foo..id", exception: true },
{ name: "3", keyPath: "foo.", exception: true },
{ name: "4", keyPath: "foo.baz" },
{ name: "5", keyPath: "fo o", exception: true },
{ name: "6", keyPath: "foo ", exception: true },
{ name: "7", keyPath: "foo[bar]", exception: true },
{ name: "8", keyPath: "$('id').stuff", exception: true },
{ name: "9", keyPath: "foo.2.bar", exception: true },
{ name: "10", keyPath: "foo.bork" },
];
let request = mozIndexedDB.open(name, 1);
request.onerror = errorHandler;
request.onupgradeneeded = grabEventAndContinueHandler;
request.onsuccess = unexpectedSuccessHandler;
let event = yield;
let db = event.target.result;
for (let i = 0; i < objectStoreInfo.length; i++) {
let info = objectStoreInfo[i];
try {
let objectStore = info.hasOwnProperty("options") ?
db.createObjectStore(info.name, info.options) :
db.createObjectStore(info.name);
ok(!info.hasOwnProperty("exception"), "expected exception behavior observed");
} catch (e) {
ok(info.hasOwnProperty("exception"), "expected exception behavior observed");
ok(e instanceof DOMException, "Got a DOM Exception");
is(e.code, DOMException.SYNTAX_ERR, "expect a syntax error");
}
}
request.onsuccess = grabEventAndContinueHandler;
yield;
let trans = db.transaction(["f"], IDBTransaction.READ_WRITE);
let objectStore = trans.objectStore("f");
objectStore.put({foo: {baz: -1, bar: 72, bork: true}});
objectStore.put({foo: {baz: 2, bar: 1, bork: false}});
try {
objectStore.put({foo: {}});
ok(false, "Should have thrown!");
} catch (e) {
ok(true, "Putting an object without the key should throw");
}
trans.onerror = errorHandler;
trans.oncomplete = grabEventAndContinueHandler;
yield;
let trans = db.transaction(["f"], IDBTransaction.READ);
let objectStore = trans.objectStore("f");
let request = objectStore.openCursor();
request.onerror = errorHandler;
request.onsuccess = grabEventAndContinueHandler;
let event = yield;
let cursor = event.target.result;
is(cursor.value.foo.baz, 2, "got things in the right order");
cursor.continue();
let event = yield
let cursor = event.target.result;
is(cursor.value.foo.baz, -1, "got things in the right order");
db.close();
// Test indexes
let request = mozIndexedDB.open(name, 2);
request.onerror = errorHandler;
request.onupgradeneeded = grabEventAndContinueHandler;
let event = yield;
let db = event.target.result;
let trans = event.target.transaction;
let objectStore = trans.objectStore("f");
let indexes = [];
for (let i = 0; i < indexInfo.length; i++) {
let info = indexInfo[i];
try {
indexes[i] = info.hasOwnProperty("options") ?
objectStore.createIndex(info.name, info.keyPath, info.options) :
objectStore.createIndex(info.name, info.keyPath);
ok(!info.hasOwnProperty("exception"), "expected exception behavior observed");
} catch (e) {
ok(info.hasOwnProperty("exception"), "expected exception behavior observed");
ok(e instanceof DOMException, "Got a DOM Exception");
is(e.code, DOMException.SYNTAX_ERR, "expect a syntax error");
}
}
request.onsuccess = grabEventAndContinueHandler;
yield;
let trans = db.transaction(["f"], IDBTransaction.READ);
let objectStore = trans.objectStore("f");
let request = objectStore.index("4").openCursor();
request.onsuccess = grabEventAndContinueHandler;
let event = yield;
let cursor = event.target.result;
is(cursor.value.foo.bar, 72, "got things in the right order");
cursor.continue();
yield;
is(cursor.value.foo.bar, 1, "got things in the right order");
let request = objectStore.index("10").openCursor();
request.onerror = errorHandler;
request.onsuccess = grabEventAndContinueHandler;
let event = yield;
is(event.target.result, null, "should have no results");
finishTest();
yield;
}
</script>
<script type="text/javascript;version=1.7" src="helpers.js"></script>
</head>
<body onload="runTest();"></body>
</html>

View File

@ -57,7 +57,7 @@
#endif
%}
[scriptable, uuid(642a3b85-4edb-4c01-a162-06b5d88171e7)]
[scriptable, uuid(f6eddb8a-7480-4b15-af2c-cc6ce9a7c140)]
interface nsIDOMHTMLMediaElement : nsIDOMHTMLElement
{
// error state
@ -94,6 +94,7 @@ interface nsIDOMHTMLMediaElement : nsIDOMHTMLElement
readonly attribute boolean ended;
readonly attribute boolean mozAutoplayEnabled;
attribute boolean autoplay;
attribute boolean loop;
void play();
void pause();

View File

@ -115,3 +115,15 @@ nsIJSONEncodeDeprecatedWarning=nsIJSON.encode is deprecated. Please use JSON.st
nsIDOMWindowInternalWarning=Use of nsIDOMWindowInternal is deprecated. Use nsIDOMWindow instead.
InputEncodingWarning=Use of inputEncoding is deprecated.
GlobalStorageWarning=Use of globalStorage is deprecated. Please use localStorage instead.
FullScreenDeniedDisabled=Request for full-screen was denied because full-screen API is disabled by user preference.
FullScreenDeniedPlugins=Request for full-screen was denied because a document on this page contains a windowed plugin.
FullScreenDeniedHidden=Request for full-screen was denied because the document is no longer visible.
FullScreenDeniedIframeDisallowed=Request for full-screen was denied because at least one of the document's containing iframes does not have a "mozallowfullscreen" attribute.
FullScreenDeniedNotInputDriven=Request for full-screen was denied because Element.mozRequestFullScreen() was not called from inside a short running user-generated event handler.
FullScreenDeniedNotInDocument=Request for full-screen was denied because requesting element is no longer in its document.
FullScreenDeniedMovedDocument=Request for full-screen was denied because requesting element has moved document.
FullScreenDeniedLostWindow=Request for full-screen was denied because we no longer have a window.
RemovedFullScreenElement=Exited full-screen because full-screen element was removed from document.
AddedWindowedPluginWhileFullScreen=Exited full-screen because windowed plugin was added to document.
HTMLMultipartXHRWarning=HTML parsing in XMLHttpRequest is not supported for multipart responses.
HTMLSyncXHRWarning=HTML parsing in XMLHttpRequest is not supported in the synchronous mode.

View File

@ -249,8 +249,9 @@ BrowserStreamChild::Deliver()
// asynchronously). Doing this resolves bug 687610, bug 670036 and possibly
// also other bugs.
if (mStreamAsFilePending) {
mInstance->mPluginIface->asfile(&mInstance->mData, &mStream,
mStreamAsFileName.get());
if (mStreamStatus == kStreamOpen)
mInstance->mPluginIface->asfile(&mInstance->mData, &mStream,
mStreamAsFileName.get());
mStreamAsFilePending = false;
}

View File

@ -566,6 +566,19 @@ public:
mProxy->mSeenLoadStart = false;
}
}
else if (mType.EqualsASCII(sEventStrings[STRING_abort])) {
if ((mUploadEvent && !mProxy->mSeenUploadLoadStart) ||
(!mUploadEvent && !mProxy->mSeenLoadStart)) {
// We've already dispatched premature abort events.
return true;
}
}
else if (mType.EqualsASCII(sEventStrings[STRING_readystatechange])) {
if (mReadyState == 4 && !mUploadEvent && !mProxy->mSeenLoadStart) {
// We've already dispatched premature abort events.
return true;
}
}
if (mProgressEvent) {
// Cache these for premature abort events.
@ -1533,7 +1546,7 @@ XMLHttpRequestPrivate::Abort(JSContext* aCx)
}
if (mProxy) {
if (!MaybeDispatchPrematureAbortEvents(aCx, false)) {
if (!MaybeDispatchPrematureAbortEvents(aCx)) {
return false;
}
}
@ -1619,7 +1632,7 @@ XMLHttpRequestPrivate::Open(JSContext* aCx, JSString* aMethod, JSString* aURL,
}
if (mProxy) {
if (!MaybeDispatchPrematureAbortEvents(aCx, true)) {
if (!MaybeDispatchPrematureAbortEvents(aCx)) {
return false;
}
}
@ -1831,8 +1844,7 @@ XMLHttpRequestPrivate::OverrideMimeType(JSContext* aCx, JSString* aMimeType)
}
bool
XMLHttpRequestPrivate::MaybeDispatchPrematureAbortEvents(JSContext* aCx,
bool aFromOpen)
XMLHttpRequestPrivate::MaybeDispatchPrematureAbortEvents(JSContext* aCx)
{
mWorkerPrivate->AssertIsOnWorkerThread();
NS_ASSERTION(mProxy, "Must have a proxy here!");
@ -1865,11 +1877,9 @@ XMLHttpRequestPrivate::MaybeDispatchPrematureAbortEvents(JSContext* aCx,
return false;
}
if (aFromOpen) {
if (!DispatchPrematureAbortEvent(aCx, target, STRING_abort, false) ||
!DispatchPrematureAbortEvent(aCx, target, STRING_loadend, false)) {
return false;
}
if (!DispatchPrematureAbortEvent(aCx, target, STRING_abort, false) ||
!DispatchPrematureAbortEvent(aCx, target, STRING_loadend, false)) {
return false;
}
mProxy->mSeenLoadStart = false;

View File

@ -155,7 +155,7 @@ private:
RootJSObject(JSContext* aCx);
bool
MaybeDispatchPrematureAbortEvents(JSContext* aCx, bool aFromOpen);
MaybeDispatchPrematureAbortEvents(JSContext* aCx);
bool
DispatchPrematureAbortEvent(JSContext* aCx, JSObject* aTarget,

View File

@ -59,7 +59,7 @@ struct Point :
Point() : Super() {}
Point(Float aX, Float aY) : Super(aX, aY) {}
Point(const IntPoint& point) : Super(point.x, point.y) {}
Point(const IntPoint& point) : Super(float(point.x), float(point.y)) {}
};
struct IntSize :
@ -76,7 +76,8 @@ struct Size :
Size() : Super() {}
Size(Float aWidth, Float aHeight) : Super(aWidth, aHeight) {}
explicit Size(const IntSize& size) : Super(size.width, size.height) {}
explicit Size(const IntSize& size) :
Super(float(size.width), float(size.height)) {}
};
}

View File

@ -81,7 +81,8 @@ struct Rect :
Rect(Float _x, Float _y, Float _width, Float _height) :
Super(_x, _y, _width, _height) {}
explicit Rect(const IntRect& rect) :
Super(rect.x, rect.y, rect.width, rect.height) {}
Super(float(rect.x), float(rect.y),
float(rect.width), float(rect.height)) {}
};
}

View File

@ -127,13 +127,15 @@ Nv3DVUtils::SetDeviceInfo(IUnknown *devUnknown)
bool rv = false;
rv = m3DVStreaming->Nv3DVSetDevice(devUnknown);
if (!rv) {
if (NS_FAILED(rv)) {
NS_WARNING("Nv3DVStreaming Nv3DVControl failed!");
return;
}
rv = m3DVStreaming->Nv3DVControl(NV_STEREO_MODE_RIGHT_LEFT, true, FIREFOX_3DV_APP_HANDLE);
NS_ASSERTION(rv, "Nv3DVStreaming Nv3DVControl failed!");
if (NS_FAILED(rv)) {
NS_WARNING("Nv3DVStreaming Nv3DVControl failed!");
}
}
/*

View File

@ -579,11 +579,10 @@ gfxUserFontSet::OnLoadComplete(gfxProxyFontEntry *aProxy,
}
// error occurred, load next src
LoadStatus status;
(void)LoadNext(aProxy);
status = LoadNext(aProxy);
// Even if loading failed, we need to bump the font-set generation
// We ignore the status returned by LoadNext();
// even if loading failed, we need to bump the font-set generation
// and return true in order to trigger reflow, so that fallback
// will be used where the text was "masked" by the pending download
IncrementGeneration();

View File

@ -42,6 +42,7 @@ DEPTH = ../..
topsrcdir = @top_srcdir@
VPATH = @srcdir@
srcdir = @srcdir@
relativesrcdir = js/jsd
include $(DEPTH)/config/autoconf.mk
@ -55,6 +56,7 @@ LIBXUL_LIBRARY = 1
MODULE_NAME = JavaScript_Debugger
EXPORT_LIBRARY = 1
XPCSHELL_TESTS = test
# REQUIRES = java js

View File

@ -0,0 +1,39 @@
// Bug 689101 - if the binary layout of jsval does not match between C and C++
// code, then calls to functions returning jsval may get compiled differently
// than the callee, resulting in parameters being shifted over by one.
//
// An example is where on Windows, calling jsdValue.getWrappedValue() will
// return a random floating point number instead of an object.
//
// This test must be run with debugging already enabled
function run_test() {
const Cc = Components.classes;
const Ci = Components.interfaces;
const DebuggerService = Cc["@mozilla.org/js/jsd/debugger-service;1"];
const jsdIDebuggerService = Ci.jsdIDebuggerService;
var jsd = DebuggerService.getService(jsdIDebuggerService);
do_check_true(jsd.isOn);
var n = 0;
function f() {
n++;
}
jsd.enumerateScripts({ enumerateScript: function(script) {
script.setBreakpoint(0);
} });
jsd.breakpointHook = function(frame, type, dummy) {
var scope = frame.scope;
var parent = scope.jsParent; // Probably does not need to be called
var wrapped = scope.getWrappedValue();
// Do not try to print 'wrapped'; it may be an internal Call object
// that will crash when you toString it. Different bug.
do_check_eq(typeof(wrapped), "object");
return Ci.jsdIExecutionHook.RETURN_CONTINUE;
};
f();
}

6
js/jsd/test/xpcshell.ini Normal file
View File

@ -0,0 +1,6 @@
[DEFAULT]
head =
tail =
[test_jsval_retval.js]
debug = 1

View File

@ -346,14 +346,14 @@ __BitScanReverse64(unsigned __int64 val)
# define js_FloorLog2wImpl(n) \
((size_t)(JS_BITS_PER_WORD - 1 - js_bitscan_clz32(n)))
# else
extern size_t js_FloorLog2wImpl(size_t n);
JS_PUBLIC_API(size_t) js_FloorLog2wImpl(size_t n);
# endif
#elif JS_BYTES_PER_WORD == 8
# ifdef JS_HAS_BUILTIN_BITSCAN64
# define js_FloorLog2wImpl(n) \
((size_t)(JS_BITS_PER_WORD - 1 - js_bitscan_clz64(n)))
# else
extern size_t js_FloorLog2wImpl(size_t n);
JS_PUBLIC_API(size_t) js_FloorLog2wImpl(size_t n);
# endif
#else
# error "NOT SUPPORTED"

View File

@ -1,14 +1,21 @@
// |jit-test| error: InternalError
// |jit-test| allow-oom;
/*
* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/licenses/publicdomain/
*/
const MAX = 10000;
var str = "";
for (var i = 0; i < MAX; ++i) {
/x/.test(str);
str += str + 'xxxxxxxxxxxxxx';
try
{
const MAX = 10000;
var str = "";
for (var i = 0; i < MAX; ++i) {
/x/.test(str);
str += str + 'xxxxxxxxxxxxxx';
}
}
catch (e)
{
assertEq(""+e, "InternalError: allocation size overflow");
}
/* Don't crash */

View File

@ -6484,6 +6484,19 @@ JS_IndexToId(JSContext *cx, uint32 index, jsid *id)
return IndexToId(cx, index, id);
}
JS_PUBLIC_API(JSBool)
JS_IsIdentifier(JSContext *cx, JSString *str, JSBool *isIdentifier)
{
assertSameCompartment(cx, str);
JSLinearString* linearStr = str->ensureLinear(cx);
if (!linearStr)
return false;
*isIdentifier = js::IsIdentifier(linearStr);
return true;
}
#ifdef JS_THREADSAFE
static PRStatus
CallOnce(void *func)

View File

@ -5020,6 +5020,12 @@ JS_ScheduleGC(JSContext *cx, uint32 count, JSBool compartment);
extern JS_PUBLIC_API(JSBool)
JS_IndexToId(JSContext *cx, uint32 index, jsid *id);
/*
* Test if the given string is a valid ECMAScript identifier
*/
extern JS_PUBLIC_API(JSBool)
JS_IsIdentifier(JSContext *cx, JSString *str, JSBool *isIdentifier);
JS_END_EXTERN_C
#endif /* jsapi_h___ */

View File

@ -552,12 +552,9 @@ DumpXPC(JSContext *cx, uintN argc, jsval *vp)
static JSBool
GC(JSContext *cx, uintN argc, jsval *vp)
{
JSRuntime *rt;
rt = cx->runtime;
JS_GC(cx);
#ifdef JS_GCMETER
js_DumpGCStats(rt, stdout);
js_DumpGCStats(cx->runtime, stdout);
#endif
JS_SET_RVAL(cx, vp, JSVAL_VOID);
return JS_TRUE;
@ -1236,6 +1233,9 @@ ProcessArgs(JSContext *cx, JSObject *obj, char **argv, int argc)
case 'x':
JS_ToggleOptions(cx, JSOPTION_XML);
break;
case 'd':
xpc_ActivateDebugMode();
break;
case 'P':
if (JS_GET_CLASS(cx, JS_GetPrototype(cx, obj)) != &global_class) {
JSObject *gobj;

View File

@ -2719,7 +2719,6 @@ nsXPCComponents_Utils::LookupMethod()
return NS_ERROR_XPC_BAD_CONVERT_JS;
jsval funval;
JSFunction *oldfunction;
// get (and perhaps lazily create) the member's cloned function
if (!member->NewFunctionObject(inner_cc, iface,
@ -2727,8 +2726,8 @@ nsXPCComponents_Utils::LookupMethod()
&funval))
return NS_ERROR_XPC_BAD_CONVERT_JS;
oldfunction = JS_ValueToFunction(inner_cc, funval);
NS_ASSERTION(oldfunction, "Function is not a function");
NS_ASSERTION(JS_ValueToFunction(inner_cc, funval),
"Function is not a function");
// Stick the function in the return value. This roots it.
*retval = funval;

View File

@ -272,7 +272,7 @@ CompartmentCallback(JSContext *cx, JSCompartment *compartment, uintN op)
XPCCompartmentMap &map = self->GetCompartmentMap();
#ifdef DEBUG
{
JSCompartment *current = NULL; // init to shut GCC up
JSCompartment *current = NULL;
NS_ASSERTION(map.Get(key, &current), "no compartment?");
NS_ASSERTION(current == compartment, "compartment mismatch");
}

View File

@ -2278,7 +2278,7 @@ CallMethodHelper::~CallMethodHelper()
// Clean up the array contents if necessary.
if (dp->DoesValNeedCleanup()) {
// We need some basic information to properly destroy the array.
JSUint32 array_count;
JSUint32 array_count = 0;
nsXPTType datum_type;
if (!GetArraySizeFromParam(i, &array_count) ||
!NS_SUCCEEDED(mIFaceInfo->GetTypeForParam(mVTableIndex,
@ -2413,7 +2413,7 @@ CallMethodHelper::GatherAndConvertResults()
nsXPTCVariant* dp = GetDispatchParam(i);
jsval v = JSVAL_NULL;
AUTO_MARK_JSVAL(mCallContext, &v);
JSUint32 array_count;
JSUint32 array_count = 0;
nsXPTType datum_type;
bool isArray = type.IsArray();
bool isSizedString = isArray ?
@ -2738,7 +2738,7 @@ CallMethodHelper::ConvertDependentParams()
continue;
nsXPTType datum_type;
JSUint32 array_count;
JSUint32 array_count = 0;
bool isArray = type.IsArray();
bool isSizedString = isArray ?

View File

@ -267,7 +267,7 @@ XPCNativeInterface::NewInstance(XPCCallContext& ccx,
PRUint16 totalCount;
PRUint16 realTotalCount = 0;
XPCNativeMember* cur;
JSString* str;
JSString* str = NULL;
jsid name;
jsid interfaceName;

View File

@ -55,6 +55,7 @@ xpc_qsUnwrapThis<_interface>(JSContext *cx, \
nsISupports *native = castNativeFromWrapper(cx, obj, callee, _bit, \
pThisRef, pThisVal, lccx, \
&rv); \
*ppThis = NULL; /* avoids uninitialized warnings in callers */ \
if (failureFatal && !native) \
return xpc_qsThrow(cx, rv); \
*ppThis = static_cast<_interface*>(static_cast<_base*>(native)); \

View File

@ -2578,6 +2578,14 @@ fail:
gDesiredDebugMode = gDebugMode = JS_FALSE;
}
NS_EXPORT_(void)
xpc_ActivateDebugMode()
{
XPCJSRuntime* rt = nsXPConnect::GetRuntimeInstance();
nsXPConnect::GetXPConnect()->SetDebugModeWhenPossible(true, true);
nsXPConnect::CheckForDebugMode(rt->GetJSRuntime());
}
/* JSContext Pop (); */
NS_IMETHODIMP
nsXPConnect::Pop(JSContext * *_retval)

View File

@ -595,6 +595,8 @@ public:
return gReportAllJSExceptions > 0;
}
static void CheckForDebugMode(JSRuntime *rt);
protected:
nsXPConnect();
@ -624,7 +626,6 @@ private:
static PRUint32 gReportAllJSExceptions;
static JSBool gDebugMode;
static JSBool gDesiredDebugMode;
static inline void CheckForDebugMode(JSRuntime *rt);
public:
static nsIScriptSecurityManager *gScriptSecurityManager;

View File

@ -182,6 +182,11 @@ xpc_UnmarkGrayObject(JSObject *obj)
xpc_UnmarkGrayObjectRecursive(obj);
}
// No JS can be on the stack when this is called. Probably only useful from
// xpcshell.
NS_EXPORT_(void)
xpc_ActivateDebugMode();
class nsIMemoryMultiReporterCallback;
namespace mozilla {

View File

@ -142,6 +142,7 @@
#undef NOISY_FIRST_LETTER
#include "nsMathMLParts.h"
#include "nsIDOMSVGFilters.h"
#include "nsSVGFeatures.h"
#include "nsSVGEffects.h"
#include "nsSVGUtils.h"
@ -213,7 +214,13 @@ NS_NewSVGPatternFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
nsIFrame*
NS_NewSVGMaskFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
nsIFrame*
NS_NewSVGLeafFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
NS_NewSVGFEContainerFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
nsIFrame*
NS_NewSVGFELeafFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
nsIFrame*
NS_NewSVGFEImageFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
nsIFrame*
NS_NewSVGFEUnstyledLeafFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
#include "nsIDocument.h"
#include "nsIScrollable.h"
@ -4717,7 +4724,7 @@ nsCSSFrameConstructor::FindSVGData(Element* aElement,
PRInt32 parentNSID;
nsIAtom* parentTag =
parentContent->OwnerDoc()->BindingManager()->
ResolveTag(aParentFrame->GetContent(), &parentNSID);
ResolveTag(parentContent, &parentNSID);
// It's not clear whether the SVG spec intends to allow any SVG
// content within svg:foreignObject at all (SVG 1.1, section
@ -4728,11 +4735,7 @@ nsCSSFrameConstructor::FindSVGData(Element* aElement,
}
if ((aTag != nsGkAtoms::svg && !parentIsSVG) ||
(aTag == nsGkAtoms::desc || aTag == nsGkAtoms::title ||
aTag == nsGkAtoms::feFuncR || aTag == nsGkAtoms::feFuncG ||
aTag == nsGkAtoms::feFuncB || aTag == nsGkAtoms::feFuncA ||
aTag == nsGkAtoms::feDistantLight || aTag == nsGkAtoms::fePointLight ||
aTag == nsGkAtoms::feSpotLight)) {
(aTag == nsGkAtoms::desc || aTag == nsGkAtoms::title)) {
// Sections 5.1 and G.4 of SVG 1.1 say that SVG elements other than
// svg:svg not contained within svg:svg are incorrect, although they
// don't seem to specify error handling. Ignore them, since many of
@ -4744,9 +4747,6 @@ nsCSSFrameConstructor::FindSVGData(Element* aElement,
// adding to the undisplayed content map.
//
// We don't currently handle any UI for desc/title
//
// The filter types are children of filter elements that use their
// parent frames when necessary
return &sSuppressData;
}
@ -4775,6 +4775,24 @@ nsCSSFrameConstructor::FindSVGData(Element* aElement,
return &sContainerData;
}
// Special case for filter primitive elements.
// These elements must have a filter element as a parent
nsCOMPtr<nsIDOMSVGFilterPrimitiveStandardAttributes> filterPrimitive =
do_QueryInterface(aElement);
if (filterPrimitive && aParentFrame->GetType() != nsGkAtoms::svgFilterFrame) {
return &sSuppressData;
}
// Some elements must be children of filter primitive elements.
if ((aTag == nsGkAtoms::feDistantLight || aTag == nsGkAtoms::fePointLight ||
aTag == nsGkAtoms::feSpotLight ||
aTag == nsGkAtoms::feFuncR || aTag == nsGkAtoms::feFuncG ||
aTag == nsGkAtoms::feFuncB || aTag == nsGkAtoms::feFuncA ||
aTag == nsGkAtoms::feMergeNode) &&
aParentFrame->GetType() != nsGkAtoms::svgFEContainerFrame) {
return &sSuppressData;
}
// Special cases for text/tspan/textPath, because the kind of frame
// they get depends on the parent frame. We ignore 'a' elements when
// determining the parent, however.
@ -4834,22 +4852,30 @@ nsCSSFrameConstructor::FindSVGData(Element* aElement,
SIMPLE_SVG_CREATE(filter, NS_NewSVGFilterFrame),
SIMPLE_SVG_CREATE(pattern, NS_NewSVGPatternFrame),
SIMPLE_SVG_CREATE(mask, NS_NewSVGMaskFrame),
SIMPLE_SVG_CREATE(feBlend, NS_NewSVGLeafFrame),
SIMPLE_SVG_CREATE(feColorMatrix, NS_NewSVGLeafFrame),
SIMPLE_SVG_CREATE(feComposite, NS_NewSVGLeafFrame),
SIMPLE_SVG_CREATE(feComponentTransfer, NS_NewSVGLeafFrame),
SIMPLE_SVG_CREATE(feConvolveMatrix, NS_NewSVGLeafFrame),
SIMPLE_SVG_CREATE(feDiffuseLighting, NS_NewSVGLeafFrame),
SIMPLE_SVG_CREATE(feDisplacementMap, NS_NewSVGLeafFrame),
SIMPLE_SVG_CREATE(feFlood, NS_NewSVGLeafFrame),
SIMPLE_SVG_CREATE(feGaussianBlur, NS_NewSVGLeafFrame),
SIMPLE_SVG_CREATE(feImage, NS_NewSVGLeafFrame),
SIMPLE_SVG_CREATE(feMergeNode, NS_NewSVGLeafFrame),
SIMPLE_SVG_CREATE(feMorphology, NS_NewSVGLeafFrame),
SIMPLE_SVG_CREATE(feOffset, NS_NewSVGLeafFrame),
SIMPLE_SVG_CREATE(feSpecularLighting, NS_NewSVGLeafFrame),
SIMPLE_SVG_CREATE(feTile, NS_NewSVGLeafFrame),
SIMPLE_SVG_CREATE(feTurbulence, NS_NewSVGLeafFrame)
SIMPLE_SVG_CREATE(feDistantLight, NS_NewSVGFEUnstyledLeafFrame),
SIMPLE_SVG_CREATE(fePointLight, NS_NewSVGFEUnstyledLeafFrame),
SIMPLE_SVG_CREATE(feSpotLight, NS_NewSVGFEUnstyledLeafFrame),
SIMPLE_SVG_CREATE(feBlend, NS_NewSVGFELeafFrame),
SIMPLE_SVG_CREATE(feColorMatrix, NS_NewSVGFELeafFrame),
SIMPLE_SVG_CREATE(feFuncR, NS_NewSVGFEUnstyledLeafFrame),
SIMPLE_SVG_CREATE(feFuncG, NS_NewSVGFEUnstyledLeafFrame),
SIMPLE_SVG_CREATE(feFuncB, NS_NewSVGFEUnstyledLeafFrame),
SIMPLE_SVG_CREATE(feFuncA, NS_NewSVGFEUnstyledLeafFrame),
SIMPLE_SVG_CREATE(feComposite, NS_NewSVGFELeafFrame),
SIMPLE_SVG_CREATE(feComponentTransfer, NS_NewSVGFEContainerFrame),
SIMPLE_SVG_CREATE(feConvolveMatrix, NS_NewSVGFELeafFrame),
SIMPLE_SVG_CREATE(feDiffuseLighting, NS_NewSVGFEContainerFrame),
SIMPLE_SVG_CREATE(feDisplacementMap, NS_NewSVGFELeafFrame),
SIMPLE_SVG_CREATE(feFlood, NS_NewSVGFELeafFrame),
SIMPLE_SVG_CREATE(feGaussianBlur, NS_NewSVGFELeafFrame),
SIMPLE_SVG_CREATE(feImage, NS_NewSVGFEImageFrame),
SIMPLE_SVG_CREATE(feMerge, NS_NewSVGFEContainerFrame),
SIMPLE_SVG_CREATE(feMergeNode, NS_NewSVGFEUnstyledLeafFrame),
SIMPLE_SVG_CREATE(feMorphology, NS_NewSVGFELeafFrame),
SIMPLE_SVG_CREATE(feOffset, NS_NewSVGFELeafFrame),
SIMPLE_SVG_CREATE(feSpecularLighting, NS_NewSVGFEContainerFrame),
SIMPLE_SVG_CREATE(feTile, NS_NewSVGFELeafFrame),
SIMPLE_SVG_CREATE(feTurbulence, NS_NewSVGFELeafFrame)
};
const FrameConstructionData* data =

View File

@ -102,11 +102,13 @@ class nsPIDOMWindow;
struct nsPoint;
struct nsIntPoint;
struct nsIntRect;
class nsRegion;
class nsRefreshDriver;
class nsARefreshObserver;
#ifdef ACCESSIBILITY
class nsAccessibilityService;
#endif
class nsIWidget;
typedef short SelectionType;
typedef PRUint64 nsFrameState;
@ -139,8 +141,8 @@ typedef struct CapturingContentInfo {
} CapturingContentInfo;
#define NS_IPRESSHELL_IID \
{ 0x67eab923, 0x5c15, 0x4c13,\
{ 0xb5, 0xcc, 0xb2, 0x75, 0xb3, 0x5a, 0xa5, 0x38 } }
{ 0x4e23d557, 0x741a, 0x4fd0,\
{ 0x91, 0x52, 0x34, 0xe2, 0xb4, 0xef, 0xe8, 0x2e } }
// Constants for ScrollContentIntoView() function
#define NS_PRESSHELL_SCROLL_TOP 0
@ -1136,6 +1138,20 @@ public:
*/
virtual void SynthesizeMouseMove(bool aFromScroll) = 0;
virtual void Paint(nsIView* aViewToPaint, nsIWidget* aWidget,
const nsRegion& aDirtyRegion, const nsIntRegion& aIntDirtyRegion,
bool aPaintDefaultBackground, bool aWillSendDidPaint) = 0;
virtual nsresult HandleEvent(nsIFrame* aFrame,
nsGUIEvent* aEvent,
bool aDontRetargetEvents,
nsEventStatus* aEventStatus) = 0;
virtual bool ShouldIgnoreInvalidation() = 0;
virtual void WillPaint(bool aWillSendDidPaint) = 0;
virtual void DidPaint() = 0;
virtual void ClearMouseCaptureOnView(nsIView* aView) = 0;
virtual bool IsVisible() = 0;
virtual void DispatchSynthMouseMove(nsGUIEvent *aEvent, bool aFlushOnHoverChange) = 0;
/**
* Refresh observer management.
*/

View File

@ -106,10 +106,14 @@ nsImageLoader::Destroy()
if (mRequest && mFrame) {
nsLayoutUtils::DeregisterImageRequest(mFrame->PresContext(), mRequest,
&mRequestRegistered);
mRequest->CancelAndForgetObserver(NS_ERROR_FAILURE);
}
mFrame = nsnull;
if (mRequest) {
mRequest->CancelAndForgetObserver(NS_ERROR_FAILURE);
}
mRequest = nsnull;
}

View File

@ -510,9 +510,7 @@ nsLayoutUtils::GetCrossDocParentFrame(const nsIFrame* aFrame,
*aExtraOffset += v->GetPosition();
}
v = v->GetParent(); // subdocumentframe's view
if (!v)
return nsnull;
return static_cast<nsIFrame*>(v->GetClientData());
return v ? v->GetFrame() : nsnull;
}
// static
@ -753,16 +751,16 @@ nsIFrame* nsLayoutUtils::GetLastSibling(nsIFrame* aFrame) {
// static
nsIView*
nsLayoutUtils::FindSiblingViewFor(nsIView* aParentView, nsIFrame* aFrame) {
nsIFrame* parentViewFrame = static_cast<nsIFrame*>(aParentView->GetClientData());
nsIFrame* parentViewFrame = aParentView->GetFrame();
nsIContent* parentViewContent = parentViewFrame ? parentViewFrame->GetContent() : nsnull;
for (nsIView* insertBefore = aParentView->GetFirstChild(); insertBefore;
insertBefore = insertBefore->GetNextSibling()) {
nsIFrame* f = static_cast<nsIFrame*>(insertBefore->GetClientData());
nsIFrame* f = insertBefore->GetFrame();
if (!f) {
// this view could be some anonymous view attached to a meaningful parent
for (nsIView* searchView = insertBefore->GetParent(); searchView;
searchView = searchView->GetParent()) {
f = static_cast<nsIFrame*>(searchView->GetClientData());
f = searchView->GetFrame();
if (f) {
break;
}

View File

@ -342,8 +342,7 @@ public:
* @param aView is the view to return the root frame for
* @return the root frame for the view
*/
static nsIFrame* GetFrameFor(nsIView *aView)
{ return static_cast<nsIFrame*>(aView->GetClientData()); }
static nsIFrame* GetFrameFor(nsIView *aView) { return aView->GetFrame(); }
/**
* GetScrollableFrameFor returns the scrollable frame for a scrolled frame

View File

@ -2301,7 +2301,7 @@ nsPresContext::IsRootContentDocument()
return true;
}
nsIFrame* f = static_cast<nsIFrame*>(view->GetClientData());
nsIFrame* f = view->GetFrame();
return (f && f->PresContext()->IsChrome());
}

View File

@ -72,7 +72,8 @@
#include "nsINameSpaceManager.h" // for Pref-related rule management (bugs 22963,20760,31816)
#include "nsIServiceManager.h"
#include "nsFrame.h"
#include "nsIViewManager.h"
#include "nsViewManager.h"
#include "nsView.h"
#include "nsCRTGlue.h"
#include "prlog.h"
#include "prmem.h"
@ -954,8 +955,8 @@ PresShell::PresShell()
sLiveShells->PutEntry(this);
}
NS_IMPL_ISUPPORTS8(PresShell, nsIPresShell, nsIDocumentObserver,
nsIViewObserver, nsISelectionController,
NS_IMPL_ISUPPORTS7(PresShell, nsIPresShell, nsIDocumentObserver,
nsISelectionController,
nsISelectionDisplay, nsIObserver, nsISupportsWeakReference,
nsIMutationObserver)
@ -1030,7 +1031,7 @@ PresShell::Init(nsIDocument* aDocument,
mFrameConstructor = new nsCSSFrameConstructor(mDocument, this);
// The document viewer owns both view manager and pres shell.
mViewManager->SetViewObserver(this);
mViewManager->SetPresShell(this);
// Bind the context to the presentation shell.
mPresContext = aPresContext;
@ -1236,7 +1237,7 @@ PresShell::Destroy()
if (mViewManager) {
// Clear the view manager's weak pointer back to |this| in case it
// was leaked.
mViewManager->SetViewObserver(nsnull);
mViewManager->SetPresShell(nsnull);
mViewManager = nsnull;
}
@ -3631,7 +3632,7 @@ nsresult PresShell::GetLinkLocation(nsIDOMNode* aNode, nsAString& aLocationStrin
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP_(void)
void
PresShell::DispatchSynthMouseMove(nsGUIEvent *aEvent,
bool aFlushOnHoverChange)
{
@ -3647,8 +3648,8 @@ PresShell::DispatchSynthMouseMove(nsGUIEvent *aEvent,
}
}
NS_IMETHODIMP_(void)
PresShell::ClearMouseCapture(nsIView* aView)
void
PresShell::ClearMouseCaptureOnView(nsIView* aView)
{
if (gCaptureInfo.mContent) {
if (aView) {
@ -5262,7 +5263,7 @@ static nsIView* FindFloatingViewContaining(nsIView* aView, nsPoint aPt)
// No need to look into descendants.
return nsnull;
nsIFrame* frame = static_cast<nsIFrame*>(aView->GetClientData());
nsIFrame* frame = aView->GetFrame();
if (frame) {
if (!frame->IsVisibleConsideringAncestors(nsIFrame::VISIBILITY_CROSS_CHROME_CONTENT_BOUNDARY) ||
!frame->PresContext()->PresShell()->IsActive()) {
@ -5299,7 +5300,7 @@ static nsIView* FindViewContaining(nsIView* aView, nsPoint aPt)
return nsnull;
}
nsIFrame* frame = static_cast<nsIFrame*>(aView->GetClientData());
nsIFrame* frame = aView->GetFrame();
if (frame) {
if (!frame->IsVisibleConsideringAncestors(nsIFrame::VISIBILITY_CROSS_CHROME_CONTENT_BOUNDARY) ||
!frame->PresContext()->PresShell()->IsActive()) {
@ -5374,7 +5375,7 @@ PresShell::ProcessSynthMouseMoveEvent(bool aFromScroll)
viewAPD = APD;
} else {
pointVM = view->GetViewManager();
nsIFrame* frame = static_cast<nsIFrame*>(view->GetClientData());
nsIFrame* frame = view->GetFrame();
NS_ASSERTION(frame, "floating views can't be anonymous");
viewAPD = frame->PresContext()->AppUnitsPerDevPixel();
refpoint = mMouseLocation.ConvertAppUnits(APD, viewAPD);
@ -5388,9 +5389,9 @@ PresShell::ProcessSynthMouseMoveEvent(bool aFromScroll)
event.time = PR_IntervalNow();
// XXX set event.isShift, event.isControl, event.isAlt, event.isMeta ?
nsCOMPtr<nsIViewObserver> observer = pointVM->GetViewObserver();
if (observer) {
observer->DispatchSynthMouseMove(&event, !aFromScroll);
nsCOMPtr<nsIPresShell> shell = pointVM->GetPresShell();
if (shell) {
shell->DispatchSynthMouseMove(&event, !aFromScroll);
}
if (!aFromScroll) {
@ -5398,7 +5399,7 @@ PresShell::ProcessSynthMouseMoveEvent(bool aFromScroll)
}
}
NS_IMETHODIMP
void
PresShell::Paint(nsIView* aViewToPaint,
nsIWidget* aWidgetToPaint,
const nsRegion& aDirtyRegion,
@ -5424,8 +5425,7 @@ PresShell::Paint(nsIView* aViewToPaint,
nsPresContext* presContext = GetPresContext();
AUTO_LAYOUT_PHASE_ENTRY_POINT(presContext, Paint);
nsIFrame* frame = aPaintDefaultBackground
? nsnull : static_cast<nsIFrame*>(aViewToPaint->GetClientData());
nsIFrame* frame = aPaintDefaultBackground ? nsnull : aViewToPaint->GetFrame();
bool isRetainingManager;
LayerManager* layerManager =
@ -5444,7 +5444,7 @@ PresShell::Paint(nsIView* aViewToPaint,
if (layerManager->EndEmptyTransaction()) {
frame->UpdatePaintCountForPaintedPresShells();
presContext->NotifyDidPaintForSubtree();
return NS_OK;
return;
}
}
@ -5473,7 +5473,7 @@ PresShell::Paint(nsIView* aViewToPaint,
frame->EndDeferringInvalidatesForDisplayRoot();
presContext->NotifyDidPaintForSubtree();
return NS_OK;
return;
}
nsRefPtr<ColorLayer> root = layerManager->CreateColorLayer();
@ -5489,7 +5489,6 @@ PresShell::Paint(nsIView* aViewToPaint,
layerManager->EndTransaction(NULL, NULL);
presContext->NotifyDidPaintForSubtree();
return NS_OK;
}
// static
@ -5645,16 +5644,9 @@ PresShell::RetargetEventToParent(nsGUIEvent* aEvent,
nsCOMPtr<nsIPresShell> kungFuDeathGrip(this);
nsCOMPtr<nsIPresShell> parentPresShell = GetParentPresShell();
NS_ENSURE_TRUE(parentPresShell, NS_ERROR_FAILURE);
nsCOMPtr<nsIViewObserver> parentViewObserver =
do_QueryInterface(parentPresShell);
if (!parentViewObserver) {
return NS_ERROR_FAILURE;
}
// Fake the event as though it'ss from the parent pres shell's root view.
nsIView *parentRootView = parentPresShell->GetViewManager()->GetRootView();
return parentViewObserver->HandleEvent(parentRootView, aEvent, true, aEventStatus);
// Fake the event as though it's from the parent pres shell's root frame.
return parentPresShell->HandleEvent(parentPresShell->GetRootFrame(), aEvent, true, aEventStatus);
}
void
@ -5726,13 +5718,13 @@ PresShell::RecordMouseLocation(nsGUIEvent* aEvent)
}
}
NS_IMETHODIMP
PresShell::HandleEvent(nsIView *aView,
nsresult
PresShell::HandleEvent(nsIFrame *aFrame,
nsGUIEvent* aEvent,
bool aDontRetargetEvents,
nsEventStatus* aEventStatus)
{
NS_ASSERTION(aView, "null view");
NS_ASSERTION(aFrame, "null frame");
if (mIsDestroying ||
(sDisableNonTestMouseEvents && NS_IS_MOUSE_EVENT(aEvent) &&
@ -5748,7 +5740,7 @@ PresShell::HandleEvent(nsIView *aView,
// Accessibility events come through OS requests and not from scripts,
// so it is safe to handle here
return HandleEventInternal(aEvent, aView, aEventStatus);
return HandleEventInternal(aEvent, aEventStatus);
}
#endif
@ -5789,17 +5781,12 @@ PresShell::HandleEvent(nsIView *aView,
}
if (retargetEventDoc) {
nsIPresShell* presShell = retargetEventDoc->GetShell();
nsCOMPtr<nsIPresShell> presShell = retargetEventDoc->GetShell();
if (!presShell)
return NS_OK;
if (presShell != this) {
nsCOMPtr<nsIViewObserver> viewObserver = do_QueryInterface(presShell);
if (!viewObserver)
return NS_ERROR_FAILURE;
nsIView* view = presShell->GetViewManager()->GetRootView();
return viewObserver->HandleEvent(view, aEvent, true, aEventStatus);
return presShell->HandleEvent(presShell->GetRootFrame(), aEvent, true, aEventStatus);
}
}
}
@ -5821,20 +5808,10 @@ PresShell::HandleEvent(nsIView *aView,
// Check for a system color change up front, since the frame type is
// irrelevant
if ((aEvent->message == NS_SYSCOLORCHANGED) && mPresContext) {
nsIViewManager* vm = GetViewManager();
if (vm) {
// Only dispatch system color change when the message originates from
// from the root views widget. This is necessary to prevent us from
// dispatching the SysColorChanged notification for each child window
// which may be redundant.
nsIView* view = vm->GetRootView();
if (view == aView) {
*aEventStatus = nsEventStatus_eConsumeDoDefault;
mPresContext->SysColorChanged();
return NS_OK;
}
}
if ((aEvent->message == NS_SYSCOLORCHANGED) && mPresContext &&
aFrame == FrameManager()->GetRootFrame()) {
*aEventStatus = nsEventStatus_eConsumeDoDefault;
mPresContext->SysColorChanged();
return NS_OK;
}
@ -5852,28 +5829,8 @@ PresShell::HandleEvent(nsIView *aView,
return NS_OK;
}
nsIFrame* frame = static_cast<nsIFrame*>(aView->GetClientData());
nsIFrame* frame = aFrame;
bool dispatchUsingCoordinates = NS_IsEventUsingCoordinates(aEvent);
// if this event has no frame, we need to retarget it at a parent
// view that has a frame.
if (!frame &&
(dispatchUsingCoordinates || NS_IS_KEY_EVENT(aEvent) ||
NS_IS_IME_RELATED_EVENT(aEvent) ||
NS_IS_NON_RETARGETED_PLUGIN_EVENT(aEvent) ||
aEvent->message == NS_PLUGIN_ACTIVATE ||
aEvent->message == NS_PLUGIN_FOCUS)) {
nsIView* targetView = aView;
while (targetView && !targetView->GetClientData()) {
targetView = targetView->GetParent();
}
if (targetView) {
aView = targetView;
frame = static_cast<nsIFrame*>(aView->GetClientData());
}
}
if (dispatchUsingCoordinates) {
NS_WARN_IF_FALSE(frame, "Nothing to handle this event!");
if (!frame)
@ -5982,7 +5939,6 @@ PresShell::HandleEvent(nsIView *aView,
nsIFrame* capturingFrame = capturingContent->GetPrimaryFrame();
if (capturingFrame) {
frame = capturingFrame;
aView = frame->GetClosestView();
}
}
@ -6026,8 +5982,7 @@ PresShell::HandleEvent(nsIView *aView,
nsContentUtils::ContentIsCrossDocDescendantOf(activeShell->GetDocument(),
shell->GetDocument())) {
shell = static_cast<PresShell*>(activeShell);
nsIView* activeShellRootView = shell->GetViewManager()->GetRootView();
frame = static_cast<nsIFrame*>(activeShellRootView->GetClientData());
frame = shell->GetRootFrame();
}
}
@ -6035,16 +5990,14 @@ PresShell::HandleEvent(nsIView *aView,
// Handle the event in the correct shell.
// Prevent deletion until we're done with event handling (bug 336582).
nsCOMPtr<nsIPresShell> kungFuDeathGrip(shell);
nsIView* subshellRootView = shell->GetViewManager()->GetRootView();
// We pass the subshell's root view as the view to start from. This is
// We pass the subshell's root frame as the frame to start from. This is
// the only correct alternative; if the event was captured then it
// must have been captured by us or some ancestor shell and we
// now ask the subshell to dispatch it normally.
return shell->HandlePositionedEvent(subshellRootView, frame,
aEvent, aEventStatus);
return shell->HandlePositionedEvent(frame, aEvent, aEventStatus);
}
return HandlePositionedEvent(aView, frame, aEvent, aEventStatus);
return HandlePositionedEvent(frame, aEvent, aEventStatus);
}
nsresult rv = NS_OK;
@ -6108,14 +6061,10 @@ PresShell::HandleEvent(nsIView *aView,
nsIDocument* targetDoc = eventTarget ? eventTarget->OwnerDoc() : nsnull;
if (targetDoc && targetDoc != mDocument) {
PopCurrentEventInfo();
nsIPresShell* shell = targetDoc->GetShell();
nsCOMPtr<nsIViewObserver> vo = do_QueryInterface(shell);
if (vo) {
nsIView* root = shell->GetViewManager()->GetRootView();
rv = static_cast<PresShell*>(shell)->HandleRetargetedEvent(aEvent,
root,
aEventStatus,
eventTarget);
nsCOMPtr<nsIPresShell> shell = targetDoc->GetShell();
if (shell) {
rv = static_cast<PresShell*>(shell.get())->
HandleRetargetedEvent(aEvent, aEventStatus, eventTarget);
}
return rv;
} else {
@ -6132,7 +6081,7 @@ PresShell::HandleEvent(nsIView *aView,
mCurrentEventFrame = frame;
}
if (GetCurrentEventFrame()) {
rv = HandleEventInternal(aEvent, aView, aEventStatus);
rv = HandleEventInternal(aEvent, aEventStatus);
}
#ifdef NS_DEBUG
@ -6145,7 +6094,7 @@ PresShell::HandleEvent(nsIView *aView,
if (!NS_EVENT_NEEDS_FRAME(aEvent)) {
mCurrentEventFrame = nsnull;
return HandleEventInternal(aEvent, aView, aEventStatus);
return HandleEventInternal(aEvent, aEventStatus);
}
else if (NS_IS_KEY_EVENT(aEvent)) {
// Keypress events in new blank tabs should not be completely thrown away.
@ -6176,8 +6125,7 @@ PresShell::ShowEventTargetDebug()
#endif
nsresult
PresShell::HandlePositionedEvent(nsIView* aView,
nsIFrame* aTargetFrame,
PresShell::HandlePositionedEvent(nsIFrame* aTargetFrame,
nsGUIEvent* aEvent,
nsEventStatus* aEventStatus)
{
@ -6219,7 +6167,7 @@ PresShell::HandlePositionedEvent(nsIView* aView,
}
if (GetCurrentEventFrame()) {
rv = HandleEventInternal(aEvent, aView, aEventStatus);
rv = HandleEventInternal(aEvent, aEventStatus);
}
#ifdef NS_DEBUG
@ -6234,7 +6182,7 @@ PresShell::HandleEventWithTarget(nsEvent* aEvent, nsIFrame* aFrame,
nsIContent* aContent, nsEventStatus* aStatus)
{
PushCurrentEventInfo(aFrame, aContent);
nsresult rv = HandleEventInternal(aEvent, nsnull, aStatus);
nsresult rv = HandleEventInternal(aEvent, aStatus);
PopCurrentEventInfo();
return rv;
}
@ -6323,8 +6271,7 @@ IsFullScreenAndRestrictedKeyEvent(nsIContent* aTarget, const nsEvent* aEvent)
}
nsresult
PresShell::HandleEventInternal(nsEvent* aEvent, nsIView *aView,
nsEventStatus* aStatus)
PresShell::HandleEventInternal(nsEvent* aEvent, nsEventStatus* aStatus)
{
NS_TIME_FUNCTION_MIN(1.0);
@ -6443,11 +6390,9 @@ PresShell::HandleEventInternal(nsEvent* aEvent, nsIView *aView,
// bug 329430
aEvent->target = nsnull;
nsWeakView weakView(aView);
// 1. Give event to event manager for pre event state changes and
// generation of synthetic events.
rv = manager->PreHandleEvent(mPresContext, aEvent, mCurrentEventFrame,
aStatus, aView);
rv = manager->PreHandleEvent(mPresContext, aEvent, mCurrentEventFrame, aStatus);
// 2. Give event to the DOM for third party and JS use.
if (GetCurrentEventFrame() && NS_SUCCEEDED(rv)) {
@ -6486,8 +6431,7 @@ PresShell::HandleEventInternal(nsEvent* aEvent, nsIView *aView,
// generation of synthetic events.
if (!mIsDestroying && NS_SUCCEEDED(rv)) {
rv = manager->PostHandleEvent(mPresContext, aEvent,
GetCurrentEventFrame(), aStatus,
weakView.GetView());
GetCurrentEventFrame(), aStatus);
}
}
@ -6896,19 +6840,13 @@ PresShell::GetCurrentItemAndPositionForElement(nsIDOMElement *aCurrentEl,
NS_IF_ADDREF(*aTargetToUse = focusedContent);
}
NS_IMETHODIMP
PresShell::ResizeReflow(nsIView *aView, nscoord aWidth, nscoord aHeight)
{
return ResizeReflow(aWidth, aHeight);
}
NS_IMETHODIMP_(bool)
bool
PresShell::ShouldIgnoreInvalidation()
{
return mPaintingSuppressed || !mIsActive;
}
NS_IMETHODIMP_(void)
void
PresShell::WillPaint(bool aWillSendDidPaint)
{
// Don't bother doing anything if some viewmanager in our tree is painting
@ -6936,7 +6874,7 @@ PresShell::WillPaint(bool aWillSendDidPaint)
FlushPendingNotifications(Flush_InterruptibleLayout);
}
NS_IMETHODIMP_(void)
void
PresShell::DidPaint()
{
if (mPaintingSuppressed || !mIsActive || !IsVisible()) {
@ -6952,7 +6890,7 @@ PresShell::DidPaint()
}
}
NS_IMETHODIMP_(bool)
bool
PresShell::IsVisible()
{
if (!mViewManager)
@ -6972,7 +6910,7 @@ PresShell::IsVisible()
if (!view)
return true;
nsIFrame* frame = static_cast<nsIFrame*>(view->GetClientData());
nsIFrame* frame = view->GetFrame();
if (!frame)
return true;
@ -8075,7 +8013,7 @@ PresShell::VerifyIncrementalReflow()
newSet.forget();
// Note that after we create the shell, we must make sure to destroy it
sh->SetVerifyReflowEnable(false); // turn off verify reflow while we're reflowing the test frame tree
vm->SetViewObserver((nsIViewObserver *)((PresShell*)sh.get()));
vm->SetPresShell(sh);
{
nsAutoCauseReflowNotifier crNotifier(this);
sh->InitialReflow(r.width, r.height);

View File

@ -60,7 +60,6 @@
#define nsPresShell_h_
#include "nsIPresShell.h"
#include "nsIViewObserver.h"
#include "nsStubDocumentObserver.h"
#include "nsISelectionController.h"
#include "nsIObserver.h"
@ -169,7 +168,7 @@ private:
class nsPresShellEventCB;
class nsAutoCauseReflowNotifier;
class PresShell : public nsIPresShell, public nsIViewObserver,
class PresShell : public nsIPresShell,
public nsStubDocumentObserver,
public nsISelectionController, public nsIObserver,
public nsSupportsWeakReference
@ -314,30 +313,25 @@ public:
//nsIViewObserver interface
NS_IMETHOD Paint(nsIView* aViewToPaint,
nsIWidget* aWidget,
const nsRegion& aDirtyRegion,
const nsIntRegion& aIntDirtyRegion,
bool aPaintDefaultBackground,
bool aWillSendDidPaint);
NS_IMETHOD HandleEvent(nsIView* aView,
nsGUIEvent* aEvent,
bool aDontRetargetEvents,
nsEventStatus* aEventStatus);
virtual void Paint(nsIView* aViewToPaint, nsIWidget* aWidget,
const nsRegion& aDirtyRegion, const nsIntRegion& aIntDirtyRegion,
bool aPaintDefaultBackground, bool aWillSendDidPaint);
virtual nsresult HandleEvent(nsIFrame* aFrame,
nsGUIEvent* aEvent,
bool aDontRetargetEvents,
nsEventStatus* aEventStatus);
virtual NS_HIDDEN_(nsresult) HandleDOMEventWithTarget(nsIContent* aTargetContent,
nsEvent* aEvent,
nsEventStatus* aStatus);
virtual NS_HIDDEN_(nsresult) HandleDOMEventWithTarget(nsIContent* aTargetContent,
nsIDOMEvent* aEvent,
nsEventStatus* aStatus);
NS_IMETHOD ResizeReflow(nsIView *aView, nscoord aWidth, nscoord aHeight);
NS_IMETHOD_(bool) ShouldIgnoreInvalidation();
NS_IMETHOD_(void) WillPaint(bool aWillSendDidPaint);
NS_IMETHOD_(void) DidPaint();
NS_IMETHOD_(void) DispatchSynthMouseMove(nsGUIEvent *aEvent,
bool aFlushOnHoverChange);
NS_IMETHOD_(void) ClearMouseCapture(nsIView* aView);
NS_IMETHOD_(bool) IsVisible();
virtual bool ShouldIgnoreInvalidation();
virtual void WillPaint(bool aWillSendDidPaint);
virtual void DidPaint();
virtual void DispatchSynthMouseMove(nsGUIEvent *aEvent, bool aFlushOnHoverChange);
virtual void ClearMouseCaptureOnView(nsIView* aView);
virtual bool IsVisible();
// caret handling
virtual NS_HIDDEN_(already_AddRefed<nsCaret>) GetCaret() const;
@ -605,14 +599,13 @@ protected:
}
}
nsresult HandleRetargetedEvent(nsEvent* aEvent, nsIView* aView,
nsEventStatus* aStatus, nsIContent* aTarget)
nsresult HandleRetargetedEvent(nsEvent* aEvent, nsEventStatus* aStatus, nsIContent* aTarget)
{
PushCurrentEventInfo(nsnull, nsnull);
mCurrentEventContent = aTarget;
nsresult rv = NS_OK;
if (GetCurrentEventFrame()) {
rv = HandleEventInternal(aEvent, aView, aStatus);
rv = HandleEventInternal(aEvent, aStatus);
}
PopCurrentEventInfo();
return rv;
@ -801,10 +794,8 @@ protected:
private:
void PushCurrentEventInfo(nsIFrame* aFrame, nsIContent* aContent);
void PopCurrentEventInfo();
nsresult HandleEventInternal(nsEvent* aEvent, nsIView* aView,
nsEventStatus *aStatus);
nsresult HandlePositionedEvent(nsIView* aView,
nsIFrame* aTargetFrame,
nsresult HandleEventInternal(nsEvent* aEvent, nsEventStatus *aStatus);
nsresult HandlePositionedEvent(nsIFrame* aTargetFrame,
nsGUIEvent* aEvent,
nsEventStatus* aEventStatus);
// This returns the focused DOM window under our top level window.

View File

@ -245,7 +245,7 @@ nsContainerFrame::DestroyFrom(nsIFrame* aDestructRoot)
{
// Prevent event dispatch during destruction
if (HasView()) {
GetView()->SetClientData(nsnull);
GetView()->SetFrame(nsnull);
}
// Delete the primary child list

View File

@ -575,7 +575,7 @@ nsFrame::DestroyFrom(nsIFrame* aDestructRoot)
if (view) {
// Break association between view and frame
view->SetClientData(nsnull);
view->SetFrame(nsnull);
// Destroy the view
view->Destroy();
@ -4049,7 +4049,7 @@ nsresult
nsIFrame::SetView(nsIView* aView)
{
if (aView) {
aView->SetClientData(this);
aView->SetFrame(this);
// Set a property on the frame
Properties().Set(ViewProperty(), aView);

View File

@ -199,6 +199,10 @@ public:
nsSVGClipPathFrame_id,
nsSVGContainerFrame_id,
nsSVGDisplayContainerFrame_id,
SVGFEContainerFrame_id,
SVGFEImageFrame_id,
SVGFELeafFrame_id,
SVGFEUnstyledLeafFrame_id,
nsSVGFilterFrame_id,
nsSVGForeignObjectFrame_id,
nsSVGGenericContainerFrame_id,
@ -208,7 +212,6 @@ public:
nsSVGGradientFrame_id,
nsSVGImageFrame_id,
nsSVGInnerSVGFrame_id,
nsSVGLeafFrame_id,
nsSVGLinearGradientFrame_id,
nsSVGMarkerFrame_id,
nsSVGMaskFrame_id,

View File

@ -107,7 +107,7 @@ GetDocumentFromView(nsIView* aView)
{
NS_PRECONDITION(aView, "");
nsIFrame* f = static_cast<nsIFrame*>(aView->GetClientData());
nsIFrame* f = aView->GetFrame();
nsIPresShell* ps = f ? f->PresContext()->PresShell() : nsnull;
return ps ? ps->GetDocument() : nsnull;
}
@ -250,9 +250,7 @@ nsSubDocumentFrame::GetSubdocumentRootFrame()
if (!mInnerView)
return nsnull;
nsIView* subdocView = mInnerView->GetFirstChild();
if (!subdocView)
return nsnull;
return static_cast<nsIFrame*>(subdocView->GetClientData());
return subdocView ? subdocView->GetFrame() : nsnull;
}
NS_IMETHODIMP
@ -287,9 +285,7 @@ nsSubDocumentFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
nsCOMPtr<nsIPresShell> presShell = nsnull;
nsIFrame* subdocRootFrame =
static_cast<nsIFrame*>(subdocView->GetClientData());
nsIFrame* subdocRootFrame = subdocView->GetFrame();
if (subdocRootFrame) {
presShell = subdocRootFrame->PresContext()->PresShell();
}
@ -303,7 +299,7 @@ nsSubDocumentFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
nsIView* nextView = subdocView->GetNextSibling();
nsIFrame* frame = nsnull;
if (nextView) {
frame = static_cast<nsIFrame*>(nextView->GetClientData());
frame = nextView->GetFrame();
}
if (frame) {
nsIPresShell* ps = frame->PresContext()->PresShell();

View File

@ -226,9 +226,11 @@ fails-if(Android) random-if(gtk2Widget) != text-language-01.xhtml text-language-
== text-layout-05.svg text-layout-05-ref.svg
== text-scale-01.svg text-scale-01-ref.svg
== text-stroke-scaling-01.svg text-stroke-scaling-01-ref.svg
== stroke-dasharray-and-pathLength-01.svg pass.svg
== stroke-linecap-square-w-zero-length-segs-01.svg pass.svg
== stroke-linecap-square-w-zero-length-segs-02.svg pass.svg
== textPath-01.svg textPath-01-ref.svg
== textPath-02.svg pass.svg
== text-style-01a.svg text-style-01-ref.svg
== text-style-01b.svg text-style-01-ref.svg
== text-style-01c.svg text-style-01-ref.svg

View File

@ -0,0 +1,20 @@
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/
-->
<svg xmlns="http://www.w3.org/2000/svg">
<title>Test stroke-dasharray with pathLength and scaling</title>
<rect width="100%" height="100%" fill="lime"/>
<!--
Here we set the 'pathLength' to twice the actual length of the path,
which should cause the stroke-dasharray values to be scaled down by one
half. Visually, this should effectively cancel out the 2x scaling along
the x-axis introduced by the 'transform' attribute.
-->
<path d="M0.5,10 L100.5,10" stroke="red" stroke-width="18" stroke-dasharray="18 22" pathLength="200" transform="scale(2,1)"/>
<rect x="1" y="1" width="18" height="18" fill="lime"/>
<rect x="41" y="1" width="18" height="18" fill="lime"/>
<rect x="81" y="1" width="18" height="18" fill="lime"/>
<rect x="121" y="1" width="18" height="18" fill="lime"/>
<rect x="161" y="1" width="18" height="18" fill="lime"/>
</svg>

After

Width:  |  Height:  |  Size: 995 B

View File

@ -0,0 +1,15 @@
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/
-->
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>Test effect on startOffset of a scale transform on a textPath's path</title>
<defs>
<path id="path" d="M20,20 C20,150 150,150 150,20" pathLength="100" transform="scale(2,1)" fill="none" stroke="black"/>
</defs>
<rect width="100%" height="100%" fill="lime"/>
<text y="50">
<textPath xlink:href="#path" font-size="20" fill="red" startOffset="50">FAIL</textPath>
</text>
<rect x="160" y="80" width="100" height="60" fill="lime"/>
</svg>

After

Width:  |  Height:  |  Size: 679 B

View File

@ -63,7 +63,10 @@ CPPSRCS = \
nsSVGImageFrame.cpp \
nsSVGInnerSVGFrame.cpp \
nsSVGIntegrationUtils.cpp \
nsSVGLeafFrame.cpp \
SVGFEContainerFrame.cpp \
SVGFEImageFrame.cpp \
SVGFELeafFrame.cpp \
SVGFEUnstyledLeafFrame.cpp \
nsSVGMarkerFrame.cpp \
nsSVGMaskFrame.cpp \
nsSVGOuterSVGFrame.cpp \

View File

@ -0,0 +1,137 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is the Mozilla SVG project.
*
* The Initial Developer of the Original Code is Robert Longson.
* Portions created by the Initial Developer are Copyright (C) 2011
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsContainerFrame.h"
#include "nsSVGEffects.h"
#include "nsSVGFilters.h"
typedef nsContainerFrame SVGFEContainerFrameBase;
/*
* This frame is used by filter primitive elements that
* have special child elements that provide parameters.
*/
class SVGFEContainerFrame : public SVGFEContainerFrameBase
{
friend nsIFrame*
NS_NewSVGFEContainerFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
protected:
SVGFEContainerFrame(nsStyleContext* aContext) : SVGFEContainerFrameBase(aContext) {}
public:
NS_DECL_FRAMEARENA_HELPERS
virtual bool IsFrameOfType(PRUint32 aFlags) const
{
return SVGFEContainerFrameBase::IsFrameOfType(
aFlags & ~(nsIFrame::eSVG | nsIFrame::eSVGContainer));
}
#ifdef DEBUG
NS_IMETHOD GetFrameName(nsAString& aResult) const
{
return MakeFrameName(NS_LITERAL_STRING("SVGFEContainer"), aResult);
}
#endif
virtual void DidSetStyleContext(nsStyleContext* aOldStyleContext);
#ifdef DEBUG
NS_IMETHOD Init(nsIContent* aContent,
nsIFrame* aParent,
nsIFrame* aPrevInFlow);
#endif
/**
* Get the "type" of the frame
*
* @see nsGkAtoms::svgFEContainerFrame
*/
virtual nsIAtom* GetType() const;
NS_IMETHOD AttributeChanged(PRInt32 aNameSpaceID,
nsIAtom* aAttribute,
PRInt32 aModType);
};
nsIFrame*
NS_NewSVGFEContainerFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
{
return new (aPresShell) SVGFEContainerFrame(aContext);
}
NS_IMPL_FRAMEARENA_HELPERS(SVGFEContainerFrame)
/* virtual */ void
SVGFEContainerFrame::DidSetStyleContext(nsStyleContext* aOldStyleContext)
{
SVGFEContainerFrameBase::DidSetStyleContext(aOldStyleContext);
nsSVGEffects::InvalidateRenderingObservers(this);
}
#ifdef DEBUG
NS_IMETHODIMP
SVGFEContainerFrame::Init(nsIContent* aContent,
nsIFrame* aParent,
nsIFrame* aPrevInFlow)
{
nsCOMPtr<nsIDOMSVGFilterPrimitiveStandardAttributes> elem = do_QueryInterface(aContent);
NS_ASSERTION(elem,
"Trying to construct an SVGFEContainerFrame for a "
"content element that doesn't support the right interfaces");
return SVGFEContainerFrameBase::Init(aContent, aParent, aPrevInFlow);
}
#endif /* DEBUG */
nsIAtom *
SVGFEContainerFrame::GetType() const
{
return nsGkAtoms::svgFEContainerFrame;
}
NS_IMETHODIMP
SVGFEContainerFrame::AttributeChanged(PRInt32 aNameSpaceID,
nsIAtom* aAttribute,
PRInt32 aModType)
{
nsSVGFE *element = static_cast<nsSVGFE*>(mContent);
if (element->AttributeAffectsRendering(aNameSpaceID, aAttribute)) {
nsSVGEffects::InvalidateRenderingObservers(this);
}
return SVGFEContainerFrameBase::AttributeChanged(aNameSpaceID,
aAttribute, aModType);
}

Some files were not shown because too many files have changed in this diff Show More