This commit is contained in:
Ryan VanderMeulen 2014-08-16 17:42:29 -04:00
Родитель 60b607ba5b 8abfa775a1
Коммит 5fe0932115
272 изменённых файлов: 4243 добавлений и 4856 удалений

Просмотреть файл

@ -196,8 +196,10 @@ static void
LogDocParent(nsIDocument* aDocumentNode)
{
nsIDocument* parentDoc = aDocumentNode->GetParentDocument();
printf("parent id: %p", static_cast<void*>(parentDoc));
printf("parent DOM document: %p", static_cast<void*>(parentDoc));
if (parentDoc) {
printf(", parent acc document: %p",
static_cast<void*>(GetExistingDocAccessible(parentDoc)));
printf("\n parent ");
LogDocURI(parentDoc);
printf("\n");

Просмотреть файл

@ -12,6 +12,7 @@
#include "nsAccUtils.h"
#include "nsCoreUtils.h"
#include "nsEventShell.h"
#include "nsFrameSelection.h"
#include "nsIAccessibleTypes.h"
#include "nsIDOMDocument.h"

Просмотреть файл

@ -972,10 +972,10 @@ nsAccessibilityService::GetOrCreateAccessible(nsINode* aNode,
// If table has strong ARIA role then all table descendants shouldn't
// expose their native roles.
if (!roleMapEntry && newAcc) {
if (!roleMapEntry && newAcc && aContext->HasStrongARIARole()) {
if (frame->AccessibleType() == eHTMLTableRowType) {
nsRoleMapEntry* contextRoleMap = aContext->ARIARoleMap();
if (contextRoleMap && !(contextRoleMap->IsOfType(eTable)))
if (!contextRoleMap->IsOfType(eTable))
roleMapEntry = &aria::gEmptyRoleMap;
} else if (frame->AccessibleType() == eHTMLTableCellType &&
@ -987,7 +987,7 @@ nsAccessibilityService::GetOrCreateAccessible(nsINode* aNode,
content->Tag() == nsGkAtoms::dd ||
frame->AccessibleType() == eHTMLLiType) {
nsRoleMapEntry* contextRoleMap = aContext->ARIARoleMap();
if (contextRoleMap && !(contextRoleMap->IsOfType(eList)))
if (!contextRoleMap->IsOfType(eList))
roleMapEntry = &aria::gEmptyRoleMap;
}
}

Просмотреть файл

@ -28,6 +28,12 @@ Accessible::IsARIARole(nsIAtom* aARIARole) const
return mRoleMapEntry && mRoleMapEntry->Is(aARIARole);
}
inline bool
Accessible::HasStrongARIARole() const
{
return mRoleMapEntry && mRoleMapEntry->roleRule == kUseMapRole;
}
inline mozilla::a11y::role
Accessible::ARIARole()
{

Просмотреть файл

@ -219,6 +219,7 @@ public:
*/
bool HasARIARole() const { return mRoleMapEntry; }
bool IsARIARole(nsIAtom* aARIARole) const;
bool HasStrongARIARole() const;
/**
* Retrun ARIA role map if any.

Просмотреть файл

@ -14,6 +14,7 @@
#include "nsIEditor.h"
#include "nsIPersistentProperties2.h"
#include "nsIPlaintextEditor.h"
#include "nsFrameSelection.h"
namespace mozilla {
namespace a11y {
@ -143,7 +144,7 @@ HyperTextAccessible::IsCaretAtEndOfLine() const
{
nsRefPtr<nsFrameSelection> frameSelection = FrameSelection();
return frameSelection &&
frameSelection->GetHint() == nsFrameSelection::HINTLEFT;
frameSelection->GetHint() == CARET_ASSOCIATE_BEFORE;
}
inline already_AddRefed<nsFrameSelection>

Просмотреть файл

@ -1269,7 +1269,7 @@ HyperTextAccessible::CaretLineNumber()
int32_t returnOffsetUnused;
uint32_t caretOffset = domSel->FocusOffset();
nsFrameSelection::HINT hint = frameSelection->GetHint();
CaretAssociationHint hint = frameSelection->GetHint();
nsIFrame *caretFrame = frameSelection->GetFrameForNodeOffset(caretContent, caretOffset,
hint, &returnOffsetUnused);
NS_ENSURE_TRUE(caretFrame, -1);
@ -1322,16 +1322,12 @@ HyperTextAccessible::GetCaretRect(nsIWidget** aWidget)
nsRefPtr<nsCaret> caret = mDoc->PresShell()->GetCaret();
NS_ENSURE_TRUE(caret, nsIntRect());
nsISelection* caretSelection = caret->GetCaretDOMSelection();
NS_ENSURE_TRUE(caretSelection, nsIntRect());
bool isVisible = false;
caret->GetCaretVisible(&isVisible);
bool isVisible = caret->IsVisible();
if (!isVisible)
return nsIntRect();
nsRect rect;
nsIFrame* frame = caret->GetGeometry(caretSelection, &rect);
nsIFrame* frame = caret->GetGeometry(&rect);
if (!frame || rect.IsEmpty())
return nsIntRect();

Просмотреть файл

@ -9,11 +9,22 @@
#include "AccessibleWrap.h"
#include "nsIAccessibleTypes.h"
#include "xpcAccessibleHyperText.h"
#include "nsDirection.h"
#include "WordMovementType.h"
#include "nsIFrame.h"
#include "nsFrameSelection.h"
#include "nsISelectionController.h"
class nsFrameSelection;
class nsRange;
class nsIWidget;
namespace mozilla {
namespace dom {
class Selection;
}
namespace a11y {
class TextRange;

Просмотреть файл

@ -396,7 +396,7 @@ this.ContentControl.prototype = {
this._contentScope.get().sendAsyncMessage(
'AccessFu:Present', Presentation.pivotChanged(
vc.position, null, Ci.nsIAccessiblePivot.REASON_NONE,
vc.startOffset, vc.endOffset));
vc.startOffset, vc.endOffset, false));
}
};
@ -416,11 +416,12 @@ this.ContentControl.prototype = {
let moveFirstOrLast = moveMethod in ['moveFirst', 'moveLast'];
if (!moveFirstOrLast || acc) {
// We either need next/previous or there is an anchor we need to use.
moved = vc[moveFirstOrLast ? 'moveNext' : moveMethod](rule, acc, true);
moved = vc[moveFirstOrLast ? 'moveNext' : moveMethod](rule, acc, true,
false);
}
if (moveFirstOrLast && !moved) {
// We move to first/last after no anchor move happened or succeeded.
moved = vc[moveMethod](rule);
moved = vc[moveMethod](rule, false);
}
let sentToChild = this.sendToChild(vc, {

Просмотреть файл

@ -161,7 +161,8 @@ this.EventManager.prototype = {
}
this.present(
Presentation.pivotChanged(position, oldAccessible, reason,
pivot.startOffset, pivot.endOffset));
pivot.startOffset, pivot.endOffset,
aEvent.isFromUserInput));
break;
}

Просмотреть файл

@ -46,8 +46,9 @@ Presenter.prototype = {
* position.
* @param {int} aReason the reason for the pivot change.
* See nsIAccessiblePivot.
* @param {bool} aIsFromUserInput the pivot change was invoked by the user
*/
pivotChanged: function pivotChanged(aContext, aReason) {}, // jshint ignore:line
pivotChanged: function pivotChanged(aContext, aReason, aIsFromUserInput) {}, // jshint ignore:line
/**
* An object's action has been invoked.
@ -66,7 +67,7 @@ Presenter.prototype = {
* Text selection has changed. TODO.
*/
textSelectionChanged: function textSelectionChanged(
aText, aStart, aEnd, aOldStart, aOldEnd, aIsFromUser) {}, // jshint ignore:line
aText, aStart, aEnd, aOldStart, aOldEnd, aIsFromUserInput) {}, // jshint ignore:line
/**
* Selection has changed. TODO.
@ -362,15 +363,15 @@ AndroidPresenter.prototype.textChanged = function AndroidPresenter_textChanged(
AndroidPresenter.prototype.textSelectionChanged =
function AndroidPresenter_textSelectionChanged(aText, aStart, aEnd, aOldStart,
aOldEnd, aIsFromUser) {
aOldEnd, aIsFromUserInput) {
let androidEvents = [];
if (Utils.AndroidSdkVersion >= 14 && !aIsFromUser) {
if (Utils.AndroidSdkVersion >= 14 && !aIsFromUserInput) {
if (!this._braillePresenter) {
this._braillePresenter = new BraillePresenter();
}
let brailleOutput = this._braillePresenter.textSelectionChanged(
aText, aStart, aEnd, aOldStart, aOldEnd, aIsFromUser).details;
aText, aStart, aEnd, aOldStart, aOldEnd, aIsFromUserInput).details;
androidEvents.push({
eventType: this.ANDROID_VIEW_TEXT_SELECTION_CHANGED,
@ -382,7 +383,7 @@ AndroidPresenter.prototype.textSelectionChanged =
});
}
if (Utils.AndroidSdkVersion >= 16 && aIsFromUser) {
if (Utils.AndroidSdkVersion >= 16 && aIsFromUserInput) {
let [from, to] = aOldStart < aStart ?
[aOldStart, aStart] : [aStart, aOldStart];
androidEvents.push({
@ -469,7 +470,7 @@ B2GPresenter.prototype.pivotChangedReasons = ['none', 'next', 'prev', 'first',
'last', 'text', 'point'];
B2GPresenter.prototype.pivotChanged =
function B2GPresenter_pivotChanged(aContext, aReason) {
function B2GPresenter_pivotChanged(aContext, aReason, aIsUserInput) {
if (!aContext.accessible) {
return null;
}
@ -482,7 +483,8 @@ B2GPresenter.prototype.pivotChanged =
options: {
pattern: this.PIVOT_CHANGE_HAPTIC_PATTERN,
isKey: aContext.accessible.role === Roles.KEY,
reason: this.pivotChangedReasons[aReason]
reason: this.pivotChangedReasons[aReason],
isUserInput: aIsUserInput
}
}
};
@ -584,10 +586,11 @@ this.Presentation = { // jshint ignore:line
},
pivotChanged: function Presentation_pivotChanged(
aPosition, aOldPosition, aReason, aStartOffset, aEndOffset) {
aPosition, aOldPosition, aReason, aStartOffset, aEndOffset, aIsUserInput) {
let context = new PivotContext(
aPosition, aOldPosition, aStartOffset, aEndOffset);
return [p.pivotChanged(context, aReason) for each (p in this.presenters)]; // jshint ignore:line
return [p.pivotChanged(context, aReason, aIsUserInput)
for each (p in this.presenters)]; // jshint ignore:line
},
actionInvoked: function Presentation_actionInvoked(aObject, aActionName) {
@ -604,9 +607,9 @@ this.Presentation = { // jshint ignore:line
textSelectionChanged: function textSelectionChanged(aText, aStart, aEnd,
aOldStart, aOldEnd,
aIsFromUser) {
aIsFromUserInput) {
return [p.textSelectionChanged(aText, aStart, aEnd, aOldStart, aOldEnd, // jshint ignore:line
aIsFromUser) for each (p in this.presenters)]; // jshint ignore:line
aIsFromUserInput) for each (p in this.presenters)]; // jshint ignore:line
},
valueChanged: function valueChanged(aAccessible) {

Просмотреть файл

@ -162,6 +162,18 @@
};
testAccessibleTree("table5", accTree);
/////////////////////////////////////////////////////////////////////////
// log table
accTree =
{ TABLE: [
{ ROW: [
{ CELL: [
{ TEXT_LEAF: [ ] }
] }
] }
] };
testAccessibleTree("logtable", accTree);
SimpleTest.finish();
}
@ -264,5 +276,7 @@
</tr>
</tbody>
</table>
<table id="logtable" role="log"><tr><td>blah</td></tr></table>
</body>
</html>

Просмотреть файл

@ -16,6 +16,7 @@
#include "nsIArray.h"
#include "nsIDocument.h"
#include "nsIDocShellTreeItem.h"
#include "nsIDOMElement.h"
#include "nsXULAppAPI.h"
using namespace mozilla;

Просмотреть файл

@ -17,6 +17,7 @@
#include "nsNameSpaceManager.h"
#include "nsServiceManagerUtils.h"
#include "nsWinUtils.h"
#include "nsRange.h"
#include "nsAutoPtr.h"

Просмотреть файл

@ -15,6 +15,7 @@
#include "nsFontMetrics.h"
#include "nsPresContext.h"
#include "nsLayoutUtils.h"
#include "nsRange.h"
#include "gfxFont.h"
#include "nsIAccessibleTypes.h"
#include "mozilla/gfx/2D.h"

Просмотреть файл

@ -8,8 +8,8 @@
#include "HyperTextAccessible.h"
#include "TextRange.h"
#include "nsIMutableArray.h"
#include "nsIMutableArray.h"
#include "nsComponentManagerUtils.h"
using namespace mozilla;
using namespace mozilla::a11y;

Просмотреть файл

@ -59,9 +59,6 @@ leak:event_base_once
# Bug 1021854 - nsFileStreamBase::DoOpen() leaking fds. bc1, oth
leak:nsLocalFile::OpenNSPRFileDesc
# Bug 1023585 - Leak of array buffer in JSStructuredCloneWriter::transferOwnership(). m1
leak:AllocateArrayBufferContents
# Bug 1022010 - Small leak under _render_glyph_outline. bc1
leak:_render_glyph_outline

1
config/external/nss/nss.def поставляемый
Просмотреть файл

@ -647,6 +647,7 @@ SSL_NumImplementedCiphers DATA
SSL_OptionSet
SSL_OptionSetDefault
SSL_PeerCertificate
SSL_PeerCertificateChain
SSL_PeerStapledOCSPResponses
SSL_ResetHandshake
SSL_SetCanFalseStartCallback

Просмотреть файл

@ -8340,10 +8340,6 @@ if test "$MOZ_APP_COMPONENT_INCLUDE"; then
AC_DEFINE_UNQUOTED(MOZ_APP_COMPONENT_INCLUDE, "$MOZ_APP_COMPONENT_INCLUDE")
fi
if test "$MOZ_APP_COMPONENT_MODULES"; then
AC_DEFINE_UNQUOTED(MOZ_APP_COMPONENT_MODULES, $MOZ_APP_COMPONENT_MODULES)
fi
dnl ========================================================
dnl =
dnl = Maintainer debug option (no --enable equivalent)
@ -8737,7 +8733,6 @@ AC_SUBST(CC_VERSION)
AC_SUBST(CXX_VERSION)
AC_SUBST(MSMANIFEST_TOOL)
AC_SUBST(NS_ENABLE_TSF)
AC_SUBST_LIST(MOZ_APP_EXTRA_LIBS)
AC_SUBST(MOZ_WAVE)
AC_SUBST(MOZ_VORBIS)

Просмотреть файл

@ -12,6 +12,7 @@
// Interface headers
#include "imgLoader.h"
#include "nsIContent.h"
#include "nsIContentInlines.h"
#include "nsIDocShell.h"
#include "nsIDocument.h"
#include "nsIDOMCustomEvent.h"
@ -82,6 +83,7 @@
#include "mozilla/EventDispatcher.h"
#include "mozilla/EventStates.h"
#include "mozilla/Telemetry.h"
#include "mozilla/dom/HTMLObjectElementBinding.h"
#ifdef XP_WIN
// Thanks so much, Microsoft! :(
@ -915,6 +917,167 @@ nsObjectLoadingContent::InstantiatePluginInstance(bool aIsLoading)
return NS_OK;
}
void
nsObjectLoadingContent::GetPluginAttributes(nsTArray<MozPluginParameter>& aAttributes)
{
aAttributes = mCachedAttributes;
}
void
nsObjectLoadingContent::GetPluginParameters(nsTArray<MozPluginParameter>& aParameters)
{
aParameters = mCachedParameters;
}
void
nsObjectLoadingContent::GetNestedParams(nsTArray<MozPluginParameter>& aParams,
bool aIgnoreCodebase)
{
nsCOMPtr<nsIDOMElement> domElement =
do_QueryInterface(static_cast<nsIObjectLoadingContent*>(this));
nsCOMPtr<nsIDOMHTMLCollection> allParams;
NS_NAMED_LITERAL_STRING(xhtml_ns, "http://www.w3.org/1999/xhtml");
domElement->GetElementsByTagNameNS(xhtml_ns,
NS_LITERAL_STRING("param"), getter_AddRefs(allParams));
if (!allParams)
return;
uint32_t numAllParams;
allParams->GetLength(&numAllParams);
for (uint32_t i = 0; i < numAllParams; i++) {
nsCOMPtr<nsIDOMNode> pNode;
allParams->Item(i, getter_AddRefs(pNode));
nsCOMPtr<nsIDOMElement> element = do_QueryInterface(pNode);
if (!element)
continue;
nsAutoString name;
element->GetAttribute(NS_LITERAL_STRING("name"), name);
if (name.IsEmpty())
continue;
nsCOMPtr<nsIDOMNode> parent;
nsCOMPtr<nsIDOMHTMLObjectElement> domObject;
nsCOMPtr<nsIDOMHTMLAppletElement> domApplet;
pNode->GetParentNode(getter_AddRefs(parent));
while (!(domObject || domApplet) && parent) {
domObject = do_QueryInterface(parent);
domApplet = do_QueryInterface(parent);
nsCOMPtr<nsIDOMNode> temp;
parent->GetParentNode(getter_AddRefs(temp));
parent = temp;
}
if (domApplet) {
parent = do_QueryInterface(domApplet);
} else if (domObject) {
parent = do_QueryInterface(domObject);
} else {
continue;
}
nsCOMPtr<nsIDOMNode> domNode = do_QueryInterface(domElement);
if (parent == domNode) {
MozPluginParameter param;
element->GetAttribute(NS_LITERAL_STRING("name"), param.mName);
element->GetAttribute(NS_LITERAL_STRING("value"), param.mValue);
param.mName.Trim(" \n\r\t\b", true, true, false);
param.mValue.Trim(" \n\r\t\b", true, true, false);
// ignore codebase param if it was already added in the attributes array.
if (aIgnoreCodebase && param.mName.EqualsIgnoreCase("codebase")) {
continue;
}
aParams.AppendElement(param);
}
}
}
void
nsObjectLoadingContent::BuildParametersArray()
{
if (mCachedAttributes.Length() || mCachedParameters.Length()) {
MOZ_ASSERT(false, "Parameters array should be empty.");
return;
}
nsCOMPtr<nsIContent> content =
do_QueryInterface(static_cast<nsIImageLoadingContent*>(this));
int32_t start = 0, end = content->GetAttrCount(), step = 1;
// HTML attributes are stored in reverse order.
if (content->IsHTML() && content->IsInHTMLDocument()) {
start = end - 1;
end = -1;
step = -1;
}
for (int32_t i = start; i != end; i += step) {
MozPluginParameter param;
const nsAttrName* attrName = content->GetAttrNameAt(i);
nsIAtom* atom = attrName->LocalName();
content->GetAttr(attrName->NamespaceID(), atom, param.mValue);
atom->ToString(param.mName);
mCachedAttributes.AppendElement(param);
}
bool isJava = nsPluginHost::IsJavaMIMEType(mContentType.get());
nsCString codebase;
if (isJava) {
mBaseURI->GetSpec(codebase);
}
nsAdoptingCString wmodeOverride = Preferences::GetCString("plugins.force.wmode");
for (uint32_t i = 0; i < mCachedAttributes.Length(); i++) {
if (!wmodeOverride.IsEmpty() && mCachedAttributes[i].mName.EqualsIgnoreCase("wmode")) {
CopyASCIItoUTF16(wmodeOverride, mCachedAttributes[i].mValue);
wmodeOverride.Truncate();
} else if (!codebase.IsEmpty() && mCachedAttributes[i].mName.EqualsIgnoreCase("codebase")) {
CopyASCIItoUTF16(codebase, mCachedAttributes[i].mValue);
codebase.Truncate();
}
}
if (!wmodeOverride.IsEmpty()) {
MozPluginParameter param;
param.mName = NS_LITERAL_STRING("wmode");
CopyASCIItoUTF16(wmodeOverride, param.mValue);
mCachedAttributes.AppendElement(param);
}
if (!codebase.IsEmpty()) {
MozPluginParameter param;
param.mName = NS_LITERAL_STRING("codebase");
CopyASCIItoUTF16(codebase, param.mValue);
mCachedAttributes.AppendElement(param);
}
// Some plugins were never written to understand the "data" attribute of the OBJECT tag.
// Real and WMP will not play unless they find a "src" attribute, see bug 152334.
// Nav 4.x would simply replace the "data" with "src". Because some plugins correctly
// look for "data", lets instead copy the "data" attribute and add another entry
// to the bottom of the array if there isn't already a "src" specified.
if (content->Tag() == nsGkAtoms::object &&
!content->HasAttr(kNameSpaceID_None, nsGkAtoms::src)) {
MozPluginParameter param;
content->GetAttr(kNameSpaceID_None, nsGkAtoms::data, param.mValue);
if (!param.mValue.IsEmpty()) {
param.mName = NS_LITERAL_STRING("SRC");
mCachedAttributes.AppendElement(param);
}
}
GetNestedParams(mCachedParameters, isJava);
}
void
nsObjectLoadingContent::NotifyOwnerDocumentActivityChanged()
{
@ -1502,59 +1665,15 @@ nsObjectLoadingContent::UpdateObjectParameters(bool aJavaURI)
// Java wants the codebase attribute even if it occurs in <param> tags
// XXX(johns): This duplicates a chunk of code from nsInstanceOwner, see
// bug 853995
if (isJava) {
// Find all <param> tags that are nested beneath us, but not beneath another
// object/applet tag.
nsCOMArray<nsIDOMElement> ourParams;
nsCOMPtr<nsIDOMElement> mydomElement = do_QueryInterface(thisContent);
nsCOMPtr<nsIDOMHTMLCollection> allParams;
NS_NAMED_LITERAL_STRING(xhtml_ns, "http://www.w3.org/1999/xhtml");
mydomElement->GetElementsByTagNameNS(xhtml_ns, NS_LITERAL_STRING("param"),
getter_AddRefs(allParams));
if (allParams) {
uint32_t numAllParams;
allParams->GetLength(&numAllParams);
for (uint32_t i = 0; i < numAllParams; i++) {
nsCOMPtr<nsIDOMNode> pnode;
allParams->Item(i, getter_AddRefs(pnode));
nsCOMPtr<nsIDOMElement> domelement = do_QueryInterface(pnode);
if (domelement) {
nsAutoString name;
domelement->GetAttribute(NS_LITERAL_STRING("name"), name);
name.Trim(" \n\r\t\b", true, true, false);
if (name.EqualsIgnoreCase("codebase")) {
// Find the first plugin element parent
nsCOMPtr<nsIDOMNode> parent;
nsCOMPtr<nsIDOMHTMLObjectElement> domobject;
nsCOMPtr<nsIDOMHTMLAppletElement> domapplet;
pnode->GetParentNode(getter_AddRefs(parent));
while (!(domobject || domapplet) && parent) {
domobject = do_QueryInterface(parent);
domapplet = do_QueryInterface(parent);
nsCOMPtr<nsIDOMNode> temp;
parent->GetParentNode(getter_AddRefs(temp));
parent = temp;
}
if (domapplet || domobject) {
if (domapplet) {
parent = do_QueryInterface(domapplet);
}
else {
parent = do_QueryInterface(domobject);
}
nsCOMPtr<nsIDOMNode> mydomNode = do_QueryInterface(mydomElement);
if (parent == mydomNode) {
hasCodebase = true;
domelement->GetAttribute(NS_LITERAL_STRING("value"),
codebaseStr);
codebaseStr.Trim(" \n\r\t\b", true, true, false);
}
}
}
}
nsTArray<MozPluginParameter> params;
GetNestedParams(params, false);
for (uint32_t i = 0; i < params.Length(); i++) {
if (params[i].mName.EqualsIgnoreCase("codebase")) {
hasCodebase = true;
codebaseStr = params[i].mValue;
}
}
}
@ -2121,6 +2240,12 @@ nsObjectLoadingContent::LoadObject(bool aNotify,
/// Attempt to load new type
///
// Cache the current attributes and parameters.
if (mType == eType_Plugin || mType == eType_Null) {
BuildParametersArray();
}
// We don't set mFinalListener until OnStartRequest has been called, to
// prevent re-entry ugliness with CloseChannel()
nsCOMPtr<nsIStreamListener> finalListener;
@ -2477,6 +2602,9 @@ nsObjectLoadingContent::UnloadObject(bool aResetState)
mIsStopping = false;
}
mCachedAttributes.Clear();
mCachedParameters.Clear();
// This call should be last as it may re-enter
StopPluginInstance();
}

Просмотреть файл

@ -34,6 +34,7 @@ class nsPluginInstanceOwner;
namespace mozilla {
namespace dom {
template<typename T> class Sequence;
struct MozPluginParameter;
}
}
@ -119,6 +120,19 @@ class nsObjectLoadingContent : public nsImageLoadingContent
mNetworkCreated = aNetworkCreated;
}
/**
* When the object is loaded, the attributes and all nested <param>
* elements are cached as name:value string pairs to be passed as
* parameters when instantiating the plugin.
*
* Note: these cached values can be overriden for different quirk cases.
*/
// Returns the cached attributes array.
void GetPluginAttributes(nsTArray<mozilla::dom::MozPluginParameter>& aAttributes);
// Returns the cached <param> array.
void GetPluginParameters(nsTArray<mozilla::dom::MozPluginParameter>& aParameters);
/**
* Immediately instantiate a plugin instance. This is a no-op if mType !=
* eType_Plugin or a plugin is already running.
@ -322,6 +336,26 @@ class nsObjectLoadingContent : public nsImageLoadingContent
eParamContentTypeChanged = 1u << 2
};
/**
* Getter for child <param> elements that are not nested in another plugin
* dom element.
* This is an internal helper function and should not be used directly for
* passing parameters to the plugin instance.
*
* See GetPluginParameters and GetPluginAttributes, which also handle
* quirk-overrides.
*
* @param aParameters The array containing pairs of name/value strings
* from nested <param> objects.
* @param aIgnoreCodebase Flag for ignoring the "codebase" param when
* building the array. This is useful when loading
* java.
*/
void GetNestedParams(nsTArray<mozilla::dom::MozPluginParameter>& aParameters,
bool aIgnoreCodebase);
void BuildParametersArray();
/**
* Loads fallback content with the specified FallbackType
*
@ -579,6 +613,8 @@ class nsObjectLoadingContent : public nsImageLoadingContent
nsWeakFrame mPrintFrame;
nsRefPtr<nsPluginInstanceOwner> mInstanceOwner;
nsTArray<mozilla::dom::MozPluginParameter> mCachedAttributes;
nsTArray<mozilla::dom::MozPluginParameter> mCachedParameters;
};
#endif

Просмотреть файл

@ -45,6 +45,7 @@
#include "mozilla/dom/ScriptSettings.h"
#include "mozilla/dom/HTMLInputElement.h"
#include "nsNumberControlFrame.h"
#include "nsFrameSelection.h"
using namespace mozilla;
using namespace mozilla::dom;
@ -417,10 +418,8 @@ nsTextInputSelectionImpl::GetCaretVisible(bool *_retval)
{
nsRefPtr<nsCaret> caret = shell->GetCaret();
if (caret) {
nsISelection* domSel = mFrameSelection->
GetSelection(nsISelectionController::SELECTION_NORMAL);
if (domSel)
return caret->GetCaretVisible(_retval);
*_retval = caret->IsVisible();
return NS_OK;
}
}
return NS_ERROR_FAILURE;
@ -546,7 +545,7 @@ nsTextInputSelectionImpl::CompleteMove(bool aForward, bool aExtend)
// make the caret be either at the very beginning (0) or the very end
int32_t offset = 0;
nsFrameSelection::HINT hint = nsFrameSelection::HINTLEFT;
CaretAssociationHint hint = CARET_ASSOCIATE_BEFORE;
if (aForward)
{
offset = parentDIV->GetChildCount();
@ -561,7 +560,7 @@ nsTextInputSelectionImpl::CompleteMove(bool aForward, bool aExtend)
if (child->Tag() == nsGkAtoms::br)
{
--offset;
hint = nsFrameSelection::HINTRIGHT; // for Bug 106855
hint = CARET_ASSOCIATE_AFTER; // for Bug 106855
}
}
}

Просмотреть файл

@ -196,6 +196,18 @@ DOMMediaStream::GetVideoTracks(nsTArray<nsRefPtr<VideoStreamTrack> >& aTracks)
}
}
void
DOMMediaStream::GetTracks(nsTArray<nsRefPtr<MediaStreamTrack> >& aTracks)
{
aTracks.AppendElements(mTracks);
}
bool
DOMMediaStream::HasTrack(const MediaStreamTrack& aTrack) const
{
return mTracks.Contains(&aTrack);
}
bool
DOMMediaStream::IsFinished()
{

Просмотреть файл

@ -81,6 +81,8 @@ public:
void GetAudioTracks(nsTArray<nsRefPtr<AudioStreamTrack> >& aTracks);
void GetVideoTracks(nsTArray<nsRefPtr<VideoStreamTrack> >& aTracks);
void GetTracks(nsTArray<nsRefPtr<MediaStreamTrack> >& aTracks);
bool HasTrack(const MediaStreamTrack& aTrack) const;
MediaStream* GetStream() const { return mStream; }

Просмотреть файл

@ -298,6 +298,12 @@ AppleVTDecoder::OutputFrame(CVPixelBufferRef aImage,
// Unlock the returned image data.
CVPixelBufferUnlockBaseAddress(aImage, kCVPixelBufferLock_ReadOnly);
if (!data) {
NS_ERROR("Couldn't create VideoData for frame");
mCallback->Error();
return NS_ERROR_FAILURE;
}
// Frames come out in DTS order but we need to output them
// in composition order.
mReorderQueue.Push(data.forget());

Просмотреть файл

@ -2145,8 +2145,7 @@ nsFocusManager::SetCaretVisible(nsIPresShell* aPresShell,
if (!caret)
return NS_OK;
bool caretVisible = false;
caret->GetCaretVisible(&caretVisible);
bool caretVisible = caret->IsVisible();
if (!aVisible && !caretVisible)
return NS_OK;
@ -2176,7 +2175,7 @@ nsFocusManager::SetCaretVisible(nsIPresShell* aPresShell,
// Caret must blink on non-editable elements
caret->SetIgnoreUserModify(true);
// Tell the caret which selection to use
caret->SetCaretDOMSelection(domSelection);
caret->SetSelection(domSelection);
// In content, we need to set the caret. The only special case is edit
// fields, which have a different frame selection from the document.
@ -2295,9 +2294,8 @@ nsFocusManager::GetSelectionLocation(nsIDocument* aDocument,
if (newCaretFrame && newCaretContent) {
// If the caret is exactly at the same position of the new frame,
// then we can use the newCaretFrame and newCaretContent for our position
nsRefPtr<nsCaret> caret = aPresShell->GetCaret();
nsRect caretRect;
nsIFrame *frame = caret->GetGeometry(domSelection, &caretRect);
nsIFrame *frame = nsCaret::GetGeometry(domSelection, &caretRect);
if (frame) {
nsPoint caretWidgetOffset;
nsIWidget *widget = frame->GetNearestWidget(caretWidgetOffset);

Просмотреть файл

@ -39,6 +39,8 @@
#include "nsISlowScriptDebug.h"
#include "nsWindowMemoryReporter.h"
#include "WindowNamedPropertiesHandler.h"
#include "nsFrameSelection.h"
#include "nsISelectionListener.h"
// Helper Classes
#include "nsJSUtils.h"

Просмотреть файл

@ -118,11 +118,8 @@ ContentEventHandler::Init(WidgetQueryContentEvent* aEvent)
NS_ENSURE_SUCCESS(rv, NS_ERROR_NOT_AVAILABLE);
aEvent->mReply.mHasSelection = !isCollapsed;
nsRefPtr<nsCaret> caret = mPresShell->GetCaret();
NS_ASSERTION(caret, "GetCaret returned null");
nsRect r;
nsIFrame* frame = caret->GetGeometry(mSelection, &r);
nsIFrame* frame = nsCaret::GetGeometry(mSelection, &r);
NS_ENSURE_TRUE(frame, NS_ERROR_FAILURE);
aEvent->mReply.mFocusedWidget = frame->GetNearestWidget();
@ -443,8 +440,8 @@ ContentEventHandler::ExpandToClusterBoundary(nsIContent* aContent,
nsRefPtr<nsFrameSelection> fs = mPresShell->FrameSelection();
int32_t offsetInFrame;
nsFrameSelection::HINT hint =
aForward ? nsFrameSelection::HINTLEFT : nsFrameSelection::HINTRIGHT;
CaretAssociationHint hint =
aForward ? CARET_ASSOCIATE_BEFORE : CARET_ASSOCIATE_AFTER;
nsIFrame* frame = fs->GetFrameForNodeOffset(aContent, int32_t(*aXPOffset),
hint, &offsetInFrame);
if (!frame) {
@ -843,30 +840,28 @@ ContentEventHandler::OnQueryCaretRect(WidgetQueryContentEvent* aEvent)
LineBreakType lineBreakType = GetLineBreakType(aEvent);
nsRefPtr<nsCaret> caret = mPresShell->GetCaret();
NS_ASSERTION(caret, "GetCaret returned null");
// When the selection is collapsed and the queried offset is current caret
// position, we should return the "real" caret rect.
bool selectionIsCollapsed;
rv = mSelection->GetIsCollapsed(&selectionIsCollapsed);
NS_ENSURE_SUCCESS(rv, rv);
nsRect caretRect;
nsIFrame* caretFrame = nsCaret::GetGeometry(mSelection, &caretRect);
if (selectionIsCollapsed) {
uint32_t offset;
rv = GetFlatTextOffsetOfRange(mRootContent, mFirstSelectedRange, &offset,
lineBreakType);
NS_ENSURE_SUCCESS(rv, rv);
if (offset == aEvent->mInput.mOffset) {
nsRect rect;
nsIFrame* caretFrame = caret->GetGeometry(mSelection, &rect);
if (!caretFrame) {
return NS_ERROR_FAILURE;
}
rv = ConvertToRootViewRelativeOffset(caretFrame, rect);
rv = ConvertToRootViewRelativeOffset(caretFrame, caretRect);
NS_ENSURE_SUCCESS(rv, rv);
aEvent->mReply.mRect =
rect.ToOutsidePixels(caretFrame->PresContext()->AppUnitsPerDevPixel());
caretRect.ToOutsidePixels(caretFrame->PresContext()->AppUnitsPerDevPixel());
aEvent->mReply.mOffset = aEvent->mInput.mOffset;
aEvent->mSucceeded = true;
return NS_OK;
@ -892,7 +887,7 @@ ContentEventHandler::OnQueryCaretRect(WidgetQueryContentEvent* aEvent)
nsRect rect;
rect.x = posInFrame.x;
rect.y = posInFrame.y;
rect.width = caret->GetCaretRect().width;
rect.width = caretRect.width;
rect.height = frame->GetSize().height;
rv = ConvertToRootViewRelativeOffset(frame, rect);

Просмотреть файл

@ -401,10 +401,6 @@ EventDispatcher::Dispatch(nsISupports* aTarget,
NS_ERROR_DOM_INVALID_STATE_ERR);
NS_ASSERTION(!aTargets || !aEvent->message, "Wrong parameters!");
#ifdef NIGHTLY_BUILD
MOZ_RELEASE_ASSERT(!mozilla::ipc::ProcessingUrgentMessages());
#endif
// If we're dispatching an already created DOMEvent object, make
// sure it is initialized!
// If aTargets is non-null, the event isn't going to be dispatched.

Просмотреть файл

@ -211,6 +211,10 @@ const kEventConstructors = {
return new MediaStreamEvent(aName, aProps);
},
},
MediaStreamTrackEvent: { create: function (aName, aProps) {
return new MediaStreamTrackEvent(aName, aProps);
},
},
MessageEvent: { create: function (aName, aProps) {
var e = new MessageEvent("messageevent", { bubbles: aProps.bubbles,
cancelable: aProps.cancelable, data: aProps.data, origin: aProps.origin,

Просмотреть файл

@ -22,6 +22,8 @@ const PC_MANAGER_CONTRACT = "@mozilla.org/dom/peerconnectionmanager;1";
const PC_STATS_CONTRACT = "@mozilla.org/dom/rtcstatsreport;1";
const PC_IDENTITY_CONTRACT = "@mozilla.org/dom/rtcidentityassertion;1";
const PC_STATIC_CONTRACT = "@mozilla.org/dom/peerconnectionstatic;1";
const PC_SENDER_CONTRACT = "@mozilla.org/dom/rtpsender;1";
const PC_RECEIVER_CONTRACT = "@mozilla.org/dom/rtpreceiver;1";
const PC_CID = Components.ID("{00e0e20d-1494-4776-8e0e-0f0acbea3c79}");
const PC_OBS_CID = Components.ID("{d1748d4c-7f6a-4dc5-add6-d55b7678537e}");
@ -31,6 +33,8 @@ const PC_MANAGER_CID = Components.ID("{7293e901-2be3-4c02-b4bd-cbef6fc24f78}");
const PC_STATS_CID = Components.ID("{7fe6e18b-0da3-4056-bf3b-440ef3809e06}");
const PC_IDENTITY_CID = Components.ID("{1abc7499-3c54-43e0-bd60-686e2703f072}");
const PC_STATIC_CID = Components.ID("{0fb47c47-a205-4583-a9fc-cbadf8c95880}");
const PC_SENDER_CID = Components.ID("{4fff5d46-d827-4cd4-a970-8fd53977440e}");
const PC_RECEIVER_CID = Components.ID("{d974b814-8fde-411c-8c45-b86791b81030}");
// Global list of PeerConnection objects, so they can be cleaned up when
// a page is torn down. (Maps inner window ID to an array of PC objects).
@ -206,12 +210,6 @@ RTCSessionDescription.prototype = {
};
function RTCStatsReport(win, dict) {
function appendStats(stats, report) {
stats.forEach(function(stat) {
report[stat.id] = stat;
});
}
this._win = win;
this._pcid = dict.pcid;
this._report = convertToRTCStatsReport(dict);
@ -283,6 +281,8 @@ RTCIdentityAssertion.prototype = {
function RTCPeerConnection() {
this._queue = [];
this._senders = [];
this._receivers = [];
this._pc = null;
this._observer = null;
@ -337,6 +337,7 @@ RTCPeerConnection.prototype = {
}
this.makeGetterSetterEH("onaddstream");
this.makeGetterSetterEH("onaddtrack");
this.makeGetterSetterEH("onicecandidate");
this.makeGetterSetterEH("onnegotiationneeded");
this.makeGetterSetterEH("onsignalingstatechange");
@ -780,16 +781,7 @@ RTCPeerConnection.prototype = {
},
addStream: function(stream) {
if (stream.currentTime === undefined) {
throw new this._win.DOMError("", "Invalid stream passed to addStream!");
}
this._queueOrRun({ func: this._addStream,
args: [stream],
wait: false });
},
_addStream: function(stream) {
this._impl.addStream(stream);
stream.getTracks().forEach(track => this.addTrack(track, stream));
},
removeStream: function(stream) {
@ -801,6 +793,26 @@ RTCPeerConnection.prototype = {
throw new this._win.DOMError("", "getStreamById not yet implemented");
},
addTrack: function(track, stream) {
if (stream.currentTime === undefined) {
throw new this._win.DOMError("", "invalid stream.");
}
if (stream.getTracks().indexOf(track) == -1) {
throw new this._win.DOMError("", "track is not in stream.");
}
this._checkClosed();
this._impl.addTrack(track, stream);
let sender = this._win.RTCRtpSender._create(this._win,
new RTCRtpSender(this, track));
this._senders.push({ sender: sender, stream: stream });
return sender;
},
removeTrack: function(sender) {
// Bug 844295: Not implementing this functionality.
throw new this._win.DOMError("", "removeTrack not yet implemented");
},
close: function() {
if (this._closed) {
return;
@ -826,6 +838,36 @@ RTCPeerConnection.prototype = {
return this._impl.getRemoteStreams();
},
getSenders: function() {
this._checkClosed();
let streams = this._impl.getLocalStreams();
let senders = [];
// prune senders in case any streams have disappeared down below
for (let i = this._senders.length - 1; i >= 0; i--) {
if (streams.indexOf(this._senders[i].stream) != -1) {
senders.push(this._senders[i].sender);
} else {
this._senders.splice(i,1);
}
}
return senders;
},
getReceivers: function() {
this._checkClosed();
let streams = this._impl.getRemoteStreams();
let receivers = [];
// prune receivers in case any streams have disappeared down below
for (let i = this._receivers.length - 1; i >= 0; i--) {
if (streams.indexOf(this._receivers[i].stream) != -1) {
receivers.push(this._receivers[i].receiver);
} else {
this._receivers.splice(i,1);
}
}
return receivers;
},
get localDescription() {
this._checkClosed();
let sdp = this._impl.localDescription;
@ -1244,6 +1286,17 @@ PeerConnectionObserver.prototype = {
{ stream: stream }));
},
onAddTrack: function(track) {
let ev = new this._dompc._win.MediaStreamTrackEvent("addtrack",
{ track: track });
this._dompc.dispatchEvent(ev);
},
onRemoveTrack: function(track, type) {
this.dispatchEvent(new this._dompc._win.MediaStreamTrackEvent("removetrack",
{ track: track }));
},
foundIceCandidate: function(cand) {
this.dispatchEvent(new this._dompc._win.RTCPeerConnectionIceEvent("icecandidate",
{ candidate: cand } ));
@ -1275,12 +1328,36 @@ RTCPeerConnectionStatic.prototype = {
},
};
function RTCRtpSender(pc, track) {
this.pc = pc;
this.track = track;
}
RTCRtpSender.prototype = {
classDescription: "RTCRtpSender",
classID: PC_SENDER_CID,
contractID: PC_SENDER_CONTRACT,
QueryInterface: XPCOMUtils.generateQI([Ci.nsISupports]),
};
function RTCRtpReceiver(pc, track) {
this.pc = pc;
this.track = track;
}
RTCRtpReceiver.prototype = {
classDescription: "RTCRtpReceiver",
classID: PC_RECEIVER_CID,
contractID: PC_RECEIVER_CONTRACT,
QueryInterface: XPCOMUtils.generateQI([Ci.nsISupports]),
};
this.NSGetFactory = XPCOMUtils.generateNSGetFactory(
[GlobalPCList,
RTCIceCandidate,
RTCSessionDescription,
RTCPeerConnection,
RTCPeerConnectionStatic,
RTCRtpReceiver,
RTCRtpSender,
RTCStatsReport,
RTCIdentityAssertion,
PeerConnectionObserver]

Просмотреть файл

@ -6,6 +6,8 @@ component {7293e901-2be3-4c02-b4bd-cbef6fc24f78} PeerConnection.js
component {7fe6e18b-0da3-4056-bf3b-440ef3809e06} PeerConnection.js
component {1abc7499-3c54-43e0-bd60-686e2703f072} PeerConnection.js
component {0fb47c47-a205-4583-a9fc-cbadf8c95880} PeerConnection.js
component {4fff5d46-d827-4cd4-a970-8fd53977440e} PeerConnection.js
component {d974b814-8fde-411c-8c45-b86791b81030} PeerConnection.js
contract @mozilla.org/dom/peerconnection;1 {00e0e20d-1494-4776-8e0e-0f0acbea3c79}
contract @mozilla.org/dom/peerconnectionobserver;1 {d1748d4c-7f6a-4dc5-add6-d55b7678537e}
@ -15,3 +17,5 @@ contract @mozilla.org/dom/peerconnectionmanager;1 {7293e901-2be3-4c02-b4bd-cbef6
contract @mozilla.org/dom/rtcstatsreport;1 {7fe6e18b-0da3-4056-bf3b-440ef3809e06}
contract @mozilla.org/dom/rtcidentityassertion;1 {1abc7499-3c54-43e0-bd60-686e2703f072}
contract @mozilla.org/dom/peerconnectionstatic;1 {0fb47c47-a205-4583-a9fc-cbadf8c95880}
contract @mozilla.org/dom/rtpsender;1 {4fff5d46-d827-4cd4-a970-8fd53977440e}
contract @mozilla.org/dom/rtpreceiver;1 {d974b814-8fde-411c-8c45-b86791b81030}

Просмотреть файл

@ -1543,7 +1543,15 @@ PeerConnectionWrapper.prototype = {
this.streams.push(stream);
if (side === 'local') {
this._pc.addStream(stream);
// In order to test both the addStream and addTrack APIs, we do video one
// way and audio + audiovideo the other.
if (type == "video") {
this._pc.addStream(stream);
} else {
stream.getTracks().forEach(function(track) {
this._pc.addTrack(track, stream);
}.bind(this));
}
}
var element = createMediaElement(type, this.label + '_' + side);

Просмотреть файл

@ -39,8 +39,10 @@
#include "mozilla/Preferences.h"
#include "mozilla/unused.h"
#include "nsILoadContext.h"
#include "mozilla/dom/HTMLObjectElementBinding.h"
using namespace mozilla;
using namespace mozilla::dom;
#ifdef MOZ_WIDGET_ANDROID
#include "ANPBase.h"
@ -196,6 +198,9 @@ nsNPAPIPluginInstance::nsNPAPIPluginInstance()
, mOnScreen(true)
#endif
, mHaveJavaC2PJSObjectQuirk(false)
, mCachedParamLength(0)
, mCachedParamNames(nullptr)
, mCachedParamValues(nullptr)
{
mNPP.pdata = nullptr;
mNPP.ndata = this;
@ -219,6 +224,28 @@ nsNPAPIPluginInstance::~nsNPAPIPluginInstance()
PR_Free((void *)mMIMEType);
mMIMEType = nullptr;
}
if (!mCachedParamValues || !mCachedParamNames) {
return;
}
MOZ_ASSERT(mCachedParamValues && mCachedParamNames);
for (uint32_t i = 0; i < mCachedParamLength; i++) {
if (mCachedParamNames[i]) {
NS_Free(mCachedParamNames[i]);
mCachedParamNames[i] = nullptr;
}
if (mCachedParamValues[i]) {
NS_Free(mCachedParamValues[i]);
mCachedParamValues[i] = nullptr;
}
}
NS_Free(mCachedParamNames);
mCachedParamNames = nullptr;
NS_Free(mCachedParamValues);
mCachedParamValues = nullptr;
}
uint32_t nsNPAPIPluginInstance::gInUnsafePluginCalls = 0;
@ -377,28 +404,6 @@ nsNPAPIPluginInstance::GetTagType(nsPluginTagType *result)
return mOwner->GetTagType(result);
}
nsresult
nsNPAPIPluginInstance::GetAttributes(uint16_t& n, const char*const*& names,
const char*const*& values)
{
if (!mOwner) {
return NS_ERROR_FAILURE;
}
return mOwner->GetAttributes(n, names, values);
}
nsresult
nsNPAPIPluginInstance::GetParameters(uint16_t& n, const char*const*& names,
const char*const*& values)
{
if (!mOwner) {
return NS_ERROR_FAILURE;
}
return mOwner->GetParameters(n, names, values);
}
nsresult
nsNPAPIPluginInstance::GetMode(int32_t *result)
{
@ -427,39 +432,53 @@ nsNPAPIPluginInstance::Start()
return NS_OK;
}
if (!mOwner) {
MOZ_ASSERT(false, "Should not be calling Start() on unowned plugin.");
return NS_ERROR_FAILURE;
}
PluginDestructionGuard guard(this);
uint16_t count = 0;
const char* const* names = nullptr;
const char* const* values = nullptr;
nsTArray<MozPluginParameter> attributes;
nsTArray<MozPluginParameter> params;
nsPluginTagType tagtype;
nsresult rv = GetTagType(&tagtype);
if (NS_SUCCEEDED(rv)) {
// Note: If we failed to get the tag type, we may be a full page plugin, so no arguments
rv = GetAttributes(count, names, values);
NS_ENSURE_SUCCESS(rv, rv);
mOwner->GetAttributes(attributes);
mOwner->GetParameters(params);
} else {
MOZ_ASSERT(false, "Failed to get tag type.");
}
// nsPluginTagType_Object or Applet may also have PARAM tags
// Note: The arrays handed back by GetParameters() are
// crafted specially to be directly behind the arrays from GetAttributes()
// with a null entry as a separator. This is for 4.x backwards compatibility!
// see bug 111008 for details
if (tagtype != nsPluginTagType_Embed) {
uint16_t pcount = 0;
const char* const* pnames = nullptr;
const char* const* pvalues = nullptr;
if (NS_SUCCEEDED(GetParameters(pcount, pnames, pvalues))) {
// Android expects an empty string as the separator instead of null
#ifdef MOZ_WIDGET_ANDROID
NS_ASSERTION(PL_strcmp(values[count], "") == 0, "attribute/parameter array not setup correctly for Android NPAPI plugins");
#else
NS_ASSERTION(!values[count], "attribute/parameter array not setup correctly for NPAPI plugins");
#endif
if (pcount)
count += ++pcount; // if it's all setup correctly, then all we need is to
// change the count (attrs + PARAM/blank + params)
}
}
mCachedParamLength = attributes.Length() + 1 + params.Length();
// We add an extra entry "PARAM" as a separator between the attribute
// and param values, but we don't count it if there are no <param> entries.
// Legacy behavior quirk.
uint32_t quirkParamLength = params.Length() ?
mCachedParamLength : attributes.Length();
mCachedParamNames = (char**)NS_Alloc(sizeof(char*) * mCachedParamLength);
mCachedParamValues = (char**)NS_Alloc(sizeof(char*) * mCachedParamLength);
for (uint32_t i = 0; i < attributes.Length(); i++) {
mCachedParamNames[i] = ToNewUTF8String(attributes[i].mName);
mCachedParamValues[i] = ToNewUTF8String(attributes[i].mValue);
}
// Android expects and empty string instead of null.
mCachedParamNames[attributes.Length()] = ToNewUTF8String(NS_LITERAL_STRING("PARAM"));
#ifdef MOZ_WIDGET_ANDROID
mCachedParamValues[attributes.Length()] = ToNewUTF8String(NS_LITERAL_STRING(""));
#else
mCachedParamValues[attributes.Length()] = nullptr;
#endif
for (uint32_t i = 0, pos = attributes.Length() + 1; i < params.Length(); i ++) {
mCachedParamNames[pos] = ToNewUTF8String(params[i].mName);
mCachedParamValues[pos] = ToNewUTF8String(params[i].mValue);
pos++;
}
int32_t mode;
@ -469,57 +488,7 @@ nsNPAPIPluginInstance::Start()
GetMode(&mode);
GetMIMEType(&mimetype);
CheckJavaC2PJSObjectQuirk(count, names, values);
// Some older versions of Flash have a bug in them
// that causes the stack to become currupt if we
// pass swliveconnect=1 in the NPP_NewProc arrays.
// See bug 149336 (UNIX), bug 186287 (Mac)
//
// The code below disables the attribute unless
// the environment variable:
// MOZILLA_PLUGIN_DISABLE_FLASH_SWLIVECONNECT_HACK
// is set.
//
// It is okay to disable this attribute because
// back in 4.x, scripting required liveconnect to
// start Java which was slow. Scripting no longer
// requires starting Java and is quick plus controled
// from the browser, so Flash now ignores this attribute.
//
// This code can not be put at the time of creating
// the array because we may need to examine the
// stream header to determine we want Flash.
static const char flashMimeType[] = "application/x-shockwave-flash";
static const char blockedParam[] = "swliveconnect";
if (count && !PL_strcasecmp(mimetype, flashMimeType)) {
static int cachedDisableHack = 0;
if (!cachedDisableHack) {
if (PR_GetEnv("MOZILLA_PLUGIN_DISABLE_FLASH_SWLIVECONNECT_HACK"))
cachedDisableHack = -1;
else
cachedDisableHack = 1;
}
if (cachedDisableHack > 0) {
for (uint16_t i=0; i<count; i++) {
if (!PL_strcasecmp(names[i], blockedParam)) {
// BIG FAT WARNIG:
// I'm ugly casting |const char*| to |char*| and altering it
// because I know we do malloc it values in
// http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/layout/html/base/src/nsObjectFrame.cpp&rev=1.349&root=/cvsroot#3020
// and free it at line #2096, so it couldn't be a const ptr to string literal
char *val = (char*) values[i];
if (val && *val) {
// we cannot just *val=0, it won't be free properly in such case
val[0] = '0';
val[1] = 0;
}
break;
}
}
}
}
CheckJavaC2PJSObjectQuirk(quirkParamLength, mCachedParamNames, mCachedParamValues);
bool oldVal = mInPluginInitCall;
mInPluginInitCall = true;
@ -541,13 +510,13 @@ nsNPAPIPluginInstance::Start()
mRunning = RUNNING;
nsresult newResult = library->NPP_New((char*)mimetype, &mNPP, (uint16_t)mode,
count, (char**)names, (char**)values,
nullptr, &error);
quirkParamLength, mCachedParamNames,
mCachedParamValues, nullptr, &error);
mInPluginInitCall = oldVal;
NPP_PLUGIN_LOG(PLUGIN_LOG_NORMAL,
("NPP New called: this=%p, npp=%p, mime=%s, mode=%d, argc=%d, return=%d\n",
this, &mNPP, mimetype, mode, count, error));
this, &mNPP, mimetype, mode, quirkParamLength, error));
if (NS_FAILED(newResult) || error != NPERR_NO_ERROR) {
mRunning = DESTROYED;

Просмотреть файл

@ -305,10 +305,6 @@ protected:
virtual ~nsNPAPIPluginInstance();
nsresult GetTagType(nsPluginTagType *result);
nsresult GetAttributes(uint16_t& n, const char*const*& names,
const char*const*& values);
nsresult GetParameters(uint16_t& n, const char*const*& names,
const char*const*& values);
nsresult GetMode(int32_t *result);
// check if this is a Java applet and affected by bug 750480
@ -398,6 +394,12 @@ private:
bool mHaveJavaC2PJSObjectQuirk;
static uint32_t gInUnsafePluginCalls;
// The arrays can only be released when the plugin instance is destroyed,
// because the plugin, in in-process mode, might keep a reference to them.
uint32_t mCachedParamLength;
char **mCachedParamNames;
char **mCachedParamValues;
};
// On Android, we need to guard against plugin code leaking entries in the local

Просмотреть файл

@ -39,6 +39,7 @@ using mozilla::DefaultXDisplay;
#include "nsIAppShell.h"
#include "nsIDOMHTMLAppletElement.h"
#include "nsIObjectLoadingContent.h"
#include "nsObjectLoadingContent.h"
#include "nsAttrName.h"
#include "nsIFocusManager.h"
#include "nsFocusManager.h"
@ -53,6 +54,8 @@ using mozilla::DefaultXDisplay;
#include "mozilla/MiscEvents.h"
#include "mozilla/MouseEvents.h"
#include "mozilla/TextEvents.h"
#include "mozilla/dom/HTMLObjectElementBinding.h"
#include "nsFrameSelection.h"
#include "nsContentCID.h"
#include "nsWidgetsCID.h"
@ -88,6 +91,7 @@ using namespace mozilla::dom;
#endif
using namespace mozilla;
using namespace mozilla::dom;
using namespace mozilla::layers;
// special class for handeling DOM context menu events because for
@ -280,10 +284,6 @@ nsPluginInstanceOwner::nsPluginInstanceOwner()
mWidgetVisible = true;
mPluginWindowVisible = false;
mPluginDocumentActiveState = true;
mNumCachedAttrs = 0;
mNumCachedParams = 0;
mCachedAttrParamNames = nullptr;
mCachedAttrParamValues = nullptr;
mLastMouseDownButtonType = -1;
#ifdef XP_MACOSX
@ -306,8 +306,6 @@ nsPluginInstanceOwner::nsPluginInstanceOwner()
nsPluginInstanceOwner::~nsPluginInstanceOwner()
{
int32_t cnt;
if (mWaitingForPaint) {
// We don't care when the event is dispatched as long as it's "soon",
// since whoever needs it will be waiting for it.
@ -317,28 +315,6 @@ nsPluginInstanceOwner::~nsPluginInstanceOwner()
mObjectFrame = nullptr;
for (cnt = 0; cnt < (mNumCachedAttrs + 1 + mNumCachedParams); cnt++) {
if (mCachedAttrParamNames && mCachedAttrParamNames[cnt]) {
NS_Free(mCachedAttrParamNames[cnt]);
mCachedAttrParamNames[cnt] = nullptr;
}
if (mCachedAttrParamValues && mCachedAttrParamValues[cnt]) {
NS_Free(mCachedAttrParamValues[cnt]);
mCachedAttrParamValues[cnt] = nullptr;
}
}
if (mCachedAttrParamNames) {
NS_Free(mCachedAttrParamNames);
mCachedAttrParamNames = nullptr;
}
if (mCachedAttrParamValues) {
NS_Free(mCachedAttrParamValues);
mCachedAttrParamValues = nullptr;
}
PLUG_DeletePluginNativeWindow(mPluginWindow);
mPluginWindow = nullptr;
@ -411,38 +387,13 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetMode(int32_t *aMode)
return rv;
}
NS_IMETHODIMP nsPluginInstanceOwner::GetAttributes(uint16_t& n,
const char*const*& names,
const char*const*& values)
void nsPluginInstanceOwner::GetAttributes(nsTArray<MozPluginParameter>& attributes)
{
nsresult rv = EnsureCachedAttrParamArrays();
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIObjectLoadingContent> content = do_QueryInterface(mContent);
nsObjectLoadingContent *loadingContent =
static_cast<nsObjectLoadingContent*>(content.get());
n = mNumCachedAttrs;
names = (const char **)mCachedAttrParamNames;
values = (const char **)mCachedAttrParamValues;
return rv;
}
NS_IMETHODIMP nsPluginInstanceOwner::GetAttribute(const char* name, const char* *result)
{
NS_ENSURE_ARG_POINTER(name);
NS_ENSURE_ARG_POINTER(result);
nsresult rv = EnsureCachedAttrParamArrays();
NS_ENSURE_SUCCESS(rv, rv);
*result = nullptr;
for (int i = 0; i < mNumCachedAttrs; i++) {
if (0 == PL_strcasecmp(mCachedAttrParamNames[i], name)) {
*result = mCachedAttrParamValues[i];
return NS_OK;
}
}
return NS_ERROR_FAILURE;
loadingContent->GetPluginAttributes(attributes);
}
NS_IMETHODIMP nsPluginInstanceOwner::GetDOMElement(nsIDOMElement* *result)
@ -789,326 +740,13 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetTagType(nsPluginTagType *result)
return NS_OK;
}
NS_IMETHODIMP nsPluginInstanceOwner::GetParameters(uint16_t& n, const char*const*& names, const char*const*& values)
void nsPluginInstanceOwner::GetParameters(nsTArray<MozPluginParameter>& parameters)
{
nsresult rv = EnsureCachedAttrParamArrays();
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIObjectLoadingContent> content = do_QueryInterface(mContent);
nsObjectLoadingContent *loadingContent =
static_cast<nsObjectLoadingContent*>(content.get());
n = mNumCachedParams;
if (n) {
names = (const char **)(mCachedAttrParamNames + mNumCachedAttrs + 1);
values = (const char **)(mCachedAttrParamValues + mNumCachedAttrs + 1);
} else
names = values = nullptr;
return rv;
}
NS_IMETHODIMP nsPluginInstanceOwner::GetParameter(const char* name, const char* *result)
{
NS_ENSURE_ARG_POINTER(name);
NS_ENSURE_ARG_POINTER(result);
nsresult rv = EnsureCachedAttrParamArrays();
NS_ENSURE_SUCCESS(rv, rv);
*result = nullptr;
for (int i = mNumCachedAttrs + 1; i < (mNumCachedParams + 1 + mNumCachedAttrs); i++) {
if (0 == PL_strcasecmp(mCachedAttrParamNames[i], name)) {
*result = mCachedAttrParamValues[i];
return NS_OK;
}
}
return NS_ERROR_FAILURE;
}
// Cache the attributes and/or parameters of our tag into a single set
// of arrays to be compatible with Netscape 4.x. The attributes go first,
// followed by a PARAM/null and then any PARAM tags. Also, hold the
// cached array around for the duration of the life of the instance
// because Netscape 4.x did. See bug 111008.
nsresult nsPluginInstanceOwner::EnsureCachedAttrParamArrays()
{
if (mCachedAttrParamValues)
return NS_OK;
NS_PRECONDITION(((mNumCachedAttrs + mNumCachedParams) == 0) &&
!mCachedAttrParamNames,
"re-cache of attrs/params not implemented! use the DOM "
"node directy instead");
// Convert to a 16-bit count. Subtract 3 in case we add an extra
// "src", "wmode", or "codebase" entry below.
uint32_t cattrs = mContent->GetAttrCount();
if (cattrs < 0x0000FFFC) {
mNumCachedAttrs = static_cast<uint16_t>(cattrs);
} else {
mNumCachedAttrs = 0xFFFC;
}
// Check if we are java for special codebase handling
const char* mime = nullptr;
bool isJava = NS_SUCCEEDED(mInstance->GetMIMEType(&mime)) && mime &&
nsPluginHost::IsJavaMIMEType(mime);
// now, we need to find all the PARAM tags that are children of us
// however, be careful not to include any PARAMs that don't have us
// as a direct parent. For nested object (or applet) tags, be sure
// to only round up the param tags that coorespond with THIS
// instance. And also, weed out any bogus tags that may get in the
// way, see bug 39609. Then, with any param tag that meet our
// qualification, temporarly cache them in an nsCOMArray until
// we can figure out what size to make our fixed char* array.
nsCOMArray<nsIDOMElement> ourParams;
// Get all dependent PARAM tags, even if they are not direct children.
nsCOMPtr<nsIDOMElement> mydomElement = do_QueryInterface(mContent);
NS_ENSURE_TRUE(mydomElement, NS_ERROR_NO_INTERFACE);
// Making DOM method calls can cause our frame to go away.
nsCOMPtr<nsIPluginInstanceOwner> kungFuDeathGrip(this);
nsCOMPtr<nsIDOMHTMLCollection> allParams;
NS_NAMED_LITERAL_STRING(xhtml_ns, "http://www.w3.org/1999/xhtml");
mydomElement->GetElementsByTagNameNS(xhtml_ns, NS_LITERAL_STRING("param"),
getter_AddRefs(allParams));
if (allParams) {
uint32_t numAllParams;
allParams->GetLength(&numAllParams);
for (uint32_t i = 0; i < numAllParams; i++) {
nsCOMPtr<nsIDOMNode> pnode;
allParams->Item(i, getter_AddRefs(pnode));
nsCOMPtr<nsIDOMElement> domelement = do_QueryInterface(pnode);
if (domelement) {
// Ignore params without a name attribute.
nsAutoString name;
domelement->GetAttribute(NS_LITERAL_STRING("name"), name);
if (!name.IsEmpty()) {
// Find the first object or applet parent.
nsCOMPtr<nsIDOMNode> parent;
nsCOMPtr<nsIDOMHTMLObjectElement> domobject;
nsCOMPtr<nsIDOMHTMLAppletElement> domapplet;
pnode->GetParentNode(getter_AddRefs(parent));
while (!(domobject || domapplet) && parent) {
domobject = do_QueryInterface(parent);
domapplet = do_QueryInterface(parent);
nsCOMPtr<nsIDOMNode> temp;
parent->GetParentNode(getter_AddRefs(temp));
parent = temp;
}
if (domapplet || domobject) {
if (domapplet) {
parent = do_QueryInterface(domapplet);
}
else {
parent = do_QueryInterface(domobject);
}
nsCOMPtr<nsIDOMNode> mydomNode = do_QueryInterface(mydomElement);
if (parent == mydomNode) {
ourParams.AppendObject(domelement);
}
}
}
}
}
}
// Convert to a 16-bit count.
uint32_t cparams = ourParams.Count();
if (cparams < 0x0000FFFF) {
mNumCachedParams = static_cast<uint16_t>(cparams);
} else {
mNumCachedParams = 0xFFFF;
}
uint16_t numRealAttrs = mNumCachedAttrs;
// Some plugins were never written to understand the "data" attribute of the OBJECT tag.
// Real and WMP will not play unless they find a "src" attribute, see bug 152334.
// Nav 4.x would simply replace the "data" with "src". Because some plugins correctly
// look for "data", lets instead copy the "data" attribute and add another entry
// to the bottom of the array if there isn't already a "src" specified.
nsAutoString data;
if (mContent->Tag() == nsGkAtoms::object &&
!mContent->HasAttr(kNameSpaceID_None, nsGkAtoms::src) &&
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::data, data) &&
!data.IsEmpty()) {
mNumCachedAttrs++;
}
// "plugins.force.wmode" forces us to send a specific "wmode" parameter,
// used by flash to select a rendering mode. Common values include
// "opaque", "transparent", "windowed", "direct"
nsCString wmodeType;
nsAdoptingCString wmodePref = Preferences::GetCString("plugins.force.wmode");
if (!wmodePref.IsEmpty()) {
mNumCachedAttrs++;
wmodeType = wmodePref;
}
#if defined(XP_WIN) || defined(XP_LINUX)
// Bug 923745 - Until we support windowed mode plugins in content processes,
// force flash to use a windowless rendering mode. This hack should go away
// when bug 923746 lands. (OS X plugins always use some native widgets, so
// unfortunately this does not help there)
else if (XRE_GetProcessType() == GeckoProcessType_Content) {
mNumCachedAttrs++;
wmodeType.AssignLiteral("transparent");
}
#endif
// (Bug 738396) java has quirks in its codebase parsing, pass the
// absolute codebase URI as content sees it.
bool addCodebase = false;
nsAutoCString codebaseStr;
if (isJava) {
nsCOMPtr<nsIObjectLoadingContent> objlc = do_QueryInterface(mContent);
NS_ENSURE_TRUE(objlc, NS_ERROR_UNEXPECTED);
nsCOMPtr<nsIURI> codebaseURI;
nsresult rv = objlc->GetBaseURI(getter_AddRefs(codebaseURI));
NS_ENSURE_SUCCESS(rv, rv);
codebaseURI->GetSpec(codebaseStr);
if (!mContent->HasAttr(kNameSpaceID_None, nsGkAtoms::codebase)) {
mNumCachedAttrs++;
addCodebase = true;
}
}
mCachedAttrParamNames = (char**)NS_Alloc(sizeof(char*) * (mNumCachedAttrs + 1 + mNumCachedParams));
NS_ENSURE_TRUE(mCachedAttrParamNames, NS_ERROR_OUT_OF_MEMORY);
mCachedAttrParamValues = (char**)NS_Alloc(sizeof(char*) * (mNumCachedAttrs + 1 + mNumCachedParams));
NS_ENSURE_TRUE(mCachedAttrParamValues, NS_ERROR_OUT_OF_MEMORY);
// Some plugins (eg Flash, see bug 234675.) are actually sensitive to the
// attribute order. So we want to make sure we give the plugin the
// attributes in the order they came in in the source, to be compatible with
// other browsers. Now in HTML, the storage order is the reverse of the
// source order, while in XML and XHTML it's the same as the source order
// (see the AddAttributes functions in the HTML and XML content sinks).
int32_t start, end, increment;
if (mContent->IsHTML() &&
mContent->IsInHTMLDocument()) {
// HTML. Walk attributes in reverse order.
start = numRealAttrs - 1;
end = -1;
increment = -1;
} else {
// XHTML or XML. Walk attributes in forward order.
start = 0;
end = numRealAttrs;
increment = 1;
}
// Set to the next slot to fill in name and value cache arrays.
uint32_t nextAttrParamIndex = 0;
// Whether or not we force the wmode below while traversing
// the name/value pairs.
bool wmodeSet = false;
// Add attribute name/value pairs.
for (int32_t index = start; index != end; index += increment) {
const nsAttrName* attrName = mContent->GetAttrNameAt(index);
nsIAtom* atom = attrName->LocalName();
nsAutoString value;
mContent->GetAttr(attrName->NamespaceID(), atom, value);
nsAutoString name;
atom->ToString(name);
FixUpURLS(name, value);
mCachedAttrParamNames [nextAttrParamIndex] = ToNewUTF8String(name);
if (!wmodeType.IsEmpty() &&
0 == PL_strcasecmp(mCachedAttrParamNames[nextAttrParamIndex], "wmode")) {
mCachedAttrParamValues[nextAttrParamIndex] = ToNewUTF8String(NS_ConvertUTF8toUTF16(wmodeType));
if (!wmodeSet) {
// We allocated space to add a wmode attr, but we don't need it now.
mNumCachedAttrs--;
wmodeSet = true;
}
} else if (isJava && 0 == PL_strcasecmp(mCachedAttrParamNames[nextAttrParamIndex], "codebase")) {
mCachedAttrParamValues[nextAttrParamIndex] = ToNewUTF8String(NS_ConvertUTF8toUTF16(codebaseStr));
} else {
mCachedAttrParamValues[nextAttrParamIndex] = ToNewUTF8String(value);
}
nextAttrParamIndex++;
}
// Potentially add CODEBASE attribute
if (addCodebase) {
mCachedAttrParamNames [nextAttrParamIndex] = ToNewUTF8String(NS_LITERAL_STRING("codebase"));
mCachedAttrParamValues[nextAttrParamIndex] = ToNewUTF8String(NS_ConvertUTF8toUTF16(codebaseStr));
nextAttrParamIndex++;
}
// Potentially add WMODE attribute.
if (!wmodeType.IsEmpty() && !wmodeSet) {
mCachedAttrParamNames [nextAttrParamIndex] = ToNewUTF8String(NS_LITERAL_STRING("wmode"));
mCachedAttrParamValues[nextAttrParamIndex] = ToNewUTF8String(NS_ConvertUTF8toUTF16(wmodeType));
nextAttrParamIndex++;
}
// Potentially add SRC attribute.
if (!data.IsEmpty()) {
mCachedAttrParamNames [nextAttrParamIndex] = ToNewUTF8String(NS_LITERAL_STRING("SRC"));
mCachedAttrParamValues[nextAttrParamIndex] = ToNewUTF8String(data);
nextAttrParamIndex++;
}
// Add PARAM and null separator.
mCachedAttrParamNames [nextAttrParamIndex] = ToNewUTF8String(NS_LITERAL_STRING("PARAM"));
#ifdef MOZ_WIDGET_ANDROID
// Flash expects an empty string on android
mCachedAttrParamValues[nextAttrParamIndex] = ToNewUTF8String(NS_LITERAL_STRING(""));
#else
mCachedAttrParamValues[nextAttrParamIndex] = nullptr;
#endif
nextAttrParamIndex++;
// Add PARAM name/value pairs.
// We may decrement mNumCachedParams below
uint16_t totalParams = mNumCachedParams;
for (uint16_t i = 0; i < totalParams; i++) {
nsIDOMElement* param = ourParams.ObjectAt(i);
if (!param) {
continue;
}
nsAutoString name;
nsAutoString value;
param->GetAttribute(NS_LITERAL_STRING("name"), name); // check for empty done above
param->GetAttribute(NS_LITERAL_STRING("value"), value);
FixUpURLS(name, value);
/*
* According to the HTML 4.01 spec, at
* http://www.w3.org/TR/html4/types.html#type-cdata
* ''User agents may ignore leading and trailing
* white space in CDATA attribute values (e.g., "
* myval " may be interpreted as "myval"). Authors
* should not declare attribute values with
* leading or trailing white space.''
* However, do not trim consecutive spaces as in bug 122119
*/
name.Trim(" \n\r\t\b", true, true, false);
value.Trim(" \n\r\t\b", true, true, false);
if (isJava && name.EqualsIgnoreCase("codebase")) {
// We inserted normalized codebase above, don't include other versions in
// params
mNumCachedParams--;
continue;
}
mCachedAttrParamNames [nextAttrParamIndex] = ToNewUTF8String(name);
mCachedAttrParamValues[nextAttrParamIndex] = ToNewUTF8String(value);
nextAttrParamIndex++;
}
return NS_OK;
loadingContent->GetPluginParameters(parameters);
}
#ifdef XP_MACOSX
@ -3168,19 +2806,6 @@ nsObjectFrame* nsPluginInstanceOwner::GetFrame()
return mObjectFrame;
}
// Little helper function to resolve relative URL in
// |value| for certain inputs of |name|
void nsPluginInstanceOwner::FixUpURLS(const nsString &name, nsAString &value)
{
if (name.LowerCaseEqualsLiteral("pluginspage")) {
nsCOMPtr<nsIURI> baseURI = GetBaseURI();
nsAutoString newURL;
NS_MakeAbsoluteURI(newURL, value, baseURI);
if (!newURL.IsEmpty())
value = newURL;
}
}
NS_IMETHODIMP nsPluginInstanceOwner::PrivateModeChanged(bool aEnabled)
{
return mInstance ? mInstance->PrivateModeStateChanged(aEnabled) : NS_OK;

Просмотреть файл

@ -29,6 +29,12 @@ class nsPluginDOMContextMenuListener;
class nsObjectFrame;
class nsDisplayListBuilder;
namespace mozilla {
namespace dom {
struct MozPluginParameter;
}
}
#ifdef MOZ_X11
class gfxXlibSurface;
#ifdef MOZ_WIDGET_QT
@ -72,50 +78,8 @@ public:
*/
NS_IMETHOD GetTagType(nsPluginTagType *aResult);
/**
* Get a ptr to the paired list of parameter names and values,
* returns the length of the array.
*
* Each name or value is a null-terminated string.
*/
NS_IMETHOD GetParameters(uint16_t& aCount,
const char*const*& aNames,
const char*const*& aValues);
/**
* Get the value for the named parameter. Returns null
* if the parameter was not set.
*
* @param aName - name of the parameter
* @param aResult - parameter value
* @result - NS_OK if this operation was successful
*/
NS_IMETHOD GetParameter(const char* aName, const char* *aResult);
/**
* QueryInterface on nsIPluginInstancePeer to get this.
*
* (Corresponds to NPP_New's argc, argn, and argv arguments.)
* Get a ptr to the paired list of attribute names and values,
* returns the length of the array.
*
* Each name or value is a null-terminated string.
*/
NS_IMETHOD GetAttributes(uint16_t& aCount,
const char*const*& aNames,
const char*const*& aValues);
/**
* Gets the value for the named attribute.
*
* @param aName - the name of the attribute to find
* @param aResult - the resulting attribute
* @result - NS_OK if this operation was successful, NS_ERROR_FAILURE if
* this operation failed. result is set to NULL if the attribute is not found
* else to the found value.
*/
NS_IMETHOD GetAttribute(const char* aName, const char* *aResult);
void GetParameters(nsTArray<mozilla::dom::MozPluginParameter>& parameters);
void GetAttributes(nsTArray<mozilla::dom::MozPluginParameter>& attributes);
/**
* Returns the DOM element corresponding to the tag which references
@ -300,8 +264,7 @@ private:
return NS_SUCCEEDED(mInstance->GetImageSize(&size)) &&
size == nsIntSize(mPluginWindow->width, mPluginWindow->height);
}
void FixUpURLS(const nsString &name, nsAString &value);
#ifdef MOZ_WIDGET_ANDROID
mozilla::LayoutDeviceRect GetPluginRect();
bool AddPluginView(const mozilla::LayoutDeviceRect& aRect = mozilla::LayoutDeviceRect(0, 0, 0, 0));
@ -347,11 +310,6 @@ private:
bool mPluginWindowVisible;
bool mPluginDocumentActiveState;
uint16_t mNumCachedAttrs;
uint16_t mNumCachedParams;
char **mCachedAttrParamNames;
char **mCachedAttrParamValues;
#ifdef XP_MACOSX
NPEventModel mEventModel;
// This is a hack! UseAsyncRendering() can incorrectly return false
@ -370,9 +328,7 @@ private:
nsresult DispatchFocusToPlugin(nsIDOMEvent* aFocusEvent);
int mLastMouseDownButtonType;
nsresult EnsureCachedAttrParamArrays();
#ifdef MOZ_X11
class Renderer
#if defined(MOZ_WIDGET_QT)

Просмотреть файл

@ -338,7 +338,8 @@ GonkGPSGeolocationProvider::SetAGpsDataConn(nsAString& aApn)
MOZ_ASSERT(mAGpsInterface);
bool hasUpdateNetworkAvailability = false;
if (mAGpsRilInterface->size >= sizeof(AGpsRilInterface) &&
if (mAGpsRilInterface &&
mAGpsRilInterface->size >= sizeof(AGpsRilInterface) &&
mAGpsRilInterface->update_network_availability) {
hasUpdateNetworkAvailability = true;
}
@ -426,7 +427,8 @@ GonkGPSGeolocationProvider::RequestSetID(uint32_t flags)
{
MOZ_ASSERT(NS_IsMainThread());
if (!mRadioInterface) {
if (!mRadioInterface ||
!mAGpsInterface) {
return;
}
@ -464,7 +466,8 @@ GonkGPSGeolocationProvider::SetReferenceLocation()
{
MOZ_ASSERT(NS_IsMainThread());
if (!mRadioInterface) {
if (!mRadioInterface ||
!mAGpsRilInterface) {
return;
}
@ -522,9 +525,7 @@ GonkGPSGeolocationProvider::SetReferenceLocation()
}
}
}
if (mAGpsRilInterface) {
mAGpsRilInterface->set_ref_location(&location, sizeof(location));
}
mAGpsRilInterface->set_ref_location(&location, sizeof(location));
}
}

Просмотреть файл

@ -619,6 +619,8 @@ var interfaceNamesInGlobalScope =
"MediaStreamAudioSourceNode",
// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "MediaStreamEvent", pref: "media.peerconnection.enabled"},
// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "MediaStreamTrackEvent", pref: "media.peerconnection.enabled"},
// IMPORTANT: Do not change this list without review from a DOM peer!
"MediaStreamTrack",
// IMPORTANT: Do not change this list without review from a DOM peer!
@ -833,6 +835,10 @@ var interfaceNamesInGlobalScope =
{name: "RTCDataChannelEvent", pref: "media.peerconnection.enabled"},
// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "RTCPeerConnectionIceEvent", pref: "media.peerconnection.enabled"},
// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "RTCRtpReceiver", pref: "media.peerconnection.enabled"},
// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "RTCRtpSender", pref: "media.peerconnection.enabled"},
// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "RTCStatsReport", pref: "media.peerconnection.enabled"},
// IMPORTANT: Do not change this list without review from a DOM peer!

Просмотреть файл

@ -155,6 +155,13 @@ interface MozObjectLoadingContent {
[ChromeOnly]
unsigned long getContentTypeForMIMEType(DOMString aMimeType);
[ChromeOnly]
sequence<MozPluginParameter> getPluginAttributes();
[ChromeOnly]
sequence<MozPluginParameter> getPluginParameters();
/**
* This method will play a plugin that has been stopped by the
* click-to-play plugins or play-preview features.
@ -206,6 +213,15 @@ interface MozObjectLoadingContent {
void cancelPlayPreview();
};
/**
* Name:Value pair type used for passing parameters to NPAPI or javascript
* plugins.
*/
dictionary MozPluginParameter {
DOMString name = "";
DOMString value = "";
};
HTMLObjectElement implements MozImageLoadingContent;
HTMLObjectElement implements MozFrameLoaderOwner;
HTMLObjectElement implements MozObjectLoadingContent;

Просмотреть файл

@ -23,8 +23,9 @@ dictionary MediaStreamConstraints {
interface MediaStream {
// readonly attribute DOMString id;
sequence<AudioStreamTrack> getAudioTracks ();
sequence<VideoStreamTrack> getVideoTracks ();
sequence<AudioStreamTrack> getAudioTracks();
sequence<VideoStreamTrack> getVideoTracks();
sequence<MediaStreamTrack> getTracks();
// MediaStreamTrack getTrackById (DOMString trackId);
// void addTrack (MediaStreamTrack track);
// void removeTrack (MediaStreamTrack track);

Просмотреть файл

@ -0,0 +1,22 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*
* The origin of this IDL file is
* http://dev.w3.org/2011/webrtc/editor/webrtc.html#mediastreamevent
*/
dictionary MediaStreamTrackEventInit : EventInit {
MediaStreamTrack? track = null;
RTCRtpReceiver? receiver = null;
MediaStream? stream = null;
};
[Pref="media.peerconnection.enabled",
Constructor(DOMString type, optional MediaStreamTrackEventInit eventInitDict)]
interface MediaStreamTrackEvent : Event {
readonly attribute RTCRtpReceiver? receiver;
readonly attribute MediaStreamTrack? track;
readonly attribute MediaStream? stream;
};

Просмотреть файл

@ -38,11 +38,11 @@ interface PeerConnectionImpl {
[Throws]
void getStats(MediaStreamTrack? selector);
/* Adds the stream created by GetUserMedia */
/* Adds the tracks created by GetUserMedia */
[Throws]
void addStream(MediaStream stream);
void addTrack(MediaStreamTrack track, MediaStream... streams);
[Throws]
void removeStream(MediaStream stream);
void removeTrack(MediaStreamTrack track);
[Throws]
void closeStreams();

Просмотреть файл

@ -34,9 +34,9 @@ interface PeerConnectionObserver
/* Notification of one of several types of state changed */
void onStateChange(PCObserverStateType state);
/* Changes to MediaStreams */
/* Changes to MediaStreamTracks */
void onAddStream(MediaStream stream);
void onRemoveStream();
void onAddTrack();
void onAddTrack(MediaStreamTrack track);
void onRemoveTrack();
};

Просмотреть файл

@ -105,11 +105,25 @@ interface mozRTCPeerConnection : EventTarget {
MediaStream? getStreamById (DOMString streamId);
void addStream (MediaStream stream);
void removeStream (MediaStream stream);
// replaces addStream; fails if already added
// because a track can be part of multiple streams, stream parameters
// indicate which particular streams should be referenced in signaling
RTCRtpSender addTrack(MediaStreamTrack track,
MediaStream stream,
MediaStream... moreStreams);
void removeTrack(RTCRtpSender sender);
sequence<RTCRtpSender> getSenders();
sequence<RTCRtpReceiver> getReceivers();
void close ();
attribute EventHandler onnegotiationneeded;
attribute EventHandler onicecandidate;
attribute EventHandler onsignalingstatechange;
attribute EventHandler onaddstream;
attribute EventHandler onaddtrack; // replaces onaddstream; see AddTrackEvent
attribute EventHandler onremovestream;
attribute EventHandler oniceconnectionstatechange;

Просмотреть файл

@ -0,0 +1,14 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*
* The origin of this IDL file is
* http://lists.w3.org/Archives/Public/public-webrtc/2014May/0067.html
*/
[Pref="media.peerconnection.enabled",
JSImplementation="@mozilla.org/dom/rtpreceiver;1"]
interface RTCRtpReceiver {
readonly attribute MediaStreamTrack track;
};

Просмотреть файл

@ -0,0 +1,14 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*
* The origin of this IDL file is
* http://lists.w3.org/Archives/Public/public-webrtc/2014May/0067.html
*/
[Pref="media.peerconnection.enabled",
JSImplementation="@mozilla.org/dom/rtpsender;1"]
interface RTCRtpSender {
readonly attribute MediaStreamTrack track;
};

Просмотреть файл

@ -314,6 +314,8 @@ WEBIDL_FILES = [
'RTCIdentityAssertion.webidl',
'RTCPeerConnection.webidl',
'RTCPeerConnectionStatic.webidl',
'RTCRtpReceiver.webidl',
'RTCRtpSender.webidl',
'RTCSessionDescription.webidl',
'RTCStatsReport.webidl',
'Screen.webidl',
@ -645,6 +647,7 @@ GENERATED_EVENTS_WEBIDL_FILES = [
'HashChangeEvent.webidl',
'IccChangeEvent.webidl',
'MediaStreamEvent.webidl',
'MediaStreamTrackEvent.webidl',
'MozApplicationEvent.webidl',
'MozClirModeEvent.webidl',
'MozContactChangeEvent.webidl',

Просмотреть файл

@ -21,8 +21,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=599322.patch
/** Test for Bug 599322.patch **/
SimpleTest.expectAssertions(1);
SimpleTest.waitForExplicitFinish();
addLoadEvent(function() {
var src = document.getElementById("src");

Просмотреть файл

@ -22,11 +22,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=674770
<pre id="test">
<script type="application/javascript">
if (!navigator.platform.startsWith("Linux")) {
SimpleTest.expectAssertions(1);
}
/** Test for Bug 674770 **/
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(function() {
SpecialPowers.setBoolPref("middlemouse.paste", true);

Просмотреть файл

@ -4927,7 +4927,7 @@ nsEditor::InitializeSelection(nsIDOMEventTarget* aFocusEventTarget)
nsRefPtr<nsCaret> caret = presShell->GetCaret();
NS_ENSURE_TRUE(caret, NS_ERROR_UNEXPECTED);
caret->SetIgnoreUserModify(false);
caret->SetCaretDOMSelection(selection);
caret->SetSelection(selection);
selCon->SetCaretReadOnly(IsReadonly());
selCon->SetCaretEnabled(true);

Просмотреть файл

@ -695,12 +695,8 @@ nsEditorEventListener::DragOver(nsIDOMDragEvent* aDragEvent)
nsresult rv = aDragEvent->GetRangeOffset(&offset);
NS_ENSURE_SUCCESS(rv, rv);
// to avoid flicker, we could track the node and offset to see if we moved
if (mCaret)
mCaret->EraseCaret();
//mCaret->SetCaretVisible(true); // make sure it's visible
mCaret->DrawAtPosition(parent, offset);
mCaret->SetVisible(true);
mCaret->SetCaretPosition(parent, offset);
}
}
else
@ -713,7 +709,7 @@ nsEditorEventListener::DragOver(nsIDOMDragEvent* aDragEvent)
if (mCaret)
{
mCaret->EraseCaret();
mCaret->SetVisible(false);
}
}
@ -725,8 +721,7 @@ nsEditorEventListener::CleanupDragDropCaret()
{
if (mCaret)
{
mCaret->EraseCaret();
mCaret->SetCaretVisible(false); // hide it, so that it turns off its timer
mCaret->SetVisible(false); // hide it, so that it turns off its timer
nsCOMPtr<nsIPresShell> presShell = GetPresShell();
if (presShell)

Просмотреть файл

@ -762,12 +762,6 @@ NS_IMETHODIMP nsPlaintextEditor::InsertLineBreak()
nsRefPtr<Selection> selection = GetSelection();
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
// Batching the selection and moving nodes out from under the caret causes
// caret turds. Ask the shell to invalidate the caret now to avoid the turds.
nsCOMPtr<nsIPresShell> shell = GetPresShell();
NS_ENSURE_TRUE(shell, NS_ERROR_NOT_INITIALIZED);
shell->MaybeInvalidateCaretPosition();
nsTextRulesInfo ruleInfo(EditAction::insertBreak);
ruleInfo.maxLength = mMaxTextLength;
bool cancel, handled;
@ -878,7 +872,7 @@ nsPlaintextEditor::UpdateIMEComposition(nsIDOMEvent* aDOMTextEvent)
rv = InsertText(widgetTextEvent->theText);
if (caretP) {
caretP->SetCaretDOMSelection(selection);
caretP->SetSelection(selection);
}
}

Просмотреть файл

@ -2035,12 +2035,11 @@ GLContext::OffscreenSize() const
bool
GLContext::CreateScreenBufferImpl(const IntSize& size, const SurfaceCaps& caps)
{
GLScreenBuffer* newScreen = GLScreenBuffer::Create(this, size, caps);
UniquePtr<GLScreenBuffer> newScreen = GLScreenBuffer::Create(this, size, caps);
if (!newScreen)
return false;
if (!newScreen->Resize(size)) {
delete newScreen;
return false;
}
@ -2050,7 +2049,7 @@ GLContext::CreateScreenBufferImpl(const IntSize& size, const SurfaceCaps& caps)
// it falls out of scope.
ScopedBindFramebuffer autoFB(this);
mScreen = newScreen;
mScreen = Move(newScreen);
return true;
}
@ -2068,7 +2067,6 @@ GLContext::ResizeScreenBuffer(const IntSize& size)
void
GLContext::DestroyScreenBuffer()
{
delete mScreen;
mScreen = nullptr;
}

Просмотреть файл

@ -2920,7 +2920,7 @@ public:
protected:
friend class GLScreenBuffer;
GLScreenBuffer* mScreen;
UniquePtr<GLScreenBuffer> mScreen;
void DestroyScreenBuffer();
@ -2946,7 +2946,7 @@ public:
}
GLScreenBuffer* Screen() const {
return mScreen;
return mScreen.get();
}
bool PublishFrame();

Просмотреть файл

@ -20,24 +20,26 @@
#endif
#include "ScopedGLHelpers.h"
#include "gfx2DGlue.h"
#include "../layers/ipc/ShadowLayers.h"
namespace mozilla {
namespace gl {
using gfx::SurfaceFormat;
GLScreenBuffer*
UniquePtr<GLScreenBuffer>
GLScreenBuffer::Create(GLContext* gl,
const gfx::IntSize& size,
const SurfaceCaps& caps)
{
UniquePtr<GLScreenBuffer> ret;
if (caps.antialias &&
!gl->IsSupported(GLFeature::framebuffer_multisample))
{
return nullptr;
return Move(ret);
}
SurfaceFactory* factory = nullptr;
UniquePtr<SurfaceFactory> factory;
#ifdef MOZ_WIDGET_GONK
/* On B2G, we want a Gralloc factory, and we want one right at the start */
@ -45,7 +47,7 @@ GLScreenBuffer::Create(GLContext* gl,
caps.surfaceAllocator &&
XRE_GetProcessType() != GeckoProcessType_Default)
{
factory = new SurfaceFactory_Gralloc(gl, caps);
factory = MakeUnique<SurfaceFactory_Gralloc>(gl, caps);
}
#endif
#ifdef XP_MACOSX
@ -55,22 +57,23 @@ GLScreenBuffer::Create(GLContext* gl,
}
#endif
if (!factory)
factory = new SurfaceFactory_Basic(gl, caps);
if (!factory) {
factory = MakeUnique<SurfaceFactory_Basic>(gl, caps);
}
SurfaceStream* stream = SurfaceStream::CreateForType(
SurfaceStream::ChooseGLStreamType(SurfaceStream::MainThread,
caps.preserve),
gl,
nullptr);
auto streamType = SurfaceStream::ChooseGLStreamType(SurfaceStream::MainThread,
caps.preserve);
RefPtr<SurfaceStream> stream;
stream = SurfaceStream::CreateForType(streamType, gl, nullptr);
return new GLScreenBuffer(gl, caps, factory, stream);
ret.reset( new GLScreenBuffer(gl, caps, Move(factory), stream) );
return Move(ret);
}
GLScreenBuffer::~GLScreenBuffer()
{
delete mDraw;
delete mRead;
mDraw = nullptr;
mRead = nullptr;
// bug 914823: it is crucial to destroy the Factory _after_ we destroy
// the SharedSurfaces around here! Reason: the shared surfaces will want
@ -78,7 +81,7 @@ GLScreenBuffer::~GLScreenBuffer()
// buffers, but that Allocator may be kept alive by the Factory,
// as it currently the case in SurfaceFactory_Gralloc holding a nsRefPtr
// to the Allocator!
delete mFactory;
mFactory = nullptr;
}
@ -372,22 +375,20 @@ GLScreenBuffer::AssureBlitted()
}
void
GLScreenBuffer::Morph(SurfaceFactory* newFactory, SurfaceStreamType streamType)
GLScreenBuffer::Morph(UniquePtr<SurfaceFactory> newFactory,
SurfaceStreamType streamType)
{
MOZ_ASSERT(mStream);
if (newFactory) {
delete mFactory;
mFactory = newFactory;
mFactory = Move(newFactory);
}
if (mStream->mType == streamType)
return;
SurfaceStream* newStream = SurfaceStream::CreateForType(streamType, mGL, mStream);
MOZ_ASSERT(newStream);
mStream = newStream;
mStream = SurfaceStream::CreateForType(streamType, mGL, mStream);
MOZ_ASSERT(mStream);
}
bool
@ -408,26 +409,20 @@ GLScreenBuffer::Attach(SharedSurface* surf, const gfx::IntSize& size)
mRead->Attach(surf);
} else {
// Else something changed, so resize:
DrawBuffer* draw = nullptr;
UniquePtr<DrawBuffer> draw;
bool drawOk = CreateDraw(size, &draw); // Can be null.
ReadBuffer* read = CreateRead(surf);
UniquePtr<ReadBuffer> read = CreateRead(surf);
bool readOk = !!read;
if (!drawOk || !readOk) {
delete draw;
delete read;
surf->UnlockProd();
return false;
}
delete mDraw;
delete mRead;
mDraw = draw;
mRead = read;
mDraw = Move(draw);
mRead = Move(read);
}
// Check that we're all set up.
@ -443,7 +438,7 @@ GLScreenBuffer::Attach(SharedSurface* surf, const gfx::IntSize& size)
bool
GLScreenBuffer::Swap(const gfx::IntSize& size)
{
SharedSurface* nextSurf = mStream->SwapProducer(mFactory, size);
SharedSurface* nextSurf = mStream->SwapProducer(mFactory.get(), size);
if (!nextSurf) {
SurfaceFactory_Basic basicFactory(mGL, mFactory->mCaps);
nextSurf = mStream->SwapProducer(&basicFactory, size);
@ -469,15 +464,16 @@ GLScreenBuffer::PublishFrame(const gfx::IntSize& size)
bool
GLScreenBuffer::Resize(const gfx::IntSize& size)
{
SharedSurface* surface = mStream->Resize(mFactory, size);
if (!surface)
SharedSurface* surf = mStream->Resize(mFactory.get(), size);
if (!surf)
return false;
return Attach(surface, size);
return Attach(surf, size);
}
bool
GLScreenBuffer::CreateDraw(const gfx::IntSize& size, DrawBuffer** out_buffer)
GLScreenBuffer::CreateDraw(const gfx::IntSize& size,
UniquePtr<DrawBuffer>* out_buffer)
{
GLContext* gl = mFactory->mGL;
const GLFormats& formats = mFactory->mFormats;
@ -486,7 +482,7 @@ GLScreenBuffer::CreateDraw(const gfx::IntSize& size, DrawBuffer** out_buffer)
return DrawBuffer::Create(gl, caps, formats, size, out_buffer);
}
ReadBuffer*
UniquePtr<ReadBuffer>
GLScreenBuffer::CreateRead(SharedSurface* surf)
{
GLContext* gl = mFactory->mGL;
@ -512,13 +508,14 @@ GLScreenBuffer::Readback(SharedSurface* src, gfx::DataSourceSurface* dest)
src->LockProd();
}
ReadBuffer* buffer = CreateRead(src);
MOZ_ASSERT(buffer);
ScopedBindFramebuffer autoFB(mGL, buffer->mFB);
ReadPixelsIntoDataSurface(mGL, dest);
{
UniquePtr<ReadBuffer> buffer = CreateRead(src);
MOZ_ASSERT(buffer);
delete buffer;
ScopedBindFramebuffer autoFB(mGL, buffer->mFB);
ReadPixelsIntoDataSurface(mGL, dest);
}
if (needsSwap) {
src->UnlockProd();
@ -534,7 +531,7 @@ DrawBuffer::Create(GLContext* const gl,
const SurfaceCaps& caps,
const GLFormats& formats,
const gfx::IntSize& size,
DrawBuffer** out_buffer)
UniquePtr<DrawBuffer>* out_buffer)
{
MOZ_ASSERT(out_buffer);
*out_buffer = nullptr;
@ -578,13 +575,13 @@ DrawBuffer::Create(GLContext* const gl,
gl->fGenFramebuffers(1, &fb);
gl->AttachBuffersToFB(0, colorMSRB, depthRB, stencilRB, fb);
ScopedDeletePtr<DrawBuffer> buffer;
buffer = new DrawBuffer(gl, size, fb, colorMSRB, depthRB, stencilRB);
UniquePtr<DrawBuffer> ret( new DrawBuffer(gl, size, fb, colorMSRB,
depthRB, stencilRB) );
if (!gl->IsFramebufferComplete(fb))
return false;
*out_buffer = buffer.forget();
*out_buffer = Move(ret);
return true;
}
@ -606,7 +603,7 @@ DrawBuffer::~DrawBuffer()
////////////////////////////////////////////////////////////////////////
// ReadBuffer
ReadBuffer*
UniquePtr<ReadBuffer>
ReadBuffer::Create(GLContext* gl,
const SurfaceCaps& caps,
const GLFormats& formats,
@ -617,9 +614,8 @@ ReadBuffer::Create(GLContext* gl,
if (surf->mAttachType == AttachmentType::Screen) {
// Don't need anything. Our read buffer will be the 'screen'.
return new ReadBuffer(gl,
0, 0, 0,
surf);
return UniquePtr<ReadBuffer>( new ReadBuffer(gl, 0, 0, 0,
surf) );
}
GLuint depthRB = 0;
@ -653,15 +649,13 @@ ReadBuffer::Create(GLContext* gl,
gl->AttachBuffersToFB(colorTex, colorRB, depthRB, stencilRB, fb, target);
gl->mFBOMapping[fb] = surf;
UniquePtr<ReadBuffer> ret( new ReadBuffer(gl, fb, depthRB,
stencilRB, surf) );
if (!gl->IsFramebufferComplete(fb)) {
ret = nullptr;
}
ScopedDeletePtr<ReadBuffer> buffer;
buffer = new ReadBuffer(gl,
fb, depthRB, stencilRB,
surf);
if (!gl->IsFramebufferComplete(fb))
return nullptr;
return buffer.forget();
return Move(ret);
}
ReadBuffer::~ReadBuffer()

Просмотреть файл

@ -21,6 +21,7 @@
#include "GLDefs.h"
#include "mozilla/gfx/2D.h"
#include "mozilla/gfx/Point.h"
#include "mozilla/UniquePtr.h"
namespace mozilla {
namespace gl {
@ -38,7 +39,7 @@ public:
const SurfaceCaps& caps,
const GLFormats& formats,
const gfx::IntSize& size,
DrawBuffer** out_buffer);
UniquePtr<DrawBuffer>* out_buffer);
protected:
GLContext* const mGL;
@ -72,10 +73,10 @@ class ReadBuffer
{
public:
// Infallible, always non-null.
static ReadBuffer* Create(GLContext* gl,
const SurfaceCaps& caps,
const GLFormats& formats,
SharedSurface* surf);
static UniquePtr<ReadBuffer> Create(GLContext* gl,
const SurfaceCaps& caps,
const GLFormats& formats,
SharedSurface* surf);
protected:
GLContext* const mGL;
@ -118,20 +119,20 @@ class GLScreenBuffer
{
public:
// Infallible.
static GLScreenBuffer* Create(GLContext* gl,
const gfx::IntSize& size,
const SurfaceCaps& caps);
static UniquePtr<GLScreenBuffer> Create(GLContext* gl,
const gfx::IntSize& size,
const SurfaceCaps& caps);
protected:
GLContext* const mGL; // Owns us.
GLContext* const mGL; // Owns us.
public:
const SurfaceCaps mCaps;
protected:
SurfaceFactory* mFactory; // Owned by us.
UniquePtr<SurfaceFactory> mFactory;
RefPtr<SurfaceStream> mStream;
DrawBuffer* mDraw; // Owned by us.
ReadBuffer* mRead; // Owned by us.
UniquePtr<DrawBuffer> mDraw;
UniquePtr<ReadBuffer> mRead;
bool mNeedsBlit;
@ -148,11 +149,11 @@ protected:
GLScreenBuffer(GLContext* gl,
const SurfaceCaps& caps,
SurfaceFactory* factory,
SurfaceStream* stream)
UniquePtr<SurfaceFactory> factory,
const RefPtr<SurfaceStream>& stream)
: mGL(gl)
, mCaps(caps)
, mFactory(factory)
, mFactory(Move(factory))
, mStream(stream)
, mDraw(nullptr)
, mRead(nullptr)
@ -175,7 +176,7 @@ public:
}
SurfaceFactory* Factory() const {
return mFactory;
return mFactory.get();
}
SharedSurface* SharedSurf() const {
@ -235,7 +236,8 @@ public:
* Once you pass newFactory into Morph, newFactory will be owned by
* GLScreenBuffer, so `forget` any references to it that still exist.
*/
void Morph(SurfaceFactory* newFactory, SurfaceStreamType streamType);
void Morph(UniquePtr<SurfaceFactory> newFactory,
SurfaceStreamType streamType);
protected:
// Returns false on error or inability to resize.
@ -249,10 +251,10 @@ public:
void Readback(SharedSurface* src, gfx::DataSourceSurface* dest);
protected:
bool Attach(SharedSurface* surface, const gfx::IntSize& size);
bool Attach(SharedSurface* surf, const gfx::IntSize& size);
bool CreateDraw(const gfx::IntSize& size, DrawBuffer** out_buffer);
ReadBuffer* CreateRead(SharedSurface* surf);
bool CreateDraw(const gfx::IntSize& size, UniquePtr<DrawBuffer>* out_buffer);
UniquePtr<ReadBuffer> CreateRead(SharedSurface* surf);
public:
/* `fb` in these functions is the framebuffer the GLContext is hoping to

Просмотреть файл

@ -29,15 +29,15 @@ SharedSurface::ProdCopy(SharedSurface* src, SharedSurface* dest,
dest->mAttachType == AttachmentType::Screen)
{
// Here, we actually need to blit through a temp surface, so let's make one.
nsAutoPtr<SharedSurface_GLTexture> tempSurf;
UniquePtr<SharedSurface_GLTexture> tempSurf;
tempSurf = SharedSurface_GLTexture::Create(gl,
gl,
factory->mFormats,
src->mSize,
factory->mCaps.alpha);
ProdCopy(src, tempSurf, factory);
ProdCopy(tempSurf, dest, factory);
ProdCopy(src, tempSurf.get(), factory);
ProdCopy(tempSurf.get(), dest, factory);
return;
}
@ -268,47 +268,37 @@ SurfaceFactory::SurfaceFactory(GLContext* gl,
SurfaceFactory::~SurfaceFactory()
{
while (!mScraps.empty()) {
SharedSurface* cur = mScraps.front();
mScraps.pop();
delete cur;
while (!mScraps.Empty()) {
mScraps.Pop();
}
}
SharedSurface*
UniquePtr<SharedSurface>
SurfaceFactory::NewSharedSurface(const gfx::IntSize& size)
{
// Attempt to reuse an old surface.
while (!mScraps.empty()) {
SharedSurface* cur = mScraps.front();
mScraps.pop();
if (cur->mSize == size)
return cur;
while (!mScraps.Empty()) {
UniquePtr<SharedSurface> cur = mScraps.Pop();
// Destroy old surfaces of the wrong size.
delete cur;
if (cur->mSize == size)
return Move(cur);
// Let `cur` be destroyed as it falls out of scope, if it wasn't
// moved.
}
SharedSurface* ret = CreateShared(size);
return ret;
return CreateShared(size);
}
// Auto-deletes surfs of the wrong type.
void
SurfaceFactory::Recycle(SharedSurface*& surf)
SurfaceFactory::Recycle(UniquePtr<SharedSurface> surf)
{
if (!surf)
return;
MOZ_ASSERT(surf);
if (surf->mType == mType) {
mScraps.push(surf);
} else {
delete surf;
mScraps.Push(Move(surf));
}
surf = nullptr;
}
} /* namespace gfx */

Просмотреть файл

@ -22,6 +22,8 @@
#include "GLDefs.h"
#include "mozilla/Attributes.h"
#include "mozilla/gfx/Point.h"
#include "mozilla/UniquePtr.h"
#include "mozilla/WeakPtr.h"
#include "SurfaceTypes.h"
namespace mozilla {
@ -112,6 +114,37 @@ public:
}
};
template<typename T>
class UniquePtrQueue
{
std::queue<T*> mQueue;
public:
~UniquePtrQueue() {
MOZ_ASSERT(Empty());
}
bool Empty() const {
return mQueue.empty();
}
void Push(UniquePtr<T> up) {
T* p = up.release();
mQueue.push(p);
}
UniquePtr<T> Pop() {
UniquePtr<T> ret;
if (!mQueue.empty()) {
ret.reset(mQueue.front());
mQueue.pop();
}
return Move(ret);
}
};
class SurfaceFactory
{
public:
@ -140,15 +173,15 @@ public:
}
protected:
virtual SharedSurface* CreateShared(const gfx::IntSize& size) = 0;
virtual UniquePtr<SharedSurface> CreateShared(const gfx::IntSize& size) = 0;
std::queue<SharedSurface*> mScraps;
UniquePtrQueue<SharedSurface> mScraps;
public:
SharedSurface* NewSharedSurface(const gfx::IntSize& size);
UniquePtr<SharedSurface> NewSharedSurface(const gfx::IntSize& size);
// Auto-deletes surfs of the wrong type.
void Recycle(SharedSurface*& surf);
void Recycle(UniquePtr<SharedSurface> surf);
};
} // namespace gl

Просмотреть файл

@ -11,23 +11,6 @@
namespace mozilla {
namespace gl {
SurfaceFactory_ANGLEShareHandle*
SurfaceFactory_ANGLEShareHandle::Create(GLContext* gl,
const SurfaceCaps& caps)
{
GLLibraryEGL* egl = &sEGLLibrary;
if (!egl)
return nullptr;
if (!egl->IsExtensionSupported(
GLLibraryEGL::ANGLE_surface_d3d_texture_2d_share_handle))
{
return nullptr;
}
return new SurfaceFactory_ANGLEShareHandle(gl, egl, caps);
}
EGLDisplay
SharedSurface_ANGLEShareHandle::Display()
{
@ -179,7 +162,7 @@ CreatePBufferSurface(GLLibraryEGL* egl,
return surface;
}
SharedSurface_ANGLEShareHandle*
/*static*/ UniquePtr<SharedSurface_ANGLEShareHandle>
SharedSurface_ANGLEShareHandle::Create(GLContext* gl,
EGLContext context, EGLConfig config,
const gfx::IntSize& size, bool hasAlpha)
@ -208,12 +191,30 @@ SharedSurface_ANGLEShareHandle::Create(GLContext* gl,
return nullptr;
}
return new SharedSurface_ANGLEShareHandle(gl, egl,
size, hasAlpha,
context, pbuffer,
shareHandle);
typedef SharedSurface_ANGLEShareHandle ptrT;
UniquePtr<ptrT> ret( new ptrT(gl, egl, size, hasAlpha, context,
pbuffer, shareHandle) );
return Move(ret);
}
/*static*/ UniquePtr<SurfaceFactory_ANGLEShareHandle>
SurfaceFactory_ANGLEShareHandle::Create(GLContext* gl,
const SurfaceCaps& caps)
{
GLLibraryEGL* egl = &sEGLLibrary;
if (!egl)
return nullptr;
auto ext = GLLibraryEGL::ANGLE_surface_d3d_texture_2d_share_handle;
if (!egl->IsExtensionSupported(ext))
{
return nullptr;
}
typedef SurfaceFactory_ANGLEShareHandle ptrT;
UniquePtr<ptrT> ret( new ptrT(gl, egl, caps) );
return Move(ret);
}
SurfaceFactory_ANGLEShareHandle::SurfaceFactory_ANGLEShareHandle(GLContext* gl,
GLLibraryEGL* egl,

Просмотреть файл

@ -20,10 +20,11 @@ class SharedSurface_ANGLEShareHandle
: public SharedSurface
{
public:
static SharedSurface_ANGLEShareHandle* Create(GLContext* gl,
EGLContext context, EGLConfig config,
const gfx::IntSize& size,
bool hasAlpha);
static UniquePtr<SharedSurface_ANGLEShareHandle> Create(GLContext* gl,
EGLContext context,
EGLConfig config,
const gfx::IntSize& size,
bool hasAlpha);
static SharedSurface_ANGLEShareHandle* Cast(SharedSurface* surf) {
MOZ_ASSERT(surf->mType == SharedSurfaceType::EGLSurfaceANGLE);
@ -85,15 +86,15 @@ protected:
EGLConfig mConfig;
public:
static SurfaceFactory_ANGLEShareHandle* Create(GLContext* gl,
const SurfaceCaps& caps);
static UniquePtr<SurfaceFactory_ANGLEShareHandle> Create(GLContext* gl,
const SurfaceCaps& caps);
protected:
SurfaceFactory_ANGLEShareHandle(GLContext* gl,
GLLibraryEGL* egl,
const SurfaceCaps& caps);
virtual SharedSurface* CreateShared(const gfx::IntSize& size) MOZ_OVERRIDE {
virtual UniquePtr<SharedSurface> CreateShared(const gfx::IntSize& size) MOZ_OVERRIDE {
bool hasAlpha = mReadCaps.alpha;
return SharedSurface_ANGLEShareHandle::Create(mProdGL,
mContext, mConfig,

Просмотреть файл

@ -16,7 +16,7 @@
namespace mozilla {
namespace gl {
SharedSurface_EGLImage*
/*static*/ UniquePtr<SharedSurface_EGLImage>
SharedSurface_EGLImage::Create(GLContext* prodGL,
const GLFormats& formats,
const gfx::IntSize& size,
@ -27,14 +27,16 @@ SharedSurface_EGLImage::Create(GLContext* prodGL,
MOZ_ASSERT(egl);
MOZ_ASSERT(context);
UniquePtr<SharedSurface_EGLImage> ret;
if (!HasExtensions(egl, prodGL)) {
return nullptr;
return Move(ret);
}
MOZ_ALWAYS_TRUE(prodGL->MakeCurrent());
GLuint prodTex = CreateTextureForOffscreen(prodGL, formats, size);
if (!prodTex) {
return nullptr;
return Move(ret);
}
EGLClientBuffer buffer = reinterpret_cast<EGLClientBuffer>(prodTex);
@ -43,15 +45,14 @@ SharedSurface_EGLImage::Create(GLContext* prodGL,
nullptr);
if (!image) {
prodGL->fDeleteTextures(1, &prodTex);
return nullptr;
return Move(ret);
}
return new SharedSurface_EGLImage(prodGL, egl,
size, hasAlpha,
formats, prodTex, image);
ret.reset( new SharedSurface_EGLImage(prodGL, egl, size, hasAlpha,
formats, prodTex, image) );
return Move(ret);
}
bool
SharedSurface_EGLImage::HasExtensions(GLLibraryEGL* egl, GLContext* gl)
{
@ -85,7 +86,6 @@ SharedSurface_EGLImage::SharedSurface_EGLImage(GLContext* gl,
SharedSurface_EGLImage::~SharedSurface_EGLImage()
{
mEGL->fDestroyImage(Display(), mImage);
mImage = 0;
mGL->MakeCurrent();
mGL->fDeleteTextures(1, &mProdTex);
@ -216,18 +216,21 @@ SharedSurface_EGLImage::AcquireConsumerTexture(GLContext* consGL, GLuint* out_te
}
SurfaceFactory_EGLImage*
/*static*/ UniquePtr<SurfaceFactory_EGLImage>
SurfaceFactory_EGLImage::Create(GLContext* prodGL,
const SurfaceCaps& caps)
const SurfaceCaps& caps)
{
EGLContext context = GLContextEGL::Cast(prodGL)->GetEGLContext();
typedef SurfaceFactory_EGLImage ptrT;
UniquePtr<ptrT> ret;
GLLibraryEGL* egl = &sEGLLibrary;
if (!SharedSurface_EGLImage::HasExtensions(egl, prodGL)) {
return nullptr;
if (SharedSurface_EGLImage::HasExtensions(egl, prodGL)) {
ret.reset( new ptrT(prodGL, context, caps) );
}
return new SurfaceFactory_EGLImage(prodGL, context, caps);
return Move(ret);
}
} /* namespace gfx */

Просмотреть файл

@ -22,11 +22,11 @@ class SharedSurface_EGLImage
: public SharedSurface
{
public:
static SharedSurface_EGLImage* Create(GLContext* prodGL,
const GLFormats& formats,
const gfx::IntSize& size,
bool hasAlpha,
EGLContext context);
static UniquePtr<SharedSurface_EGLImage> Create(GLContext* prodGL,
const GLFormats& formats,
const gfx::IntSize& size,
bool hasAlpha,
EGLContext context);
static SharedSurface_EGLImage* Cast(SharedSurface* surf) {
MOZ_ASSERT(surf->mType == SharedSurfaceType::EGLImageShare);
@ -41,7 +41,9 @@ protected:
GLLibraryEGL* const mEGL;
const GLFormats mFormats;
GLuint mProdTex;
EGLImage mImage;
public:
const EGLImage mImage;
protected:
GLContext* mCurConsGL;
GLuint mConsTex;
nsRefPtr<TextureGarbageBin> mGarbageBin;
@ -84,8 +86,8 @@ class SurfaceFactory_EGLImage
{
public:
// Fallible:
static SurfaceFactory_EGLImage* Create(GLContext* prodGL,
const SurfaceCaps& caps);
static UniquePtr<SurfaceFactory_EGLImage> Create(GLContext* prodGL,
const SurfaceCaps& caps);
protected:
const EGLContext mContext;
@ -98,7 +100,7 @@ protected:
{}
public:
virtual SharedSurface* CreateShared(const gfx::IntSize& size) MOZ_OVERRIDE {
virtual UniquePtr<SharedSurface> CreateShared(const gfx::IntSize& size) MOZ_OVERRIDE {
bool hasAlpha = mReadCaps.alpha;
return SharedSurface_EGLImage::Create(mGL, mFormats, size, hasAlpha, mContext);
}

Просмотреть файл

@ -17,7 +17,7 @@ namespace gl {
using gfx::IntSize;
using gfx::SurfaceFormat;
SharedSurface_Basic*
/*static*/ UniquePtr<SharedSurface_Basic>
SharedSurface_Basic::Create(GLContext* gl,
const GLFormats& formats,
const IntSize& size,
@ -45,7 +45,10 @@ SharedSurface_Basic::Create(GLContext* gl,
default:
MOZ_CRASH("Unhandled Tex format.");
}
return new SharedSurface_Basic(gl, size, hasAlpha, format, tex);
typedef SharedSurface_Basic ptrT;
UniquePtr<ptrT> ret( new ptrT(gl, size, hasAlpha, format, tex) );
return Move(ret);
}
SharedSurface_Basic::SharedSurface_Basic(GLContext* gl,
@ -100,9 +103,10 @@ SharedSurface_Basic::Fence()
ReadPixelsIntoDataSurface(mGL, mData);
}
////////////////////////////////////////////////////////////////////////
// SharedSurface_GLTexture
SharedSurface_GLTexture*
/*static*/ UniquePtr<SharedSurface_GLTexture>
SharedSurface_GLTexture::Create(GLContext* prodGL,
GLContext* consGL,
const GLFormats& formats,
@ -124,7 +128,10 @@ SharedSurface_GLTexture::Create(GLContext* prodGL,
ownsTex = true;
}
return new SharedSurface_GLTexture(prodGL, consGL, size, hasAlpha, tex, ownsTex);
typedef SharedSurface_GLTexture ptrT;
UniquePtr<ptrT> ret( new ptrT(prodGL, consGL, size, hasAlpha, tex,
ownsTex) );
return Move(ret);
}
SharedSurface_GLTexture::~SharedSurface_GLTexture()

Просмотреть файл

@ -34,10 +34,10 @@ class SharedSurface_Basic
: public SharedSurface
{
public:
static SharedSurface_Basic* Create(GLContext* gl,
const GLFormats& formats,
const gfx::IntSize& size,
bool hasAlpha);
static UniquePtr<SharedSurface_Basic> Create(GLContext* gl,
const GLFormats& formats,
const gfx::IntSize& size,
bool hasAlpha);
static SharedSurface_Basic* Cast(SharedSurface* surf) {
MOZ_ASSERT(surf->mType == SharedSurfaceType::Basic);
@ -90,7 +90,7 @@ public:
: SurfaceFactory(gl, SharedSurfaceType::Basic, caps)
{}
virtual SharedSurface* CreateShared(const gfx::IntSize& size) MOZ_OVERRIDE {
virtual UniquePtr<SharedSurface> CreateShared(const gfx::IntSize& size) MOZ_OVERRIDE {
bool hasAlpha = mReadCaps.alpha;
return SharedSurface_Basic::Create(mGL, mFormats, size, hasAlpha);
}
@ -102,12 +102,12 @@ class SharedSurface_GLTexture
: public SharedSurface
{
public:
static SharedSurface_GLTexture* Create(GLContext* prodGL,
GLContext* consGL,
const GLFormats& formats,
const gfx::IntSize& size,
bool hasAlpha,
GLuint texture = 0);
static UniquePtr<SharedSurface_GLTexture> Create(GLContext* prodGL,
GLContext* consGL,
const GLFormats& formats,
const gfx::IntSize& size,
bool hasAlpha,
GLuint texture = 0);
static SharedSurface_GLTexture* Cast(SharedSurface* surf) {
MOZ_ASSERT(surf->mType == SharedSurfaceType::GLTextureShare);
@ -183,7 +183,7 @@ public:
MOZ_ASSERT(consGL != prodGL);
}
virtual SharedSurface* CreateShared(const gfx::IntSize& size) MOZ_OVERRIDE {
virtual UniquePtr<SharedSurface> CreateShared(const gfx::IntSize& size) MOZ_OVERRIDE {
bool hasAlpha = mReadCaps.alpha;
return SharedSurface_GLTexture::Create(mGL, mConsGL, mFormats, size, hasAlpha);
}

Просмотреть файл

@ -49,7 +49,7 @@ SurfaceFactory_Gralloc::SurfaceFactory_Gralloc(GLContext* prodGL,
mAllocator = allocator;
}
SharedSurface_Gralloc*
/*static*/ UniquePtr<SharedSurface_Gralloc>
SharedSurface_Gralloc::Create(GLContext* prodGL,
const GLFormats& formats,
const gfx::IntSize& size,
@ -59,10 +59,12 @@ SharedSurface_Gralloc::Create(GLContext* prodGL,
GLLibraryEGL* egl = &sEGLLibrary;
MOZ_ASSERT(egl);
UniquePtr<SharedSurface_Gralloc> ret;
DEBUG_PRINT("SharedSurface_Gralloc::Create -------\n");
if (!HasExtensions(egl, prodGL))
return nullptr;
return Move(ret);
gfxContentType type = hasAlpha ? gfxContentType::COLOR_ALPHA
: gfxContentType::COLOR;
@ -78,7 +80,7 @@ SharedSurface_Gralloc::Create(GLContext* prodGL,
layers::TextureFlags::DEFAULT);
if (!grallocTC->AllocateForGLRendering(size)) {
return nullptr;
return Move(ret);
}
sp<GraphicBuffer> buffer = grallocTC->GetGraphicBuffer();
@ -93,7 +95,7 @@ SharedSurface_Gralloc::Create(GLContext* prodGL,
LOCAL_EGL_NATIVE_BUFFER_ANDROID,
clientBuffer, attrs);
if (!image) {
return nullptr;
return Move(ret);
}
prodGL->MakeCurrent();
@ -110,11 +112,15 @@ SharedSurface_Gralloc::Create(GLContext* prodGL,
egl->fDestroyImage(display, image);
SharedSurface_Gralloc *surf = new SharedSurface_Gralloc(prodGL, size, hasAlpha, egl, allocator, grallocTC, prodTex);
ret.reset( new SharedSurface_Gralloc(prodGL, size, hasAlpha, egl,
allocator, grallocTC,
prodTex) );
DEBUG_PRINT("SharedSurface_Gralloc::Create: success -- surface %p, GraphicBuffer %p.\n", surf, buffer.get());
DEBUG_PRINT("SharedSurface_Gralloc::Create: success -- surface %p,"
" GraphicBuffer %p.\n",
ret.get(), buffer.get());
return surf;
return Move(ret);
}

Просмотреть файл

@ -23,11 +23,11 @@ class SharedSurface_Gralloc
: public SharedSurface
{
public:
static SharedSurface_Gralloc* Create(GLContext* prodGL,
const GLFormats& formats,
const gfx::IntSize& size,
bool hasAlpha,
layers::ISurfaceAllocator* allocator);
static UniquePtr<SharedSurface_Gralloc> Create(GLContext* prodGL,
const GLFormats& formats,
const gfx::IntSize& size,
bool hasAlpha,
layers::ISurfaceAllocator* allocator);
static SharedSurface_Gralloc* Cast(SharedSurface* surf) {
MOZ_ASSERT(surf->mType == SharedSurfaceType::Gralloc);
@ -84,12 +84,15 @@ public:
const SurfaceCaps& caps,
layers::ISurfaceAllocator* allocator = nullptr);
virtual SharedSurface* CreateShared(const gfx::IntSize& size) MOZ_OVERRIDE {
virtual UniquePtr<SharedSurface> CreateShared(const gfx::IntSize& size) MOZ_OVERRIDE {
bool hasAlpha = mReadCaps.alpha;
if (!mAllocator) {
return nullptr;
UniquePtr<SharedSurface> ret;
if (mAllocator) {
ret = SharedSurface_Gralloc::Create(mGL, mFormats, size,
hasAlpha, mAllocator);
}
return SharedSurface_Gralloc::Create(mGL, mFormats, size, hasAlpha, mAllocator);
return Move(ret);
}
};

Просмотреть файл

@ -13,14 +13,19 @@
namespace mozilla {
namespace gl {
/* static */ SharedSurface_IOSurface*
SharedSurface_IOSurface::Create(MacIOSurface* surface, GLContext* gl, bool hasAlpha)
/*static*/ UniquePtr<SharedSurface_IOSurface>
SharedSurface_IOSurface::Create(const RefPtr<MacIOSurface>& ioSurf,
GLContext* gl,
bool hasAlpha)
{
MOZ_ASSERT(surface);
MOZ_ASSERT(ioSurf);
MOZ_ASSERT(gl);
gfx::IntSize size(surface->GetWidth(), surface->GetHeight());
return new SharedSurface_IOSurface(surface, gl, size, hasAlpha);
gfx::IntSize size(ioSurf->GetWidth(), ioSurf->GetHeight());
typedef SharedSurface_IOSurface ptrT;
UniquePtr<ptrT> ret( new ptrT(ioSurf, gl, size, hasAlpha) );
return Move(ret);
}
void
@ -87,7 +92,7 @@ BackTextureWithIOSurf(GLContext* gl, GLuint tex, MacIOSurface* ioSurf)
ioSurf->CGLTexImageIOSurface2D(cgl);
}
SharedSurface_IOSurface::SharedSurface_IOSurface(MacIOSurface* surface,
SharedSurface_IOSurface::SharedSurface_IOSurface(const RefPtr<MacIOSurface>& ioSurf,
GLContext* gl,
const gfx::IntSize& size,
bool hasAlpha)
@ -96,14 +101,14 @@ SharedSurface_IOSurface::SharedSurface_IOSurface(MacIOSurface* surface,
gl,
size,
hasAlpha)
, mSurface(surface)
, mIOSurf(ioSurf)
, mCurConsGL(nullptr)
, mConsTex(0)
{
gl->MakeCurrent();
mProdTex = 0;
gl->fGenTextures(1, &mProdTex);
BackTextureWithIOSurf(gl, mProdTex, surface);
BackTextureWithIOSurf(gl, mProdTex, mIOSurf);
}
GLuint
@ -118,7 +123,7 @@ SharedSurface_IOSurface::ConsTexture(GLContext* consGL)
consGL->MakeCurrent();
mConsTex = 0;
consGL->fGenTextures(1, &mConsTex);
BackTextureWithIOSurf(consGL, mConsTex, mSurface);
BackTextureWithIOSurf(consGL, mConsTex, mIOSurf);
}
return mConsTex;
@ -134,17 +139,22 @@ SharedSurface_IOSurface::~SharedSurface_IOSurface()
}
}
////////////////////////////////////////////////////////////////////////
// SurfaceFactory_IOSurface
/*static*/ SurfaceFactory_IOSurface*
/*static*/ UniquePtr<SurfaceFactory_IOSurface>
SurfaceFactory_IOSurface::Create(GLContext* gl,
const SurfaceCaps& caps)
{
gfx::IntSize maxDims(MacIOSurface::GetMaxWidth(),
MacIOSurface::GetMaxHeight());
return new SurfaceFactory_IOSurface(gl, caps, maxDims);
typedef SurfaceFactory_IOSurface ptrT;
UniquePtr<ptrT> ret( new ptrT(gl, caps, maxDims) );
return Move(ret);
}
SharedSurface*
UniquePtr<SharedSurface>
SurfaceFactory_IOSurface::CreateShared(const gfx::IntSize& size)
{
if (size.width > mMaxDims.width ||
@ -154,15 +164,16 @@ SurfaceFactory_IOSurface::CreateShared(const gfx::IntSize& size)
}
bool hasAlpha = mReadCaps.alpha;
RefPtr<MacIOSurface> surf =
MacIOSurface::CreateIOSurface(size.width, size.height, 1.0, hasAlpha);
RefPtr<MacIOSurface> ioSurf;
ioSurf = MacIOSurface::CreateIOSurface(size.width, size.height, 1.0,
hasAlpha);
if (!surf) {
if (!ioSurf) {
NS_WARNING("Failed to create MacIOSurface.");
return nullptr;
}
return SharedSurface_IOSurface::Create(surf, mGL, hasAlpha);
return SharedSurface_IOSurface::Create(ioSurf, mGL, hasAlpha);
}
}

Просмотреть файл

@ -17,7 +17,9 @@ namespace gl {
class SharedSurface_IOSurface : public SharedSurface
{
public:
static SharedSurface_IOSurface* Create(MacIOSurface* surface, GLContext* gl, bool hasAlpha);
static UniquePtr<SharedSurface_IOSurface> Create(const RefPtr<MacIOSurface>& ioSurf,
GLContext* gl,
bool hasAlpha);
~SharedSurface_IOSurface();
@ -51,13 +53,15 @@ public:
}
MacIOSurface* GetIOSurface() const {
return mSurface;
return mIOSurf;
}
private:
SharedSurface_IOSurface(MacIOSurface* surface, GLContext* gl, const gfx::IntSize& size, bool hasAlpha);
SharedSurface_IOSurface(const RefPtr<MacIOSurface>& ioSurf,
GLContext* gl, const gfx::IntSize& size,
bool hasAlpha);
RefPtr<MacIOSurface> mSurface;
RefPtr<MacIOSurface> mIOSurf;
GLuint mProdTex;
const GLContext* mCurConsGL;
GLuint mConsTex;
@ -67,8 +71,8 @@ class SurfaceFactory_IOSurface : public SurfaceFactory
{
public:
// Infallible.
static SurfaceFactory_IOSurface* Create(GLContext* gl,
const SurfaceCaps& caps);
static UniquePtr<SurfaceFactory_IOSurface> Create(GLContext* gl,
const SurfaceCaps& caps);
protected:
const gfx::IntSize mMaxDims;
@ -80,7 +84,7 @@ protected:
{
}
virtual SharedSurface* CreateShared(const gfx::IntSize& size) MOZ_OVERRIDE;
virtual UniquePtr<SharedSurface> CreateShared(const gfx::IntSize& size) MOZ_OVERRIDE;
};
} /* namespace gfx */

Просмотреть файл

@ -9,6 +9,7 @@
#include "SharedSurface.h"
#include "SharedSurfaceGL.h"
#include "GeckoProfiler.h"
#include "mozilla/Move.h"
namespace mozilla {
namespace gl {
@ -30,10 +31,10 @@ SurfaceStream::ChooseGLStreamType(SurfaceStream::OMTC omtc,
}
}
SurfaceStream*
TemporaryRef<SurfaceStream>
SurfaceStream::CreateForType(SurfaceStreamType type, mozilla::gl::GLContext* glContext, SurfaceStream* prevStream)
{
SurfaceStream* result = nullptr;
RefPtr<SurfaceStream> result;
switch (type) {
case SurfaceStreamType::SingleBuffer:
@ -53,14 +54,15 @@ SurfaceStream::CreateForType(SurfaceStreamType type, mozilla::gl::GLContext* glC
}
result->mGLContext = glContext;
return result;
return result.forget();
}
bool
SurfaceStream_TripleBuffer::CopySurfaceToProducer(SharedSurface* src, SurfaceFactory* factory)
{
if (!mProducer) {
New(factory, src->mSize, mProducer);
New(factory, src->mSize, &mProducer);
if (!mProducer) {
return false;
}
@ -68,14 +70,17 @@ SurfaceStream_TripleBuffer::CopySurfaceToProducer(SharedSurface* src, SurfaceFac
MOZ_ASSERT(src->mSize == mProducer->mSize, "Size mismatch");
SharedSurface::ProdCopy(src, mProducer, factory);
SharedSurface::ProdCopy(src, mProducer.get(), factory);
return true;
}
void
SurfaceStream::New(SurfaceFactory* factory, const gfx::IntSize& size,
SharedSurface*& surf)
UniquePtr<SharedSurface>* surfSlot)
{
MOZ_ASSERT(surfSlot);
UniquePtr<SharedSurface>& surf = *surfSlot;
MOZ_ASSERT(!surf);
surf = factory->NewSharedSurface(size);
@ -83,91 +88,141 @@ SurfaceStream::New(SurfaceFactory* factory, const gfx::IntSize& size,
// Before next use, wait until SharedSurface's buffer
// is no longer being used.
surf->WaitForBufferOwnership();
mSurfaces.insert(surf);
#ifdef DEBUG
mSurfaces.insert(surf.get());
#endif
}
}
void
SurfaceStream::Recycle(SurfaceFactory* factory, SharedSurface*& surf)
SurfaceStream::MoveTo(UniquePtr<SharedSurface>* slotFrom,
UniquePtr<SharedSurface>* slotTo)
{
MOZ_ASSERT(slotFrom);
UniquePtr<SharedSurface>& from = *slotFrom;
MOZ_ASSERT(slotTo);
UniquePtr<SharedSurface>& to = *slotTo;
MOZ_ASSERT(!to);
to = Move(from);
MOZ_ASSERT(!from);
}
void
SurfaceStream::Recycle(SurfaceFactory* factory, UniquePtr<SharedSurface>* surfSlot)
{
MOZ_ASSERT(surfSlot);
UniquePtr<SharedSurface>& surf = *surfSlot;
if (surf) {
mSurfaces.erase(surf);
factory->Recycle(surf);
#ifdef DEBUG
mSurfaces.erase(surf.get());
#endif
factory->Recycle(Move(surf));
}
MOZ_ASSERT(!surf);
}
void
SurfaceStream::Delete(SharedSurface*& surf)
SurfaceStream::Delete(UniquePtr<SharedSurface>* surfSlot)
{
MOZ_ASSERT(surfSlot);
UniquePtr<SharedSurface>& surf = *surfSlot;
if (surf) {
mSurfaces.erase(surf);
delete surf;
#ifdef DEBUG
mSurfaces.erase(surf.get());
#endif
surf = nullptr;
}
MOZ_ASSERT(!surf);
}
SharedSurface*
SurfaceStream::Surrender(SharedSurface*& surf)
UniquePtr<SharedSurface>
SurfaceStream::Surrender(UniquePtr<SharedSurface>* surfSlot)
{
SharedSurface* ret = surf;
MOZ_ASSERT(surfSlot);
UniquePtr<SharedSurface>& surf = *surfSlot;
#ifdef DEBUG
if (surf) {
mSurfaces.erase(surf);
surf = nullptr;
mSurfaces.erase(surf.get());
}
#endif
UniquePtr<SharedSurface> ret = Move(surf);
MOZ_ASSERT(!surf);
return ret;
return Move(ret);
}
SharedSurface*
SurfaceStream::Absorb(SharedSurface*& surf)
// Move `surfSlot` to `return`, but record that the surf is now part of
// this stream.
UniquePtr<SharedSurface>
SurfaceStream::Absorb(UniquePtr<SharedSurface>* surfSlot)
{
SharedSurface* ret = surf;
MOZ_ASSERT(surfSlot);
UniquePtr<SharedSurface>& surf = *surfSlot;
#ifdef DEBUG
if (surf) {
mSurfaces.insert(surf);
surf = nullptr;
mSurfaces.insert(surf.get());
}
#endif
UniquePtr<SharedSurface> ret = Move(surf);
MOZ_ASSERT(!surf);
return ret;
return Move(ret);
}
void
SurfaceStream::Scrap(SharedSurface*& scrap)
SurfaceStream::Scrap(UniquePtr<SharedSurface>* surfSlot)
{
if (scrap) {
mScraps.push(scrap);
scrap = nullptr;
MOZ_ASSERT(surfSlot);
UniquePtr<SharedSurface>& surf = *surfSlot;
if (surf) {
mScraps.Push(Move(surf));
}
MOZ_ASSERT(!scrap);
MOZ_ASSERT(!surf);
}
void
SurfaceStream::RecycleScraps(SurfaceFactory* factory)
{
while (!mScraps.empty()) {
SharedSurface* cur = mScraps.top();
mScraps.pop();
while (!mScraps.Empty()) {
UniquePtr<SharedSurface> cur = mScraps.Pop();
Recycle(factory, cur);
Recycle(factory, &cur);
}
}
////////////////////////////////////////////////////////////////////////
// SurfaceStream
SurfaceStream::SurfaceStream(SurfaceStreamType type,
SurfaceStream* prevStream)
: mType(type)
, mProducer(nullptr)
, mMonitor("SurfaceStream monitor")
, mIsAlive(true)
{
MOZ_ASSERT(!prevStream || mType != prevStream->mType,
"We should not need to create a SurfaceStream from another "
"of the same type.");
}
SurfaceStream::~SurfaceStream()
{
Delete(mProducer);
Delete(&mProducer);
while (!mScraps.empty()) {
SharedSurface* cur = mScraps.top();
mScraps.pop();
while (!mScraps.Empty()) {
UniquePtr<SharedSurface> cur = mScraps.Pop();
Delete(cur);
Delete(&cur);
}
MOZ_ASSERT(mSurfaces.empty());
@ -195,13 +250,16 @@ SurfaceStream::Resize(SurfaceFactory* factory, const gfx::IntSize& size)
MonitorAutoLock lock(mMonitor);
if (mProducer) {
Scrap(mProducer);
Scrap(&mProducer);
}
New(factory, size, mProducer);
return mProducer;
New(factory, size, &mProducer);
return mProducer.get();
}
////////////////////////////////////////////////////////////////////////
// SurfaceStream_SingleBuffer
SurfaceStream_SingleBuffer::SurfaceStream_SingleBuffer(SurfaceStream* prevStream)
: SurfaceStream(SurfaceStreamType::SingleBuffer, prevStream)
, mConsumer(nullptr)
@ -209,33 +267,30 @@ SurfaceStream_SingleBuffer::SurfaceStream_SingleBuffer(SurfaceStream* prevStream
if (!prevStream)
return;
SharedSurface* prevProducer = nullptr;
SharedSurface* prevConsumer = nullptr;
prevStream->SurrenderSurfaces(prevProducer, prevConsumer);
UniquePtr<SharedSurface> prevProducer;
UniquePtr<SharedSurface> prevConsumer;
prevStream->SurrenderSurfaces(&prevProducer, &prevConsumer);
if (prevConsumer == prevProducer)
prevConsumer = nullptr;
mProducer = Absorb(prevProducer);
mConsumer = Absorb(prevConsumer);
mProducer = Absorb(&prevProducer);
mConsumer = Absorb(&prevConsumer);
}
SurfaceStream_SingleBuffer::~SurfaceStream_SingleBuffer()
{
Delete(mConsumer);
Delete(&mConsumer);
}
void
SurfaceStream_SingleBuffer::SurrenderSurfaces(SharedSurface*& producer,
SharedSurface*& consumer)
SurfaceStream_SingleBuffer::SurrenderSurfaces(UniquePtr<SharedSurface>* out_producer,
UniquePtr<SharedSurface>* out_consumer)
{
MOZ_ASSERT(out_producer);
MOZ_ASSERT(out_consumer);
mIsAlive = false;
producer = Surrender(mProducer);
consumer = Surrender(mConsumer);
if (!consumer)
consumer = producer;
*out_producer = Surrender(&mProducer);
*out_consumer = Surrender(&mConsumer);
}
SharedSurface*
@ -244,7 +299,7 @@ SurfaceStream_SingleBuffer::SwapProducer(SurfaceFactory* factory,
{
MonitorAutoLock lock(mMonitor);
if (mConsumer) {
Recycle(factory, mConsumer);
Recycle(factory, &mConsumer);
}
if (mProducer) {
@ -264,17 +319,17 @@ SurfaceStream_SingleBuffer::SwapProducer(SurfaceFactory* factory,
}
if (needsNewBuffer) {
Move(mProducer, mConsumer);
MoveTo(&mProducer, &mConsumer);
}
}
// The old Prod (if there every was one) was invalid,
// so we need a new one.
if (!mProducer) {
New(factory, size, mProducer);
New(factory, size, &mProducer);
}
return mProducer;
return mProducer.get();
}
SharedSurface*
@ -284,14 +339,15 @@ SurfaceStream_SingleBuffer::SwapConsumer_NoWait()
// Use Cons, if present.
// Otherwise, just use Prod directly.
SharedSurface* toConsume = mConsumer;
SharedSurface* toConsume = mConsumer.get();
if (!toConsume)
toConsume = mProducer;
toConsume = mProducer.get();
return toConsume;
}
////////////////////////////////////////////////////////////////////////
// SurfaceStream_TripleBuffer_Copy
SurfaceStream_TripleBuffer_Copy::SurfaceStream_TripleBuffer_Copy(SurfaceStream* prevStream)
: SurfaceStream(SurfaceStreamType::TripleBuffer_Copy, prevStream)
@ -301,34 +357,34 @@ SurfaceStream_TripleBuffer_Copy::SurfaceStream_TripleBuffer_Copy(SurfaceStream*
if (!prevStream)
return;
SharedSurface* prevProducer = nullptr;
SharedSurface* prevConsumer = nullptr;
prevStream->SurrenderSurfaces(prevProducer, prevConsumer);
UniquePtr<SharedSurface> prevProducer;
UniquePtr<SharedSurface> prevConsumer;
prevStream->SurrenderSurfaces(&prevProducer, &prevConsumer);
if (prevConsumer == prevProducer)
prevConsumer = nullptr;
mProducer = Absorb(prevProducer);
mConsumer = Absorb(prevConsumer);
mProducer = Absorb(&prevProducer);
mConsumer = Absorb(&prevConsumer);
}
SurfaceStream_TripleBuffer_Copy::~SurfaceStream_TripleBuffer_Copy()
{
Delete(mStaging);
Delete(mConsumer);
Delete(&mStaging);
Delete(&mConsumer);
}
void
SurfaceStream_TripleBuffer_Copy::SurrenderSurfaces(SharedSurface*& producer,
SharedSurface*& consumer)
SurfaceStream_TripleBuffer_Copy::SurrenderSurfaces(UniquePtr<SharedSurface>* out_producer,
UniquePtr<SharedSurface>* out_consumer)
{
MOZ_ASSERT(out_producer);
MOZ_ASSERT(out_consumer);
mIsAlive = false;
producer = Surrender(mProducer);
consumer = Surrender(mConsumer);
*out_producer = Surrender(&mProducer);
*out_consumer = Surrender(&mConsumer);
if (!consumer)
consumer = Surrender(mStaging);
if (!*out_consumer)
*out_consumer = Surrender(&mStaging);
}
SharedSurface*
@ -342,55 +398,57 @@ SurfaceStream_TripleBuffer_Copy::SwapProducer(SurfaceFactory* factory,
if (mStaging) {
// We'll re-use this for a new mProducer later on if
// the size remains the same
Recycle(factory, mStaging);
Recycle(factory, &mStaging);
}
Move(mProducer, mStaging);
MoveTo(&mProducer, &mStaging);
mStaging->Fence();
New(factory, size, mProducer);
New(factory, size, &mProducer);
if (mProducer && mStaging->mSize == mProducer->mSize)
SharedSurface::ProdCopy(mStaging, mProducer, factory);
if (mProducer &&
mStaging->mSize == mProducer->mSize)
{
SharedSurface::ProdCopy(mStaging.get(), mProducer.get(), factory);
}
} else {
New(factory, size, mProducer);
New(factory, size, &mProducer);
}
return mProducer;
return mProducer.get();
}
SharedSurface*
SurfaceStream_TripleBuffer_Copy::SwapConsumer_NoWait()
{
MonitorAutoLock lock(mMonitor);
if (mStaging) {
Scrap(mConsumer);
Move(mStaging, mConsumer);
Scrap(&mConsumer);
MoveTo(&mStaging, &mConsumer);
}
return mConsumer;
return mConsumer.get();
}
////////////////////////////////////////////////////////////////////////
// SurfaceStream_TripleBuffer
void SurfaceStream_TripleBuffer::Init(SurfaceStream* prevStream)
{
if (!prevStream)
return;
SharedSurface* prevProducer = nullptr;
SharedSurface* prevConsumer = nullptr;
prevStream->SurrenderSurfaces(prevProducer, prevConsumer);
UniquePtr<SharedSurface> prevProducer;
UniquePtr<SharedSurface> prevConsumer;
prevStream->SurrenderSurfaces(&prevProducer, &prevConsumer);
if (prevConsumer == prevProducer)
prevConsumer = nullptr;
mProducer = Absorb(prevProducer);
mConsumer = Absorb(prevConsumer);
mProducer = Absorb(&prevProducer);
mConsumer = Absorb(&prevConsumer);
}
SurfaceStream_TripleBuffer::SurfaceStream_TripleBuffer(SurfaceStreamType type, SurfaceStream* prevStream)
SurfaceStream_TripleBuffer::SurfaceStream_TripleBuffer(SurfaceStreamType type,
SurfaceStream* prevStream)
: SurfaceStream(type, prevStream)
, mStaging(nullptr)
, mConsumer(nullptr)
@ -408,21 +466,24 @@ SurfaceStream_TripleBuffer::SurfaceStream_TripleBuffer(SurfaceStream* prevStream
SurfaceStream_TripleBuffer::~SurfaceStream_TripleBuffer()
{
Delete(mStaging);
Delete(mConsumer);
Delete(&mStaging);
Delete(&mConsumer);
}
void
SurfaceStream_TripleBuffer::SurrenderSurfaces(SharedSurface*& producer,
SharedSurface*& consumer)
SurfaceStream_TripleBuffer::SurrenderSurfaces(UniquePtr<SharedSurface>* out_producer,
UniquePtr<SharedSurface>* out_consumer)
{
MOZ_ASSERT(out_producer);
MOZ_ASSERT(out_consumer);
mIsAlive = false;
producer = Surrender(mProducer);
consumer = Surrender(mConsumer);
*out_producer = Surrender(&mProducer);
*out_consumer = Surrender(&mConsumer);
if (!consumer)
consumer = Surrender(mStaging);
if (!*out_consumer)
*out_consumer = Surrender(&mStaging);
}
SharedSurface*
@ -430,7 +491,7 @@ SurfaceStream_TripleBuffer::SwapProducer(SurfaceFactory* factory,
const gfx::IntSize& size)
{
PROFILER_LABEL("SurfaceStream_TripleBuffer", "SwapProducer",
js::ProfileEntry::Category::GRAPHICS);
js::ProfileEntry::Category::GRAPHICS);
MonitorAutoLock lock(mMonitor);
if (mProducer) {
@ -442,17 +503,17 @@ SurfaceStream_TripleBuffer::SwapProducer(SurfaceFactory* factory,
WaitForCompositor();
}
if (mStaging) {
Scrap(mStaging);
Scrap(&mStaging);
}
Move(mProducer, mStaging);
MoveTo(&mProducer, &mStaging);
mStaging->Fence();
}
MOZ_ASSERT(!mProducer);
New(factory, size, mProducer);
New(factory, size, &mProducer);
return mProducer;
return mProducer.get();
}
SharedSurface*
@ -460,16 +521,20 @@ SurfaceStream_TripleBuffer::SwapConsumer_NoWait()
{
MonitorAutoLock lock(mMonitor);
if (mStaging) {
Scrap(mConsumer);
Move(mStaging, mConsumer);
Scrap(&mConsumer);
MoveTo(&mStaging, &mConsumer);
mMonitor.NotifyAll();
}
return mConsumer;
return mConsumer.get();
}
////////////////////////////////////////////////////////////////////////
// SurfaceStream_TripleBuffer_Async
SurfaceStream_TripleBuffer_Async::SurfaceStream_TripleBuffer_Async(SurfaceStream* prevStream)
: SurfaceStream_TripleBuffer(SurfaceStreamType::TripleBuffer_Async, prevStream)
: SurfaceStream_TripleBuffer(SurfaceStreamType::TripleBuffer_Async,
prevStream)
{
}
@ -480,8 +545,9 @@ SurfaceStream_TripleBuffer_Async::~SurfaceStream_TripleBuffer_Async()
void
SurfaceStream_TripleBuffer_Async::WaitForCompositor()
{
PROFILER_LABEL("SurfaceStream_TripleBuffer_Async", "WaitForCompositor",
js::ProfileEntry::Category::GRAPHICS);
PROFILER_LABEL("SurfaceStream_TripleBuffer_Async",
"WaitForCompositor",
js::ProfileEntry::Category::GRAPHICS);
// If we haven't be notified within 100ms, then
// something must have happened and it will never arrive.

Просмотреть файл

@ -12,7 +12,9 @@
#include "mozilla/Attributes.h"
#include "mozilla/gfx/Point.h"
#include "mozilla/GenericRefCounted.h"
#include "mozilla/UniquePtr.h"
#include "SurfaceTypes.h"
#include "SharedSurface.h"
namespace mozilla {
@ -34,9 +36,9 @@ public:
static SurfaceStreamType ChooseGLStreamType(OMTC omtc,
bool preserveBuffer);
static SurfaceStream* CreateForType(SurfaceStreamType type,
mozilla::gl::GLContext* glContext,
SurfaceStream* prevStream = nullptr);
static TemporaryRef<SurfaceStream> CreateForType(SurfaceStreamType type,
mozilla::gl::GLContext* glContext,
SurfaceStream* prevStream = nullptr);
const SurfaceStreamType mType;
@ -46,9 +48,11 @@ public:
protected:
// |mProd| is owned by us, but can be ripped away when
// creating a new GLStream from this one.
SharedSurface* mProducer;
UniquePtr<SharedSurface> mProducer;
#ifdef DEBUG
std::set<SharedSurface*> mSurfaces;
std::stack<SharedSurface*> mScraps;
#endif
UniquePtrQueue<SharedSurface> mScraps;
mutable Monitor mMonitor;
bool mIsAlive;
@ -58,16 +62,7 @@ protected:
// |previous| can be null, indicating this is the first one.
// Otherwise, we pull in |mProd| from |previous| an our initial surface.
SurfaceStream(SurfaceStreamType type, SurfaceStream* prevStream)
: mType(type)
, mProducer(nullptr)
, mMonitor("SurfaceStream monitor")
, mIsAlive(true)
{
MOZ_ASSERT(!prevStream || mType != prevStream->mType,
"We should not need to create a SurfaceStream from another "
"of the same type.");
}
SurfaceStream(SurfaceStreamType type, SurfaceStream* prevStream);
public:
virtual ~SurfaceStream();
@ -76,26 +71,23 @@ protected:
// These functions below are helpers to make trading buffers around easier.
// For instance, using Move(a,b) instead of normal assignment assures that
// we are never leaving anything hanging around, keeping things very safe.
static void Move(SharedSurface*& from, SharedSurface*& to) {
MOZ_ASSERT(!to);
to = from;
from = nullptr;
}
void MoveTo(UniquePtr<SharedSurface>* slotFrom,
UniquePtr<SharedSurface>* slotTo);
void New(SurfaceFactory* factory, const gfx::IntSize& size,
SharedSurface*& surf);
void Delete(SharedSurface*& surf);
void Recycle(SurfaceFactory* factory, SharedSurface*& surf);
UniquePtr<SharedSurface>* surfSlot);
void Delete(UniquePtr<SharedSurface>* surfSlot);
void Recycle(SurfaceFactory* factory,
UniquePtr<SharedSurface>* surfSlot);
// Surrender control of a surface, and return it for use elsewhere.
SharedSurface* Surrender(SharedSurface*& surf);
UniquePtr<SharedSurface> Surrender(UniquePtr<SharedSurface>* surfSlot);
// Absorb control of a surface from elsewhere, clears its old location.
SharedSurface* Absorb(SharedSurface*& surf);
UniquePtr<SharedSurface> Absorb(UniquePtr<SharedSurface>* surfSlot);
// For holding on to surfaces we don't need until we can return them to the
// Producer's factory via SurfaceFactory::Recycle.
// Not thread-safe.
void Scrap(SharedSurface*& scrap);
void Scrap(UniquePtr<SharedSurface>* surfSlot);
// Not thread-safe.
void RecycleScraps(SurfaceFactory* factory);
@ -124,7 +116,8 @@ protected:
public:
virtual SharedSurface* SwapConsumer();
virtual void SurrenderSurfaces(SharedSurface*& producer, SharedSurface*& consumer) = 0;
virtual void SurrenderSurfaces(UniquePtr<SharedSurface>* out_producer,
UniquePtr<SharedSurface>* out_consumer) = 0;
};
// Not thread-safe. Don't use cross-threads.
@ -132,10 +125,11 @@ class SurfaceStream_SingleBuffer
: public SurfaceStream
{
protected:
SharedSurface* mConsumer; // Only present after resize-swap.
UniquePtr<SharedSurface> mConsumer; // Only present after resize-swap.
public:
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(SurfaceStream_SingleBuffer)
explicit SurfaceStream_SingleBuffer(SurfaceStream* prevStream);
virtual ~SurfaceStream_SingleBuffer();
@ -144,11 +138,12 @@ public:
* SwapCons being called in Render.
*/
virtual SharedSurface* SwapProducer(SurfaceFactory* factory,
const gfx::IntSize& size);
const gfx::IntSize& size) MOZ_OVERRIDE;
virtual SharedSurface* SwapConsumer_NoWait();
virtual SharedSurface* SwapConsumer_NoWait() MOZ_OVERRIDE;
virtual void SurrenderSurfaces(SharedSurface*& producer, SharedSurface*& consumer);
virtual void SurrenderSurfaces(UniquePtr<SharedSurface>* out_producer,
UniquePtr<SharedSurface>* out_consumer) MOZ_OVERRIDE;
};
// Our hero for preserveDrawingBuffer=true.
@ -156,20 +151,22 @@ class SurfaceStream_TripleBuffer_Copy
: public SurfaceStream
{
protected:
SharedSurface* mStaging;
SharedSurface* mConsumer;
UniquePtr<SharedSurface> mStaging;
UniquePtr<SharedSurface> mConsumer;
public:
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(SurfaceStream_TripleBuffer_Copy)
explicit SurfaceStream_TripleBuffer_Copy(SurfaceStream* prevStream);
virtual ~SurfaceStream_TripleBuffer_Copy();
virtual SharedSurface* SwapProducer(SurfaceFactory* factory,
const gfx::IntSize& size);
const gfx::IntSize& size) MOZ_OVERRIDE;
virtual SharedSurface* SwapConsumer_NoWait();
virtual SharedSurface* SwapConsumer_NoWait() MOZ_OVERRIDE;
virtual void SurrenderSurfaces(SharedSurface*& producer, SharedSurface*& consumer);
virtual void SurrenderSurfaces(UniquePtr<SharedSurface>* out_producer,
UniquePtr<SharedSurface>* out_consumer) MOZ_OVERRIDE;
};
@ -177,8 +174,8 @@ class SurfaceStream_TripleBuffer
: public SurfaceStream
{
protected:
SharedSurface* mStaging;
SharedSurface* mConsumer;
UniquePtr<SharedSurface> mStaging;
UniquePtr<SharedSurface> mConsumer;
// Returns true if we were able to wait, false if not
virtual void WaitForCompositor() {}
@ -188,9 +185,12 @@ protected:
public:
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(SurfaceStream_TripleBuffer)
explicit SurfaceStream_TripleBuffer(SurfaceStream* prevStream);
virtual ~SurfaceStream_TripleBuffer();
virtual bool CopySurfaceToProducer(SharedSurface* src, SurfaceFactory* factory);
virtual bool CopySurfaceToProducer(SharedSurface* src,
SurfaceFactory* factory) MOZ_OVERRIDE;
private:
// Common constructor code.
@ -199,11 +199,12 @@ private:
public:
// Done writing to prod, swap prod and staging
virtual SharedSurface* SwapProducer(SurfaceFactory* factory,
const gfx::IntSize& size);
const gfx::IntSize& size) MOZ_OVERRIDE;
virtual SharedSurface* SwapConsumer_NoWait();
virtual SharedSurface* SwapConsumer_NoWait() MOZ_OVERRIDE;
virtual void SurrenderSurfaces(SharedSurface*& producer, SharedSurface*& consumer);
virtual void SurrenderSurfaces(UniquePtr<SharedSurface>* out_producer,
UniquePtr<SharedSurface>* out_consumer) MOZ_OVERRIDE;
};
class SurfaceStream_TripleBuffer_Async
@ -213,6 +214,8 @@ protected:
virtual void WaitForCompositor() MOZ_OVERRIDE;
public:
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(SurfaceStream_TripleBuffer_Async)
explicit SurfaceStream_TripleBuffer_Async(SurfaceStream* prevStream);
virtual ~SurfaceStream_TripleBuffer_Async();
};

Просмотреть файл

@ -143,6 +143,7 @@ MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(DiagnosticFlags)
MOZ_BEGIN_ENUM_CLASS(EffectTypes, uint8_t)
MASK,
BLEND_MODE,
COLOR_MATRIX,
MAX_SECONDARY, // sentinel for the count of secondary effect types
RGB,
YCBCR,

Просмотреть файл

@ -61,3 +61,11 @@ EffectBlendMode::PrintInfo(std::stringstream& aStream, const char* aPrefix)
aStream << nsPrintfCString("EffectBlendMode (0x%p) [blendmode=%i]", this, (int)mBlendMode).get();
}
void
EffectColorMatrix::PrintInfo(std::stringstream& aStream, const char* aPrefix)
{
aStream << aPrefix;
aStream << nsPrintfCString("EffectColorMatrix (0x%p)", this).get();
AppendToString(aStream, mColorMatrix, " [matrix=", "]");
}

Просмотреть файл

@ -121,8 +121,29 @@ struct EffectRenderTarget : public TexturedEffect
virtual void PrintInfo(std::stringstream& aStream, const char* aPrefix);
RefPtr<CompositingRenderTarget> mRenderTarget;
protected:
EffectRenderTarget(EffectTypes aType, CompositingRenderTarget *aRenderTarget)
: TexturedEffect(aType, aRenderTarget, true, gfx::Filter::LINEAR)
, mRenderTarget(aRenderTarget)
{}
};
// Render to a render target rather than the screen.
struct EffectColorMatrix : public Effect
{
EffectColorMatrix(gfx::Matrix5x4 aMatrix)
: Effect(EffectTypes::COLOR_MATRIX)
, mColorMatrix(aMatrix)
{}
virtual const char* Name() { return "EffectColorMatrix"; }
virtual void PrintInfo(std::stringstream& aStream, const char* aPrefix);
const gfx::Matrix5x4 mColorMatrix;
};
struct EffectRGB : public TexturedEffect
{
EffectRGB(TextureSource *aTexture,

Просмотреть файл

@ -169,6 +169,22 @@ AppendToString(std::stringstream& aStream, const Matrix4x4& m,
aStream << sfx;
}
void
AppendToString(std::stringstream& aStream, const Matrix5x4& m,
const char* pfx, const char* sfx)
{
aStream << pfx;
aStream << nsPrintfCString(
"[ %g %g %g %g; %g %g %g %g; %g %g %g %g; %g %g %g %g; %g %g %g %g]",
m._11, m._12, m._13, m._14,
m._21, m._22, m._23, m._24,
m._31, m._32, m._33, m._34,
m._41, m._42, m._43, m._44,
m._51, m._52, m._53, m._54).get();
aStream << sfx;
}
void
AppendToString(std::stringstream& aStream, const Filter filter,
const char* pfx, const char* sfx)

Просмотреть файл

@ -139,6 +139,10 @@ void
AppendToString(std::stringstream& aStream, const mozilla::gfx::Matrix4x4& m,
const char* pfx="", const char* sfx="");
void
AppendToString(std::stringstream& aStream, const mozilla::gfx::Matrix5x4& m,
const char* pfx="", const char* sfx="");
void
AppendToString(std::stringstream& aStream, const mozilla::gfx::Filter filter,
const char* pfx="", const char* sfx="");

Просмотреть файл

@ -157,8 +157,10 @@ CanvasClientSurfaceStream::Update(gfx::IntSize aSize, ClientCanvasLayer* aLayer)
// Copy our current surface to the current producer surface in our stream, then
// call SwapProducer to make a new buffer ready.
stream->CopySurfaceToProducer(aLayer->mTextureSurface, aLayer->mFactory);
stream->SwapProducer(aLayer->mFactory, gfx::IntSize(aSize.width, aSize.height));
stream->CopySurfaceToProducer(aLayer->mTextureSurface.get(),
aLayer->mFactory.get());
stream->SwapProducer(aLayer->mFactory.get(),
gfx::IntSize(aSize.width, aSize.height));
} else {
stream = screen->Stream();
}

Просмотреть файл

@ -47,7 +47,7 @@ ClientCanvasLayer::~ClientCanvasLayer()
mCanvasClient = nullptr;
}
if (mTextureSurface) {
delete mTextureSurface;
mTextureSurface = nullptr;
}
}
@ -73,13 +73,16 @@ ClientCanvasLayer::Initialize(const Data& aData)
SurfaceStreamType streamType =
SurfaceStream::ChooseGLStreamType(SurfaceStream::OffMainThread,
screen->PreserveBuffer());
SurfaceFactory* factory = nullptr;
UniquePtr<SurfaceFactory> factory;
if (!gfxPrefs::WebGLForceLayersReadback()) {
switch (ClientManager()->AsShadowForwarder()->GetCompositorBackendType()) {
case mozilla::layers::LayersBackend::LAYERS_OPENGL: {
if (mGLContext->GetContextType() == GLContextType::EGL) {
#ifdef MOZ_WIDGET_GONK
factory = new SurfaceFactory_Gralloc(mGLContext, caps, ClientManager()->AsShadowForwarder());
factory = MakeUnique<SurfaceFactory_Gralloc>(mGLContext,
caps,
ClientManager()->AsShadowForwarder());
#else
bool isCrossProcess = !(XRE_GetProcessType() == GeckoProcessType_Default);
if (!isCrossProcess) {
@ -96,7 +99,8 @@ ClientCanvasLayer::Initialize(const Data& aData)
#ifdef XP_MACOSX
factory = SurfaceFactory_IOSurface::Create(mGLContext, caps);
#else
factory = new SurfaceFactory_GLTexture(mGLContext, nullptr, caps);
GLContext* nullConsGL = nullptr; // Bug 1050044.
factory = MakeUnique<SurfaceFactory_GLTexture>(mGLContext, nullConsGL, caps);
#endif
}
break;
@ -117,26 +121,25 @@ ClientCanvasLayer::Initialize(const Data& aData)
if (mStream) {
// We're using a stream other than the one in the default screen
mFactory = factory;
mFactory = Move(factory);
if (!mFactory) {
// Absolutely must have a factory here, so create a basic one
mFactory = new SurfaceFactory_Basic(mGLContext, caps);
mFactory = MakeUnique<SurfaceFactory_Basic>(mGLContext, caps);
}
gfx::IntSize size = gfx::IntSize(aData.mSize.width, aData.mSize.height);
mTextureSurface = SharedSurface_GLTexture::Create(mGLContext, mGLContext,
mGLContext->GetGLFormats(),
size, caps.alpha, aData.mTexID);
SharedSurface* producer = mStream->SwapProducer(mFactory, size);
SharedSurface* producer = mStream->SwapProducer(mFactory.get(), size);
if (!producer) {
// Fallback to basic factory
delete mFactory;
mFactory = new SurfaceFactory_Basic(mGLContext, caps);
producer = mStream->SwapProducer(mFactory, size);
mFactory = MakeUnique<SurfaceFactory_Basic>(mGLContext, caps);
producer = mStream->SwapProducer(mFactory.get(), size);
MOZ_ASSERT(producer, "Failed to create initial canvas surface with basic factory");
}
} else if (factory) {
screen->Morph(factory, streamType);
screen->Morph(Move(factory), streamType);
}
}
}

Просмотреть файл

@ -101,8 +101,8 @@ protected:
RefPtr<CanvasClient> mCanvasClient;
gl::SharedSurface* mTextureSurface;
gl::SurfaceFactory* mFactory;
UniquePtr<gl::SharedSurface> mTextureSurface;
UniquePtr<gl::SurfaceFactory> mFactory;
friend class DeprecatedCanvasClient2D;
friend class CanvasClient2D;

Просмотреть файл

@ -49,7 +49,7 @@ FPSCounter::Init()
bool
FPSCounter::CapturedFullInterval(TimeStamp aTimestamp) {
TimeDuration duration = aTimestamp - mLastInterval;
return duration.ToSecondsSigDigits() >= kFpsDumpInterval;
return duration.ToSeconds() >= kFpsDumpInterval;
}
void

Просмотреть файл

@ -410,6 +410,58 @@ LayerManagerComposite::RenderDebugOverlay(const Rect& aBounds)
}
}
RefPtr<CompositingRenderTarget>
LayerManagerComposite::PushGroup()
{
RefPtr<CompositingRenderTarget> previousTarget = mCompositor->GetCurrentRenderTarget();
// make our render target the same size as the destination target
// so that we don't have to change size if the drawing area changes.
IntRect rect(previousTarget->GetOrigin(), previousTarget->GetSize());
// XXX: I'm not sure if this is true or not...
MOZ_ASSERT(rect.x == 0 && rect.y == 0);
if (!mTwoPassTmpTarget ||
mTwoPassTmpTarget->GetSize() != previousTarget->GetSize() ||
mTwoPassTmpTarget->GetOrigin() != previousTarget->GetOrigin()) {
mTwoPassTmpTarget = mCompositor->CreateRenderTarget(rect, INIT_MODE_NONE);
}
mCompositor->SetRenderTarget(mTwoPassTmpTarget);
return previousTarget;
}
void LayerManagerComposite::PopGroup(RefPtr<CompositingRenderTarget> aPreviousTarget, nsIntRect aClipRect)
{
mCompositor->SetRenderTarget(aPreviousTarget);
EffectChain effectChain(RootLayer());
Matrix5x4 matrix;
if (gfxPrefs::Grayscale()) {
matrix._11 = matrix._12 = matrix._13 = 0.2126f;
matrix._21 = matrix._22 = matrix._23 = 0.7152f;
matrix._31 = matrix._32 = matrix._33 = 0.0722f;
}
if (gfxPrefs::Invert()) {
matrix._11 = -matrix._11;
matrix._12 = -matrix._12;
matrix._13 = -matrix._13;
matrix._21 = -matrix._21;
matrix._22 = -matrix._22;
matrix._23 = -matrix._23;
matrix._31 = -matrix._31;
matrix._32 = -matrix._32;
matrix._33 = -matrix._33;
matrix._51 = 1;
matrix._52 = 1;
matrix._53 = 1;
}
effectChain.mPrimaryEffect = new EffectRenderTarget(mTwoPassTmpTarget);
effectChain.mSecondaryEffects[EffectTypes::COLOR_MATRIX] = new EffectColorMatrix(matrix);
gfx::Rect clipRectF(aClipRect.x, aClipRect.y, aClipRect.width, aClipRect.height);
mCompositor->DrawQuad(Rect(Point(0, 0), Size(mTwoPassTmpTarget->GetSize())), clipRectF, effectChain, 1.,
Matrix4x4());
}
void
LayerManagerComposite::Render()
{
@ -442,6 +494,10 @@ LayerManagerComposite::Render()
LayerScope::SendLayerDump(Move(packet));
}
if (gfxPrefs::Invert() || gfxPrefs::Grayscale()) {
composer2D = nullptr;
}
if (!mTarget && composer2D && composer2D->TryRender(mRoot, mWorldMatrix, mGeometryChanged)) {
if (mFPS) {
double fps = mFPS->mCompositionFps.AddFrameAndGetFps(TimeStamp::Now());
@ -501,6 +557,13 @@ LayerManagerComposite::Render()
actualBounds.width,
actualBounds.height));
RefPtr<CompositingRenderTarget> previousTarget;
if (gfxPrefs::Invert() || gfxPrefs::Grayscale()) {
previousTarget = PushGroup();
} else {
mTwoPassTmpTarget = nullptr;
}
// Render our layers.
RootLayer()->Prepare(clipRect);
RootLayer()->RenderLayer(clipRect);
@ -513,6 +576,10 @@ LayerManagerComposite::Render()
}
}
if (mTwoPassTmpTarget) {
PopGroup(previousTarget, clipRect);
}
// Allow widget to render a custom foreground.
mCompositor->GetWidget()->DrawWindowOverlay(this, nsIntRect(actualBounds.x,
actualBounds.y,

Просмотреть файл

@ -63,6 +63,7 @@ class SurfaceDescriptor;
class ThebesLayerComposite;
class TiledLayerComposer;
class TextRenderer;
class CompositingRenderTarget;
struct FPSState;
class LayerManagerComposite : public LayerManager
@ -268,6 +269,9 @@ private:
void WorldTransformRect(nsIntRect& aRect);
RefPtr<CompositingRenderTarget> PushGroup();
void PopGroup(RefPtr<CompositingRenderTarget> aPreviousTarget, nsIntRect aClipRect);
RefPtr<Compositor> mCompositor;
nsAutoPtr<LayerProperties> mClonedLayerTreeProperties;
@ -285,6 +289,7 @@ private:
bool mIsCompositorReady;
bool mDebugOverlayWantsNextFrame;
RefPtr<CompositingRenderTarget> mTwoPassTmpTarget;
RefPtr<TextRenderer> mTextRenderer;
bool mGeometryChanged;
};

Просмотреть файл

@ -51,7 +51,7 @@ CanvasLayerD3D10::Initialize(const Data& aData)
SurfaceStream::ChooseGLStreamType(SurfaceStream::MainThread,
screen->PreserveBuffer());
SurfaceFactory* factory = nullptr;
UniquePtr<SurfaceFactory> factory = nullptr;
if (!gfxPrefs::WebGLForceLayersReadback()) {
if (mGLContext->IsANGLE()) {
factory = SurfaceFactory_ANGLEShareHandle::Create(mGLContext,
@ -60,7 +60,7 @@ CanvasLayerD3D10::Initialize(const Data& aData)
}
if (factory) {
screen->Morph(factory, streamType);
screen->Morph(Move(factory), streamType);
}
} else if (aData.mDrawTarget) {
mDrawTarget = aData.mDrawTarget;

Просмотреть файл

@ -137,9 +137,7 @@ public:
}
gfx::IntSize GetSize() const MOZ_OVERRIDE
{
// XXX - Bug 900770
MOZ_ASSERT(false, "CompositingRenderTargetOGL should not be used as a TextureSource");
return gfx::IntSize(0, 0);
return mInitParams.mSize;
}
gfx::SurfaceFormat GetFormat() const MOZ_OVERRIDE

Просмотреть файл

@ -897,7 +897,8 @@ CompositorOGL::CreateFBOWithTexture(const IntRect& aRect, bool aCopyFromSource,
ShaderConfigOGL
CompositorOGL::GetShaderConfigFor(Effect *aEffect,
MaskType aMask,
gfx::CompositionOp aOp) const
gfx::CompositionOp aOp,
bool aColorMatrix) const
{
ShaderConfigOGL config;
@ -944,6 +945,7 @@ CompositorOGL::GetShaderConfigFor(Effect *aEffect,
break;
}
}
config.SetColorMatrix(aColorMatrix);
config.SetMask2D(aMask == MaskType::Mask2d);
config.SetMask3D(aMask == MaskType::Mask3d);
return config;
@ -1091,12 +1093,20 @@ CompositorOGL::DrawQuad(const Rect& aRect,
blendMode = blendEffect->mBlendMode;
}
ShaderConfigOGL config = GetShaderConfigFor(aEffectChain.mPrimaryEffect, maskType, blendMode);
bool colorMatrix = aEffectChain.mSecondaryEffects[EffectTypes::COLOR_MATRIX];
ShaderConfigOGL config = GetShaderConfigFor(aEffectChain.mPrimaryEffect, maskType, blendMode, colorMatrix);
config.SetOpacity(aOpacity != 1.f);
ShaderProgramOGL *program = GetShaderProgramFor(config);
program->Activate();
program->SetProjectionMatrix(mProjMatrix);
program->SetLayerTransform(aTransform);
if (colorMatrix) {
EffectColorMatrix* effectColorMatrix =
static_cast<EffectColorMatrix*>(aEffectChain.mSecondaryEffects[EffectTypes::COLOR_MATRIX].get());
program->SetColorMatrix(effectColorMatrix->mColorMatrix);
}
IntPoint offset = mCurrentRenderTarget->GetOrigin();
program->SetRenderOffset(offset.x, offset.y);
if (aOpacity != 1.f)

Просмотреть файл

@ -333,7 +333,8 @@ private:
ShaderConfigOGL GetShaderConfigFor(Effect *aEffect,
MaskType aMask = MaskType::MaskNone,
gfx::CompositionOp aOp = gfx::CompositionOp::OP_OVER) const;
gfx::CompositionOp aOp = gfx::CompositionOp::OP_OVER,
bool aColorMatrix = false) const;
ShaderProgramOGL* GetShaderProgramFor(const ShaderConfigOGL &aConfig);
/**

Просмотреть файл

@ -47,6 +47,8 @@ AddUniforms(ProgramProfileOGL& aProfile)
"uRenderColor",
"uTexCoordMultiplier",
"uTexturePass2",
"uColorMatrix",
"uColorMatrixVector",
nullptr
};

Просмотреть файл

@ -68,6 +68,8 @@ public:
RenderColor,
TexCoordMultiplier,
TexturePass2,
ColorMatrix,
ColorMatrixVector,
KnownUniformCount
};
@ -369,6 +371,12 @@ public:
SetUniform(KnownUniform::RenderColor, aColor);
}
void SetColorMatrix(const gfx::Matrix5x4& aColorMatrix)
{
SetMatrixUniform(KnownUniform::ColorMatrix, &aColorMatrix._11);
SetUniform(KnownUniform::ColorMatrixVector, 4, &aColorMatrix._51);
}
void SetTexCoordMultiplier(float aWidth, float aHeight) {
float f[] = {aWidth, aHeight};
SetUniform(KnownUniform::TexCoordMultiplier, 2, f);
@ -432,7 +440,7 @@ protected:
}
}
void SetUniform(KnownUniform::KnownUniformName aKnownUniform, int aLength, float *aFloatValues)
void SetUniform(KnownUniform::KnownUniformName aKnownUniform, int aLength, const float *aFloatValues)
{
ASSERT_THIS_PROGRAM;
NS_ASSERTION(aKnownUniform >= 0 && aKnownUniform < KnownUniform::KnownUniformCount, "Invalid known uniform");

Просмотреть файл

@ -250,6 +250,8 @@ private:
DECL_GFX_PREF(Once, "layers.progressive-paint", UseProgressiveTilePainting, bool, false);
DECL_GFX_PREF(Once, "layers.scroll-graph", LayersScrollGraph, bool, false);
DECL_GFX_PREF(Once, "layers.uniformity-info", UniformityInfo, bool, false);
DECL_GFX_PREF(Live, "layers.invert", Invert, bool, false);
DECL_GFX_PREF(Live, "layers.grayscale", Grayscale, bool, false);
DECL_GFX_PREF(Live, "layout.css.scroll-behavior.damping-ratio", ScrollBehaviorDampingRatio, float, 1.0f);
DECL_GFX_PREF(Live, "layout.css.scroll-behavior.enabled", ScrollBehaviorEnabled, bool, false);

Просмотреть файл

@ -20,17 +20,6 @@ using namespace mozilla::jsipc;
using mozilla::AutoSafeJSContext;
#ifdef NIGHTLY_BUILD
static void
UrgentMessageCheck(JSContext *cx, HandleScript script)
{
// We're only allowed to enter chrome JS code while processing urgent
// messages.
if (ipc::ProcessingUrgentMessages())
MOZ_RELEASE_ASSERT(xpc::AccessCheck::isChrome(js::GetContextCompartment(cx)));
}
#endif
static void
FinalizeChild(JSFreeOp *fop, JSFinalizeStatus status, bool isCompartment, void *data)
{
@ -43,9 +32,6 @@ JavaScriptChild::JavaScriptChild(JSRuntime *rt)
: JavaScriptShared(rt),
JavaScriptBase<PJavaScriptChild>(rt)
{
#ifdef NIGHTLY_BUILD
js::SetAssertOnScriptEntryHook(rt, UrgentMessageCheck);
#endif
}
JavaScriptChild::~JavaScriptChild()

Просмотреть файл

@ -1803,12 +1803,12 @@ GetCPUID(uint32_t *cpuId)
};
#if defined(JS_CODEGEN_X86)
JS_ASSERT(uint32_t(JSC::MacroAssembler::getSSEState()) <= (UINT32_MAX >> ARCH_BITS));
*cpuId = X86 | (JSC::MacroAssembler::getSSEState() << ARCH_BITS);
JS_ASSERT(uint32_t(JSC::MacroAssemblerX86Common::getSSEState()) <= (UINT32_MAX >> ARCH_BITS));
*cpuId = X86 | (JSC::MacroAssemblerX86Common::getSSEState() << ARCH_BITS);
return true;
#elif defined(JS_CODEGEN_X64)
JS_ASSERT(uint32_t(JSC::MacroAssembler::getSSEState()) <= (UINT32_MAX >> ARCH_BITS));
*cpuId = X64 | (JSC::MacroAssembler::getSSEState() << ARCH_BITS);
JS_ASSERT(uint32_t(JSC::MacroAssemblerX86Common::getSSEState()) <= (UINT32_MAX >> ARCH_BITS));
*cpuId = X64 | (JSC::MacroAssemblerX86Common::getSSEState() << ARCH_BITS);
return true;
#elif defined(JS_CODEGEN_ARM)
JS_ASSERT(GetARMFlags() <= (UINT32_MAX >> ARCH_BITS));

Просмотреть файл

@ -21,7 +21,6 @@
#include "mozilla/DebugOnly.h"
#include "asmjs/AsmJSModule.h"
#include "assembler/assembler/MacroAssembler.h"
#include "vm/Runtime.h"
using namespace js;

Просмотреть файл

@ -30,10 +30,6 @@
#ifndef assembler_assembler_AssemblerBuffer_h
#define assembler_assembler_AssemblerBuffer_h
#include "assembler/wtf/Platform.h"
#if ENABLE_ASSEMBLER
#include <string.h>
#include <limits.h>
#include <stdarg.h>
@ -329,6 +325,4 @@ namespace JSC {
} // namespace JSC
#endif // ENABLE(ASSEMBLER)
#endif /* assembler_assembler_AssemblerBuffer_h */

Просмотреть файл

@ -1,67 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* vim: set ts=8 sts=4 et sw=4 tw=99:
*
* ***** BEGIN LICENSE BLOCK *****
* Copyright (C) 2008 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */
#ifndef assembler_assembler_MacroAssembler_h
#define assembler_assembler_MacroAssembler_h
#include "assembler/wtf/Platform.h"
#if ENABLE_ASSEMBLER
#if JS_CODEGEN_NONE
#include "jit/none/BaseMacroAssembler-none.h"
namespace JSC { typedef MacroAssemblerNone MacroAssembler; }
#elif JS_CODEGEN_ARM
// Merged with the jit backend support.
#elif JS_CODEGEN_MIPS
#include "assembler/assembler/MacroAssemblerMIPS.h"
namespace JSC { typedef MacroAssemblerMIPS MacroAssembler; }
#elif JS_CODEGEN_X86
#include "assembler/assembler/MacroAssemblerX86.h"
namespace JSC { typedef MacroAssemblerX86 MacroAssembler; }
#elif JS_CODEGEN_X64
#include "assembler/assembler/MacroAssemblerX86_64.h"
namespace JSC { typedef MacroAssemblerX86_64 MacroAssembler; }
#elif WTF_CPU_SPARC
#include "assembler/assembler/MacroAssemblerSparc.h"
namespace JSC { typedef MacroAssemblerSparc MacroAssembler; }
#else
#error "The MacroAssembler is not supported on this platform."
#endif
#endif // ENABLE(ASSEMBLER)
#endif /* assembler_assembler_MacroAssembler_h */

Просмотреть файл

@ -1,52 +0,0 @@
/*
* Copyright (C) 2008 Apple Inc. All rights reserved.
* Copyright (C) 2010 MIPS Technologies, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY MIPS TECHNOLOGIES, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MIPS TECHNOLOGIES, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef assembler_assembler_MacroAssemblerMIPS_h
#define assembler_assembler_MacroAssemblerMIPS_h
#if ENABLE(ASSEMBLER) && CPU(MIPS)
#include "assembler/wtf/Platform.h"
namespace JSC {
class MacroAssemblerMIPS {
public:
static bool supportsFloatingPoint()
{
#if (defined(__mips_hard_float) && !defined(__mips_single_float)) || defined(JS_MIPS_SIMULATOR)
return true;
#else
return false;
#endif
}
};
}
#endif // ENABLE(ASSEMBLER) && CPU(MIPS)
#endif /* assembler_assembler_MacroAssemblerMIPS_h */

Просмотреть файл

@ -1,25 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* vim: set ts=8 sts=4 et sw=4 tw=99: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef assembler_assembler_MacroAssemblerSparc_h
#define assembler_assembler_MacroAssemblerSparc_h
#include "assembler/wtf/Platform.h"
#if ENABLE_ASSEMBLER && WTF_CPU_SPARC
namespace JSC {
class MacroAssemblerSparc {
public:
static bool supportsFloatingPoint() { return true; }
};
}
#endif // ENABLE(ASSEMBLER) && CPU(SPARC)
#endif /* assembler_assembler_MacroAssemblerSparc_h */

Просмотреть файл

@ -1,44 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* vim: set ts=8 sts=4 et sw=4 tw=99:
*
* ***** BEGIN LICENSE BLOCK *****
* Copyright (C) 2008 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */
#ifndef assembler_assembler_MacroAssemblerX86_h
#define assembler_assembler_MacroAssemblerX86_h
#include "assembler/assembler/MacroAssemblerX86Common.h"
namespace JSC {
class MacroAssemblerX86 : public MacroAssemblerX86Common {
public:
static bool supportsFloatingPoint() { return isSSE2Present(); }
};
} // namespace JSC
#endif /* assembler_assembler_MacroAssemblerX86_h */

Просмотреть файл

@ -6,8 +6,6 @@
#include "assembler/assembler/MacroAssemblerX86Common.h"
#include "assembler/wtf/Platform.h"
#ifdef _MSC_VER
#ifdef JS_CODEGEN_X64
/* for __cpuid */

Просмотреть файл

@ -30,10 +30,6 @@
#ifndef assembler_assembler_MacroAssemblerX86Common_h
#define assembler_assembler_MacroAssemblerX86Common_h
#include "assembler/wtf/Platform.h"
#if ENABLE_ASSEMBLER
#include "assembler/assembler/X86Assembler.h"
namespace JSC {
@ -192,6 +188,4 @@ private:
} // namespace JSC
#endif // ENABLE(ASSEMBLER)
#endif /* assembler_assembler_MacroAssemblerX86Common_h */

Просмотреть файл

@ -1,44 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* vim: set ts=8 sts=4 et sw=4 tw=99:
*
* ***** BEGIN LICENSE BLOCK *****
* Copyright (C) 2008 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */
#ifndef assembler_assembler_MacroAssemblerX86_64_h
#define assembler_assembler_MacroAssemblerX86_64_h
#include "assembler/assembler/MacroAssemblerX86Common.h"
namespace JSC {
class MacroAssemblerX86_64 : public MacroAssemblerX86Common {
public:
static bool supportsFloatingPoint() { return true; }
};
} // namespace JSC
#endif /* assembler_assembler_MacroAssemblerX86_64_h */

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше