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/DOMWindow.h" 35 #include "core/page/Page.h" 36 #include "core/page/PageConsole.h" 37 #include "public/platform/Platform.h" 38 39 namespace WebCore { 40 41 static int totalPagesMeasuredCSSSampleId() { return 1; } 42 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) 49 { 50 CSSPropertyID cssPropertyID = convertToCSSPropertyID(id); 51 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 CSSPropertyWebkitFontVariantLigatures: 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; 281 #endif 282 #if defined(ENABLE_CSS_FILTERS) && ENABLE_CSS_FILTERS 283 case CSSPropertyWebkitFilter: return 229; 284 #endif 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 CSSPropertyGridDefinitionColumns: return 242; 298 case CSSPropertyGridDefinitionRows: 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; 402 #endif 403 #if defined(ENABLE_DRAGGABLE_REGION) && ENABLE_DRAGGABLE_REGION 404 case CSSPropertyWebkitAppRegion: return 354; 405 #endif 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; 449 #endif 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; 455 #endif 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 CSSPropertyGridTemplate: 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 499 // Add new features above this line (don't change the assigned numbers of the existing 500 // items) and update maximumCSSSampleId() with the new maximum value. 501 502 // Internal properties should not be counted. 503 case CSSPropertyInternalMarqueeDirection: 504 case CSSPropertyInternalMarqueeIncrement: 505 case CSSPropertyInternalMarqueeRepetition: 506 case CSSPropertyInternalMarqueeSpeed: 507 case CSSPropertyInternalMarqueeStyle: 508 case CSSPropertyInvalid: 509 case CSSPropertyVariable: 510 ASSERT_NOT_REACHED(); 511 return 0; 512 } 513 514 ASSERT_NOT_REACHED(); 515 return 0; 516 } 517 518 static int maximumCSSSampleId() { return 442; } 519 520 UseCounter::UseCounter() 521 { 522 m_CSSFeatureBits.ensureSize(lastCSSProperty + 1); 523 m_CSSFeatureBits.clearAll(); 524 } 525 526 UseCounter::~UseCounter() 527 { 528 // We always log PageDestruction so that we have a scale for the rest of the features. 529 blink::Platform::current()->histogramEnumeration("WebCore.FeatureObserver", PageDestruction, NumberOfFeatures); 530 531 updateMeasurements(); 532 } 533 534 void UseCounter::updateMeasurements() 535 { 536 blink::Platform::current()->histogramEnumeration("WebCore.FeatureObserver", PageVisits, NumberOfFeatures); 537 538 if (m_countBits) { 539 for (unsigned i = 0; i < NumberOfFeatures; ++i) { 540 if (m_countBits->quickGet(i)) 541 blink::Platform::current()->histogramEnumeration("WebCore.FeatureObserver", i, NumberOfFeatures); 542 } 543 // Clearing count bits is timing sensitive. 544 m_countBits->clearAll(); 545 } 546 547 // FIXME: Sometimes this function is called more than once per page. The following 548 // bool guards against incrementing the page count when there are no CSS 549 // bits set. http://crbug.com/236262. 550 bool needsPagesMeasuredUpdate = false; 551 for (int i = firstCSSProperty; i <= lastCSSProperty; ++i) { 552 if (m_CSSFeatureBits.quickGet(i)) { 553 int cssSampleId = mapCSSPropertyIdToCSSSampleIdForHistogram(i); 554 blink::Platform::current()->histogramEnumeration("WebCore.FeatureObserver.CSSProperties", cssSampleId, maximumCSSSampleId()); 555 needsPagesMeasuredUpdate = true; 556 } 557 } 558 559 if (needsPagesMeasuredUpdate) 560 blink::Platform::current()->histogramEnumeration("WebCore.FeatureObserver.CSSProperties", totalPagesMeasuredCSSSampleId(), maximumCSSSampleId()); 561 562 m_CSSFeatureBits.clearAll(); 563 } 564 565 void UseCounter::didCommitLoad() 566 { 567 updateMeasurements(); 568 } 569 570 void UseCounter::count(const Document& document, Feature feature) 571 { 572 Page* page = document.page(); 573 if (!page) 574 return; 575 576 ASSERT(page->useCounter().deprecationMessage(feature).isEmpty()); 577 page->useCounter().recordMeasurement(feature); 578 } 579 580 void UseCounter::count(const DOMWindow* domWindow, Feature feature) 581 { 582 ASSERT(domWindow); 583 if (!domWindow->document()) 584 return; 585 count(*domWindow->document(), feature); 586 } 587 588 void UseCounter::countDeprecation(ExecutionContext* context, Feature feature) 589 { 590 if (!context || !context->isDocument()) 591 return; 592 UseCounter::countDeprecation(*toDocument(context), feature); 593 } 594 595 void UseCounter::countDeprecation(const DOMWindow* window, Feature feature) 596 { 597 if (!window || !window->document()) 598 return; 599 UseCounter::countDeprecation(*window->document(), feature); 600 } 601 602 void UseCounter::countDeprecation(const Document& document, Feature feature) 603 { 604 Page* page = document.page(); 605 if (!page) 606 return; 607 608 if (page->useCounter().recordMeasurement(feature)) { 609 ASSERT(!page->useCounter().deprecationMessage(feature).isEmpty()); 610 page->console().addMessage(DeprecationMessageSource, WarningMessageLevel, page->useCounter().deprecationMessage(feature)); 611 } 612 } 613 614 String UseCounter::deprecationMessage(Feature feature) 615 { 616 switch (feature) { 617 // Content Security Policy 618 case PrefixedContentSecurityPolicy: 619 case PrefixedContentSecurityPolicyReportOnly: 620 return "The 'X-WebKit-CSP' headers are no longer supported. Please consider using the canonical 'Content-Security-Policy' header instead."; 621 622 // HTMLMediaElement 623 case PrefixedMediaGenerateKeyRequest: 624 return "'HTMLMediaElement.webkitGenerateKeyRequest()' is deprecated. Please use 'MediaKeys.createSession()' instead."; 625 626 // Quota 627 case StorageInfo: 628 return "'window.webkitStorageInfo' is deprecated. Please use 'navigator.webkitTemporaryStorage' or 'navigator.webkitPersistentStorage' instead."; 629 630 // Performance 631 case PrefixedPerformanceTimeline: 632 return "'window.performance.webkitGet*' methods have been deprecated. Please use the unprefixed 'performance.get*' methods instead."; 633 case PrefixedUserTiming: 634 return "'window.performance.webkit*' methods have been deprecated. Please use the unprefixed 'window.performance.*' methods instead."; 635 636 // Web Audio 637 case WebAudioLooping: 638 return "AudioBufferSourceNode 'looping' attribute is deprecated. Use 'loop' instead."; 639 640 case DocumentClear: 641 return "document.clear() is deprecated. This method doesn't do anything."; 642 643 case PrefixedTransitionMediaFeature: 644 return "The '(-webkit-transition)' media query feature is deprecated; please consider using the more exact conditional \"@supports('(transition-property: prop_name)')\" instead."; 645 646 // Web Components 647 case HTMLShadowElementOlderShadowRoot: 648 return "HTMLShadowElement.olderShadowRoot is deprecated."; 649 650 // HTML Media Capture 651 case CaptureAttributeAsEnum: 652 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."; 653 654 // Keyboard Event (DOM Level 3) 655 case KeyboardEventKeyLocation: 656 return "'KeyboardEvent.keyLocation'' is deprecated. Please use 'KeyboardEvent.location' instead."; 657 658 case CaptureEvents: 659 return "captureEvents() is deprecated. This method doesn't do anything."; 660 661 case ReleaseEvents: 662 return "releaseEvents() is deprecated. This method doesn't do anything."; 663 664 case ConsoleMarkTimeline: 665 return "console.markTimeline is deprecated. Please use the console.timeStamp instead."; 666 667 case FileError: 668 return "FileError is deprecated. Please use the 'name' or 'message' attributes of DOMError rather than 'code'."; 669 670 case EventReturnValue: 671 return "event.returnValue is deprecated. Please use the standard event.preventDefault() instead."; 672 673 case ScrollTopBodyNotQuirksMode: 674 return "body.scrollTop is deprecated in strict mode. Please use 'documentElement.scrollTop' if in strict mode and 'body.scrollTop' only if in quirks mode."; 675 676 case ScrollLeftBodyNotQuirksMode: 677 return "body.scrollLeft is deprecated in strict mode. Please use 'documentElement.scrollLeft' if in strict mode and 'body.scrollLeft' only if in quirks mode."; 678 679 case ShowModalDialog: 680 return "Chromium is considering deprecating showModalDialog. Please use window.open and postMessage instead."; 681 682 case CSSStyleSheetInsertRuleOptionalArg: 683 return "Calling CSSStyleSheet.insertRule() with one argument is deprecated. Please pass the index argument as well: insertRule(x, 0)."; 684 685 // Features that aren't deprecated don't have a deprecation message. 686 default: 687 return String(); 688 } 689 } 690 691 void UseCounter::count(CSSParserContext context, CSSPropertyID feature) 692 { 693 ASSERT(feature >= firstCSSProperty); 694 ASSERT(feature <= lastCSSProperty); 695 ASSERT(!isInternalProperty(feature)); 696 697 if (!isUseCounterEnabledForMode(context.mode())) 698 return; 699 700 m_CSSFeatureBits.quickSet(feature); 701 } 702 703 void UseCounter::count(Feature feature) 704 { 705 ASSERT(deprecationMessage(feature).isEmpty()); 706 recordMeasurement(feature); 707 } 708 709 UseCounter* UseCounter::getFrom(const Document* document) 710 { 711 if (document && document->page()) 712 return &document->page()->useCounter(); 713 return 0; 714 } 715 716 UseCounter* UseCounter::getFrom(const CSSStyleSheet* sheet) 717 { 718 if (sheet) 719 return getFrom(sheet->contents()); 720 return 0; 721 } 722 723 UseCounter* UseCounter::getFrom(const StyleSheetContents* sheetContents) 724 { 725 // FIXME: We may want to handle stylesheets that have multiple owners 726 // http://crbug.com/242125 727 if (sheetContents && sheetContents->hasSingleOwnerNode()) 728 return getFrom(sheetContents->singleOwnerDocument()); 729 return 0; 730 } 731 732 } // namespace WebCore 733