Merge cedar into mozilla-central

This commit is contained in:
Ehsan Akhgari 2011-03-25 14:21:07 -04:00
commit 395dbdf918
188 changed files with 2565 additions and 1985 deletions

View File

@ -3297,7 +3297,7 @@ nsAccessible::GetAttrValue(nsIAtom *aProperty, double *aValue)
return NS_OK;
PRInt32 error = NS_OK;
double value = attrValue.ToFloat(&error);
double value = attrValue.ToDouble(&error);
if (NS_SUCCEEDED(error))
*aValue = value;

View File

@ -362,7 +362,7 @@ nsXFormsRangeAccessible::GetMaximumValue(double *aMaximumValue)
NS_ENSURE_SUCCESS(rv, rv);
PRInt32 error = NS_OK;
*aMaximumValue = value.ToFloat(&error);
*aMaximumValue = value.ToDouble(&error);
return error;
}
@ -377,7 +377,7 @@ nsXFormsRangeAccessible::GetMinimumValue(double *aMinimumValue)
NS_ENSURE_SUCCESS(rv, rv);
PRInt32 error = NS_OK;
*aMinimumValue = value.ToFloat(&error);
*aMinimumValue = value.ToDouble(&error);
return error;
}
@ -392,7 +392,7 @@ nsXFormsRangeAccessible::GetMinimumIncrement(double *aMinimumIncrement)
NS_ENSURE_SUCCESS(rv, rv);
PRInt32 error = NS_OK;
*aMinimumIncrement = value.ToFloat(&error);
*aMinimumIncrement = value.ToDouble(&error);
return error;
}
@ -407,7 +407,7 @@ nsXFormsRangeAccessible::GetCurrentValue(double *aCurrentValue)
NS_ENSURE_SUCCESS(rv, rv);
PRInt32 error = NS_OK;
*aCurrentValue = value.ToFloat(&error);
*aCurrentValue = value.ToDouble(&error);
return error;
}

View File

@ -569,7 +569,7 @@ nsXULProgressMeterAccessible::GetMaximumValue(double *aMaximumValue)
nsAutoString value;
if (mContent->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::max, value)) {
PRInt32 result = NS_OK;
*aMaximumValue = value.ToFloat(&result);
*aMaximumValue = value.ToDouble(&result);
return result;
}
@ -614,7 +614,7 @@ nsXULProgressMeterAccessible::GetCurrentValue(double *aCurrentValue)
return NS_OK;
PRInt32 error = NS_OK;
double value = attrValue.ToFloat(&error);
double value = attrValue.ToDouble(&error);
if (NS_FAILED(error))
return NS_OK; // Zero value because of wrong markup.

View File

@ -272,7 +272,7 @@ nsXULSliderAccessible::GetSliderAttr(nsIAtom *aName, double *aValue)
return NS_OK;
PRInt32 error = NS_OK;
double value = attrValue.ToFloat(&error);
double value = attrValue.ToDouble(&error);
if (NS_SUCCEEDED(error))
*aValue = value;

View File

@ -2,6 +2,7 @@
<head>
<title>Text attributes tests</title>
<meta charset="utf-8" />
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
<script type="application/javascript"
@ -190,43 +191,43 @@
testDefaultTextAttrs(ID, defAttrs);
attrs = {"language": "ru"};
testTextAttrs(ID, 0, attrs, defAttrs, 0, 12);
testTextAttrs(ID, 0, attrs, defAttrs, 0, 6);
attrs = {};
testTextAttrs(ID, 12, attrs, defAttrs, 12, 13);
testTextAttrs(ID, 6, attrs, defAttrs, 6, 7);
tempElem = getNode(ID).firstChild.nextSibling.nextSibling.nextSibling;
gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
attrs = { "background-color": gComputedStyle.backgroundColor};
testTextAttrs(ID, 13, attrs, defAttrs, 13, 26);
testTextAttrs(ID, 13, attrs, defAttrs, 7, 20);
attrs = {};
testTextAttrs(ID, 26, attrs, defAttrs, 26, 27);
testTextAttrs(ID, 20, attrs, defAttrs, 20, 21);
attrs = {"language": "de"};
testTextAttrs(ID, 27, attrs, defAttrs, 27, 42);
testTextAttrs(ID, 21, attrs, defAttrs, 21, 36);
attrs = {};
testTextAttrs(ID, 42, attrs, defAttrs, 42, 50);
testTextAttrs(ID, 36, attrs, defAttrs, 36, 44);
attrs = {};
testTextAttrs(ID, 43, attrs, defAttrs, 42, 50);
testTextAttrs(ID, 37, attrs, defAttrs, 36, 44);
tempElem = tempElem.nextSibling.nextSibling.nextSibling.nextSibling.firstChild.nextSibling;
gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
attrs = {"color": gComputedStyle.color};
testTextAttrs(ID, 50, attrs, defAttrs, 50, 57);
testTextAttrs(ID, 44, attrs, defAttrs, 44, 51);
tempElem = tempElem.firstChild.nextSibling;
gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
attrs = {"font-weight": kBoldFontWeight,
"color": gComputedStyle.color};
testTextAttrs(ID, 57, attrs, defAttrs, 57, 61);
testTextAttrs(ID, 51, attrs, defAttrs, 51, 55);
tempElem = tempElem.parentNode;
gComputedStyle = document.defaultView.getComputedStyle(tempElem, "");
attrs = {"color": gComputedStyle.color};
testTextAttrs(ID, 61, attrs, defAttrs, 61, 68);
testTextAttrs(ID, 55, attrs, defAttrs, 55, 62);
//////////////////////////////////////////////////////////////////////////
// area9, different single style spans in styled paragraph

View File

@ -2,6 +2,7 @@
<html>
<head>
<title>nsIAccessibleText getText related function tests for html:input,html:div and html:textarea</title>
<meta charset="utf-8" />
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
<script type="application/javascript"
@ -65,7 +66,7 @@
testWords("div12", ["4,261.01"], kTodo);
// "カタカナ"
testWords("div13", ["カタカナ"], kTodo);
testWords("div13", ["カタカナ"], kOk);
// "Peter's car"
testWords("div14", ["Peter's", "car"], kTodo);

View File

@ -37,6 +37,10 @@
new invokerChecker(EVENT_FOCUS, getAccessible, this.linkNode)
];
this.unexpectedEventSeq = [
new invokerChecker(EVENT_REORDER, this.linkNode.parentNode)
];
this.invoke = function focusAnchor_invoke()
{
this.linkNode.focus();
@ -44,8 +48,8 @@
this.check = function focusAnchor_check(aEvent)
{
isnot(this.link, aEvent.accessible,
"Focus should be fired against new link accessible!");
is(this.link, aEvent.accessible,
"The link accessible shouldn't be recreated!");
}
this.getID = function focusAnchor_getID()
@ -63,6 +67,10 @@
new invokerChecker(EVENT_FOCUS, getAccessible, this.linkNode)
];
this.unexpectedEventSeq = [
new invokerChecker(EVENT_REORDER, this.linkNode.parentNode)
];
this.invoke = function tabAnchor_invoke()
{
synthesizeKey("VK_TAB", { shiftKey: false });
@ -70,8 +78,8 @@
this.check = function tabAnchor_check(aEvent)
{
isnot(this.link, aEvent.accessible,
"Focus should be fired against new link accessible!");
is(this.link, aEvent.accessible,
"The link accessible shouldn't be recreated!");
}
this.getID = function tabAnchor_getID()
@ -119,6 +127,11 @@
href="https://bugzilla.mozilla.org/show_bug.cgi?id=570275">
Mozilla Bug 570275
</a><br>
<a target="_blank"
title="Don't recreate frames for inlines with overflow style applied"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=606087">
Mozilla Bug 606087
</a><br>
<p id="display"></p>
<div id="content" style="display: none"></div>

View File

@ -1,5 +1,5 @@
function test() {
var startup_info = Components.classes["@mozilla.org/toolkit/app-startup;1"].getService(Components.interfaces.nsIAppStartup_MOZILLA_2_0).getStartupInfo();
var startup_info = Components.classes["@mozilla.org/toolkit/app-startup;1"].getService(Components.interfaces.nsIAppStartup).getStartupInfo();
// No .process info on mac
ok(startup_info.process <= startup_info.main, "process created before main is run " + uneval(startup_info));

View File

@ -186,7 +186,7 @@ libs-%:
@$(MAKE) -C ../../toolkit/locales libs-$* BOTH_MANIFESTS=1
@$(MAKE) -C ../../services/sync/locales AB_CD=$* XPI_NAME=locale-$* BOTH_MANIFESTS=1
@$(MAKE) -C ../../extensions/spellcheck/locales AB_CD=$* XPI_NAME=locale-$* BOTH_MANIFESTS=1
@$(MAKE) libs AB_CD=$* XPI_NAME=locale-$* PREF_DIR=$(PREF_DIR) BOTH_MANIFESTS=1
@$(MAKE) libs AB_CD=$* XPI_NAME=locale-$* PREF_DIR=defaults/pref BOTH_MANIFESTS=1
@$(MAKE) -C $(DEPTH)/$(MOZ_BRANDING_DIRECTORY)/locales AB_CD=$* XPI_NAME=locale-$* BOTH_MANIFESTS=1

View File

@ -328,6 +328,12 @@
-moz-image-region: rect(32px, 49px, 48px, 32px);
}
#minimize-button:-moz-locale-dir(rtl),
#restore-button:-moz-locale-dir(rtl),
#close-button:-moz-locale-dir(rtl) {
-moz-transform: scaleX(-1);
}
/* ::::: splitmenu highlight style that imitates Windows 7 start menu ::::: */
@media all and (-moz-windows-default-theme) {
.splitmenu-menuitem,

View File

@ -76,8 +76,8 @@ enum nsLinkState {
// IID for the nsIContent interface
#define NS_ICONTENT_IID \
{ 0x557a7d96, 0xb9cd, 0x4be2, \
{ 0xa3, 0xe7, 0x5f, 0x43, 0x6d, 0xfd, 0xd9, 0x4f } }
{ 0x8331ca9f, 0x8717, 0x4ab4, \
{ 0xad, 0x17, 0xb4, 0x9d, 0xdc, 0xe8, 0xb6, 0x77 } }
/**
* A node of content in a document's content model. This interface

View File

@ -1517,6 +1517,8 @@ public:
// state is unlocked/false.
virtual nsresult SetImageLockingState(PRBool aLocked) = 0;
virtual nsresult GetMozCurrentStateObject(nsIVariant** aResult) = 0;
protected:
~nsIDocument()
{

View File

@ -141,7 +141,7 @@ interface nsIContentViewManager : nsISupports
readonly attribute nsIContentView rootContentView;
};
[scriptable, uuid(50a67436-bb44-11df-8d9a-001e37d2764a)]
[scriptable, uuid(13c512d6-fba0-402a-9244-fe7941c43965)]
interface nsIFrameLoader : nsISupports
{
/**
@ -217,16 +217,23 @@ interface nsIFrameLoader : nsISupports
attribute boolean delayRemoteDialogs;
/**
* The default rendering mode is synchronous scrolling. In this
* mode, it's an error to try to set a target viewport.
*/
const unsigned long RENDER_MODE_DEFAULT = 0x00000000;
/**
* DEPRECATED. Please QI to nsIContentViewManager.
* FIXME 615368
* When asynchronous scrolling is enabled, a target viewport can be
* set to transform content pixels wrt its CSS viewport.
*
* NB: when async scrolling is enabled, it's the *user's*
* responsibility to update the target scroll offset. In effect,
* the platform hands over control of scroll offset to the user.
*/
void scrollViewportTo(in float xPx, in float yPx);
void scrollViewportBy(in float dxPx, in float dyPx);
void setViewportScale(in float xScale, in float yScale);
readonly attribute float viewportScrollX;
readonly attribute float viewportScrollY;
const unsigned long RENDER_MODE_ASYNC_SCROLL = 0x00000001;
attribute unsigned long renderMode;
};
native alreadyAddRefed_nsFrameLoader(already_AddRefed<nsFrameLoader>);
@ -252,25 +259,3 @@ interface nsIFrameLoaderOwner : nsISupports
*/
void swapFrameLoaders(in nsIFrameLoaderOwner aOtherOwner);
};
/** Please merge me into something else after 2.0 branches. */
[scriptable, uuid(e3e2d3f8-1397-4984-abb3-435c29a1ca55)]
interface nsIFrameLoader_MOZILLA_2_0_BRANCH : nsISupports
{
/**
* The default rendering mode is synchronous scrolling. In this
* mode, it's an error to try to set a target viewport.
*/
const unsigned long RENDER_MODE_DEFAULT = 0x00000000;
/**
* When asynchronous scrolling is enabled, a target viewport can be
* set to transform content pixels wrt its CSS viewport.
*
* NB: when async scrolling is enabled, it's the *user's*
* responsibility to update the target scroll offset. In effect,
* the platform hands over control of scroll offset to the user.
*/
const unsigned long RENDER_MODE_ASYNC_SCROLL = 0x00000001;
attribute unsigned long renderMode;
};

View File

