merge fx-team to m-c

This commit is contained in:
Rob Campbell 2012-04-17 14:29:29 -03:00
commit 2de66c3fc1
881 changed files with 15256 additions and 12803 deletions

View File

@ -39,11 +39,14 @@
#include "nsARIAMap.h" #include "nsARIAMap.h"
#include "nsCoreUtils.h"
#include "Role.h" #include "Role.h"
#include "States.h" #include "States.h"
#include "nsIContent.h" #include "nsIContent.h"
#include "nsWhitespaceTokenizer.h"
using namespace mozilla;
using namespace mozilla::a11y; using namespace mozilla::a11y;
using namespace mozilla::a11y::aria; using namespace mozilla::a11y::aria;
@ -62,7 +65,7 @@ using namespace mozilla::a11y::aria;
* banner, contentinfo, main, navigation, note, search, secondary, seealso, breadcrumbs * banner, contentinfo, main, navigation, note, search, secondary, seealso, breadcrumbs
*/ */
nsRoleMapEntry nsARIAMap::gWAIRoleMap[] = static nsRoleMapEntry sWAIRoleMaps[] =
{ {
{ {
"alert", "alert",
@ -586,9 +589,7 @@ nsRoleMapEntry nsARIAMap::gWAIRoleMap[] =
} }
}; };
PRUint32 nsARIAMap::gWAIRoleMapLength = NS_ARRAY_LENGTH(nsARIAMap::gWAIRoleMap); static nsRoleMapEntry sLandmarkRoleMap = {
nsRoleMapEntry nsARIAMap::gLandmarkRoleMap = {
"", "",
roles::NOTHING, roles::NOTHING,
kUseNativeRole, kUseNativeRole,
@ -667,3 +668,39 @@ nsAttributeCharacteristics nsARIAMap::gWAIUnivAttrMap[] = {
}; };
PRUint32 nsARIAMap::gWAIUnivAttrMapLength = NS_ARRAY_LENGTH(nsARIAMap::gWAIUnivAttrMap); PRUint32 nsARIAMap::gWAIUnivAttrMapLength = NS_ARRAY_LENGTH(nsARIAMap::gWAIUnivAttrMap);
nsRoleMapEntry*
aria::GetRoleMap(nsINode* aNode)
{
nsIContent* content = nsCoreUtils::GetRoleContent(aNode);
nsAutoString roleString;
if (!content ||
!content->GetAttr(kNameSpaceID_None, nsGkAtoms::role, roleString) ||
roleString.IsEmpty()) {
// We treat role="" as if the role attribute is absent (per aria spec:8.1.1)
return nsnull;
}
nsWhitespaceTokenizer tokenizer(roleString);
while (tokenizer.hasMoreTokens()) {
// Do a binary search through table for the next role in role list
NS_LossyConvertUTF16toASCII role(tokenizer.nextToken());
PRUint32 low = 0;
PRUint32 high = ArrayLength(sWAIRoleMaps);
while (low < high) {
PRUint32 idx = (low + high) / 2;
PRInt32 compare = strcmp(role.get(), sWAIRoleMaps[idx].roleString);
if (compare == 0)
return sWAIRoleMaps + idx;
if (compare < 0)
high = idx;
else
low = idx + 1;
}
}
// Always use some entry if there is a non-empty role string
// To ensure an accessible object is created
return &sLandmarkRoleMap;
}

View File

@ -45,6 +45,7 @@
class nsIAtom; class nsIAtom;
class nsIContent; class nsIContent;
class nsINode;
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Value constants // Value constants
@ -210,18 +211,6 @@ struct nsRoleMapEntry
*/ */
struct nsARIAMap struct nsARIAMap
{ {
/**
* Array of supported ARIA role map entries and its length.
*/
static nsRoleMapEntry gWAIRoleMap[];
static PRUint32 gWAIRoleMapLength;
/**
* Landmark role map entry. Used when specified ARIA role isn't mapped to
* accessibility API.
*/
static nsRoleMapEntry gLandmarkRoleMap;
/** /**
* Empty role map entry. Used by accessibility service to create an accessible * Empty role map entry. Used by accessibility service to create an accessible
* if the accessible can't use role of used accessible class. For example, * if the accessible can't use role of used accessible class. For example,
@ -257,4 +246,22 @@ struct nsARIAMap
} }
}; };
namespace mozilla {
namespace a11y {
namespace aria {
/**
* Get the role map entry for a given DOM node. This will use the first
* ARIA role if the role attribute provides a space delimited list of roles.
*
* @param aNode [in] the DOM node to get the role map entry for
* @return a pointer to the role map entry for the ARIA role, or nsnull
* if none
*/
nsRoleMapEntry* GetRoleMap(nsINode* aNode);
} // namespace aria
} // namespace a11y
} // namespace mozilla
#endif #endif

View File

