Skip to content

Commit

Permalink
merge mozilla-inbound to mozilla-central. r=merge a=merge
Browse files Browse the repository at this point in the history
MozReview-Commit-ID: IgyDMUVYYBm
  • Loading branch information
Archaeopteryx committed Sep 11, 2017
2 parents e376f14 + f2b7e3f commit dbddac8
Show file tree
Hide file tree
Showing 30 changed files with 508 additions and 342 deletions.
2 changes: 2 additions & 0 deletions browser/app/profile/firefox.js
Original file line number Diff line number Diff line change
Expand Up @@ -1481,6 +1481,8 @@ pref("toolkit.telemetry.archive.enabled", true);
pref("toolkit.telemetry.shutdownPingSender.enabled", true);
// Enables sending the shutdown ping using the pingsender from the first session.
pref("toolkit.telemetry.shutdownPingSender.enabledFirstSession", false);
// Enables sending a duplicate of the first shutdown ping from the first session.
pref("toolkit.telemetry.firstShutdownPing.enabled", true);
// Enables sending the 'new-profile' ping on new profiles.
pref("toolkit.telemetry.newProfilePing.enabled", true);
// Enables sending 'update' pings on Firefox updates.
Expand Down
8 changes: 4 additions & 4 deletions dom/html/nsHTMLDocument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3242,9 +3242,10 @@ nsHTMLDocument::ExecCommand(const nsAString& commandID,

bool isCutCopy = (commandID.LowerCaseEqualsLiteral("cut") ||
commandID.LowerCaseEqualsLiteral("copy"));
bool isPaste = commandID.LowerCaseEqualsLiteral("paste");

// if editing is not on, bail
if (!isCutCopy && !IsEditingOnAfterFlush()) {
if (!isCutCopy && !isPaste && !IsEditingOnAfterFlush()) {
return false;
}

Expand Down Expand Up @@ -3285,9 +3286,8 @@ nsHTMLDocument::ExecCommand(const nsAString& commandID,
return false;
}

bool restricted = commandID.LowerCaseEqualsLiteral("paste");
if (restricted && !nsContentUtils::PrincipalHasPermission(&aSubjectPrincipal,
nsGkAtoms::clipboardRead)) {
if (isPaste && !nsContentUtils::PrincipalHasPermission(&aSubjectPrincipal,
nsGkAtoms::clipboardRead)) {
return false;
}

Expand Down
1 change: 1 addition & 0 deletions editor/libeditor/tests/mochitest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -278,3 +278,4 @@ skip-if = toolkit == 'android' # chrome urls not available due to packaging
[test_selection_move_commands.html]
[test_pasteImgTextarea.html]
skip-if = toolkit == 'android' # bug 1299578
[test_execCommandPaste_noTarget.html]
48 changes: 48 additions & 0 deletions editor/libeditor/tests/test_execCommandPaste_noTarget.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<!DOCTYPE HTML>
<html>
<head>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SpawnTask.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<script>

add_task(async function() {
let seenPaste = false;
let seenCopy = false;
document.addEventListener("copy", function oncpy(e) {
document.removeEventListener("copy", oncpy);
e.clipboardData.setData("text/plain", "my text");
e.preventDefault();
seenCopy = true;
});
document.addEventListener("paste", function onpst(e) {
document.removeEventListener("paste", onpst);
is(e.clipboardData.getData("text/plain"), "my text",
"The correct text was read from the clipboard");
e.preventDefault();
seenPaste = true;
});

ok(SpecialPowers.wrap(document).execCommand("copy"),
"Call should succeed");
ok(seenCopy, "Successfully copied the text to the clipboard");
ok(SpecialPowers.wrap(document).execCommand("paste"),
"Call should succeed");
ok(seenPaste, "Successfully read text from the clipboard");

// Check that reading text from the clipboard in non-privileged contexts
// still doesn't work.
function onpstfail(e) {
ok(false, "Should not see paste event triggered by non-privileged call");
}
document.addEventListener("paste", onpstfail);
ok(!document.execCommand("paste"), "Call should fail");
document.removeEventListener("paste", onpstfail);
});

</script>
</body>
</html>
35 changes: 16 additions & 19 deletions gfx/thebes/gfxDWriteFontList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,19 @@ gfxDWriteFontFamily::LocalizedName(nsAString &aLocalizedName)
aLocalizedName = nsDependentString(famName.Elements());
}

bool
gfxDWriteFontFamily::IsSymbolFontFamily() const
{
// Just check the first font in the family
if (mDWFamily->GetFontCount() > 0) {
RefPtr<IDWriteFont> font;
if (SUCCEEDED(mDWFamily->GetFont(0, getter_AddRefs(font)))) {
return font->IsSymbolFont();
}
}
return false;
}

void
gfxDWriteFontFamily::AddSizeOfExcludingThis(MallocSizeOf aMallocSizeOf,
FontListSizes* aSizes) const
Expand Down Expand Up @@ -371,16 +384,6 @@ gfxDWriteFontEntry::~gfxDWriteFontEntry()
{
}

bool
gfxDWriteFontEntry::IsSymbolFont()
{
if (mFont) {
return mFont->IsSymbolFont();
} else {
return false;
}
}

static bool
UsingArabicOrHebrewScriptSystemLocale()
{
Expand Down Expand Up @@ -532,26 +535,22 @@ gfxDWriteFontEntry::ReadCMAP(FontInfoData *aFontInfoData)

RefPtr<gfxCharacterMap> charmap;
nsresult rv;
bool symbolFont;

if (aFontInfoData && (charmap = GetCMAPFromFontInfo(aFontInfoData,
mUVSOffset,
symbolFont))) {
mUVSOffset))) {
rv = NS_OK;
} else {
uint32_t kCMAP = TRUETYPE_TAG('c','m','a','p');
charmap = new gfxCharacterMap();
AutoTable cmapTable(this, kCMAP);

if (cmapTable) {
bool unicodeFont = false, symbolFont = false; // currently ignored
uint32_t cmapLen;
const uint8_t* cmapData =
reinterpret_cast<const uint8_t*>(hb_blob_get_data(cmapTable,
&cmapLen));
rv = gfxFontUtils::ReadCMAP(cmapData, cmapLen,
*charmap, mUVSOffset,
unicodeFont, symbolFont);
*charmap, mUVSOffset);
} else {
rv = NS_ERROR_NOT_AVAILABLE;
}
Expand Down Expand Up @@ -1673,18 +1672,16 @@ DirectWriteFontInfo::LoadFontFamilyData(const nsAString& aFamilyName)

if (SUCCEEDED(hr)) {
bool cmapLoaded = false;
bool unicodeFont = false, symbolFont = false;
RefPtr<gfxCharacterMap> charmap = new gfxCharacterMap();
uint32_t offset;

if (cmapData &&
cmapSize > 0 &&
NS_SUCCEEDED(
gfxFontUtils::ReadCMAP(cmapData, cmapSize, *charmap,
offset, unicodeFont, symbolFont))) {
offset))) {
fontData.mCharacterMap = charmap;
fontData.mUVSOffset = offset;
fontData.mSymbolFont = symbolFont;
cmapLoaded = true;
mLoadStats.cmaps++;
}
Expand Down
10 changes: 8 additions & 2 deletions gfx/thebes/gfxDWriteFontList.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,15 @@ class gfxDWriteFontFamily : public gfxFontFamily
void AddSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
FontListSizes* aSizes) const final;