@ -262,9 +262,9 @@ nsAttrValue::SetTo(const nsAttrValue& aOther)
break;
}
#endif
case eFloatValue:
case eDoubleValue:
{
cont->mFloatValue = otherCont->mFloatValue;
cont->mDoubleValue = otherCont->mDoubleValue;
break;
}
case eIntMarginValue:
@ -443,10 +443,10 @@ nsAttrValue::ToString(nsAString& aResult) const
break;
}
#endif
case eFloatValue:
case eDoubleValue:
{
aResult.Truncate();
aResult.AppendFloat(GetFloatValue());
aResult.AppendFloat(GetDoubleValue());
break;
}
default:
@ -607,10 +607,10 @@ nsAttrValue::HashValue() const
return NS_PTR_TO_INT32(cont->mSVGValue);
}
#endif
case eFloatValue:
case eDoubleValue:
{
// XXX this is crappy, but oh well
return cont->mFloatValue;
return cont->mDoubleValue;
}
case eIntMarginValue:
{
@ -706,9 +706,9 @@ nsAttrValue::Equals(const nsAttrValue& aOther) const
return thisCont->mSVGValue == otherCont->mSVGValue;
}
#endif
case eFloatValue:
case eDoubleValue:
{
return thisCont->mFloatValue == otherCont->mFloatValue;
return thisCont->mDoubleValue == otherCont->mDoubleValue;
}
case eIntMarginValue:
{
@ -1206,19 +1206,19 @@ nsAttrValue::ParseColor(const nsAString& aString)
return PR_FALSE;
}
PRBool nsAttrValue::ParseFloatValue(const nsAString& aString)
PRBool nsAttrValue::ParseDoubleValue(const nsAString& aString)
{
ResetIfSet();
PRInt32 ec;
float val = PromiseFlatString(aString).ToFloat(&ec);
double val = PromiseFlatString(aString).ToDouble(&ec);
if (NS_FAILED(ec)) {
return PR_FALSE;
}
if (EnsureEmptyMiscContainer()) {
MiscContainer* cont = GetMiscContainer();
cont->mFloatValue = val;
cont->mType = eFloatValue;
cont->mDoubleValue = val;
cont->mType = eDoubleValue;
nsAutoString serializedFloat;
serializedFloat.AppendFloat(val);
SetMiscAtomOrString(serializedFloat.Equals(aString) ? nsnull : &aString);

View File

@ -130,7 +130,7 @@ public:
#ifdef MOZ_SVG
,eSVGValue = 0x12
#endif
,eFloatValue = 0x13
,eDoubleValue = 0x13
,eIntMarginValue = 0x14
};
@ -165,7 +165,7 @@ public:
#ifdef MOZ_SVG
inline nsISVGValue* GetSVGValue() const;
#endif
inline float GetFloatValue() const;
inline double GetDoubleValue() const;
PRBool GetIntMarginValue(nsIntMargin& aMargin) const;
/**
@ -297,12 +297,12 @@ public:
PRBool ParseColor(const nsAString& aString);
/**
* Parse a string value into a float.
* Parse a string value into a double-precision floating point value.
*
* @param aString the string to parse
* @return whether the value could be parsed
*/
PRBool ParseFloatValue(const nsAString& aString);
PRBool ParseDoubleValue(const nsAString& aString);
/**
* Parse a lazy URI. This just sets up the storage for the URI; it
@ -346,7 +346,7 @@ private:
#ifdef MOZ_SVG
nsISVGValue* mSVGValue;
#endif
float mFloatValue;
double mDoubleValue;
nsIntMargin* mIntMargin;
};
};
@ -458,11 +458,11 @@ nsAttrValue::GetSVGValue() const
}
#endif
inline float
nsAttrValue::GetFloatValue() const
inline double
nsAttrValue::GetDoubleValue() const
{
NS_PRECONDITION(Type() == eFloatValue, "wrong type");
return GetMiscContainer()->mFloatValue;
NS_PRECONDITION(Type() == eDoubleValue, "wrong type");
return GetMiscContainer()->mDoubleValue;
}
inline PRBool

View File

@ -535,24 +535,6 @@ nsContentSink::ProcessHeaderData(nsIAtom* aHeader, const nsAString& aValue,
}
}
}
// Don't report "refresh" headers back to necko, since our document handles
// them
else if (aHeader != nsGkAtoms::refresh && mParser) {
// we also need to report back HTTP-EQUIV headers to the channel
// so that it can process things like pragma: no-cache or other
// cache-control headers. Ideally this should also be the way for
// cookies to be set! But we'll worry about that in the next
// iteration
nsCOMPtr<nsIChannel> channel;
if (NS_SUCCEEDED(mParser->GetChannel(getter_AddRefs(channel)))) {
nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(channel));
if (httpChannel) {
httpChannel->SetResponseHeader(nsAtomCString(aHeader),
NS_ConvertUTF16toUTF8(aValue),
PR_TRUE);
}
}
}
return rv;
}

View File

@ -6393,9 +6393,9 @@ LayerManagerForDocumentInternal(nsIDocument *aDoc, bool aRequirePersistent,
nsIWidget* widget = displayRoot->GetNearestWidget(nsnull);
if (widget) {
nsRefPtr<LayerManager> manager =
static_cast<nsIWidget_MOZILLA_2_0_BRANCH*>(widget)->
GetLayerManager(aRequirePersistent ? nsIWidget_MOZILLA_2_0_BRANCH::LAYER_MANAGER_PERSISTENT :
nsIWidget_MOZILLA_2_0_BRANCH::LAYER_MANAGER_CURRENT,
widget->
GetLayerManager(aRequirePersistent ? nsIWidget::LAYER_MANAGER_PERSISTENT :
nsIWidget::LAYER_MANAGER_CURRENT,
aAllowRetaining);
return manager.forget();
}

View File

@ -1735,7 +1735,6 @@ NS_INTERFACE_TABLE_HEAD(nsDocument)
NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIRadioGroupContainer_MOZILLA_2_0_BRANCH)
NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIMutationObserver)
NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIApplicationCacheContainer)
NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIDOMNSDocument_MOZILLA_2_0_BRANCH)
NS_OFFSET_AND_INTERFACE_TABLE_END
NS_OFFSET_AND_INTERFACE_TABLE_TO_MAP_SEGUE
NS_INTERFACE_MAP_ENTRIES_CYCLE_COLLECTION(nsDocument)
@ -8188,7 +8187,7 @@ nsIDocument::ScheduleBeforePaintEvent(nsIAnimationFrameListener* aListener)
}
NS_IMETHODIMP
nsresult
nsDocument::GetMozCurrentStateObject(nsIVariant** aState)
{
// Get the document's current state object. This is the object returned form

View File

@ -517,8 +517,7 @@ class nsDocument : public nsIDocument,
public nsIScriptObjectPrincipal,
public nsIRadioGroupContainer_MOZILLA_2_0_BRANCH,
public nsIApplicationCacheContainer,
public nsStubMutationObserver,
public nsIDOMNSDocument_MOZILLA_2_0_BRANCH
public nsStubMutationObserver
{
public:
typedef mozilla::dom::Element Element;
@ -814,7 +813,6 @@ public:
// nsIDOMNSDocument
NS_DECL_NSIDOMNSDOCUMENT
NS_DECL_NSIDOMNSDOCUMENT_MOZILLA_2_0_BRANCH
// nsIDOMDocumentEvent
NS_DECL_NSIDOMDOCUMENTEVENT
@ -993,6 +991,8 @@ public:
virtual NS_HIDDEN_(nsresult) RemoveImage(imgIRequest* aImage);
virtual NS_HIDDEN_(nsresult) SetImageLockingState(PRBool aLocked);
virtual nsresult GetMozCurrentStateObject(nsIVariant** aResult);
protected:
friend class nsNodeUtils;

View File

@ -310,7 +310,6 @@ NS_IMPL_CYCLE_COLLECTING_RELEASE_AMBIGUOUS(nsFrameLoader, nsIFrameLoader)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsFrameLoader)
NS_INTERFACE_MAP_ENTRY(nsIFrameLoader)
NS_INTERFACE_MAP_ENTRY(nsIFrameLoader_MOZILLA_2_0_BRANCH)
NS_INTERFACE_MAP_ENTRY(nsIContentViewManager)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIFrameLoader)
NS_INTERFACE_MAP_END
@ -1684,36 +1683,6 @@ nsFrameLoader::UpdateBaseWindowPositionAndSize(nsIFrame *aIFrame)
return NS_OK;
}
NS_IMETHODIMP
nsFrameLoader::ScrollViewportTo(float aXpx, float aYpx)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsFrameLoader::ScrollViewportBy(float aDXpx, float aDYpx)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsFrameLoader::SetViewportScale(float aXScale, float aYScale)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsFrameLoader::GetViewportScrollX(float* aViewportScrollX)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsFrameLoader::GetViewportScrollY(float* aViewportScrollY)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsFrameLoader::GetRenderMode(PRUint32* aRenderMode)
{

View File

@ -164,7 +164,6 @@ private:
class nsFrameLoader : public nsIFrameLoader,
public nsIFrameLoader_MOZILLA_2_0_BRANCH,
public nsIContentViewManager
{
friend class AutoResetInShow;
@ -196,7 +195,6 @@ public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsFrameLoader, nsIFrameLoader)
NS_DECL_NSIFRAMELOADER
NS_DECL_NSIFRAMELOADER_MOZILLA_2_0_BRANCH
NS_DECL_NSICONTENTVIEWMANAGER
NS_HIDDEN_(nsresult) CheckForRecursiveLoad(nsIURI* aURI);
nsresult ReallyStartLoading();

View File

@ -71,7 +71,7 @@
#include "nsIDocShell.h"
#include "nsIEditorDocShell.h"
#include "nsIEditor.h"
#include "nsIHTMLEditor_MOZILLA_2_0_BRANCH.h"
#include "nsIHTMLEditor.h"
static const PRInt32 kLongLineLen = 128;
@ -105,7 +105,7 @@ IsInvisibleBreak(nsIContent *aNode, nsIAtom *aTag) {
if (editorDocShell) {
nsCOMPtr<nsIEditor> editor;
editorDocShell->GetEditor(getter_AddRefs(editor));
nsCOMPtr<nsIHTMLEditor_MOZILLA_2_0_BRANCH> htmlEditor = do_QueryInterface(editor);
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(editor);
if (htmlEditor) {
PRBool isVisible = PR_FALSE;
nsCOMPtr<nsIDOMNode> domNode = do_QueryInterface(aNode);

View File

@ -0,0 +1,196 @@
/* -*- 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 Mozilla Corporation code.
*
* The Initial Developer of the Original Code is Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2011
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Robert O'Callahan <robert@ocallahan.org>
*
* 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 "CanvasImageCache.h"
#include "nsIImageLoadingContent.h"
#include "nsExpirationTracker.h"
#include "imgIRequest.h"
#include "gfxASurface.h"
#include "gfxPoint.h"
#include "nsIDOMElement.h"
#include "nsTHashtable.h"
#include "nsHTMLCanvasElement.h"
namespace mozilla {
struct ImageCacheKey {
ImageCacheKey(nsIDOMElement* aImage, nsHTMLCanvasElement* aCanvas)
: mImage(aImage), mCanvas(aCanvas) {}
nsIDOMElement* mImage;
nsHTMLCanvasElement* mCanvas;
};
struct ImageCacheEntryData {
ImageCacheEntryData(const ImageCacheEntryData& aOther)
: mImage(aOther.mImage)
, mILC(aOther.mILC)
, mCanvas(aOther.mCanvas)
, mRequest(aOther.mRequest)
, mSurface(aOther.mSurface)
, mSize(aOther.mSize)
{}
ImageCacheEntryData(const ImageCacheKey& aKey)
: mImage(aKey.mImage)
, mILC(nsnull)
, mCanvas(aKey.mCanvas)
{}
nsExpirationState* GetExpirationState() { return &mState; }
// Key
nsCOMPtr<nsIDOMElement> mImage;
nsIImageLoadingContent* mILC;
nsRefPtr<nsHTMLCanvasElement> mCanvas;
// Value
nsCOMPtr<imgIRequest> mRequest;
nsRefPtr<gfxASurface> mSurface;
gfxIntSize mSize;
nsExpirationState mState;
};
class ImageCacheEntry : public PLDHashEntryHdr {
public:
typedef ImageCacheKey KeyType;
typedef const ImageCacheKey* KeyTypePointer;
ImageCacheEntry(const KeyType *key) :
mData(new ImageCacheEntryData(*key)) {}
ImageCacheEntry(const ImageCacheEntry &toCopy) :
mData(new ImageCacheEntryData(*toCopy.mData)) {}
~ImageCacheEntry() {}
PRBool KeyEquals(KeyTypePointer key) const
{
return mData->mImage == key->mImage && mData->mCanvas == key->mCanvas;
}
static KeyTypePointer KeyToPointer(KeyType& key) { return &key; }
static PLDHashNumber HashKey(KeyTypePointer key)
{
return (NS_PTR_TO_INT32(key->mImage) ^ NS_PTR_TO_INT32(key->mCanvas)) >> 2;
}
enum { ALLOW_MEMMOVE = PR_TRUE };
nsAutoPtr<ImageCacheEntryData> mData;
};
class ImageCache : public nsExpirationTracker<ImageCacheEntryData,4> {
public:
// We use 3 generations of 1 second each to get a 2-3 seconds timeout.
enum { GENERATION_MS = 1000 };
ImageCache()
: nsExpirationTracker<ImageCacheEntryData,4>(GENERATION_MS)
{
mCache.Init();
}
~ImageCache() {
AgeAllGenerations();
}
virtual void NotifyExpired(ImageCacheEntryData* aObject)
{
RemoveObject(aObject);
// Deleting the entry will delete aObject since the entry owns aObject
mCache.RemoveEntry(ImageCacheKey(aObject->mImage, aObject->mCanvas));
}
nsTHashtable<ImageCacheEntry> mCache;
};
static ImageCache* gImageCache = nsnull;
void
CanvasImageCache::NotifyDrawImage(nsIDOMElement* aImage,
nsHTMLCanvasElement* aCanvas,
imgIRequest* aRequest,
gfxASurface* aSurface,
const gfxIntSize& aSize)
{
if (!gImageCache) {
gImageCache = new ImageCache();
}
ImageCacheEntry* entry = gImageCache->mCache.PutEntry(ImageCacheKey(aImage, aCanvas));
if (entry) {
if (entry->mData->mSurface) {
// We are overwriting an existing entry.
gImageCache->RemoveObject(entry->mData);
}
gImageCache->AddObject(entry->mData);
nsCOMPtr<nsIImageLoadingContent> ilc = do_QueryInterface(aImage);
if (ilc) {
ilc->GetRequest(nsIImageLoadingContent::CURRENT_REQUEST,
getter_AddRefs(entry->mData->mRequest));
}
entry->mData->mILC = ilc;
entry->mData->mSurface = aSurface;
entry->mData->mSize = aSize;
}
}
gfxASurface*
CanvasImageCache::Lookup(nsIDOMElement* aImage,
nsHTMLCanvasElement* aCanvas,
gfxIntSize* aSize)
{
if (!gImageCache)
return nsnull;
ImageCacheEntry* entry = gImageCache->mCache.GetEntry(ImageCacheKey(aImage, aCanvas));
if (!entry || !entry->mData->mILC)
return nsnull;
nsCOMPtr<imgIRequest> request;
entry->mData->mILC->GetRequest(nsIImageLoadingContent::CURRENT_REQUEST, getter_AddRefs(request));
if (request != entry->mData->mRequest)
return nsnull;
gImageCache->MarkUsed(entry->mData);
*aSize = entry->mData->mSize;
return entry->mData->mSurface;
}
void
CanvasImageCache::Shutdown()
{
delete gImageCache;
gImageCache = nsnull;
}
}

View File

@ -0,0 +1,77 @@
/* -*- 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 Mozilla Corporation code.
*
* The Initial Developer of the Original Code is Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2011
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Robert O'Callahan <robert@ocallahan.org>
*
* 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 ***** */
#ifndef CANVASIMAGECACHE_H_
#define CANVASIMAGECACHE_H_
class nsIDOMElement;
class nsHTMLCanvasElement;
class imgIRequest;
class gfxASurface;
struct gfxIntSize;
namespace mozilla {
class CanvasImageCache {
public:
/**
* Notify that image element aImage was (or is about to be) drawn to aCanvas
* using the first frame of aRequest's image. The data for the surface is
* in aSurface, and the image size is in aSize.
*/
static void NotifyDrawImage(nsIDOMElement* aImage,
nsHTMLCanvasElement* aCanvas,
imgIRequest* aRequest,
gfxASurface* aSurface,
const gfxIntSize& aSize);
/**
* Check whether aImage has recently been drawn into aCanvas. If we return
* a non-null surface, then the image was recently drawn into the canvas
* (with the same image request) and the returned surface contains the image
* data, and the image size will be returned in aSize.
*/
static gfxASurface* Lookup(nsIDOMElement* aImage,
nsHTMLCanvasElement* aCanvas,
gfxIntSize* aSize);
static void Shutdown();
};
}
#endif /* CANVASIMAGECACHE_H_ */

View File

@ -83,16 +83,13 @@ CanvasUtils::DoDrawImageSecurityCheck(nsHTMLCanvasElement *aCanvasElement,
if (aPrincipal == nsnull)
return;
nsCOMPtr<nsINode> elem = do_QueryInterface(static_cast<nsIDOMHTMLCanvasElement*>(aCanvasElement));
if (elem) { // XXXbz How could this actually be null?
PRBool subsumes;
nsresult rv =
elem->NodePrincipal()->Subsumes(aPrincipal, &subsumes);
if (NS_SUCCEEDED(rv) && subsumes) {
// This canvas has access to that image anyway
return;
}
PRBool subsumes;
nsresult rv =
aCanvasElement->NodePrincipal()->Subsumes(aPrincipal, &subsumes);
if (NS_SUCCEEDED(rv) && subsumes) {
// This canvas has access to that image anyway
return;
}
aCanvasElement->SetWriteOnly();

View File

@ -52,6 +52,7 @@ EXPORTS = \
$(NULL)
CPPSRCS = \
CanvasImageCache.cpp \
CanvasUtils.cpp \
nsCanvasRenderingContext2D.cpp \
$(NULL)

View File

@ -749,7 +749,6 @@ DOMCI_DATA(WebGLRenderingContext, WebGLContext)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(WebGLContext)
NS_INTERFACE_MAP_ENTRY(nsIDOMWebGLRenderingContext)
NS_INTERFACE_MAP_ENTRY(nsIDOMWebGLRenderingContext_MOZILLA_2_0_BRANCH)
NS_INTERFACE_MAP_ENTRY(nsICanvasRenderingContextInternal)
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMWebGLRenderingContext)

View File

@ -315,7 +315,6 @@ struct WebGLContextOptions {
class WebGLContext :
public nsIDOMWebGLRenderingContext,
public nsIDOMWebGLRenderingContext_MOZILLA_2_0_BRANCH,
public nsICanvasRenderingContextInternal,
public nsSupportsWeakReference
{
@ -328,7 +327,6 @@ public:
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(WebGLContext, nsIDOMWebGLRenderingContext)
NS_DECL_NSIDOMWEBGLRENDERINGCONTEXT
NS_DECL_NSIDOMWEBGLRENDERINGCONTEXT_MOZILLA_2_0_BRANCH
// nsICanvasRenderingContextInternal
NS_IMETHOD SetCanvasElement(nsHTMLCanvasElement* aParentCanvas);

View File

@ -111,18 +111,13 @@
#include "gfxUtils.h"
#include "nsFrameManager.h"
#include "nsFrameLoader.h"
#include "nsBidiPresUtils.h"
#include "Layers.h"
#include "CanvasUtils.h"
#include "nsIMemoryReporter.h"
#include "nsStyleUtil.h"
#include "CanvasImageCache.h"
#ifdef MOZ_IPC
# include <algorithm>
@ -416,8 +411,10 @@ public:
LayerManager *aManager);
void MarkContextClean();
NS_IMETHOD SetIsIPC(PRBool isIPC);
// this rect is in CSS pixels
// this rect is in canvas device space
NS_IMETHOD Redraw(const gfxRect &r);
// this rect is in mThebes's current user space
NS_IMETHOD RedrawUser(const gfxRect &r);
// nsISupports interface + CC
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
@ -434,6 +431,29 @@ public:
STYLE_MAX
};
class PathAutoSaveRestore
{
public:
PathAutoSaveRestore(nsCanvasRenderingContext2D* aCtx) :
mContext(aCtx->mThebes)
{
if (aCtx->mHasPath) {
mPath = mContext->CopyPath();
}
}
~PathAutoSaveRestore()
{
mContext->NewPath();
if (mPath) {
mContext->AppendPath(mPath);
}
}
private:
gfxContext *mContext;
nsRefPtr<gfxPath> mPath;
};
friend class PathAutoSaveRestore;
protected:
/**
@ -508,7 +528,17 @@ protected:
* Flag to avoid duplicate calls to InvalidateFrame. Set to true whenever
* Redraw is called, reset to false when Render is called.
*/
PRBool mIsEntireFrameInvalid;
PRPackedBool mIsEntireFrameInvalid;
/**
* When this is set, the first call to Redraw(gfxRect) should set
* mIsEntireFrameInvalid since we expect it will be followed by
* many more Redraw calls.
*/
PRPackedBool mPredictManyRedrawCalls;
/**
* This is set whenever there's a nonempty path set by the API user.
*/
PRPackedBool mHasPath;
/**
* Number of times we've invalidated before calling redraw
@ -608,7 +638,7 @@ protected:
* Draws the current path in the given style. Takes care of
* any shadow drawing and will use intermediate surfaces as needed.
*
* If dirtyRect is given, it will contain the device-space dirty
* If dirtyRect is given, it will contain the user-space dirty
* rectangle of the draw operation.
*/
nsresult DrawPath(Style style, gfxRect *dirtyRect = nsnull);
@ -826,7 +856,8 @@ nsCanvasRenderingContext2D::nsCanvasRenderingContext2D()
: mValid(PR_FALSE), mOpaque(PR_FALSE), mResetLayer(PR_TRUE)
, mIPC(PR_FALSE)
, mCanvasElement(nsnull)
, mSaveCount(0), mIsEntireFrameInvalid(PR_FALSE), mInvalidateCount(0)
, mSaveCount(0), mIsEntireFrameInvalid(PR_FALSE)
, mPredictManyRedrawCalls(PR_FALSE), mHasPath(PR_FALSE), mInvalidateCount(0)
, mLastStyle(STYLE_MAX), mStyleStack(20)
{
sNumLivingContexts++;
@ -856,6 +887,7 @@ nsCanvasRenderingContext2D::Reset()
mThebes = nsnull;
mValid = PR_FALSE;
mIsEntireFrameInvalid = PR_FALSE;
mPredictManyRedrawCalls = PR_FALSE;
return NS_OK;
}
@ -1019,6 +1051,10 @@ nsCanvasRenderingContext2D::ApplyStyle(Style aWhichStyle,
nsresult
nsCanvasRenderingContext2D::Redraw()
{
if (mIsEntireFrameInvalid)
return NS_OK;
mIsEntireFrameInvalid = PR_TRUE;
if (!mCanvasElement) {
NS_ASSERTION(mDocShell, "Redraw with no canvas element or docshell!");
return NS_OK;
@ -1028,11 +1064,6 @@ nsCanvasRenderingContext2D::Redraw()
nsSVGEffects::InvalidateDirectRenderingObservers(HTMLCanvasElement());
#endif
if (mIsEntireFrameInvalid)
return NS_OK;
mIsEntireFrameInvalid = PR_TRUE;
HTMLCanvasElement()->InvalidateFrame();
return NS_OK;
@ -1041,6 +1072,16 @@ nsCanvasRenderingContext2D::Redraw()
NS_IMETHODIMP
nsCanvasRenderingContext2D::Redraw(const gfxRect& r)
{
++mInvalidateCount;
if (mIsEntireFrameInvalid)
return NS_OK;
if (mPredictManyRedrawCalls ||
mInvalidateCount > kCanvasMaxInvalidateCount) {
return Redraw();
}
if (!mCanvasElement) {
NS_ASSERTION(mDocShell, "Redraw with no canvas element or docshell!");
return NS_OK;
@ -1050,17 +1091,22 @@ nsCanvasRenderingContext2D::Redraw(const gfxRect& r)
nsSVGEffects::InvalidateDirectRenderingObservers(HTMLCanvasElement());
#endif
if (mIsEntireFrameInvalid)
return NS_OK;
if (++mInvalidateCount > kCanvasMaxInvalidateCount)
return Redraw();
HTMLCanvasElement()->InvalidateFrame(&r);
return NS_OK;
}
NS_IMETHODIMP
nsCanvasRenderingContext2D::RedrawUser(const gfxRect& r)
{
if (mIsEntireFrameInvalid) {
++mInvalidateCount;
return NS_OK;
}
return Redraw(mThebes->UserToDevice(r));
}
NS_IMETHODIMP
nsCanvasRenderingContext2D::SetDimensions(PRInt32 width, PRInt32 height)
{
@ -1919,8 +1965,6 @@ nsCanvasRenderingContext2D::DrawPath(Style style, gfxRect *dirtyRect)
// just use the clip extents
*dirtyRect = mThebes->GetClipExtents();
}
*dirtyRect = mThebes->UserToDevice(*dirtyRect);
}
return NS_OK;
@ -1936,7 +1980,7 @@ nsCanvasRenderingContext2D::ClearRect(float x, float y, float w, float h)
if (!FloatValidate(x,y,w,h))
return NS_ERROR_DOM_SYNTAX_ERR;
gfxContextPathAutoSaveRestore pathSR(mThebes);
PathAutoSaveRestore pathSR(this);
gfxContextAutoSaveRestore autoSR(mThebes);
mThebes->SetOperator(gfxContext::OPERATOR_CLEAR);
@ -1944,8 +1988,7 @@ nsCanvasRenderingContext2D::ClearRect(float x, float y, float w, float h)
mThebes->Rectangle(gfxRect(x, y, w, h));
mThebes->Fill();
gfxRect dirty = mThebes->UserToDevice(mThebes->GetUserPathExtent());
return Redraw(dirty);
return RedrawUser(mThebes->GetUserPathExtent());
}
nsresult
@ -1954,7 +1997,7 @@ nsCanvasRenderingContext2D::DrawRect(const gfxRect& rect, Style style)
if (!FloatValidate(rect.pos.x, rect.pos.y, rect.size.width, rect.size.height))
return NS_ERROR_DOM_SYNTAX_ERR;
gfxContextPathAutoSaveRestore pathSR(mThebes);
PathAutoSaveRestore pathSR(this);
mThebes->NewPath();
mThebes->Rectangle(rect);
@ -1964,7 +2007,7 @@ nsCanvasRenderingContext2D::DrawRect(const gfxRect& rect, Style style)
if (NS_FAILED(rv))
return rv;
return Redraw(dirty);
return RedrawUser(dirty);
}
NS_IMETHODIMP
@ -1986,6 +2029,7 @@ nsCanvasRenderingContext2D::StrokeRect(float x, float y, float w, float h)
NS_IMETHODIMP
nsCanvasRenderingContext2D::BeginPath()
{
mHasPath = PR_FALSE;
mThebes->NewPath();
return NS_OK;
}
@ -2004,7 +2048,7 @@ nsCanvasRenderingContext2D::Fill()
nsresult rv = DrawPath(STYLE_FILL, &dirty);
if (NS_FAILED(rv))
return rv;
return Redraw(dirty);
return RedrawUser(dirty);
}
NS_IMETHODIMP
@ -2014,7 +2058,7 @@ nsCanvasRenderingContext2D::Stroke()
nsresult rv = DrawPath(STYLE_STROKE, &dirty);
if (NS_FAILED(rv))
return rv;
return Redraw(dirty);
return RedrawUser(dirty);
}
NS_IMETHODIMP
@ -2030,6 +2074,7 @@ nsCanvasRenderingContext2D::MoveTo(float x, float y)
if (!FloatValidate(x,y))
return NS_ERROR_DOM_SYNTAX_ERR;
mHasPath = PR_TRUE;
mThebes->MoveTo(gfxPoint(x, y));
return NS_OK;
}
@ -2040,6 +2085,7 @@ nsCanvasRenderingContext2D::LineTo(float x, float y)
if (!FloatValidate(x,y))
return NS_ERROR_DOM_SYNTAX_ERR;
mHasPath = PR_TRUE;
mThebes->LineTo(gfxPoint(x, y));
return NS_OK;
}
@ -2056,6 +2102,7 @@ nsCanvasRenderingContext2D::QuadraticCurveTo(float cpx, float cpy, float x, floa
gfxPoint p(x,y);
gfxPoint cp(cpx, cpy);
mHasPath = PR_TRUE;
mThebes->CurveTo((c+cp*2)/3.0, (p+cp*2)/3.0, p);
return NS_OK;
@ -2069,6 +2116,7 @@ nsCanvasRenderingContext2D::BezierCurveTo(float cp1x, float cp1y,
if (!FloatValidate(cp1x,cp1y,cp2x,cp2y,x,y))
return NS_ERROR_DOM_SYNTAX_ERR;
mHasPath = PR_TRUE;
mThebes->CurveTo(gfxPoint(cp1x, cp1y),
gfxPoint(cp2x, cp2y),
gfxPoint(x, y));
@ -2085,6 +2133,8 @@ nsCanvasRenderingContext2D::ArcTo(float x1, float y1, float x2, float y2, float
if (radius < 0)
return NS_ERROR_DOM_INDEX_SIZE_ERR;
mHasPath = PR_TRUE;
gfxPoint p0 = mThebes->CurrentPoint();
double dir, a2, b2, c2, cosx, sinx, d, anx, any, bnx, bny, x3, y3, x4, y4, cx, cy, angle0, angle1;
@ -2144,6 +2194,7 @@ nsCanvasRenderingContext2D::Arc(float x, float y, float r, float startAngle, flo
gfxPoint p(x,y);
mHasPath = PR_TRUE;
if (ccw)
mThebes->NegativeArc(p, r, startAngle, endAngle);
else
@ -2157,6 +2208,7 @@ nsCanvasRenderingContext2D::Rect(float x, float y, float w, float h)
if (!FloatValidate(x,y,w,h))
return NS_ERROR_DOM_SYNTAX_ERR;
mHasPath = PR_TRUE;
mThebes->Rectangle(gfxRect(x, y, w, h));
return NS_OK;
}
@ -2853,7 +2905,7 @@ nsCanvasRenderingContext2D::DrawOrMeasureText(const nsAString& aRawText,
mThebes->Paint(CurrentState().StyleIsColor(STYLE_FILL) ? 1.0 : CurrentState().globalAlpha);
if (aOp == nsCanvasRenderingContext2D::TEXT_DRAW_OPERATION_FILL && !doDrawShadow)
return Redraw(mThebes->UserToDevice(boundingBox));
return RedrawUser(boundingBox);
return Redraw();
}
@ -3315,48 +3367,50 @@ nsCanvasRenderingContext2D::DrawImage(nsIDOMElement *imgElt, float a1,
{
NS_ENSURE_ARG(imgElt);
nsresult rv;
gfxRect dirty(0.0, 0.0, 0.0, 0.0);
double sx,sy,sw,sh;
double dx,dy,dw,dh;
gfxMatrix matrix;
nsRefPtr<gfxPattern> pattern;
nsRefPtr<gfxPath> path;
gfxIntSize imgSize;
nsRefPtr<gfxASurface> imgsurf =
CanvasImageCache::Lookup(imgElt, HTMLCanvasElement(), &imgSize);
// The canvas spec says that drawImage should draw the first frame
// of animated images
PRUint32 sfeFlags = nsLayoutUtils::SFE_WANT_FIRST_FRAME;
nsLayoutUtils::SurfaceFromElementResult res =
nsLayoutUtils::SurfaceFromElement(imgElt, sfeFlags);
if (!res.mSurface) {
// Spec says to silently do nothing if the element is still loading.
return res.mIsStillLoading ? NS_OK : NS_ERROR_NOT_AVAILABLE;
}
if (!imgsurf) {
// The canvas spec says that drawImage should draw the first frame
// of animated images
PRUint32 sfeFlags = nsLayoutUtils::SFE_WANT_FIRST_FRAME;
nsLayoutUtils::SurfaceFromElementResult res =
nsLayoutUtils::SurfaceFromElement(imgElt, sfeFlags);
if (!res.mSurface) {
// Spec says to silently do nothing if the element is still loading.
return res.mIsStillLoading ? NS_OK : NS_ERROR_NOT_AVAILABLE;
}
#ifndef WINCE
// On non-CE, force a copy if we're using drawImage with our destination
// as a source to work around some Cairo self-copy semantics issues.
if (res.mSurface == mSurface) {
sfeFlags |= nsLayoutUtils::SFE_WANT_NEW_SURFACE;
res = nsLayoutUtils::SurfaceFromElement(imgElt, sfeFlags);
if (!res.mSurface)
return NS_ERROR_NOT_AVAILABLE;
}
// On non-CE, force a copy if we're using drawImage with our destination
// as a source to work around some Cairo self-copy semantics issues.
if (res.mSurface == mSurface) {
sfeFlags |= nsLayoutUtils::SFE_WANT_NEW_SURFACE;
res = nsLayoutUtils::SurfaceFromElement(imgElt, sfeFlags);
if (!res.mSurface)
return NS_ERROR_NOT_AVAILABLE;
}
#endif
nsRefPtr<gfxASurface> imgsurf = res.mSurface;
nsCOMPtr<nsIPrincipal> principal = res.mPrincipal;
gfxIntSize imgSize = res.mSize;
PRBool forceWriteOnly = res.mIsWriteOnly;
imgsurf = res.mSurface.forget();
imgSize = res.mSize;
if (mCanvasElement)
CanvasUtils::DoDrawImageSecurityCheck(HTMLCanvasElement(), principal, forceWriteOnly);
if (mCanvasElement) {
CanvasUtils::DoDrawImageSecurityCheck(HTMLCanvasElement(),
res.mPrincipal, res.mIsWriteOnly);
}
gfxContextPathAutoSaveRestore pathSR(mThebes, PR_FALSE);
rv = NS_OK;
if (res.mImageRequest) {
CanvasImageCache::NotifyDrawImage(imgElt, HTMLCanvasElement(),
res.mImageRequest, imgsurf, imgSize);
}
}
if (optional_argc == 0) {
dx = a1;
@ -3383,20 +3437,17 @@ nsCanvasRenderingContext2D::DrawImage(nsIDOMElement *imgElt, float a1,
dh = a8;
} else {
// XXX ERRMSG we need to report an error to developers here! (bug 329026)
rv = NS_ERROR_INVALID_ARG;
goto FINISH;
return NS_ERROR_INVALID_ARG;
}
if (dw == 0.0 || dh == 0.0) {
rv = NS_OK;
// not really failure, but nothing to do --
// and noone likes a divide-by-zero
goto FINISH;
return NS_OK;
}
if (!FloatValidate(sx, sy, sw, sh) || !FloatValidate(dx, dy, dw, dh)) {
rv = NS_ERROR_DOM_SYNTAX_ERR;
goto FINISH;
return NS_ERROR_DOM_SYNTAX_ERR;
}
// check args
@ -3406,8 +3457,7 @@ nsCanvasRenderingContext2D::DrawImage(nsIDOMElement *imgElt, float a1,
dw < 0.0 || dh < 0.0)
{
// XXX ERRMSG we need to report an error to developers here! (bug 329026)
rv = NS_ERROR_DOM_INDEX_SIZE_ERR;
goto FINISH;
return NS_ERROR_DOM_INDEX_SIZE_ERR;
}
matrix.Translate(gfxPoint(sx, sy));
@ -3434,8 +3484,7 @@ nsCanvasRenderingContext2D::DrawImage(nsIDOMElement *imgElt, float a1,
if (opaque && unscaled) {
bitblt(surf, sx, sy, sw, sh, dx, dy);
rv = NS_OK;
goto FINISH;
return NS_OK;
}
}
}
@ -3450,15 +3499,17 @@ nsCanvasRenderingContext2D::DrawImage(nsIDOMElement *imgElt, float a1,
else
pattern->SetFilter(gfxPattern::FILTER_NEAREST);
pathSR.Save();
PathAutoSaveRestore pathSR(this);
// Clear the surface if we need to simulate unbounded SOURCE operator
ClearSurfaceForUnboundedSource();
{
gfxContextAutoSaveRestore autoSR(mThebes);
gfxContextMatrixAutoSaveRestore autoMatrixSR(mThebes);
mThebes->Translate(gfxPoint(dx, dy));
mThebes->SetPattern(pattern);
DirtyAllStyles();
gfxRect clip(0, 0, dw, dh);
@ -3479,11 +3530,9 @@ nsCanvasRenderingContext2D::DrawImage(nsIDOMElement *imgElt, float a1,
}
PRBool doUseIntermediateSurface = NeedToUseIntermediateSurface();
mThebes->SetPattern(pattern);
DirtyAllStyles();
if (doUseIntermediateSurface) {
gfxContextAutoSaveRestore autoSR(mThebes);
// draw onto a pushed group
mThebes->PushGroup(gfxASurface::CONTENT_COLOR_ALPHA);
mThebes->Clip(clip);
@ -3501,18 +3550,17 @@ nsCanvasRenderingContext2D::DrawImage(nsIDOMElement *imgElt, float a1,
mThebes->Rectangle(clip);
mThebes->Fill();
} else {
gfxContextAutoSaveRestore autoSR(mThebes);
/* we need to use to clip instead of fill for globalAlpha */
mThebes->Clip(clip);
mThebes->Paint(CurrentState().globalAlpha);
}
dirty = mThebes->UserToDevice(clip);
RedrawUser(clip);
}
FINISH:
if (NS_SUCCEEDED(rv))
rv = Redraw(dirty);
return rv;
return NS_OK;
}
NS_IMETHODIMP
@ -3663,9 +3711,7 @@ nsCanvasRenderingContext2D::DrawWindow(nsIDOMWindow* aWindow, float aX, float aY
// note that aX and aY are coordinates in the document that
// we're drawing; aX and aY are drawn to 0,0 in current user
// space.
gfxRect damageRect = mThebes->UserToDevice(gfxRect(0, 0, aW, aH));
Redraw(damageRect);
RedrawUser(gfxRect(0, 0, aW, aH));
return rv;
}
@ -3996,7 +4042,7 @@ nsCanvasRenderingContext2D::PutImageData_explicit(PRInt32 x, PRInt32 y, PRUint32
}
}
gfxContextPathAutoSaveRestore pathSR(mThebes);
PathAutoSaveRestore pathSR(this);
gfxContextAutoSaveRestore autoSR(mThebes);
// ignore clipping region, as per spec
@ -4101,6 +4147,9 @@ nsCanvasRenderingContext2D::GetCanvasLayer(CanvasLayer *aOldLayer,
void
nsCanvasRenderingContext2D::MarkContextClean()
{
if (mInvalidateCount > 0) {
mPredictManyRedrawCalls = mInvalidateCount > kCanvasMaxInvalidateCount;
}
mIsEntireFrameInvalid = PR_FALSE;
mInvalidateCount = 0;
}

View File

@ -82,6 +82,7 @@ _TEST_FILES_0 = \
test_mozGetAsFile.html \
test_canvas_strokeStyle_getter.html \
test_bug613794.html \
test_drawImage_edge_cases.html \
$(NULL)
ifneq (1_Linux,$(MOZ_SUITE)_$(OS_ARCH))

View File

@ -25,8 +25,6 @@ c.width = c.height = 1;
c = c.getContext("2d");
SimpleTest.waitForExplicitFinish();
var threw = true;
try {
c.putImageData({ width: 1, height: 1, data: [ 0, 0, 0, 0] }, 0, 0);
@ -47,8 +45,6 @@ try {
is(threw, DOMException.TYPE_MISMATCH_ERR,
"Should throw type error when data is not an array");
SimpleTest.finish();
</script>
</pre>

View File

@ -19871,7 +19871,7 @@ function test_size_attributes_parse_negative() {
var canvas = document.getElementById('c639');
var ctx = canvas.getContext('2d');
todo(canvas.width == 300, "canvas.width == 300");
ok(canvas.width == 300, "canvas.width == 300");
}
@ -20084,7 +20084,7 @@ var canvas = document.getElementById('c650');
var ctx = canvas.getContext('2d');
canvas.setAttribute('width', '-100');
todo(canvas.width == 300, "canvas.width == 300");
ok(canvas.width == 300, "canvas.width == 300");
}

View File

@ -0,0 +1,43 @@
<!DOCTYPE HTML>
<html>
<head>
<script type="application/javascript" src="/MochiKit/packed.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body onload="doTest()">
<p id="display">
<canvas id="c" width="1" height="1"></canvas>
<img id="img" src="image_red.png">
</p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script type="application/javascript">
var c = document.getElementById("c");
var ctx = c.getContext("2d");
var img = document.getElementById("img");
SimpleTest.waitForExplicitFinish();
function doTest() {
ctx.drawImage(img, 0, 0);
img.src = "image_green-1x1.png";
img.onload = function() {
ctx.drawImage(img, 0, 0);
var data = ctx.getImageData(0, 0, 1, 1).data;
is(data[0], 0, "Red channel should be 0");
is(data[1], 255, "Green channel should be 1.0");
is(data[2], 0, "Blue channel should be 0")
is(data[3], 255, "Alpha channel should be opaque");
SimpleTest.finish();
}
}
</script>
</pre>
</body>
</html>

View File

@ -50,6 +50,7 @@
#include "nsINode.h"
#include "nsPIDOMWindow.h"
#include "nsDOMPopStateEvent.h"
#include "nsFrameLoader.h"
#define NS_TARGET_CHAIN_FORCE_CONTENT_DISPATCH (1 << 0)
#define NS_TARGET_CHAIN_WANTS_WILL_HANDLE_EVENT (1 << 1)
@ -500,11 +501,22 @@ nsEventDispatcher::Dispatch(nsISupports* aTarget,
if (!nsContentUtils::IsChromeDoc(doc)) {
nsPIDOMWindow* win = doc ? doc->GetInnerWindow() : nsnull;
// If we can't dispatch the event to chrome, do nothing.
NS_ENSURE_TRUE(win && win->GetChromeEventHandler(), NS_OK);
nsPIDOMEventTarget* piTarget = win ? win->GetChromeEventHandler() : nsnull;
NS_ENSURE_TRUE(piTarget, NS_OK);
nsCOMPtr<nsIFrameLoaderOwner> flo = do_QueryInterface(piTarget);
if (flo) {
nsRefPtr<nsFrameLoader> fl = flo->GetFrameLoader();
if (fl) {
nsPIDOMEventTarget* t = fl->GetTabChildGlobalAsEventTarget();
piTarget = t ? t : piTarget;
}
}
// Set the target to be the original dispatch target,
aEvent->target = target;
// but use chrome event handler for event target chain.
target = do_QueryInterface(win->GetChromeEventHandler());
// but use chrome event handler or TabChildGlobal for event target chain.
target = piTarget;
}
}

View File

@ -166,9 +166,8 @@ nsIMEStateManager::OnChangeFocus(nsPresContext* aPresContext,
// the enabled state isn't changing, we should do nothing.
return NS_OK;
}
nsIWidget_MOZILLA_2_0_BRANCH* widget2 = static_cast<nsIWidget_MOZILLA_2_0_BRANCH*>(widget.get());
IMEContext context;
if (!widget2 || NS_FAILED(widget2->GetInputMode(context))) {
if (!widget || NS_FAILED(widget->GetInputMode(context))) {
// this platform doesn't support IME controlling
return NS_OK;
}
@ -223,9 +222,8 @@ nsIMEStateManager::UpdateIMEState(PRUint32 aNewIMEState, nsIContent* aContent)
}
// Don't update IME state when enabled state isn't actually changed.
nsIWidget_MOZILLA_2_0_BRANCH* widget2 = static_cast<nsIWidget_MOZILLA_2_0_BRANCH*>(widget.get());
IMEContext context;
nsresult rv = widget2->GetInputMode(context);
nsresult rv = widget->GetInputMode(context);
if (NS_FAILED(rv)) {
return; // This platform doesn't support controling the IME state.
}
@ -294,8 +292,7 @@ nsIMEStateManager::SetIMEState(PRUint32 aState,
nsIWidget* aWidget)
{
if (aState & nsIContent::IME_STATUS_MASK_ENABLED) {
nsIWidget_MOZILLA_2_0_BRANCH* widget2 = static_cast<nsIWidget_MOZILLA_2_0_BRANCH*>(aWidget);
if (!widget2)
if (!aWidget)
return;
PRUint32 state = nsContentUtils::GetWidgetStatusFromIMEStatus(aState);
@ -330,7 +327,7 @@ nsIMEStateManager::SetIMEState(PRUint32 aState,
}
}
widget2->SetInputMode(context);
aWidget->SetInputMode(context);
nsContentUtils::AddScriptRunner(new IMEEnabledStateChangedEvent(state));
}

View File

@ -61,6 +61,11 @@ function fireDrop(element, shouldAllowDrop, shouldAllowOnlyChromeDrop) {
ok(!ds.getCurrentSession(), "There shouldn't be a drag session anymore!");
}
var chromeGotEvent = false;
function chromeListener(e) {
chromeGotEvent = true;
}
function runTests()
{
var targetHandling = document.getElementById("handling_target");
@ -73,9 +78,11 @@ function runTests()
gGotHandlingDrop = false;
gGotNotHandlingDrop = false;
SpecialPowers.addChromeEventListener("drop", chromeListener, true, false);
var targetNotHandling = document.getElementById("nothandling_target");
fireDrop(targetNotHandling, true, true);
SpecialPowers.removeChromeEventListener("drop", chromeListener, true);
ok(chromeGotEvent, "Chrome should have got drop event!");
is(gGotHandlingDrop, false, "Didn't get drop on accepting element (2)");
is(gGotNotHandlingDrop, false, "Didn't get drop on unaccepting element (2)");

View File

@ -2177,11 +2177,11 @@ nsGenericHTMLElement::SetUnsignedIntAttr(nsIAtom* aAttr, PRUint32 aValue)
}
nsresult
nsGenericHTMLElement::GetFloatAttr(nsIAtom* aAttr, float aDefault, float* aResult)
nsGenericHTMLElement::GetDoubleAttr(nsIAtom* aAttr, double aDefault, double* aResult)
{
const nsAttrValue* attrVal = mAttrsAndChildren.GetAttr(aAttr);
if (attrVal && attrVal->Type() == nsAttrValue::eFloatValue) {
*aResult = attrVal->GetFloatValue();
if (attrVal && attrVal->Type() == nsAttrValue::eDoubleValue) {
*aResult = attrVal->GetDoubleValue();
}
else {
*aResult = aDefault;
@ -2190,7 +2190,7 @@ nsGenericHTMLElement::GetFloatAttr(nsIAtom* aAttr, float aDefault, float* aResul
}
nsresult
nsGenericHTMLElement::SetFloatAttr(nsIAtom* aAttr, float aValue)
nsGenericHTMLElement::SetDoubleAttr(nsIAtom* aAttr, double aValue)
{
nsAutoString value;
value.AppendFloat(aValue);

View File

@ -686,26 +686,26 @@ protected:
NS_HIDDEN_(nsresult) SetUnsignedIntAttr(nsIAtom* aAttr, PRUint32 aValue);
/**
* Helper method for NS_IMPL_FLOAT_ATTR macro.
* Gets the float-value of an attribute, returns specified default value
* if the attribute isn't set or isn't set to a float. Only works for
* Helper method for NS_IMPL_DOUBLE_ATTR macro.
* Gets the double-value of an attribute, returns specified default value
* if the attribute isn't set or isn't set to a double. Only works for
* attributes in null namespace.
*
* @param aAttr name of attribute.
* @param aDefault default-value to return if attribute isn't set.
* @param aResult result value [out]
*/
NS_HIDDEN_(nsresult) GetFloatAttr(nsIAtom* aAttr, float aDefault, float* aValue);
NS_HIDDEN_(nsresult) GetDoubleAttr(nsIAtom* aAttr, double aDefault, double* aValue);
/**
* Helper method for NS_IMPL_FLOAT_ATTR macro.
* Sets value of attribute to specified float. Only works for attributes
* Helper method for NS_IMPL_DOUBLE_ATTR macro.
* Sets value of attribute to specified double. Only works for attributes
* in null namespace.
*
* @param aAttr name of attribute.
* @param aValue Float value of attribute.
* @param aValue Double value of attribute.
*/
NS_HIDDEN_(nsresult) SetFloatAttr(nsIAtom* aAttr, float aValue);
NS_HIDDEN_(nsresult) SetDoubleAttr(nsIAtom* aAttr, double aValue);
/**
* Helper for GetURIAttr and GetHrefURIForAnchors which returns an
@ -1189,23 +1189,23 @@ protected:
}
/**
* A macro to implement the getter and setter for a given float
* valued content property. The method uses the generic GetAttr and
* SetAttr methods.
* A macro to implement the getter and setter for a given double-precision
* floating point valued content property. The method uses GetDoubleAttr and
* SetDoubleAttr methods.
*/
#define NS_IMPL_FLOAT_ATTR(_class, _method, _atom) \
NS_IMPL_FLOAT_ATTR_DEFAULT_VALUE(_class, _method, _atom, 0.0)
#define NS_IMPL_DOUBLE_ATTR(_class, _method, _atom) \
NS_IMPL_DOUBLE_ATTR_DEFAULT_VALUE(_class, _method, _atom, 0.0)
#define NS_IMPL_FLOAT_ATTR_DEFAULT_VALUE(_class, _method, _atom, _default) \
#define NS_IMPL_DOUBLE_ATTR_DEFAULT_VALUE(_class, _method, _atom, _default) \
NS_IMETHODIMP \
_class::Get##_method(float* aValue) \
_class::Get##_method(double* aValue) \
{ \
return GetFloatAttr(nsGkAtoms::_atom, _default, aValue); \
return GetDoubleAttr(nsGkAtoms::_atom, _default, aValue); \
} \
NS_IMETHODIMP \
_class::Set##_method(float aValue) \
_class::Set##_method(double aValue) \
{ \
return SetFloatAttr(nsGkAtoms::_atom, aValue); \
return SetDoubleAttr(nsGkAtoms::_atom, aValue); \
}
/**

View File

@ -126,8 +126,8 @@ nsHTMLCanvasElement::GetWidthHeight()
return size;
}
NS_IMPL_INT_ATTR_DEFAULT_VALUE(nsHTMLCanvasElement, Width, width, DEFAULT_CANVAS_WIDTH)
NS_IMPL_INT_ATTR_DEFAULT_VALUE(nsHTMLCanvasElement, Height, height, DEFAULT_CANVAS_HEIGHT)
NS_IMPL_UINT_ATTR_DEFAULT_VALUE(nsHTMLCanvasElement, Width, width, DEFAULT_CANVAS_WIDTH)
NS_IMPL_UINT_ATTR_DEFAULT_VALUE(nsHTMLCanvasElement, Height, height, DEFAULT_CANVAS_HEIGHT)
NS_IMPL_BOOL_ATTR(nsHTMLCanvasElement, MozOpaque, moz_opaque)
nsresult
@ -190,7 +190,7 @@ nsHTMLCanvasElement::ParseAttribute(PRInt32 aNamespaceID,
{
if (aNamespaceID == kNameSpaceID_None &&
(aAttribute == nsGkAtoms::width || aAttribute == nsGkAtoms::height)) {
return aResult.ParseIntWithBounds(aValue, 0);
return aResult.ParseNonNegativeIntValue(aValue);
}
return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,

View File

@ -1426,7 +1426,7 @@ PRBool nsHTMLMediaElement::ParseAttribute(PRInt32 aNamespaceID,
|| aAttribute == nsGkAtoms::loopend
|| aAttribute == nsGkAtoms::start
|| aAttribute == nsGkAtoms::end) {
return aResult.ParseFloatValue(aValue);
return aResult.ParseDoubleValue(aValue);
}
else if (ParseImageAttribute(aAttribute, aValue, aResult)) {
return PR_TRUE;

View File

@ -187,9 +187,8 @@ DOMCI_NODE_DATA(HTMLSelectElement, nsHTMLSelectElement)
// QueryInterface implementation for nsHTMLSelectElement
NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(nsHTMLSelectElement)
NS_HTML_CONTENT_INTERFACE_TABLE4(nsHTMLSelectElement,
NS_HTML_CONTENT_INTERFACE_TABLE3(nsHTMLSelectElement,
nsIDOMHTMLSelectElement,
nsIDOMHTMLSelectElement_Mozilla_2_0_Branch,
nsISelectElement,
nsIConstraintValidation)
NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLSelectElement,

View File

@ -237,7 +237,7 @@ private:
* Implementation of &lt;select&gt;
*/
class nsHTMLSelectElement : public nsGenericHTMLFormElement,
public nsIDOMHTMLSelectElement_Mozilla_2_0_Branch,
public nsIDOMHTMLSelectElement,
public nsISelectElement,
public nsIConstraintValidation
{
@ -263,9 +263,6 @@ public:
// nsIDOMHTMLSelectElement
NS_DECL_NSIDOMHTMLSELECTELEMENT
// nsIDOMHTMLSelectElement_Mozilla_2_0_Branch
NS_DECL_NSIDOMHTMLSELECTELEMENT_MOZILLA_2_0_BRANCH
// nsIContent
virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor);
virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor);

View File

@ -256,6 +256,8 @@ _TEST_FILES = \
test_bug622597.html \
test_bug636336.html \
test_bug630889.html \
test_bug610212.html \
test_bug633058.html \
$(NULL)
libs:: $(_TEST_FILES)

View File

@ -219,7 +219,7 @@ HTML_TAG("s", ""); // HTMLElement
HTML_TAG("samp", ""); // HTMLElement
HTML_TAG("script", "Script", [], [ "nsIScriptLoaderObserver" ]);
HTML_TAG("section", "") // HTMLElement
HTML_TAG("select", "Select", ["nsIDOMHTMLSelectElement_Mozilla_2_0_Branch"]);
HTML_TAG("select", "Select", ["nsIDOMHTMLSelectElement"]);
HTML_TAG("small", ""); // HTMLElement
HTML_TAG("span", "Span");
HTML_TAG("strike", ""); // HTMLElement

View File

@ -0,0 +1,31 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=610212
-->
<head>
<title>Test for Bug 610212</title>
<script type="application/javascript" src="/MochiKit/packed.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="reflect.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=610212">Mozilla Bug 610212</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 610212 **/
var canvas = document.createElement('canvas');
reflectUnsignedInt(canvas, "width", false, 300);
reflectUnsignedInt(canvas, "height", false, 150);
</script>
</pre>
</body>
</html>

View File

@ -0,0 +1,66 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=633058
-->
<head>
<title>Test for Bug 633058</title>
<script type="application/javascript" src="/MochiKit/packed.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=633058">Mozilla Bug 633058</a>
<p id="display"></p>
<div id="content">
<input>
</div>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 633058 **/
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(function() {
var nbExpectedKeyPress = 8;
var inputGotKeyPress = 0;
var divGotKeyPress = 0;
var input = document.getElementsByTagName('input')[0];
var content = document.getElementById('content');
content.addEventListener('keypress', function() {
divGotKeyPress++;
if (divGotKeyPress == nbExpectedKeyPress) {
is(inputGotKeyPress, nbExpectedKeyPress, "input got all keypress events");
is(divGotKeyPress, nbExpectedKeyPress, "div got all keypress events");
SimpleTest.finish();
}
}, false);
input.addEventListener('keypress', function() {
inputGotKeyPress++;
}, false);
input.addEventListener('focus', function() {
input.removeEventListener('focus', arguments.callee, false);
synthesizeKey('VK_UP', {});
synthesizeKey('VK_LEFT', {});
synthesizeKey('VK_RIGHT', {});
synthesizeKey('VK_DOWN', {});
synthesizeKey('VK_BACK_SPACE', {});
synthesizeKey('VK_DELETE', {});
synthesizeKey('VK_ESCAPE', {});
synthesizeKey('VK_RETURN', {});
}, false);
input.focus();
});
</script>
</pre>
</body>
</html>

View File

@ -414,6 +414,7 @@ private:
class nsBuiltinDecoderReader : public nsRunnable {
public:
typedef mozilla::Monitor Monitor;
typedef mozilla::MonitorAutoEnter MonitorAutoEnter;
nsBuiltinDecoderReader(nsBuiltinDecoder* aDecoder);
~nsBuiltinDecoderReader();
@ -443,7 +444,7 @@ public:
// Read header data for all bitstreams in the file. Fills mInfo with
// the data required to present the media. Returns NS_OK on success,
// or NS_ERROR_FAILURE on failure.
virtual nsresult ReadMetadata() = 0;
virtual nsresult ReadMetadata(nsVideoInfo* aInfo) = 0;
// Stores the presentation time of the first frame/sample we'd be
// able to play if we started playback at aOffset, and returns the
@ -463,11 +464,6 @@ public:
PRInt64 aEndTime,
PRInt64 aCurrentTime) = 0;
// Gets presentation info required for playback.
const nsVideoInfo& GetInfo() {
return mInfo;
}
// Queue of audio samples. This queue is threadsafe.
MediaQueue<SoundData> mAudioQueue;
@ -520,7 +516,8 @@ protected:
// Used to seek to media start time.
PRInt64 mDataOffset;
// Stores presentation info required for playback.
// Stores presentation info required for playback. The reader's monitor
// must be held when accessing this.
nsVideoInfo mInfo;
};

View File

@ -417,8 +417,8 @@ void nsBuiltinDecoderStateMachine::AudioLoop()
MonitorAutoEnter mon(mDecoder->GetMonitor());
mAudioCompleted = PR_FALSE;
audioStartTime = mAudioStartTime;
channels = mReader->GetInfo().mAudioChannels;
rate = mReader->GetInfo().mAudioRate;
channels = mInfo.mAudioChannels;
rate = mInfo.mAudioRate;
NS_ASSERTION(audioStartTime != -1, "Should have audio start time by now");
}
while (1) {
@ -712,20 +712,22 @@ void nsBuiltinDecoderStateMachine::StartPlayback()
LOG(PR_LOG_DEBUG, ("%p StartPlayback", mDecoder));
mDecoder->mPlaybackStatistics.Start(TimeStamp::Now());
if (HasAudio()) {
MonitorAutoExit exitMon(mDecoder->GetMonitor());
MonitorAutoEnter audioMon(mAudioMonitor);
if (mAudioStream) {
// We have an audiostream, so it must have been paused the last time
// StopPlayback() was called.
mAudioStream->Resume();
} else {
// No audiostream, create one.
const nsVideoInfo& info = mReader->GetInfo();
mAudioStream = nsAudioStream::AllocateStream();
mAudioStream->Init(info.mAudioChannels,
info.mAudioRate,
MOZ_SOUND_DATA_FORMAT);
mAudioStream->SetVolume(mVolume);
PRInt32 rate = mInfo.mAudioRate;
PRInt32 channels = mInfo.mAudioChannels;
{
MonitorAutoExit exitMon(mDecoder->GetMonitor());
MonitorAutoEnter audioMon(mAudioMonitor);
if (mAudioStream) {
// We have an audiostream, so it must have been paused the last time
// StopPlayback() was called.
mAudioStream->Resume();
} else {
// No audiostream, create one.
mAudioStream = nsAudioStream::AllocateStream();
mAudioStream->Init(channels, rate, MOZ_SOUND_DATA_FORMAT);
mAudioStream->SetVolume(mVolume);
}
}
}
mPlayStartTime = TimeStamp::Now();
@ -1057,8 +1059,12 @@ nsresult nsBuiltinDecoderStateMachine::Run()
VideoData* videoData = FindStartTime();
if (videoData) {
MonitorAutoExit exitMon(mDecoder->GetMonitor());
RenderVideoFrame(videoData, TimeStamp::Now());
nsIntSize display = mInfo.mDisplay;
float aspect = mInfo.mPixelAspectRatio;
{
MonitorAutoExit exitMon(mDecoder->GetMonitor());
RenderVideoFrame(videoData, TimeStamp::Now(), display, aspect);
}
}
// Start the decode threads, so that we can pre buffer the streams.
@ -1082,14 +1088,13 @@ nsresult nsBuiltinDecoderStateMachine::Run()
// setting the default framebuffer size for audioavailable events. Also,
// if there is audio, let the MozAudioAvailable event manager know about
// the metadata.
const nsVideoInfo& info = mReader->GetInfo();
PRUint32 frameBufferLength = info.mAudioChannels * FRAMEBUFFER_LENGTH_PER_CHANNEL;
PRUint32 frameBufferLength = mInfo.mAudioChannels * FRAMEBUFFER_LENGTH_PER_CHANNEL;
nsCOMPtr<nsIRunnable> metadataLoadedEvent =
new nsAudioMetadataEventRunner(mDecoder, info.mAudioChannels,
info.mAudioRate, frameBufferLength);
new nsAudioMetadataEventRunner(mDecoder, mInfo.mAudioChannels,
mInfo.mAudioRate, frameBufferLength);
NS_DispatchToMainThread(metadataLoadedEvent, NS_DISPATCH_NORMAL);
if (HasAudio()) {
mEventManager.Init(info.mAudioChannels, info.mAudioRate);
mEventManager.Init(mInfo.mAudioChannels, mInfo.mAudioRate);
mDecoder->RequestFrameBufferLength(frameBufferLength);
}
@ -1180,7 +1185,12 @@ nsresult nsBuiltinDecoderStateMachine::Run()
if (video) {
NS_ASSERTION(video->mTime <= seekTime && seekTime <= video->mEndTime,
"Seek target should lie inside the first frame after seek");
RenderVideoFrame(video, TimeStamp::Now());
nsIntSize display = mInfo.mDisplay;
float aspect = mInfo.mPixelAspectRatio;
{
MonitorAutoExit exitMon(mDecoder->GetMonitor());
RenderVideoFrame(video, TimeStamp::Now(), display, aspect);
}
mReader->mVideoQueue.PopFront();
nsCOMPtr<nsIRunnable> event =
NS_NewRunnableMethod(mDecoder, &nsBuiltinDecoder::Invalidate);
@ -1336,9 +1346,12 @@ nsresult nsBuiltinDecoderStateMachine::Run()
}
void nsBuiltinDecoderStateMachine::RenderVideoFrame(VideoData* aData,
TimeStamp aTarget)
TimeStamp aTarget,
nsIntSize aDisplaySize,
float aAspectRatio)
{
NS_ASSERTION(IsCurrentThread(mDecoder->mStateMachineThread), "Should be on state machine thread.");
mDecoder->GetMonitor().AssertNotCurrentThreadIn();
if (aData->mDuplicate) {
return;
@ -1346,11 +1359,8 @@ void nsBuiltinDecoderStateMachine::RenderVideoFrame(VideoData* aData,
nsRefPtr<Image> image = aData->mImage;
if (image) {
const nsVideoInfo& info = mReader->GetInfo();
mDecoder->SetVideoData(gfxIntSize(info.mDisplay.width, info.mDisplay.height),
info.mPixelAspectRatio,
image,
aTarget);
mDecoder->SetVideoData(gfxIntSize(aDisplaySize.width, aDisplaySize.height),
aAspectRatio, image, aTarget);
}
}
@ -1460,10 +1470,14 @@ void nsBuiltinDecoderStateMachine::AdvanceFrame()
MsToDuration(currentFrame->mTime - mStartTime);
NS_ASSERTION(currentFrame->mTime >= mStartTime, "Should have positive frame time");
{
MonitorAutoExit exitMon(mDecoder->GetMonitor());
// If we have video, we want to increment the clock in steps of the frame
// duration.
RenderVideoFrame(currentFrame, presTime);
nsIntSize display = mInfo.mDisplay;
float aspect = mInfo.mPixelAspectRatio;
{
MonitorAutoExit exitMon(mDecoder->GetMonitor());
// If we have video, we want to increment the clock in steps of the frame
// duration.
RenderVideoFrame(currentFrame, presTime, display, aspect);
}
}
mDecoder->GetFrameStatistics().NotifyPresentedFrame();
PRInt64 now = DurationToMs(TimeStamp::Now() - mPlayStartTime + mPlayDuration);
@ -1537,9 +1551,10 @@ VideoData* nsBuiltinDecoderStateMachine::FindStartTime()
PRInt64 startTime = 0;
mStartTime = 0;
VideoData* v = nsnull;
PRInt64 dataOffset = mInfo.mDataOffset;
{
MonitorAutoExit exitMon(mDecoder->GetMonitor());
v = mReader->FindStartTime(mReader->GetInfo().mDataOffset, startTime);
v = mReader->FindStartTime(dataOffset, startTime);
}
if (startTime != 0) {
mStartTime = startTime;
@ -1613,11 +1628,12 @@ void nsBuiltinDecoderStateMachine::LoadMetadata()
LOG(PR_LOG_DEBUG, ("Loading Media Headers"));
nsresult res;
nsVideoInfo info;
{
MonitorAutoExit exitMon(mDecoder->GetMonitor());
res = mReader->ReadMetadata();
res = mReader->ReadMetadata(&info);
}
const nsVideoInfo& info = mReader->GetInfo();
mInfo = info;
if (NS_FAILED(res) || (!info.mHasVideo && !info.mHasAudio)) {
mState = DECODER_STATE_SHUTDOWN;

View File

@ -184,14 +184,14 @@ public:
// The decoder monitor must be obtained before calling this.
PRBool HasAudio() const {
mDecoder->GetMonitor().AssertCurrentThreadIn();
return mReader->GetInfo().mHasAudio;
return mInfo.mHasAudio;
}
// This is called on the state machine thread and audio thread.
// The decoder monitor must be obtained before calling this.
PRBool HasVideo() const {
mDecoder->GetMonitor().AssertCurrentThreadIn();
return mReader->GetInfo().mHasVideo;
return mInfo.mHasVideo;
}
// Should be called by main thread.
@ -311,10 +311,11 @@ protected:
void UpdatePlaybackPositionInternal(PRInt64 aTime);
// Performs YCbCr to RGB conversion, and pushes the image down the
// rendering pipeline. Called on the state machine thread.
void RenderVideoFrame(VideoData* aData,
TimeStamp aTarget);
// rendering pipeline. Called on the state machine thread. The decoder
// monitor must not be held when calling this.
void RenderVideoFrame(VideoData* aData, TimeStamp aTarget,
nsIntSize aDisplaySize, float aAspectRatio);
// If we have video, display a video frame if it's time for display has
// arrived, otherwise sleep until it's time for the next sample. Update
// the current frame time as appropriate, and trigger ready state update.
@ -524,6 +525,10 @@ private:
// event manager is accessed from the state machine and audio threads,
// and takes care of synchronizing access to its internal queue.
nsAudioAvailableEventManager mEventManager;
// Stores presentation info required for playback. The decoder monitor
// must be held when accessing this.
nsVideoInfo mInfo;
};
#endif

View File

@ -222,7 +222,7 @@ nsMediaChannelStream::OnStartRequest(nsIRequest* aRequest)
}
if (NS_SUCCEEDED(rv)) {
double duration = durationText.ToFloat(&ec);
double duration = durationText.ToDouble(&ec);
if (ec == NS_OK && duration >= 0) {
mDecoder->SetDuration(PRInt64(NS_round(duration*1000)));
}

View File

@ -114,7 +114,7 @@ PRBool nsOggCodecState::PageInFromBuffer() {
int ret = ogg_stream_pagein(&mState, p);
NS_ENSURE_TRUE(ret == 0, PR_FALSE);
mBuffer.PopFront();
delete p->header;
delete [] p->header;
delete p;
return PR_TRUE;
}
@ -394,6 +394,7 @@ PRInt64 nsVorbisState::Time(vorbis_info* aInfo, PRInt64 aGranulepos)
nsSkeletonState::nsSkeletonState(ogg_page* aBosPage)
: nsOggCodecState(aBosPage),
mVersion(0),
mPresentationTime(0),
mLength(0)
{
MOZ_COUNT_CTOR(nsSkeletonState);
@ -407,7 +408,8 @@ nsSkeletonState::~nsSkeletonState()
// Support for Ogg Skeleton 4.0, as per specification at:
// http://wiki.xiph.org/Ogg_Skeleton_4
// Minimum length in bytes of a Skeleton 4.0 header packet.
// Minimum length in bytes of a Skeleton header packet.
#define SKELETON_MIN_HEADER_LEN 28
#define SKELETON_4_0_MIN_HEADER_LEN 80
// Minimum length in bytes of a Skeleton 4.0 index packet.
@ -421,6 +423,10 @@ nsSkeletonState::~nsSkeletonState()
#define SKELETON_VERSION_MAJOR_OFFSET 8
#define SKELETON_VERSION_MINOR_OFFSET 10
// Byte-offsets of the presentation time numerator and denominator
#define SKELETON_PRESENTATION_TIME_NUMERATOR_OFFSET 12
#define SKELETON_PRESENTATION_TIME_DENOMINATOR_OFFSET 20
// Byte-offsets of the length of file field in the Skeleton 4.0 header packet.
#define SKELETON_FILE_LENGTH_OFFSET 64
@ -434,7 +440,7 @@ nsSkeletonState::~nsSkeletonState()
static PRBool IsSkeletonBOS(ogg_packet* aPacket)
{
return aPacket->bytes >= SKELETON_4_0_MIN_HEADER_LEN &&
return aPacket->bytes >= SKELETON_MIN_HEADER_LEN &&
memcmp(reinterpret_cast<char*>(aPacket->packet), "fishead", 8) == 0;
}
@ -699,6 +705,13 @@ PRBool nsSkeletonState::DecodeHeader(ogg_packet* aPacket)
if (IsSkeletonBOS(aPacket)) {
PRUint16 verMajor = LEUint16(aPacket->packet + SKELETON_VERSION_MAJOR_OFFSET);
PRUint16 verMinor = LEUint16(aPacket->packet + SKELETON_VERSION_MINOR_OFFSET);
// Read the presentation time. We read this before the version check as the
// presentation time exists in all versions.
PRInt64 n = LEInt64(aPacket->packet + SKELETON_PRESENTATION_TIME_NUMERATOR_OFFSET);
PRInt64 d = LEInt64(aPacket->packet + SKELETON_PRESENTATION_TIME_DENOMINATOR_OFFSET);
mPresentationTime = d == 0 ? 0 : (static_cast<float>(n) / static_cast<float>(d)) * 1000;
mVersion = SKELETON_VERSION(verMajor, verMinor);
if (mVersion < SKELETON_VERSION(4,0) ||
mVersion >= SKELETON_VERSION(5,0) ||

View File

@ -54,7 +54,7 @@
class OggPageDeallocator : public nsDequeFunctor {
virtual void* operator() (void* aPage) {
ogg_page* p = static_cast<ogg_page*>(aPage);
delete p->header;
delete [] p->header;
delete p;
return nsnull;
}
@ -214,6 +214,9 @@ public:
virtual PRInt64 Time(PRInt64 granulepos) { return -1; }
virtual PRBool Init() { return PR_TRUE; }
// Return PR_TRUE if the given time (in milliseconds) is within
// the presentation time defined in the skeleton track.
PRBool IsPresentable(PRInt64 aTime) { return aTime >= mPresentationTime; }
// Stores the offset of the page on which a keyframe starts,
// and its presentation time.
@ -283,6 +286,9 @@ private:
// Version of the decoded skeleton track, as per the SKELETON_VERSION macro.
PRUint32 mVersion;
// Presentation time of the resource in milliseconds
PRInt64 mPresentationTime;
// Length of the resource in bytes.
PRInt64 mLength;

View File

@ -169,7 +169,7 @@ static PRBool DoneReadingHeaders(nsTArray<nsOggCodecState*>& aBitstreams) {
return PR_TRUE;
}
nsresult nsOggReader::ReadMetadata()
nsresult nsOggReader::ReadMetadata(nsVideoInfo* aInfo)
{
NS_ASSERTION(mDecoder->OnStateMachineThread(), "Should be on play state machine thread.");
MonitorAutoEnter mon(mMonitor);
@ -353,6 +353,8 @@ nsresult nsOggReader::ReadMetadata()
mTheoraSerial = mTheoraState->mSerial;
}
*aInfo = mInfo;
LOG(PR_LOG_DEBUG, ("Done loading headers, data offset %lld", mDataOffset));
return NS_OK;
@ -561,6 +563,10 @@ nsresult nsOggReader::DecodeTheora(nsTArray<nsAutoPtr<VideoData> >& aFrames,
b.mPlanes[i].mWidth = buffer[i].width;
b.mPlanes[i].mStride = buffer[i].stride;
}
// Need the monitor to be held to be able to use mInfo. This
// is held by our caller.
mMonitor.AssertCurrentThreadIn();
VideoData *v = VideoData::Create(mInfo,
mDecoder->GetImageContainer(),
mPageOffset,
@ -628,7 +634,7 @@ PRBool nsOggReader::DecodeVideoFrame(PRBool &aKeyframeSkip,
// packets we read subsequently.
mTheoraGranulepos = packet.granulepos;
}
if (DecodeTheora(frames, &packet) == NS_ERROR_OUT_OF_MEMORY) {
NS_WARNING("Theora decode memory allocation failure!");
return PR_FALSE;
@ -741,6 +747,7 @@ PRBool nsOggReader::DecodeVideoFrame(PRBool &aKeyframeSkip,
PRInt64 time = mTheoraState->StartTime(mTheoraGranulepos);
NS_ASSERTION(packet.granulepos != -1, "Must know packet granulepos");
if (!aKeyframeSkip ||
(th_packet_iskeyframe(&packet) == 1 && time >= aTimeThreshold))
{
@ -754,13 +761,17 @@ PRBool nsOggReader::DecodeVideoFrame(PRBool &aKeyframeSkip,
// Push decoded data into the video frame queue.
for (PRUint32 i = 0; i < frames.Length(); i++) {
nsAutoPtr<VideoData> data(frames[i].forget());
if (aKeyframeSkip && data->mKeyframe) {
aKeyframeSkip = PR_FALSE;
}
if (!aKeyframeSkip && data->mEndTime >= aTimeThreshold) {
mVideoQueue.Push(data.forget());
decoded++;
// Don't use the frame if it's outside the bounds of the presentation
// start time in the skeleton track.
if (!mSkeletonState || mSkeletonState->IsPresentable(data->mTime)) {
if (aKeyframeSkip && data->mKeyframe) {
aKeyframeSkip = PR_FALSE;
}
if (!aKeyframeSkip && data->mEndTime >= aTimeThreshold) {
mVideoQueue.Push(data.forget());
decoded++;
}
}
}

View File

@ -90,7 +90,7 @@ public:
return mTheoraState != 0 && mTheoraState->mActive;
}
virtual nsresult ReadMetadata();
virtual nsresult ReadMetadata(nsVideoInfo* aInfo);
virtual nsresult Seek(PRInt64 aTime, PRInt64 aStartTime, PRInt64 aEndTime, PRInt64 aCurrentTime);
virtual nsresult GetBuffered(nsTimeRanges* aBuffered, PRInt64 aStartTime);
@ -194,7 +194,8 @@ private:
nsresult DecodeVorbis(nsTArray<nsAutoPtr<SoundData> >& aChunks,
ogg_packet* aPacket);
// May return NS_ERROR_OUT_OF_MEMORY.
// May return NS_ERROR_OUT_OF_MEMORY. Caller must have obtained the
// reader's monitor.
nsresult DecodeTheora(nsTArray<nsAutoPtr<VideoData> >& aFrames,
ogg_packet* aPacket);

View File

@ -68,7 +68,7 @@ nsresult nsRawReader::ResetDecode()
return nsBuiltinDecoderReader::ResetDecode();
}
nsresult nsRawReader::ReadMetadata()
nsresult nsRawReader::ReadMetadata(nsVideoInfo* aInfo)
{
NS_ASSERTION(mDecoder->OnStateMachineThread(),
"Should be on state machine thread.");
@ -134,6 +134,8 @@ nsresult nsRawReader::ReadMetadata()
(mFrameSize * mFrameRate));
}
*aInfo = mInfo;
return NS_OK;
}

View File

@ -110,7 +110,7 @@ public:
return PR_TRUE;
}
virtual nsresult ReadMetadata();
virtual nsresult ReadMetadata(nsVideoInfo* aInfo);
virtual nsresult Seek(PRInt64 aTime, PRInt64 aStartTime, PRInt64 aEndTime, PRInt64 aCurrentTime);
virtual PRInt64 FindEndTime(PRInt64 aEndOffset);
virtual nsresult GetBuffered(nsTimeRanges* aBuffered, PRInt64 aStartTime);

View File

@ -201,6 +201,7 @@ _TEST_FILES += \
bug523816.ogv \
bug533822.ogg \
bug557094.ogv \
bug556821.ogv \
bug580982.webm \
bug603918.webm \
bug604067.webm \

Binary file not shown.

View File

@ -74,6 +74,8 @@ var gPlayTests = [
{ name:"bug504613.ogv", type:"video/ogg", duration:Number.NaN },
// Multiple audio streams.
{ name:"bug516323.ogv", type:"video/ogg", duration:4.208 },
// oggz-chop with non-keyframe as first frame
{ name:"bug556821.ogv", type:"video/ogg", duration:2.551 },
// Encoded with vorbis beta1, includes unusually sized codebooks
{ name:"beta-phrasebook.ogg", type:"audio/ogg", duration:4.01 },

View File

@ -209,7 +209,7 @@ void nsWebMReader::Cleanup()
}
}
nsresult nsWebMReader::ReadMetadata()
nsresult nsWebMReader::ReadMetadata(nsVideoInfo* aInfo)
{
NS_ASSERTION(mDecoder->OnStateMachineThread(), "Should be on state machine thread.");
MonitorAutoEnter mon(mMonitor);
@ -396,6 +396,8 @@ nsresult nsWebMReader::ReadMetadata()
}
}
*aInfo = mInfo;
return NS_OK;
}

View File

@ -153,7 +153,7 @@ public:
return mHasVideo;
}
virtual nsresult ReadMetadata();
virtual nsresult ReadMetadata(nsVideoInfo* aInfo);
virtual nsresult Seek(PRInt64 aTime, PRInt64 aStartTime, PRInt64 aEndTime, PRInt64 aCurrentTime);
virtual nsresult GetBuffered(nsTimeRanges* aBuffered, PRInt64 aStartTime);
virtual void NotifyDataArrived(const char* aBuffer, PRUint32 aLength, PRUint32 aOffset);

View File

@ -494,9 +494,9 @@ XULSortServiceImpl::CompareValues(const nsAString& aLeft,
{
if (aSortHints & SORT_INTEGER) {
PRInt32 err;
PRInt32 leftint = nsDependentString(aLeft).ToInteger(&err);
PRInt32 leftint = PromiseFlatString(aLeft).ToInteger(&err);
if (NS_SUCCEEDED(err)) {
PRInt32 rightint = nsDependentString(aRight).ToInteger(&err);
PRInt32 rightint = PromiseFlatString(aRight).ToInteger(&err);
if (NS_SUCCEEDED(err)) {
return leftint - rightint;
}

View File

@ -864,7 +864,6 @@ NS_INTERFACE_MAP_BEGIN(nsDocShell)
NS_INTERFACE_MAP_ENTRY(nsIWebShellServices)
NS_INTERFACE_MAP_ENTRY(nsILinkHandler)
NS_INTERFACE_MAP_ENTRY(nsIClipboardCommands)
NS_INTERFACE_MAP_ENTRY(nsIDocShell_MOZILLA_2_0_BRANCH)
NS_INTERFACE_MAP_END_INHERITING(nsDocLoader)
///*****************************************************************************

View File

@ -186,8 +186,7 @@ class nsDocShell : public nsDocLoader,
public nsILoadContext,
public nsIWebShellServices,
public nsILinkHandler,
public nsIClipboardCommands,
public nsIDocShell_MOZILLA_2_0_BRANCH
public nsIClipboardCommands
{
friend class nsDSURIContentListener;
@ -202,7 +201,6 @@ public:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIDOCSHELL
NS_DECL_NSIDOCSHELL_MOZILLA_2_0_BRANCH
NS_DECL_NSIDOCSHELLTREEITEM
NS_DECL_NSIDOCSHELLTREENODE
NS_DECL_NSIDOCSHELLHISTORY

View File

@ -15,7 +15,7 @@ struct nsIntRect;
[ptr] native nsIDocumentPtr(nsIDocument);
[ref] native nsIntRectRef(nsIntRect);
[scriptable, uuid(e2e5dd7d-8140-4fc5-b2c3-3a3b4f946fc7)]
[scriptable, uuid(75306a89-e3ad-4a2b-9daf-ac4de06661a4)]
interface nsIContentViewer : nsISupports
{
@ -133,11 +133,7 @@ interface nsIContentViewer : nsISupports
* destroyed. Can return null
*/
readonly attribute nsISHEntry historyEntry;
};
[scriptable, uuid(4710ef6e-6de3-47fe-88f4-e49b48c87fc9)]
interface nsIContentViewer_MOZILLA_2_0_BRANCH : nsISupports
{
/*
* Indicates when we're in a state where content shouldn't be allowed to
* trigger a tab-modal prompt (as opposed to a window-modal prompt) because

View File

@ -71,7 +71,7 @@ interface nsIPrincipal;
interface nsIWebBrowserPrint;
interface nsIVariant;
[scriptable, uuid(98cdbcc4-2d81-4191-a63f-b6c52085edbc)]
[scriptable, uuid(1917a6d6-31f6-4033-868d-f15ca08ca2df)]
interface nsIDocShell : nsISupports
{
/**
@ -540,10 +540,7 @@ interface nsIDocShell : nsISupports
* handling link clicks. Docshells are not app tabs unless told otherwise.
*/
attribute boolean isAppTab;
};
[uuid(5f7a2184-31b6-4d67-9c75-0c17477766e2)]
interface nsIDocShell_MOZILLA_2_0_BRANCH : nsISupports {
/**
* Create a new about:blank document and content viewer.
* @param aPrincipal the principal to use for the new document.

View File

@ -2287,7 +2287,6 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_MAP_BEGIN(WindowUtils, nsIDOMWindowUtils)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindowUtils)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindowUtils_MOZILLA_2_0_BRANCH)
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(Location, nsIDOMLocation)
@ -2331,7 +2330,6 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_MAP_BEGIN(History, nsIDOMHistory)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMHistory)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMHistory_MOZILLA_2_0_BRANCH)
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(Screen, nsIDOMScreen)
@ -2765,7 +2763,6 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_MAP_BEGIN(HTMLSelectElement, nsIDOMHTMLSelectElement)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLSelectElement)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLSelectElement_Mozilla_2_0_Branch)
DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
DOM_CLASSINFO_MAP_END
@ -4016,7 +4013,6 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_MAP_BEGIN(WebGLRenderingContext, nsIDOMWebGLRenderingContext)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMWebGLRenderingContext)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMWebGLRenderingContext_MOZILLA_2_0_BRANCH)
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(WebGLBuffer, nsIWebGLBuffer)

View File

@ -98,7 +98,6 @@ DOMCI_DATA(WindowUtils, nsDOMWindowUtils)
NS_INTERFACE_MAP_BEGIN(nsDOMWindowUtils)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMWindowUtils)
NS_INTERFACE_MAP_ENTRY(nsIDOMWindowUtils)
NS_INTERFACE_MAP_ENTRY(nsIDOMWindowUtils_MOZILLA_2_0_BRANCH)
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(WindowUtils)
NS_INTERFACE_MAP_END
@ -266,14 +265,6 @@ static void DestroyNsRect(void* aObject, nsIAtom* aPropertyName,
delete rect;
}
NS_IMETHODIMP
nsDOMWindowUtils::SetDisplayPort(float aXPx, float aYPx,
float aWidthPx, float aHeightPx)
{
NS_ABORT_IF_FALSE(false, "This interface is deprecated.");
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsDOMWindowUtils::SetDisplayPortForElement(float aXPx, float aYPx,
float aWidthPx, float aHeightPx,
@ -1015,9 +1006,8 @@ nsDOMWindowUtils::GetIMEIsOpen(PRBool *aState)
return NS_ERROR_FAILURE;
// Open state should not be available when IME is not enabled.
nsIWidget_MOZILLA_2_0_BRANCH* widget2 = static_cast<nsIWidget_MOZILLA_2_0_BRANCH*>(widget.get());
IMEContext context;
nsresult rv = widget2->GetInputMode(context);
nsresult rv = widget->GetInputMode(context);
NS_ENSURE_SUCCESS(rv, rv);
if (context.mStatus != nsIWidget::IME_STATUS_ENABLED)
return NS_ERROR_NOT_AVAILABLE;
@ -1034,9 +1024,8 @@ nsDOMWindowUtils::GetIMEStatus(PRUint32 *aState)
if (!widget)
return NS_ERROR_FAILURE;
nsIWidget_MOZILLA_2_0_BRANCH* widget2 = static_cast<nsIWidget_MOZILLA_2_0_BRANCH*>(widget.get());
IMEContext context;
nsresult rv = widget2->GetInputMode(context);
nsresult rv = widget->GetInputMode(context);
NS_ENSURE_SUCCESS(rv, rv);
*aState = context.mStatus;
@ -1053,9 +1042,8 @@ nsDOMWindowUtils::GetFocusedInputType(char** aType)
return NS_ERROR_FAILURE;
}
nsIWidget_MOZILLA_2_0_BRANCH* widget2 = static_cast<nsIWidget_MOZILLA_2_0_BRANCH*>(widget.get());
IMEContext context;
nsresult rv = widget2->GetInputMode(context);
nsresult rv = widget->GetInputMode(context);
NS_ENSURE_SUCCESS(rv, rv);
*aType = ToNewCString(context.mHTMLInputType);

View File

@ -44,7 +44,6 @@ class nsGlobalWindow;
class nsIPresShell;
class nsDOMWindowUtils : public nsIDOMWindowUtils,
public nsIDOMWindowUtils_MOZILLA_2_0_BRANCH,
public nsSupportsWeakReference
{
public:
@ -52,7 +51,6 @@ public:
~nsDOMWindowUtils();
NS_DECL_ISUPPORTS
NS_DECL_NSIDOMWINDOWUTILS
NS_DECL_NSIDOMWINDOWUTILS_MOZILLA_2_0_BRANCH
protected:
nsRefPtr<nsGlobalWindow> mWindow;

View File

@ -57,7 +57,6 @@ struct nsDelayedBlurOrFocusEvent;
*/
class nsFocusManager : public nsIFocusManager,
public nsIFocusManager_MOZILLA_2_0_BRANCH,
public nsIObserver,
public nsSupportsWeakReference
{
@ -67,7 +66,6 @@ public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_NSIOBSERVER
NS_DECL_NSIFOCUSMANAGER
NS_DECL_NSIFOCUSMANAGER_MOZILLA_2_0_BRANCH
// called to initialize and stop the focus manager at startup and shutdown
static nsresult Init();

View File

@ -1609,8 +1609,7 @@ nsGlobalWindow::SetOpenerScriptPrincipal(nsIPrincipal* aPrincipal)
"Unexpected original document");
#endif
nsCOMPtr<nsIDocShell_MOZILLA_2_0_BRANCH> ds(do_QueryInterface(GetDocShell()));
ds->CreateAboutBlankContentViewer(aPrincipal);
GetDocShell()->CreateAboutBlankContentViewer(aPrincipal);
mDoc->SetIsInitialDocument(PR_TRUE);
nsCOMPtr<nsIPresShell> shell;
@ -2508,9 +2507,7 @@ nsGlobalWindow::GetIsTabModalPromptAllowed()
if (mDocShell) {
nsCOMPtr<nsIContentViewer> cv;
mDocShell->GetContentViewer(getter_AddRefs(cv));
nsCOMPtr<nsIContentViewer_MOZILLA_2_0_BRANCH> cv2 = do_QueryInterface(cv);
if (cv2)
cv2->GetIsTabModalPromptAllowed(&allowTabModal);
cv->GetIsTabModalPromptAllowed(&allowTabModal);
}
return allowTabModal;
@ -7730,12 +7727,7 @@ nsGlobalWindow::DispatchSyncPopState()
// going to send along with the popstate event. The object is serialized as
// JSON.
nsCOMPtr<nsIVariant> stateObj;
nsCOMPtr<nsIDOMNSDocument_MOZILLA_2_0_BRANCH> doc2 = do_QueryInterface(mDoc);
if (!doc2) {
return NS_OK;
}
rv = doc2->GetMozCurrentStateObject(getter_AddRefs(stateObj));
rv = mDoc->GetMozCurrentStateObject(getter_AddRefs(stateObj));
NS_ENSURE_SUCCESS(rv, rv);
// Obtain a presentation shell for use in creating a popstate event.
@ -8141,8 +8133,7 @@ nsGlobalWindow::GetInterface(const nsIID & aIID, void **aSink)
}
}
}
else if (aIID.Equals(NS_GET_IID(nsIDOMWindowUtils)) ||
aIID.Equals(NS_GET_IID(nsIDOMWindowUtils_MOZILLA_2_0_BRANCH))) {
else if (aIID.Equals(NS_GET_IID(nsIDOMWindowUtils))) {
FORWARD_TO_OUTER(GetInterface, (aIID, aSink), NS_ERROR_NOT_INITIALIZED);
nsCOMPtr<nsISupports> utils(do_QueryReferent(mWindowUtils));

View File

@ -85,7 +85,6 @@ DOMCI_DATA(History, nsHistory)
NS_INTERFACE_MAP_BEGIN(nsHistory)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMHistory)
NS_INTERFACE_MAP_ENTRY(nsIDOMHistory)
NS_INTERFACE_MAP_ENTRY(nsIDOMHistory_MOZILLA_2_0_BRANCH)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(History)
NS_INTERFACE_MAP_END
@ -350,7 +349,7 @@ nsHistory::GetState(nsIVariant **aState)
if (!nsContentUtils::CanCallerAccess(win->GetOuterWindow()))
return NS_ERROR_DOM_SECURITY_ERR;
nsCOMPtr<nsIDOMNSDocument_MOZILLA_2_0_BRANCH> doc =
nsCOMPtr<nsIDocument> doc =
do_QueryInterface(win->GetExtantDocument());
if (!doc)
return NS_ERROR_NOT_AVAILABLE;

View File

@ -49,8 +49,7 @@
class nsIDocShell;
// Script "History" object
class nsHistory : public nsIDOMHistory,
public nsIDOMHistory_MOZILLA_2_0_BRANCH
class nsHistory : public nsIDOMHistory
{
public:
nsHistory(nsPIDOMWindow* aInnerWindow);
@ -61,7 +60,6 @@ public:
// nsIDOMHistory
NS_DECL_NSIDOMHISTORY
NS_DECL_NSIDOMHISTORY_MOZILLA_2_0_BRANCH
nsIDocShell *GetDocShell() {
nsCOMPtr<nsPIDOMWindow> win(do_QueryReferent(mInnerWindow));

View File

@ -71,7 +71,7 @@ interface nsIContentPrefCallback : nsISupports
void onResult(in nsIVariant aResult);
};
[scriptable, uuid(36715960-de39-457b-9d02-b800d5d3079b)]
[scriptable, uuid(0014e2b4-1bab-4946-9211-7d28fc8df4d7)]
interface nsIContentPrefService : nsISupports
{
/**
@ -131,6 +131,19 @@ interface nsIContentPrefService : nsISupports
*/
boolean hasPref(in nsIVariant aGroup, in AString aName);
/**
* Check whether or not the value of a pref (or its non-existance) is cached.
*
* @param aGroup the group for which to check for the pref, as an nsIURI
* from which the hostname will be used, a string
* (typically in the format of a hostname), or null
* to check for the global pref (applies to all sites)
* @param aName the name of the pref to check for
* @throws NS_ERROR_ILLEGAL_VALUE if aGroup is not a string, nsIURI, or null
* @throws NS_ERROR_ILLEGAL_VALUE if aName is null or an empty string
*/
boolean hasCachedPref(in nsIVariant aGroup, in AString aName);
/**
* Remove a pref.
*
@ -217,23 +230,6 @@ interface nsIContentPrefService : nsISupports
readonly attribute mozIStorageConnection DBConnection;
};
[scriptable, uuid(126f07cb-edfe-497e-87dd-ba906506b287)]
interface nsIContentPrefService_MOZILLA_2_0 : nsIContentPrefService
{
/**
* Check whether or not the value of a pref (or its non-existance) is cached.
*
* @param aGroup the group for which to check for the pref, as an nsIURI
* from which the hostname will be used, a string
* (typically in the format of a hostname), or null
* to check for the global pref (applies to all sites)
* @param aName the name of the pref to check for
* @throws NS_ERROR_ILLEGAL_VALUE if aGroup is not a string, nsIURI, or null
* @throws NS_ERROR_ILLEGAL_VALUE if aName is null or an empty string
*/
boolean hasCachedPref(in nsIVariant aGroup, in AString aName);
};
%{C++
// The contractID for the generic implementation built in to xpcom.
#define NS_CONTENT_PREF_SERVICE_CONTRACTID "@mozilla.org/content-pref/service;1"

View File

@ -41,7 +41,7 @@
interface nsIVariant;
[scriptable, uuid(208f2af7-9f2e-497c-8a53-9e7803280898)]
[scriptable, uuid(dba2e0d5-1682-40a3-be46-28eda99d757e)]
interface nsIDOMHistory : nsISupports
{
readonly attribute long length;
@ -60,10 +60,6 @@ interface nsIDOMHistory : nsISupports
void replaceState(in nsIVariant aData,
in DOMString aTitle,
[optional] in DOMString aURL);
};
[scriptable, uuid(949fcdc1-664b-4a4b-939a-7144c94b48ac)]
interface nsIDOMHistory_MOZILLA_2_0_BRANCH : nsISupports
{
readonly attribute nsIVariant state;
};

View File

@ -54,6 +54,7 @@
[ref] native nsConstRect(const nsRect);
native nscolor(nscolor);
[ptr] native gfxContext(gfxContext);
typedef unsigned long long nsViewID;
interface nsICycleCollectorListener;
interface nsIDOMNode;
@ -65,7 +66,7 @@ interface nsITransferable;
interface nsIQueryContentEventResult;
interface nsIDOMWindow;
[scriptable, uuid(85fa978a-fc91-4513-9f11-8911e671577f)]
[scriptable, uuid(da529d62-ba27-480c-bb37-766ad083179a)]
interface nsIDOMWindowUtils : nsISupports {
/**
@ -129,10 +130,34 @@ interface nsIDOMWindowUtils : nsISupports {
void setCSSViewport(in float aWidthPx, in float aHeightPx);
/**
* @DEPRECATED See nsIDOMWindowUtils_MOZILLA_2_0_BRANCH.
* For any scrollable element, this allows you to override the
* visible region and draw more than what is visible, which is
* useful for asynchronous drawing. The "displayport" will be
* <xPx, yPx, widthPx, heightPx> in units of CSS pixels,
* regardless of the size of the enclosing container. This
* will *not* trigger reflow.
*
* For the root scroll area, pass in the root document element.
* For scrollable elements, pass in the container element (for
* instance, the element with overflow: scroll).
*
* <x, y> is relative to the top-left of what would normally be
* the visible area of the element. This means that the pixels
* rendered to the displayport take scrolling into account,
* for example.
*
* It's legal to set a displayport that extends beyond the overflow
* area in any direction (left/right/top/bottom).
*
* It's also legal to set a displayport that extends beyond the
* area's bounds. No pixels are rendered outside the area bounds.
*
* The caller of this method must have UniversalXPConnect
* privileges.
*/
void setDisplayPort(in float aXPx, in float aYPx,
in float aWidthPx, in float aHeightPx);
void setDisplayPortForElement(in float aXPx, in float aYPx,
in float aWidthPx, in float aHeightPx,
in nsIDOMElement aElement);
/**
* Get/set the resolution at which rescalable web content is drawn.
@ -753,6 +778,19 @@ interface nsIDOMWindowUtils : nsISupports {
*/
[noscript] void leaveModalState();
/**
* Same as enterModalState, but returns the window associated with the
* current JS context.
*/
nsIDOMWindow enterModalStateWithWindow();
/**
* Same as leaveModalState, but takes a window associated with the active
* context when enterModalStateWithWindow was called. The currently context
* might be different at the moment (see bug 621764).
*/
void leaveModalStateWithWindow(in nsIDOMWindow aWindow);
/**
* Is the window is in a modal state? [See enterModalState()]
*/
@ -797,12 +835,7 @@ interface nsIDOMWindowUtils : nsISupports {
in AString property,
in AString value1,
in AString value2);
};
typedef unsigned long long nsViewID;
[scriptable, uuid(7ad49829-e631-4cdd-a237-95847d9bcbe6)]
interface nsIDOMWindowUtils_MOZILLA_2_0_BRANCH : nsISupports {
/**
* Get the type of the currently focused html input, if any.
*/
@ -815,49 +848,6 @@ interface nsIDOMWindowUtils_MOZILLA_2_0_BRANCH : nsISupports {
*/
nsIDOMElement findElementWithViewId(in nsViewID aId);
/**
* For any scrollable element, this allows you to override the
* visible region and draw more than what is visible, which is
* useful for asynchronous drawing. The "displayport" will be
* <xPx, yPx, widthPx, heightPx> in units of CSS pixels,
* regardless of the size of the enclosing container. This
* will *not* trigger reflow.
*
* For the root scroll area, pass in the root document element.
* For scrollable elements, pass in the container element (for
* instance, the element with overflow: scroll).
*
* <x, y> is relative to the top-left of what would normally be
* the visible area of the element. This means that the pixels
* rendered to the displayport take scrolling into account,
* for example.
*
* It's legal to set a displayport that extends beyond the overflow
* area in any direction (left/right/top/bottom).
*
* It's also legal to set a displayport that extends beyond the
* area's bounds. No pixels are rendered outside the area bounds.
*
* The caller of this method must have UniversalXPConnect
* privileges.
*/
void setDisplayPortForElement(in float aXPx, in float aYPx,
in float aWidthPx, in float aHeightPx,
in nsIDOMElement aElement);
/**
* Same as enterModalState, but returns the window associated with the
* current JS context.
*/
nsIDOMWindow enterModalStateWithWindow();
/**
* Same as leaveModalState, but takes a window associated with the active
* context when enterModalStateWithWindow was called. The currently context
* might be different at the moment (see bug 621764).
*/
void leaveModalStateWithWindow(in nsIDOMWindow aWindow);
/**
* Checks the layer tree for this window and returns true
* if all layers have transforms that are translations by integers,

View File

@ -39,7 +39,7 @@
interface nsIDocument;
interface nsIContent;
[scriptable, uuid(5cb91200-53f6-4d35-989d-1d28ad80a0d4)]
[scriptable, uuid(51db277b-7ee7-4bce-9b84-fd2efcd2c8bd)]
/**
* The focus manager deals with all focus related behaviour. Only one element
* in the entire application may have the focus at a time; this element
@ -261,14 +261,7 @@ interface nsIFocusManager : nsISupports
* Fire any events that have been delayed due to synchronized actions.
*/
[noscript] void fireDelayedEvents(in nsIDocument aDocument);
};
/**
* This interface extends nsIFocusManager for the 2.0 branch
*/
[scriptable, uuid(94a49833-0f6d-4d9b-b859-990546ad9b8d)]
interface nsIFocusManager_MOZILLA_2_0_BRANCH : nsISupports
{
/**
* Indicate that a plugin wishes to take the focus. This is similar to a
* normal focus except that the widget focus is not changed. Updating the

View File

@ -133,7 +133,7 @@ interface nsIWebGLUniformLocation : nsISupports
};
[scriptable, uuid(2f21ca21-9720-4eee-ad94-27eefe4f72dc)]
[scriptable, uuid(44119fc2-b5f0-4acc-b836-5d28cc43e8fb)]
interface nsIDOMWebGLRenderingContext : nsISupports
{
//
@ -837,11 +837,7 @@ interface nsIDOMWebGLRenderingContext : nsISupports
// extensions
nsISupports getExtension(in DOMString name);
};
[scriptable, uuid(23182042-3d92-407d-9b9b-37c9886398f7)]
interface nsIDOMWebGLRenderingContext_MOZILLA_2_0_BRANCH : nsISupports
{
nsIVariant getSupportedExtensions();
WebGLboolean isContextLost();
};

View File

@ -130,10 +130,3 @@ interface nsIDOMNSDocument : nsISupports
void mozSetImageElement(in DOMString aImageElementId,
in nsIDOMElement aImageElement);
};
// WARNING! This interface is currently not exposed to script in classinfo
[scriptable, uuid(fee67aed-3b94-4136-ad7d-fb88ef23f45f)]
interface nsIDOMNSDocument_MOZILLA_2_0_BRANCH : nsISupports
{
[noscript] readonly attribute nsIVariant mozCurrentStateObject;
};

View File

@ -54,11 +54,11 @@
interface nsIDOMFile;
[scriptable, uuid(53ad994a-3cd0-48fa-8ffb-7f3d8cd19c50)]
[scriptable, uuid(6b44a95a-c0ad-41f9-beb5-579bdb8698f2)]
interface nsIDOMHTMLCanvasElement : nsIDOMHTMLElement
{
attribute long width;
attribute long height;
attribute unsigned long width;
attribute unsigned long height;
attribute boolean mozOpaque;
nsISupports getContext(in DOMString contextId,

View File

@ -53,7 +53,7 @@
interface nsIDOMValidityState;
[scriptable, uuid(e3c6d960-972c-4a5e-a8f4-6ca65d578abf)]
[scriptable, uuid(da2be32d-63de-47ae-8c81-7ab8ac6b5aae)]
interface nsIDOMHTMLSelectElement : nsIDOMHTMLElement
{
attribute boolean autofocus;
@ -88,10 +88,6 @@ interface nsIDOMHTMLSelectElement : nsIDOMHTMLElement
readonly attribute DOMString validationMessage;
boolean checkValidity();
void setCustomValidity(in DOMString error);
};
[scriptable, uuid(9b63d2d3-ccb0-4eed-a9e5-d1c142a805b7)]
interface nsIDOMHTMLSelectElement_Mozilla_2_0_Branch : nsIDOMHTMLSelectElement
{
attribute boolean required;
attribute boolean required;
};

View File

@ -48,7 +48,9 @@
#include "ContentChild.h"
#include "CrashReporterChild.h"
#include "TabChild.h"
#if defined(MOZ_SYDNEYAUDIO)
#include "AudioChild.h"
#endif
#include "mozilla/ipc/TestShellChild.h"
#include "mozilla/net/NeckoChild.h"
@ -58,7 +60,9 @@
#include "mozilla/dom/StorageChild.h"
#include "mozilla/dom/PCrashReporterChild.h"
#if defined(MOZ_SYDNEYAUDIO)
#include "nsAudioStream.h"
#endif
#include "nsIMemoryReporter.h"
#include "nsIObserverService.h"
#include "nsTObserverArray.h"
@ -384,16 +388,22 @@ ContentChild::AllocPAudio(const PRInt32& numChannels,
const PRInt32& rate,
const PRInt32& format)
{
#if defined(MOZ_SYDNEYAUDIO)
AudioChild *child = new AudioChild();
NS_ADDREF(child);
return child;
#else
return nsnull;
#endif
}
bool
ContentChild::DeallocPAudio(PAudioChild* doomed)
{
#if defined(MOZ_SYDNEYAUDIO)
AudioChild *child = static_cast<AudioChild*>(doomed);
NS_RELEASE(child);
#endif
return true;
}

View File

@ -68,7 +68,9 @@
#include "nsIConsoleService.h"
#include "nsIScriptError.h"
#include "nsConsoleMessage.h"
#if defined(MOZ_SYDNEYAUDIO)
#include "AudioParent.h"
#endif
#if defined(ANDROID) || defined(LINUX)
#include <sys/time.h>
@ -687,16 +689,22 @@ ContentParent::AllocPAudio(const PRInt32& numChannels,
const PRInt32& rate,
const PRInt32& format)
{
#if defined(MOZ_SYDNEYAUDIO)
AudioParent *parent = new AudioParent(numChannels, rate, format);
NS_ADDREF(parent);
return parent;
#else
return nsnull;
#endif
}
bool
ContentParent::DeallocPAudio(PAudioParent* doomed)
{
#if defined(MOZ_SYDNEYAUDIO)
AudioParent *parent = static_cast<AudioParent*>(doomed);
NS_RELEASE(parent);
#endif
return true;
}

View File

@ -56,8 +56,6 @@ EXPORTS = TabMessageUtils.h PCOMContentPermissionRequestChild.h
EXPORTS_NAMESPACES = mozilla/dom
EXPORTS_mozilla/dom = \
AudioChild.h \
AudioParent.h \
ContentChild.h \
ContentParent.h \
ContentProcess.h \
@ -68,8 +66,6 @@ EXPORTS_mozilla/dom = \
$(NULL)
CPPSRCS = \
AudioChild.cpp \
AudioParent.cpp \
ContentProcess.cpp \
ContentParent.cpp \
ContentChild.cpp \
@ -79,6 +75,18 @@ CPPSRCS = \
TabMessageUtils.cpp \
$(NULL)
ifdef MOZ_SYDNEYAUDIO
EXPORTS_mozilla/dom += \
AudioChild.h \
AudioParent.h \
$(NULL)
CPPSRCS += \
AudioChild.cpp \
AudioParent.cpp \
$(NULL)
endif
include $(topsrcdir)/config/config.mk
include $(topsrcdir)/ipc/chromium/chromium-config.mk
include $(topsrcdir)/config/rules.mk

View File

@ -518,12 +518,9 @@ TabParent::RecvGetIMEEnabled(PRUint32* aValue)
if (!widget)
return true;
nsIWidget_MOZILLA_2_0_BRANCH* widget2 = static_cast<nsIWidget_MOZILLA_2_0_BRANCH*>(widget.get());
IMEContext context;
if (widget2) {
widget2->GetInputMode(context);
*aValue = context.mStatus;
}
widget->GetInputMode(context);
*aValue = context.mStatus;
return true;
}
@ -534,13 +531,11 @@ TabParent::RecvSetInputMode(const PRUint32& aValue, const nsString& aType, const
if (!widget || !AllowContentIME())
return true;
nsIWidget_MOZILLA_2_0_BRANCH* widget2 = static_cast<nsIWidget_MOZILLA_2_0_BRANCH*>(widget.get());
IMEContext context;
context.mStatus = aValue;
context.mHTMLInputType.Assign(aType);
context.mActionHint.Assign(aAction);
widget2->SetInputMode(context);
widget->SetInputMode(context);
nsCOMPtr<nsIObserverService> observerService = mozilla::services::GetObserverService();
if (!observerService)

View File

@ -54,7 +54,7 @@ function registerMockPromptService()
// abusive pages.
var winUtils = this.domWindow
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils_MOZILLA_2_0_BRANCH);
.getInterface(Ci.nsIDOMWindowUtils);
var w = winUtils.enterModalStateWithWindow();
winUtils.leaveModalStateWithWindow(w);
},

View File

@ -57,7 +57,6 @@ XPIDLSRCS = \
nsIEditorSpellCheck.idl \
nsIEditorStyleSheets.idl \
nsIHTMLEditor.idl \
nsIHTMLEditor_MOZILLA_2_0_BRANCH.idl \
nsIHTMLObjectResizer.idl \
nsIHTMLAbsPosEditor.idl \
nsIHTMLObjectResizeListener.idl \

View File

@ -51,7 +51,7 @@ interface nsIContentFilter;
NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_EDITOR, 1)
%}
[scriptable, uuid(afc36593-5787-4420-93d9-b2c0ccbf0cad)]
[scriptable, uuid(c964b8b0-e9e8-11df-9492-0800200c9a66)]
interface nsIHTMLEditor : nsISupports
{
@ -608,5 +608,10 @@ interface nsIHTMLEditor : nsISupports
* @return true if CR in a paragraph creates a new paragraph
*/
attribute boolean returnInParagraphCreatesNewParagraph;
/**
* Checks whether a BR node is visible to the user.
*/
boolean breakIsVisible(in nsIDOMNode aNode);
};

View File

@ -1,51 +0,0 @@
/* -*- 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 Mozilla Editor code.
*
* The Initial Developer of the Original Code is
* Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of 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 "nsISupports.idl"
interface nsIDOMNode;
[scriptable, uuid(278714d1-2072-440a-bb0f-6522d98d280a)]
interface nsIHTMLEditor_MOZILLA_2_0_BRANCH : nsISupports
{
/**
* Checks whether a BR node is visible to the user.
*/
boolean breakIsVisible(in nsIDOMNode aNode);
};

View File

@ -257,7 +257,6 @@ NS_IMPL_RELEASE_INHERITED(nsHTMLEditor, nsEditor)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsHTMLEditor)
NS_INTERFACE_MAP_ENTRY(nsIHTMLEditor)
NS_INTERFACE_MAP_ENTRY(nsIHTMLEditor_MOZILLA_2_0_BRANCH)
NS_INTERFACE_MAP_ENTRY(nsIHTMLObjectResizer)
NS_INTERFACE_MAP_ENTRY(nsIHTMLAbsPosEditor)
NS_INTERFACE_MAP_ENTRY(nsIHTMLInlineTableEditor)

View File

@ -45,7 +45,6 @@
#include "nsPlaintextEditor.h"
#include "nsIEditor.h"
#include "nsIHTMLEditor.h"
#include "nsIHTMLEditor_MOZILLA_2_0_BRANCH.h"
#include "nsITableEditor.h"
#include "nsIEditorMailSupport.h"
#include "nsIEditorStyleSheets.h"
@ -91,7 +90,6 @@ struct PropItem;
*/
class nsHTMLEditor : public nsPlaintextEditor,
public nsIHTMLEditor,
public nsIHTMLEditor_MOZILLA_2_0_BRANCH,
public nsIHTMLObjectResizer,
public nsIHTMLAbsPosEditor,
public nsITableEditor,
@ -169,10 +167,6 @@ public:
NS_DECL_NSIHTMLEDITOR
/* ------------ nsIHTMLEditor_MOZILLA_2_0_BRANCH methods -------------- */
NS_DECL_NSIHTMLEDITOR_MOZILLA_2_0_BRANCH
/* ------------ nsIHTMLObjectResizer methods -------------- */
/* -------- Implemented in nsHTMLObjectResizer.cpp -------- */
NS_DECL_NSIHTMLOBJECTRESIZER

View File

@ -46,6 +46,7 @@
#include "Layers.h"
#include "gfxPlatform.h"
#include "ReadbackLayer.h"
#include "gfxUtils.h"
using namespace mozilla::layers;
@ -316,6 +317,47 @@ Layer::SnapTransform(const gfx3DMatrix& aTransform,
return result;
}
nsIntRect
Layer::CalculateScissorRect(bool aIntermediate,
const nsIntRect& aVisibleRect,
const nsIntRect& aParentScissor,
const gfxMatrix& aTransform)
{
nsIntRect scissorRect(aVisibleRect);
const nsIntRect *clipRect = GetEffectiveClipRect();
if (!aIntermediate && !clipRect) {
return aParentScissor;
}
if (clipRect) {
if (clipRect->IsEmpty()) {
return *clipRect;
}
scissorRect = *clipRect;
if (!aIntermediate) {
gfxRect r(scissorRect.x, scissorRect.y, scissorRect.width, scissorRect.height);
gfxRect trScissor = aTransform.TransformBounds(r);
trScissor.Round();
if (!gfxUtils::GfxRectToIntRect(trScissor, &scissorRect)) {
scissorRect = aVisibleRect;
}
}
}
if (aIntermediate) {
scissorRect.MoveBy(- aVisibleRect.TopLeft());
} else if (clipRect) {
scissorRect.IntersectRect(scissorRect, aParentScissor);
}
NS_ASSERTION(scissorRect.x >= 0 && scissorRect.y >= 0,
"Attempting to scissor out of bounds!");
return scissorRect;
}
const gfx3DMatrix&
Layer::GetLocalTransform()
{

View File

@ -797,6 +797,20 @@ public:
* have already had ComputeEffectiveTransforms called.
*/
virtual void ComputeEffectiveTransforms(const gfx3DMatrix& aTransformToSurface) = 0;
/**
* Calculate the scissor rect required when rendering this layer.
*
* @param aIntermediate true if the layer is being rendered to an
* intermediate surface, false otherwise.
* @param aVisibleRect The bounds of the parent's visible region.
* @param aParentScissor The existing scissor rect set for the parent.
* @param aTransform The current 2d transform of the parent.
*/
nsIntRect CalculateScissorRect(bool aIntermediate,
const nsIntRect& aVisibleRect,
const nsIntRect& aParentScissor,
const gfxMatrix& aTransform);
virtual const char* Name() const =0;
virtual LayerType GetType() const =0;

View File

@ -257,6 +257,16 @@ ContainerLayerD3D10::RenderLayer()
PRBool is2d = GetEffectiveTransform().Is2D(&contTransform);
NS_ASSERTION(is2d, "Transform must be 2D");
}
D3D10_RECT oldD3D10Scissor;
UINT numRects = 1;
device()->RSGetScissorRects(&numRects, &oldD3D10Scissor);
// Convert scissor to an nsIntRect. D3D10_RECT's are exclusive
// on the bottom and right values.
nsIntRect oldScissor(oldD3D10Scissor.left,
oldD3D10Scissor.top,
oldD3D10Scissor.right - oldD3D10Scissor.left,
oldD3D10Scissor.bottom - oldD3D10Scissor.top);
/*
* Render this container's contents.
@ -265,78 +275,31 @@ ContainerLayerD3D10::RenderLayer()
layerToRender != nsnull;
layerToRender = GetNextSiblingD3D10(layerToRender)) {
const nsIntRect* clipRect = layerToRender->GetLayer()->GetClipRect();
if ((clipRect && clipRect->IsEmpty()) ||
layerToRender->GetLayer()->GetEffectiveVisibleRegion().IsEmpty()) {
if (layerToRender->GetLayer()->GetEffectiveVisibleRegion().IsEmpty()) {
continue;
}
nsIntRect scissorRect =
layerToRender->GetLayer()->CalculateScissorRect(useIntermediate,
visibleRect,
oldScissor,
contTransform);
if (scissorRect.IsEmpty()) {
continue;
}
D3D10_RECT oldScissor;
if (clipRect || useIntermediate) {
UINT numRects = 1;
device()->RSGetScissorRects(&numRects, &oldScissor);
D3D10_RECT d3drect;
d3drect.left = scissorRect.x;
d3drect.top = scissorRect.y;
d3drect.right = scissorRect.x + scissorRect.width;
d3drect.bottom = scissorRect.y + scissorRect.height;
device()->RSSetScissorRects(1, &d3drect);
RECT r;
if (clipRect) {
r.left = (LONG)(clipRect->x - renderTargetOffset[0]);
r.top = (LONG)(clipRect->y - renderTargetOffset[1]);
r.right = (LONG)(clipRect->x - renderTargetOffset[0] + clipRect->width);
r.bottom = (LONG)(clipRect->y - renderTargetOffset[1] + clipRect->height);
} else {
// useIntermediate == true
r.left = 0;
r.top = 0;
r.right = visibleRect.width;
r.bottom = visibleRect.height;
}
D3D10_RECT d3drect;
if (!useIntermediate) {
if (clipRect) {
gfxRect cliprect(r.left, r.top, r.right - r.left, r.bottom - r.top);
gfxRect trScissor = contTransform.TransformBounds(cliprect);
trScissor.Round();
nsIntRect trIntScissor;
if (gfxUtils::GfxRectToIntRect(trScissor, &trIntScissor)) {
r.left = trIntScissor.x;
r.top = trIntScissor.y;
r.right = trIntScissor.XMost();
r.bottom = trIntScissor.YMost();
} else {
r.left = 0;
r.top = 0;
r.right = visibleRect.width;
r.bottom = visibleRect.height;
clipRect = nsnull;
}
}
// Scissor rect should be an intersection of the old and current scissor.
r.left = NS_MAX<PRInt32>(oldScissor.left, r.left);
r.right = NS_MIN<PRInt32>(oldScissor.right, r.right);
r.top = NS_MAX<PRInt32>(oldScissor.top, r.top);
r.bottom = NS_MIN<PRInt32>(oldScissor.bottom, r.bottom);
}
if (r.left >= r.right || r.top >= r.bottom) {
// Entire layer's clipped out, don't bother drawing.
continue;
}
d3drect.left = NS_MAX<PRInt32>(r.left, 0);
d3drect.top = NS_MAX<PRInt32>(r.top, 0);
d3drect.bottom = r.bottom;
d3drect.right = r.right;
device()->RSSetScissorRects(1, &d3drect);
}
// SetScissorRect
layerToRender->RenderLayer();
if (clipRect || useIntermediate) {
device()->RSSetScissorRects(1, &oldScissor);
}
}
device()->RSSetScissorRects(1, &oldD3D10Scissor);
if (useIntermediate) {
mD3DManager->SetViewport(previousViewportSize);

View File

@ -175,11 +175,17 @@ ContainerLayerD3D9::RenderLayer()
nsRefPtr<IDirect3DSurface9> previousRenderTarget;
nsRefPtr<IDirect3DTexture9> renderTexture;
float previousRenderTargetOffset[4];
RECT containerClipRect;
float renderTargetOffset[] = { 0, 0, 0, 0 };
float oldViewMatrix[4][4];
device()->GetScissorRect(&containerClipRect);
RECT containerD3D9ClipRect;
device()->GetScissorRect(&containerD3D9ClipRect);
// Convert scissor to an nsIntRect. RECT's are exclusive on the bottom and
// right values.
nsIntRect oldScissor(containerD3D9ClipRect.left,
containerD3D9ClipRect.top,
containerD3D9ClipRect.right - containerD3D9ClipRect.left,
containerD3D9ClipRect.bottom - containerD3D9ClipRect.top);
ReadbackProcessor readback;
readback.BuildUpdates(this);
@ -262,82 +268,36 @@ ContainerLayerD3D9::RenderLayer()
layerToRender != nsnull;
layerToRender = GetNextSiblingD3D9(layerToRender)) {
const nsIntRect* clipRect = layerToRender->GetLayer()->GetClipRect();
if ((clipRect && clipRect->IsEmpty()) ||
layerToRender->GetLayer()->GetEffectiveVisibleRegion().IsEmpty()) {
if (layerToRender->GetLayer()->GetEffectiveVisibleRegion().IsEmpty()) {
continue;
}
nsIntRect scissorRect =
layerToRender->GetLayer()->CalculateScissorRect(useIntermediate,
visibleRect,
oldScissor,
contTransform);
if (scissorRect.IsEmpty()) {
continue;
}
if (clipRect || useIntermediate) {
RECT r;
if (clipRect) {
r.left = (LONG)(clipRect->x - renderTargetOffset[0]);
r.top = (LONG)(clipRect->y - renderTargetOffset[1]);
r.right = (LONG)(clipRect->x - renderTargetOffset[0] + clipRect->width);
r.bottom = (LONG)(clipRect->y - renderTargetOffset[1] + clipRect->height);
} else {
r.left = 0;
r.top = 0;
r.right = visibleRect.width;
r.bottom = visibleRect.height;
}
nsRefPtr<IDirect3DSurface9> renderSurface;
device()->GetRenderTarget(0, getter_AddRefs(renderSurface));
D3DSURFACE_DESC desc;
renderSurface->GetDesc(&desc);
if (!useIntermediate) {
// Transform clip rect
if (clipRect) {
gfxRect cliprect(r.left, r.top, r.right - r.left, r.bottom - r.top);
gfxRect trScissor = contTransform.TransformBounds(cliprect);
trScissor.Round();
nsIntRect trIntScissor;
if (gfxUtils::GfxRectToIntRect(trScissor, &trIntScissor)) {
r.left = trIntScissor.x;
r.top = trIntScissor.y;
r.right = trIntScissor.XMost();
r.bottom = trIntScissor.YMost();
} else {
r.left = 0;
r.top = 0;
r.right = visibleRect.width;
r.bottom = visibleRect.height;
clipRect = nsnull;
}
}
// Intersect with current clip rect.
r.left = NS_MAX<PRInt32>(containerClipRect.left, r.left);
r.right = NS_MIN<PRInt32>(containerClipRect.right, r.right);
r.top = NS_MAX<PRInt32>(containerClipRect.top, r.top);
r.bottom = NS_MIN<PRInt32>(containerClipRect.bottom, r.bottom);
} else {
// > 0 is implied during the intersection when useIntermediate == true;
r.left = NS_MAX<LONG>(0, r.left);
r.top = NS_MAX<LONG>(0, r.top);
}
r.bottom = NS_MIN<LONG>(r.bottom, desc.Height);
r.right = NS_MIN<LONG>(r.right, desc.Width);
device()->SetScissorRect(&r);
}
RECT d3drect;
d3drect.left = scissorRect.x;
d3drect.top = scissorRect.y;
d3drect.right = scissorRect.x + scissorRect.width;
d3drect.bottom = scissorRect.y + scissorRect.height;
device()->SetScissorRect(&d3drect);
if (layerToRender->GetLayer()->GetType() == TYPE_THEBES) {
static_cast<ThebesLayerD3D9*>(layerToRender)->RenderThebesLayer(&readback);
} else {
layerToRender->RenderLayer();
}
if (clipRect && !useIntermediate) {
// In this situation we've set a new scissor rect and we will continue
// to render directly to our container. We need to restore its scissor.
// Not setting this when useIntermediate is true is an optimization since
// we'll get a new one set anyway.
device()->SetScissorRect(&containerClipRect);
}
}
device()->SetScissorRect(&containerD3D9ClipRect);
if (useIntermediate) {
device()->SetRenderTarget(0, previousRenderTarget);
@ -355,7 +315,6 @@ ContainerLayerD3D9::RenderLayer()
mD3DManager->SetShaderMode(DeviceManagerD3D9::RGBALAYER);
device()->SetScissorRect(&containerClipRect);
device()->SetTexture(0, renderTexture);
device()->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);
}

View File

@ -99,6 +99,10 @@ ShadowLayerParent::ActorDestroy(ActorDestroyReason why)
// let IPDL-generated code automatically clean up Shmems and so
// forth; our channel is disconnected anyway
break;
case FailedConstructor:
NS_RUNTIMEABORT("FailedConstructor isn't possible in PLayers");
return; // unreached
}
mLayer = NULL;

View File

@ -201,23 +201,14 @@ ContainerRender(Container* aContainer,
}
}
aContainer->gl()->fScissor(0, 0, visibleRect.width, visibleRect.height);
aContainer->gl()->PushViewportRect();
framebufferRect -= childOffset;
if (!aPreviousFrameBuffer) {
aContainer->gl()->FixWindowCoordinateRect(framebufferRect,
aManager->GetWigetSize().height);
}
aManager->CreateFBOWithTexture(framebufferRect,
mode,
&frameBuffer,
&containerSurface);
childOffset.x = visibleRect.x;
childOffset.y = visibleRect.y;
aContainer->gl()->PushViewportRect();
aManager->SetupPipeline(visibleRect.width, visibleRect.height,
LayerManagerOGL::DontApplyWorldTransform);
} else {
frameBuffer = aPreviousFrameBuffer;
aContainer->mSupportsComponentAlphaChildren = (aContainer->GetContentFlags() & Layer::CONTENT_OPAQUE) ||
@ -240,65 +231,25 @@ ContainerRender(Container* aContainer,
continue;
}
nsIntRect scissorRect(visibleRect);
nsIntRect scissorRect =
layerToRender->GetLayer()->CalculateScissorRect(needsFramebuffer,
visibleRect,
cachedScissor,
contTransform);
const nsIntRect *clipRect = layerToRender->GetLayer()->GetEffectiveClipRect();
if (clipRect) {
if (clipRect->IsEmpty()) {
continue;
}
scissorRect = *clipRect;
if (!needsFramebuffer) {
gfxRect r(scissorRect.x, scissorRect.y, scissorRect.width, scissorRect.height);
gfxRect trScissor = contTransform.TransformBounds(r);
trScissor.Round();
if (!gfxUtils::GfxRectToIntRect(trScissor, &scissorRect)) {
scissorRect = visibleRect;
}
}
if (scissorRect.IsEmpty()) {
continue;
}
if (needsFramebuffer) {
scissorRect.MoveBy(- visibleRect.TopLeft());
}
if (aManager->IsDrawingFlipped()) {
/**
* glScissor coordinates are oriented with 0,0 being at the bottom left,
* the opposite to layout (0,0 at the top left).
* All rendering to an FBO is upside-down, making the coordinate systems
* match.
* When rendering directly to a window (No current or previous FBO),
* we need to flip the scissor rect.
*/
aContainer->gl()->FixWindowCoordinateRect(scissorRect,
aContainer->gl()->ViewportRect().height);
}
if (clipRect && !needsFramebuffer) {
scissorRect.IntersectRect(scissorRect, cachedScissor);
}
/**
* We can't clip to a visible region if theres no framebuffer since we might be transformed
*/
if (needsFramebuffer || clipRect) {
aContainer->gl()->fScissor(scissorRect.x,
scissorRect.y,
scissorRect.width,
scissorRect.height);
} else {
aContainer->gl()->fScissor(cachedScissor.x,
cachedScissor.y,
cachedScissor.width,
cachedScissor.height);
}
aContainer->gl()->fScissor(scissorRect.x,
scissorRect.y,
scissorRect.width,
scissorRect.height);
layerToRender->RenderLayer(frameBuffer, childOffset);
aContainer->gl()->MakeCurrent();
}
aContainer->gl()->PopScissorRect();
if (needsFramebuffer) {
// Unbind the current framebuffer and rebind the previous one.
@ -308,6 +259,7 @@ ContainerRender(Container* aContainer,
nsIntRect viewport = aContainer->gl()->ViewportRect();
aManager->SetupPipeline(viewport.width, viewport.height,
LayerManagerOGL::ApplyWorldTransform);
aContainer->gl()->PopScissorRect();
aContainer->gl()->fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, aPreviousFrameBuffer);
aContainer->gl()->fDeleteFramebuffers(1, &frameBuffer);
@ -332,10 +284,15 @@ ContainerRender(Container* aContainer,
2, f);
}
aManager->BindAndDrawQuad(rgb, aManager->IsDrawingFlipped());
// Drawing is always flipped, but when copying between surfaces we want to avoid
// this. Pass true for the flip parameter to introduce a second flip
// that cancels the other one out.
aManager->BindAndDrawQuad(rgb, true);
// Clean up resources. This also unbinds the texture.
aContainer->gl()->fDeleteTextures(1, &containerSurface);
} else {
aContainer->gl()->PopScissorRect();
}
}

View File

@ -183,6 +183,7 @@ LayerManagerOGL::Initialize(nsRefPtr<GLContext> aContext)
return PR_FALSE;
mGLContext = aContext;
mGLContext->SetFlipped(PR_TRUE);
MakeCurrent();
@ -585,8 +586,6 @@ LayerManagerOGL::Render()
if (clipRect) {
nsIntRect r = *clipRect;
WorldTransformRect(r);
if (IsDrawingFlipped())
mGLContext->FixWindowCoordinateRect(r, mWidgetSize.height);
mGLContext->fScissor(r.x, r.y, r.width, r.height);
} else {
mGLContext->fScissor(0, 0, width, height);
@ -598,10 +597,10 @@ LayerManagerOGL::Render()
mGLContext->fClear(LOCAL_GL_COLOR_BUFFER_BIT | LOCAL_GL_DEPTH_BUFFER_BIT);
// Render our layers.
RootLayer()->RenderLayer(mGLContext->IsDoubleBuffered() && !mTarget ? 0 : mBackBufferFBO,
RootLayer()->RenderLayer(mGLContext->IsDoubleBuffered() ? 0 : mBackBufferFBO,
nsIntPoint(0, 0));
static_cast<nsIWidget_MOZILLA_2_0_BRANCH*>(mWidget)->DrawOver(this, rect);
mWidget->DrawOver(this, rect);
if (mTarget) {
CopyToTarget();
@ -722,52 +721,35 @@ void
LayerManagerOGL::SetupPipeline(int aWidth, int aHeight, WorldTransforPolicy aTransformPolicy)
{
// Set the viewport correctly.
//
// When we're not double buffering, we use a FBO as our backbuffer.
// We use a normal view transform in that case, meaning that our FBO
// and all other FBOs look upside down. We then do a Y-flip when
// we draw it into the window.
mGLContext->fViewport(0, 0, aWidth, aHeight);
// Matrix to transform to viewport space ( <-1.0, 1.0> topleft,
// <1.0, -1.0> bottomright).
// We flip the view matrix around so that everything is right-side up; we're
// drawing directly into the window's back buffer, so this keeps things
// looking correct.
//
// When we are double buffering, we change the view matrix around so
// that everything is right-side up; we're drawing directly into
// the window's back buffer, so this keeps things looking correct.
//
// XXX we could potentially always use the double-buffering view
// matrix and just change our single-buffer draw code.
//
// XXX we keep track of whether the window size changed, so we can
// skip this update if it hadn't since the last call.
gfx3DMatrix viewMatrix;
if (IsDrawingFlipped()) {
/* If it's double buffered, we don't have a frontbuffer FBO,
* so put in a Y-flip in this transform.
*/
viewMatrix._11 = 2.0f / float(aWidth);
viewMatrix._22 = -2.0f / float(aHeight);
viewMatrix._41 = -1.0f;
viewMatrix._42 = 1.0f;
} else {
viewMatrix._11 = 2.0f / float(aWidth);
viewMatrix._22 = 2.0f / float(aHeight);
viewMatrix._41 = -1.0f;
viewMatrix._42 = -1.0f;
}
// XXX: We keep track of whether the window size changed, so we could skip
// this update if it hadn't changed since the last call. We will need to
// track changes to aTransformPolicy and mWorldMatrix for this to work
// though.
// Matrix to transform (0, 0, aWidth, aHeight) to viewport space (-1.0, 1.0,
// 2, 2) and flip the contents.
gfxMatrix viewMatrix;
viewMatrix.Translate(-gfxPoint(1.0, -1.0));
viewMatrix.Scale(2.0f / float(aWidth), 2.0f / float(aHeight));
viewMatrix.Scale(1.0f, -1.0f);
if (aTransformPolicy == ApplyWorldTransform) {
viewMatrix = gfx3DMatrix::From2D(mWorldMatrix) * viewMatrix;
viewMatrix = mWorldMatrix * viewMatrix;
}
SetLayerProgramProjectionMatrix(viewMatrix);
SetLayerProgramProjectionMatrix(gfx3DMatrix::From2D(viewMatrix));
}
void
LayerManagerOGL::SetupBackBuffer(int aWidth, int aHeight)
{
if (mGLContext->IsDoubleBuffered() && !mTarget) {
if (mGLContext->IsDoubleBuffered()) {
mGLContext->fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, 0);
return;
}
@ -825,11 +807,17 @@ LayerManagerOGL::CopyToTarget()
gfxASurface::ImageFormatARGB32);
mGLContext->fBindFramebuffer(LOCAL_GL_FRAMEBUFFER,
mBackBufferFBO);
mGLContext->IsDoubleBuffered() ? 0 : mBackBufferFBO);
if (mGLContext->IsDoubleBuffered()) {
mGLContext->fReadBuffer(LOCAL_GL_BACK);
}
#ifndef USE_GLES2
else {
// GLES2 promises that binding to any custom FBO will attach
// to GL_COLOR_ATTACHMENT0 attachment point.
mGLContext->fReadBuffer(LOCAL_GL_COLOR_ATTACHMENT0);
}
#endif
GLenum format = LOCAL_GL_RGBA;
@ -868,7 +856,9 @@ LayerManagerOGL::CopyToTarget()
}
}
mTarget->SetOperator(gfxContext::OPERATOR_OVER);
mTarget->SetOperator(gfxContext::OPERATOR_SOURCE);
mTarget->Scale(1.0, -1.0);
mTarget->Translate(-gfxPoint(0.0, height));
mTarget->SetSource(imageSurface);
mTarget->Paint();
}
@ -954,6 +944,9 @@ LayerManagerOGL::CreateFBOWithTexture(const nsIntRect& aRect, InitMode aInit,
NS_ASSERTION(mGLContext->fCheckFramebufferStatus(LOCAL_GL_FRAMEBUFFER) ==
LOCAL_GL_FRAMEBUFFER_COMPLETE, "Error setting up framebuffer.");
SetupPipeline(aRect.width, aRect.height, DontApplyWorldTransform);
mGLContext->fScissor(0, 0, aRect.width, aRect.height);
if (aInit == InitModeClear) {
mGLContext->fClearColor(0.0, 0.0, 0.0, 0.0);
mGLContext->fClear(LOCAL_GL_COLOR_BUFFER_BIT);

View File

@ -382,15 +382,7 @@ public:
* to a window of the given dimensions.
*/
void SetupPipeline(int aWidth, int aHeight, WorldTransforPolicy aTransformPolicy);
/**
* Returns true if the viewport has a Y axip flip transform applied, and all
* drawing will be done upside-down.
*/
bool IsDrawingFlipped() {
return mGLContext->IsDoubleBuffered() && !mTarget;
}
/**
* Setup World transform matrix.
* Transform will be ignored if it is not PreservesAxisAlignedRectangles

View File

@ -572,7 +572,7 @@ BasicTextureImage::BeginUpdate(nsIntRegion& aRegion)
ImageFormat format =
(GetContentType() == gfxASurface::CONTENT_COLOR) ?
gfxASurface::ImageFormatRGB24 : gfxASurface::ImageFormatARGB32;
if (!mTextureInited)
if (mTextureState != Valid)
{
// if the texture hasn't been initialized yet, or something important
// changed, we need to recreate our backing surface and force the
@ -620,13 +620,13 @@ BasicTextureImage::EndUpdate()
mGLContext->UploadSurfaceToTexture(mUpdateSurface,
mUpdateRegion,
mTexture,
!mTextureInited,
mTextureState == Created,
mUpdateOffset,
relative);
FinishedSurfaceUpload();
mUpdateSurface = nsnull;
mTextureInited = PR_TRUE;
mTextureState = Valid;
}
already_AddRefed<gfxASurface>
@ -652,7 +652,7 @@ BasicTextureImage::DirectUpdate(gfxASurface *aSurf, const nsIntRegion& aRegion)
{
nsIntRect bounds = aRegion.GetBounds();
nsIntRegion region;
if (!mTextureInited) {
if (mTextureState != Valid) {
bounds = nsIntRect(0, 0, mSize.width, mSize.height);
region = nsIntRegion(bounds);
} else {
@ -663,10 +663,10 @@ BasicTextureImage::DirectUpdate(gfxASurface *aSurf, const nsIntRegion& aRegion)
mGLContext->UploadSurfaceToTexture(aSurf,
region,
mTexture,
!mTextureInited,
mTextureState == Created,
bounds.TopLeft(),
PR_FALSE);
mTextureInited = PR_TRUE;
mTextureState = Valid;
return true;
}
@ -687,7 +687,7 @@ BasicTextureImage::Resize(const nsIntSize& aSize)
LOCAL_GL_UNSIGNED_BYTE,
NULL);
mTextureInited = PR_TRUE;
mTextureState = Initialized;
mSize = aSize;
}

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