Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(733)

Unified Diff: Source/core/html/canvas/CanvasRenderingContext2D.cpp

Issue 337343002: IDL: make optional arguments (without default) explicit sometimes Base URL: https://chromium.googlesource.com/chromium/blink.git@idl-default-arguments-next
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/html/canvas/CanvasRenderingContext2D.cpp
diff --git a/Source/core/html/canvas/CanvasRenderingContext2D.cpp b/Source/core/html/canvas/CanvasRenderingContext2D.cpp
index 4eea12475e641bce52e6482f6efa3b73d6060b7e..57c1f5ef584658e7df061c62cd080281ecfb36e2 100644
--- a/Source/core/html/canvas/CanvasRenderingContext2D.cpp
+++ b/Source/core/html/canvas/CanvasRenderingContext2D.cpp
@@ -862,8 +862,12 @@ void CanvasRenderingContext2D::setTransform(float m11, float m12, float m21, flo
transform(m11, m12, m21, m22, dx, dy);
}
-void CanvasRenderingContext2D::setStrokeColor(const String& color)
+void CanvasRenderingContext2D::setStrokeColor(const String& color, Optional<float> alpha)
{
+ if (!alpha.isMissing()) {
+ setStrokeStyle(CanvasStyle::createFromStringWithOverrideAlpha(color, alpha));
+ return;
+ }
if (color == state().m_unparsedStrokeColor)
return;
realizeSaves();
@@ -871,18 +875,6 @@ void CanvasRenderingContext2D::setStrokeColor(const String& color)
modifiableState().m_unparsedStrokeColor = color;
}
-void CanvasRenderingContext2D::setStrokeColor(float grayLevel)
-{
- if (state().m_strokeStyle && state().m_strokeStyle->isEquivalentRGBA(grayLevel, grayLevel, grayLevel, 1.0f))
- return;
- setStrokeStyle(CanvasStyle::createFromGrayLevelWithAlpha(grayLevel, 1.0f));
-}
-
-void CanvasRenderingContext2D::setStrokeColor(const String& color, float alpha)
-{
- setStrokeStyle(CanvasStyle::createFromStringWithOverrideAlpha(color, alpha));
-}
-
void CanvasRenderingContext2D::setStrokeColor(float grayLevel, float alpha)
{
if (state().m_strokeStyle && state().m_strokeStyle->isEquivalentRGBA(grayLevel, grayLevel, grayLevel, alpha))
@@ -904,8 +896,12 @@ void CanvasRenderingContext2D::setStrokeColor(float c, float m, float y, float k
setStrokeStyle(CanvasStyle::createFromCMYKAChannels(c, m, y, k, a));
}
-void CanvasRenderingContext2D::setFillColor(const String& color)
+void CanvasRenderingContext2D::setFillColor(const String& color, Optional<float> alpha)
{
+ if (!alpha.isMissing()) {
+ setFillStyle(CanvasStyle::createFromStringWithOverrideAlpha(color, alpha));
+ return;
+ }
if (color == state().m_unparsedFillColor)
return;
realizeSaves();
@@ -913,18 +909,6 @@ void CanvasRenderingContext2D::setFillColor(const String& color)
modifiableState().m_unparsedFillColor = color;
}
-void CanvasRenderingContext2D::setFillColor(float grayLevel)
-{
- if (state().m_fillStyle && state().m_fillStyle->isEquivalentRGBA(grayLevel, grayLevel, grayLevel, 1.0f))
- return;
- setFillStyle(CanvasStyle::createFromGrayLevelWithAlpha(grayLevel, 1.0f));
-}
-
-void CanvasRenderingContext2D::setFillColor(const String& color, float alpha)
-{
- setFillStyle(CanvasStyle::createFromStringWithOverrideAlpha(color, alpha));
-}
-
void CanvasRenderingContext2D::setFillColor(float grayLevel, float alpha)
{
if (state().m_fillStyle && state().m_fillStyle->isEquivalentRGBA(grayLevel, grayLevel, grayLevel, alpha))
@@ -1180,14 +1164,9 @@ bool CanvasRenderingContext2D::isPointInStrokeInternal(const Path& path, const f
return path.strokeContains(transformedPoint, strokeData);
}
-void CanvasRenderingContext2D::scrollPathIntoView()
-{
- scrollPathIntoViewInternal(m_path);
-}
-
void CanvasRenderingContext2D::scrollPathIntoView(Path2D* path2d)
{
- scrollPathIntoViewInternal(path2d->path());
+ scrollPathIntoViewInternal(path2d ? path2d->path() : m_path);
}
void CanvasRenderingContext2D::scrollPathIntoViewInternal(const Path& path)
@@ -1344,32 +1323,18 @@ void CanvasRenderingContext2D::strokeRect(float x, float y, float width, float h
}
}
-void CanvasRenderingContext2D::setShadow(float width, float height, float blur)
-{
- setShadow(FloatSize(width, height), blur, Color::transparent);
-}
-
-void CanvasRenderingContext2D::setShadow(float width, float height, float blur, const String& color)
+void CanvasRenderingContext2D::setShadow(float width, float height, float blur, const Optional<String>& color, Optional<float> alpha)
{
RGBA32 rgba;
- if (!parseColorOrCurrentColor(rgba, color, canvas()))
+ if (color.isMissing())
+ rgba = Color::transparent;
+ else if (!parseColorOrCurrentColor(rgba, color, canvas()))
return;
+ if (!alpha.isMissing())
+ rgba = colorWithOverrideAlpha(rgba, alpha);
setShadow(FloatSize(width, height), blur, rgba);
}
-void CanvasRenderingContext2D::setShadow(float width, float height, float blur, float grayLevel)
-{
- setShadow(FloatSize(width, height), blur, makeRGBA32FromFloats(grayLevel, grayLevel, grayLevel, 1));
-}
-
-void CanvasRenderingContext2D::setShadow(float width, float height, float blur, const String& color, float alpha)
-{
- RGBA32 rgba;
- if (!parseColorOrCurrentColor(rgba, color, canvas()))
- return;
- setShadow(FloatSize(width, height), blur, colorWithOverrideAlpha(rgba, alpha));
-}
-
void CanvasRenderingContext2D::setShadow(float width, float height, float blur, float grayLevel, float alpha)
{
setShadow(FloatSize(width, height), blur, makeRGBA32FromFloats(grayLevel, grayLevel, grayLevel, alpha));
@@ -2016,24 +1981,14 @@ void CanvasRenderingContext2D::setTextBaseline(const String& s)
modifiableState().m_textBaseline = baseline;
}
-void CanvasRenderingContext2D::fillText(const String& text, float x, float y)
-{
- drawTextInternal(text, x, y, true);
-}
-
-void CanvasRenderingContext2D::fillText(const String& text, float x, float y, float maxWidth)
-{
- drawTextInternal(text, x, y, true, maxWidth, true);
-}
-
-void CanvasRenderingContext2D::strokeText(const String& text, float x, float y)
+void CanvasRenderingContext2D::fillText(const String& text, float x, float y, Optional<float> maxWidth)
{
- drawTextInternal(text, x, y, false);
+ drawTextInternal(text, x, y, true, maxWidth.get(), !maxWidth.isMissing());
}
-void CanvasRenderingContext2D::strokeText(const String& text, float x, float y, float maxWidth)
+void CanvasRenderingContext2D::strokeText(const String& text, float x, float y, Optional<float> maxWidth)
{
- drawTextInternal(text, x, y, false, maxWidth, true);
+ drawTextInternal(text, x, y, false, maxWidth.get(), !maxWidth.isMissing());
}
static inline bool isSpaceCharacter(UChar c)
« no previous file with comments | « Source/core/html/canvas/CanvasRenderingContext2D.h ('k') | Source/core/html/canvas/CanvasRenderingContext2D.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698