[Webkit-unassigned] [Bug 18994] LANG/LC_ALL influences the result of element.style.opacity

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Sun Oct 10 05:13:28 PDT 2010


https://bugs.webkit.org/show_bug.cgi?id=18994





--- Comment #114 from Nikolas Zimmermann <zimmermann at kde.org>  2010-10-10 05:13:26 PST ---
When removing String::format(), following code has to change.

String::format() users that don't dump floating-point numbers, and can be converted to a String::number() + StringBuilder/Vector<UChar> based solution right now:

bindings/js/JSDOMWindowBase.cpp:    return String::format("Unsafe JavaScript attempt to access frame with URL %s from frame with URL %s. Domains, protocols and ports must match.\n",
bindings/v8/V8Proxy.cpp:    String str = String::format("Unsafe JavaScript attempt to access frame "
css/CSSOMUtils.cpp:    append(appendTo, String::format("\\%x ", c));
dom/Document.cpp:    return String::format("%02d/%02d/%04d %02d:%02d:%02d", date.month() + 1, date.monthDay(), date.fullYear(), date.hour(), date.minute(), date.second());
dom/ExceptionBase.cpp:        m_message = String::format("%s: %s Exception %d", description.name, description.typeName, description.code);
dom/ExceptionBase.cpp:        m_message = String::format("%s Exception %d", description.typeName, description.code);
dom/StyledElement.cpp:            color = String::format("#%02x%02x%02x", colors[0], colors[1], colors[2]);
dom/XMLDocumentParser.cpp:                m_errorMessages += String::format("warning on line %d at column %d: %s", lineNumber, columnNumber, m);
dom/XMLDocumentParser.cpp:                m_errorMessages += String::format("error on line %d at column %d: %s", lineNumber, columnNumber, m);
html/DateComponents.cpp:        return String::format("%02d:%02d", m_hour, m_minute);
html/DateComponents.cpp:        return String::format("%02d:%02d:%02d", m_hour, m_minute, m_second);
html/DateComponents.cpp:        return String::format("%02d:%02d:%02d.%03d", m_hour, m_minute, m_second, m_millisecond);
html/DateComponents.cpp:        return String::format("%04d-%02d-%02d", m_year, m_month + 1, m_monthDay);
html/DateComponents.cpp:        return String::format("%04d-%02d-%02dT", m_year, m_month + 1, m_monthDay)
html/DateComponents.cpp:        return String::format("%04d-%02d-%02dT", m_year, m_month + 1, m_monthDay)
html/DateComponents.cpp:        return String::format("%04d-%02d", m_year, m_month + 1);
html/DateComponents.cpp:        return String::format("%04d-W%02d", m_year, m_week);
html/FTPDirectoryDocument.cpp:            timeOfDay = String::format(", %i:%02i AM", hour, fileTime.tm_min);
html/FTPDirectoryDocument.cpp:            timeOfDay = String::format(", %i:%02i PM", hour, fileTime.tm_min);
html/FTPDirectoryDocument.cpp:        dateString = String::format("%s %i, %i", months[month], fileTime.tm_mday, fileTime.tm_year);
html/FTPDirectoryDocument.cpp:        dateString = String::format("%s %i, %i", months[month], fileTime.tm_mday, now.tm_year);
inspector/CodeGeneratorInspector.pm:    push(@function, "        protocolErrors->pushString(String::format(\"Protocol Error: %s handler is not available.\", \"$domain\"));");
inspector/CodeGeneratorInspector.pm:        push(@function, "        protocolErrors->pushString(String::format(\"Protocol Error: 'arguments' property with type 'object' was not found.\"));");
inspector/CodeGeneratorInspector.pm:            push(@function, "            protocolErrors->pushString(String::format(\"Protocol Error: Argument '%s' with type '%s' was not found.\", \"$name\", \"$JSONType\"));");
inspector/CodeGeneratorInspector.pm:            push(@function, "                protocolErrors->pushString(String::format(\"Protocol Error: Argument '%s' has wrong type. It should be '%s'.\", \"$name\", \"$JSONType\"));");
inspector/CodeGeneratorInspector.pm:        reportProtocolError(callId, String::format("Protocol Error: Invalid command was received. '%s' wasn't found.", command.utf8().data()));
inspector/InspectorController.cpp:        String message = String::format("Failed to load resource: the server responded with a status of %u (", response.httpStatusCode()) + response.httpStatusText() + ")";
inspector/InspectorController.cpp:    String identifier = title + String::format("@%s:%d", sourceID.utf8().data(), lineNumber);
inspector/InspectorController.cpp:    String message = String::format("%s: %d", title.utf8().data(), count);
inspector/InspectorDebuggerAgent.cpp:    return String::format("%s:%d", sourceID.utf8().data(), lineNumber);
inspector/InspectorProfilerAgent.cpp:    String message = String::format("Profile \"webkit-profile://%s/%s#%d\" finished.", CPUProfileType, encodeWithURLEscapeSequences(title).utf8().data(), profile->uid());
inspector/InspectorProfilerAgent.cpp:    String message = String::format("Profile \"webkit-profile://%s/%s#0\" started.", CPUProfileType, encodeWithURLEscapeSequences(title).utf8().data());
inspector/InspectorProfilerAgent.cpp:    return String::format("%s.%d", UserInitiatedProfileName, m_currentUserInitiatedProfileNumber);
inspector/InspectorProfilerAgent.cpp:    String title = String::format("%s.%d", UserInitiatedProfileName, m_nextUserInitiatedHeapSnapshotNumber++);
inspector/InspectorValues.cpp:                String symbolCode = String::format("\\u%04X", symbol);
loader/archive/cf/LegacyWebArchive.cpp:    String iframeMarkup = String::format("<iframe frameborder=\"no\" marginwidth=\"0\" marginheight=\"0\" width=\"98%%\" height=\"98%%\" src=\"%s\"></iframe>", 
loader/CachedResourceLoader.cpp:        String::format("Unsafe attempt to load URL %s.",
loader/CachedResourceLoader.cpp:        String::format("Unsafe attempt to load URL %s from frame with URL %s. "
loader/FrameLoader.cpp:    String message = String::format("The page at %s displayed insecure content from %s.\n",
loader/FrameLoader.cpp:    String message = String::format("The page at %s ran insecure content from %s.\n",
loader/FrameLoader.cpp:        String message = String::format("Unsafe JavaScript attempt to initiate a navigation change for frame with URL %s from frame with URL %s.\n",
page/DOMWindow.cpp:            String message = String::format("Unable to post message to %s. Recipient has origin %s.\n", 
page/PrintContext.cpp:        return String::format("%d", style->marginLeft().rawValue());
page/PrintContext.cpp:        return String::format("%d", style->lineHeight().rawValue());
page/PrintContext.cpp:        return String::format("%d", style->fontDescription().computedPixelSize());
page/PrintContext.cpp:        return String::format("%s", style->fontDescription().family().family().string().utf8().data());
page/PrintContext.cpp:        return String::format("%d %d", style->pageSize().width().rawValue(), style->pageSize().height().rawValue());
page/PrintContext.cpp:    return String::format("pageProperty() unimplemented for: %s", propertyName);
page/PrintContext.cpp:    return String::format("(%d, %d) %d %d %d %d", pageSize.width(), pageSize.height(), marginTop, marginRight, marginBottom, marginLeft);
page/XSSAuditor.cpp:        String consoleMessage = String::format("Refused to load an object. URL found within request: \"%s\".\n", url.utf8().data());
platform/audio/HRTFElevation.cpp:    String resourceName = String::format("IRC_%s_C_R0195_T%03d_P%03d", subjectName.utf8().data(), azimuth, positiveElevation);
platform/brew/FileSystemBrew.cpp:    return String::format("fs:/~0X%08X/", webViewClassId);
platform/brew/PlatformKeyboardEventBrew.cpp:        return String::format("U+%04X", toASCIIUpper(keyCode));
platform/cocoa/KeyEventCocoa.mm:            return String::format("U+%04X", toASCIIUpper(charCode));
platform/efl/PlatformKeyboardEventEfl.cpp:        String key = String::format("F%d", i);
platform/efl/PlatformKeyboardEventEfl.cpp:        String key = String::format("%c", alphabet[i]);
platform/efl/PlatformKeyboardEventEfl.cpp:        String key = String::format("%d", i);
platform/efl/PlatformKeyboardEventEfl.cpp:        String key = String::format("F%d", i);
platform/graphics/brew/ImageBrew.cpp:    String resourcePath = homeDirectoryPath() + String::format("res/%s.png", name);
platform/graphics/cg/ImageBufferCG.cpp:    return String::format("data:%s;base64,%s", mimeType.utf8().data(), out.data());
platform/graphics/chromium/FontUtilsChromiumWin.cpp:    String fontKey = String::format("%1d:%d:%ls", style, logfont->lfHeight, family);
platform/graphics/chromium/GraphicsLayerChromium.cpp:    String name = String::format("GraphicsLayerChromium(%p) GraphicsLayer(%p) ", m_layer.get(), this) + inName;
platform/graphics/Color.cpp:        return String::format("#%02x%02x%02x", red(), green(), blue());
platform/graphics/Color.cpp:        return String::format("rgba(%u, %u, %u, 0.0)", red(), green(), blue());
platform/graphics/Color.cpp:        return String::format("#%02X%02X%02X%02X", red(), green(), blue(), alpha());
platform/graphics/Color.cpp:    return String::format("#%02X%02X%02X", red(), green(), blue());
platform/graphics/efl/ImageEfl.cpp:    RefPtr<SharedBuffer> buffer = SharedBuffer::createWithContentsOfFile(String::format(DATA_DIR "/webkit-1.0/images/%s.png", name));
platform/graphics/GraphicsLayer.cpp:    return String::format("-|transition%c-", property);
platform/graphics/gtk/ImageBufferGtk.cpp:    return String::format("data:%s;base64,%s", mimeType.utf8().data(), out.data());
platform/graphics/haiku/ImageBufferHaiku.cpp:    return String::format("data:%s;base64,%s", mimeType.utf8().data(),
platform/graphics/mac/GraphicsLayerCA.mm:    return animationName + String::format("_%d_%d", property, index);
platform/graphics/mac/GraphicsLayerCA.mm:    String longName = String::format("CALayer(%p) GraphicsLayer(%p) ", m_layer.get(), this) + name;
platform/graphics/mac/GraphicsLayerCA.mm:    String name = String::format("CALayer(%p) GraphicsLayer(%p) ", m_layer.get(), this) + m_name;
platform/graphics/qt/ImageBufferQt.cpp:    return String::format("data:%s;base64,%s", mimeType.utf8().data(), data.toBase64().data());
platform/graphics/skia/ImageBufferSkia.cpp:    return String::format("data:image/png;base64,%s", base64EncodedData.data());
platform/graphics/win/GraphicsLayerCACF.cpp:    String longName = String::format("CALayer(%p) GraphicsLayer(%p) ", m_layer.get(), this) + name;
platform/graphics/win/GraphicsLayerCACF.cpp:    String name = String::format("CALayer(%p) GraphicsLayer(%p) %s", m_layer.get(), this, m_usingTiledLayer ? "[Tiled Layer] " : "") + m_name;
platform/graphics/win/WebLayer.cpp:        String text = String::format("%d", m_owner->incrementRepaintCount());;
platform/gtk/KeyEventGtk.cpp:            return String::format("U+%04X", gdk_keyval_to_unicode(gdk_keyval_to_upper(keyCode)));
platform/haiku/PlatformKeyboardEventHaiku.cpp:    return String::format("U+%04X", toASCIIUpper(singleByte));
platform/network/CredentialStorage.cpp:        return url.protocol() + "://" + url.host() + String::format(":%i/", url.port());
platform/qt/PlatformKeyboardEventQt.cpp:        return String::format("U+%04X", toupper(keyCode));
platform/sql/SQLiteDatabase.cpp:    executeCommand(String::format("PRAGMA synchronous = %i", sync));
platform/sql/SQLiteFileSystem.cpp:        fileName = pathByAppendingComponent(dbDir, String::format("%016"PRIx64".db", seq));
platform/sql/SQLiteFileSystem.cpp:    return String::format("%016"PRIx64".db", seq);
platform/text/wince/TextCodecWinCE.cpp:                String cpName = String::format("cp%d", cpInfo.uiCodePage);
platform/win/ClipboardUtilitiesWin.cpp:    append(result, String::format(header, startHTMLOffset, endHTMLOffset, startFragmentOffset, endFragmentOffset).utf8());
platform/win/GDIObjectCounter.cpp:    init(String::format("%s (%p)", className.latin1().data(), instance));
platform/win/KeyEventWin.cpp:            return String::format("U+%04X", toASCIIUpper(keyCode));
platform/win/Language.cpp:        computedDefaultLanguage = String::format("%s-%s", languageName.latin1().data(), countryName.latin1().data());
platform/wx/KeyboardEventWx.cpp:            return String::format("U+%04X", toupper(keyCode));
plugins/PluginStream.cpp:        String statusLine = String::format("HTTP %d OK\n", m_resourceResponse.httpStatusCode());
rendering/RenderTheme.cpp:            return String::format("%s%02d:%02d:%02d", (time < 0 ? "-" : ""), hours, minutes, seconds);
rendering/RenderTheme.cpp:        return String::format("%s%01d:%02d:%02d", (time < 0 ? "-" : ""), hours, minutes, seconds);
rendering/RenderTheme.cpp:    return String::format("%s%02d:%02d", (time < 0 ? "-" : ""), minutes, seconds);
rendering/RenderTreeAsText.cpp:                String hex = String::format("\\x{%X}", u);
svg/SVGUseElement.cpp:    text += String::format("SVGElementInstance this=%p, (parentNode=%s (%p), firstChild=%s (%p), correspondingElement=%s (%p), shadowTreeElement=%s (%p), id=%s)\n",
svg/SVGUseElement.cpp:    text += String::format("Corresponding element is associated with %i instance(s):\n", elementInstances.size());
svg/SVGUseElement.cpp:        text += String::format(" -> SVGElementInstance this=%p, (refCount: %i, shadowTreeElement in document? %i)\n",
websockets/WebSocket.cpp:            builder.append(String::format("\\u%04X", protocol[i]));
websockets/WebSocket.cpp:        scriptExecutionContext()->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, String::format("WebSocket port %d blocked", url.port()), 0, scriptExecutionContext()->securityOrigin()->toString());
websockets/WebSocketChannel.cpp:    m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, String::format("WebSocket frame (at %lu bytes) is too long.", static_cast<unsigned long>(newBufferSize)), 0, m_handshake.clientOrigin());
websockets/WebSocketHandshake.cpp:        m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, String::format("Unexpected response code: %d", statusCode), 0, clientOrigin());

String::format() users that dump floating-point numbers, and would need my patch for String::number() before they could be converted:

css/CSSParser.cpp:        String str = String::format("%06d", (int)(value->fValue+.5));
css/CSSPrimitiveValue.cpp:            text = String::format("%.6lg%%", m_value.num);
css/CSSPrimitiveValue.cpp:            text = String::format("%.6lgem", m_value.num);
css/CSSPrimitiveValue.cpp:            text = String::format("%.6lgex", m_value.num);
css/CSSPrimitiveValue.cpp:            text = String::format("%.6lgrem", m_value.num);
css/CSSPrimitiveValue.cpp:            text = String::format("%.6lgpx", m_value.num);
css/CSSPrimitiveValue.cpp:            text = String::format("%.6lgcm", m_value.num);
css/CSSPrimitiveValue.cpp:            text = String::format("%.6lgmm", m_value.num);
css/CSSPrimitiveValue.cpp:            text = String::format("%.6lgin", m_value.num);
css/CSSPrimitiveValue.cpp:            text = String::format("%.6lgpt", m_value.num);
css/CSSPrimitiveValue.cpp:            text = String::format("%.6lgpc", m_value.num);
css/CSSPrimitiveValue.cpp:            text = String::format("%.6lgdeg", m_value.num);
css/CSSPrimitiveValue.cpp:            text = String::format("%.6lgrad", m_value.num);
css/CSSPrimitiveValue.cpp:            text = String::format("%.6lggrad", m_value.num);
css/CSSPrimitiveValue.cpp:            text = String::format("%.6lgms", m_value.num);
css/CSSPrimitiveValue.cpp:            text = String::format("%.6lgs", m_value.num);
css/CSSPrimitiveValue.cpp:            text = String::format("%.6lghz", m_value.num);
css/CSSPrimitiveValue.cpp:            text = String::format("%.6lgkhz", m_value.num);
css/CSSPrimitiveValue.cpp:            text = String::format("%.6lgturn", m_value.num);
css/WebKitCSSMatrix.cpp:        return String::format("matrix(%f, %f, %f, %f, %f, %f)",
css/WebKitCSSMatrix.cpp:    return String::format("matrix3d(%f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f)",
html/FTPDirectoryDocument.cpp:        return String::format("%.2f KB", static_cast<float>(bytes)/1000);
html/FTPDirectoryDocument.cpp:        return String::format("%.2f MB", static_cast<float>(bytes)/1000000);
html/FTPDirectoryDocument.cpp:    return String::format("%.2f GB", static_cast<float>(bytes)/1000000000);
inspector/InspectorValues.cpp:        String value = String::format("%f", m_doubleValue);
page/Console.cpp:    String message = title + String::format(": %.0fms", elapsed);
platform/graphics/Color.cpp:    return String::format("rgba(%u, %u, %u, %.5f)", red(), green(), blue(), alpha() / 255.0f);
platform/graphics/gtk/ImageBufferGtk.cpp:        String qualityString = String::format("%f", *quality);
platform/graphics/mac/MediaPlayerPrivateQTKit.mm:            String text = String::format("%1.2f", frameRate);
svg/SVGAnimatedPropertyTraits.h:    static String toString(PassType type) { return String::format("%f %f %f %f", type.x(), type.y(), type.width(), type.height()); }
svg/SVGTransformList.cpp:        return String::format("matrix(%f %f %f %f %f %f)", matrix.a(), matrix.b(), matrix.c(), matrix.d(), matrix.e(), matrix.f());

If my patch is considered good, I'd change the usages of String::format("%f") to the new String::number() implementation combined StringBuilder/Vector<UChar> to replace the String::format() calls. That would be a good first step, fixing this bug, and then later on we can kill String::format().

I've just realized that not all code wants to round to 6 significant figures, some explicitely demand 2 decimals, some code just uses %f. That means my patch has to be adapted to that. The code in FTPDirectoryDocument for example doesn't want to print exponential numbers, never, that is also not handled yet, when using String::number(double). So maybe we want another enum, that precisely describes the conversion mode.

enum FloatingPointConversion {
    RoundToSignificantFigures,
    RoundToDecimalPlaces,
    AvoidExponentials
};

String String::number(double number, unsigned = RoundToSignificantFigures, unsigned significantFiguresOrDecimalPlaces = 6). The second argument could be used to combine eg. RoundToSiginificantFigures | AvoidExponentials.

Enough for today, what do others think? :-)

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list