зеркало из https://github.com/mozilla/gecko-dev.git
Merge m-c to fx-team
This commit is contained in:
Коммит
9b91de51f1
|
@ -39,16 +39,6 @@ HyperTextAccessible::IsValidRange(int32_t aStartOffset, int32_t aEndOffset)
|
|||
return endOffset <= static_cast<int32_t>(CharacterCount());
|
||||
}
|
||||
|
||||
inline nsIntRect
|
||||
HyperTextAccessible::TextBounds(int32_t aStartOffset, int32_t aEndOffset,
|
||||
uint32_t aCoordType)
|
||||
{
|
||||
nsIntRect bounds;
|
||||
GetPosAndText(aStartOffset, aEndOffset, nullptr, nullptr, &bounds);
|
||||
nsAccUtils::ConvertScreenCoordsTo(&bounds.x, &bounds.y, aCoordType, this);
|
||||
return bounds;
|
||||
}
|
||||
|
||||
inline bool
|
||||
HyperTextAccessible::AddToSelection(int32_t aStartOffset, int32_t aEndOffset)
|
||||
{
|
||||
|
|
|
@ -117,19 +117,18 @@ HyperTextAccessible::NativeState()
|
|||
return states;
|
||||
}
|
||||
|
||||
// Substring must be entirely within the same text node
|
||||
nsIntRect
|
||||
HyperTextAccessible::GetBoundsForString(nsIFrame* aFrame, uint32_t aStartRenderedOffset,
|
||||
uint32_t aEndRenderedOffset)
|
||||
HyperTextAccessible::GetBoundsInFrame(nsIFrame* aFrame,
|
||||
uint32_t aStartRenderedOffset,
|
||||
uint32_t aEndRenderedOffset)
|
||||
{
|
||||
nsPresContext* presContext = mDoc->PresContext();
|
||||
if (aFrame->GetType() != nsGkAtoms::textFrame) {
|
||||
// XXX fallback for non-text frames, happens for bullets right now
|
||||
// but in the future bullets will have proper text frames
|
||||
return aFrame->GetScreenRectInAppUnits().
|
||||
ToNearestPixels(presContext->AppUnitsPerDevPixel());
|
||||
}
|
||||
|
||||
// Substring must be entirely within the same text node.
|
||||
int32_t startContentOffset, endContentOffset;
|
||||
nsresult rv = RenderedToContentOffset(aFrame, aStartRenderedOffset, &startContentOffset);
|
||||
NS_ENSURE_SUCCESS(rv, nsIntRect());
|
||||
|
@ -189,7 +188,6 @@ HyperTextAccessible::GetBoundsForString(nsIFrame* aFrame, uint32_t aStartRendere
|
|||
nsIFrame*
|
||||
HyperTextAccessible::GetPosAndText(int32_t& aStartOffset, int32_t& aEndOffset,
|
||||
nsAString* aText, nsIFrame** aEndFrame,
|
||||
nsIntRect* aBoundsRect,
|
||||
Accessible** aStartAcc,
|
||||
Accessible** aEndAcc)
|
||||
{
|
||||
|
@ -218,9 +216,6 @@ HyperTextAccessible::GetPosAndText(int32_t& aStartOffset, int32_t& aEndOffset,
|
|||
if (aEndFrame) {
|
||||
*aEndFrame = nullptr;
|
||||
}
|
||||
if (aBoundsRect) {
|
||||
aBoundsRect->SetEmpty();
|
||||
}
|
||||
if (aStartAcc)
|
||||
*aStartAcc = nullptr;
|
||||
if (aEndAcc)
|
||||
|
@ -243,7 +238,6 @@ HyperTextAccessible::GetPosAndText(int32_t& aStartOffset, int32_t& aEndOffset,
|
|||
if (!frame) {
|
||||
continue;
|
||||
}
|
||||
nsIFrame *primaryFrame = frame;
|
||||
endFrame = frame;
|
||||
if (!nsAccUtils::IsEmbeddedObject(childAcc)) {
|
||||
// We only need info up to rendered offset -- that is what we're
|
||||
|
@ -304,11 +298,6 @@ HyperTextAccessible::GetPosAndText(int32_t& aStartOffset, int32_t& aEndOffset,
|
|||
substringEndOffset - startOffset);
|
||||
}
|
||||
}
|
||||
if (aBoundsRect) { // Caller wants the bounds of the text
|
||||
aBoundsRect->UnionRect(*aBoundsRect,
|
||||
GetBoundsForString(primaryFrame, startOffset,
|
||||
substringEndOffset));
|
||||
}
|
||||
if (!startFrame) {
|
||||
startFrame = frame;
|
||||
aStartOffset = startOffset;
|
||||
|
@ -347,11 +336,6 @@ HyperTextAccessible::GetPosAndText(int32_t& aStartOffset, int32_t& aEndOffset,
|
|||
*aText += kEmbeddedObjectChar;
|
||||
}
|
||||
}
|
||||
if (aBoundsRect) {
|
||||
nsIntRect frameScreenRect = frame->GetScreenRectInAppUnits().
|
||||
ToNearestPixels(frame->PresContext()->AppUnitsPerDevPixel());
|
||||
aBoundsRect->UnionRect(*aBoundsRect, frameScreenRect);
|
||||
}
|
||||
}
|
||||
if (!startFrame) {
|
||||
startFrame = frame;
|
||||
|
@ -595,7 +579,7 @@ HyperTextAccessible::HypertextOffsetsToDOMRange(int32_t aStartHTOffset,
|
|||
int32_t startOffset = aStartHTOffset, endOffset = aEndHTOffset;
|
||||
nsIFrame *startFrame = nullptr, *endFrame = nullptr;
|
||||
|
||||
startFrame = GetPosAndText(startOffset, endOffset, nullptr, &endFrame, nullptr,
|
||||
startFrame = GetPosAndText(startOffset, endOffset, nullptr, &endFrame,
|
||||
getter_AddRefs(startAcc), getter_AddRefs(endAcc));
|
||||
if (!startAcc || !endAcc)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
@ -697,7 +681,7 @@ HyperTextAccessible::FindOffset(int32_t aOffset, nsDirection aDirection,
|
|||
nsRefPtr<Accessible> accAtOffset;
|
||||
nsIFrame* frameAtOffset =
|
||||
GetPosAndText(offsetInFrame, notUsedOffset, nullptr, nullptr,
|
||||
nullptr, getter_AddRefs(accAtOffset));
|
||||
getter_AddRefs(accAtOffset));
|
||||
if (!frameAtOffset) {
|
||||
if (aOffset == CharacterCount()) {
|
||||
// Asking for start of line, while on last character.
|
||||
|
@ -1219,6 +1203,44 @@ HyperTextAccessible::OffsetAtPoint(int32_t aX, int32_t aY, uint32_t aCoordType)
|
|||
return -1; // Not found
|
||||
}
|
||||
|
||||
nsIntRect
|
||||
HyperTextAccessible::TextBounds(int32_t aStartOffset, int32_t aEndOffset,
|
||||
uint32_t aCoordType)
|
||||
{
|
||||
int32_t startOffset = ConvertMagicOffset(aStartOffset);
|
||||
int32_t endOffset = ConvertMagicOffset(aEndOffset);
|
||||
NS_ASSERTION(startOffset < endOffset, "Wrong bad in!");
|
||||
|
||||
int32_t childIdx = GetChildIndexAtOffset(startOffset);
|
||||
if (childIdx == -1)
|
||||
return nsIntRect();
|
||||
|
||||
nsIntRect bounds;
|
||||
int32_t prevOffset = GetChildOffset(childIdx);
|
||||
int32_t offset1 = startOffset - prevOffset;
|
||||
|
||||
while (childIdx < ChildCount()) {
|
||||
nsIFrame* frame = GetChildAt(childIdx)->GetFrame();
|
||||
|
||||
childIdx++;
|
||||
int32_t nextOffset = GetChildOffset(childIdx);
|
||||
if (nextOffset >= endOffset) {
|
||||
bounds.UnionRect(bounds, GetBoundsInFrame(frame, offset1,
|
||||
endOffset - prevOffset));
|
||||
break;
|
||||
}
|
||||
|
||||
bounds.UnionRect(bounds, GetBoundsInFrame(frame, offset1,
|
||||
nextOffset - prevOffset));
|
||||
|
||||
prevOffset = nextOffset;
|
||||
offset1 = 0;
|
||||
}
|
||||
|
||||
nsAccUtils::ConvertScreenCoordsTo(&bounds.x, &bounds.y, aCoordType, this);
|
||||
return bounds;
|
||||
}
|
||||
|
||||
already_AddRefed<nsIEditor>
|
||||
HyperTextAccessible::GetEditor() const
|
||||
{
|
||||
|
|
|
@ -473,8 +473,6 @@ protected:
|
|||
* @param aText [out, optional] return the substring's text
|
||||
* @param aEndFrame [out, optional] return the end frame for this
|
||||
* substring
|
||||
* @param aBoundsRect [out, optional] return the bounds rectangle for this
|
||||
* substring
|
||||
* @param aStartAcc [out, optional] return the start accessible for this
|
||||
* substring
|
||||
* @param aEndAcc [out, optional] return the end accessible for this
|
||||
|
@ -484,11 +482,16 @@ protected:
|
|||
nsIFrame* GetPosAndText(int32_t& aStartOffset, int32_t& aEndOffset,
|
||||
nsAString *aText = nullptr,
|
||||
nsIFrame **aEndFrame = nullptr,
|
||||
nsIntRect *aBoundsRect = nullptr,
|
||||
Accessible** aStartAcc = nullptr,
|
||||
Accessible** aEndAcc = nullptr);
|
||||
|
||||
nsIntRect GetBoundsForString(nsIFrame *aFrame, uint32_t aStartRenderedOffset, uint32_t aEndRenderedOffset);
|
||||
/**
|
||||
* Return the boundaries of the substring in case of textual frame or
|
||||
* frame boundaries in case of non textual frame, offsets are ignored.
|
||||
*/
|
||||
nsIntRect GetBoundsInFrame(nsIFrame* aFrame,
|
||||
uint32_t aStartRenderedOffset,
|
||||
uint32_t aEndRenderedOffset);
|
||||
|
||||
// Selection helpers
|
||||
|
||||
|
|
|
@ -232,7 +232,7 @@ ia2AccessibleText::get_textBeforeOffset(long aOffset,
|
|||
if (textAcc->IsDefunct())
|
||||
return CO_E_OBJNOTCONNECTED;
|
||||
|
||||
if (textAcc->IsValidOffset(aOffset))
|
||||
if (!textAcc->IsValidOffset(aOffset))
|
||||
return E_INVALIDARG;
|
||||
|
||||
nsAutoString text;
|
||||
|
@ -281,7 +281,7 @@ ia2AccessibleText::get_textAfterOffset(long aOffset,
|
|||
if (textAcc->IsDefunct())
|
||||
return CO_E_OBJNOTCONNECTED;
|
||||
|
||||
if (textAcc->IsValidOffset(aOffset))
|
||||
if (!textAcc->IsValidOffset(aOffset))
|
||||
return E_INVALIDARG;
|
||||
|
||||
nsAutoString text;
|
||||
|
@ -328,7 +328,7 @@ ia2AccessibleText::get_textAtOffset(long aOffset,
|
|||
if (textAcc->IsDefunct())
|
||||
return CO_E_OBJNOTCONNECTED;
|
||||
|
||||
if (textAcc->IsValidOffset(aOffset))
|
||||
if (!textAcc->IsValidOffset(aOffset))
|
||||
return E_INVALIDARG;
|
||||
|
||||
nsAutoString text;
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
src="../events.js"></script>
|
||||
|
||||
<script type="application/javascript">
|
||||
SimpleTest.expectAssertions(0, 1);
|
||||
|
||||
var gFocusHandler = {
|
||||
handleEvent: function(aEvent) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{
|
||||
"revision": "aac07cb753d6c364c3cbd39ad8116d455d5adf01",
|
||||
"revision": "fefcf4aab784c6e9a0c8b3f4b282c21fb0e0ac6e",
|
||||
"repo_path": "/integration/gaia-central"
|
||||
}
|
||||
|
|
|
@ -6,140 +6,36 @@
|
|||
|
||||
#expand <menu id="__ID_PREFIX__charsetMenu"
|
||||
label="&charsetMenu.label;"
|
||||
#ifndef OMIT_ACCESSKEYS
|
||||
accesskey="&charsetMenu.accesskey;"
|
||||
#endif
|
||||
datasources="rdf:charset-menu"
|
||||
ref="NC:BrowserCharsetMenuRoot"
|
||||
oncommand="MultiplexHandler(event)"
|
||||
onpopupshowing="CreateMenu('browser'); CreateMenu('more-menu');"
|
||||
onpopupshown="UpdateMenus(event);"
|
||||
observes="isImage">
|
||||
<template>
|
||||
<rule rdf:type="http://home.netscape.com/NC-rdf#BookmarkSeparator">
|
||||
<menupopup>
|
||||
<menuseparator uri="..." />
|
||||
</menupopup>
|
||||
</rule>
|
||||
<rule>
|
||||
<menupopup>
|
||||
<menuitem type="radio" name="charsetGroup" checked="rdf:http://home.netscape.com/NC-rdf#Checked" uri="..." label="rdf:http://home.netscape.com/NC-rdf#Name"/>
|
||||
</menupopup>
|
||||
</rule>
|
||||
</template>
|
||||
|
||||
onpopupshowing="CharsetMenu.build(event);"
|
||||
onpopupshown="UpdateMenus(event);">
|
||||
<menupopup>
|
||||
<menu label="&charsetMenuAutodet.label;"
|
||||
#ifndef OMIT_ACCESSKEYS
|
||||
accesskey="&charsetMenuAutodet.accesskey;"
|
||||
#endif
|
||||
datasources="rdf:charset-menu" ref="NC:BrowserAutodetMenuRoot">
|
||||
<template>
|
||||
<rule rdf:type="http://home.netscape.com/NC-rdf#CharsetDetector">
|
||||
<menupopup>
|
||||
<menuitem type="radio" name="detectorGroup" checked="rdf:http://home.netscape.com/NC-rdf#Checked" uri="..." label="rdf:http://home.netscape.com/NC-rdf#Name"/>
|
||||
</menupopup>
|
||||
</rule>
|
||||
</template>
|
||||
<menupopup>
|
||||
</menupopup>
|
||||
</menu>
|
||||
<menu label="&charsetMenuMore.label;"
|
||||
#ifndef OMIT_ACCESSKEYS
|
||||
accesskey="&charsetMenuMore.accesskey;"
|
||||
#endif
|
||||
datasources="rdf:charset-menu" ref="NC:BrowserMoreCharsetMenuRoot">
|
||||
<template>
|
||||
<rule>
|
||||
<menupopup>
|
||||
<menuitem uri="..." label="rdf:http://home.netscape.com/NC-rdf#Name"/>
|
||||
</menupopup>
|
||||
</rule>
|
||||
</template>
|
||||
<menupopup>
|
||||
<menu label="&charsetMenuMore1.label;"
|
||||
#ifndef OMIT_ACCESSKEYS
|
||||
accesskey="&charsetMenuMore1.accesskey;"
|
||||
#endif
|
||||
datasources="rdf:charset-menu" ref="NC:BrowserMore1CharsetMenuRoot">
|
||||
<template>
|
||||
<rule>
|
||||
<menupopup>
|
||||
<menuitem uri="..." label="rdf:http://home.netscape.com/NC-rdf#Name"/>
|
||||
</menupopup>
|
||||
</rule>
|
||||
</template>
|
||||
<menupopup>
|
||||
</menupopup>
|
||||
</menu>
|
||||
<menu label="&charsetMenuMore2.label;"
|
||||
#ifndef OMIT_ACCESSKEYS
|
||||
accesskey="&charsetMenuMore2.accesskey;"
|
||||
#endif
|
||||
datasources="rdf:charset-menu" ref="NC:BrowserMore2CharsetMenuRoot">
|
||||
<template>
|
||||
<rule>
|
||||
<menupopup>
|
||||
<menuitem uri="..." label="rdf:http://home.netscape.com/NC-rdf#Name"/>
|
||||
</menupopup>
|
||||
</rule>
|
||||
</template>
|
||||
<menupopup>
|
||||
</menupopup>
|
||||
</menu>
|
||||
<menu label="&charsetMenuMore3.label;"
|
||||
#ifndef OMIT_ACCESSKEYS
|
||||
accesskey="&charsetMenuMore3.accesskey;"
|
||||
#endif
|
||||
datasources="rdf:charset-menu" ref="NC:BrowserMore3CharsetMenuRoot">
|
||||
<template>
|
||||
<rule>
|
||||
<menupopup>
|
||||
<menuitem uri="..." label="rdf:http://home.netscape.com/NC-rdf#Name"/>
|
||||
</menupopup>
|
||||
</rule>
|
||||
</template>
|
||||
<menupopup>
|
||||
</menupopup>
|
||||
</menu>
|
||||
<menu label="&charsetMenuMore4.label;"
|
||||
#ifndef OMIT_ACCESSKEYS
|
||||
accesskey="&charsetMenuMore4.accesskey;"
|
||||
#endif
|
||||
datasources="rdf:charset-menu" ref="NC:BrowserMore4CharsetMenuRoot">
|
||||
<template>
|
||||
<rule>
|
||||
<menupopup>
|
||||
<menuitem uri="..." label="rdf:http://home.netscape.com/NC-rdf#Name"/>
|
||||
</menupopup>
|
||||
</rule>
|
||||
</template>
|
||||
<menupopup>
|
||||
</menupopup>
|
||||
</menu>
|
||||
<menu label="&charsetMenuMore5.label;"
|
||||
#ifndef OMIT_ACCESSKEYS
|
||||
accesskey="&charsetMenuMore5.accesskey;"
|
||||
#endif
|
||||
datasources="rdf:charset-menu" ref="NC:BrowserMore5CharsetMenuRoot">
|
||||
<template>
|
||||
<rule>
|
||||
<menupopup>
|
||||
<menuitem uri="..." label="rdf:http://home.netscape.com/NC-rdf#Name"/>
|
||||
</menupopup>
|
||||
</rule>
|
||||
</template>
|
||||
<menupopup>
|
||||
</menupopup>
|
||||
</menu>
|
||||
<menuseparator />
|
||||
</menupopup>
|
||||
</menu>
|
||||
<menuitem name="charsetCustomize"
|
||||
#ifndef OMIT_ACCESSKEYS
|
||||
accesskey="&charsetCustomize.accesskey;"
|
||||
#endif
|
||||
label="&charsetCustomize.label;"
|
||||
oncommand="window.openDialog('chrome://global/content/customizeCharset.xul', 'PrefWindow', 'chrome,modal=yes,resizable=yes', 'browser');"/>
|
||||
<menu label="&charsetMenuAutodet.label;"
|
||||
accesskey="&charsetMenuAutodet.accesskey;">
|
||||
<menupopup>
|
||||
<menuitem type="radio"
|
||||
name="detectorGroup"
|
||||
id="chardet.off"
|
||||
label="&charsetMenuAutodet.off.label;"
|
||||
accesskey="&charsetMenuAutodet.off.accesskey;"/>
|
||||
<menuitem type="radio"
|
||||
name="detectorGroup"
|
||||
id="chardet.ja_parallel_state_machine"
|
||||
label="&charsetMenuAutodet.ja.label;"
|
||||
accesskey="&charsetMenuAutodet.ja.accesskey;"/>
|
||||
<menuitem type="radio"
|
||||
name="detectorGroup"
|
||||
id="chardet.ruprob"
|
||||
label="&charsetMenuAutodet.ru.label;"
|
||||
accesskey="&charsetMenuAutodet.ru.accesskey;"/>
|
||||
<menuitem type="radio"
|
||||
name="detectorGroup"
|
||||
id="chardet.ukprob"
|
||||
label="&charsetMenuAutodet.uk.label;"
|
||||
accesskey="&charsetMenuAutodet.uk.accesskey;"/>
|
||||
</menupopup>
|
||||
</menu>
|
||||
<menuseparator/>
|
||||
</menupopup>
|
||||
</menu>
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
%browserDTD;
|
||||
<!ENTITY % baseMenuDTD SYSTEM "chrome://browser/locale/baseMenuOverlay.dtd" >
|
||||
%baseMenuDTD;
|
||||
<!ENTITY % charsetDTD SYSTEM "chrome://global/locale/charsetOverlay.dtd" >
|
||||
<!ENTITY % charsetDTD SYSTEM "chrome://browser/locale/charsetMenu.dtd" >
|
||||
%charsetDTD;
|
||||
<!ENTITY % textcontextDTD SYSTEM "chrome://global/locale/textcontext.dtd" >
|
||||
%textcontextDTD;
|
||||
|
|
|
@ -12,10 +12,11 @@ Cu.import("resource:///modules/RecentWindow.jsm");
|
|||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "Task",
|
||||
"resource://gre/modules/Task.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "CharsetMenu",
|
||||
"resource:///modules/CharsetMenu.jsm");
|
||||
|
||||
const nsIWebNavigation = Ci.nsIWebNavigation;
|
||||
|
||||
var gCharsetMenu = null;
|
||||
var gLastBrowserCharset = null;
|
||||
var gPrevCharset = null;
|
||||
var gProxyFavIcon = null;
|
||||
|
@ -5176,17 +5177,10 @@ function UpdateMenus(event) {
|
|||
UpdateCharsetDetector(event.target);
|
||||
}
|
||||
|
||||
function CreateMenu(node) {
|
||||
Services.obs.notifyObservers(null, "charsetmenu-selected", node);
|
||||
}
|
||||
|
||||
function charsetLoadListener() {
|
||||
var charset = window.content.document.characterSet;
|
||||
|
||||
if (charset.length > 0 && (charset != gLastBrowserCharset)) {
|
||||
if (!gCharsetMenu)
|
||||
gCharsetMenu = Cc['@mozilla.org/rdf/datasource;1?name=charset-menu'].getService(Ci.nsICurrentCharsetListener);
|
||||
gCharsetMenu.SetCurrentCharset(charset);
|
||||
gPrevCharset = gLastBrowserCharset;
|
||||
gLastBrowserCharset = charset;
|
||||
}
|
||||
|
|
|
@ -106,8 +106,6 @@
|
|||
|
||||
<panelview id="PanelUI-characterEncodingView" flex="1">
|
||||
<label value="&charsetMenu.label;"/>
|
||||
<toolbarbutton label="&charsetCustomize.label;"
|
||||
oncommand="PanelUI.onCharsetCustomizeCommand();"/>
|
||||
|
||||
<vbox id="PanelUI-characterEncodingView-customlist"
|
||||
class="PanelUI-characterEncodingView-list"/>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<!DOCTYPE html>
|
||||
<!DOCTYPE html>
|
||||
<!--
|
||||
Copyright 2012 Mozilla Foundation
|
||||
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
||||
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||
|
||||
<!ENTITY charsetMenu.label "Character Encoding">
|
||||
<!ENTITY charsetMenu.accesskey "C">
|
||||
<!ENTITY charsetMenuAutodet.label "Auto-Detect">
|
||||
<!ENTITY charsetMenuAutodet.accesskey "D"><!-- A reserved for Arabic -->
|
||||
|
||||
<!ENTITY charsetMenuAutodet.off.label "(off)">
|
||||
<!ENTITY charsetMenuAutodet.off.accesskey "o">
|
||||
<!ENTITY charsetMenuAutodet.ja.label "Japanese">
|
||||
<!ENTITY charsetMenuAutodet.ja.accesskey "J">
|
||||
<!ENTITY charsetMenuAutodet.ru.label "Russian">
|
||||
<!ENTITY charsetMenuAutodet.ru.accesskey "R">
|
||||
<!ENTITY charsetMenuAutodet.uk.label "Ukranian">
|
||||
<!ENTITY charsetMenuAutodet.uk.accesskey "U">
|
||||
|
|
@ -0,0 +1,105 @@
|
|||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
# LOCALIZATION NOTE: The property keys ending with ".key" are for access keys.
|
||||
# Localizations may add or delete properties where the property key ends with
|
||||
# ".key" as appropriate for the localization. The code that uses this data can
|
||||
# deal with the absence of an access key for an item.
|
||||
#
|
||||
# Make sure the keys defined here don't collide with
|
||||
# charsetMenuAutodet.accesskey in charsetMenu.dtd.
|
||||
#
|
||||
# In the en-US version of this file, access keys are given to the following:
|
||||
# * UTF-8
|
||||
# * All encodings that are the fallback encoding for some locale in Firefox
|
||||
# * All encodings that are the fallback encoding for some locale in IE
|
||||
# * All Japanese encodings
|
||||
#
|
||||
# For the items whose property key does not end in ".key" and whose value
|
||||
# includes "(" U+0028 LEFT PARENTHESIS, the "(" character is significant for
|
||||
# processing by CharsetMenu.jsm. If your localization does not use ASCII
|
||||
# parentheses where en-US does in this file, please file a bug to make
|
||||
# CharsetMenu.jsm also recognize the delimiter your localization uses.
|
||||
# (When this code was developed, all localizations appeared to use
|
||||
# U+0028 LEFT PARENTHESIS for this purpose.)
|
||||
|
||||
# Globally-relevant
|
||||
UTF-8.key = U
|
||||
UTF-8 = Unicode
|
||||
windows-1252.key = W
|
||||
windows-1252 = Western
|
||||
|
||||
# Arabic
|
||||
windows-1256.key = A
|
||||
windows-1256 = Arabic (Windows)
|
||||
ISO-8859-6 = Arabic (ISO)
|
||||
|
||||
# Baltic
|
||||
windows-1257.key = B
|
||||
windows-1257 = Baltic (Windows)
|
||||
ISO-8859-4 = Baltic (ISO)
|
||||
|
||||
# Central European
|
||||
windows-1250.key = E
|
||||
windows-1250 = Central European (Windows)
|
||||
ISO-8859-2.key = l
|
||||
ISO-8859-2 = Central European (ISO)
|
||||
|
||||
# Chinese, Simplified
|
||||
gbk.key = S
|
||||
gbk = Chinese, Simplified (GBK)
|
||||
gb18030 = Chinese, Simplified (GB18030)
|
||||
|
||||
# Chinese, Traditional
|
||||
Big5.key = T
|
||||
Big5 = Chinese, Traditional
|
||||
|
||||
# Cyrillic
|
||||
windows-1251.key = C
|
||||
windows-1251 = Cyrillic (Windows)
|
||||
ISO-8859-5 = Cyrillic (ISO)
|
||||
KOI8-R = Cyrillic (KOI8-R)
|
||||
KOI8-U = Cyrillic (KOI8-U)
|
||||
IBM866 = Cyrillic (DOS)
|
||||
|
||||
# Greek
|
||||
windows-1253.key = G
|
||||
windows-1253 = Greek (Windows)
|
||||
ISO-8859-7.key = O
|
||||
ISO-8859-7 = Greek (ISO)
|
||||
|
||||
# Hebrew
|
||||
windows-1255.key = H
|
||||
windows-1255 = Hebrew (Windows)
|
||||
ISO-8859-8-I = Hebrew (ISO)
|
||||
# LOCALIZATION NOTE (ISO-8859-8): The value for this item should begin with
|
||||
# the same word for Hebrew as the values for windows-1255 and ISO-8859-8-I
|
||||
# so that this item sorts right after those two in the collation order for your
|
||||
# locale.
|
||||
ISO-8859-8 = Hebrew, Visual
|
||||
|
||||
# Japanese
|
||||
Shift_JIS.key = J
|
||||
Shift_JIS = Japanese (Shift_JIS)
|
||||
EUC-JP.key = p
|
||||
EUC-JP = Japanese (EUC-JP)
|
||||
ISO-2022-JP.key = n
|
||||
ISO-2022-JP = Japanese (ISO-2022-JP)
|
||||
|
||||
# Korean
|
||||
EUC-KR.key = K
|
||||
EUC-KR = Korean
|
||||
|
||||
# Thai
|
||||
windows-874.key = i
|
||||
windows-874 = Thai
|
||||
|
||||
# Turkish
|
||||
windows-1254.key = r
|
||||
windows-1254 = Turkish
|
||||
|
||||
# Vietnamese
|
||||
windows-1258.key = V
|
||||
windows-1258 = Vietnamese
|
||||
|
|
@ -22,6 +22,8 @@
|
|||
locale/browser/browser.dtd (%chrome/browser/browser.dtd)
|
||||
locale/browser/baseMenuOverlay.dtd (%chrome/browser/baseMenuOverlay.dtd)
|
||||
locale/browser/browser.properties (%chrome/browser/browser.properties)
|
||||
locale/browser/charsetMenu.properties (%chrome/browser/charsetMenu.properties)
|
||||
locale/browser/charsetMenu.dtd (%chrome/browser/charsetMenu.dtd)
|
||||
locale/browser/customizableui/customizableWidgets.properties (%chrome/browser/customizableui/customizableWidgets.properties)
|
||||
locale/browser/devtools/appcacheutils.properties (%chrome/browser/devtools/appcacheutils.properties)
|
||||
locale/browser/devtools/debugger.dtd (%chrome/browser/devtools/debugger.dtd)
|
||||
|
|
|
@ -225,7 +225,6 @@ let Content = {
|
|||
let json = aMessage.json;
|
||||
let x = json.x;
|
||||
let y = json.y;
|
||||
let modifiers = json.modifiers;
|
||||
|
||||
switch (aMessage.name) {
|
||||
case "Browser:Blur":
|
||||
|
@ -263,7 +262,7 @@ let Content = {
|
|||
break;
|
||||
|
||||
case "Gesture:SingleTap":
|
||||
this._onSingleTap(json.x, json.y);
|
||||
this._onSingleTap(json.x, json.y, json.modifiers);
|
||||
break;
|
||||
|
||||
case "Gesture:DoubleTap":
|
||||
|
@ -373,10 +372,11 @@ let Content = {
|
|||
}
|
||||
},
|
||||
|
||||
_onSingleTap: function (aX, aY) {
|
||||
_onSingleTap: function (aX, aY, aModifiers) {
|
||||
let utils = Util.getWindowUtils(content);
|
||||
for (let type of ["mousemove", "mousedown", "mouseup"]) {
|
||||
utils.sendMouseEventToWindow(type, aX, aY, 0, 1, 0, true, 1.0, Ci.nsIDOMMouseEvent.MOZ_SOURCE_TOUCH);
|
||||
utils.sendMouseEventToWindow(type, aX, aY, 0, 1, aModifiers, true, 1.0,
|
||||
Ci.nsIDOMMouseEvent.MOZ_SOURCE_TOUCH);
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -0,0 +1,160 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
this.EXPORTED_SYMBOLS = [ "CharsetMenu" ];
|
||||
|
||||
const { classes: Cc, interfaces: Ci, utils: Cu} = Components;
|
||||
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
XPCOMUtils.defineLazyGetter(this, "gBundle", function() {
|
||||
const kUrl = "chrome://browser/locale/charsetMenu.properties";
|
||||
return Services.strings.createBundle(kUrl);
|
||||
});
|
||||
/**
|
||||
* This set contains encodings that are in the Encoding Standard, except:
|
||||
* - XSS-dangerous encodings (except ISO-2022-JP which is assumed to be
|
||||
* too common not to be included).
|
||||
* - x-user-defined, which practically never makes sense as an end-user-chosen
|
||||
* override.
|
||||
* - Encodings that IE11 doesn't have in its correspoding menu.
|
||||
*/
|
||||
const kEncodings = new Set([
|
||||
// Globally relevant
|
||||
"UTF-8",
|
||||
"windows-1252",
|
||||
// Arabic
|
||||
"windows-1256",
|
||||
"ISO-8859-6",
|
||||
// Baltic
|
||||
"windows-1257",
|
||||
"ISO-8859-4",
|
||||
// "ISO-8859-13", // Hidden since not in menu in IE11
|
||||
// Central European
|
||||
"windows-1250",
|
||||
"ISO-8859-2",
|
||||
// Chinese, Simplified
|
||||
"gbk",
|
||||
"gb18030",
|
||||
// Chinese, Traditional
|
||||
"Big5",
|
||||
// Cyrillic
|
||||
"windows-1251",
|
||||
"ISO-8859-5",
|
||||
"KOI8-R",
|
||||
"KOI8-U",
|
||||
"IBM866", // Not in menu in Chromium. Maybe drop this?
|
||||
// "x-mac-cyrillic", // Not in menu in IE11 or Chromium.
|
||||
// Greek
|
||||
"windows-1253",
|
||||
"ISO-8859-7",
|
||||
// Hebrew
|
||||
"windows-1255",
|
||||
"ISO-8859-8-I",
|
||||
"ISO-8859-8",
|
||||
// Japanese
|
||||
"Shift_JIS",
|
||||
"EUC-JP",
|
||||
"ISO-2022-JP",
|
||||
// Korean
|
||||
"EUC-KR",
|
||||
// Thai
|
||||
"windows-874",
|
||||
// Turkish
|
||||
"windows-1254",
|
||||
// Vietnamese
|
||||
"windows-1258",
|
||||
// Hiding rare European encodings that aren't in the menu in IE11 and would
|
||||
// make the menu messy by sorting all over the place
|
||||
// "ISO-8859-3",
|
||||
// "ISO-8859-10",
|
||||
// "ISO-8859-14",
|
||||
// "ISO-8859-15",
|
||||
// "ISO-8859-16",
|
||||
// "macintosh"
|
||||
]);
|
||||
|
||||
// Always at the start of the menu, in this order, followed by a separator.
|
||||
const kPinned = [
|
||||
"UTF-8",
|
||||
"windows-1252"
|
||||
];
|
||||
|
||||
this.CharsetMenu = Object.freeze({
|
||||
build: function BuildCharsetMenu(event) {
|
||||
let parent = event.target;
|
||||
if (parent.lastChild.localName != "menuseparator") {
|
||||
// Detector menu or charset menu already built
|
||||
return;
|
||||
}
|
||||
let doc = parent.ownerDocument;
|
||||
|
||||
function createItem(encoding) {
|
||||
let menuItem = doc.createElement("menuitem");
|
||||
menuItem.setAttribute("type", "radio");
|
||||
menuItem.setAttribute("name", "charsetGroup");
|
||||
try {
|
||||
menuItem.setAttribute("label", gBundle.GetStringFromName(encoding));
|
||||
} catch (e) {
|
||||
// Localization error but put *something* in the menu to recover.
|
||||
menuItem.setAttribute("label", encoding);
|
||||
}
|
||||
try {
|
||||
menuItem.setAttribute("accesskey",
|
||||
gBundle.GetStringFromName(encoding + ".key"));
|
||||
} catch (e) {
|
||||
// Some items intentionally don't have an accesskey
|
||||
}
|
||||
menuItem.setAttribute("id", "charset." + encoding);
|
||||
return menuItem;
|
||||
}
|
||||
|
||||
// Clone the set in order to be able to remove the pinned encodings from
|
||||
// the cloned set.
|
||||
let encodings = new Set(kEncodings);
|
||||
for (let encoding of kPinned) {
|
||||
encodings.delete(encoding);
|
||||
parent.appendChild(createItem(encoding));
|
||||
}
|
||||
parent.appendChild(doc.createElement("menuseparator"));
|
||||
let list = [];
|
||||
for (let encoding of encodings) {
|
||||
list.push(createItem(encoding));
|
||||
}
|
||||
|
||||
list.sort(function (a, b) {
|
||||
let titleA = a.getAttribute("label");
|
||||
let titleB = b.getAttribute("label");
|
||||
// Normal sorting sorts the part in parenthesis in an order that
|
||||
// happens to make the less frequently-used items first.
|
||||
let index;
|
||||
if ((index = titleA.indexOf("(")) > -1) {
|
||||
titleA = titleA.substring(0, index);
|
||||
}
|
||||
if ((index = titleB.indexOf("(")) > -1) {
|
||||
titleA = titleB.substring(0, index);
|
||||
}
|
||||
let comp = titleA.localeCompare(titleB);
|
||||
if (comp) {
|
||||
return comp;
|
||||
}
|
||||
// secondarily reverse sort by encoding name to sort "windows" or
|
||||
// "shift_jis" first. This works regardless of localization, because
|
||||
// the ids aren't localized.
|
||||
let idA = a.getAttribute("id");
|
||||
let idB = b.getAttribute("id");
|
||||
if (idA < idB) {
|
||||
return 1;
|
||||
}
|
||||
if (idB < idA) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
|
||||
for (let item of list) {
|
||||
parent.appendChild(item);
|
||||
}
|
||||
},
|
||||
});
|
|
@ -8,6 +8,7 @@ TEST_DIRS += ['test']
|
|||
|
||||
EXTRA_JS_MODULES += [
|
||||
'BrowserNewTabPreloader.jsm',
|
||||
'CharsetMenu.jsm',
|
||||
'ContentClick.jsm',
|
||||
'NetworkPrioritizer.jsm',
|
||||
'offlineAppCache.jsm',
|
||||
|
|
|
@ -107,20 +107,6 @@ ifndef INCLUDED_TESTS_MOCHITEST_MK #{
|
|||
include $(topsrcdir)/config/makefiles/mochitest.mk
|
||||
endif #}
|
||||
|
||||
ifdef MOZ_ENABLE_GTEST
|
||||
ifdef GTEST_CPPSRCS
|
||||
CPPSRCS += $(GTEST_CPPSRCS)
|
||||
endif
|
||||
|
||||
ifdef GTEST_CSRCS
|
||||
CSRCS += $(GTEST_CSRCS)
|
||||
endif
|
||||
|
||||
ifdef GTEST_CMMSRCS
|
||||
CMMSRCS += $(GTEST_CMMSRCS)
|
||||
endif
|
||||
endif
|
||||
|
||||
ifdef CPP_UNIT_TESTS
|
||||
ifdef COMPILE_ENVIRONMENT
|
||||
|
||||
|
|
|
@ -98,8 +98,8 @@ def checkMkdir(work, debug=False):
|
|||
|
||||
logging.debug("Testing: checkMkdir")
|
||||
|
||||
# On Windows + Pymake, don't convert paths to POSIX
|
||||
skipposix = sys.platform == "win32" and os.environ.get(".PYMAKE") == "1"
|
||||
# On Windows, don't convert paths to POSIX
|
||||
skipposix = sys.platform == "win32"
|
||||
if skipposix:
|
||||
path = os.path.abspath(__file__)
|
||||
dirname_fun = os.path.dirname
|
||||
|
|
|
@ -6325,11 +6325,8 @@ MOZ_ARG_DISABLE_BOOL(tests,
|
|||
ENABLE_TESTS=1 )
|
||||
|
||||
if test -n "$ENABLE_TESTS"; then
|
||||
MOZ_ENABLE_GTEST=1
|
||||
GTEST_HAS_RTTI=0
|
||||
AC_DEFINE(MOZ_ENABLE_GTEST)
|
||||
AC_DEFINE_UNQUOTED(GTEST_HAS_RTTI, 0)
|
||||
AC_SUBST(MOZ_ENABLE_GTEST)
|
||||
AC_SUBST(GTEST_HAS_RTTI)
|
||||
if test -n "$_WIN32_MSVC"; then
|
||||
AC_DEFINE_UNQUOTED(_VARIADIC_MAX, 10)
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#include "nsJSUtils.h"
|
||||
#include "nsIAsyncVerifyRedirectCallback.h"
|
||||
#include "nsIScriptError.h"
|
||||
#include "nsICharsetConverterManager.h"
|
||||
#include "mozilla/dom/EncodingUtils.h"
|
||||
#include "nsIChannelPolicy.h"
|
||||
#include "nsIContentSecurityPolicy.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
@ -264,13 +264,7 @@ EventSource::Init(nsISupports* aOwner,
|
|||
Preferences::GetInt("dom.server-events.default-reconnection-time",
|
||||
DEFAULT_RECONNECTION_TIME_VALUE);
|
||||
|
||||
nsCOMPtr<nsICharsetConverterManager> convManager =
|
||||
do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = convManager->GetUnicodeDecoderRaw("UTF-8",
|
||||
getter_AddRefs(mUnicodeDecoder));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
mUnicodeDecoder = EncodingUtils::DecoderForEncoding("UTF-8");
|
||||
|
||||
// the constructor should throw a SYNTAX_ERROR only if it fails resolving the
|
||||
// url parameter, so we don't care about the InitChannelAndRequestEventSource
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
#include "nsError.h"
|
||||
#include "nsIScriptObjectPrincipal.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsICharsetConverterManager.h"
|
||||
#include "nsIUnicodeEncoder.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsIDOMMessageEvent.h"
|
||||
|
|
|
@ -83,7 +83,6 @@
|
|||
#include "nsICategoryManager.h"
|
||||
#include "nsIChannelEventSink.h"
|
||||
#include "nsIChannelPolicy.h"
|
||||
#include "nsICharsetConverterManager.h"
|
||||
#include "nsICharsetDetectionObserver.h"
|
||||
#include "nsICharsetDetector.h"
|
||||
#include "nsIChromeRegistry.h"
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
#include "nsDOMClassInfoID.h"
|
||||
#include "nsError.h"
|
||||
#include "nsICharsetDetector.h"
|
||||
#include "nsICharsetConverterManager.h"
|
||||
#include "nsIClassInfo.h"
|
||||
#include "nsIConverterInputStream.h"
|
||||
#include "nsIDocument.h"
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
#include "nsDOMClassInfoID.h"
|
||||
#include "nsDOMFile.h"
|
||||
#include "nsError.h"
|
||||
#include "nsICharsetConverterManager.h"
|
||||
#include "nsIConverterInputStream.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIFile.h"
|
||||
|
@ -535,14 +534,9 @@ nsDOMFileReader::ConvertStream(const char *aFileData,
|
|||
nsAString &aResult)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsICharsetConverterManager> charsetConverter =
|
||||
do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIUnicodeDecoder> unicodeDecoder;
|
||||
rv = charsetConverter->GetUnicodeDecoderRaw(aCharset,
|
||||
getter_AddRefs(unicodeDecoder));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr<nsIUnicodeDecoder> unicodeDecoder =
|
||||
EncodingUtils::DecoderForEncoding(aCharset);
|
||||
|
||||
int32_t destLength;
|
||||
rv = unicodeDecoder->GetMaxLength(aFileData, aDataLen, &destLength);
|
||||
|
|
|
@ -251,7 +251,7 @@ private:
|
|||
NS_IMETHODIMP
|
||||
nsSimplePluginEvent::Run()
|
||||
{
|
||||
if (mDocument->IsActive()) {
|
||||
if (mDocument && mDocument->IsActive()) {
|
||||
LOG(("OBJLC [%p]: nsSimplePluginEvent firing event \"%s\"", mTarget.get(),
|
||||
NS_ConvertUTF16toUTF8(mEvent).get()));
|
||||
nsContentUtils::DispatchTrustedEvent(mDocument, mTarget,
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
#include "jsapi.h"
|
||||
#include "jsfriendapi.h"
|
||||
#include "nsScriptLoader.h"
|
||||
#include "nsICharsetConverterManager.h"
|
||||
#include "nsIUnicodeDecoder.h"
|
||||
#include "nsIContent.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
|
@ -1182,37 +1181,30 @@ nsScriptLoader::ConvertToUTF16(nsIChannel* aChannel, const uint8_t* aData,
|
|||
|
||||
nsAutoCString charset;
|
||||
|
||||
nsCOMPtr<nsICharsetConverterManager> charsetConv =
|
||||
do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID);
|
||||
|
||||
nsCOMPtr<nsIUnicodeDecoder> unicodeDecoder;
|
||||
|
||||
if (DetectByteOrderMark(aData, aLength, charset)) {
|
||||
// charset is now "UTF-8" or "UTF-16". The UTF-16 decoder will re-sniff
|
||||
// the BOM for endianness. Both the UTF-16 and the UTF-8 decoder will
|
||||
// take care of swallowing the BOM.
|
||||
charsetConv->GetUnicodeDecoderRaw(charset.get(),
|
||||
getter_AddRefs(unicodeDecoder));
|
||||
unicodeDecoder = EncodingUtils::DecoderForEncoding(charset);
|
||||
}
|
||||
|
||||
if (!unicodeDecoder &&
|
||||
aChannel &&
|
||||
NS_SUCCEEDED(aChannel->GetContentCharset(charset)) &&
|
||||
EncodingUtils::FindEncodingForLabel(charset, charset)) {
|
||||
charsetConv->GetUnicodeDecoderRaw(charset.get(),
|
||||
getter_AddRefs(unicodeDecoder));
|
||||
unicodeDecoder = EncodingUtils::DecoderForEncoding(charset);
|
||||
}
|
||||
|
||||
if (!unicodeDecoder &&
|
||||
EncodingUtils::FindEncodingForLabel(aHintCharset, charset)) {
|
||||
charsetConv->GetUnicodeDecoderRaw(charset.get(),
|
||||
getter_AddRefs(unicodeDecoder));
|
||||
unicodeDecoder = EncodingUtils::DecoderForEncoding(charset);
|
||||
}
|
||||
|
||||
if (!unicodeDecoder && aDocument) {
|
||||
charset = aDocument->GetDocumentCharacterSet();
|
||||
charsetConv->GetUnicodeDecoderRaw(charset.get(),
|
||||
getter_AddRefs(unicodeDecoder));
|
||||
unicodeDecoder = EncodingUtils::DecoderForEncoding(charset);
|
||||
}
|
||||
|
||||
if (!unicodeDecoder) {
|
||||
|
@ -1220,8 +1212,7 @@ nsScriptLoader::ConvertToUTF16(nsIChannel* aChannel, const uint8_t* aData,
|
|||
// fallback in the old code was ISO-8859-1, which behaved like
|
||||
// windows-1252. Saying windows-1252 for clarity and for compliance
|
||||
// with the Encoding Standard.
|
||||
charsetConv->GetUnicodeDecoderRaw("windows-1252",
|
||||
getter_AddRefs(unicodeDecoder));
|
||||
unicodeDecoder = EncodingUtils::DecoderForEncoding("windows-1252");
|
||||
}
|
||||
|
||||
int32_t unicodeLength = 0;
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
#include "mozilla/MemoryReporting.h"
|
||||
#include "mozilla/Util.h"
|
||||
#include "nsDOMBlobBuilder.h"
|
||||
#include "nsICharsetConverterManager.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMProgressEvent.h"
|
||||
#include "nsIJARChannel.h"
|
||||
|
@ -58,6 +57,7 @@
|
|||
#include "jsfriendapi.h"
|
||||
#include "GeckoProfiler.h"
|
||||
#include "mozilla/dom/EncodingUtils.h"
|
||||
#include "nsIUnicodeDecoder.h"
|
||||
#include "mozilla/dom/XMLHttpRequestBinding.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "nsIPermissionManager.h"
|
||||
|
@ -633,13 +633,9 @@ nsXMLHttpRequest::DetectCharset()
|
|||
mResponseCharset.AssignLiteral("UTF-8");
|
||||
}
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsICharsetConverterManager> ccm =
|
||||
do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
mDecoder = EncodingUtils::DecoderForEncoding(mResponseCharset);
|
||||
|
||||
return ccm->GetUnicodeDecoderRaw(mResponseCharset.get(),
|
||||
getter_AddRefs(mDecoder));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -724,20 +720,7 @@ nsXMLHttpRequest::GetResponseText(nsString& aResponseText, ErrorResult& aRv)
|
|||
mResponseCharset = mResponseXML->GetDocumentCharacterSet();
|
||||
mResponseText.Truncate();
|
||||
mResponseBodyDecodedPos = 0;
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsICharsetConverterManager> ccm =
|
||||
do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
aRv.Throw(rv);
|
||||
return;
|
||||
}
|
||||
|
||||
aRv = ccm->GetUnicodeDecoderRaw(mResponseCharset.get(),
|
||||
getter_AddRefs(mDecoder));
|
||||
if (aRv.Failed()) {
|
||||
return;
|
||||
}
|
||||
mDecoder = EncodingUtils::DecoderForEncoding(mResponseCharset);
|
||||
}
|
||||
|
||||
NS_ASSERTION(mResponseBodyDecodedPos < mResponseBody.Length(),
|
||||
|
|
|
@ -48,7 +48,7 @@ public:
|
|||
{
|
||||
return mHeight;
|
||||
}
|
||||
JSObject* Data(JSContext* cx, JS::Handle<JSObject*> /* unused */) const
|
||||
JSObject* Data(JSContext* cx) const
|
||||
{
|
||||
return GetDataObject();
|
||||
}
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
#include "nsIURL.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsLinebreakConverter.h"
|
||||
#include "nsICharsetConverterManager.h"
|
||||
#include "nsEscape.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "nsIMultiplexInputStream.h"
|
||||
|
|
|
@ -35,6 +35,11 @@ public:
|
|||
|
||||
virtual void SetScriptGlobalObject(nsIScriptGlobalObject* aGlobalObject) MOZ_OVERRIDE;
|
||||
|
||||
virtual bool WillIgnoreCharsetOverride()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected:
|
||||
void BecomeInteractive();
|
||||
|
||||
|
|
|
@ -64,6 +64,7 @@ FAIL_ON_WARNINGS = True
|
|||
LOCAL_INCLUDES += [
|
||||
'../base/src',
|
||||
'../events/src',
|
||||
'../svg/content/src',
|
||||
'/layout/style',
|
||||
]
|
||||
|
||||
|
|
|
@ -754,11 +754,11 @@ nsSMILAnimationFunction::GetValues(const nsISMILAttr& aSMILAttr,
|
|||
nsAutoString attValue;
|
||||
GetAttr(nsGkAtoms::values, attValue);
|
||||
bool preventCachingOfSandwich = false;
|
||||
nsresult rv = nsSMILParserUtils::ParseValues(attValue, mAnimationElement,
|
||||
aSMILAttr, result,
|
||||
preventCachingOfSandwich);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
if (!nsSMILParserUtils::ParseValues(attValue, mAnimationElement,
|
||||
aSMILAttr, result,
|
||||
preventCachingOfSandwich)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (preventCachingOfSandwich) {
|
||||
mValueNeedsReparsingEverySample = true;
|
||||
|
@ -1014,29 +1014,14 @@ nsSMILAnimationFunction::SetKeySplines(const nsAString& aKeySplines,
|
|||
mKeySplines.Clear();
|
||||
aResult.SetTo(aKeySplines);
|
||||
|
||||
nsTArray<double> keySplines;
|
||||
nsresult rv = nsSMILParserUtils::ParseKeySplines(aKeySplines, keySplines);
|
||||
|
||||
if (keySplines.Length() < 1 || keySplines.Length() % 4)
|
||||
rv = NS_ERROR_FAILURE;
|
||||
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
mKeySplines.SetCapacity(keySplines.Length() % 4);
|
||||
for (uint32_t i = 0; i < keySplines.Length() && NS_SUCCEEDED(rv); i += 4)
|
||||
{
|
||||
if (!mKeySplines.AppendElement(nsSMILKeySpline(keySplines[i],
|
||||
keySplines[i+1],
|
||||
keySplines[i+2],
|
||||
keySplines[i+3]))) {
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mHasChanged = true;
|
||||
|
||||
return rv;
|
||||
if (!nsSMILParserUtils::ParseKeySplines(aKeySplines, mKeySplines)) {
|
||||
mKeySplines.Clear();
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1054,18 +1039,14 @@ nsSMILAnimationFunction::SetKeyTimes(const nsAString& aKeyTimes,
|
|||
mKeyTimes.Clear();
|
||||
aResult.SetTo(aKeyTimes);
|
||||
|
||||
nsresult rv =
|
||||
nsSMILParserUtils::ParseSemicolonDelimitedProgressList(aKeyTimes, true,
|
||||
mKeyTimes);
|
||||
|
||||
if (NS_SUCCEEDED(rv) && mKeyTimes.Length() < 1)
|
||||
rv = NS_ERROR_FAILURE;
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
mKeyTimes.Clear();
|
||||
|
||||
mHasChanged = true;
|
||||
|
||||
if (!nsSMILParserUtils::ParseSemicolonDelimitedProgressList(aKeyTimes, true,
|
||||
mKeyTimes)) {
|
||||
mKeyTimes.Clear();
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -251,7 +251,7 @@ public:
|
|||
|
||||
protected:
|
||||
// Typedefs
|
||||
typedef nsTArray<nsSMILValue> nsSMILValueArray;
|
||||
typedef FallibleTArray<nsSMILValue> nsSMILValueArray;
|
||||
|
||||
// Types
|
||||
enum nsSMILCalcMode
|
||||
|
@ -398,8 +398,8 @@ protected:
|
|||
static nsAttrValue::EnumTable sCalcModeTable[];
|
||||
static nsAttrValue::EnumTable sAccumulateTable[];
|
||||
|
||||
nsTArray<double> mKeyTimes;
|
||||
nsTArray<nsSMILKeySpline> mKeySplines;
|
||||
FallibleTArray<double> mKeyTimes;
|
||||
FallibleTArray<nsSMILKeySpline> mKeySplines;
|
||||
|
||||
// These are the parameters provided by the previous sample. Currently we
|
||||
// perform lazy calculation. That is, we only calculate the result if and when
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -6,11 +6,11 @@
|
|||
#ifndef NS_SMILPARSERUTILS_H_
|
||||
#define NS_SMILPARSERUTILS_H_
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsString.h"
|
||||
#include "nsStringFwd.h"
|
||||
|
||||
class nsISMILAttr;
|
||||
class nsSMILKeySpline;
|
||||
class nsSMILTimeValue;
|
||||
class nsSMILValue;
|
||||
class nsSMILRepeatCount;
|
||||
|
@ -31,72 +31,49 @@ class nsSMILParserUtils
|
|||
{
|
||||
public:
|
||||
// Abstract helper-class for assisting in parsing |values| attribute
|
||||
class GenericValueParser {
|
||||
class MOZ_STACK_CLASS GenericValueParser {
|
||||
public:
|
||||
virtual nsresult Parse(const nsAString& aValueStr) = 0;
|
||||
virtual bool Parse(const nsAString& aValueStr) = 0;
|
||||
};
|
||||
|
||||
static nsresult ParseKeySplines(const nsAString& aSpec,
|
||||
nsTArray<double>& aSplineArray);
|
||||
static const nsDependentSubstring TrimWhitespace(const nsAString& aString);
|
||||
|
||||
static bool ParseKeySplines(const nsAString& aSpec,
|
||||
FallibleTArray<nsSMILKeySpline>& aKeySplines);
|
||||
|
||||
// Used for parsing the |keyTimes| and |keyPoints| attributes.
|
||||
static nsresult ParseSemicolonDelimitedProgressList(const nsAString& aSpec,
|
||||
bool aNonDecreasing,
|
||||
nsTArray<double>& aArray);
|
||||
static bool ParseSemicolonDelimitedProgressList(const nsAString& aSpec,
|
||||
bool aNonDecreasing,
|
||||
FallibleTArray<double>& aArray);
|
||||
|
||||
static nsresult ParseValues(const nsAString& aSpec,
|
||||
const mozilla::dom::SVGAnimationElement* aSrcElement,
|
||||
const nsISMILAttr& aAttribute,
|
||||
nsTArray<nsSMILValue>& aValuesArray,
|
||||
bool& aPreventCachingOfSandwich);
|
||||
static bool ParseValues(const nsAString& aSpec,
|
||||
const mozilla::dom::SVGAnimationElement* aSrcElement,
|
||||
const nsISMILAttr& aAttribute,
|
||||
FallibleTArray<nsSMILValue>& aValuesArray,
|
||||
bool& aPreventCachingOfSandwich);
|
||||
|
||||
// Generic method that will run some code on each sub-section of an animation
|
||||
// element's "values" list.
|
||||
static nsresult ParseValuesGeneric(const nsAString& aSpec,
|
||||
GenericValueParser& aParser);
|
||||
static bool ParseValuesGeneric(const nsAString& aSpec,
|
||||
GenericValueParser& aParser);
|
||||
|
||||
static nsresult ParseRepeatCount(const nsAString& aSpec,
|
||||
nsSMILRepeatCount& aResult);
|
||||
static bool ParseRepeatCount(const nsAString& aSpec,
|
||||
nsSMILRepeatCount& aResult);
|
||||
|
||||
static nsresult ParseTimeValueSpecParams(const nsAString& aSpec,
|
||||
nsSMILTimeValueSpecParams& aResult);
|
||||
|
||||
|
||||
// Used with ParseClockValue. Allow + or - before a clock value.
|
||||
static const int8_t kClockValueAllowSign = 1;
|
||||
// Used with ParseClockValue. Allow "indefinite" in a clock value
|
||||
static const int8_t kClockValueAllowIndefinite = 2;
|
||||
static bool ParseTimeValueSpecParams(const nsAString& aSpec,
|
||||
nsSMILTimeValueSpecParams& aResult);
|
||||
|
||||
/*
|
||||
* This method can actually parse more than a clock value as defined in the
|
||||
* SMIL Animation specification. It can also parse:
|
||||
* - the + or - before an offset
|
||||
* - the special value "indefinite"
|
||||
* - the special value "media"
|
||||
*
|
||||
* Because the value "media" cannot be represented as part of an
|
||||
* nsSMILTimeValue and has different meanings depending on where it is used,
|
||||
* it is passed out as a separate parameter (which can be set to nullptr if the
|
||||
* media attribute is not allowed).
|
||||
* Parses a clock value as defined in the SMIL Animation specification.
|
||||
* If parsing succeeds the returned value will be a non-negative, definite
|
||||
* time value i.e. IsDefinite will return true.
|
||||
*
|
||||
* @param aSpec The string containing a clock value, e.g. "10s"
|
||||
* @param aResult The parsed result. May be nullptr (e.g. if this method is
|
||||
* being called just to test if aSpec is a valid clock value).
|
||||
* [OUT]
|
||||
* @param aFlags A combination of the kClockValue* bit flags OR'ed together
|
||||
* to define what additional syntax is allowed.
|
||||
* @param aIsMedia Optional out parameter which, if not null, will be set to
|
||||
* true if the value is the string "media", false
|
||||
* otherwise. If it is null, the string "media" is not
|
||||
* allowed.
|
||||
*
|
||||
* @return NS_OK if aSpec was successfully parsed as a valid clock value
|
||||
* (according to aFlags), an error code otherwise.
|
||||
* @param aResult The parsed result. [OUT]
|
||||
* @return true if parsing succeeded, otherwise false.
|
||||
*/
|
||||
static nsresult ParseClockValue(const nsAString& aSpec,
|
||||
nsSMILTimeValue* aResult,
|
||||
uint32_t aFlags = 0,
|
||||
bool* aIsMedia = nullptr);
|
||||
static bool ParseClockValue(const nsAString& aSpec,
|
||||
nsSMILTimeValue* aResult);
|
||||
|
||||
/*
|
||||
* This method checks whether the given string looks like a negative number.
|
||||
|
|
|
@ -68,11 +68,9 @@ nsSMILTimeValueSpec::SetSpec(const nsAString& aStringSpec,
|
|||
Element* aContextNode)
|
||||
{
|
||||
nsSMILTimeValueSpecParams params;
|
||||
nsresult rv =
|
||||
nsSMILParserUtils::ParseTimeValueSpecParams(aStringSpec, params);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
if (!nsSMILParserUtils::ParseTimeValueSpecParams(aStringSpec, params))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
mParams = params;
|
||||
|
||||
|
@ -94,7 +92,7 @@ nsSMILTimeValueSpec::SetSpec(const nsAString& aStringSpec,
|
|||
|
||||
ResolveReferences(aContextNode);
|
||||
|
||||
return rv;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -906,31 +906,22 @@ nsresult
|
|||
nsSMILTimedElement::SetSimpleDuration(const nsAString& aDurSpec)
|
||||
{
|
||||
nsSMILTimeValue duration;
|
||||
bool isMedia;
|
||||
nsresult rv;
|
||||
|
||||
rv = nsSMILParserUtils::ParseClockValue(aDurSpec, &duration,
|
||||
nsSMILParserUtils::kClockValueAllowIndefinite, &isMedia);
|
||||
const nsAString& dur = nsSMILParserUtils::TrimWhitespace(aDurSpec);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
mSimpleDur.SetIndefinite();
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (duration.IsDefinite() && duration.GetMillis() == 0L) {
|
||||
mSimpleDur.SetIndefinite();
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
//
|
||||
// SVG-specific: "For SVG's animation elements, if "media" is specified, the
|
||||
// attribute will be ignored." (SVG 1.1, section 19.2.6)
|
||||
//
|
||||
if (isMedia)
|
||||
if (dur.EqualsLiteral("media") || dur.EqualsLiteral("indefinite")) {
|
||||
duration.SetIndefinite();
|
||||
|
||||
} else {
|
||||
if (!nsSMILParserUtils::ParseClockValue(dur, &duration) ||
|
||||
duration.GetMillis() == 0L) {
|
||||
mSimpleDur.SetIndefinite();
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
// mSimpleDur should never be unresolved. ParseClockValue will either set
|
||||
// duration to resolved/indefinite/media or will return a failure code.
|
||||
// duration to resolved or will return false.
|
||||
NS_ABORT_IF_FALSE(duration.IsResolved(),
|
||||
"Setting unresolved simple duration");
|
||||
|
||||
|
@ -951,24 +942,19 @@ nsresult
|
|||
nsSMILTimedElement::SetMin(const nsAString& aMinSpec)
|
||||
{
|
||||
nsSMILTimeValue duration;
|
||||
bool isMedia;
|
||||
nsresult rv;
|
||||
|
||||
rv = nsSMILParserUtils::ParseClockValue(aMinSpec, &duration, 0, &isMedia);
|
||||
const nsAString& min = nsSMILParserUtils::TrimWhitespace(aMinSpec);
|
||||
|
||||
if (isMedia) {
|
||||
if (min.EqualsLiteral("media")) {
|
||||
duration.SetMillis(0L);
|
||||
} else {
|
||||
if (!nsSMILParserUtils::ParseClockValue(min, &duration)) {
|
||||
mMin.SetMillis(0L);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv) || !duration.IsDefinite()) {
|
||||
mMin.SetMillis(0L);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (duration.GetMillis() < 0L) {
|
||||
mMin.SetMillis(0L);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
NS_ABORT_IF_FALSE(duration.GetMillis() >= 0L, "Invalid duration");
|
||||
|
||||
mMin = duration;
|
||||
UpdateCurrentInterval();
|
||||
|
@ -987,23 +973,18 @@ nsresult
|
|||
nsSMILTimedElement::SetMax(const nsAString& aMaxSpec)
|
||||
{
|
||||
nsSMILTimeValue duration;
|
||||
bool isMedia;
|
||||
nsresult rv;
|
||||
|
||||
rv = nsSMILParserUtils::ParseClockValue(aMaxSpec, &duration,
|
||||
nsSMILParserUtils::kClockValueAllowIndefinite, &isMedia);
|
||||
const nsAString& max = nsSMILParserUtils::TrimWhitespace(aMaxSpec);
|
||||
|
||||
if (isMedia)
|
||||
if (max.EqualsLiteral("media") || max.EqualsLiteral("indefinite")) {
|
||||
duration.SetIndefinite();
|
||||
|
||||
if (NS_FAILED(rv) || !duration.IsResolved()) {
|
||||
mMax.SetIndefinite();
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (duration.IsDefinite() && duration.GetMillis() <= 0L) {
|
||||
mMax.SetIndefinite();
|
||||
return NS_ERROR_FAILURE;
|
||||
} else {
|
||||
if (!nsSMILParserUtils::ParseClockValue(max, &duration) ||
|
||||
duration.GetMillis() == 0L) {
|
||||
mMax.SetIndefinite();
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
NS_ABORT_IF_FALSE(duration.GetMillis() > 0L, "Invalid duration");
|
||||
}
|
||||
|
||||
mMax = duration;
|
||||
|
@ -1043,18 +1024,15 @@ nsresult
|
|||
nsSMILTimedElement::SetRepeatCount(const nsAString& aRepeatCountSpec)
|
||||
{
|
||||
nsSMILRepeatCount newRepeatCount;
|
||||
nsresult rv =
|
||||
nsSMILParserUtils::ParseRepeatCount(aRepeatCountSpec, newRepeatCount);
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
if (nsSMILParserUtils::ParseRepeatCount(aRepeatCountSpec, newRepeatCount)) {
|
||||
mRepeatCount = newRepeatCount;
|
||||
} else {
|
||||
mRepeatCount.Unset();
|
||||
UpdateCurrentInterval();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
mRepeatCount.Unset();
|
||||
UpdateCurrentInterval();
|
||||
|
||||
return rv;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1067,15 +1045,18 @@ nsSMILTimedElement::UnsetRepeatCount()
|
|||
nsresult
|
||||
nsSMILTimedElement::SetRepeatDur(const nsAString& aRepeatDurSpec)
|
||||
{
|
||||
nsresult rv;
|
||||
nsSMILTimeValue duration;
|
||||
|
||||
rv = nsSMILParserUtils::ParseClockValue(aRepeatDurSpec, &duration,
|
||||
nsSMILParserUtils::kClockValueAllowIndefinite);
|
||||
const nsAString& repeatDur =
|
||||
nsSMILParserUtils::TrimWhitespace(aRepeatDurSpec);
|
||||
|
||||
if (NS_FAILED(rv) || !duration.IsResolved()) {
|
||||
mRepeatDur.SetUnresolved();
|
||||
return NS_ERROR_FAILURE;
|
||||
if (repeatDur.EqualsLiteral("indefinite")) {
|
||||
duration.SetIndefinite();
|
||||
} else {
|
||||
if (!nsSMILParserUtils::ParseClockValue(repeatDur, &duration)) {
|
||||
mRepeatDur.SetUnresolved();
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
mRepeatDur = duration;
|
||||
|
|
|
@ -368,97 +368,70 @@ SVGContentUtils::GetViewBoxTransform(float aViewportWidth, float aViewportHeight
|
|||
return gfxMatrix(a, 0.0f, 0.0f, d, e, f);
|
||||
}
|
||||
|
||||
/**
|
||||
* True if 'aCh' is a decimal digit.
|
||||
*/
|
||||
static inline bool
|
||||
IsDigit(PRUnichar aCh)
|
||||
static bool
|
||||
ParseNumber(RangedPtr<const PRUnichar>& aIter,
|
||||
const RangedPtr<const PRUnichar>& aEnd,
|
||||
double& aValue)
|
||||
{
|
||||
return aCh >= '0' && aCh <= '9';
|
||||
}
|
||||
|
||||
/**
|
||||
* Assuming that 'aCh' is a decimal digit, return its numeric value.
|
||||
*/
|
||||
static inline uint32_t
|
||||
DecimalDigitValue(PRUnichar aCh)
|
||||
{
|
||||
MOZ_ASSERT(IsDigit(aCh), "Digit expected");
|
||||
return aCh - '0';
|
||||
}
|
||||
|
||||
template<class floatType>
|
||||
bool
|
||||
SVGContentUtils::ParseNumber(RangedPtr<const PRUnichar>& aIter,
|
||||
const RangedPtr<const PRUnichar>& aEnd,
|
||||
floatType& aValue)
|
||||
{
|
||||
if (aIter == aEnd) {
|
||||
int32_t sign;
|
||||
if (!SVGContentUtils::ParseOptionalSign(aIter, aEnd, sign)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
RangedPtr<const PRUnichar> iter(aIter);
|
||||
|
||||
// Sign of the mantissa (-1 or 1).
|
||||
int32_t sign = *iter == '-' ? -1 : 1;
|
||||
|
||||
if (*iter == '-' || *iter == '+') {
|
||||
++iter;
|
||||
if (iter == aEnd) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Absolute value of the integer part of the mantissa.
|
||||
floatType intPart = floatType(0);
|
||||
double intPart = 0.0;
|
||||
|
||||
bool gotDot = *iter == '.';
|
||||
bool gotDot = *aIter == '.';
|
||||
|
||||
if (!gotDot) {
|
||||
if (!IsDigit(*iter)) {
|
||||
if (!SVGContentUtils::IsDigit(*aIter)) {
|
||||
return false;
|
||||
}
|
||||
do {
|
||||
intPart = floatType(10) * intPart + DecimalDigitValue(*iter);
|
||||
++iter;
|
||||
} while (iter != aEnd && IsDigit(*iter));
|
||||
intPart = 10.0 * intPart + SVGContentUtils::DecimalDigitValue(*aIter);
|
||||
++aIter;
|
||||
} while (aIter != aEnd && SVGContentUtils::IsDigit(*aIter));
|
||||
|
||||
if (iter != aEnd) {
|
||||
gotDot = *iter == '.';
|
||||
if (aIter != aEnd) {
|
||||
gotDot = *aIter == '.';
|
||||
}
|
||||
}
|
||||
|
||||
// Fractional part of the mantissa.
|
||||
floatType fracPart = floatType(0);
|
||||
double fracPart = 0.0;
|
||||
|
||||
if (gotDot) {
|
||||
++iter;
|
||||
if (iter == aEnd || !IsDigit(*iter)) {
|
||||
++aIter;
|
||||
if (aIter == aEnd || !SVGContentUtils::IsDigit(*aIter)) {
|
||||
return false;
|
||||
}
|
||||
// Power of ten by which we need to divide our next digit
|
||||
floatType divisor = floatType(10);
|
||||
|
||||
// Power of ten by which we need to divide the fraction
|
||||
double divisor = 1.0;
|
||||
|
||||
do {
|
||||
fracPart += DecimalDigitValue(*iter) / divisor;
|
||||
divisor *= 10;
|
||||
++iter;
|
||||
} while (iter != aEnd && IsDigit(*iter));
|
||||
fracPart = 10.0 * fracPart + SVGContentUtils::DecimalDigitValue(*aIter);
|
||||
divisor *= 10.0;
|
||||
++aIter;
|
||||
} while (aIter != aEnd && SVGContentUtils::IsDigit(*aIter));
|
||||
|
||||
fracPart /= divisor;
|
||||
}
|
||||
|
||||
bool gotE = false;
|
||||
int32_t exponent = 0;
|
||||
int32_t expSign;
|
||||
|
||||
if (iter != aEnd && (*iter == 'e' || *iter == 'E')) {
|
||||
if (aIter != aEnd && (*aIter == 'e' || *aIter == 'E')) {
|
||||
|
||||
RangedPtr<const PRUnichar> expIter(iter);
|
||||
RangedPtr<const PRUnichar> expIter(aIter);
|
||||
|
||||
++expIter;
|
||||
if (expIter != aEnd) {
|
||||
expSign = *expIter == '-' ? -1 : 1;
|
||||
if (*expIter == '-' || *expIter == '+') {
|
||||
++expIter;
|
||||
if (expIter != aEnd && IsDigit(*expIter)) {
|
||||
if (expIter != aEnd && SVGContentUtils::IsDigit(*expIter)) {
|
||||
// At this point we're sure this is an exponent
|
||||
// and not the start of a unit such as em or ex.
|
||||
gotE = true;
|
||||
|
@ -467,24 +440,40 @@ SVGContentUtils::ParseNumber(RangedPtr<const PRUnichar>& aIter,
|
|||
}
|
||||
|
||||
if (gotE) {
|
||||
iter = expIter;
|
||||
aIter = expIter;
|
||||
do {
|
||||
exponent = 10 * exponent + DecimalDigitValue(*iter);
|
||||
++iter;
|
||||
} while (iter != aEnd && IsDigit(*iter));
|
||||
exponent = 10.0 * exponent + SVGContentUtils::DecimalDigitValue(*aIter);
|
||||
++aIter;
|
||||
} while (aIter != aEnd && SVGContentUtils::IsDigit(*aIter));
|
||||
}
|
||||
}
|
||||
|
||||
// Assemble the number
|
||||
floatType value = sign * (intPart + fracPart);
|
||||
aValue = sign * (intPart + fracPart);
|
||||
if (gotE) {
|
||||
value *= pow(floatType(10), floatType(expSign * exponent));
|
||||
aValue *= pow(10.0, expSign * exponent);
|
||||
}
|
||||
if (!NS_finite(value)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
template<class floatType>
|
||||
bool
|
||||
SVGContentUtils::ParseNumber(RangedPtr<const PRUnichar>& aIter,
|
||||
const RangedPtr<const PRUnichar>& aEnd,
|
||||
floatType& aValue)
|
||||
{
|
||||
RangedPtr<const PRUnichar> iter(aIter);
|
||||
|
||||
double value;
|
||||
if (!::ParseNumber(iter, aEnd, value)) {
|
||||
return false;
|
||||
}
|
||||
floatType floatValue = floatType(value);
|
||||
if (!NS_finite(floatValue)) {
|
||||
return false;
|
||||
}
|
||||
aValue = floatValue;
|
||||
aIter = iter;
|
||||
aValue = value;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -492,6 +481,7 @@ template bool
|
|||
SVGContentUtils::ParseNumber<float>(RangedPtr<const PRUnichar>& aIter,
|
||||
const RangedPtr<const PRUnichar>& aEnd,
|
||||
float& aValue);
|
||||
|
||||
template bool
|
||||
SVGContentUtils::ParseNumber<double>(RangedPtr<const PRUnichar>& aIter,
|
||||
const RangedPtr<const PRUnichar>& aEnd,
|
||||
|
@ -528,6 +518,40 @@ template bool
|
|||
SVGContentUtils::ParseNumber<double>(const nsAString& aString,
|
||||
double& aValue);
|
||||
|
||||
/* static */
|
||||
bool
|
||||
SVGContentUtils::ParseInteger(RangedPtr<const PRUnichar>& aIter,
|
||||
const RangedPtr<const PRUnichar>& aEnd,
|
||||
int32_t& aValue)
|
||||
{
|
||||
RangedPtr<const PRUnichar> iter(aIter);
|
||||
|
||||
int32_t sign;
|
||||
if (!ParseOptionalSign(iter, aEnd, sign)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!IsDigit(*iter)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int64_t value = 0;
|
||||
|
||||
do {
|
||||
if (value <= std::numeric_limits<int32_t>::max()) {
|
||||
value = 10 * value + DecimalDigitValue(*iter);
|
||||
}
|
||||
++iter;
|
||||
} while (iter != aEnd && IsDigit(*iter));
|
||||
|
||||
aIter = iter;
|
||||
aValue = int32_t(clamped(sign * value,
|
||||
int64_t(std::numeric_limits<int32_t>::min()),
|
||||
int64_t(std::numeric_limits<int32_t>::max())));
|
||||
return true;
|
||||
}
|
||||
|
||||
/* static */
|
||||
bool
|
||||
SVGContentUtils::ParseInteger(const nsAString& aString,
|
||||
int32_t& aValue)
|
||||
|
@ -535,35 +559,7 @@ SVGContentUtils::ParseInteger(const nsAString& aString,
|
|||
RangedPtr<const PRUnichar> iter = GetStartRangedPtr(aString);
|
||||
const RangedPtr<const PRUnichar> end = GetEndRangedPtr(aString);
|
||||
|
||||
if (iter == end) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int32_t sign = *iter == '-' ? -1 : 1;
|
||||
|
||||
if (*iter == '-' || *iter == '+') {
|
||||
++iter;
|
||||
if (iter == end) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
int64_t value = 0;
|
||||
|
||||
do {
|
||||
if (!IsDigit(*iter)) {
|
||||
return false;
|
||||
}
|
||||
if (value <= std::numeric_limits<int32_t>::max()) {
|
||||
value = 10 * value + DecimalDigitValue(*iter);
|
||||
}
|
||||
++iter;
|
||||
} while (iter != end);
|
||||
|
||||
aValue = int32_t(clamped(sign * value,
|
||||
int64_t(std::numeric_limits<int32_t>::min()),
|
||||
int64_t(std::numeric_limits<int32_t>::max())));
|
||||
return true;
|
||||
return ParseInteger(iter, end, aValue) && iter == end;
|
||||
}
|
||||
|
||||
float
|
||||
|
|
|
@ -141,6 +141,52 @@ public:
|
|||
static mozilla::RangedPtr<const PRUnichar>
|
||||
GetEndRangedPtr(const nsAString& aString);
|
||||
|
||||
/**
|
||||
* True if 'aCh' is a decimal digit.
|
||||
*/
|
||||
static inline bool IsDigit(PRUnichar aCh)
|
||||
{
|
||||
return aCh >= '0' && aCh <= '9';
|
||||
}
|
||||
|
||||
/**
|
||||
* Assuming that 'aCh' is a decimal digit, return its numeric value.
|
||||
*/
|
||||
static inline uint32_t DecimalDigitValue(PRUnichar aCh)
|
||||
{
|
||||
MOZ_ASSERT(IsDigit(aCh), "Digit expected");
|
||||
return aCh - '0';
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the sign (+ or -) of a number and moves aIter to the next
|
||||
* character if a sign is found.
|
||||
* @param aSignMultiplier [outparam] -1 if the sign is negative otherwise 1
|
||||
* @return false if we hit the end of the string (i.e. if aIter is initially
|
||||
* at aEnd, or if we reach aEnd right after the sign character).
|
||||
*/
|
||||
static inline bool
|
||||
ParseOptionalSign(mozilla::RangedPtr<const PRUnichar>& aIter,
|
||||
const mozilla::RangedPtr<const PRUnichar>& aEnd,
|
||||
int32_t& aSignMultiplier)
|
||||
{
|
||||
if (aIter == aEnd) {
|
||||
return false;
|
||||
}
|
||||
aSignMultiplier = *aIter == '-' ? -1 : 1;
|
||||
|
||||
mozilla::RangedPtr<const PRUnichar> iter(aIter);
|
||||
|
||||
if (*iter == '-' || *iter == '+') {
|
||||
++iter;
|
||||
if (iter == aEnd) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
aIter = iter;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a number of the form:
|
||||
* number ::= integer ([Ee] integer)? | [+-]? [0-9]* "." [0-9]+ ([Ee] integer)?
|
||||
|
@ -167,10 +213,21 @@ public:
|
|||
/**
|
||||
* Parse an integer of the form:
|
||||
* integer ::= [+-]? [0-9]+
|
||||
* Parsing fails if the number cannot be represented by an int32_t.
|
||||
* The returned number is clamped to an int32_t if outside that range.
|
||||
* If parsing succeeds, aIter is updated so that it points to the character
|
||||
* after the end of the number, otherwise it is left unchanged
|
||||
*/
|
||||
static bool
|
||||
ParseInteger(const nsAString& aString, int32_t& aValue);
|
||||
static bool ParseInteger(mozilla::RangedPtr<const PRUnichar>& aIter,
|
||||
const mozilla::RangedPtr<const PRUnichar>& aEnd,
|
||||
int32_t& aValue);
|
||||
|
||||
/**
|
||||
* Parse an integer of the form:
|
||||
* integer ::= [+-]? [0-9]+
|
||||
* The returned number is clamped to an int32_t if outside that range.
|
||||
* Parsing fails if there is anything left over after the number.
|
||||
*/
|
||||
static bool ParseInteger(const nsAString& aString, int32_t& aValue);
|
||||
|
||||
/**
|
||||
* Converts an nsStyleCoord into a userspace value. Handles units
|
||||
|
|
|
@ -168,8 +168,7 @@ SVGMotionSMILAnimationFunction::
|
|||
const nsAString& valuesStr = GetAttr(nsGkAtoms::values)->GetStringValue();
|
||||
SVGMotionSMILPathUtils::MotionValueParser parser(&pathGenerator,
|
||||
&mPathVertices);
|
||||
success =
|
||||
NS_SUCCEEDED(nsSMILParserUtils::ParseValuesGeneric(valuesStr, parser));
|
||||
success = nsSMILParserUtils::ParseValuesGeneric(valuesStr, parser);
|
||||
} else if (HasAttr(nsGkAtoms::to) || HasAttr(nsGkAtoms::by)) {
|
||||
// Apply 'from' value (or a dummy 0,0 'from' value)
|
||||
if (HasAttr(nsGkAtoms::from)) {
|
||||
|
@ -296,8 +295,8 @@ bool
|
|||
SVGMotionSMILAnimationFunction::
|
||||
GenerateValuesForPathAndPoints(Path* aPath,
|
||||
bool aIsKeyPoints,
|
||||
nsTArray<double>& aPointDistances,
|
||||
nsTArray<nsSMILValue>& aResult)
|
||||
FallibleTArray<double>& aPointDistances,
|
||||
nsSMILValueArray& aResult)
|
||||
{
|
||||
NS_ABORT_IF_FALSE(aResult.IsEmpty(), "outparam is non-empty");
|
||||
|
||||
|
@ -335,9 +334,9 @@ SVGMotionSMILAnimationFunction::GetValues(const nsISMILAttr& aSMILAttr,
|
|||
// Now: Make the actual list of nsSMILValues (using keyPoints, if set)
|
||||
bool isUsingKeyPoints = !mKeyPoints.IsEmpty();
|
||||
bool success = GenerateValuesForPathAndPoints(mPath, isUsingKeyPoints,
|
||||
isUsingKeyPoints ?
|
||||
isUsingKeyPoints ?
|
||||
mKeyPoints : mPathVertices,
|
||||
aResult);
|
||||
aResult);
|
||||
if (!success) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -402,19 +401,14 @@ SVGMotionSMILAnimationFunction::SetKeyPoints(const nsAString& aKeyPoints,
|
|||
mKeyPoints.Clear();
|
||||
aResult.SetTo(aKeyPoints);
|
||||
|
||||
nsresult rv =
|
||||
nsSMILParserUtils::ParseSemicolonDelimitedProgressList(aKeyPoints, false,
|
||||
mKeyPoints);
|
||||
|
||||
if (NS_SUCCEEDED(rv) && mKeyPoints.Length() < 1)
|
||||
rv = NS_ERROR_FAILURE;
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
mKeyPoints.Clear();
|
||||
}
|
||||
|
||||
mHasChanged = true;
|
||||
|
||||
if (!nsSMILParserUtils::ParseSemicolonDelimitedProgressList(aKeyPoints, false,
|
||||
mKeyPoints)) {
|
||||
mKeyPoints.Clear();
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -83,19 +83,19 @@ protected:
|
|||
void RebuildPathAndVerticesFromBasicAttrs(const nsIContent* aContextElem);
|
||||
bool GenerateValuesForPathAndPoints(Path* aPath,
|
||||
bool aIsKeyPoints,
|
||||
nsTArray<double>& aPointDistances,
|
||||
nsTArray<nsSMILValue>& aResult);
|
||||
FallibleTArray<double>& aPointDistances,
|
||||
nsSMILValueArray& aResult);
|
||||
|
||||
// Members
|
||||
// -------
|
||||
nsTArray<double> mKeyPoints; // parsed from "keyPoints" attribute.
|
||||
FallibleTArray<double> mKeyPoints; // parsed from "keyPoints" attribute.
|
||||
|
||||
RotateType mRotateType; // auto, auto-reverse, or explicit.
|
||||
float mRotateAngle; // the angle value, if explicit.
|
||||
|
||||
PathSourceType mPathSourceType; // source of our Path.
|
||||
RefPtr<Path> mPath; // representation of motion path.
|
||||
nsTArray<double> mPathVertices; // distances of vertices along path.
|
||||
FallibleTArray<double> mPathVertices; // distances of vertices along path.
|
||||
|
||||
bool mIsPathStale;
|
||||
};
|
||||
|
|
|
@ -126,7 +126,7 @@ SVGMotionSMILPathUtils::PathGenerator::
|
|||
|
||||
//----------------------------------------------------------------------
|
||||
// MotionValueParser methods
|
||||
nsresult
|
||||
bool
|
||||
SVGMotionSMILPathUtils::MotionValueParser::
|
||||
Parse(const nsAString& aValueStr)
|
||||
{
|
||||
|
@ -145,7 +145,7 @@ SVGMotionSMILPathUtils::MotionValueParser::
|
|||
success = !!mPointDistances->AppendElement(mDistanceSoFar);
|
||||
}
|
||||
}
|
||||
return success ? NS_OK : NS_ERROR_FAILURE;
|
||||
return success;
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -76,11 +76,12 @@ public:
|
|||
|
||||
// Class to assist in passing each subcomponent of a |values| attribute to
|
||||
// a PathGenerator, for generating a corresponding Path.
|
||||
class MotionValueParser : public nsSMILParserUtils::GenericValueParser
|
||||
class MOZ_STACK_CLASS MotionValueParser :
|
||||
public nsSMILParserUtils::GenericValueParser
|
||||
{
|
||||
public:
|
||||
MotionValueParser(PathGenerator* aPathGenerator,
|
||||
nsTArray<double>* aPointDistances)
|
||||
FallibleTArray<double>* aPointDistances)
|
||||
: mPathGenerator(aPathGenerator),
|
||||
mPointDistances(aPointDistances),
|
||||
mDistanceSoFar(0.0)
|
||||
|
@ -90,12 +91,12 @@ public:
|
|||
}
|
||||
|
||||
// nsSMILParserUtils::GenericValueParser interface
|
||||
virtual nsresult Parse(const nsAString& aValueStr) MOZ_OVERRIDE;
|
||||
virtual bool Parse(const nsAString& aValueStr) MOZ_OVERRIDE;
|
||||
|
||||
protected:
|
||||
PathGenerator* mPathGenerator;
|
||||
nsTArray<double>* mPointDistances;
|
||||
double mDistanceSoFar;
|
||||
PathGenerator* mPathGenerator;
|
||||
FallibleTArray<double>* mPointDistances;
|
||||
double mDistanceSoFar;
|
||||
};
|
||||
|
||||
};
|
||||
|
|
|
@ -151,7 +151,7 @@ SVGPathData::GetSegmentLengths(nsTArray<double> *aLengths) const
|
|||
}
|
||||
|
||||
bool
|
||||
SVGPathData::GetDistancesFromOriginToEndsOfVisibleSegments(nsTArray<double> *aOutput) const
|
||||
SVGPathData::GetDistancesFromOriginToEndsOfVisibleSegments(FallibleTArray<double> *aOutput) const
|
||||
{
|
||||
SVGPathTraversalState state;
|
||||
|
||||
|
|
|
@ -156,7 +156,7 @@ public:
|
|||
/**
|
||||
* Returns true, except on OOM, in which case returns false.
|
||||
*/
|
||||
bool GetDistancesFromOriginToEndsOfVisibleSegments(nsTArray<double> *aArray) const;
|
||||
bool GetDistancesFromOriginToEndsOfVisibleSegments(FallibleTArray<double> *aArray) const;
|
||||
|
||||
/**
|
||||
* This returns a path without the extra little line segments that
|
||||
|
|
|
@ -113,9 +113,6 @@ nsXBLProtoImpl::InstallImplementation(nsXBLPrototypeBinding* aPrototypeBinding,
|
|||
curr = curr->GetNext())
|
||||
curr->InstallMember(cx, propertyHolder);
|
||||
|
||||
// From here on out, work in the scope of the bound element.
|
||||
JSAutoCompartment ac2(cx, targetClassObject);
|
||||
|
||||
// Now, if we're using a separate XBL scope, enter the compartment of the
|
||||
// bound node and copy exposable properties to the prototype there. This
|
||||
// rewraps them appropriately, which should result in cross-compartment
|
||||
|
@ -135,6 +132,9 @@ nsXBLProtoImpl::InstallImplementation(nsXBLPrototypeBinding* aPrototypeBinding,
|
|||
}
|
||||
}
|
||||
|
||||
// From here on out, work in the scope of the bound element.
|
||||
JSAutoCompartment ac2(cx, targetClassObject);
|
||||
|
||||
// Install all of our field accessors.
|
||||
for (nsXBLProtoImplField* curr = mFields;
|
||||
curr;
|
||||
|
|
|
@ -30,6 +30,8 @@ support-files =
|
|||
file_bug503832.html
|
||||
file_bug655270.html
|
||||
file_bug670318.html
|
||||
file_bug852909.pdf
|
||||
file_bug852909.png
|
||||
file_bug941562-child.html
|
||||
file_bug941562.html
|
||||
print_postdata.sjs
|
||||
|
@ -59,6 +61,7 @@ support-files =
|
|||
[browser_bug655273.js]
|
||||
[browser_bug670318.js]
|
||||
[browser_bug673467.js]
|
||||
[browser_bug852909.js]
|
||||
[browser_bug92473.js]
|
||||
[browser_bug941562.js]
|
||||
[browser_loadDisallowInherit.js]
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
var rootDir = "http://mochi.test:8888/browser/docshell/test/browser/";
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
|
||||
gBrowser.selectedTab = gBrowser.addTab(rootDir + "file_bug852909.png");
|
||||
gBrowser.selectedBrowser.addEventListener("load", image, true);
|
||||
}
|
||||
|
||||
function image(event) {
|
||||
if (event.target != gBrowser.contentDocument) {
|
||||
return;
|
||||
}
|
||||
gBrowser.selectedBrowser.removeEventListener("load", image, true);
|
||||
|
||||
ok(!gBrowser.docShell.mayEnableCharacterEncodingMenu, "Docshell should say the menu should be disabled for images.");
|
||||
|
||||
gBrowser.removeCurrentTab();
|
||||
gBrowser.selectedTab = gBrowser.addTab(rootDir + "file_bug852909.pdf");
|
||||
gBrowser.selectedBrowser.addEventListener("load", pdf, true);
|
||||
}
|
||||
|
||||
function pdf(event) {
|
||||
if (event.target != gBrowser.contentDocument) {
|
||||
return;
|
||||
}
|
||||
gBrowser.selectedBrowser.removeEventListener("load", pdf, true);
|
||||
|
||||
ok(!gBrowser.docShell.mayEnableCharacterEncodingMenu, "Docshell should say the menu should be disabled for PDF.js.");
|
||||
|
||||
gBrowser.removeCurrentTab();
|
||||
finish();
|
||||
}
|
Двоичный файл не отображается.
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 94 B |
|
@ -0,0 +1,7 @@
|
|||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
# You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
ifdef MOZ_DEBUG
|
||||
DEFINES += -DMOZ_DEBUG=1
|
||||
endif
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -37,7 +37,7 @@ function checkAppInstallError(aMiniManifestURL, aExpectedError) {
|
|||
ok(true, "Got expected " + aExpectedError);
|
||||
PackagedTestHelper.next();
|
||||
} else {
|
||||
ok(false, "Got unexpected " + aError);
|
||||
ok(false, "Got unexpected " + error);
|
||||
PackagedTestHelper.finish();
|
||||
}
|
||||
};
|
||||
|
|
|
@ -25,6 +25,7 @@ HASINSTANCE_HOOK_NAME = '_hasInstance'
|
|||
NEWRESOLVE_HOOK_NAME = '_newResolve'
|
||||
ENUMERATE_HOOK_NAME= '_enumerate'
|
||||
ENUM_ENTRY_VARIABLE_NAME = 'strings'
|
||||
INSTANCE_RESERVED_SLOTS = 3
|
||||
|
||||
def replaceFileIfChanged(filename, newContents):
|
||||
"""
|
||||
|
@ -192,12 +193,13 @@ class CGDOMJSClass(CGThing):
|
|||
def define(self):
|
||||
traceHook = TRACE_HOOK_NAME if self.descriptor.customTrace else 'nullptr'
|
||||
callHook = LEGACYCALLER_HOOK_NAME if self.descriptor.operations["LegacyCaller"] else 'nullptr'
|
||||
slotCount = INSTANCE_RESERVED_SLOTS + self.descriptor.interface.totalMembersInSlots
|
||||
classFlags = "JSCLASS_IS_DOMJSCLASS | "
|
||||
if self.descriptor.interface.getExtendedAttribute("Global"):
|
||||
classFlags += "JSCLASS_DOM_GLOBAL | JSCLASS_GLOBAL_FLAGS_WITH_SLOTS(DOM_GLOBAL_SLOTS) | JSCLASS_IMPLEMENTS_BARRIERS"
|
||||
traceHook = "mozilla::dom::TraceGlobal"
|
||||
else:
|
||||
classFlags += "JSCLASS_HAS_RESERVED_SLOTS(3)"
|
||||
classFlags += "JSCLASS_HAS_RESERVED_SLOTS(%d)" % slotCount
|
||||
if self.descriptor.interface.getExtendedAttribute("NeedNewResolve"):
|
||||
newResolveHook = "(JSResolveOp)" + NEWRESOLVE_HOOK_NAME
|
||||
classFlags += " | JSCLASS_NEW_RESOLVE"
|
||||
|
@ -647,13 +649,16 @@ class CGHeaders(CGWrapper):
|
|||
dictionary, if passed, to decide what to do with interface types.
|
||||
"""
|
||||
assert not descriptor or not dictionary
|
||||
# Dictionaries have members that need to be actually
|
||||
# declared, not just forward-declared.
|
||||
if dictionary:
|
||||
headerSet = declareIncludes
|
||||
else:
|
||||
headerSet = bindingHeaders
|
||||
if t.nullable():
|
||||
if dictionary:
|
||||
# Need to make sure that Nullable as a dictionary
|
||||
# member works.
|
||||
declareIncludes.add("mozilla/dom/Nullable.h")
|
||||
else:
|
||||
bindingHeaders.add("mozilla/dom/Nullable.h")
|
||||
# Need to make sure that Nullable as a dictionary
|
||||
# member works.
|
||||
headerSet.add("mozilla/dom/Nullable.h")
|
||||
unrolled = t.unroll()
|
||||
if unrolled.isUnion():
|
||||
# UnionConversions.h includes UnionTypes.h
|
||||
|
@ -664,17 +669,12 @@ class CGHeaders(CGWrapper):
|
|||
declareIncludes.add("mozilla/dom/UnionTypes.h")
|
||||
elif unrolled.isDate():
|
||||
if dictionary or jsImplementedDescriptors:
|
||||
headerSet = declareIncludes
|
||||
declareIncludes.add("mozilla/dom/Date.h")
|
||||
else:
|
||||
headerSet = bindingHeaders
|
||||
headerSet.add("mozilla/dom/Date.h")
|
||||
bindingHeaders.add("mozilla/dom/Date.h")
|
||||
elif unrolled.isInterface():
|
||||
if unrolled.isSpiderMonkeyInterface():
|
||||
bindingHeaders.add("jsfriendapi.h")
|
||||
if dictionary:
|
||||
headerSet = declareIncludes
|
||||
else:
|
||||
headerSet = bindingHeaders
|
||||
headerSet.add("mozilla/dom/TypedArray.h")
|
||||
else:
|
||||
providers = getRelevantProviders(descriptor, config)
|
||||
|
@ -683,34 +683,28 @@ class CGHeaders(CGWrapper):
|
|||
typeDesc = p.getDescriptor(unrolled.inner.identifier.name)
|
||||
except NoSuchDescriptorError:
|
||||
continue
|
||||
if dictionary:
|
||||
# Dictionaries with interface members rely on the
|
||||
# actual class definition of that interface member
|
||||
# being visible in the binding header, because they
|
||||
# store them in nsRefPtr and have inline
|
||||
# constructors/destructors.
|
||||
#
|
||||
# XXXbz maybe dictionaries with interface members
|
||||
# should just have out-of-line constructors and
|
||||
# destructors?
|
||||
declareIncludes.add(typeDesc.headerFile)
|
||||
else:
|
||||
implementationIncludes.add(typeDesc.headerFile)
|
||||
# Dictionaries with interface members rely on the
|
||||
# actual class definition of that interface member
|
||||
# being visible in the binding header, because they
|
||||
# store them in nsRefPtr and have inline
|
||||
# constructors/destructors.
|
||||
#
|
||||
# XXXbz maybe dictionaries with interface members
|
||||
# should just have out-of-line constructors and
|
||||
# destructors?
|
||||
headerSet.add(typeDesc.headerFile)
|
||||
elif unrolled.isDictionary():
|
||||
bindingHeaders.add(self.getDeclarationFilename(unrolled.inner))
|
||||
headerSet.add(self.getDeclarationFilename(unrolled.inner))
|
||||
elif unrolled.isCallback():
|
||||
# Callbacks are both a type and an object
|
||||
bindingHeaders.add(self.getDeclarationFilename(t.unroll()))
|
||||
headerSet.add(self.getDeclarationFilename(t.unroll()))
|
||||
elif unrolled.isFloat() and not unrolled.isUnrestricted():
|
||||
# Restricted floats are tested for finiteness
|
||||
bindingHeaders.add("mozilla/FloatingPoint.h")
|
||||
bindingHeaders.add("mozilla/dom/PrimitiveConversions.h")
|
||||
elif unrolled.isEnum():
|
||||
filename = self.getDeclarationFilename(unrolled.inner)
|
||||
# Do nothing if the enum is defined in the same webidl file
|
||||
# (the binding header doesn't need to include itself).
|
||||
if filename != prefix + ".h":
|
||||
declareIncludes.add(filename)
|
||||
declareIncludes.add(filename)
|
||||
elif unrolled.isPrimitive():
|
||||
bindingHeaders.add("mozilla/dom/PrimitiveConversions.h")
|
||||
|
||||
|
@ -718,6 +712,9 @@ class CGHeaders(CGWrapper):
|
|||
getAllTypes(descriptors + callbackDescriptors, dictionaries,
|
||||
callbacks))
|
||||
|
||||
# Now make sure we're not trying to include the header from inside itself
|
||||
declareIncludes.discard(prefix + ".h");
|
||||
|
||||
# Now for non-callback descriptors make sure we include any
|
||||
# headers needed by Func declarations.
|
||||
for desc in descriptors:
|
||||
|
@ -2169,9 +2166,12 @@ class CGConstructorEnabledViaFunc(CGAbstractMethod):
|
|||
def CreateBindingJSObject(descriptor, properties, parent):
|
||||
# When we have unforgeable properties, we're going to define them
|
||||
# on our object, so we have to root it when we create it, so it
|
||||
# won't suddenly die while defining the unforgeables.
|
||||
# won't suddenly die while defining the unforgeables. Similarly,
|
||||
# if we have members in slots we'll have to call the getters which
|
||||
# could also GC.
|
||||
needRoot = (properties.unforgeableAttrs.hasNonChromeOnly() or
|
||||
properties.unforgeableAttrs.hasChromeOnly())
|
||||
properties.unforgeableAttrs.hasChromeOnly() or
|
||||
descriptor.interface.hasMembersInSlots())
|
||||
if needRoot:
|
||||
objDecl = " JS::Rooted<JSObject*> obj(aCx);\n"
|
||||
else:
|
||||
|
@ -2286,6 +2286,27 @@ def AssertInheritanceChain(descriptor):
|
|||
" MOZ_ASSERT(ToSupportsIsCorrect(aObject));\n")
|
||||
return asserts
|
||||
|
||||
def InitMemberSlots(descriptor, wrapperCache):
|
||||
"""
|
||||
Initialize member slots on our JS object if we're supposed to have some.
|
||||
|
||||
Note that this is called after the SetWrapper() call in the
|
||||
wrapperCache case, since that can affect how our getters behave
|
||||
and we plan to invoke them here. So if we fail, we need to
|
||||
ClearWrapper.
|
||||
"""
|
||||
if not descriptor.interface.hasMembersInSlots():
|
||||
return ""
|
||||
if wrapperCache:
|
||||
clearWrapper = " aCache->ClearWrapper();\n"
|
||||
else:
|
||||
clearWrapper = ""
|
||||
return CGIndenter(CGGeneric(
|
||||
("if (!UpdateMemberSlots(aCx, obj, aObject)) {\n"
|
||||
"%s"
|
||||
" return nullptr;\n"
|
||||
"}" % clearWrapper))).define()
|
||||
|
||||
class CGWrapWithCacheMethod(CGAbstractMethod):
|
||||
"""
|
||||
Create a wrapper JSObject for a given native that implements nsWrapperCache.
|
||||
|
@ -2303,6 +2324,7 @@ class CGWrapWithCacheMethod(CGAbstractMethod):
|
|||
|
||||
def definition_body(self):
|
||||
if self.descriptor.nativeOwnership == 'worker':
|
||||
assert not self.descriptor.interface.hasMembersInSlots()
|
||||
return """ return aObject->GetJSObject();"""
|
||||
|
||||
assertISupportsInheritance = (
|
||||
|
@ -2337,12 +2359,13 @@ class CGWrapWithCacheMethod(CGAbstractMethod):
|
|||
%s
|
||||
%s
|
||||
aCache->SetWrapper(obj);
|
||||
|
||||
%s
|
||||
return obj;""" % (AssertInheritanceChain(self.descriptor),
|
||||
assertISupportsInheritance,
|
||||
CreateBindingJSObject(self.descriptor, self.properties,
|
||||
"parent"),
|
||||
InitUnforgeableProperties(self.descriptor, self.properties))
|
||||
InitUnforgeableProperties(self.descriptor, self.properties),
|
||||
InitMemberSlots(self.descriptor, True))
|
||||
|
||||
class CGWrapMethod(CGAbstractMethod):
|
||||
def __init__(self, descriptor):
|
||||
|
@ -2382,12 +2405,14 @@ class CGWrapNonWrapperCacheMethod(CGAbstractMethod):
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
%s
|
||||
%s
|
||||
%s
|
||||
return obj;""" % (AssertInheritanceChain(self.descriptor),
|
||||
CreateBindingJSObject(self.descriptor, self.properties,
|
||||
"global"),
|
||||
InitUnforgeableProperties(self.descriptor, self.properties))
|
||||
InitUnforgeableProperties(self.descriptor, self.properties),
|
||||
InitMemberSlots(self.descriptor, False))
|
||||
|
||||
class CGWrapGlobalMethod(CGAbstractMethod):
|
||||
"""
|
||||
|
@ -2430,6 +2455,36 @@ class CGWrapGlobalMethod(CGAbstractMethod):
|
|||
self.descriptor.nativeType,
|
||||
InitUnforgeableProperties(self.descriptor, self.properties))
|
||||
|
||||
class CGUpdateMemberSlotsMethod(CGAbstractMethod):
|
||||
def __init__(self, descriptor):
|
||||
args = [Argument('JSContext*', 'aCx'),
|
||||
Argument('JS::Handle<JSObject*>', 'aWrapper'),
|
||||
Argument(descriptor.nativeType + '*' , 'aObject')]
|
||||
CGAbstractMethod.__init__(self, descriptor, 'UpdateMemberSlots', 'bool', args)
|
||||
|
||||
def definition_body(self):
|
||||
slotMembers = (m for m in self.descriptor.interface.members if
|
||||
m.isAttr() and m.getExtendedAttribute("StoreInSlot"))
|
||||
def slotIndex(member):
|
||||
return member.slotIndex + INSTANCE_RESERVED_SLOTS
|
||||
storeSlots = (
|
||||
CGGeneric(
|
||||
'static_assert(%d < js::shadow::Object::MAX_FIXED_SLOTS,\n'
|
||||
' "Not enough fixed slots to fit \'%s.%s\'");\n'
|
||||
"if (!get_%s(aCx, aWrapper, aObject, args)) {\n"
|
||||
" return false;\n"
|
||||
"}\n"
|
||||
"js::SetReservedSlot(aWrapper, %d, args.rval());" %
|
||||
(slotIndex(m), self.descriptor.interface.identifier.name,
|
||||
m.identifier.name, m.identifier.name, slotIndex(m)))
|
||||
for m in slotMembers)
|
||||
body = CGList(storeSlots, "\n\n")
|
||||
body.prepend(CGGeneric("JS::Rooted<JS::Value> temp(aCx);\n"
|
||||
"JSJitGetterCallArgs args(&temp);"))
|
||||
body.append(CGGeneric("return true;"))
|
||||
|
||||
return CGIndenter(body).define()
|
||||
|
||||
builtinNames = {
|
||||
IDLType.Tags.bool: 'bool',
|
||||
IDLType.Tags.int8: 'int8_t',
|
||||
|
@ -4588,9 +4643,13 @@ def needCx(returnType, arguments, extendedAttributes, considerTypes):
|
|||
'implicitJSContext' in extendedAttributes)
|
||||
|
||||
def needScopeObject(returnType, arguments, extendedAttributes,
|
||||
isWrapperCached, considerTypes):
|
||||
isWrapperCached, considerTypes, isMember):
|
||||
"""
|
||||
isMember should be true if we're dealing with an attribute
|
||||
annotated as [StoreInSlot].
|
||||
"""
|
||||
return (considerTypes and not isWrapperCached and
|
||||
(typeNeedsScopeObject(returnType, True) or
|
||||
((not isMember and typeNeedsScopeObject(returnType, True)) or
|
||||
any(typeNeedsScopeObject(a.type) for a in arguments)))
|
||||
|
||||
class CGCallGenerator(CGThing):
|
||||
|
@ -4891,7 +4950,8 @@ if (global.Failed()) {
|
|||
needsUnwrappedVar = True
|
||||
argsPost.append("js::GetObjectCompartment(unwrappedObj.empty() ? obj : unwrappedObj.ref())")
|
||||
elif needScopeObject(returnType, arguments, self.extendedAttributes,
|
||||
descriptor.wrapperCache, True):
|
||||
descriptor.wrapperCache, True,
|
||||
idlNode.getExtendedAttribute("StoreInSlot")):
|
||||
needsUnwrap = True
|
||||
needsUnwrappedVar = True
|
||||
argsPre.append("unwrappedObj.empty() ? obj : unwrappedObj.ref()")
|
||||
|
@ -6001,16 +6061,34 @@ class CGMemberJITInfo(CGThing):
|
|||
return ""
|
||||
|
||||
def defineJitInfo(self, infoName, opName, opType, infallible, constant,
|
||||
pure, returnTypes):
|
||||
pure, hasSlot, slotIndex, returnTypes, args):
|
||||
"""
|
||||
args is None if we don't want to output argTypes for some
|
||||
reason (e.g. we have overloads or we're not a method) and
|
||||
otherwise an iterable of the arguments for this method.
|
||||
"""
|
||||
assert(not constant or pure) # constants are always pure
|
||||
assert(not hasSlot or pure) # Things with slots had better be pure
|
||||
protoID = "prototypes::id::%s" % self.descriptor.name
|
||||
depth = "PrototypeTraits<%s>::Depth" % protoID
|
||||
failstr = toStringBool(infallible)
|
||||
conststr = toStringBool(constant)
|
||||
purestr = toStringBool(pure)
|
||||
slotStr = toStringBool(hasSlot)
|
||||
returnType = reduce(CGMemberJITInfo.getSingleReturnType, returnTypes,
|
||||
"")
|
||||
if args is not None:
|
||||
argTypes = "%s_argTypes" % infoName
|
||||
args = [CGMemberJITInfo.getJSArgType(arg.type) for arg in args]
|
||||
args.append("JSJitInfo::ArgTypeListEnd")
|
||||
argTypesDecl = (
|
||||
"static const JSJitInfo::ArgType %s[] = { %s };\n" %
|
||||
(argTypes, ", ".join(args)))
|
||||
else:
|
||||
argTypes = "nullptr"
|
||||
argTypesDecl = ""
|
||||
return ("\n"
|
||||
"%s"
|
||||
"static const JSJitInfo %s = {\n"
|
||||
" { %s },\n"
|
||||
" %s,\n"
|
||||
|
@ -6018,10 +6096,15 @@ class CGMemberJITInfo(CGThing):
|
|||
" JSJitInfo::%s,\n"
|
||||
" %s, /* isInfallible. False in setters. */\n"
|
||||
" %s, /* isConstant. Only relevant for getters. */\n"
|
||||
" %s, /* isPure. Only relevant for getters. */\n"
|
||||
" %s /* returnType. Only relevant for getters/methods. */\n"
|
||||
"};\n" % (infoName, opName, protoID, depth, opType, failstr,
|
||||
conststr, purestr, returnType))
|
||||
" %s, /* isPure. Not relevant for setters. */\n"
|
||||
" %s, /* hasSlot. Only relevant for getters. */\n"
|
||||
" %d, /* Reserved slot index, if we're stored in a slot, else 0. */\n"
|
||||
" %s, /* returnType. Not relevant for setters. */\n"
|
||||
" %s, /* argTypes. Only relevant for methods */\n"
|
||||
" nullptr /* parallelNative */\n"
|
||||
"};\n" % (argTypesDecl, infoName, opName, protoID, depth,
|
||||
opType, failstr, conststr, purestr, slotStr,
|
||||
slotIndex, returnType, argTypes))
|
||||
|
||||
def define(self):
|
||||
if self.member.isAttr():
|
||||
|
@ -6036,9 +6119,19 @@ class CGMemberJITInfo(CGThing):
|
|||
assert (getterinfal or (not getterconst and not getterpure))
|
||||
|
||||
getterinfal = getterinfal and infallibleForMember(self.member, self.member.type, self.descriptor)
|
||||
isInSlot = self.member.getExtendedAttribute("StoreInSlot")
|
||||
if isInSlot:
|
||||
slotIndex = INSTANCE_RESERVED_SLOTS + self.member.slotIndex;
|
||||
if slotIndex >= 16 : # JS engine currently allows 16 fixed slots
|
||||
raise TypeError("Make sure we can actually have this many "
|
||||
"fixed slots, please!")
|
||||
else:
|
||||
slotIndex = 0
|
||||
|
||||
result = self.defineJitInfo(getterinfo, getter, "Getter",
|
||||
getterinfal, getterconst, getterpure,
|
||||
[self.member.type])
|
||||
isInSlot, slotIndex,
|
||||
[self.member.type], None)
|
||||
if (not self.member.readonly or
|
||||
self.member.getExtendedAttribute("PutForwards") is not None or
|
||||
self.member.getExtendedAttribute("Replaceable") is not None):
|
||||
|
@ -6048,14 +6141,16 @@ class CGMemberJITInfo(CGThing):
|
|||
setter = ("(JSJitGetterOp)set_%s" % self.member.identifier.name)
|
||||
# Setters are always fallible, since they have to do a typed unwrap.
|
||||
result += self.defineJitInfo(setterinfo, setter, "Setter",
|
||||
False, False, False,
|
||||
[BuiltinTypes[IDLBuiltinType.Types.void]])
|
||||
False, False, False, False, 0,
|
||||
[BuiltinTypes[IDLBuiltinType.Types.void]],
|
||||
None)
|
||||
return result
|
||||
if self.member.isMethod():
|
||||
methodinfo = ("%s_methodinfo" % self.member.identifier.name)
|
||||
name = CppKeywords.checkMethodName(self.member.identifier.name)
|
||||
# Actually a JSJitMethodOp, but JSJitGetterOp is first in the union.
|
||||
method = ("(JSJitGetterOp)%s" % name)
|
||||
methodPure = self.member.getExtendedAttribute("Pure")
|
||||
|
||||
# Methods are infallible if they are infallible, have no arguments
|
||||
# to unwrap, and have a return type that's infallible to wrap up for
|
||||
|
@ -6065,18 +6160,26 @@ class CGMemberJITInfo(CGThing):
|
|||
# Don't handle overloading. If there's more than one signature,
|
||||
# one of them must take arguments.
|
||||
methodInfal = False
|
||||
args = None
|
||||
else:
|
||||
sig = sigs[0]
|
||||
# XXXbz can we move the smarts about fallibility due to arg
|
||||
# conversions into the JIT, using our new args stuff?
|
||||
if (len(sig[1]) != 0 or
|
||||
not infallibleForMember(self.member, sig[0], self.descriptor)):
|
||||
# We have arguments or our return-value boxing can fail
|
||||
methodInfal = False
|
||||
else:
|
||||
methodInfal = "infallible" in self.descriptor.getExtendedAttributes(self.member)
|
||||
# For now, only bother to output args if we're pure
|
||||
if methodPure:
|
||||
args = sig[1]
|
||||
else:
|
||||
args = None
|
||||
|
||||
result = self.defineJitInfo(methodinfo, method, "Method",
|
||||
methodInfal, False, False,
|
||||
[s[0] for s in sigs])
|
||||
methodInfal, False, methodPure, False, 0,
|
||||
[s[0] for s in sigs], args)
|
||||
return result
|
||||
raise TypeError("Illegal member type to CGPropertyJITInfo")
|
||||
|
||||
|
@ -6158,6 +6261,74 @@ class CGMemberJITInfo(CGThing):
|
|||
# Different types
|
||||
return "JSVAL_TYPE_UNKNOWN"
|
||||
|
||||
@staticmethod
|
||||
def getJSArgType(t):
|
||||
assert not t.isVoid()
|
||||
if t.nullable():
|
||||
# Sometimes it might return null, sometimes not
|
||||
return "JSJitInfo::ArgType(JSJitInfo::Null | %s)" % CGMemberJITInfo.getJSArgType(t.inner)
|
||||
if t.isArray():
|
||||
# No idea yet
|
||||
assert False
|
||||
if t.isSequence():
|
||||
return "JSJitInfo::Object"
|
||||
if t.isGeckoInterface():
|
||||
return "JSJitInfo::Object"
|
||||
if t.isString():
|
||||
return "JSJitInfo::String"
|
||||
if t.isEnum():
|
||||
return "JSJitInfo::String"
|
||||
if t.isCallback():
|
||||
return "JSJitInfo::Object"
|
||||
if t.isAny():
|
||||
# The whole point is to return various stuff
|
||||
return "JSJitInfo::Any"
|
||||
if t.isObject():
|
||||
return "JSJitInfo::Object"
|
||||
if t.isSpiderMonkeyInterface():
|
||||
return "JSJitInfo::Object"
|
||||
if t.isUnion():
|
||||
u = t.unroll();
|
||||
type = "JSJitInfo::Null" if u.hasNullableType else ""
|
||||
return ("JSJitInfo::ArgType(%s)" %
|
||||
reduce(CGMemberJITInfo.getSingleArgType,
|
||||
u.flatMemberTypes, type))
|
||||
if t.isDictionary():
|
||||
return "JSJitInfo::Object"
|
||||
if t.isDate():
|
||||
return "JSJitInfo::Object"
|
||||
if not t.isPrimitive():
|
||||
raise TypeError("No idea what type " + str(t) + " is.")
|
||||
tag = t.tag()
|
||||
if tag == IDLType.Tags.bool:
|
||||
return "JSJitInfo::Boolean"
|
||||
if tag in [IDLType.Tags.int8, IDLType.Tags.uint8,
|
||||
IDLType.Tags.int16, IDLType.Tags.uint16,
|
||||
IDLType.Tags.int32]:
|
||||
return "JSJitInfo::Integer"
|
||||
if tag in [IDLType.Tags.int64, IDLType.Tags.uint64,
|
||||
IDLType.Tags.unrestricted_float, IDLType.Tags.float,
|
||||
IDLType.Tags.unrestricted_double, IDLType.Tags.double]:
|
||||
# These all use JS_NumberValue, which can return int or double.
|
||||
# But TI treats "double" as meaning "int or double", so we're
|
||||
# good to return JSVAL_TYPE_DOUBLE here.
|
||||
return "JSJitInfo::Double"
|
||||
if tag != IDLType.Tags.uint32:
|
||||
raise TypeError("No idea what type " + str(t) + " is.")
|
||||
# uint32 is sometimes int and sometimes double.
|
||||
return "JSJitInfo::Double"
|
||||
|
||||
@staticmethod
|
||||
def getSingleArgType(existingType, t):
|
||||
type = CGMemberJITInfo.getJSArgType(t)
|
||||
if existingType == "":
|
||||
# First element of the list; just return its type
|
||||
return type
|
||||
|
||||
if type == existingType:
|
||||
return existingType
|
||||
return "%s | %s" % (existingType, type)
|
||||
|
||||
def getEnumValueName(value):
|
||||
# Some enum values can be empty strings. Others might have weird
|
||||
# characters in them. Deal with the former by returning "_empty",
|
||||
|
@ -8292,6 +8463,10 @@ class CGDescriptor(CGThing):
|
|||
|
||||
if descriptor.concrete:
|
||||
if descriptor.proxy:
|
||||
if descriptor.interface.totalMembersInSlots != 0:
|
||||
raise TypeError("We can't have extra reserved slots for "
|
||||
"proxy interface %s" %
|
||||
descriptor.interface.identifier.name)
|
||||
cgThings.append(CGGeneric("""static_assert(IsBaseOf<nsISupports, %s >::value,
|
||||
"We don't support non-nsISupports native classes for "
|
||||
"proxy-based bindings yet");
|
||||
|
@ -8309,6 +8484,12 @@ class CGDescriptor(CGThing):
|
|||
else:
|
||||
cgThings.append(CGDOMJSClass(descriptor))
|
||||
cgThings.append(CGGetJSClassMethod(descriptor))
|
||||
if descriptor.interface.hasMembersInSlots():
|
||||
if descriptor.interface.hasChildInterfaces():
|
||||
raise TypeError("We don't support members in slots on "
|
||||
"non-leaf interfaces like %s" %
|
||||
descriptor.interface.identifier.name)
|
||||
cgThings.append(CGUpdateMemberSlotsMethod(descriptor))
|
||||
|
||||
if descriptor.interface.getExtendedAttribute("Global"):
|
||||
assert descriptor.wrapperCache
|
||||
|
@ -9453,8 +9634,9 @@ class CGNativeMember(ClassMethod):
|
|||
self.passJSBitsAsNeeded):
|
||||
args.insert(0, Argument("JSContext*", "cx"))
|
||||
if needScopeObject(returnType, argList, self.extendedAttrs,
|
||||
self.descriptorProvider,
|
||||
self.passJSBitsAsNeeded):
|
||||
self.descriptorProvider.wrapperCache,
|
||||
self.passJSBitsAsNeeded,
|
||||
self.member.getExtendedAttribute("StoreInSlot")):
|
||||
args.insert(1, Argument("JS::Handle<JSObject*>", "obj"))
|
||||
# And if we're static, a global
|
||||
if self.member.isStatic():
|
||||
|
@ -9867,7 +10049,8 @@ class CGExampleRoot(CGThing):
|
|||
"mozilla/Attributes.h",
|
||||
"mozilla/ErrorResult.h" ],
|
||||
[ "%s.h" % interfaceName,
|
||||
"mozilla/dom/%sBinding.h" % interfaceName,
|
||||
("mozilla/dom/%s" %
|
||||
CGHeaders.getDeclarationFilename(descriptor.interface)),
|
||||
"nsContentUtils.h" ], "", self.root);
|
||||
|
||||
# And now some include guards
|
||||
|
|
|
@ -493,6 +493,11 @@ class IDLInterface(IDLObjectWithScope):
|
|||
self.interfacesImplementingSelf = set()
|
||||
self._hasChildInterfaces = False
|
||||
self._isOnGlobalProtoChain = False
|
||||
# Tracking of the number of reserved slots we need for our
|
||||
# members and those of ancestor interfaces.
|
||||
self.totalMembersInSlots = 0
|
||||
# Tracking of the number of own own members we have in slots
|
||||
self._ownMembersInSlots = 0
|
||||
|
||||
IDLObjectWithScope.__init__(self, location, parentScope, name)
|
||||
|
||||
|
@ -556,6 +561,8 @@ class IDLInterface(IDLObjectWithScope):
|
|||
|
||||
self.parent._hasChildInterfaces = True
|
||||
|
||||
self.totalMembersInSlots = self.parent.totalMembersInSlots
|
||||
|
||||
# Interfaces with [Global] must not have anything inherit from them
|
||||
if self.parent.getExtendedAttribute("Global"):
|
||||
# Note: This is not a self.parent.isOnGlobalProtoChain() check
|
||||
|
@ -651,6 +658,14 @@ class IDLInterface(IDLObjectWithScope):
|
|||
not hasattr(member, "originatingInterface")):
|
||||
member.originatingInterface = self
|
||||
|
||||
# Compute slot indices for our members before we pull in
|
||||
# unforgeable members from our parent.
|
||||
for member in self.members:
|
||||
if member.isAttr() and member.getExtendedAttribute("StoreInSlot"):
|
||||
member.slotIndex = self.totalMembersInSlots
|
||||
self.totalMembersInSlots += 1
|
||||
self._ownMembersInSlots += 1
|
||||
|
||||
if self.parent:
|
||||
# Make sure we don't shadow any of the [Unforgeable] attributes on
|
||||
# our ancestor interfaces. We don't have to worry about
|
||||
|
@ -1072,6 +1087,9 @@ class IDLInterface(IDLObjectWithScope):
|
|||
deps.add(self.parent)
|
||||
return deps
|
||||
|
||||
def hasMembersInSlots(self):
|
||||
return self._ownMembersInSlots != 0
|
||||
|
||||
class IDLDictionary(IDLObjectWithScope):
|
||||
def __init__(self, location, parentScope, name, parent, members):
|
||||
assert isinstance(parentScope, IDLScope)
|
||||
|
@ -2603,6 +2621,7 @@ class IDLAttribute(IDLInterfaceMember):
|
|||
self.stringifier = stringifier
|
||||
self.enforceRange = False
|
||||
self.clamp = False
|
||||
self.slotIndex = 0
|
||||
|
||||
if static and identifier.name == "prototype":
|
||||
raise WebIDLError("The identifier of a static attribute must not be 'prototype'",
|
||||
|
@ -2669,14 +2688,16 @@ class IDLAttribute(IDLInterfaceMember):
|
|||
[self.location])
|
||||
elif (((identifier == "Throws" or identifier == "GetterThrows") and
|
||||
(self.getExtendedAttribute("Pure") or
|
||||
self.getExtendedAttribute("StoreInSlot") or
|
||||
self.getExtendedAttribute("SameObject") or
|
||||
self.getExtendedAttribute("Constant"))) or
|
||||
((identifier == "Pure" or identifier == "SameObject" or
|
||||
identifier == "Constant") and
|
||||
identifier == "Constant" or identifier == "StoreInSlot") and
|
||||
(self.getExtendedAttribute("Throws") or
|
||||
self.getExtendedAttribute("GetterThrows")))):
|
||||
raise WebIDLError("Throwing things can't be [Pure] or [Constant] "
|
||||
"or [SameObject]", [attr.location])
|
||||
"or [SameObject] or [StoreInSlot]",
|
||||
[attr.location])
|
||||
elif identifier == "LenientThis":
|
||||
if not attr.noArguments():
|
||||
raise WebIDLError("[LenientThis] must take no arguments",
|
||||
|
@ -2745,6 +2766,7 @@ class IDLAttribute(IDLInterfaceMember):
|
|||
identifier == "SameObject" or
|
||||
identifier == "Constant" or
|
||||
identifier == "Func" or
|
||||
identifier == "StoreInSlot" or
|
||||
identifier == "NewObject"):
|
||||
# Known attributes that we don't need to do anything with here
|
||||
pass
|
||||
|
@ -3264,10 +3286,10 @@ class IDLMethod(IDLInterfaceMember, IDLScope):
|
|||
elif identifier == "Constant":
|
||||
raise WebIDLError("Methods must not be flagged as [Constant]",
|
||||
[attr.location, self.location]);
|
||||
elif identifier == "Pure":
|
||||
raise WebIDLError("Methods must not be flagged as [Pure] and if "
|
||||
"that changes, don't forget to check for [Throws]",
|
||||
[attr.location, self.location]);
|
||||
elif ((identifier == "Pure" and self.getExtendedAttribute("Throws")) or
|
||||
(identifier == "Throws" and self.getExtendedAttribute("Pure"))):
|
||||
raise WebIDLError("Throwing methods can't be [Pure]",
|
||||
[attr.location]);
|
||||
elif identifier == "PutForwards":
|
||||
raise WebIDLError("Only attributes support [PutForwards]",
|
||||
[attr.location, self.location])
|
||||
|
@ -3287,6 +3309,7 @@ class IDLMethod(IDLInterfaceMember, IDLScope):
|
|||
identifier == "ChromeOnly" or
|
||||
identifier == "Pref" or
|
||||
identifier == "Func" or
|
||||
identifier == "Pure" or
|
||||
identifier == "WebGLHandlesContextLoss"):
|
||||
# Known attributes that we don't need to do anything with here
|
||||
pass
|
||||
|
|
|
@ -7,36 +7,29 @@
|
|||
#include "BluetoothRilListener.h"
|
||||
|
||||
#include "BluetoothHfpManager.h"
|
||||
#include "nsIIccProvider.h"
|
||||
#include "nsIMobileConnectionProvider.h"
|
||||
#include "nsITelephonyProvider.h"
|
||||
#include "nsIDOMMobileConnection.h"
|
||||
#include "nsIRadioInterfaceLayer.h"
|
||||
#include "nsRadioInterfaceLayer.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsString.h"
|
||||
|
||||
USING_BLUETOOTH_NAMESPACE
|
||||
|
||||
namespace {
|
||||
|
||||
/**
|
||||
* IccListener
|
||||
*/
|
||||
class IccListener : public nsIIccListener
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIICCLISTENER
|
||||
|
||||
IccListener() { }
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS1(IccListener, nsIIccListener)
|
||||
|
||||
NS_IMETHODIMP
|
||||
IccListener::NotifyIccInfoChanged()
|
||||
{
|
||||
// mOwner would be set to nullptr only in the dtor of BluetoothRilListener
|
||||
NS_ENSURE_TRUE(mOwner, NS_ERROR_FAILURE);
|
||||
|
||||
BluetoothHfpManager* hfp = BluetoothHfpManager::Get();
|
||||
hfp->HandleIccInfoChanged();
|
||||
NS_ENSURE_TRUE(hfp, NS_ERROR_FAILURE);
|
||||
|
||||
hfp->HandleIccInfoChanged(mOwner->mClientId);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -59,25 +52,43 @@ IccListener::NotifyCardStateChanged()
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
bool
|
||||
IccListener::Listen(bool aStart)
|
||||
{
|
||||
NS_ENSURE_TRUE(mOwner, false);
|
||||
|
||||
nsCOMPtr<nsIIccProvider> provider =
|
||||
do_GetService(NS_RILCONTENTHELPER_CONTRACTID);
|
||||
NS_ENSURE_TRUE(provider, false);
|
||||
|
||||
nsresult rv;
|
||||
if (aStart) {
|
||||
rv = provider->RegisterIccMsg(mOwner->mClientId, this);
|
||||
} else {
|
||||
rv = provider->UnregisterIccMsg(mOwner->mClientId, this);
|
||||
}
|
||||
|
||||
return NS_SUCCEEDED(rv);
|
||||
}
|
||||
|
||||
void
|
||||
IccListener::SetOwner(BluetoothRilListener *aOwner)
|
||||
{
|
||||
mOwner = aOwner;
|
||||
}
|
||||
|
||||
/**
|
||||
* MobileConnectionListener
|
||||
*/
|
||||
class MobileConnectionListener : public nsIMobileConnectionListener
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIMOBILECONNECTIONLISTENER
|
||||
|
||||
MobileConnectionListener() { }
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS1(MobileConnectionListener, nsIMobileConnectionListener)
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileConnectionListener::NotifyVoiceChanged()
|
||||
{
|
||||
BluetoothHfpManager* hfp = BluetoothHfpManager::Get();
|
||||
hfp->HandleVoiceConnectionChanged();
|
||||
NS_ENSURE_TRUE(hfp, NS_OK);
|
||||
|
||||
hfp->HandleVoiceConnectionChanged(mClientId);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -137,20 +148,26 @@ MobileConnectionListener::NotifyRadioStateChanged()
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
bool
|
||||
MobileConnectionListener::Listen(bool aStart)
|
||||
{
|
||||
nsCOMPtr<nsIMobileConnectionProvider> provider =
|
||||
do_GetService(NS_RILCONTENTHELPER_CONTRACTID);
|
||||
NS_ENSURE_TRUE(provider, false);
|
||||
|
||||
nsresult rv;
|
||||
if (aStart) {
|
||||
rv = provider->RegisterMobileConnectionMsg(mClientId, this);
|
||||
} else {
|
||||
rv = provider->UnregisterMobileConnectionMsg(mClientId, this);
|
||||
}
|
||||
|
||||
return NS_SUCCEEDED(rv);
|
||||
}
|
||||
|
||||
/**
|
||||
* TelephonyListener Implementation
|
||||
*
|
||||
* TODO: Bug 921991 - B2G BT: support multiple sim cards
|
||||
*/
|
||||
class TelephonyListener : public nsITelephonyListener
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSITELEPHONYLISTENER
|
||||
|
||||
TelephonyListener() { }
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS1(TelephonyListener, nsITelephonyListener)
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -164,9 +181,10 @@ TelephonyListener::CallStateChanged(uint32_t aServiceId,
|
|||
bool aIsConference)
|
||||
{
|
||||
BluetoothHfpManager* hfp = BluetoothHfpManager::Get();
|
||||
NS_ENSURE_TRUE(hfp, NS_ERROR_FAILURE);
|
||||
|
||||
hfp->HandleCallStateChanged(aCallIndex, aCallState, EmptyString(), aNumber,
|
||||
aIsOutgoing, true);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -181,6 +199,8 @@ TelephonyListener::EnumerateCallState(uint32_t aServiceId,
|
|||
bool aIsConference)
|
||||
{
|
||||
BluetoothHfpManager* hfp = BluetoothHfpManager::Get();
|
||||
NS_ENSURE_TRUE(hfp, NS_ERROR_FAILURE);
|
||||
|
||||
hfp->HandleCallStateChanged(aCallIndex, aCallState, EmptyString(), aNumber,
|
||||
aIsOutgoing, false);
|
||||
return NS_OK;
|
||||
|
@ -192,6 +212,7 @@ TelephonyListener::NotifyError(uint32_t aServiceId,
|
|||
const nsAString& aError)
|
||||
{
|
||||
BluetoothHfpManager* hfp = BluetoothHfpManager::Get();
|
||||
NS_ENSURE_TRUE(hfp, NS_ERROR_FAILURE);
|
||||
|
||||
if (aCallIndex > 0) {
|
||||
// In order to not miss any related call state transition.
|
||||
|
@ -244,41 +265,123 @@ TelephonyListener::NotifyCdmaCallWaiting(uint32_t aServiceId,
|
|||
const nsAString& aNumber)
|
||||
{
|
||||
BluetoothHfpManager* hfp = BluetoothHfpManager::Get();
|
||||
NS_ENSURE_TRUE(hfp, NS_ERROR_FAILURE);
|
||||
|
||||
hfp->UpdateSecondNumber(aNumber);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
bool
|
||||
TelephonyListener::Listen(bool aStart)
|
||||
{
|
||||
nsCOMPtr<nsITelephonyProvider> provider =
|
||||
do_GetService(TELEPHONY_PROVIDER_CONTRACTID);
|
||||
NS_ENSURE_TRUE(provider, false);
|
||||
|
||||
nsresult rv;
|
||||
if (aStart) {
|
||||
rv = provider->RegisterListener(this);
|
||||
} else {
|
||||
rv = provider->UnregisterListener(this);
|
||||
}
|
||||
|
||||
return NS_SUCCEEDED(rv);
|
||||
}
|
||||
|
||||
/**
|
||||
* BluetoothRilListener
|
||||
*/
|
||||
BluetoothRilListener::BluetoothRilListener()
|
||||
{
|
||||
mIccListener = new IccListener();
|
||||
mMobileConnectionListener = new MobileConnectionListener();
|
||||
// Query number of total clients (sim slots)
|
||||
uint32_t numOfClients;
|
||||
nsCOMPtr<nsIRadioInterfaceLayer> radioInterfaceLayer =
|
||||
do_GetService(NS_RADIOINTERFACELAYER_CONTRACTID);
|
||||
NS_ENSURE_TRUE_VOID(radioInterfaceLayer);
|
||||
|
||||
radioInterfaceLayer->GetNumRadioInterfaces(&numOfClients);
|
||||
|
||||
// Init MobileConnectionListener array and IccInfoListener
|
||||
for (uint32_t i = 0; i < numOfClients; i++) {
|
||||
mMobileConnListeners.AppendElement(new MobileConnectionListener(i));
|
||||
}
|
||||
|
||||
mTelephonyListener = new TelephonyListener();
|
||||
mIccListener = new IccListener();
|
||||
mIccListener->SetOwner(this);
|
||||
|
||||
// Probe for available client
|
||||
SelectClient();
|
||||
}
|
||||
|
||||
BluetoothRilListener::~BluetoothRilListener()
|
||||
{
|
||||
mIccListener->SetOwner(nullptr);
|
||||
}
|
||||
|
||||
bool
|
||||
BluetoothRilListener::StartListening()
|
||||
BluetoothRilListener::Listen(bool aStart)
|
||||
{
|
||||
NS_ENSURE_TRUE(StartIccListening(), false);
|
||||
NS_ENSURE_TRUE(StartMobileConnectionListening(), false);
|
||||
NS_ENSURE_TRUE(StartTelephonyListening(), false);
|
||||
NS_ENSURE_TRUE(ListenMobileConnAndIccInfo(aStart), false);
|
||||
NS_ENSURE_TRUE(mTelephonyListener->Listen(aStart), false);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
BluetoothRilListener::StopListening()
|
||||
void
|
||||
BluetoothRilListener::SelectClient()
|
||||
{
|
||||
NS_ENSURE_TRUE(StopIccListening(), false);
|
||||
NS_ENSURE_TRUE(StopMobileConnectionListening(), false);
|
||||
NS_ENSURE_TRUE(StopTelephonyListening(), false);
|
||||
// Reset mClientId
|
||||
mClientId = mMobileConnListeners.Length();
|
||||
|
||||
return true;
|
||||
nsCOMPtr<nsIMobileConnectionProvider> connection =
|
||||
do_GetService(NS_RILCONTENTHELPER_CONTRACTID);
|
||||
NS_ENSURE_TRUE_VOID(connection);
|
||||
|
||||
for (uint32_t i = 0; i < mMobileConnListeners.Length(); i++) {
|
||||
nsCOMPtr<nsIDOMMozMobileConnectionInfo> voiceInfo;
|
||||
connection->GetVoiceConnectionInfo(i, getter_AddRefs(voiceInfo));
|
||||
if (!voiceInfo) {
|
||||
BT_WARNING("%s: Failed to get voice connection info", __FUNCTION__);
|
||||
continue;
|
||||
}
|
||||
|
||||
nsString regState;
|
||||
voiceInfo->GetState(regState);
|
||||
if (regState.EqualsLiteral("registered")) {
|
||||
// Found available client
|
||||
mClientId = i;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothRilListener::ServiceChanged(uint32_t aClientId, bool aRegistered)
|
||||
{
|
||||
// Stop listening
|
||||
ListenMobileConnAndIccInfo(false);
|
||||
|
||||
/**
|
||||
* aRegistered:
|
||||
* - TRUE: service becomes registered. We were listening to all clients
|
||||
* and one of them becomes available. Select it to listen.
|
||||
* - FALSE: service becomes un-registered. The client we were listening
|
||||
* becomes unavailable. Select another registered one to listen.
|
||||
*/
|
||||
if (aRegistered) {
|
||||
mClientId = aClientId;
|
||||
} else {
|
||||
SelectClient();
|
||||
}
|
||||
|
||||
// Restart listening
|
||||
ListenMobileConnAndIccInfo(true);
|
||||
|
||||
BT_LOGR("%s: %d client %d. new mClientId %d",
|
||||
__FUNCTION__, aRegistered, aClientId,
|
||||
(mClientId < mMobileConnListeners.Length()) ? mClientId : -1);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -288,78 +391,32 @@ BluetoothRilListener::EnumerateCalls()
|
|||
do_GetService(TELEPHONY_PROVIDER_CONTRACTID);
|
||||
NS_ENSURE_TRUE_VOID(provider);
|
||||
|
||||
provider->EnumerateCalls(mTelephonyListener);
|
||||
}
|
||||
nsCOMPtr<nsITelephonyListener> listener(
|
||||
do_QueryObject(mTelephonyListener));
|
||||
|
||||
// private
|
||||
bool
|
||||
BluetoothRilListener::StartIccListening()
|
||||
{
|
||||
nsCOMPtr<nsIIccProvider> provider =
|
||||
do_GetService(NS_RILCONTENTHELPER_CONTRACTID);
|
||||
NS_ENSURE_TRUE(provider, false);
|
||||
|
||||
// TODO: Bug 921991 - B2G BT: support multiple sim cards
|
||||
nsresult rv = provider->RegisterIccMsg(0, mIccListener);
|
||||
return NS_SUCCEEDED(rv);
|
||||
provider->EnumerateCalls(listener);
|
||||
}
|
||||
|
||||
bool
|
||||
BluetoothRilListener::StopIccListening()
|
||||
BluetoothRilListener::ListenMobileConnAndIccInfo(bool aStart)
|
||||
{
|
||||
nsCOMPtr<nsIIccProvider> provider =
|
||||
do_GetService(NS_RILCONTENTHELPER_CONTRACTID);
|
||||
NS_ENSURE_TRUE(provider, false);
|
||||
/**
|
||||
* mClientId < number of total clients:
|
||||
* The client with mClientId is available. Start/Stop listening
|
||||
* mobile connection and icc info of this client only.
|
||||
*
|
||||
* mClientId >= number of total clients:
|
||||
* All clients are unavailable. Start/Stop listening mobile
|
||||
* connections of all clients.
|
||||
*/
|
||||
if (mClientId < mMobileConnListeners.Length()) {
|
||||
NS_ENSURE_TRUE(mMobileConnListeners[mClientId]->Listen(aStart), false);
|
||||
NS_ENSURE_TRUE(mIccListener->Listen(aStart), false);
|
||||
} else {
|
||||
for (uint32_t i = 0; i < mMobileConnListeners.Length(); i++) {
|
||||
NS_ENSURE_TRUE(mMobileConnListeners[i]->Listen(aStart), false);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Bug 921991 - B2G BT: support multiple sim cards
|
||||
nsresult rv = provider->UnregisterIccMsg(0, mIccListener);
|
||||
return NS_SUCCEEDED(rv);
|
||||
}
|
||||
|
||||
bool
|
||||
BluetoothRilListener::StartMobileConnectionListening()
|
||||
{
|
||||
nsCOMPtr<nsIMobileConnectionProvider> provider =
|
||||
do_GetService(NS_RILCONTENTHELPER_CONTRACTID);
|
||||
NS_ENSURE_TRUE(provider, false);
|
||||
|
||||
// TODO: Bug 921991 - B2G BT: support multiple sim cards
|
||||
nsresult rv = provider->
|
||||
RegisterMobileConnectionMsg(0, mMobileConnectionListener);
|
||||
return NS_SUCCEEDED(rv);
|
||||
}
|
||||
|
||||
bool
|
||||
BluetoothRilListener::StopMobileConnectionListening()
|
||||
{
|
||||
nsCOMPtr<nsIMobileConnectionProvider> provider =
|
||||
do_GetService(NS_RILCONTENTHELPER_CONTRACTID);
|
||||
NS_ENSURE_TRUE(provider, false);
|
||||
|
||||
// TODO: Bug 921991 - B2G BT: support multiple sim cards
|
||||
nsresult rv = provider->
|
||||
UnregisterMobileConnectionMsg(0, mMobileConnectionListener);
|
||||
return NS_SUCCEEDED(rv);
|
||||
}
|
||||
|
||||
bool
|
||||
BluetoothRilListener::StartTelephonyListening()
|
||||
{
|
||||
nsCOMPtr<nsITelephonyProvider> provider =
|
||||
do_GetService(TELEPHONY_PROVIDER_CONTRACTID);
|
||||
NS_ENSURE_TRUE(provider, false);
|
||||
|
||||
nsresult rv = provider->RegisterListener(mTelephonyListener);
|
||||
return NS_SUCCEEDED(rv);
|
||||
}
|
||||
|
||||
bool
|
||||
BluetoothRilListener::StopTelephonyListening()
|
||||
{
|
||||
nsCOMPtr<nsITelephonyProvider> provider =
|
||||
do_GetService(TELEPHONY_PROVIDER_CONTRACTID);
|
||||
NS_ENSURE_TRUE(provider, false);
|
||||
|
||||
nsresult rv = provider->UnregisterListener(mTelephonyListener);
|
||||
return NS_SUCCEEDED(rv);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -9,37 +9,117 @@
|
|||
|
||||
#include "BluetoothCommon.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsAutoPtr.h"
|
||||
|
||||
class nsIIccListener;
|
||||
class nsIMobileConnectionListener;
|
||||
class nsITelephonyListener;
|
||||
#include "nsIIccProvider.h"
|
||||
#include "nsIMobileConnectionProvider.h"
|
||||
#include "nsITelephonyProvider.h"
|
||||
|
||||
BEGIN_BLUETOOTH_NAMESPACE
|
||||
|
||||
class BluetoothRilListener;
|
||||
|
||||
class IccListener : public nsIIccListener
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIICCLISTENER
|
||||
|
||||
IccListener() { }
|
||||
|
||||
bool Listen(bool aStart);
|
||||
void SetOwner(BluetoothRilListener *aOwner);
|
||||
|
||||
private:
|
||||
BluetoothRilListener* mOwner;
|
||||
};
|
||||
|
||||
class MobileConnectionListener : public nsIMobileConnectionListener
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIMOBILECONNECTIONLISTENER
|
||||
|
||||
MobileConnectionListener(uint32_t aClientId)
|
||||
: mClientId(aClientId) { }
|
||||
|
||||
bool Listen(bool aStart);
|
||||
|
||||
private:
|
||||
uint32_t mClientId;
|
||||
};
|
||||
|
||||
class TelephonyListener : public nsITelephonyListener
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSITELEPHONYLISTENER
|
||||
|
||||
TelephonyListener() { }
|
||||
|
||||
bool Listen(bool aStart);
|
||||
};
|
||||
|
||||
class BluetoothRilListener
|
||||
{
|
||||
public:
|
||||
BluetoothRilListener();
|
||||
~BluetoothRilListener();
|
||||
|
||||
bool StartListening();
|
||||
bool StopListening();
|
||||
/**
|
||||
* Start/Stop listening.
|
||||
*
|
||||
* @param aStart [in] whether to start/stop listening
|
||||
*/
|
||||
bool Listen(bool aStart);
|
||||
|
||||
/**
|
||||
* Be informed that certain client's service has changed.
|
||||
*
|
||||
* @param aClientId [in] the client id with service change
|
||||
* @param aRegistered [in] whether changed service is registered
|
||||
*/
|
||||
void ServiceChanged(uint32_t aClientId, bool aRegistered);
|
||||
|
||||
/**
|
||||
* Enumerate current calls.
|
||||
*/
|
||||
void EnumerateCalls();
|
||||
|
||||
/**
|
||||
* The id of client that mobile connection and icc info listeners
|
||||
* are listening to.
|
||||
*
|
||||
* mClientId equals to number of total clients (array length of
|
||||
* mobile connection listeners) if there is no available client to listen.
|
||||
*/
|
||||
uint32_t mClientId;
|
||||
|
||||
private:
|
||||
bool StartIccListening();
|
||||
bool StopIccListening();
|
||||
/**
|
||||
* Start/Stop listening of mobile connection and icc info.
|
||||
*
|
||||
* @param aStart [in] whether to start/stop listening
|
||||
*/
|
||||
bool ListenMobileConnAndIccInfo(bool aStart);
|
||||
|
||||
bool StartMobileConnectionListening();
|
||||
bool StopMobileConnectionListening();
|
||||
/**
|
||||
* Select available client to listen and assign mClientId.
|
||||
*
|
||||
* mClientId is assigned to number of total clients (array length of
|
||||
* mobile connection listeners) if there is no available client to listen.
|
||||
*/
|
||||
void SelectClient();
|
||||
|
||||
bool StartTelephonyListening();
|
||||
bool StopTelephonyListening();
|
||||
/**
|
||||
* Array of mobile connection listeners.
|
||||
*
|
||||
* The length equals to number of total clients.
|
||||
*/
|
||||
nsTArray<nsRefPtr<MobileConnectionListener> > mMobileConnListeners;
|
||||
|
||||
nsCOMPtr<nsIIccListener> mIccListener;
|
||||
nsCOMPtr<nsIMobileConnectionListener> mMobileConnectionListener;
|
||||
nsCOMPtr<nsITelephonyListener> mTelephonyListener;
|
||||
nsRefPtr<IccListener> mIccListener;
|
||||
nsRefPtr<TelephonyListener> mTelephonyListener;
|
||||
};
|
||||
|
||||
END_BLUETOOTH_NAMESPACE
|
||||
|
|
|
@ -386,7 +386,7 @@ BluetoothHfpManager::Init()
|
|||
hal::RegisterBatteryObserver(this);
|
||||
|
||||
mListener = new BluetoothRilListener();
|
||||
NS_ENSURE_TRUE(mListener->StartListening(), false);
|
||||
NS_ENSURE_TRUE(mListener->Listen(true), false);
|
||||
|
||||
nsCOMPtr<nsISettingsService> settings =
|
||||
do_GetService("@mozilla.org/settingsService;1");
|
||||
|
@ -427,7 +427,7 @@ BluetoothHfpManager::InitHfpInterface()
|
|||
|
||||
BluetoothHfpManager::~BluetoothHfpManager()
|
||||
{
|
||||
if (!mListener->StopListening()) {
|
||||
if (!mListener->Listen(false)) {
|
||||
BT_WARNING("Failed to stop listening RIL");
|
||||
}
|
||||
mListener = nullptr;
|
||||
|
@ -815,17 +815,20 @@ BluetoothHfpManager::HandleVolumeChanged(const nsAString& aData)
|
|||
}
|
||||
|
||||
void
|
||||
BluetoothHfpManager::HandleVoiceConnectionChanged()
|
||||
BluetoothHfpManager::HandleVoiceConnectionChanged(uint32_t aClientId)
|
||||
{
|
||||
nsCOMPtr<nsIMobileConnectionProvider> connection =
|
||||
do_GetService(NS_RILCONTENTHELPER_CONTRACTID);
|
||||
NS_ENSURE_TRUE_VOID(connection);
|
||||
|
||||
nsCOMPtr<nsIDOMMozMobileConnectionInfo> voiceInfo;
|
||||
connection->GetVoiceConnectionInfo(0, getter_AddRefs(voiceInfo));
|
||||
connection->GetVoiceConnectionInfo(aClientId, getter_AddRefs(voiceInfo));
|
||||
NS_ENSURE_TRUE_VOID(voiceInfo);
|
||||
|
||||
// Roam
|
||||
nsString type;
|
||||
voiceInfo->GetType(type);
|
||||
mPhoneType = GetPhoneType(type);
|
||||
|
||||
bool roaming;
|
||||
voiceInfo->GetRoaming(&roaming);
|
||||
mRoam = (roaming) ? 1 : 0;
|
||||
|
@ -867,14 +870,14 @@ BluetoothHfpManager::HandleVoiceConnectionChanged()
|
|||
}
|
||||
|
||||
void
|
||||
BluetoothHfpManager::HandleIccInfoChanged()
|
||||
BluetoothHfpManager::HandleIccInfoChanged(uint32_t aClientId)
|
||||
{
|
||||
nsCOMPtr<nsIIccProvider> icc =
|
||||
do_GetService(NS_RILCONTENTHELPER_CONTRACTID);
|
||||
NS_ENSURE_TRUE_VOID(icc);
|
||||
|
||||
nsCOMPtr<nsIDOMMozIccInfo> iccInfo;
|
||||
icc->GetIccInfo(0, getter_AddRefs(iccInfo));
|
||||
icc->GetIccInfo(aClientId, getter_AddRefs(iccInfo));
|
||||
NS_ENSURE_TRUE_VOID(iccInfo);
|
||||
|
||||
nsCOMPtr<nsIDOMMozGsmIccInfo> gsmIccInfo = do_QueryInterface(iccInfo);
|
||||
|
|
|
@ -96,8 +96,8 @@ public:
|
|||
void HandleCallStateChanged(uint32_t aCallIndex, uint16_t aCallState,
|
||||
const nsAString& aError, const nsAString& aNumber,
|
||||
const bool aIsOutgoing, bool aSend);
|
||||
void HandleIccInfoChanged();
|
||||
void HandleVoiceConnectionChanged();
|
||||
void HandleIccInfoChanged(uint32_t aClientId);
|
||||
void HandleVoiceConnectionChanged(uint32_t aClientId);
|
||||
|
||||
// Bluedroid hfp callback handlers
|
||||
void ProcessConnectionState(bthf_connection_state_t aState, bt_bdaddr_t* aBdAddress);
|
||||
|
|
|
@ -382,6 +382,8 @@ BluetoothHfpManager::Reset()
|
|||
#endif
|
||||
mCMEE = false;
|
||||
mCMER = false;
|
||||
mConnectScoRequest = false;
|
||||
mSlcConnected = false;
|
||||
mReceiveVgsFlag = false;
|
||||
|
||||
#ifdef MOZ_B2G_RIL
|
||||
|
@ -414,7 +416,7 @@ BluetoothHfpManager::Init()
|
|||
|
||||
#ifdef MOZ_B2G_RIL
|
||||
mListener = new BluetoothRilListener();
|
||||
if (!mListener->StartListening()) {
|
||||
if (!mListener->Listen(true)) {
|
||||
BT_WARNING("Failed to start listening RIL");
|
||||
return false;
|
||||
}
|
||||
|
@ -446,7 +448,7 @@ BluetoothHfpManager::Init()
|
|||
BluetoothHfpManager::~BluetoothHfpManager()
|
||||
{
|
||||
#ifdef MOZ_B2G_RIL
|
||||
if (!mListener->StopListening()) {
|
||||
if (!mListener->Listen(false)) {
|
||||
BT_WARNING("Failed to stop listening RIL");
|
||||
}
|
||||
mListener = nullptr;
|
||||
|
@ -585,15 +587,14 @@ BluetoothHfpManager::HandleVolumeChanged(const nsAString& aData)
|
|||
|
||||
#ifdef MOZ_B2G_RIL
|
||||
void
|
||||
BluetoothHfpManager::HandleVoiceConnectionChanged()
|
||||
BluetoothHfpManager::HandleVoiceConnectionChanged(uint32_t aClientId)
|
||||
{
|
||||
nsCOMPtr<nsIMobileConnectionProvider> connection =
|
||||
do_GetService(NS_RILCONTENTHELPER_CONTRACTID);
|
||||
NS_ENSURE_TRUE_VOID(connection);
|
||||
|
||||
nsCOMPtr<nsIDOMMozMobileConnectionInfo> voiceInfo;
|
||||
// TODO: Bug 921991 - B2G BT: support multiple sim cards
|
||||
connection->GetVoiceConnectionInfo(0, getter_AddRefs(voiceInfo));
|
||||
connection->GetVoiceConnectionInfo(aClientId, getter_AddRefs(voiceInfo));
|
||||
NS_ENSURE_TRUE_VOID(voiceInfo);
|
||||
|
||||
nsString type;
|
||||
|
@ -604,11 +605,12 @@ BluetoothHfpManager::HandleVoiceConnectionChanged()
|
|||
voiceInfo->GetRoaming(&roaming);
|
||||
UpdateCIND(CINDType::ROAM, roaming);
|
||||
|
||||
bool service = false;
|
||||
nsString regState;
|
||||
voiceInfo->GetState(regState);
|
||||
if (regState.EqualsLiteral("registered")) {
|
||||
service = true;
|
||||
bool service = regState.EqualsLiteral("registered");
|
||||
if (service != sCINDItems[CINDType::SERVICE].value) {
|
||||
// Notify BluetoothRilListener of service change
|
||||
mListener->ServiceChanged(aClientId, service);
|
||||
}
|
||||
UpdateCIND(CINDType::SERVICE, service);
|
||||
|
||||
|
@ -629,8 +631,7 @@ BluetoothHfpManager::HandleVoiceConnectionChanged()
|
|||
* - manual: set mNetworkSelectionMode to 1 (manual)
|
||||
*/
|
||||
nsString mode;
|
||||
// TODO: Bug 921991 - B2G BT: support multiple sim cards
|
||||
connection->GetNetworkSelectionMode(0, mode);
|
||||
connection->GetNetworkSelectionMode(aClientId, mode);
|
||||
if (mode.EqualsLiteral("manual")) {
|
||||
mNetworkSelectionMode = 1;
|
||||
} else {
|
||||
|
@ -657,15 +658,14 @@ BluetoothHfpManager::HandleVoiceConnectionChanged()
|
|||
}
|
||||
|
||||
void
|
||||
BluetoothHfpManager::HandleIccInfoChanged()
|
||||
BluetoothHfpManager::HandleIccInfoChanged(uint32_t aClientId)
|
||||
{
|
||||
nsCOMPtr<nsIIccProvider> icc =
|
||||
do_GetService(NS_RILCONTENTHELPER_CONTRACTID);
|
||||
NS_ENSURE_TRUE_VOID(icc);
|
||||
|
||||
nsCOMPtr<nsIDOMMozIccInfo> iccInfo;
|
||||
// TODO: Bug 921991 - B2G BT: support multiple sim cards
|
||||
icc->GetIccInfo(0, getter_AddRefs(iccInfo));
|
||||
icc->GetIccInfo(aClientId, getter_AddRefs(iccInfo));
|
||||
NS_ENSURE_TRUE_VOID(iccInfo);
|
||||
|
||||
nsCOMPtr<nsIDOMMozGsmIccInfo> gsmIccInfo = do_QueryInterface(iccInfo);
|
||||
|
@ -744,6 +744,14 @@ BluetoothHfpManager::ReceiveSocketData(BluetoothSocket* aSocket,
|
|||
}
|
||||
|
||||
mCMER = atCommandValues[3].EqualsLiteral("1");
|
||||
mSlcConnected = mCMER;
|
||||
|
||||
// If we get internal request for SCO connection,
|
||||
// setup SCO after Service Level Connection established.
|
||||
if(mConnectScoRequest) {
|
||||
mConnectScoRequest = false;
|
||||
ConnectSco();
|
||||
}
|
||||
} else if (msg.Find("AT+CMEE=") != -1) {
|
||||
ParseAtCommand(msg, 8, atCommandValues);
|
||||
|
||||
|
@ -1426,6 +1434,7 @@ BluetoothHfpManager::HandleCallStateChanged(uint32_t aCallIndex,
|
|||
// Incoming call, no break
|
||||
sStopSendingRingFlag = true;
|
||||
ConnectSco();
|
||||
// NO BREAK HERE. continue to next statement
|
||||
case nsITelephonyProvider::CALL_STATE_DIALING:
|
||||
case nsITelephonyProvider::CALL_STATE_ALERTING:
|
||||
// Outgoing call
|
||||
|
@ -1793,6 +1802,14 @@ BluetoothHfpManager::ConnectSco(BluetoothReplyRunnable* aRunnable)
|
|||
return false;
|
||||
}
|
||||
|
||||
// Make sure Service Level Connection established before we start to
|
||||
// set up SCO (synchronous connection).
|
||||
if (!mSlcConnected) {
|
||||
mConnectScoRequest = true;
|
||||
BT_WARNING("ConnectSco called before Service Level Connection established");
|
||||
return false;
|
||||
}
|
||||
|
||||
mScoSocket->Disconnect();
|
||||
|
||||
mScoRunnable = aRunnable;
|
||||
|
@ -1801,7 +1818,7 @@ BluetoothHfpManager::ConnectSco(BluetoothReplyRunnable* aRunnable)
|
|||
NS_ENSURE_TRUE(bs, false);
|
||||
nsresult rv = bs->GetScoSocket(mDeviceAddress, true, false, mScoSocket);
|
||||
|
||||
mScoSocketStatus = mSocket->GetConnectionStatus();
|
||||
mScoSocketStatus = mScoSocket->GetConnectionStatus();
|
||||
return NS_SUCCEEDED(rv);
|
||||
}
|
||||
|
||||
|
|
|
@ -98,6 +98,17 @@ public:
|
|||
virtual void OnSocketDisconnect(BluetoothSocket* aSocket) MOZ_OVERRIDE;
|
||||
|
||||
bool Listen();
|
||||
/**
|
||||
* This function set up a Synchronous Connection (SCO) link for HFP.
|
||||
* Service Level Connection (SLC) should be established before SCO setup
|
||||
* process.
|
||||
* If SLC haven't been established, this function will return false and send a
|
||||
* request to set up SCO ater HfpManager receive AT+CMER.
|
||||
*
|
||||
* @param aRunnable Indicate a BluetoothReplyRunnable to execute this
|
||||
* function. The default value is nullpter
|
||||
* @return <code>true</code> if SCO established successfully
|
||||
*/
|
||||
bool ConnectSco(BluetoothReplyRunnable* aRunnable = nullptr);
|
||||
bool DisconnectSco();
|
||||
bool ListenSco();
|
||||
|
@ -110,8 +121,8 @@ public:
|
|||
void HandleCallStateChanged(uint32_t aCallIndex, uint16_t aCallState,
|
||||
const nsAString& aError, const nsAString& aNumber,
|
||||
const bool aIsOutgoing, bool aSend);
|
||||
void HandleIccInfoChanged();
|
||||
void HandleVoiceConnectionChanged();
|
||||
void HandleIccInfoChanged(uint32_t aClientId);
|
||||
void HandleVoiceConnectionChanged(uint32_t aClientId);
|
||||
|
||||
// CDMA-specific functions
|
||||
void UpdateSecondNumber(const nsAString& aNumber);
|
||||
|
@ -175,6 +186,8 @@ private:
|
|||
#endif
|
||||
bool mCMEE;
|
||||
bool mCMER;
|
||||
bool mConnectScoRequest;
|
||||
bool mSlcConnected;
|
||||
#ifdef MOZ_B2G_RIL
|
||||
bool mFirstCKPD;
|
||||
int mNetworkSelectionMode;
|
||||
|
|
|
@ -6,6 +6,9 @@
|
|||
|
||||
#include "mozilla/Util.h" // ArrayLength
|
||||
#include "nsUConvPropertySearch.h"
|
||||
#include "nsIUnicodeDecoder.h"
|
||||
#include "nsIUnicodeEncoder.h"
|
||||
#include "nsComponentManagerUtils.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
@ -44,5 +47,27 @@ EncodingUtils::IsAsciiCompatible(const nsACString& aPreferredName)
|
|||
aPreferredName.LowerCaseEqualsLiteral("x-imap4-modified-utf7"));
|
||||
}
|
||||
|
||||
already_AddRefed<nsIUnicodeDecoder>
|
||||
EncodingUtils::DecoderForEncoding(const nsACString& aEncoding)
|
||||
{
|
||||
nsAutoCString contractId(NS_UNICODEDECODER_CONTRACTID_BASE);
|
||||
contractId.Append(aEncoding);
|
||||
|
||||
nsCOMPtr<nsIUnicodeDecoder> decoder = do_CreateInstance(contractId.get());
|
||||
MOZ_ASSERT(decoder, "Tried to create decoder for unknown encoding.");
|
||||
return decoder.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<nsIUnicodeEncoder>
|
||||
EncodingUtils::EncoderForEncoding(const nsACString& aEncoding)
|
||||
{
|
||||
nsAutoCString contractId(NS_UNICODEENCODER_CONTRACTID_BASE);
|
||||
contractId.Append(aEncoding);
|
||||
|
||||
nsCOMPtr<nsIUnicodeEncoder> encoder = do_CreateInstance(contractId.get());
|
||||
MOZ_ASSERT(encoder, "Tried to create encoder for unknown encoding.");
|
||||
return encoder.forget();
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -8,6 +8,9 @@
|
|||
#include "nsDataHashtable.h"
|
||||
#include "nsString.h"
|
||||
|
||||
class nsIUnicodeDecoder;
|
||||
class nsIUnicodeEncoder;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
|
@ -62,6 +65,50 @@ public:
|
|||
*/
|
||||
static bool IsAsciiCompatible(const nsACString& aPreferredName);
|
||||
|
||||
/**
|
||||
* Instantiates a decoder for an encoding. The input must be a
|
||||
* Gecko-canonical encoding name.
|
||||
* @param aEncoding a Gecko-canonical encoding name
|
||||
* @return a decoder
|
||||
*/
|
||||
static already_AddRefed<nsIUnicodeDecoder>
|
||||
DecoderForEncoding(const char* aEncoding)
|
||||
{
|
||||
nsDependentCString encoding(aEncoding);
|
||||
return DecoderForEncoding(encoding);
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a decoder for an encoding. The input must be a
|
||||
* Gecko-canonical encoding name
|
||||
* @param aEncoding a Gecko-canonical encoding name
|
||||
* @return a decoder
|
||||
*/
|
||||
static already_AddRefed<nsIUnicodeDecoder>
|
||||
DecoderForEncoding(const nsACString& aEncoding);
|
||||
|
||||
/**
|
||||
* Instantiates an encoder for an encoding. The input must be a
|
||||
* Gecko-canonical encoding name.
|
||||
* @param aEncoding a Gecko-canonical encoding name
|
||||
* @return an encoder
|
||||
*/
|
||||
static already_AddRefed<nsIUnicodeEncoder>
|
||||
EncoderForEncoding(const char* aEncoding)
|
||||
{
|
||||
nsDependentCString encoding(aEncoding);
|
||||
return EncoderForEncoding(encoding);
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates an encoder for an encoding. The input must be a
|
||||
* Gecko-canonical encoding name.
|
||||
* @param aEncoding a Gecko-canonical encoding name
|
||||
* @return an encoder
|
||||
*/
|
||||
static already_AddRefed<nsIUnicodeEncoder>
|
||||
EncoderForEncoding(const nsACString& aEncoding);
|
||||
|
||||
private:
|
||||
EncodingUtils() MOZ_DELETE;
|
||||
};
|
||||
|
|
|
@ -5,8 +5,6 @@
|
|||
#include "mozilla/dom/TextDecoder.h"
|
||||
#include "mozilla/dom/EncodingUtils.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsICharsetConverterManager.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
@ -34,18 +32,7 @@ TextDecoder::Init(const nsAString& aEncoding, const bool aFatal,
|
|||
mFatal = aFatal;
|
||||
|
||||
// Create a decoder object for mEncoding.
|
||||
nsCOMPtr<nsICharsetConverterManager> ccm =
|
||||
do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID);
|
||||
if (!ccm) {
|
||||
aRv.Throw(NS_ERROR_UNEXPECTED);
|
||||
return;
|
||||
}
|
||||
|
||||
ccm->GetUnicodeDecoderRaw(mEncoding.get(), getter_AddRefs(mDecoder));
|
||||
if (!mDecoder) {
|
||||
aRv.Throw(NS_ERROR_UNEXPECTED);
|
||||
return;
|
||||
}
|
||||
mDecoder = EncodingUtils::DecoderForEncoding(mEncoding);
|
||||
|
||||
if (mFatal) {
|
||||
mDecoder->SetInputErrorBehavior(nsIUnicodeDecoder::kOnError_Signal);
|
||||
|
|
|
@ -5,8 +5,6 @@
|
|||
#include "mozilla/dom/TextEncoder.h"
|
||||
#include "mozilla/dom/EncodingUtils.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsICharsetConverterManager.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
@ -33,18 +31,7 @@ TextEncoder::Init(const nsAString& aEncoding, ErrorResult& aRv)
|
|||
}
|
||||
|
||||
// Create an encoder object for mEncoding.
|
||||
nsCOMPtr<nsICharsetConverterManager> ccm =
|
||||
do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID);
|
||||
if (!ccm) {
|
||||
aRv.Throw(NS_ERROR_UNEXPECTED);
|
||||
return;
|
||||
}
|
||||
|
||||
ccm->GetUnicodeEncoderRaw(mEncoding.get(), getter_AddRefs(mEncoder));
|
||||
if (!mEncoder) {
|
||||
aRv.Throw(NS_ERROR_UNEXPECTED);
|
||||
return;
|
||||
}
|
||||
mEncoder = EncodingUtils::EncoderForEncoding(mEncoding);
|
||||
}
|
||||
|
||||
JSObject*
|
||||
|
|
|
@ -154,7 +154,7 @@ FileService::Enqueue(LockedFile* aLockedFile, FileHelper* aFileHelper)
|
|||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
nsIAtom* storageId = fileHandle->mFileStorage->Id();
|
||||
const nsACString& storageId = fileHandle->mFileStorage->Id();
|
||||
const nsAString& fileName = fileHandle->mFileName;
|
||||
bool modeIsWrite = aLockedFile->mMode == FileMode::Readwrite;
|
||||
|
||||
|
@ -224,7 +224,7 @@ FileService::NotifyLockedFileCompleted(LockedFile* aLockedFile)
|
|||
NS_ASSERTION(aLockedFile, "Null pointer!");
|
||||
|
||||
FileHandle* fileHandle = aLockedFile->mFileHandle;
|
||||
nsIAtom* storageId = fileHandle->mFileStorage->Id();
|
||||
const nsACString& storageId = fileHandle->mFileStorage->Id();
|
||||
|
||||
FileStorageInfo* fileStorageInfo;
|
||||
if (!mFileStorageInfos.Get(storageId, &fileStorageInfo)) {
|
||||
|
@ -237,11 +237,7 @@ FileService::NotifyLockedFileCompleted(LockedFile* aLockedFile)
|
|||
if (!fileStorageInfo->HasRunningLockedFiles()) {
|
||||
mFileStorageInfos.Remove(storageId);
|
||||
|
||||
#ifdef DEBUG
|
||||
storageId = nullptr;
|
||||
#endif
|
||||
|
||||
// See if we need to fire any complete callbacks.
|
||||
// See if we need to fire any complete callbacks.
|
||||
uint32_t index = 0;
|
||||
while (index < mCompleteCallbacks.Length()) {
|
||||
if (MaybeFireCallback(mCompleteCallbacks[index])) {
|
||||
|
|
|
@ -186,7 +186,7 @@ private:
|
|||
MaybeFireCallback(StoragesCompleteCallback& aCallback);
|
||||
|
||||
nsCOMPtr<nsIEventTarget> mStreamTransportTarget;
|
||||
nsClassHashtable<nsISupportsHashKey, FileStorageInfo> mFileStorageInfos;
|
||||
nsClassHashtable<nsCStringHashKey, FileStorageInfo> mFileStorageInfos;
|
||||
nsTArray<StoragesCompleteCallback> mCompleteCallbacks;
|
||||
};
|
||||
|
||||
|
|
|
@ -13,14 +13,12 @@
|
|||
{0x6278f453, 0xd557, 0x4a55, \
|
||||
{ 0x99, 0x3e, 0xf4, 0x69, 0xe2, 0xa5, 0xe1, 0xd0 } }
|
||||
|
||||
class nsIAtom;
|
||||
|
||||
class nsIFileStorage : public nsISupports
|
||||
{
|
||||
public:
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_FILESTORAGE_IID)
|
||||
|
||||
NS_IMETHOD_(nsIAtom*)
|
||||
NS_IMETHOD_(const nsACString&)
|
||||
Id() = 0;
|
||||
|
||||
// Whether or not the storage has been invalidated. If it has then no further
|
||||
|
@ -41,7 +39,7 @@ public:
|
|||
NS_DEFINE_STATIC_IID_ACCESSOR(nsIFileStorage, NS_FILESTORAGE_IID)
|
||||
|
||||
#define NS_DECL_NSIFILESTORAGE \
|
||||
NS_IMETHOD_(nsIAtom*) \
|
||||
NS_IMETHOD_(const nsACString&) \
|
||||
Id() MOZ_OVERRIDE; \
|
||||
\
|
||||
NS_IMETHOD_(bool) \
|
||||
|
|
|
@ -13,7 +13,7 @@ USING_INDEXEDDB_NAMESPACE
|
|||
|
||||
namespace {
|
||||
|
||||
typedef nsDataHashtable<nsISupportsHashKey, DatabaseInfo*>
|
||||
typedef nsDataHashtable<nsCStringHashKey, DatabaseInfo*>
|
||||
DatabaseHash;
|
||||
|
||||
DatabaseHash* gDatabaseHash = nullptr;
|
||||
|
@ -128,11 +128,11 @@ IndexUpdateInfo::~IndexUpdateInfo()
|
|||
|
||||
// static
|
||||
bool
|
||||
DatabaseInfo::Get(nsIAtom* aId,
|
||||
DatabaseInfo::Get(const nsACString& aId,
|
||||
DatabaseInfo** aInfo)
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
NS_ASSERTION(aId, "Bad id!");
|
||||
NS_ASSERTION(!aId.IsEmpty(), "Bad id!");
|
||||
|
||||
if (gDatabaseHash &&
|
||||
gDatabaseHash->Get(aId, aInfo)) {
|
||||
|
@ -166,7 +166,7 @@ DatabaseInfo::Put(DatabaseInfo* aInfo)
|
|||
|
||||
// static
|
||||
void
|
||||
DatabaseInfo::Remove(nsIAtom* aId)
|
||||
DatabaseInfo::Remove(const nsACString& aId)
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
|
||||
|
|
|
@ -62,12 +62,12 @@ struct DatabaseInfo : public DatabaseInfoGuts
|
|||
|
||||
~DatabaseInfo();
|
||||
|
||||
static bool Get(nsIAtom* aId,
|
||||
static bool Get(const nsACString& aId,
|
||||
DatabaseInfo** aInfo);
|
||||
|
||||
static bool Put(DatabaseInfo* aInfo);
|
||||
|
||||
static void Remove(nsIAtom* aId);
|
||||
static void Remove(const nsACString& aId);
|
||||
|
||||
bool GetObjectStoreNames(nsTArray<nsString>& aNames);
|
||||
bool ContainsStoreName(const nsAString& aName);
|
||||
|
@ -80,7 +80,7 @@ struct DatabaseInfo : public DatabaseInfoGuts
|
|||
|
||||
already_AddRefed<DatabaseInfo> Clone();
|
||||
|
||||
nsCOMPtr<nsIAtom> id;
|
||||
nsCString id;
|
||||
nsString filePath;
|
||||
bool cloned;
|
||||
|
||||
|
|
|
@ -734,7 +734,7 @@ IDBDatabase::Close()
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(nsIAtom*)
|
||||
NS_IMETHODIMP_(const nsACString&)
|
||||
IDBDatabase::Id()
|
||||
{
|
||||
return mDatabaseId;
|
||||
|
|
|
@ -245,7 +245,7 @@ private:
|
|||
// Set to a copy of the existing DatabaseInfo when starting a versionchange
|
||||
// transaction.
|
||||
nsRefPtr<DatabaseInfo> mPreviousDatabaseInfo;
|
||||
nsCOMPtr<nsIAtom> mDatabaseId;
|
||||
nsCString mDatabaseId;
|
||||
nsString mName;
|
||||
nsString mFilePath;
|
||||
nsCString mASCIIOrigin;
|
||||
|
|
|
@ -384,7 +384,7 @@ IgnoreWhitespace(PRUnichar c)
|
|||
// static
|
||||
nsresult
|
||||
IDBFactory::LoadDatabaseInformation(mozIStorageConnection* aConnection,
|
||||
nsIAtom* aDatabaseId,
|
||||
const nsACString& aDatabaseId,
|
||||
uint64_t* aVersion,
|
||||
ObjectStoreInfoArray& aObjectStores)
|
||||
{
|
||||
|
@ -647,9 +647,10 @@ IDBFactory::OpenInternal(const nsAString& aName,
|
|||
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||
}
|
||||
else if (aDeleting) {
|
||||
nsCOMPtr<nsIAtom> databaseId =
|
||||
QuotaManager::GetStorageId(aPersistenceType, aASCIIOrigin, aName);
|
||||
NS_ENSURE_TRUE(databaseId, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||
nsCString databaseId;
|
||||
QuotaManager::GetStorageId(aPersistenceType, aASCIIOrigin, aName,
|
||||
databaseId);
|
||||
MOZ_ASSERT(!databaseId.IsEmpty());
|
||||
|
||||
IndexedDBDeleteDatabaseRequestChild* actor =
|
||||
new IndexedDBDeleteDatabaseRequestChild(this, request, databaseId);
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#include "nsWrapperCache.h"
|
||||
|
||||
class mozIStorageConnection;
|
||||
class nsIAtom;
|
||||
class nsIFile;
|
||||
class nsIFileURL;
|
||||
class nsIPrincipal;
|
||||
|
@ -97,7 +96,7 @@ public:
|
|||
|
||||
static nsresult
|
||||
LoadDatabaseInformation(mozIStorageConnection* aConnection,
|
||||
nsIAtom* aDatabaseId,
|
||||
const nsACString& aDatabaseId,
|
||||
uint64_t* aVersion,
|
||||
ObjectStoreInfoArray& aObjectStores);
|
||||
|
||||
|
|
|
@ -1444,7 +1444,7 @@ GetAllKeysHelper::GetSuccessResult(JSContext* aCx,
|
|||
nsTArray<Key> keys;
|
||||
mKeys.SwapElements(keys);
|
||||
|
||||
JS::Rooted<JSObject*> array(aCx, JS_NewArrayObject(aCx, 0, NULL));
|
||||
JS::Rooted<JSObject*> array(aCx, JS_NewArrayObject(aCx, 0, nullptr));
|
||||
if (!array) {
|
||||
NS_WARNING("Failed to make array!");
|
||||
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
||||
|
|
|
@ -613,7 +613,7 @@ class ThreadLocalJSRuntime
|
|||
static const unsigned sRuntimeHeapSize = 768 * 1024;
|
||||
|
||||
ThreadLocalJSRuntime()
|
||||
: mRuntime(NULL), mContext(NULL), mGlobal(NULL)
|
||||
: mRuntime(nullptr), mContext(nullptr), mGlobal(nullptr)
|
||||
{
|
||||
MOZ_COUNT_CTOR(ThreadLocalJSRuntime);
|
||||
}
|
||||
|
@ -634,7 +634,7 @@ class ThreadLocalJSRuntime
|
|||
|
||||
JSAutoRequest ar(mContext);
|
||||
|
||||
mGlobal = JS_NewGlobalObject(mContext, &sGlobalClass, NULL,
|
||||
mGlobal = JS_NewGlobalObject(mContext, &sGlobalClass, nullptr,
|
||||
JS::FireOnNewGlobalHook);
|
||||
NS_ENSURE_TRUE(mGlobal, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
|
@ -962,7 +962,7 @@ const JSClass IDBObjectStore::sDummyPropJSClass = {
|
|||
already_AddRefed<IDBObjectStore>
|
||||
IDBObjectStore::Create(IDBTransaction* aTransaction,
|
||||
ObjectStoreInfo* aStoreInfo,
|
||||
nsIAtom* aDatabaseId,
|
||||
const nsACString& aDatabaseId,
|
||||
bool aCreating)
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
|
@ -4924,7 +4924,7 @@ GetAllKeysHelper::GetSuccessResult(JSContext* aCx,
|
|||
nsTArray<Key> keys;
|
||||
mKeys.SwapElements(keys);
|
||||
|
||||
JS::Rooted<JSObject*> array(aCx, JS_NewArrayObject(aCx, 0, NULL));
|
||||
JS::Rooted<JSObject*> array(aCx, JS_NewArrayObject(aCx, 0, nullptr));
|
||||
if (!array) {
|
||||
NS_WARNING("Failed to make array!");
|
||||
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
||||
|
|
|
@ -60,7 +60,7 @@ public:
|
|||
static already_AddRefed<IDBObjectStore>
|
||||
Create(IDBTransaction* aTransaction,
|
||||
ObjectStoreInfo* aInfo,
|
||||
nsIAtom* aDatabaseId,
|
||||
const nsACString& aDatabaseId,
|
||||
bool aCreating);
|
||||
|
||||
static nsresult
|
||||
|
@ -402,7 +402,7 @@ private:
|
|||
JS::Heap<JS::Value> mCachedKeyPath;
|
||||
bool mRooted;
|
||||
bool mAutoIncrement;
|
||||
nsCOMPtr<nsIAtom> mDatabaseId;
|
||||
nsCString mDatabaseId;
|
||||
nsRefPtr<ObjectStoreInfo> mInfo;
|
||||
|
||||
nsTArray<nsRefPtr<IDBIndex> > mCreatedIndexes;
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
|
||||
#define INDEXEDDB_MANAGER_CONTRACTID "@mozilla.org/dom/indexeddb/manager;1"
|
||||
|
||||
class nsIAtom;
|
||||
class nsPIDOMWindow;
|
||||
class nsEventChainPostVisitor;
|
||||
|
||||
|
|
|
@ -1717,9 +1717,9 @@ NS_IMPL_ISUPPORTS1(OpenDatabaseHelper, nsIRunnable)
|
|||
nsresult
|
||||
OpenDatabaseHelper::Init()
|
||||
{
|
||||
mDatabaseId =
|
||||
QuotaManager::GetStorageId(mPersistenceType, mASCIIOrigin, mName);
|
||||
NS_ENSURE_TRUE(mDatabaseId, NS_ERROR_FAILURE);
|
||||
QuotaManager::GetStorageId(mPersistenceType, mASCIIOrigin, mName,
|
||||
mDatabaseId);
|
||||
MOZ_ASSERT(!mDatabaseId.IsEmpty());
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -2509,7 +2509,6 @@ OpenDatabaseHelper::ReleaseMainThreadObjects()
|
|||
|
||||
mOpenDBRequest = nullptr;
|
||||
mDatabase = nullptr;
|
||||
mDatabaseId = nullptr;
|
||||
|
||||
HelperBase::ReleaseMainThreadObjects();
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ public:
|
|||
: HelperBase(aRequest), mOpenDBRequest(aRequest), mName(aName),
|
||||
mGroup(aGroup), mASCIIOrigin(aASCIIOrigin),
|
||||
mRequestedVersion(aRequestedVersion), mPersistenceType(aPersistenceType),
|
||||
mForDeletion(aForDeletion), mPrivilege(aPrivilege), mDatabaseId(nullptr),
|
||||
mForDeletion(aForDeletion), mPrivilege(aPrivilege),
|
||||
mContentParent(aContentParent), mCurrentVersion(0), mLastObjectStoreId(0),
|
||||
mLastIndexId(0), mState(eCreated), mResultCode(NS_OK),
|
||||
mLoadDBMetadata(false),
|
||||
|
@ -82,9 +82,9 @@ public:
|
|||
nsresult NotifyDeleteFinished();
|
||||
void BlockDatabase();
|
||||
|
||||
nsIAtom* Id() const
|
||||
const nsACString& Id() const
|
||||
{
|
||||
return mDatabaseId.get();
|
||||
return mDatabaseId;
|
||||
}
|
||||
|
||||
IDBDatabase* Database() const
|
||||
|
@ -136,7 +136,7 @@ protected:
|
|||
PersistenceType mPersistenceType;
|
||||
bool mForDeletion;
|
||||
StoragePrivilege mPrivilege;
|
||||
nsCOMPtr<nsIAtom> mDatabaseId;
|
||||
nsCString mDatabaseId;
|
||||
mozilla::dom::ContentParent* mContentParent;
|
||||
|
||||
// Out-params.
|
||||
|
|
|
@ -212,7 +212,7 @@ TransactionThreadPool::FinishTransaction(IDBTransaction* aTransaction)
|
|||
// AddRef here because removing from the hash will call Release.
|
||||
nsRefPtr<IDBTransaction> transaction(aTransaction);
|
||||
|
||||
nsIAtom* databaseId = aTransaction->mDatabase->Id();
|
||||
const nsACString& databaseId = aTransaction->mDatabase->Id();
|
||||
|
||||
DatabaseTransactionInfo* dbTransactionInfo;
|
||||
if (!mTransactionsInProgress.Get(databaseId, &dbTransactionInfo)) {
|
||||
|
@ -286,7 +286,8 @@ TransactionThreadPool::GetQueueForTransaction(IDBTransaction* aTransaction)
|
|||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
NS_ASSERTION(aTransaction, "Null pointer!");
|
||||
|
||||
nsIAtom* databaseId = aTransaction->mDatabase->Id();
|
||||
const nsACString& databaseId = aTransaction->mDatabase->Id();
|
||||
|
||||
const nsTArray<nsString>& objectStoreNames = aTransaction->mObjectStoreNames;
|
||||
const uint16_t mode = aTransaction->mMode;
|
||||
|
||||
|
@ -509,8 +510,7 @@ TransactionThreadPool::MaybeFireCallback(DatabasesCompleteCallback aCallback)
|
|||
MOZ_CRASH();
|
||||
}
|
||||
|
||||
if (mTransactionsInProgress.Get(database->Id(),
|
||||
nullptr)) {
|
||||
if (mTransactionsInProgress.Get(database->Id(), nullptr)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -171,7 +171,7 @@ protected:
|
|||
|
||||
nsCOMPtr<nsIThreadPool> mThreadPool;
|
||||
|
||||
nsClassHashtable<nsISupportsHashKey, DatabaseTransactionInfo>
|
||||
nsClassHashtable<nsCStringHashKey, DatabaseTransactionInfo>
|
||||
mTransactionsInProgress;
|
||||
|
||||
nsTArray<DatabasesCompleteCallback> mCompleteCallbacks;
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
#include "IndexedDBChild.h"
|
||||
|
||||
#include "nsIAtom.h"
|
||||
#include "nsIInputStream.h"
|
||||
|
||||
#include "mozilla/Assertions.h"
|
||||
|
@ -50,14 +49,14 @@ public:
|
|||
virtual nsresult
|
||||
OnSuccess() MOZ_OVERRIDE
|
||||
{
|
||||
static_cast<IDBOpenDBRequest*>(mRequest.get())->SetTransaction(NULL);
|
||||
static_cast<IDBOpenDBRequest*>(mRequest.get())->SetTransaction(nullptr);
|
||||
return AsyncConnectionHelper::OnSuccess();
|
||||
}
|
||||
|
||||
virtual void
|
||||
OnError() MOZ_OVERRIDE
|
||||
{
|
||||
static_cast<IDBOpenDBRequest*>(mRequest.get())->SetTransaction(NULL);
|
||||
static_cast<IDBOpenDBRequest*>(mRequest.get())->SetTransaction(nullptr);
|
||||
AsyncConnectionHelper::OnError();
|
||||
}
|
||||
|
||||
|
@ -103,7 +102,7 @@ class IPCDeleteDatabaseHelper : public AsyncConnectionHelper
|
|||
{
|
||||
public:
|
||||
IPCDeleteDatabaseHelper(IDBRequest* aRequest)
|
||||
: AsyncConnectionHelper(static_cast<IDBDatabase*>(NULL), aRequest)
|
||||
: AsyncConnectionHelper(static_cast<IDBDatabase*>(nullptr), aRequest)
|
||||
{ }
|
||||
|
||||
virtual nsresult UnpackResponseFromParentProcess(
|
||||
|
@ -202,9 +201,9 @@ void
|
|||
IndexedDBChild::ActorDestroy(ActorDestroyReason aWhy)
|
||||
{
|
||||
if (mFactory) {
|
||||
mFactory->SetActor(static_cast<IndexedDBChild*>(NULL));
|
||||
mFactory->SetActor(static_cast<IndexedDBChild*>(nullptr));
|
||||
#ifdef DEBUG
|
||||
mFactory = NULL;
|
||||
mFactory = nullptr;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -247,7 +246,7 @@ IndexedDBChild::DeallocPIndexedDBDeleteDatabaseRequestChild(
|
|||
|
||||
IndexedDBDatabaseChild::IndexedDBDatabaseChild(const nsString& aName,
|
||||
uint64_t aVersion)
|
||||
: mDatabase(NULL), mName(aName), mVersion(aVersion)
|
||||
: mDatabase(nullptr), mName(aName), mVersion(aVersion)
|
||||
{
|
||||
MOZ_COUNT_CTOR(IndexedDBDatabaseChild);
|
||||
}
|
||||
|
@ -284,15 +283,15 @@ IndexedDBDatabaseChild::EnsureDatabase(
|
|||
const DatabaseInfoGuts& aDBInfo,
|
||||
const InfallibleTArray<ObjectStoreInfoGuts>& aOSInfo)
|
||||
{
|
||||
nsCOMPtr<nsIAtom> databaseId;
|
||||
nsCString databaseId;
|
||||
if (mDatabase) {
|
||||
databaseId = mDatabase->Id();
|
||||
}
|
||||
else {
|
||||
databaseId = QuotaManager::GetStorageId(aDBInfo.persistenceType,
|
||||
aDBInfo.origin, aDBInfo.name);
|
||||
QuotaManager::GetStorageId(aDBInfo.persistenceType,
|
||||
aDBInfo.origin, aDBInfo.name, databaseId);
|
||||
}
|
||||
NS_ENSURE_TRUE(databaseId, false);
|
||||
MOZ_ASSERT(!databaseId.IsEmpty());
|
||||
|
||||
nsRefPtr<DatabaseInfo> dbInfo;
|
||||
if (DatabaseInfo::Get(databaseId, getter_AddRefs(dbInfo))) {
|
||||
|
@ -326,7 +325,7 @@ IndexedDBDatabaseChild::EnsureDatabase(
|
|||
if (!mDatabase) {
|
||||
nsRefPtr<IDBDatabase> database =
|
||||
IDBDatabase::Create(aRequest, aRequest->Factory(), dbInfo.forget(),
|
||||
aDBInfo.origin, NULL, NULL);
|
||||
aDBInfo.origin, nullptr, nullptr);
|
||||
if (!database) {
|
||||
NS_WARNING("Failed to create database!");
|
||||
return false;
|
||||
|
@ -345,9 +344,9 @@ void
|
|||
IndexedDBDatabaseChild::ActorDestroy(ActorDestroyReason aWhy)
|
||||
{
|
||||
if (mDatabase) {
|
||||
mDatabase->SetActor(static_cast<IndexedDBDatabaseChild*>(NULL));
|
||||
mDatabase->SetActor(static_cast<IndexedDBDatabaseChild*>(nullptr));
|
||||
#ifdef DEBUG
|
||||
mDatabase = NULL;
|
||||
mDatabase = nullptr;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -416,7 +415,7 @@ IndexedDBDatabaseChild::RecvError(const nsresult& aRv)
|
|||
request->Reset();
|
||||
}
|
||||
else {
|
||||
openHelper = new IPCOpenDatabaseHelper(NULL, request);
|
||||
openHelper = new IPCOpenDatabaseHelper(nullptr, request);
|
||||
}
|
||||
|
||||
openHelper->SetError(aRv);
|
||||
|
@ -558,7 +557,7 @@ IndexedDBDatabaseChild::DeallocPIndexedDBTransactionChild(
|
|||
******************************************************************************/
|
||||
|
||||
IndexedDBTransactionChild::IndexedDBTransactionChild()
|
||||
: mTransaction(NULL)
|
||||
: mTransaction(nullptr)
|
||||
{
|
||||
MOZ_COUNT_CTOR(IndexedDBTransactionChild);
|
||||
}
|
||||
|
@ -625,9 +624,9 @@ IndexedDBTransactionChild::ActorDestroy(ActorDestroyReason aWhy)
|
|||
}
|
||||
|
||||
if (mTransaction) {
|
||||
mTransaction->SetActor(static_cast<IndexedDBTransactionChild*>(NULL));
|
||||
mTransaction->SetActor(static_cast<IndexedDBTransactionChild*>(nullptr));
|
||||
#ifdef DEBUG
|
||||
mTransaction = NULL;
|
||||
mTransaction = nullptr;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -718,9 +717,9 @@ void
|
|||
IndexedDBObjectStoreChild::ActorDestroy(ActorDestroyReason aWhy)
|
||||
{
|
||||
if (mObjectStore) {
|
||||
mObjectStore->SetActor(static_cast<IndexedDBObjectStoreChild*>(NULL));
|
||||
mObjectStore->SetActor(static_cast<IndexedDBObjectStoreChild*>(nullptr));
|
||||
#ifdef DEBUG
|
||||
mObjectStore = NULL;
|
||||
mObjectStore = nullptr;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -861,9 +860,9 @@ void
|
|||
IndexedDBIndexChild::ActorDestroy(ActorDestroyReason aWhy)
|
||||
{
|
||||
if (mIndex) {
|
||||
mIndex->SetActor(static_cast<IndexedDBIndexChild*>(NULL));
|
||||
mIndex->SetActor(static_cast<IndexedDBIndexChild*>(nullptr));
|
||||
#ifdef DEBUG
|
||||
mIndex = NULL;
|
||||
mIndex = nullptr;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -953,7 +952,7 @@ IndexedDBIndexChild::DeallocPIndexedDBCursorChild(PIndexedDBCursorChild* aActor)
|
|||
******************************************************************************/
|
||||
|
||||
IndexedDBCursorChild::IndexedDBCursorChild()
|
||||
: mCursor(NULL)
|
||||
: mCursor(nullptr)
|
||||
{
|
||||
MOZ_COUNT_CTOR(IndexedDBCursorChild);
|
||||
}
|
||||
|
@ -991,9 +990,9 @@ void
|
|||
IndexedDBCursorChild::ActorDestroy(ActorDestroyReason aWhy)
|
||||
{
|
||||
if (mCursor) {
|
||||
mCursor->SetActor(static_cast<IndexedDBCursorChild*>(NULL));
|
||||
mCursor->SetActor(static_cast<IndexedDBCursorChild*>(nullptr));
|
||||
#ifdef DEBUG
|
||||
mCursor = NULL;
|
||||
mCursor = nullptr;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -1232,13 +1231,13 @@ IndexedDBCursorRequestChild::Recv__delete__(const ResponseValue& aResponse)
|
|||
IndexedDBDeleteDatabaseRequestChild::IndexedDBDeleteDatabaseRequestChild(
|
||||
IDBFactory* aFactory,
|
||||
IDBOpenDBRequest* aOpenRequest,
|
||||
nsIAtom* aDatabaseId)
|
||||
const nsACString& aDatabaseId)
|
||||
: mFactory(aFactory), mOpenRequest(aOpenRequest), mDatabaseId(aDatabaseId)
|
||||
{
|
||||
MOZ_COUNT_CTOR(IndexedDBDeleteDatabaseRequestChild);
|
||||
MOZ_ASSERT(aFactory);
|
||||
MOZ_ASSERT(aOpenRequest);
|
||||
MOZ_ASSERT(aDatabaseId);
|
||||
MOZ_ASSERT(!aDatabaseId.IsEmpty());
|
||||
}
|
||||
|
||||
IndexedDBDeleteDatabaseRequestChild::~IndexedDBDeleteDatabaseRequestChild()
|
||||
|
|
|
@ -19,8 +19,6 @@
|
|||
#include "mozilla/dom/indexedDB/PIndexedDBRequestChild.h"
|
||||
#include "mozilla/dom/indexedDB/PIndexedDBTransactionChild.h"
|
||||
|
||||
class nsIAtom;
|
||||
|
||||
BEGIN_INDEXEDDB_NAMESPACE
|
||||
|
||||
class AsyncConnectionHelper;
|
||||
|
@ -415,12 +413,12 @@ class IndexedDBDeleteDatabaseRequestChild :
|
|||
{
|
||||
nsRefPtr<IDBFactory> mFactory;
|
||||
nsRefPtr<IDBOpenDBRequest> mOpenRequest;
|
||||
nsCOMPtr<nsIAtom> mDatabaseId;
|
||||
nsCString mDatabaseId;
|
||||
|
||||
public:
|
||||
IndexedDBDeleteDatabaseRequestChild(IDBFactory* aFactory,
|
||||
IDBOpenDBRequest* aOpenRequest,
|
||||
nsIAtom* aDatabaseId);
|
||||
const nsACString& aDatabaseId);
|
||||
virtual ~IndexedDBDeleteDatabaseRequestChild();
|
||||
|
||||
protected:
|
||||
|
|
|
@ -53,7 +53,7 @@ AutoSetCurrentTransaction::AutoSetCurrentTransaction(
|
|||
|
||||
AutoSetCurrentTransaction::~AutoSetCurrentTransaction()
|
||||
{
|
||||
AsyncConnectionHelper::SetCurrentTransaction(NULL);
|
||||
AsyncConnectionHelper::SetCurrentTransaction(nullptr);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
|
@ -567,7 +567,7 @@ void
|
|||
IndexedDBDatabaseParent::ActorDestroy(ActorDestroyReason aWhy)
|
||||
{
|
||||
if (mDatabase) {
|
||||
mDatabase->SetActor(static_cast<IndexedDBDatabaseParent*>(NULL));
|
||||
mDatabase->SetActor(static_cast<IndexedDBDatabaseParent*>(nullptr));
|
||||
mDatabase->Invalidate();
|
||||
}
|
||||
}
|
||||
|
@ -746,7 +746,7 @@ IndexedDBTransactionParent::ActorDestroy(ActorDestroyReason aWhy)
|
|||
mArtificialRequestCount = false;
|
||||
#endif
|
||||
}
|
||||
mTransaction->SetActor(static_cast<IndexedDBTransactionParent*>(NULL));
|
||||
mTransaction->SetActor(static_cast<IndexedDBTransactionParent*>(nullptr));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -998,7 +998,7 @@ void
|
|||
IndexedDBCursorParent::ActorDestroy(ActorDestroyReason aWhy)
|
||||
{
|
||||
MOZ_ASSERT(mCursor);
|
||||
mCursor->SetActor(static_cast<IndexedDBCursorParent*>(NULL));
|
||||
mCursor->SetActor(static_cast<IndexedDBCursorParent*>(nullptr));
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -1075,7 +1075,7 @@ void
|
|||
IndexedDBObjectStoreParent::ActorDestroy(ActorDestroyReason aWhy)
|
||||
{
|
||||
if (mObjectStore) {
|
||||
mObjectStore->SetActor(static_cast<IndexedDBObjectStoreParent*>(NULL));
|
||||
mObjectStore->SetActor(static_cast<IndexedDBObjectStoreParent*>(nullptr));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1359,7 +1359,7 @@ void
|
|||
IndexedDBIndexParent::ActorDestroy(ActorDestroyReason aWhy)
|
||||
{
|
||||
if (mIndex) {
|
||||
mIndex->SetActor(static_cast<IndexedDBIndexParent*>(NULL));
|
||||
mIndex->SetActor(static_cast<IndexedDBIndexParent*>(nullptr));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1460,7 +1460,7 @@ void
|
|||
IndexedDBRequestParentBase::ActorDestroy(ActorDestroyReason aWhy)
|
||||
{
|
||||
if (mRequest) {
|
||||
mRequest->SetActor(NULL);
|
||||
mRequest->SetActor(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -93,7 +93,7 @@ public:
|
|||
void
|
||||
NoteDyingActor()
|
||||
{
|
||||
mActor = NULL;
|
||||
mActor = nullptr;
|
||||
}
|
||||
|
||||
NS_IMETHOD
|
||||
|
|
|
@ -244,7 +244,7 @@ struct ParamTraits<mozilla::dom::indexedDB::SerializedStructuredCloneReadInfo>
|
|||
return false;
|
||||
}
|
||||
} else {
|
||||
aResult->data = NULL;
|
||||
aResult->data = nullptr;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -283,7 +283,7 @@ struct ParamTraits<mozilla::dom::indexedDB::SerializedStructuredCloneWriteInfo>
|
|||
return false;
|
||||
}
|
||||
} else {
|
||||
aResult->data = NULL;
|
||||
aResult->data = nullptr;
|
||||
}
|
||||
|
||||
if (!ReadParam(aMsg, aIter, &aResult->offsetToKeyProp)) {
|
||||
|
|
|
@ -494,21 +494,22 @@ TabParent::UpdateFrame(const FrameMetrics& aFrameMetrics)
|
|||
}
|
||||
}
|
||||
|
||||
void TabParent::HandleDoubleTap(const CSSIntPoint& aPoint)
|
||||
void TabParent::HandleDoubleTap(const CSSIntPoint& aPoint, int32_t aModifiers)
|
||||
{
|
||||
if (!mIsDestroyed) {
|
||||
unused << SendHandleDoubleTap(aPoint);
|
||||
}
|
||||
}
|
||||
|
||||
void TabParent::HandleSingleTap(const CSSIntPoint& aPoint)
|
||||
void TabParent::HandleSingleTap(const CSSIntPoint& aPoint, int32_t aModifiers)
|
||||
{
|
||||
// TODO Send the modifier data to TabChild for use in mouse events.
|
||||
if (!mIsDestroyed) {
|
||||
unused << SendHandleSingleTap(aPoint);
|
||||
}
|
||||
}
|
||||
|
||||
void TabParent::HandleLongTap(const CSSIntPoint& aPoint)
|
||||
void TabParent::HandleLongTap(const CSSIntPoint& aPoint, int32_t aModifiers)
|
||||
{
|
||||
if (!mIsDestroyed) {
|
||||
unused << SendHandleLongTap(aPoint);
|
||||
|
|
|
@ -196,9 +196,9 @@ public:
|
|||
void Show(const nsIntSize& size);
|
||||
void UpdateDimensions(const nsRect& rect, const nsIntSize& size);
|
||||
void UpdateFrame(const layers::FrameMetrics& aFrameMetrics);
|
||||
void HandleDoubleTap(const CSSIntPoint& aPoint);
|
||||
void HandleSingleTap(const CSSIntPoint& aPoint);
|
||||
void HandleLongTap(const CSSIntPoint& aPoint);
|
||||
void HandleDoubleTap(const CSSIntPoint& aPoint, int32_t aModifiers);
|
||||
void HandleSingleTap(const CSSIntPoint& aPoint, int32_t aModifiers);
|
||||
void HandleLongTap(const CSSIntPoint& aPoint, int32_t aModifiers);
|
||||
void Activate();
|
||||
void Deactivate();
|
||||
|
||||
|
|
|
@ -6,41 +6,42 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=872377
|
|||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for Bug 872377 and Bug 928304</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<script type="application/javascript">
|
||||
|
||||
/** Test for Bug 872377 **/
|
||||
|
||||
var rtcSession = new mozRTCSessionDescription({ sdp: "Picklechips!",
|
||||
type: "offer" });
|
||||
var jsonCopy = JSON.parse(JSON.stringify(rtcSession));
|
||||
for (key in rtcSession) {
|
||||
if (typeof(rtcSession[key]) == "function") continue;
|
||||
is(rtcSession[key], jsonCopy[key], "key " + key + " should match.");
|
||||
}
|
||||
|
||||
/** Test for Bug 928304 **/
|
||||
|
||||
var rtcIceCandidate = new mozRTCIceCandidate({ candidate: "dummy",
|
||||
sdpMid: "test",
|
||||
sdpMLineIndex: 3 });
|
||||
jsonCopy = JSON.parse(JSON.stringify(rtcIceCandidate));
|
||||
for (key in rtcIceCandidate) {
|
||||
if (typeof(rtcIceCandidate[key]) == "function") continue;
|
||||
is(rtcIceCandidate[key], jsonCopy[key], "key " + key + " should match.");
|
||||
}
|
||||
|
||||
</script>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="application/javascript" src="head.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=872377">Mozilla Bug 872377</a>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=928304">Mozilla Bug 928304</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
createHTML({
|
||||
bug: "928304",
|
||||
title: "test toJSON() on mozRTCSessionDescription and mozRTCIceCandidate"
|
||||
});
|
||||
|
||||
runTest(function () {
|
||||
/** Test for Bug 872377 **/
|
||||
|
||||
var rtcSession = new mozRTCSessionDescription({ sdp: "Picklechips!",
|
||||
type: "offer" });
|
||||
var jsonCopy = JSON.parse(JSON.stringify(rtcSession));
|
||||
for (key in rtcSession) {
|
||||
if (typeof(rtcSession[key]) == "function") continue;
|
||||
is(rtcSession[key], jsonCopy[key], "key " + key + " should match.");
|
||||
}
|
||||
|
||||
/** Test for Bug 928304 **/
|
||||
|
||||
var rtcIceCandidate = new mozRTCIceCandidate({ candidate: "dummy",
|
||||
sdpMid: "test",
|
||||
sdpMLineIndex: 3 });
|
||||
jsonCopy = JSON.parse(JSON.stringify(rtcIceCandidate));
|
||||
for (key in rtcIceCandidate) {
|
||||
if (typeof(rtcIceCandidate[key]) == "function") continue;
|
||||
is(rtcIceCandidate[key], jsonCopy[key], "key " + key + " should match.");
|
||||
}
|
||||
SimpleTest.finish();
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
#include "QuotaManager.h"
|
||||
|
||||
#include "mozIApplicationClearPrivateDataParams.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsIBinaryInputStream.h"
|
||||
#include "nsIBinaryOutputStream.h"
|
||||
#include "nsIFile.h"
|
||||
|
@ -110,7 +109,7 @@ struct SynchronizedOp
|
|||
{
|
||||
SynchronizedOp(const OriginOrPatternString& aOriginOrPattern,
|
||||
Nullable<PersistenceType> aPersistenceType,
|
||||
nsISupports* aId);
|
||||
const nsACString& aId);
|
||||
|
||||
~SynchronizedOp();
|
||||
|
||||
|
@ -126,7 +125,7 @@ struct SynchronizedOp
|
|||
|
||||
const OriginOrPatternString mOriginOrPattern;
|
||||
Nullable<PersistenceType> mPersistenceType;
|
||||
nsCOMPtr<nsISupports> mId;
|
||||
nsCString mId;
|
||||
nsRefPtr<AcquireListener> mListener;
|
||||
nsTArray<nsCOMPtr<nsIRunnable> > mDelayedRunnables;
|
||||
ArrayCluster<nsIOfflineStorage*> mStorages;
|
||||
|
@ -1551,8 +1550,7 @@ QuotaManager::HasOpenTransactions(nsPIDOMWindow* aWindow)
|
|||
nsresult
|
||||
QuotaManager::WaitForOpenAllowed(const OriginOrPatternString& aOriginOrPattern,
|
||||
Nullable<PersistenceType> aPersistenceType,
|
||||
nsIAtom* aId,
|
||||
nsIRunnable* aRunnable)
|
||||
const nsACString& aId, nsIRunnable* aRunnable)
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
NS_ASSERTION(!aOriginOrPattern.IsEmpty() || aOriginOrPattern.IsNull(),
|
||||
|
@ -1588,11 +1586,11 @@ QuotaManager::WaitForOpenAllowed(const OriginOrPatternString& aOriginOrPattern,
|
|||
|
||||
void
|
||||
QuotaManager::AddSynchronizedOp(const OriginOrPatternString& aOriginOrPattern,
|
||||
Nullable<PersistenceType> aPersistenceType,
|
||||
nsIAtom* aId)
|
||||
Nullable<PersistenceType> aPersistenceType)
|
||||
{
|
||||
nsAutoPtr<SynchronizedOp> op(new SynchronizedOp(aOriginOrPattern,
|
||||
aPersistenceType, nullptr));
|
||||
aPersistenceType,
|
||||
EmptyCString()));
|
||||
|
||||
#ifdef DEBUG
|
||||
for (uint32_t index = mSynchronizedOps.Length(); index > 0; index--) {
|
||||
|
@ -1608,7 +1606,7 @@ void
|
|||
QuotaManager::AllowNextSynchronizedOp(
|
||||
const OriginOrPatternString& aOriginOrPattern,
|
||||
Nullable<PersistenceType> aPersistenceType,
|
||||
nsIAtom* aId)
|
||||
const nsACString& aId)
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
NS_ASSERTION(!aOriginOrPattern.IsEmpty() || aOriginOrPattern.IsNull(),
|
||||
|
@ -1631,7 +1629,8 @@ QuotaManager::AllowNextSynchronizedOp(
|
|||
|
||||
// If one or the other is for an origin clear, we should have matched
|
||||
// solely on origin.
|
||||
NS_ASSERTION(op->mId && aId, "Why didn't we match earlier?");
|
||||
NS_ASSERTION(!op->mId.IsEmpty() && !aId.IsEmpty(),
|
||||
"Why didn't we match earlier?");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2004,10 +2003,11 @@ QuotaManager::GetStorageQuotaMB()
|
|||
}
|
||||
|
||||
// static
|
||||
already_AddRefed<nsIAtom>
|
||||
void
|
||||
QuotaManager::GetStorageId(PersistenceType aPersistenceType,
|
||||
const nsACString& aOrigin,
|
||||
const nsAString& aName)
|
||||
const nsAString& aName,
|
||||
nsACString& aDatabaseId)
|
||||
{
|
||||
nsAutoCString str;
|
||||
str.AppendInt(aPersistenceType);
|
||||
|
@ -2016,10 +2016,7 @@ QuotaManager::GetStorageId(PersistenceType aPersistenceType,
|
|||
str.Append('*');
|
||||
str.Append(NS_ConvertUTF16toUTF8(aName));
|
||||
|
||||
nsCOMPtr<nsIAtom> atom = do_GetAtom(str);
|
||||
NS_ENSURE_TRUE(atom, nullptr);
|
||||
|
||||
return atom.forget();
|
||||
aDatabaseId = str;
|
||||
}
|
||||
|
||||
// static
|
||||
|
@ -2218,7 +2215,8 @@ QuotaManager::GetUsageForURI(nsIURI* aURI,
|
|||
aCallback);
|
||||
|
||||
// Put the computation runnable in the queue.
|
||||
rv = WaitForOpenAllowed(oops, Nullable<PersistenceType>(), nullptr, runnable);
|
||||
rv = WaitForOpenAllowed(oops, Nullable<PersistenceType>(), EmptyCString(),
|
||||
runnable);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
runnable->AdvanceState();
|
||||
|
@ -2243,7 +2241,8 @@ QuotaManager::Clear()
|
|||
|
||||
// Put the clear runnable in the queue.
|
||||
nsresult rv =
|
||||
WaitForOpenAllowed(oops, Nullable<PersistenceType>(), nullptr, runnable);
|
||||
WaitForOpenAllowed(oops, Nullable<PersistenceType>(), EmptyCString(),
|
||||
runnable);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
runnable->AdvanceState();
|
||||
|
@ -2301,7 +2300,8 @@ QuotaManager::ClearStoragesForURI(nsIURI* aURI,
|
|||
// Queue up the origin clear runnable.
|
||||
nsRefPtr<OriginClearRunnable> runnable = new OriginClearRunnable(oops);
|
||||
|
||||
rv = WaitForOpenAllowed(oops, Nullable<PersistenceType>(), nullptr, runnable);
|
||||
rv = WaitForOpenAllowed(oops, Nullable<PersistenceType>(), EmptyCString(),
|
||||
runnable);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
runnable->AdvanceState();
|
||||
|
@ -2338,7 +2338,8 @@ QuotaManager::Reset()
|
|||
|
||||
// Put the reset runnable in the queue.
|
||||
nsresult rv =
|
||||
WaitForOpenAllowed(oops, Nullable<PersistenceType>(), nullptr, runnable);
|
||||
WaitForOpenAllowed(oops, Nullable<PersistenceType>(), EmptyCString(),
|
||||
runnable);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
runnable->AdvanceState();
|
||||
|
@ -2642,7 +2643,8 @@ QuotaManager::AcquireExclusiveAccess(const nsACString& aPattern,
|
|||
aStorage->Id());
|
||||
}
|
||||
else {
|
||||
op = FindSynchronizedOp(aPattern, Nullable<PersistenceType>(), nullptr);
|
||||
op = FindSynchronizedOp(aPattern, Nullable<PersistenceType>(),
|
||||
EmptyCString());
|
||||
}
|
||||
|
||||
NS_ASSERTION(op, "We didn't find a SynchronizedOp?");
|
||||
|
@ -2797,14 +2799,14 @@ QuotaManager::RunSynchronizedOp(nsIOfflineStorage* aStorage,
|
|||
SynchronizedOp*
|
||||
QuotaManager::FindSynchronizedOp(const nsACString& aPattern,
|
||||
Nullable<PersistenceType> aPersistenceType,
|
||||
nsISupports* aId)
|
||||
const nsACString& aId)
|
||||
{
|
||||
for (uint32_t index = 0; index < mSynchronizedOps.Length(); index++) {
|
||||
const nsAutoPtr<SynchronizedOp>& currentOp = mSynchronizedOps[index];
|
||||
if (PatternMatchesOrigin(aPattern, currentOp->mOriginOrPattern) &&
|
||||
(currentOp->mPersistenceType.IsNull() ||
|
||||
currentOp->mPersistenceType == aPersistenceType) &&
|
||||
(!currentOp->mId || currentOp->mId == aId)) {
|
||||
(currentOp->mId.IsEmpty() || currentOp->mId == aId)) {
|
||||
return currentOp;
|
||||
}
|
||||
}
|
||||
|
@ -2837,7 +2839,8 @@ QuotaManager::ClearStoragesForApp(uint32_t aAppId, bool aBrowserOnly)
|
|||
nsRefPtr<OriginClearRunnable> runnable = new OriginClearRunnable(oops);
|
||||
|
||||
nsresult rv =
|
||||
WaitForOpenAllowed(oops, Nullable<PersistenceType>(), nullptr, runnable);
|
||||
WaitForOpenAllowed(oops, Nullable<PersistenceType>(), EmptyCString(),
|
||||
runnable);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
runnable->AdvanceState();
|
||||
|
@ -3125,8 +3128,7 @@ QuotaManager::CollectOriginsForEviction(uint64_t aMinSizeToBeFreed,
|
|||
OriginOrPatternString::FromOrigin(inactiveOrigins[index]->mOrigin);
|
||||
|
||||
AddSynchronizedOp(oops,
|
||||
Nullable<PersistenceType>(PERSISTENCE_TYPE_TEMPORARY),
|
||||
nullptr);
|
||||
Nullable<PersistenceType>(PERSISTENCE_TYPE_TEMPORARY));
|
||||
}
|
||||
|
||||
inactiveOrigins.SwapElements(aOriginInfos);
|
||||
|
@ -3229,7 +3231,7 @@ QuotaManager::GetOriginPatternString(uint32_t aAppId,
|
|||
|
||||
SynchronizedOp::SynchronizedOp(const OriginOrPatternString& aOriginOrPattern,
|
||||
Nullable<PersistenceType> aPersistenceType,
|
||||
nsISupports* aId)
|
||||
const nsACString& aId)
|
||||
: mOriginOrPattern(aOriginOrPattern), mPersistenceType(aPersistenceType),
|
||||
mId(aId)
|
||||
{
|
||||
|
@ -3288,8 +3290,8 @@ SynchronizedOp::MustWaitFor(const SynchronizedOp& aExistingOp)
|
|||
}
|
||||
|
||||
// Waiting is required if either one corresponds to an origin clearing
|
||||
// (a null Id).
|
||||
if (!aExistingOp.mId || !mId) {
|
||||
// (an empty Id).
|
||||
if (aExistingOp.mId.IsEmpty() || mId.IsEmpty()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -3302,7 +3304,7 @@ void
|
|||
SynchronizedOp::DelayRunnable(nsIRunnable* aRunnable)
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
NS_ASSERTION(mDelayedRunnables.IsEmpty() || !mId,
|
||||
NS_ASSERTION(mDelayedRunnables.IsEmpty() || mId.IsEmpty(),
|
||||
"Only ClearOrigin operations can delay multiple runnables!");
|
||||
|
||||
mDelayedRunnables.AppendElement(aRunnable);
|
||||
|
@ -3523,7 +3525,7 @@ OriginClearRunnable::Run()
|
|||
// Tell the QuotaManager that we're done.
|
||||
quotaManager->AllowNextSynchronizedOp(mOriginOrPattern,
|
||||
Nullable<PersistenceType>(),
|
||||
nullptr);
|
||||
EmptyCString());
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -3633,7 +3635,7 @@ AsyncUsageRunnable::RunInternal()
|
|||
if (mCallbackState == Complete) {
|
||||
quotaManager->AllowNextSynchronizedOp(mOrigin,
|
||||
Nullable<PersistenceType>(),
|
||||
nullptr);
|
||||
EmptyCString());
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -3883,7 +3885,7 @@ ResetOrClearRunnable::Run()
|
|||
// Tell the QuotaManager that we're done.
|
||||
quotaManager->AllowNextSynchronizedOp(OriginOrPatternString::FromNull(),
|
||||
Nullable<PersistenceType>(),
|
||||
nullptr);
|
||||
EmptyCString());
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -3950,7 +3952,7 @@ FinalizeOriginEvictionRunnable::Run()
|
|||
quotaManager->AllowNextSynchronizedOp(
|
||||
OriginOrPatternString::FromOrigin(mOrigins[index]),
|
||||
Nullable<PersistenceType>(PERSISTENCE_TYPE_TEMPORARY),
|
||||
nullptr);
|
||||
EmptyCString());
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
#define QUOTA_MANAGER_CONTRACTID "@mozilla.org/dom/quota/manager;1"
|
||||
|
||||
class nsIAtom;
|
||||
class nsIOfflineStorage;
|
||||
class nsIPrincipal;
|
||||
class nsIThread;
|
||||
|
@ -191,8 +190,7 @@ public:
|
|||
nsresult
|
||||
WaitForOpenAllowed(const OriginOrPatternString& aOriginOrPattern,
|
||||
Nullable<PersistenceType> aPersistenceType,
|
||||
nsIAtom* aId,
|
||||
nsIRunnable* aRunnable);
|
||||
const nsACString& aId, nsIRunnable* aRunnable);
|
||||
|
||||
// Acquire exclusive access to the storage given (waits for all others to
|
||||
// close). If storages need to close first, the callback will be invoked
|
||||
|
@ -222,12 +220,13 @@ public:
|
|||
void
|
||||
AllowNextSynchronizedOp(const OriginOrPatternString& aOriginOrPattern,
|
||||
Nullable<PersistenceType> aPersistenceType,
|
||||
nsIAtom* aId);
|
||||
const nsACString& aId);
|
||||
|
||||
bool
|
||||
IsClearOriginPending(const nsACString& aPattern)
|
||||
{
|
||||
return !!FindSynchronizedOp(aPattern, Nullable<PersistenceType>(), nullptr);
|
||||
return !!FindSynchronizedOp(aPattern, Nullable<PersistenceType>(),
|
||||
EmptyCString());
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -286,10 +285,11 @@ public:
|
|||
static uint32_t
|
||||
GetStorageQuotaMB();
|
||||
|
||||
static already_AddRefed<nsIAtom>
|
||||
static void
|
||||
GetStorageId(PersistenceType aPersistenceType,
|
||||
const nsACString& aOrigin,
|
||||
const nsAString& aName);
|
||||
const nsAString& aName,
|
||||
nsACString& aDatabaseId);
|
||||
|
||||
static nsresult
|
||||
GetInfoFromURI(nsIURI* aURI,
|
||||
|
@ -375,8 +375,7 @@ private:
|
|||
|
||||
void
|
||||
AddSynchronizedOp(const OriginOrPatternString& aOriginOrPattern,
|
||||
Nullable<PersistenceType> aPersistenceType,
|
||||
nsIAtom* aId);
|
||||
Nullable<PersistenceType> aPersistenceType);
|
||||
|
||||
nsresult
|
||||
RunSynchronizedOp(nsIOfflineStorage* aStorage,
|
||||
|
@ -385,7 +384,7 @@ private:
|
|||
SynchronizedOp*
|
||||
FindSynchronizedOp(const nsACString& aPattern,
|
||||
Nullable<PersistenceType> aPersistenceType,
|
||||
nsISupports* aId);
|
||||
const nsACString& aId);
|
||||
|
||||
nsresult
|
||||
MaybeUpgradeIndexedDBDirectory();
|
||||
|
|
|
@ -6,14 +6,15 @@
|
|||
|
||||
#include "jsapi.h"
|
||||
#include "js/OldDebugAPI.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsJSON.h"
|
||||
#include "nsIXPConnect.h"
|
||||
#include "nsIXPCScriptable.h"
|
||||
#include "nsStreamUtils.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsStringStream.h"
|
||||
#include "nsICharsetConverterManager.h"
|
||||
#include "mozilla/dom/EncodingUtils.h"
|
||||
#include "nsIUnicodeEncoder.h"
|
||||
#include "nsIUnicodeDecoder.h"
|
||||
#include "nsXPCOMStrings.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
@ -24,6 +25,8 @@
|
|||
#include "mozilla/Maybe.h"
|
||||
#include <algorithm>
|
||||
|
||||
using mozilla::dom::EncodingUtils;
|
||||
|
||||
#define JSON_STREAM_BUFSIZE 4096
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsJSON)
|
||||
|
@ -275,11 +278,7 @@ nsJSONWriter::SetCharset(const char* aCharset)
|
|||
{
|
||||
nsresult rv = NS_OK;
|
||||
if (mStream) {
|
||||
nsCOMPtr<nsICharsetConverterManager> ccm =
|
||||
do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = ccm->GetUnicodeEncoder(aCharset, getter_AddRefs(mEncoder));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
mEncoder = EncodingUtils::EncoderForEncoding(aCharset);
|
||||
rv = mEncoder->SetOutputErrorBehavior(nsIUnicodeEncoder::kOnError_Signal,
|
||||
nullptr, '\0');
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
@ -601,11 +600,7 @@ nsJSONListener::ProcessBytes(const char* aBuffer, uint32_t aByteLength)
|
|||
// We should have a unicode charset by now
|
||||
rv = CheckCharset(charset.get());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr<nsICharsetConverterManager> ccm =
|
||||
do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = ccm->GetUnicodeDecoderRaw(charset.get(), getter_AddRefs(mDecoder));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
mDecoder = EncodingUtils::DecoderForEncoding(charset);
|
||||
|
||||
// consume the sniffed bytes
|
||||
rv = ConsumeConverted(mSniffBuffer.get(), mSniffBuffer.Length());
|
||||
|
|
|
@ -11,4 +11,6 @@
|
|||
#define NS_RILCONTENTHELPER_CID \
|
||||
{ 0x472816e1, 0x1fd6, 0x4405, \
|
||||
{ 0x99, 0x6c, 0x80, 0x6f, 0x9e, 0xa6, 0x81, 0x74 } }
|
||||
|
||||
#define NS_RADIOINTERFACELAYER_CONTRACTID "@mozilla.org/ril;1"
|
||||
#define NS_RILCONTENTHELPER_CONTRACTID "@mozilla.org/ril/content-helper;1"
|
||||
|
|
|
@ -330,7 +330,7 @@ var interfaceNamesInGlobalScope =
|
|||
"MediaStream",
|
||||
"MediaStreamAudioDestinationNode",
|
||||
"MediaStreamAudioSourceNode",
|
||||
"MediaStreamEvent",
|
||||
{name: "MediaStreamEvent", pref: "media.peerconnection.enabled"},
|
||||
"MediaStreamTrack",
|
||||
"MessageEvent",
|
||||
"MessagePort",
|
||||
|
@ -366,9 +366,9 @@ var interfaceNamesInGlobalScope =
|
|||
{name: "MozNFCTag", b2g: true},
|
||||
{name: "MozOtaStatusEvent", b2g: true, pref: "dom.mobileconnection.enabled"},
|
||||
"MozPowerManager",
|
||||
"mozRTCIceCandidate",
|
||||
"mozRTCPeerConnection",
|
||||
"mozRTCSessionDescription",
|
||||
{name: "mozRTCIceCandidate", pref: "media.peerconnection.enabled"},
|
||||
{name: "mozRTCPeerConnection", pref: "media.peerconnection.enabled"},
|
||||
{name: "mozRTCSessionDescription", pref: "media.peerconnection.enabled"},
|
||||
"MozSettingsEvent",
|
||||
"MozSmsEvent",
|
||||
"MozSmsFilter",
|
||||
|
@ -419,9 +419,9 @@ var interfaceNamesInGlobalScope =
|
|||
"RecordErrorEvent",
|
||||
"Rect",
|
||||
"RGBColor",
|
||||
"RTCDataChannelEvent",
|
||||
"RTCPeerConnectionIceEvent",
|
||||
"RTCStatsReport",
|
||||
{name: "RTCDataChannelEvent", pref: "media.peerconnection.enabled"},
|
||||
{name: "RTCPeerConnectionIceEvent", pref: "media.peerconnection.enabled"},
|
||||
{name: "RTCStatsReport", pref: "media.peerconnection.enabled"},
|
||||
"Screen",
|
||||
"ScriptProcessorNode",
|
||||
"ScrollAreaEvent",
|
||||
|
|
|
@ -27,17 +27,28 @@ enum VisibilityState { "hidden", "visible" };
|
|||
interface Document : Node {
|
||||
[Throws]
|
||||
readonly attribute DOMImplementation implementation;
|
||||
[Pure]
|
||||
readonly attribute DOMString URL;
|
||||
[Pure]
|
||||
readonly attribute DOMString documentURI;
|
||||
[Pure]
|
||||
readonly attribute DOMString compatMode;
|
||||
[Pure]
|
||||
readonly attribute DOMString characterSet;
|
||||
[Pure]
|
||||
readonly attribute DOMString contentType;
|
||||
|
||||
[Pure]
|
||||
readonly attribute DocumentType? doctype;
|
||||
[Pure]
|
||||
readonly attribute Element? documentElement;
|
||||
[Pure]
|
||||
HTMLCollection getElementsByTagName(DOMString localName);
|
||||
[Pure]
|
||||
HTMLCollection getElementsByTagNameNS(DOMString? namespace, DOMString localName);
|
||||
[Pure]
|
||||
HTMLCollection getElementsByClassName(DOMString classNames);
|
||||
[Pure]
|
||||
Element? getElementById(DOMString elementId);
|
||||
|
||||
[NewObject, Throws]
|
||||
|
@ -85,6 +96,7 @@ interface Document : Node {
|
|||
Attr createAttribute(DOMString name);
|
||||
[NewObject, Throws]
|
||||
Attr createAttributeNS(DOMString? namespace, DOMString name);
|
||||
[Pure]
|
||||
readonly attribute DOMString? inputEncoding;
|
||||
};
|
||||
|
||||
|
@ -99,8 +111,9 @@ partial interface Document {
|
|||
|
||||
// DOM tree accessors
|
||||
//(Not proxy yet)getter object (DOMString name);
|
||||
[SetterThrows]
|
||||
[SetterThrows, Pure]
|
||||
attribute DOMString title;
|
||||
[Pure]
|
||||
attribute DOMString dir;
|
||||
//(HTML only) attribute HTMLElement? body;
|
||||
//(HTML only)readonly attribute HTMLHeadElement? head;
|
||||
|
@ -122,6 +135,7 @@ partial interface Document {
|
|||
//(HTML only)void writeln(DOMString... text);
|
||||
|
||||
// user interaction
|
||||
[Pure]
|
||||
readonly attribute WindowProxy? defaultView;
|
||||
readonly attribute Element? activeElement;
|
||||
[Throws]
|
||||
|
@ -157,6 +171,7 @@ partial interface Document {
|
|||
*
|
||||
* @see <https://developer.mozilla.org/en/DOM/document.currentScript>
|
||||
*/
|
||||
[Pure]
|
||||
readonly attribute Element? currentScript;
|
||||
/**
|
||||
* Release the current mouse capture if it is on an element within this
|
||||
|
|
|
@ -37,7 +37,9 @@ interface Element : Node {
|
|||
|
||||
[SameObject]
|
||||
readonly attribute MozNamedAttrMap attributes;
|
||||
[Pure]
|
||||
DOMString? getAttribute(DOMString name);
|
||||
[Pure]
|
||||
DOMString? getAttributeNS(DOMString? namespace, DOMString localName);
|
||||
[Throws]
|
||||
void setAttribute(DOMString name, DOMString value);
|
||||
|
@ -47,12 +49,16 @@ interface Element : Node {
|
|||
void removeAttribute(DOMString name);
|
||||
[Throws]
|
||||
void removeAttributeNS(DOMString? namespace, DOMString localName);
|
||||
[Pure]
|
||||
boolean hasAttribute(DOMString name);
|
||||
[Pure]
|
||||
boolean hasAttributeNS(DOMString? namespace, DOMString localName);
|
||||
|
||||
[Pure]
|
||||
HTMLCollection getElementsByTagName(DOMString localName);
|
||||
[Throws]
|
||||
HTMLCollection getElementsByTagNameNS(DOMString? namespace, DOMString localName);
|
||||
[Pure]
|
||||
HTMLCollection getElementsByClassName(DOMString classNames);
|
||||
|
||||
/**
|
||||
|
@ -70,7 +76,7 @@ interface Element : Node {
|
|||
readonly attribute float fontSizeInflation;
|
||||
|
||||
// Mozilla specific stuff
|
||||
|
||||
[Pure]
|
||||
attribute EventHandler onwheel;
|
||||
|
||||
// Selectors API
|
||||
|
|
|
@ -15,6 +15,6 @@ interface ImageData {
|
|||
readonly attribute unsigned long width;
|
||||
[Constant]
|
||||
readonly attribute unsigned long height;
|
||||
[Constant]
|
||||
[Constant, StoreInSlot]
|
||||
readonly attribute Uint8ClampedArray data;
|
||||
};
|
||||
|
|
|
@ -41,6 +41,7 @@ interface Node : EventTarget {
|
|||
readonly attribute Node? parentNode;
|
||||
[Pure]
|
||||
readonly attribute Element? parentElement;
|
||||
[Pure]
|
||||
boolean hasChildNodes();
|
||||
[SameObject]
|
||||
readonly attribute NodeList childNodes;
|
||||
|
@ -71,6 +72,7 @@ interface Node : EventTarget {
|
|||
Node cloneNode();
|
||||
[Throws]
|
||||
Node cloneNode(boolean deep);
|
||||
[Pure]
|
||||
boolean isEqualNode(Node? node);
|
||||
|
||||
const unsigned short DOCUMENT_POSITION_DISCONNECTED = 0x01;
|
||||
|
@ -79,11 +81,16 @@ interface Node : EventTarget {
|
|||
const unsigned short DOCUMENT_POSITION_CONTAINS = 0x08;
|
||||
const unsigned short DOCUMENT_POSITION_CONTAINED_BY = 0x10;
|
||||
const unsigned short DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 0x20; // historical
|
||||
[Pure]
|
||||
unsigned short compareDocumentPosition(Node other);
|
||||
[Pure]
|
||||
boolean contains(Node? other);
|
||||
|
||||
[Pure]
|
||||
DOMString? lookupPrefix(DOMString? namespace);
|
||||
[Pure]
|
||||
DOMString? lookupNamespaceURI(DOMString? prefix);
|
||||
[Pure]
|
||||
boolean isDefaultNamespace(DOMString? namespace);
|
||||
|
||||
// Mozilla-specific stuff
|
||||
|
@ -97,6 +104,7 @@ interface Node : EventTarget {
|
|||
[Constant]
|
||||
readonly attribute DOMString? localName;
|
||||
|
||||
[Pure]
|
||||
boolean hasAttributes();
|
||||
[Throws, Func="IsChromeOrXBL"]
|
||||
any setUserData(DOMString key, any data, UserDataHandler? handler);
|
||||
|
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче