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