Sat, 03 Jan 2015 20:18:00 +0100
Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.
michael@0 | 1 | /* |
michael@0 | 2 | * Copyright 2011 Google Inc. |
michael@0 | 3 | * |
michael@0 | 4 | * Use of this source code is governed by a BSD-style license that can be |
michael@0 | 5 | * found in the LICENSE file. |
michael@0 | 6 | */ |
michael@0 | 7 | |
michael@0 | 8 | |
michael@0 | 9 | |
michael@0 | 10 | #ifndef GrGLIRect_DEFINED |
michael@0 | 11 | #define GrGLIRect_DEFINED |
michael@0 | 12 | |
michael@0 | 13 | #include "gl/GrGLInterface.h" |
michael@0 | 14 | #include "GrGLUtil.h" |
michael@0 | 15 | |
michael@0 | 16 | /** |
michael@0 | 17 | * Helper struct for dealing with the fact that Ganesh and GL use different |
michael@0 | 18 | * window coordinate systems (top-down vs bottom-up) |
michael@0 | 19 | */ |
michael@0 | 20 | struct GrGLIRect { |
michael@0 | 21 | GrGLint fLeft; |
michael@0 | 22 | GrGLint fBottom; |
michael@0 | 23 | GrGLsizei fWidth; |
michael@0 | 24 | GrGLsizei fHeight; |
michael@0 | 25 | |
michael@0 | 26 | void pushToGLViewport(const GrGLInterface* gl) const { |
michael@0 | 27 | GR_GL_CALL(gl, Viewport(fLeft, fBottom, fWidth, fHeight)); |
michael@0 | 28 | } |
michael@0 | 29 | |
michael@0 | 30 | void pushToGLScissor(const GrGLInterface* gl) const { |
michael@0 | 31 | GR_GL_CALL(gl, Scissor(fLeft, fBottom, fWidth, fHeight)); |
michael@0 | 32 | } |
michael@0 | 33 | |
michael@0 | 34 | void setFromGLViewport(const GrGLInterface* gl) { |
michael@0 | 35 | GR_STATIC_ASSERT(sizeof(GrGLIRect) == 4*sizeof(GrGLint)); |
michael@0 | 36 | GR_GL_GetIntegerv(gl, GR_GL_VIEWPORT, (GrGLint*) this); |
michael@0 | 37 | } |
michael@0 | 38 | |
michael@0 | 39 | // sometimes we have a SkIRect from the client that we |
michael@0 | 40 | // want to simultaneously make relative to GL's viewport |
michael@0 | 41 | // and (optionally) convert from top-down to bottom-up. |
michael@0 | 42 | void setRelativeTo(const GrGLIRect& glRect, |
michael@0 | 43 | int leftOffset, |
michael@0 | 44 | int topOffset, |
michael@0 | 45 | int width, |
michael@0 | 46 | int height, |
michael@0 | 47 | GrSurfaceOrigin origin) { |
michael@0 | 48 | fLeft = glRect.fLeft + leftOffset; |
michael@0 | 49 | fWidth = width; |
michael@0 | 50 | if (kBottomLeft_GrSurfaceOrigin == origin) { |
michael@0 | 51 | fBottom = glRect.fBottom + (glRect.fHeight - topOffset - height); |
michael@0 | 52 | } else { |
michael@0 | 53 | fBottom = glRect.fBottom + topOffset; |
michael@0 | 54 | } |
michael@0 | 55 | fHeight = height; |
michael@0 | 56 | |
michael@0 | 57 | SkASSERT(fLeft >= 0); |
michael@0 | 58 | SkASSERT(fWidth >= 0); |
michael@0 | 59 | SkASSERT(fBottom >= 0); |
michael@0 | 60 | SkASSERT(fHeight >= 0); |
michael@0 | 61 | } |
michael@0 | 62 | |
michael@0 | 63 | bool contains(const GrGLIRect& glRect) const { |
michael@0 | 64 | return fLeft <= glRect.fLeft && |
michael@0 | 65 | fBottom <= glRect.fBottom && |
michael@0 | 66 | fLeft + fWidth >= glRect.fLeft + glRect.fWidth && |
michael@0 | 67 | fBottom + fHeight >= glRect.fBottom + glRect.fHeight; |
michael@0 | 68 | } |
michael@0 | 69 | |
michael@0 | 70 | void invalidate() {fLeft = fWidth = fBottom = fHeight = -1;} |
michael@0 | 71 | |
michael@0 | 72 | bool operator ==(const GrGLIRect& glRect) const { |
michael@0 | 73 | return 0 == memcmp(this, &glRect, sizeof(GrGLIRect)); |
michael@0 | 74 | } |
michael@0 | 75 | |
michael@0 | 76 | bool operator !=(const GrGLIRect& glRect) const {return !(*this == glRect);} |
michael@0 | 77 | }; |
michael@0 | 78 | |
michael@0 | 79 | #endif |