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 // CSSPropertyWebkitAspectRatio was 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 // CSSPropertyWebkitBorderFit was 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 // CSSPropertyWebkitCursorVisibility has been removed, was return 396;
441 // CSSPropertyImageOrientation has been removed, was return 397;
442 // CSSPropertyImageResolution has been removed, was return 398;
443 #if defined(ENABLE_CSS_COMPOSITING) && ENABLE_CSS_COMPOSITING
444 case CSSPropertyWebkitBlendMode: return 399;
445 case CSSPropertyWebkitBackgroundBlendMode: return 400;
447 case CSSPropertyTextDecorationLine: return 401;
448 case CSSPropertyTextDecorationStyle: return 402;
449 case CSSPropertyTextDecorationColor: return 403;
450 case CSSPropertyTextAlignLast: return 404;
451 case CSSPropertyTextUnderlinePosition: return 405;
452 case CSSPropertyMaxZoom: return 406;
453 case CSSPropertyMinZoom: return 407;
454 case CSSPropertyOrientation: return 408;
455 case CSSPropertyUserZoom: return 409;
456 // CSSPropertyWebkitDashboardRegion was 410.
457 // CSSPropertyWebkitOverflowScrolling was 411.
458 case CSSPropertyWebkitAppRegion: return 412;
459 case CSSPropertyWebkitFilter: return 413;
460 case CSSPropertyWebkitBoxDecorationBreak: return 414;
461 case CSSPropertyWebkitTapHighlightColor: return 415;
462 case CSSPropertyBufferedRendering: return 416;
463 case CSSPropertyGridAutoRows: return 417;
464 case CSSPropertyGridAutoColumns: return 418;
465 case CSSPropertyBackgroundBlendMode: return 419;
466 case CSSPropertyMixBlendMode: return 420;
467 case CSSPropertyTouchAction: return 421;
468 case CSSPropertyGridArea: return 422;
469 case CSSPropertyGridTemplateAreas: return 423;
470 case CSSPropertyAnimation: return 424;
471 case CSSPropertyAnimationDelay: return 425;
472 case CSSPropertyAnimationDirection: return 426;
473 case CSSPropertyAnimationDuration: return 427;
474 case CSSPropertyAnimationFillMode: return 428;
475 case CSSPropertyAnimationIterationCount: return 429;
476 case CSSPropertyAnimationName: return 430;
477 case CSSPropertyAnimationPlayState: return 431;
478 case CSSPropertyAnimationTimingFunction: return 432;
479 case CSSPropertyObjectFit: return 433;
480 case CSSPropertyPaintOrder: return 434;
481 case CSSPropertyMaskSourceType: return 435;
482 case CSSPropertyIsolation: return 436;
483 case CSSPropertyObjectPosition: return 437;
484 // case CSSPropertyInternalCallback: return 438;
485 case CSSPropertyShapeImageThreshold: return 439;
486 case CSSPropertyColumnFill: return 440;
487 case CSSPropertyTextJustify: return 441;
488 case CSSPropertyTouchActionDelay: return 442;
489 case CSSPropertyJustifySelf: return 443;
490 case CSSPropertyScrollBehavior: return 444;
491 case CSSPropertyWillChange: return 445;
492 case CSSPropertyTransform: return 446;
493 case CSSPropertyTransformOrigin: return 447;
494 case CSSPropertyTransformStyle: return 448;
495 case CSSPropertyPerspective: return 449;
496 case CSSPropertyPerspectiveOrigin: return 450;
497 case CSSPropertyBackfaceVisibility: return 451;
498 case CSSPropertyGridTemplate: return 452;
499 case CSSPropertyGrid: return 453;
500 case CSSPropertyAll: return 454;
501 case CSSPropertyJustifyItems: return 455;
503 // 1. Add new features above this line (don't change the assigned numbers of the existing
505 // 2. Update maximumCSSSampleId() with the new maximum value.
506 // 3. Run the update_use_counter_css.py script in
507 // chromium/src/tools/metrics/histograms to update the UMA histogram names.
509 case CSSPropertyInvalid:
510 ASSERT_NOT_REACHED();
514 ASSERT_NOT_REACHED();
518 static int maximumCSSSampleId() { return 455; }
520 void UseCounter::muteForInspector()
522 UseCounter::m_muteCount++;
525 void UseCounter::unmuteForInspector()
527 UseCounter::m_muteCount--;
530 UseCounter::UseCounter()
532 m_CSSFeatureBits.ensureSize(lastCSSProperty + 1);
533 m_CSSFeatureBits.clearAll();
536 UseCounter::~UseCounter()
538 // We always log PageDestruction so that we have a scale for the rest of the features.
539 blink::Platform::current()->histogramEnumeration("WebCore.FeatureObserver", PageDestruction, NumberOfFeatures);
541 updateMeasurements();
544 void UseCounter::updateMeasurements()
546 blink::Platform::current()->histogramEnumeration("WebCore.FeatureObserver", PageVisits, NumberOfFeatures);
549 for (unsigned i = 0; i < NumberOfFeatures; ++i) {
550 if (m_countBits->quickGet(i))
551 blink::Platform::current()->histogramEnumeration("WebCore.FeatureObserver", i, NumberOfFeatures);
553 // Clearing count bits is timing sensitive.
554 m_countBits->clearAll();
557 // FIXME: Sometimes this function is called more than once per page. The following
558 // bool guards against incrementing the page count when there are no CSS
559 // bits set. http://crbug.com/236262.
560 bool needsPagesMeasuredUpdate = false;
561 for (int i = firstCSSProperty; i <= lastCSSProperty; ++i) {
562 if (m_CSSFeatureBits.quickGet(i)) {
563 int cssSampleId = mapCSSPropertyIdToCSSSampleIdForHistogram(i);
564 blink::Platform::current()->histogramEnumeration("WebCore.FeatureObserver.CSSProperties", cssSampleId, maximumCSSSampleId());
565 needsPagesMeasuredUpdate = true;
569 if (needsPagesMeasuredUpdate)
570 blink::Platform::current()->histogramEnumeration("WebCore.FeatureObserver.CSSProperties", totalPagesMeasuredCSSSampleId(), maximumCSSSampleId());
572 m_CSSFeatureBits.clearAll();
575 void UseCounter::didCommitLoad()
577 updateMeasurements();
580 void UseCounter::count(const Document& document, Feature feature)
582 FrameHost* host = document.frameHost();
586 ASSERT(host->useCounter().deprecationMessage(feature).isEmpty());
587 host->useCounter().recordMeasurement(feature);
590 void UseCounter::count(const ExecutionContext* context, Feature feature)
594 if (context->isDocument()) {
595 count(*toDocument(context), feature);
598 if (context->isWorkerGlobalScope())
599 toWorkerGlobalScope(context)->countFeature(feature);
602 void UseCounter::countIfNotPrivateScript(v8::Isolate* isolate, const Document& document, Feature feature)
604 if (DOMWrapperWorld::current(isolate).isPrivateScriptIsolatedWorld())
606 UseCounter::count(document, feature);
609 void UseCounter::countIfNotPrivateScript(v8::Isolate* isolate, const ExecutionContext* context, Feature feature)
611 if (DOMWrapperWorld::current(isolate).isPrivateScriptIsolatedWorld())
613 UseCounter::count(context, feature);
616 void UseCounter::countDeprecation(ExecutionContext* context, Feature feature)
620 if (context->isDocument()) {
621 UseCounter::countDeprecation(*toDocument(context), feature);
624 if (context->isWorkerGlobalScope())
625 toWorkerGlobalScope(context)->countDeprecation(feature);
628 void UseCounter::countDeprecation(const LocalDOMWindow* window, Feature feature)
630 if (!window || !window->document())
632 UseCounter::countDeprecation(*window->document(), feature);
635 void UseCounter::countDeprecation(const Document& document, Feature feature)
637 FrameHost* host = document.frameHost();
638 LocalFrame* frame = document.frame();
642 if (host->useCounter().recordMeasurement(feature)) {
643 ASSERT(!host->useCounter().deprecationMessage(feature).isEmpty());
644 frame->console().addMessage(ConsoleMessage::create(DeprecationMessageSource, WarningMessageLevel, host->useCounter().deprecationMessage(feature)));
648 void UseCounter::countDeprecationIfNotPrivateScript(v8::Isolate* isolate, ExecutionContext* context, Feature feature)
650 if (DOMWrapperWorld::current(isolate).isPrivateScriptIsolatedWorld())
652 UseCounter::countDeprecation(context, feature);
655 // FIXME: Update other UseCounter::deprecationMessage() cases to use this.
656 static String replacedBy(const char* oldString, const char* newString)
658 return String::format("'%s' is deprecated. Please use '%s' instead.", oldString, newString);
661 String UseCounter::deprecationMessage(Feature feature)
665 case PrefixedStorageInfo:
666 return "'window.webkitStorageInfo' is deprecated. Please use 'navigator.webkitTemporaryStorage' or 'navigator.webkitPersistentStorage' instead.";
668 // Keyboard Event (DOM Level 3)
669 case KeyboardEventKeyLocation:
670 return replacedBy("KeyboardEvent.keyLocation", "KeyboardEvent.location");
672 case ConsoleMarkTimeline:
673 return "console.markTimeline is deprecated. Please use the console.timeStamp instead.";
676 return "FileError is deprecated. Please use the 'name' or 'message' attributes of DOMError rather than 'code'.";
678 case ShowModalDialog:
679 return "showModalDialog is deprecated. Please use window.open and postMessage instead.";
681 case CSSStyleSheetInsertRuleOptionalArg:
682 return "Calling CSSStyleSheet.insertRule() with one argument is deprecated. Please pass the index argument as well: insertRule(x, 0).";
684 case PrefixedVideoSupportsFullscreen:
685 return "'HTMLVideoElement.webkitSupportsFullscreen' is deprecated. Its value is true if the video is loaded.";
687 case PrefixedVideoDisplayingFullscreen:
688 return "'HTMLVideoElement.webkitDisplayingFullscreen' is deprecated. Please use the 'fullscreenchange' and 'webkitfullscreenchange' events instead.";
690 case PrefixedVideoEnterFullscreen:
691 return "'HTMLVideoElement.webkitEnterFullscreen()' is deprecated. Please use 'Element.requestFullscreen()' and 'Element.webkitRequestFullscreen()' instead.";
693 case PrefixedVideoExitFullscreen:
694 return "'HTMLVideoElement.webkitExitFullscreen()' is deprecated. Please use 'Document.exitFullscreen()' and 'Document.webkitExitFullscreen()' instead.";
696 case PrefixedVideoEnterFullScreen:
697 return "'HTMLVideoElement.webkitEnterFullScreen()' is deprecated. Please use 'Element.requestFullscreen()' and 'Element.webkitRequestFullscreen()' instead.";
699 case PrefixedVideoExitFullScreen:
700 return "'HTMLVideoElement.webkitExitFullScreen()' is deprecated. Please use 'Document.exitFullscreen()' and 'Document.webkitExitFullscreen()' instead.";
702 case MediaErrorEncrypted:
703 return "'MediaError.MEDIA_ERR_ENCRYPTED' is deprecated. This error code is never used.";
705 case PrefixedGamepad:
706 return replacedBy("navigator.webkitGetGamepads", "navigator.getGamepads");
708 case PrefixedIndexedDB:
709 return replacedBy("webkitIndexedDB", "indexedDB");
711 case PrefixedIDBCursorConstructor:
712 return replacedBy("webkitIDBCursor", "IDBCursor");
714 case PrefixedIDBDatabaseConstructor:
715 return replacedBy("webkitIDBDatabase", "IDBDatabase");
717 case PrefixedIDBFactoryConstructor:
718 return replacedBy("webkitIDBFactory", "IDBFactory");
720 case PrefixedIDBIndexConstructor:
721 return replacedBy("webkitIDBIndex", "IDBIndex");
723 case PrefixedIDBKeyRangeConstructor:
724 return replacedBy("webkitIDBKeyRange", "IDBKeyRange");
726 case PrefixedIDBObjectStoreConstructor:
727 return replacedBy("webkitIDBObjectStore", "IDBObjectStore");
729 case PrefixedIDBRequestConstructor:
730 return replacedBy("webkitIDBRequest", "IDBRequest");
732 case PrefixedIDBTransactionConstructor:
733 return replacedBy("webkitIDBTransaction", "IDBTransaction");
735 case PrefixedRequestAnimationFrame:
736 return "'webkitRequestAnimationFrame' is vendor-specific. Please use the standard 'requestAnimationFrame' instead.";
738 case PrefixedCancelAnimationFrame:
739 return "'webkitCancelAnimationFrame' is vendor-specific. Please use the standard 'cancelAnimationFrame' instead.";
741 case PrefixedCancelRequestAnimationFrame:
742 return "'webkitCancelRequestAnimationFrame' is vendor-specific. Please use the standard 'cancelAnimationFrame' instead.";
744 case DocumentCreateAttributeNS:
745 return "'Document.createAttributeNS' is deprecated and has been removed from DOM4 (http://w3.org/tr/dom).";
747 case AttributeOwnerElement:
748 return "'Attr.ownerElement' is deprecated and has been removed from DOM4 (http://w3.org/tr/dom).";
750 case ElementSetAttributeNodeNS:
751 return "'Element.setAttributeNodeNS' is deprecated and has been removed from DOM4 (http://w3.org/tr/dom).";
753 case NodeIteratorDetach:
754 return "'NodeIterator.detach' is now a no-op, as per DOM (http://dom.spec.whatwg.org/#dom-nodeiterator-detach).";
757 return replacedBy("Attr.nodeValue", "value");
759 case AttrTextContent:
760 return replacedBy("Attr.textContent", "value");
762 case NodeIteratorExpandEntityReferences:
763 return "'NodeIterator.expandEntityReferences' is deprecated and has been removed from DOM. It always returns false.";
765 case TreeWalkerExpandEntityReferences:
766 return "'TreeWalker.expandEntityReferences' is deprecated and has been removed from DOM. It always returns false.";
769 return "'Range.detach' is now a no-op, as per DOM (http://dom.spec.whatwg.org/#dom-range-detach).";
771 case OverflowChangedEvent:
772 return "The 'overflowchanged' event is deprecated and may be removed. Please do not use it.";
774 case ElementSetPrefix:
775 return "Setting 'Element.prefix' is deprecated, as it is read-only per DOM (http://dom.spec.whatwg.org/#element).";
777 case SyncXHRWithCredentials:
778 return "Setting 'XMLHttpRequest.withCredentials' for synchronous requests is deprecated.";
781 return "'EventSource.URL' is deprecated. Please use 'EventSource.url' instead.";
784 return "'WebSocket.URL' is deprecated. Please use 'WebSocket.url' instead.";
786 case HTMLTableElementVspace:
787 return "The 'vspace' attribute on table is deprecated. Please use CSS instead.";
789 case HTMLTableElementHspace:
790 return "The 'hspace' attribute on table is deprecated. Please use CSS instead.";
792 case PictureSourceSrc:
793 return "<source src> with a <picture> parent is invalid and therefore ignored. Please use <source srcset> instead.";
795 case XHRProgressEventPosition:
796 return "The XMLHttpRequest progress event property 'position' is deprecated. Please use 'loaded' instead.";
798 case XHRProgressEventTotalSize:
799 return "The XMLHttpRequest progress event property 'totalSize' is deprecated. Please use 'total' instead.";
801 case ConsoleTimeline:
802 return "console.timeline is deprecated. Please use the console.time instead.";
804 case ConsoleTimelineEnd:
805 return "console.timelineEnd is deprecated. Please use the console.timeEnd instead.";
807 case XMLHttpRequestSynchronousInNonWorkerOutsideBeforeUnload:
808 return "Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check http://xhr.spec.whatwg.org/.";
810 case FontFaceSetReady:
811 return "document.fonts.ready() method is going to be replaced with document.fonts.ready attribute in future releases. Please be prepared. For more help, check https://code.google.com/p/chromium/issues/detail?id=392077#c3 .";
813 // Features that aren't deprecated don't have a deprecation message.
819 void UseCounter::count(CSSParserContext context, CSSPropertyID feature)
821 ASSERT(feature >= firstCSSProperty);
822 ASSERT(feature <= lastCSSProperty);
823 ASSERT(!isInternalProperty(feature));
825 if (!isUseCounterEnabledForMode(context.mode()))
828 m_CSSFeatureBits.quickSet(feature);
831 void UseCounter::count(Feature feature)
833 ASSERT(deprecationMessage(feature).isEmpty());
834 recordMeasurement(feature);
837 UseCounter* UseCounter::getFrom(const Document* document)
839 if (document && document->frameHost())
840 return &document->frameHost()->useCounter();
844 UseCounter* UseCounter::getFrom(const CSSStyleSheet* sheet)
847 return getFrom(sheet->contents());
851 UseCounter* UseCounter::getFrom(const StyleSheetContents* sheetContents)
853 // FIXME: We may want to handle stylesheets that have multiple owners
854 // http://crbug.com/242125
855 if (sheetContents && sheetContents->hasSingleOwnerNode())
856 return getFrom(sheetContents->singleOwnerDocument());