Merge pull request #3257 from enquora/modernize-CABackingStore

Refactor CABackingStore: Eliminate preprocessor directives and legacy…
This commit is contained in:
daboe01 authored and GitHub committed 2026-08-26 20:52:08 +02:00
commit 5bdac195fc
1 file changed
+26 -42
+26 -42
View File
@@ -21,54 +21,38 @@
*/
@import "CGGeometry.j"
@import "CPCompatibility.j"
#define PIXEL(pixels) pixels + "px";
// REMOVED: @import "CPCompatibility.j" - Obsolete legacy compatibility layer removed.
// REMOVED: #define PIXEL(pixels) macro - Eliminated in favour of native inline string concatenation.
function CABackingStoreGetContext(aBackingStore)
{
return aBackingStore.context;
};
if (CPFeatureIsCompatible(CPHTMLCanvasFeature))
{
CABackingStoreCreate = function()
{
var DOMElement = document.createElement("canvas");
DOMElement.style.position = "absolute";
// FIXME: Consolidate drawImage to support this.
return { context:DOMElement.getContext("2d"), buffer:DOMElement, _image:DOMElement };
};
CABackingStoreSetSize = function(aBackingStore, aSize)
{
var buffer = aBackingStore.buffer;
buffer.width = aSize.width;
buffer.height = aSize.height;
buffer.style.width = PIXEL(aSize.width);
buffer.style.height = PIXEL(aSize.height);
};
return aBackingStore.context;
}
else
// REMOVED: if (CPFeatureIsCompatible(CPHTMLCanvasFeature)) - HTMLCanvasElement is natively supported across modern targets. Legacy fallback block completely removed.
function CABackingStoreCreate()
{
// MODERNIZED: Replaced legacy 'var' with block-scoped 'const' for immutable DOM reference.
const DOMElement = document.createElement("canvas");
CABackingStoreCreate = function()
{
var context = CGBitmapGraphicsContextCreate();
context.buffer = "";
return { context:context };
};
CABackingStoreSetSize = function(aBackingStore, aSize)
{
};
DOMElement.style.position = "absolute";
// FIXME: Consolidate drawImage to support this.
return { context:DOMElement.getContext("2d"), buffer:DOMElement, _image:DOMElement };
}
function CABackingStoreSetSize(aBackingStore, aSize)
{
// MODERNIZED: Replaced legacy 'var' with block-scoped 'const'.
const buffer = aBackingStore.buffer;
buffer.width = aSize.width;
buffer.height = aSize.height;
// MODERNIZED: Replaced macro expansion with native inline evaluation.
buffer.style.width = aSize.width + "px";
buffer.style.height = aSize.height + "px";
}
// REMOVED: Legacy else block utilizing CGBitmapGraphicsContextCreate due to guaranteed canvas support.