Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
8302684: Cherry-pick WebKit 615.1 stabilization fixes (2)
Backport-of: 67c2b7a
  • Loading branch information
kevinrushforth committed Mar 13, 2023
1 parent 8aa7d21 commit 0869711
Show file tree
Hide file tree
Showing 14 changed files with 33 additions and 16 deletions.
Expand Up @@ -209,7 +209,8 @@ inline ToThisResult isToThisAnIdentity(ECMAMode ecmaMode, AbstractValue& valueFo
}
}

if ((ecmaMode.isStrict() || (valueForNode.m_type && !(valueForNode.m_type & ~SpecObject))) && valueForNode.m_structure.isFinite()) {
bool onlyObjects = valueForNode.m_type && !(valueForNode.m_type & ~SpecObject);
if ((ecmaMode.isStrict() || onlyObjects) && valueForNode.m_structure.isFinite()) {
bool allStructuresAreJSScope = !valueForNode.m_structure.isClear();
bool overridesToThis = false;
valueForNode.m_structure.forEach([&](RegisteredStructure structure) {
Expand All @@ -226,9 +227,13 @@ inline ToThisResult isToThisAnIdentity(ECMAMode ecmaMode, AbstractValue& valueFo
// If all the structures are JSScope's ones, we know the details of JSScope::toThis() operation.
allStructuresAreJSScope &= structure->classInfoForCells()->methodTable.toThis == JSScope::info()->methodTable.toThis;
});

// This is correct for strict mode even if this can have non objects, since the right semantics is Identity.
if (!overridesToThis)
return ToThisResult::Identity;
if (allStructuresAreJSScope) {

// But this folding is available only if input is always an object.
if (onlyObjects && allStructuresAreJSScope) {
if (ecmaMode.isStrict())
return ToThisResult::Undefined;
return ToThisResult::GlobalThis;
Expand Down
Expand Up @@ -50,7 +50,7 @@ static ExceptionOr<bool> canWriteHeader(const String& name, const String& value,
return Exception { TypeError, "Headers object's guard is 'immutable'"_s };
if (guard == FetchHeaders::Guard::Request && isForbiddenHeaderName(name))
return false;
if (guard == FetchHeaders::Guard::RequestNoCors && !combinedValue.isEmpty() && !isSimpleHeader(name, combinedValue))
if (guard == FetchHeaders::Guard::RequestNoCors && !isSimpleHeader(name, combinedValue))
return false;
if (guard == FetchHeaders::Guard::Response && isForbiddenResponseHeaderName(name))
return false;
Expand Down
Expand Up @@ -438,7 +438,7 @@ RefPtr<CSSCalcOperationNode> CSSCalcOperationNode::createHypot(Vector<Ref<CSSCal
{
auto expectedCategory = commonCategory(values);

if (expectedCategory == CalculationCategory::Other) {
if (!expectedCategory || expectedCategory == CalculationCategory::Other) {
LOG_WITH_STREAM(Calc, stream << "Failed to create hypot node because unable to determine category from " << prettyPrintNodes(values));
return nullptr;
}
Expand Down
Expand Up @@ -6745,7 +6745,7 @@ void Document::postTask(Task&& task)
callOnMainThread([documentID = identifier(), task = WTFMove(task)]() mutable {
ASSERT(isMainThread());

auto* document = allDocumentsMap().get(documentID);
RefPtr document = allDocumentsMap().get(documentID);
if (!document)
return;

Expand All @@ -6759,7 +6759,8 @@ void Document::postTask(Task&& task)

void Document::pendingTasksTimerFired()
{
Vector<Task> pendingTasks = WTFMove(m_pendingTasks);
Ref protectedThis { *this };
auto pendingTasks = std::exchange(m_pendingTasks, Vector<Task> { });
for (auto& task : pendingTasks)
task.performTask(*this);
}
Expand Down
Expand Up @@ -44,6 +44,7 @@
#include "Editor.h"
#include "ElementInlines.h"
#include "EventNames.h"
#include "EventLoop.h"
#include "FileChooser.h"
#include "FileInputType.h"
#include "FileList.h"
Expand Down
Expand Up @@ -158,7 +158,7 @@ void HTMLSourceElement::parseAttribute(const QualifiedName& name, const AtomStri
if (name == mediaAttr)
m_cachedParsedMediaAttribute = std::nullopt;
RefPtr parent = parentNode();
if (m_shouldCallSourcesChanged)
if (m_shouldCallSourcesChanged && parent)
downcast<HTMLPictureElement>(*parent).sourcesChanged();
}
#if ENABLE(MODEL_ELEMENT)
Expand Down
Expand Up @@ -317,7 +317,7 @@ URL ContentFilter::url()
#endif
}

static const URL& blockedPageURL()
const URL& ContentFilter::blockedPageURL()
{
static NeverDestroyed blockedPageURL = [] () -> URL {
auto webCoreBundle = CFBundleGetBundleWithIdentifier(CFSTR("com.apple.WebCore"));
Expand Down
Expand Up @@ -79,6 +79,8 @@ class ContentFilter {
bool isAllowed() const { return m_state == State::Allowed; }
bool responseReceived() const { return m_responseReceived; }

WEBCORE_EXPORT static const URL& blockedPageURL();

private:
using State = PlatformContentFilter::State;

Expand Down
Expand Up @@ -110,12 +110,12 @@ static HashSet<String, ASCIICaseInsensitiveHash>& mimeTypeCache()
if (typeListInitialized)
return cache;

const char* mimeTypes[] = {
"video/holepunch"
const ASCIILiteral mimeTypes[] = {
"video/holepunch"_s
};

for (unsigned i = 0; i < (sizeof(mimeTypes) / sizeof(*mimeTypes)); ++i)
cache.get().add(String(mimeTypes[i]));
cache.get().add(mimeTypes[i]);

typeListInitialized = true;

Expand Down
Expand Up @@ -37,7 +37,11 @@ namespace Nicosia {
std::unique_ptr<PaintingEngine> PaintingEngine::create()
{
#if (ENABLE(DEVELOPER_MODE) && PLATFORM(WPE)) || USE(GTK4)
#if USE(GTK4)
unsigned numThreads = 1;
#else
unsigned numThreads = 0;
#endif
if (const char* numThreadsEnv = getenv("WEBKIT_NICOSIA_PAINTING_THREADS")) {
if (sscanf(numThreadsEnv, "%u", &numThreads) == 1) {
if (numThreads > 8) {
Expand Down
Expand Up @@ -372,8 +372,11 @@ void NetworkStorageSession::resetAppBoundDomains()

std::optional<Seconds> NetworkStorageSession::clientSideCookieCap(const RegistrableDomain& firstParty, std::optional<PageIdentifier> pageID) const
{
auto domainIterator = m_navigatedToWithLinkDecorationByPrevalentResource.find(*pageID);
#if ENABLE(JS_COOKIE_CHECKING)
if (!pageID)
return std::nullopt;

auto domainIterator = m_navigatedToWithLinkDecorationByPrevalentResource.find(*pageID);
if (domainIterator != m_navigatedToWithLinkDecorationByPrevalentResource.end() && domainIterator->value == firstParty)
return m_ageCapForClientSideCookiesForLinkDecorationTargetPage;

Expand All @@ -382,6 +385,7 @@ std::optional<Seconds> NetworkStorageSession::clientSideCookieCap(const Registra
if (!m_ageCapForClientSideCookies || !pageID || m_navigatedToWithLinkDecorationByPrevalentResource.isEmpty())
return m_ageCapForClientSideCookies;

auto domainIterator = m_navigatedToWithLinkDecorationByPrevalentResource.find(*pageID);
if (domainIterator == m_navigatedToWithLinkDecorationByPrevalentResource.end())
return m_ageCapForClientSideCookies;

Expand Down
Expand Up @@ -45,7 +45,7 @@ class SQLiteTransaction {
void stop();

bool inProgress() const { return m_inProgress; }
bool wasRolledBackBySqlite() const;
WEBCORE_EXPORT bool wasRolledBackBySqlite() const;

SQLiteDatabase& database() const { return m_db; }

Expand Down
Expand Up @@ -3262,7 +3262,7 @@ void RenderLayer::paintLayerContents(GraphicsContext& context, const LayerPainti

// Now walk the sorted list of children with negative z-indices.
if ((isPaintingScrollingContent && isPaintingOverflowContents) || (!isPaintingScrollingContent && isPaintingCompositedBackground))
paintList(negativeZOrderLayers(), currentContext, localPaintingInfo, localPaintFlags);
paintList(negativeZOrderLayers(), currentContext, paintingInfo, localPaintFlags);

if (isPaintingCompositedForeground) {
if (shouldPaintContent) {
Expand All @@ -3279,7 +3279,7 @@ void RenderLayer::paintLayerContents(GraphicsContext& context, const LayerPainti

if (isPaintingCompositedForeground) {
// Paint any child layers that have overflow.
paintList(normalFlowLayers(), currentContext, localPaintingInfo, localPaintFlags);
paintList(normalFlowLayers(), currentContext, paintingInfo, localPaintFlags);

// Now walk the sorted list of children with positive z-indices.
paintList(positiveZOrderLayers(), currentContext, localPaintingInfo, localPaintFlags);
Expand Down
Expand Up @@ -122,7 +122,7 @@ void* DebugHeap::malloc(size_t size, FailureAction action)

void* DebugHeap::memalign(size_t alignment, size_t size, FailureAction action)
{
void* result;
void* result = nullptr;
if (posix_memalign(&result, alignment, size))
RELEASE_BASSERT(action == FailureAction::ReturnNull || result);
return result;
Expand Down

1 comment on commit 0869711

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.