WebGL compatibility: add stencil mask and ref restriction

BUG=angleproject:1523
BUG=chromium:668223

Change-Id: I0726769c938fdfd50af0fad1cef1746d4af2a589
Reviewed-on: https://chromium-review.googlesource.com/422084
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
diff --git a/src/libANGLE/Framebuffer.cpp b/src/libANGLE/Framebuffer.cpp
index ee72b36..72886d6 100644
--- a/src/libANGLE/Framebuffer.cpp
+++ b/src/libANGLE/Framebuffer.cpp
@@ -132,6 +132,15 @@
     return nullptr;
 }
 
+const FramebufferAttachment *FramebufferState::getStencilOrDepthStencilAttachment() const
+{
+    if (mStencilAttachment.isAttached())
+    {
+        return &mStencilAttachment;
+    }
+    return getDepthStencilAttachment();
+}
+
 const FramebufferAttachment *FramebufferState::getColorAttachment(size_t colorAttachment) const
 {
     ASSERT(colorAttachment < mColorAttachments.size());
@@ -360,6 +369,11 @@
     return mState.getDepthOrStencilAttachment();
 }
 
+const FramebufferAttachment *Framebuffer::getStencilOrDepthStencilAttachment() const
+{
+    return mState.getStencilOrDepthStencilAttachment();
+}
+
 const FramebufferAttachment *Framebuffer::getReadColorbuffer() const
 {
     return mState.getReadAttachment();