Merge autoland to mozilla-central. a=merge

This commit is contained in:
Cristian Tuns 2023-08-28 17:18:28 -04:00
Родитель ddb4ab256d afccc66e1a
Коммит f71f1a118e
58 изменённых файлов: 798 добавлений и 502 удалений

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

@ -5,9 +5,9 @@
[source.crates-io]
replace-with = "vendored-sources"
[source."git+https://github.com/FirefoxGraphics/aa-stroke?rev=c1916bc1b5336438207881a362fc3dd921d915e4"]
[source."git+https://github.com/FirefoxGraphics/aa-stroke?rev=c7bc7190f6d3115bc81640c0433649c1fce9491c"]
git = "https://github.com/FirefoxGraphics/aa-stroke"
rev = "c1916bc1b5336438207881a362fc3dd921d915e4"
rev = "c7bc7190f6d3115bc81640c0433649c1fce9491c"
replace-with = "vendored-sources"
[source."git+https://github.com/FirefoxGraphics/wpf-gpu-raster?rev=5ab6fe33d00021325ee920b3c10526dc8301cf46"]

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

@ -5,7 +5,7 @@ version = 3
[[package]]
name = "aa-stroke"
version = "0.1.0"
source = "git+https://github.com/FirefoxGraphics/aa-stroke?rev=c1916bc1b5336438207881a362fc3dd921d915e4#c1916bc1b5336438207881a362fc3dd921d915e4"
source = "git+https://github.com/FirefoxGraphics/aa-stroke?rev=c7bc7190f6d3115bc81640c0433649c1fce9491c#c7bc7190f6d3115bc81640c0433649c1fce9491c"
dependencies = [
"euclid",
]

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

@ -123,7 +123,7 @@
"win64-aarch64-devedition",
"win64-devedition"
],
"revision": "f278f3c615de9920c58849537f0e448dd055323f"
"revision": "2f60b8ce75258165ed79ea5e99f7e1c727040774"
},
"bg": {
"pin": false,
@ -483,7 +483,7 @@
"win64-aarch64-devedition",
"win64-devedition"
],
"revision": "4cffcde885c5f13af0c2c258506953dd2b50b753"
"revision": "f66d42785447e963964ed39c7b7b299c4dc21d63"
},
"es-CL": {
"pin": false,

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

@ -356,22 +356,24 @@
/* Labeled result menu button */
.urlbarView-results:not([wrap]) > .urlbarView-row > &:not(:empty) {
display: inline-flex;
align-items: center;
border-radius: var(--urlbarView-result-button-size);
padding-inline: 8px 26px;
background-position-x: right 4px;
font-size: var(--urlbarView-small-font-size);
.urlbarView-row > &:not(:empty) {
.urlbarView-results:not([wrap]) > & {
display: inline-flex;
align-items: center;
border-radius: var(--urlbarView-result-button-size);
padding-inline: 8px 26px;
background-position-x: right 4px;
font-size: var(--urlbarView-small-font-size);
&:-moz-locale-dir(rtl) {
background-position-x: left 4px;
&:-moz-locale-dir(rtl) {
background-position-x: left 4px;
}
}
}
.urlbarView-results[wrap] > .urlbarView-row > &:not(:empty) {
/* Hide the label in narrow windows. */
font-size: 0;
.urlbarView-results[wrap] > & {
/* Hide the label in narrow windows. */
font-size: 0;
}
}
}
@ -436,12 +438,20 @@
margin-top: 4px;
}
& > .urlbarView-row-inner {
> .urlbarView-row-inner {
min-height: 32px;
/* Add space between the tip title (and the rest of row-inner) and its
button. */
margin-inline-end: 1.8em;
> .urlbarView-no-wrap > .urlbarView-title-separator,
> .urlbarView-url {
display: none;
}
> .urlbarView-no-wrap > .urlbarView-title {
white-space: normal;
}
}
&:not([tip-type=dismissalAcknowledgment]) > .urlbarView-row-inner > .urlbarView-no-wrap > .urlbarView-favicon {
@ -452,15 +462,6 @@
flex-grow: 0;
}
& > .urlbarView-row-inner > .urlbarView-no-wrap > .urlbarView-title-separator,
& > .urlbarView-row-inner > .urlbarView-url {
display: none;
}
& > .urlbarView-row-inner > .urlbarView-no-wrap > .urlbarView-title {
white-space: normal;
}
&[tip-type=dismissalAcknowledgment] {
padding-block: 6px;
}

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

@ -2,6 +2,6 @@
Performance
===========
The documentation about the new performance took (also known as the Firefox
The documentation about the new performance tool (also known as the Firefox
Profiler) can be found on the `Firefox Profiler website
<https://profiler.firefox.com/docs/>`_.

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

@ -590,8 +590,8 @@ nsIContent* ContentIteratorBase<NodeType>::GetNextSibling(nsINode* aNode) {
return nullptr;
}
if (aNode->GetNextSibling()) {
return aNode->GetNextSibling();
if (nsIContent* next = aNode->GetNextSibling()) {
return next;
}
nsINode* parent = aNode->GetParentNode();
@ -599,15 +599,6 @@ nsIContent* ContentIteratorBase<NodeType>::GetNextSibling(nsINode* aNode) {
return nullptr;
}
// XXX This is a hack to preserve previous behaviour: This should be fixed
// in bug 1404916. If we were positioned on anonymous content, move to
// the first child of our parent.
if (aNode->IsRootOfNativeAnonymousSubtree()) {
if (nsIContent* first = parent->GetFirstChild()) {
return first;
}
}
return ContentIteratorBase::GetNextSibling(parent);
}
@ -619,8 +610,8 @@ nsIContent* ContentIteratorBase<NodeType>::GetPrevSibling(nsINode* aNode) {
return nullptr;
}
if (aNode->GetPreviousSibling()) {
return aNode->GetPreviousSibling();
if (nsIContent* prev = aNode->GetPreviousSibling()) {
return prev;
}
nsINode* parent = aNode->GetParentNode();
@ -628,15 +619,6 @@ nsIContent* ContentIteratorBase<NodeType>::GetPrevSibling(nsINode* aNode) {
return nullptr;
}
// XXX This is a hack to preserve previous behaviour: This should be fixed
// in bug 1404916. If we were positioned on anonymous content, move to
// the last child of our parent.
if (aNode->IsRootOfNativeAnonymousSubtree()) {
if (nsIContent* last = parent->GetLastChild()) {
return last;
}
}
return ContentIteratorBase::GetPrevSibling(parent);
}

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

@ -14433,14 +14433,23 @@ void Document::SetFullscreenRoot(Document* aRoot) {
mFullscreenRoot = do_GetWeakReference(aRoot);
}
void Document::TryCancelDialog() {
// Check if the document is blocked by modal dialog
// https://github.com/whatwg/html/issues/9143
// We need to consider the precedence between active modal dialog, topmost auto
// popover and fullscreen element once it's specified.
void Document::HandleEscKey() {
for (const nsWeakPtr& weakPtr : Reversed(mTopLayer)) {
nsCOMPtr<Element> element(do_QueryReferent(weakPtr));
if (auto* dialog = HTMLDialogElement::FromNodeOrNull(element)) {
dialog->QueueCancelDialog();
break;
}
if (RefPtr<nsGenericHTMLElement> popoverHTMLEl =
nsGenericHTMLElement::FromNodeOrNull(element)) {
if (element->IsAutoPopover() && element->IsPopoverOpen()) {
popoverHTMLEl->HidePopover(IgnoreErrors());
break;
}
}
}
}

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

@ -1878,8 +1878,11 @@ class Document : public nsINode,
// Whether we has pending fullscreen request.
bool HasPendingFullscreenRequests();
// Cancel the dialog element if the document is blocked by the dialog
void TryCancelDialog();
/**
* When Esc key is pressed, cancel the dialog element if the document is
* blocked by the dialog or hide popover if popover is shown.
*/
MOZ_CAN_RUN_SCRIPT void HandleEscKey();
void AddModalDialog(HTMLDialogElement&);
void RemoveModalDialog(HTMLDialogElement&);

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

@ -29,6 +29,7 @@
#include "mozilla/dom/Event.h"
#include "mozilla/dom/EventTargetBinding.h"
#include "mozilla/dom/PopupBlocker.h"
#include "mozilla/dom/RequestBinding.h"
#include "mozilla/dom/ScriptLoader.h"
#include "mozilla/dom/ScriptSettings.h"
#include "mozilla/dom/TouchEvent.h"
@ -1253,7 +1254,8 @@ nsresult EventListenerManager::CompileEventHandlerInternal(
RefPtr<JS::loader::ScriptFetchOptions> fetchOptions =
new JS::loader::ScriptFetchOptions(
CORS_NONE, aElement->OwnerDoc()->GetReferrerPolicy(),
/* aNonce = */ u""_ns, JS::loader::ParserMetadata::NotParserInserted,
/* aNonce = */ u""_ns, RequestPriority::Auto,
JS::loader::ParserMetadata::NotParserInserted,
aElement->OwnerDoc()->NodePrincipal());
RefPtr<JS::loader::EventScript> eventScript =

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

@ -0,0 +1,13 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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 "mozilla/dom/FetchPriority.h"
namespace mozilla::dom {
const char* kFetchPriorityAttributeValueHigh = "high";
const char* kFetchPriorityAttributeValueLow = "low";
const char* kFetchPriorityAttributeValueAuto = "auto";
} // namespace mozilla::dom

23
dom/html/FetchPriority.h Normal file
Просмотреть файл

@ -0,0 +1,23 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_dom_FetchPriority_h
#define mozilla_dom_FetchPriority_h
#include <cstdint>
namespace mozilla::dom {
// <https://html.spec.whatwg.org/multipage/urls-and-fetching.html#fetch-priority-attributes>.
enum class FetchPriority : uint8_t { High, Low, Auto };
extern const char* kFetchPriorityAttributeValueHigh;
extern const char* kFetchPriorityAttributeValueLow;
extern const char* kFetchPriorityAttributeValueAuto;
} // namespace mozilla::dom
#endif // mozilla_dom_FetchPriority_h

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

@ -4,6 +4,9 @@
* 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 "nsAttrValue.h"
#include "nsAttrValueOrString.h"
#include "nsGenericHTMLElement.h"
#include "nsGkAtoms.h"
#include "nsStyleConsts.h"
#include "mozilla/dom/Document.h"
@ -18,8 +21,10 @@
#include "nsDOMJSUtils.h"
#include "nsIScriptError.h"
#include "nsISupportsImpl.h"
#include "mozilla/dom/FetchPriority.h"
#include "mozilla/dom/HTMLScriptElement.h"
#include "mozilla/dom/HTMLScriptElementBinding.h"
#include "mozilla/Assertions.h"
#include "mozilla/StaticPrefs_dom.h"
NS_IMPL_NS_NEW_HTML_ELEMENT_CHECK_PARSER(Script)
@ -58,6 +63,19 @@ nsresult HTMLScriptElement::BindToTree(BindContext& aContext,
return NS_OK;
}
namespace {
// <https://html.spec.whatwg.org/multipage/urls-and-fetching.html#fetch-priority-attributes>.
static const nsAttrValue::EnumTable kFetchPriorityEnumTable[] = {
{kFetchPriorityAttributeValueHigh, FetchPriority::High},
{kFetchPriorityAttributeValueLow, FetchPriority::Low},
{kFetchPriorityAttributeValueAuto, FetchPriority::Auto},
{nullptr, 0}};
// <https://html.spec.whatwg.org/multipage/urls-and-fetching.html#fetch-priority-attributes>.
static const nsAttrValue::EnumTable*
kFetchPriorityEnumTableInvalidValueDefault = &kFetchPriorityEnumTable[2];
} // namespace
bool HTMLScriptElement::ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute,
const nsAString& aValue,
nsIPrincipal* aMaybeScriptedPrincipal,
@ -72,6 +90,11 @@ bool HTMLScriptElement::ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute,
aResult.ParseStringOrAtom(aValue);
return true;
}
if (aAttribute == nsGkAtoms::fetchpriority) {
HTMLScriptElement::ParseFetchPriority(aValue, aResult);
return true;
}
}
return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
@ -202,6 +225,17 @@ CORSMode HTMLScriptElement::GetCORSMode() const {
return AttrValueToCORSMode(GetParsedAttr(nsGkAtoms::crossorigin));
}
FetchPriority HTMLScriptElement::GetFetchPriority() const {
const nsAttrValue* fetchpriorityAttribute =
GetParsedAttr(nsGkAtoms::fetchpriority);
if (fetchpriorityAttribute) {
MOZ_ASSERT(fetchpriorityAttribute->Type() == nsAttrValue::eEnum);
return FetchPriority(fetchpriorityAttribute->GetEnumValue());
}
return FetchPriority::Auto;
}
mozilla::dom::ReferrerPolicy HTMLScriptElement::GetReferrerPolicy() {
return GetReferrerPolicyAsEnum();
}
@ -211,6 +245,20 @@ bool HTMLScriptElement::HasScriptContent() {
nsContentUtils::HasNonEmptyTextContent(this);
}
void HTMLScriptElement::GetFetchPriority(nsAString& aFetchPriority) const {
// <https://html.spec.whatwg.org/multipage/urls-and-fetching.html#fetch-priority-attributes>.
GetEnumAttr(nsGkAtoms::fetchpriority, kFetchPriorityAttributeValueAuto,
aFetchPriority);
}
/* static */
FetchPriority HTMLScriptElement::ToFetchPriority(const nsAString& aValue) {
nsAttrValue attrValue;
HTMLScriptElement::ParseFetchPriority(aValue, attrValue);
MOZ_ASSERT(attrValue.Type() == nsAttrValue::eEnum);
return FetchPriority(attrValue.GetEnumValue());
}
// https://html.spec.whatwg.org/multipage/scripting.html#dom-script-supports
/* static */
bool HTMLScriptElement::Supports(const GlobalObject& aGlobal,
@ -221,4 +269,12 @@ bool HTMLScriptElement::Supports(const GlobalObject& aGlobal,
aType.EqualsLiteral("importmap"));
}
/* static */
void HTMLScriptElement::ParseFetchPriority(const nsAString& aValue,
nsAttrValue& aResult) {
aResult.ParseEnumValue(aValue, kFetchPriorityEnumTable,
false /* aCaseSensitive */,
kFetchPriorityEnumTableInvalidValueDefault);
}
} // namespace mozilla::dom

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

@ -7,9 +7,11 @@
#ifndef mozilla_dom_HTMLScriptElement_h
#define mozilla_dom_HTMLScriptElement_h
#include "mozilla/dom/FetchPriority.h"
#include "nsGenericHTMLElement.h"
#include "mozilla/Attributes.h"
#include "mozilla/dom/ScriptElement.h"
#include "nsStringFwd.h"
namespace mozilla::dom {
@ -34,6 +36,7 @@ class HTMLScriptElement final : public nsGenericHTMLElement,
virtual void GetScriptCharset(nsAString& charset) override;
virtual void FreezeExecutionAttrs(const Document* aOwnerDoc) override;
virtual CORSMode GetCORSMode() const override;
virtual FetchPriority GetFetchPriority() const override;
virtual mozilla::dom::ReferrerPolicy GetReferrerPolicy() override;
// nsIContent
@ -128,6 +131,15 @@ class HTMLScriptElement final : public nsGenericHTMLElement,
GetEnumAttr(nsGkAtoms::referrerpolicy, "", aReferrerPolicy);
}
void GetFetchPriority(nsAString& aFetchPriority) const;
void SetFetchPriority(const nsAString& aFetchPriority) {
SetHTMLAttr(nsGkAtoms::fetchpriority, aFetchPriority);
}
// <https://html.spec.whatwg.org/#fetch-priority-attribute>.
static FetchPriority ToFetchPriority(const nsAString& aValue);
[[nodiscard]] static bool Supports(const GlobalObject& aGlobal,
const nsAString& aType);
@ -144,6 +156,9 @@ class HTMLScriptElement final : public nsGenericHTMLElement,
// ScriptElement
virtual bool HasScriptContent() override;
private:
static void ParseFetchPriority(const nsAString& aValue, nsAttrValue& aResult);
};
} // namespace mozilla::dom

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

