Make the stocks popup menu fade in

The final animation is more involved, but this CL starts implementing the menu
animation by making it fade in.

R=ianh@google.com

Review URL: https://codereview.chromium.org/1174253003.
This commit is contained in:
Adam Barth 2015-06-10 17:28:43 -07:00
parent 508ff93761
commit d0c30be6ca
6 changed files with 68 additions and 45 deletions

View File

@ -22,6 +22,9 @@ Rect DartConverter<Rect>::FromArgumentsWithNullCheck(Dart_NativeArguments args,
Dart_Handle dart_rect = Dart_GetNativeArgument(args, index);
DCHECK(!LogIfError(dart_rect));
if (Dart_IsNull(dart_rect))
return result;
Dart_Handle value =
Dart_GetField(dart_rect, DOMDartState::Current()->value_handle());
if (Dart_IsNull(value))

View File

@ -1,22 +0,0 @@
--- platform/graphics/GraphicsContext.cpp
+++ platform/graphics/GraphicsContext.cpp
@@ -419,19 +419,6 @@
paint->setLCDRenderText(couldUseLCDRenderedText());
}
-bool GraphicsContext::couldUseLCDRenderedText() const
-{
- ASSERT(m_canvas);
- // Our layers only have a single alpha channel. This means that subpixel
- // rendered text cannot be composited correctly when the layer is
- // collapsed. Therefore, subpixel text is contextDisabled when we are drawing
- // onto a layer.
- if (contextDisabled() || m_canvas->isDrawingToLayer() || !isCertainlyOpaque())
- return false;
-
- return shouldSmoothFonts();
-}
-
void GraphicsContext::setCompositeOperation(CompositeOperator compositeOperation, WebBlendMode blendMode)
{
if (contextDisabled())

View File

@ -1,15 +0,0 @@
--- platform/graphics/GraphicsContext.h
+++ platform/graphics/GraphicsContext.h
@@ -155,11 +155,10 @@
// FIXME: the setter is only used once, at construction time; convert to a constructor param,
// and possibly consolidate with other flags (paintDisabled, isPrinting, ...)
void setShouldSmoothFonts(bool smoothFonts) { m_shouldSmoothFonts = smoothFonts; }
- bool shouldSmoothFonts() const { return m_shouldSmoothFonts; }
// Turn off LCD text for the paint if not supported on this context.
void adjustTextRenderMode(SkPaint*) const;
- bool couldUseLCDRenderedText() const;
+ bool couldUseLCDRenderedText() const { return m_isCertainlyOpaque && m_shouldSmoothFonts; }
void setTextDrawingMode(TextDrawingModeFlags mode) { mutableState()->setTextDrawingMode(mode); }
TextDrawingModeFlags textDrawingMode() const { return immutableState()->textDrawingMode(); }

View File

@ -114,14 +114,17 @@ class PopupMenu extends AnimatedComponent {
}));
// inlineStyle: _inlineStyle(),
return new ShrinkWrapWidth(
child: new Container(
padding: const EdgeDims.all(8.0),
decoration: new BoxDecoration(
backgroundColor: Grey[50],
borderRadius: 2.0,
boxShadow: Shadow[level]),
child: new Block(children)
return new Opacity(
opacity: math.min(1.0, _position * 3.0),
child: new ShrinkWrapWidth(
child: new Container(
padding: const EdgeDims.all(8.0),
decoration: new BoxDecoration(
backgroundColor: Grey[50],
borderRadius: 2.0,
boxShadow: Shadow[level]),
child: new Block(children)
)
)
);
}

View File

@ -378,6 +378,21 @@ abstract class OneChildRenderObjectWrapper extends RenderObjectWrapper {
}
class Opacity extends OneChildRenderObjectWrapper {
Opacity({ this.opacity, UINode child, Object key })
: super(child: child, key: key);
RenderOpacity get root { RenderOpacity result = super.root; return result; }
final double opacity;
RenderOpacity createNode() => new RenderOpacity(opacity: opacity);
void syncRenderObject(Opacity old) {
super.syncRenderObject(old);
root.opacity = opacity;
}
}
class ClipRect extends OneChildRenderObjectWrapper {
ClipRect({ UINode child, Object key })

View File

@ -439,6 +439,45 @@ class RenderShrinkWrapWidth extends RenderProxyBox {
}
}
class RenderOpacity extends RenderProxyBox {
RenderOpacity({ RenderBox child, double opacity })
: this._opacity = opacity, super(child) {
assert(opacity >= 0.0 && opacity <= 1.0);
}
double _opacity;
double get opacity => _opacity;
void set opacity (double value) {
assert(value != null);
assert(value >= 0.0 && value <= 1.0);
if (_opacity == value)
return;
_opacity = value;
markNeedsPaint();
}
void paint(RenderObjectDisplayList canvas) {
if (child != null) {
int a = (_opacity * 255).round();
if (a == 0)
return;
if (a == 255) {
child.paint(canvas);
return;
}
Paint paint = new Paint()
..color = new Color.fromARGB(a, 0, 0, 0)
..setTransferMode(sky.TransferMode.srcOverMode);
canvas.saveLayer(null, paint);
child.paint(canvas);
canvas.restore();
}
}
}
class RenderClipRect extends RenderProxyBox {
RenderClipRect({ RenderBox child }) : super(child);