mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-10-07 09:28:02 +00:00
Merge pull request #3257 from enquora/modernize-CABackingStore
Refactor CABackingStore: Eliminate preprocessor directives and legacy…
This commit is contained in:
1 file changed
+26
-42
@@ -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.
|
||||
Reference in new issue
Block a user