merge mozilla-central to mozilla-inbound. r=merge a=merge

This commit is contained in:
Sebastian Hengst 2017-11-09 12:01:00 +02:00
Родитель dcc4df0d8e 1b0413a887
Коммит 1911626bf9
114 изменённых файлов: 830 добавлений и 851 удалений

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

@ -781,7 +781,7 @@ html|input.urlbar-input[textoverflow]:not([focused]) {
margin-inline-end: 0.25em !important; margin-inline-end: 0.25em !important;
} }
#main-window[customizing] :-moz-any(#urlbar, .searchbar-textbox) > .autocomplete-textbox-container > .textbox-input-box { #main-window[customizing] :-moz-any(#urlbar, .searchbar-textbox) > .urlbar-textbox-container > .textbox-input-box {
visibility: hidden; visibility: hidden;
} }

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

@ -2,11 +2,17 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#viewGroup > radio > .radio-label-box {
#viewGroup > radio { -moz-box-orient: vertical;
-moz-binding: url("chrome://browser/content/pageinfo/pageInfo.xml#viewbutton"); -moz-box-align: center;
} }
/* Hide the radio button for the section headers */
#viewGroup > radio > .radio-check {
display: none;
}
richlistitem[feed] { richlistitem[feed] {
-moz-binding: url("chrome://browser/content/pageinfo/feeds.xml#feed"); -moz-binding: url("chrome://browser/content/pageinfo/feeds.xml#feed");
} }

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

@ -1,20 +0,0 @@
<?xml version="1.0"?>
<!-- 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/. -->
<bindings id="pageInfoBindings"
xmlns="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:xbl="http://www.mozilla.org/xbl">
<!-- based on preferences.xml paneButton -->
<binding id="viewbutton" extends="chrome://global/content/bindings/radio.xml#radio" role="xullistitem">
<content>
<xul:image class="viewButtonIcon" xbl:inherits="src"/>
<xul:label class="viewButtonLabel" xbl:inherits="value=label"/>
</content>
</binding>
</bindings>

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

@ -81,7 +81,6 @@
oncommand="showTab('perm');"/> oncommand="showTab('perm');"/>
<radio id="securityTab" label="&securityTab;" accesskey="&securityTab.accesskey;" <radio id="securityTab" label="&securityTab;" accesskey="&securityTab.accesskey;"
oncommand="showTab('security');"/> oncommand="showTab('security');"/>
<!-- Others added by overlay -->
</radiogroup> </radiogroup>
</windowdragbox> </windowdragbox>

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

@ -26,9 +26,7 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
<binding id="urlbar" extends="chrome://global/content/bindings/autocomplete.xml#autocomplete"> <binding id="urlbar" extends="chrome://global/content/bindings/autocomplete.xml#autocomplete">
<content sizetopopup="pref"> <content sizetopopup="pref">
<xul:hbox anonid="textbox-container" <xul:hbox flex="1" class="urlbar-textbox-container">
class="autocomplete-textbox-container urlbar-textbox-container"
flex="1" xbl:inherits="focused">
<children includes="image|deck|stack|box"/> <children includes="image|deck|stack|box"/>
<xul:hbox anonid="textbox-input-box" <xul:hbox anonid="textbox-input-box"
class="textbox-input-box urlbar-input-box" class="textbox-input-box urlbar-input-box"

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

@ -113,7 +113,6 @@ browser.jar:
* content/browser/pageinfo/pageInfo.xul (content/pageinfo/pageInfo.xul) * content/browser/pageinfo/pageInfo.xul (content/pageinfo/pageInfo.xul)
content/browser/pageinfo/pageInfo.js (content/pageinfo/pageInfo.js) content/browser/pageinfo/pageInfo.js (content/pageinfo/pageInfo.js)
content/browser/pageinfo/pageInfo.css (content/pageinfo/pageInfo.css) content/browser/pageinfo/pageInfo.css (content/pageinfo/pageInfo.css)
content/browser/pageinfo/pageInfo.xml (content/pageinfo/pageInfo.xml)
content/browser/pageinfo/feeds.js (content/pageinfo/feeds.js) content/browser/pageinfo/feeds.js (content/pageinfo/feeds.js)
content/browser/pageinfo/feeds.xml (content/pageinfo/feeds.xml) content/browser/pageinfo/feeds.xml (content/pageinfo/feeds.xml)
content/browser/pageinfo/permissions.js (content/pageinfo/permissions.js) content/browser/pageinfo/permissions.js (content/pageinfo/permissions.js)

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

@ -566,10 +566,7 @@
<hbox id="PanelUI-panic-timeframe"> <hbox id="PanelUI-panic-timeframe">
<image id="PanelUI-panic-timeframe-icon" alt=""/> <image id="PanelUI-panic-timeframe-icon" alt=""/>
<vbox flex="1"> <vbox flex="1">
<hbox id="PanelUI-panic-header"> <description id="PanelUI-panic-mainDesc">&panicButton.view.mainTimeframeDesc;</description>
<image id="PanelUI-panic-timeframe-icon-small" alt=""/>
<description id="PanelUI-panic-mainDesc" flex="1">&panicButton.view.mainTimeframeDesc;</description>
</hbox>
<radiogroup id="PanelUI-panic-timeSpan" aria-labelledby="PanelUI-panic-mainDesc" closemenu="none"> <radiogroup id="PanelUI-panic-timeSpan" aria-labelledby="PanelUI-panic-mainDesc" closemenu="none">
<radio id="PanelUI-panic-5min" label="&panicButton.view.5min;" selected="true" <radio id="PanelUI-panic-5min" label="&panicButton.view.5min;" selected="true"
value="5" class="subviewradio"/> value="5" class="subviewradio"/>

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

