comparison Applications/Platforms/WebAssembly/WebAssemblyViewport.cpp @ 1687:cc5a2e076746

Added error check to emscripten_get_element_css_size
author Benjamin Golinvaux <bgo@osimis.io>
date Wed, 25 Nov 2020 17:02:43 +0100
parents 2e3b2ed239b9
children 9ac2a65d4172
comparison
equal deleted inserted replaced
1685:7896aac14587 1687:cc5a2e076746
418 } 418 }
419 419
420 420
421 void WebAssemblyViewport::RefreshCanvasSize() 421 void WebAssemblyViewport::RefreshCanvasSize()
422 { 422 {
423 double w, h; 423 double w = -1, h = -1;
424 emscripten_get_element_css_size(GetCanvasCssSelector().c_str(), &w, &h); 424 EMSCRIPTEN_RESULT result =
425 emscripten_get_element_css_size(GetCanvasCssSelector().c_str(), &w, &h);
426
427 if (result != EMSCRIPTEN_RESULT_SUCCESS)
428 {
429 LOG(WARNING) << "WebAssemblyViewport::RefreshCanvasSize failed to "
430 << "retrieve CSS size for " << GetCanvasCssSelector();
431 }
425 432
426 /** 433 /**
427 * Emscripten has the function emscripten_get_element_css_size() 434 * Emscripten has the function emscripten_get_element_css_size()
428 * to query the width and height of a named HTML element. I'm 435 * to query the width and height of a named HTML element. I'm
429 * calling this first to get the initial size of the canvas DOM 436 * calling this first to get the initial size of the canvas DOM