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 | /* |
michael@0 | 3 | * Copyright 2006 The Android Open Source Project |
michael@0 | 4 | * |
michael@0 | 5 | * Use of this source code is governed by a BSD-style license that can be |
michael@0 | 6 | * found in the LICENSE file. |
michael@0 | 7 | */ |
michael@0 | 8 | |
michael@0 | 9 | |
michael@0 | 10 | #ifndef SkTextBox_DEFINED |
michael@0 | 11 | #define SkTextBox_DEFINED |
michael@0 | 12 | |
michael@0 | 13 | #include "SkCanvas.h" |
michael@0 | 14 | |
michael@0 | 15 | /** \class SkTextBox |
michael@0 | 16 | |
michael@0 | 17 | SkTextBox is a helper class for drawing 1 or more lines of text |
michael@0 | 18 | within a rectangle. The textbox is positioned and clipped by its Frame. |
michael@0 | 19 | The Margin rectangle controls where the text is drawn relative to |
michael@0 | 20 | the Frame. Line-breaks occur inside the Margin rectangle. |
michael@0 | 21 | |
michael@0 | 22 | Spacing is a linear equation used to compute the distance between lines |
michael@0 | 23 | of text. Spacing consists of two scalars: mul and add, and the spacing |
michael@0 | 24 | between lines is computed as: spacing = paint.getTextSize() * mul + add |
michael@0 | 25 | */ |
michael@0 | 26 | class SkTextBox { |
michael@0 | 27 | public: |
michael@0 | 28 | SkTextBox(); |
michael@0 | 29 | |
michael@0 | 30 | enum Mode { |
michael@0 | 31 | kOneLine_Mode, |
michael@0 | 32 | kLineBreak_Mode, |
michael@0 | 33 | |
michael@0 | 34 | kModeCount |
michael@0 | 35 | }; |
michael@0 | 36 | Mode getMode() const { return (Mode)fMode; } |
michael@0 | 37 | void setMode(Mode); |
michael@0 | 38 | |
michael@0 | 39 | enum SpacingAlign { |
michael@0 | 40 | kStart_SpacingAlign, |
michael@0 | 41 | kCenter_SpacingAlign, |
michael@0 | 42 | kEnd_SpacingAlign, |
michael@0 | 43 | |
michael@0 | 44 | kSpacingAlignCount |
michael@0 | 45 | }; |
michael@0 | 46 | SpacingAlign getSpacingAlign() const { return (SpacingAlign)fSpacingAlign; } |
michael@0 | 47 | void setSpacingAlign(SpacingAlign); |
michael@0 | 48 | |
michael@0 | 49 | void getBox(SkRect*) const; |
michael@0 | 50 | void setBox(const SkRect&); |
michael@0 | 51 | void setBox(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom); |
michael@0 | 52 | |
michael@0 | 53 | void getSpacing(SkScalar* mul, SkScalar* add) const; |
michael@0 | 54 | void setSpacing(SkScalar mul, SkScalar add); |
michael@0 | 55 | |
michael@0 | 56 | void draw(SkCanvas*, const char text[], size_t len, const SkPaint&); |
michael@0 | 57 | |
michael@0 | 58 | void setText(const char text[], size_t len, const SkPaint&); |
michael@0 | 59 | void draw(SkCanvas*); |
michael@0 | 60 | int countLines() const; |
michael@0 | 61 | SkScalar getTextHeight() const; |
michael@0 | 62 | |
michael@0 | 63 | private: |
michael@0 | 64 | SkRect fBox; |
michael@0 | 65 | SkScalar fSpacingMul, fSpacingAdd; |
michael@0 | 66 | uint8_t fMode, fSpacingAlign; |
michael@0 | 67 | const char* fText; |
michael@0 | 68 | size_t fLen; |
michael@0 | 69 | const SkPaint* fPaint; |
michael@0 | 70 | }; |
michael@0 | 71 | |
michael@0 | 72 | class SkTextLineBreaker { |
michael@0 | 73 | public: |
michael@0 | 74 | static int CountLines(const char text[], size_t len, const SkPaint&, SkScalar width); |
michael@0 | 75 | }; |
michael@0 | 76 | |
michael@0 | 77 | #endif |