@ -375,7 +375,7 @@ FormAutofillHandler.prototype = {
} }
let element = fieldDetail.elementWeakRef.get(); let element = fieldDetail.elementWeakRef.get();
if (!(element instanceof Ci.nsIDOMHTMLSelectElement)) { if (ChromeUtils.getClassName(element) !== "HTMLSelectElement") {
continue; continue;
} }
@ -515,7 +515,7 @@ FormAutofillHandler.prototype = {
} }
} }
if (element instanceof Ci.nsIDOMHTMLSelectElement) { if (ChromeUtils.getClassName(element) === "HTMLSelectElement") {
let cache = this._cacheValue.matchingSelectOption.get(element) || {}; let cache = this._cacheValue.matchingSelectOption.get(element) || {};
let option = cache[value] && cache[value].get(); let option = cache[value] && cache[value].get();
if (!option) { if (!option) {
@ -595,7 +595,7 @@ FormAutofillHandler.prototype = {
continue; continue;
} }
if (element instanceof Ci.nsIDOMHTMLSelectElement) { if (ChromeUtils.getClassName(element) === "HTMLSelectElement") {
// Unlike text input, select element is always previewed even if // Unlike text input, select element is always previewed even if
// the option is already selected. // the option is already selected.
if (value) { if (value) {
@ -745,7 +745,7 @@ FormAutofillHandler.prototype = {
// Try to abbreviate the value of select element. // Try to abbreviate the value of select element.
if (type == "address" && if (type == "address" &&
detail.fieldName == "address-level1" && detail.fieldName == "address-level1" &&
element instanceof Ci.nsIDOMHTMLSelectElement) { ChromeUtils.getClassName(element) === "HTMLSelectElement") {
// Don't save the record when the option value is empty *OR* there // Don't save the record when the option value is empty *OR* there
// are multiple options being selected. The empty option is usually // are multiple options being selected. The empty option is usually
// assumed to be default along with a meaningless text to users. // assumed to be default along with a meaningless text to users.

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

@ -310,7 +310,7 @@ this.FormAutofillHeuristics = {
* the current element. * the current element.
*/ */
_isExpirationMonthLikely(element) { _isExpirationMonthLikely(element) {
if (!(element instanceof Ci.nsIDOMHTMLSelectElement)) { if (ChromeUtils.getClassName(element) !== "HTMLSelectElement") {
return false; return false;
} }
@ -337,7 +337,7 @@ this.FormAutofillHeuristics = {
* the current element. * the current element.
*/ */
_isExpirationYearLikely(element) { _isExpirationYearLikely(element) {
if (!(element instanceof Ci.nsIDOMHTMLSelectElement)) { if (ChromeUtils.getClassName(element) !== "HTMLSelectElement") {
return false; return false;
} }

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

@ -551,7 +551,7 @@ TESTCASES.forEach(testcase => {
let input = MOCK_DOC.getElementById(key); let input = MOCK_DOC.getElementById(key);
let value = testcase.formValue[key]; let value = testcase.formValue[key];
if (input instanceof Ci.nsIDOMHTMLSelectElement && value) { if (ChromeUtils.getClassName(input) === "HTMLSelectElement" && value) {
input.multiple = Array.isArray(value); input.multiple = Array.isArray(value);
[...input.options].forEach(option => { [...input.options].forEach(option => {
option.selected = value.includes(option.value); option.selected = value.includes(option.value);

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

@ -9,8 +9,6 @@
/* View buttons */ /* View buttons */
#viewGroup > radio { #viewGroup > radio {
list-style-image: url("chrome://browser/skin/pageInfo.png"); list-style-image: url("chrome://browser/skin/pageInfo.png");
-moz-box-orient: vertical;
-moz-box-align: center;
-moz-appearance: none; -moz-appearance: none;
min-width: 4.5em; min-width: 4.5em;
margin: 0; margin: 0;

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

@ -2,10 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
.autocomplete-textbox-container {
-moz-box-align: stretch;
}
.searchbar-engine-image { .searchbar-engine-image {
height: 16px; height: 16px;
width: 16px; width: 16px;

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

@ -696,7 +696,7 @@ html|span.ac-emphasize-text-url {
} }
} }
#editBMPanel_tagsField > .autocomplete-textbox-container > .textbox-input-box > html|*.textbox-input::placeholder { #editBMPanel_tagsField > .textbox-input-box > html|*.textbox-input::placeholder {
opacity: 1.0; opacity: 1.0;
color: #bbb; color: #bbb;
} }

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

@ -17,7 +17,7 @@ browser.jar:
skin/classic/browser/panel-expander-open@2x.png skin/classic/browser/panel-expander-open@2x.png
skin/classic/browser/panel-plus-sign.png skin/classic/browser/panel-plus-sign.png
skin/classic/browser/page-livemarks.png skin/classic/browser/page-livemarks.png
skin/classic/browser/pageInfo.css * skin/classic/browser/pageInfo.css
skin/classic/browser/searchbar.css skin/classic/browser/searchbar.css
skin/classic/browser/slowStartup-16.png skin/classic/browser/slowStartup-16.png
skin/classic/browser/toolbarbutton-dropmarker.png skin/classic/browser/toolbarbutton-dropmarker.png

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

@ -4,13 +4,37 @@
@import "chrome://global/skin/"; @import "chrome://global/skin/";
/* View buttons */ %include shared.inc
@import "chrome://global/skin/viewbuttons.css";
/* Extensions will provide icons because the view buttons have icons #topBar {
on the windows and linux themes. We don't want to display them */ -moz-appearance: toolbar;
.viewButtonIcon { }
display: none;
.viewGroupWrapper {
-moz-box-align: center;
-moz-box-pack: center;
}
#viewGroup {
margin: 4px 0 9px;
}
#viewGroup > radio,
#viewGroup > toolbarbutton {
-moz-box-orient: vertical;
-moz-box-align: center;
-moz-appearance: toolbarbutton;
font: menu;
text-shadow: @loweredShadow@;
margin: 0;
padding: 0 1px;
height: 22px;
}
#viewGroup > radio[selected=true],
#viewGroup > toolbarbutton[checked=true] {
color: #FFF !important;
text-shadow: rgba(0, 0, 0, 0.4) 0 1px;
} }
deck { deck {

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

@ -1378,8 +1378,7 @@ menuitem[checked="true"].subviewbutton > .menu-iconic-left {
} }
#panic-button-success-icon, #panic-button-success-icon,
#PanelUI-panic-timeframe-icon, #PanelUI-panic-timeframe-icon {
#PanelUI-panic-timeframe-icon-small {
background-color: transparent; background-color: transparent;
margin-inline-end: 10px; margin-inline-end: 10px;
} }
@ -1391,32 +1390,11 @@ menuitem[checked="true"].subviewbutton > .menu-iconic-left {
width: 48px; width: 48px;
} }
#PanelUI-panic-timeframe-icon-small { #panic-button-success-header {
list-style-image: url(chrome://browser/skin/panic-panel/header-small.png);
max-height: 32px;
width: 32px;
}
/* current attribute is only set when in use as a subview instead of a main view */
#PanelUI-panicView[current] #PanelUI-panic-timeframe-icon {
display: none;
}
#PanelUI-panicView.cui-widget-panelview #PanelUI-panic-timeframe-icon-small {
display: none;
}
#panic-button-success-header,
#PanelUI-panic-header {
-moz-box-align: center; -moz-box-align: center;
margin-bottom: 5px; margin-bottom: 5px;
} }
#PanelUI-panicView.cui-widget-panelview #PanelUI-panic-header {
margin-bottom: 0;
}
#PanelUI-panic-timeframe-icon-small:-moz-locale-dir(rtl),
#PanelUI-panic-timeframe-icon:-moz-locale-dir(rtl) { #PanelUI-panic-timeframe-icon:-moz-locale-dir(rtl) {
transform: scaleX(-1); transform: scaleX(-1);
} }
@ -1560,10 +1538,6 @@ menuitem[checked="true"].subviewbutton > .menu-iconic-left {
list-style-image: url(chrome://browser/skin/panic-panel/header@2x.png); list-style-image: url(chrome://browser/skin/panic-panel/header@2x.png);
} }
#PanelUI-panic-timeframe-icon-small {
list-style-image: url(chrome://browser/skin/panic-panel/header-small@2x.png);
}
#PanelUI-panic-actionlist-cookies { #PanelUI-panic-actionlist-cookies {
background-image: -moz-image-rect(url(chrome://browser/skin/panic-panel/icons@2x.png), 0, 32, 32, 0); background-image: -moz-image-rect(url(chrome://browser/skin/panic-panel/icons@2x.png), 0, 32, 32, 0);
} }

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

@ -217,8 +217,6 @@
skin/classic/browser/readerMode.svg (../shared/reader/readerMode.svg) skin/classic/browser/readerMode.svg (../shared/reader/readerMode.svg)
skin/classic/browser/panic-panel/header.png (../shared/panic-panel/header.png) skin/classic/browser/panic-panel/header.png (../shared/panic-panel/header.png)
skin/classic/browser/panic-panel/header@2x.png (../shared/panic-panel/header@2x.png) skin/classic/browser/panic-panel/header@2x.png (../shared/panic-panel/header@2x.png)
skin/classic/browser/panic-panel/header-small.png (../shared/panic-panel/header-small.png)
skin/classic/browser/panic-panel/header-small@2x.png (../shared/panic-panel/header-small@2x.png)
skin/classic/browser/panic-panel/icons.png (../shared/panic-panel/icons.png) skin/classic/browser/panic-panel/icons.png (../shared/panic-panel/icons.png)
skin/classic/browser/panic-panel/icons@2x.png (../shared/panic-panel/icons@2x.png) skin/classic/browser/panic-panel/icons@2x.png (../shared/panic-panel/icons@2x.png)
skin/classic/browser/places/bookmarks-notification-finish.png (../shared/places/bookmarks-notification-finish.png) skin/classic/browser/places/bookmarks-notification-finish.png (../shared/places/bookmarks-notification-finish.png)

Двоичный файл не отображается.

До

Ширина:  |  Высота:  |  Размер: 1.3 KiB

Двоичный файл не отображается.

До

Ширина:  |  Высота:  |  Размер: 2.9 KiB

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

@ -524,7 +524,7 @@ menuitem.bookmark-item {
} }
html|*.urlbar-input:-moz-lwtheme::placeholder, html|*.urlbar-input:-moz-lwtheme::placeholder,
.searchbar-textbox:-moz-lwtheme > .autocomplete-textbox-container > .textbox-input-box > html|*.textbox-input::placeholder { .searchbar-textbox:-moz-lwtheme > .urlbar-textbox-container > .textbox-input-box > html|*.textbox-input::placeholder {
opacity: 1.0; opacity: 1.0;
color: #777; color: #777;
} }

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

@ -11,8 +11,6 @@
#viewGroup > radio { #viewGroup > radio {
list-style-image: url("chrome://browser/skin/pageInfo.png"); list-style-image: url("chrome://browser/skin/pageInfo.png");
-moz-box-orient: vertical;
-moz-box-align: center;
-moz-appearance: none; -moz-appearance: none;
padding: 5px 3px 1px 3px; padding: 5px 3px 1px 3px;
margin: 0 1px; margin: 0 1px;

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

@ -2,10 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
.autocomplete-textbox-container {
-moz-box-align: stretch;
}
.searchbar-engine-image { .searchbar-engine-image {
height: 16px; height: 16px;
width: 16px; width: 16px;

2
config/external/moz.build поставляемый
Просмотреть файл

@ -42,7 +42,7 @@ if not CONFIG['MOZ_SYSTEM_PNG']:
external_dirs += ['media/libpng'] external_dirs += ['media/libpng']
if CONFIG['CPU_ARCH'] == 'arm': if CONFIG['CPU_ARCH'] == 'arm':
external_dirs += ['media/openmax_dl'] external_dirs += ['media/openmax_dl/dl']
if CONFIG['MOZ_FFVPX']: if CONFIG['MOZ_FFVPX']:
external_dirs += ['media/ffvpx'] external_dirs += ['media/ffvpx']

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

@ -160,8 +160,7 @@ devtools.jar:
skin/images/breakpoint.svg (themes/images/breakpoint.svg) skin/images/breakpoint.svg (themes/images/breakpoint.svg)
skin/webconsole.css (themes/webconsole.css) skin/webconsole.css (themes/webconsole.css)
skin/images/webconsole.svg (themes/images/webconsole.svg) skin/images/webconsole.svg (themes/images/webconsole.svg)
skin/images/breadcrumbs-scrollbutton.png (themes/images/breadcrumbs-scrollbutton.png) skin/images/breadcrumbs-scrollbutton.svg (themes/images/breadcrumbs-scrollbutton.svg)
skin/images/breadcrumbs-scrollbutton@2x.png (themes/images/breadcrumbs-scrollbutton@2x.png)
skin/animation.css (themes/animation.css) skin/animation.css (themes/animation.css)
skin/animationinspector.css (themes/animationinspector.css) skin/animationinspector.css (themes/animationinspector.css)
skin/canvasdebugger.css (themes/canvasdebugger.css) skin/canvasdebugger.css (themes/canvasdebugger.css)

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

@ -33,27 +33,22 @@
.scrollbutton-up > .toolbarbutton-icon, .scrollbutton-up > .toolbarbutton-icon,
.scrollbutton-down > .toolbarbutton-icon { .scrollbutton-down > .toolbarbutton-icon {
-moz-appearance: none; -moz-appearance: none;
width: 7px; width: 20px;
height: 16px; height: 16px;
background-size: 14px 16px; background-size: 16px;
background-position: 0 center; background-position: center;
background-repeat: no-repeat; background-repeat: no-repeat;
background-image: url("images/breadcrumbs-scrollbutton.png"); background-image: url("images/breadcrumbs-scrollbutton.svg");
list-style-image: none; list-style-image: none;
margin: 0 8px;
padding: 0; padding: 0;
-moz-context-properties: fill;
fill: var(--theme-toolbar-color);
} }
@media (min-resolution: 1.1dppx) { .scrollbutton-up:not([disabled]):active:hover,
.scrollbutton-up > .toolbarbutton-icon, .scrollbutton-down:not([disabled]):active:hover {
.scrollbutton-down > .toolbarbutton-icon { background-color: var(--theme-toolbar-hover);
background-image: url("images/breadcrumbs-scrollbutton@2x.png");
}
}
.scrollbutton-up:not([disabled]):active:hover > .toolbarbutton-icon,
.scrollbutton-down:not([disabled]):active:hover > .toolbarbutton-icon {
background-position: -7px center;
} }
.scrollbutton-up[disabled] > .toolbarbutton-icon, .scrollbutton-up[disabled] > .toolbarbutton-icon,
@ -242,8 +237,3 @@ widgets.css is overwritten. */
.theme-firebug .breadcrumbs-widget-container .scrollbutton-down:active { .theme-firebug .breadcrumbs-widget-container .scrollbutton-down:active {
background: none !important; background: none !important;
} }
.theme-firebug .breadcrumbs-widget-container .scrollbutton-up:not([disabled]):active:hover > .toolbarbutton-icon,
.theme-firebug .breadcrumbs-widget-container .scrollbutton-down:not([disabled]):active:hover > .toolbarbutton-icon {
background-position: 0 center;
}

Двоичный файл не отображается.

До

Ширина:  |  Высота:  |  Размер: 260 B

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

@ -0,0 +1,6 @@
<!-- 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/. -->
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<path fill="context-fill" d="M6.414 8l4.293-4.293a1 1 0 0 0-1.414-1.414l-5 5a1 1 0 0 0 0 1.414l5 5a1 1 0 0 0 1.414-1.414z"></path>
</svg>

После

Ширина:  |  Высота:  |  Размер: 436 B

Двоичный файл не отображается.

До

Ширина:  |  Высота:  |  Размер: 627 B

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

@ -1154,6 +1154,25 @@ Element::GetSlot(nsAString& aName)
GetAttr(kNameSpaceID_None, nsGkAtoms::slot, aName); GetAttr(kNameSpaceID_None, nsGkAtoms::slot, aName);
} }
// https://dom.spec.whatwg.org/#dom-element-shadowroot
ShadowRoot*
Element::GetShadowRootByMode() const
{
/**
* 1. Let shadow be context objects shadow root.
* 2. If shadow is null or its mode is "closed", then return null.
*/
ShadowRoot* shadowRoot = GetShadowRoot();
if (!shadowRoot || shadowRoot->IsClosed()) {
return nullptr;
}
/**
* 3. Return shadow.
*/
return shadowRoot;
}
// https://dom.spec.whatwg.org/#dom-element-attachshadow // https://dom.spec.whatwg.org/#dom-element-attachshadow
already_AddRefed<ShadowRoot> already_AddRefed<ShadowRoot>
Element::AttachShadow(const ShadowRootInit& aInit, ErrorResult& aError) Element::AttachShadow(const ShadowRootInit& aInit, ErrorResult& aError)

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

@ -1088,6 +1088,7 @@ public:
// Shadow DOM v1 // Shadow DOM v1
already_AddRefed<ShadowRoot> AttachShadow(const ShadowRootInit& aInit, already_AddRefed<ShadowRoot> AttachShadow(const ShadowRootInit& aInit,
ErrorResult& aError); ErrorResult& aError);
ShadowRoot* GetShadowRootByMode() const;
void SetSlot(const nsAString& aName, ErrorResult& aError); void SetSlot(const nsAString& aName, ErrorResult& aError);
void GetSlot(nsAString& aName); void GetSlot(nsAString& aName);

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

@ -155,6 +155,36 @@ nsIContent::FindFirstNonChromeOnlyAccessContent() const
return nullptr; return nullptr;
} }
// https://dom.spec.whatwg.org/#dom-slotable-assignedslot
HTMLSlotElement*
nsIContent::GetAssignedSlotByMode() const
{
/**
* Get slotable's assigned slot for the result of
* find a slot with open flag UNSET [1].
*
* [1] https://dom.spec.whatwg.org/#assign-a-slot
*/
HTMLSlotElement* slot = GetAssignedSlot();
if (!slot) {
return nullptr;
}
MOZ_ASSERT(GetParent());
MOZ_ASSERT(GetParent()->GetShadowRoot());
/**
* Additional check for open flag SET:
* If slotables parents shadow root's mode is not "open",
* then return null.
*/
if (GetParent()->GetShadowRoot()->IsClosed()) {
return nullptr;
}
return slot;
}
nsINode* nsINode*
nsIContent::GetFlattenedTreeParentNodeInternal(FlattenedParentType aType) const nsIContent::GetFlattenedTreeParentNodeInternal(FlattenedParentType aType) const
{ {

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

@ -216,9 +216,13 @@ public:
mOffset = mozilla::Some(aOffset); mOffset = mozilla::Some(aOffset);
} }
void void
Set(const nsIContent* aChild) Set(const nsINode* aChild)
{ {
MOZ_ASSERT(aChild); MOZ_ASSERT(aChild);
if (!aChild->IsContent()) {
Clear();
return;
}
mParent = aChild->GetParentNode(); mParent = aChild->GetParentNode();
mRef = aChild->GetPreviousSibling(); mRef = aChild->GetPreviousSibling();
if (!mRef) { if (!mRef) {
@ -246,12 +250,14 @@ public:
* If the container can have children and there is no next sibling, this * If the container can have children and there is no next sibling, this
* outputs warning and does nothing. So, callers need to check if there is * outputs warning and does nothing. So, callers need to check if there is
* next sibling which you need to refer. * next sibling which you need to refer.
*
* @return true if there is a next sibling to refer.
*/ */
void bool
AdvanceOffset() AdvanceOffset()
{ {
if (NS_WARN_IF(!mParent)) { if (NS_WARN_IF(!mParent)) {
return; return false;
} }
EnsureRef(); EnsureRef();
if (!mRef) { if (!mRef) {
@ -260,30 +266,31 @@ public:
MOZ_ASSERT(mOffset.isSome()); MOZ_ASSERT(mOffset.isSome());
if (NS_WARN_IF(mOffset.value() == mParent->Length())) { if (NS_WARN_IF(mOffset.value() == mParent->Length())) {
// Already referring the end of the node. // Already referring the end of the node.
return; return false;
} }
mOffset = mozilla::Some(mOffset.value() + 1); mOffset = mozilla::Some(mOffset.value() + 1);
return; return true;
} }
mRef = mParent->GetFirstChild(); mRef = mParent->GetFirstChild();
if (NS_WARN_IF(!mRef)) { if (NS_WARN_IF(!mRef)) {
// No children in the container. // No children in the container.
mOffset = mozilla::Some(0); mOffset = mozilla::Some(0);
} else { return false;
mOffset = mozilla::Some(1);
} }
return; mOffset = mozilla::Some(1);
return true;
} }
nsIContent* nextSibling = mRef->GetNextSibling(); nsIContent* nextSibling = mRef->GetNextSibling();
if (NS_WARN_IF(!nextSibling)) { if (NS_WARN_IF(!nextSibling)) {
// Already referring the end of the container. // Already referring the end of the container.
return; return false;
} }
mRef = nextSibling; mRef = nextSibling;
if (mOffset.isSome()) { if (mOffset.isSome()) {
mOffset = mozilla::Some(mOffset.value() + 1); mOffset = mozilla::Some(mOffset.value() + 1);
} }
return true;
} }
/** /**
@ -293,34 +300,37 @@ public:
* If the container can have children and there is no next previous, this * If the container can have children and there is no next previous, this
* outputs warning and does nothing. So, callers need to check if there is * outputs warning and does nothing. So, callers need to check if there is
* previous sibling which you need to refer. * previous sibling which you need to refer.
*
* @return true if there is a previous sibling to refer.
*/ */
void bool
RewindOffset() RewindOffset()
{ {
if (NS_WARN_IF(!mParent)) { if (NS_WARN_IF(!mParent)) {
return; return false;
} }
EnsureRef(); EnsureRef();
if (!mRef) { if (!mRef) {
if (NS_WARN_IF(mParent->IsContainerNode())) { if (NS_WARN_IF(mParent->IsContainerNode())) {
// Already referring the start of the container // Already referring the start of the container
mOffset = mozilla::Some(0); mOffset = mozilla::Some(0);
return; return false;
} }
// In text node or something, just decrement the offset. // In text node or something, just decrement the offset.
MOZ_ASSERT(mOffset.isSome()); MOZ_ASSERT(mOffset.isSome());
if (NS_WARN_IF(mOffset.value() == 0)) { if (NS_WARN_IF(mOffset.value() == 0)) {
// Already referring the start of the node. // Already referring the start of the node.
return; return false;
} }
mOffset = mozilla::Some(mOffset.value() - 1); mOffset = mozilla::Some(mOffset.value() - 1);
return; return true;
} }
mRef = mRef->GetPreviousSibling(); mRef = mRef->GetPreviousSibling();
if (mOffset.isSome()) { if (mOffset.isSome()) {
mOffset = mozilla::Some(mOffset.value() - 1); mOffset = mozilla::Some(mOffset.value() - 1);
} }
return true;
} }
void void

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

@ -14,6 +14,7 @@
#include "mozilla/AutoRestore.h" #include "mozilla/AutoRestore.h"
#include "mozilla/EventStates.h" #include "mozilla/EventStates.h"
#include "mozilla/HTMLEditor.h" #include "mozilla/HTMLEditor.h"
#include "mozilla/RangeBoundary.h"
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "nsString.h" #include "nsString.h"
@ -2544,13 +2545,13 @@ NS_IMETHODIMP
Selection::Collapse(nsIDOMNode* aContainer, int32_t aOffset) Selection::Collapse(nsIDOMNode* aContainer, int32_t aOffset)
{ {
nsCOMPtr<nsINode> container = do_QueryInterface(aContainer); nsCOMPtr<nsINode> container = do_QueryInterface(aContainer);
return Collapse(container, aOffset); return Collapse(RawRangeBoundary(container, aOffset));
} }
NS_IMETHODIMP NS_IMETHODIMP
Selection::CollapseNative(nsINode* aContainer, int32_t aOffset) Selection::CollapseNative(nsINode* aContainer, int32_t aOffset)
{ {
return Collapse(aContainer, aOffset); return Collapse(RawRangeBoundary(aContainer, aOffset));
} }
void void
@ -2562,56 +2563,52 @@ Selection::CollapseJS(nsINode* aContainer, uint32_t aOffset, ErrorResult& aRv)
RemoveAllRanges(aRv); RemoveAllRanges(aRv);
return; return;
} }
Collapse(*aContainer, aOffset, aRv); Collapse(RawRangeBoundary(aContainer, aOffset), aRv);
}
nsresult
Selection::Collapse(nsINode* aContainer, int32_t aOffset)
{
if (!aContainer) {
return NS_ERROR_INVALID_ARG;
}
ErrorResult result;
Collapse(*aContainer, static_cast<uint32_t>(aOffset), result);
return result.StealNSResult();
} }
void void
Selection::Collapse(nsINode& aContainer, uint32_t aOffset, ErrorResult& aRv) Selection::Collapse(const RawRangeBoundary& aPoint, ErrorResult& aRv)
{ {
if (!mFrameSelection) { if (!mFrameSelection) {
aRv.Throw(NS_ERROR_NOT_INITIALIZED); // Can't do selection aRv.Throw(NS_ERROR_NOT_INITIALIZED); // Can't do selection
return; return;
} }
if (aContainer.NodeType() == nsIDOMNode::DOCUMENT_TYPE_NODE) { if (!aPoint.IsSet()) {
aRv.Throw(NS_ERROR_INVALID_ARG);
return;
}
if (aPoint.Container()->NodeType() == nsIDOMNode::DOCUMENT_TYPE_NODE) {
aRv.Throw(NS_ERROR_DOM_INVALID_NODE_TYPE_ERR); aRv.Throw(NS_ERROR_DOM_INVALID_NODE_TYPE_ERR);
return; return;
} }
if (aOffset > aContainer.Length()) { // RawRangeBoundary::IsSetAndValid() checks if the point actually refers
// a child of the container when IsSet() is true. If its offset hasn't been
// computed yet, this just checks it with its mRef. So, we can avoid
// computing offset here.
if (!aPoint.IsSetAndValid()) {
aRv.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR); aRv.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
return; return;
} }
if (!HasSameRoot(aContainer)) { if (!HasSameRoot(*aPoint.Container())) {
// Return with no error // Return with no error
return; return;
} }
nsCOMPtr<nsINode> container = &aContainer;
RefPtr<nsFrameSelection> frameSelection = mFrameSelection; RefPtr<nsFrameSelection> frameSelection = mFrameSelection;
frameSelection->InvalidateDesiredPos(); frameSelection->InvalidateDesiredPos();
if (!IsValidSelectionPoint(frameSelection, container)) { if (!IsValidSelectionPoint(frameSelection, aPoint.Container())) {
aRv.Throw(NS_ERROR_FAILURE); aRv.Throw(NS_ERROR_FAILURE);
return; return;
} }
nsresult result; nsresult result;
RefPtr<nsPresContext> presContext = GetPresContext(); RefPtr<nsPresContext> presContext = GetPresContext();
if (!presContext || presContext->Document() != container->OwnerDoc()) { if (!presContext ||
presContext->Document() != aPoint.Container()->OwnerDoc()) {
aRv.Throw(NS_ERROR_FAILURE); aRv.Throw(NS_ERROR_FAILURE);
return; return;
} }
@ -2627,16 +2624,21 @@ Selection::Collapse(nsINode& aContainer, uint32_t aOffset, ErrorResult& aRv)
// Hack to display the caret on the right line (bug 1237236). // Hack to display the caret on the right line (bug 1237236).
if (frameSelection->GetHint() != CARET_ASSOCIATE_AFTER && if (frameSelection->GetHint() != CARET_ASSOCIATE_AFTER &&
container->IsContent()) { aPoint.Container()->IsContent()) {
int32_t frameOffset; int32_t frameOffset;
nsTextFrame* f = nsTextFrame* f =
do_QueryFrame(nsCaret::GetFrameAndOffset(this, container, do_QueryFrame(nsCaret::GetFrameAndOffset(this, aPoint.Container(),
aOffset, &frameOffset)); aPoint.Offset(), &frameOffset));
if (f && f->IsAtEndOfLine() && f->HasSignificantTerminalNewline()) { if (f && f->IsAtEndOfLine() && f->HasSignificantTerminalNewline()) {
if ((container->AsContent() == f->GetContent() && // RawRangeBounary::Offset() causes computing offset if it's not been
f->GetContentEnd() == int32_t(aOffset)) || // done yet. However, it's called only when the container is a text
(container == f->GetContent()->GetParentNode() && // node. In such case, offset has always been set since it cannot have
container->IndexOf(f->GetContent()) + 1 == int32_t(aOffset))) { // any children. So, this doesn't cause computing offset with expensive
// method, nsINode::IndexOf().
if ((aPoint.Container()->AsContent() == f->GetContent() &&
f->GetContentEnd() == static_cast<int32_t>(aPoint.Offset())) ||
(aPoint.Container() == f->GetContent()->GetParentNode() &&
f->GetContent() == aPoint.GetPreviousSiblingOfChildAtOffset())) {
frameSelection->SetHint(CARET_ASSOCIATE_AFTER); frameSelection->SetHint(CARET_ASSOCIATE_AFTER);
} }
} }
@ -2650,21 +2652,21 @@ Selection::Collapse(nsINode& aContainer, uint32_t aOffset, ErrorResult& aRv)
} else if (mCachedRange) { } else if (mCachedRange) {
range = Move(mCachedRange); range = Move(mCachedRange);
} else { } else {
range = new nsRange(container); range = new nsRange(aPoint.Container());
} }
result = range->CollapseTo(container, aOffset); result = range->CollapseTo(aPoint);
if (NS_FAILED(result)) { if (NS_FAILED(result)) {
aRv.Throw(result); aRv.Throw(result);
return; return;
} }
#ifdef DEBUG_SELECTION #ifdef DEBUG_SELECTION
nsCOMPtr<nsIContent> content = do_QueryInterface(container); nsCOMPtr<nsIContent> content = do_QueryInterface(aPoint.Container());
nsCOMPtr<nsIDocument> doc = do_QueryInterface(container); nsCOMPtr<nsIDocument> doc = do_QueryInterface(aPoint.Container());
printf ("Sel. Collapse to %p %s %d\n", container.get(), printf ("Sel. Collapse to %p %s %d\n", container.get(),
content ? nsAtomCString(content->NodeInfo()->NameAtom()).get() content ? nsAtomCString(content->NodeInfo()->NameAtom()).get()
: (doc ? "DOCUMENT" : "???"), : (doc ? "DOCUMENT" : "???"),
aOffset); aPoint.Offset());
#endif #endif
int32_t rangeIndex = -1; int32_t rangeIndex = -1;

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

@ -10,6 +10,7 @@
#include "nsIWeakReference.h" #include "nsIWeakReference.h"
#include "mozilla/AutoRestore.h" #include "mozilla/AutoRestore.h"
#include "mozilla/RangeBoundary.h"
#include "mozilla/TextRange.h" #include "mozilla/TextRange.h"
#include "mozilla/UniquePtr.h" #include "mozilla/UniquePtr.h"
#include "nsISelection.h" #include "nsISelection.h"
@ -132,7 +133,19 @@ public:
nsresult RemoveItem(nsRange* aRange); nsresult RemoveItem(nsRange* aRange);
nsresult RemoveCollapsedRanges(); nsresult RemoveCollapsedRanges();
nsresult Clear(nsPresContext* aPresContext); nsresult Clear(nsPresContext* aPresContext);
nsresult Collapse(nsINode* aContainer, int32_t aOffset); nsresult Collapse(nsINode* aContainer, int32_t aOffset)
{
if (!aContainer) {
return NS_ERROR_INVALID_ARG;
}
return Collapse(RawRangeBoundary(aContainer, aOffset));
}
nsresult Collapse(const RawRangeBoundary& aPoint)
{
ErrorResult result;
Collapse(aPoint, result);
return result.StealNSResult();
}
nsresult Extend(nsINode* aContainer, int32_t aOffset); nsresult Extend(nsINode* aContainer, int32_t aOffset);
nsRange* GetRangeAt(int32_t aIndex) const; nsRange* GetRangeAt(int32_t aIndex) const;
@ -291,7 +304,11 @@ public:
void ResetColors(mozilla::ErrorResult& aRv); void ResetColors(mozilla::ErrorResult& aRv);
// Non-JS callers should use the following methods. // Non-JS callers should use the following methods.
void Collapse(nsINode& aContainer, uint32_t aOffset, ErrorResult& aRv); void Collapse(nsINode& aContainer, uint32_t aOffset, ErrorResult& aRv)
{
Collapse(RawRangeBoundary(&aContainer, aOffset), aRv);
}
void Collapse(const RawRangeBoundary& aPoint, ErrorResult& aRv);
void CollapseToStart(mozilla::ErrorResult& aRv); void CollapseToStart(mozilla::ErrorResult& aRv);
void CollapseToEnd(mozilla::ErrorResult& aRv); void CollapseToEnd(mozilla::ErrorResult& aRv);
void Extend(nsINode& aContainer, uint32_t aOffset, ErrorResult& aRv); void Extend(nsINode& aContainer, uint32_t aOffset, ErrorResult& aRv);

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

@ -51,6 +51,10 @@ public:
{ {
return mMode; return mMode;
} }
bool IsClosed()
{
return mMode == ShadowRootMode::Closed;
}
// [deprecated] Shadow DOM v0 // [deprecated] Shadow DOM v0
void AddToIdTable(Element* aElement, nsAtom* aId); void AddToIdTable(Element* aElement, nsAtom* aId);

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

@ -758,6 +758,15 @@ public:
*/ */
virtual void SetAssignedSlot(mozilla::dom::HTMLSlotElement* aSlot) = 0; virtual void SetAssignedSlot(mozilla::dom::HTMLSlotElement* aSlot) = 0;
/**
* Gets the assigned slot associated with this content based on parent's
* shadow root mode. Returns null if parent's shadow root is "closed".
* https://dom.spec.whatwg.org/#dom-slotable-assignedslot
*
* @return The assigned slot element or null.
*/
mozilla::dom::HTMLSlotElement* GetAssignedSlotByMode() const;
nsIContent* GetXBLInsertionParent() const nsIContent* GetXBLInsertionParent() const
{ {
nsIContent* ip = GetXBLInsertionPoint(); nsIContent* ip = GetXBLInsertionPoint();

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

@ -220,7 +220,11 @@ public:
*/ */
nsresult CollapseTo(nsINode* aContainer, uint32_t aOffset) nsresult CollapseTo(nsINode* aContainer, uint32_t aOffset)
{ {
return SetStartAndEnd(aContainer, aOffset, aContainer, aOffset); return CollapseTo(RawRangeBoundary(aContainer, aOffset));
}
nsresult CollapseTo(const RawRangeBoundary& aPoint)
{
return SetStartAndEnd(aPoint, aPoint);
} }
/** /**

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

@ -19,7 +19,6 @@
// Notify/query select frame for selected state // Notify/query select frame for selected state
#include "nsIFormControlFrame.h" #include "nsIFormControlFrame.h"
#include "nsIDocument.h" #include "nsIDocument.h"
#include "nsIDOMHTMLSelectElement.h"
#include "nsNodeInfoManager.h" #include "nsNodeInfoManager.h"
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "mozilla/EventStates.h" #include "mozilla/EventStates.h"

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

@ -97,16 +97,13 @@ NS_INTERFACE_TABLE_HEAD(HTMLOptionsCollection)
NS_WRAPPERCACHE_INTERFACE_TABLE_ENTRY NS_WRAPPERCACHE_INTERFACE_TABLE_ENTRY
NS_INTERFACE_TABLE(HTMLOptionsCollection, NS_INTERFACE_TABLE(HTMLOptionsCollection,
nsIHTMLCollection, nsIHTMLCollection,
nsIDOMHTMLOptionsCollection,
nsIDOMHTMLCollection) nsIDOMHTMLCollection)
NS_INTERFACE_TABLE_TO_MAP_SEGUE_CYCLE_COLLECTION(HTMLOptionsCollection) NS_INTERFACE_TABLE_TO_MAP_SEGUE_CYCLE_COLLECTION(HTMLOptionsCollection)
NS_INTERFACE_MAP_END NS_INTERFACE_MAP_END
NS_IMPL_CYCLE_COLLECTING_ADDREF(HTMLOptionsCollection) NS_IMPL_CYCLE_COLLECTING_ADDREF(HTMLOptionsCollection)
NS_IMPL_CYCLE_COLLECTING_RELEASE(HTMLOptionsCollection) NS_IMPL_CYCLE_COLLECTING_RELEASE(HTMLOptionsCollection)
JSObject* JSObject*
HTMLOptionsCollection::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) HTMLOptionsCollection::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
{ {
@ -121,14 +118,15 @@ HTMLOptionsCollection::GetLength(uint32_t* aLength)
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP void
HTMLOptionsCollection::SetLength(uint32_t aLength) HTMLOptionsCollection::SetLength(uint32_t aLength, ErrorResult& aError)
{ {
if (!mSelect) { if (!mSelect) {
return NS_ERROR_UNEXPECTED; aError.Throw(NS_ERROR_UNEXPECTED);
return;
} }
return mSelect->SetLength(aLength); mSelect->SetLength(aLength, aError);
} }
void void
@ -153,11 +151,8 @@ HTMLOptionsCollection::IndexedSetter(uint32_t aIndex,
if (aIndex > mElements.Length()) { if (aIndex > mElements.Length()) {
// Fill our array with blank options up to (but not including, since we're // Fill our array with blank options up to (but not including, since we're
// about to change it) aIndex, for compat with other browsers. // about to change it) aIndex, for compat with other browsers.
nsresult rv = SetLength(aIndex); SetLength(aIndex, aError);
if (NS_WARN_IF(NS_FAILED(rv))) { ENSURE_SUCCESS_VOID(aError);
aError.Throw(rv);
return;
}
} }
NS_ASSERTION(aIndex <= mElements.Length(), "SetLength lied"); NS_ASSERTION(aIndex <= mElements.Length(), "SetLength lied");
@ -191,17 +186,7 @@ HTMLOptionsCollection::GetSelectedIndex(ErrorResult& aError)
return 0; return 0;
} }
int32_t selectedIndex; return mSelect->SelectedIndex();
aError = mSelect->GetSelectedIndex(&selectedIndex);
return selectedIndex;
}
NS_IMETHODIMP
HTMLOptionsCollection::GetSelectedIndex(int32_t* aSelectedIndex)
{
ErrorResult rv;
*aSelectedIndex = GetSelectedIndex(rv);
return rv.StealNSResult();
} }
void void
@ -213,15 +198,7 @@ HTMLOptionsCollection::SetSelectedIndex(int32_t aSelectedIndex,
return; return;
} }
aError = mSelect->SetSelectedIndex(aSelectedIndex); mSelect->SetSelectedIndex(aSelectedIndex, aError);
}
NS_IMETHODIMP
HTMLOptionsCollection::SetSelectedIndex(int32_t aSelectedIndex)
{
ErrorResult rv;
SetSelectedIndex(aSelectedIndex, rv);
return rv.StealNSResult();
} }
NS_IMETHODIMP NS_IMETHODIMP
@ -310,29 +287,6 @@ HTMLOptionsCollection::GetSupportedNames(nsTArray<nsString>& aNames)
} }
} }
NS_IMETHODIMP
HTMLOptionsCollection::GetSelect(nsIDOMHTMLSelectElement** aReturn)
{
NS_IF_ADDREF(*aReturn = mSelect);
return NS_OK;
}
NS_IMETHODIMP
HTMLOptionsCollection::Add(nsIDOMHTMLOptionElement* aOption,
nsIVariant* aBefore)
{
if (!aOption) {
return NS_ERROR_INVALID_ARG;
}
if (!mSelect) {
return NS_ERROR_NOT_INITIALIZED;
}
nsCOMPtr<nsIDOMHTMLElement> elem = do_QueryInterface(aOption);
return mSelect->Add(elem, aBefore);
}
void void
HTMLOptionsCollection::Add(const HTMLOptionOrOptGroupElement& aElement, HTMLOptionsCollection::Add(const HTMLOptionOrOptGroupElement& aElement,
const Nullable<HTMLElementOrLong>& aBefore, const Nullable<HTMLElementOrLong>& aBefore,
@ -354,20 +308,11 @@ HTMLOptionsCollection::Remove(int32_t aIndex, ErrorResult& aError)
return; return;
} }
uint32_t len = 0; uint32_t len = mSelect->Length();
mSelect->GetLength(&len);
if (aIndex < 0 || (uint32_t)aIndex >= len) if (aIndex < 0 || (uint32_t)aIndex >= len)
aIndex = 0; aIndex = 0;
aError = mSelect->Remove(aIndex); mSelect->Remove(aIndex);
}
NS_IMETHODIMP
HTMLOptionsCollection::Remove(int32_t aIndex)
{
ErrorResult rv;
Remove(aIndex, rv);
return rv.StealNSResult();
} }
} // namespace dom } // namespace dom

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

@ -8,7 +8,6 @@
#include "mozilla/Attributes.h" #include "mozilla/Attributes.h"
#include "nsIHTMLCollection.h" #include "nsIHTMLCollection.h"
#include "nsIDOMHTMLOptionsCollection.h"
#include "nsWrapperCache.h" #include "nsWrapperCache.h"
#include "mozilla/dom/HTMLOptionElement.h" #include "mozilla/dom/HTMLOptionElement.h"
@ -32,7 +31,6 @@ class HTMLSelectElement;
* select.options in DOM) * select.options in DOM)
*/ */
class HTMLOptionsCollection final : public nsIHTMLCollection class HTMLOptionsCollection final : public nsIHTMLCollection
, public nsIDOMHTMLOptionsCollection
, public nsWrapperCache , public nsWrapperCache
{ {
typedef HTMLOptionElementOrHTMLOptGroupElement HTMLOptionOrOptGroupElement; typedef HTMLOptionElementOrHTMLOptGroupElement HTMLOptionOrOptGroupElement;
@ -40,6 +38,7 @@ public:
explicit HTMLOptionsCollection(HTMLSelectElement* aSelect); explicit HTMLOptionsCollection(HTMLSelectElement* aSelect);
NS_DECL_CYCLE_COLLECTING_ISUPPORTS NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_NSIDOMHTMLCOLLECTION
// nsWrapperCache // nsWrapperCache
using nsWrapperCache::GetWrapperPreserveColor; using nsWrapperCache::GetWrapperPreserveColor;
@ -59,12 +58,6 @@ protected:
} }
public: public:
// nsIDOMHTMLOptionsCollection interface
NS_DECL_NSIDOMHTMLOPTIONSCOLLECTION
// nsIDOMHTMLCollection interface, all its methods are defined in
// nsIDOMHTMLOptionsCollection
virtual Element* GetElementAt(uint32_t aIndex) override; virtual Element* GetElementAt(uint32_t aIndex) override;
virtual nsINode* GetParentObject() override; virtual nsINode* GetParentObject() override;
@ -147,7 +140,6 @@ public:
{ {
return NamedGetter(aName, aFound); return NamedGetter(aName, aFound);
} }
void Add(const HTMLOptionOrOptGroupElement& aElement, void Add(const HTMLOptionOrOptGroupElement& aElement,
const Nullable<HTMLElementOrLong>& aBefore, const Nullable<HTMLElementOrLong>& aBefore,
ErrorResult& aError); ErrorResult& aError);
@ -157,6 +149,7 @@ public:
void IndexedSetter(uint32_t aIndex, HTMLOptionElement* aOption, void IndexedSetter(uint32_t aIndex, HTMLOptionElement* aOption,
ErrorResult& aError); ErrorResult& aError);
virtual void GetSupportedNames(nsTArray<nsString>& aNames) override; virtual void GetSupportedNames(nsTArray<nsString>& aNames) override;
void SetLength(uint32_t aLength, ErrorResult& aError);
private: private:
/** The list of options (holds strong references). This is infallible, so /** The list of options (holds strong references). This is infallible, so

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

@ -167,7 +167,6 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHERITED(HTMLSelectElement, NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHERITED(HTMLSelectElement,
nsGenericHTMLFormElementWithState, nsGenericHTMLFormElementWithState,
nsIDOMHTMLSelectElement,
nsIConstraintValidation) nsIConstraintValidation)
@ -204,12 +203,6 @@ HTMLSelectElement::GetAutocompleteInfo(AutocompleteInfo& aInfo)
true); true);
} }
NS_IMETHODIMP
HTMLSelectElement::GetForm(nsIDOMHTMLFormElement** aForm)
{
return nsGenericHTMLFormElementWithState::GetForm(aForm);
}
nsresult nsresult
HTMLSelectElement::InsertChildAt(nsIContent* aKid, HTMLSelectElement::InsertChildAt(nsIContent* aKid,
uint32_t aIndex, uint32_t aIndex,
@ -605,74 +598,18 @@ HTMLSelectElement::Add(nsGenericHTMLElement& aElement,
parent->InsertBefore(aElement, refNode, aError); parent->InsertBefore(aElement, refNode, aError);
} }
NS_IMETHODIMP void
HTMLSelectElement::Add(nsIDOMHTMLElement* aElement,
nsIVariant* aBefore)
{
uint16_t dataType;
nsresult rv = aBefore->GetDataType(&dataType);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIContent> element = do_QueryInterface(aElement);
nsGenericHTMLElement* htmlElement =
nsGenericHTMLElement::FromContentOrNull(element);
if (!htmlElement) {
return NS_ERROR_NULL_POINTER;
}
// aBefore is omitted, undefined or null
if (dataType == nsIDataType::VTYPE_EMPTY ||
dataType == nsIDataType::VTYPE_VOID) {
ErrorResult error;
Add(*htmlElement, (nsGenericHTMLElement*)nullptr, error);
return error.StealNSResult();
}
nsCOMPtr<nsISupports> supports;
// whether aBefore is nsIDOMHTMLElement...
if (NS_SUCCEEDED(aBefore->GetAsISupports(getter_AddRefs(supports)))) {
nsCOMPtr<nsIContent> beforeElement = do_QueryInterface(supports);
nsGenericHTMLElement* beforeHTMLElement =
nsGenericHTMLElement::FromContentOrNull(beforeElement);
NS_ENSURE_TRUE(beforeHTMLElement, NS_ERROR_DOM_SYNTAX_ERR);
ErrorResult error;
Add(*htmlElement, beforeHTMLElement, error);
return error.StealNSResult();
}
// otherwise, whether aBefore is long
int32_t index;
NS_ENSURE_SUCCESS(aBefore->GetAsInt32(&index), NS_ERROR_DOM_SYNTAX_ERR);
ErrorResult error;
Add(*htmlElement, index, error);
return error.StealNSResult();
}
NS_IMETHODIMP
HTMLSelectElement::Remove(int32_t aIndex) HTMLSelectElement::Remove(int32_t aIndex)
{ {
nsCOMPtr<nsINode> option = Item(static_cast<uint32_t>(aIndex)); nsCOMPtr<nsINode> option = Item(static_cast<uint32_t>(aIndex));
if (!option) { if (!option) {
return NS_OK; return;
} }
option->Remove(); option->Remove();
return NS_OK;
} }
NS_IMETHODIMP void
HTMLSelectElement::GetOptions(nsIDOMHTMLOptionsCollection** aValue)
{
NS_IF_ADDREF(*aValue = GetOptions());
return NS_OK;
}
NS_IMETHODIMP
HTMLSelectElement::GetType(nsAString& aType) HTMLSelectElement::GetType(nsAString& aType)
{ {
if (HasAttr(kNameSpaceID_None, nsGkAtoms::multiple)) { if (HasAttr(kNameSpaceID_None, nsGkAtoms::multiple)) {
@ -681,26 +618,10 @@ HTMLSelectElement::GetType(nsAString& aType)
else { else {
aType.AssignLiteral("select-one"); aType.AssignLiteral("select-one");
} }
return NS_OK;
}
NS_IMETHODIMP
HTMLSelectElement::GetLength(uint32_t* aLength)
{
return mOptions->GetLength(aLength);
} }
#define MAX_DYNAMIC_SELECT_LENGTH 10000 #define MAX_DYNAMIC_SELECT_LENGTH 10000
NS_IMETHODIMP
HTMLSelectElement::SetLength(uint32_t aLength)
{
ErrorResult rv;
SetLength(aLength, rv);
return rv.StealNSResult();
}
void void
HTMLSelectElement::SetLength(uint32_t aLength, ErrorResult& aRv) HTMLSelectElement::SetLength(uint32_t aLength, ErrorResult& aRv)
{ {
@ -708,7 +629,7 @@ HTMLSelectElement::SetLength(uint32_t aLength, ErrorResult& aRv)
if (curlen > aLength) { // Remove extra options if (curlen > aLength) { // Remove extra options
for (uint32_t i = curlen; i > aLength; --i) { for (uint32_t i = curlen; i > aLength; --i) {
MOZ_ALWAYS_SUCCEEDS(Remove(i - 1)); Remove(i - 1);
} }
} else if (aLength > curlen) { } else if (aLength > curlen) {
if (aLength > MAX_DYNAMIC_SELECT_LENGTH) { if (aLength > MAX_DYNAMIC_SELECT_LENGTH) {
@ -768,23 +689,6 @@ HTMLSelectElement::SelectedOptions()
return mSelectedOptions; return mSelectedOptions;
} }
NS_IMETHODIMP
HTMLSelectElement::GetSelectedOptions(nsIDOMHTMLCollection** aSelectedOptions)
{
NS_ADDREF(*aSelectedOptions = SelectedOptions());
return NS_OK;
}
//NS_IMPL_INT_ATTR(HTMLSelectElement, SelectedIndex, selectedindex)
NS_IMETHODIMP
HTMLSelectElement::GetSelectedIndex(int32_t* aValue)
{
*aValue = SelectedIndex();
return NS_OK;
}
nsresult nsresult
HTMLSelectElement::SetSelectedIndexInternal(int32_t aIndex, bool aNotify) HTMLSelectElement::SetSelectedIndexInternal(int32_t aIndex, bool aNotify)
{ {
@ -807,12 +711,6 @@ HTMLSelectElement::SetSelectedIndexInternal(int32_t aIndex, bool aNotify)
return rv; return rv;
} }
NS_IMETHODIMP
HTMLSelectElement::SetSelectedIndex(int32_t aIndex)
{
return SetSelectedIndexInternal(aIndex, true);
}
NS_IMETHODIMP NS_IMETHODIMP
HTMLSelectElement::GetOptionIndex(nsIDOMHTMLOptionElement* aOption, HTMLSelectElement::GetOptionIndex(nsIDOMHTMLOptionElement* aOption,
int32_t aStartIndex, bool aForward, int32_t aStartIndex, bool aForward,
@ -1119,15 +1017,6 @@ HTMLSelectElement::IsOptionDisabled(HTMLOptionElement* aOption) const
return false; return false;
} }
NS_IMETHODIMP
HTMLSelectElement::GetValue(nsAString& aValue)
{
DOMString value;
GetValue(value);
value.ToString(aValue);
return NS_OK;
}
void void
HTMLSelectElement::GetValue(DOMString& aValue) HTMLSelectElement::GetValue(DOMString& aValue)
{ {
@ -1147,7 +1036,7 @@ HTMLSelectElement::GetValue(DOMString& aValue)
MOZ_ASSERT(NS_SUCCEEDED(rv)); MOZ_ASSERT(NS_SUCCEEDED(rv));
} }
NS_IMETHODIMP void
HTMLSelectElement::SetValue(const nsAString& aValue) HTMLSelectElement::SetValue(const nsAString& aValue)
{ {
uint32_t length = Length(); uint32_t length = Length();
@ -1162,22 +1051,13 @@ HTMLSelectElement::SetValue(const nsAString& aValue)
option->GetValue(optionVal); option->GetValue(optionVal);
if (optionVal.Equals(aValue)) { if (optionVal.Equals(aValue)) {
SetSelectedIndexInternal(int32_t(i), true); SetSelectedIndexInternal(int32_t(i), true);
return NS_OK; return;
} }
} }
// No matching option was found. // No matching option was found.
SetSelectedIndexInternal(-1, true); SetSelectedIndexInternal(-1, true);
return NS_OK;
} }
NS_IMPL_BOOL_ATTR(HTMLSelectElement, Autofocus, autofocus)
NS_IMPL_BOOL_ATTR(HTMLSelectElement, Disabled, disabled)
NS_IMPL_BOOL_ATTR(HTMLSelectElement, Multiple, multiple)
NS_IMPL_STRING_ATTR(HTMLSelectElement, Name, name)
NS_IMPL_BOOL_ATTR(HTMLSelectElement, Required, required)
NS_IMPL_UINT_ATTR(HTMLSelectElement, Size, size)
int32_t int32_t
HTMLSelectElement::TabIndexDefault() HTMLSelectElement::TabIndexDefault()
{ {
@ -1199,18 +1079,6 @@ HTMLSelectElement::IsHTMLFocusable(bool aWithMouse,
return false; return false;
} }
NS_IMETHODIMP
HTMLSelectElement::Item(uint32_t aIndex, nsIDOMNode** aReturn)
{
return mOptions->Item(aIndex, aReturn);
}
NS_IMETHODIMP
HTMLSelectElement::NamedItem(const nsAString& aName, nsIDOMNode** aReturn)
{
return mOptions->NamedItem(aName, aReturn);
}
bool bool
HTMLSelectElement::CheckSelectSomething(bool aNotify) HTMLSelectElement::CheckSelectSomething(bool aNotify)
{ {
@ -1230,8 +1098,7 @@ HTMLSelectElement::SelectSomething(bool aNotify)
return false; return false;
} }
uint32_t count; uint32_t count = Length();
GetLength(&count);
for (uint32_t i = 0; i < count; i++) { for (uint32_t i = 0; i < count; i++) {
bool disabled; bool disabled;
nsresult rv = IsOptionDisabled(i, &disabled); nsresult rv = IsOptionDisabled(i, &disabled);
@ -1586,7 +1453,8 @@ HTMLSelectElement::RestoreState(nsPresState* aState)
} }
if (aState->IsDisabledSet() && !aState->GetDisabled()) { if (aState->IsDisabledSet() && !aState->GetDisabled()) {
SetDisabled(false); IgnoredErrorResult rv;
SetDisabled(false, rv);
} }
return false; return false;

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

@ -8,10 +8,10 @@
#include "mozilla/Attributes.h" #include "mozilla/Attributes.h"
#include "nsGenericHTMLElement.h" #include "nsGenericHTMLElement.h"
#include "nsIDOMHTMLSelectElement.h"
#include "nsIConstraintValidation.h" #include "nsIConstraintValidation.h"
#include "mozilla/dom/BindingDeclarations.h" #include "mozilla/dom/BindingDeclarations.h"
#include "mozilla/dom/UnionTypes.h"
#include "mozilla/dom/HTMLOptionsCollection.h" #include "mozilla/dom/HTMLOptionsCollection.h"
#include "mozilla/ErrorResult.h" #include "mozilla/ErrorResult.h"
#include "nsCheapSets.h" #include "nsCheapSets.h"
@ -120,7 +120,6 @@ private:
* Implementation of &lt;select&gt; * Implementation of &lt;select&gt;
*/ */
class HTMLSelectElement final : public nsGenericHTMLFormElementWithState, class HTMLSelectElement final : public nsGenericHTMLFormElementWithState,
public nsIDOMHTMLSelectElement,
public nsIConstraintValidation public nsIConstraintValidation
{ {
public: public:
@ -164,9 +163,6 @@ public:
return true; return true;
} }
// nsIDOMHTMLSelectElement
NS_DECL_NSIDOMHTMLSELECTELEMENT
// WebIdl HTMLSelectElement // WebIdl HTMLSelectElement
bool Autofocus() const bool Autofocus() const
{ {
@ -204,7 +200,11 @@ public:
{ {
SetHTMLBoolAttr(nsGkAtoms::multiple, aVal, aRv); SetHTMLBoolAttr(nsGkAtoms::multiple, aVal, aRv);
} }
// Uses XPCOM GetName.
void GetName(DOMString& aValue)
{
GetHTMLAttr(nsGkAtoms::name, aValue);
}
void SetName(const nsAString& aName, ErrorResult& aRv) void SetName(const nsAString& aName, ErrorResult& aRv)
{ {
SetHTMLAttr(nsGkAtoms::name, aName, aRv); SetHTMLAttr(nsGkAtoms::name, aName, aRv);
@ -226,7 +226,7 @@ public:
SetUnsignedIntAttr(nsGkAtoms::size, aSize, 0, aRv); SetUnsignedIntAttr(nsGkAtoms::size, aSize, 0, aRv);
} }
// Uses XPCOM GetType. void GetType(nsAString& aValue);
HTMLOptionsCollection* Options() const HTMLOptionsCollection* Options() const
{ {
@ -252,7 +252,7 @@ public:
void Add(const HTMLOptionElementOrHTMLOptGroupElement& aElement, void Add(const HTMLOptionElementOrHTMLOptGroupElement& aElement,
const Nullable<HTMLElementOrLong>& aBefore, const Nullable<HTMLElementOrLong>& aBefore,
ErrorResult& aRv); ErrorResult& aRv);
// Uses XPCOM Remove. void Remove(int32_t aIndex);
void IndexedSetter(uint32_t aIndex, HTMLOptionElement* aOption, void IndexedSetter(uint32_t aIndex, HTMLOptionElement* aOption,
ErrorResult& aRv) ErrorResult& aRv)
{ {
@ -273,7 +273,7 @@ public:
aRv = SetSelectedIndexInternal(aIdx, true); aRv = SetSelectedIndexInternal(aIdx, true);
} }
void GetValue(DOMString& aValue); void GetValue(DOMString& aValue);
// Uses XPCOM SetValue. void SetValue(const nsAString& aValue);
// Override SetCustomValidity so we update our state properly when it's called // Override SetCustomValidity so we update our state properly when it's called
// via bindings. // via bindings.

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

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

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

@ -17,9 +17,7 @@ XPIDL_SOURCES += [
'nsIDOMHTMLInputElement.idl', 'nsIDOMHTMLInputElement.idl',
'nsIDOMHTMLMediaElement.idl', 'nsIDOMHTMLMediaElement.idl',
'nsIDOMHTMLOptionElement.idl', 'nsIDOMHTMLOptionElement.idl',
'nsIDOMHTMLOptionsCollection.idl',
'nsIDOMHTMLScriptElement.idl', 'nsIDOMHTMLScriptElement.idl',
'nsIDOMHTMLSelectElement.idl',
'nsIDOMMozBrowserFrame.idl', 'nsIDOMMozBrowserFrame.idl',
'nsIDOMTimeRanges.idl', 'nsIDOMTimeRanges.idl',
'nsIDOMValidityState.idl', 'nsIDOMValidityState.idl',

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

@ -1,49 +0,0 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsIDOMHTMLElement.idl"
#include "nsIDOMHTMLCollection.idl"
interface nsIDOMHTMLOptionElement;
interface nsIDOMHTMLSelectElement;
/**
* The nsIDOMHTMLOptionsCollection interface is the interface to a
* collection of [X]HTML option elements.
*
* This interface is trying to follow the DOM Level 2 HTML specification:
* http://www.w3.org/TR/DOM-Level-2-HTML/
*
* with changes from the work-in-progress WHATWG HTML specification:
* http://www.whatwg.org/specs/web-apps/current-work/
*/
// Introduced in DOM Level 2:
[uuid(4173cc53-30f6-4d12-a770-981ba53164e2)]
interface nsIDOMHTMLOptionsCollection : nsISupports
{
attribute unsigned long length;
// raises(DOMException) on setting
// FIXME item should just be inherited from nsIDOMHTMLCollection
nsIDOMNode item(in unsigned long index);
// FIXME namedItem (and getNamedItem) should return a NodeList if there are
// multiple matching items
nsIDOMNode namedItem(in DOMString name);
attribute long selectedIndex;
[noscript] readonly attribute nsIDOMHTMLSelectElement select;
// This add method implementation means the following
// since IDL doesn't support overloading.
// void add(in nsIDOMHTMLOptionElement,
// [optional] in nsIDOMHTMLOptionElement)
// void add(in nsIDOMHTMLOptionElement, in long)
void add(in nsIDOMHTMLOptionElement option,
[optional] in nsIVariant before);
void remove(in long index);
};

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

@ -1,52 +0,0 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsIDOMHTMLElement.idl"
#include "nsIDOMHTMLOptionsCollection.idl"
/**
* The nsIDOMHTMLSelectElement interface is the interface to a [X]HTML
* select element.
*
* This interface is trying to follow the DOM Level 2 HTML specification:
* http://www.w3.org/TR/DOM-Level-2-HTML/
*
* with changes from the work-in-progress WHATWG HTML specification:
* http://www.whatwg.org/specs/web-apps/current-work/
*/
interface nsIDOMValidityState;
[uuid(d8914a2d-3556-4b66-911c-a84c4394e7fa)]
interface nsIDOMHTMLSelectElement : nsISupports
{
attribute boolean autofocus;
attribute boolean disabled;
readonly attribute nsIDOMHTMLFormElement form;
attribute boolean multiple;
attribute DOMString name;
attribute unsigned long size;
readonly attribute DOMString type;
readonly attribute nsIDOMHTMLOptionsCollection options;
attribute unsigned long length;
nsIDOMNode item(in unsigned long index);
nsIDOMNode namedItem(in DOMString name);
// This add method implementation means the following
// since IDL doesn't support overfload.
// void add(in nsIDOMHTMLElement, [optional] in nsIDOMHTMLElement)
// void add(in nsIDOMHTMLElement, in long)
void add(in nsIDOMHTMLElement element,
[optional] in nsIVariant before)
raises(DOMException);
void remove(in long index);
readonly attribute nsIDOMHTMLCollection selectedOptions;
attribute long selectedIndex;
attribute DOMString value;
attribute boolean required;
};

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

@ -245,9 +245,9 @@ partial interface Element {
// Shadow DOM v1 // Shadow DOM v1
[Throws, Pref="dom.webcomponents.enabled"] [Throws, Pref="dom.webcomponents.enabled"]
ShadowRoot attachShadow(ShadowRootInit shadowRootInitDict); ShadowRoot attachShadow(ShadowRootInit shadowRootInitDict);
[Pref="dom.webcomponents.enabled"] [BinaryName="shadowRootByMode", Pref="dom.webcomponents.enabled"]
readonly attribute ShadowRoot? shadowRoot; readonly attribute ShadowRoot? shadowRoot;
[Pref="dom.webcomponents.enabled"] [BinaryName="assignedSlotByMode", Pref="dom.webcomponents.enabled"]
readonly attribute HTMLSlotElement? assignedSlot; readonly attribute HTMLSlotElement? assignedSlot;
[CEReactions, Unscopable, SetterThrows, Pref="dom.webcomponents.enabled"] [CEReactions, Unscopable, SetterThrows, Pref="dom.webcomponents.enabled"]
attribute DOMString slot; attribute DOMString slot;

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

@ -11,7 +11,7 @@
*/ */
interface HTMLOptionsCollection : HTMLCollection { interface HTMLOptionsCollection : HTMLCollection {
[CEReactions] [CEReactions, SetterThrows]
attribute unsigned long length; attribute unsigned long length;
[CEReactions, Throws] [CEReactions, Throws]
setter void (unsigned long index, HTMLOptionElement? option); setter void (unsigned long index, HTMLOptionElement? option);

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

@ -19,7 +19,7 @@ interface Text : CharacterData {
}; };
partial interface Text { partial interface Text {
[Pref="dom.webcomponents.enabled"] [BinaryName="assignedSlotByMode", Pref="dom.webcomponents.enabled"]
readonly attribute HTMLSlotElement? assignedSlot; readonly attribute HTMLSlotElement? assignedSlot;
}; };

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

@ -13,6 +13,7 @@
#include "mozilla/Casting.h" #include "mozilla/Casting.h"
#include "mozilla/EditorBase.h" #include "mozilla/EditorBase.h"
#include "mozilla/EditorDOMPoint.h"
#include "nsAlgorithm.h" #include "nsAlgorithm.h"
#include "nsAString.h" #include "nsAString.h"
@ -103,7 +104,14 @@ CreateElementTransaction::DoTransaction()
RefPtr<Selection> selection = mEditorBase->GetSelection(); RefPtr<Selection> selection = mEditorBase->GetSelection();
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER); NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
rv = selection->Collapse(mParent, mParent->IndexOf(mNewNode) + 1); EditorRawDOMPoint afterNewNode(mNewNode);
if (NS_WARN_IF(!afterNewNode.AdvanceOffset())) {
// If mutation observer or mutation event listener moved or removed the
// new node, we hit this case. Should we use script blocker while we're
// in this method?
return NS_ERROR_FAILURE;
}
rv = selection->Collapse(afterNewNode);
NS_ASSERTION(!rv.Failed(), NS_ASSERTION(!rv.Failed(),
"selection could not be collapsed after insert"); "selection could not be collapsed after insert");
return NS_OK; return NS_OK;

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

@ -4278,22 +4278,30 @@ EditorBase::DeleteSelectionAndPrepareToCreateNode()
uint32_t offset = selection->AnchorOffset(); uint32_t offset = selection->AnchorOffset();
if (!offset) { if (!offset) {
nsresult rv = selection->Collapse(node->GetParentNode(), EditorRawDOMPoint atNode(node);
node->GetParentNode()->IndexOf(node)); if (NS_WARN_IF(!atNode.IsSetAndValid())) {
return NS_ERROR_FAILURE;
}
nsresult rv = selection->Collapse(atNode);
MOZ_ASSERT(NS_SUCCEEDED(rv)); MOZ_ASSERT(NS_SUCCEEDED(rv));
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
} else if (offset == node->Length()) { } else if (offset == node->Length()) {
nsresult rv = EditorRawDOMPoint afterNode(node);
selection->Collapse(node->GetParentNode(), if (NS_WARN_IF(!afterNode.AdvanceOffset())) {
node->GetParentNode()->IndexOf(node) + 1); return NS_ERROR_FAILURE;
}
nsresult rv = selection->Collapse(afterNode);
MOZ_ASSERT(NS_SUCCEEDED(rv)); MOZ_ASSERT(NS_SUCCEEDED(rv));
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
} else { } else {
nsCOMPtr<nsIDOMNode> tmp; nsCOMPtr<nsIDOMNode> tmp;
nsresult rv = SplitNode(node->AsDOMNode(), offset, getter_AddRefs(tmp)); nsresult rv = SplitNode(node->AsDOMNode(), offset, getter_AddRefs(tmp));
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
rv = selection->Collapse(node->GetParentNode(), EditorRawDOMPoint atNode(node);
node->GetParentNode()->IndexOf(node)); if (NS_WARN_IF(!atNode.IsSetAndValid())) {
return NS_ERROR_FAILURE;
}
rv = selection->Collapse(atNode);
MOZ_ASSERT(NS_SUCCEEDED(rv)); MOZ_ASSERT(NS_SUCCEEDED(rv));
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
} }

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

@ -49,15 +49,17 @@ public:
} }
/** /**
* Different from RangeBoundary, aReferenceChild should be a child node * Different from RangeBoundary, aPointedNode should be a child node
* which you want to refer. So, set non-nullptr if offset is * which you want to refer. So, set non-nullptr if offset is
* 0 - Length() - 1. Otherwise, set nullptr, i.e., if offset is same as * 0 - Length() - 1. Otherwise, set nullptr, i.e., if offset is same as
* Length(). * Length().
*/ */
EditorDOMPointBase(nsINode* aContainer, explicit EditorDOMPointBase(nsINode* aPointedNode)
nsIContent* aPointedNode) : RangeBoundaryBase<ParentType, RefType>(
: RangeBoundaryBase<ParentType, RefType>(aContainer, aPointedNode && aPointedNode->IsContent() ?
GetRef(aPointedNode)) aPointedNode->GetParentNode() : nullptr,
aPointedNode && aPointedNode->IsContent() ?
GetRef(aPointedNode->AsContent()) : nullptr)
{ {
} }

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

@ -1265,9 +1265,8 @@ HTMLEditRules::WillInsert(Selection& aSelection,
// If we are here then the selection is right after a mozBR that is in // If we are here then the selection is right after a mozBR that is in
// the same block as the selection. We need to move the selection start // the same block as the selection. We need to move the selection start
// to be before the mozBR. // to be before the mozBR.
selNode = priorNode->GetParentNode(); EditorRawDOMPoint point(priorNode);
selOffset = selNode->IndexOf(priorNode); nsresult rv = aSelection.Collapse(point.AsRaw());
nsresult rv = aSelection.Collapse(selNode, selOffset);
NS_ENSURE_SUCCESS_VOID(rv); NS_ENSURE_SUCCESS_VOID(rv);
} }
} }
@ -1493,7 +1492,9 @@ HTMLEditRules::WillInsertText(EditAction aAction,
} }
} }
aSelection->SetInterlinePosition(false); aSelection->SetInterlinePosition(false);
if (curNode) aSelection->Collapse(curNode, curOffset); if (curNode) {
aSelection->Collapse(curNode, curOffset);
}
// manually update the doc changed range so that AfterEdit will clean up // manually update the doc changed range so that AfterEdit will clean up
// the correct portion of the document. // the correct portion of the document.
if (!mDocChangeRange) { if (!mDocChangeRange) {
@ -1802,15 +1803,16 @@ HTMLEditRules::StandardBreakImpl(nsINode& aNode,
} }
node = brNode->GetParentNode(); node = brNode->GetParentNode();
NS_ENSURE_TRUE(node, NS_ERROR_NULL_POINTER); NS_ENSURE_TRUE(node, NS_ERROR_NULL_POINTER);
int32_t offset = node->IndexOf(brNode);
if (bAfterBlock && bBeforeBlock) { if (bAfterBlock && bBeforeBlock) {
// We just placed a br between block boundaries. This is the one case // We just placed a br between block boundaries. This is the one case
// where we want the selection to be before the br we just placed, as the // where we want the selection to be before the br we just placed, as the
// br will be on a new line, rather than at end of prior line. // br will be on a new line, rather than at end of prior line.
aSelection.SetInterlinePosition(true); aSelection.SetInterlinePosition(true);
nsresult rv = aSelection.Collapse(node, offset); EditorRawDOMPoint point(brNode);
nsresult rv = aSelection.Collapse(point.AsRaw());
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
} else { } else {
int32_t offset = node->IndexOf(brNode);
WSRunObject wsObj(htmlEditor, node, offset + 1); WSRunObject wsObj(htmlEditor, node, offset + 1);
nsCOMPtr<nsINode> secondBR; nsCOMPtr<nsINode> secondBR;
int32_t visOffset = 0; int32_t visOffset = 0;
@ -2309,7 +2311,7 @@ HTMLEditRules::WillDeleteSelection(Selection* aSelection,
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
// Fix up selection // Fix up selection
rv = aSelection->Collapse(pt.Container(), pt.Offset()); rv = aSelection->Collapse(pt.AsRaw());
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
} }
rv = InsertBRIfNeeded(aSelection); rv = InsertBRIfNeeded(aSelection);
@ -2380,7 +2382,7 @@ HTMLEditRules::WillDeleteSelection(Selection* aSelection,
if (NS_WARN_IF(!newSel.IsSet())) { if (NS_WARN_IF(!newSel.IsSet())) {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
aSelection->Collapse(newSel.Container(), newSel.Offset()); aSelection->Collapse(newSel.AsRaw());
return NS_OK; return NS_OK;
} }
@ -2572,7 +2574,7 @@ HTMLEditRules::WillDeleteSelection(Selection* aSelection,
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
// Fix up selection // Fix up selection
rv = aSelection->Collapse(pt.Container(), pt.Offset()); rv = aSelection->Collapse(pt.AsRaw());
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
return NS_OK; return NS_OK;
} }
@ -2792,7 +2794,7 @@ HTMLEditRules::GetGoodSelPointForNode(nsINode& aNode,
return EditorDOMPoint(); return EditorDOMPoint();
} }
EditorDOMPoint ret(aNode.GetParentNode(), aNode.AsContent()); EditorDOMPoint ret(&aNode);
if ((!aNode.IsHTMLElement(nsGkAtoms::br) || if ((!aNode.IsHTMLElement(nsGkAtoms::br) ||
mHTMLEditor->IsVisibleBRElement(&aNode)) && isPreviousAction) { mHTMLEditor->IsVisibleBRElement(&aNode)) && isPreviousAction) {
ret.AdvanceOffset(); ret.AdvanceOffset();
@ -4552,25 +4554,22 @@ HTMLEditRules::WillOutdent(Selection& aSelection,
NS_ENSURE_TRUE(aSelection.GetRangeAt(0), NS_OK); NS_ENSURE_TRUE(aSelection.GetRangeAt(0), NS_OK);
nsCOMPtr<nsINode> startNode = nsCOMPtr<nsINode> startNode =
aSelection.GetRangeAt(0)->GetStartContainer(); aSelection.GetRangeAt(0)->GetStartContainer();
int32_t startOffset = aSelection.GetRangeAt(0)->StartOffset();
if (rememberedLeftBQ && if (rememberedLeftBQ &&
(startNode == rememberedLeftBQ || (startNode == rememberedLeftBQ ||
EditorUtils::IsDescendantOf(*startNode, *rememberedLeftBQ))) { EditorUtils::IsDescendantOf(*startNode, *rememberedLeftBQ))) {
// Selection is inside rememberedLeftBQ - push it past it. // Selection is inside rememberedLeftBQ - push it past it.
startNode = rememberedLeftBQ->GetParentNode(); EditorRawDOMPoint afterRememberedLeftBQ(rememberedLeftBQ);
startOffset = startNode ? 1 + startNode->IndexOf(rememberedLeftBQ) : 0; afterRememberedLeftBQ.AdvanceOffset();
aSelection.Collapse(startNode, startOffset); aSelection.Collapse(afterRememberedLeftBQ);
} }
// And pull selection before beginning of rememberedRightBQ // And pull selection before beginning of rememberedRightBQ
startNode = aSelection.GetRangeAt(0)->GetStartContainer(); startNode = aSelection.GetRangeAt(0)->GetStartContainer();
startOffset = aSelection.GetRangeAt(0)->StartOffset();
if (rememberedRightBQ && if (rememberedRightBQ &&
(startNode == rememberedRightBQ || (startNode == rememberedRightBQ ||
EditorUtils::IsDescendantOf(*startNode, *rememberedRightBQ))) { EditorUtils::IsDescendantOf(*startNode, *rememberedRightBQ))) {
// Selection is inside rememberedRightBQ - push it before it. // Selection is inside rememberedRightBQ - push it before it.
startNode = rememberedRightBQ->GetParentNode(); EditorRawDOMPoint atRememberedRightBQ(rememberedRightBQ);
startOffset = startNode ? startNode->IndexOf(rememberedRightBQ) : -1; aSelection.Collapse(atRememberedRightBQ);
aSelection.Collapse(startNode, startOffset);
} }
} }
return NS_OK; return NS_OK;
@ -5188,37 +5187,45 @@ HTMLEditRules::CheckForEmptyBlock(nsINode* aStartNode,
// AfterEdit() // AfterEdit()
} }
} else { } else {
int32_t offset = blockParent->IndexOf(emptyBlock);
if (aAction == nsIEditor::eNext || aAction == nsIEditor::eNextWord || if (aAction == nsIEditor::eNext || aAction == nsIEditor::eNextWord ||
aAction == nsIEditor::eToEndOfLine) { aAction == nsIEditor::eToEndOfLine) {
// Move to the start of the next node, if any // Move to the start of the next node, if any
nsINode* child = emptyBlock->GetNextSibling(); nsINode* child = emptyBlock->GetNextSibling();
int32_t offset = blockParent->IndexOf(emptyBlock);
nsCOMPtr<nsIContent> nextNode = nsCOMPtr<nsIContent> nextNode =
htmlEditor->GetNextNode(blockParent, offset + 1, child, true); htmlEditor->GetNextNode(blockParent, offset + 1, child, true);
if (nextNode) { if (nextNode) {
EditorDOMPoint pt = GetGoodSelPointForNode(*nextNode, aAction); EditorDOMPoint pt = GetGoodSelPointForNode(*nextNode, aAction);
nsresult rv = aSelection->Collapse(pt.Container(), pt.Offset()); nsresult rv = aSelection->Collapse(pt.AsRaw());
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
} else { } else {
// Adjust selection to be right after it. // Adjust selection to be right after it.
nsresult rv = aSelection->Collapse(blockParent, offset + 1); EditorRawDOMPoint afterEmptyBlock(emptyBlock);
if (NS_WARN_IF(!afterEmptyBlock.AdvanceOffset())) {
return NS_ERROR_FAILURE;
}
nsresult rv = aSelection->Collapse(afterEmptyBlock);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
} }
} else if (aAction == nsIEditor::ePrevious || } else if (aAction == nsIEditor::ePrevious ||
aAction == nsIEditor::ePreviousWord || aAction == nsIEditor::ePreviousWord ||
aAction == nsIEditor::eToBeginningOfLine) { aAction == nsIEditor::eToBeginningOfLine) {
// Move to the end of the previous node // Move to the end of the previous node
int32_t offset = blockParent->IndexOf(emptyBlock);
nsCOMPtr<nsIContent> priorNode = htmlEditor->GetPriorNode(blockParent, nsCOMPtr<nsIContent> priorNode = htmlEditor->GetPriorNode(blockParent,
offset, offset,
emptyBlock, emptyBlock,
true); true);
if (priorNode) { if (priorNode) {
EditorDOMPoint pt = GetGoodSelPointForNode(*priorNode, aAction); EditorDOMPoint pt = GetGoodSelPointForNode(*priorNode, aAction);
nsresult rv = aSelection->Collapse(pt.Container(), pt.Offset()); nsresult rv = aSelection->Collapse(pt.AsRaw());
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
} else { } else {
nsresult rv = aSelection->Collapse(blockParent, offset + 1); EditorRawDOMPoint afterEmptyBlock(emptyBlock);
if (NS_WARN_IF(!afterEmptyBlock.AdvanceOffset())) {
return NS_ERROR_FAILURE;
}
nsresult rv = aSelection->Collapse(afterEmptyBlock);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
} }
} else if (aAction != nsIEditor::eNone) { } else if (aAction != nsIEditor::eNone) {
@ -6625,10 +6632,12 @@ HTMLEditRules::ReturnInHeader(Selection& aSelection,
rv = aSelection.Collapse(pNode, 0); rv = aSelection.Collapse(pNode, 0);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
} else { } else {
headerParent = sibling->GetParentNode(); EditorRawDOMPoint afterSibling(sibling);
offset = headerParent ? headerParent->IndexOf(sibling) : -1; if (NS_WARN_IF(!afterSibling.AdvanceOffset())) {
return NS_ERROR_FAILURE;
}
// Put selection after break // Put selection after break
rv = aSelection.Collapse(headerParent, offset + 1); rv = aSelection.Collapse(afterSibling);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
} }
} else { } else {
@ -6825,15 +6834,13 @@ HTMLEditRules::SplitParagraph(nsIDOMNode *aPara,
// look inside any containers that are up front. // look inside any containers that are up front.
nsCOMPtr<nsINode> rightParaNode = do_QueryInterface(rightPara); nsCOMPtr<nsINode> rightParaNode = do_QueryInterface(rightPara);
NS_ENSURE_STATE(mHTMLEditor && rightParaNode); NS_ENSURE_STATE(mHTMLEditor && rightParaNode);
nsCOMPtr<nsIDOMNode> child = nsIContent* child = mHTMLEditor->GetLeftmostChild(rightParaNode, true);
GetAsDOMNode(mHTMLEditor->GetLeftmostChild(rightParaNode, true));
if (EditorBase::IsTextNode(child) || if (EditorBase::IsTextNode(child) ||
mHTMLEditor->IsContainer(child)) { mHTMLEditor->IsContainer(child)) {
aSelection->Collapse(child,0); aSelection->Collapse(child,0);
} else { } else {
int32_t offset; EditorRawDOMPoint atChild(child);
nsCOMPtr<nsIDOMNode> parent = EditorBase::GetNodeLocation(child, &offset); aSelection->Collapse(atChild);
aSelection->Collapse(parent,offset);
} }
return NS_OK; return NS_OK;
} }
@ -6959,9 +6966,11 @@ HTMLEditRules::ReturnInListItem(Selection& aSelection,
getter_AddRefs(brNode)); getter_AddRefs(brNode));
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
if (brNode) { if (brNode) {
nsCOMPtr<nsINode> brParent = brNode->GetParentNode(); EditorRawDOMPoint atBrNode(brNode);
int32_t offset = brParent ? brParent->IndexOf(brNode) : -1; if (NS_WARN_IF(!atBrNode.IsSetAndValid())) {
rv = aSelection.Collapse(brParent, offset); return NS_ERROR_FAILURE;
}
rv = aSelection.Collapse(atBrNode);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
return NS_OK; return NS_OK;
} }
@ -6974,9 +6983,11 @@ HTMLEditRules::ReturnInListItem(Selection& aSelection,
&visOffset, &wsType); &visOffset, &wsType);
if (wsType == WSType::special || wsType == WSType::br || if (wsType == WSType::special || wsType == WSType::br ||
visNode->IsHTMLElement(nsGkAtoms::hr)) { visNode->IsHTMLElement(nsGkAtoms::hr)) {
nsCOMPtr<nsINode> parent = visNode->GetParentNode(); EditorRawDOMPoint atVisNode(visNode);
int32_t offset = parent ? parent->IndexOf(visNode) : -1; if (NS_WARN_IF(!atVisNode.IsSetAndValid())) {
rv = aSelection.Collapse(parent, offset); return NS_ERROR_FAILURE;
}
rv = aSelection.Collapse(atVisNode);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
return NS_OK; return NS_OK;
} else { } else {
@ -7681,36 +7692,42 @@ HTMLEditRules::PinSelectionToNewBlock(Selection* aSelection)
if (nodeBefore && nodeAfter) { if (nodeBefore && nodeAfter) {
return NS_OK; // selection is inside block return NS_OK; // selection is inside block
} else if (nodeBefore) { }
if (nodeBefore) {
// selection is after block. put at end of block. // selection is after block. put at end of block.
NS_ENSURE_STATE(mHTMLEditor); NS_ENSURE_STATE(mHTMLEditor);
nsCOMPtr<nsINode> tmp = mHTMLEditor->GetLastEditableChild(*mNewBlock); nsCOMPtr<nsINode> tmp = mHTMLEditor->GetLastEditableChild(*mNewBlock);
if (!tmp) { if (!tmp) {
tmp = mNewBlock; tmp = mNewBlock;
} }
uint32_t endPoint; EditorRawDOMPoint endPoint;
if (EditorBase::IsTextNode(tmp) || if (EditorBase::IsTextNode(tmp) ||
mHTMLEditor->IsContainer(tmp)) { mHTMLEditor->IsContainer(tmp)) {
endPoint = tmp->Length(); endPoint.Set(tmp, tmp->Length());
} else { } else {
tmp = EditorBase::GetNodeLocation(tmp, (int32_t*)&endPoint); endPoint.Set(tmp);
endPoint++; // want to be after this node if (NS_WARN_IF(!endPoint.AdvanceOffset())) {
return NS_ERROR_FAILURE;
} }
return aSelection->Collapse(tmp, (int32_t)endPoint); }
} else { return aSelection->Collapse(endPoint);
}
// selection is before block. put at start of block. // selection is before block. put at start of block.
NS_ENSURE_STATE(mHTMLEditor); NS_ENSURE_STATE(mHTMLEditor);
nsCOMPtr<nsINode> tmp = mHTMLEditor->GetFirstEditableChild(*mNewBlock); nsCOMPtr<nsINode> tmp = mHTMLEditor->GetFirstEditableChild(*mNewBlock);
if (!tmp) { if (!tmp) {
tmp = mNewBlock; tmp = mNewBlock;
} }
int32_t offset; EditorRawDOMPoint atStartOfBlock;
if (EditorBase::IsTextNode(tmp) || if (EditorBase::IsTextNode(tmp) ||
mHTMLEditor->IsContainer(tmp)) { mHTMLEditor->IsContainer(tmp)) {
tmp = EditorBase::GetNodeLocation(tmp, &offset); atStartOfBlock.Set(tmp);
} } else {
return aSelection->Collapse(tmp, 0); atStartOfBlock.Set(tmp, 0);
} }
return aSelection->Collapse(atStartOfBlock);
} }
void void
@ -7904,7 +7921,7 @@ HTMLEditRules::AdjustSelection(Selection* aSelection,
return NS_OK; return NS_OK;
} }
EditorDOMPoint pt = GetGoodSelPointForNode(*nearNode, aAction); EditorDOMPoint pt = GetGoodSelPointForNode(*nearNode, aAction);
rv = aSelection->Collapse(pt.Container(), pt.Offset()); rv = aSelection->Collapse(pt.AsRaw());
if (NS_WARN_IF(NS_FAILED(rv))) { if (NS_WARN_IF(NS_FAILED(rv))) {
return rv; return rv;
} }

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

@ -1086,10 +1086,18 @@ HTMLEditor::InsertBR(nsCOMPtr<nsIDOMNode>* outBRNode)
rv = CreateBR(selNode, selOffset, outBRNode); rv = CreateBR(selNode, selOffset, outBRNode);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
// position selection after br
selNode = GetNodeLocation(*outBRNode, &selOffset);
selection->SetInterlinePosition(true); selection->SetInterlinePosition(true);
return selection->Collapse(selNode, selOffset+1);
// position selection after br
nsCOMPtr<nsINode> brNode = do_QueryInterface(*outBRNode);
if (NS_WARN_IF(!brNode)) {
return NS_ERROR_FAILURE;
}
EditorRawDOMPoint afterBrNode(brNode);
if (NS_WARN_IF(!afterBrNode.AdvanceOffset())) {
return NS_ERROR_FAILURE;
}
return selection->Collapse(afterBrNode);
} }
void void
@ -1692,9 +1700,12 @@ HTMLEditor::SetCaretAfterElement(nsIDOMElement* aElement)
nsresult rv = aElement->GetParentNode(getter_AddRefs(parent)); nsresult rv = aElement->GetParentNode(getter_AddRefs(parent));
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_TRUE(parent, NS_ERROR_NULL_POINTER); NS_ENSURE_TRUE(parent, NS_ERROR_NULL_POINTER);
int32_t offsetInParent = GetChildOffset(aElement, parent);
// Collapse selection to just after desired element, // Collapse selection to just after desired element,
return selection->Collapse(parent, offsetInParent + 1); EditorRawDOMPoint afterElement(element);
if (NS_WARN_IF(!afterElement.AdvanceOffset())) {
return NS_ERROR_FAILURE;
}
return selection->Collapse(afterElement);
} }
NS_IMETHODIMP NS_IMETHODIMP

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

