Home | History | Annotate | Download | only in page
      1 
      2 /*
      3  * Copyright (C) 2012 Google, Inc. All rights reserved.
      4  *
      5  * Redistribution and use in source and binary forms, with or without
      6  * modification, are permitted provided that the following conditions
      7  * are met:
      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.
     13  *
     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.
     25  */
     26 
     27 #include "config.h"
     28 #include "core/page/UseCounter.h"
     29 
     30 #include "core/css/CSSStyleSheet.h"
     31 #include "core/css/StyleSheetContents.h"
     32 #include "core/dom/Document.h"
     33 #include "core/dom/ScriptExecutionContext.h"
     34 #include "core/page/DOMWindow.h"
     35 #include "core/page/Page.h"
     36 #include "core/page/PageConsole.h"
     37 #include "core/platform/HistogramSupport.h"
     38 #include "wtf/text/WTFString.h"
     39 
     40 namespace WebCore {
     41 
     42 static int totalPagesMeasuredCSSSampleId() { return 1; }
     43 
     44 // FIXME : This mapping should be autogenerated. This function should
     45 //         be moved to a separate file and a script run at build time
     46 //         to detect new values in CSSPropertyID and add them to the
     47 //         end of this function. This file would be checked in.
     48 //         https://code.google.com/p/chromium/issues/detail?id=234940
     49 int UseCounter::mapCSSPropertyIdToCSSSampleIdForHistogram(int id)
     50 {
     51     CSSPropertyID cssPropertyID = convertToCSSPropertyID(id);
     52 
     53     switch (cssPropertyID) {
     54     // Begin at 2, because 1 is reserved for totalPagesMeasuredCSSSampleId.
     55     case CSSPropertyColor: return 2;
     56     case CSSPropertyDirection: return 3;
     57     case CSSPropertyDisplay: return 4;
     58     case CSSPropertyFont: return 5;
     59     case CSSPropertyFontFamily: return 6;
     60     case CSSPropertyFontSize: return 7;
     61     case CSSPropertyFontStyle: return 8;
     62     case CSSPropertyFontVariant: return 9;
     63     case CSSPropertyFontWeight: return 10;
     64     case CSSPropertyTextRendering: return 11;
     65     case CSSPropertyWebkitFontFeatureSettings: return 12;
     66     case CSSPropertyWebkitFontKerning: return 13;
     67     case CSSPropertyWebkitFontSmoothing: return 14;
     68     case CSSPropertyWebkitFontVariantLigatures: return 15;
     69     case CSSPropertyWebkitLocale: return 16;
     70     case CSSPropertyWebkitTextOrientation: return 17;
     71     case CSSPropertyWebkitWritingMode: return 18;
     72     case CSSPropertyZoom: return 19;
     73     case CSSPropertyLineHeight: return 20;
     74     case CSSPropertyBackground: return 21;
     75     case CSSPropertyBackgroundAttachment: return 22;
     76     case CSSPropertyBackgroundClip: return 23;
     77     case CSSPropertyBackgroundColor: return 24;
     78     case CSSPropertyBackgroundImage: return 25;
     79     case CSSPropertyBackgroundOrigin: return 26;
     80     case CSSPropertyBackgroundPosition: return 27;
     81     case CSSPropertyBackgroundPositionX: return 28;
     82     case CSSPropertyBackgroundPositionY: return 29;
     83     case CSSPropertyBackgroundRepeat: return 30;
     84     case CSSPropertyBackgroundRepeatX: return 31;
     85     case CSSPropertyBackgroundRepeatY: return 32;
     86     case CSSPropertyBackgroundSize: return 33;
     87     case CSSPropertyBorder: return 34;
     88     case CSSPropertyBorderBottom: return 35;
     89     case CSSPropertyBorderBottomColor: return 36;
     90     case CSSPropertyBorderBottomLeftRadius: return 37;
     91     case CSSPropertyBorderBottomRightRadius: return 38;
     92     case CSSPropertyBorderBottomStyle: return 39;
     93     case CSSPropertyBorderBottomWidth: return 40;
     94     case CSSPropertyBorderCollapse: return 41;
     95     case CSSPropertyBorderColor: return 42;
     96     case CSSPropertyBorderImage: return 43;
     97     case CSSPropertyBorderImageOutset: return 44;
     98     case CSSPropertyBorderImageRepeat: return 45;
     99     case CSSPropertyBorderImageSlice: return 46;
    100     case CSSPropertyBorderImageSource: return 47;
    101     case CSSPropertyBorderImageWidth: return 48;
    102     case CSSPropertyBorderLeft: return 49;
    103     case CSSPropertyBorderLeftColor: return 50;
    104     case CSSPropertyBorderLeftStyle: return 51;
    105     case CSSPropertyBorderLeftWidth: return 52;
    106     case CSSPropertyBorderRadius: return 53;
    107     case CSSPropertyBorderRight: return 54;
    108     case CSSPropertyBorderRightColor: return 55;
    109     case CSSPropertyBorderRightStyle: return 56;
    110     case CSSPropertyBorderRightWidth: return 57;
    111     case CSSPropertyBorderSpacing: return 58;
    112     case CSSPropertyBorderStyle: return 59;
    113     case CSSPropertyBorderTop: return 60;
    114     case CSSPropertyBorderTopColor: return 61;
    115     case CSSPropertyBorderTopLeftRadius: return 62;
    116     case CSSPropertyBorderTopRightRadius: return 63;
    117     case CSSPropertyBorderTopStyle: return 64;
    118     case CSSPropertyBorderTopWidth: return 65;
    119     case CSSPropertyBorderWidth: return 66;
    120     case CSSPropertyBottom: return 67;
    121     case CSSPropertyBoxShadow: return 68;
    122     case CSSPropertyBoxSizing: return 69;
    123     case CSSPropertyCaptionSide: return 70;
    124     case CSSPropertyClear: return 71;
    125     case CSSPropertyClip: return 72;
    126     case CSSPropertyWebkitClipPath: return 73;
    127     case CSSPropertyContent: return 74;
    128     case CSSPropertyCounterIncrement: return 75;
    129     case CSSPropertyCounterReset: return 76;
    130     case CSSPropertyCursor: return 77;
    131     case CSSPropertyEmptyCells: return 78;
    132     case CSSPropertyFloat: return 79;
    133     case CSSPropertyFontStretch: return 80;
    134     case CSSPropertyHeight: return 81;
    135     case CSSPropertyImageRendering: return 82;
    136     case CSSPropertyLeft: return 83;
    137     case CSSPropertyLetterSpacing: return 84;
    138     case CSSPropertyListStyle: return 85;
    139     case CSSPropertyListStyleImage: return 86;
    140     case CSSPropertyListStylePosition: return 87;
    141     case CSSPropertyListStyleType: return 88;
    142     case CSSPropertyMargin: return 89;
    143     case CSSPropertyMarginBottom: return 90;
    144     case CSSPropertyMarginLeft: return 91;
    145     case CSSPropertyMarginRight: return 92;
    146     case CSSPropertyMarginTop: return 93;
    147     case CSSPropertyMaxHeight: return 94;
    148     case CSSPropertyMaxWidth: return 95;
    149     case CSSPropertyMinHeight: return 96;
    150     case CSSPropertyMinWidth: return 97;
    151     case CSSPropertyOpacity: return 98;
    152     case CSSPropertyOrphans: return 99;
    153     case CSSPropertyOutline: return 100;
    154     case CSSPropertyOutlineColor: return 101;
    155     case CSSPropertyOutlineOffset: return 102;
    156     case CSSPropertyOutlineStyle: return 103;
    157     case CSSPropertyOutlineWidth: return 104;
    158     case CSSPropertyOverflow: return 105;
    159     case CSSPropertyOverflowWrap: return 106;
    160     case CSSPropertyOverflowX: return 107;
    161     case CSSPropertyOverflowY: return 108;
    162     case CSSPropertyPadding: return 109;
    163     case CSSPropertyPaddingBottom: return 110;
    164     case CSSPropertyPaddingLeft: return 111;
    165     case CSSPropertyPaddingRight: return 112;
    166     case CSSPropertyPaddingTop: return 113;
    167     case CSSPropertyPage: return 114;
    168     case CSSPropertyPageBreakAfter: return 115;
    169     case CSSPropertyPageBreakBefore: return 116;
    170     case CSSPropertyPageBreakInside: return 117;
    171     case CSSPropertyPointerEvents: return 118;
    172     case CSSPropertyPosition: return 119;
    173     case CSSPropertyQuotes: return 120;
    174     case CSSPropertyResize: return 121;
    175     case CSSPropertyRight: return 122;
    176     case CSSPropertySize: return 123;
    177     case CSSPropertySrc: return 124;
    178     case CSSPropertySpeak: return 125;
    179     case CSSPropertyTableLayout: return 126;
    180     case CSSPropertyTabSize: return 127;
    181     case CSSPropertyTextAlign: return 128;
    182     case CSSPropertyTextDecoration: return 129;
    183     case CSSPropertyTextIndent: return 130;
    184     /* Removed CSSPropertyTextLineThrough - 131 */
    185     case CSSPropertyTextLineThroughColor: return 132;
    186     case CSSPropertyTextLineThroughMode: return 133;
    187     case CSSPropertyTextLineThroughStyle: return 134;
    188     case CSSPropertyTextLineThroughWidth: return 135;
    189     case CSSPropertyTextOverflow: return 136;
    190     /* Removed CSSPropertyTextOverline - 137 */
    191     case CSSPropertyTextOverlineColor: return 138;
    192     case CSSPropertyTextOverlineMode: return 139;
    193     case CSSPropertyTextOverlineStyle: return 140;
    194     case CSSPropertyTextOverlineWidth: return 141;
    195     case CSSPropertyTextShadow: return 142;
    196     case CSSPropertyTextTransform: return 143;
    197     /* Removed CSSPropertyTextUnderline - 144 */
    198     case CSSPropertyTextUnderlineColor: return 145;
    199     case CSSPropertyTextUnderlineMode: return 146;
    200     case CSSPropertyTextUnderlineStyle: return 147;
    201     case CSSPropertyTextUnderlineWidth: return 148;
    202     case CSSPropertyTop: return 149;
    203     case CSSPropertyTransition: return 150;
    204     case CSSPropertyTransitionDelay: return 151;
    205     case CSSPropertyTransitionDuration: return 152;
    206     case CSSPropertyTransitionProperty: return 153;
    207     case CSSPropertyTransitionTimingFunction: return 154;
    208     case CSSPropertyUnicodeBidi: return 155;
    209     case CSSPropertyUnicodeRange: return 156;
    210     case CSSPropertyVerticalAlign: return 157;
    211     case CSSPropertyVisibility: return 158;
    212     case CSSPropertyWhiteSpace: return 159;
    213     case CSSPropertyWidows: return 160;
    214     case CSSPropertyWidth: return 161;
    215     case CSSPropertyWordBreak: return 162;
    216     case CSSPropertyWordSpacing: return 163;
    217     case CSSPropertyWordWrap: return 164;
    218     case CSSPropertyZIndex: return 165;
    219     case CSSPropertyWebkitAnimation: return 166;
    220     case CSSPropertyWebkitAnimationDelay: return 167;
    221     case CSSPropertyWebkitAnimationDirection: return 168;
    222     case CSSPropertyWebkitAnimationDuration: return 169;
    223     case CSSPropertyWebkitAnimationFillMode: return 170;
    224     case CSSPropertyWebkitAnimationIterationCount: return 171;
    225     case CSSPropertyWebkitAnimationName: return 172;
    226     case CSSPropertyWebkitAnimationPlayState: return 173;
    227     case CSSPropertyWebkitAnimationTimingFunction: return 174;
    228     case CSSPropertyWebkitAppearance: return 175;
    229     case CSSPropertyWebkitAspectRatio: return 176;
    230     case CSSPropertyWebkitBackfaceVisibility: return 177;
    231     case CSSPropertyWebkitBackgroundClip: return 178;
    232     case CSSPropertyWebkitBackgroundComposite: return 179;
    233     case CSSPropertyWebkitBackgroundOrigin: return 180;
    234     case CSSPropertyWebkitBackgroundSize: return 181;
    235     case CSSPropertyWebkitBorderAfter: return 182;
    236     case CSSPropertyWebkitBorderAfterColor: return 183;
    237     case CSSPropertyWebkitBorderAfterStyle: return 184;
    238     case CSSPropertyWebkitBorderAfterWidth: return 185;
    239     case CSSPropertyWebkitBorderBefore: return 186;
    240     case CSSPropertyWebkitBorderBeforeColor: return 187;
    241     case CSSPropertyWebkitBorderBeforeStyle: return 188;
    242     case CSSPropertyWebkitBorderBeforeWidth: return 189;
    243     case CSSPropertyWebkitBorderEnd: return 190;
    244     case CSSPropertyWebkitBorderEndColor: return 191;
    245     case CSSPropertyWebkitBorderEndStyle: return 192;
    246     case CSSPropertyWebkitBorderEndWidth: return 193;
    247     case CSSPropertyWebkitBorderFit: return 194;
    248     case CSSPropertyWebkitBorderHorizontalSpacing: return 195;
    249     case CSSPropertyWebkitBorderImage: return 196;
    250     case CSSPropertyWebkitBorderRadius: return 197;
    251     case CSSPropertyWebkitBorderStart: return 198;
    252     case CSSPropertyWebkitBorderStartColor: return 199;
    253     case CSSPropertyWebkitBorderStartStyle: return 200;
    254     case CSSPropertyWebkitBorderStartWidth: return 201;
    255     case CSSPropertyWebkitBorderVerticalSpacing: return 202;
    256     case CSSPropertyWebkitBoxAlign: return 203;
    257     case CSSPropertyWebkitBoxDirection: return 204;
    258     case CSSPropertyWebkitBoxFlex: return 205;
    259     case CSSPropertyWebkitBoxFlexGroup: return 206;
    260     case CSSPropertyWebkitBoxLines: return 207;
    261     case CSSPropertyWebkitBoxOrdinalGroup: return 208;
    262     case CSSPropertyWebkitBoxOrient: return 209;
    263     case CSSPropertyWebkitBoxPack: return 210;
    264     case CSSPropertyWebkitBoxReflect: return 211;
    265     case CSSPropertyWebkitBoxShadow: return 212;
    266     case CSSPropertyWebkitColumnAxis: return 214;
    267     case CSSPropertyWebkitColumnBreakAfter: return 215;
    268     case CSSPropertyWebkitColumnBreakBefore: return 216;
    269     case CSSPropertyWebkitColumnBreakInside: return 217;
    270     case CSSPropertyWebkitColumnCount: return 218;
    271     case CSSPropertyWebkitColumnGap: return 219;
    272     case CSSPropertyWebkitColumnProgression: return 220;
    273     case CSSPropertyWebkitColumnRule: return 221;
    274     case CSSPropertyWebkitColumnRuleColor: return 222;
    275     case CSSPropertyWebkitColumnRuleStyle: return 223;
    276     case CSSPropertyWebkitColumnRuleWidth: return 224;
    277     case CSSPropertyWebkitColumnSpan: return 225;
    278     case CSSPropertyWebkitColumnWidth: return 226;
    279     case CSSPropertyWebkitColumns: return 227;
    280 #if defined(ENABLE_CSS_BOX_DECORATION_BREAK) && ENABLE_CSS_BOX_DECORATION_BREAK
    281     case CSSPropertyWebkitBoxDecorationBreak: return 228;
    282 #endif
    283 #if defined(ENABLE_CSS_FILTERS) && ENABLE_CSS_FILTERS
    284     case CSSPropertyWebkitFilter: return 229;
    285 #endif
    286     case CSSPropertyAlignContent: return 230;
    287     case CSSPropertyAlignItems: return 231;
    288     case CSSPropertyAlignSelf: return 232;
    289     case CSSPropertyFlex: return 233;
    290     case CSSPropertyFlexBasis: return 234;
    291     case CSSPropertyFlexDirection: return 235;
    292     case CSSPropertyFlexFlow: return 236;
    293     case CSSPropertyFlexGrow: return 237;
    294     case CSSPropertyFlexShrink: return 238;
    295     case CSSPropertyFlexWrap: return 239;
    296     case CSSPropertyJustifyContent: return 240;
    297     case CSSPropertyWebkitFontSizeDelta: return 241;
    298     case CSSPropertyGridDefinitionColumns: return 242;
    299     case CSSPropertyGridDefinitionRows: return 243;
    300     case CSSPropertyGridColumnStart: return 244;
    301     case CSSPropertyGridColumnEnd: return 245;
    302     case CSSPropertyGridRowStart: return 246;
    303     case CSSPropertyGridRowEnd: return 247;
    304     case CSSPropertyGridColumn: return 248;
    305     case CSSPropertyGridRow: return 249;
    306     case CSSPropertyGridAutoFlow: return 250;
    307     case CSSPropertyWebkitHighlight: return 251;
    308     case CSSPropertyWebkitHyphenateCharacter: return 252;
    309     case CSSPropertyWebkitLineBoxContain: return 257;
    310     case CSSPropertyWebkitLineAlign: return 258;
    311     case CSSPropertyWebkitLineBreak: return 259;
    312     case CSSPropertyWebkitLineClamp: return 260;
    313     case CSSPropertyWebkitLineGrid: return 261;
    314     case CSSPropertyWebkitLineSnap: return 262;
    315     case CSSPropertyWebkitLogicalWidth: return 263;
    316     case CSSPropertyWebkitLogicalHeight: return 264;
    317     case CSSPropertyWebkitMarginAfterCollapse: return 265;
    318     case CSSPropertyWebkitMarginBeforeCollapse: return 266;
    319     case CSSPropertyWebkitMarginBottomCollapse: return 267;
    320     case CSSPropertyWebkitMarginTopCollapse: return 268;
    321     case CSSPropertyWebkitMarginCollapse: return 269;
    322     case CSSPropertyWebkitMarginAfter: return 270;
    323     case CSSPropertyWebkitMarginBefore: return 271;
    324     case CSSPropertyWebkitMarginEnd: return 272;
    325     case CSSPropertyWebkitMarginStart: return 273;
    326     case CSSPropertyWebkitMarquee: return 274;
    327     case CSSPropertyWebkitMarqueeDirection: return 275;
    328     case CSSPropertyWebkitMarqueeIncrement: return 276;
    329     case CSSPropertyWebkitMarqueeRepetition: return 277;
    330     case CSSPropertyWebkitMarqueeSpeed: return 278;
    331     case CSSPropertyWebkitMarqueeStyle: return 279;
    332     case CSSPropertyWebkitMask: return 280;
    333     case CSSPropertyWebkitMaskBoxImage: return 281;
    334     case CSSPropertyWebkitMaskBoxImageOutset: return 282;
    335     case CSSPropertyWebkitMaskBoxImageRepeat: return 283;
    336     case CSSPropertyWebkitMaskBoxImageSlice: return 284;
    337     case CSSPropertyWebkitMaskBoxImageSource: return 285;
    338     case CSSPropertyWebkitMaskBoxImageWidth: return 286;
    339     case CSSPropertyWebkitMaskClip: return 287;
    340     case CSSPropertyWebkitMaskComposite: return 288;
    341     case CSSPropertyWebkitMaskImage: return 289;
    342     case CSSPropertyWebkitMaskOrigin: return 290;
    343     case CSSPropertyWebkitMaskPosition: return 291;
    344     case CSSPropertyWebkitMaskPositionX: return 292;
    345     case CSSPropertyWebkitMaskPositionY: return 293;
    346     case CSSPropertyWebkitMaskRepeat: return 294;
    347     case CSSPropertyWebkitMaskRepeatX: return 295;
    348     case CSSPropertyWebkitMaskRepeatY: return 296;
    349     case CSSPropertyWebkitMaskSize: return 297;
    350     case CSSPropertyWebkitMaxLogicalWidth: return 298;
    351     case CSSPropertyWebkitMaxLogicalHeight: return 299;
    352     case CSSPropertyWebkitMinLogicalWidth: return 300;
    353     case CSSPropertyWebkitMinLogicalHeight: return 301;
    354     // WebkitNbspMode has been deleted, was return 302;
    355     case CSSPropertyOrder: return 303;
    356     case CSSPropertyWebkitPaddingAfter: return 304;
    357     case CSSPropertyWebkitPaddingBefore: return 305;
    358     case CSSPropertyWebkitPaddingEnd: return 306;
    359     case CSSPropertyWebkitPaddingStart: return 307;
    360     case CSSPropertyWebkitPerspective: return 308;
    361     case CSSPropertyWebkitPerspectiveOrigin: return 309;
    362     case CSSPropertyWebkitPerspectiveOriginX: return 310;
    363     case CSSPropertyWebkitPerspectiveOriginY: return 311;
    364     case CSSPropertyWebkitPrintColorAdjust: return 312;
    365     case CSSPropertyWebkitRtlOrdering: return 313;
    366     case CSSPropertyWebkitRubyPosition: return 314;
    367     case CSSPropertyWebkitTextCombine: return 315;
    368     case CSSPropertyWebkitTextDecorationsInEffect: return 316;
    369     case CSSPropertyWebkitTextEmphasis: return 317;
    370     case CSSPropertyWebkitTextEmphasisColor: return 318;
    371     case CSSPropertyWebkitTextEmphasisPosition: return 319;
    372     case CSSPropertyWebkitTextEmphasisStyle: return 320;
    373     case CSSPropertyWebkitTextFillColor: return 321;
    374     case CSSPropertyWebkitTextSecurity: return 322;
    375     case CSSPropertyWebkitTextStroke: return 323;
    376     case CSSPropertyWebkitTextStrokeColor: return 324;
    377     case CSSPropertyWebkitTextStrokeWidth: return 325;
    378     case CSSPropertyWebkitTransform: return 326;
    379     case CSSPropertyWebkitTransformOrigin: return 327;
    380     case CSSPropertyWebkitTransformOriginX: return 328;
    381     case CSSPropertyWebkitTransformOriginY: return 329;
    382     case CSSPropertyWebkitTransformOriginZ: return 330;
    383     case CSSPropertyWebkitTransformStyle: return 331;
    384     case CSSPropertyWebkitTransition: return 332;
    385     case CSSPropertyWebkitTransitionDelay: return 333;
    386     case CSSPropertyWebkitTransitionDuration: return 334;
    387     case CSSPropertyWebkitTransitionProperty: return 335;
    388     case CSSPropertyWebkitTransitionTimingFunction: return 336;
    389     case CSSPropertyWebkitUserDrag: return 337;
    390     case CSSPropertyWebkitUserModify: return 338;
    391     case CSSPropertyWebkitUserSelect: return 339;
    392     case CSSPropertyWebkitFlowInto: return 340;
    393     case CSSPropertyWebkitFlowFrom: return 341;
    394     case CSSPropertyWebkitRegionFragment: return 342;
    395     case CSSPropertyWebkitRegionBreakAfter: return 343;
    396     case CSSPropertyWebkitRegionBreakBefore: return 344;
    397     case CSSPropertyWebkitRegionBreakInside: return 345;
    398     case CSSPropertyWebkitShapeInside: return 346;
    399     case CSSPropertyWebkitShapeOutside: return 347;
    400     case CSSPropertyWebkitShapeMargin: return 348;
    401     case CSSPropertyWebkitShapePadding: return 349;
    402     case CSSPropertyWebkitWrapFlow: return 350;
    403     case CSSPropertyWebkitWrapThrough: return 351;
    404     // CSSPropertyWebkitWrap was 352.
    405 #if defined(ENABLE_TOUCH_EVENTS) && ENABLE_TOUCH_EVENTS
    406     case CSSPropertyWebkitTapHighlightColor: return 353;
    407 #endif
    408 #if defined(ENABLE_DRAGGABLE_REGION) && ENABLE_DRAGGABLE_REGION
    409     case CSSPropertyWebkitAppRegion: return 354;
    410 #endif
    411     case CSSPropertyClipPath: return 355;
    412     case CSSPropertyClipRule: return 356;
    413     case CSSPropertyMask: return 357;
    414     case CSSPropertyEnableBackground: return 358;
    415     case CSSPropertyFilter: return 359;
    416     case CSSPropertyFloodColor: return 360;
    417     case CSSPropertyFloodOpacity: return 361;
    418     case CSSPropertyLightingColor: return 362;
    419     case CSSPropertyStopColor: return 363;
    420     case CSSPropertyStopOpacity: return 364;
    421     case CSSPropertyColorInterpolation: return 365;
    422     case CSSPropertyColorInterpolationFilters: return 366;
    423     case CSSPropertyColorProfile: return 367;
    424     case CSSPropertyColorRendering: return 368;
    425     case CSSPropertyFill: return 369;
    426     case CSSPropertyFillOpacity: return 370;
    427     case CSSPropertyFillRule: return 371;
    428     case CSSPropertyMarker: return 372;
    429     case CSSPropertyMarkerEnd: return 373;
    430     case CSSPropertyMarkerMid: return 374;
    431     case CSSPropertyMarkerStart: return 375;
    432     case CSSPropertyMaskType: return 376;
    433     case CSSPropertyShapeRendering: return 377;
    434     case CSSPropertyStroke: return 378;
    435     case CSSPropertyStrokeDasharray: return 379;
    436     case CSSPropertyStrokeDashoffset: return 380;
    437     case CSSPropertyStrokeLinecap: return 381;
    438     case CSSPropertyStrokeLinejoin: return 382;
    439     case CSSPropertyStrokeMiterlimit: return 383;
    440     case CSSPropertyStrokeOpacity: return 384;
    441     case CSSPropertyStrokeWidth: return 385;
    442     case CSSPropertyAlignmentBaseline: return 386;
    443     case CSSPropertyBaselineShift: return 387;
    444     case CSSPropertyDominantBaseline: return 388;
    445     case CSSPropertyGlyphOrientationHorizontal: return 389;
    446     case CSSPropertyGlyphOrientationVertical: return 390;
    447     case CSSPropertyKerning: return 391;
    448     case CSSPropertyTextAnchor: return 392;
    449     case CSSPropertyVectorEffect: return 393;
    450     case CSSPropertyWritingMode: return 394;
    451     // CSSPropertyWebkitSvgShadow has been removed, was return 395;
    452 #if defined(ENABLE_CURSOR_VISIBILITY) && ENABLE_CURSOR_VISIBILITY
    453     case CSSPropertyWebkitCursorVisibility: return 396;
    454 #endif
    455     // CSSPropertyImageOrientation has been removed, was return 397;
    456     // CSSPropertyImageResolution has been removed, was return 398;
    457 #if defined(ENABLE_CSS_COMPOSITING) && ENABLE_CSS_COMPOSITING
    458     case CSSPropertyWebkitBlendMode: return 399;
    459     case CSSPropertyWebkitBackgroundBlendMode: return 400;
    460 #endif
    461     case CSSPropertyTextDecorationLine: return 401;
    462     case CSSPropertyTextDecorationStyle: return 402;
    463     case CSSPropertyTextDecorationColor: return 403;
    464     case CSSPropertyTextAlignLast: return 404;
    465 #if defined(ENABLE_CSS3_TEXT) && ENABLE_CSS3_TEXT
    466     case CSSPropertyWebkitTextUnderlinePosition: return 405;
    467 #endif
    468     case CSSPropertyMaxZoom: return 406;
    469     case CSSPropertyMinZoom: return 407;
    470     case CSSPropertyOrientation: return 408;
    471     case CSSPropertyUserZoom: return 409;
    472 #if defined(ENABLE_DASHBOARD_SUPPORT) && ENABLE_DASHBOARD_SUPPORT
    473     case CSSPropertyWebkitDashboardRegion: return 410;
    474 #endif
    475     // CSSPropertyWebkitOverflowScrolling was 411.
    476     case CSSPropertyWebkitAppRegion: return 412;
    477     case CSSPropertyWebkitFilter: return 413;
    478     case CSSPropertyWebkitBoxDecorationBreak: return 414;
    479     case CSSPropertyWebkitTapHighlightColor: return 415;
    480     case CSSPropertyBufferedRendering: return 416;
    481     case CSSPropertyGridAutoRows: return 417;
    482     case CSSPropertyGridAutoColumns: return 418;
    483     case CSSPropertyBackgroundBlendMode: return 419;
    484     case CSSPropertyMixBlendMode: return 420;
    485     case CSSPropertyTouchAction: return 421;
    486     case CSSPropertyGridArea: return 422;
    487     case CSSPropertyGridTemplate: return 423;
    488 
    489     // Add new features above this line (don't change the assigned numbers of the existing
    490     // items) and update maximumCSSSampleId() with the new maximum value.
    491 
    492     case CSSPropertyInvalid:
    493     case CSSPropertyVariable:
    494         ASSERT_NOT_REACHED();
    495         return 0;
    496     }
    497 
    498     ASSERT_NOT_REACHED();
    499     return 0;
    500 }
    501 
    502 static int maximumCSSSampleId() { return 423; }
    503 
    504 UseCounter::UseCounter()
    505 {
    506     m_CSSFeatureBits.ensureSize(lastCSSProperty + 1);
    507     m_CSSFeatureBits.clearAll();
    508 }
    509 
    510 UseCounter::~UseCounter()
    511 {
    512     // We always log PageDestruction so that we have a scale for the rest of the features.
    513     HistogramSupport::histogramEnumeration("WebCore.FeatureObserver", PageDestruction, NumberOfFeatures);
    514 
    515     updateMeasurements();
    516 }
    517 
    518 void UseCounter::updateMeasurements()
    519 {
    520     HistogramSupport::histogramEnumeration("WebCore.FeatureObserver", PageVisits, NumberOfFeatures);
    521 
    522     if (m_countBits) {
    523         for (unsigned i = 0; i < NumberOfFeatures; ++i) {
    524             if (m_countBits->quickGet(i))
    525                 HistogramSupport::histogramEnumeration("WebCore.FeatureObserver", i, NumberOfFeatures);
    526         }
    527         // Clearing count bits is timing sensitive.
    528         m_countBits->clearAll();
    529     }
    530 
    531     // FIXME: Sometimes this function is called more than once per page. The following
    532     //        bool guards against incrementing the page count when there are no CSS
    533     //        bits set. http://crbug.com/236262.
    534     bool needsPagesMeasuredUpdate = false;
    535     for (int i = firstCSSProperty; i <= lastCSSProperty; ++i) {
    536         if (m_CSSFeatureBits.quickGet(i)) {
    537             int cssSampleId = mapCSSPropertyIdToCSSSampleIdForHistogram(i);
    538             HistogramSupport::histogramEnumeration("WebCore.FeatureObserver.CSSProperties", cssSampleId, maximumCSSSampleId());
    539             needsPagesMeasuredUpdate = true;
    540         }
    541     }
    542 
    543     if (needsPagesMeasuredUpdate)
    544         HistogramSupport::histogramEnumeration("WebCore.FeatureObserver.CSSProperties", totalPagesMeasuredCSSSampleId(), maximumCSSSampleId());
    545 
    546     m_CSSFeatureBits.clearAll();
    547 }
    548 
    549 void UseCounter::didCommitLoad()
    550 {
    551     updateMeasurements();
    552 }
    553 
    554 void UseCounter::count(Document* document, Feature feature)
    555 {
    556     if (!document)
    557         return;
    558 
    559     Page* page = document->page();
    560     if (!page)
    561         return;
    562 
    563     ASSERT(page->useCounter()->deprecationMessage(feature).isEmpty());
    564     page->useCounter()->recordMeasurement(feature);
    565 }
    566 
    567 void UseCounter::count(DOMWindow* domWindow, Feature feature)
    568 {
    569     ASSERT(domWindow);
    570     count(domWindow->document(), feature);
    571 }
    572 
    573 void UseCounter::countDeprecation(ScriptExecutionContext* context, Feature feature)
    574 {
    575     if (!context || !context->isDocument())
    576         return;
    577     UseCounter::countDeprecation(toDocument(context), feature);
    578 }
    579 
    580 void UseCounter::countDeprecation(DOMWindow* window, Feature feature)
    581 {
    582     if (!window)
    583         return;
    584     UseCounter::countDeprecation(window->document(), feature);
    585 }
    586 
    587 void UseCounter::countDeprecation(Document* document, Feature feature)
    588 {
    589     if (!document)
    590         return;
    591 
    592     Page* page = document->page();
    593     if (!page)
    594         return;
    595 
    596     if (page->useCounter()->recordMeasurement(feature)) {
    597         ASSERT(!page->useCounter()->deprecationMessage(feature).isEmpty());
    598         page->console()->addMessage(DeprecationMessageSource, WarningMessageLevel, page->useCounter()->deprecationMessage(feature));
    599     }
    600 }
    601 
    602 String UseCounter::deprecationMessage(Feature feature)
    603 {
    604     switch (feature) {
    605     // Content Security Policy
    606     case PrefixedContentSecurityPolicy:
    607     case PrefixedContentSecurityPolicyReportOnly:
    608         return "The 'X-WebKit-CSP' headers are deprecated; please consider using the canonical 'Content-Security-Policy' header instead.";
    609 
    610     // HTMLMediaElement
    611     case PrefixedMediaGenerateKeyRequest:
    612         return "'HTMLMediaElement.webkitGenerateKeyRequest()' is deprecated. Please use 'MediaKeys.createSession()' instead.";
    613 
    614     // Quota
    615     case StorageInfo:
    616         return "'window.webkitStorageInfo' is deprecated. Please use 'navigator.webkitTemporaryStorage' or 'navigator.webkitPersistentStorage' instead.";
    617 
    618     // Performance
    619     case PrefixedPerformanceTimeline:
    620         return "'window.performance.webkitGet*' methods have been deprecated. Please use the unprefixed 'performance.get*' methods instead.";
    621     case PrefixedUserTiming:
    622         return "'window.performance.webkit*' methods have been deprecated. Please use the unprefixed 'window.performance.*' methods instead.";
    623 
    624     // Web Audio
    625     case WebAudioLooping:
    626         return "AudioBufferSourceNode 'looping' attribute is deprecated.  Use 'loop' instead.";
    627 
    628     case DocumentClear:
    629         return "document.clear() is deprecated. This method doesn't do anything.";
    630 
    631     case PrefixedTransitionMediaFeature:
    632         return "The '(-webkit-transition)' media query feature is deprecated; please consider using the more exact conditional \"@supports('(transition-property: prop_name)')\" instead.";
    633 
    634     // Web Components
    635     case HTMLShadowElementOlderShadowRoot:
    636         return "HTMLShadowElement.olderShadowRoot is deprecated.";
    637     case PrefixedDocumentRegister:
    638         return "The document.webkitRegister method is deprecated. Use the document.register method instead.";
    639 
    640     // HTML Media Capture
    641     case CaptureAttributeAsEnum:
    642         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.";
    643 
    644     // Keyboard Event (DOM Level 3)
    645     case KeyboardEventKeyLocation:
    646         return "'KeyboardEvent.keyLocation'' is deprecated. Please use 'KeyboardEvent.location' instead.";
    647 
    648     case CaptureEvents:
    649         return "captureEvents() is deprecated. This method doesn't do anything.";
    650 
    651     case ReleaseEvents:
    652         return "releaseEvents() is deprecated. This method doesn't do anything.";
    653 
    654     case ConsoleMarkTimeline:
    655         return "console.markTimeline is deprecated. Please use the console.timeStamp instead.";
    656 
    657     // Features that aren't deprecated don't have a deprecation message.
    658     default:
    659         return String();
    660     }
    661 }
    662 
    663 void UseCounter::count(CSSPropertyID feature)
    664 {
    665     ASSERT(feature >= firstCSSProperty);
    666     ASSERT(feature <= lastCSSProperty);
    667     m_CSSFeatureBits.quickSet(feature);
    668 }
    669 
    670 void UseCounter::count(Feature feature)
    671 {
    672     ASSERT(deprecationMessage(feature).isEmpty());
    673     recordMeasurement(feature);
    674 }
    675 
    676 UseCounter* UseCounter::getFrom(const Document* document)
    677 {
    678     if (document && document->page())
    679         return document->page()->useCounter();
    680     return 0;
    681 }
    682 
    683 UseCounter* UseCounter::getFrom(const CSSStyleSheet* sheet)
    684 {
    685     if (sheet)
    686         return getFrom(sheet->contents());
    687     return 0;
    688 }
    689 
    690 UseCounter* UseCounter::getFrom(const StyleSheetContents* sheetContents)
    691 {
    692     // FIXME: We may want to handle stylesheets that have multiple owners
    693     //        http://crbug.com/242125
    694     if (sheetContents && !sheetContents->isUserStyleSheet() && sheetContents->hasSingleOwnerNode())
    695         return getFrom(sheetContents->singleOwnerDocument());
    696     return 0;
    697 }
    698 
    699 } // namespace WebCore
    700