@ -43,6 +43,7 @@ EXPORTS.mozilla += [
EXPORTS.mozilla.dom += [
"ConstraintValidation.h",
"ElementInternals.h",
"FetchPriority.h",
"HTMLAllCollection.h",
"HTMLAnchorElement.h",
"HTMLAreaElement.h",
@ -127,6 +128,7 @@ EXPORTS.mozilla.dom += [
UNIFIED_SOURCES += [
"ConstraintValidation.cpp",
"ElementInternals.cpp",
"FetchPriority.cpp",
"HTMLAllCollection.cpp",
"HTMLAnchorElement.cpp",
"HTMLAreaElement.cpp",

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

@ -3447,13 +3447,10 @@ void nsGenericHTMLElement::FocusPreviousElementAfterHidingPopover() {
return;
}
// Run the focusing steps for previouslyFocusedElement if focus is within the
// popover hierarchy.
if (IsShadowIncludingInclusiveDescendantOf(control)) {
FocusOptions options;
options.mPreventScroll = true;
control->Focus(options, CallerType::NonSystem, IgnoreErrors());
}
// Run the focusing steps for previouslyFocusedElement.
FocusOptions options;
options.mPreventScroll = true;
control->Focus(options, CallerType::NonSystem, IgnoreErrors());
}
// https://html.spec.whatwg.org/multipage/popover.html#dom-togglepopover

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

@ -21,6 +21,7 @@
#include "js/loader/ScriptLoadRequest.h"
#include "js/loader/ModuleLoaderBase.h"
#include "js/loader/ModuleLoadRequest.h"
#include "mozilla/dom/RequestBinding.h"
#include "xpcpublic.h"
#include "GeckoProfiler.h"
#include "nsContentSecurityManager.h"
@ -298,8 +299,8 @@ already_AddRefed<ModuleLoadRequest> ModuleLoader::CreateDynamicImport(
// "auto".
options = new ScriptFetchOptions(
mozilla::CORS_NONE, document->GetReferrerPolicy(),
/* aNonce = */ u""_ns, ParserMetadata::NotParserInserted, principal,
nullptr);
/* aNonce = */ u""_ns, RequestPriority::Auto,
ParserMetadata::NotParserInserted, principal, nullptr);
baseURL = document->GetDocBaseURI();
}

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

@ -9,6 +9,10 @@
#include "ScriptTrace.h"
#include "ModuleLoader.h"
#include "mozilla/Assertions.h"
#include "mozilla/dom/FetchPriority.h"
#include "mozilla/dom/HTMLScriptElement.h"
#include "mozilla/dom/RequestBinding.h"
#include "nsIChildChannel.h"
#include "zlib.h"
@ -837,16 +841,34 @@ static bool CSPAllowsInlineScript(nsIScriptElement* aElement,
return NS_SUCCEEDED(rv) && allowInlineScript;
}
namespace {
RequestPriority FetchPriorityToRequestPriority(
const FetchPriority aFetchPriority) {
switch (aFetchPriority) {
case FetchPriority::High:
return RequestPriority::High;
case FetchPriority::Low:
return RequestPriority::Low;
case FetchPriority::Auto:
return RequestPriority::Auto;
}
MOZ_ASSERT_UNREACHABLE();
return RequestPriority::Auto;
}
} // namespace
already_AddRefed<ScriptLoadRequest> ScriptLoader::CreateLoadRequest(
ScriptKind aKind, nsIURI* aURI, nsIScriptElement* aElement,
nsIPrincipal* aTriggeringPrincipal, CORSMode aCORSMode,
const nsAString& aNonce, const SRIMetadata& aIntegrity,
ReferrerPolicy aReferrerPolicy, ParserMetadata aParserMetadata) {
const nsAString& aNonce, RequestPriority aRequestPriority,
const SRIMetadata& aIntegrity, ReferrerPolicy aReferrerPolicy,
ParserMetadata aParserMetadata) {
nsIURI* referrer = mDocument->GetDocumentURIAsReferrer();
nsCOMPtr<Element> domElement = do_QueryInterface(aElement);
RefPtr<ScriptFetchOptions> fetchOptions =
new ScriptFetchOptions(aCORSMode, aReferrerPolicy, aNonce,
aParserMetadata, aTriggeringPrincipal, domElement);
RefPtr<ScriptFetchOptions> fetchOptions = new ScriptFetchOptions(
aCORSMode, aReferrerPolicy, aNonce, aRequestPriority, aParserMetadata,
aTriggeringPrincipal, domElement);
RefPtr<ScriptLoadContext> context = new ScriptLoadContext();
if (aKind == ScriptKind::eClassic || aKind == ScriptKind::eImportMap) {
@ -1021,12 +1043,14 @@ bool ScriptLoader::ProcessExternalScript(nsIScriptElement* aElement,
}
CORSMode ourCORSMode = aElement->GetCORSMode();
const FetchPriority fetchPriority = aElement->GetFetchPriority();
ReferrerPolicy referrerPolicy = GetReferrerPolicy(aElement);
ParserMetadata parserMetadata = GetParserMetadata(aElement);
request = CreateLoadRequest(aScriptKind, scriptURI, aElement, principal,
ourCORSMode, nonce, sriMetadata, referrerPolicy,
parserMetadata);
ourCORSMode, nonce,
FetchPriorityToRequestPriority(fetchPriority),
sriMetadata, referrerPolicy, parserMetadata);
request->GetScriptLoadContext()->mIsInline = false;
request->GetScriptLoadContext()->SetScriptMode(
aElement->GetScriptDeferred(), aElement->GetScriptAsync(), false);
@ -1193,12 +1217,18 @@ bool ScriptLoader::ProcessInlineScript(nsIScriptElement* aElement,
if (aScriptKind == ScriptKind::eModule) {
corsMode = aElement->GetCORSMode();
}
// <https://html.spec.whatwg.org/multipage/scripting.html#prepare-the-script-element>
// step 29 specifies to use the fetch priority. Presumably it has no effect
// for inline scripts.
const auto fetchPriority = aElement->GetFetchPriority();
ReferrerPolicy referrerPolicy = GetReferrerPolicy(aElement);
ParserMetadata parserMetadata = GetParserMetadata(aElement);
RefPtr<ScriptLoadRequest> request =
CreateLoadRequest(aScriptKind, mDocument->GetDocumentURI(), aElement,
mDocument->NodePrincipal(), corsMode, nonce,
FetchPriorityToRequestPriority(fetchPriority),
SRIMetadata(), // SRI doesn't apply
referrerPolicy, parserMetadata);
request->GetScriptLoadContext()->mIsInline = true;
@ -3547,8 +3577,9 @@ void ScriptLoader::ParsingComplete(bool aTerminated) {
void ScriptLoader::PreloadURI(
nsIURI* aURI, const nsAString& aCharset, const nsAString& aType,
const nsAString& aCrossOrigin, const nsAString& aNonce,
const nsAString& aIntegrity, bool aScriptFromHead, bool aAsync, bool aDefer,
bool aNoModule, bool aLinkPreload, const ReferrerPolicy aReferrerPolicy,
const nsAString& aFetchPriority, const nsAString& aIntegrity,
bool aScriptFromHead, bool aAsync, bool aDefer, bool aNoModule,
bool aLinkPreload, const ReferrerPolicy aReferrerPolicy,
uint64_t aEarlyHintPreloaderId) {
NS_ENSURE_TRUE_VOID(mDocument);
// Check to see if scripts has been turned off.
@ -3580,6 +3611,9 @@ void ScriptLoader::PreloadURI(
SRIMetadata sriMetadata;
GetSRIMetadata(aIntegrity, &sriMetadata);
const auto requestPriority = FetchPriorityToRequestPriority(
HTMLScriptElement::ToFetchPriority(aFetchPriority));
// For link type "modulepreload":
// https://html.spec.whatwg.org/multipage/links.html#link-type-modulepreload
// Step 11. Let options be a script fetch options whose cryptographic nonce is
@ -3593,7 +3627,7 @@ void ScriptLoader::PreloadURI(
RefPtr<ScriptLoadRequest> request =
CreateLoadRequest(scriptKind, aURI, nullptr, mDocument->NodePrincipal(),
Element::StringToCORSMode(aCrossOrigin), aNonce,
sriMetadata, aReferrerPolicy,
requestPriority, sriMetadata, aReferrerPolicy,
aLinkPreload ? ParserMetadata::NotParserInserted
: ParserMetadata::ParserInserted);
request->GetScriptLoadContext()->mIsInline = false;

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

@ -79,6 +79,7 @@ class ScriptLoader;
class ScriptRequestProcessor;
enum class ReferrerPolicy : uint8_t;
enum class RequestPriority : uint8_t;
class AsyncCompileShutdownObserver final : public nsIObserver {
~AsyncCompileShutdownObserver() { Unregister(); }
@ -373,14 +374,19 @@ class ScriptLoader final : public JS::loader::ScriptLoaderInterface {
* @param aType The type parameter for the script.
* @param aCrossOrigin The crossorigin attribute for the script.
* Void if not present.
* @param aFetchPriority
* <https://html.spec.whatwg.org/#the-script-element:attr-script-fetchpriority>.
* @param aIntegrity The expect hash url, if avail, of the request
* @param aScriptFromHead Whether or not the script was a child of head
*/
virtual void PreloadURI(nsIURI* aURI, const nsAString& aCharset,
const nsAString& aType, const nsAString& aCrossOrigin,
const nsAString& aNonce, const nsAString& aIntegrity,
bool aScriptFromHead, bool aAsync, bool aDefer,
bool aNoModule, bool aLinkPreload,
const nsAString& aNonce,
const nsAString& aFetchPriority,
const nsAString& aIntegrity, bool aScriptFromHead,
bool aAsync, bool aDefer, bool aNoModule,
bool aLinkPreload,
const ReferrerPolicy aReferrerPolicy,
uint64_t aEarlyHintPreloaderId);
@ -429,8 +435,8 @@ class ScriptLoader final : public JS::loader::ScriptLoaderInterface {
already_AddRefed<ScriptLoadRequest> CreateLoadRequest(
ScriptKind aKind, nsIURI* aURI, nsIScriptElement* aElement,
nsIPrincipal* aTriggeringPrincipal, mozilla::CORSMode aCORSMode,
const nsAString& aNonce, const SRIMetadata& aIntegrity,
ReferrerPolicy aReferrerPolicy,
const nsAString& aNonce, RequestPriority aRequestPriority,
const SRIMetadata& aIntegrity, ReferrerPolicy aReferrerPolicy,
JS::loader::ParserMetadata aParserMetadata);
/**

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

@ -29,6 +29,7 @@ class nsIURI;
namespace mozilla::dom {
class Document;
enum class FetchPriority : uint8_t;
enum class ReferrerPolicy : uint8_t;
} // namespace mozilla::dom
@ -236,6 +237,13 @@ class nsIScriptElement : public nsIScriptLoaderObserver {
return mozilla::CORS_NONE;
}
/**
* Get the fetch priority
* (https://html.spec.whatwg.org/multipage/scripting.html#attr-script-fetchpriority)
* of the script element.
*/
virtual mozilla::dom::FetchPriority GetFetchPriority() const = 0;
/**
* Get referrer policy of the script element
*/

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

@ -6,6 +6,7 @@
#include "mozilla/dom/SVGScriptElement.h"
#include "mozilla/dom/FetchPriority.h"
#include "nsGkAtoms.h"
#include "nsNetUtil.h"
#include "nsContentUtils.h"
@ -214,4 +215,9 @@ CORSMode SVGScriptElement::GetCORSMode() const {
return AttrValueToCORSMode(GetParsedAttr(nsGkAtoms::crossorigin));
}
FetchPriority SVGScriptElement::GetFetchPriority() const {
// <https://github.com/w3c/svgwg/issues/916>.
return FetchPriority::Auto;
}
} // namespace mozilla::dom

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

@ -43,6 +43,7 @@ class SVGScriptElement final : public SVGScriptElementBase,
void GetScriptCharset(nsAString& charset) override;
void FreezeExecutionAttrs(const Document* aOwnerDoc) override;
CORSMode GetCORSMode() const override;
FetchPriority GetFetchPriority() const override;
// ScriptElement
bool HasScriptContent() override;

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

@ -30,6 +30,8 @@ interface HTMLScriptElement : HTMLElement {
attribute DOMString referrerPolicy;
[CEReactions, Throws]
attribute DOMString text;
[Pref="network.fetchpriority.enabled", CEReactions]
attribute DOMString fetchPriority;
static boolean supports(DOMString type);
};

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

@ -46,6 +46,7 @@ interface Request {
};
Request includes Body;
// <https://fetch.spec.whatwg.org/#requestinit>.
dictionary RequestInit {
ByteString method;
HeadersInit headers;
@ -78,3 +79,4 @@ enum RequestMode { "same-origin", "no-cors", "cors", "navigate" };
enum RequestCredentials { "omit", "same-origin", "include" };
enum RequestCache { "default", "no-store", "reload", "no-cache", "force-cache", "only-if-cached" };
enum RequestRedirect { "follow", "error", "manual" };
enum RequestPriority { "high" , "low" , "auto" };

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

@ -9,6 +9,7 @@
#include <algorithm>
#include <type_traits>
#include "mozilla/dom/RequestBinding.h"
#include "nsIChannel.h"
#include "nsIContentPolicy.h"
#include "nsIContentSecurityPolicy.h"
@ -645,7 +646,7 @@ already_AddRefed<ScriptLoadRequest> WorkerScriptLoader::CreateScriptLoadRequest(
// policy is the empty string, and fetch priority is "auto".
RefPtr<ScriptFetchOptions> fetchOptions = new ScriptFetchOptions(
CORSMode::CORS_NONE, referrerPolicy, /* aNonce = */ u""_ns,
ParserMetadata::NotParserInserted, nullptr);
RequestPriority::Auto, ParserMetadata::NotParserInserted, nullptr);
RefPtr<ScriptLoadRequest> request = nullptr;
// Bug 1817259 - For now the debugger scripts are always loaded a Classic.

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

@ -6,6 +6,7 @@
#include "js/experimental/JSStencil.h" // JS::Stencil, JS::CompileModuleScriptToStencil, JS::InstantiateModuleStencil
#include "js/loader/ModuleLoadRequest.h"
#include "mozilla/dom/RequestBinding.h"
#include "mozilla/dom/WorkerLoadContext.h"
#include "mozilla/dom/WorkerPrivate.h"
#include "mozilla/dom/workerinternals/ScriptLoader.h"
@ -117,8 +118,8 @@ already_AddRefed<ModuleLoadRequest> WorkerModuleLoader::CreateDynamicImport(
ReferrerPolicy referrerPolicy = workerPrivate->GetReferrerPolicy();
options = new ScriptFetchOptions(
CORSMode::CORS_NONE, referrerPolicy,
/* aNonce = */ u""_ns, JS::loader::ParserMetadata::NotParserInserted,
nullptr);
/* aNonce = */ u""_ns, RequestPriority::Auto,
JS::loader::ParserMetadata::NotParserInserted, nullptr);
baseURL = GetBaseURI();
}

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

@ -9,6 +9,7 @@
#include "mozilla/dom/Document.h"
#include "mozilla/dom/Fetch.h"
#include "mozilla/dom/Request.h"
#include "mozilla/dom/RequestBinding.h"
#include "mozilla/dom/Response.h"
#include "mozilla/dom/RootedDictionary.h"
#include "mozilla/dom/ScriptLoader.h"
@ -94,7 +95,7 @@ NS_IMETHODIMP StartModuleLoadRunnable::RunOnWorkletThread() {
// policy is the empty string, and fetch priority is "auto".
RefPtr<ScriptFetchOptions> fetchOptions = new ScriptFetchOptions(
CORSMode::CORS_NONE, ReferrerPolicy::_empty, /* aNonce = */ u""_ns,
ParserMetadata::NotParserInserted,
RequestPriority::Auto, ParserMetadata::NotParserInserted,
/*triggeringPrincipal*/ nullptr);
WorkletModuleLoader* moduleLoader =

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

@ -37,11 +37,13 @@ NS_IMPL_CYCLE_COLLECTION(ScriptFetchOptions, mTriggeringPrincipal, mElement)
ScriptFetchOptions::ScriptFetchOptions(
mozilla::CORSMode aCORSMode, mozilla::dom::ReferrerPolicy aReferrerPolicy,
const nsAString& aNonce, const ParserMetadata aParserMetadata,
nsIPrincipal* aTriggeringPrincipal, mozilla::dom::Element* aElement)
const nsAString& aNonce, mozilla::dom::RequestPriority aFetchPriority,
const ParserMetadata aParserMetadata, nsIPrincipal* aTriggeringPrincipal,
mozilla::dom::Element* aElement)
: mCORSMode(aCORSMode),
mReferrerPolicy(aReferrerPolicy),
mNonce(aNonce),
mFetchPriority(aFetchPriority),
mParserMetadata(aParserMetadata),
mTriggeringPrincipal(aTriggeringPrincipal),
mElement(aElement) {}

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

@ -37,6 +37,7 @@ namespace mozilla::dom {
class ScriptLoadContext;
class WorkerLoadContext;
class WorkletLoadContext;
enum class RequestPriority : uint8_t;
} // namespace mozilla::dom
@ -88,6 +89,7 @@ class ScriptFetchOptions {
ScriptFetchOptions(mozilla::CORSMode aCORSMode,
enum mozilla::dom::ReferrerPolicy aReferrerPolicy,
const nsAString& aNonce,
mozilla::dom::RequestPriority aFetchPriority,
const ParserMetadata aParserMetadata,
nsIPrincipal* aTriggeringPrincipal,
mozilla::dom::Element* aElement = nullptr);
@ -111,6 +113,11 @@ class ScriptFetchOptions {
*/
const nsString mNonce;
/*
* <https://html.spec.whatwg.org/multipage/webappapis.html#script-fetch-options>.
*/
const mozilla::dom::RequestPriority mFetchPriority;
/*
* The parser metadata used for the initial fetch and for fetching any
* imported modules
@ -288,6 +295,10 @@ class ScriptLoadRequest
: ScriptText<Utf8Unit>().clearAndFree();
}
mozilla::dom::RequestPriority FetchPriority() const {
return mFetchOptions->mFetchPriority;
}
enum mozilla::dom::ReferrerPolicy ReferrerPolicy() const {
return mFetchOptions->mReferrerPolicy;
}

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

@ -4,6 +4,7 @@
* 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 "ScriptLoadRequest.h"
#include "mozilla/Attributes.h"
#include "mozilla/ArrayUtils.h" // mozilla::ArrayLength
#include "mozilla/Utf8.h" // mozilla::Utf8Unit
@ -11,6 +12,7 @@
#include <cstdarg>
#include "mozilla/Logging.h"
#include "mozilla/dom/RequestBinding.h"
#ifdef ANDROID
# include <android/log.h>
#endif
@ -1804,9 +1806,10 @@ nsresult mozJSModuleLoader::ImportESModule(
mModuleLoader->GetGlobalObject()->PrincipalOrNull();
MOZ_ASSERT(principal);
RefPtr<ScriptFetchOptions> options = new ScriptFetchOptions(
CORS_NONE, dom::ReferrerPolicy::No_referrer,
/* aNonce = */ u""_ns, ParserMetadata::NotParserInserted, principal);
RefPtr<ScriptFetchOptions> options =
new ScriptFetchOptions(CORS_NONE, dom::ReferrerPolicy::No_referrer,
/* aNonce = */ u""_ns, dom::RequestPriority::Auto,
ParserMetadata::NotParserInserted, principal);
RefPtr<ComponentLoadContext> context = new ComponentLoadContext();
context->mSkipCheck = aSkipCheck;

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

@ -78,7 +78,7 @@ class mozJSModuleLoader final : public nsIMemoryReporter {
JS::MutableHandleObject aModuleExports,
bool aIgnoreExports = false);
// Load an ES6 module and all its dependencies.
// Synchronously load an ES6 module and all its dependencies.
nsresult ImportESModule(
JSContext* aCx, const nsACString& aResourceURI,
JS::MutableHandleObject aModuleNamespace,

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

@ -8371,8 +8371,8 @@ void PresShell::EventHandler::FinalizeHandlingEvent(WidgetEvent* aEvent) {
}
if (aEvent->mMessage == eKeyDown &&
!aEvent->mFlags.mDefaultPrevented) {
if (Document* doc = GetDocument()) {
doc->TryCancelDialog();
if (RefPtr<Document> doc = GetDocument()) {
doc->HandleEscKey();
}
}
}

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

@ -2762,7 +2762,7 @@ class PresShell final : public nsStubDocumentObserver,
*
* @param aEvent The handled event.
*/
void FinalizeHandlingEvent(WidgetEvent* aEvent);
MOZ_CAN_RUN_SCRIPT void FinalizeHandlingEvent(WidgetEvent* aEvent);
/**
* AutoCurrentEventInfoSetter() pushes and pops current event info of

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

@ -11660,6 +11660,13 @@
value: false
mirror: always
# Indicates whether the `fetchpriority` attribute for elements which support it
# (e.g. `<script>`) is enabled.
- name: network.fetchpriority.enabled
type: bool
value: false
mirror: always
# Enables `<link rel="preconnect">` tag and `Link: rel=preconnect` response header
# handling.
- name: network.preconnect

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

@ -6719,7 +6719,7 @@ org.zw
// newGTLDs
// List of new gTLDs imported from https://www.icann.org/resources/registries/gtlds/v2/gtlds.json on 2023-08-23T15:12:42Z
// List of new gTLDs imported from https://www.icann.org/resources/registries/gtlds/v2/gtlds.json on 2023-08-26T15:11:08Z
// This list is auto-generated, don't edit it manually.
// aaa : American Automobile Association, Inc.
// https://www.iana.org/domains/root/db/aaa.html
@ -9401,7 +9401,7 @@ nyc
// https://www.iana.org/domains/root/db/obi.html
obi
// observer : Dog Beach, LLC
// observer : Fegistry, LLC
// https://www.iana.org/domains/root/db/observer.html
observer

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

@ -63,33 +63,33 @@ void nsHtml5SpeculativeLoad::Perform(nsHtml5TreeOpExecutor* aExecutor) {
aExecutor->PreloadScript(
mUrlOrSizes, mCharsetOrSrcset,
mTypeOrCharsetSourceOrDocumentModeOrMetaCSPOrSizesOrIntegrity,
mCrossOrigin, mMedia, mNonce, mReferrerPolicyOrIntegrity,
mScriptReferrerPolicy, false, mIsAsync, mIsDefer, false,
mIsLinkPreload);
mCrossOrigin, mMedia, mNonce, mFetchPriority,
mReferrerPolicyOrIntegrity, mScriptReferrerPolicy, false, mIsAsync,
mIsDefer, false, mIsLinkPreload);
break;
case eSpeculativeLoadScriptFromHead:
aExecutor->PreloadScript(
mUrlOrSizes, mCharsetOrSrcset,
mTypeOrCharsetSourceOrDocumentModeOrMetaCSPOrSizesOrIntegrity,
mCrossOrigin, mMedia, mNonce, mReferrerPolicyOrIntegrity,
mScriptReferrerPolicy, true, mIsAsync, mIsDefer, false,
mIsLinkPreload);
mCrossOrigin, mMedia, mNonce, mFetchPriority,
mReferrerPolicyOrIntegrity, mScriptReferrerPolicy, true, mIsAsync,
mIsDefer, false, mIsLinkPreload);
break;
case eSpeculativeLoadNoModuleScript:
aExecutor->PreloadScript(
mUrlOrSizes, mCharsetOrSrcset,
mTypeOrCharsetSourceOrDocumentModeOrMetaCSPOrSizesOrIntegrity,
mCrossOrigin, mMedia, mNonce, mReferrerPolicyOrIntegrity,
mScriptReferrerPolicy, false, mIsAsync, mIsDefer, true,
mIsLinkPreload);
mCrossOrigin, mMedia, mNonce, mFetchPriority,
mReferrerPolicyOrIntegrity, mScriptReferrerPolicy, false, mIsAsync,
mIsDefer, true, mIsLinkPreload);
break;
case eSpeculativeLoadNoModuleScriptFromHead:
aExecutor->PreloadScript(
mUrlOrSizes, mCharsetOrSrcset,
mTypeOrCharsetSourceOrDocumentModeOrMetaCSPOrSizesOrIntegrity,
mCrossOrigin, mMedia, mNonce, mReferrerPolicyOrIntegrity,
mScriptReferrerPolicy, true, mIsAsync, mIsDefer, true,
mIsLinkPreload);
mCrossOrigin, mMedia, mNonce, mFetchPriority,
mReferrerPolicyOrIntegrity, mScriptReferrerPolicy, true, mIsAsync,
mIsDefer, true, mIsLinkPreload);
break;
case eSpeculativeLoadStyle:
aExecutor->PreloadStyle(

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

@ -169,7 +169,7 @@ class nsHtml5SpeculativeLoad {
inline void InitScript(nsHtml5String aUrl, nsHtml5String aCharset,
nsHtml5String aType, nsHtml5String aCrossOrigin,
nsHtml5String aMedia, nsHtml5String aNonce,
nsHtml5String aIntegrity,
nsHtml5String aFetchPriority, nsHtml5String aIntegrity,
nsHtml5String aReferrerPolicy, bool aParserInHead,
bool aAsync, bool aDefer, bool aNoModule,
bool aLinkPreload) {
@ -189,6 +189,7 @@ class nsHtml5SpeculativeLoad {
aCrossOrigin.ToString(mCrossOrigin);
aMedia.ToString(mMedia);
aNonce.ToString(mNonce);
aFetchPriority.ToString(mFetchPriority);
aIntegrity.ToString(mReferrerPolicyOrIntegrity);
nsAutoString referrerPolicy;
aReferrerPolicy.ToString(referrerPolicy);
@ -415,6 +416,12 @@ class nsHtml5SpeculativeLoad {
* of the "nonce" attribute.
*/
nsString mNonce;
/**
* If mOpCode is eSpeculativeLoadNoModuleScript[FromHead] or
* eSpeculativeLoadScript[FromHead] this represents the value of the
* "fetchpriority" attribute.
*/
nsString mFetchPriority;
/**
* If mOpCode is eSpeculativeLoadScript[FromHead] this represents the value
* of the "referrerpolicy" attribute. This field holds one of the values

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

@ -6,7 +6,10 @@
#include "ErrorList.h"
#include "nsError.h"
#include "nsHtml5AttributeName.h"
#include "nsHtml5String.h"
#include "nsNetUtil.h"
#include "mozilla/dom/FetchPriority.h"
#include "mozilla/CheckedInt.h"
#include "mozilla/Likely.h"
#include "mozilla/StaticPrefs_dom.h"
@ -250,6 +253,8 @@ nsIContentHandle* nsHtml5TreeBuilder::createElement(
aAttributes->getValue(nsHtml5AttributeName::ATTR_CROSSORIGIN);
nsHtml5String nonce =
aAttributes->getValue(nsHtml5AttributeName::ATTR_NONCE);
nsHtml5String fetchPriority =
aAttributes->getValue(nsHtml5AttributeName::ATTR_FETCHPRIORITY);
nsHtml5String integrity =
aAttributes->getValue(nsHtml5AttributeName::ATTR_INTEGRITY);
nsHtml5String referrerPolicy = aAttributes->getValue(
@ -262,8 +267,9 @@ nsIContentHandle* nsHtml5TreeBuilder::createElement(
aAttributes->contains(nsHtml5AttributeName::ATTR_NOMODULE);
mSpeculativeLoadQueue.AppendElement()->InitScript(
url, charset, type, crossOrigin, /* aMedia = */ nullptr, nonce,
integrity, referrerPolicy, mode == nsHtml5TreeBuilder::IN_HEAD,
async, defer, noModule, false);
fetchPriority, integrity, referrerPolicy,
mode == nsHtml5TreeBuilder::IN_HEAD, async, defer, noModule,
false);
mCurrentHtmlScriptIsAsyncOrDefer = async || defer;
}
} else if (nsGkAtoms::link == aName) {
@ -330,8 +336,17 @@ nsIContentHandle* nsHtml5TreeBuilder::createElement(
if (as.LowerCaseEqualsASCII("script")) {
nsHtml5String type =
aAttributes->getValue(nsHtml5AttributeName::ATTR_TYPE);
// Bug 1839315: get the attribute's value instead.
// Use the empty string and rely on the
// "invalid value default" state being used later.
// Compared to using a non-empty string, this doesn't
// require calling `Release()` for the string.
nsHtml5String fetchPriority = nsHtml5String::EmptyString();
mSpeculativeLoadQueue.AppendElement()->InitScript(
url, charset, type, crossOrigin, media, nonce, integrity,
url, charset, type, crossOrigin, media, nonce,
/* aFetchPriority */ fetchPriority, integrity,
referrerPolicy, mode == nsHtml5TreeBuilder::IN_HEAD,
false, false, false, true);
} else if (as.LowerCaseEqualsASCII("style")) {
@ -381,8 +396,17 @@ nsIContentHandle* nsHtml5TreeBuilder::createElement(
nsHtml5AttributeName::ATTR_INTEGRITY);
nsHtml5String referrerPolicy = aAttributes->getValue(
nsHtml5AttributeName::ATTR_REFERRERPOLICY);
// Bug 1839315: get the attribute's value instead.
// Use the empty string and rely on the
// "invalid value default" state being used later.
// Compared to using a non-empty string, this doesn't
// require calling `Release()` for the string.
nsHtml5String fetchPriority = nsHtml5String::EmptyString();
mSpeculativeLoadQueue.AppendElement()->InitScript(
url, charset, type, crossOrigin, media, nonce, integrity,
url, charset, type, crossOrigin, media, nonce,
/* aFetchPriority */ fetchPriority, integrity,
referrerPolicy, mode == nsHtml5TreeBuilder::IN_HEAD,
false, false, false, true);
}
@ -481,10 +505,20 @@ nsIContentHandle* nsHtml5TreeBuilder::createElement(
aAttributes->getValue(nsHtml5AttributeName::ATTR_INTEGRITY);
nsHtml5String referrerPolicy = aAttributes->getValue(
nsHtml5AttributeName::ATTR_REFERRERPOLICY);
// Bug 1847712: SVG's `<script>` element doesn't support
// `fetchpriority` yet.
// Use the empty string and rely on the
// "invalid value default" state being used later.
// Compared to using a non-empty string, this doesn't
// require calling `Release()` for the string.
nsHtml5String fetchPriority = nsHtml5String::EmptyString();
mSpeculativeLoadQueue.AppendElement()->InitScript(
url, nullptr, type, crossOrigin, /* aMedia = */ nullptr, nonce,
integrity, referrerPolicy, mode == nsHtml5TreeBuilder::IN_HEAD,
false, false, false, false);
fetchPriority, integrity, referrerPolicy,
mode == nsHtml5TreeBuilder::IN_HEAD, false, false, false,
false);
}
} else if (nsGkAtoms::style == aName) {
mImportScanner.Start();

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

@ -1205,9 +1205,10 @@ dom::ReferrerPolicy nsHtml5TreeOpExecutor::GetPreloadReferrerPolicy(
void nsHtml5TreeOpExecutor::PreloadScript(
const nsAString& aURL, const nsAString& aCharset, const nsAString& aType,
const nsAString& aCrossOrigin, const nsAString& aMedia,
const nsAString& aNonce, const nsAString& aIntegrity,
dom::ReferrerPolicy aReferrerPolicy, bool aScriptFromHead, bool aAsync,
bool aDefer, bool aNoModule, bool aLinkPreload) {
const nsAString& aNonce, const nsAString& aFetchPriority,
const nsAString& aIntegrity, dom::ReferrerPolicy aReferrerPolicy,
bool aScriptFromHead, bool aAsync, bool aDefer, bool aNoModule,
bool aLinkPreload) {
nsCOMPtr<nsIURI> uri = ConvertIfNotPreloadedYetAndMediaApplies(aURL, aMedia);
if (!uri) {
return;
@ -1217,8 +1218,8 @@ void nsHtml5TreeOpExecutor::PreloadScript(
return;
}
mDocument->ScriptLoader()->PreloadURI(
uri, aCharset, aType, aCrossOrigin, aNonce, aIntegrity, aScriptFromHead,
aAsync, aDefer, aNoModule, aLinkPreload,
uri, aCharset, aType, aCrossOrigin, aNonce, aFetchPriority, aIntegrity,
aScriptFromHead, aAsync, aDefer, aNoModule, aLinkPreload,
GetPreloadReferrerPolicy(aReferrerPolicy), 0);
}

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

@ -246,6 +246,7 @@ class nsHtml5TreeOpExecutor final
void PreloadScript(const nsAString& aURL, const nsAString& aCharset,
const nsAString& aType, const nsAString& aCrossOrigin,
const nsAString& aMedia, const nsAString& aNonce,
const nsAString& aFetchPriority,
const nsAString& aIntegrity,
ReferrerPolicy aReferrerPolicy, bool aScriptFromHead,
bool aAsync, bool aDefer, bool aNoModule,

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

@ -42,16 +42,16 @@ if (Services.appinfo.processType != Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT) {
// Preferences for remote control and automation can be set from several entry
// points:
// - remote/shared/RecommendedPreferences.sys.mjs
// - remote/test/puppeteer/src/node/FirefoxLauncher.ts
// - remote/test/puppeteer/packages/browsers/src/browser-data/firefox.ts
// - testing/geckodriver/src/prefs.rs
// - testing/marionette/client/marionette_driver/geckoinstance.py
//
// The preferences in `FirefoxLauncher.ts`, `prefs.rs` and `geckoinstance.py`
// will be applied before the Application starts, and should typically be used
// for preferences which cannot be updated during the lifetime of the Application.
// The preferences in `firefox.ts`, `prefs.rs` and `geckoinstance.py`
// will be applied before the application starts, and should typically be used
// for preferences which cannot be updated during the lifetime of the application.
//
// The preferences in `RecommendedPreferences.sys.mjs` are applied after
// the Application has started, which means that the application must apply this
// the application has started, which means that the application must apply this
// change dynamically and behave correctly. Note that you can also define
// protocol specific preferences (CDP, WebDriver, ...) which are merged with the
// COMMON_PREFERENCES from `RecommendedPreferences.sys.mjs`.
@ -115,15 +115,19 @@ const COMMON_PREFERENCES = new Map([
// thumbnails in general cannot hurt
["browser.pagethumbnails.capturing_disabled", true],
// Disable geolocation ping(#1)
["browser.region.network.url", ""],
// Disable safebrowsing components.
//
// These should also be set in the profile prior to starting Firefox,
// as it is picked up at runtime.
["browser.safebrowsing.blockedURIs.enabled", false],
["browser.safebrowsing.downloads.enabled", false],
["browser.safebrowsing.passwords.enabled", false],
["browser.safebrowsing.malware.enabled", false],
["browser.safebrowsing.passwords.enabled", false],
["browser.safebrowsing.phishing.enabled", false],
["browser.safebrowsing.update.enabled", false],
// Disable updates to search engines.
//
@ -170,11 +174,6 @@ const COMMON_PREFERENCES = new Map([
// Disable first run splash page on Windows 10
["browser.usedOnWindows10.introURL", ""],
// Disable the UI tour.
//
// Should be set in profile.
["browser.uitour.enabled", false],
// Turn off Merino suggestions in the location bar so as not to trigger
// network connections.
["browser.urlbar.merino.endpointURL", ""],
@ -186,6 +185,9 @@ const COMMON_PREFERENCES = new Map([
// Do not warn on quitting Firefox
["browser.warnOnQuit", false],
// Disable captive portal
["captivedetect.canonicalURL", ""],
// Do not show datareporting policy notifications which can
// interfere with tests
[
@ -246,12 +248,46 @@ const COMMON_PREFERENCES = new Map([
// Make sure opening about:addons will not hit the network
["extensions.getAddons.discovery.api_url", "data:, "],
// Redirect various extension update URLs
[
"extensions.blocklist.detailsURL",
"http://%(server)s/extensions-dummy/blocklistDetailsURL",
],
[
"extensions.blocklist.itemURL",
"http://%(server)s/extensions-dummy/blocklistItemURL",
],
["extensions.hotfix.url", "http://%(server)s/extensions-dummy/hotfixURL"],
[
"extensions.systemAddon.update.url",
"http://%(server)s/dummy-system-addons.xml",
],
[
"extensions.update.background.url",
"http://%(server)s/extensions-dummy/updateBackgroundURL",
],
["extensions.update.url", "http://%(server)s/extensions-dummy/updateURL"],
// Make sure opening about: addons won't hit the network
["extensions.getAddons.discovery.api_url", "data:, "],
[
"extensions.getAddons.get.url",
"http://%(server)s/extensions-dummy/repositoryGetURL",
],
[
"extensions.getAddons.search.browseURL",
"http://%(server)s/extensions-dummy/repositoryBrowseURL",
],
// Allow the application to have focus even it runs in the background
["focusmanager.testmode", true],
// Disable useragent updates
["general.useragent.updates.enabled", false],
// Disable geolocation ping(#2)
["geo.provider.network.url", ""],
// Always use network provider for geolocation tests so we bypass the
// macOS dialog raised by the corelocation provider
["geo.provider.testing", true],
@ -259,6 +295,12 @@ const COMMON_PREFERENCES = new Map([
// Do not scan Wifi
["geo.wifi.scan", false],
// Disable Firefox accounts ping
["identity.fxaccounts.auth.uri", "https://{server}/dummy/fxa"],
// Disable connectivity service pings
["network.connectivity-service.enabled", false],
// Do not prompt with long usernames or passwords in URLs
["network.http.phishy-userpass-length", 255],
@ -302,6 +344,9 @@ const COMMON_PREFERENCES = new Map([
// Prevent starting into safe mode after application crashes
["toolkit.startup.max_resumed_crashes", -1],
// Disable all telemetry pings
["toolkit.telemetry.server", "https://%(server)s/telemetry-dummy/"],
// Disable window occlusion on Windows, which can prevent webdriver commands
// such as WebDriver:FindElements from working properly (Bug 1802473).
["widget.windows.window_occlusion_tracking.enabled", false],

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

@ -879,4 +879,4 @@ static const TransportSecurityPreload kPublicKeyPinningPreloadList[] = {
static const int32_t kUnknownId = -1;
static const PRTime kPreloadPKPinsExpirationTime = INT64_C(1701341279093000);
static const PRTime kPreloadPKPinsExpirationTime = INT64_C(1701686952629000);

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -1,5 +1,113 @@
{
"data": [
{
"schema": 1693104479614,
"derHash": "8BBP8XJ0YI8aGKHh6r+OaKUfUAqH4u+iLstiJ2P+9M8=",
"subject": "CN=Gandi RSA Domain Validation Secure Server CA 3,O=Gandi,C=FR",
"subjectDN": "MFYxCzAJBgNVBAYTAkZSMQ4wDAYDVQQKEwVHYW5kaTE3MDUGA1UEAxMuR2FuZGkgUlNBIERvbWFpbiBWYWxpZGF0aW9uIFNlY3VyZSBTZXJ2ZXIgQ0EgMw==",
"whitelist": false,
"attachment": {
"hash": "c57cc4329fa8b504ce063f97a8a15ffe28c6c989bbff9d66c2b1723fce07bf43",
"size": 2263,
"filename": "CFtSlX6OU4eENrKNiHtx6zY8UV7_SoMM63hXbHdXgjs=.pem",
"location": "security-state-staging/intermediates/0f4a0c2f-72a0-436a-ab5c-c6019c2d0993.pem",
"mimetype": "application/x-pem-file"
},
"pubKeyHash": "CFtSlX6OU4eENrKNiHtx6zY8UV7/SoMM63hXbHdXgjs=",
"crlite_enrolled": false,
"id": "9c147e1e-3e85-4edb-b057-0affdeff0587",
"last_modified": 1693105023362
},
{
"schema": 1693104480201,
"derHash": "DZkEhRHJDhZjGpf6dm8ore7cExhiTjdUsk/WD9WkvE0=",
"subject": "CN=McAfee RSA Organization Validation Secure Server CA 3,O=McAfee\\, Inc.,C=US",
"subjectDN": "MGQxCzAJBgNVBAYTAlVTMRUwEwYDVQQKEwxNY0FmZWUsIEluYy4xPjA8BgNVBAMTNU1jQWZlZSBSU0EgT3JnYW5pemF0aW9uIFZhbGlkYXRpb24gU2VjdXJlIFNlcnZlciBDQSAz",
"whitelist": false,
"attachment": {
"hash": "8912a3bcb18bc8d4ae518cd66260d08a84acd4e56f04810c5345f4450ae2b969",
"size": 2284,
"filename": "gg9oIaRipMX5XuQCgBVsizhbKNuS7AJ0CmZZ5o0Jdb0=.pem",
"location": "security-state-staging/intermediates/db48f214-40d6-42b2-a070-27fd1bbe65a7.pem",
"mimetype": "application/x-pem-file"
},
"pubKeyHash": "gg9oIaRipMX5XuQCgBVsizhbKNuS7AJ0CmZZ5o0Jdb0=",
"crlite_enrolled": false,
"id": "a6651c04-79b3-4cef-aa51-845d9c8544b7",
"last_modified": 1693105023359
},
{
"schema": 1693104479894,
"derHash": "+xKIZNrFbzq5PDcWkjANyjRcBP/lp/brJP5uRJs0iVA=",
"subject": "CN=Gandi RSA Organization Validation Secure Server CA 3,O=Gandi,C=FR",
"subjectDN": "MFwxCzAJBgNVBAYTAkZSMQ4wDAYDVQQKEwVHYW5kaTE9MDsGA1UEAxM0R2FuZGkgUlNBIE9yZ2FuaXphdGlvbiBWYWxpZGF0aW9uIFNlY3VyZSBTZXJ2ZXIgQ0EgMw==",
"whitelist": false,
"attachment": {
"hash": "d026088b09a6e613ad8b5fcca9d59a8473a0692b01cbf76e773d881242d2cc27",
"size": 2272,
"filename": "rhYwjniKVh_GqP4xzEvEzVgdmxdxg_K1YyDK64M7rT4=.pem",
"location": "security-state-staging/intermediates/6675899f-be87-41eb-9b0d-656394edfaea.pem",
"mimetype": "application/x-pem-file"
},
"pubKeyHash": "rhYwjniKVh/GqP4xzEvEzVgdmxdxg/K1YyDK64M7rT4=",
"crlite_enrolled": false,
"id": "67147348-c740-4048-90e8-5e6ba1027579",
"last_modified": 1693105023357
},
{
"schema": 1692910086131,
"derHash": "AmCeiJefxoYuoVcfO8bfbHDy/pJ3Rz5D/gTDWXxDQx0=",
"subject": "CN=GTS CA 1D9,O=Google Trust Services LLC,C=US",
"subjectDN": "MEYxCzAJBgNVBAYTAlVTMSIwIAYDVQQKExlHb29nbGUgVHJ1c3QgU2VydmljZXMgTExDMRMwEQYDVQQDEwpHVFMgQ0EgMUQ5",
"whitelist": false,
"attachment": {
"hash": "d44fe24100e78a1699cb4766985db89ddd82c97eb1d2f7d5cbc6c7d0fa9bdf59",
"size": 1987,
"filename": "VhionU4ApKSODjkwxSzRGaien1cg3KhOAaTX0sEzqA4=.pem",
"location": "security-state-staging/intermediates/f02c6bb6-5014-4963-a200-4062712233bd.pem",
"mimetype": "application/x-pem-file"
},
"pubKeyHash": "VhionU4ApKSODjkwxSzRGaien1cg3KhOAaTX0sEzqA4=",
"crlite_enrolled": false,
"id": "f850e310-6786-40c0-86b7-56b717fc241a",
"last_modified": 1692910623870
},
{
"schema": 1692910086775,
"derHash": "7bzdAWmNg+r6Hj048BezrZay2NiOdGxYARzuDvEGk5w=",
"subject": "CN=GTS CA 2D5,O=Google Trust Services LLC,C=US",
"subjectDN": "MEYxCzAJBgNVBAYTAlVTMSIwIAYDVQQKExlHb29nbGUgVHJ1c3QgU2VydmljZXMgTExDMRMwEQYDVQQDEwpHVFMgQ0EgMkQ1",
"whitelist": false,
"attachment": {
"hash": "ceaac730634820c4595c9b174b9bf271cc07f2fd81a0105a5358e73c275ab68a",
"size": 1114,
"filename": "ahc0N7bGYyDMmxgBgeh3thoK90J-_LSNwxbG-EnqfU0=.pem",
"location": "security-state-staging/intermediates/86022f5c-03d1-41c9-91f6-6fd7edb68eb0.pem",
"mimetype": "application/x-pem-file"
},
"pubKeyHash": "ahc0N7bGYyDMmxgBgeh3thoK90J+/LSNwxbG+EnqfU0=",
"crlite_enrolled": false,
"id": "ba3f498c-afb5-4773-9d62-c76498a15062",
"last_modified": 1692910623867
},
{
"schema": 1692910087070,
"derHash": "9dEkFaEsB/3pO9b55ORYjgPSBZbk+KXp0hOoM2S87nE=",
"subject": "CN=GTS CA 2D6,O=Google Trust Services LLC,C=US",
"subjectDN": "MEYxCzAJBgNVBAYTAlVTMSIwIAYDVQQKExlHb29nbGUgVHJ1c3QgU2VydmljZXMgTExDMRMwEQYDVQQDEwpHVFMgQ0EgMkQ2",
"whitelist": false,
"attachment": {
"hash": "4f5acb34ad2db0121e100e350ec7414b51fb7d8b4ab658accc1e30881d887d08",
"size": 1150,
"filename": "mGJygqQlaAdWTKB8W35Jg_xbYW_7zpL45PiiDd1w0qE=.pem",
"location": "security-state-staging/intermediates/4a0ac7d9-fa09-455a-bfca-a6ea4a6e575a.pem",
"mimetype": "application/x-pem-file"
},
"pubKeyHash": "mGJygqQlaAdWTKB8W35Jg/xbYW/7zpL45PiiDd1w0qE=",
"crlite_enrolled": false,
"id": "377d9ef0-09a3-4298-947f-880fa1460cbf",
"last_modified": 1692910623864
},
{
"schema": 1692715688843,
"derHash": "xulqF0VwcJnwInlHL6KKmbrkR9d1EeGehrrzBHZRwes=",
@ -28891,5 +28999,5 @@
"last_modified": 1559865863642
}
],
"timestamp": 1692716223578
"timestamp": 1693105023362
}

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

@ -32,12 +32,9 @@ lazy_static! {
("browser.dom.window.dump.enabled", Pref::new(true)),
("devtools.console.stdout.chrome", Pref::new(true)),
// Disable safebrowsing components
("browser.safebrowsing.blockedURIs.enabled", Pref::new(false)),
("browser.safebrowsing.downloads.enabled", Pref::new(false)),
("browser.safebrowsing.passwords.enabled", Pref::new(false)),
("browser.safebrowsing.malware.enabled", Pref::new(false)),
("browser.safebrowsing.phishing.enabled", Pref::new(false)),
// Disable safebrowsing updates
// TODO: Can be removed when Firefox 117 is no longer supported.
("browser.safebrowsing.update.enabled", Pref::new(false)),
// Do not restore the last open set of tabs if the browser crashed
("browser.sessionstore.resume_from_crash", Pref::new(false)),

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

@ -48,8 +48,7 @@ class GeckoInstance(object):
# Don't pull Top Sites content from the network
"browser.topsites.contile.enabled": False,
# Disable UI tour
"browser.uitour.pinnedTabUrl": "http://%(server)s/uitour-dummy/pinnedTab",
"browser.uitour.url": "http://%(server)s/uitour-dummy/tour",
"browser.uitour.enabled": False,
# Disable captive portal
"captivedetect.canonicalURL": "",
# Defensively disable data reporting systems

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

@ -466,7 +466,7 @@ function sendString(aStr, aWindow) {
i + 1 < aStr.length &&
(aStr.charCodeAt(i + 1) & 0xfc00) == 0xdc00
) {
sendChar(aStr.substring(i, i + 2));
sendChar(aStr.substring(i, i + 2), aWindow);
i++;
} else {
sendChar(aStr.charAt(i), aWindow);

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

@ -1,6 +1,2 @@
[attr-script-fetchpriority.html]
[fetchpriority attribute on <script> elements should reflect valid IDL values]
expected: FAIL
[default fetchpriority attribute on <script> elements should be 'auto']
expected: FAIL
prefs: [network.fetchpriority.enabled:true]

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

@ -1,3 +0,0 @@
[popover-change-type.html]
[Changing the popover attribute should always update the auto/manual behavior.]
expected: FAIL

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

@ -1,60 +1,42 @@
[popover-focus.html]
[Popover focus test: default behavior - popover is not focused]
expected: FAIL
[Popover button click focus test: default behavior - popover is not focused]
expected: FAIL
[Popover focus test: autofocus popover]
expected: FAIL
[Popover button click focus test: autofocus popover]
expected: FAIL
[Popover focus test: autofocus empty popover]
expected: FAIL
[Popover button click focus test: autofocus empty popover]
expected: FAIL
[Popover focus test: autofocus popover with button]
expected: FAIL
[Popover button click focus test: autofocus popover with button]
expected: FAIL
[Popover focus test: autofocus child]
expected: FAIL
[Popover button click focus test: autofocus child]
expected: FAIL
[Popover focus test: autofocus on tabindex=0 element]
expected: FAIL
[Popover button click focus test: autofocus on tabindex=0 element]
expected: FAIL
[Popover focus test: autofocus multiple children]
expected: FAIL
[Popover button click focus test: autofocus multiple children]
expected: FAIL
[Popover focus test: autofocus popover and multiple autofocus children]
expected: FAIL
[Popover button click focus test: autofocus popover and multiple autofocus children]
expected: FAIL
[Popover button click focus test: Opening dialogs as popovers should use dialog initial focus algorithm.]
expected: FAIL
[Popover button click focus test: Opening dialogs as popovers which have autofocus should focus the dialog.]
expected: FAIL
[Popover focus test: Opening dialogs as popovers should use dialog initial focus algorithm.]
expected: FAIL
[Popover button click focus test: Opening dialogs as popovers should use dialog initial focus algorithm.]
[Popover corner cases test: Opening dialogs as popovers should use dialog initial focus algorithm.]
expected: FAIL
[Popover focus test: Opening dialogs as popovers which have autofocus should focus the dialog.]
expected: FAIL
[Popover button click focus test: Opening dialogs as popovers which have autofocus should focus the dialog.]
[Popover corner cases test: Opening dialogs as popovers which have autofocus should focus the dialog.]
expected: FAIL

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

@ -5,7 +5,10 @@
[test_reload[about:blank\]]
expected: FAIL
[test_reload[hash\]]
[test_reload[without hash\]]
expected: FAIL
[test_reload[with hash\]]
expected: FAIL
[test_reload[data url\]]

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

@ -898,11 +898,6 @@ class FirefoxWdSpecBrowser(WebDriverBrowser):
headless,
chaos_mode_flags)
env["RUST_BACKTRACE"] = "1"
# This doesn't work with wdspec tests
# In particular tests can create a session without passing in the capabilites
# and in those cases we get the default geckodriver profile which doesn't
# guarantee zero network access
del env["MOZ_DISABLE_NONLOCAL_CONNECTIONS"]
return env
def create_output_handler(self, cmd):

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

@ -355,7 +355,6 @@ class FirefoxAndroidWdSpecBrowser(FirefoxWdSpecBrowser):
def get_env(self, binary, debug_info, headless, chaos_mode_flags):
env = get_environ(chaos_mode_flags)
env["RUST_BACKTRACE"] = "1"
del env["MOZ_DISABLE_NONLOCAL_CONNECTIONS"]
return env
def executor_browser(self):

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

@ -21,27 +21,31 @@ async def test_return_value(bidi_session, inline, new_tab):
"initial_url",
[
"about:blank",
"https://example.com/#foo",
"https://{host}",
"https://{host}/#foo",
"data:text/html,<p>foo</p>",
f'file://{Path(__file__).parent.parent.resolve() / "support/empty.html"}',
],
ids=[
"about:blank",
"hash",
"without hash",
"with hash",
"data url",
"file url",
],
)
async def test_reload(bidi_session, new_tab, initial_url):
async def test_reload(bidi_session, server_config, new_tab, initial_url):
target_url = initial_url.format(host=server_config["domains"][""][""])
await bidi_session.browsing_context.navigate(context=new_tab["context"],
url=initial_url)
url=target_url)
await bidi_session.browsing_context.reload(context=new_tab["context"],
wait="complete")
contexts = await bidi_session.browsing_context.get_tree(
root=new_tab['context'])
assert len(contexts) == 1
assert contexts[0]["url"] == initial_url
assert contexts[0]["url"] == target_url
async def test_image(bidi_session, new_tab, url):

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

@ -1 +1 @@
{"files":{".github/workflows/rust.yml":"e859b12cfed145b66e4fbf1571dde15880359717ca5b0a9720341229183f2c6f","Cargo.toml":"f507cac11c3c26af28420d68ec3748a5453322d51ef1379a340fdd3b1c9b187a","README.md":"60b34cfa653114d5054009696df2ed2ea1d4926a6bc312d0cac4b84845c2beff","examples/simple.rs":"c196e79568fe4be31a08374aa451c70c9377db5428aef924a985e069c12ed91e","src/bezierflattener.rs":"61687da22490cb1bd901d0b5eb1de3a98802b46c03719ded4163c7a4997f0ad9","src/c_bindings.rs":"23890f7bb5d40d87d72b28842821ada7b2e1509a3b37c9af8ed0055036ceadcc","src/lib.rs":"022bf8fd13d9f097b5d905d01d3632258b41697c9b07c3674444bc4fa3e9e800","src/tri_rasterize.rs":"fb6f595ab9340d8ea6429b41638c378bbd772c8e4d8f7793e225624c12cd3a21"},"package":null}
{"files":{".github/workflows/rust.yml":"e859b12cfed145b66e4fbf1571dde15880359717ca5b0a9720341229183f2c6f","Cargo.toml":"f507cac11c3c26af28420d68ec3748a5453322d51ef1379a340fdd3b1c9b187a","README.md":"60b34cfa653114d5054009696df2ed2ea1d4926a6bc312d0cac4b84845c2beff","examples/simple.rs":"c196e79568fe4be31a08374aa451c70c9377db5428aef924a985e069c12ed91e","src/bezierflattener.rs":"61687da22490cb1bd901d0b5eb1de3a98802b46c03719ded4163c7a4997f0ad9","src/c_bindings.rs":"23890f7bb5d40d87d72b28842821ada7b2e1509a3b37c9af8ed0055036ceadcc","src/lib.rs":"18480fd1f92519229d2439c226011df88a3abf9a6a12295685611cf2bddc8965","src/tri_rasterize.rs":"fb6f595ab9340d8ea6429b41638c378bbd772c8e4d8f7793e225624c12cd3a21"},"package":null}

118
third_party/rust/aa-stroke/src/lib.rs поставляемый
Просмотреть файл

@ -519,6 +519,10 @@ fn dot(a: Vector, b: Vector) -> f32 {
a.x * b.x + a.y * b.y
}
fn cross(a: Vector, b: Vector) -> f32 {
return a.x * b.y - a.y * b.x;
}
/* Finds the intersection of two lines each defined by a point and a normal.
From "Example 2: Find the intersection of two lines" of
"The Pleasures of "Perp Dot" Products"
@ -578,30 +582,62 @@ fn join_line(
if dest.aa {
let ramp_start = pt + s1_normal * (offset + 1.);
let ramp_end = pt + s2_normal * (offset + 1.);
// The following diagram is inspired by the DoLimitedMiter code
// from WpfGfx. Their math doesn't make sense to me so
// there's an original derivation from jgilbert below:
//
// offset point
// --*---------------------- offset line
// | *
// |*
// * clip point
// *|s a spine
// *-- offset ................
// q| point .
// | .
// | .
// | .
// | - r - . -------
// | . |
// | . |
//
// b = a/2
// r/(q+r) = cos b => q + r = r/cos b => q = r/cos b - r
// q/s = sin b/cos b => s = q cos b/sin b
// s = (r/cos b - r) * cos b/sin b = (r - r cos b)/sin b
// sub in r = 1
// s = (1 - cos b)/sin b
//
// rearrange so that we don't have denominator of 0 when b = 0 (parallel lines)
// this prevents numerical instability in that case
//
// (1 - cos b)/sin b => (1 - cos b)(1 + cos b)/(sin b * (1 + cos b))
// => (1 - cos^2 b) / (sin b * (1 + cos b)
// => sin^2 b / sin b * (1 + cos b)
// => sin b / (1 + cos b)
let mid = bisect(s1_normal, s2_normal);
let ramp_intersection = intersection + mid;
let ramp_s1 = line_intersection(ramp_start, s1_normal, ramp_intersection, flip(mid));
let ramp_s2 = line_intersection(ramp_end, s2_normal, ramp_intersection, flip(mid));
// cross = sin, dot = cos
let s = cross(mid, s1_normal)/(1. + dot(s1_normal, mid));
if let Some(ramp_s1) = ramp_s1 {
dest.ramp(intersection.x, intersection.y,
ramp_s1.x, ramp_s1.y,
ramp_start.x, ramp_start.y,
pt.x + s1_normal.x * offset, pt.y + s1_normal.y * offset,
);
}
if let Some(ramp_s2) = ramp_s2 {
dest.ramp(pt.x + s2_normal.x * offset, pt.y + s2_normal.y * offset,
ramp_end.x, ramp_end.y,
ramp_s2.x, ramp_s2.y,
intersection.x, intersection.y);
if let Some(ramp_s1) = ramp_s1 {
dest.tri_ramp(ramp_s1.x, ramp_s1.y, ramp_s2.x, ramp_s2.y, intersection.x, intersection.y);
}
}
let ramp_s1 = intersection + s1_normal * 1. + unperp(s1_normal) * s;
let ramp_s2 = intersection + s2_normal * 1. + unperp(s2_normal) * s;
dest.ramp(intersection.x, intersection.y,
ramp_s1.x, ramp_s1.y,
ramp_start.x, ramp_start.y,
pt.x + s1_normal.x * offset, pt.y + s1_normal.y * offset,
);
dest.ramp(pt.x + s2_normal.x * offset, pt.y + s2_normal.y * offset,
ramp_end.x, ramp_end.y,
ramp_s2.x, ramp_s2.y,
intersection.x, intersection.y);
// put a flat cap on the end
dest.tri_ramp(ramp_s1.x, ramp_s1.y, ramp_s2.x, ramp_s2.y, intersection.x, intersection.y);
// we'll want to intersect the ramps and put a flat cap on the end
dest.quad(pt.x + s1_normal.x * offset, pt.y + s1_normal.y * offset,
intersection.x, intersection.y,
pt.x + s2_normal.x * offset, pt.y + s2_normal.y * offset,
@ -952,3 +988,45 @@ fn parallel_line_join() {
}
}
#[test]
fn degenerate_miter_join() {
// from https://bugzilla.mozilla.org/show_bug.cgi?id=1841020
let mut stroker = Stroker::new(&StrokeStyle{
cap: LineCap::Square,
join: LineJoin::Miter,
width: 1.0,
..Default::default()});
stroker.move_to(Point::new(-204.48355, 528.4429), false);
stroker.line_to(Point::new(-203.89037, 529.0532));
stroker.line_to(Point::new(-202.58539, 530.396,));
stroker.line_to(Point::new(-201.2804, 531.73883,));
stroker.line_to(Point::new(-200.68721, 532.3492,));
let result = stroker.finish();
// make sure none of the verticies are wildly out of place
for v in result {
assert!(v.y >= 527.);
}
let mut stroker = Stroker::new(&StrokeStyle{
cap: LineCap::Square,
join: LineJoin::Miter,
width: 40.0,
..Default::default()});
fn distance_from_line(p1: Point, p2: Point, x: Point) -> f32 {
((p2.x - p1.x)*(p1.y - x.y) - (p1.x - x.x)*(p2.y - p1.y)).abs() /
((p2.x - p1.x).powi(2) + (p2.y - p1.y).powi(2)).sqrt()
}
let start = Point::new(512., 599.);
let end = Point::new(513.51666, 597.47736);
stroker.move_to(start, false);
stroker.line_to(Point::new(512.3874, 598.6111));
stroker.line_to_capped(end);
let result = stroker.finish();
for v in result {
assert!(dbg!(distance_from_line(start, end, Point::new(v.x, v.y))) <= 21.);
}
}

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

@ -95,7 +95,7 @@ processtools = { path = "../../../components/processtools" }
qcms = { path = "../../../../gfx/qcms", features = ["c_bindings", "neon"], default-features = false }
wpf-gpu-raster = { git = "https://github.com/FirefoxGraphics/wpf-gpu-raster", rev = "5ab6fe33d00021325ee920b3c10526dc8301cf46" }
aa-stroke = { git = "https://github.com/FirefoxGraphics/aa-stroke", rev = "c1916bc1b5336438207881a362fc3dd921d915e4" }
aa-stroke = { git = "https://github.com/FirefoxGraphics/aa-stroke", rev = "c7bc7190f6d3115bc81640c0433649c1fce9491c" }
# Force url to stay at 2.1.0. See bug 1734538.
url = "=2.1.0"

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

@ -8,6 +8,7 @@
#include "FetchPreloader.h"
#include "PreloaderBase.h"
#include "mozilla/AsyncEventDispatcher.h"
#include "mozilla/dom/FetchPriority.h"
#include "mozilla/dom/HTMLLinkElement.h"
#include "mozilla/dom/ScriptLoader.h"
#include "mozilla/dom/ReferrerInfo.h"
@ -68,8 +69,8 @@ already_AddRefed<PreloaderBase> PreloadService::PreloadLinkElement(
return nullptr;
}
nsAutoString as, charset, crossOrigin, integrity, referrerPolicy, rel, srcset,
sizes, type, url;
nsAutoString as, charset, crossOrigin, integrity, referrerPolicy,
fetchPriority, rel, srcset, sizes, type, url;
nsCOMPtr<nsIURI> uri = aLinkElement->GetURI();
aLinkElement->GetCharset(charset);
@ -79,6 +80,8 @@ already_AddRefed<PreloaderBase> PreloadService::PreloadLinkElement(
aLinkElement->GetCrossOrigin(crossOrigin);
aLinkElement->GetIntegrity(integrity);
aLinkElement->GetReferrerPolicy(referrerPolicy);
// Bug 1839315: get "fetchpriority"'s value from the link element instead,
fetchPriority = NS_ConvertUTF8toUTF16(dom::kFetchPriorityAttributeValueAuto);
aLinkElement->GetRel(rel);
nsAutoString nonce;
@ -97,7 +100,8 @@ already_AddRefed<PreloaderBase> PreloadService::PreloadLinkElement(
auto result = PreloadOrCoalesce(uri, url, aPolicyType, as, type, charset,
srcset, sizes, nonce, integrity, crossOrigin,
referrerPolicy, /* aFromHeader = */ false, 0);
referrerPolicy, fetchPriority,
/* aFromHeader = */ false, 0);
if (!result.mPreloader) {
NotifyNodeEvent(aLinkElement, result.mAlreadyComplete);
@ -119,8 +123,12 @@ void PreloadService::PreloadLinkHeader(
return;
}
// Bug 1839315: which fetch priority to use here?
const nsAutoString fetchPriority =
NS_ConvertUTF8toUTF16(dom::kFetchPriorityAttributeValueAuto);
PreloadOrCoalesce(aURI, aURL, aPolicyType, aAs, aType, u""_ns, aSrcset,
aSizes, aNonce, aIntegrity, aCORS, aReferrerPolicy,
fetchPriority,
/* aFromHeader = */ true, aEarlyHintPreloaderId);
}
@ -129,8 +137,8 @@ PreloadService::PreloadOrCoalesceResult PreloadService::PreloadOrCoalesce(
const nsAString& aAs, const nsAString& aType, const nsAString& aCharset,
const nsAString& aSrcset, const nsAString& aSizes, const nsAString& aNonce,
const nsAString& aIntegrity, const nsAString& aCORS,
const nsAString& aReferrerPolicy, bool aFromHeader,
uint64_t aEarlyHintPreloaderId) {
const nsAString& aReferrerPolicy, const nsAString& aFetchPriority,
bool aFromHeader, uint64_t aEarlyHintPreloaderId) {
if (!aURI) {
MOZ_ASSERT_UNREACHABLE("Should not pass null nsIURI");
return {nullptr, false};
@ -171,7 +179,7 @@ PreloadService::PreloadOrCoalesceResult PreloadService::PreloadOrCoalesce(
if (aAs.LowerCaseEqualsASCII("script")) {
PreloadScript(uri, aType, aCharset, aCORS, aReferrerPolicy, aNonce,
aIntegrity, true /* isInHead - TODO */,
aFetchPriority, aIntegrity, true /* isInHead - TODO */,
aEarlyHintPreloaderId);
} else if (aAs.LowerCaseEqualsASCII("style")) {
auto status = mDocument->PreloadStyle(
@ -206,12 +214,13 @@ PreloadService::PreloadOrCoalesceResult PreloadService::PreloadOrCoalesce(
void PreloadService::PreloadScript(
nsIURI* aURI, const nsAString& aType, const nsAString& aCharset,
const nsAString& aCrossOrigin, const nsAString& aReferrerPolicy,
const nsAString& aNonce, const nsAString& aIntegrity, bool aScriptFromHead,
const nsAString& aNonce, const nsAString& aFetchPriority,
const nsAString& aIntegrity, bool aScriptFromHead,
uint64_t aEarlyHintPreloaderId) {
mDocument->ScriptLoader()->PreloadURI(
aURI, aCharset, aType, aCrossOrigin, aNonce, aIntegrity, aScriptFromHead,
false, false, false, true, PreloadReferrerPolicy(aReferrerPolicy),
aEarlyHintPreloaderId);
aURI, aCharset, aType, aCrossOrigin, aNonce, aFetchPriority, aIntegrity,
aScriptFromHead, false, false, false, true,
PreloadReferrerPolicy(aReferrerPolicy), aEarlyHintPreloaderId);
}
void PreloadService::PreloadImage(nsIURI* aURI, const nsAString& aCrossOrigin,

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

@ -81,6 +81,7 @@ class PreloadService {
void PreloadScript(nsIURI* aURI, const nsAString& aType,
const nsAString& aCharset, const nsAString& aCrossOrigin,
const nsAString& aReferrerPolicy, const nsAString& aNonce,
const nsAString& aFetchPriority,
const nsAString& aIntegrity, bool aScriptFromHead,
uint64_t aEarlyHintPreloaderId);
@ -116,7 +117,8 @@ class PreloadService {
const nsAString& aSrcset, const nsAString& aSizes,
const nsAString& aNonce, const nsAString& aIntegrity,
const nsAString& aCORS, const nsAString& aReferrerPolicy,
bool aFromHeader, uint64_t aEarlyHintPreloaderId);
const nsAString& aFetchPriority, bool aFromHeader,
uint64_t aEarlyHintPreloaderId);
private:
nsRefPtrHashtable<PreloadHashKey, PreloaderBase> mPreloads;