gfx/skia/trunk/src/animator/SkDisplayAdd.cpp

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

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 #include "SkDisplayAdd.h"
michael@0 11 #include "SkAnimateMaker.h"
michael@0 12 #include "SkDisplayApply.h"
michael@0 13 #include "SkDisplayList.h"
michael@0 14 #include "SkDrawable.h"
michael@0 15 #include "SkDrawGroup.h"
michael@0 16
michael@0 17 #if SK_USE_CONDENSED_INFO == 0
michael@0 18
michael@0 19 const SkMemberInfo SkAdd::fInfo[] = {
michael@0 20 SK_MEMBER(mode, AddMode),
michael@0 21 SK_MEMBER(offset, Int),
michael@0 22 SK_MEMBER(use, Drawable),
michael@0 23 SK_MEMBER(where, Drawable)
michael@0 24 };
michael@0 25
michael@0 26 #endif
michael@0 27
michael@0 28 // start here;
michael@0 29 // add onEndElement to turn where string into f_Where
michael@0 30 // probably need new SkAnimateMaker::resolve flavor that takes
michael@0 31 // where="id", where="event-target" or not-specified
michael@0 32 // offset="#" (implements before, after, and index if no 'where')
michael@0 33
michael@0 34 DEFINE_GET_MEMBER(SkAdd);
michael@0 35
michael@0 36 SkAdd::SkAdd() : mode(kMode_indirect),
michael@0 37 offset(SK_MaxS32), use(NULL), where(NULL) {
michael@0 38 }
michael@0 39
michael@0 40 SkDisplayable* SkAdd::deepCopy(SkAnimateMaker* maker) {
michael@0 41 SkDrawable* saveUse = use;
michael@0 42 SkDrawable* saveWhere = where;
michael@0 43 use = NULL;
michael@0 44 where = NULL;
michael@0 45 SkAdd* copy = (SkAdd*) INHERITED::deepCopy(maker);
michael@0 46 copy->use = use = saveUse;
michael@0 47 copy->where = where = saveWhere;
michael@0 48 return copy;
michael@0 49 }
michael@0 50
michael@0 51 bool SkAdd::draw(SkAnimateMaker& maker) {
michael@0 52 SkASSERT(use);
michael@0 53 SkASSERT(use->isDrawable());
michael@0 54 if (mode == kMode_indirect)
michael@0 55 use->draw(maker);
michael@0 56 return false;
michael@0 57 }
michael@0 58
michael@0 59 #ifdef SK_DUMP_ENABLED
michael@0 60 void SkAdd::dump(SkAnimateMaker* maker) {
michael@0 61 dumpBase(maker);
michael@0 62 dumpAttrs(maker);
michael@0 63 if (where)
michael@0 64 SkDebugf("where=\"%s\" ", where->id);
michael@0 65 if (mode == kMode_immediate)
michael@0 66 SkDebugf("mode=\"immediate\" ");
michael@0 67 SkDebugf(">\n");
michael@0 68 SkDisplayList::fIndent += 4;
michael@0 69 int save = SkDisplayList::fDumpIndex;
michael@0 70 if (use) //just in case
michael@0 71 use->dump(maker);
michael@0 72 SkDisplayList::fIndent -= 4;
michael@0 73 SkDisplayList::fDumpIndex = save;
michael@0 74 dumpEnd(maker);
michael@0 75 }
michael@0 76 #endif
michael@0 77
michael@0 78 bool SkAdd::enable(SkAnimateMaker& maker ) {
michael@0 79 SkDisplayTypes type = getType();
michael@0 80 SkDisplayList& displayList = maker.fDisplayList;
michael@0 81 SkTDDrawableArray* parentList = displayList.getDrawList();
michael@0 82 if (type == SkType_Add) {
michael@0 83 if (use == NULL) // not set in apply yet
michael@0 84 return true;
michael@0 85 }
michael@0 86 bool skipAddToParent = true;
michael@0 87 SkASSERT(type != SkType_Replace || where);
michael@0 88 SkTDDrawableArray* grandList SK_INIT_TO_AVOID_WARNING;
michael@0 89 SkGroup* parentGroup = NULL;
michael@0 90 SkGroup* thisGroup = NULL;
michael@0 91 int index = where ? displayList.findGroup(where, &parentList, &parentGroup,
michael@0 92 &thisGroup, &grandList) : 0;
michael@0 93 if (index < 0)
michael@0 94 return true;
michael@0 95 int max = parentList->count();
michael@0 96 if (where == NULL && type == SkType_Move)
michael@0 97 index = max;
michael@0 98 if (offset != SK_MaxS32) {
michael@0 99 index += offset;
michael@0 100 if (index > max) {
michael@0 101 maker.setErrorCode(SkDisplayXMLParserError::kIndexOutOfRange);
michael@0 102 return true; // caller should not add
michael@0 103 }
michael@0 104 }
michael@0 105 if (offset < 0 && where == NULL)
michael@0 106 index += max + 1;
michael@0 107 switch (type) {
michael@0 108 case SkType_Add:
michael@0 109 if (offset == SK_MaxS32 && where == NULL) {
michael@0 110 if (use->isDrawable()) {
michael@0 111 skipAddToParent = mode == kMode_immediate;
michael@0 112 if (skipAddToParent) {
michael@0 113 if (where == NULL) {
michael@0 114 SkTDDrawableArray* useParentList;
michael@0 115 index = displayList.findGroup(this, &useParentList, &parentGroup,
michael@0 116 &thisGroup, &grandList);
michael@0 117 if (index >= 0) {
michael@0 118 parentGroup->markCopySize(index);
michael@0 119 parentGroup->markCopySet(index);
michael@0 120 useParentList->begin()[index] = use;
michael@0 121 break;
michael@0 122 }
michael@0 123 }
michael@0 124 *parentList->append() = use;
michael@0 125 }
michael@0 126 }
michael@0 127 break;
michael@0 128 } else {
michael@0 129 if (thisGroup)
michael@0 130 thisGroup->markCopySize(index);
michael@0 131 *parentList->insert(index) = use;
michael@0 132 if (thisGroup)
michael@0 133 thisGroup->markCopySet(index);
michael@0 134 if (use->isApply())
michael@0 135 ((SkApply*) use)->setEmbedded();
michael@0 136 }
michael@0 137 break;
michael@0 138 case SkType_Move: {
michael@0 139 int priorLocation = parentList->find(use);
michael@0 140 if (priorLocation < 0)
michael@0 141 break;
michael@0 142 *parentList->insert(index) = use;
michael@0 143 if (index < priorLocation)
michael@0 144 priorLocation++;
michael@0 145 parentList->remove(priorLocation);
michael@0 146 } break;
michael@0 147 case SkType_Remove: {
michael@0 148 SkDisplayable* old = (*parentList)[index];
michael@0 149 if (((SkRemove*)(this))->fDelete) {
michael@0 150 delete old;
michael@0 151 goto noHelperNeeded;
michael@0 152 }
michael@0 153 for (int inner = 0; inner < maker.fChildren.count(); inner++) {
michael@0 154 SkDisplayable* child = maker.fChildren[inner];
michael@0 155 if (child == old || child->contains(old))
michael@0 156 goto noHelperNeeded;
michael@0 157 }
michael@0 158 if (maker.fHelpers.find(old) < 0)
michael@0 159 maker.helperAdd(old);
michael@0 160 noHelperNeeded:
michael@0 161 parentList->remove(index);
michael@0 162 } break;
michael@0 163 case SkType_Replace:
michael@0 164 if (thisGroup) {
michael@0 165 thisGroup->markCopySize(index);
michael@0 166 if (thisGroup->markedForDelete(index)) {
michael@0 167 SkDisplayable* old = (*parentList)[index];
michael@0 168 if (maker.fHelpers.find(old) < 0)
michael@0 169 maker.helperAdd(old);
michael@0 170 }
michael@0 171 }
michael@0 172 (*parentList)[index] = use;
michael@0 173 if (thisGroup)
michael@0 174 thisGroup->markCopySet(index);
michael@0 175 break;
michael@0 176 default:
michael@0 177 SkASSERT(0);
michael@0 178 }
michael@0 179 if (type == SkType_Remove)
michael@0 180 return true;
michael@0 181 if (use->hasEnable())
michael@0 182 use->enable(maker);
michael@0 183 return skipAddToParent; // append if indirect: *parentList->append() = this;
michael@0 184 }
michael@0 185
michael@0 186 bool SkAdd::hasEnable() const {
michael@0 187 return true;
michael@0 188 }
michael@0 189
michael@0 190 void SkAdd::initialize() {
michael@0 191 if (use)
michael@0 192 use->initialize();
michael@0 193 }
michael@0 194
michael@0 195 bool SkAdd::isDrawable() const {
michael@0 196 return getType() == SkType_Add && mode == kMode_indirect && offset == SK_MaxS32 &&
michael@0 197 where == NULL && use != NULL && use->isDrawable();
michael@0 198 }
michael@0 199
michael@0 200 //SkDisplayable* SkAdd::resolveTarget(SkAnimateMaker& maker) {
michael@0 201 // return use;
michael@0 202 //}
michael@0 203
michael@0 204
michael@0 205 bool SkClear::enable(SkAnimateMaker& maker ) {
michael@0 206 SkDisplayList& displayList = maker.fDisplayList;
michael@0 207 displayList.clear();
michael@0 208 return true;
michael@0 209 }
michael@0 210
michael@0 211
michael@0 212 #if SK_USE_CONDENSED_INFO == 0
michael@0 213
michael@0 214 const SkMemberInfo SkMove::fInfo[] = {
michael@0 215 SK_MEMBER_INHERITED
michael@0 216 };
michael@0 217
michael@0 218 #endif
michael@0 219
michael@0 220 DEFINE_GET_MEMBER(SkMove);
michael@0 221
michael@0 222 #if SK_USE_CONDENSED_INFO == 0
michael@0 223
michael@0 224 const SkMemberInfo SkRemove::fInfo[] = {
michael@0 225 SK_MEMBER_ALIAS(delete, fDelete, Boolean), // !!! experimental
michael@0 226 SK_MEMBER(offset, Int),
michael@0 227 SK_MEMBER(where, Drawable)
michael@0 228 };
michael@0 229
michael@0 230 #endif
michael@0 231
michael@0 232 DEFINE_GET_MEMBER(SkRemove);
michael@0 233
michael@0 234 SkRemove::SkRemove() : fDelete(false) {
michael@0 235 }
michael@0 236
michael@0 237 #if SK_USE_CONDENSED_INFO == 0
michael@0 238
michael@0 239 const SkMemberInfo SkReplace::fInfo[] = {
michael@0 240 SK_MEMBER_INHERITED
michael@0 241 };
michael@0 242
michael@0 243 #endif
michael@0 244
michael@0 245 DEFINE_GET_MEMBER(SkReplace);

mercurial