Changeset 200058 in webkit
- Timestamp:
- Apr 25, 2016 4:39:01 PM (8 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r200056 r200058 1 2016-04-25 Chris Dumez <cdumez@apple.com> 2 3 [Web IDL] Specify default values for optional parameters of type 'float' / 'unrestricted float' 4 https://bugs.webkit.org/show_bug.cgi?id=156995 5 6 Reviewed by Darin Adler. 7 8 Specify default values for optional parameters of type 'float' / 'unrestricted float' 9 and let the bindings generator use WTF::Optional<> for the ones that do not have a 10 default value. 11 12 * bindings/scripts/CodeGeneratorJS.pm: 13 (CanUseWTFOptionalForParameter): Deleted. 14 * bindings/scripts/test/JS/JSTestTypedefs.cpp: 15 (WebCore::jsTestTypedefsPrototypeFunctionSetShadow): 16 * html/canvas/CanvasRenderingContext2D.cpp: 17 (WebCore::CanvasRenderingContext2D::setStrokeColor): 18 (WebCore::CanvasRenderingContext2D::setFillColor): 19 (WebCore::CanvasRenderingContext2D::setShadow): 20 (WebCore::CanvasRenderingContext2D::fillText): 21 (WebCore::CanvasRenderingContext2D::strokeText): 22 (WebCore::CanvasRenderingContext2D::drawTextInternal): 23 (WebCore::CanvasRenderingContext2D::clearShadow): Deleted. 24 (WebCore::normalizeSpaces): Deleted. 25 (WebCore::CanvasRenderingContext2D::measureText): Deleted. 26 * html/canvas/CanvasRenderingContext2D.h: 27 * html/canvas/CanvasRenderingContext2D.idl: 28 * testing/Internals.idl: 29 1 30 2016-04-25 Brent Fulgham <bfulgham@apple.com> 2 31 -
trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
r200037 r200058 3387 3387 return 0 if $type eq "Dictionary"; 3388 3388 return 0 if $type eq "any"; 3389 return 0 if $type eq "float";3390 3389 return 0 if $type eq "long"; 3391 return 0 if $type eq "unrestricted float";3392 3390 return 0 if $type eq "unrestricted double"; 3393 3391 return 0 if $type eq "unsigned long"; -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestTypedefs.cpp
r200044 r200058 500 500 if (UNLIKELY(state->hadException())) 501 501 return JSValue::encode(jsUndefined()); 502 if (argsCount <= 4) { 503 impl.setShadow(width, height, blur, color); 504 return JSValue::encode(jsUndefined()); 505 } 506 507 float alpha = state->argument(4).toFloat(state); 502 Optional<float> alpha = state->argument(4).isUndefined() ? Optional<float>() : state->uncheckedArgument(4).toFloat(state); 508 503 if (UNLIKELY(state->hadException())) 509 504 return JSValue::encode(jsUndefined()); -
trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp
r200041 r200058 820 820 } 821 821 822 void CanvasRenderingContext2D::setStrokeColor(const String& color) 823 { 822 void CanvasRenderingContext2D::setStrokeColor(const String& color, Optional<float> alpha) 823 { 824 if (alpha) { 825 setStrokeStyle(CanvasStyle::createFromStringWithOverrideAlpha(color, alpha.value())); 826 return; 827 } 828 824 829 if (color == state().unparsedStrokeColor) 825 830 return; 831 826 832 realizeSaves(); 827 833 setStrokeStyle(CanvasStyle::createFromString(color, &canvas()->document())); … … 829 835 } 830 836 831 void CanvasRenderingContext2D::setStrokeColor(float grayLevel)832 {833 if (state().strokeStyle.isValid() && state().strokeStyle.isEquivalentRGBA(grayLevel, grayLevel, grayLevel, 1.0f))834 return;835 setStrokeStyle(CanvasStyle(grayLevel, 1.0f));836 }837 838 void CanvasRenderingContext2D::setStrokeColor(const String& color, float alpha)839 {840 setStrokeStyle(CanvasStyle::createFromStringWithOverrideAlpha(color, alpha));841 }842 843 837 void CanvasRenderingContext2D::setStrokeColor(float grayLevel, float alpha) 844 838 { … … 862 856 } 863 857 864 void CanvasRenderingContext2D::setFillColor(const String& color) 865 { 858 void CanvasRenderingContext2D::setFillColor(const String& color, Optional<float> alpha) 859 { 860 if (alpha) { 861 setFillStyle(CanvasStyle::createFromStringWithOverrideAlpha(color, alpha.value())); 862 return; 863 } 864 866 865 if (color == state().unparsedFillColor) 867 866 return; 867 868 868 realizeSaves(); 869 869 setFillStyle(CanvasStyle::createFromString(color, &canvas()->document())); 870 870 modifiableState().unparsedFillColor = color; 871 }872 873 void CanvasRenderingContext2D::setFillColor(float grayLevel)874 {875 if (state().fillStyle.isValid() && state().fillStyle.isEquivalentRGBA(grayLevel, grayLevel, grayLevel, 1.0f))876 return;877 setFillStyle(CanvasStyle(grayLevel, 1.0f));878 }879 880 void CanvasRenderingContext2D::setFillColor(const String& color, float alpha)881 {882 setFillStyle(CanvasStyle::createFromStringWithOverrideAlpha(color, alpha));883 871 } 884 872 … … 1272 1260 } 1273 1261 1274 void CanvasRenderingContext2D::setShadow(float width, float height, float blur, const String& color) 1275 { 1276 RGBA32 rgba; 1277 if (!parseColorOrCurrentColor(rgba, color, canvas())) 1278 return; 1279 setShadow(FloatSize(width, height), blur, rgba); 1280 } 1281 1282 void CanvasRenderingContext2D::setShadow(float width, float height, float blur, float grayLevel) 1283 { 1284 setShadow(FloatSize(width, height), blur, makeRGBA32FromFloats(grayLevel, grayLevel, grayLevel, 1)); 1285 } 1286 1287 void CanvasRenderingContext2D::setShadow(float width, float height, float blur, const String& color, float alpha) 1262 void CanvasRenderingContext2D::setShadow(float width, float height, float blur, const String& color, Optional<float> alpha) 1288 1263 { 1289 1264 RGBA32 rgba; … … 2328 2303 } 2329 2304 2330 void CanvasRenderingContext2D::fillText(const String& text, float x, float y) 2331 { 2332 drawTextInternal(text, x, y, true); 2333 } 2334 2335 void CanvasRenderingContext2D::fillText(const String& text, float x, float y, float maxWidth) 2336 { 2337 drawTextInternal(text, x, y, true, maxWidth, true); 2338 } 2339 2340 void CanvasRenderingContext2D::strokeText(const String& text, float x, float y) 2341 { 2342 drawTextInternal(text, x, y, false); 2343 } 2344 2345 void CanvasRenderingContext2D::strokeText(const String& text, float x, float y, float maxWidth) 2346 { 2347 drawTextInternal(text, x, y, false, maxWidth, true); 2305 void CanvasRenderingContext2D::fillText(const String& text, float x, float y, Optional<float> maxWidth) 2306 { 2307 drawTextInternal(text, x, y, true, maxWidth); 2308 } 2309 2310 void CanvasRenderingContext2D::strokeText(const String& text, float x, float y, Optional<float> maxWidth) 2311 { 2312 drawTextInternal(text, x, y, false, maxWidth); 2348 2313 } 2349 2314 … … 2391 2356 } 2392 2357 2393 void CanvasRenderingContext2D::drawTextInternal(const String& text, float x, float y, bool fill, float maxWidth, bool useMaxWidth)2358 void CanvasRenderingContext2D::drawTextInternal(const String& text, float x, float y, bool fill, Optional<float> maxWidth) 2394 2359 { 2395 2360 const auto& fontProxy = this->fontProxy(); … … 2403 2368 if (!std::isfinite(x) | !std::isfinite(y)) 2404 2369 return; 2405 if ( useMaxWidth && (!std::isfinite(maxWidth) || maxWidth<= 0))2370 if (maxWidth && (!std::isfinite(maxWidth.value()) || maxWidth.value() <= 0)) 2406 2371 return; 2407 2372 … … 2448 2413 float fontWidth = fontProxy.width(TextRun(normalizedText, 0, 0, AllowTrailingExpansion, direction, override)); 2449 2414 2450 useMaxWidth = (useMaxWidth && maxWidth < fontWidth);2451 float width = useMaxWidth ? maxWidth : fontWidth;2415 bool useMaxWidth = maxWidth && maxWidth.value() < fontWidth; 2416 float width = useMaxWidth ? maxWidth.value() : fontWidth; 2452 2417 2453 2418 TextAlign align = state().textAlign; -
trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.h
r199776 r200058 118 118 void setTransform(float m11, float m12, float m21, float m22, float dx, float dy); 119 119 120 void setStrokeColor(const String& color); 121 void setStrokeColor(float grayLevel); 122 void setStrokeColor(const String& color, float alpha); 123 void setStrokeColor(float grayLevel, float alpha); 120 void setStrokeColor(const String& color, Optional<float> alpha = Nullopt); 121 void setStrokeColor(float grayLevel, float alpha = 1.0); 124 122 void setStrokeColor(float r, float g, float b, float a); 125 123 void setStrokeColor(float c, float m, float y, float k, float a); 126 124 127 void setFillColor(const String& color); 128 void setFillColor(float grayLevel); 129 void setFillColor(const String& color, float alpha); 130 void setFillColor(float grayLevel, float alpha); 125 void setFillColor(const String& color, Optional<float> alpha = Nullopt); 126 void setFillColor(float grayLevel, float alpha = 1.0f); 131 127 void setFillColor(float r, float g, float b, float a); 132 128 void setFillColor(float c, float m, float y, float k, float a); … … 153 149 154 150 void setShadow(float width, float height, float blur); 155 void setShadow(float width, float height, float blur, const String& color);156 151 void setShadow(float width, float height, float blur, float grayLevel); 157 void setShadow(float width, float height, float blur, const String& color, float alpha);158 void setShadow(float width, float height, float blur, float grayLevel, float alpha );152 void setShadow(float width, float height, float blur, const String& color, Optional<float> alpha = Nullopt); 153 void setShadow(float width, float height, float blur, float grayLevel, float alpha = 1.0); 159 154 void setShadow(float width, float height, float blur, float r, float g, float b, float a); 160 155 void setShadow(float width, float height, float blur, float c, float m, float y, float k, float a); … … 218 213 void setDirection(const String&); 219 214 220 void fillText(const String& text, float x, float y); 221 void fillText(const String& text, float x, float y, float maxWidth); 222 void strokeText(const String& text, float x, float y); 223 void strokeText(const String& text, float x, float y, float maxWidth); 215 void fillText(const String& text, float x, float y, Optional<float> maxWidth = Nullopt); 216 void strokeText(const String& text, float x, float y, Optional<float> maxWidth = Nullopt); 224 217 Ref<TextMetrics> measureText(const String& text); 225 218 … … 346 339 void applyFillPattern(); 347 340 348 void drawTextInternal(const String& text, float x, float y, bool fill, float maxWidth = 0, bool useMaxWidth = false);341 void drawTextInternal(const String& text, float x, float y, bool fill, Optional<float> maxWidth = Nullopt); 349 342 350 343 // The relationship between FontCascade and CanvasRenderingContext2D::FontProxy must hold certain invariants. -
trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.idl
r199969 r200058 129 129 130 130 void setStrokeColor([StrictTypeChecking] DOMString color, optional unrestricted float alpha); 131 void setStrokeColor(unrestricted float grayLevel, optional float alpha );131 void setStrokeColor(unrestricted float grayLevel, optional float alpha = 1); 132 132 void setStrokeColor(unrestricted float r, unrestricted float g, unrestricted float b, unrestricted float a); 133 133 void setStrokeColor(unrestricted float c, unrestricted float m, unrestricted float y, unrestricted float k, unrestricted float a); 134 134 135 135 void setFillColor([StrictTypeChecking] DOMString color, optional unrestricted float alpha); 136 void setFillColor(unrestricted float grayLevel, optional unrestricted float alpha );136 void setFillColor(unrestricted float grayLevel, optional unrestricted float alpha = 1); 137 137 void setFillColor(unrestricted float r, unrestricted float g, unrestricted float b, unrestricted float a); 138 138 void setFillColor(unrestricted float c, unrestricted float m, unrestricted float y, unrestricted float k, unrestricted float a); … … 157 157 158 158 void drawImageFromRect(HTMLImageElement image, 159 optional unrestricted float sx , optional unrestricted float sy, optional unrestricted float sw, optional unrestricted float sh,160 optional unrestricted float dx , optional unrestricted float dy, optional unrestricted float dw, optional unrestricted float dh,161 optional DOMString compositeOperation );159 optional unrestricted float sx = 0, optional unrestricted float sy = 0, optional unrestricted float sw = 0, optional unrestricted float sh = 0, 160 optional unrestricted float dx = 0, optional unrestricted float dy = 0, optional unrestricted float dw = 0, optional unrestricted float dh = 0, 161 optional DOMString compositeOperation = ""); 162 162 163 163 void setShadow(unrestricted float width, unrestricted float height, unrestricted float blur, 164 164 [StrictTypeChecking] optional DOMString color, optional unrestricted float alpha); 165 165 void setShadow(unrestricted float width, unrestricted float height, unrestricted float blur, unrestricted float grayLevel, 166 optional unrestricted float alpha );166 optional unrestricted float alpha = 1); 167 167 void setShadow(unrestricted float width, unrestricted float height, unrestricted float blur, unrestricted float r, 168 168 unrestricted float g, unrestricted float b, unrestricted float a); -
trunk/Source/WebCore/platform/graphics/Color.h
r196360 r200058 33 33 #include <unicode/uchar.h> 34 34 #include <wtf/Forward.h> 35 #include <wtf/Optional.h> 35 36 #include <wtf/text/LChar.h> 36 37 … … 56 57 57 58 WEBCORE_EXPORT RGBA32 colorWithOverrideAlpha(RGBA32 color, float overrideAlpha); 59 WEBCORE_EXPORT RGBA32 colorWithOverrideAlpha(RGBA32 color, Optional<float> overrideAlpha); 60 58 61 WEBCORE_EXPORT RGBA32 makeRGBA32FromFloats(float r, float g, float b, float a); 59 62 RGBA32 makeRGBAFromHSLA(double h, double s, double l, double a); … … 296 299 } 297 300 301 inline RGBA32 colorWithOverrideAlpha(RGBA32 color, Optional<float> overrideAlpha) 302 { 303 return overrideAlpha ? colorWithOverrideAlpha(color, overrideAlpha.value()) : color; 304 } 305 298 306 WEBCORE_EXPORT TextStream& operator<<(TextStream&, const Color&); 299 307 -
trunk/Source/WebCore/testing/Internals.idl
r200037 r200058 272 272 273 273 DOMString counterValue(Element element); 274 long pageNumber(Element element, optional unrestricted float pageWidth , optional unrestricted float pageHeight);274 long pageNumber(Element element, optional unrestricted float pageWidth = 800, optional unrestricted float pageHeight = 600); 275 275 DOMString[] shortcutIconURLs(); 276 276 long numberOfPages(optional unrestricted double pageWidthInPixels, optional unrestricted double pageHeightInPixels);
Note: See TracChangeset
for help on using the changeset viewer.