@ -41,6 +41,7 @@
#include "nsAccessibilityService.h" #include "nsAccessibilityService.h"
#include "nsAccUtils.h" #include "nsAccUtils.h"
#include "nsApplicationAccessible.h" #include "nsApplicationAccessible.h"
#include "nsARIAMap.h"
#include "nsRootAccessibleWrap.h" #include "nsRootAccessibleWrap.h"
#include "States.h" #include "States.h"
@ -402,7 +403,7 @@ nsAccDocManager::CreateDocOrRootAccessible(nsIDocument *aDocument)
docAcc->Shutdown(); docAcc->Shutdown();
return nsnull; return nsnull;
} }
docAcc->SetRoleMapEntry(nsAccUtils::GetRoleMapEntry(aDocument)); docAcc->SetRoleMapEntry(aria::GetRoleMap(aDocument));
// Bind the document to the tree. // Bind the document to the tree.
if (isRootDoc) { if (isRootDoc) {

View File

@ -44,6 +44,7 @@
#include "nsIWebProgress.h" #include "nsIWebProgress.h"
#include "nsIWebProgressListener.h" #include "nsIWebProgressListener.h"
#include "nsWeakReference.h" #include "nsWeakReference.h"
#include "nsIPresShell.h"
class nsAccessible; class nsAccessible;
class nsDocAccessible; class nsDocAccessible;
@ -69,6 +70,14 @@ public:
*/ */
nsDocAccessible *GetDocAccessible(nsIDocument *aDocument); nsDocAccessible *GetDocAccessible(nsIDocument *aDocument);
/**
* Return document accessible for the given presshell.
*/
nsDocAccessible* GetDocAccessible(const nsIPresShell* aPresShell)
{
return aPresShell ? GetDocAccessible(aPresShell->GetDocument()) : nsnull;
}
/** /**
* Search through all document accessibles for an accessible with the given * Search through all document accessibles for an accessible with the given
* unique id. * unique id.

View File

@ -174,7 +174,7 @@ nsAccUtils::SetLiveContainerAttributes(nsIPersistentProperties *aAttributes,
// container-live, and container-live-role attributes // container-live, and container-live-role attributes
if (live.IsEmpty()) { if (live.IsEmpty()) {
nsRoleMapEntry *role = GetRoleMapEntry(ancestor); nsRoleMapEntry* role = aria::GetRoleMap(ancestor);
if (nsAccUtils::HasDefinedARIAToken(ancestor, if (nsAccUtils::HasDefinedARIAToken(ancestor,
nsGkAtoms::aria_live)) { nsGkAtoms::aria_live)) {
ancestor->GetAttr(kNameSpaceID_None, nsGkAtoms::aria_live, ancestor->GetAttr(kNameSpaceID_None, nsGkAtoms::aria_live,
@ -418,45 +418,6 @@ nsAccUtils::GetScreenCoordsForParent(nsAccessNode *aAccessNode)
return nsIntPoint(parentRect.x, parentRect.y); return nsIntPoint(parentRect.x, parentRect.y);
} }
nsRoleMapEntry*
nsAccUtils::GetRoleMapEntry(nsINode *aNode)
{
nsIContent *content = nsCoreUtils::GetRoleContent(aNode);
nsAutoString roleString;
if (!content ||
!content->GetAttr(kNameSpaceID_None, nsGkAtoms::role, roleString) ||
roleString.IsEmpty()) {
// We treat role="" as if the role attribute is absent (per aria spec:8.1.1)
return nsnull;
}
nsWhitespaceTokenizer tokenizer(roleString);
while (tokenizer.hasMoreTokens()) {
// Do a binary search through table for the next role in role list
NS_LossyConvertUTF16toASCII role(tokenizer.nextToken());
PRUint32 low = 0;
PRUint32 high = nsARIAMap::gWAIRoleMapLength;
while (low < high) {
PRUint32 index = (low + high) / 2;
PRInt32 compare = PL_strcmp(role.get(), nsARIAMap::gWAIRoleMap[index].roleString);
if (compare == 0) {
// The role attribute maps to an entry in the role table
return &nsARIAMap::gWAIRoleMap[index];
}
if (compare < 0) {
high = index;
}
else {
low = index + 1;
}
}
}
// Always use some entry if there is a non-empty role string
// To ensure an accessible object is created
return &nsARIAMap::gLandmarkRoleMap;
}
PRUint8 PRUint8
nsAccUtils::GetAttributeCharacteristics(nsIAtom* aAtom) nsAccUtils::GetAttributeCharacteristics(nsIAtom* aAtom)
{ {

View File

@ -137,23 +137,13 @@ public:
*/ */
static nsIAtom* GetARIAToken(mozilla::dom::Element* aElement, nsIAtom* aAttr); static nsIAtom* GetARIAToken(mozilla::dom::Element* aElement, nsIAtom* aAttr);
/**
* Return document accessible for the given presshell.
*/
static nsDocAccessible* GetDocAccessibleFor(const nsIPresShell* aPresShell)
{
return aPresShell ?
GetAccService()->GetDocAccessible(aPresShell->GetDocument()) : nsnull;
}
/** /**
* Return document accessible for the given DOM node. * Return document accessible for the given DOM node.
*/ */
static nsDocAccessible *GetDocAccessibleFor(nsINode *aNode) static nsDocAccessible *GetDocAccessibleFor(nsINode *aNode)
{ {
nsIPresShell *presShell = nsCoreUtils::GetPresShellFor(aNode); nsIPresShell *presShell = nsCoreUtils::GetPresShellFor(aNode);
return presShell ? return GetAccService()->GetDocAccessible(presShell);
GetAccService()->GetDocAccessible(presShell->GetDocument()) : nsnull;
} }
/** /**
@ -164,8 +154,7 @@ public:
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(aContainer)); nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(aContainer));
nsCOMPtr<nsIPresShell> presShell; nsCOMPtr<nsIPresShell> presShell;
docShell->GetPresShell(getter_AddRefs(presShell)); docShell->GetPresShell(getter_AddRefs(presShell));
return presShell ? return GetAccService()->GetDocAccessible(presShell);
GetAccService()->GetDocAccessible(presShell->GetDocument()) : nsnull;
} }
/** /**
@ -249,16 +238,6 @@ public:
*/ */
static nsIntPoint GetScreenCoordsForParent(nsAccessNode *aAccessNode); static nsIntPoint GetScreenCoordsForParent(nsAccessNode *aAccessNode);
/**
* Get the role map entry for a given DOM node. This will use the first
* ARIA role if the role attribute provides a space delimited list of roles.
*
* @param aNode [in] the DOM node to get the role map entry for
* @return a pointer to the role map entry for the ARIA role, or nsnull
* if none
*/
static nsRoleMapEntry *GetRoleMapEntry(nsINode *aNode);
/** /**
* Return the role of the given accessible. * Return the role of the given accessible.
*/ */

View File

@ -202,8 +202,7 @@ nsAccessibilityService::CreateOuterDocAccessible(nsIContent* aContent,
nsIPresShell* aPresShell) nsIPresShell* aPresShell)
{ {
nsAccessible* accessible = nsAccessible* accessible =
new OuterDocAccessible(aContent, new OuterDocAccessible(aContent, GetDocAccessible(aPresShell));
nsAccUtils::GetDocAccessibleFor(aPresShell));
NS_ADDREF(accessible); NS_ADDREF(accessible);
return accessible; return accessible;
} }
@ -213,8 +212,7 @@ nsAccessibilityService::CreateHTMLButtonAccessible(nsIContent* aContent,
nsIPresShell* aPresShell) nsIPresShell* aPresShell)
{ {
nsAccessible* accessible = nsAccessible* accessible =
new HTMLButtonAccessible(aContent, new HTMLButtonAccessible(aContent, GetDocAccessible(aPresShell));
nsAccUtils::GetDocAccessibleFor(aPresShell));
NS_ADDREF(accessible); NS_ADDREF(accessible);
return accessible; return accessible;
} }
@ -224,8 +222,7 @@ nsAccessibilityService::CreateHTMLLIAccessible(nsIContent* aContent,
nsIPresShell* aPresShell) nsIPresShell* aPresShell)
{ {
nsAccessible* accessible = nsAccessible* accessible =
new nsHTMLLIAccessible(aContent, new nsHTMLLIAccessible(aContent, GetDocAccessible(aPresShell));
nsAccUtils::GetDocAccessibleFor(aPresShell));
NS_ADDREF(accessible); NS_ADDREF(accessible);
return accessible; return accessible;
} }
@ -235,8 +232,7 @@ nsAccessibilityService::CreateHyperTextAccessible(nsIContent* aContent,
nsIPresShell* aPresShell) nsIPresShell* aPresShell)
{ {
nsAccessible* accessible = nsAccessible* accessible =
new nsHyperTextAccessibleWrap(aContent, new nsHyperTextAccessibleWrap(aContent, GetDocAccessible(aPresShell));
nsAccUtils::GetDocAccessibleFor(aPresShell));
NS_ADDREF(accessible); NS_ADDREF(accessible);
return accessible; return accessible;
} }
@ -246,8 +242,7 @@ nsAccessibilityService::CreateHTMLCheckboxAccessible(nsIContent* aContent,
nsIPresShell* aPresShell) nsIPresShell* aPresShell)
{ {
nsAccessible* accessible = nsAccessible* accessible =
new HTMLCheckboxAccessible(aContent, new HTMLCheckboxAccessible(aContent, GetDocAccessible(aPresShell));
nsAccUtils::GetDocAccessibleFor(aPresShell));
NS_ADDREF(accessible); NS_ADDREF(accessible);
return accessible; return accessible;
} }
@ -257,8 +252,7 @@ nsAccessibilityService::CreateHTMLComboboxAccessible(nsIContent* aContent,
nsIPresShell* aPresShell) nsIPresShell* aPresShell)
{ {
nsAccessible* accessible = nsAccessible* accessible =
new nsHTMLComboboxAccessible(aContent, new nsHTMLComboboxAccessible(aContent, GetDocAccessible(aPresShell));
nsAccUtils::GetDocAccessibleFor(aPresShell));
NS_ADDREF(accessible); NS_ADDREF(accessible);
return accessible; return accessible;
} }
@ -268,8 +262,7 @@ nsAccessibilityService::CreateHTMLCanvasAccessible(nsIContent* aContent,
nsIPresShell* aPresShell) nsIPresShell* aPresShell)
{ {
nsAccessible* accessible = nsAccessible* accessible =
new nsHTMLCanvasAccessible(aContent, new nsHTMLCanvasAccessible(aContent, GetDocAccessible(aPresShell));
nsAccUtils::GetDocAccessibleFor(aPresShell));
NS_ADDREF(accessible); NS_ADDREF(accessible);
return accessible; return accessible;
} }
@ -279,8 +272,7 @@ nsAccessibilityService::CreateHTMLFileInputAccessible(nsIContent* aContent,
nsIPresShell* aPresShell) nsIPresShell* aPresShell)
{ {
nsAccessible* accessible = nsAccessible* accessible =
new HTMLFileInputAccessible(aContent, new HTMLFileInputAccessible(aContent, GetDocAccessible(aPresShell));
nsAccUtils::GetDocAccessibleFor(aPresShell));
NS_ADDREF(accessible); NS_ADDREF(accessible);
return accessible; return accessible;
} }
@ -290,8 +282,7 @@ nsAccessibilityService::CreateHTMLImageAccessible(nsIContent* aContent,
nsIPresShell* aPresShell) nsIPresShell* aPresShell)
{ {
nsAccessible* accessible = nsAccessible* accessible =
new nsHTMLImageAccessibleWrap(aContent, new nsHTMLImageAccessibleWrap(aContent, GetDocAccessible(aPresShell));
nsAccUtils::GetDocAccessibleFor(aPresShell));
NS_ADDREF(accessible); NS_ADDREF(accessible);
return accessible; return accessible;
} }
@ -301,8 +292,7 @@ nsAccessibilityService::CreateHTMLImageMapAccessible(nsIContent* aContent,
nsIPresShell* aPresShell) nsIPresShell* aPresShell)
{ {
nsAccessible* accessible = nsAccessible* accessible =
new nsHTMLImageMapAccessible(aContent, new nsHTMLImageMapAccessible(aContent, GetDocAccessible(aPresShell));
nsAccUtils::GetDocAccessibleFor(aPresShell));
NS_ADDREF(accessible); NS_ADDREF(accessible);
return accessible; return accessible;
} }
@ -312,8 +302,7 @@ nsAccessibilityService::CreateHTMLGroupboxAccessible(nsIContent* aContent,
nsIPresShell* aPresShell) nsIPresShell* aPresShell)
{ {
nsAccessible* accessible = nsAccessible* accessible =
new HTMLGroupboxAccessible(aContent, new HTMLGroupboxAccessible(aContent, GetDocAccessible(aPresShell));
nsAccUtils::GetDocAccessibleFor(aPresShell));
NS_ADDREF(accessible); NS_ADDREF(accessible);
return accessible; return accessible;
} }
@ -323,8 +312,7 @@ nsAccessibilityService::CreateHTMLListboxAccessible(nsIContent* aContent,
nsIPresShell* aPresShell) nsIPresShell* aPresShell)
{ {
nsAccessible* accessible = nsAccessible* accessible =
new nsHTMLSelectListAccessible(aContent, new nsHTMLSelectListAccessible(aContent, GetDocAccessible(aPresShell));
nsAccUtils::GetDocAccessibleFor(aPresShell));
NS_ADDREF(accessible); NS_ADDREF(accessible);
return accessible; return accessible;
} }
@ -334,8 +322,7 @@ nsAccessibilityService::CreateHTMLMediaAccessible(nsIContent* aContent,
nsIPresShell* aPresShell) nsIPresShell* aPresShell)
{ {
nsAccessible* accessible = nsAccessible* accessible =
new nsEnumRoleAccessible(aContent, new nsEnumRoleAccessible(aContent, GetDocAccessible(aPresShell),
nsAccUtils::GetDocAccessibleFor(aPresShell),
roles::GROUPING); roles::GROUPING);
NS_ADDREF(accessible); NS_ADDREF(accessible);
return accessible; return accessible;
@ -379,7 +366,7 @@ nsAccessibilityService::CreateHTMLObjectFrameAccessible(nsObjectFrame* aFrame,
nsAccessible* accessible = nsAccessible* accessible =
new nsHTMLWin32ObjectOwnerAccessible(aContent, new nsHTMLWin32ObjectOwnerAccessible(aContent,
nsAccUtils::GetDocAccessibleFor(aPresShell), GetDocAccessible(aPresShell),
pluginPort); pluginPort);
NS_ADDREF(accessible); NS_ADDREF(accessible);
return accessible; return accessible;
@ -393,8 +380,7 @@ nsAccessibilityService::CreateHTMLObjectFrameAccessible(nsObjectFrame* aFrame,
NPPVpluginNativeAccessibleAtkPlugId, &plugId); NPPVpluginNativeAccessibleAtkPlugId, &plugId);
if (NS_SUCCEEDED(rv) && !plugId.IsEmpty()) { if (NS_SUCCEEDED(rv) && !plugId.IsEmpty()) {
AtkSocketAccessible* socketAccessible = AtkSocketAccessible* socketAccessible =
new AtkSocketAccessible(aContent, new AtkSocketAccessible(aContent, GetDocAccessible(aPresShell),
nsAccUtils::GetDocAccessibleFor(aPresShell),
plugId); plugId);
NS_ADDREF(socketAccessible); NS_ADDREF(socketAccessible);
@ -415,8 +401,7 @@ nsAccessibilityService::CreateHTMLRadioButtonAccessible(nsIContent* aContent,
nsIPresShell* aPresShell) nsIPresShell* aPresShell)
{ {
nsAccessible* accessible = nsAccessible* accessible =
new HTMLRadioButtonAccessible(aContent, new HTMLRadioButtonAccessible(aContent, GetDocAccessible(aPresShell));
nsAccUtils::GetDocAccessibleFor(aPresShell));
NS_ADDREF(accessible); NS_ADDREF(accessible);
return accessible; return accessible;
} }
@ -426,8 +411,7 @@ nsAccessibilityService::CreateHTMLTableAccessible(nsIContent* aContent,
nsIPresShell* aPresShell) nsIPresShell* aPresShell)
{ {
nsAccessible* accessible = nsAccessible* accessible =
new nsHTMLTableAccessibleWrap(aContent, new nsHTMLTableAccessibleWrap(aContent, GetDocAccessible(aPresShell));
nsAccUtils::GetDocAccessibleFor(aPresShell));
NS_ADDREF(accessible); NS_ADDREF(accessible);
return accessible; return accessible;
} }
@ -437,8 +421,7 @@ nsAccessibilityService::CreateHTMLTableCellAccessible(nsIContent* aContent,
nsIPresShell* aPresShell) nsIPresShell* aPresShell)
{ {
nsAccessible* accessible = nsAccessible* accessible =
new nsHTMLTableCellAccessibleWrap(aContent, new nsHTMLTableCellAccessibleWrap(aContent, GetDocAccessible(aPresShell));
nsAccUtils::GetDocAccessibleFor(aPresShell));
NS_ADDREF(accessible); NS_ADDREF(accessible);
return accessible; return accessible;
} }
@ -448,8 +431,7 @@ nsAccessibilityService::CreateHTMLTextAccessible(nsIContent* aContent,
nsIPresShell* aPresShell) nsIPresShell* aPresShell)
{ {
nsAccessible* accessible = nsAccessible* accessible =
new nsHTMLTextAccessible(aContent, new nsHTMLTextAccessible(aContent, GetDocAccessible(aPresShell));
nsAccUtils::GetDocAccessibleFor(aPresShell));
NS_ADDREF(accessible); NS_ADDREF(accessible);
return accessible; return accessible;
} }
@ -459,8 +441,7 @@ nsAccessibilityService::CreateHTMLTextFieldAccessible(nsIContent* aContent,
nsIPresShell* aPresShell) nsIPresShell* aPresShell)
{ {
nsAccessible* accessible = nsAccessible* accessible =
new HTMLTextFieldAccessible(aContent, new HTMLTextFieldAccessible(aContent, GetDocAccessible(aPresShell));
nsAccUtils::GetDocAccessibleFor(aPresShell));
NS_ADDREF(accessible); NS_ADDREF(accessible);
return accessible; return accessible;
} }
@ -470,8 +451,7 @@ nsAccessibilityService::CreateHTMLLabelAccessible(nsIContent* aContent,
nsIPresShell* aPresShell) nsIPresShell* aPresShell)
{ {
nsAccessible* accessible = nsAccessible* accessible =
new nsHTMLLabelAccessible(aContent, new nsHTMLLabelAccessible(aContent, GetDocAccessible(aPresShell));
nsAccUtils::GetDocAccessibleFor(aPresShell));
NS_ADDREF(accessible); NS_ADDREF(accessible);
return accessible; return accessible;
} }
@ -481,8 +461,7 @@ nsAccessibilityService::CreateHTMLHRAccessible(nsIContent* aContent,
nsIPresShell* aPresShell) nsIPresShell* aPresShell)
{ {
nsAccessible* accessible = nsAccessible* accessible =
new nsHTMLHRAccessible(aContent, new nsHTMLHRAccessible(aContent, GetDocAccessible(aPresShell));
nsAccUtils::GetDocAccessibleFor(aPresShell));
NS_ADDREF(accessible); NS_ADDREF(accessible);
return accessible; return accessible;
} }
@ -492,8 +471,7 @@ nsAccessibilityService::CreateHTMLBRAccessible(nsIContent* aContent,
nsIPresShell* aPresShell) nsIPresShell* aPresShell)
{ {
nsAccessible* accessible = nsAccessible* accessible =
new nsHTMLBRAccessible(aContent, new nsHTMLBRAccessible(aContent, GetDocAccessible(aPresShell));
nsAccUtils::GetDocAccessibleFor(aPresShell));
NS_ADDREF(accessible); NS_ADDREF(accessible);
return accessible; return accessible;
} }
@ -503,8 +481,7 @@ nsAccessibilityService::CreateHTMLCaptionAccessible(nsIContent* aContent,
nsIPresShell* aPresShell) nsIPresShell* aPresShell)
{ {
nsAccessible* accessible = nsAccessible* accessible =
new nsHTMLCaptionAccessible(aContent, new nsHTMLCaptionAccessible(aContent, GetDocAccessible(aPresShell));
nsAccUtils::GetDocAccessibleFor(aPresShell));
NS_ADDREF(accessible); NS_ADDREF(accessible);
return accessible; return accessible;
} }
@ -539,7 +516,7 @@ nsAccessibilityService::ContentRangeInserted(nsIPresShell* aPresShell,
NS_ConvertUTF16toUTF8(ctag).get(), cid.get(), aEndChild); NS_ConvertUTF16toUTF8(ctag).get(), cid.get(), aEndChild);
#endif #endif
nsDocAccessible* docAccessible = GetDocAccessible(aPresShell->GetDocument()); nsDocAccessible* docAccessible = GetDocAccessible(aPresShell);
if (docAccessible) if (docAccessible)
docAccessible->ContentInserted(aContainer, aStartChild, aEndChild); docAccessible->ContentInserted(aContainer, aStartChild, aEndChild);
} }
@ -573,7 +550,7 @@ nsAccessibilityService::ContentRemoved(nsIPresShell* aPresShell,
NS_ConvertUTF16toUTF8(ctag).get(), cid.get()); NS_ConvertUTF16toUTF8(ctag).get(), cid.get());
#endif #endif
nsDocAccessible* docAccessible = GetDocAccessible(aPresShell->GetDocument()); nsDocAccessible* docAccessible = GetDocAccessible(aPresShell);
if (docAccessible) if (docAccessible)
docAccessible->ContentRemoved(aContainer, aChild); docAccessible->ContentRemoved(aContainer, aChild);
} }
@ -582,7 +559,7 @@ void
nsAccessibilityService::UpdateText(nsIPresShell* aPresShell, nsAccessibilityService::UpdateText(nsIPresShell* aPresShell,
nsIContent* aContent) nsIContent* aContent)
{ {
nsDocAccessible* document = GetDocAccessible(aPresShell->GetDocument()); nsDocAccessible* document = GetDocAccessible(aPresShell);
if (document) if (document)
document->UpdateText(aContent); document->UpdateText(aContent);
} }
@ -592,7 +569,7 @@ nsAccessibilityService::TreeViewChanged(nsIPresShell* aPresShell,
nsIContent* aContent, nsIContent* aContent,
nsITreeView* aView) nsITreeView* aView)
{ {
nsDocAccessible* document = GetDocAccessible(aPresShell->GetDocument()); nsDocAccessible* document = GetDocAccessible(aPresShell);
if (document) { if (document) {
nsAccessible* accessible = document->GetAccessible(aContent); nsAccessible* accessible = document->GetAccessible(aContent);
if (accessible) { if (accessible) {
@ -608,7 +585,7 @@ nsAccessibilityService::UpdateListBullet(nsIPresShell* aPresShell,
nsIContent* aHTMLListItemContent, nsIContent* aHTMLListItemContent,
bool aHasBullet) bool aHasBullet)
{ {
nsDocAccessible* document = GetDocAccessible(aPresShell->GetDocument()); nsDocAccessible* document = GetDocAccessible(aPresShell);
if (document) { if (document) {
nsAccessible* accessible = document->GetAccessible(aHTMLListItemContent); nsAccessible* accessible = document->GetAccessible(aHTMLListItemContent);
if (accessible) { if (accessible) {
@ -623,7 +600,7 @@ void
nsAccessibilityService::UpdateImageMap(nsImageFrame* aImageFrame) nsAccessibilityService::UpdateImageMap(nsImageFrame* aImageFrame)
{ {
nsIPresShell* presShell = aImageFrame->PresContext()->PresShell(); nsIPresShell* presShell = aImageFrame->PresContext()->PresShell();
nsDocAccessible* document = GetDocAccessible(presShell->GetDocument()); nsDocAccessible* document = GetDocAccessible(presShell);
if (document) { if (document) {
nsAccessible* accessible = nsAccessible* accessible =
document->GetAccessible(aImageFrame->GetContent()); document->GetAccessible(aImageFrame->GetContent());
@ -682,7 +659,7 @@ void
nsAccessibilityService::RecreateAccessible(nsIPresShell* aPresShell, nsAccessibilityService::RecreateAccessible(nsIPresShell* aPresShell,
nsIContent* aContent) nsIContent* aContent)
{ {
nsDocAccessible* document = GetDocAccessible(aPresShell->GetDocument()); nsDocAccessible* document = GetDocAccessible(aPresShell);
if (document) if (document)
document->RecreateAccessible(aContent); document->RecreateAccessible(aContent);
} }
@ -1075,12 +1052,12 @@ nsAccessibilityService::GetOrCreateAccessible(nsINode* aNode,
} }
newAcc = new nsHyperTextAccessibleWrap(content, docAcc); newAcc = new nsHyperTextAccessibleWrap(content, docAcc);
if (docAcc->BindToDocument(newAcc, nsAccUtils::GetRoleMapEntry(aNode))) if (docAcc->BindToDocument(newAcc, aria::GetRoleMap(aNode)))
return newAcc; return newAcc;
return nsnull; return nsnull;
} }
nsRoleMapEntry *roleMapEntry = nsAccUtils::GetRoleMapEntry(aNode); nsRoleMapEntry* roleMapEntry = aria::GetRoleMap(aNode);
if (roleMapEntry && !nsCRT::strcmp(roleMapEntry->roleString, "presentation")) { if (roleMapEntry && !nsCRT::strcmp(roleMapEntry->roleString, "presentation")) {
// Ignore presentation role if element is focusable (focus event shouldn't // Ignore presentation role if element is focusable (focus event shouldn't
// be ever lost and should be sensible). // be ever lost and should be sensible).
@ -1127,8 +1104,7 @@ nsAccessibilityService::GetOrCreateAccessible(nsINode* aNode,
} }
#ifdef DEBUG #ifdef DEBUG
nsRoleMapEntry *tableRoleMapEntry = nsRoleMapEntry* tableRoleMapEntry = aria::GetRoleMap(tableContent);
nsAccUtils::GetRoleMapEntry(tableContent);
NS_ASSERTION(tableRoleMapEntry && NS_ASSERTION(tableRoleMapEntry &&
!nsCRT::strcmp(tableRoleMapEntry->roleString, "presentation"), !nsCRT::strcmp(tableRoleMapEntry->roleString, "presentation"),
"No accessible for parent table and it didn't have role of presentation"); "No accessible for parent table and it didn't have role of presentation");
@ -1667,7 +1643,7 @@ nsAccessibilityService::CreateHTMLAccessibleByMarkup(nsIFrame* aFrame,
if (tag == nsGkAtoms::a) { if (tag == nsGkAtoms::a) {
// Only some roles truly enjoy life as nsHTMLLinkAccessibles, for details // Only some roles truly enjoy life as nsHTMLLinkAccessibles, for details
// see closed bug 494807. // see closed bug 494807.
nsRoleMapEntry *roleMapEntry = nsAccUtils::GetRoleMapEntry(aContent); nsRoleMapEntry* roleMapEntry = aria::GetRoleMap(aContent);
if (roleMapEntry && roleMapEntry->role != roles::NOTHING && if (roleMapEntry && roleMapEntry->role != roles::NOTHING &&
roleMapEntry->role != roles::LINK) { roleMapEntry->role != roles::LINK) {
nsAccessible* accessible = new nsHyperTextAccessibleWrap(aContent, aDoc); nsAccessible* accessible = new nsHyperTextAccessibleWrap(aContent, aDoc);

View File

@ -276,7 +276,7 @@ public:
* @param aRoleMapEntry The ARIA nsRoleMapEntry* for the accessible, or * @param aRoleMapEntry The ARIA nsRoleMapEntry* for the accessible, or
* nsnull if none. * nsnull if none.
*/ */
virtual void SetRoleMapEntry(nsRoleMapEntry *aRoleMapEntry); virtual void SetRoleMapEntry(nsRoleMapEntry* aRoleMapEntry);
/** /**
* Update the children cache. * Update the children cache.
@ -836,8 +836,11 @@ protected:
nsAutoPtr<AccGroupInfo> mGroupInfo; nsAutoPtr<AccGroupInfo> mGroupInfo;
friend class AccGroupInfo; friend class AccGroupInfo;
nsRoleMapEntry *mRoleMapEntry; // Non-null indicates author-supplied role; possibly state & value as well /**
* Non-null indicates author-supplied role; possibly state & value as well
*/
nsRoleMapEntry* mRoleMapEntry;
}; };
NS_DEFINE_STATIC_IID_ACCESSOR(nsAccessible, NS_DEFINE_STATIC_IID_ACCESSOR(nsAccessible,

View File

@ -285,7 +285,7 @@ nsDocAccessible::SetRoleMapEntry(nsRoleMapEntry* aRoleMapEntry)
// Allow use of ARIA role from outer to override // Allow use of ARIA role from outer to override
nsIContent *ownerContent = parentDoc->FindContentForSubDocument(mDocument); nsIContent *ownerContent = parentDoc->FindContentForSubDocument(mDocument);
if (ownerContent) { if (ownerContent) {
nsRoleMapEntry *roleMapEntry = nsAccUtils::GetRoleMapEntry(ownerContent); nsRoleMapEntry* roleMapEntry = aria::GetRoleMap(ownerContent);
if (roleMapEntry) if (roleMapEntry)
mRoleMapEntry = roleMapEntry; // Override mRoleMapEntry = roleMapEntry; // Override
} }
@ -1698,7 +1698,7 @@ nsDocAccessible::UpdateAccessibleOnAttrChange(dom::Element* aElement,
// It is common for js libraries to set the role on the body element after // It is common for js libraries to set the role on the body element after
// the document has loaded. In this case we just update the role map entry. // the document has loaded. In this case we just update the role map entry.
if (mContent == aElement) { if (mContent == aElement) {
SetRoleMapEntry(nsAccUtils::GetRoleMapEntry(aElement)); SetRoleMapEntry(aria::GetRoleMap(aElement));
return true; return true;
} }

View File

@ -84,18 +84,6 @@ ARIAGridAccessible::Shutdown()
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// nsIAccessibleTable // nsIAccessibleTable
NS_IMETHODIMP
ARIAGridAccessible::GetSummary(nsAString& aSummary)
{
aSummary.Truncate();
if (IsDefunct())
return NS_ERROR_FAILURE;
// XXX: should be pointed by aria-describedby on grid?
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP NS_IMETHODIMP
ARIAGridAccessible::GetColumnCount(PRInt32* aColumnCount) ARIAGridAccessible::GetColumnCount(PRInt32* aColumnCount)
{ {

View File

@ -143,7 +143,7 @@ nsHTMLImageMapAccessible::UpdateChildAreas(bool aDoFireEvents)
nsAccessible* area = mChildren.SafeElementAt(idx); nsAccessible* area = mChildren.SafeElementAt(idx);
if (!area || area->GetContent() != areaContent) { if (!area || area->GetContent() != areaContent) {
nsRefPtr<nsAccessible> area = new nsHTMLAreaAccessible(areaContent, mDoc); nsRefPtr<nsAccessible> area = new nsHTMLAreaAccessible(areaContent, mDoc);
if (!mDoc->BindToDocument(area, nsAccUtils::GetRoleMapEntry(areaContent))) if (!mDoc->BindToDocument(area, aria::GetRoleMap(areaContent)))
break; break;
if (!InsertChildAt(idx, area)) { if (!InsertChildAt(idx, area)) {

View File

@ -554,13 +554,13 @@ nsHTMLTableAccessible::Caption()
return child && child->Role() == roles::CAPTION ? child : nsnull; return child && child->Role() == roles::CAPTION ? child : nsnull;
} }
NS_IMETHODIMP void
nsHTMLTableAccessible::GetSummary(nsAString &aSummary) nsHTMLTableAccessible::Summary(nsString& aSummary)
{ {
nsCOMPtr<nsIDOMHTMLTableElement> table(do_QueryInterface(mContent)); nsCOMPtr<nsIDOMHTMLTableElement> table(do_QueryInterface(mContent));
NS_ENSURE_TRUE(table, NS_ERROR_FAILURE);
if (table)
return table->GetSummary(aSummary); table->GetSummary(aSummary);
} }
NS_IMETHODIMP NS_IMETHODIMP

View File

@ -129,6 +129,7 @@ public:
// TableAccessible // TableAccessible
virtual nsAccessible* Caption(); virtual nsAccessible* Caption();
virtual void Summary(nsString& aSummary);
virtual bool IsProbablyLayoutTable(); virtual bool IsProbablyLayoutTable();
// nsAccessNode // nsAccessNode

View File

@ -2241,11 +2241,11 @@ nsHyperTextAccessible::GetChildIndexAtOffset(PRUint32 aOffset)
// nsHyperTextAccessible protected // nsHyperTextAccessible protected
nsresult nsresult
nsHyperTextAccessible::GetDOMPointByFrameOffset(nsIFrame *aFrame, nsHyperTextAccessible::GetDOMPointByFrameOffset(nsIFrame* aFrame,
PRInt32 aOffset, PRInt32 aOffset,
nsIAccessible *aAccessible, nsAccessible* aAccessible,
nsIDOMNode **aNode, nsIDOMNode** aNode,
PRInt32 *aNodeOffset) PRInt32* aNodeOffset)
{ {
NS_ENSURE_ARG(aAccessible); NS_ENSURE_ARG(aAccessible);
@ -2254,13 +2254,13 @@ nsHyperTextAccessible::GetDOMPointByFrameOffset(nsIFrame *aFrame,
if (!aFrame) { if (!aFrame) {
// If the given frame is null then set offset after the DOM node of the // If the given frame is null then set offset after the DOM node of the
// given accessible. // given accessible.
nsCOMPtr<nsIDOMNode> DOMNode; NS_ASSERTION(!aAccessible->IsDoc(),
aAccessible->GetDOMNode(getter_AddRefs(DOMNode)); "Shouldn't be called on document accessible!");
nsCOMPtr<nsIContent> content(do_QueryInterface(DOMNode));
NS_ENSURE_STATE(content);
nsCOMPtr<nsIContent> parent(content->GetParent()); nsIContent* content = aAccessible->GetContent();
NS_ENSURE_STATE(parent); NS_ASSERTION(content, "Shouldn't operate on defunct accessible!");
nsIContent* parent = content->GetParent();
*aNodeOffset = parent->IndexOf(content) + 1; *aNodeOffset = parent->IndexOf(content) + 1;
node = do_QueryInterface(parent); node = do_QueryInterface(parent);

View File

@ -396,9 +396,9 @@ protected:
nsresult SetSelectionRange(PRInt32 aStartPos, PRInt32 aEndPos); nsresult SetSelectionRange(PRInt32 aStartPos, PRInt32 aEndPos);
// Helpers // Helpers
nsresult GetDOMPointByFrameOffset(nsIFrame *aFrame, PRInt32 aOffset, nsresult GetDOMPointByFrameOffset(nsIFrame* aFrame, PRInt32 aOffset,
nsIAccessible *aAccessible, nsAccessible* aAccessible,
nsIDOMNode **aNode, PRInt32 *aNodeOffset); nsIDOMNode** aNode, PRInt32* aNodeOffset);
/** /**

View File

@ -80,7 +80,7 @@ IsModuleVersionLessThan(HMODULE aModuleHandle, DWORD aMajor, DWORD aMinor)
// Compatibility // Compatibility
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
PRUint32 Compatibility::sMode = Compatibility::NoCompatibilityMode; PRUint32 Compatibility::sConsumers = Compatibility::UNKNOWN;
void void
Compatibility::Init() Compatibility::Init()
@ -88,47 +88,53 @@ Compatibility::Init()
// Note we collect some AT statistics/telemetry here for convenience. // Note we collect some AT statistics/telemetry here for convenience.
HMODULE jawsHandle = ::GetModuleHandleW(L"jhook"); HMODULE jawsHandle = ::GetModuleHandleW(L"jhook");
if (jawsHandle) { if (jawsHandle)
sMode |= JAWSMode; sConsumers |= (IsModuleVersionLessThan(jawsHandle, 8, 2173)) ?
// IA2 off mode for JAWS versions below 8.0.2173. OLDJAWS : JAWS;
if (IsModuleVersionLessThan(jawsHandle, 8, 2173)) {
sMode |= IA2OffMode;
statistics::A11yConsumers(OLDJAWS);
} else {
statistics::A11yConsumers(JAWS);
}
}
if (::GetModuleHandleW(L"gwm32inc")) { if (::GetModuleHandleW(L"gwm32inc"))
sMode |= WEMode; sConsumers |= WE;
statistics::A11yConsumers(WE);
} if (::GetModuleHandleW(L"dolwinhk"))
if (::GetModuleHandleW(L"dolwinhk")) { sConsumers |= DOLPHIN;
sMode |= DolphinMode;
statistics::A11yConsumers(DOLPHIN);
}
if (::GetModuleHandleW(L"STSA32")) if (::GetModuleHandleW(L"STSA32"))
statistics::A11yConsumers(SEROTEK); sConsumers |= SEROTEK;
if (::GetModuleHandleW(L"nvdaHelperRemote")) if (::GetModuleHandleW(L"nvdaHelperRemote"))
statistics::A11yConsumers(NVDA); sConsumers |= NVDA;
if (::GetModuleHandleW(L"OsmHooks")) if (::GetModuleHandleW(L"OsmHooks"))
statistics::A11yConsumers(COBRA); sConsumers |= COBRA;
if (::GetModuleHandleW(L"WebFinderRemote")) if (::GetModuleHandleW(L"WebFinderRemote"))
statistics::A11yConsumers(ZOOMTEXT); sConsumers |= ZOOMTEXT;
if (::GetModuleHandleW(L"Kazahook")) if (::GetModuleHandleW(L"Kazahook"))
statistics::A11yConsumers(KAZAGURU); sConsumers |= KAZAGURU;
if (::GetModuleHandleW(L"TextExtractorImpl32") || if (::GetModuleHandleW(L"TextExtractorImpl32") ||
::GetModuleHandleW(L"TextExtractorImpl64")) ::GetModuleHandleW(L"TextExtractorImpl64"))
statistics::A11yConsumers(YOUDAO); sConsumers |= YOUDAO;
if (::GetModuleHandleW(L"uiautomation"))
sConsumers |= UIAUTOMATION;
// If we have a known consumer remove the unknown bit.
if (sConsumers != Compatibility::UNKNOWN)
sConsumers ^= Compatibility::UNKNOWN;
// Gather telemetry
PRUint32 temp = sConsumers;
for (int i = 0; temp; i++) {
if (temp & 0x1)
statistics::A11yConsumers(i);
temp >>= 1;
}
// Turn off new tab switching for Jaws and WE. // Turn off new tab switching for Jaws and WE.
if (sMode & JAWSMode || sMode & WEMode) { if (sConsumers & (JAWS | OLDJAWS | WE)) {
// Check to see if the pref for disallowing CtrlTab is already set. If so, // Check to see if the pref for disallowing CtrlTab is already set. If so,
// bail out (respect the user settings). If not, set it. // bail out (respect the user settings). If not, set it.
if (!Preferences::HasUserValue("browser.ctrlTab.disallowForScreenReaders")) if (!Preferences::HasUserValue("browser.ctrlTab.disallowForScreenReaders"))

View File

@ -57,22 +57,22 @@ public:
/** /**
* Return true if IAccessible2 disabled. * Return true if IAccessible2 disabled.
*/ */
static bool IsIA2Off() { return sMode & IA2OffMode; } static bool IsIA2Off() { return !!(sConsumers & OLDJAWS); }
/** /**
* Return true if JAWS mode is enabled. * Return true if JAWS mode is enabled.
*/ */
static bool IsJAWS() { return sMode & JAWSMode; } static bool IsJAWS() { return !!(sConsumers & (JAWS | OLDJAWS)); }
/** /**
* Return true if WE mode is enabled. * Return true if WE mode is enabled.
*/ */
static bool IsWE() { return sMode & WEMode; } static bool IsWE() { return !!(sConsumers & WE); }
/** /**
* Return true if Dolphin mode is enabled. * Return true if Dolphin mode is enabled.
*/ */
static bool IsDolphin() { return sMode & DolphinMode; } static bool IsDolphin() { return !!(sConsumers & DOLPHIN); }
private: private:
Compatibility(); Compatibility();
@ -87,34 +87,25 @@ private:
friend class nsAccessNodeWrap; friend class nsAccessNodeWrap;
/** /**
* List of compatibility modes. * List of detected consumers of a11y (used for statistics/telemetry and compat)
*/ */
enum { enum {
NoCompatibilityMode = 0, NVDA = 1 << 0,
JAWSMode = 1 << 0, JAWS = 1 << 1,
WEMode = 1 << 1, OLDJAWS = 1 << 2,
DolphinMode = 1 << 2, WE = 1 << 3,
IA2OffMode = 1 << 3 DOLPHIN = 1 << 4,
}; SEROTEK = 1 << 5,
COBRA = 1 << 6,
/** ZOOMTEXT = 1 << 7,
* List of detected consumers of a11y (used for statistics/telemetry) KAZAGURU = 1 << 8,
*/ YOUDAO = 1 << 9,
enum { UNKNOWN = 1 << 10,
NVDA = 0, UIAUTOMATION = 1 << 11
JAWS = 1,
OLDJAWS = 2,
WE = 3,
DOLPHIN = 4,
SEROTEK = 5,
COBRA = 6,
ZOOMTEXT = 7,
KAZAGURU = 8,
YOUDAO = 9
}; };
private: private:
static PRUint32 sMode; static PRUint32 sConsumers;
}; };
} // a11y namespace } // a11y namespace

View File

@ -21,6 +21,19 @@ xpcAccessibleTable::GetCaption(nsIAccessible** aCaption)
return NS_OK; return NS_OK;
} }
nsresult
xpcAccessibleTable::GetSummary(nsAString& aSummary)
{
if (!mTable)
return NS_ERROR_FAILURE;
nsAutoString summary;
mTable->Summary(summary);
aSummary.Assign(summary);
return NS_OK;
}
nsresult nsresult
xpcAccessibleTable::IsProbablyForLayout(bool* aResult) xpcAccessibleTable::IsProbablyForLayout(bool* aResult)
{ {

View File

@ -7,6 +7,7 @@
#ifndef MOZILLA_A11Y_XPCOM_XPACCESSIBLETABLE_H_ #ifndef MOZILLA_A11Y_XPCOM_XPACCESSIBLETABLE_H_
#define MOZILLA_A11Y_XPCOM_XPACCESSIBLETABLE_H_ #define MOZILLA_A11Y_XPCOM_XPACCESSIBLETABLE_H_
#include "nsAString.h"
#include "nscore.h" #include "nscore.h"
class nsIAccessible; class nsIAccessible;
@ -22,6 +23,7 @@ public:
xpcAccessibleTable(mozilla::a11y::TableAccessible* aTable) : mTable(aTable) { } xpcAccessibleTable(mozilla::a11y::TableAccessible* aTable) : mTable(aTable) { }
nsresult GetCaption(nsIAccessible** aCaption); nsresult GetCaption(nsIAccessible** aCaption);
nsresult GetSummary(nsAString& aSummary);
nsresult IsProbablyForLayout(bool* aIsForLayout); nsresult IsProbablyForLayout(bool* aIsForLayout);
protected: protected:
@ -31,7 +33,8 @@ protected:
#define NS_DECL_OR_FORWARD_NSIACCESSIBLETABLE_WITH_XPCACCESSIBLETABLE \ #define NS_DECL_OR_FORWARD_NSIACCESSIBLETABLE_WITH_XPCACCESSIBLETABLE \
NS_IMETHOD GetCaption(nsIAccessible** aCaption) \ NS_IMETHOD GetCaption(nsIAccessible** aCaption) \
{ return xpcAccessibleTable::GetCaption(aCaption); } \ { return xpcAccessibleTable::GetCaption(aCaption); } \
NS_SCRIPTABLE NS_IMETHOD GetSummary(nsAString & aSummary); \ NS_SCRIPTABLE NS_IMETHOD GetSummary(nsAString & aSummary) \
{ return xpcAccessibleTable::GetSummary(aSummary); } \
NS_SCRIPTABLE NS_IMETHOD GetColumnCount(PRInt32 *aColumnCount); \ NS_SCRIPTABLE NS_IMETHOD GetColumnCount(PRInt32 *aColumnCount); \
NS_SCRIPTABLE NS_IMETHOD GetRowCount(PRInt32 *aRowCount); \ NS_SCRIPTABLE NS_IMETHOD GetRowCount(PRInt32 *aRowCount); \
NS_SCRIPTABLE NS_IMETHOD GetCellAt(PRInt32 rowIndex, PRInt32 columnIndex, nsIAccessible * *_retval NS_OUTPARAM); \ NS_SCRIPTABLE NS_IMETHOD GetCellAt(PRInt32 rowIndex, PRInt32 columnIndex, nsIAccessible * *_retval NS_OUTPARAM); \

View File

@ -241,14 +241,6 @@ nsXULListboxAccessible::NativeRole()
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// nsXULListboxAccessible. nsIAccessibleTable // nsXULListboxAccessible. nsIAccessibleTable
NS_IMETHODIMP
nsXULListboxAccessible::GetSummary(nsAString &aSummary)
{
aSummary.Truncate();
return NS_OK;
}
NS_IMETHODIMP NS_IMETHODIMP
nsXULListboxAccessible::GetColumnCount(PRInt32 *aColumnsCout) nsXULListboxAccessible::GetColumnCount(PRInt32 *aColumnsCout)
{ {

View File

@ -72,13 +72,6 @@ NS_IMPL_ISUPPORTS_INHERITED1(nsXULTreeGridAccessible,
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// nsXULTreeGridAccessible: nsIAccessibleTable implementation // nsXULTreeGridAccessible: nsIAccessibleTable implementation
NS_IMETHODIMP
nsXULTreeGridAccessible::GetSummary(nsAString &aSummary)
{
aSummary.Truncate();
return IsDefunct() ? NS_ERROR_FAILURE : NS_OK;
}
NS_IMETHODIMP NS_IMETHODIMP
nsXULTreeGridAccessible::GetColumnCount(PRInt32 *aColumnCount) nsXULTreeGridAccessible::GetColumnCount(PRInt32 *aColumnCount)
{ {

View File

@ -323,6 +323,10 @@ var shell = {
navigator.mozPower.screenEnabled = true; navigator.mozPower.screenEnabled = true;
} }
} }
if (topic == "cpu") {
navigator.mozPower.cpuSleepAllowed = (state != "locked-foreground" &&
state != "locked-background");
}
} }
let idleTimeout = Services.prefs.getIntPref("power.screen.timeout"); let idleTimeout = Services.prefs.getIntPref("power.screen.timeout");

View File

@ -12,6 +12,7 @@
Jakob Miland <saebekassebil@gmail.com> Jakob Miland <saebekassebil@gmail.com>
Artur Adib <aadib@mozilla.com> Artur Adib <aadib@mozilla.com>
Brendan Dahl <bdahl@mozilla.com> Brendan Dahl <bdahl@mozilla.com>
David Quintana <gigaherz@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"), copy of this software and associated documentation files (the "Software"),

View File

@ -1,4 +1,4 @@
This is the pdf.js project output, https://github.com/mozilla/pdf.js This is the pdf.js project output, https://github.com/mozilla/pdf.js
Current extension version is: 0.2.414 Current extension version is: 0.2.536

View File

@ -30,23 +30,11 @@ function log(aMsg) {
Services.console.logStringMessage(msg); Services.console.logStringMessage(msg);
dump(msg + '\n'); dump(msg + '\n');
} }
function getWindow(top, id) {
return top.QueryInterface(Ci.nsIInterfaceRequestor) function getDOMWindow(aChannel) {
.getInterface(Ci.nsIDOMWindowUtils) var requestor = aChannel.notificationCallbacks;
.getOuterWindowWithId(id); var win = requestor.getInterface(Components.interfaces.nsIDOMWindow);
} return win;
function windowID(win) {
return win.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils)
.outerWindowID;
}
function topWindow(win) {
return win.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsIDocShellTreeItem)
.rootTreeItem
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindow);
} }
// All the priviledged actions. // All the priviledged actions.
@ -75,6 +63,7 @@ ChromeActions.prototype = {
} }
}; };
// Event listener to trigger chrome privedged code. // Event listener to trigger chrome privedged code.
function RequestListener(actions) { function RequestListener(actions) {
this.actions = actions; this.actions = actions;
@ -163,38 +152,32 @@ PdfStreamConverter.prototype = {
var channel = ioService.newChannel( var channel = ioService.newChannel(
'resource://pdf.js/web/viewer.html', null, null); 'resource://pdf.js/web/viewer.html', null, null);
var listener = this.listener;
// Proxy all the request observer calls, when it gets to onStopRequest
// we can get the dom window.
var proxy = {
onStartRequest: function() {
listener.onStartRequest.apply(listener, arguments);
},
onDataAvailable: function() {
listener.onDataAvailable.apply(listener, arguments);
},
onStopRequest: function() {
var domWindow = getDOMWindow(channel);
// Double check the url is still the correct one.
if (domWindow.document.documentURIObject.equals(aRequest.URI)) {
let requestListener = new RequestListener(new ChromeActions);
domWindow.addEventListener(PDFJS_EVENT_ID, function(event) {
requestListener.receive(event);
}, false, true);
}
listener.onStopRequest.apply(listener, arguments);
}
};
// Keep the URL the same so the browser sees it as the same. // Keep the URL the same so the browser sees it as the same.
channel.originalURI = aRequest.URI; channel.originalURI = aRequest.URI;
channel.asyncOpen(this.listener, aContext); channel.asyncOpen(proxy, aContext);
// Setup a global listener waiting for the next DOM to be created and verfiy
// that its the one we want by its URL. When the correct DOM is found create
// an event listener on that window for the pdf.js events that require
// chrome priviledges. Code snippet from John Galt.
let window = aRequest.loadGroup.groupObserver
.QueryInterface(Ci.nsIWebProgress)
.DOMWindow;
let top = topWindow(window);
let id = windowID(window);
window = null;
top.addEventListener('DOMWindowCreated', function onDOMWinCreated(event) {
let doc = event.originalTarget;
let win = doc.defaultView;
if (id == windowID(win)) {
top.removeEventListener('DOMWindowCreated', onDOMWinCreated, true);
if (!doc.documentURIObject.equals(aRequest.URI))
return;
let requestListener = new RequestListener(new ChromeActions);
win.addEventListener(PDFJS_EVENT_ID, function(event) {
requestListener.receive(event);
}, false, true);
} else if (!getWindow(top, id)) {
top.removeEventListener('DOMWindowCreated', onDOMWinCreated, true);
}
}, true);
}, },
// nsIRequestObserver::onStopRequest // nsIRequestObserver::onStopRequest

View File

@ -391,11 +391,43 @@ canvas {
} }
} }
#loading { #loadingBox {
margin: 100px 0; margin: 100px 0;
text-align: center; text-align: center;
} }
#loadingBar {
background-color: #333;
display: inline-block;
border: 1px solid black;
clear: both;
margin:0px;
line-height: 0;
border-radius: 4px;
width: 15em;
height: 1.5em;
}
#loadingBar .progress {
background-color: green;
display: inline-block;
float: left;
background: #b4e391;
background: -moz-linear-gradient(top, #b4e391 0%, #61c419 50%, #b4e391 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#b4e391), color-stop(50%,#61c419), color-stop(100%,#b4e391));
background: -webkit-linear-gradient(top, #b4e391 0%,#61c419 50%,#b4e391 100%);
background: -o-linear-gradient(top, #b4e391 0%,#61c419 50%,#b4e391 100%);
background: -ms-linear-gradient(top, #b4e391 0%,#61c419 50%,#b4e391 100%);
background: linear-gradient(top, #b4e391 0%,#61c419 50%,#b4e391 100%);
border-top-left-radius: 3px;
border-bottom-left-radius: 3px;
width: 0%;
height: 100%;
}
#PDFBug { #PDFBug {
font-size: 10px; font-size: 10px;
position: fixed; position: fixed;

View File

@ -15,6 +15,15 @@ var kMaxScale = 4.0;
var kImageDirectory = './images/'; var kImageDirectory = './images/';
var kSettingsMemory = 20; var kSettingsMemory = 20;
function getFileName(url) {
var anchor = url.indexOf('#');
var query = url.indexOf('?');
var end = Math.min(
anchor > 0 ? anchor : url.length,
query > 0 ? query : url.length);
return url.substring(url.lastIndexOf('/', end) + 1, end);
}
var Cache = function cacheCache(size) { var Cache = function cacheCache(size) {
var data = []; var data = [];
this.push = function cachePush(view) { this.push = function cachePush(view) {
@ -27,6 +36,48 @@ var Cache = function cacheCache(size) {
}; };
}; };
var ProgressBar = (function ProgressBarClosure() {
function clamp(v, min, max) {
return Math.min(Math.max(v, min), max);
}
function ProgressBar(id, opts) {
// Fetch the sub-elements for later
this.div = document.querySelector(id + ' .progress');
// Get options, with sensible defaults
this.height = opts.height || 100;
this.width = opts.width || 100;
this.units = opts.units || '%';
this.percent = opts.percent || 0;
// Initialize heights
this.div.style.height = this.height + this.units;
}
ProgressBar.prototype = {
updateBar: function ProgressBar_updateBar() {
var progressSize = this.width * this._percent / 100;
this.div.style.width = progressSize + this.units;
},
get percent() {
return this._percent;
},
set percent(val) {
this._percent = clamp(val, 0, 100);
this.updateBar();
}
};
return ProgressBar;
})();
var RenderingQueue = (function RenderingQueueClosure() { var RenderingQueue = (function RenderingQueueClosure() {
function RenderingQueue() { function RenderingQueue() {
this.items = []; this.items = [];
@ -258,7 +309,13 @@ var PDFView = {
}, },
open: function pdfViewOpen(url, scale) { open: function pdfViewOpen(url, scale) {
document.title = this.url = url; this.url = url;
document.title = decodeURIComponent(getFileName(url)) || url;
if (!PDFView.loadingBar) {
PDFView.loadingBar = new ProgressBar('#loadingBar', {});
}
var self = this; var self = this;
PDFJS.getPdf( PDFJS.getPdf(
@ -400,6 +457,8 @@ var PDFView = {
var percent = Math.round(level * 100); var percent = Math.round(level * 100);
var loadingIndicator = document.getElementById('loading'); var loadingIndicator = document.getElementById('loading');
loadingIndicator.textContent = 'Loading... ' + percent + '%'; loadingIndicator.textContent = 'Loading... ' + percent + '%';
PDFView.loadingBar.percent = percent;
}, },
load: function pdfViewLoad(data, scale) { load: function pdfViewLoad(data, scale) {
@ -414,8 +473,8 @@ var PDFView = {
var errorWrapper = document.getElementById('errorWrapper'); var errorWrapper = document.getElementById('errorWrapper');
errorWrapper.setAttribute('hidden', 'true'); errorWrapper.setAttribute('hidden', 'true');
var loadingIndicator = document.getElementById('loading'); var loadingBox = document.getElementById('loadingBox');
loadingIndicator.setAttribute('hidden', 'true'); loadingBox.setAttribute('hidden', 'true');
var sidebar = document.getElementById('sidebarView'); var sidebar = document.getElementById('sidebarView');
sidebar.parentNode.scrollTop = 0; sidebar.parentNode.scrollTop = 0;
@ -499,6 +558,24 @@ var PDFView = {
// Setting the default one. // Setting the default one.
this.parseScale(kDefaultScale, true); this.parseScale(kDefaultScale, true);
} }
this.metadata = null;
var metadata = pdf.catalog.metadata;
var info = this.documentInfo = pdf.info;
var pdfTitle;
if (metadata) {
this.metadata = metadata = new PDFJS.Metadata(metadata);
if (metadata.has('dc:title'))
pdfTitle = metadata.get('dc:title');
}
if (!pdfTitle && info && info['Title'])
pdfTitle = info['Title'];
if (pdfTitle)
document.title = pdfTitle;
}, },
setHash: function pdfViewSetHash(hash) { setHash: function pdfViewSetHash(hash) {
@ -1195,10 +1272,6 @@ window.addEventListener('load', function webViewerLoad(evt) {
sidebarScrollView.addEventListener('scroll', updateThumbViewArea, true); sidebarScrollView.addEventListener('scroll', updateThumbViewArea, true);
}, true); }, true);
window.addEventListener('unload', function webViewerUnload(evt) {
window.scrollTo(0, 0);
}, true);
/** /**
* Render the next not yet visible page already such that it is * Render the next not yet visible page already such that it is
* hopefully ready once the user scrolls to it. * hopefully ready once the user scrolls to it.

View File

@ -8,7 +8,7 @@
<Description about="urn:mozilla:install-manifest"> <Description about="urn:mozilla:install-manifest">
<em:id>uriloader@pdf.js</em:id> <em:id>uriloader@pdf.js</em:id>
<em:name>PDF Viewer</em:name> <em:name>PDF Viewer</em:name>
<em:version>0.2.414</em:version> <em:version>0.2.536</em:version>
<em:targetApplication> <em:targetApplication>
<Description> <Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id> <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
@ -20,7 +20,7 @@
<em:bootstrap>true</em:bootstrap> <em:bootstrap>true</em:bootstrap>
<em:creator>Mozilla</em:creator> <em:creator>Mozilla</em:creator>
<em:description>Uses HTML5 to display PDF files directly in Firefox.</em:description> <em:description>Uses HTML5 to display PDF files directly in Firefox.</em:description>
<em:homepageURL>http://support.mozilla.org/kb/using-mozilla-pdf-viewer</em:homepageURL> <em:homepageURL>https://support.mozilla.org/kb/Opening%20PDF%20files%20within%20Firefox</em:homepageURL>
<em:type>2</em:type> <em:type>2</em:type>
</Description> </Description>
</RDF> </RDF>

View File

@ -939,8 +939,8 @@ const gFormSubmitObserver = {
element.addEventListener("blur", blurHandler, false); element.addEventListener("blur", blurHandler, false);
// One event to bring them all and in the darkness bind them. // One event to bring them all and in the darkness bind them.
this.panel.addEventListener("popuphiding", function(aEvent) { this.panel.addEventListener("popuphiding", function onPopupHiding(aEvent) {
aEvent.target.removeEventListener("popuphiding", arguments.callee, false); aEvent.target.removeEventListener("popuphiding", onPopupHiding, false);
element.removeEventListener("input", inputHandler, false); element.removeEventListener("input", inputHandler, false);
element.removeEventListener("blur", blurHandler, false); element.removeEventListener("blur", blurHandler, false);
}, false); }, false);
@ -3746,8 +3746,8 @@ function BrowserCustomizeToolbar()
// Open the panel, but make it invisible until the iframe has loaded so // Open the panel, but make it invisible until the iframe has loaded so
// that the user doesn't see a white flash. // that the user doesn't see a white flash.
panel.style.visibility = "hidden"; panel.style.visibility = "hidden";
gNavToolbox.addEventListener("beforecustomization", function () { gNavToolbox.addEventListener("beforecustomization", function onBeforeCustomization() {
gNavToolbox.removeEventListener("beforecustomization", arguments.callee, false); gNavToolbox.removeEventListener("beforecustomization", onBeforeCustomization, false);
panel.style.removeProperty("visibility"); panel.style.removeProperty("visibility");
}, false); }, false);
panel.openPopup(gNavToolbox, "after_start", 0, 0); panel.openPopup(gNavToolbox, "after_start", 0, 0);
@ -5182,9 +5182,9 @@ var TabsProgressListener = {
Components.isSuccessCode(aStatus) && Components.isSuccessCode(aStatus) &&
/^about:/.test(aWebProgress.DOMWindow.document.documentURI)) { /^about:/.test(aWebProgress.DOMWindow.document.documentURI)) {
aBrowser.addEventListener("click", BrowserOnClick, false); aBrowser.addEventListener("click", BrowserOnClick, false);
aBrowser.addEventListener("pagehide", function () { aBrowser.addEventListener("pagehide", function onPageHide() {
aBrowser.removeEventListener("click", BrowserOnClick, false); aBrowser.removeEventListener("click", BrowserOnClick, false);
aBrowser.removeEventListener("pagehide", arguments.callee, true); aBrowser.removeEventListener("pagehide", onPageHide, true);
}, true); }, true);
// We also want to make changes to page UI for unprivileged about pages. // We also want to make changes to page UI for unprivileged about pages.
@ -6922,8 +6922,8 @@ function BrowserOpenAddonsMgr(aView) {
if (aView) { if (aView) {
// This must be a new load, else the ping/pong would have // This must be a new load, else the ping/pong would have
// found the window above. // found the window above.
Services.obs.addObserver(function (aSubject, aTopic, aData) { Services.obs.addObserver(function observer(aSubject, aTopic, aData) {
Services.obs.removeObserver(arguments.callee, aTopic); Services.obs.removeObserver(observer, aTopic);
aSubject.loadView(aView); aSubject.loadView(aView);
}, "EM-loaded", false); }, "EM-loaded", false);
} }
@ -8330,8 +8330,8 @@ var gIdentityHandler = {
// Add the "open" attribute to the identity box for styling // Add the "open" attribute to the identity box for styling
this._identityBox.setAttribute("open", "true"); this._identityBox.setAttribute("open", "true");
var self = this; var self = this;
this._identityPopup.addEventListener("popuphidden", function (e) { this._identityPopup.addEventListener("popuphidden", function onPopupHidden(e) {
e.currentTarget.removeEventListener("popuphidden", arguments.callee, false); e.currentTarget.removeEventListener("popuphidden", onPopupHidden, false);
self._identityBox.removeAttribute("open"); self._identityBox.removeAttribute("open");
}, false); }, false);

View File

@ -924,6 +924,7 @@
if (!this._previewMode) { if (!this._previewMode) {
this.mCurrentTab.removeAttribute("unread"); this.mCurrentTab.removeAttribute("unread");
this.selectedTab.lastAccessed = Date.now();
#ifdef MOZ_E10S_COMPAT #ifdef MOZ_E10S_COMPAT
// Bug 666816 - TypeAheadFind support for e10s // Bug 666816 - TypeAheadFind support for e10s
@ -3816,6 +3817,7 @@
<field name="mCorrespondingMenuitem">null</field> <field name="mCorrespondingMenuitem">null</field>
<field name="_fullyOpen">false</field> <field name="_fullyOpen">false</field>
<field name="closing">false</field> <field name="closing">false</field>
<field name="lastAccessed">0</field>
</implementation> </implementation>
<handlers> <handlers>

View File

@ -273,6 +273,7 @@ _BROWSER_FILES = \
browser_middleMouse_inherit.js \ browser_middleMouse_inherit.js \
redirect_bug623155.sjs \ redirect_bug623155.sjs \
browser_tabDrop.js \ browser_tabDrop.js \
browser_lastAccessedTab.js \
$(NULL) $(NULL)
ifneq (cocoa,$(MOZ_WIDGET_TOOLKIT)) ifneq (cocoa,$(MOZ_WIDGET_TOOLKIT))

View File

@ -0,0 +1,24 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/**
* Test for bug 739866.
*
* 1. Adds a new tab (but doesn't select it)
* 2. Checks if timestamp on the new tab is 0
* 3. Selects the new tab, checks that the timestamp is updated (>0)
* 4. Selects the original tab & checks if new tab's timestamp has remained changed
*/
function test() {
let originalTab = gBrowser.selectedTab;
let newTab = gBrowser.addTab("about:blank", {skipAnimation: true});
is(newTab.lastAccessed, 0, "Timestamp on the new tab is 0.");
gBrowser.selectedTab = newTab;
let newTabAccessedDate = newTab.lastAccessed;
ok(newTabAccessedDate > 0, "Timestamp on the selected tab is more than 0.");
ok(newTabAccessedDate <= Date.now(), "Timestamp less than or equal current Date.");
gBrowser.selectedTab = originalTab;
is(newTab.lastAccessed, newTabAccessedDate, "New tab's timestamp remains the same.");
gBrowser.removeTab(newTab);
}

View File

@ -401,9 +401,8 @@ WebContentConverterRegistrar.prototype = {
function WCCR_registerProtocolHandler(aProtocol, aURIString, aTitle, aContentWindow) { function WCCR_registerProtocolHandler(aProtocol, aURIString, aTitle, aContentWindow) {
LOG("registerProtocolHandler(" + aProtocol + "," + aURIString + "," + aTitle + ")"); LOG("registerProtocolHandler(" + aProtocol + "," + aURIString + "," + aTitle + ")");
if (Cc["@mozilla.org/privatebrowsing;1"]. var browserWindow = this._getBrowserWindowForContentWindow(aContentWindow);
getService(Ci.nsIPrivateBrowsingService). if (browserWindow.gPrivateBrowsingUI.privateWindow) {
privateBrowsingEnabled) {
// Inside the private browsing mode, we don't want to alert the user to save // Inside the private browsing mode, we don't want to alert the user to save
// a protocol handler. We log it to the error console so that web developers // a protocol handler. We log it to the error console so that web developers
// would have some way to tell what's going wrong. // would have some way to tell what's going wrong.
@ -488,7 +487,7 @@ WebContentConverterRegistrar.prototype = {
buttons = [addButton]; buttons = [addButton];
} }
var browserWindow = this._getBrowserWindowForContentWindow(aContentWindow);
var browserElement = this._getBrowserForContentWindow(browserWindow, aContentWindow); var browserElement = this._getBrowserForContentWindow(browserWindow, aContentWindow);
var notificationBox = browserWindow.getBrowser().getNotificationBox(browserElement); var notificationBox = browserWindow.getBrowser().getNotificationBox(browserElement);
notificationBox.appendNotification(message, notificationBox.appendNotification(message,

View File

@ -133,32 +133,18 @@ Cu.import("resource://gre/modules/debug.js");
Cu.import("resource:///modules/TelemetryTimestamps.jsm"); Cu.import("resource:///modules/TelemetryTimestamps.jsm");
Cu.import("resource://gre/modules/TelemetryStopwatch.jsm"); Cu.import("resource://gre/modules/TelemetryStopwatch.jsm");
XPCOMUtils.defineLazyGetter(this, "NetUtil", function() { XPCOMUtils.defineLazyModuleGetter(this, "NetUtil",
Cu.import("resource://gre/modules/NetUtil.jsm"); "resource://gre/modules/NetUtil.jsm");
return NetUtil; XPCOMUtils.defineLazyModuleGetter(this, "ScratchpadManager",
}); "resource:///modules/devtools/scratchpad-manager.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "XPathGenerator",
XPCOMUtils.defineLazyGetter(this, "ScratchpadManager", function() { "resource:///modules/sessionstore/XPathGenerator.jsm");
Cu.import("resource:///modules/devtools/scratchpad-manager.jsm");
return ScratchpadManager;
});
XPCOMUtils.defineLazyGetter(this, "XPathGenerator", function() {
Cu.import("resource:///modules/sessionstore/XPathGenerator.jsm");
return XPathGenerator;
});
XPCOMUtils.defineLazyServiceGetter(this, "CookieSvc",
"@mozilla.org/cookiemanager;1", "nsICookieManager2");
#ifdef MOZ_CRASHREPORTER #ifdef MOZ_CRASHREPORTER
XPCOMUtils.defineLazyServiceGetter(this, "CrashReporter", XPCOMUtils.defineLazyServiceGetter(this, "CrashReporter",
"@mozilla.org/xre/app-info;1", "nsICrashReporter"); "@mozilla.org/xre/app-info;1", "nsICrashReporter");
#endif #endif
XPCOMUtils.defineLazyServiceGetter(this, "SecuritySvc",
"@mozilla.org/scriptsecuritymanager;1", "nsIScriptSecurityManager");
function debug(aMsg) { function debug(aMsg) {
aMsg = ("SessionStore: " + aMsg).replace(/\S{80}/g, "$&\n"); aMsg = ("SessionStore: " + aMsg).replace(/\S{80}/g, "$&\n");
Services.console.logStringMessage(aMsg); Services.console.logStringMessage(aMsg);
@ -168,8 +154,7 @@ function debug(aMsg) {
function SessionStoreService() { function SessionStoreService() {
XPCOMUtils.defineLazyGetter(this, "_prefBranch", function () { XPCOMUtils.defineLazyGetter(this, "_prefBranch", function () {
return Cc["@mozilla.org/preferences-service;1"]. return Services.prefs.getBranch("browser.");
getService(Ci.nsIPrefService).getBranch("browser.");
}); });
// minimal interval between two save operations (in milliseconds) // minimal interval between two save operations (in milliseconds)
@ -2141,7 +2126,7 @@ SessionStoreService.prototype = {
let storage, storageItemCount = 0; let storage, storageItemCount = 0;
try { try {
var principal = SecuritySvc.getCodebasePrincipal(uri); var principal = Services.scriptSecurityManager.getCodebasePrincipal(uri);
// Using getSessionStorageForPrincipal instead of getSessionStorageForURI // Using getSessionStorageForPrincipal instead of getSessionStorageForURI
// just to be able to pass aCreate = false, that avoids creation of the // just to be able to pass aCreate = false, that avoids creation of the
@ -2515,7 +2500,7 @@ SessionStoreService.prototype = {
for (var [host, isPinned] in Iterator(internalWindow.hosts)) { for (var [host, isPinned] in Iterator(internalWindow.hosts)) {
let list; let list;
try { try {
list = CookieSvc.getCookiesFromHost(host); list = Services.cookies.getCookiesFromHost(host);
} }
catch (ex) { catch (ex) {
debug("getCookiesFromHost failed. Host: " + host); debug("getCookiesFromHost failed. Host: " + host);
@ -3711,9 +3696,9 @@ SessionStoreService.prototype = {
for (let i = 0; i < aCookies.length; i++) { for (let i = 0; i < aCookies.length; i++) {
var cookie = aCookies[i]; var cookie = aCookies[i];
try { try {
CookieSvc.add(cookie.host, cookie.path || "", cookie.name || "", Services.cookies.add(cookie.host, cookie.path || "", cookie.name || "",
cookie.value, !!cookie.secure, !!cookie.httponly, true, cookie.value, !!cookie.secure, !!cookie.httponly, true,
"expiry" in cookie ? cookie.expiry : MAX_EXPIRY); "expiry" in cookie ? cookie.expiry : MAX_EXPIRY);
} }
catch (ex) { Cu.reportError(ex); } // don't let a single cookie stop recovering catch (ex) { Cu.reportError(ex); } // don't let a single cookie stop recovering
} }

View File

@ -408,7 +408,11 @@
@BINPATH@/components/ProfileMigrator.js @BINPATH@/components/ProfileMigrator.js
@BINPATH@/components/ChromeProfileMigrator.js @BINPATH@/components/ChromeProfileMigrator.js
@BINPATH@/components/FirefoxProfileMigrator.js @BINPATH@/components/FirefoxProfileMigrator.js
#ifdef XP_WIN
@BINPATH@/components/SafariProfileMigrator.js
#endif
#ifdef XP_MACOSX #ifdef XP_MACOSX
@BINPATH@/components/SafariProfileMigrator.js
@BINPATH@/components/libalerts.dylib @BINPATH@/components/libalerts.dylib
#endif #endif
#ifdef MOZ_ENABLE_DBUS #ifdef MOZ_ENABLE_DBUS

View File

@ -611,23 +611,14 @@ nsScriptSecurityManager::ContentSecurityPolicyPermitsJSAction(JSContext *cx)
if (!evalOK) { if (!evalOK) {
// get the script filename, script sample, and line number // get the script filename, script sample, and line number
// to log with the violation // to log with the violation
JSStackFrame *fp = nsnull;
nsAutoString fileName; nsAutoString fileName;
PRUint32 lineNum = 0; unsigned lineNum = 0;
NS_NAMED_LITERAL_STRING(scriptSample, "call to eval() or related function blocked by CSP"); NS_NAMED_LITERAL_STRING(scriptSample, "call to eval() or related function blocked by CSP");
fp = JS_FrameIterator(cx, &fp); JSScript *script;
if (fp) { if (JS_DescribeScriptedCaller(cx, &script, &lineNum)) {
JSScript *script = JS_GetFrameScript(cx, fp); if (const char *file = JS_GetScriptFilename(cx, script)) {
if (script) { CopyUTF8toUTF16(nsDependentCString(file), fileName);
const char *file = JS_GetScriptFilename(cx, script);
if (file) {
CopyUTF8toUTF16(nsDependentCString(file), fileName);
}
jsbytecode *pc = JS_GetFramePC(cx, fp);
if (pc) {
lineNum = JS_PCToLineNumber(cx, script, pc);
}
} }
} }

View File

@ -1439,6 +1439,8 @@ void
nsContentSink::DidBuildModelImpl(bool aTerminated) nsContentSink::DidBuildModelImpl(bool aTerminated)
{ {
if (mDocument && !aTerminated) { if (mDocument && !aTerminated) {
MOZ_ASSERT(mDocument->GetReadyStateEnum() ==
nsIDocument::READYSTATE_LOADING, "Bad readyState");
mDocument->SetReadyStateInternal(nsIDocument::READYSTATE_INTERACTIVE); mDocument->SetReadyStateInternal(nsIDocument::READYSTATE_INTERACTIVE);
} }

View File

@ -4109,16 +4109,9 @@ nsContentUtils::CreateDocument(const nsAString& aNamespaceURI,
DocumentFlavor aFlavor, DocumentFlavor aFlavor,
nsIDOMDocument** aResult) nsIDOMDocument** aResult)
{ {
nsresult rv = NS_NewDOMDocument(aResult, aNamespaceURI, aQualifiedName, return NS_NewDOMDocument(aResult, aNamespaceURI, aQualifiedName,
aDoctype, aDocumentURI, aBaseURI, aPrincipal, aDoctype, aDocumentURI, aBaseURI, aPrincipal,
true, aEventObject, aFlavor); true, aEventObject, aFlavor);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDocument> document = do_QueryInterface(*aResult);
// created documents are immediately "complete" (ready to use)
document->SetReadyStateInternal(nsIDocument::READYSTATE_COMPLETE);
return NS_OK;
} }
/* static */ /* static */
@ -5732,18 +5725,15 @@ nsContentUtils::CanAccessNativeAnon()
sSecurityManager->GetCxSubjectPrincipalAndFrame(cx, &fp); sSecurityManager->GetCxSubjectPrincipalAndFrame(cx, &fp);
NS_ENSURE_TRUE(principal, false); NS_ENSURE_TRUE(principal, false);
JSScript *script = nsnull;
if (!fp) { if (!fp) {
if (!JS_FrameIterator(cx, &fp)) { if (!JS_DescribeScriptedCaller(cx, &script, nsnull)) {
// No code at all is running. So we must be arriving here as the result // No code at all is running. So we must be arriving here as the result
// of C++ code asking us to do something. Allow access. // of C++ code asking us to do something. Allow access.
return true; return true;
} }
} else if (JS_IsScriptFrame(cx, fp)) {
// Some code is running, we can't make the assumption, as above, but we script = JS_GetFrameScript(cx, fp);
// can't use a native frame, so clear fp.
fp = nsnull;
} else if (!JS_IsScriptFrame(cx, fp)) {
fp = nsnull;
} }
bool privileged; bool privileged;
@ -5757,8 +5747,8 @@ nsContentUtils::CanAccessNativeAnon()
// if they've been cloned into less privileged contexts. // if they've been cloned into less privileged contexts.
static const char prefix[] = "chrome://global/"; static const char prefix[] = "chrome://global/";
const char *filename; const char *filename;
if (fp && JS_IsScriptFrame(cx, fp) && if (script &&
(filename = JS_GetScriptFilename(cx, JS_GetFrameScript(cx, fp))) && (filename = JS_GetScriptFilename(cx, script)) &&
!strncmp(filename, prefix, ArrayLength(prefix) - 1)) { !strncmp(filename, prefix, ArrayLength(prefix) - 1)) {
return true; return true;
} }

View File

@ -1442,12 +1442,21 @@ nsDOMImplementation::CreateDocument(const nsAString& aNamespaceURI,
NS_ENSURE_STATE(!mScriptObject || scriptHandlingObject); NS_ENSURE_STATE(!mScriptObject || scriptHandlingObject);
return nsContentUtils::CreateDocument(aNamespaceURI, aQualifiedName, aDoctype, nsCOMPtr<nsIDOMDocument> document;
mDocumentURI, mBaseURI,
mOwner->NodePrincipal(), rv = nsContentUtils::CreateDocument(aNamespaceURI, aQualifiedName, aDoctype,
scriptHandlingObject, mDocumentURI, mBaseURI,
mOwner->NodePrincipal(),
scriptHandlingObject,
DocumentFlavorLegacyGuess, DocumentFlavorLegacyGuess,
aReturn); getter_AddRefs(document));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDocument> doc = do_QueryInterface(document);
doc->SetReadyStateInternal(nsIDocument::READYSTATE_COMPLETE);
document.forget(aReturn);
return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
@ -1519,6 +1528,8 @@ nsDOMImplementation::CreateHTMLDocument(const nsAString& aTitle,
rv = root->AppendChildTo(body, false); rv = root->AppendChildTo(body, false);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
doc->SetReadyStateInternal(nsIDocument::READYSTATE_COMPLETE);
document.forget(aReturn); document.forget(aReturn);
return NS_OK; return NS_OK;
@ -2366,6 +2377,8 @@ nsDocument::StartDocumentLoad(const char* aCommand, nsIChannel* aChannel,
} }
#endif #endif
MOZ_ASSERT(GetReadyStateEnum() == nsIDocument::READYSTATE_UNINITIALIZED,
"Bad readyState");
SetReadyStateInternal(READYSTATE_LOADING); SetReadyStateInternal(READYSTATE_LOADING);
if (nsCRT::strcmp(kLoadAsData, aCommand) == 0) { if (nsCRT::strcmp(kLoadAsData, aCommand) == 0) {
@ -7646,6 +7659,12 @@ void
nsDocument::SetReadyStateInternal(ReadyState rs) nsDocument::SetReadyStateInternal(ReadyState rs)
{ {
mReadyState = rs; mReadyState = rs;
if (rs == READYSTATE_UNINITIALIZED) {
// Transition back to uninitialized happens only to keep assertions happy
// right before readyState transitions to something else. Make this
// transition undetectable by Web content.
return;
}
if (mTiming) { if (mTiming) {
switch (rs) { switch (rs) {
case READYSTATE_LOADING: case READYSTATE_LOADING:

View File

@ -677,12 +677,14 @@ nsObjectLoadingContent::InstantiatePluginInstance(const char* aMimeType, nsIURI*
if (fullPageMode) { if (fullPageMode) {
nsCOMPtr<nsIStreamListener> stream; nsCOMPtr<nsIStreamListener> stream;
rv = pluginHost->InstantiateFullPagePlugin(aMimeType, aURI, this, getter_AddRefs(mInstanceOwner), getter_AddRefs(stream)); rv = pluginHost->InstantiateFullPagePluginInstance(aMimeType, aURI, this,
getter_AddRefs(mInstanceOwner), getter_AddRefs(stream));
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(rv)) {
pDoc->SetStreamListener(stream); pDoc->SetStreamListener(stream);
} }
} else { } else {
rv = pluginHost->InstantiateEmbeddedPlugin(aMimeType, aURI, this, getter_AddRefs(mInstanceOwner)); rv = pluginHost->InstantiateEmbeddedPluginInstance(aMimeType, aURI, this,
getter_AddRefs(mInstanceOwner));
} }
if (appShell) { if (appShell) {

View File

@ -70,6 +70,8 @@
#include "ForceDiscreteGPUHelperCGL.h" #include "ForceDiscreteGPUHelperCGL.h"
#endif #endif
#include "angle/ShaderLang.h"
/* /*
* Minimum value constants defined in 6.2 State Tables of OpenGL ES - 2.0.25 * Minimum value constants defined in 6.2 State Tables of OpenGL ES - 2.0.25
* https://bugzilla.mozilla.org/show_bug.cgi?id=686732 * https://bugzilla.mozilla.org/show_bug.cgi?id=686732
@ -1658,6 +1660,46 @@ struct WebGLMappedIdentifier {
WebGLMappedIdentifier(const nsACString& o, const nsACString& m) : original(o), mapped(m) {} WebGLMappedIdentifier(const nsACString& o, const nsACString& m) : original(o), mapped(m) {}
}; };
struct WebGLUniformInfo {
PRUint32 arraySize;
bool isArray;
ShDataType type;
WebGLUniformInfo(PRUint32 s = 0, bool a = false, ShDataType t = SH_NONE)
: arraySize(s), isArray(a), type(t) {}
int ElementSize() const {
switch (type) {
case SH_INT:
case SH_FLOAT:
case SH_BOOL:
case SH_SAMPLER_2D:
case SH_SAMPLER_CUBE:
return 1;
case SH_INT_VEC2:
case SH_FLOAT_VEC2:
case SH_BOOL_VEC2:
return 2;
case SH_INT_VEC3:
case SH_FLOAT_VEC3:
case SH_BOOL_VEC3:
return 3;
case SH_INT_VEC4:
case SH_FLOAT_VEC4:
case SH_BOOL_VEC4:
case SH_FLOAT_MAT2:
return 4;
case SH_FLOAT_MAT3:
return 9;
case SH_FLOAT_MAT4:
return 16;
default:
NS_ABORT(); // should never get here
return 0;
}
}
};
class WebGLShader MOZ_FINAL class WebGLShader MOZ_FINAL
: public nsIWebGLShader : public nsIWebGLShader
, public WebGLRefCountedObject<WebGLShader> , public WebGLRefCountedObject<WebGLShader>
@ -1733,6 +1775,7 @@ protected:
WebGLMonotonicHandle mMonotonicHandle; WebGLMonotonicHandle mMonotonicHandle;
nsTArray<WebGLMappedIdentifier> mAttributes; nsTArray<WebGLMappedIdentifier> mAttributes;
nsTArray<WebGLMappedIdentifier> mUniforms; nsTArray<WebGLMappedIdentifier> mUniforms;
nsTArray<WebGLUniformInfo> mUniformInfos;
int mAttribMaxNameLength; int mAttribMaxNameLength;
}; };
@ -1765,7 +1808,8 @@ static bool SplitLastSquareBracket(nsACString& string, nsCString& bracketPart)
return true; return true;
} }
typedef nsDataHashtable<nsCStringHashKey, nsCString> CStringHash; typedef nsDataHashtable<nsCStringHashKey, nsCString> CStringMap;
typedef nsDataHashtable<nsCStringHashKey, WebGLUniformInfo> CStringToUniformInfoMap;
class WebGLProgram MOZ_FINAL class WebGLProgram MOZ_FINAL
: public nsIWebGLProgram : public nsIWebGLProgram
@ -1867,7 +1911,7 @@ public:
void MapIdentifier(const nsACString& name, nsCString *mappedName) { void MapIdentifier(const nsACString& name, nsCString *mappedName) {
if (!mIdentifierMap) { if (!mIdentifierMap) {
// if the identifier map doesn't exist yet, build it now // if the identifier map doesn't exist yet, build it now
mIdentifierMap = new CStringHash; mIdentifierMap = new CStringMap;
mIdentifierMap->Init(); mIdentifierMap->Init();
for (size_t i = 0; i < mAttachedShaders.Length(); i++) { for (size_t i = 0; i < mAttachedShaders.Length(); i++) {
for (size_t j = 0; j < mAttachedShaders[i]->mAttributes.Length(); j++) { for (size_t j = 0; j < mAttachedShaders[i]->mAttributes.Length(); j++) {
@ -1915,7 +1959,7 @@ public:
void ReverseMapIdentifier(const nsACString& name, nsCString *reverseMappedName) { void ReverseMapIdentifier(const nsACString& name, nsCString *reverseMappedName) {
if (!mIdentifierReverseMap) { if (!mIdentifierReverseMap) {
// if the identifier reverse map doesn't exist yet, build it now // if the identifier reverse map doesn't exist yet, build it now
mIdentifierReverseMap = new CStringHash; mIdentifierReverseMap = new CStringMap;
mIdentifierReverseMap->Init(); mIdentifierReverseMap->Init();
for (size_t i = 0; i < mAttachedShaders.Length(); i++) { for (size_t i = 0; i < mAttachedShaders.Length(); i++) {
for (size_t j = 0; j < mAttachedShaders[i]->mAttributes.Length(); j++) { for (size_t j = 0; j < mAttachedShaders[i]->mAttributes.Length(); j++) {
@ -1957,6 +2001,44 @@ public:
reverseMappedName->Assign(name); reverseMappedName->Assign(name);
} }
/* Returns the uniform array size (or 1 if the uniform is not an array) of
* the uniform with given mapped identifier.
*
* Note: the input string |name| is the mapped identifier, not the original identifier.
*/
WebGLUniformInfo GetUniformInfoForMappedIdentifier(const nsACString& name) {
if (!mUniformInfoMap) {
// if the identifier-to-array-size map doesn't exist yet, build it now
mUniformInfoMap = new CStringToUniformInfoMap;
mUniformInfoMap->Init();
for (size_t i = 0; i < mAttachedShaders.Length(); i++) {
for (size_t j = 0; j < mAttachedShaders[i]->mUniforms.Length(); j++) {
const WebGLMappedIdentifier& uniform = mAttachedShaders[i]->mUniforms[j];
const WebGLUniformInfo& info = mAttachedShaders[i]->mUniformInfos[j];
mUniformInfoMap->Put(uniform.mapped, info);
}
}
}
nsCString mutableName(name);
nsCString bracketPart;
bool hadBracketPart = SplitLastSquareBracket(mutableName, bracketPart);
// if there is a bracket, we're either an array or an entry in an array.
if (hadBracketPart)
mutableName.AppendLiteral("[0]");
WebGLUniformInfo info;
mUniformInfoMap->Get(mutableName, &info);
// we don't check if that Get failed, as if it did, it left info with default values
// if there is a bracket and it's not [0], then we're not an array, we're just an entry in an array
if (hadBracketPart && !bracketPart.EqualsLiteral("[0]")) {
info.isArray = false;
info.arraySize = 1;
}
return info;
}
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS
NS_DECL_NSIWEBGLPROGRAM NS_DECL_NSIWEBGLPROGRAM
@ -1971,7 +2053,8 @@ protected:
// post-link data // post-link data
std::vector<bool> mAttribsInUse; std::vector<bool> mAttribsInUse;
WebGLMonotonicHandle mMonotonicHandle; WebGLMonotonicHandle mMonotonicHandle;
nsAutoPtr<CStringHash> mIdentifierMap, mIdentifierReverseMap; nsAutoPtr<CStringMap> mIdentifierMap, mIdentifierReverseMap;
nsAutoPtr<CStringToUniformInfoMap> mUniformInfoMap;
int mAttribMaxNameLength; int mAttribMaxNameLength;
}; };
@ -2482,12 +2565,14 @@ class WebGLUniformLocation MOZ_FINAL
, public WebGLRefCountedObject<WebGLUniformLocation> , public WebGLRefCountedObject<WebGLUniformLocation>
{ {
public: public:
WebGLUniformLocation(WebGLContext *context, WebGLProgram *program, GLint location) WebGLUniformLocation(WebGLContext *context, WebGLProgram *program, GLint location, const WebGLUniformInfo& info)
: WebGLContextBoundObject(context) : WebGLContextBoundObject(context)
, mProgram(program) , mProgram(program)
, mProgramGeneration(program->Generation()) , mProgramGeneration(program->Generation())
, mLocation(location) , mLocation(location)
, mInfo(info)
{ {
mElementSize = info.ElementSize();
mMonotonicHandle = mContext->mUniformLocations.AppendElement(this); mMonotonicHandle = mContext->mUniformLocations.AppendElement(this);
} }
@ -2500,9 +2585,12 @@ public:
mContext->mUniformLocations.RemoveElement(mMonotonicHandle); mContext->mUniformLocations.RemoveElement(mMonotonicHandle);
} }
const WebGLUniformInfo &Info() const { return mInfo; }
WebGLProgram *Program() const { return mProgram; } WebGLProgram *Program() const { return mProgram; }
GLint Location() const { return mLocation; } GLint Location() const { return mLocation; }
PRUint32 ProgramGeneration() const { return mProgramGeneration; } PRUint32 ProgramGeneration() const { return mProgramGeneration; }
int ElementSize() const { return mElementSize; }
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS
NS_DECL_NSIWEBGLUNIFORMLOCATION NS_DECL_NSIWEBGLUNIFORMLOCATION
@ -2513,6 +2601,8 @@ protected:
PRUint32 mProgramGeneration; PRUint32 mProgramGeneration;
GLint mLocation; GLint mLocation;
WebGLUniformInfo mInfo;
int mElementSize;
WebGLMonotonicHandle mMonotonicHandle; WebGLMonotonicHandle mMonotonicHandle;
friend class WebGLProgram; friend class WebGLProgram;
}; };

View File

@ -56,11 +56,6 @@
#include "jstypedarray.h" #include "jstypedarray.h"
#if defined(USE_ANGLE)
// shader translator
#include "angle/ShaderLang.h"
#endif
#include "WebGLTexelConversions.h" #include "WebGLTexelConversions.h"
#include "WebGLValidateStrings.h" #include "WebGLValidateStrings.h"
@ -3029,8 +3024,14 @@ WebGLContext::GetUniformLocation(nsIWebGLProgram *pobj, const nsAString& name, n
GLint intlocation = gl->fGetUniformLocation(progname, mappedName.get()); GLint intlocation = gl->fGetUniformLocation(progname, mappedName.get());
WebGLUniformLocation *loc = nsnull; WebGLUniformLocation *loc = nsnull;
if (intlocation >= 0) if (intlocation >= 0) {
NS_ADDREF(loc = new WebGLUniformLocation(this, prog, intlocation)); WebGLUniformInfo info = prog->GetUniformInfoForMappedIdentifier(mappedName);
loc = new WebGLUniformLocation(this,
prog,
intlocation,
info);
NS_ADDREF(loc);
}
*retval = loc; *retval = loc;
return NS_OK; return NS_OK;
} }
@ -4139,14 +4140,39 @@ WebGLContext::name(nsIWebGLUniformLocation *aLocation, const JS::Value& aValue,
if (JS_GetTypedArrayType(wa) != js::TypedArray::arrayType) { \ if (JS_GetTypedArrayType(wa) != js::TypedArray::arrayType) { \
return ErrorInvalidOperation(#name ": array must be " #arrayType); \ return ErrorInvalidOperation(#name ": array must be " #arrayType); \
} \ } \
if (JS_GetTypedArrayLength(wa) == 0 || \ int elementSize = location_object->ElementSize(); \
JS_GetTypedArrayLength(wa) % cnt != 0) { \ if (cnt != elementSize) { \
return ErrorInvalidValue(#name ": array must be > 0 elements and have " \ return ErrorInvalidOperation( \
"a length multiple of %d", cnt); \ #name ": this function expected a uniform of element size %d," \
" got a uniform of element size %d", \
cnt, \
elementSize); \
} \
PRUint32 arrayLength = JS_GetTypedArrayLength(wa); \
const WebGLUniformInfo& info = location_object->Info(); \
PRUint32 expectedArrayLength = cnt * info.arraySize; \
if (arrayLength < expectedArrayLength || \
(arrayLength % cnt)) \
{ \
return ErrorInvalidValue("%s: expected an array of length a multiple of" \
" %d and at least %d, got an array of length %d", \
#name, \
cnt, \
expectedArrayLength, \
arrayLength); \
} \
if (!info.isArray && \
arrayLength > expectedArrayLength) { \
return ErrorInvalidOperation("%s: expected an array of length exactly %d" \
" (since this uniform is not an array uniform)," \
" got an array of length %d", \
#name, \
expectedArrayLength, \
arrayLength); \
} \ } \
\ \
MakeContextCurrent(); \ MakeContextCurrent(); \
gl->f##name(location, JS_GetTypedArrayLength(wa) / cnt, \ gl->f##name(location, info.arraySize, \
static_cast<ptrType*>(JS_GetTypedArrayData(wa))); \ static_cast<ptrType*>(JS_GetTypedArrayData(wa))); \
return NS_OK; \ return NS_OK; \
} }
@ -4168,12 +4194,37 @@ WebGLContext::name(nsIWebGLUniformLocation* aLocation, bool aTranspose,
nsIWebGLUniformLocation* ploc = aLocation; \ nsIWebGLUniformLocation* ploc = aLocation; \
OBTAIN_UNIFORM_LOCATION(#name ": location") \ OBTAIN_UNIFORM_LOCATION(#name ": location") \
if (JS_GetTypedArrayType(wa) != js::TypedArray::TYPE_FLOAT32) { \ if (JS_GetTypedArrayType(wa) != js::TypedArray::TYPE_FLOAT32) { \
return ErrorInvalidValue(#name ": array must be TYPE_FLOAT32"); \ return ErrorInvalidValue(#name ": array must be of Float32 type"); \
} \ } \
if (JS_GetTypedArrayLength(wa) == 0 || \ int elementSize = location_object->ElementSize(); \
JS_GetTypedArrayLength(wa) % (dim*dim) != 0) { \ if (dim*dim != elementSize) { \
return ErrorInvalidValue(#name ": array length must be >0 and " \ return ErrorInvalidOperation( \
"multiple of %d", dim*dim); \ #name ": this function expected a uniform of element size %d," \
" got a uniform of element size %d", \
dim*dim, \
elementSize); \
} \
PRUint32 arrayLength = JS_GetTypedArrayLength(wa); \
const WebGLUniformInfo& info = location_object->Info(); \
PRUint32 expectedArrayLength = dim * dim * info.arraySize; \
if (arrayLength < expectedArrayLength || \
(arrayLength % (dim*dim))) \
{ \
return ErrorInvalidValue("%s: expected an array of length a multiple of" \
" %d and at least %d, got an array of length %d", \
#name, \
dim*dim, \
expectedArrayLength, \
arrayLength); \
} \
if (!info.isArray && \
arrayLength > expectedArrayLength) { \
return ErrorInvalidOperation("%s: expected an array of length exactly %d" \
" (since this uniform is not an array uniform)," \
" got an array of length %d", \
#name, \
expectedArrayLength, \
arrayLength); \
} \ } \
if (aTranspose) { \ if (aTranspose) { \
return ErrorInvalidValue(#name ": transpose must be FALSE as per the " \ return ErrorInvalidValue(#name ": transpose must be FALSE as per the " \
@ -4181,7 +4232,7 @@ WebGLContext::name(nsIWebGLUniformLocation* aLocation, bool aTranspose,
} \ } \
\ \
MakeContextCurrent(); \ MakeContextCurrent(); \
gl->f##name(location, JS_GetTypedArrayLength(wa) / (dim*dim), false, \ gl->f##name(location, info.arraySize, false, \
static_cast<WebGLfloat*>(JS_GetTypedArrayData(wa))); \ static_cast<WebGLfloat*>(JS_GetTypedArrayData(wa))); \
return NS_OK; \ return NS_OK; \
} }
@ -4534,11 +4585,10 @@ WebGLContext::CompileShader(nsIWebGLShader *sobj)
targetShaderSourceLanguage, targetShaderSourceLanguage,
&resources); &resources);
int compileOptions = 0; int compileOptions = SH_ATTRIBUTES_UNIFORMS;
if (useShaderSourceTranslation) { if (useShaderSourceTranslation) {
compileOptions |= SH_OBJECT_CODE compileOptions |= SH_OBJECT_CODE
| SH_MAP_LONG_VARIABLE_NAMES | SH_MAP_LONG_VARIABLE_NAMES;
| SH_ATTRIBUTES_UNIFORMS;
#ifdef XP_MACOSX #ifdef XP_MACOSX
// work around bug 665578 // work around bug 665578
if (gl->WorkAroundDriverBugs() && if (gl->WorkAroundDriverBugs() &&
@ -4581,11 +4631,37 @@ WebGLContext::CompileShader(nsIWebGLShader *sobj)
shader->mAttributes.Clear(); shader->mAttributes.Clear();
shader->mUniforms.Clear(); shader->mUniforms.Clear();
shader->mUniformInfos.Clear();
nsAutoArrayPtr<char> attribute_name(new char[attrib_max_length+1]); nsAutoArrayPtr<char> attribute_name(new char[attrib_max_length+1]);
nsAutoArrayPtr<char> uniform_name(new char[uniform_max_length+1]); nsAutoArrayPtr<char> uniform_name(new char[uniform_max_length+1]);
nsAutoArrayPtr<char> mapped_name(new char[mapped_max_length+1]); nsAutoArrayPtr<char> mapped_name(new char[mapped_max_length+1]);
for (int i = 0; i < num_uniforms; i++) {
int length, size;
ShDataType type;
ShGetActiveUniform(compiler, i,
&length, &size, &type,
uniform_name,
mapped_name);
if (useShaderSourceTranslation) {
shader->mUniforms.AppendElement(WebGLMappedIdentifier(
nsDependentCString(uniform_name),
nsDependentCString(mapped_name)));
}
// we always query uniform info, regardless of useShaderSourceTranslation,
// as we need it to validate uniform setter calls, and it doesn't rely on
// shader translation.
shader->mUniformInfos.AppendElement(WebGLUniformInfo(
size,
length > 1 && mapped_name[length - 1] == ']',
type));
}
if (useShaderSourceTranslation) { if (useShaderSourceTranslation) {
for (int i = 0; i < num_attributes; i++) { for (int i = 0; i < num_attributes; i++) {
int length, size; int length, size;
ShDataType type; ShDataType type;
@ -4598,18 +4674,6 @@ WebGLContext::CompileShader(nsIWebGLShader *sobj)
nsDependentCString(mapped_name))); nsDependentCString(mapped_name)));
} }
for (int i = 0; i < num_uniforms; i++) {
int length, size;
ShDataType type;
ShGetActiveUniform(compiler, i,
&length, &size, &type,
uniform_name,
mapped_name);
shader->mUniforms.AppendElement(WebGLMappedIdentifier(
nsDependentCString(uniform_name),
nsDependentCString(mapped_name)));
}
int len = 0; int len = 0;
ShGetInfo(compiler, SH_OBJECT_CODE_LENGTH, &len); ShGetInfo(compiler, SH_OBJECT_CODE_LENGTH, &len);

View File

@ -61,6 +61,7 @@ WebGLProgram::UpdateInfo()
{ {
mIdentifierMap = nsnull; mIdentifierMap = nsnull;
mIdentifierReverseMap = nsnull; mIdentifierReverseMap = nsnull;
mUniformInfoMap = nsnull;
mAttribMaxNameLength = 0; mAttribMaxNameLength = 0;

View File

@ -1,3 +0,0 @@
conformance/glsl/functions/glsl-function-atan-xy.html
conformance/glsl/misc/struct-nesting-under-maximum.html
conformance/more/functions/uniformfArrayLen1.html

View File

@ -447,16 +447,6 @@ function start() {
if (kIsWindows && !kIsWindowsVistaOrHigher) if (kIsWindows && !kIsWindowsVistaOrHigher)
testsExpectedToFail.push('conformance/textures/texture-mips.html'); testsExpectedToFail.push('conformance/textures/texture-mips.html');
if (kIsMac && kDarwinVersion < 11.0) { // Darwin 11 == Mac OS 10.7
testsExpectedToFail.push('conformance/more/functions/uniformfBadArgs.html');
testsExpectedToFail.push('conformance/more/functions/uniformiBadArgs.html');
}
if (kIsMac && kDarwinVersion >= 11.0) {
testsExpectedToFail.push('conformance/textures/texture-mips.html');
testsExpectedToFail.push('conformance/textures/texture-npot.html');
}
var testsToIgnore = []; var testsToIgnore = [];
runTestSuite(); runTestSuite();

View File

@ -54,6 +54,7 @@
#include "nsFrameLoader.h" #include "nsFrameLoader.h"
#include "nsDOMTouchEvent.h" #include "nsDOMTouchEvent.h"
#include "nsDOMStorage.h" #include "nsDOMStorage.h"
#include "sampler.h"
#define NS_TARGET_CHAIN_FORCE_CONTENT_DISPATCH (1 << 0) #define NS_TARGET_CHAIN_FORCE_CONTENT_DISPATCH (1 << 0)
#define NS_TARGET_CHAIN_WANTS_WILL_HANDLE_EVENT (1 << 1) #define NS_TARGET_CHAIN_WANTS_WILL_HANDLE_EVENT (1 << 1)
@ -480,6 +481,7 @@ nsEventDispatcher::Dispatch(nsISupports* aTarget,
nsDispatchingCallback* aCallback, nsDispatchingCallback* aCallback,
nsCOMArray<nsIDOMEventTarget>* aTargets) nsCOMArray<nsIDOMEventTarget>* aTargets)
{ {
SAMPLE_LABEL("nsEventDispatcher", "Dispatch");
NS_ASSERTION(aEvent, "Trying to dispatch without nsEvent!"); NS_ASSERTION(aEvent, "Trying to dispatch without nsEvent!");
NS_ENSURE_TRUE(!NS_IS_EVENT_IN_DISPATCH(aEvent), NS_ENSURE_TRUE(!NS_IS_EVENT_IN_DISPATCH(aEvent),
NS_ERROR_ILLEGAL_VALUE); NS_ERROR_ILLEGAL_VALUE);

View File

@ -88,7 +88,6 @@
#include "nsIContentSecurityPolicy.h" #include "nsIContentSecurityPolicy.h"
#include "nsJSEnvironment.h" #include "nsJSEnvironment.h"
#include "xpcpublic.h" #include "xpcpublic.h"
#include "sampler.h"
using namespace mozilla::dom; using namespace mozilla::dom;
using namespace mozilla::hal; using namespace mozilla::hal;
@ -836,7 +835,6 @@ nsEventListenerManager::HandleEventInternal(nsPresContext* aPresContext,
nsEventStatus* aEventStatus, nsEventStatus* aEventStatus,
nsCxPusher* aPusher) nsCxPusher* aPusher)
{ {
SAMPLE_LABEL("nsEventListenerManager", "HandleEventInternal");
//Set the value of the internal PreventDefault flag properly based on aEventStatus //Set the value of the internal PreventDefault flag properly based on aEventStatus
if (*aEventStatus == nsEventStatus_eConsumeNoDefault) { if (*aEventStatus == nsEventStatus_eConsumeNoDefault) {
aEvent->flags |= NS_EVENT_FLAG_NO_DEFAULT; aEvent->flags |= NS_EVENT_FLAG_NO_DEFAULT;

View File

@ -1067,9 +1067,9 @@ nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext,
// Store last known screenPoint and clientPoint so pointer lock // Store last known screenPoint and clientPoint so pointer lock
// can use these values as constants. // can use these values as constants.
if (NS_IS_TRUSTED_EVENT(aEvent) && if (NS_IS_TRUSTED_EVENT(aEvent) &&
(NS_IS_MOUSE_EVENT_STRUCT(aEvent) && ((NS_IS_MOUSE_EVENT_STRUCT(aEvent) &&
IsMouseEventReal(aEvent)) || IsMouseEventReal(aEvent)) ||
aEvent->eventStructType == NS_MOUSE_SCROLL_EVENT) { aEvent->eventStructType == NS_MOUSE_SCROLL_EVENT)) {
if (!sIsPointerLocked) { if (!sIsPointerLocked) {
sLastScreenPoint = nsDOMUIEvent::CalculateScreenPoint(aPresContext, aEvent); sLastScreenPoint = nsDOMUIEvent::CalculateScreenPoint(aPresContext, aEvent);
sLastClientPoint = nsDOMUIEvent::CalculateClientPoint(aPresContext, aEvent, nsnull); sLastClientPoint = nsDOMUIEvent::CalculateClientPoint(aPresContext, aEvent, nsnull);

View File

@ -1578,6 +1578,8 @@ nsHTMLDocument::Open(const nsAString& aContentTypeOrUrl,
--mWriteLevel; --mWriteLevel;
SetReadyStateInternal(nsIDocument::READYSTATE_LOADING);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
return CallQueryInterface(this, aReturn); return CallQueryInterface(this, aReturn);
} }

View File

@ -165,6 +165,9 @@ void nsAudioAvailableEventManager::QueueWrittenAudioData(AudioDataValue* aAudioD
signalBuffer[i] = MOZ_CONVERT_AUDIO_SAMPLE(audioData[i]); signalBuffer[i] = MOZ_CONVERT_AUDIO_SAMPLE(audioData[i]);
} }
audioData += signalBufferTail; audioData += signalBufferTail;
NS_ASSERTION(audioDataLength >= signalBufferTail,
"audioDataLength about to wrap past zero to +infinity!");
audioDataLength -= signalBufferTail; audioDataLength -= signalBufferTail;
if (mPendingEvents.Length() > 0) { if (mPendingEvents.Length() > 0) {
@ -192,7 +195,6 @@ void nsAudioAvailableEventManager::QueueWrittenAudioData(AudioDataValue* aAudioD
mSignalBuffer = new float[currentBufferSize]; mSignalBuffer = new float[currentBufferSize];
mSignalBufferPosition = 0; mSignalBufferPosition = 0;
signalBufferTail = currentBufferSize; signalBufferTail = currentBufferSize;
NS_ASSERTION(audioDataLength >= 0, "Past new signal data length.");
} }
NS_ASSERTION(mSignalBufferPosition + audioDataLength < mSignalBufferLength, NS_ASSERTION(mSignalBufferPosition + audioDataLength < mSignalBufferLength,

View File

@ -83,10 +83,6 @@ using mozilla::TimeStamp;
PRLogModuleInfo* gAudioStreamLog = nsnull; PRLogModuleInfo* gAudioStreamLog = nsnull;
#endif #endif
#if defined(MOZ_CUBEB)
static cubeb* gCubebContext;
#endif
static const PRUint32 FAKE_BUFFER_SIZE = 176400; static const PRUint32 FAKE_BUFFER_SIZE = 176400;
// Number of milliseconds per second. // Number of milliseconds per second.
@ -336,7 +332,7 @@ static int PrefChanged(const char* aPref, void* aClosure)
gVolumeScale = NS_MAX<double>(0, PR_strtod(utf8.get(), nsnull)); gVolumeScale = NS_MAX<double>(0, PR_strtod(utf8.get(), nsnull));
} }
} else if (strcmp(aPref, PREF_USE_CUBEB) == 0) { } else if (strcmp(aPref, PREF_USE_CUBEB) == 0) {
bool value = Preferences::GetBool(aPref, false); bool value = Preferences::GetBool(aPref, true);
mozilla::MutexAutoLock lock(*gAudioPrefsLock); mozilla::MutexAutoLock lock(*gAudioPrefsLock);
gUseCubeb = value; gUseCubeb = value;
} }
@ -355,6 +351,19 @@ static bool GetUseCubeb()
mozilla::MutexAutoLock lock(*gAudioPrefsLock); mozilla::MutexAutoLock lock(*gAudioPrefsLock);
return gUseCubeb; return gUseCubeb;
} }
static cubeb* gCubebContext;
static cubeb* GetCubebContext()
{
mozilla::MutexAutoLock lock(*gAudioPrefsLock);
if (gCubebContext ||
cubeb_init(&gCubebContext, "nsAudioStream") == CUBEB_OK) {
return gCubebContext;
}
NS_WARNING("cubeb_init failed");
return nsnull;
}
#endif #endif
void nsAudioStream::InitLibrary() void nsAudioStream::InitLibrary()
@ -368,9 +377,6 @@ void nsAudioStream::InitLibrary()
#if defined(MOZ_CUBEB) #if defined(MOZ_CUBEB)
PrefChanged(PREF_USE_CUBEB, nsnull); PrefChanged(PREF_USE_CUBEB, nsnull);
Preferences::RegisterCallback(PrefChanged, PREF_USE_CUBEB); Preferences::RegisterCallback(PrefChanged, PREF_USE_CUBEB);
if (cubeb_init(&gCubebContext, "nsAudioStream") != 0) {
NS_WARNING("cubeb_init failed");
}
#endif #endif
} }
@ -872,7 +878,8 @@ private:
// once the remaining contents of mBuffer are requested by // once the remaining contents of mBuffer are requested by
// cubeb, after which StateCallback will indicate drain // cubeb, after which StateCallback will indicate drain
// completion. // completion.
DRAINED // StateCallback has indicated that the drain is complete. DRAINED, // StateCallback has indicated that the drain is complete.
ERRORED // Stream disabled due to an internal error.
}; };
StreamState mState; StreamState mState;
@ -915,7 +922,9 @@ NS_IMPL_THREADSAFE_ISUPPORTS0(nsBufferedAudioStream)
nsresult nsresult
nsBufferedAudioStream::Init(PRInt32 aNumChannels, PRInt32 aRate, SampleFormat aFormat) nsBufferedAudioStream::Init(PRInt32 aNumChannels, PRInt32 aRate, SampleFormat aFormat)
{ {
if (!gCubebContext || aNumChannels < 0 || aRate < 0) { cubeb* cubebContext = GetCubebContext();
if (!cubebContext || aNumChannels < 0 || aRate < 0) {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
@ -941,7 +950,7 @@ nsBufferedAudioStream::Init(PRInt32 aNumChannels, PRInt32 aRate, SampleFormat aF
{ {
cubeb_stream* stream; cubeb_stream* stream;
if (cubeb_stream_init(gCubebContext, &stream, "nsBufferedAudioStream", params, if (cubeb_stream_init(cubebContext, &stream, "nsBufferedAudioStream", params,
DEFAULT_LATENCY_MS, DataCallback_S, StateCallback_S, this) == CUBEB_OK) { DEFAULT_LATENCY_MS, DataCallback_S, StateCallback_S, this) == CUBEB_OK) {
mCubebStream.own(stream); mCubebStream.own(stream);
} }
@ -978,7 +987,7 @@ nsresult
nsBufferedAudioStream::Write(const void* aBuf, PRUint32 aFrames) nsBufferedAudioStream::Write(const void* aBuf, PRUint32 aFrames)
{ {
MonitorAutoLock mon(mMonitor); MonitorAutoLock mon(mMonitor);
if (!mCubebStream) { if (!mCubebStream || mState == ERRORED) {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
NS_ASSERTION(mState == INITIALIZED || mState == STARTED, "Stream write in unexpected state."); NS_ASSERTION(mState == INITIALIZED || mState == STARTED, "Stream write in unexpected state.");
@ -1000,9 +1009,13 @@ nsBufferedAudioStream::Write(const void* aBuf, PRUint32 aFrames)
mState = STARTED; mState = STARTED;
} }
if (bytesToCopy > 0) { if (mState == STARTED && bytesToCopy > 0) {
mon.Wait(); mon.Wait();
} }
if (mState != STARTED) {
return NS_ERROR_FAILURE;
}
} }
return NS_OK; return NS_OK;
@ -1038,7 +1051,7 @@ nsBufferedAudioStream::Drain()
return; return;
} }
mState = DRAINING; mState = DRAINING;
while (mState != DRAINED) { while (mState == DRAINING) {
mon.Wait(); mon.Wait();
} }
} }
@ -1091,7 +1104,7 @@ nsBufferedAudioStream::GetPositionInFramesUnlocked()
{ {
mMonitor.AssertCurrentThreadOwns(); mMonitor.AssertCurrentThreadOwns();
if (!mCubebStream) { if (!mCubebStream || mState == ERRORED) {
return -1; return -1;
} }
@ -1178,6 +1191,10 @@ nsBufferedAudioStream::StateCallback(cubeb_state aState)
MonitorAutoLock mon(mMonitor); MonitorAutoLock mon(mMonitor);
mState = DRAINED; mState = DRAINED;
mon.NotifyAll(); mon.NotifyAll();
} else if (aState == CUBEB_STATE_ERROR) {
MonitorAutoLock mon(mMonitor);
mState = ERRORED;
mon.NotifyAll();
} }
return CUBEB_OK; return CUBEB_OK;
} }

View File

@ -18,5 +18,8 @@
<!-- empty container should not affect parent's bbox --> <!-- empty container should not affect parent's bbox -->
<g/> <g/>
<circle cx="100" cy="100" r="5"/> <circle cx="100" cy="100" r="5"/>
<g/>
<circle cx="100" cy="100" r="5"/>
<g/>
</g> </g>
</svg> </svg>

Before

Width:  |  Height:  |  Size: 602 B

After

Width:  |  Height:  |  Size: 658 B

View File

@ -457,6 +457,14 @@ nsXMLDocument::Load(const nsAString& aUrl, bool *aReturn)
return rv; return rv;
} }
// StartDocumentLoad asserts that readyState is uninitialized, so
// uninitialize it. SetReadyStateInternal make this transition invisible to
// Web content. But before doing that, assert that the current readyState
// is complete as it should be after the call to ResetToURI() above.
MOZ_ASSERT(GetReadyStateEnum() == nsIDocument::READYSTATE_COMPLETE,
"Bad readyState");
SetReadyStateInternal(nsIDocument::READYSTATE_UNINITIALIZED);
// Prepare for loading the XML document "into oneself" // Prepare for loading the XML document "into oneself"
nsCOMPtr<nsIStreamListener> listener; nsCOMPtr<nsIStreamListener> listener;
if (NS_FAILED(rv = StartDocumentLoad(kLoadAsData, channel, if (NS_FAILED(rv = StartDocumentLoad(kLoadAsData, channel,

View File

@ -258,6 +258,8 @@ txMozillaXMLOutput::endDocument(nsresult aResult)
if (mCreatingNewDocument) { if (mCreatingNewDocument) {
// This should really be handled by nsIDocument::EndLoad // This should really be handled by nsIDocument::EndLoad
MOZ_ASSERT(mDocument->GetReadyStateEnum() ==
nsIDocument::READYSTATE_LOADING, "Bad readyState");
mDocument->SetReadyStateInternal(nsIDocument::READYSTATE_INTERACTIVE); mDocument->SetReadyStateInternal(nsIDocument::READYSTATE_INTERACTIVE);
nsScriptLoader* loader = mDocument->ScriptLoader(); nsScriptLoader* loader = mDocument->ScriptLoader();
if (loader) { if (loader) {
@ -837,6 +839,8 @@ txMozillaXMLOutput::createResultDocument(const nsSubstring& aName, PRInt32 aNsID
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
} }
// This should really be handled by nsIDocument::BeginLoad // This should really be handled by nsIDocument::BeginLoad
MOZ_ASSERT(mDocument->GetReadyStateEnum() ==
nsIDocument::READYSTATE_UNINITIALIZED, "Bad readyState");
mDocument->SetReadyStateInternal(nsIDocument::READYSTATE_LOADING); mDocument->SetReadyStateInternal(nsIDocument::READYSTATE_LOADING);
nsCOMPtr<nsIDocument> source = do_QueryInterface(aSourceDocument); nsCOMPtr<nsIDocument> source = do_QueryInterface(aSourceDocument);
NS_ENSURE_STATE(source); NS_ENSURE_STATE(source);

View File

@ -687,6 +687,8 @@ txMozillaXSLTProcessor::TransformToDoc(nsIDOMDocument **aResult)
static_cast<txAOutputXMLEventHandler*>(es.mOutputHandler); static_cast<txAOutputXMLEventHandler*>(es.mOutputHandler);
handler->getOutputDocument(aResult); handler->getOutputDocument(aResult);
nsCOMPtr<nsIDocument> doc = do_QueryInterface(*aResult); nsCOMPtr<nsIDocument> doc = do_QueryInterface(*aResult);
MOZ_ASSERT(doc->GetReadyStateEnum() ==
nsIDocument::READYSTATE_INTERACTIVE, "Bad readyState");
doc->SetReadyStateInternal(nsIDocument::READYSTATE_COMPLETE); doc->SetReadyStateInternal(nsIDocument::READYSTATE_COMPLETE);
} }
} }

View File

@ -9726,7 +9726,12 @@ nsDocShell::AddState(nsIVariant *aData, const nsAString& aTitle,
} }
} }
mCurrentURI->Equals(newURI, &equalURIs); if (mCurrentURI) {
mCurrentURI->Equals(newURI, &equalURIs);
}
else {
equalURIs = false;
}
} // end of same-origin check } // end of same-origin check

View File

@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<script>
function boom()
{
var frame = document.createElementNS("http://www.w3.org/1999/xhtml", "iframe");
document.body.appendChild(frame);
var frameScreen = frame.contentWindow.screen;
document.body.removeChild(frame);
frameScreen.top;
}
</script>
</head>
<body onload="boom();"></body>
</html>

View File

@ -37,3 +37,4 @@ load 695867.html
load 697643.html load 697643.html
load 706283-1.html load 706283-1.html
load 708405-1.html load 708405-1.html
load 745495.html

View File

@ -1834,21 +1834,13 @@ PrintWarningOnConsole(JSContext *cx, const char *stringBundleProperty)
return; return;
} }
JSStackFrame *fp, *iterator = nsnull; unsigned lineno = 0;
fp = ::JS_FrameIterator(cx, &iterator); JSScript *script;
PRUint32 lineno = 0;
nsAutoString sourcefile; nsAutoString sourcefile;
if (fp) {
JSScript* script = ::JS_GetFrameScript(cx, fp); if (JS_DescribeScriptedCaller(cx, &script, &lineno)) {
if (script) { if (const char *filename = ::JS_GetScriptFilename(cx, script)) {
const char* filename = ::JS_GetScriptFilename(cx, script); CopyUTF8toUTF16(nsDependentCString(filename), sourcefile);
if (filename) {
CopyUTF8toUTF16(nsDependentCString(filename), sourcefile);
}
jsbytecode* pc = ::JS_GetFramePC(cx, fp);
if (pc) {
lineno = ::JS_PCToLineNumber(cx, script, pc);
}
} }
} }

View File

@ -311,6 +311,10 @@ nsDOMWindowUtils::SetDisplayPortForElement(float aXPx, float aYPx,
return NS_ERROR_INVALID_ARG; return NS_ERROR_INVALID_ARG;
} }
if (content->GetCurrentDoc() != presShell->GetDocument()) {
return NS_ERROR_INVALID_ARG;
}
nsRect lastDisplayPort; nsRect lastDisplayPort;
if (nsLayoutUtils::GetDisplayPort(content, &lastDisplayPort) && if (nsLayoutUtils::GetDisplayPort(content, &lastDisplayPort) &&
displayport.IsEqualInterior(lastDisplayPort)) { displayport.IsEqualInterior(lastDisplayPort)) {

View File

@ -5979,23 +5979,7 @@ JSObject* nsGlobalWindow::CallerGlobal()
return nsnull; return nsnull;
} }
JSObject *scope = nsnull; return JS_GetScriptedGlobal(cx);
JSStackFrame *fp = nsnull;
JS_FrameIterator(cx, &fp);
if (fp) {
while (!JS_IsScriptFrame(cx, fp)) {
if (!JS_FrameIterator(cx, &fp))
break;
}
if (fp)
scope = JS_GetGlobalForFrame(fp);
}
if (!scope)
scope = JS_GetGlobalForScopeChain(cx);
return scope;
} }
nsGlobalWindow* nsGlobalWindow*

View File

@ -445,11 +445,8 @@ NS_ScriptErrorReporter(JSContext *cx,
// We don't want to report exceptions too eagerly, but warnings in the // We don't want to report exceptions too eagerly, but warnings in the
// absence of werror are swallowed whole, so report those now. // absence of werror are swallowed whole, so report those now.
if (!JSREPORT_IS_WARNING(report->flags)) { if (!JSREPORT_IS_WARNING(report->flags)) {
JSStackFrame * fp = nsnull; if (JS_DescribeScriptedCaller(cx, nsnull, nsnull)) {
while ((fp = JS_FrameIterator(cx, &fp))) { return;
if (JS_IsScriptFrame(cx, fp)) {
return;
}
} }
nsIXPConnect* xpc = nsContentUtils::XPConnect(); nsIXPConnect* xpc = nsContentUtils::XPConnect();

View File

@ -67,35 +67,17 @@ JSBool
nsJSUtils::GetCallingLocation(JSContext* aContext, const char* *aFilename, nsJSUtils::GetCallingLocation(JSContext* aContext, const char* *aFilename,
PRUint32* aLineno) PRUint32* aLineno)
{ {
// Get the current filename and line number
JSStackFrame* frame = nsnull;
JSScript* script = nsnull; JSScript* script = nsnull;
do { unsigned lineno = 0;
frame = ::JS_FrameIterator(aContext, &frame);
if (frame) { if (!JS_DescribeScriptedCaller(aContext, &script, &lineno)) {
script = ::JS_GetFrameScript(aContext, frame); return JS_FALSE;
}
} while (frame && !script);
if (script) {
const char* filename = ::JS_GetScriptFilename(aContext, script);
if (filename) {
PRUint32 lineno = 0;
jsbytecode* bytecode = ::JS_GetFramePC(aContext, frame);
if (bytecode) {
lineno = ::JS_PCToLineNumber(aContext, script, bytecode);
}
*aFilename = filename;
*aLineno = lineno;
return JS_TRUE;
}
} }
return JS_FALSE; *aFilename = ::JS_GetScriptFilename(aContext, script);
*aLineno = lineno;
return JS_TRUE;
} }
nsIScriptGlobalObject * nsIScriptGlobalObject *

View File

@ -53,7 +53,6 @@ XPIDLSRCS = \
nsIDOMGeoPositionCallback.idl \ nsIDOMGeoPositionCallback.idl \
nsIDOMGeoPositionError.idl \ nsIDOMGeoPositionError.idl \
nsIDOMGeoPositionErrorCallback.idl \ nsIDOMGeoPositionErrorCallback.idl \
nsIDOMGeoPositionOptions.idl \
nsIDOMNavigatorGeolocation.idl \ nsIDOMNavigatorGeolocation.idl \
$(NULL) $(NULL)

View File

@ -41,16 +41,27 @@ interface nsIDOMGeoPositionOptions;
interface nsIDOMGeoPositionCallback; interface nsIDOMGeoPositionCallback;
interface nsIDOMGeoPositionErrorCallback; interface nsIDOMGeoPositionErrorCallback;
[scriptable, uuid(37687DAF-B85F-4E4D-8881-85A0AD24CF78)] dictionary GeoPositionOptions
{
boolean enableHighAccuracy;
long timeout;
long maximumAge;
};
[scriptable, uuid(b9a301f7-285b-4be9-b739-fb869019c77a)]
interface nsIDOMGeoGeolocation : nsISupports interface nsIDOMGeoGeolocation : nsISupports
{ {
[implicit_jscontext]
void getCurrentPosition(in nsIDOMGeoPositionCallback successCallback, void getCurrentPosition(in nsIDOMGeoPositionCallback successCallback,
[optional] in nsIDOMGeoPositionErrorCallback errorCallback, [optional] in nsIDOMGeoPositionErrorCallback errorCallback,
[optional] in nsIDOMGeoPositionOptions options); /* GeoPositionOptions */
[optional] in jsval options);
[implicit_jscontext]
long watchPosition(in nsIDOMGeoPositionCallback successCallback, long watchPosition(in nsIDOMGeoPositionCallback successCallback,
[optional] in nsIDOMGeoPositionErrorCallback errorCallback, [optional] in nsIDOMGeoPositionErrorCallback errorCallback,
[optional] in nsIDOMGeoPositionOptions options); /* GeoPositionOptions */
[optional] in jsval options);
void clearWatch(in long watchId); void clearWatch(in long watchId);
}; };

View File

@ -1,46 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Geolocation.
*
* The Initial Developer of the Original Code is Mozilla Foundation
* Portions created by the Initial Developer are Copyright (C) 2008
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Doug Turner <dougt@meer.net> (Original Author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "domstubs.idl"
[scriptable, uuid(453B72DE-EA90-4F09-AE16-C2E7EE0DDDC4)]
interface nsIDOMGeoPositionOptions : nsISupports
{
attribute boolean enableHighAccuracy;
attribute long timeout;
attribute long maximumAge;
};

View File

@ -1172,7 +1172,8 @@ ContentParent::RecvAddGeolocationListener()
if (!geo) { if (!geo) {
return true; return true;
} }
geo->WatchPosition(this, nsnull, nsnull, &mGeolocationWatchID); jsval dummy = JSVAL_VOID;
geo->WatchPosition(this, nsnull, dummy, nsnull, &mGeolocationWatchID);
} }
return true; return true;
} }

View File

@ -944,9 +944,9 @@ nsresult nsPluginHost::CreateListenerForChannel(nsIChannel* aChannel,
} }
nsresult nsresult
nsPluginHost::InstantiateEmbeddedPlugin(const char *aMimeType, nsIURI* aURL, nsPluginHost::InstantiateEmbeddedPluginInstance(const char *aMimeType, nsIURI* aURL,
nsObjectLoadingContent *aContent, nsObjectLoadingContent *aContent,
nsPluginInstanceOwner** aOwner) nsPluginInstanceOwner** aOwner)
{ {
NS_ENSURE_ARG_POINTER(aOwner); NS_ENSURE_ARG_POINTER(aOwner);
@ -1099,11 +1099,11 @@ nsPluginHost::InstantiateEmbeddedPlugin(const char *aMimeType, nsIURI* aURL,
return NS_OK; return NS_OK;
} }
nsresult nsPluginHost::InstantiateFullPagePlugin(const char *aMimeType, nsresult nsPluginHost::InstantiateFullPagePluginInstance(const char *aMimeType,
nsIURI* aURI, nsIURI* aURI,
nsObjectLoadingContent *aContent, nsObjectLoadingContent *aContent,
nsPluginInstanceOwner **aOwner, nsPluginInstanceOwner **aOwner,
nsIStreamListener **aStreamListener) nsIStreamListener **aStreamListener)
{ {
#ifdef PLUGIN_LOGGING #ifdef PLUGIN_LOGGING
nsCAutoString urlSpec; nsCAutoString urlSpec;
@ -1145,7 +1145,7 @@ nsresult nsPluginHost::InstantiateFullPagePlugin(const char *aMimeType,
instanceOwner->CreateWidget(); instanceOwner->CreateWidget();
instanceOwner->CallSetWindow(); instanceOwner->CallSetWindow();
rv = NewFullPagePluginStream(aURI, instance.get(), aStreamListener); rv = NewFullPagePluginStreamListener(aURI, instance.get(), aStreamListener);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
return rv; return rv;
} }
@ -3246,33 +3246,28 @@ nsresult nsPluginHost::NewEmbeddedPluginStreamListener(nsIURI* aURL,
nsNPAPIPluginInstance* aInstance, nsNPAPIPluginInstance* aInstance,
nsIStreamListener** aListener) nsIStreamListener** aListener)
{ {
if (!aURL) NS_ENSURE_ARG_POINTER(aURL);
return NS_OK;
nsRefPtr<nsPluginStreamListenerPeer> listener = new nsPluginStreamListenerPeer(); nsRefPtr<nsPluginStreamListenerPeer> listener = new nsPluginStreamListenerPeer();
if (!listener)
return NS_ERROR_OUT_OF_MEMORY;
nsresult rv; // If we have an instance, everything has been set up
// if we have an instance, everything has been set up
// if we only have an owner, then we need to pass it in // if we only have an owner, then we need to pass it in
// so the listener can set up the instance later after // so the listener can set up the instance later after
// we've determined the mimetype of the stream // we've determined the mimetype of the stream.
if (aInstance) nsresult rv = NS_ERROR_ILLEGAL_VALUE;
if (aInstance) {
rv = listener->InitializeEmbedded(aURL, aInstance, nsnull); rv = listener->InitializeEmbedded(aURL, aInstance, nsnull);
else if (aContent) } else if (aContent) {
rv = listener->InitializeEmbedded(aURL, nsnull, aContent); rv = listener->InitializeEmbedded(aURL, nsnull, aContent);
else }
rv = NS_ERROR_ILLEGAL_VALUE;
if (NS_SUCCEEDED(rv)) if (NS_SUCCEEDED(rv)) {
NS_ADDREF(*aListener = listener); NS_ADDREF(*aListener = listener);
}
return rv; return rv;
} }
// Called by InstantiateEmbeddedPlugin()
nsresult nsPluginHost::NewEmbeddedPluginStream(nsIURI* aURL, nsresult nsPluginHost::NewEmbeddedPluginStream(nsIURI* aURL,
nsObjectLoadingContent *aContent, nsObjectLoadingContent *aContent,
nsNPAPIPluginInstance* aInstance) nsNPAPIPluginInstance* aInstance)
@ -3308,17 +3303,13 @@ nsresult nsPluginHost::NewEmbeddedPluginStream(nsIURI* aURL,
return rv; return rv;
} }
// Called by InstantiateFullPagePlugin() nsresult nsPluginHost::NewFullPagePluginStreamListener(nsIURI* aURI,
nsresult nsPluginHost::NewFullPagePluginStream(nsIURI* aURI, nsNPAPIPluginInstance *aInstance,
nsNPAPIPluginInstance *aInstance, nsIStreamListener **aStreamListener)
nsIStreamListener **aStreamListener)
{ {
NS_ASSERTION(aStreamListener, "Stream listener out param cannot be null"); NS_ENSURE_ARG_POINTER(aStreamListener);
nsRefPtr<nsPluginStreamListenerPeer> listener = new nsPluginStreamListenerPeer(); nsRefPtr<nsPluginStreamListenerPeer> listener = new nsPluginStreamListenerPeer();
if (!listener)
return NS_ERROR_OUT_OF_MEMORY;
nsresult rv = listener->InitializeFullPage(aURI, aInstance); nsresult rv = listener->InitializeFullPage(aURI, aInstance);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
return rv; return rv;

View File

@ -218,15 +218,15 @@ public:
// The last argument should be false if we already have an in-flight stream // The last argument should be false if we already have an in-flight stream
// and don't need to set up a new stream. // and don't need to set up a new stream.
nsresult InstantiateEmbeddedPlugin(const char *aMimeType, nsIURI* aURL, nsresult InstantiateEmbeddedPluginInstance(const char *aMimeType, nsIURI* aURL,
nsObjectLoadingContent *aContent, nsObjectLoadingContent *aContent,
nsPluginInstanceOwner** aOwner); nsPluginInstanceOwner** aOwner);
nsresult InstantiateFullPagePlugin(const char *aMimeType, nsresult InstantiateFullPagePluginInstance(const char *aMimeType,
nsIURI* aURI, nsIURI* aURI,
nsObjectLoadingContent *aContent, nsObjectLoadingContent *aContent,
nsPluginInstanceOwner **aOwner, nsPluginInstanceOwner **aOwner,
nsIStreamListener **aStreamListener); nsIStreamListener **aStreamListener);
// Does not accept NULL and should never fail. // Does not accept NULL and should never fail.
nsPluginTag* TagForPlugin(nsNPAPIPlugin* aPlugin); nsPluginTag* TagForPlugin(nsNPAPIPlugin* aPlugin);
@ -246,9 +246,9 @@ private:
NewEmbeddedPluginStream(nsIURI* aURL, nsObjectLoadingContent *aContent, nsNPAPIPluginInstance* aInstance); NewEmbeddedPluginStream(nsIURI* aURL, nsObjectLoadingContent *aContent, nsNPAPIPluginInstance* aInstance);
nsresult nsresult
NewFullPagePluginStream(nsIURI* aURI, NewFullPagePluginStreamListener(nsIURI* aURI,
nsNPAPIPluginInstance *aInstance, nsNPAPIPluginInstance *aInstance,
nsIStreamListener **aStreamListener); nsIStreamListener **aStreamListener);
// Return an nsPluginTag for this type, if any. If aCheckEnabled is // Return an nsPluginTag for this type, if any. If aCheckEnabled is
// true, only enabled plugins will be returned. // true, only enabled plugins will be returned.

View File

@ -236,6 +236,27 @@ PowerManager::SetScreenBrightness(double aBrightness)
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP
PowerManager::GetCpuSleepAllowed(bool *aAllowed)
{
if (!CheckPermission()) {
*aAllowed = true;
return NS_OK;
}
*aAllowed = hal::GetCpuSleepAllowed();
return NS_OK;
}
NS_IMETHODIMP
PowerManager::SetCpuSleepAllowed(bool aAllowed)
{
NS_ENSURE_TRUE(CheckPermission(), NS_ERROR_DOM_SECURITY_ERR);
hal::SetCpuSleepAllowed(aAllowed);
return NS_OK;
}
} // power } // power
} // dom } // dom
} // mozilla } // mozilla

View File

@ -42,7 +42,7 @@ interface nsIDOMMozWakeLockListener;
/** /**
* This interface implements navigator.mozPower * This interface implements navigator.mozPower
*/ */
[scriptable, uuid(4586bed1-cf78-4436-b503-88277d645b68)] [scriptable, uuid(256a3287-f528-45b5-9ba8-2b3650c056e6)]
interface nsIDOMMozPowerManager : nsISupports interface nsIDOMMozPowerManager : nsISupports
{ {
void powerOff(); void powerOff();
@ -96,4 +96,11 @@ interface nsIDOMMozPowerManager : nsISupports
* @throw NS_ERROR_INVALID_ARG if brightness is not in the range [0, 1]. * @throw NS_ERROR_INVALID_ARG if brightness is not in the range [0, 1].
*/ */
attribute double screenBrightness; attribute double screenBrightness;
/**
* Is it possible that the device's CPU will sleep after the screen is
* disabled? Setting this attribute to false will prevent the device
* entering suspend state.
*/
attribute boolean cpuSleepAllowed;
}; };

View File

@ -242,14 +242,12 @@ nsDOMGeoPositionError::NotifyCallback(nsIDOMGeoPositionErrorCallback* aCallback)
nsGeolocationRequest::nsGeolocationRequest(nsGeolocation* aLocator, nsGeolocationRequest::nsGeolocationRequest(nsGeolocation* aLocator,
nsIDOMGeoPositionCallback* aCallback, nsIDOMGeoPositionCallback* aCallback,
nsIDOMGeoPositionErrorCallback* aErrorCallback, nsIDOMGeoPositionErrorCallback* aErrorCallback,
nsIDOMGeoPositionOptions* aOptions,
bool aWatchPositionRequest) bool aWatchPositionRequest)
: mAllowed(false), : mAllowed(false),
mCleared(false), mCleared(false),
mIsWatchPositionRequest(aWatchPositionRequest), mIsWatchPositionRequest(aWatchPositionRequest),
mCallback(aCallback), mCallback(aCallback),
mErrorCallback(aErrorCallback), mErrorCallback(aErrorCallback),
mOptions(aOptions),
mLocator(aLocator) mLocator(aLocator)
{ {
} }
@ -259,9 +257,13 @@ nsGeolocationRequest::~nsGeolocationRequest()
} }
nsresult nsresult
nsGeolocationRequest::Init() nsGeolocationRequest::Init(JSContext* aCx, const jsval& aOptions)
{ {
// This method is called before the user has given permission for this request. if (aCx && !JSVAL_IS_VOID(aOptions) && !JSVAL_IS_NULL(aOptions)) {
mOptions = new mozilla::dom::GeoPositionOptions();
nsresult rv = mOptions->Init(aCx, &aOptions);
NS_ENSURE_SUCCESS(rv, rv);
}
return NS_OK; return NS_OK;
} }
@ -274,7 +276,7 @@ NS_INTERFACE_MAP_END
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsGeolocationRequest) NS_IMPL_CYCLE_COLLECTING_ADDREF(nsGeolocationRequest)
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsGeolocationRequest) NS_IMPL_CYCLE_COLLECTING_RELEASE(nsGeolocationRequest)
NS_IMPL_CYCLE_COLLECTION_4(nsGeolocationRequest, mCallback, mErrorCallback, mOptions, mLocator) NS_IMPL_CYCLE_COLLECTION_3(nsGeolocationRequest, mCallback, mErrorCallback, mLocator)
void void
@ -378,16 +380,11 @@ nsGeolocationRequest::Allow()
PRUint32 maximumAge = 30 * PR_MSEC_PER_SEC; PRUint32 maximumAge = 30 * PR_MSEC_PER_SEC;
if (mOptions) { if (mOptions) {
PRInt32 tempAge; if (mOptions->maximumAge >= 0) {
nsresult rv = mOptions->GetMaximumAge(&tempAge); maximumAge = mOptions->maximumAge;
if (NS_SUCCEEDED(rv)) {
if (tempAge >= 0)
maximumAge = tempAge;
} }
bool highAccuracy; if (mOptions->enableHighAccuracy) {
rv = mOptions->GetEnableHighAccuracy(&highAccuracy); geoService->SetHigherAccuracy(true);
if (NS_SUCCEEDED(rv) && highAccuracy) {
geoService->SetHigherAccuracy(true);
} }
} }
@ -417,7 +414,7 @@ nsGeolocationRequest::SetTimeoutTimer()
mTimeoutTimer = nsnull; mTimeoutTimer = nsnull;
} }
PRInt32 timeout; PRInt32 timeout;
if (mOptions && NS_SUCCEEDED(mOptions->GetTimeout(&timeout)) && timeout != 0) { if (mOptions && (timeout = mOptions->timeout) != 0) {
if (timeout < 0) if (timeout < 0)
timeout = 0; timeout = 0;
@ -487,14 +484,11 @@ nsGeolocationRequest::Update(nsIDOMGeoPosition* aPosition)
void void
nsGeolocationRequest::Shutdown() nsGeolocationRequest::Shutdown()
{ {
if (mOptions) { if (mOptions && mOptions->enableHighAccuracy) {
bool highAccuracy; nsRefPtr<nsGeolocationService> geoService = nsGeolocationService::GetInstance();
nsresult rv = mOptions->GetEnableHighAccuracy(&highAccuracy); if (geoService) {
if (NS_SUCCEEDED(rv) && highAccuracy) { geoService->SetHigherAccuracy(false);
nsRefPtr<nsGeolocationService> geoService = nsGeolocationService::GetInstance(); }
if (geoService)
geoService->SetHigherAccuracy(false);
}
} }
if (mTimeoutTimer) { if (mTimeoutTimer) {
@ -941,7 +935,8 @@ nsGeolocation::Update(nsIDOMGeoPosition *aSomewhere)
NS_IMETHODIMP NS_IMETHODIMP
nsGeolocation::GetCurrentPosition(nsIDOMGeoPositionCallback *callback, nsGeolocation::GetCurrentPosition(nsIDOMGeoPositionCallback *callback,
nsIDOMGeoPositionErrorCallback *errorCallback, nsIDOMGeoPositionErrorCallback *errorCallback,
nsIDOMGeoPositionOptions *options) const jsval& options,
JSContext* cx)
{ {
NS_ENSURE_ARG_POINTER(callback); NS_ENSURE_ARG_POINTER(callback);
@ -954,13 +949,12 @@ nsGeolocation::GetCurrentPosition(nsIDOMGeoPositionCallback *callback,
nsRefPtr<nsGeolocationRequest> request = new nsGeolocationRequest(this, nsRefPtr<nsGeolocationRequest> request = new nsGeolocationRequest(this,
callback, callback,
errorCallback, errorCallback,
options,
false); false);
if (!request) if (!request)
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
if (NS_FAILED(request->Init())) nsresult rv = request->Init(cx, options);
return NS_ERROR_FAILURE; // this as OKAY. not sure why we wouldn't throw. xxx dft NS_ENSURE_SUCCESS(rv, rv);
if (mOwner) { if (mOwner) {
if (!RegisterRequestWithPrompt(request)) if (!RegisterRequestWithPrompt(request))
@ -984,7 +978,8 @@ nsGeolocation::GetCurrentPosition(nsIDOMGeoPositionCallback *callback,
NS_IMETHODIMP NS_IMETHODIMP
nsGeolocation::WatchPosition(nsIDOMGeoPositionCallback *callback, nsGeolocation::WatchPosition(nsIDOMGeoPositionCallback *callback,
nsIDOMGeoPositionErrorCallback *errorCallback, nsIDOMGeoPositionErrorCallback *errorCallback,
nsIDOMGeoPositionOptions *options, const jsval& options,
JSContext* cx,
PRInt32 *_retval NS_OUTPARAM) PRInt32 *_retval NS_OUTPARAM)
{ {
@ -999,13 +994,12 @@ nsGeolocation::WatchPosition(nsIDOMGeoPositionCallback *callback,
nsRefPtr<nsGeolocationRequest> request = new nsGeolocationRequest(this, nsRefPtr<nsGeolocationRequest> request = new nsGeolocationRequest(this,
callback, callback,
errorCallback, errorCallback,
options,
true); true);
if (!request) if (!request)
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
if (NS_FAILED(request->Init())) nsresult rv = request->Init(cx, options);
return NS_ERROR_FAILURE; // this as OKAY. not sure why we wouldn't throw. xxx dft NS_ENSURE_SUCCESS(rv, rv);
if (mOwner) { if (mOwner) {
if (!RegisterRequestWithPrompt(request)) if (!RegisterRequestWithPrompt(request))

View File

@ -57,14 +57,13 @@
#include "nsIDOMGeoPositionError.h" #include "nsIDOMGeoPositionError.h"
#include "nsIDOMGeoPositionCallback.h" #include "nsIDOMGeoPositionCallback.h"
#include "nsIDOMGeoPositionErrorCallback.h" #include "nsIDOMGeoPositionErrorCallback.h"
#include "nsIDOMGeoPositionOptions.h"
#include "nsIDOMNavigatorGeolocation.h" #include "nsIDOMNavigatorGeolocation.h"
#include "nsPIDOMWindow.h" #include "nsPIDOMWindow.h"
#include "nsIGeolocationProvider.h" #include "nsIGeolocationProvider.h"
#include "nsIContentPermissionPrompt.h" #include "nsIContentPermissionPrompt.h"
#include "DictionaryHelpers.h"
#include "PCOMContentPermissionRequestChild.h" #include "PCOMContentPermissionRequestChild.h"
class nsGeolocationService; class nsGeolocationService;
@ -85,9 +84,8 @@ class nsGeolocationRequest
nsGeolocationRequest(nsGeolocation* locator, nsGeolocationRequest(nsGeolocation* locator,
nsIDOMGeoPositionCallback* callback, nsIDOMGeoPositionCallback* callback,
nsIDOMGeoPositionErrorCallback* errorCallback, nsIDOMGeoPositionErrorCallback* errorCallback,
nsIDOMGeoPositionOptions* options,
bool watchPositionRequest = false); bool watchPositionRequest = false);
nsresult Init(); nsresult Init(JSContext* aCx, const jsval& aOptions);
void Shutdown(); void Shutdown();
// Called by the geolocation device to notify that a location has changed. // Called by the geolocation device to notify that a location has changed.
@ -114,7 +112,7 @@ class nsGeolocationRequest
nsCOMPtr<nsITimer> mTimeoutTimer; nsCOMPtr<nsITimer> mTimeoutTimer;
nsCOMPtr<nsIDOMGeoPositionCallback> mCallback; nsCOMPtr<nsIDOMGeoPositionCallback> mCallback;
nsCOMPtr<nsIDOMGeoPositionErrorCallback> mErrorCallback; nsCOMPtr<nsIDOMGeoPositionErrorCallback> mErrorCallback;
nsCOMPtr<nsIDOMGeoPositionOptions> mOptions; nsAutoPtr<mozilla::dom::GeoPositionOptions> mOptions;
nsRefPtr<nsGeolocation> mLocator; nsRefPtr<nsGeolocation> mLocator;
}; };

View File

@ -52,7 +52,6 @@
#include "nsIDOMGeoPositionError.h" #include "nsIDOMGeoPositionError.h"
#include "nsIDOMGeoPositionCallback.h" #include "nsIDOMGeoPositionCallback.h"
#include "nsIDOMGeoPositionErrorCallback.h" #include "nsIDOMGeoPositionErrorCallback.h"
#include "nsIDOMGeoPositionOptions.h"
#include "nsIDOMNavigatorGeolocation.h" #include "nsIDOMNavigatorGeolocation.h"
#include "nsIDOMGeoPositionCoords.h" #include "nsIDOMGeoPositionCoords.h"

View File

@ -47,6 +47,7 @@ DOMWifiManager.prototype = {
// Maintain this state for synchronous APIs. // Maintain this state for synchronous APIs.
this._currentNetwork = null; this._currentNetwork = null;
this._connectionStatus = "disconnected";
this._enabled = true; this._enabled = true;
this._lastConnectionInfo = null; this._lastConnectionInfo = null;
@ -65,10 +66,12 @@ DOMWifiManager.prototype = {
this._currentNetwork = state.network; this._currentNetwork = state.network;
this._lastConnectionInfo = state.connectionInfo; this._lastConnectionInfo = state.connectionInfo;
this._enabled = state.enabled; this._enabled = state.enabled;
this._connectionStatus = state.status;
} else { } else {
this._currentNetwork = null; this._currentNetwork = null;
this._lastConnectionInfo = null; this._lastConnectionInfo = null;
this._enabled = null; this._enabled = false;
this._connectionStatus = "disconnected";
} }
}, },
@ -137,22 +140,26 @@ DOMWifiManager.prototype = {
case "WifiManager:onconnecting": case "WifiManager:onconnecting":
this._currentNetwork = msg.network; this._currentNetwork = msg.network;
this._connectionStatus = "connecting";
this._fireOnConnecting(msg.network); this._fireOnConnecting(msg.network);
break; break;
case "WifiManager:onassociate": case "WifiManager:onassociate":
this._currentNetwork = msg.network; this._currentNetwork = msg.network;
this._connectionStatus = "associated";
this._fireOnAssociate(msg.network); this._fireOnAssociate(msg.network);
break; break;
case "WifiManager:onconnect": case "WifiManager:onconnect":
this._currentNetwork = msg.network; this._currentNetwork = msg.network;
this._connectionStatus = "connected";
this._fireOnConnect(msg.network); this._fireOnConnect(msg.network);
break; break;
case "WifiManager:ondisconnect": case "WifiManager:ondisconnect":
this._fireOnDisconnect(this._currentNetwork); this._fireOnDisconnect(this._currentNetwork);
this._currentNetwork = null; this._currentNetwork = null;
this._connectionStatus = "disconnected";
this._lastConnectionInfo = null; this._lastConnectionInfo = null;
break; break;
@ -232,10 +239,10 @@ DOMWifiManager.prototype = {
return this._enabled; return this._enabled;
}, },
get connectedNetwork() { get connection() {
if (!this._hasPrivileges) if (!this._hasPrivileges)
throw new Components.Exception("Denied", Cr.NS_ERROR_FAILURE); throw new Components.Exception("Denied", Cr.NS_ERROR_FAILURE);
return this._currentNetwork; return { status: this._connectionStatus, network: this._currentNetwork };
}, },
get connectionInfo() { get connectionInfo() {

View File

@ -1026,6 +1026,7 @@ var WifiManager = (function() {
manager.scan = scanCommand; manager.scan = scanCommand;
manager.getRssiApprox = getRssiApproxCommand; manager.getRssiApprox = getRssiApproxCommand;
manager.getLinkSpeed = getLinkSpeedCommand; manager.getLinkSpeed = getLinkSpeedCommand;
manager.getDhcpInfo = function() { return dhcpInfo; }
return manager; return manager;
})(); })();
@ -1374,6 +1375,27 @@ function WifiWorker() {
debug("Wifi starting"); debug("Wifi starting");
} }
function translateState(state) {
switch (state) {
case "INTERFACE_DISABLED":
case "INACTIVE":
case "SCANNING":
case "DISCONNECTED":
default:
return "disconnected";
case "AUTHENTICATING":
case "ASSOCIATING":
case "ASSOCIATED":
case "FOUR_WAY_HANDSHAKE":
case "GROUP_HANDSHAKE":
return "connecting";
case "COMPLETED":
return WifiManager.getDhcpInfo() ? "connected" : "associated";
}
}
WifiWorker.prototype = { WifiWorker.prototype = {
classID: WIFIWORKER_CID, classID: WIFIWORKER_CID,
classInfo: XPCOMUtils.generateCI({classID: WIFIWORKER_CID, classInfo: XPCOMUtils.generateCI({classID: WIFIWORKER_CID,
@ -1583,7 +1605,8 @@ WifiWorker.prototype = {
let net = this.currentNetwork ? netToDOM(this.currentNetwork) : null; let net = this.currentNetwork ? netToDOM(this.currentNetwork) : null;
return { network: net, return { network: net,
connectionInfo: this._lastConnectionInfo, connectionInfo: this._lastConnectionInfo,
enabled: WifiManager.state !== "UNINITIALIZED", }; enabled: WifiManager.state !== "UNINITIALIZED",
status: translateState(WifiManager.state) };
} }
} }
}, },

View File

@ -99,9 +99,14 @@ interface nsIDOMWifiManager : nsISupports {
readonly attribute boolean enabled; readonly attribute boolean enabled;
/** /**
* A network object describing the currently connected network. * An non-null object containing the following information:
* - status ("disconnected", "connecting", "associated", "connected")
* - network
*
* Note that the object returned is read only. Any changes required must
* be done by calling other APIs.
*/ */
readonly attribute jsval connectedNetwork; readonly attribute jsval connection;
/** /**
* A connectionInformation object with the same information found in an * A connectionInformation object with the same information found in an

View File

@ -47,4 +47,5 @@ Yore Apex
Mark Callow Mark Callow
Yuriy O'Donnell Yuriy O'Donnell
Sam Hocevar Sam Hocevar
Pierre Leveille

View File

@ -1,6 +1,9 @@
deps = { deps = {
"trunk/third_party/gyp": "trunk/third_party/gyp":
"http://gyp.googlecode.com/svn/trunk@1080", "http://gyp.googlecode.com/svn/trunk@1080",
"trunk/third_party/googletest":
"http://googletest.googlecode.com/svn/trunk@573", #release 1.6.0
} }
hooks = [ hooks = [

View File

@ -60,6 +60,7 @@ LOCAL_INCLUDES += -I$(srcdir)/include -I$(srcdir)/src
VPATH += $(srcdir)/src VPATH += $(srcdir)/src
VPATH += $(srcdir)/src/compiler VPATH += $(srcdir)/src/compiler
VPATH += $(srcdir)/src/compiler/preprocessor VPATH += $(srcdir)/src/compiler/preprocessor
VPATH += $(srcdir)/src/compiler/preprocessor/new
CPPSRCS = \ CPPSRCS = \
Compiler.cpp \ Compiler.cpp \
@ -86,6 +87,12 @@ CPPSRCS = \
MapLongVariableNames.cpp \ MapLongVariableNames.cpp \
spooky.cpp \ spooky.cpp \
BuiltInFunctionEmulator.cpp \ BuiltInFunctionEmulator.cpp \
Input.cpp \
Lexer.cpp \
pp_lex.cpp \
Preprocessor.cpp \
Token.cpp \
lexer_glue.cpp \
$(NULL) $(NULL)
# flex/yacc generated files # flex/yacc generated files

View File

@ -1,6 +1,6 @@
This is the ANGLE project, from http://code.google.com/p/angleproject/ This is the ANGLE project, from http://code.google.com/p/angleproject/
Current revision: r963 Current revision: r1042
== Applied local patches == == Applied local patches ==
@ -8,10 +8,9 @@ In this order:
angle-renaming-debug.patch - rename debug.h to compilerdebug.h to avoid conflict in our makefiles angle-renaming-debug.patch - rename debug.h to compilerdebug.h to avoid conflict in our makefiles
angle-intrinsic-msvc2005.patch - work around a MSVC 2005 compile error angle-intrinsic-msvc2005.patch - work around a MSVC 2005 compile error
angle-use-xmalloc.patch - see bug 680840. Can drop this patch whenever the new preprocessor lands. angle-use-xmalloc.patch - see bug 680840. Can drop this patch whenever the new preprocessor lands.
angle-castrate-bug-241.patch - see bug 699033 / angle bug 241
angle-enforce-readpixels-spec.patch - see bug 724476. angle-enforce-readpixels-spec.patch - see bug 724476.
angle-impl-read-bgra.patch - see bug 724476. angle-impl-read-bgra.patch - see bug 724476.
gfx/angle/angle-long-identifier-hash-spooky.patch - see bug 676071 angle-long-identifier-hash-spooky.patch - see bug 676071
In addition to these patches, the Makefile.in files are ours, they're not present in upsteam ANGLE. In addition to these patches, the Makefile.in files are ours, they're not present in upsteam ANGLE.

View File

@ -1,6 +1,5 @@
From: Jeff Gilbert <jgilbert@mozilla.com> # HG changeset patch
Bug 724476 - ANGLE Bug 293 - Enforce readPixels format/type semantics # Parent 8d84c8d4e3ed41a4941afdf9d51819b19ca64716
diff --git a/gfx/angle/src/libGLESv2/libGLESv2.cpp b/gfx/angle/src/libGLESv2/libGLESv2.cpp diff --git a/gfx/angle/src/libGLESv2/libGLESv2.cpp b/gfx/angle/src/libGLESv2/libGLESv2.cpp
--- a/gfx/angle/src/libGLESv2/libGLESv2.cpp --- a/gfx/angle/src/libGLESv2/libGLESv2.cpp
+++ b/gfx/angle/src/libGLESv2/libGLESv2.cpp +++ b/gfx/angle/src/libGLESv2/libGLESv2.cpp

View File

@ -1,10 +1,9 @@
From: Jeff Gilbert <jgilbert@mozilla.com> # HG changeset patch
Bug 724476 - ANGLE Bug 294 - Use BGRA/UBYTE as exposed fast format/type for readPixels # Parent 8b838be49f115022e403c850c24b28ad62d72ad6
diff --git a/gfx/angle/src/libGLESv2/Context.cpp b/gfx/angle/src/libGLESv2/Context.cpp diff --git a/gfx/angle/src/libGLESv2/Context.cpp b/gfx/angle/src/libGLESv2/Context.cpp
--- a/gfx/angle/src/libGLESv2/Context.cpp --- a/gfx/angle/src/libGLESv2/Context.cpp
+++ b/gfx/angle/src/libGLESv2/Context.cpp +++ b/gfx/angle/src/libGLESv2/Context.cpp
@@ -2520,16 +2520,17 @@ void Context::readPixels(GLint x, GLint @@ -2518,16 +2518,17 @@ void Context::readPixels(GLint x, GLint
{ {
if (desc.Format == D3DFMT_A8R8G8B8 && if (desc.Format == D3DFMT_A8R8G8B8 &&
format == GL_BGRA_EXT && format == GL_BGRA_EXT &&
@ -22,7 +21,7 @@ diff --git a/gfx/angle/src/libGLESv2/Context.cpp b/gfx/angle/src/libGLESv2/Conte
for (int i = 0; i < rect.right - rect.left; i++) for (int i = 0; i < rect.right - rect.left; i++)
{ {
@@ -2666,20 +2667,20 @@ void Context::readPixels(GLint x, GLint @@ -2665,20 +2666,20 @@ void Context::readPixels(GLint x, GLint
((unsigned short)( a + 0.5f) << 15) | ((unsigned short)( a + 0.5f) << 15) |
((unsigned short)(31 * r + 0.5f) << 10) | ((unsigned short)(31 * r + 0.5f) << 10) |
((unsigned short)(31 * g + 0.5f) << 5) | ((unsigned short)(31 * g + 0.5f) << 5) |

View File

@ -1,5 +1,5 @@
# HG changeset patch # HG changeset patch
# Parent 6ee54a11fd135a2b594db77f7eaf83f06ee7b1d8 # Parent 4ef86d96d456866537beea57b0a4451cf919cd34
diff --git a/gfx/angle/src/libGLESv2/Texture.cpp b/gfx/angle/src/libGLESv2/Texture.cpp diff --git a/gfx/angle/src/libGLESv2/Texture.cpp b/gfx/angle/src/libGLESv2/Texture.cpp
--- a/gfx/angle/src/libGLESv2/Texture.cpp --- a/gfx/angle/src/libGLESv2/Texture.cpp
+++ b/gfx/angle/src/libGLESv2/Texture.cpp +++ b/gfx/angle/src/libGLESv2/Texture.cpp

View File

@ -1,6 +1,5 @@
# HG changeset patch # HG changeset patch
# Parent 69255fe4cb94f1681bc9200db37c0ad3de171abc # Parent 268bda9ac676b6f4cca5aa044d0dcefff2008535
diff --git a/gfx/angle/Makefile.in b/gfx/angle/Makefile.in diff --git a/gfx/angle/Makefile.in b/gfx/angle/Makefile.in
--- a/gfx/angle/Makefile.in --- a/gfx/angle/Makefile.in
+++ b/gfx/angle/Makefile.in +++ b/gfx/angle/Makefile.in

View File

@ -1,9 +1,9 @@
# HG changeset patch # HG changeset patch
# Parent 326590fb862cf7e277487f48c7a434bde3566ea0 # Parent f22671e05062a082c7b22192868b804fbf42653b
diff --git a/gfx/angle/Makefile.in b/gfx/angle/Makefile.in diff --git a/gfx/angle/Makefile.in b/gfx/angle/Makefile.in
--- a/gfx/angle/Makefile.in --- a/gfx/angle/Makefile.in
+++ b/gfx/angle/Makefile.in +++ b/gfx/angle/Makefile.in
@@ -75,17 +75,17 @@ CPPSRCS = \ @@ -73,17 +73,17 @@ CPPSRCS = \
parseConst.cpp \ parseConst.cpp \
ParseHelper.cpp \ ParseHelper.cpp \
PoolAlloc.cpp \ PoolAlloc.cpp \
@ -48,7 +48,7 @@ diff --git a/gfx/angle/src/compiler/OutputHLSL.cpp b/gfx/angle/src/compiler/Outp
+++ b/gfx/angle/src/compiler/OutputHLSL.cpp +++ b/gfx/angle/src/compiler/OutputHLSL.cpp
@@ -1,17 +1,17 @@ @@ -1,17 +1,17 @@
// //
// Copyright (c) 2002-2011 The ANGLE Project Authors. All rights reserved. // Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// //
@ -191,8 +191,8 @@ diff --git a/gfx/angle/src/compiler/preprocessor/tokens.c b/gfx/angle/src/compil
#include "compiler/preprocessor/slglobals.h" #include "compiler/preprocessor/slglobals.h"
#include "compiler/util.h" #include "compiler/util.h"
/////////////////////////////////////////////////////////////////////////////////////////////// #if defined(_MSC_VER)
//////////////////////// Preprocessor and Token Recorder and Playback: //////////////////////// #pragma warning(disable: 4054)
/////////////////////////////////////////////////////////////////////////////////////////////// #pragma warning(disable: 4152)
#endif
/*

View File

@ -1,9 +1,9 @@
# HG changeset patch # HG changeset patch
# Parent 93033f21b121382b50e5bc9787edf704d6906508 # Parent 6ccfe6b908da8ade8b37e772ed8a9f3c494d8ef9
diff --git a/gfx/angle/Makefile.in b/gfx/angle/Makefile.in diff --git a/gfx/angle/Makefile.in b/gfx/angle/Makefile.in
--- a/gfx/angle/Makefile.in --- a/gfx/angle/Makefile.in
+++ b/gfx/angle/Makefile.in +++ b/gfx/angle/Makefile.in
@@ -129,16 +129,18 @@ CSRCS = \ @@ -127,16 +127,18 @@ CSRCS = \
$(NULL) $(NULL)
DEFINES += -DANGLE_USE_NSPR -DANGLE_BUILD -DCOMPILER_IMPLEMENTATION DEFINES += -DANGLE_USE_NSPR -DANGLE_BUILD -DCOMPILER_IMPLEMENTATION

View File

@ -14,7 +14,7 @@
# manually maintained ones. # manually maintained ones.
'../samples/build_samples.gyp:*', '../samples/build_samples.gyp:*',
'../src/build_angle.gyp:*', '../src/build_angle.gyp:*',
# '../tests/tests.gyp:*', '../tests/build_tests.gyp:*',
], ],
}, },
], ],

View File

@ -40,7 +40,6 @@
'PreprocessorDefinitions': [ 'PreprocessorDefinitions': [
'_CRT_SECURE_NO_DEPRECATE', '_CRT_SECURE_NO_DEPRECATE',
'_HAS_EXCEPTIONS=0', '_HAS_EXCEPTIONS=0',
'_HAS_TR1=0',
'_WIN32_WINNT=0x0600', '_WIN32_WINNT=0x0600',
'_WINDOWS', '_WINDOWS',
'NOMINMAX', 'NOMINMAX',
@ -49,7 +48,8 @@
'WINVER=0x0600', 'WINVER=0x0600',
], ],
'RuntimeTypeInfo': 'false', 'RuntimeTypeInfo': 'false',
'WarningLevel': '3', 'WarningLevel': '4',
'DisableSpecificWarnings': '4100;4127;4189;4239;4244;4245;4512;4702',
}, },
'VCLinkerTool': { 'VCLinkerTool': {
'FixedBaseAddress': '1', 'FixedBaseAddress': '1',

View File

@ -0,0 +1,359 @@
Name
ANGLE_instanced_arrays
Name Strings
GL_ANGLE_instanced_arrays
Contributors
Contributors to ARB_instanced_arrays
Nicolas Capens, TransGaming Inc.
James Helferty, TransGaming Inc.
Kenneth Russell, Google Inc.
Vangelis Kokkevis, Google Inc.
Contact
Daniel Koch, TransGaming Inc. (daniel 'at' transgaming.com)
Status
Implemented in ANGLE r976.
Version
Last Modified Date: February 8, 2012
Author Revision: 3
Number
OpenGL ES Extension #??
Dependencies
OpenGL ES 2.0 is required.
This extension is written against the OpenGL ES 2.0 Specification.
Overview
A common use case in GL for some applications is to be able to
draw the same object, or groups of similar objects that share
vertex data, primitive count and type, multiple times. This
extension provides a means of accelerating such use cases while
restricting the number of API calls, and keeping the amount of
duplicate data to a minimum.
This extension introduces an array "divisor" for generic
vertex array attributes, which when non-zero specifies that the
attribute is "instanced." An instanced attribute does not
advance per-vertex as usual, but rather after every <divisor>
conceptual draw calls.
(Attributes which aren't instanced are repeated in their entirety
for every conceptual draw call.)
By specifying transform data in an instanced attribute or series
of instanced attributes, vertex shaders can, in concert with the
instancing draw calls, draw multiple instances of an object with
one draw call.
IP Status
No known IP claims.
New Tokens
Accepted by the <pname> parameters of GetVertexAttribfv and
GetVertexAttribiv:
VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE 0x88FE
New Procedures and Functions
void DrawArraysInstancedANGLE(enum mode, int first, sizei count,
sizei primcount);
void DrawElementsInstancedANGLE(enum mode, sizei count, enum type,
const void *indices, sizei primcount);
void VertexAttribDivisorANGLE(uint index, uint divisor);
Additions to Chapter 2 of the OpenGL ES 2.0 Specification
(OpenGL ES Operation)
Modify section 2.8 (Vertex Arrays), p. 21
After description of EnableVertexAttribArray / DisableVertexAttribArray
add the following:
"The command
void VertexAttribDivisorANGLE(uint index, uint divisor);
modifies the rate at which generic vertex attributes advance when
rendering multiple instances of primitives in a single draw call
(see DrawArraysInstancedANGLE and DrawElementsInstancedANGLE below).
If <divisor> is zero, the attribute at slot <index> advances once
per vertex. If <divisor> is non-zero, the attribute advances once
per <divisor> instances of the primitives being rendered.
An attribute is referred to as "instanced" if its <divisor> value is
non-zero."
Replace the text describing DrawArrays and DrawElements in the
"Transferring Array Elements" subsection of 2.8, from the second paragraph
through the end of the section with the following:
"The command
void DrawArraysOneInstance( enum mode, int first, sizei count, int instance );
does not exist in the GL, but is used to describe functionality in
the rest of this section. This function constructs a sequence of
geometric primitives by transferring elements <first> through <first> +
<count> - 1 of each enabled non-instanced array to the GL. <mode>
specifies what kind of primitives are constructed, as defined in section
2.6.1.
If an enabled vertex attribute array is instanced (it has a non-zero
attribute <divisor> as specified by VertexAttribDivisorANGLE), the element
that is transferred to the GL is given by:
floor( <instance> / <divisor> ).
If an array corresponding to a generic attribute required by a vertex shader
is not enabled, then the corresponding element is taken from the current
generic attribute state (see section 2.7).
If an array corresponding to a generic attribute required by a vertex shader
is enabled, the corresponding current generic attribute value is unaffected
by the execution of DrawArraysOneInstance.
Specifying <first> < 0 results in undefined behavior. Generating the error
INVALID_VALUE is recommended in this case.
The command
void DrawArrays( enum mode, int first, sizei count );
is equivalent to the command sequence
DrawArraysOneInstance(mode, first, count, 0);
The command
void DrawArraysInstancedANGLE(enum mode, int first, sizei count,
sizei primcount);
behaves identically to DrawArrays except that <primcount>
instances of the range of elements are executed, and the
<instance> advances for each iteration. Instanced attributes that
have <divisor> N, (where N > 0, as specified by
VertexAttribDivisorANGLE) advance once every N instances.
It has the same effect as:
if (mode, count, or primcount is invalid)
generate appropriate error
else {
for (i = 0; i < primcount; i++) {
DrawArraysOneInstance(mode, first, count, i);
}
}
The command
void DrawElementsOneInstance( enum mode, sizei count, enum type,
void *indices, int instance );
does not exist in the GL, but is used to describe functionality in
the rest of this section. This command constructs a sequence of
geometric primitives by successively transferring the <count> elements
whose indices are stored in the currently bound element array buffer
(see section 2.9.2) at the offset defined by <indices> to the GL.
The <i>-th element transferred by DrawElementsOneInstance will be taken
from element <indices>[i] of each enabled non-instanced array.
<type> must be one of UNSIGNED_BYTE, UNSIGNED_SHORT, or UNSIGNED_INT,
indicating that the index values are of GL type ubyte, ushort, or uint
respectively. <mode> specifies what kind of primitives are constructed,
as defined in section 2.6.1.
If an enabled vertex attribute array is instanced (it has a non-zero
attribute <divisor> as specified by VertexAttribDivisorANGLE), the element
that is transferred to the GL is given by:
floor( <instance> / <divisor> );
If an array corresponding to a generic attribute required by a vertex
shader is not enabled, then the corresponding element is taken from the
current generic attribute state (see section 2.7). Otherwise, if an array
is enabled, the corresponding current generic attribute value is
unaffected by the execution of DrawElementsOneInstance.
The command
void DrawElements( enum mode, sizei count, enum type,
const void *indices);
behaves identically to DrawElementsOneInstance with the <instance>
parameter set to zero; the effect of calling
DrawElements(mode, count, type, indices);
is equivalent to the command sequence:
if (mode, count or type is invalid )
generate appropriate error
else
DrawElementsOneInstance(mode, count, type, indices, 0);
The command
void DrawElementsInstancedANGLE(enum mode, sizei count, enum type,
const void *indices, sizei primcount);
behaves identically to DrawElements except that <primcount>
instances of the set of elements are executed and the instance
advances between each set. Instanced attributes are advanced as they do
during the execution of DrawArraysInstancedANGLE. It has the same effect as:
if (mode, count, primcount, or type is invalid )
generate appropriate error
else {
for (int i = 0; i < primcount; i++) {
DrawElementsOneInstance(mode, count, type, indices, i);
}
}
If the number of supported generic vertex attributes (the value of
MAX_VERTEX_ATTRIBS) is <n>, then the client state required to implement
vertex arrays consists of <n> boolean values, <n> memory pointers, <n>
integer stride values, <n> symbolic constants representing array types,
<n> integers representing values per element, <n> boolean values
indicating normalization, and <n> integers representing vertex attribute
divisors.
In the initial state, the boolean values are each false, the memory
pointers are each NULL, the strides are each zero, the array types are
each FLOAT, the integers representing values per element are each four,
and the divisors are each zero."
Additions to Chapter 3 of the OpenGL ES 2.0 Specification (Rasterization)
None
Additions to Chapter 4 of the OpenGL ES 2.0 Specification (Per-Fragment
Operations and the Framebuffer)
None
Additions to Chapter 5 of the OpenGL ES 2.0 Specification (Special Functions)
None
Additions to Chapter 6 of the OpenGL ES 2.0 Specification (State and State
Requests)
In section 6.1.8, add VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE to the list of
pnames accepted by GetVertexAttribfv and GetVertexAttribiv.
Additions to the AGL/EGL/GLX/WGL Specifications
None
Dependencies on OES_element_index_uint
If OES_element_index_uint is not supported, removed all references
to UNSIGNED_INT indices and the associated GL data type uint in
the description of DrawElementsOneInstance.
Errors
INVALID_VALUE is generated by VertexAttribDivisorANGLE if <index>
is greater than or equal to MAX_VERTEX_ATTRIBS.
INVALID_ENUM is generated by DrawElementsInstancedANGLE if <type> is
not one of UNSIGNED_BYTE, UNSIGNED_SHORT or UNSIGNED_INT.
INVALID_VALUE is generated by DrawArraysInstancedANGLE if <first>,
<count>, or <primcount> is less than zero.
INVALID_ENUM is generated by DrawArraysInstancedANGLE or
DrawElementsInstancedANGLE if <mode> is not one of the modes described in
section 2.6.1.
INVALID_VALUE is generated by DrawElementsInstancedANGLE if <count> or
<primcount> is less than zero.
INVALID_OPERATION is generated by DrawArraysInstancedANGLE or
DrawElementsInstancedANGLE if there is not at least one enabled
vertex attribute array that has a <divisor> of zero and is bound to an
active generic attribute value in the program used for the draw command.
New State
Changes to table 6.7, p. 268 (Vertex Array Data)
Initial
Get Value Type Get Command Value Description Sec.
--------- ----- ----------- ------- ----------- ----
VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE 8*xZ+ GetVertexAttrib 0 Instance Divisor 2.8
Issues
1) Should vertex attribute zero be instance-able?
Resolved: Yes.
Discussion: In Direct3D 9 stream 0 must be specified as indexed data
and it cannot be instanced. In ANGLE we can work around this by
remapping any other stream that does have indexed data (ie a zero
attribute divisor) to stream 0 in D3D9. This works because the HLSL
vertex shader matches attributes against the stream by using the
shader semantic index.
2) Can all vertex attributes be instanced simultaneously?
Resolved: No
Discussion: In rare cases it is possible for no attribute to have a
divisor of 0, meaning that all attributes are instanced and none of
them are regularly indexed. This in turn means each instance can only
have a single position element, and so it only actually renders
something when rendering point primitives. This is not a very
meaningful way of using instancing (which is likely why D3D restricts
stream 0 to be indexed regularly for position data in the first place).
We could implement it by drawing these points one at a time (essentially
emulating instancing), but it would not be very efficient and there
seems to be little-to-no value in doing so.
If all of the enabled vertex attribute arrays that are bound to active
generic attributes in the program have a non-zero divisor, the draw
call should return INVALID_OPERATION.
3) Direct3D 9 only supports instancing for DrawIndexedPrimitive which
corresponds to DrawElementsInstanced. Should we support
DrawArraysInstanced?
Resolved: Yes
Discussion: This can be supported easily enough by simply manufacturing
a linear index buffer of sufficient size and using that to do indexed
D3D9 drawing.
4) How much data is needed in a buffer for an instanced attribute?
Resolved: Where stride is the value passed to VertexAttribPointer:
if stride > 0
size = stride * ceil(primcount / divisor);
else
size = elementsize * ceil(primcount / divisor);
Revision History
#3 February 8, 2012 dgkoch
- clarify Issue 3 and the error condition for no indexed attributes
#2 January 24, 2012 dgkoch
- fix typos, add clarifications, and more errors
#1 January 17, 2012 dgkoch
- initial GLES2 version from ARB_instanced_arrays

View File

@ -18,16 +18,16 @@ Contributors
Status Status
XXX - Not complete yet!!! Implemented in ANGLE ES2
Version Version
Last Modified Date: November 22, 2011 Last Modified Date: February 22, 2011
Author Revision: 1 Author Revision: 22
Number Number
XXX not yet TBD
Dependencies Dependencies
@ -59,9 +59,6 @@ IP Status
No known IP claims. No known IP claims.
Issues
New Procedures and Functions New Procedures and Functions
None None
@ -108,6 +105,8 @@ Additions to Chapter 3 of the OpenGL 3.2 Specification (Rasterization)
is packed in the same manner as when PACK_REVERSE_ROW_ORDER_ANGLE is is packed in the same manner as when PACK_REVERSE_ROW_ORDER_ANGLE is
FALSE. FALSE.
Additions to Chapter 6 of the OpenGL 3.2 Specification (State and State Requests)
In Section 6.1.4 add the following sentence to the fifth paragraph In Section 6.1.4 add the following sentence to the fifth paragraph
(beginning with "For three-dimensional and two-dimensional array (beginning with "For three-dimensional and two-dimensional array
textures..."): textures..."):
@ -142,23 +141,29 @@ New Implementation Dependent State
None None
Issues
None
Sample Code Sample Code
/* Allocate space to hold the pixel data */ /* Allocate space to hold the pixel data */
const GLvoid* pixels = malloc(width * height * 4); const GLvoid* pixels = malloc(width * height * 4);
/* Bind the framebuffer object to be read */ /* Bind the framebuffer object to be read */
glBindFramebuffer(READ_FRAMEBUFFER, framebuffer); glBindFramebuffer(GL_READ_FRAMEBUFFER, framebuffer);
/* Enable row order reversal */ /* Enable row order reversal */
glPixelStore(PACK_REVERSE_ROW_ORDER_ANGLE, TRUE); glPixelStore(GL_PACK_REVERSE_ROW_ORDER_ANGLE, TRUE);
/* The pixel data stored in pixels will be in top-down order, ready for /* The pixel data stored in pixels will be in top-down order, ready for
* use with a windowing system API that expects this order. * use with a windowing system API that expects this order.
*/ */
glReadPixels(x, y, width, height, RGBA, UNSIGNED_BYTE, pixels); glReadPixels(x, y, width, height, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
Revision History Revision History
Revision 1, 2011/11/22 (Brian Salomon) Revision 1, 2011/11/22 (Brian Salomon)
- First version - First version
Revision 2, 2012/02/22 (dgkoch)
- prepare for publishing

View File

@ -233,6 +233,11 @@ typedef void* GLeglImageOES;
#define GL_FRAMEBUFFER_ATTACHMENT_ANGLE 0x93A3 #define GL_FRAMEBUFFER_ATTACHMENT_ANGLE 0x93A3
#endif #endif
/* GL_ANGLE_instanced_arrays */
#ifndef GL_ANGLE_instanced_arrays
#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE 0x88FE
#endif
/*------------------------------------------------------------------------* /*------------------------------------------------------------------------*
* APPLE extension tokens * APPLE extension tokens
*------------------------------------------------------------------------*/ *------------------------------------------------------------------------*/
@ -951,6 +956,19 @@ typedef void (GL_APIENTRYP PFNGLGETTRANSLATEDSHADERSOURCEANGLEPROC) (GLuint shad
#define GL_ANGLE_texture_usage 1 #define GL_ANGLE_texture_usage 1
#endif #endif
/* GL_ANGLE_instanced_arrays */
#ifndef GL_ANGLE_instanced_arrays
#define GL_ANGLE_instanced_arrays 1
#ifdef GL_GLEXT_PROTOTYPES
GL_APICALL void GL_APIENTRY glVertexAttribDivisorANGLE(GLuint index, GLuint divisor);
GL_APICALL void GL_APIENTRY glDrawArraysInstancedANGLE(GLenum mode, GLint first, GLsizei count, GLsizei primcount);
GL_APICALL void GL_APIENTRY glDrawElementsInstancedANGLE(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount);
#endif
typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBDIVISORANGLEPROC) (GLuint index, GLuint divisor);
typedef void (GL_APIENTRYP PFNGLDRAWARRAYSINSTANCEDANGLEPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount);
typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDANGLEPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount);
#endif
/*------------------------------------------------------------------------* /*------------------------------------------------------------------------*
* APPLE extension functions * APPLE extension functions
*------------------------------------------------------------------------*/ *------------------------------------------------------------------------*/

View File

@ -17,31 +17,31 @@
'translator/translator.cpp', 'translator/translator.cpp',
], ],
}, },
{
'target_name': 'essl_to_hlsl',
'type': 'executable',
'dependencies': [
'../src/build_angle.gyp:translator_hlsl',
],
'include_dirs': [
'../include',
'../src',
],
'sources': [
'translator/translator.cpp',
'../src/common/debug.cpp',
],
'msvs_settings': {
'VCLinkerTool': {
'AdditionalLibraryDirectories': ['$(DXSDK_DIR)/lib/x86'],
'AdditionalDependencies': ['d3d9.lib'],
}
}
},
], ],
'conditions': [ 'conditions': [
['OS=="win"', { ['OS=="win"', {
'targets': [ 'targets': [
{
'target_name': 'essl_to_hlsl',
'type': 'executable',
'dependencies': [
'../src/build_angle.gyp:translator_hlsl',
],
'include_dirs': [
'../include',
'../src',
],
'sources': [
'translator/translator.cpp',
'../src/common/debug.cpp',
],
'msvs_settings': {
'VCLinkerTool': {
'AdditionalLibraryDirectories': ['$(DXSDK_DIR)/lib/x86'],
'AdditionalDependencies': ['d3d9.lib'],
}
}
},
{ {
'target_name': 'es_util', 'target_name': 'es_util',
'type': 'static_library', 'type': 'static_library',

View File

@ -171,7 +171,7 @@ esOrtho(ESMatrix *result, float left, float right, float bottom, float top, floa
void ESUTIL_API void ESUTIL_API
esMatrixMultiply(ESMatrix *result, ESMatrix *srcA, ESMatrix *srcB) esMatrixMultiply(ESMatrix *result, ESMatrix *srcA, ESMatrix *srcB)
{ {
ESMatrix tmp; ESMatrix tmp = { 0.0f };
int i; int i;
for (i=0; i<4; i++) for (i=0; i<4; i++)

View File

@ -26,6 +26,9 @@
#include "esUtil.h" #include "esUtil.h"
#include "esUtil_win.h" #include "esUtil_win.h"
#if defined(_MSC_VER)
#pragma warning(disable: 4204) // nonstandard extension used : non-constant aggregate initializer
#endif
/// ///
// Extensions // Extensions

View File

@ -151,7 +151,7 @@ GLuint CreateMipMappedTexture2D( )
int level; int level;
GLubyte *pixels; GLubyte *pixels;
GLubyte *prevImage; GLubyte *prevImage;
GLubyte *newImage; GLubyte *newImage = NULL;
pixels = GenCheckImage( width, height, 8 ); pixels = GenCheckImage( width, height, 8 );
if ( pixels == NULL ) if ( pixels == NULL )

View File

@ -219,7 +219,8 @@ ShShaderType FindShaderType(const char* fileName)
if (ext && strcmp(ext, ".sl") == 0) if (ext && strcmp(ext, ".sl") == 0)
for (; ext > fileName && ext[0] != '.'; ext--); for (; ext > fileName && ext[0] != '.'; ext--);
if (ext = strrchr(fileName, '.')) { ext = strrchr(fileName, '.');
if (ext) {
if (strncmp(ext, ".frag", 4) == 0) return SH_FRAGMENT_SHADER; if (strncmp(ext, ".frag", 4) == 0) return SH_FRAGMENT_SHADER;
if (strncmp(ext, ".vert", 4) == 0) return SH_VERTEX_SHADER; if (strncmp(ext, ".vert", 4) == 0) return SH_VERTEX_SHADER;
} }

View File

@ -3,9 +3,6 @@
# found in the LICENSE file. # found in the LICENSE file.
{ {
'variables': {
'chromium_code': 1,
},
'target_defaults': { 'target_defaults': {
'defines': [ 'defines': [
'ANGLE_DISABLE_TRACE', 'ANGLE_DISABLE_TRACE',
@ -13,9 +10,27 @@
], ],
}, },
'targets': [ 'targets': [
{
'target_name': 'preprocessor',
'type': 'static_library',
'include_dirs': [
],
'sources': [
'compiler/preprocessor/new/Input.cpp',
'compiler/preprocessor/new/Input.h',
'compiler/preprocessor/new/Lexer.cpp',
'compiler/preprocessor/new/Lexer.h',
'compiler/preprocessor/new/pp_lex.cpp',
'compiler/preprocessor/new/Preprocessor.cpp',
'compiler/preprocessor/new/Preprocessor.h',
'compiler/preprocessor/new/Token.cpp',
'compiler/preprocessor/new/Token.h',
],
},
{ {
'target_name': 'translator_common', 'target_name': 'translator_common',
'type': 'static_library', 'type': 'static_library',
'dependencies': ['preprocessor'],
'include_dirs': [ 'include_dirs': [
'.', '.',
'../include', '../include',
@ -76,6 +91,7 @@
'compiler/ValidateLimitations.h', 'compiler/ValidateLimitations.h',
'compiler/VariableInfo.cpp', 'compiler/VariableInfo.cpp',
'compiler/VariableInfo.h', 'compiler/VariableInfo.h',
# Old preprocessor
'compiler/preprocessor/atom.c', 'compiler/preprocessor/atom.c',
'compiler/preprocessor/atom.h', 'compiler/preprocessor/atom.h',
'compiler/preprocessor/compile.h', 'compiler/preprocessor/compile.h',
@ -83,6 +99,8 @@
'compiler/preprocessor/cpp.h', 'compiler/preprocessor/cpp.h',
'compiler/preprocessor/cppstruct.c', 'compiler/preprocessor/cppstruct.c',
'compiler/preprocessor/length_limits.h', 'compiler/preprocessor/length_limits.h',
'compiler/preprocessor/lexer_glue.cpp',
'compiler/preprocessor/lexer_glue.h',
'compiler/preprocessor/memory.c', 'compiler/preprocessor/memory.c',
'compiler/preprocessor/memory.h', 'compiler/preprocessor/memory.h',
'compiler/preprocessor/parser.h', 'compiler/preprocessor/parser.h',
@ -131,34 +149,34 @@
'compiler/VersionGLSL.h', 'compiler/VersionGLSL.h',
], ],
}, },
{
'target_name': 'translator_hlsl',
'type': '<(component)',
'dependencies': ['translator_common'],
'include_dirs': [
'.',
'../include',
],
'defines': [
'COMPILER_IMPLEMENTATION',
],
'sources': [
'compiler/ShaderLang.cpp',
'compiler/CodeGenHLSL.cpp',
'compiler/OutputHLSL.cpp',
'compiler/OutputHLSL.h',
'compiler/TranslatorHLSL.cpp',
'compiler/TranslatorHLSL.h',
'compiler/UnfoldSelect.cpp',
'compiler/UnfoldSelect.h',
'compiler/SearchSymbol.cpp',
'compiler/SearchSymbol.h',
],
},
], ],
'conditions': [ 'conditions': [
['OS=="win"', { ['OS=="win"', {
'targets': [ 'targets': [
{
'target_name': 'translator_hlsl',
'type': '<(component)',
'dependencies': ['translator_common'],
'include_dirs': [
'.',
'../include',
],
'defines': [
'COMPILER_IMPLEMENTATION',
],
'sources': [
'compiler/ShaderLang.cpp',
'compiler/CodeGenHLSL.cpp',
'compiler/OutputHLSL.cpp',
'compiler/OutputHLSL.h',
'compiler/TranslatorHLSL.cpp',
'compiler/TranslatorHLSL.h',
'compiler/UnfoldSelect.cpp',
'compiler/UnfoldSelect.h',
'compiler/SearchSymbol.cpp',
'compiler/SearchSymbol.h',
],
},
{ {
'target_name': 'libGLESv2', 'target_name': 'libGLESv2',
'type': 'shared_library', 'type': 'shared_library',

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