bool FilterForFontList(nsIAtom* aLangGroup,
const nsACString& aGeneric) const final {
return !IsSymbolFontFamily();
}

protected:
// helper for FilterForFontList
bool IsSymbolFontFamily() const;

/** This font family's directwrite fontfamily object */
RefPtr<IDWriteFontFamily> mDWFamily;
bool mForceGDIClassic;
Expand Down Expand Up @@ -154,8 +162,6 @@ class gfxDWriteFontEntry : public gfxFontEntry

virtual ~gfxDWriteFontEntry();

virtual bool IsSymbolFont();

virtual hb_blob_t* GetFontTable(uint32_t aTableTag) override;

nsresult ReadCMAP(FontInfoData *aFontInfoData = nullptr);
Expand Down
5 changes: 1 addition & 4 deletions gfx/thebes/gfxFT2FontList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -484,11 +484,8 @@ FT2FontEntry::ReadCMAP(FontInfoData *aFontInfoData)
nsresult rv = CopyFontTable(TTAG_cmap, buffer);

if (NS_SUCCEEDED(rv)) {
bool unicodeFont;
bool symbolFont;
rv = gfxFontUtils::ReadCMAP(buffer.Elements(), buffer.Length(),
*charmap, mUVSOffset,
unicodeFont, symbolFont);
*charmap, mUVSOffset);
}

