Skip to content

Commit 926b5b6

Browse files
committed
8249839: Cherry pick GTK WebKit 2.28.3 changes
Reviewed-by: kcr, bchoudhary
1 parent aae8b6b commit 926b5b6

36 files changed

+467
-152
lines changed

modules/javafx.web/src/main/native/Source/JavaScriptCore/dfg/DFGClobberize.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ void clobberize(Graph& graph, Node* node, const ReadFunctor& read, const WriteFu
228228

229229
case ArithAbs:
230230
if (node->child1().useKind() == Int32Use || node->child1().useKind() == DoubleRepUse)
231-
def(PureValue(node));
231+
def(PureValue(node, node->arithMode()));
232232
else {
233233
read(World);
234234
write(Heap);
@@ -248,7 +248,7 @@ void clobberize(Graph& graph, Node* node, const ReadFunctor& read, const WriteFu
248248
if (node->child1().useKind() == Int32Use
249249
|| node->child1().useKind() == DoubleRepUse
250250
|| node->child1().useKind() == Int52RepUse)
251-
def(PureValue(node));
251+
def(PureValue(node, node->arithMode()));
252252
else {
253253
read(World);
254254
write(Heap);

modules/javafx.web/src/main/native/Source/JavaScriptCore/heap/GCMemoryOperations.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ ALWAYS_INLINE void gcSafeMemcpy(T* dst, T* src, size_t bytes)
5353
bitwise_cast<volatile uint64_t*>(dst)[i] = bitwise_cast<volatile uint64_t*>(src)[i];
5454
};
5555

56-
#if COMPILER(GCC_COMPATIBLE) && USE(JSVALUE64)
56+
#if COMPILER(GCC_COMPATIBLE) && (CPU(X86_64) || CPU(ARM64))
5757
if (bytes <= smallCutoff)
5858
slowPathForwardMemcpy();
5959
else if (isARM64() || bytes <= mediumCutoff) {
@@ -121,8 +121,6 @@ ALWAYS_INLINE void gcSafeMemcpy(T* dst, T* src, size_t bytes)
121121
:
122122
: "d0", "d1", "memory"
123123
);
124-
#else
125-
slowPathForwardMemcpy();
126124
#endif // CPU(X86_64)
127125
} else {
128126
RELEASE_ASSERT(isX86_64());
@@ -139,7 +137,7 @@ ALWAYS_INLINE void gcSafeMemcpy(T* dst, T* src, size_t bytes)
139137
}
140138
#else
141139
slowPathForwardMemcpy();
142-
#endif // COMPILER(GCC_COMPATIBLE)
140+
#endif // COMPILER(GCC_COMPATIBLE) && (CPU(X86_64) || CPU(ARM64))
143141
#else
144142
memcpy(dst, src, bytes);
145143
#endif // USE(JSVALUE64)

modules/javafx.web/src/main/native/Source/JavaScriptCore/runtime/StructureInlines.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,16 @@
3636

3737
namespace JSC {
3838

39-
inline Structure* Structure::create(VM& vm, JSGlobalObject* globalObject, JSValue prototype, const TypeInfo& typeInfo, const ClassInfo* classInfo, IndexingType indexingType, unsigned inlineCapacity)
39+
inline Structure* Structure::create(VM& vm, JSGlobalObject* globalObject, JSValue prototype, const TypeInfo& typeInfo, const ClassInfo* classInfo, IndexingType indexingModeIncludingHistory, unsigned inlineCapacity)
4040
{
4141
ASSERT(vm.structureStructure);
4242
ASSERT(classInfo);
4343
if (auto* object = prototype.getObject()) {
44-
ASSERT(!object->anyObjectInChainMayInterceptIndexedAccesses(vm) || hasSlowPutArrayStorage(indexingType) || !hasIndexedProperties(indexingType));
44+
ASSERT(!object->anyObjectInChainMayInterceptIndexedAccesses(vm) || hasSlowPutArrayStorage(indexingModeIncludingHistory) || !hasIndexedProperties(indexingModeIncludingHistory));
4545
object->didBecomePrototype();
4646
}
4747

48-
Structure* structure = new (NotNull, allocateCell<Structure>(vm.heap)) Structure(vm, globalObject, prototype, typeInfo, classInfo, indexingType, inlineCapacity);
48+
Structure* structure = new (NotNull, allocateCell<Structure>(vm.heap)) Structure(vm, globalObject, prototype, typeInfo, classInfo, indexingModeIncludingHistory, inlineCapacity);
4949
structure->finishCreation(vm);
5050
return structure;
5151
}

modules/javafx.web/src/main/native/Source/WTF/wtf/DataMutex.h

Lines changed: 82 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,74 @@
2121
#pragma once
2222

2323
#include <wtf/Lock.h>
24+
#include <wtf/Threading.h>
2425

2526
namespace WTF {
2627

27-
template<typename T>
28+
// By default invalid access checks are only done in Debug builds.
29+
#if !defined(ENABLE_DATA_MUTEX_CHECKS)
30+
#if defined(NDEBUG)
31+
#define ENABLE_DATA_MUTEX_CHECKS 0
32+
#else
33+
#define ENABLE_DATA_MUTEX_CHECKS 1
34+
#endif
35+
#endif
36+
37+
#if ENABLE_DATA_MUTEX_CHECKS
38+
#define DATA_MUTEX_CHECK(expr) RELEASE_ASSERT(expr)
39+
#else
40+
#define DATA_MUTEX_CHECK(expr)
41+
#endif
42+
43+
template<typename LockType>
44+
class OwnerAwareLockAdapter {
45+
public:
46+
void lock()
47+
{
48+
DATA_MUTEX_CHECK(m_owner != &Thread::current()); // Thread attempted recursive lock (unsupported).
49+
m_lock.lock();
50+
#if ENABLE_DATA_MUTEX_CHECKS
51+
ASSERT(!m_owner);
52+
m_owner = &Thread::current();
53+
#endif
54+
}
55+
56+
void unlock()
57+
{
58+
#if ENABLE_DATA_MUTEX_CHECKS
59+
m_owner = nullptr;
60+
#endif
61+
m_lock.unlock();
62+
}
63+
64+
bool tryLock()
65+
{
66+
DATA_MUTEX_CHECK(m_owner != &Thread::current()); // Thread attempted recursive lock (unsupported).
67+
if (!m_lock.tryLock())
68+
return false;
69+
70+
#if ENABLE_DATA_MUTEX_CHECKS
71+
ASSERT(!m_owner);
72+
m_owner = &Thread::current();
73+
#endif
74+
return true;
75+
}
76+
77+
bool isLocked() const
78+
{
79+
return m_lock.isLocked();
80+
}
81+
82+
private:
83+
#if ENABLE_DATA_MUTEX_CHECKS
84+
Thread* m_owner { nullptr }; // Use Thread* instead of RefPtr<Thread> since m_owner thread is always alive while m_owner is set.
85+
#endif
86+
LockType m_lock;
87+
};
88+
89+
using OwnerAwareLock = OwnerAwareLockAdapter<Lock>;
90+
91+
template<typename T, typename LockType = OwnerAwareLock>
2892
class DataMutex {
2993
WTF_MAKE_FAST_ALLOCATED;
3094
WTF_MAKE_NONCOPYABLE(DataMutex);
@@ -44,32 +108,44 @@ class DataMutex {
44108

45109
T* operator->()
46110
{
111+
DATA_MUTEX_CHECK(m_mutex.isLocked());
47112
return &m_data;
48113
}
49114

50115
T& operator*()
51116
{
117+
DATA_MUTEX_CHECK(m_mutex.isLocked());
52118
return m_data;
53119
}
54120

55-
Lock& mutex()
121+
LockType& mutex()
56122
{
57123
return m_mutex;
58124
}
59125

60-
LockHolder& lockHolder()
126+
Locker<LockType>& lockHolder()
61127
{
62128
return m_lockHolder;
63129
}
64130

131+
// Used to avoid excessive brace scoping when only small parts of the code need to be run unlocked.
132+
// Please be mindful that accessing the wrapped data from the callback is unsafe and will fail on assertions.
133+
// It's helpful to use a minimal lambda capture to be conscious of what data you're having access to in these sections.
134+
void runUnlocked(WTF::Function<void()> callback)
135+
{
136+
m_mutex.unlock();
137+
callback();
138+
m_mutex.lock();
139+
}
140+
65141
private:
66-
Lock& m_mutex;
67-
LockHolder m_lockHolder;
142+
LockType& m_mutex;
143+
Locker<LockType> m_lockHolder;
68144
T& m_data;
69145
};
70146

71147
private:
72-
Lock m_mutex;
148+
LockType m_mutex;
73149
T m_data;
74150
};
75151

modules/javafx.web/src/main/native/Source/WebCore/SourcesWPE.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ page/scrolling/nicosia/ScrollingTreeStickyNode.cpp
5959

6060
page/scrolling/generic/ScrollingThreadGeneric.cpp
6161

62+
platform/ScrollAnimationKinetic.cpp
63+
6264
platform/UserAgentQuirks.cpp
6365

6466
platform/graphics/GLContext.cpp

modules/javafx.web/src/main/native/Source/WebCore/bindings/js/JSDOMWindowProperties.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class JSDOMWindowProperties final : public JSDOMObject {
5151

5252
static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
5353
{
54-
return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
54+
return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info(), JSC::MayHaveIndexedAccessors);
5555
}
5656

5757
static bool getOwnPropertySlot(JSC::JSObject*, JSC::JSGlobalObject*, JSC::PropertyName, JSC::PropertySlot&);

modules/javafx.web/src/main/native/Source/WebCore/bindings/js/ScriptController.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -811,16 +811,27 @@ bool ScriptController::executeIfJavaScriptURL(const URL& url, RefPtr<SecurityOri
811811

812812
const int javascriptSchemeLength = sizeof("javascript:") - 1;
813813

814+
JSDOMGlobalObject* globalObject = jsWindowProxy(mainThreadNormalWorld()).window();
815+
VM& vm = globalObject->vm();
816+
auto throwScope = DECLARE_THROW_SCOPE(vm);
817+
814818
String decodedURL = decodeURLEscapeSequences(url.string());
815819
auto result = executeScriptIgnoringException(decodedURL.substring(javascriptSchemeLength));
820+
RELEASE_ASSERT(&vm == &jsWindowProxy(mainThreadNormalWorld()).window()->vm());
816821

817822
// If executing script caused this frame to be removed from the page, we
818823
// don't want to try to replace its document!
819824
if (!m_frame.page())
820825
return true;
821826

827+
if (!result)
828+
return true;
829+
822830
String scriptResult;
823-
if (!result || !result.getString(jsWindowProxy(mainThreadNormalWorld()).window(), scriptResult))
831+
bool isString = result.getString(globalObject, scriptResult);
832+
RETURN_IF_EXCEPTION(throwScope, true);
833+
834+
if (!isString)
824835
return true;
825836

826837
// FIXME: We should always replace the document, but doing so

modules/javafx.web/src/main/native/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2741,15 +2741,16 @@ sub GenerateHeader
27412741
# Structure ID
27422742
push(@headerContent, " static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)\n");
27432743
push(@headerContent, " {\n");
2744+
my $indexingModeIncludingHistory = InstanceOverridesGetOwnPropertySlot($interface) ? "JSC::MayHaveIndexedAccessors" : "JSC::NonArray";
27442745
if (IsDOMGlobalObject($interface)) {
2745-
push(@headerContent, " return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::GlobalObjectType, StructureFlags), info());\n");
2746+
push(@headerContent, " return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::GlobalObjectType, StructureFlags), info(), $indexingModeIncludingHistory);\n");
27462747
} elsif ($codeGenerator->InheritsInterface($interface, "Node")) {
27472748
my $type = GetJSTypeForNode($interface);
2748-
push(@headerContent, " return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::JSType($type), StructureFlags), info());\n");
2749+
push(@headerContent, " return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::JSType($type), StructureFlags), info(), $indexingModeIncludingHistory);\n");
27492750
} elsif ($codeGenerator->InheritsInterface($interface, "Event")) {
2750-
push(@headerContent, " return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::JSType(JSEventType), StructureFlags), info());\n");
2751+
push(@headerContent, " return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::JSType(JSEventType), StructureFlags), info(), $indexingModeIncludingHistory);\n");
27512752
} else {
2752-
push(@headerContent, " return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());\n");
2753+
push(@headerContent, " return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info(), $indexingModeIncludingHistory);\n");
27532754
}
27542755
push(@headerContent, " }\n\n");
27552756

modules/javafx.web/src/main/native/Source/WebCore/loader/FrameLoader.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4169,12 +4169,21 @@ RefPtr<Frame> createWindow(Frame& openerFrame, Frame& lookupFrame, FrameLoadRequ
41694169
windowRect.setX(*features.x);
41704170
if (features.y)
41714171
windowRect.setY(*features.y);
4172-
// Zero width and height mean using default size, not minumum one.
4172+
// Zero width and height mean using default size, not minimum one.
41734173
if (features.width && *features.width)
41744174
windowRect.setWidth(*features.width + (windowRect.width() - viewportSize.width()));
41754175
if (features.height && *features.height)
41764176
windowRect.setHeight(*features.height + (windowRect.height() - viewportSize.height()));
41774177

4178+
#if PLATFORM(GTK)
4179+
FloatRect oldWindowRect = oldPage->chrome().windowRect();
4180+
// Use the size of the previous window if there is no default size.
4181+
if (!windowRect.width())
4182+
windowRect.setWidth(oldWindowRect.width());
4183+
if (!windowRect.height())
4184+
windowRect.setHeight(oldWindowRect.height());
4185+
#endif
4186+
41784187
// Ensure non-NaN values, minimum size as well as being within valid screen area.
41794188
FloatRect newWindowRect = DOMWindow::adjustWindowRect(*page, windowRect);
41804189

modules/javafx.web/src/main/native/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,9 @@ void ScrollingTreeScrollingNode::scrollTo(const FloatPoint& position, ScrollType
164164
if (position == m_currentScrollPosition)
165165
return;
166166

167+
if (scrollType == ScrollType::Programmatic)
168+
stopScrollAnimations();
169+
167170
scrollingTree().setIsHandlingProgrammaticScroll(scrollType == ScrollType::Programmatic);
168171

169172
m_currentScrollPosition = adjustedScrollPosition(position, clamp);

0 commit comments

Comments
 (0)