@ -18,6 +18,7 @@
#include "mozilla/ArrayUtils.h" #include "mozilla/ArrayUtils.h"
#include "mozilla/Base64.h" #include "mozilla/Base64.h"
#include "mozilla/BasicEvents.h" #include "mozilla/BasicEvents.h"
#include "mozilla/EditorDOMPoint.h"
#include "mozilla/EditorUtils.h" #include "mozilla/EditorUtils.h"
#include "mozilla/OwningNonNull.h" #include "mozilla/OwningNonNull.h"
#include "mozilla/Preferences.h" #include "mozilla/Preferences.h"
@ -657,8 +658,10 @@ HTMLEditor::DoInsertHTMLWithContext(const nsAString& aInputString,
SplitNodeDeep(*linkContent, *selContent, selOffset, SplitNodeDeep(*linkContent, *selContent, selOffset,
EmptyContainers::no, getter_AddRefs(leftLink)); EmptyContainers::no, getter_AddRefs(leftLink));
if (leftLink) { if (leftLink) {
selNode = GetNodeLocation(GetAsDOMNode(leftLink), &selOffset); EditorRawDOMPoint afterLeftLink(leftLink);
selection->Collapse(selNode, selOffset+1); if (afterLeftLink.AdvanceOffset()) {
selection->Collapse(afterLeftLink);
}
} }
} }
} }
@ -1898,10 +1901,9 @@ HTMLEditor::InsertAsPlaintextQuotation(const nsAString& aQuotedText,
// Set the selection to just after the inserted node: // Set the selection to just after the inserted node:
if (NS_SUCCEEDED(rv) && newNode) { if (NS_SUCCEEDED(rv) && newNode) {
nsCOMPtr<nsINode> parent = newNode->GetParentNode(); EditorRawDOMPoint afterNewNode(newNode);
int32_t offset = parent ? parent->IndexOf(newNode) : -1; if (afterNewNode.AdvanceOffset()) {
if (parent) { selection->Collapse(afterNewNode);
selection->Collapse(parent, offset + 1);
} }
} }
return rv; return rv;
@ -1978,10 +1980,9 @@ HTMLEditor::InsertAsCitedQuotation(const nsAString& aQuotedText,
// Set the selection to just after the inserted node: // Set the selection to just after the inserted node:
if (NS_SUCCEEDED(rv) && newNode) { if (NS_SUCCEEDED(rv) && newNode) {
nsCOMPtr<nsINode> parent = newNode->GetParentNode(); EditorRawDOMPoint afterNewNode(newNode);
int32_t offset = parent ? parent->IndexOf(newNode) : -1; if (afterNewNode.AdvanceOffset()) {
if (parent) { selection->Collapse(afterNewNode);
selection->Collapse(parent, offset + 1);
} }
} }
return rv; return rv;

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

@ -9,6 +9,7 @@
#include "HTMLEditUtils.h" #include "HTMLEditUtils.h"
#include "mozilla/Assertions.h" #include "mozilla/Assertions.h"
#include "mozilla/EditorDOMPoint.h"
#include "mozilla/EditorUtils.h" #include "mozilla/EditorUtils.h"
#include "mozilla/FlushType.h" #include "mozilla/FlushType.h"
#include "mozilla/dom/Selection.h" #include "mozilla/dom/Selection.h"
@ -3157,8 +3158,15 @@ HTMLEditor::SetSelectionAfterTableEdit(nsIDOMElement* aTable,
nsCOMPtr<nsIDOMNode> tableParent; nsCOMPtr<nsIDOMNode> tableParent;
nsresult rv = aTable->GetParentNode(getter_AddRefs(tableParent)); nsresult rv = aTable->GetParentNode(getter_AddRefs(tableParent));
if (NS_SUCCEEDED(rv) && tableParent) { if (NS_SUCCEEDED(rv) && tableParent) {
int32_t tableOffset = GetChildOffset(aTable, tableParent); nsCOMPtr<nsIContent> table = do_QueryInterface(aTable);
selection->Collapse(tableParent, tableOffset); if (NS_WARN_IF(!table)) {
return;
}
EditorRawDOMPoint atTable(table);
if (NS_WARN_IF(!atTable.IsSetAndValid())) {
return;
}
selection->Collapse(atTable);
return; return;
} }
// Last resort: Set selection to start of doc // Last resort: Set selection to start of doc

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

@ -7,6 +7,7 @@
#include "TextEditUtils.h" #include "TextEditUtils.h"
#include "mozilla/Assertions.h" #include "mozilla/Assertions.h"
#include "mozilla/EditorDOMPoint.h"
#include "mozilla/EditorUtils.h" #include "mozilla/EditorUtils.h"
#include "mozilla/LookAndFeel.h" #include "mozilla/LookAndFeel.h"
#include "mozilla/Preferences.h" #include "mozilla/Preferences.h"
@ -494,8 +495,11 @@ TextEditRules::CollapseSelectionToTrailingBRIfNeeded(Selection* aSelection)
nsINode* nextNode = selNode->GetNextSibling(); nsINode* nextNode = selNode->GetNextSibling();
if (nextNode && TextEditUtils::IsMozBR(nextNode)) { if (nextNode && TextEditUtils::IsMozBR(nextNode)) {
int32_t offsetInParent = EditorBase::GetChildOffset(selNode, parentNode); EditorRawDOMPoint afterSelNode(selNode);
rv = aSelection->Collapse(parentNode, offsetInParent + 1); if (NS_WARN_IF(!afterSelNode.AdvanceOffset())) {
return NS_ERROR_FAILURE;
}
rv = aSelection->Collapse(afterSelNode);
if (NS_WARN_IF(NS_FAILED(rv))) { if (NS_WARN_IF(NS_FAILED(rv))) {
return rv; return rv;
} }
@ -778,6 +782,8 @@ TextEditRules::WillInsertText(EditAction aAction,
!outString->IsEmpty() && outString->Last() == nsCRT::LF; !outString->IsEmpty() && outString->Last() == nsCRT::LF;
aSelection->SetInterlinePosition(endsWithLF); aSelection->SetInterlinePosition(endsWithLF);
MOZ_ASSERT(!selChild,
"After inserting text into a text node, selChild should be nullptr");
aSelection->Collapse(curNode, curOffset); aSelection->Collapse(curNode, curOffset);
} }
} }

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

@ -9,6 +9,7 @@
#include "TextEditUtils.h" #include "TextEditUtils.h"
#include "gfxFontUtils.h" #include "gfxFontUtils.h"
#include "mozilla/Assertions.h" #include "mozilla/Assertions.h"
#include "mozilla/EditorDOMPoint.h"
#include "mozilla/EditorUtils.h" // AutoPlaceholderBatch, AutoRules #include "mozilla/EditorUtils.h" // AutoPlaceholderBatch, AutoRules
#include "mozilla/HTMLEditor.h" #include "mozilla/HTMLEditor.h"
#include "mozilla/mozalloc.h" #include "mozilla/mozalloc.h"
@ -476,19 +477,24 @@ TextEditor::CreateBRImpl(nsCOMPtr<nsIDOMNode>* aInOutParent,
*outBRNode = GetAsDOMNode(brNode); *outBRNode = GetAsDOMNode(brNode);
if (*outBRNode && (aSelect != eNone)) { if (*outBRNode && (aSelect != eNone)) {
int32_t offset;
nsCOMPtr<nsINode> parent = GetNodeLocation(brNode, &offset);
RefPtr<Selection> selection = GetSelection(); RefPtr<Selection> selection = GetSelection();
NS_ENSURE_STATE(selection); NS_ENSURE_STATE(selection);
if (aSelect == eNext) { if (aSelect == eNext) {
selection->SetInterlinePosition(true);
// position selection after br // position selection after br
selection->SetInterlinePosition(true); EditorRawDOMPoint afterBrNode(brNode);
selection->Collapse(parent, offset + 1); if (NS_WARN_IF(!afterBrNode.AdvanceOffset())) {
return NS_OK;
}
selection->Collapse(afterBrNode);
} else if (aSelect == ePrevious) { } else if (aSelect == ePrevious) {
// position selection before br
selection->SetInterlinePosition(true); selection->SetInterlinePosition(true);
selection->Collapse(parent, offset); // position selection before br
EditorRawDOMPoint atBrNode(brNode);
if (NS_WARN_IF(!atBrNode.IsSetAndValid())) {
return NS_OK;
}
selection->Collapse(atBrNode);
} }
} }
return NS_OK; return NS_OK;
@ -729,7 +735,9 @@ TextEditor::InsertLineBreak()
} }
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(rv)) {
// set the selection to the correct location // set the selection to the correct location
rv = selection->Collapse(selNode, selOffset); MOZ_ASSERT(!selChild,
"After inserting text into a text node, selChild should be nullptr");
rv = selection->Collapse(EditorRawDOMPoint(selNode, selOffset));
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(rv)) {
// see if we're at the end of the editor range // see if we're at the end of the editor range
nsCOMPtr<nsIDOMNode> endNode; nsCOMPtr<nsIDOMNode> endNode;

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

@ -375,9 +375,6 @@ interface nsIXPConnect : nsISupports
getWrappedNativeOfJSObject(in JSContextPtr aJSContext, getWrappedNativeOfJSObject(in JSContextPtr aJSContext,
in JSObjectPtr aJSObj); in JSObjectPtr aJSObj);
// Will return null if there is no JS stack right now.
readonly attribute nsIStackFrame CurrentJSStack;
void debugDump(in short depth); void debugDump(in short depth);
void debugDumpObject(in nsISupports aCOMObj, in short depth); void debugDumpObject(in nsISupports aCOMObj, in short depth);
void debugDumpJSStack(in boolean showArgs, void debugDumpJSStack(in boolean showArgs,

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

@ -1726,8 +1726,7 @@ AssembleSandboxMemoryReporterName(JSContext* cx, nsCString& sandboxName)
NS_ENSURE_TRUE(cc, NS_ERROR_INVALID_ARG); NS_ENSURE_TRUE(cc, NS_ERROR_INVALID_ARG);
// Get the current source info from xpc. // Get the current source info from xpc.
nsCOMPtr<nsIStackFrame> frame; nsCOMPtr<nsIStackFrame> frame = dom::GetCurrentJSStack();
nsXPConnect::XPConnect()->GetCurrentJSStack(getter_AddRefs(frame));
// Append the caller's location information. // Append the caller's location information.
if (frame) { if (frame) {

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

@ -2235,13 +2235,8 @@ nsXPCComponents_Utils::EvalInSandbox(const nsAString& source,
if (!filenameArg.IsVoid()) { if (!filenameArg.IsVoid()) {
filename.Assign(filenameArg); filename.Assign(filenameArg);
} else { } else {
// Get the current source info from xpc. // Get the current source info.
nsresult rv; nsCOMPtr<nsIStackFrame> frame = dom::GetCurrentJSStack();
nsCOMPtr<nsIXPConnect> xpc = do_GetService(nsIXPConnect::GetCID(), &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIStackFrame> frame;
xpc->GetCurrentJSStack(getter_AddRefs(frame));
if (frame) { if (frame) {
nsString frameFile; nsString frameFile;
frame->GetFilename(cx, frameFile); frame->GetFilename(cx, frameFile);
@ -3294,12 +3289,11 @@ nsXPCComponentsBase::IsSuccessCode(nsresult result, bool* out)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsXPCComponents::GetStack(nsIStackFrame * *aStack) nsXPCComponents::GetStack(nsIStackFrame** aStack)
{ {
nsresult rv; nsCOMPtr<nsIStackFrame> frame = dom::GetCurrentJSStack();
nsXPConnect* xpc = nsXPConnect::XPConnect(); frame.forget(aStack);
rv = xpc->GetCurrentJSStack(aStack); return NS_OK;
return rv;
} }
NS_IMETHODIMP NS_IMETHODIMP

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

@ -802,17 +802,6 @@ nsXPConnect::GetWrappedNativeOfNativeObject(JSContext * aJSContext,
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP
nsXPConnect::GetCurrentJSStack(nsIStackFrame * *aCurrentJSStack)
{
MOZ_ASSERT(aCurrentJSStack, "bad param");
nsCOMPtr<nsIStackFrame> currentStack = dom::GetCurrentJSStack();
currentStack.forget(aCurrentJSStack);
return NS_OK;
}
NS_IMETHODIMP NS_IMETHODIMP
nsXPConnect::SetFunctionThisTranslator(const nsIID & aIID, nsXPConnect::SetFunctionThisTranslator(const nsIID & aIID,
nsIXPCFunctionThisTranslator* aTranslator) nsIXPCFunctionThisTranslator* aTranslator)

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

@ -10,7 +10,6 @@
#include "nsListControlFrame.h" #include "nsListControlFrame.h"
#include "nsCheckboxRadioFrame.h" // for COMPARE macro #include "nsCheckboxRadioFrame.h" // for COMPARE macro
#include "nsGkAtoms.h" #include "nsGkAtoms.h"
#include "nsIDOMHTMLSelectElement.h"
#include "nsIDOMHTMLOptionElement.h" #include "nsIDOMHTMLOptionElement.h"
#include "nsComboboxControlFrame.h" #include "nsComboboxControlFrame.h"
#include "nsIPresShell.h" #include "nsIPresShell.h"
@ -1054,10 +1053,9 @@ nsListControlFrame::ResetList(bool aAllowScrolling)
// Scroll to the selected index // Scroll to the selected index
int32_t indexToSelect = kNothingSelected; int32_t indexToSelect = kNothingSelected;
nsCOMPtr<nsIDOMHTMLSelectElement> selectElement(do_QueryInterface(mContent)); HTMLSelectElement* selectElement = HTMLSelectElement::FromContent(mContent);
NS_ASSERTION(selectElement, "No select element!");
if (selectElement) { if (selectElement) {
selectElement->GetSelectedIndex(&indexToSelect); indexToSelect = selectElement->SelectedIndex();
AutoWeakFrame weakFrame(this); AutoWeakFrame weakFrame(this);
ScrollToIndex(indexToSelect); ScrollToIndex(indexToSelect);
if (!weakFrame.IsAlive()) { if (!weakFrame.IsAlive()) {

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

@ -8495,6 +8495,14 @@ nsDisplayTransform::GetLayerState(nsDisplayListBuilder* aBuilder,
bool nsDisplayTransform::ComputeVisibility(nsDisplayListBuilder *aBuilder, bool nsDisplayTransform::ComputeVisibility(nsDisplayListBuilder *aBuilder,
nsRegion *aVisibleRegion) nsRegion *aVisibleRegion)
{ {
// nsDisplayTransform::GetBounds() returns an empty rect in nested 3d context.
// Calling mStoredList.RecomputeVisibility below for such transform causes the
// child display items to end up with empty visible rect.
// We avoid this by bailing out always if we are dealing with a 3d context.
if (mFrame->Extend3DContext() || mFrame->Combines3DTransformWithAncestors()) {
return true;
}
/* As we do this, we need to be sure to /* As we do this, we need to be sure to
* untransform the visible rect, since we want everything that's painting to * untransform the visible rect, since we want everything that's painting to
* think that it's painting in its original rectangular coordinate space. * think that it's painting in its original rectangular coordinate space.

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

@ -0,0 +1,36 @@
<!DOCTYPE html>
<html>
<head>
<title>Green square</title>
<style>
.filter {
filter: brightness(0.75);
}
.container {
width: 200px;
height: 200px;
background-color: green;
}
.square {
position: absolute;
width: 200px;
height: 200px;
background-color: green;
}
</style>
</head>
<body>
<div class="filter">
<div class="container">
<div class="square"></div>
</div>
</div>
</body>
</html>

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

@ -0,0 +1,38 @@
<!DOCTYPE html>
<html>
<head>
<title>Green square</title>
<style>
.filter {
filter: brightness(0.75);
}
.container {
width: 200px;
height: 200px;
transform-style: preserve-3d;
background-color: red;
}
.square {
position: absolute;
width: 200px;
height: 200px;
transform-style: preserve-3d;
background-color: green;
}
</style>
</head>
<body>
<div class="filter">
<div class="container">
<div class="square"></div>
</div>
</div>
</body>
</html>

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

@ -90,3 +90,4 @@ fuzzy-if(winWidget,150,120) == component-alpha-1.html component-alpha-1-ref.html
== nested-transform-1.html nested-transform-1-ref.html == nested-transform-1.html nested-transform-1-ref.html
== transform-geometry-1.html transform-geometry-1-ref.html == transform-geometry-1.html transform-geometry-1-ref.html
== intermediate-1.html intermediate-1-ref.html == intermediate-1.html intermediate-1-ref.html
== preserves3d-nested-filter-1.html preserves3d-nested-filter-1-ref.html

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

@ -1,3 +1,9 @@
Version 1.3.3 (2017 November 7)
* Fix and issue with corrupt continued packet handling.
* Update Windows projects and build settings.
* Remove Mac OS 9 build support.
Version 1.3.2 (2014 May 27) Version 1.3.2 (2014 May 27)
* Fix an bug in oggpack_writecopy(). * Fix an bug in oggpack_writecopy().

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

@ -1,4 +1,4 @@
Version: 1.3.2 Version: 1.3.3
The source from this directory was extracted from the official source The source from this directory was extracted from the official source
package downloaded from xiph.org and copied using the update.sh script. package downloaded from xiph.org and copied using the update.sh script.

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

@ -16,10 +16,10 @@
# include <sys/types.h> # include <sys/types.h>
#endif #endif
typedef short ogg_int16_t; typedef int16_t ogg_int16_t;
typedef unsigned short ogg_uint16_t; typedef uint16_t ogg_uint16_t;
typedef int ogg_int32_t; typedef int32_t ogg_int32_t;
typedef unsigned int ogg_uint32_t; typedef uint32_t ogg_uint32_t;
typedef long long ogg_int64_t; typedef int64_t ogg_int64_t;
#endif #endif

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

@ -11,7 +11,7 @@
******************************************************************** ********************************************************************
function: toplevel libogg include function: toplevel libogg include
last mod: $Id: ogg.h 18044 2011-08-01 17:55:20Z gmaxwell $ last mod: $Id$
********************************************************************/ ********************************************************************/
#ifndef _OGG_H #ifndef _OGG_H

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

@ -11,7 +11,7 @@
******************************************************************** ********************************************************************
function: #ifdef jail to whip a few platforms into the UNIX ideal. function: #ifdef jail to whip a few platforms into the UNIX ideal.
last mod: $Id: os_types.h 19098 2014-02-26 19:06:45Z giles $ last mod: $Id$
********************************************************************/ ********************************************************************/
#ifndef _OS_TYPES_H #ifndef _OS_TYPES_H
@ -69,6 +69,15 @@ extern ogg_free_function_type *ogg_free_func;
typedef unsigned int ogg_uint32_t; typedef unsigned int ogg_uint32_t;
typedef short ogg_int16_t; typedef short ogg_int16_t;
typedef unsigned short ogg_uint16_t; typedef unsigned short ogg_uint16_t;
# else
# if defined(_MSC_VER) && (_MSC_VER >= 1800) /* MSVC 2013 and newer */
# include <stdint.h>
typedef int16_t ogg_int16_t;
typedef uint16_t ogg_uint16_t;
typedef int32_t ogg_int32_t;
typedef uint32_t ogg_uint32_t;
typedef int64_t ogg_int64_t;
typedef uint64_t ogg_uint64_t;
# else # else
/* MSVC/Borland */ /* MSVC/Borland */
typedef __int64 ogg_int64_t; typedef __int64 ogg_int64_t;
@ -77,15 +86,7 @@ extern ogg_free_function_type *ogg_free_func;
typedef __int16 ogg_int16_t; typedef __int16 ogg_int16_t;
typedef unsigned __int16 ogg_uint16_t; typedef unsigned __int16 ogg_uint16_t;
# endif # endif
# endif
#elif defined(__MACOS__)
# include <sys/types.h>
typedef SInt16 ogg_int16_t;
typedef UInt16 ogg_uint16_t;
typedef SInt32 ogg_int32_t;
typedef UInt32 ogg_uint32_t;
typedef SInt64 ogg_int64_t;
#elif (defined(__APPLE__) && defined(__MACH__)) /* MacOS X Framework build */ #elif (defined(__APPLE__) && defined(__MACH__)) /* MacOS X Framework build */

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

@ -11,7 +11,7 @@
******************************************************************** ********************************************************************
function: packing variable sized words into an octet stream function: packing variable sized words into an octet stream
last mod: $Id: bitwise.c 19149 2014-05-27 16:26:23Z giles $ last mod: $Id$
********************************************************************/ ********************************************************************/

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

@ -12,7 +12,7 @@
function: code raw packets into framed OggSquish stream and function: code raw packets into framed OggSquish stream and
decode Ogg streams back into raw packets decode Ogg streams back into raw packets
last mod: $Id: framing.c 18758 2013-01-08 16:29:56Z tterribe $ last mod: $Id$
note: The CRC code is directly derived from public domain code by note: The CRC code is directly derived from public domain code by
Ross Williams (ross@guest.adelaide.edu.au). See docs/framing.html Ross Williams (ross@guest.adelaide.edu.au). See docs/framing.html
@ -875,6 +875,7 @@ int ogg_stream_pagein(ogg_stream_state *os, ogg_page *og){
some segments */ some segments */
if(continued){ if(continued){
if(os->lacing_fill<1 || if(os->lacing_fill<1 ||
(os->lacing_vals[os->lacing_fill-1]&0xff)<255 ||
os->lacing_vals[os->lacing_fill-1]==0x400){ os->lacing_vals[os->lacing_fill-1]==0x400){
bos=0; bos=0;
for(;segptr<segments;segptr++){ for(;segptr<segments;segptr++){
@ -1492,6 +1493,34 @@ const int head3_7[] = {0x4f,0x67,0x67,0x53,0,0x05,
1, 1,
0}; 0};
int compare_packet(const ogg_packet *op1, const ogg_packet *op2){
if(op1->packet!=op2->packet){
fprintf(stderr,"op1->packet != op2->packet\n");
return(1);
}
if(op1->bytes!=op2->bytes){
fprintf(stderr,"op1->bytes != op2->bytes\n");
return(1);
}
if(op1->b_o_s!=op2->b_o_s){
fprintf(stderr,"op1->b_o_s != op2->b_o_s\n");
return(1);
}
if(op1->e_o_s!=op2->e_o_s){
fprintf(stderr,"op1->e_o_s != op2->e_o_s\n");
return(1);
}
if(op1->granulepos!=op2->granulepos){
fprintf(stderr,"op1->granulepos != op2->granulepos\n");
return(1);
}
if(op1->packetno!=op2->packetno){
fprintf(stderr,"op1->packetno != op2->packetno\n");
return(1);
}
return(0);
}
void test_pack(const int *pl, const int **headers, int byteskip, void test_pack(const int *pl, const int **headers, int byteskip,
int pageskip, int packetskip){ int pageskip, int packetskip){
unsigned char *data=_ogg_malloc(1024*1024); /* for scripted test cases only */ unsigned char *data=_ogg_malloc(1024*1024); /* for scripted test cases only */
@ -1600,7 +1629,7 @@ void test_pack(const int *pl, const int **headers, int byteskip,
ogg_stream_packetout(&os_de,&op_de); /* just catching them all */ ogg_stream_packetout(&os_de,&op_de); /* just catching them all */
/* verify peek and out match */ /* verify peek and out match */
if(memcmp(&op_de,&op_de2,sizeof(op_de))){ if(compare_packet(&op_de,&op_de2)){
fprintf(stderr,"packetout != packetpeek! pos=%ld\n", fprintf(stderr,"packetout != packetpeek! pos=%ld\n",
depacket); depacket);
exit(1); exit(1);

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

@ -10,6 +10,9 @@ with Files("**"):
with Files("update-libjpeg.sh"): with Files("update-libjpeg.sh"):
BUG_COMPONENT = ("Core", "ImageLib") BUG_COMPONENT = ("Core", "ImageLib")
with Files("openmax_dl/**"):
BUG_COMPONENT = ("Core", "Web Audio")
with Files("openmax_il/**"): with Files("openmax_il/**"):
BUG_COMPONENT = ("Core", "Audio/Video: Playback") BUG_COMPONENT = ("Core", "Audio/Video: Playback")

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

@ -1,7 +0,0 @@
# 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/.
ifeq (WINNT,$(OS_TARGET))
VISIBILITY_FLAGS =
endif

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

@ -1,10 +0,0 @@
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# 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/.
with Files("**"):
BUG_COMPONENT = ("Core", "Web Audio")
DIRS += ['dl']

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

@ -173,7 +173,6 @@ android {
if (mozconfig.substs.MOZ_ANDROID_DISTRIBUTION_DIRECTORY) { if (mozconfig.substs.MOZ_ANDROID_DISTRIBUTION_DIRECTORY) {
srcDir "${mozconfig.substs.MOZ_ANDROID_DISTRIBUTION_DIRECTORY}/assets" srcDir "${mozconfig.substs.MOZ_ANDROID_DISTRIBUTION_DIRECTORY}/assets"
} }
srcDir "${topsrcdir}/mobile/android/app/assets"
} }
} }
@ -568,3 +567,14 @@ android.applicationVariants.all { variant ->
assembleTask.dependsOn dumpTask assembleTask.dependsOn dumpTask
} }
// Bug 1415298: make Robolectric find assets. Fix adapted from
// https://github.com/robolectric/robolectric/issues/2647.
android.applicationVariants.all { variant ->
def productFlavor = ""
variant.productFlavors.each {
productFlavor += "${it.name.capitalize()}"
}
def buildType = "${variant.buildType.name.capitalize()}"
tasks["compile${productFlavor}${buildType}UnitTestSources"].dependsOn(tasks["merge${productFlavor}${buildType}Assets"])
}

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

@ -19,12 +19,12 @@ with Files('mobile*'):
with Files('ua-update.json.in'): with Files('ua-update.json.in'):
BUG_COMPONENT = ('Firefox for Android', 'General') BUG_COMPONENT = ('Firefox for Android', 'General')
with Files('assets/**'):
BUG_COMPONENT = ('Firefox for Android', 'General')
with Files('omnijar/**'): with Files('omnijar/**'):
BUG_COMPONENT = ('Firefox for Android', 'Build Config & IDE Support') BUG_COMPONENT = ('Firefox for Android', 'Build Config & IDE Support')
with Files('src/main/**'):
BUG_COMPONENT = ('Firefox for Android', 'General')
with Files('src/androidTest/**'): with Files('src/androidTest/**'):
BUG_COMPONENT = ('Firefox for Android', 'Testing') BUG_COMPONENT = ('Firefox for Android', 'Testing')

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

До

Ширина:  |  Высота:  |  Размер: 2.8 KiB

После

Ширина:  |  Высота:  |  Размер: 2.8 KiB

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

@ -1408,7 +1408,7 @@ ANDROID_GENERATED_RESFILES += [
] ]
ANDROID_ASSETS_DIRS += [ ANDROID_ASSETS_DIRS += [
'/mobile/android/app/assets', '/mobile/android/app/src/main/assets',
] ]
if CONFIG['MOZ_ANDROID_DISTRIBUTION_DIRECTORY']: if CONFIG['MOZ_ANDROID_DISTRIBUTION_DIRECTORY']:

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

@ -1,4 +1,11 @@
{ {
"ach": {
"platforms": [
"android",
"android-api-16"
],
"revision": "default"
},
"an": { "an": {
"platforms": [ "platforms": [
"android", "android",
@ -79,6 +86,13 @@
], ],
"revision": "default" "revision": "default"
}, },
"bs": {
"platforms": [
"android",
"android-api-16"
],
"revision": "default"
},
"ca": { "ca": {
"platforms": [ "platforms": [
"android", "android",
@ -343,6 +357,13 @@
], ],
"revision": "default" "revision": "default"
}, },
"ia": {
"platforms": [
"android",
"android-api-16"
],
"revision": "default"
},
"id": { "id": {
"platforms": [ "platforms": [
"android", "android",
@ -431,6 +452,13 @@
], ],
"revision": "default" "revision": "default"
}, },
"ltg": {
"platforms": [
"android",
"android-api-16"
],
"revision": "default"
},
"lv": { "lv": {
"platforms": [ "platforms": [
"android", "android",
@ -511,6 +539,13 @@
], ],
"revision": "default" "revision": "default"
}, },
"oc": {
"platforms": [
"android",
"android-api-16"
],
"revision": "default"
},
"or": { "or": {
"platforms": [ "platforms": [
"android", "android",

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

@ -108,7 +108,10 @@ def moz_debug(debug):
set_config('MOZ_DEBUG', moz_debug) set_config('MOZ_DEBUG', moz_debug)
set_define('MOZ_DEBUG', moz_debug) set_define('MOZ_DEBUG', moz_debug)
add_old_configure_assignment('MOZ_DEBUG', moz_debug) # Override any value MOZ_DEBUG may have from the environment when passing it
# down to old-configure.
add_old_configure_assignment('MOZ_DEBUG',
depends('--enable-debug')(lambda x: bool(x)))
js_option('--enable-rust-debug', js_option('--enable-rust-debug',
help='Build Rust code with debug assertions turned on.') help='Build Rust code with debug assertions turned on.')

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

@ -13,7 +13,7 @@
#include "mozilla/Casting.h" #include "mozilla/Casting.h"
#include "nsDependentString.h" #include "nsDependentString.h"
#include "nsIContent.h" #include "nsIContent.h"
#include "nsIDOMHTMLSelectElement.h" #include "nsIDOMHTMLElement.h"
#include "nsIGenKeypairInfoDlg.h" #include "nsIGenKeypairInfoDlg.h"
#include "nsIServiceManager.h" #include "nsIServiceManager.h"
#include "nsITokenDialogs.h" #include "nsITokenDialogs.h"

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

@ -1199,25 +1199,23 @@ SyncEngine.prototype = {
backfilledItems.sort = "newest"; backfilledItems.sort = "newest";
backfilledItems.full = true; backfilledItems.full = true;
// `get` includes the list of IDs as a query parameter, so we need to fetch // `getBatched` includes the list of IDs as a query parameter, so we need to fetch
// records in chunks to avoid exceeding URI length limits. // records in chunks to avoid exceeding URI length limits.
for (let ids of PlacesSyncUtils.chunkArray(idsToBackfill, this.guidFetchBatchSize)) { for (let ids of PlacesSyncUtils.chunkArray(idsToBackfill, this.guidFetchBatchSize)) {
backfilledItems.ids = ids; backfilledItems.ids = ids;
let resp = await backfilledItems.get(); let {response, records} = await backfilledItems.getBatched(this.downloadBatchSize);
if (!resp.success) { if (!response.success) {
resp.failureCode = ENGINE_DOWNLOAD_FAIL; response.failureCode = ENGINE_DOWNLOAD_FAIL;
throw resp; throw response;
} }
let maybeYield = Async.jankYielder(); let maybeYield = Async.jankYielder();
let backfilledRecordsToApply = []; let backfilledRecordsToApply = [];
let failedInBackfill = []; let failedInBackfill = [];
for (let json of resp.obj) { for (let record of records) {
await maybeYield(); await maybeYield();
let record = new this._recordObj();
record.deserialize(json);
let { shouldApply, error } = await this._maybeReconcile(record); let { shouldApply, error } = await this._maybeReconcile(record);
if (error) { if (error) {

43
servo/Cargo.lock сгенерированный
Просмотреть файл

@ -1395,20 +1395,6 @@ dependencies = [
"rayon 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", "rayon 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]]
name = "js"
version = "0.1.6"
source = "git+https://github.com/servo/rust-mozjs#cdb9570900b74cf4e0ba129eeb8bf527cee3ddb5"
dependencies = [
"cmake 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)",
"heapsize 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.23 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"mozjs_sys 0.0.0 (git+https://github.com/servo/mozjs)",
"num-traits 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "jstraceable_derive" name = "jstraceable_derive"
version = "0.0.1" version = "0.0.1"
@ -1680,7 +1666,7 @@ dependencies = [
"cssparser 0.22.0 (registry+https://github.com/rust-lang/crates.io-index)", "cssparser 0.22.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.15.3 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.15.3 (registry+https://github.com/rust-lang/crates.io-index)",
"hashglobe 0.1.0", "hashglobe 0.1.0",
"js 0.1.6 (git+https://github.com/servo/rust-mozjs)", "mozjs 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
"servo_arc 0.0.1", "servo_arc 0.0.1",
"smallbitvec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "smallbitvec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"smallvec 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1828,10 +1814,23 @@ name = "mitochondria"
version = "1.1.2" version = "1.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "mozjs"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cmake 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.23 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"mozjs_sys 0.50.0 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "mozjs_sys" name = "mozjs_sys"
version = "0.0.0" version = "0.50.0"
source = "git+https://github.com/servo/mozjs#424067c8d176bf1ee4c7f90c56916d35542de672" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"libc 0.2.23 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.23 (registry+https://github.com/rust-lang/crates.io-index)",
"libz-sys 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)", "libz-sys 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)",
@ -2532,7 +2531,6 @@ dependencies = [
"hyper_serde 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "hyper_serde 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"image 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", "image 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)",
"ipc-channel 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "ipc-channel 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"js 0.1.6 (git+https://github.com/servo/rust-mozjs)",
"jstraceable_derive 0.0.1", "jstraceable_derive 0.0.1",
"lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.23 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.23 (registry+https://github.com/rust-lang/crates.io-index)",
@ -2543,6 +2541,7 @@ dependencies = [
"mime 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "mime 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
"mime_guess 1.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "mime_guess 1.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
"mitochondria 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "mitochondria 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"mozjs 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
"msg 0.0.1", "msg 0.0.1",
"net_traits 0.0.1", "net_traits 0.0.1",
"nonzero 0.0.1", "nonzero 0.0.1",
@ -3476,7 +3475,7 @@ dependencies = [
[[package]] [[package]]
name = "webrender" name = "webrender"
version = "0.53.1" version = "0.53.1"
source = "git+https://github.com/servo/webrender#24b3fa46ec628e2e07f754d87791114378a842f8" source = "git+https://github.com/servo/webrender#aa74cdfc155d8f5b917332e6ab344fe3253c5a72"
dependencies = [ dependencies = [
"app_units 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", "app_units 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)",
"bincode 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", "bincode 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)",
@ -3503,7 +3502,7 @@ dependencies = [
[[package]] [[package]]
name = "webrender_api" name = "webrender_api"
version = "0.53.1" version = "0.53.1"
source = "git+https://github.com/servo/webrender#24b3fa46ec628e2e07f754d87791114378a842f8" source = "git+https://github.com/servo/webrender#aa74cdfc155d8f5b917332e6ab344fe3253c5a72"
dependencies = [ dependencies = [
"app_units 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", "app_units 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)",
"bincode 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", "bincode 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)",
@ -3776,7 +3775,6 @@ dependencies = [
"checksum jemalloc-sys 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "479294d130502fada93c7a957e8d059b632b03d6204aca37af557dee947f30a9" "checksum jemalloc-sys 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "479294d130502fada93c7a957e8d059b632b03d6204aca37af557dee947f30a9"
"checksum jemallocator 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "28b211ca65c440322b6d4d9b5b850b01e8e298393b7ebcb8205b7cbb14ea6329" "checksum jemallocator 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "28b211ca65c440322b6d4d9b5b850b01e8e298393b7ebcb8205b7cbb14ea6329"
"checksum jpeg-decoder 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2805ccb10ffe4d10e06ef68a158ff94c255211ecbae848fbde2146b098f93ce7" "checksum jpeg-decoder 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2805ccb10ffe4d10e06ef68a158ff94c255211ecbae848fbde2146b098f93ce7"
"checksum js 0.1.6 (git+https://github.com/servo/rust-mozjs)" = "<none>"
"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
"checksum khronos_api 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d5a08e2a31d665af8f1ca437eab6d00a93c9d62a549f73f9ed8fc2e55b5a91a7" "checksum khronos_api 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d5a08e2a31d665af8f1ca437eab6d00a93c9d62a549f73f9ed8fc2e55b5a91a7"
"checksum language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a91d884b6667cd606bb5a69aa0c99ba811a115fc68915e7056ec08a46e93199a" "checksum language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a91d884b6667cd606bb5a69aa0c99ba811a115fc68915e7056ec08a46e93199a"
@ -3802,7 +3800,8 @@ dependencies = [
"checksum mio 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)" = "9e965267d4d58496fc4f740e9861118367f13570cadf66316ed2c3f2f14d87c7" "checksum mio 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)" = "9e965267d4d58496fc4f740e9861118367f13570cadf66316ed2c3f2f14d87c7"
"checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" "checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919"
"checksum mitochondria 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9de3eca27871df31c33b807f834b94ef7d000956f57aa25c5aed9c5f0aae8f6f" "checksum mitochondria 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9de3eca27871df31c33b807f834b94ef7d000956f57aa25c5aed9c5f0aae8f6f"
"checksum mozjs_sys 0.0.0 (git+https://github.com/servo/mozjs)" = "<none>" "checksum mozjs 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "a77c99a22091d3e6f7cd93caaf18bcb9ce5ff0a5d93c45aa73e443a447ab4296"
"checksum mozjs_sys 0.50.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ef1e24df9f76502cd4459919098ec1ac3af75ce694ec5b8837aa91f69f2ad0eb"
"checksum mp3-metadata 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4ab5f1d2693586420208d1200ce5a51cd44726f055b635176188137aff42c7de" "checksum mp3-metadata 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4ab5f1d2693586420208d1200ce5a51cd44726f055b635176188137aff42c7de"
"checksum mp4parse 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7b81651f9ede53d59281b54c7eb51ae50a868ac4765dd3bdfbbc79ce3d8aca7a" "checksum mp4parse 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7b81651f9ede53d59281b54c7eb51ae50a868ac4765dd3bdfbbc79ce3d8aca7a"
"checksum multistr 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "90fb6e1b4f6ca2f2098a437e1c7f09c122da62bbf2bde45b3693defc1eb61e2d" "checksum multistr 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "90fb6e1b4f6ca2f2098a437e1c7f09c122da62bbf2bde45b3693defc1eb61e2d"

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

@ -9,14 +9,14 @@ publish = false
path = "lib.rs" path = "lib.rs"
[features] [features]
servo = ["js", "string_cache", "url", "webrender_api", "xml5ever"] servo = ["mozjs", "string_cache", "url", "webrender_api", "xml5ever"]
[dependencies] [dependencies]
app_units = "0.5.5" app_units = "0.5.5"
cssparser = "0.22.0" cssparser = "0.22.0"
euclid = "0.15" euclid = "0.15"
hashglobe = { path = "../hashglobe" } hashglobe = { path = "../hashglobe" }
js = { git = "https://github.com/servo/rust-mozjs", features = ["promises"], optional = true } mozjs = { version = "0.1.7", features = ["promises"], optional = true }
servo_arc = { path = "../servo_arc" } servo_arc = { path = "../servo_arc" }
smallbitvec = "1.0.3" smallbitvec = "1.0.3"
smallvec = "0.4" smallvec = "0.4"

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

@ -48,7 +48,7 @@ extern crate cssparser;
extern crate euclid; extern crate euclid;
extern crate hashglobe; extern crate hashglobe;
#[cfg(feature = "servo")] #[cfg(feature = "servo")]
extern crate js; extern crate mozjs as js;
extern crate servo_arc; extern crate servo_arc;
extern crate smallbitvec; extern crate smallbitvec;
extern crate smallvec; extern crate smallvec;

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

@ -12,7 +12,7 @@ name = "script"
path = "lib.rs" path = "lib.rs"
[features] [features]
debugmozjs = ['js/debugmozjs'] debugmozjs = ['mozjs/debugmozjs']
unstable = ["servo_allocator/unstable"] unstable = ["servo_allocator/unstable"]
unrooted_must_root_lint = ["script_plugins/unrooted_must_root_lint"] unrooted_must_root_lint = ["script_plugins/unrooted_must_root_lint"]
default = ["unrooted_must_root_lint"] default = ["unrooted_must_root_lint"]
@ -51,7 +51,7 @@ hyper = "0.10"
hyper_serde = "0.7" hyper_serde = "0.7"
image = "0.16" image = "0.16"
ipc-channel = "0.9" ipc-channel = "0.9"
js = {git = "https://github.com/servo/rust-mozjs", features = ["promises"]} mozjs = { version = "0.1.7", features = ["promises"]}
jstraceable_derive = {path = "../jstraceable_derive"} jstraceable_derive = {path = "../jstraceable_derive"}
lazy_static = "0.2" lazy_static = "0.2"
libc = "0.2" libc = "0.2"

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

@ -47,8 +47,6 @@ extern crate hyper_serde;
extern crate image; extern crate image;
extern crate ipc_channel; extern crate ipc_channel;
#[macro_use] #[macro_use]
extern crate js;
#[macro_use]
extern crate jstraceable_derive; extern crate jstraceable_derive;
#[macro_use] #[macro_use]
extern crate lazy_static; extern crate lazy_static;
@ -62,6 +60,8 @@ extern crate metrics;
extern crate mime; extern crate mime;
extern crate mime_guess; extern crate mime_guess;
extern crate mitochondria; extern crate mitochondria;
#[macro_use]
extern crate mozjs as js;
extern crate msg; extern crate msg;
extern crate net_traits; extern crate net_traits;
extern crate nonzero; extern crate nonzero;

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

@ -106,32 +106,25 @@ be applied to every task no matter what. If the template should only be applied
to certain kinds of tasks, this needs to be specified in the template itself to certain kinds of tasks, this needs to be specified in the template itself
using JSON-e `condition statements`_. using JSON-e `condition statements`_.
The context available to the JSON-e render aims to match that of ``actions``. The context available to the JSON-e render contains attributes from the
It looks like this: :py:class:`taskgraph.task.Task` class. It looks like this:
.. parsed-literal:: .. parsed-literal::
{ {
"task": { "attributes": task.attributes,
"payload": { "kind": task.kind,
"env": { ... }, "label": task.label,
... "target_tasks": [<tasks from try_task_config.json>],
} "task": task.task,
"extra": { "taskId": task.task_id,
"treeherder": { ... }, "input": ...
...
},
"tags": { "kind": "<kind>", ... },
...
},
"input": {
"enabled": 1,
...
},
"taskId": "<task id>"
} }
See the `existing templates`_ for examples. The ``input`` context can be any arbitrary value or object. What it contains
depends on each specific template. Templates must return objects that have have
either ``attributes`` or ``task`` as a top level key. All other top level keys
will be ignored. See the `existing templates`_ for examples.
Empty Try Empty Try
::::::::: :::::::::

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

@ -27,3 +27,4 @@ PYTHON_UNITTEST_MANIFESTS += [
'taskgraph/test/python.ini', 'taskgraph/test/python.ini',
] ]
SPHINX_TREES['taskcluster'] = 'docs' SPHINX_TREES['taskcluster'] = 'docs'
SPHINX_PYTHON_PACKAGE_DIRS += ['taskgraph']

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

@ -253,8 +253,9 @@ class apply_jsone_templates(object):
""" """
template_dir = os.path.join(here, 'templates') template_dir = os.path.join(here, 'templates')
def __init__(self, templates): def __init__(self, try_task_config):
self.templates = templates self.templates = try_task_config.get('templates')
self.target_tasks = try_task_config.get('tasks')
def __call__(self, taskgraph, label_to_taskid): def __call__(self, taskgraph, label_to_taskid):
if not self.templates: if not self.templates:
@ -268,12 +269,19 @@ class apply_jsone_templates(object):
'taskId': task.task_id, 'taskId': task.task_id,
'kind': task.kind, 'kind': task.kind,
'input': self.templates[template], 'input': self.templates[template],
# The following context differs from action tasks
'attributes': task.attributes,
'label': task.label,
'target_tasks': self.target_tasks,
} }
template_path = os.path.join(self.template_dir, template + '.yml') template_path = os.path.join(self.template_dir, template + '.yml')
with open(template_path) as f: with open(template_path) as f:
template = yaml.load(f) template = yaml.load(f)
task.task = jsone.render(template, context) result = jsone.render(template, context) or {}
for attr in ('task', 'attributes'):
if attr in result:
setattr(task, attr, result[attr])
return taskgraph, label_to_taskid return taskgraph, label_to_taskid
@ -285,7 +293,7 @@ def morph(taskgraph, label_to_taskid, parameters):
add_s3_uploader_task, add_s3_uploader_task,
] ]
if parameters['try_mode'] == 'try_task_config': if parameters['try_mode'] == 'try_task_config':
morphs.append(apply_jsone_templates(parameters['try_task_config'].get('templates'))) morphs.append(apply_jsone_templates(parameters['try_task_config']))
for m in morphs: for m in morphs:
taskgraph, label_to_taskid = m(taskgraph, label_to_taskid) taskgraph, label_to_taskid = m(taskgraph, label_to_taskid)

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

@ -3,6 +3,7 @@ $if: task["tags"]
then: then:
$if: task.tags["kind"] == "build" $if: task.tags["kind"] == "build"
then: then:
task:
$mergeDeep: $mergeDeep:
- $eval: task - $eval: task
- extra: - extra:
@ -12,7 +13,3 @@ then:
env: env:
USE_ARTIFACT: USE_ARTIFACT:
$eval: input.enabled $eval: input.enabled
else:
$eval: task
else:
$eval: task

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

@ -1,4 +1,5 @@
$mergeDeep: task:
$mergeDeep:
- $eval: task - $eval: task
- payload: - payload:
env: env:

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

@ -0,0 +1,8 @@
---
$if: label in target_tasks
then:
attributes:
$merge:
- $eval: attributes
- task_duplicates:
$eval: input

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

@ -138,7 +138,12 @@ class TestApplyJSONeTemplates(MorphTestCase):
t['label']: Task(**t) for t in self.tasks[:] t['label']: Task(**t) for t in self.tasks[:]
}) })
fn = morph.apply_jsone_templates({'artifact': {'enabled': 1}}) try_task_config = {
'templates': {
'artifact': {'enabled': 1}
},
}
fn = morph.apply_jsone_templates(try_task_config)
morphed = fn(tg, label_to_taskid)[0] morphed = fn(tg, label_to_taskid)[0]
self.assertEqual(len(morphed.tasks), 2) self.assertEqual(len(morphed.tasks), 2)
@ -158,7 +163,15 @@ class TestApplyJSONeTemplates(MorphTestCase):
t['label']: Task(**t) for t in self.tasks[:] t['label']: Task(**t) for t in self.tasks[:]
}) })
fn = morph.apply_jsone_templates({'env': {'ENABLED': 1, 'FOO': 'BAZ'}}) try_task_config = {
'templates': {
'env': {
'ENABLED': 1,
'FOO': 'BAZ',
}
},
}
fn = morph.apply_jsone_templates(try_task_config)
morphed = fn(tg, label_to_taskid)[0] morphed = fn(tg, label_to_taskid)[0]
self.assertEqual(len(morphed.tasks), 2) self.assertEqual(len(morphed.tasks), 2)
@ -167,7 +180,10 @@ class TestApplyJSONeTemplates(MorphTestCase):
self.assertEqual(t.task['payload']['env']['ENABLED'], 1) self.assertEqual(t.task['payload']['env']['ENABLED'], 1)
self.assertEqual(t.task['payload']['env']['FOO'], 'BAZ') self.assertEqual(t.task['payload']['env']['FOO'], 'BAZ')
fn = morph.apply_jsone_templates({'env': {'ENABLED': 0}}) try_task_config['templates']['env'] = {
'ENABLED': 0,
}
fn = morph.apply_jsone_templates(try_task_config)
morphed = fn(tg, label_to_taskid)[0] morphed = fn(tg, label_to_taskid)[0]
self.assertEqual(len(morphed.tasks), 2) self.assertEqual(len(morphed.tasks), 2)
@ -176,6 +192,28 @@ class TestApplyJSONeTemplates(MorphTestCase):
self.assertEqual(t.task['payload']['env']['ENABLED'], 0) self.assertEqual(t.task['payload']['env']['ENABLED'], 0)
self.assertEqual(t.task['payload']['env']['FOO'], 'BAZ') self.assertEqual(t.task['payload']['env']['FOO'], 'BAZ')
def test_template_rebuild(self):
tg, label_to_taskid = self.make_taskgraph({
t['label']: Task(**t) for t in self.tasks[:]
})
try_task_config = {
'tasks': ['b'],
'templates': {
'rebuild': 4,
},
}
fn = morph.apply_jsone_templates(try_task_config)
tasks = fn(tg, label_to_taskid)[0].tasks.values()
self.assertEqual(len(tasks), 2)
for t in tasks:
if t.label == 'a':
self.assertNotIn('task_duplicates', t.attributes)
elif t.label == 'b':
self.assertIn('task_duplicates', t.attributes)
self.assertEqual(t.attributes['task_duplicates'], 4)
if __name__ == '__main__': if __name__ == '__main__':
main() main()

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

@ -1,5 +0,0 @@
[Element-interface-shadowRoot-attribute.html]
type: testharness
[shadowRoot attribute must return null if the shadow root attached to the element is closed]
expected: FAIL

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