3 * Copyright (C) 2012 Google, Inc. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY GOOGLE INC. ``AS IS'' AND ANY
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 #include "core/frame/UseCounter.h"
30 #include "core/css/CSSStyleSheet.h"
31 #include "core/css/StyleSheetContents.h"
32 #include "core/dom/Document.h"
33 #include "core/dom/ExecutionContext.h"
34 #include "core/frame/LocalDOMWindow.h"
35 #include "core/frame/FrameConsole.h"
36 #include "core/frame/FrameHost.h"
37 #include "core/frame/LocalFrame.h"
38 #include "core/inspector/ConsoleMessage.h"
39 #include "core/workers/WorkerGlobalScope.h"
40 #include "public/platform/Platform.h"
44 static int totalPagesMeasuredCSSSampleId() { return 1; }
46 int UseCounter::m_muteCount = 0;
48 // FIXME : This mapping should be autogenerated. This function should
49 // be moved to a separate file and a script run at build time
50 // to detect new values in CSSPropertyID and add them to the
51 // end of this function. This file would be checked in.
52 // https://code.google.com/p/chromium/issues/detail?id=234940
53 int UseCounter::mapCSSPropertyIdToCSSSampleIdForHistogram(int id)
55 CSSPropertyID cssPropertyID = convertToCSSPropertyID(id);
57 switch (cssPropertyID) {
58 // Begin at 2, because 1 is reserved for totalPagesMeasuredCSSSampleId.
59 case CSSPropertyColor: return 2;
60 case CSSPropertyDirection: return 3;
61 case CSSPropertyDisplay: return 4;
62 case CSSPropertyFont: return 5;
63 case CSSPropertyFontFamily: return 6;
64 case CSSPropertyFontSize: return 7;
65 case CSSPropertyFontStyle: return 8;
66 case CSSPropertyFontVariant: return 9;
67 case CSSPropertyFontWeight: return 10;
68 case CSSPropertyTextRendering: return 11;
69 case CSSPropertyWebkitFontFeatureSettings: return 12;
70 case CSSPropertyFontKerning: return 13;
71 case CSSPropertyWebkitFontSmoothing: return 14;
72 case CSSPropertyFontVariantLigatures: return 15;
73 case CSSPropertyWebkitLocale: return 16;
74 case CSSPropertyWebkitTextOrientation: return 17;
75 case CSSPropertyWebkitWritingMode: return 18;
76 case CSSPropertyZoom: return 19;
77 case CSSPropertyLineHeight: return 20;
78 case CSSPropertyBackground: return 21;
79 case CSSPropertyBackgroundAttachment: return 22;
80 case CSSPropertyBackgroundClip: return 23;
81 case CSSPropertyBackgroundColor: return 24;
82 case CSSPropertyBackgroundImage: return 25;
83 case CSSPropertyBackgroundOrigin: return 26;
84 case CSSPropertyBackgroundPosition: return 27;
85 case CSSPropertyBackgroundPositionX: return 28;
86 case CSSPropertyBackgroundPositionY: return 29;
87 case CSSPropertyBackgroundRepeat: return 30;
88 case CSSPropertyBackgroundRepeatX: return 31;
89 case CSSPropertyBackgroundRepeatY: return 32;
90 case CSSPropertyBackgroundSize: return 33;
91 case CSSPropertyBorder: return 34;
92 case CSSPropertyBorderBottom: return 35;
93 case CSSPropertyBorderBottomColor: return 36;
94 case CSSPropertyBorderBottomLeftRadius: return 37;
95 case CSSPropertyBorderBottomRightRadius: return 38;
96 case CSSPropertyBorderBottomStyle: return 39;
97 case CSSPropertyBorderBottomWidth: return 40;
98 case CSSPropertyBorderCollapse: return 41;
99 case CSSPropertyBorderColor: return 42;
100 case CSSPropertyBorderImage: return 43;
101 case CSSPropertyBorderImageOutset: return 44;
102 case CSSPropertyBorderImageRepeat: return 45;
103 case CSSPropertyBorderImageSlice: return 46;
104 case CSSPropertyBorderImageSource: return 47;
105 case CSSPropertyBorderImageWidth: return 48;
106 case CSSPropertyBorderLeft: return 49;
107 case CSSPropertyBorderLeftColor: return 50;
108 case CSSPropertyBorderLeftStyle: return 51;
109 case CSSPropertyBorderLeftWidth: return 52;
110 case CSSPropertyBorderRadius: return 53;
111 case CSSPropertyBorderRight: return 54;
112 case CSSPropertyBorderRightColor: return 55;
113 case CSSPropertyBorderRightStyle: return 56;
114 case CSSPropertyBorderRightWidth: return 57;
115 case CSSPropertyBorderSpacing: return 58;
116 case CSSPropertyBorderStyle: return 59;
117 case CSSPropertyBorderTop: return 60;
118 case CSSPropertyBorderTopColor: return 61;
119 case CSSPropertyBorderTopLeftRadius: return 62;
120 case CSSPropertyBorderTopRightRadius: return 63;
121 case CSSPropertyBorderTopStyle: return 64;
122 case CSSPropertyBorderTopWidth: return 65;
123 case CSSPropertyBorderWidth: return 66;
124 case CSSPropertyBottom: return 67;
125 case CSSPropertyBoxShadow: return 68;
126 case CSSPropertyBoxSizing: return 69;
127 case CSSPropertyCaptionSide: return 70;
128 case CSSPropertyClear: return 71;
129 case CSSPropertyClip: return 72;
130 case CSSPropertyWebkitClipPath: return 73;
131 case CSSPropertyContent: return 74;
132 case CSSPropertyCounterIncrement: return 75;
133 case CSSPropertyCounterReset: return 76;
134 case CSSPropertyCursor: return 77;
135 case CSSPropertyEmptyCells: return 78;
136 case CSSPropertyFloat: return 79;
137 case CSSPropertyFontStretch: return 80;
138 case CSSPropertyHeight: return 81;
139 case CSSPropertyImageRendering: return 82;
140 case CSSPropertyLeft: return 83;
141 case CSSPropertyLetterSpacing: return 84;
142 case CSSPropertyListStyle: return 85;
143 case CSSPropertyListStyleImage: return 86;
144 case CSSPropertyListStylePosition: return 87;
145 case CSSPropertyListStyleType: return 88;
146 case CSSPropertyMargin: return 89;
147 case CSSPropertyMarginBottom: return 90;
148 case CSSPropertyMarginLeft: return 91;
149 case CSSPropertyMarginRight: return 92;
150 case CSSPropertyMarginTop: return 93;
151 case CSSPropertyMaxHeight: return 94;
152 case CSSPropertyMaxWidth: return 95;
153 case CSSPropertyMinHeight: return 96;
154 case CSSPropertyMinWidth: return 97;
155 case CSSPropertyOpacity: return 98;
156 case CSSPropertyOrphans: return 99;
157 case CSSPropertyOutline: return 100;
158 case CSSPropertyOutlineColor: return 101;
159 case CSSPropertyOutlineOffset: return 102;
160 case CSSPropertyOutlineStyle: return 103;
161 case CSSPropertyOutlineWidth: return 104;
162 case CSSPropertyOverflow: return 105;
163 case CSSPropertyOverflowWrap: return 106;
164 case CSSPropertyOverflowX: return 107;
165 case CSSPropertyOverflowY: return 108;
166 case CSSPropertyPadding: return 109;
167 case CSSPropertyPaddingBottom: return 110;
168 case CSSPropertyPaddingLeft: return 111;
169 case CSSPropertyPaddingRight: return 112;
170 case CSSPropertyPaddingTop: return 113;
171 case CSSPropertyPage: return 114;
172 case CSSPropertyPageBreakAfter: return 115;
173 case CSSPropertyPageBreakBefore: return 116;
174 case CSSPropertyPageBreakInside: return 117;
175 case CSSPropertyPointerEvents: return 118;
176 case CSSPropertyPosition: return 119;
177 case CSSPropertyQuotes: return 120;
178 case CSSPropertyResize: return 121;
179 case CSSPropertyRight: return 122;
180 case CSSPropertySize: return 123;
181 case CSSPropertySrc: return 124;
182 case CSSPropertySpeak: return 125;
183 case CSSPropertyTableLayout: return 126;
184 case CSSPropertyTabSize: return 127;
185 case CSSPropertyTextAlign: return 128;
186 case CSSPropertyTextDecoration: return 129;
187 case CSSPropertyTextIndent: return 130;
188 /* Removed CSSPropertyTextLineThrough* - 131-135 */
189 case CSSPropertyTextOverflow: return 136;
190 /* Removed CSSPropertyTextOverline* - 137-141 */
191 case CSSPropertyTextShadow: return 142;
192 case CSSPropertyTextTransform: return 143;
193 /* Removed CSSPropertyTextUnderline* - 144-148 */
194 case CSSPropertyTop: return 149;
195 case CSSPropertyTransition: return 150;
196 case CSSPropertyTransitionDelay: return 151;
197 case CSSPropertyTransitionDuration: return 152;
198 case CSSPropertyTransitionProperty: return 153;
199 case CSSPropertyTransitionTimingFunction: return 154;
200 case CSSPropertyUnicodeBidi: return 155;
201 case CSSPropertyUnicodeRange: return 156;
202 case CSSPropertyVerticalAlign: return 157;
203 case CSSPropertyVisibility: return 158;
204 case CSSPropertyWhiteSpace: return 159;
205 case CSSPropertyWidows: return 160;
206 case CSSPropertyWidth: return 161;
207 case CSSPropertyWordBreak: return 162;
208 case CSSPropertyWordSpacing: return 163;
209 case CSSPropertyWordWrap: return 164;
210 case CSSPropertyZIndex: return 165;
211 case CSSPropertyWebkitAnimation: return 166;
212 case CSSPropertyWebkitAnimationDelay: return 167;
213 case CSSPropertyWebkitAnimationDirection: return 168;
214 case CSSPropertyWebkitAnimationDuration: return 169;
215 case CSSPropertyWebkitAnimationFillMode: return 170;
216 case CSSPropertyWebkitAnimationIterationCount: return 171;
217 case CSSPropertyWebkitAnimationName: return 172;
218 case CSSPropertyWebkitAnimationPlayState: return 173;
219 case CSSPropertyWebkitAnimationTimingFunction: return 174;
220 case CSSPropertyWebkitAppearance: return 175;
221 case CSSPropertyWebkitAspectRatio: return 176;
222 case CSSPropertyWebkitBackfaceVisibility: return 177;
223 case CSSPropertyWebkitBackgroundClip: return 178;
224 case CSSPropertyWebkitBackgroundComposite: return 179;
225 case CSSPropertyWebkitBackgroundOrigin: return 180;
226 case CSSPropertyWebkitBackgroundSize: return 181;
227 case CSSPropertyWebkitBorderAfter: return 182;
228 case CSSPropertyWebkitBorderAfterColor: return 183;
229 case CSSPropertyWebkitBorderAfterStyle: return 184;
230 case CSSPropertyWebkitBorderAfterWidth: return 185;
231 case CSSPropertyWebkitBorderBefore: return 186;
232 case CSSPropertyWebkitBorderBeforeColor: return 187;
233 case CSSPropertyWebkitBorderBeforeStyle: return 188;
234 case CSSPropertyWebkitBorderBeforeWidth: return 189;
235 case CSSPropertyWebkitBorderEnd: return 190;
236 case CSSPropertyWebkitBorderEndColor: return 191;
237 case CSSPropertyWebkitBorderEndStyle: return 192;
238 case CSSPropertyWebkitBorderEndWidth: return 193;
239 case CSSPropertyWebkitBorderFit: return 194;
240 case CSSPropertyWebkitBorderHorizontalSpacing: return 195;
241 case CSSPropertyWebkitBorderImage: return 196;
242 case CSSPropertyWebkitBorderRadius: return 197;
243 case CSSPropertyWebkitBorderStart: return 198;
244 case CSSPropertyWebkitBorderStartColor: return 199;
245 case CSSPropertyWebkitBorderStartStyle: return 200;
246 case CSSPropertyWebkitBorderStartWidth: return 201;
247 case CSSPropertyWebkitBorderVerticalSpacing: return 202;
248 case CSSPropertyWebkitBoxAlign: return 203;
249 case CSSPropertyWebkitBoxDirection: return 204;
250 case CSSPropertyWebkitBoxFlex: return 205;
251 case CSSPropertyWebkitBoxFlexGroup: return 206;
252 case CSSPropertyWebkitBoxLines: return 207;
253 case CSSPropertyWebkitBoxOrdinalGroup: return 208;
254 case CSSPropertyWebkitBoxOrient: return 209;
255 case CSSPropertyWebkitBoxPack: return 210;
256 case CSSPropertyWebkitBoxReflect: return 211;
257 case CSSPropertyWebkitBoxShadow: return 212;
258 // CSSPropertyWebkitColumnAxis was 214
259 case CSSPropertyWebkitColumnBreakAfter: return 215;
260 case CSSPropertyWebkitColumnBreakBefore: return 216;
261 case CSSPropertyWebkitColumnBreakInside: return 217;
262 case CSSPropertyWebkitColumnCount: return 218;
263 case CSSPropertyWebkitColumnGap: return 219;
264 // CSSPropertyWebkitColumnProgression was 220
265 case CSSPropertyWebkitColumnRule: return 221;
266 case CSSPropertyWebkitColumnRuleColor: return 222;
267 case CSSPropertyWebkitColumnRuleStyle: return 223;
268 case CSSPropertyWebkitColumnRuleWidth: return 224;
269 case CSSPropertyWebkitColumnSpan: return 225;
270 case CSSPropertyWebkitColumnWidth: return 226;
271 case CSSPropertyWebkitColumns: return 227;
272 #if defined(ENABLE_CSS_BOX_DECORATION_BREAK) && ENABLE_CSS_BOX_DECORATION_BREAK
273 case CSSPropertyWebkitBoxDecorationBreak: return 228;
275 #if defined(ENABLE_CSS_FILTERS) && ENABLE_CSS_FILTERS
276 case CSSPropertyWebkitFilter: return 229;
278 case CSSPropertyAlignContent: return 230;
279 case CSSPropertyAlignItems: return 231;
280 case CSSPropertyAlignSelf: return 232;
281 case CSSPropertyFlex: return 233;
282 case CSSPropertyFlexBasis: return 234;
283 case CSSPropertyFlexDirection: return 235;
284 case CSSPropertyFlexFlow: return 236;
285 case CSSPropertyFlexGrow: return 237;
286 case CSSPropertyFlexShrink: return 238;
287 case CSSPropertyFlexWrap: return 239;
288 case CSSPropertyJustifyContent: return 240;
289 case CSSPropertyWebkitFontSizeDelta: return 241;
290 case CSSPropertyGridTemplateColumns: return 242;
291 case CSSPropertyGridTemplateRows: return 243;
292 case CSSPropertyGridColumnStart: return 244;
293 case CSSPropertyGridColumnEnd: return 245;
294 case CSSPropertyGridRowStart: return 246;
295 case CSSPropertyGridRowEnd: return 247;
296 case CSSPropertyGridColumn: return 248;
297 case CSSPropertyGridRow: return 249;
298 case CSSPropertyGridAutoFlow: return 250;
299 case CSSPropertyWebkitHighlight: return 251;
300 case CSSPropertyWebkitHyphenateCharacter: return 252;
301 case CSSPropertyWebkitLineBoxContain: return 257;
302 // case CSSPropertyWebkitLineAlign: return 258;
303 case CSSPropertyWebkitLineBreak: return 259;
304 case CSSPropertyWebkitLineClamp: return 260;
305 // case CSSPropertyWebkitLineGrid: return 261;
306 // case CSSPropertyWebkitLineSnap: return 262;
307 case CSSPropertyWebkitLogicalWidth: return 263;
308 case CSSPropertyWebkitLogicalHeight: return 264;
309 case CSSPropertyWebkitMarginAfterCollapse: return 265;
310 case CSSPropertyWebkitMarginBeforeCollapse: return 266;
311 case CSSPropertyWebkitMarginBottomCollapse: return 267;
312 case CSSPropertyWebkitMarginTopCollapse: return 268;
313 case CSSPropertyWebkitMarginCollapse: return 269;
314 case CSSPropertyWebkitMarginAfter: return 270;
315 case CSSPropertyWebkitMarginBefore: return 271;
316 case CSSPropertyWebkitMarginEnd: return 272;
317 case CSSPropertyWebkitMarginStart: return 273;
318 // CSSPropertyWebkitMarquee was 274.
319 // CSSPropertyInternalMarquee* were 275-279.
320 case CSSPropertyWebkitMask: return 280;
321 case CSSPropertyWebkitMaskBoxImage: return 281;
322 case CSSPropertyWebkitMaskBoxImageOutset: return 282;
323 case CSSPropertyWebkitMaskBoxImageRepeat: return 283;
324 case CSSPropertyWebkitMaskBoxImageSlice: return 284;
325 case CSSPropertyWebkitMaskBoxImageSource: return 285;
326 case CSSPropertyWebkitMaskBoxImageWidth: return 286;
327 case CSSPropertyWebkitMaskClip: return 287;
328 case CSSPropertyWebkitMaskComposite: return 288;
329 case CSSPropertyWebkitMaskImage: return 289;
330 case CSSPropertyWebkitMaskOrigin: return 290;
331 case CSSPropertyWebkitMaskPosition: return 291;
332 case CSSPropertyWebkitMaskPositionX: return 292;
333 case CSSPropertyWebkitMaskPositionY: return 293;
334 case CSSPropertyWebkitMaskRepeat: return 294;
335 case CSSPropertyWebkitMaskRepeatX: return 295;
336 case CSSPropertyWebkitMaskRepeatY: return 296;
337 case CSSPropertyWebkitMaskSize: return 297;
338 case CSSPropertyWebkitMaxLogicalWidth: return 298;
339 case CSSPropertyWebkitMaxLogicalHeight: return 299;
340 case CSSPropertyWebkitMinLogicalWidth: return 300;
341 case CSSPropertyWebkitMinLogicalHeight: return 301;
342 // WebkitNbspMode has been deleted, was return 302;
343 case CSSPropertyOrder: return 303;
344 case CSSPropertyWebkitPaddingAfter: return 304;
345 case CSSPropertyWebkitPaddingBefore: return 305;
346 case CSSPropertyWebkitPaddingEnd: return 306;
347 case CSSPropertyWebkitPaddingStart: return 307;
348 case CSSPropertyWebkitPerspective: return 308;
349 case CSSPropertyWebkitPerspectiveOrigin: return 309;
350 case CSSPropertyWebkitPerspectiveOriginX: return 310;
351 case CSSPropertyWebkitPerspectiveOriginY: return 311;
352 case CSSPropertyWebkitPrintColorAdjust: return 312;
353 case CSSPropertyWebkitRtlOrdering: return 313;
354 case CSSPropertyWebkitRubyPosition: return 314;
355 case CSSPropertyWebkitTextCombine: return 315;
356 case CSSPropertyWebkitTextDecorationsInEffect: return 316;
357 case CSSPropertyWebkitTextEmphasis: return 317;
358 case CSSPropertyWebkitTextEmphasisColor: return 318;
359 case CSSPropertyWebkitTextEmphasisPosition: return 319;
360 case CSSPropertyWebkitTextEmphasisStyle: return 320;
361 case CSSPropertyWebkitTextFillColor: return 321;
362 case CSSPropertyWebkitTextSecurity: return 322;
363 case CSSPropertyWebkitTextStroke: return 323;
364 case CSSPropertyWebkitTextStrokeColor: return 324;
365 case CSSPropertyWebkitTextStrokeWidth: return 325;
366 case CSSPropertyWebkitTransform: return 326;
367 case CSSPropertyWebkitTransformOrigin: return 327;
368 case CSSPropertyWebkitTransformOriginX: return 328;
369 case CSSPropertyWebkitTransformOriginY: return 329;
370 case CSSPropertyWebkitTransformOriginZ: return 330;
371 case CSSPropertyWebkitTransformStyle: return 331;
372 case CSSPropertyWebkitTransition: return 332;
373 case CSSPropertyWebkitTransitionDelay: return 333;
374 case CSSPropertyWebkitTransitionDuration: return 334;
375 case CSSPropertyWebkitTransitionProperty: return 335;
376 case CSSPropertyWebkitTransitionTimingFunction: return 336;
377 case CSSPropertyWebkitUserDrag: return 337;
378 case CSSPropertyWebkitUserModify: return 338;
379 case CSSPropertyWebkitUserSelect: return 339;
380 // case CSSPropertyWebkitFlowInto: return 340;
381 // case CSSPropertyWebkitFlowFrom: return 341;
382 // case CSSPropertyWebkitRegionFragment: return 342;
383 // case CSSPropertyWebkitRegionBreakAfter: return 343;
384 // case CSSPropertyWebkitRegionBreakBefore: return 344;
385 // case CSSPropertyWebkitRegionBreakInside: return 345;
386 // case CSSPropertyShapeInside: return 346;
387 case CSSPropertyShapeOutside: return 347;
388 case CSSPropertyShapeMargin: return 348;
389 // case CSSPropertyShapePadding: return 349;
390 // case CSSPropertyWebkitWrapFlow: return 350;
391 // case CSSPropertyWebkitWrapThrough: return 351;
392 // CSSPropertyWebkitWrap was 352.
393 #if defined(ENABLE_TOUCH_EVENTS) && ENABLE_TOUCH_EVENTS
394 case CSSPropertyWebkitTapHighlightColor: return 353;
396 #if defined(ENABLE_DRAGGABLE_REGION) && ENABLE_DRAGGABLE_REGION
397 case CSSPropertyWebkitAppRegion: return 354;
399 case CSSPropertyClipPath: return 355;
400 case CSSPropertyClipRule: return 356;
401 case CSSPropertyMask: return 357;
402 case CSSPropertyEnableBackground: return 358;
403 case CSSPropertyFilter: return 359;
404 case CSSPropertyFloodColor: return 360;
405 case CSSPropertyFloodOpacity: return 361;
406 case CSSPropertyLightingColor: return 362;
407 case CSSPropertyStopColor: return 363;
408 case CSSPropertyStopOpacity: return 364;
409 case CSSPropertyColorInterpolation: return 365;
410 case CSSPropertyColorInterpolationFilters: return 366;
411 // case CSSPropertyColorProfile: return 367;
412 case CSSPropertyColorRendering: return 368;
413 case CSSPropertyFill: return 369;
414 case CSSPropertyFillOpacity: return 370;
415 case CSSPropertyFillRule: return 371;
416 case CSSPropertyMarker: return 372;
417 case CSSPropertyMarkerEnd: return 373;
418 case CSSPropertyMarkerMid: return 374;
419 case CSSPropertyMarkerStart: return 375;
420 case CSSPropertyMaskType: return 376;
421 case CSSPropertyShapeRendering: return 377;
422 case CSSPropertyStroke: return 378;
423 case CSSPropertyStrokeDasharray: return 379;
424 case CSSPropertyStrokeDashoffset: return 380;
425 case CSSPropertyStrokeLinecap: return 381;
426 case CSSPropertyStrokeLinejoin: return 382;
427 case CSSPropertyStrokeMiterlimit: return 383;
428 case CSSPropertyStrokeOpacity: return 384;
429 case CSSPropertyStrokeWidth: return 385;
430 case CSSPropertyAlignmentBaseline: return 386;
431 case CSSPropertyBaselineShift: return 387;
432 case CSSPropertyDominantBaseline: return 388;
433 case CSSPropertyGlyphOrientationHorizontal: return 389;
434 case CSSPropertyGlyphOrientationVertical: return 390;
435 // CSSPropertyKerning has been removed, was return 391;
436 case CSSPropertyTextAnchor: return 392;
437 case CSSPropertyVectorEffect: return 393;
438 case CSSPropertyWritingMode: return 394;
439 // CSSPropertyWebkitSvgShadow has been removed, was return 395;
440 #if defined(ENABLE_CURSOR_VISIBILITY) && ENABLE_CURSOR_VISIBILITY
441 case CSSPropertyWebkitCursorVisibility: return 396;
443 // CSSPropertyImageOrientation has been removed, was return 397;
444 // CSSPropertyImageResolution has been removed, was return 398;
445 #if defined(ENABLE_CSS_COMPOSITING) && ENABLE_CSS_COMPOSITING
446 case CSSPropertyWebkitBlendMode: return 399;
447 case CSSPropertyWebkitBackgroundBlendMode: return 400;
449 case CSSPropertyTextDecorationLine: return 401;
450 case CSSPropertyTextDecorationStyle: return 402;
451 case CSSPropertyTextDecorationColor: return 403;
452 case CSSPropertyTextAlignLast: return 404;
453 case CSSPropertyTextUnderlinePosition: return 405;
454 case CSSPropertyMaxZoom: return 406;
455 case CSSPropertyMinZoom: return 407;
456 case CSSPropertyOrientation: return 408;
457 case CSSPropertyUserZoom: return 409;
458 // CSSPropertyWebkitDashboardRegion was 410.
459 // CSSPropertyWebkitOverflowScrolling was 411.
460 case CSSPropertyWebkitAppRegion: return 412;
461 case CSSPropertyWebkitFilter: return 413;
462 case CSSPropertyWebkitBoxDecorationBreak: return 414;
463 case CSSPropertyWebkitTapHighlightColor: return 415;
464 case CSSPropertyBufferedRendering: return 416;
465 case CSSPropertyGridAutoRows: return 417;
466 case CSSPropertyGridAutoColumns: return 418;
467 case CSSPropertyBackgroundBlendMode: return 419;
468 case CSSPropertyMixBlendMode: return 420;
469 case CSSPropertyTouchAction: return 421;
470 case CSSPropertyGridArea: return 422;
471 case CSSPropertyGridTemplateAreas: return 423;
472 case CSSPropertyAnimation: return 424;
473 case CSSPropertyAnimationDelay: return 425;
474 case CSSPropertyAnimationDirection: return 426;
475 case CSSPropertyAnimationDuration: return 427;
476 case CSSPropertyAnimationFillMode: return 428;
477 case CSSPropertyAnimationIterationCount: return 429;
478 case CSSPropertyAnimationName: return 430;
479 case CSSPropertyAnimationPlayState: return 431;
480 case CSSPropertyAnimationTimingFunction: return 432;
481 case CSSPropertyObjectFit: return 433;
482 case CSSPropertyPaintOrder: return 434;
483 case CSSPropertyMaskSourceType: return 435;
484 case CSSPropertyIsolation: return 436;
485 case CSSPropertyObjectPosition: return 437;
486 case CSSPropertyInternalCallback: return 438;
487 case CSSPropertyShapeImageThreshold: return 439;
488 case CSSPropertyColumnFill: return 440;
489 case CSSPropertyTextJustify: return 441;
490 case CSSPropertyTouchActionDelay: return 442;
491 case CSSPropertyJustifySelf: return 443;
492 case CSSPropertyScrollBehavior: return 444;
493 case CSSPropertyWillChange: return 445;
494 case CSSPropertyTransform: return 446;
495 case CSSPropertyTransformOrigin: return 447;
496 case CSSPropertyTransformStyle: return 448;
497 case CSSPropertyPerspective: return 449;
498 case CSSPropertyPerspectiveOrigin: return 450;
499 case CSSPropertyBackfaceVisibility: return 451;
500 case CSSPropertyGridTemplate: return 452;
501 case CSSPropertyGrid: return 453;
502 case CSSPropertyAll: return 454;
503 case CSSPropertyJustifyItems: return 455;
505 // 1. Add new features above this line (don't change the assigned numbers of the existing
507 // 2. Update maximumCSSSampleId() with the new maximum value.
508 // 3. Run the update_use_counter_css.py script in
509 // chromium/src/tools/metrics/histograms to update the UMA histogram names.
511 // Internal properties should not be counted.
512 case CSSPropertyInternalMarqueeDirection:
513 case CSSPropertyInternalMarqueeIncrement:
514 case CSSPropertyInternalMarqueeRepetition:
515 case CSSPropertyInternalMarqueeSpeed:
516 case CSSPropertyInternalMarqueeStyle:
517 case CSSPropertyInvalid:
518 ASSERT_NOT_REACHED();
522 ASSERT_NOT_REACHED();
526 static int maximumCSSSampleId() { return 455; }
528 void UseCounter::muteForInspector()
530 UseCounter::m_muteCount++;
533 void UseCounter::unmuteForInspector()
535 UseCounter::m_muteCount--;
538 UseCounter::UseCounter()
540 m_CSSFeatureBits.ensureSize(lastCSSProperty + 1);
541 m_CSSFeatureBits.clearAll();
544 UseCounter::~UseCounter()
546 // We always log PageDestruction so that we have a scale for the rest of the features.
547 blink::Platform::current()->histogramEnumeration("WebCore.FeatureObserver", PageDestruction, NumberOfFeatures);
549 updateMeasurements();
552 void UseCounter::updateMeasurements()
554 blink::Platform::current()->histogramEnumeration("WebCore.FeatureObserver", PageVisits, NumberOfFeatures);
557 for (unsigned i = 0; i < NumberOfFeatures; ++i) {
558 if (m_countBits->quickGet(i))
559 blink::Platform::current()->histogramEnumeration("WebCore.FeatureObserver", i, NumberOfFeatures);
561 // Clearing count bits is timing sensitive.
562 m_countBits->clearAll();
565 // FIXME: Sometimes this function is called more than once per page. The following
566 // bool guards against incrementing the page count when there are no CSS
567 // bits set. http://crbug.com/236262.
568 bool needsPagesMeasuredUpdate = false;
569 for (int i = firstCSSProperty; i <= lastCSSProperty; ++i) {
570 if (m_CSSFeatureBits.quickGet(i)) {
571 int cssSampleId = mapCSSPropertyIdToCSSSampleIdForHistogram(i);
572 blink::Platform::current()->histogramEnumeration("WebCore.FeatureObserver.CSSProperties", cssSampleId, maximumCSSSampleId());
573 needsPagesMeasuredUpdate = true;
577 if (needsPagesMeasuredUpdate)
578 blink::Platform::current()->histogramEnumeration("WebCore.FeatureObserver.CSSProperties", totalPagesMeasuredCSSSampleId(), maximumCSSSampleId());
580 m_CSSFeatureBits.clearAll();
583 void UseCounter::didCommitLoad()
585 updateMeasurements();
588 void UseCounter::count(const Document& document, Feature feature)
590 FrameHost* host = document.frameHost();
594 ASSERT(host->useCounter().deprecationMessage(feature).isEmpty());
595 host->useCounter().recordMeasurement(feature);
598 void UseCounter::count(const ExecutionContext* context, Feature feature)
602 if (context->isDocument()) {
603 count(*toDocument(context), feature);
606 if (context->isWorkerGlobalScope())
607 toWorkerGlobalScope(context)->countFeature(feature);
610 void UseCounter::countDeprecation(ExecutionContext* context, Feature feature)
614 if (context->isDocument()) {
615 UseCounter::countDeprecation(*toDocument(context), feature);
618 if (context->isWorkerGlobalScope())
619 toWorkerGlobalScope(context)->countDeprecation(feature);
622 void UseCounter::countDeprecation(const LocalDOMWindow* window, Feature feature)
624 if (!window || !window->document())
626 UseCounter::countDeprecation(*window->document(), feature);
629 void UseCounter::countDeprecation(const Document& document, Feature feature)
631 FrameHost* host = document.frameHost();
632 LocalFrame* frame = document.frame();
636 if (host->useCounter().recordMeasurement(feature)) {
637 ASSERT(!host->useCounter().deprecationMessage(feature).isEmpty());
638 frame->console().addMessage(ConsoleMessage::create(DeprecationMessageSource, WarningMessageLevel, host->useCounter().deprecationMessage(feature)));
642 // FIXME: Update other UseCounter::deprecationMessage() cases to use this.
643 static String replacedBy(const char* oldString, const char* newString)
645 return String::format("'%s' is deprecated. Please use '%s' instead.", oldString, newString);
648 String UseCounter::deprecationMessage(Feature feature)
652 case PrefixedStorageInfo:
653 return "'window.webkitStorageInfo' is deprecated. Please use 'navigator.webkitTemporaryStorage' or 'navigator.webkitPersistentStorage' instead.";
655 // Keyboard Event (DOM Level 3)
656 case KeyboardEventKeyLocation:
657 return replacedBy("KeyboardEvent.keyLocation", "KeyboardEvent.location");
659 case ConsoleMarkTimeline:
660 return "console.markTimeline is deprecated. Please use the console.timeStamp instead.";
663 return "FileError is deprecated. Please use the 'name' or 'message' attributes of DOMError rather than 'code'.";
665 case ShowModalDialog:
666 return "showModalDialog is deprecated. Please use window.open and postMessage instead.";
668 case CSSStyleSheetInsertRuleOptionalArg:
669 return "Calling CSSStyleSheet.insertRule() with one argument is deprecated. Please pass the index argument as well: insertRule(x, 0).";
671 case PrefixedVideoSupportsFullscreen:
672 return "'HTMLVideoElement.webkitSupportsFullscreen' is deprecated. Its value is true if the video is loaded.";
674 case PrefixedVideoDisplayingFullscreen:
675 return "'HTMLVideoElement.webkitDisplayingFullscreen' is deprecated. Please use the 'fullscreenchange' and 'webkitfullscreenchange' events instead.";
677 case PrefixedVideoEnterFullscreen:
678 return "'HTMLVideoElement.webkitEnterFullscreen()' is deprecated. Please use 'Element.requestFullscreen()' and 'Element.webkitRequestFullscreen()' instead.";
680 case PrefixedVideoExitFullscreen:
681 return "'HTMLVideoElement.webkitExitFullscreen()' is deprecated. Please use 'Document.exitFullscreen()' and 'Document.webkitExitFullscreen()' instead.";
683 case PrefixedVideoEnterFullScreen:
684 return "'HTMLVideoElement.webkitEnterFullScreen()' is deprecated. Please use 'Element.requestFullscreen()' and 'Element.webkitRequestFullscreen()' instead.";
686 case PrefixedVideoExitFullScreen:
687 return "'HTMLVideoElement.webkitExitFullScreen()' is deprecated. Please use 'Document.exitFullscreen()' and 'Document.webkitExitFullscreen()' instead.";
689 case MediaErrorEncrypted:
690 return "'MediaError.MEDIA_ERR_ENCRYPTED' is deprecated. This error code is never used.";
692 case PrefixedGamepad:
693 return replacedBy("navigator.webkitGetGamepads", "navigator.getGamepads");
695 case PrefixedIndexedDB:
696 return replacedBy("webkitIndexedDB", "indexedDB");
698 case PrefixedIDBCursorConstructor:
699 return replacedBy("webkitIDBCursor", "IDBCursor");
701 case PrefixedIDBDatabaseConstructor:
702 return replacedBy("webkitIDBDatabase", "IDBDatabase");
704 case PrefixedIDBFactoryConstructor:
705 return replacedBy("webkitIDBFactory", "IDBFactory");
707 case PrefixedIDBIndexConstructor:
708 return replacedBy("webkitIDBIndex", "IDBIndex");
710 case PrefixedIDBKeyRangeConstructor:
711 return replacedBy("webkitIDBKeyRange", "IDBKeyRange");
713 case PrefixedIDBObjectStoreConstructor:
714 return replacedBy("webkitIDBObjectStore", "IDBObjectStore");
716 case PrefixedIDBRequestConstructor:
717 return replacedBy("webkitIDBRequest", "IDBRequest");
719 case PrefixedIDBTransactionConstructor:
720 return replacedBy("webkitIDBTransaction", "IDBTransaction");
722 case PrefixedRequestAnimationFrame:
723 return "'webkitRequestAnimationFrame' is vendor-specific. Please use the standard 'requestAnimationFrame' instead.";
725 case PrefixedCancelAnimationFrame:
726 return "'webkitCancelAnimationFrame' is vendor-specific. Please use the standard 'cancelAnimationFrame' instead.";
728 case PrefixedCancelRequestAnimationFrame:
729 return "'webkitCancelRequestAnimationFrame' is vendor-specific. Please use the standard 'cancelAnimationFrame' instead.";
731 case DocumentCreateAttributeNS:
732 return "'Document.createAttributeNS' is deprecated and has been removed from DOM4 (http://w3.org/tr/dom).";
734 case AttributeOwnerElement:
735 return "'Attr.ownerElement' is deprecated and has been removed from DOM4 (http://w3.org/tr/dom).";
737 case ElementSetAttributeNodeNS:
738 return "'Element.setAttributeNodeNS' is deprecated and has been removed from DOM4 (http://w3.org/tr/dom).";
740 case NodeIteratorDetach:
741 return "'NodeIterator.detach' is now a no-op, as per DOM (http://dom.spec.whatwg.org/#dom-nodeiterator-detach).";
744 return replacedBy("Attr.nodeValue", "value");
746 case AttrTextContent:
747 return replacedBy("Attr.textContent", "value");
749 case NodeIteratorExpandEntityReferences:
750 return "'NodeIterator.expandEntityReferences' is deprecated and has been removed from DOM. It always returns false.";
752 case TreeWalkerExpandEntityReferences:
753 return "'TreeWalker.expandEntityReferences' is deprecated and has been removed from DOM. It always returns false.";
756 return "'Range.detach' is now a no-op, as per DOM (http://dom.spec.whatwg.org/#dom-range-detach).";
758 case OverflowChangedEvent:
759 return "The 'overflowchanged' event is deprecated and may be removed. Please do not use it.";
761 case HTMLHeadElementProfile:
762 return "'HTMLHeadElement.profile' is deprecated. The reflected attribute has no effect.";
764 case ElementSetPrefix:
765 return "Setting 'Element.prefix' is deprecated, as it is read-only per DOM (http://dom.spec.whatwg.org/#element).";
767 case SyncXHRWithCredentials:
768 return "Setting 'XMLHttpRequest.withCredentials' for synchronous requests is deprecated.";
770 case OpenWebDatabaseInWorker:
771 return "'openDatabase' in Workers is deprecated. Please switch to Indexed Database API.";
773 case OpenWebDatabaseSyncInWorker:
774 return "'openDatabaseSync' is deprecated. Please switch to Indexed Database API.";
777 return "'EventSource.URL' is deprecated. Please use 'EventSource.url' instead.";
780 return "'WebSocket.URL' is deprecated. Please use 'WebSocket.url' instead.";
782 case HTMLTableElementVspace:
783 return "The 'vspace' attribute on table is deprecated. Please use CSS instead.";
785 case HTMLTableElementHspace:
786 return "The 'hspace' attribute on table is deprecated. Please use CSS instead.";
788 case PictureSourceSrc:
789 return "<source src> with a <picture> parent is invalid and therefore ignored. Please use <source srcset> instead.";
791 // Features that aren't deprecated don't have a deprecation message.
797 void UseCounter::count(CSSParserContext context, CSSPropertyID feature)
799 ASSERT(feature >= firstCSSProperty);
800 ASSERT(feature <= lastCSSProperty);
801 ASSERT(!isInternalProperty(feature));
803 if (!isUseCounterEnabledForMode(context.mode()))
806 m_CSSFeatureBits.quickSet(feature);
809 void UseCounter::count(Feature feature)
811 ASSERT(deprecationMessage(feature).isEmpty());
812 recordMeasurement(feature);
815 UseCounter* UseCounter::getFrom(const Document* document)
817 if (document && document->frameHost())
818 return &document->frameHost()->useCounter();
822 UseCounter* UseCounter::getFrom(const CSSStyleSheet* sheet)
825 return getFrom(sheet->contents());
829 UseCounter* UseCounter::getFrom(const StyleSheetContents* sheetContents)
831 // FIXME: We may want to handle stylesheets that have multiple owners
832 // http://crbug.com/242125
833 if (sheetContents && sheetContents->hasSingleOwnerNode())
834 return getFrom(sheetContents->singleOwnerDocument());