if (NS_SUCCEEDED(rv) && !HasGraphiteTables()) {
Expand Down
89 changes: 50 additions & 39 deletions gfx/thebes/gfxFcPlatformFontList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,39 +325,6 @@ gfxFontconfigFontEntry::~gfxFontconfigFontEntry()
{
}

static bool
PatternHasLang(const FcPattern *aPattern, const FcChar8 *aLang)
{
FcLangSet *langset;

if (FcPatternGetLangSet(aPattern, FC_LANG, 0, &langset) != FcResultMatch) {
return false;
}

if (FcLangSetHasLang(langset, aLang) != FcLangDifferentLang) {
return true;
}
return false;
}

bool
gfxFontconfigFontEntry::SupportsLangGroup(nsIAtom *aLangGroup) const
{
if (!aLangGroup || aLangGroup == nsGkAtoms::Unicode) {
return true;
}

nsAutoCString fcLang;
gfxFcPlatformFontList* pfl = gfxFcPlatformFontList::PlatformFontList();
pfl->GetSampleLangForGroup(aLangGroup, fcLang);
if (fcLang.IsEmpty()) {
return true;
}

// is lang included in the underlying pattern?
return PatternHasLang(mFontPattern, ToFcChar8Ptr(fcLang.get()));
}

nsresult
gfxFontconfigFontEntry::ReadCMAP(FontInfoData *aFontInfoData)
{
Expand All @@ -368,26 +335,22 @@ gfxFontconfigFontEntry::ReadCMAP(FontInfoData *aFontInfoData)

RefPtr<gfxCharacterMap> charmap;
nsresult rv;
bool symbolFont = false; // currently ignored

if (aFontInfoData && (charmap = GetCMAPFromFontInfo(aFontInfoData,
mUVSOffset,
symbolFont))) {
mUVSOffset))) {
rv = NS_OK;
} else {
uint32_t kCMAP = TRUETYPE_TAG('c','m','a','p');
charmap = new gfxCharacterMap();
AutoTable cmapTable(this, kCMAP);

if (cmapTable) {
bool unicodeFont = false; // currently ignored
uint32_t cmapLen;
const uint8_t* cmapData =
reinterpret_cast<const uint8_t*>(hb_blob_get_data(cmapTable,
&cmapLen));
rv = gfxFontUtils::ReadCMAP(cmapData, cmapLen,
*charmap, mUVSOffset,
unicodeFont, symbolFont);
*charmap, mUVSOffset);
} else {
rv = NS_ERROR_NOT_AVAILABLE;
}
Expand Down Expand Up @@ -1189,6 +1152,54 @@ gfxFontconfigFontFamily::FindAllFontsForStyle(const gfxFontStyle& aFontStyle,
}
}

static bool
PatternHasLang(const FcPattern *aPattern, const FcChar8 *aLang)
{
FcLangSet *langset;

if (FcPatternGetLangSet(aPattern, FC_LANG, 0, &langset) != FcResultMatch) {
return false;
}

if (FcLangSetHasLang(langset, aLang) != FcLangDifferentLang) {
return true;
}
return false;
}

bool
gfxFontconfigFontFamily::SupportsLangGroup(nsIAtom *aLangGroup) const
{
if (!aLangGroup || aLangGroup == nsGkAtoms::Unicode) {
return true;
}

nsAutoCString fcLang;
gfxFcPlatformFontList* pfl = gfxFcPlatformFontList::PlatformFontList();
pfl->GetSampleLangForGroup(aLangGroup, fcLang);
if (fcLang.IsEmpty()) {
return true;
}

// Before FindStyleVariations has been called, mFontPatterns will contain
// the font patterns. Afterward, it'll be empty, but mAvailableFonts
// will contain the font entries, each of which holds a reference to its
// pattern. We only check the first pattern in each list, because support
// for langs is considered to be consistent across all faces in a family.
FcPattern* fontPattern;
if (mFontPatterns.Length()) {
fontPattern = mFontPatterns[0];
} else if (mAvailableFonts.Length()) {
fontPattern = static_cast<gfxFontconfigFontEntry*>
(mAvailableFonts[0].get())->GetPattern();
} else {
return true;
}

// is lang included in the underlying pattern?
return PatternHasLang(fontPattern, ToFcChar8Ptr(fcLang.get()));
}

/* virtual */
gfxFontconfigFontFamily::~gfxFontconfigFontFamily()
{
Expand Down
10 changes: 8 additions & 2 deletions gfx/thebes/gfxFcPlatformFontList.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,6 @@ class gfxFontconfigFontEntry : public gfxFontEntry {

FcPattern* GetPattern() { return mFontPattern; }

bool SupportsLangGroup(nsIAtom *aLangGroup) const override;

nsresult ReadCMAP(FontInfoData *aFontInfoData = nullptr) override;
bool TestCharacterMap(uint32_t aCh) override;

Expand Down Expand Up @@ -201,9 +199,17 @@ class gfxFontconfigFontFamily : public gfxFontFamily {
bool& aNeedsSyntheticBold,
bool aIgnoreSizeTolerance) override;

bool FilterForFontList(nsIAtom* aLangGroup,
const nsACString& aGeneric) const final {
return SupportsLangGroup(aLangGroup);
}

protected:
virtual ~gfxFontconfigFontFamily();

// helper for FilterForFontList
bool SupportsLangGroup(nsIAtom *aLangGroup) const;

nsTArray<nsCountedRef<FcPattern> > mFontPatterns;

bool mContainsAppFonts;
Expand Down
Loading

0 comments on commit dbddac8

Please sign in to comment.