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/DOMWindow.h"
35 #include "core/frame/FrameHost.h"
36 #include "core/frame/PageConsole.h"
37 #include "public/platform/Platform.h"
41 static int totalPagesMeasuredCSSSampleId() { return 1; }
43 // FIXME : This mapping should be autogenerated. This function should
44 // be moved to a separate file and a script run at build time
45 // to detect new values in CSSPropertyID and add them to the
46 // end of this function. This file would be checked in.
47 // https://code.google.com/p/chromium/issues/detail?id=234940
48 int UseCounter::mapCSSPropertyIdToCSSSampleIdForHistogram(int id)
50 CSSPropertyID cssPropertyID = convertToCSSPropertyID(id);
52 switch (cssPropertyID) {
53 // Begin at 2, because 1 is reserved for totalPagesMeasuredCSSSampleId.
54 case CSSPropertyColor: return 2;
55 case CSSPropertyDirection: return 3;
56 case CSSPropertyDisplay: return 4;
57 case CSSPropertyFont: return 5;
58 case CSSPropertyFontFamily: return 6;
59 case CSSPropertyFontSize: return 7;
60 case CSSPropertyFontStyle: return 8;
61 case CSSPropertyFontVariant: return 9;
62 case CSSPropertyFontWeight: return 10;
63 case CSSPropertyTextRendering: return 11;
64 case CSSPropertyWebkitFontFeatureSettings: return 12;
65 case CSSPropertyFontKerning: return 13;
66 case CSSPropertyWebkitFontSmoothing: return 14;
67 case CSSPropertyFontVariantLigatures: return 15;
68 case CSSPropertyWebkitLocale: return 16;
69 case CSSPropertyWebkitTextOrientation: return 17;
70 case CSSPropertyWebkitWritingMode: return 18;
71 case CSSPropertyZoom: return 19;
72 case CSSPropertyLineHeight: return 20;
73 case CSSPropertyBackground: return 21;
74 case CSSPropertyBackgroundAttachment: return 22;
75 case CSSPropertyBackgroundClip: return 23;
76 case CSSPropertyBackgroundColor: return 24;
77 case CSSPropertyBackgroundImage: return 25;
78 case CSSPropertyBackgroundOrigin: return 26;
79 case CSSPropertyBackgroundPosition: return 27;
80 case CSSPropertyBackgroundPositionX: return 28;
81 case CSSPropertyBackgroundPositionY: return 29;
82 case CSSPropertyBackgroundRepeat: return 30;
83 case CSSPropertyBackgroundRepeatX: return 31;
84 case CSSPropertyBackgroundRepeatY: return 32;
85 case CSSPropertyBackgroundSize: return 33;
86 case CSSPropertyBorder: return 34;
87 case CSSPropertyBorderBottom: return 35;
88 case CSSPropertyBorderBottomColor: return 36;
89 case CSSPropertyBorderBottomLeftRadius: return 37;
90 case CSSPropertyBorderBottomRightRadius: return 38;
91 case CSSPropertyBorderBottomStyle: return 39;
92 case CSSPropertyBorderBottomWidth: return 40;
93 case CSSPropertyBorderCollapse: return 41;
94 case CSSPropertyBorderColor: return 42;
95 case CSSPropertyBorderImage: return 43;
96 case CSSPropertyBorderImageOutset: return 44;
97 case CSSPropertyBorderImageRepeat: return 45;
98 case CSSPropertyBorderImageSlice: return 46;
99 case CSSPropertyBorderImageSource: return 47;
100 case CSSPropertyBorderImageWidth: return 48;
101 case CSSPropertyBorderLeft: return 49;
102 case CSSPropertyBorderLeftColor: return 50;
103 case CSSPropertyBorderLeftStyle: return 51;
104 case CSSPropertyBorderLeftWidth: return 52;
105 case CSSPropertyBorderRadius: return 53;
106 case CSSPropertyBorderRight: return 54;
107 case CSSPropertyBorderRightColor: return 55;
108 case CSSPropertyBorderRightStyle: return 56;
109 case CSSPropertyBorderRightWidth: return 57;
110 case CSSPropertyBorderSpacing: return 58;
111 case CSSPropertyBorderStyle: return 59;
112 case CSSPropertyBorderTop: return 60;
113 case CSSPropertyBorderTopColor: return 61;
114 case CSSPropertyBorderTopLeftRadius: return 62;
115 case CSSPropertyBorderTopRightRadius: return 63;
116 case CSSPropertyBorderTopStyle: return 64;
117 case CSSPropertyBorderTopWidth: return 65;
118 case CSSPropertyBorderWidth: return 66;
119 case CSSPropertyBottom: return 67;
120 case CSSPropertyBoxShadow: return 68;
121 case CSSPropertyBoxSizing: return 69;
122 case CSSPropertyCaptionSide: return 70;
123 case CSSPropertyClear: return 71;
124 case CSSPropertyClip: return 72;
125 case CSSPropertyWebkitClipPath: return 73;
126 case CSSPropertyContent: return 74;
127 case CSSPropertyCounterIncrement: return 75;
128 case CSSPropertyCounterReset: return 76;
129 case CSSPropertyCursor: return 77;
130 case CSSPropertyEmptyCells: return 78;
131 case CSSPropertyFloat: return 79;
132 case CSSPropertyFontStretch: return 80;
133 case CSSPropertyHeight: return 81;
134 case CSSPropertyImageRendering: return 82;
135 case CSSPropertyLeft: return 83;
136 case CSSPropertyLetterSpacing: return 84;
137 case CSSPropertyListStyle: return 85;
138 case CSSPropertyListStyleImage: return 86;
139 case CSSPropertyListStylePosition: return 87;
140 case CSSPropertyListStyleType: return 88;
141 case CSSPropertyMargin: return 89;
142 case CSSPropertyMarginBottom: return 90;
143 case CSSPropertyMarginLeft: return 91;
144 case CSSPropertyMarginRight: return 92;
145 case CSSPropertyMarginTop: return 93;
146 case CSSPropertyMaxHeight: return 94;
147 case CSSPropertyMaxWidth: return 95;
148 case CSSPropertyMinHeight: return 96;
149 case CSSPropertyMinWidth: return 97;
150 case CSSPropertyOpacity: return 98;
151 case CSSPropertyOrphans: return 99;
152 case CSSPropertyOutline: return 100;
153 case CSSPropertyOutlineColor: return 101;
154 case CSSPropertyOutlineOffset: return 102;
155 case CSSPropertyOutlineStyle: return 103;
156 case CSSPropertyOutlineWidth: return 104;
157 case CSSPropertyOverflow: return 105;
158 case CSSPropertyOverflowWrap: return 106;
159 case CSSPropertyOverflowX: return 107;
160 case CSSPropertyOverflowY: return 108;
161 case CSSPropertyPadding: return 109;
162 case CSSPropertyPaddingBottom: return 110;
163 case CSSPropertyPaddingLeft: return 111;
164 case CSSPropertyPaddingRight: return 112;
165 case CSSPropertyPaddingTop: return 113;
166 case CSSPropertyPage: return 114;
167 case CSSPropertyPageBreakAfter: return 115;
168 case CSSPropertyPageBreakBefore: return 116;
169 case CSSPropertyPageBreakInside: return 117;
170 case CSSPropertyPointerEvents: return 118;
171 case CSSPropertyPosition: return 119;
172 case CSSPropertyQuotes: return 120;
173 case CSSPropertyResize: return 121;
174 case CSSPropertyRight: return 122;
175 case CSSPropertySize: return 123;
176 case CSSPropertySrc: return 124;
177 case CSSPropertySpeak: return 125;
178 case CSSPropertyTableLayout: return 126;
179 case CSSPropertyTabSize: return 127;
180 case CSSPropertyTextAlign: return 128;
181 case CSSPropertyTextDecoration: return 129;
182 case CSSPropertyTextIndent: return 130;
183 /* Removed CSSPropertyTextLineThrough - 131 */
184 case CSSPropertyTextLineThroughColor: return 132;
185 case CSSPropertyTextLineThroughMode: return 133;
186 case CSSPropertyTextLineThroughStyle: return 134;
187 case CSSPropertyTextLineThroughWidth: return 135;
188 case CSSPropertyTextOverflow: return 136;
189 /* Removed CSSPropertyTextOverline - 137 */
190 case CSSPropertyTextOverlineColor: return 138;
191 case CSSPropertyTextOverlineMode: return 139;
192 case CSSPropertyTextOverlineStyle: return 140;
193 case CSSPropertyTextOverlineWidth: return 141;
194 case CSSPropertyTextShadow: return 142;
195 case CSSPropertyTextTransform: return 143;
196 /* Removed CSSPropertyTextUnderline - 144 */
197 case CSSPropertyTextUnderlineColor: return 145;
198 case CSSPropertyTextUnderlineMode: return 146;
199 case CSSPropertyTextUnderlineStyle: return 147;
200 case CSSPropertyTextUnderlineWidth: return 148;
201 case CSSPropertyTop: return 149;
202 case CSSPropertyTransition: return 150;
203 case CSSPropertyTransitionDelay: return 151;
204 case CSSPropertyTransitionDuration: return 152;
205 case CSSPropertyTransitionProperty: return 153;
206 case CSSPropertyTransitionTimingFunction: return 154;
207 case CSSPropertyUnicodeBidi: return 155;
208 case CSSPropertyUnicodeRange: return 156;
209 case CSSPropertyVerticalAlign: return 157;
210 case CSSPropertyVisibility: return 158;
211 case CSSPropertyWhiteSpace: return 159;
212 case CSSPropertyWidows: return 160;
213 case CSSPropertyWidth: return 161;
214 case CSSPropertyWordBreak: return 162;
215 case CSSPropertyWordSpacing: return 163;
216 case CSSPropertyWordWrap: return 164;
217 case CSSPropertyZIndex: return 165;
218 case CSSPropertyWebkitAnimation: return 166;
219 case CSSPropertyWebkitAnimationDelay: return 167;
220 case CSSPropertyWebkitAnimationDirection: return 168;
221 case CSSPropertyWebkitAnimationDuration: return 169;
222 case CSSPropertyWebkitAnimationFillMode: return 170;
223 case CSSPropertyWebkitAnimationIterationCount: return 171;
224 case CSSPropertyWebkitAnimationName: return 172;
225 case CSSPropertyWebkitAnimationPlayState: return 173;
226 case CSSPropertyWebkitAnimationTimingFunction: return 174;
227 case CSSPropertyWebkitAppearance: return 175;
228 case CSSPropertyWebkitAspectRatio: return 176;
229 case CSSPropertyWebkitBackfaceVisibility: return 177;
230 case CSSPropertyWebkitBackgroundClip: return 178;
231 case CSSPropertyWebkitBackgroundComposite: return 179;
232 case CSSPropertyWebkitBackgroundOrigin: return 180;
233 case CSSPropertyWebkitBackgroundSize: return 181;
234 case CSSPropertyWebkitBorderAfter: return 182;
235 case CSSPropertyWebkitBorderAfterColor: return 183;
236 case CSSPropertyWebkitBorderAfterStyle: return 184;
237 case CSSPropertyWebkitBorderAfterWidth: return 185;
238 case CSSPropertyWebkitBorderBefore: return 186;
239 case CSSPropertyWebkitBorderBeforeColor: return 187;
240 case CSSPropertyWebkitBorderBeforeStyle: return 188;
241 case CSSPropertyWebkitBorderBeforeWidth: return 189;
242 case CSSPropertyWebkitBorderEnd: return 190;
243 case CSSPropertyWebkitBorderEndColor: return 191;
244 case CSSPropertyWebkitBorderEndStyle: return 192;
245 case CSSPropertyWebkitBorderEndWidth: return 193;
246 case CSSPropertyWebkitBorderFit: return 194;
247 case CSSPropertyWebkitBorderHorizontalSpacing: return 195;
248 case CSSPropertyWebkitBorderImage: return 196;
249 case CSSPropertyWebkitBorderRadius: return 197;
250 case CSSPropertyWebkitBorderStart: return 198;
251 case CSSPropertyWebkitBorderStartColor: return 199;
252 case CSSPropertyWebkitBorderStartStyle: return 200;
253 case CSSPropertyWebkitBorderStartWidth: return 201;
254 case CSSPropertyWebkitBorderVerticalSpacing: return 202;
255 case CSSPropertyWebkitBoxAlign: return 203;
256 case CSSPropertyWebkitBoxDirection: return 204;
257 case CSSPropertyWebkitBoxFlex: return 205;
258 case CSSPropertyWebkitBoxFlexGroup: return 206;
259 case CSSPropertyWebkitBoxLines: return 207;
260 case CSSPropertyWebkitBoxOrdinalGroup: return 208;
261 case CSSPropertyWebkitBoxOrient: return 209;
262 case CSSPropertyWebkitBoxPack: return 210;
263 case CSSPropertyWebkitBoxReflect: return 211;
264 case CSSPropertyWebkitBoxShadow: return 212;
265 case CSSPropertyWebkitColumnAxis: return 214;
266 case CSSPropertyWebkitColumnBreakAfter: return 215;
267 case CSSPropertyWebkitColumnBreakBefore: return 216;
268 case CSSPropertyWebkitColumnBreakInside: return 217;
269 case CSSPropertyWebkitColumnCount: return 218;
270 case CSSPropertyWebkitColumnGap: return 219;
271 case CSSPropertyWebkitColumnProgression: return 220;
272 case CSSPropertyWebkitColumnRule: return 221;
273 case CSSPropertyWebkitColumnRuleColor: return 222;
274 case CSSPropertyWebkitColumnRuleStyle: return 223;
275 case CSSPropertyWebkitColumnRuleWidth: return 224;
276 case CSSPropertyWebkitColumnSpan: return 225;
277 case CSSPropertyWebkitColumnWidth: return 226;
278 case CSSPropertyWebkitColumns: return 227;
279 #if defined(ENABLE_CSS_BOX_DECORATION_BREAK) && ENABLE_CSS_BOX_DECORATION_BREAK
280 case CSSPropertyWebkitBoxDecorationBreak: return 228;
282 #if defined(ENABLE_CSS_FILTERS) && ENABLE_CSS_FILTERS
283 case CSSPropertyWebkitFilter: return 229;
285 case CSSPropertyAlignContent: return 230;
286 case CSSPropertyAlignItems: return 231;
287 case CSSPropertyAlignSelf: return 232;
288 case CSSPropertyFlex: return 233;
289 case CSSPropertyFlexBasis: return 234;
290 case CSSPropertyFlexDirection: return 235;
291 case CSSPropertyFlexFlow: return 236;
292 case CSSPropertyFlexGrow: return 237;
293 case CSSPropertyFlexShrink: return 238;
294 case CSSPropertyFlexWrap: return 239;
295 case CSSPropertyJustifyContent: return 240;
296 case CSSPropertyWebkitFontSizeDelta: return 241;
297 case CSSPropertyGridTemplateColumns: return 242;
298 case CSSPropertyGridTemplateRows: return 243;
299 case CSSPropertyGridColumnStart: return 244;
300 case CSSPropertyGridColumnEnd: return 245;
301 case CSSPropertyGridRowStart: return 246;
302 case CSSPropertyGridRowEnd: return 247;
303 case CSSPropertyGridColumn: return 248;
304 case CSSPropertyGridRow: return 249;
305 case CSSPropertyGridAutoFlow: return 250;
306 case CSSPropertyWebkitHighlight: return 251;
307 case CSSPropertyWebkitHyphenateCharacter: return 252;
308 case CSSPropertyWebkitLineBoxContain: return 257;
309 // case CSSPropertyWebkitLineAlign: return 258;
310 case CSSPropertyWebkitLineBreak: return 259;
311 case CSSPropertyWebkitLineClamp: return 260;
312 // case CSSPropertyWebkitLineGrid: return 261;
313 // case CSSPropertyWebkitLineSnap: return 262;
314 case CSSPropertyWebkitLogicalWidth: return 263;
315 case CSSPropertyWebkitLogicalHeight: return 264;
316 case CSSPropertyWebkitMarginAfterCollapse: return 265;
317 case CSSPropertyWebkitMarginBeforeCollapse: return 266;
318 case CSSPropertyWebkitMarginBottomCollapse: return 267;
319 case CSSPropertyWebkitMarginTopCollapse: return 268;
320 case CSSPropertyWebkitMarginCollapse: return 269;
321 case CSSPropertyWebkitMarginAfter: return 270;
322 case CSSPropertyWebkitMarginBefore: return 271;
323 case CSSPropertyWebkitMarginEnd: return 272;
324 case CSSPropertyWebkitMarginStart: return 273;
325 // CSSPropertyWebkitMarquee was 274.
326 // CSSPropertyInternalMarquee* were 275-279.
327 case CSSPropertyWebkitMask: return 280;
328 case CSSPropertyWebkitMaskBoxImage: return 281;
329 case CSSPropertyWebkitMaskBoxImageOutset: return 282;
330 case CSSPropertyWebkitMaskBoxImageRepeat: return 283;
331 case CSSPropertyWebkitMaskBoxImageSlice: return 284;
332 case CSSPropertyWebkitMaskBoxImageSource: return 285;
333 case CSSPropertyWebkitMaskBoxImageWidth: return 286;
334 case CSSPropertyWebkitMaskClip: return 287;
335 case CSSPropertyWebkitMaskComposite: return 288;
336 case CSSPropertyWebkitMaskImage: return 289;
337 case CSSPropertyWebkitMaskOrigin: return 290;
338 case CSSPropertyWebkitMaskPosition: return 291;
339 case CSSPropertyWebkitMaskPositionX: return 292;
340 case CSSPropertyWebkitMaskPositionY: return 293;
341 case CSSPropertyWebkitMaskRepeat: return 294;
342 case CSSPropertyWebkitMaskRepeatX: return 295;
343 case CSSPropertyWebkitMaskRepeatY: return 296;
344 case CSSPropertyWebkitMaskSize: return 297;
345 case CSSPropertyWebkitMaxLogicalWidth: return 298;
346 case CSSPropertyWebkitMaxLogicalHeight: return 299;
347 case CSSPropertyWebkitMinLogicalWidth: return 300;
348 case CSSPropertyWebkitMinLogicalHeight: return 301;
349 // WebkitNbspMode has been deleted, was return 302;
350 case CSSPropertyOrder: return 303;
351 case CSSPropertyWebkitPaddingAfter: return 304;
352 case CSSPropertyWebkitPaddingBefore: return 305;
353 case CSSPropertyWebkitPaddingEnd: return 306;
354 case CSSPropertyWebkitPaddingStart: return 307;
355 case CSSPropertyWebkitPerspective: return 308;
356 case CSSPropertyWebkitPerspectiveOrigin: return 309;
357 case CSSPropertyWebkitPerspectiveOriginX: return 310;
358 case CSSPropertyWebkitPerspectiveOriginY: return 311;
359 case CSSPropertyWebkitPrintColorAdjust: return 312;
360 case CSSPropertyWebkitRtlOrdering: return 313;
361 case CSSPropertyWebkitRubyPosition: return 314;
362 case CSSPropertyWebkitTextCombine: return 315;
363 case CSSPropertyWebkitTextDecorationsInEffect: return 316;
364 case CSSPropertyWebkitTextEmphasis: return 317;
365 case CSSPropertyWebkitTextEmphasisColor: return 318;
366 case CSSPropertyWebkitTextEmphasisPosition: return 319;
367 case CSSPropertyWebkitTextEmphasisStyle: return 320;
368 case CSSPropertyWebkitTextFillColor: return 321;
369 case CSSPropertyWebkitTextSecurity: return 322;
370 case CSSPropertyWebkitTextStroke: return 323;
371 case CSSPropertyWebkitTextStrokeColor: return 324;
372 case CSSPropertyWebkitTextStrokeWidth: return 325;
373 case CSSPropertyWebkitTransform: return 326;
374 case CSSPropertyWebkitTransformOrigin: return 327;
375 case CSSPropertyWebkitTransformOriginX: return 328;
376 case CSSPropertyWebkitTransformOriginY: return 329;
377 case CSSPropertyWebkitTransformOriginZ: return 330;
378 case CSSPropertyWebkitTransformStyle: return 331;
379 case CSSPropertyWebkitTransition: return 332;
380 case CSSPropertyWebkitTransitionDelay: return 333;
381 case CSSPropertyWebkitTransitionDuration: return 334;
382 case CSSPropertyWebkitTransitionProperty: return 335;
383 case CSSPropertyWebkitTransitionTimingFunction: return 336;
384 case CSSPropertyWebkitUserDrag: return 337;
385 case CSSPropertyWebkitUserModify: return 338;
386 case CSSPropertyWebkitUserSelect: return 339;
387 // case CSSPropertyWebkitFlowInto: return 340;
388 // case CSSPropertyWebkitFlowFrom: return 341;
389 // case CSSPropertyWebkitRegionFragment: return 342;
390 // case CSSPropertyWebkitRegionBreakAfter: return 343;
391 // case CSSPropertyWebkitRegionBreakBefore: return 344;
392 // case CSSPropertyWebkitRegionBreakInside: return 345;
393 case CSSPropertyShapeInside: return 346;
394 case CSSPropertyShapeOutside: return 347;
395 case CSSPropertyShapeMargin: return 348;
396 case CSSPropertyShapePadding: return 349;
397 case CSSPropertyWebkitWrapFlow: return 350;
398 case CSSPropertyWebkitWrapThrough: return 351;
399 // CSSPropertyWebkitWrap was 352.
400 #if defined(ENABLE_TOUCH_EVENTS) && ENABLE_TOUCH_EVENTS
401 case CSSPropertyWebkitTapHighlightColor: return 353;
403 #if defined(ENABLE_DRAGGABLE_REGION) && ENABLE_DRAGGABLE_REGION
404 case CSSPropertyWebkitAppRegion: return 354;
406 case CSSPropertyClipPath: return 355;
407 case CSSPropertyClipRule: return 356;
408 case CSSPropertyMask: return 357;
409 case CSSPropertyEnableBackground: return 358;
410 case CSSPropertyFilter: return 359;
411 case CSSPropertyFloodColor: return 360;
412 case CSSPropertyFloodOpacity: return 361;
413 case CSSPropertyLightingColor: return 362;
414 case CSSPropertyStopColor: return 363;
415 case CSSPropertyStopOpacity: return 364;
416 case CSSPropertyColorInterpolation: return 365;
417 case CSSPropertyColorInterpolationFilters: return 366;
418 case CSSPropertyColorProfile: return 367;
419 case CSSPropertyColorRendering: return 368;
420 case CSSPropertyFill: return 369;
421 case CSSPropertyFillOpacity: return 370;
422 case CSSPropertyFillRule: return 371;
423 case CSSPropertyMarker: return 372;
424 case CSSPropertyMarkerEnd: return 373;
425 case CSSPropertyMarkerMid: return 374;
426 case CSSPropertyMarkerStart: return 375;
427 case CSSPropertyMaskType: return 376;
428 case CSSPropertyShapeRendering: return 377;
429 case CSSPropertyStroke: return 378;
430 case CSSPropertyStrokeDasharray: return 379;
431 case CSSPropertyStrokeDashoffset: return 380;
432 case CSSPropertyStrokeLinecap: return 381;
433 case CSSPropertyStrokeLinejoin: return 382;
434 case CSSPropertyStrokeMiterlimit: return 383;
435 case CSSPropertyStrokeOpacity: return 384;
436 case CSSPropertyStrokeWidth: return 385;
437 case CSSPropertyAlignmentBaseline: return 386;
438 case CSSPropertyBaselineShift: return 387;
439 case CSSPropertyDominantBaseline: return 388;
440 case CSSPropertyGlyphOrientationHorizontal: return 389;
441 case CSSPropertyGlyphOrientationVertical: return 390;
442 case CSSPropertyKerning: return 391;
443 case CSSPropertyTextAnchor: return 392;
444 case CSSPropertyVectorEffect: return 393;
445 case CSSPropertyWritingMode: return 394;
446 // CSSPropertyWebkitSvgShadow has been removed, was return 395;
447 #if defined(ENABLE_CURSOR_VISIBILITY) && ENABLE_CURSOR_VISIBILITY
448 case CSSPropertyWebkitCursorVisibility: return 396;
450 // CSSPropertyImageOrientation has been removed, was return 397;
451 // CSSPropertyImageResolution has been removed, was return 398;
452 #if defined(ENABLE_CSS_COMPOSITING) && ENABLE_CSS_COMPOSITING
453 case CSSPropertyWebkitBlendMode: return 399;
454 case CSSPropertyWebkitBackgroundBlendMode: return 400;
456 case CSSPropertyTextDecorationLine: return 401;
457 case CSSPropertyTextDecorationStyle: return 402;
458 case CSSPropertyTextDecorationColor: return 403;
459 case CSSPropertyTextAlignLast: return 404;
460 case CSSPropertyTextUnderlinePosition: return 405;
461 case CSSPropertyMaxZoom: return 406;
462 case CSSPropertyMinZoom: return 407;
463 case CSSPropertyOrientation: return 408;
464 case CSSPropertyUserZoom: return 409;
465 // CSSPropertyWebkitDashboardRegion was 410.
466 // CSSPropertyWebkitOverflowScrolling was 411.
467 case CSSPropertyWebkitAppRegion: return 412;
468 case CSSPropertyWebkitFilter: return 413;
469 case CSSPropertyWebkitBoxDecorationBreak: return 414;
470 case CSSPropertyWebkitTapHighlightColor: return 415;
471 case CSSPropertyBufferedRendering: return 416;
472 case CSSPropertyGridAutoRows: return 417;
473 case CSSPropertyGridAutoColumns: return 418;
474 case CSSPropertyBackgroundBlendMode: return 419;
475 case CSSPropertyMixBlendMode: return 420;
476 case CSSPropertyTouchAction: return 421;
477 case CSSPropertyGridArea: return 422;
478 case CSSPropertyGridTemplateAreas: return 423;
479 case CSSPropertyAnimation: return 424;
480 case CSSPropertyAnimationDelay: return 425;
481 case CSSPropertyAnimationDirection: return 426;
482 case CSSPropertyAnimationDuration: return 427;
483 case CSSPropertyAnimationFillMode: return 428;
484 case CSSPropertyAnimationIterationCount: return 429;
485 case CSSPropertyAnimationName: return 430;
486 case CSSPropertyAnimationPlayState: return 431;
487 case CSSPropertyAnimationTimingFunction: return 432;
488 case CSSPropertyObjectFit: return 433;
489 case CSSPropertyPaintOrder: return 434;
490 case CSSPropertyMaskSourceType: return 435;
491 case CSSPropertyIsolation: return 436;
492 case CSSPropertyObjectPosition: return 437;
493 case CSSPropertyInternalCallback: return 438;
494 case CSSPropertyShapeImageThreshold: return 439;
495 case CSSPropertyColumnFill: return 440;
496 case CSSPropertyTextJustify: return 441;
497 case CSSPropertyTouchActionDelay: return 442;
498 case CSSPropertyJustifySelf: return 443;
499 case CSSPropertyScrollBehavior: return 444;
501 // Add new features above this line (don't change the assigned numbers of the existing
502 // items) and update maximumCSSSampleId() with the new maximum value.
504 // Internal properties should not be counted.
505 case CSSPropertyInternalMarqueeDirection:
506 case CSSPropertyInternalMarqueeIncrement:
507 case CSSPropertyInternalMarqueeRepetition:
508 case CSSPropertyInternalMarqueeSpeed:
509 case CSSPropertyInternalMarqueeStyle:
510 case CSSPropertyInvalid:
511 ASSERT_NOT_REACHED();
515 ASSERT_NOT_REACHED();
519 static int maximumCSSSampleId() { return 444; }
521 UseCounter::UseCounter()
523 m_CSSFeatureBits.ensureSize(lastCSSProperty + 1);
524 m_CSSFeatureBits.clearAll();
527 UseCounter::~UseCounter()
529 // We always log PageDestruction so that we have a scale for the rest of the features.
530 blink::Platform::current()->histogramEnumeration("WebCore.FeatureObserver", PageDestruction, NumberOfFeatures);
532 updateMeasurements();
535 void UseCounter::updateMeasurements()
537 blink::Platform::current()->histogramEnumeration("WebCore.FeatureObserver", PageVisits, NumberOfFeatures);
540 for (unsigned i = 0; i < NumberOfFeatures; ++i) {
541 if (m_countBits->quickGet(i))
542 blink::Platform::current()->histogramEnumeration("WebCore.FeatureObserver", i, NumberOfFeatures);
544 // Clearing count bits is timing sensitive.
545 m_countBits->clearAll();
548 // FIXME: Sometimes this function is called more than once per page. The following
549 // bool guards against incrementing the page count when there are no CSS
550 // bits set. http://crbug.com/236262.
551 bool needsPagesMeasuredUpdate = false;
552 for (int i = firstCSSProperty; i <= lastCSSProperty; ++i) {
553 if (m_CSSFeatureBits.quickGet(i)) {
554 int cssSampleId = mapCSSPropertyIdToCSSSampleIdForHistogram(i);
555 blink::Platform::current()->histogramEnumeration("WebCore.FeatureObserver.CSSProperties", cssSampleId, maximumCSSSampleId());
556 needsPagesMeasuredUpdate = true;
560 if (needsPagesMeasuredUpdate)
561 blink::Platform::current()->histogramEnumeration("WebCore.FeatureObserver.CSSProperties", totalPagesMeasuredCSSSampleId(), maximumCSSSampleId());
563 m_CSSFeatureBits.clearAll();
566 void UseCounter::didCommitLoad()
568 updateMeasurements();
571 void UseCounter::count(const Document& document, Feature feature)
573 FrameHost* host = document.frameHost();
577 ASSERT(host->useCounter().deprecationMessage(feature).isEmpty());
578 host->useCounter().recordMeasurement(feature);
581 void UseCounter::count(const ExecutionContext* context, Feature feature)
583 if (!context || !context->isDocument())
585 count(*toDocument(context), feature);
588 void UseCounter::countDeprecation(ExecutionContext* context, Feature feature)
590 if (!context || !context->isDocument())
592 UseCounter::countDeprecation(*toDocument(context), feature);
595 void UseCounter::countDeprecation(const DOMWindow* window, Feature feature)
597 if (!window || !window->document())
599 UseCounter::countDeprecation(*window->document(), feature);
602 void UseCounter::countDeprecation(const Document& document, Feature feature)
604 FrameHost* host = document.frameHost();
608 if (host->useCounter().recordMeasurement(feature)) {
609 ASSERT(!host->useCounter().deprecationMessage(feature).isEmpty());
610 host->console().addMessage(DeprecationMessageSource, WarningMessageLevel, host->useCounter().deprecationMessage(feature));
614 String UseCounter::deprecationMessage(Feature feature)
618 case PrefixedStorageInfo:
619 return "'window.webkitStorageInfo' is deprecated. Please use 'navigator.webkitTemporaryStorage' or 'navigator.webkitPersistentStorage' instead.";
622 case PrefixedPerformanceTimeline:
623 return "'window.performance.webkitGet*' methods have been deprecated. Please use the unprefixed 'performance.get*' methods instead.";
626 return "document.clear() is deprecated. This method doesn't do anything.";
629 case HTMLShadowElementOlderShadowRoot:
630 return "HTMLShadowElement.olderShadowRoot is deprecated.";
632 // HTML Media Capture
633 case CaptureAttributeAsEnum:
634 return "Using the 'capture' attribute as an enum is deprecated. Please use it as a boolean and specify the media types that should be accepted in the 'accept' attribute.";
636 // Keyboard Event (DOM Level 3)
637 case KeyboardEventKeyLocation:
638 return "'KeyboardEvent.keyLocation' is deprecated. Please use 'KeyboardEvent.location' instead.";
641 return "captureEvents() is deprecated. This method doesn't do anything.";
644 return "releaseEvents() is deprecated. This method doesn't do anything.";
646 case ConsoleMarkTimeline:
647 return "console.markTimeline is deprecated. Please use the console.timeStamp instead.";
650 return "FileError is deprecated. Please use the 'name' or 'message' attributes of DOMError rather than 'code'.";
652 case EventReturnValue:
653 return "event.returnValue is deprecated. Please use the standard event.preventDefault() instead.";
655 case ScrollTopBodyNotQuirksMode:
656 return "body.scrollTop is deprecated in strict mode. Please use 'documentElement.scrollTop' if in strict mode and 'body.scrollTop' only if in quirks mode.";
658 case ScrollLeftBodyNotQuirksMode:
659 return "body.scrollLeft is deprecated in strict mode. Please use 'documentElement.scrollLeft' if in strict mode and 'body.scrollLeft' only if in quirks mode.";
661 case ShowModalDialog:
662 return "Chromium is considering deprecating showModalDialog. Please use window.open and postMessage instead.";
664 case CSSStyleSheetInsertRuleOptionalArg:
665 return "Calling CSSStyleSheet.insertRule() with one argument is deprecated. Please pass the index argument as well: insertRule(x, 0).";
667 case AttributeSpecified:
668 return "Attr.specified is deprecated. Its value is always true.";
670 case SVGElementGetPresentationAttribute:
671 return "CSSValue and SVGElement.getPresentationAttribute are deprecated. Please use getPropertyValue and parse the return value instead.";
673 case TextTrackCueConstructor:
674 return "The 'TextTrackCue' constructor is deprecated. Please use 'VTTCue' instead.";
676 case PrefixedVideoSupportsFullscreen:
677 return "'HTMLVideoElement.webkitSupportsFullscreen' is deprecated. Its value is true if the video is loaded.";
679 case PrefixedVideoDisplayingFullscreen:
680 return "'HTMLVideoElement.webkitDisplayingFullscreen' is deprecated. Please use the 'fullscreenchange' and 'webkitfullscreenchange' events instead.";
682 case PrefixedVideoEnterFullscreen:
683 return "'HTMLVideoElement.webkitEnterFullscreen()' is deprecated. Please use 'Element.requestFullscreen()' and 'Element.webkitRequestFullscreen()' instead.";
685 case PrefixedVideoExitFullscreen:
686 return "'HTMLVideoElement.webkitExitFullscreen()' is deprecated. Please use 'Document.exitFullscreen()' and 'Document.webkitExitFullscreen()' instead.";
688 case PrefixedVideoEnterFullScreen:
689 return "'HTMLVideoElement.webkitEnterFullScreen()' is deprecated. Please use 'Element.requestFullscreen()' and 'Element.webkitRequestFullscreen()' instead.";
691 case PrefixedVideoExitFullScreen:
692 return "'HTMLVideoElement.webkitExitFullScreen()' is deprecated. Please use 'Document.exitFullscreen()' and 'Document.webkitExitFullscreen()' instead.";
694 case PrefixedMediaSourceOpen:
695 return "'WebKitMediaSource' is deprecated. Please use 'MediaSource' instead.";
697 case DOMImplementationCreateCSSStyleSheet:
698 return "'DOMImplementation.createCSSStyleSheet()' is deprecated.";
700 case MediaErrorEncrypted:
701 return "'MediaError.MEDIA_ERR_ENCRYPTED' is deprecated. This error code is never used.";
703 case HTMLSourceElementMedia:
704 return "'HTMLSourceElement.media' is deprecated. This attribute doesn't do anything.";
706 case PrefixedGetImageDataHD:
707 return "'CanvasRenderingContext2D.webkitGetImageDataHD' is deprecated. Please use getImageData instead.";
709 case PrefixedPutImageDataHD:
710 return "'CanvasRenderingContext2D.webkitPutImageDataHD' is deprecated. Please use putImageData instead.";
712 case ShadowRootApplyAuthorStyles:
713 return "'ShadowRoot.applyAuthorStyles' is deprecated.";
715 case PrefixedSpeechAttribute:
716 return "The 'x-webkit-speech' input field attribute is deprecated. Please use the JavaScript API instead.";
718 // Features that aren't deprecated don't have a deprecation message.
724 void UseCounter::count(CSSParserContext context, CSSPropertyID feature)
726 ASSERT(feature >= firstCSSProperty);
727 ASSERT(feature <= lastCSSProperty);
728 ASSERT(!isInternalProperty(feature));
730 if (!isUseCounterEnabledForMode(context.mode()))
733 m_CSSFeatureBits.quickSet(feature);
736 void UseCounter::count(Feature feature)
738 ASSERT(deprecationMessage(feature).isEmpty());
739 recordMeasurement(feature);
742 UseCounter* UseCounter::getFrom(const Document* document)
744 if (document && document->frameHost())
745 return &document->frameHost()->useCounter();
749 UseCounter* UseCounter::getFrom(const CSSStyleSheet* sheet)
752 return getFrom(sheet->contents());
756 UseCounter* UseCounter::getFrom(const StyleSheetContents* sheetContents)
758 // FIXME: We may want to handle stylesheets that have multiple owners
759 // http://crbug.com/242125
760 if (sheetContents && sheetContents->hasSingleOwnerNode())
761 return getFrom(sheetContents->singleOwnerDocument());
765 } // namespace WebCore