CSSComputedStyleDeclaration.cpp 148 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126
  1. /*
  2. * Copyright (C) 2004 Zack Rusin <zack@kde.org>
  3. * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
  4. * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
  5. * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com>
  6. * Copyright (C) 2011 Sencha, Inc. All rights reserved.
  7. *
  8. * This library is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU Lesser General Public
  10. * License as published by the Free Software Foundation; either
  11. * version 2 of the License, or (at your option) any later version.
  12. *
  13. * This library is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * Lesser General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with this library; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  21. * 02110-1301 USA
  22. */
  23. #include "config.h"
  24. #include "CSSComputedStyleDeclaration.h"
  25. #include "AnimationController.h"
  26. #include "BasicShapeFunctions.h"
  27. #include "BasicShapes.h"
  28. #include "CSSAspectRatioValue.h"
  29. #include "CSSBasicShapes.h"
  30. #include "CSSBorderImage.h"
  31. #include "CSSFunctionValue.h"
  32. #include "CSSLineBoxContainValue.h"
  33. #include "CSSParser.h"
  34. #include "CSSPrimitiveValue.h"
  35. #include "CSSPrimitiveValueMappings.h"
  36. #include "CSSPropertyNames.h"
  37. #include "CSSReflectValue.h"
  38. #include "CSSSelector.h"
  39. #include "CSSTimingFunctionValue.h"
  40. #include "CSSValueList.h"
  41. #include "CSSValuePool.h"
  42. #include "ContentData.h"
  43. #include "CounterContent.h"
  44. #include "CursorList.h"
  45. #include "Document.h"
  46. #include "ExceptionCode.h"
  47. #include "FontFeatureSettings.h"
  48. #include "FontFeatureValue.h"
  49. #include "FontValue.h"
  50. #include "HTMLFrameOwnerElement.h"
  51. #include "Pair.h"
  52. #include "PseudoElement.h"
  53. #include "Rect.h"
  54. #include "RenderBox.h"
  55. #include "RenderStyle.h"
  56. #include "RenderView.h"
  57. #include "ShadowValue.h"
  58. #include "StyleInheritedData.h"
  59. #include "StylePropertySet.h"
  60. #include "StylePropertyShorthand.h"
  61. #include "StyleResolver.h"
  62. #include "WebKitCSSTransformValue.h"
  63. #include "WebKitFontFamilyNames.h"
  64. #include <wtf/text/StringBuilder.h>
  65. #if ENABLE(CSS_SHAPES)
  66. #include "ShapeValue.h"
  67. #endif
  68. #if ENABLE(CSS_SHADERS)
  69. #include "CustomFilterArrayParameter.h"
  70. #include "CustomFilterColorParameter.h"
  71. #include "CustomFilterNumberParameter.h"
  72. #include "CustomFilterOperation.h"
  73. #include "CustomFilterParameter.h"
  74. #include "CustomFilterTransformParameter.h"
  75. #include "WebKitCSSArrayFunctionValue.h"
  76. #include "WebKitCSSMatFunctionValue.h"
  77. #include "WebKitCSSMixFunctionValue.h"
  78. #endif
  79. #if ENABLE(CSS_FILTERS)
  80. #include "StyleCustomFilterProgram.h"
  81. #include "WebKitCSSFilterValue.h"
  82. #endif
  83. #if ENABLE(DASHBOARD_SUPPORT)
  84. #include "DashboardRegion.h"
  85. #endif
  86. namespace WebCore {
  87. // List of all properties we know how to compute, omitting shorthands.
  88. static const CSSPropertyID computedProperties[] = {
  89. CSSPropertyBackgroundAttachment,
  90. CSSPropertyBackgroundClip,
  91. CSSPropertyBackgroundColor,
  92. CSSPropertyBackgroundImage,
  93. CSSPropertyBackgroundOrigin,
  94. CSSPropertyBackgroundPosition, // more-specific background-position-x/y are non-standard
  95. CSSPropertyBackgroundRepeat,
  96. CSSPropertyBackgroundSize,
  97. CSSPropertyBorderBottomColor,
  98. CSSPropertyBorderBottomLeftRadius,
  99. CSSPropertyBorderBottomRightRadius,
  100. CSSPropertyBorderBottomStyle,
  101. CSSPropertyBorderBottomWidth,
  102. CSSPropertyBorderCollapse,
  103. CSSPropertyBorderImageOutset,
  104. CSSPropertyBorderImageRepeat,
  105. CSSPropertyBorderImageSlice,
  106. CSSPropertyBorderImageSource,
  107. CSSPropertyBorderImageWidth,
  108. CSSPropertyBorderLeftColor,
  109. CSSPropertyBorderLeftStyle,
  110. CSSPropertyBorderLeftWidth,
  111. CSSPropertyBorderRightColor,
  112. CSSPropertyBorderRightStyle,
  113. CSSPropertyBorderRightWidth,
  114. CSSPropertyBorderTopColor,
  115. CSSPropertyBorderTopLeftRadius,
  116. CSSPropertyBorderTopRightRadius,
  117. CSSPropertyBorderTopStyle,
  118. CSSPropertyBorderTopWidth,
  119. CSSPropertyBottom,
  120. CSSPropertyBoxShadow,
  121. CSSPropertyBoxSizing,
  122. CSSPropertyCaptionSide,
  123. CSSPropertyClear,
  124. CSSPropertyClip,
  125. CSSPropertyColor,
  126. CSSPropertyCursor,
  127. CSSPropertyDirection,
  128. CSSPropertyDisplay,
  129. CSSPropertyEmptyCells,
  130. CSSPropertyFloat,
  131. CSSPropertyFontFamily,
  132. CSSPropertyFontSize,
  133. CSSPropertyFontStyle,
  134. CSSPropertyFontVariant,
  135. CSSPropertyFontWeight,
  136. CSSPropertyHeight,
  137. #if ENABLE(CSS_IMAGE_ORIENTATION)
  138. CSSPropertyImageOrientation,
  139. #endif
  140. CSSPropertyImageRendering,
  141. #if ENABLE(CSS_IMAGE_RESOLUTION)
  142. CSSPropertyImageResolution,
  143. #endif
  144. CSSPropertyLeft,
  145. CSSPropertyLetterSpacing,
  146. CSSPropertyLineHeight,
  147. CSSPropertyListStyleImage,
  148. CSSPropertyListStylePosition,
  149. CSSPropertyListStyleType,
  150. CSSPropertyMarginBottom,
  151. CSSPropertyMarginLeft,
  152. CSSPropertyMarginRight,
  153. CSSPropertyMarginTop,
  154. CSSPropertyMaxHeight,
  155. CSSPropertyMaxWidth,
  156. CSSPropertyMinHeight,
  157. CSSPropertyMinWidth,
  158. CSSPropertyOpacity,
  159. CSSPropertyOrphans,
  160. CSSPropertyOutlineColor,
  161. CSSPropertyOutlineOffset,
  162. CSSPropertyOutlineStyle,
  163. CSSPropertyOutlineWidth,
  164. CSSPropertyOverflowWrap,
  165. CSSPropertyOverflowX,
  166. CSSPropertyOverflowY,
  167. CSSPropertyPaddingBottom,
  168. CSSPropertyPaddingLeft,
  169. CSSPropertyPaddingRight,
  170. CSSPropertyPaddingTop,
  171. CSSPropertyPageBreakAfter,
  172. CSSPropertyPageBreakBefore,
  173. CSSPropertyPageBreakInside,
  174. CSSPropertyPointerEvents,
  175. CSSPropertyPosition,
  176. CSSPropertyResize,
  177. CSSPropertyRight,
  178. CSSPropertySpeak,
  179. CSSPropertyTableLayout,
  180. CSSPropertyTabSize,
  181. CSSPropertyTextAlign,
  182. CSSPropertyTextDecoration,
  183. #if ENABLE(CSS3_TEXT)
  184. CSSPropertyWebkitTextDecorationLine,
  185. CSSPropertyWebkitTextDecorationStyle,
  186. CSSPropertyWebkitTextDecorationColor,
  187. CSSPropertyWebkitTextAlignLast,
  188. CSSPropertyWebkitTextJustify,
  189. CSSPropertyWebkitTextUnderlinePosition,
  190. #endif // CSS3_TEXT
  191. CSSPropertyTextIndent,
  192. CSSPropertyTextRendering,
  193. CSSPropertyTextShadow,
  194. CSSPropertyTextOverflow,
  195. CSSPropertyTextTransform,
  196. CSSPropertyTop,
  197. CSSPropertyTransitionDelay,
  198. CSSPropertyTransitionDuration,
  199. CSSPropertyTransitionProperty,
  200. CSSPropertyTransitionTimingFunction,
  201. CSSPropertyUnicodeBidi,
  202. CSSPropertyVerticalAlign,
  203. CSSPropertyVisibility,
  204. CSSPropertyWhiteSpace,
  205. CSSPropertyWidows,
  206. CSSPropertyWidth,
  207. CSSPropertyWordBreak,
  208. CSSPropertyWordSpacing,
  209. CSSPropertyWordWrap,
  210. CSSPropertyZIndex,
  211. CSSPropertyZoom,
  212. CSSPropertyWebkitAnimationDelay,
  213. CSSPropertyWebkitAnimationDirection,
  214. CSSPropertyWebkitAnimationDuration,
  215. CSSPropertyWebkitAnimationFillMode,
  216. CSSPropertyWebkitAnimationIterationCount,
  217. CSSPropertyWebkitAnimationName,
  218. CSSPropertyWebkitAnimationPlayState,
  219. CSSPropertyWebkitAnimationTimingFunction,
  220. CSSPropertyWebkitAppearance,
  221. CSSPropertyWebkitBackfaceVisibility,
  222. CSSPropertyWebkitBackgroundClip,
  223. CSSPropertyWebkitBackgroundComposite,
  224. CSSPropertyWebkitBackgroundOrigin,
  225. CSSPropertyWebkitBackgroundSize,
  226. #if ENABLE(CSS_COMPOSITING)
  227. CSSPropertyWebkitBlendMode,
  228. CSSPropertyWebkitBackgroundBlendMode,
  229. #endif
  230. CSSPropertyWebkitBorderFit,
  231. CSSPropertyWebkitBorderHorizontalSpacing,
  232. CSSPropertyWebkitBorderImage,
  233. CSSPropertyWebkitBorderVerticalSpacing,
  234. CSSPropertyWebkitBoxAlign,
  235. #if ENABLE(CSS_BOX_DECORATION_BREAK)
  236. CSSPropertyWebkitBoxDecorationBreak,
  237. #endif
  238. CSSPropertyWebkitBoxDirection,
  239. CSSPropertyWebkitBoxFlex,
  240. CSSPropertyWebkitBoxFlexGroup,
  241. CSSPropertyWebkitBoxLines,
  242. CSSPropertyWebkitBoxOrdinalGroup,
  243. CSSPropertyWebkitBoxOrient,
  244. CSSPropertyWebkitBoxPack,
  245. CSSPropertyWebkitBoxReflect,
  246. CSSPropertyWebkitBoxShadow,
  247. CSSPropertyWebkitClipPath,
  248. CSSPropertyWebkitColorCorrection,
  249. CSSPropertyWebkitColumnBreakAfter,
  250. CSSPropertyWebkitColumnBreakBefore,
  251. CSSPropertyWebkitColumnBreakInside,
  252. CSSPropertyWebkitColumnAxis,
  253. CSSPropertyWebkitColumnCount,
  254. CSSPropertyWebkitColumnGap,
  255. CSSPropertyWebkitColumnProgression,
  256. CSSPropertyWebkitColumnRuleColor,
  257. CSSPropertyWebkitColumnRuleStyle,
  258. CSSPropertyWebkitColumnRuleWidth,
  259. CSSPropertyWebkitColumnSpan,
  260. CSSPropertyWebkitColumnWidth,
  261. #if ENABLE(CURSOR_VISIBILITY)
  262. CSSPropertyWebkitCursorVisibility,
  263. #endif
  264. #if ENABLE(DASHBOARD_SUPPORT)
  265. CSSPropertyWebkitDashboardRegion,
  266. #endif
  267. #if ENABLE(CSS_FILTERS)
  268. CSSPropertyWebkitFilter,
  269. #endif
  270. CSSPropertyWebkitAlignContent,
  271. CSSPropertyWebkitAlignItems,
  272. CSSPropertyWebkitAlignSelf,
  273. CSSPropertyWebkitFlexBasis,
  274. CSSPropertyWebkitFlexGrow,
  275. CSSPropertyWebkitFlexShrink,
  276. CSSPropertyWebkitFlexDirection,
  277. CSSPropertyWebkitFlexWrap,
  278. CSSPropertyWebkitJustifyContent,
  279. CSSPropertyWebkitFontKerning,
  280. CSSPropertyWebkitFontSmoothing,
  281. CSSPropertyWebkitFontVariantLigatures,
  282. CSSPropertyWebkitGridAutoColumns,
  283. CSSPropertyWebkitGridAutoFlow,
  284. CSSPropertyWebkitGridAutoRows,
  285. CSSPropertyWebkitGridColumns,
  286. CSSPropertyWebkitGridRows,
  287. CSSPropertyWebkitGridStart,
  288. CSSPropertyWebkitGridEnd,
  289. CSSPropertyWebkitGridBefore,
  290. CSSPropertyWebkitGridAfter,
  291. CSSPropertyWebkitHighlight,
  292. CSSPropertyWebkitHyphenateCharacter,
  293. CSSPropertyWebkitHyphenateLimitAfter,
  294. CSSPropertyWebkitHyphenateLimitBefore,
  295. CSSPropertyWebkitHyphenateLimitLines,
  296. CSSPropertyWebkitHyphens,
  297. CSSPropertyWebkitLineAlign,
  298. CSSPropertyWebkitLineBoxContain,
  299. CSSPropertyWebkitLineBreak,
  300. CSSPropertyWebkitLineClamp,
  301. CSSPropertyWebkitLineGrid,
  302. CSSPropertyWebkitLineSnap,
  303. CSSPropertyWebkitLocale,
  304. CSSPropertyWebkitMarginBeforeCollapse,
  305. CSSPropertyWebkitMarginAfterCollapse,
  306. CSSPropertyWebkitMarqueeDirection,
  307. CSSPropertyWebkitMarqueeIncrement,
  308. CSSPropertyWebkitMarqueeRepetition,
  309. CSSPropertyWebkitMarqueeStyle,
  310. CSSPropertyWebkitMaskBoxImage,
  311. CSSPropertyWebkitMaskBoxImageOutset,
  312. CSSPropertyWebkitMaskBoxImageRepeat,
  313. CSSPropertyWebkitMaskBoxImageSlice,
  314. CSSPropertyWebkitMaskBoxImageSource,
  315. CSSPropertyWebkitMaskBoxImageWidth,
  316. CSSPropertyWebkitMaskClip,
  317. CSSPropertyWebkitMaskComposite,
  318. CSSPropertyWebkitMaskImage,
  319. CSSPropertyWebkitMaskOrigin,
  320. CSSPropertyWebkitMaskPosition,
  321. CSSPropertyWebkitMaskRepeat,
  322. CSSPropertyWebkitMaskSize,
  323. CSSPropertyWebkitNbspMode,
  324. CSSPropertyWebkitOrder,
  325. #if ENABLE(ACCELERATED_OVERFLOW_SCROLLING)
  326. CSSPropertyWebkitOverflowScrolling,
  327. #endif
  328. CSSPropertyWebkitPerspective,
  329. CSSPropertyWebkitPerspectiveOrigin,
  330. CSSPropertyWebkitPrintColorAdjust,
  331. CSSPropertyWebkitRtlOrdering,
  332. #if ENABLE(CSS_SHAPES)
  333. CSSPropertyWebkitShapeInside,
  334. CSSPropertyWebkitShapeOutside,
  335. #endif
  336. #if ENABLE(TOUCH_EVENTS)
  337. CSSPropertyWebkitTapHighlightColor,
  338. #endif
  339. CSSPropertyWebkitTextCombine,
  340. CSSPropertyWebkitTextDecorationsInEffect,
  341. CSSPropertyWebkitTextEmphasisColor,
  342. CSSPropertyWebkitTextEmphasisPosition,
  343. CSSPropertyWebkitTextEmphasisStyle,
  344. CSSPropertyWebkitTextFillColor,
  345. CSSPropertyWebkitTextOrientation,
  346. CSSPropertyWebkitTextSecurity,
  347. CSSPropertyWebkitTextStrokeColor,
  348. CSSPropertyWebkitTextStrokeWidth,
  349. CSSPropertyWebkitTransform,
  350. CSSPropertyWebkitTransformOrigin,
  351. CSSPropertyWebkitTransformStyle,
  352. CSSPropertyWebkitTransitionDelay,
  353. CSSPropertyWebkitTransitionDuration,
  354. CSSPropertyWebkitTransitionProperty,
  355. CSSPropertyWebkitTransitionTimingFunction,
  356. CSSPropertyWebkitUserDrag,
  357. CSSPropertyWebkitUserModify,
  358. CSSPropertyWebkitUserSelect,
  359. CSSPropertyWebkitWritingMode,
  360. #if ENABLE(CSS_REGIONS)
  361. CSSPropertyWebkitFlowInto,
  362. CSSPropertyWebkitFlowFrom,
  363. CSSPropertyWebkitRegionBreakAfter,
  364. CSSPropertyWebkitRegionBreakBefore,
  365. CSSPropertyWebkitRegionBreakInside,
  366. CSSPropertyWebkitRegionFragment,
  367. #endif
  368. #if ENABLE(DRAGGABLE_REGION)
  369. CSSPropertyWebkitAppRegion,
  370. #endif
  371. #if ENABLE(CSS_EXCLUSIONS)
  372. CSSPropertyWebkitWrapFlow,
  373. CSSPropertyWebkitWrapThrough,
  374. #endif
  375. #if ENABLE(CSS_SHAPES)
  376. CSSPropertyWebkitShapeMargin,
  377. CSSPropertyWebkitShapePadding,
  378. #endif
  379. #if ENABLE(SVG)
  380. CSSPropertyBufferedRendering,
  381. CSSPropertyClipPath,
  382. CSSPropertyClipRule,
  383. CSSPropertyMask,
  384. CSSPropertyFilter,
  385. CSSPropertyFloodColor,
  386. CSSPropertyFloodOpacity,
  387. CSSPropertyLightingColor,
  388. CSSPropertyStopColor,
  389. CSSPropertyStopOpacity,
  390. CSSPropertyColorInterpolation,
  391. CSSPropertyColorInterpolationFilters,
  392. CSSPropertyColorRendering,
  393. CSSPropertyFill,
  394. CSSPropertyFillOpacity,
  395. CSSPropertyFillRule,
  396. CSSPropertyMarkerEnd,
  397. CSSPropertyMarkerMid,
  398. CSSPropertyMarkerStart,
  399. CSSPropertyMaskType,
  400. CSSPropertyShapeRendering,
  401. CSSPropertyStroke,
  402. CSSPropertyStrokeDasharray,
  403. CSSPropertyStrokeDashoffset,
  404. CSSPropertyStrokeLinecap,
  405. CSSPropertyStrokeLinejoin,
  406. CSSPropertyStrokeMiterlimit,
  407. CSSPropertyStrokeOpacity,
  408. CSSPropertyStrokeWidth,
  409. CSSPropertyAlignmentBaseline,
  410. CSSPropertyBaselineShift,
  411. CSSPropertyDominantBaseline,
  412. CSSPropertyKerning,
  413. CSSPropertyTextAnchor,
  414. CSSPropertyWritingMode,
  415. CSSPropertyGlyphOrientationHorizontal,
  416. CSSPropertyGlyphOrientationVertical,
  417. CSSPropertyWebkitSvgShadow,
  418. CSSPropertyVectorEffect
  419. #endif
  420. };
  421. const unsigned numComputedProperties = WTF_ARRAY_LENGTH(computedProperties);
  422. static int valueForRepeatRule(int rule)
  423. {
  424. switch (rule) {
  425. case RepeatImageRule:
  426. return CSSValueRepeat;
  427. case RoundImageRule:
  428. return CSSValueRound;
  429. case SpaceImageRule:
  430. return CSSValueSpace;
  431. default:
  432. return CSSValueStretch;
  433. }
  434. }
  435. static PassRefPtr<CSSBorderImageSliceValue> valueForNinePieceImageSlice(const NinePieceImage& image)
  436. {
  437. // Create the slices.
  438. RefPtr<CSSPrimitiveValue> top;
  439. RefPtr<CSSPrimitiveValue> right;
  440. RefPtr<CSSPrimitiveValue> bottom;
  441. RefPtr<CSSPrimitiveValue> left;
  442. if (image.imageSlices().top().isPercent())
  443. top = cssValuePool().createValue(image.imageSlices().top().value(), CSSPrimitiveValue::CSS_PERCENTAGE);
  444. else
  445. top = cssValuePool().createValue(image.imageSlices().top().value(), CSSPrimitiveValue::CSS_NUMBER);
  446. if (image.imageSlices().right() == image.imageSlices().top() && image.imageSlices().bottom() == image.imageSlices().top()
  447. && image.imageSlices().left() == image.imageSlices().top()) {
  448. right = top;
  449. bottom = top;
  450. left = top;
  451. } else {
  452. if (image.imageSlices().right().isPercent())
  453. right = cssValuePool().createValue(image.imageSlices().right().value(), CSSPrimitiveValue::CSS_PERCENTAGE);
  454. else
  455. right = cssValuePool().createValue(image.imageSlices().right().value(), CSSPrimitiveValue::CSS_NUMBER);
  456. if (image.imageSlices().bottom() == image.imageSlices().top() && image.imageSlices().right() == image.imageSlices().left()) {
  457. bottom = top;
  458. left = right;
  459. } else {
  460. if (image.imageSlices().bottom().isPercent())
  461. bottom = cssValuePool().createValue(image.imageSlices().bottom().value(), CSSPrimitiveValue::CSS_PERCENTAGE);
  462. else
  463. bottom = cssValuePool().createValue(image.imageSlices().bottom().value(), CSSPrimitiveValue::CSS_NUMBER);
  464. if (image.imageSlices().left() == image.imageSlices().right())
  465. left = right;
  466. else {
  467. if (image.imageSlices().left().isPercent())
  468. left = cssValuePool().createValue(image.imageSlices().left().value(), CSSPrimitiveValue::CSS_PERCENTAGE);
  469. else
  470. left = cssValuePool().createValue(image.imageSlices().left().value(), CSSPrimitiveValue::CSS_NUMBER);
  471. }
  472. }
  473. }
  474. RefPtr<Quad> quad = Quad::create();
  475. quad->setTop(top);
  476. quad->setRight(right);
  477. quad->setBottom(bottom);
  478. quad->setLeft(left);
  479. return CSSBorderImageSliceValue::create(cssValuePool().createValue(quad.release()), image.fill());
  480. }
  481. static PassRefPtr<CSSPrimitiveValue> valueForNinePieceImageQuad(const LengthBox& box)
  482. {
  483. // Create the slices.
  484. RefPtr<CSSPrimitiveValue> top;
  485. RefPtr<CSSPrimitiveValue> right;
  486. RefPtr<CSSPrimitiveValue> bottom;
  487. RefPtr<CSSPrimitiveValue> left;
  488. if (box.top().isRelative())
  489. top = cssValuePool().createValue(box.top().value(), CSSPrimitiveValue::CSS_NUMBER);
  490. else
  491. top = cssValuePool().createValue(box.top());
  492. if (box.right() == box.top() && box.bottom() == box.top() && box.left() == box.top()) {
  493. right = top;
  494. bottom = top;
  495. left = top;
  496. } else {
  497. if (box.right().isRelative())
  498. right = cssValuePool().createValue(box.right().value(), CSSPrimitiveValue::CSS_NUMBER);
  499. else
  500. right = cssValuePool().createValue(box.right());
  501. if (box.bottom() == box.top() && box.right() == box.left()) {
  502. bottom = top;
  503. left = right;
  504. } else {
  505. if (box.bottom().isRelative())
  506. bottom = cssValuePool().createValue(box.bottom().value(), CSSPrimitiveValue::CSS_NUMBER);
  507. else
  508. bottom = cssValuePool().createValue(box.bottom());
  509. if (box.left() == box.right())
  510. left = right;
  511. else {
  512. if (box.left().isRelative())
  513. left = cssValuePool().createValue(box.left().value(), CSSPrimitiveValue::CSS_NUMBER);
  514. else
  515. left = cssValuePool().createValue(box.left());
  516. }
  517. }
  518. }
  519. RefPtr<Quad> quad = Quad::create();
  520. quad->setTop(top);
  521. quad->setRight(right);
  522. quad->setBottom(bottom);
  523. quad->setLeft(left);
  524. return cssValuePool().createValue(quad.release());
  525. }
  526. static PassRefPtr<CSSValue> valueForNinePieceImageRepeat(const NinePieceImage& image)
  527. {
  528. RefPtr<CSSPrimitiveValue> horizontalRepeat;
  529. RefPtr<CSSPrimitiveValue> verticalRepeat;
  530. horizontalRepeat = cssValuePool().createIdentifierValue(valueForRepeatRule(image.horizontalRule()));
  531. if (image.horizontalRule() == image.verticalRule())
  532. verticalRepeat = horizontalRepeat;
  533. else
  534. verticalRepeat = cssValuePool().createIdentifierValue(valueForRepeatRule(image.verticalRule()));
  535. return cssValuePool().createValue(Pair::create(horizontalRepeat.release(), verticalRepeat.release()));
  536. }
  537. static PassRefPtr<CSSValue> valueForNinePieceImage(const NinePieceImage& image)
  538. {
  539. if (!image.hasImage())
  540. return cssValuePool().createIdentifierValue(CSSValueNone);
  541. // Image first.
  542. RefPtr<CSSValue> imageValue;
  543. if (image.image())
  544. imageValue = image.image()->cssValue();
  545. // Create the image slice.
  546. RefPtr<CSSBorderImageSliceValue> imageSlices = valueForNinePieceImageSlice(image);
  547. // Create the border area slices.
  548. RefPtr<CSSValue> borderSlices = valueForNinePieceImageQuad(image.borderSlices());
  549. // Create the border outset.
  550. RefPtr<CSSValue> outset = valueForNinePieceImageQuad(image.outset());
  551. // Create the repeat rules.
  552. RefPtr<CSSValue> repeat = valueForNinePieceImageRepeat(image);
  553. return createBorderImageValue(imageValue.release(), imageSlices.release(), borderSlices.release(), outset.release(), repeat.release());
  554. }
  555. inline static PassRefPtr<CSSPrimitiveValue> zoomAdjustedPixelValue(double value, const RenderStyle* style)
  556. {
  557. return cssValuePool().createValue(adjustFloatForAbsoluteZoom(value, style), CSSPrimitiveValue::CSS_PX);
  558. }
  559. inline static PassRefPtr<CSSPrimitiveValue> zoomAdjustedNumberValue(double value, const RenderStyle* style)
  560. {
  561. return cssValuePool().createValue(value / style->effectiveZoom(), CSSPrimitiveValue::CSS_NUMBER);
  562. }
  563. static PassRefPtr<CSSValue> zoomAdjustedPixelValueForLength(const Length& length, const RenderStyle* style)
  564. {
  565. if (length.isFixed())
  566. return zoomAdjustedPixelValue(length.value(), style);
  567. return cssValuePool().createValue(length);
  568. }
  569. static PassRefPtr<CSSValue> valueForReflection(const StyleReflection* reflection, const RenderStyle* style)
  570. {
  571. if (!reflection)
  572. return cssValuePool().createIdentifierValue(CSSValueNone);
  573. RefPtr<CSSPrimitiveValue> offset;
  574. if (reflection->offset().isPercent())
  575. offset = cssValuePool().createValue(reflection->offset().percent(), CSSPrimitiveValue::CSS_PERCENTAGE);
  576. else
  577. offset = zoomAdjustedPixelValue(reflection->offset().value(), style);
  578. RefPtr<CSSPrimitiveValue> direction;
  579. switch (reflection->direction()) {
  580. case ReflectionBelow:
  581. direction = cssValuePool().createIdentifierValue(CSSValueBelow);
  582. break;
  583. case ReflectionAbove:
  584. direction = cssValuePool().createIdentifierValue(CSSValueAbove);
  585. break;
  586. case ReflectionLeft:
  587. direction = cssValuePool().createIdentifierValue(CSSValueLeft);
  588. break;
  589. case ReflectionRight:
  590. direction = cssValuePool().createIdentifierValue(CSSValueRight);
  591. break;
  592. }
  593. return CSSReflectValue::create(direction.release(), offset.release(), valueForNinePieceImage(reflection->mask()));
  594. }
  595. static PassRefPtr<CSSValueList> createPositionListForLayer(CSSPropertyID propertyID, const FillLayer* layer, const RenderStyle* style)
  596. {
  597. RefPtr<CSSValueList> positionList = CSSValueList::createSpaceSeparated();
  598. if (layer->isBackgroundOriginSet()) {
  599. ASSERT_UNUSED(propertyID, propertyID == CSSPropertyBackgroundPosition || propertyID == CSSPropertyWebkitMaskPosition);
  600. positionList->append(cssValuePool().createValue(layer->backgroundXOrigin()));
  601. }
  602. positionList->append(zoomAdjustedPixelValueForLength(layer->xPosition(), style));
  603. if (layer->isBackgroundOriginSet()) {
  604. ASSERT(propertyID == CSSPropertyBackgroundPosition || propertyID == CSSPropertyWebkitMaskPosition);
  605. positionList->append(cssValuePool().createValue(layer->backgroundYOrigin()));
  606. }
  607. positionList->append(zoomAdjustedPixelValueForLength(layer->yPosition(), style));
  608. return positionList.release();
  609. }
  610. static PassRefPtr<CSSValue> getPositionOffsetValue(RenderStyle* style, CSSPropertyID propertyID, RenderView* renderView)
  611. {
  612. if (!style)
  613. return 0;
  614. Length l;
  615. switch (propertyID) {
  616. case CSSPropertyLeft:
  617. l = style->left();
  618. break;
  619. case CSSPropertyRight:
  620. l = style->right();
  621. break;
  622. case CSSPropertyTop:
  623. l = style->top();
  624. break;
  625. case CSSPropertyBottom:
  626. l = style->bottom();
  627. break;
  628. default:
  629. return 0;
  630. }
  631. if (style->hasOutOfFlowPosition()) {
  632. if (l.type() == WebCore::Fixed)
  633. return zoomAdjustedPixelValue(l.value(), style);
  634. else if (l.isViewportPercentage())
  635. return zoomAdjustedPixelValue(valueForLength(l, 0, renderView), style);
  636. return cssValuePool().createValue(l);
  637. }
  638. if (style->hasInFlowPosition()) {
  639. // FIXME: It's not enough to simply return "auto" values for one offset if the other side is defined.
  640. // In other words if left is auto and right is not auto, then left's computed value is negative right().
  641. // So we should get the opposite length unit and see if it is auto.
  642. return cssValuePool().createValue(l);
  643. }
  644. return cssValuePool().createIdentifierValue(CSSValueAuto);
  645. }
  646. PassRefPtr<CSSPrimitiveValue> ComputedStyleExtractor::currentColorOrValidColor(RenderStyle* style, const Color& color) const
  647. {
  648. // This function does NOT look at visited information, so that computed style doesn't expose that.
  649. if (!color.isValid())
  650. return cssValuePool().createColorValue(style->color().rgb());
  651. return cssValuePool().createColorValue(color.rgb());
  652. }
  653. static PassRefPtr<CSSValueList> getBorderRadiusCornerValues(LengthSize radius, const RenderStyle* style, RenderView* renderView)
  654. {
  655. RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
  656. if (radius.width().type() == Percent)
  657. list->append(cssValuePool().createValue(radius.width().percent(), CSSPrimitiveValue::CSS_PERCENTAGE));
  658. else
  659. list->append(zoomAdjustedPixelValue(valueForLength(radius.width(), 0, renderView), style));
  660. if (radius.height().type() == Percent)
  661. list->append(cssValuePool().createValue(radius.height().percent(), CSSPrimitiveValue::CSS_PERCENTAGE));
  662. else
  663. list->append(zoomAdjustedPixelValue(valueForLength(radius.height(), 0, renderView), style));
  664. return list.release();
  665. }
  666. static PassRefPtr<CSSValue> getBorderRadiusCornerValue(LengthSize radius, const RenderStyle* style, RenderView* renderView)
  667. {
  668. if (radius.width() == radius.height()) {
  669. if (radius.width().type() == Percent)
  670. return cssValuePool().createValue(radius.width().percent(), CSSPrimitiveValue::CSS_PERCENTAGE);
  671. return zoomAdjustedPixelValue(valueForLength(radius.width(), 0, renderView), style);
  672. }
  673. return getBorderRadiusCornerValues(radius, style, renderView);
  674. }
  675. static PassRefPtr<CSSValueList> getBorderRadiusShorthandValue(const RenderStyle* style, RenderView* renderView)
  676. {
  677. RefPtr<CSSValueList> list = CSSValueList::createSlashSeparated();
  678. bool showHorizontalBottomLeft = style->borderTopRightRadius().width() != style->borderBottomLeftRadius().width();
  679. bool showHorizontalBottomRight = style->borderBottomRightRadius().width() != style->borderTopLeftRadius().width();
  680. bool showHorizontalTopRight = style->borderTopRightRadius().width() != style->borderTopLeftRadius().width();
  681. bool showVerticalBottomLeft = style->borderTopRightRadius().height() != style->borderBottomLeftRadius().height();
  682. bool showVerticalBottomRight = (style->borderBottomRightRadius().height() != style->borderTopLeftRadius().height()) || showVerticalBottomLeft;
  683. bool showVerticalTopRight = (style->borderTopRightRadius().height() != style->borderTopLeftRadius().height()) || showVerticalBottomRight;
  684. bool showVerticalTopLeft = (style->borderTopLeftRadius().width() != style->borderTopLeftRadius().height());
  685. RefPtr<CSSValueList> topLeftRadius = getBorderRadiusCornerValues(style->borderTopLeftRadius(), style, renderView);
  686. RefPtr<CSSValueList> topRightRadius = getBorderRadiusCornerValues(style->borderTopRightRadius(), style, renderView);
  687. RefPtr<CSSValueList> bottomRightRadius = getBorderRadiusCornerValues(style->borderBottomRightRadius(), style, renderView);
  688. RefPtr<CSSValueList> bottomLeftRadius = getBorderRadiusCornerValues(style->borderBottomLeftRadius(), style, renderView);
  689. RefPtr<CSSValueList> horizontalRadii = CSSValueList::createSpaceSeparated();
  690. horizontalRadii->append(topLeftRadius->item(0));
  691. if (showHorizontalTopRight)
  692. horizontalRadii->append(topRightRadius->item(0));
  693. if (showHorizontalBottomRight)
  694. horizontalRadii->append(bottomRightRadius->item(0));
  695. if (showHorizontalBottomLeft)
  696. horizontalRadii->append(bottomLeftRadius->item(0));
  697. list->append(horizontalRadii.release());
  698. if (showVerticalTopLeft) {
  699. RefPtr<CSSValueList> verticalRadii = CSSValueList::createSpaceSeparated();
  700. verticalRadii->append(topLeftRadius->item(1));
  701. if (showVerticalTopRight)
  702. verticalRadii->append(topRightRadius->item(1));
  703. if (showVerticalBottomRight)
  704. verticalRadii->append(bottomRightRadius->item(1));
  705. if (showVerticalBottomLeft)
  706. verticalRadii->append(bottomLeftRadius->item(1));
  707. list->append(verticalRadii.release());
  708. }
  709. return list.release();
  710. }
  711. static LayoutRect sizingBox(RenderObject* renderer)
  712. {
  713. if (!renderer->isBox())
  714. return LayoutRect();
  715. RenderBox* box = toRenderBox(renderer);
  716. return box->style()->boxSizing() == BORDER_BOX ? box->borderBoxRect() : box->computedCSSContentBoxRect();
  717. }
  718. static PassRefPtr<WebKitCSSTransformValue> matrixTransformValue(const TransformationMatrix& transform, const RenderStyle* style)
  719. {
  720. RefPtr<WebKitCSSTransformValue> transformValue;
  721. if (transform.isAffine()) {
  722. transformValue = WebKitCSSTransformValue::create(WebKitCSSTransformValue::MatrixTransformOperation);
  723. transformValue->append(cssValuePool().createValue(transform.a(), CSSPrimitiveValue::CSS_NUMBER));
  724. transformValue->append(cssValuePool().createValue(transform.b(), CSSPrimitiveValue::CSS_NUMBER));
  725. transformValue->append(cssValuePool().createValue(transform.c(), CSSPrimitiveValue::CSS_NUMBER));
  726. transformValue->append(cssValuePool().createValue(transform.d(), CSSPrimitiveValue::CSS_NUMBER));
  727. transformValue->append(zoomAdjustedNumberValue(transform.e(), style));
  728. transformValue->append(zoomAdjustedNumberValue(transform.f(), style));
  729. } else {
  730. transformValue = WebKitCSSTransformValue::create(WebKitCSSTransformValue::Matrix3DTransformOperation);
  731. transformValue->append(cssValuePool().createValue(transform.m11(), CSSPrimitiveValue::CSS_NUMBER));
  732. transformValue->append(cssValuePool().createValue(transform.m12(), CSSPrimitiveValue::CSS_NUMBER));
  733. transformValue->append(cssValuePool().createValue(transform.m13(), CSSPrimitiveValue::CSS_NUMBER));
  734. transformValue->append(cssValuePool().createValue(transform.m14(), CSSPrimitiveValue::CSS_NUMBER));
  735. transformValue->append(cssValuePool().createValue(transform.m21(), CSSPrimitiveValue::CSS_NUMBER));
  736. transformValue->append(cssValuePool().createValue(transform.m22(), CSSPrimitiveValue::CSS_NUMBER));
  737. transformValue->append(cssValuePool().createValue(transform.m23(), CSSPrimitiveValue::CSS_NUMBER));
  738. transformValue->append(cssValuePool().createValue(transform.m24(), CSSPrimitiveValue::CSS_NUMBER));
  739. transformValue->append(cssValuePool().createValue(transform.m31(), CSSPrimitiveValue::CSS_NUMBER));
  740. transformValue->append(cssValuePool().createValue(transform.m32(), CSSPrimitiveValue::CSS_NUMBER));
  741. transformValue->append(cssValuePool().createValue(transform.m33(), CSSPrimitiveValue::CSS_NUMBER));
  742. transformValue->append(cssValuePool().createValue(transform.m34(), CSSPrimitiveValue::CSS_NUMBER));
  743. transformValue->append(zoomAdjustedNumberValue(transform.m41(), style));
  744. transformValue->append(zoomAdjustedNumberValue(transform.m42(), style));
  745. transformValue->append(zoomAdjustedNumberValue(transform.m43(), style));
  746. transformValue->append(cssValuePool().createValue(transform.m44(), CSSPrimitiveValue::CSS_NUMBER));
  747. }
  748. return transformValue.release();
  749. }
  750. static PassRefPtr<CSSValue> computedTransform(RenderObject* renderer, const RenderStyle* style)
  751. {
  752. if (!renderer || !renderer->hasTransform() || !style->hasTransform())
  753. return cssValuePool().createIdentifierValue(CSSValueNone);
  754. IntRect box;
  755. if (renderer->isBox())
  756. box = pixelSnappedIntRect(toRenderBox(renderer)->borderBoxRect());
  757. TransformationMatrix transform;
  758. style->applyTransform(transform, box.size(), RenderStyle::ExcludeTransformOrigin);
  759. // Note that this does not flatten to an affine transform if ENABLE(3D_RENDERING) is off, by design.
  760. // FIXME: Need to print out individual functions (https://bugs.webkit.org/show_bug.cgi?id=23924)
  761. RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
  762. list->append(matrixTransformValue(transform, style));
  763. return list.release();
  764. }
  765. #if ENABLE(CSS_SHADERS)
  766. static PassRefPtr<CSSValue> valueForCustomFilterArrayParameter(const CustomFilterArrayParameter* arrayParameter)
  767. {
  768. RefPtr<WebKitCSSArrayFunctionValue> arrayParameterValue = WebKitCSSArrayFunctionValue::create();
  769. for (unsigned i = 0, size = arrayParameter->size(); i < size; ++i)
  770. arrayParameterValue->append(cssValuePool().createValue(arrayParameter->valueAt(i), CSSPrimitiveValue::CSS_NUMBER));
  771. return arrayParameterValue.release();
  772. }
  773. static PassRefPtr<CSSValue> valueForCustomFilterMatParameter(const CustomFilterArrayParameter* matrixParameter)
  774. {
  775. RefPtr<WebKitCSSMatFunctionValue> matrixParameterValue = WebKitCSSMatFunctionValue::create();
  776. for (unsigned i = 0, size = matrixParameter->size(); i < size; ++i)
  777. matrixParameterValue->append(cssValuePool().createValue(matrixParameter->valueAt(i), CSSPrimitiveValue::CSS_NUMBER));
  778. return matrixParameterValue.release();
  779. }
  780. static PassRefPtr<CSSValue> valueForCustomFilterColorParameter(const CustomFilterColorParameter* colorParameter)
  781. {
  782. RefPtr<CSSValueList> colorParameterValue = CSSValueList::createSpaceSeparated();
  783. colorParameterValue->append(cssValuePool().createColorValue(colorParameter->color().rgb()));
  784. return colorParameterValue.release();
  785. }
  786. static PassRefPtr<CSSValue> valueForCustomFilterNumberParameter(const CustomFilterNumberParameter* numberParameter)
  787. {
  788. RefPtr<CSSValueList> numberParameterValue = CSSValueList::createSpaceSeparated();
  789. for (unsigned i = 0; i < numberParameter->size(); ++i)
  790. numberParameterValue->append(cssValuePool().createValue(numberParameter->valueAt(i), CSSPrimitiveValue::CSS_NUMBER));
  791. return numberParameterValue.release();
  792. }
  793. static PassRefPtr<CSSValue> valueForCustomFilterTransformParameter(const RenderObject* renderer, const RenderStyle* style, const CustomFilterTransformParameter* transformParameter)
  794. {
  795. IntSize size;
  796. if (renderer && renderer->isBox())
  797. size = pixelSnappedIntRect(toRenderBox(renderer)->borderBoxRect()).size();
  798. TransformationMatrix transform;
  799. transformParameter->applyTransform(transform, size);
  800. // FIXME: Need to print out individual functions (https://bugs.webkit.org/show_bug.cgi?id=23924)
  801. return matrixTransformValue(transform, style);
  802. }
  803. static PassRefPtr<CSSValue> valueForCustomFilterParameter(const RenderObject* renderer, const RenderStyle* style, const CustomFilterParameter* parameter)
  804. {
  805. // FIXME: Add here computed style for the other types: boolean, transform, matrix, texture.
  806. ASSERT(parameter);
  807. switch (parameter->parameterType()) {
  808. case CustomFilterParameter::ARRAY:
  809. return valueForCustomFilterArrayParameter(static_cast<const CustomFilterArrayParameter*>(parameter));
  810. case CustomFilterParameter::COLOR:
  811. return valueForCustomFilterColorParameter(static_cast<const CustomFilterColorParameter*>(parameter));
  812. case CustomFilterParameter::MATRIX:
  813. return valueForCustomFilterMatParameter(static_cast<const CustomFilterArrayParameter*>(parameter));
  814. case CustomFilterParameter::NUMBER:
  815. return valueForCustomFilterNumberParameter(static_cast<const CustomFilterNumberParameter*>(parameter));
  816. case CustomFilterParameter::TRANSFORM:
  817. return valueForCustomFilterTransformParameter(renderer, style, static_cast<const CustomFilterTransformParameter*>(parameter));
  818. }
  819. ASSERT_NOT_REACHED();
  820. return 0;
  821. }
  822. #endif // ENABLE(CSS_SHADERS)
  823. #if ENABLE(CSS_FILTERS)
  824. PassRefPtr<CSSValue> ComputedStyleExtractor::valueForFilter(const RenderObject* renderer, const RenderStyle* style) const
  825. {
  826. #if !ENABLE(CSS_SHADERS)
  827. UNUSED_PARAM(renderer);
  828. #endif
  829. if (style->filter().operations().isEmpty())
  830. return cssValuePool().createIdentifierValue(CSSValueNone);
  831. RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
  832. RefPtr<WebKitCSSFilterValue> filterValue;
  833. Vector<RefPtr<FilterOperation> >::const_iterator end = style->filter().operations().end();
  834. for (Vector<RefPtr<FilterOperation> >::const_iterator it = style->filter().operations().begin(); it != end; ++it) {
  835. FilterOperation* filterOperation = (*it).get();
  836. switch (filterOperation->getOperationType()) {
  837. case FilterOperation::REFERENCE: {
  838. ReferenceFilterOperation* referenceOperation = static_cast<ReferenceFilterOperation*>(filterOperation);
  839. filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::ReferenceFilterOperation);
  840. filterValue->append(cssValuePool().createValue(referenceOperation->url(), CSSPrimitiveValue::CSS_STRING));
  841. break;
  842. }
  843. case FilterOperation::GRAYSCALE: {
  844. BasicColorMatrixFilterOperation* colorMatrixOperation = static_cast<BasicColorMatrixFilterOperation*>(filterOperation);
  845. filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::GrayscaleFilterOperation);
  846. filterValue->append(cssValuePool().createValue(colorMatrixOperation->amount(), CSSPrimitiveValue::CSS_NUMBER));
  847. break;
  848. }
  849. case FilterOperation::SEPIA: {
  850. BasicColorMatrixFilterOperation* colorMatrixOperation = static_cast<BasicColorMatrixFilterOperation*>(filterOperation);
  851. filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::SepiaFilterOperation);
  852. filterValue->append(cssValuePool().createValue(colorMatrixOperation->amount(), CSSPrimitiveValue::CSS_NUMBER));
  853. break;
  854. }
  855. case FilterOperation::SATURATE: {
  856. BasicColorMatrixFilterOperation* colorMatrixOperation = static_cast<BasicColorMatrixFilterOperation*>(filterOperation);
  857. filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::SaturateFilterOperation);
  858. filterValue->append(cssValuePool().createValue(colorMatrixOperation->amount(), CSSPrimitiveValue::CSS_NUMBER));
  859. break;
  860. }
  861. case FilterOperation::HUE_ROTATE: {
  862. BasicColorMatrixFilterOperation* colorMatrixOperation = static_cast<BasicColorMatrixFilterOperation*>(filterOperation);
  863. filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::HueRotateFilterOperation);
  864. filterValue->append(cssValuePool().createValue(colorMatrixOperation->amount(), CSSPrimitiveValue::CSS_DEG));
  865. break;
  866. }
  867. case FilterOperation::INVERT: {
  868. BasicComponentTransferFilterOperation* componentTransferOperation = static_cast<BasicComponentTransferFilterOperation*>(filterOperation);
  869. filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::InvertFilterOperation);
  870. filterValue->append(cssValuePool().createValue(componentTransferOperation->amount(), CSSPrimitiveValue::CSS_NUMBER));
  871. break;
  872. }
  873. case FilterOperation::OPACITY: {
  874. BasicComponentTransferFilterOperation* componentTransferOperation = static_cast<BasicComponentTransferFilterOperation*>(filterOperation);
  875. filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::OpacityFilterOperation);
  876. filterValue->append(cssValuePool().createValue(componentTransferOperation->amount(), CSSPrimitiveValue::CSS_NUMBER));
  877. break;
  878. }
  879. case FilterOperation::BRIGHTNESS: {
  880. BasicComponentTransferFilterOperation* brightnessOperation = static_cast<BasicComponentTransferFilterOperation*>(filterOperation);
  881. filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::BrightnessFilterOperation);
  882. filterValue->append(cssValuePool().createValue(brightnessOperation->amount(), CSSPrimitiveValue::CSS_NUMBER));
  883. break;
  884. }
  885. case FilterOperation::CONTRAST: {
  886. BasicComponentTransferFilterOperation* contrastOperation = static_cast<BasicComponentTransferFilterOperation*>(filterOperation);
  887. filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::ContrastFilterOperation);
  888. filterValue->append(cssValuePool().createValue(contrastOperation->amount(), CSSPrimitiveValue::CSS_NUMBER));
  889. break;
  890. }
  891. case FilterOperation::BLUR: {
  892. BlurFilterOperation* blurOperation = static_cast<BlurFilterOperation*>(filterOperation);
  893. filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::BlurFilterOperation);
  894. filterValue->append(zoomAdjustedPixelValue(blurOperation->stdDeviation().value(), style));
  895. break;
  896. }
  897. case FilterOperation::DROP_SHADOW: {
  898. DropShadowFilterOperation* dropShadowOperation = static_cast<DropShadowFilterOperation*>(filterOperation);
  899. filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::DropShadowFilterOperation);
  900. // We want our computed style to look like that of a text shadow (has neither spread nor inset style).
  901. ShadowData shadowData = ShadowData(dropShadowOperation->location(), dropShadowOperation->stdDeviation(), 0, Normal, false, dropShadowOperation->color());
  902. filterValue->append(valueForShadow(&shadowData, CSSPropertyTextShadow, style));
  903. break;
  904. }
  905. #if ENABLE(CSS_SHADERS)
  906. case FilterOperation::VALIDATED_CUSTOM:
  907. // ValidatedCustomFilterOperation is not supposed to end up in the RenderStyle.
  908. ASSERT_NOT_REACHED();
  909. break;
  910. case FilterOperation::CUSTOM: {
  911. CustomFilterOperation* customOperation = static_cast<CustomFilterOperation*>(filterOperation);
  912. filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::CustomFilterOperation);
  913. // The output should be verbose, even if the values are the default ones.
  914. ASSERT(customOperation->program());
  915. StyleCustomFilterProgram* program = static_cast<StyleCustomFilterProgram*>(customOperation->program());
  916. RefPtr<CSSValueList> shadersList = CSSValueList::createSpaceSeparated();
  917. if (program->vertexShader())
  918. shadersList->append(program->vertexShader()->cssValue());
  919. else
  920. shadersList->append(cssValuePool().createIdentifierValue(CSSValueNone));
  921. const CustomFilterProgramMixSettings mixSettings = program->mixSettings();
  922. if (program->fragmentShader()) {
  923. if (program->programType() == PROGRAM_TYPE_BLENDS_ELEMENT_TEXTURE) {
  924. RefPtr<WebKitCSSMixFunctionValue> mixFunction = WebKitCSSMixFunctionValue::create();
  925. mixFunction->append(program->fragmentShader()->cssValue());
  926. mixFunction->append(cssValuePool().createValue(mixSettings.blendMode));
  927. mixFunction->append(cssValuePool().createValue(mixSettings.compositeOperator));
  928. shadersList->append(mixFunction.release());
  929. } else
  930. shadersList->append(program->fragmentShader()->cssValue());
  931. }
  932. else
  933. shadersList->append(cssValuePool().createIdentifierValue(CSSValueNone));
  934. filterValue->append(shadersList.release());
  935. RefPtr<CSSValueList> meshParameters = CSSValueList::createSpaceSeparated();
  936. meshParameters->append(cssValuePool().createValue(customOperation->meshColumns(), CSSPrimitiveValue::CSS_NUMBER));
  937. meshParameters->append(cssValuePool().createValue(customOperation->meshRows(), CSSPrimitiveValue::CSS_NUMBER));
  938. // FIXME: The specification doesn't have any "attached" identifier. Should we add one?
  939. // https://bugs.webkit.org/show_bug.cgi?id=72700
  940. if (customOperation->meshType() == MeshTypeDetached)
  941. meshParameters->append(cssValuePool().createIdentifierValue(CSSValueDetached));
  942. filterValue->append(meshParameters.release());
  943. const CustomFilterParameterList& parameters = customOperation->parameters();
  944. size_t parametersSize = parameters.size();
  945. if (!parametersSize)
  946. break;
  947. RefPtr<CSSValueList> parametersCSSValue = CSSValueList::createCommaSeparated();
  948. for (size_t i = 0; i < parametersSize; ++i) {
  949. const CustomFilterParameter* parameter = parameters.at(i).get();
  950. RefPtr<CSSValueList> parameterCSSNameAndValue = CSSValueList::createSpaceSeparated();
  951. parameterCSSNameAndValue->append(cssValuePool().createValue(parameter->name(), CSSPrimitiveValue::CSS_STRING));
  952. parameterCSSNameAndValue->append(valueForCustomFilterParameter(renderer, style, parameter));
  953. parametersCSSValue->append(parameterCSSNameAndValue.release());
  954. }
  955. filterValue->append(parametersCSSValue.release());
  956. break;
  957. }
  958. #endif
  959. default:
  960. filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::UnknownFilterOperation);
  961. break;
  962. }
  963. list->append(filterValue.release());
  964. }
  965. return list.release();
  966. }
  967. #endif
  968. static PassRefPtr<CSSValue> valueForGridTrackBreadth(const Length& trackBreadth, const RenderStyle* style, RenderView *renderView)
  969. {
  970. if (trackBreadth.isAuto())
  971. return cssValuePool().createIdentifierValue(CSSValueAuto);
  972. if (trackBreadth.isViewportPercentage())
  973. return zoomAdjustedPixelValue(valueForLength(trackBreadth, 0, renderView), style);
  974. return zoomAdjustedPixelValueForLength(trackBreadth, style);
  975. }
  976. static PassRefPtr<CSSValue> valueForGridTrackSize(const GridTrackSize& trackSize, const RenderStyle* style, RenderView* renderView)
  977. {
  978. switch (trackSize.type()) {
  979. case LengthTrackSizing:
  980. return valueForGridTrackBreadth(trackSize.length(), style, renderView);
  981. case MinMaxTrackSizing:
  982. RefPtr<CSSValueList> minMaxTrackBreadths = CSSValueList::createCommaSeparated();
  983. minMaxTrackBreadths->append(valueForGridTrackBreadth(trackSize.minTrackBreadth(), style, renderView));
  984. minMaxTrackBreadths->append(valueForGridTrackBreadth(trackSize.maxTrackBreadth(), style, renderView));
  985. return CSSFunctionValue::create("minmax(", minMaxTrackBreadths);
  986. }
  987. ASSERT_NOT_REACHED();
  988. return 0;
  989. }
  990. static PassRefPtr<CSSValue> valueForGridTrackList(const Vector<GridTrackSize>& trackSizes, const RenderStyle* style, RenderView *renderView)
  991. {
  992. // Handle the 'none' case here.
  993. if (!trackSizes.size())
  994. return cssValuePool().createIdentifierValue(CSSValueNone);
  995. RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
  996. for (size_t i = 0; i < trackSizes.size(); ++i)
  997. list->append(valueForGridTrackSize(trackSizes[i], style, renderView));
  998. return list.release();
  999. }
  1000. static PassRefPtr<CSSValue> valueForGridPosition(const GridPosition& position)
  1001. {
  1002. if (position.isAuto())
  1003. return cssValuePool().createIdentifierValue(CSSValueAuto);
  1004. return cssValuePool().createValue(position.integerPosition(), CSSPrimitiveValue::CSS_NUMBER);
  1005. }
  1006. static PassRefPtr<CSSValue> createTransitionPropertyValue(const Animation* animation)
  1007. {
  1008. RefPtr<CSSValue> propertyValue;
  1009. if (animation->animationMode() == Animation::AnimateNone)
  1010. propertyValue = cssValuePool().createIdentifierValue(CSSValueNone);
  1011. else if (animation->animationMode() == Animation::AnimateAll)
  1012. propertyValue = cssValuePool().createIdentifierValue(CSSValueAll);
  1013. else
  1014. propertyValue = cssValuePool().createValue(getPropertyNameString(animation->property()), CSSPrimitiveValue::CSS_STRING);
  1015. return propertyValue.release();
  1016. }
  1017. static PassRefPtr<CSSValue> getTransitionPropertyValue(const AnimationList* animList)
  1018. {
  1019. RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
  1020. if (animList) {
  1021. for (size_t i = 0; i < animList->size(); ++i)
  1022. list->append(createTransitionPropertyValue(animList->animation(i)));
  1023. } else
  1024. list->append(cssValuePool().createIdentifierValue(CSSValueAll));
  1025. return list.release();
  1026. }
  1027. static PassRefPtr<CSSValue> getDelayValue(const AnimationList* animList)
  1028. {
  1029. RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
  1030. if (animList) {
  1031. for (size_t i = 0; i < animList->size(); ++i)
  1032. list->append(cssValuePool().createValue(animList->animation(i)->delay(), CSSPrimitiveValue::CSS_S));
  1033. } else {
  1034. // Note that initialAnimationDelay() is used for both transitions and animations
  1035. list->append(cssValuePool().createValue(Animation::initialAnimationDelay(), CSSPrimitiveValue::CSS_S));
  1036. }
  1037. return list.release();
  1038. }
  1039. static PassRefPtr<CSSValue> getDurationValue(const AnimationList* animList)
  1040. {
  1041. RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
  1042. if (animList) {
  1043. for (size_t i = 0; i < animList->size(); ++i)
  1044. list->append(cssValuePool().createValue(animList->animation(i)->duration(), CSSPrimitiveValue::CSS_S));
  1045. } else {
  1046. // Note that initialAnimationDuration() is used for both transitions and animations
  1047. list->append(cssValuePool().createValue(Animation::initialAnimationDuration(), CSSPrimitiveValue::CSS_S));
  1048. }
  1049. return list.release();
  1050. }
  1051. static PassRefPtr<CSSValue> createTimingFunctionValue(const TimingFunction* timingFunction)
  1052. {
  1053. if (timingFunction->isCubicBezierTimingFunction()) {
  1054. const CubicBezierTimingFunction* bezierTimingFunction = static_cast<const CubicBezierTimingFunction*>(timingFunction);
  1055. if (bezierTimingFunction->timingFunctionPreset() != CubicBezierTimingFunction::Custom) {
  1056. CSSValueID valueId = CSSValueInvalid;
  1057. switch (bezierTimingFunction->timingFunctionPreset()) {
  1058. case CubicBezierTimingFunction::Ease:
  1059. valueId = CSSValueEase;
  1060. break;
  1061. case CubicBezierTimingFunction::EaseIn:
  1062. valueId = CSSValueEaseIn;
  1063. break;
  1064. case CubicBezierTimingFunction::EaseOut:
  1065. valueId = CSSValueEaseOut;
  1066. break;
  1067. case CubicBezierTimingFunction::EaseInOut:
  1068. valueId = CSSValueEaseInOut;
  1069. break;
  1070. default:
  1071. ASSERT_NOT_REACHED();
  1072. return 0;
  1073. }
  1074. return cssValuePool().createIdentifierValue(valueId);
  1075. }
  1076. return CSSCubicBezierTimingFunctionValue::create(bezierTimingFunction->x1(), bezierTimingFunction->y1(), bezierTimingFunction->x2(), bezierTimingFunction->y2());
  1077. }
  1078. if (timingFunction->isStepsTimingFunction()) {
  1079. const StepsTimingFunction* stepsTimingFunction = static_cast<const StepsTimingFunction*>(timingFunction);
  1080. return CSSStepsTimingFunctionValue::create(stepsTimingFunction->numberOfSteps(), stepsTimingFunction->stepAtStart());
  1081. }
  1082. return CSSLinearTimingFunctionValue::create();
  1083. }
  1084. static PassRefPtr<CSSValue> getTimingFunctionValue(const AnimationList* animList)
  1085. {
  1086. RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
  1087. if (animList) {
  1088. for (size_t i = 0; i < animList->size(); ++i)
  1089. list->append(createTimingFunctionValue(animList->animation(i)->timingFunction().get()));
  1090. } else
  1091. // Note that initialAnimationTimingFunction() is used for both transitions and animations
  1092. list->append(createTimingFunctionValue(Animation::initialAnimationTimingFunction().get()));
  1093. return list.release();
  1094. }
  1095. static PassRefPtr<CSSValue> createLineBoxContainValue(unsigned lineBoxContain)
  1096. {
  1097. if (!lineBoxContain)
  1098. return cssValuePool().createIdentifierValue(CSSValueNone);
  1099. return CSSLineBoxContainValue::create(lineBoxContain);
  1100. }
  1101. ComputedStyleExtractor::ComputedStyleExtractor(PassRefPtr<Node> node, bool allowVisitedStyle, PseudoId pseudoElementSpecifier)
  1102. : m_node(node)
  1103. , m_pseudoElementSpecifier(pseudoElementSpecifier)
  1104. , m_allowVisitedStyle(allowVisitedStyle)
  1105. {
  1106. }
  1107. CSSComputedStyleDeclaration::CSSComputedStyleDeclaration(PassRefPtr<Node> n, bool allowVisitedStyle, const String& pseudoElementName)
  1108. : m_node(n)
  1109. , m_allowVisitedStyle(allowVisitedStyle)
  1110. , m_refCount(1)
  1111. {
  1112. unsigned nameWithoutColonsStart = pseudoElementName[0] == ':' ? (pseudoElementName[1] == ':' ? 2 : 1) : 0;
  1113. m_pseudoElementSpecifier = CSSSelector::pseudoId(CSSSelector::parsePseudoType(
  1114. AtomicString(pseudoElementName.substring(nameWithoutColonsStart))));
  1115. }
  1116. CSSComputedStyleDeclaration::~CSSComputedStyleDeclaration()
  1117. {
  1118. }
  1119. void CSSComputedStyleDeclaration::ref()
  1120. {
  1121. ++m_refCount;
  1122. }
  1123. void CSSComputedStyleDeclaration::deref()
  1124. {
  1125. ASSERT(m_refCount);
  1126. if (!--m_refCount)
  1127. delete this;
  1128. }
  1129. String CSSComputedStyleDeclaration::cssText() const
  1130. {
  1131. StringBuilder result;
  1132. for (unsigned i = 0; i < numComputedProperties; i++) {
  1133. if (i)
  1134. result.append(' ');
  1135. result.append(getPropertyName(computedProperties[i]));
  1136. result.append(": ", 2);
  1137. result.append(getPropertyValue(computedProperties[i]));
  1138. result.append(';');
  1139. }
  1140. return result.toString();
  1141. }
  1142. void CSSComputedStyleDeclaration::setCssText(const String&, ExceptionCode& ec)
  1143. {
  1144. ec = NO_MODIFICATION_ALLOWED_ERR;
  1145. }
  1146. static int cssIdentifierForFontSizeKeyword(int keywordSize)
  1147. {
  1148. ASSERT_ARG(keywordSize, keywordSize);
  1149. ASSERT_ARG(keywordSize, keywordSize <= 8);
  1150. return CSSValueXxSmall + keywordSize - 1;
  1151. }
  1152. PassRefPtr<CSSPrimitiveValue> ComputedStyleExtractor::getFontSizeCSSValuePreferringKeyword() const
  1153. {
  1154. if (!m_node)
  1155. return 0;
  1156. m_node->document()->updateLayoutIgnorePendingStylesheets();
  1157. RefPtr<RenderStyle> style = m_node->computedStyle(m_pseudoElementSpecifier);
  1158. if (!style)
  1159. return 0;
  1160. if (int keywordSize = style->fontDescription().keywordSize())
  1161. return cssValuePool().createIdentifierValue(cssIdentifierForFontSizeKeyword(keywordSize));
  1162. return zoomAdjustedPixelValue(style->fontDescription().computedPixelSize(), style.get());
  1163. }
  1164. bool ComputedStyleExtractor::useFixedFontDefaultSize() const
  1165. {
  1166. if (!m_node)
  1167. return false;
  1168. RefPtr<RenderStyle> style = m_node->computedStyle(m_pseudoElementSpecifier);
  1169. if (!style)
  1170. return false;
  1171. return style->fontDescription().useFixedDefaultSize();
  1172. }
  1173. PassRefPtr<CSSValue> ComputedStyleExtractor::valueForShadow(const ShadowData* shadow, CSSPropertyID propertyID, const RenderStyle* style) const
  1174. {
  1175. if (!shadow)
  1176. return cssValuePool().createIdentifierValue(CSSValueNone);
  1177. RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
  1178. for (const ShadowData* s = shadow; s; s = s->next()) {
  1179. RefPtr<CSSPrimitiveValue> x = zoomAdjustedPixelValue(s->x(), style);
  1180. RefPtr<CSSPrimitiveValue> y = zoomAdjustedPixelValue(s->y(), style);
  1181. RefPtr<CSSPrimitiveValue> blur = zoomAdjustedPixelValue(s->radius(), style);
  1182. RefPtr<CSSPrimitiveValue> spread = propertyID == CSSPropertyTextShadow ? PassRefPtr<CSSPrimitiveValue>() : zoomAdjustedPixelValue(s->spread(), style);
  1183. RefPtr<CSSPrimitiveValue> style = propertyID == CSSPropertyTextShadow || s->style() == Normal ? PassRefPtr<CSSPrimitiveValue>() : cssValuePool().createIdentifierValue(CSSValueInset);
  1184. RefPtr<CSSPrimitiveValue> color = cssValuePool().createColorValue(s->color().rgb());
  1185. list->prepend(ShadowValue::create(x.release(), y.release(), blur.release(), spread.release(), style.release(), color.release()));
  1186. }
  1187. return list.release();
  1188. }
  1189. static int identifierForFamily(const AtomicString& family)
  1190. {
  1191. if (family == cursiveFamily)
  1192. return CSSValueCursive;
  1193. if (family == fantasyFamily)
  1194. return CSSValueFantasy;
  1195. if (family == monospaceFamily)
  1196. return CSSValueMonospace;
  1197. if (family == pictographFamily)
  1198. return CSSValueWebkitPictograph;
  1199. if (family == sansSerifFamily)
  1200. return CSSValueSansSerif;
  1201. if (family == serifFamily)
  1202. return CSSValueSerif;
  1203. return 0;
  1204. }
  1205. static PassRefPtr<CSSPrimitiveValue> valueForFamily(const AtomicString& family)
  1206. {
  1207. if (int familyIdentifier = identifierForFamily(family))
  1208. return cssValuePool().createIdentifierValue(familyIdentifier);
  1209. return cssValuePool().createValue(family.string(), CSSPrimitiveValue::CSS_STRING);
  1210. }
  1211. static PassRefPtr<CSSValue> renderTextDecorationFlagsToCSSValue(int textDecoration)
  1212. {
  1213. // Blink value is ignored.
  1214. RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
  1215. if (textDecoration & TextDecorationUnderline)
  1216. list->append(cssValuePool().createIdentifierValue(CSSValueUnderline));
  1217. if (textDecoration & TextDecorationOverline)
  1218. list->append(cssValuePool().createIdentifierValue(CSSValueOverline));
  1219. if (textDecoration & TextDecorationLineThrough)
  1220. list->append(cssValuePool().createIdentifierValue(CSSValueLineThrough));
  1221. if (!list->length())
  1222. return cssValuePool().createIdentifierValue(CSSValueNone);
  1223. return list;
  1224. }
  1225. #if ENABLE(CSS3_TEXT)
  1226. static PassRefPtr<CSSValue> renderTextDecorationStyleFlagsToCSSValue(TextDecorationStyle textDecorationStyle)
  1227. {
  1228. switch (textDecorationStyle) {
  1229. case TextDecorationStyleSolid:
  1230. return cssValuePool().createIdentifierValue(CSSValueSolid);
  1231. case TextDecorationStyleDouble:
  1232. return cssValuePool().createIdentifierValue(CSSValueDouble);
  1233. case TextDecorationStyleDotted:
  1234. return cssValuePool().createIdentifierValue(CSSValueDotted);
  1235. case TextDecorationStyleDashed:
  1236. return cssValuePool().createIdentifierValue(CSSValueDashed);
  1237. case TextDecorationStyleWavy:
  1238. return cssValuePool().createIdentifierValue(CSSValueWavy);
  1239. }
  1240. ASSERT_NOT_REACHED();
  1241. return cssValuePool().createExplicitInitialValue();
  1242. }
  1243. #endif // CSS3_TEXT
  1244. static PassRefPtr<CSSValue> fillRepeatToCSSValue(EFillRepeat xRepeat, EFillRepeat yRepeat)
  1245. {
  1246. // For backwards compatibility, if both values are equal, just return one of them. And
  1247. // if the two values are equivalent to repeat-x or repeat-y, just return the shorthand.
  1248. if (xRepeat == yRepeat)
  1249. return cssValuePool().createValue(xRepeat);
  1250. if (xRepeat == RepeatFill && yRepeat == NoRepeatFill)
  1251. return cssValuePool().createIdentifierValue(CSSValueRepeatX);
  1252. if (xRepeat == NoRepeatFill && yRepeat == RepeatFill)
  1253. return cssValuePool().createIdentifierValue(CSSValueRepeatY);
  1254. RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
  1255. list->append(cssValuePool().createValue(xRepeat));
  1256. list->append(cssValuePool().createValue(yRepeat));
  1257. return list.release();
  1258. }
  1259. static PassRefPtr<CSSValue> fillSizeToCSSValue(const FillSize& fillSize, const RenderStyle* style)
  1260. {
  1261. if (fillSize.type == Contain)
  1262. return cssValuePool().createIdentifierValue(CSSValueContain);
  1263. if (fillSize.type == Cover)
  1264. return cssValuePool().createIdentifierValue(CSSValueCover);
  1265. if (fillSize.size.height().isAuto())
  1266. return zoomAdjustedPixelValueForLength(fillSize.size.width(), style);
  1267. RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
  1268. list->append(zoomAdjustedPixelValueForLength(fillSize.size.width(), style));
  1269. list->append(zoomAdjustedPixelValueForLength(fillSize.size.height(), style));
  1270. return list.release();
  1271. }
  1272. static PassRefPtr<CSSValue> contentToCSSValue(const RenderStyle* style)
  1273. {
  1274. RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
  1275. for (const ContentData* contentData = style->contentData(); contentData; contentData = contentData->next()) {
  1276. if (contentData->isCounter()) {
  1277. const CounterContent* counter = static_cast<const CounterContentData*>(contentData)->counter();
  1278. ASSERT(counter);
  1279. list->append(cssValuePool().createValue(counter->identifier(), CSSPrimitiveValue::CSS_COUNTER_NAME));
  1280. } else if (contentData->isImage()) {
  1281. const StyleImage* image = static_cast<const ImageContentData*>(contentData)->image();
  1282. ASSERT(image);
  1283. list->append(image->cssValue());
  1284. } else if (contentData->isText())
  1285. list->append(cssValuePool().createValue(static_cast<const TextContentData*>(contentData)->text(), CSSPrimitiveValue::CSS_STRING));
  1286. }
  1287. if (!style->regionThread().isNull())
  1288. list->append(cssValuePool().createValue(style->regionThread(), CSSPrimitiveValue::CSS_STRING));
  1289. return list.release();
  1290. }
  1291. static PassRefPtr<CSSValue> counterToCSSValue(const RenderStyle* style, CSSPropertyID propertyID)
  1292. {
  1293. const CounterDirectiveMap* map = style->counterDirectives();
  1294. if (!map)
  1295. return 0;
  1296. RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
  1297. for (CounterDirectiveMap::const_iterator it = map->begin(); it != map->end(); ++it) {
  1298. list->append(cssValuePool().createValue(it->key, CSSPrimitiveValue::CSS_STRING));
  1299. short number = propertyID == CSSPropertyCounterIncrement ? it->value.incrementValue() : it->value.resetValue();
  1300. list->append(cssValuePool().createValue((double)number, CSSPrimitiveValue::CSS_NUMBER));
  1301. }
  1302. return list.release();
  1303. }
  1304. static void logUnimplementedPropertyID(CSSPropertyID propertyID)
  1305. {
  1306. DEFINE_STATIC_LOCAL(HashSet<CSSPropertyID>, propertyIDSet, ());
  1307. if (!propertyIDSet.add(propertyID).isNewEntry)
  1308. return;
  1309. LOG_ERROR("WebKit does not yet implement getComputedStyle for '%s'.", getPropertyName(propertyID));
  1310. }
  1311. static PassRefPtr<CSSValueList> fontFamilyFromStyle(RenderStyle* style)
  1312. {
  1313. RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
  1314. for (unsigned i = 0; i < style->font().familyCount(); ++i)
  1315. list->append(valueForFamily(style->font().familyAt(i)));
  1316. return list.release();
  1317. }
  1318. static PassRefPtr<CSSPrimitiveValue> lineHeightFromStyle(RenderStyle* style, RenderView* renderView)
  1319. {
  1320. Length length = style->lineHeight();
  1321. if (length.isNegative())
  1322. return cssValuePool().createIdentifierValue(CSSValueNormal);
  1323. if (length.isPercent())
  1324. // This is imperfect, because it doesn't include the zoom factor and the real computation
  1325. // for how high to be in pixels does include things like minimum font size and the zoom factor.
  1326. // On the other hand, since font-size doesn't include the zoom factor, we really can't do
  1327. // that here either.
  1328. return zoomAdjustedPixelValue(static_cast<int>(length.percent() * style->fontDescription().specifiedSize()) / 100, style);
  1329. return zoomAdjustedPixelValue(valueForLength(length, 0, renderView), style);
  1330. }
  1331. static PassRefPtr<CSSPrimitiveValue> fontSizeFromStyle(RenderStyle* style)
  1332. {
  1333. return zoomAdjustedPixelValue(style->fontDescription().computedPixelSize(), style);
  1334. }
  1335. static PassRefPtr<CSSPrimitiveValue> fontStyleFromStyle(RenderStyle* style)
  1336. {
  1337. if (style->fontDescription().italic())
  1338. return cssValuePool().createIdentifierValue(CSSValueItalic);
  1339. return cssValuePool().createIdentifierValue(CSSValueNormal);
  1340. }
  1341. static PassRefPtr<CSSPrimitiveValue> fontVariantFromStyle(RenderStyle* style)
  1342. {
  1343. if (style->fontDescription().smallCaps())
  1344. return cssValuePool().createIdentifierValue(CSSValueSmallCaps);
  1345. return cssValuePool().createIdentifierValue(CSSValueNormal);
  1346. }
  1347. static PassRefPtr<CSSPrimitiveValue> fontWeightFromStyle(RenderStyle* style)
  1348. {
  1349. switch (style->fontDescription().weight()) {
  1350. case FontWeight100:
  1351. return cssValuePool().createIdentifierValue(CSSValue100);
  1352. case FontWeight200:
  1353. return cssValuePool().createIdentifierValue(CSSValue200);
  1354. case FontWeight300:
  1355. return cssValuePool().createIdentifierValue(CSSValue300);
  1356. case FontWeightNormal:
  1357. return cssValuePool().createIdentifierValue(CSSValueNormal);
  1358. case FontWeight500:
  1359. return cssValuePool().createIdentifierValue(CSSValue500);
  1360. case FontWeight600:
  1361. return cssValuePool().createIdentifierValue(CSSValue600);
  1362. case FontWeightBold:
  1363. return cssValuePool().createIdentifierValue(CSSValueBold);
  1364. case FontWeight800:
  1365. return cssValuePool().createIdentifierValue(CSSValue800);
  1366. case FontWeight900:
  1367. return cssValuePool().createIdentifierValue(CSSValue900);
  1368. }
  1369. ASSERT_NOT_REACHED();
  1370. return cssValuePool().createIdentifierValue(CSSValueNormal);
  1371. }
  1372. static bool isLayoutDependentProperty(CSSPropertyID propertyID)
  1373. {
  1374. switch (propertyID) {
  1375. case CSSPropertyWidth:
  1376. case CSSPropertyHeight:
  1377. case CSSPropertyMargin:
  1378. case CSSPropertyMarginTop:
  1379. case CSSPropertyMarginBottom:
  1380. case CSSPropertyMarginLeft:
  1381. case CSSPropertyMarginRight:
  1382. case CSSPropertyPadding:
  1383. case CSSPropertyPaddingTop:
  1384. case CSSPropertyPaddingBottom:
  1385. case CSSPropertyPaddingLeft:
  1386. case CSSPropertyPaddingRight:
  1387. case CSSPropertyWebkitPerspectiveOrigin:
  1388. case CSSPropertyWebkitTransformOrigin:
  1389. case CSSPropertyWebkitTransform:
  1390. #if ENABLE(CSS_FILTERS)
  1391. case CSSPropertyWebkitFilter:
  1392. #endif
  1393. return true;
  1394. default:
  1395. return false;
  1396. }
  1397. }
  1398. Node* ComputedStyleExtractor::styledNode() const
  1399. {
  1400. if (!m_node)
  1401. return 0;
  1402. if (m_node->isElementNode()) {
  1403. if (PseudoElement* element = toElement(m_node.get())->pseudoElement(m_pseudoElementSpecifier))
  1404. return element;
  1405. }
  1406. return m_node.get();
  1407. }
  1408. PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(CSSPropertyID propertyID, EUpdateLayout updateLayout) const
  1409. {
  1410. return ComputedStyleExtractor(m_node, m_allowVisitedStyle, m_pseudoElementSpecifier).propertyValue(propertyID, updateLayout);
  1411. }
  1412. PassRefPtr<MutableStylePropertySet> CSSComputedStyleDeclaration::copyProperties() const
  1413. {
  1414. return ComputedStyleExtractor(m_node, m_allowVisitedStyle, m_pseudoElementSpecifier).copyProperties();
  1415. }
  1416. PassRefPtr<CSSValue> ComputedStyleExtractor::propertyValue(CSSPropertyID propertyID, EUpdateLayout updateLayout) const
  1417. {
  1418. Node* styledNode = this->styledNode();
  1419. if (!styledNode)
  1420. return 0;
  1421. if (updateLayout) {
  1422. Document* document = styledNode->document();
  1423. // FIXME: Some of these cases could be narrowed down or optimized better.
  1424. bool forceFullLayout = isLayoutDependentProperty(propertyID)
  1425. || styledNode->isInShadowTree()
  1426. || (document->styleResolverIfExists() && document->styleResolverIfExists()->hasViewportDependentMediaQueries() && document->ownerElement())
  1427. || document->seamlessParentIFrame();
  1428. if (forceFullLayout)
  1429. document->updateLayoutIgnorePendingStylesheets();
  1430. else {
  1431. bool needsStyleRecalc = document->hasPendingForcedStyleRecalc();
  1432. for (Node* n = styledNode; n && !needsStyleRecalc; n = n->parentNode())
  1433. needsStyleRecalc = n->needsStyleRecalc();
  1434. if (needsStyleRecalc)
  1435. document->updateStyleIfNeeded();
  1436. }
  1437. // The style recalc could have caused the styled node to be discarded or replaced
  1438. // if it was a PseudoElement so we need to update it.
  1439. styledNode = this->styledNode();
  1440. }
  1441. RenderObject* renderer = styledNode->renderer();
  1442. RefPtr<RenderStyle> style;
  1443. if (renderer && renderer->isComposited() && AnimationController::supportsAcceleratedAnimationOfProperty(propertyID)) {
  1444. AnimationUpdateBlock animationUpdateBlock(renderer->animation());
  1445. style = renderer->animation()->getAnimatedStyleForRenderer(renderer);
  1446. if (m_pseudoElementSpecifier && !styledNode->isPseudoElement()) {
  1447. // FIXME: This cached pseudo style will only exist if the animation has been run at least once.
  1448. style = style->getCachedPseudoStyle(m_pseudoElementSpecifier);
  1449. }
  1450. } else
  1451. style = styledNode->computedStyle(styledNode->isPseudoElement() ? NOPSEUDO : m_pseudoElementSpecifier);
  1452. if (!style)
  1453. return 0;
  1454. propertyID = CSSProperty::resolveDirectionAwareProperty(propertyID, style->direction(), style->writingMode());
  1455. switch (propertyID) {
  1456. case CSSPropertyInvalid:
  1457. #if ENABLE(CSS_VARIABLES)
  1458. case CSSPropertyVariable:
  1459. #endif
  1460. break;
  1461. case CSSPropertyBackgroundColor:
  1462. return cssValuePool().createColorValue(m_allowVisitedStyle? style->visitedDependentColor(CSSPropertyBackgroundColor).rgb() : style->backgroundColor().rgb());
  1463. case CSSPropertyBackgroundImage:
  1464. case CSSPropertyWebkitMaskImage: {
  1465. const FillLayer* layers = propertyID == CSSPropertyWebkitMaskImage ? style->maskLayers() : style->backgroundLayers();
  1466. if (!layers)
  1467. return cssValuePool().createIdentifierValue(CSSValueNone);
  1468. if (!layers->next()) {
  1469. if (layers->image())
  1470. return layers->image()->cssValue();
  1471. return cssValuePool().createIdentifierValue(CSSValueNone);
  1472. }
  1473. RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
  1474. for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next()) {
  1475. if (currLayer->image())
  1476. list->append(currLayer->image()->cssValue());
  1477. else
  1478. list->append(cssValuePool().createIdentifierValue(CSSValueNone));
  1479. }
  1480. return list.release();
  1481. }
  1482. case CSSPropertyBackgroundSize:
  1483. case CSSPropertyWebkitBackgroundSize:
  1484. case CSSPropertyWebkitMaskSize: {
  1485. const FillLayer* layers = propertyID == CSSPropertyWebkitMaskSize ? style->maskLayers() : style->backgroundLayers();
  1486. if (!layers->next())
  1487. return fillSizeToCSSValue(layers->size(), style.get());
  1488. RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
  1489. for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
  1490. list->append(fillSizeToCSSValue(currLayer->size(), style.get()));
  1491. return list.release();
  1492. }
  1493. case CSSPropertyBackgroundRepeat:
  1494. case CSSPropertyWebkitMaskRepeat: {
  1495. const FillLayer* layers = propertyID == CSSPropertyWebkitMaskRepeat ? style->maskLayers() : style->backgroundLayers();
  1496. if (!layers->next())
  1497. return fillRepeatToCSSValue(layers->repeatX(), layers->repeatY());
  1498. RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
  1499. for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
  1500. list->append(fillRepeatToCSSValue(currLayer->repeatX(), currLayer->repeatY()));
  1501. return list.release();
  1502. }
  1503. case CSSPropertyWebkitBackgroundComposite:
  1504. case CSSPropertyWebkitMaskComposite: {
  1505. const FillLayer* layers = propertyID == CSSPropertyWebkitMaskComposite ? style->maskLayers() : style->backgroundLayers();
  1506. if (!layers->next())
  1507. return cssValuePool().createValue(layers->composite());
  1508. RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
  1509. for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
  1510. list->append(cssValuePool().createValue(currLayer->composite()));
  1511. return list.release();
  1512. }
  1513. case CSSPropertyBackgroundAttachment: {
  1514. const FillLayer* layers = style->backgroundLayers();
  1515. if (!layers->next())
  1516. return cssValuePool().createValue(layers->attachment());
  1517. RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
  1518. for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
  1519. list->append(cssValuePool().createValue(currLayer->attachment()));
  1520. return list.release();
  1521. }
  1522. case CSSPropertyBackgroundClip:
  1523. case CSSPropertyBackgroundOrigin:
  1524. case CSSPropertyWebkitBackgroundClip:
  1525. case CSSPropertyWebkitBackgroundOrigin:
  1526. case CSSPropertyWebkitMaskClip:
  1527. case CSSPropertyWebkitMaskOrigin: {
  1528. const FillLayer* layers = (propertyID == CSSPropertyWebkitMaskClip || propertyID == CSSPropertyWebkitMaskOrigin) ? style->maskLayers() : style->backgroundLayers();
  1529. bool isClip = propertyID == CSSPropertyBackgroundClip || propertyID == CSSPropertyWebkitBackgroundClip || propertyID == CSSPropertyWebkitMaskClip;
  1530. if (!layers->next()) {
  1531. EFillBox box = isClip ? layers->clip() : layers->origin();
  1532. return cssValuePool().createValue(box);
  1533. }
  1534. RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
  1535. for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next()) {
  1536. EFillBox box = isClip ? currLayer->clip() : currLayer->origin();
  1537. list->append(cssValuePool().createValue(box));
  1538. }
  1539. return list.release();
  1540. }
  1541. case CSSPropertyBackgroundPosition:
  1542. case CSSPropertyWebkitMaskPosition: {
  1543. const FillLayer* layers = propertyID == CSSPropertyWebkitMaskPosition ? style->maskLayers() : style->backgroundLayers();
  1544. if (!layers->next())
  1545. return createPositionListForLayer(propertyID, layers, style.get());
  1546. RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
  1547. for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
  1548. list->append(createPositionListForLayer(propertyID, currLayer, style.get()));
  1549. return list.release();
  1550. }
  1551. case CSSPropertyBackgroundPositionX:
  1552. case CSSPropertyWebkitMaskPositionX: {
  1553. const FillLayer* layers = propertyID == CSSPropertyWebkitMaskPositionX ? style->maskLayers() : style->backgroundLayers();
  1554. if (!layers->next())
  1555. return cssValuePool().createValue(layers->xPosition());
  1556. RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
  1557. for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
  1558. list->append(cssValuePool().createValue(currLayer->xPosition()));
  1559. return list.release();
  1560. }
  1561. case CSSPropertyBackgroundPositionY:
  1562. case CSSPropertyWebkitMaskPositionY: {
  1563. const FillLayer* layers = propertyID == CSSPropertyWebkitMaskPositionY ? style->maskLayers() : style->backgroundLayers();
  1564. if (!layers->next())
  1565. return cssValuePool().createValue(layers->yPosition());
  1566. RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
  1567. for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
  1568. list->append(cssValuePool().createValue(currLayer->yPosition()));
  1569. return list.release();
  1570. }
  1571. case CSSPropertyBorderCollapse:
  1572. if (style->borderCollapse())
  1573. return cssValuePool().createIdentifierValue(CSSValueCollapse);
  1574. return cssValuePool().createIdentifierValue(CSSValueSeparate);
  1575. case CSSPropertyBorderSpacing: {
  1576. RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
  1577. list->append(zoomAdjustedPixelValue(style->horizontalBorderSpacing(), style.get()));
  1578. list->append(zoomAdjustedPixelValue(style->verticalBorderSpacing(), style.get()));
  1579. return list.release();
  1580. }
  1581. case CSSPropertyWebkitBorderHorizontalSpacing:
  1582. return zoomAdjustedPixelValue(style->horizontalBorderSpacing(), style.get());
  1583. case CSSPropertyWebkitBorderVerticalSpacing:
  1584. return zoomAdjustedPixelValue(style->verticalBorderSpacing(), style.get());
  1585. case CSSPropertyBorderImageSource:
  1586. if (style->borderImageSource())
  1587. return style->borderImageSource()->cssValue();
  1588. return cssValuePool().createIdentifierValue(CSSValueNone);
  1589. case CSSPropertyBorderTopColor:
  1590. return m_allowVisitedStyle ? cssValuePool().createColorValue(style->visitedDependentColor(CSSPropertyBorderTopColor).rgb()) : currentColorOrValidColor(style.get(), style->borderTopColor());
  1591. case CSSPropertyBorderRightColor:
  1592. return m_allowVisitedStyle ? cssValuePool().createColorValue(style->visitedDependentColor(CSSPropertyBorderRightColor).rgb()) : currentColorOrValidColor(style.get(), style->borderRightColor());
  1593. case CSSPropertyBorderBottomColor:
  1594. return m_allowVisitedStyle ? cssValuePool().createColorValue(style->visitedDependentColor(CSSPropertyBorderBottomColor).rgb()) : currentColorOrValidColor(style.get(), style->borderBottomColor());
  1595. case CSSPropertyBorderLeftColor:
  1596. return m_allowVisitedStyle ? cssValuePool().createColorValue(style->visitedDependentColor(CSSPropertyBorderLeftColor).rgb()) : currentColorOrValidColor(style.get(), style->borderLeftColor());
  1597. case CSSPropertyBorderTopStyle:
  1598. return cssValuePool().createValue(style->borderTopStyle());
  1599. case CSSPropertyBorderRightStyle:
  1600. return cssValuePool().createValue(style->borderRightStyle());
  1601. case CSSPropertyBorderBottomStyle:
  1602. return cssValuePool().createValue(style->borderBottomStyle());
  1603. case CSSPropertyBorderLeftStyle:
  1604. return cssValuePool().createValue(style->borderLeftStyle());
  1605. case CSSPropertyBorderTopWidth:
  1606. return zoomAdjustedPixelValue(style->borderTopWidth(), style.get());
  1607. case CSSPropertyBorderRightWidth:
  1608. return zoomAdjustedPixelValue(style->borderRightWidth(), style.get());
  1609. case CSSPropertyBorderBottomWidth:
  1610. return zoomAdjustedPixelValue(style->borderBottomWidth(), style.get());
  1611. case CSSPropertyBorderLeftWidth:
  1612. return zoomAdjustedPixelValue(style->borderLeftWidth(), style.get());
  1613. case CSSPropertyBottom:
  1614. return getPositionOffsetValue(style.get(), CSSPropertyBottom, m_node->document()->renderView());
  1615. case CSSPropertyWebkitBoxAlign:
  1616. return cssValuePool().createValue(style->boxAlign());
  1617. #if ENABLE(CSS_BOX_DECORATION_BREAK)
  1618. case CSSPropertyWebkitBoxDecorationBreak:
  1619. if (style->boxDecorationBreak() == DSLICE)
  1620. return cssValuePool().createIdentifierValue(CSSValueSlice);
  1621. return cssValuePool().createIdentifierValue(CSSValueClone);
  1622. #endif
  1623. case CSSPropertyWebkitBoxDirection:
  1624. return cssValuePool().createValue(style->boxDirection());
  1625. case CSSPropertyWebkitBoxFlex:
  1626. return cssValuePool().createValue(style->boxFlex(), CSSPrimitiveValue::CSS_NUMBER);
  1627. case CSSPropertyWebkitBoxFlexGroup:
  1628. return cssValuePool().createValue(style->boxFlexGroup(), CSSPrimitiveValue::CSS_NUMBER);
  1629. case CSSPropertyWebkitBoxLines:
  1630. return cssValuePool().createValue(style->boxLines());
  1631. case CSSPropertyWebkitBoxOrdinalGroup:
  1632. return cssValuePool().createValue(style->boxOrdinalGroup(), CSSPrimitiveValue::CSS_NUMBER);
  1633. case CSSPropertyWebkitBoxOrient:
  1634. return cssValuePool().createValue(style->boxOrient());
  1635. case CSSPropertyWebkitBoxPack:
  1636. return cssValuePool().createValue(style->boxPack());
  1637. case CSSPropertyWebkitBoxReflect:
  1638. return valueForReflection(style->boxReflect(), style.get());
  1639. case CSSPropertyBoxShadow:
  1640. case CSSPropertyWebkitBoxShadow:
  1641. return valueForShadow(style->boxShadow(), propertyID, style.get());
  1642. case CSSPropertyCaptionSide:
  1643. return cssValuePool().createValue(style->captionSide());
  1644. case CSSPropertyClear:
  1645. return cssValuePool().createValue(style->clear());
  1646. case CSSPropertyColor:
  1647. return cssValuePool().createColorValue(m_allowVisitedStyle ? style->visitedDependentColor(CSSPropertyColor).rgb() : style->color().rgb());
  1648. case CSSPropertyWebkitPrintColorAdjust:
  1649. return cssValuePool().createValue(style->printColorAdjust());
  1650. case CSSPropertyWebkitColumnAxis:
  1651. return cssValuePool().createValue(style->columnAxis());
  1652. case CSSPropertyWebkitColumnCount:
  1653. if (style->hasAutoColumnCount())
  1654. return cssValuePool().createIdentifierValue(CSSValueAuto);
  1655. return cssValuePool().createValue(style->columnCount(), CSSPrimitiveValue::CSS_NUMBER);
  1656. case CSSPropertyWebkitColumnGap:
  1657. if (style->hasNormalColumnGap())
  1658. return cssValuePool().createIdentifierValue(CSSValueNormal);
  1659. return zoomAdjustedPixelValue(style->columnGap(), style.get());
  1660. case CSSPropertyWebkitColumnProgression:
  1661. return cssValuePool().createValue(style->columnProgression());
  1662. case CSSPropertyWebkitColumnRuleColor:
  1663. return m_allowVisitedStyle ? cssValuePool().createColorValue(style->visitedDependentColor(CSSPropertyOutlineColor).rgb()) : currentColorOrValidColor(style.get(), style->columnRuleColor());
  1664. case CSSPropertyWebkitColumnRuleStyle:
  1665. return cssValuePool().createValue(style->columnRuleStyle());
  1666. case CSSPropertyWebkitColumnRuleWidth:
  1667. return zoomAdjustedPixelValue(style->columnRuleWidth(), style.get());
  1668. case CSSPropertyWebkitColumnSpan:
  1669. return cssValuePool().createIdentifierValue(style->columnSpan() ? CSSValueAll : CSSValueNone);
  1670. case CSSPropertyWebkitColumnBreakAfter:
  1671. return cssValuePool().createValue(style->columnBreakAfter());
  1672. case CSSPropertyWebkitColumnBreakBefore:
  1673. return cssValuePool().createValue(style->columnBreakBefore());
  1674. case CSSPropertyWebkitColumnBreakInside:
  1675. return cssValuePool().createValue(style->columnBreakInside());
  1676. case CSSPropertyWebkitColumnWidth:
  1677. if (style->hasAutoColumnWidth())
  1678. return cssValuePool().createIdentifierValue(CSSValueAuto);
  1679. return zoomAdjustedPixelValue(style->columnWidth(), style.get());
  1680. case CSSPropertyTabSize:
  1681. return cssValuePool().createValue(style->tabSize(), CSSPrimitiveValue::CSS_NUMBER);
  1682. #if ENABLE(CSS_REGIONS)
  1683. case CSSPropertyWebkitRegionBreakAfter:
  1684. return cssValuePool().createValue(style->regionBreakAfter());
  1685. case CSSPropertyWebkitRegionBreakBefore:
  1686. return cssValuePool().createValue(style->regionBreakBefore());
  1687. case CSSPropertyWebkitRegionBreakInside:
  1688. return cssValuePool().createValue(style->regionBreakInside());
  1689. #endif
  1690. case CSSPropertyCursor: {
  1691. RefPtr<CSSValueList> list;
  1692. CursorList* cursors = style->cursors();
  1693. if (cursors && cursors->size() > 0) {
  1694. list = CSSValueList::createCommaSeparated();
  1695. for (unsigned i = 0; i < cursors->size(); ++i)
  1696. if (StyleImage* image = cursors->at(i).image())
  1697. list->append(image->cssValue());
  1698. }
  1699. RefPtr<CSSValue> value = cssValuePool().createValue(style->cursor());
  1700. if (list) {
  1701. list->append(value.release());
  1702. return list.release();
  1703. }
  1704. return value.release();
  1705. }
  1706. #if ENABLE(CURSOR_VISIBILITY)
  1707. case CSSPropertyWebkitCursorVisibility:
  1708. return cssValuePool().createValue(style->cursorVisibility());
  1709. #endif
  1710. case CSSPropertyDirection:
  1711. return cssValuePool().createValue(style->direction());
  1712. case CSSPropertyDisplay:
  1713. return cssValuePool().createValue(style->display());
  1714. case CSSPropertyEmptyCells:
  1715. return cssValuePool().createValue(style->emptyCells());
  1716. case CSSPropertyWebkitAlignContent:
  1717. return cssValuePool().createValue(style->alignContent());
  1718. case CSSPropertyWebkitAlignItems:
  1719. return cssValuePool().createValue(style->alignItems());
  1720. case CSSPropertyWebkitAlignSelf:
  1721. if (style->alignSelf() == AlignAuto) {
  1722. Node* parent = styledNode->parentNode();
  1723. if (parent && parent->computedStyle())
  1724. return cssValuePool().createValue(parent->computedStyle()->alignItems());
  1725. return cssValuePool().createValue(AlignStretch);
  1726. }
  1727. return cssValuePool().createValue(style->alignSelf());
  1728. case CSSPropertyWebkitFlex:
  1729. return getCSSPropertyValuesForShorthandProperties(webkitFlexShorthand());
  1730. case CSSPropertyWebkitFlexBasis:
  1731. return cssValuePool().createValue(style->flexBasis());
  1732. case CSSPropertyWebkitFlexDirection:
  1733. return cssValuePool().createValue(style->flexDirection());
  1734. case CSSPropertyWebkitFlexFlow:
  1735. return getCSSPropertyValuesForShorthandProperties(webkitFlexFlowShorthand());
  1736. case CSSPropertyWebkitFlexGrow:
  1737. return cssValuePool().createValue(style->flexGrow());
  1738. case CSSPropertyWebkitFlexShrink:
  1739. return cssValuePool().createValue(style->flexShrink());
  1740. case CSSPropertyWebkitFlexWrap:
  1741. return cssValuePool().createValue(style->flexWrap());
  1742. case CSSPropertyWebkitJustifyContent:
  1743. return cssValuePool().createValue(style->justifyContent());
  1744. case CSSPropertyWebkitOrder:
  1745. return cssValuePool().createValue(style->order(), CSSPrimitiveValue::CSS_NUMBER);
  1746. case CSSPropertyFloat:
  1747. if (style->display() != NONE && style->hasOutOfFlowPosition())
  1748. return cssValuePool().createIdentifierValue(CSSValueNone);
  1749. return cssValuePool().createValue(style->floating());
  1750. case CSSPropertyFont: {
  1751. RefPtr<FontValue> computedFont = FontValue::create();
  1752. computedFont->style = fontStyleFromStyle(style.get());
  1753. computedFont->variant = fontVariantFromStyle(style.get());
  1754. computedFont->weight = fontWeightFromStyle(style.get());
  1755. computedFont->size = fontSizeFromStyle(style.get());
  1756. computedFont->lineHeight = lineHeightFromStyle(style.get(), m_node->document()->renderView());
  1757. computedFont->family = fontFamilyFromStyle(style.get());
  1758. return computedFont.release();
  1759. }
  1760. case CSSPropertyFontFamily: {
  1761. RefPtr<CSSValueList> fontFamilyList = fontFamilyFromStyle(style.get());
  1762. // If there's only a single family, return that as a CSSPrimitiveValue.
  1763. // NOTE: Gecko always returns this as a comma-separated CSSPrimitiveValue string.
  1764. if (fontFamilyList->length() == 1)
  1765. return fontFamilyList->item(0);
  1766. return fontFamilyList.release();
  1767. }
  1768. case CSSPropertyFontSize:
  1769. return fontSizeFromStyle(style.get());
  1770. case CSSPropertyFontStyle:
  1771. return fontStyleFromStyle(style.get());
  1772. case CSSPropertyFontVariant:
  1773. return fontVariantFromStyle(style.get());
  1774. case CSSPropertyFontWeight:
  1775. return fontWeightFromStyle(style.get());
  1776. case CSSPropertyWebkitFontFeatureSettings: {
  1777. const FontFeatureSettings* featureSettings = style->fontDescription().featureSettings();
  1778. if (!featureSettings || !featureSettings->size())
  1779. return cssValuePool().createIdentifierValue(CSSValueNormal);
  1780. RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
  1781. for (unsigned i = 0; i < featureSettings->size(); ++i) {
  1782. const FontFeature& feature = featureSettings->at(i);
  1783. RefPtr<FontFeatureValue> featureValue = FontFeatureValue::create(feature.tag(), feature.value());
  1784. list->append(featureValue.release());
  1785. }
  1786. return list.release();
  1787. }
  1788. case CSSPropertyWebkitGridAutoColumns:
  1789. return valueForGridTrackSize(style->gridAutoColumns(), style.get(), m_node->document()->renderView());
  1790. case CSSPropertyWebkitGridAutoFlow:
  1791. return cssValuePool().createValue(style->gridAutoFlow());
  1792. case CSSPropertyWebkitGridAutoRows:
  1793. return valueForGridTrackSize(style->gridAutoRows(), style.get(), m_node->document()->renderView());
  1794. case CSSPropertyWebkitGridColumns:
  1795. return valueForGridTrackList(style->gridColumns(), style.get(), m_node->document()->renderView());
  1796. case CSSPropertyWebkitGridRows:
  1797. return valueForGridTrackList(style->gridRows(), style.get(), m_node->document()->renderView());
  1798. case CSSPropertyWebkitGridStart:
  1799. return valueForGridPosition(style->gridItemStart());
  1800. case CSSPropertyWebkitGridEnd:
  1801. return valueForGridPosition(style->gridItemEnd());
  1802. case CSSPropertyWebkitGridBefore:
  1803. return valueForGridPosition(style->gridItemBefore());
  1804. case CSSPropertyWebkitGridAfter:
  1805. return valueForGridPosition(style->gridItemAfter());
  1806. case CSSPropertyWebkitGridColumn:
  1807. return getCSSPropertyValuesForGridShorthand(webkitGridColumnShorthand());
  1808. case CSSPropertyWebkitGridRow:
  1809. return getCSSPropertyValuesForGridShorthand(webkitGridRowShorthand());
  1810. case CSSPropertyHeight:
  1811. if (renderer) {
  1812. // According to http://www.w3.org/TR/CSS2/visudet.html#the-height-property,
  1813. // the "height" property does not apply for non-replaced inline elements.
  1814. if (!renderer->isReplaced() && renderer->isInline())
  1815. return cssValuePool().createIdentifierValue(CSSValueAuto);
  1816. return zoomAdjustedPixelValue(sizingBox(renderer).height(), style.get());
  1817. }
  1818. return zoomAdjustedPixelValueForLength(style->height(), style.get());
  1819. case CSSPropertyWebkitHighlight:
  1820. if (style->highlight() == nullAtom)
  1821. return cssValuePool().createIdentifierValue(CSSValueNone);
  1822. return cssValuePool().createValue(style->highlight(), CSSPrimitiveValue::CSS_STRING);
  1823. case CSSPropertyWebkitHyphens:
  1824. return cssValuePool().createValue(style->hyphens());
  1825. case CSSPropertyWebkitHyphenateCharacter:
  1826. if (style->hyphenationString().isNull())
  1827. return cssValuePool().createIdentifierValue(CSSValueAuto);
  1828. return cssValuePool().createValue(style->hyphenationString(), CSSPrimitiveValue::CSS_STRING);
  1829. case CSSPropertyWebkitHyphenateLimitAfter:
  1830. if (style->hyphenationLimitAfter() < 0)
  1831. return CSSPrimitiveValue::createIdentifier(CSSValueAuto);
  1832. return CSSPrimitiveValue::create(style->hyphenationLimitAfter(), CSSPrimitiveValue::CSS_NUMBER);
  1833. case CSSPropertyWebkitHyphenateLimitBefore:
  1834. if (style->hyphenationLimitBefore() < 0)
  1835. return CSSPrimitiveValue::createIdentifier(CSSValueAuto);
  1836. return CSSPrimitiveValue::create(style->hyphenationLimitBefore(), CSSPrimitiveValue::CSS_NUMBER);
  1837. case CSSPropertyWebkitHyphenateLimitLines:
  1838. if (style->hyphenationLimitLines() < 0)
  1839. return CSSPrimitiveValue::createIdentifier(CSSValueNoLimit);
  1840. return CSSPrimitiveValue::create(style->hyphenationLimitLines(), CSSPrimitiveValue::CSS_NUMBER);
  1841. case CSSPropertyWebkitBorderFit:
  1842. if (style->borderFit() == BorderFitBorder)
  1843. return cssValuePool().createIdentifierValue(CSSValueBorder);
  1844. return cssValuePool().createIdentifierValue(CSSValueLines);
  1845. #if ENABLE(CSS_IMAGE_ORIENTATION)
  1846. case CSSPropertyImageOrientation:
  1847. return cssValuePool().createValue(style->imageOrientation());
  1848. #endif
  1849. case CSSPropertyImageRendering:
  1850. return CSSPrimitiveValue::create(style->imageRendering());
  1851. #if ENABLE(CSS_IMAGE_RESOLUTION)
  1852. case CSSPropertyImageResolution:
  1853. return cssValuePool().createValue(style->imageResolution(), CSSPrimitiveValue::CSS_DPPX);
  1854. #endif
  1855. case CSSPropertyLeft:
  1856. return getPositionOffsetValue(style.get(), CSSPropertyLeft, m_node->document()->renderView());
  1857. case CSSPropertyLetterSpacing:
  1858. if (!style->letterSpacing())
  1859. return cssValuePool().createIdentifierValue(CSSValueNormal);
  1860. return zoomAdjustedPixelValue(style->letterSpacing(), style.get());
  1861. case CSSPropertyWebkitLineClamp:
  1862. if (style->lineClamp().isNone())
  1863. return cssValuePool().createIdentifierValue(CSSValueNone);
  1864. return cssValuePool().createValue(style->lineClamp().value(), style->lineClamp().isPercentage() ? CSSPrimitiveValue::CSS_PERCENTAGE : CSSPrimitiveValue::CSS_NUMBER);
  1865. case CSSPropertyLineHeight:
  1866. return lineHeightFromStyle(style.get(), m_node->document()->renderView());
  1867. case CSSPropertyListStyleImage:
  1868. if (style->listStyleImage())
  1869. return style->listStyleImage()->cssValue();
  1870. return cssValuePool().createIdentifierValue(CSSValueNone);
  1871. case CSSPropertyListStylePosition:
  1872. return cssValuePool().createValue(style->listStylePosition());
  1873. case CSSPropertyListStyleType:
  1874. return cssValuePool().createValue(style->listStyleType());
  1875. case CSSPropertyWebkitLocale:
  1876. if (style->locale().isNull())
  1877. return cssValuePool().createIdentifierValue(CSSValueAuto);
  1878. return cssValuePool().createValue(style->locale(), CSSPrimitiveValue::CSS_STRING);
  1879. case CSSPropertyMarginTop: {
  1880. Length marginTop = style->marginTop();
  1881. if (marginTop.isFixed() || !renderer || !renderer->isBox())
  1882. return zoomAdjustedPixelValueForLength(marginTop, style.get());
  1883. return zoomAdjustedPixelValue(toRenderBox(renderer)->marginTop(), style.get());
  1884. }
  1885. case CSSPropertyMarginRight: {
  1886. Length marginRight = style->marginRight();
  1887. if (marginRight.isFixed() || !renderer || !renderer->isBox())
  1888. return zoomAdjustedPixelValueForLength(marginRight, style.get());
  1889. float value;
  1890. if (marginRight.isPercent() || marginRight.isViewportPercentage())
  1891. // RenderBox gives a marginRight() that is the distance between the right-edge of the child box
  1892. // and the right-edge of the containing box, when display == BLOCK. Let's calculate the absolute
  1893. // value of the specified margin-right % instead of relying on RenderBox's marginRight() value.
  1894. value = minimumValueForLength(marginRight, toRenderBox(renderer)->containingBlockLogicalWidthForContent(), m_node->document()->renderView());
  1895. else
  1896. value = toRenderBox(renderer)->marginRight();
  1897. return zoomAdjustedPixelValue(value, style.get());
  1898. }
  1899. case CSSPropertyMarginBottom: {
  1900. Length marginBottom = style->marginBottom();
  1901. if (marginBottom.isFixed() || !renderer || !renderer->isBox())
  1902. return zoomAdjustedPixelValueForLength(marginBottom, style.get());
  1903. return zoomAdjustedPixelValue(toRenderBox(renderer)->marginBottom(), style.get());
  1904. }
  1905. case CSSPropertyMarginLeft: {
  1906. Length marginLeft = style->marginLeft();
  1907. if (marginLeft.isFixed() || !renderer || !renderer->isBox())
  1908. return zoomAdjustedPixelValueForLength(marginLeft, style.get());
  1909. return zoomAdjustedPixelValue(toRenderBox(renderer)->marginLeft(), style.get());
  1910. }
  1911. case CSSPropertyWebkitMarqueeDirection:
  1912. return cssValuePool().createValue(style->marqueeDirection());
  1913. case CSSPropertyWebkitMarqueeIncrement:
  1914. return cssValuePool().createValue(style->marqueeIncrement());
  1915. case CSSPropertyWebkitMarqueeRepetition:
  1916. if (style->marqueeLoopCount() < 0)
  1917. return cssValuePool().createIdentifierValue(CSSValueInfinite);
  1918. return cssValuePool().createValue(style->marqueeLoopCount(), CSSPrimitiveValue::CSS_NUMBER);
  1919. case CSSPropertyWebkitMarqueeStyle:
  1920. return cssValuePool().createValue(style->marqueeBehavior());
  1921. case CSSPropertyWebkitUserModify:
  1922. return cssValuePool().createValue(style->userModify());
  1923. case CSSPropertyMaxHeight: {
  1924. const Length& maxHeight = style->maxHeight();
  1925. if (maxHeight.isUndefined())
  1926. return cssValuePool().createIdentifierValue(CSSValueNone);
  1927. return zoomAdjustedPixelValueForLength(maxHeight, style.get());
  1928. }
  1929. case CSSPropertyMaxWidth: {
  1930. const Length& maxWidth = style->maxWidth();
  1931. if (maxWidth.isUndefined())
  1932. return cssValuePool().createIdentifierValue(CSSValueNone);
  1933. return zoomAdjustedPixelValueForLength(maxWidth, style.get());
  1934. }
  1935. case CSSPropertyMinHeight:
  1936. // FIXME: For flex-items, min-height:auto should compute to min-content.
  1937. if (style->minHeight().isAuto())
  1938. return zoomAdjustedPixelValue(0, style.get());
  1939. return zoomAdjustedPixelValueForLength(style->minHeight(), style.get());
  1940. case CSSPropertyMinWidth:
  1941. // FIXME: For flex-items, min-width:auto should compute to min-content.
  1942. if (style->minWidth().isAuto())
  1943. return zoomAdjustedPixelValue(0, style.get());
  1944. return zoomAdjustedPixelValueForLength(style->minWidth(), style.get());
  1945. case CSSPropertyOpacity:
  1946. return cssValuePool().createValue(style->opacity(), CSSPrimitiveValue::CSS_NUMBER);
  1947. case CSSPropertyOrphans:
  1948. if (style->hasAutoOrphans())
  1949. return cssValuePool().createIdentifierValue(CSSValueAuto);
  1950. return cssValuePool().createValue(style->orphans(), CSSPrimitiveValue::CSS_NUMBER);
  1951. case CSSPropertyOutlineColor:
  1952. return m_allowVisitedStyle ? cssValuePool().createColorValue(style->visitedDependentColor(CSSPropertyOutlineColor).rgb()) : currentColorOrValidColor(style.get(), style->outlineColor());
  1953. case CSSPropertyOutlineOffset:
  1954. return zoomAdjustedPixelValue(style->outlineOffset(), style.get());
  1955. case CSSPropertyOutlineStyle:
  1956. if (style->outlineStyleIsAuto())
  1957. return cssValuePool().createIdentifierValue(CSSValueAuto);
  1958. return cssValuePool().createValue(style->outlineStyle());
  1959. case CSSPropertyOutlineWidth:
  1960. return zoomAdjustedPixelValue(style->outlineWidth(), style.get());
  1961. case CSSPropertyOverflow:
  1962. return cssValuePool().createValue(max(style->overflowX(), style->overflowY()));
  1963. case CSSPropertyOverflowWrap:
  1964. return cssValuePool().createValue(style->overflowWrap());
  1965. case CSSPropertyOverflowX:
  1966. return cssValuePool().createValue(style->overflowX());
  1967. case CSSPropertyOverflowY:
  1968. return cssValuePool().createValue(style->overflowY());
  1969. case CSSPropertyPaddingTop:
  1970. if (renderer && renderer->isBox())
  1971. return zoomAdjustedPixelValue(toRenderBox(renderer)->computedCSSPaddingTop(), style.get());
  1972. return zoomAdjustedPixelValueForLength(style->paddingTop(), style.get());
  1973. case CSSPropertyPaddingRight:
  1974. if (renderer && renderer->isBox())
  1975. return zoomAdjustedPixelValue(toRenderBox(renderer)->computedCSSPaddingRight(), style.get());
  1976. return zoomAdjustedPixelValueForLength(style->paddingRight(), style.get());
  1977. case CSSPropertyPaddingBottom:
  1978. if (renderer && renderer->isBox())
  1979. return zoomAdjustedPixelValue(toRenderBox(renderer)->computedCSSPaddingBottom(), style.get());
  1980. return zoomAdjustedPixelValueForLength(style->paddingBottom(), style.get());
  1981. case CSSPropertyPaddingLeft:
  1982. if (renderer && renderer->isBox())
  1983. return zoomAdjustedPixelValue(toRenderBox(renderer)->computedCSSPaddingLeft(), style.get());
  1984. return zoomAdjustedPixelValueForLength(style->paddingLeft(), style.get());
  1985. case CSSPropertyPageBreakAfter:
  1986. return cssValuePool().createValue(style->pageBreakAfter());
  1987. case CSSPropertyPageBreakBefore:
  1988. return cssValuePool().createValue(style->pageBreakBefore());
  1989. case CSSPropertyPageBreakInside: {
  1990. EPageBreak pageBreak = style->pageBreakInside();
  1991. ASSERT(pageBreak != PBALWAYS);
  1992. if (pageBreak == PBALWAYS)
  1993. return 0;
  1994. return cssValuePool().createValue(style->pageBreakInside());
  1995. }
  1996. case CSSPropertyPosition:
  1997. return cssValuePool().createValue(style->position());
  1998. case CSSPropertyRight:
  1999. return getPositionOffsetValue(style.get(), CSSPropertyRight, m_node->document()->renderView());
  2000. case CSSPropertyWebkitRubyPosition:
  2001. return cssValuePool().createValue(style->rubyPosition());
  2002. case CSSPropertyTableLayout:
  2003. return cssValuePool().createValue(style->tableLayout());
  2004. case CSSPropertyTextAlign:
  2005. return cssValuePool().createValue(style->textAlign());
  2006. case CSSPropertyTextDecoration:
  2007. return renderTextDecorationFlagsToCSSValue(style->textDecoration());
  2008. #if ENABLE(CSS3_TEXT)
  2009. case CSSPropertyWebkitTextDecorationLine:
  2010. return renderTextDecorationFlagsToCSSValue(style->textDecoration());
  2011. case CSSPropertyWebkitTextDecorationStyle:
  2012. return renderTextDecorationStyleFlagsToCSSValue(style->textDecorationStyle());
  2013. case CSSPropertyWebkitTextDecorationColor:
  2014. return currentColorOrValidColor(style.get(), style->textDecorationColor());
  2015. case CSSPropertyWebkitTextAlignLast:
  2016. return cssValuePool().createValue(style->textAlignLast());
  2017. case CSSPropertyWebkitTextJustify:
  2018. return cssValuePool().createValue(style->textJustify());
  2019. case CSSPropertyWebkitTextUnderlinePosition:
  2020. return cssValuePool().createValue(style->textUnderlinePosition());
  2021. #endif // CSS3_TEXT
  2022. case CSSPropertyWebkitTextDecorationsInEffect:
  2023. return renderTextDecorationFlagsToCSSValue(style->textDecorationsInEffect());
  2024. case CSSPropertyWebkitTextFillColor:
  2025. return currentColorOrValidColor(style.get(), style->textFillColor());
  2026. case CSSPropertyWebkitTextEmphasisColor:
  2027. return currentColorOrValidColor(style.get(), style->textEmphasisColor());
  2028. case CSSPropertyWebkitTextEmphasisPosition:
  2029. return cssValuePool().createValue(style->textEmphasisPosition());
  2030. case CSSPropertyWebkitTextEmphasisStyle:
  2031. switch (style->textEmphasisMark()) {
  2032. case TextEmphasisMarkNone:
  2033. return cssValuePool().createIdentifierValue(CSSValueNone);
  2034. case TextEmphasisMarkCustom:
  2035. return cssValuePool().createValue(style->textEmphasisCustomMark(), CSSPrimitiveValue::CSS_STRING);
  2036. case TextEmphasisMarkAuto:
  2037. ASSERT_NOT_REACHED();
  2038. // Fall through
  2039. case TextEmphasisMarkDot:
  2040. case TextEmphasisMarkCircle:
  2041. case TextEmphasisMarkDoubleCircle:
  2042. case TextEmphasisMarkTriangle:
  2043. case TextEmphasisMarkSesame: {
  2044. RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
  2045. list->append(cssValuePool().createValue(style->textEmphasisFill()));
  2046. list->append(cssValuePool().createValue(style->textEmphasisMark()));
  2047. return list.release();
  2048. }
  2049. }
  2050. case CSSPropertyTextIndent: {
  2051. // If CSS3_TEXT is disabled or text-indent has only one value(<length> | <percentage>),
  2052. // getPropertyCSSValue() returns CSSValue.
  2053. RefPtr<CSSValue> textIndent = zoomAdjustedPixelValueForLength(style->textIndent(), style.get());
  2054. #if ENABLE(CSS3_TEXT)
  2055. // If CSS3_TEXT is enabled and text-indent has -webkit-each-line or -webkit-hanging,
  2056. // getPropertyCSSValue() returns CSSValueList.
  2057. if (style->textIndentLine() == TextIndentEachLine || style->textIndentType() == TextIndentHanging) {
  2058. RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
  2059. list->append(textIndent.release());
  2060. if (style->textIndentLine() == TextIndentEachLine)
  2061. list->append(cssValuePool().createIdentifierValue(CSSValueWebkitEachLine));
  2062. if (style->textIndentType() == TextIndentHanging)
  2063. list->append(cssValuePool().createIdentifierValue(CSSValueWebkitHanging));
  2064. return list.release();
  2065. }
  2066. #endif
  2067. return textIndent.release();
  2068. }
  2069. case CSSPropertyTextShadow:
  2070. return valueForShadow(style->textShadow(), propertyID, style.get());
  2071. case CSSPropertyTextRendering:
  2072. return cssValuePool().createValue(style->fontDescription().textRenderingMode());
  2073. case CSSPropertyTextOverflow:
  2074. if (style->textOverflow())
  2075. return cssValuePool().createIdentifierValue(CSSValueEllipsis);
  2076. return cssValuePool().createIdentifierValue(CSSValueClip);
  2077. case CSSPropertyWebkitTextSecurity:
  2078. return cssValuePool().createValue(style->textSecurity());
  2079. case CSSPropertyWebkitTextStrokeColor:
  2080. return currentColorOrValidColor(style.get(), style->textStrokeColor());
  2081. case CSSPropertyWebkitTextStrokeWidth:
  2082. return zoomAdjustedPixelValue(style->textStrokeWidth(), style.get());
  2083. case CSSPropertyTextTransform:
  2084. return cssValuePool().createValue(style->textTransform());
  2085. case CSSPropertyTop:
  2086. return getPositionOffsetValue(style.get(), CSSPropertyTop, m_node->document()->renderView());
  2087. case CSSPropertyUnicodeBidi:
  2088. return cssValuePool().createValue(style->unicodeBidi());
  2089. case CSSPropertyVerticalAlign:
  2090. switch (style->verticalAlign()) {
  2091. case BASELINE:
  2092. return cssValuePool().createIdentifierValue(CSSValueBaseline);
  2093. case MIDDLE:
  2094. return cssValuePool().createIdentifierValue(CSSValueMiddle);
  2095. case SUB:
  2096. return cssValuePool().createIdentifierValue(CSSValueSub);
  2097. case SUPER:
  2098. return cssValuePool().createIdentifierValue(CSSValueSuper);
  2099. case TEXT_TOP:
  2100. return cssValuePool().createIdentifierValue(CSSValueTextTop);
  2101. case TEXT_BOTTOM:
  2102. return cssValuePool().createIdentifierValue(CSSValueTextBottom);
  2103. case TOP:
  2104. return cssValuePool().createIdentifierValue(CSSValueTop);
  2105. case BOTTOM:
  2106. return cssValuePool().createIdentifierValue(CSSValueBottom);
  2107. case BASELINE_MIDDLE:
  2108. return cssValuePool().createIdentifierValue(CSSValueWebkitBaselineMiddle);
  2109. case LENGTH:
  2110. return cssValuePool().createValue(style->verticalAlignLength());
  2111. }
  2112. ASSERT_NOT_REACHED();
  2113. return 0;
  2114. case CSSPropertyVisibility:
  2115. return cssValuePool().createValue(style->visibility());
  2116. case CSSPropertyWhiteSpace:
  2117. return cssValuePool().createValue(style->whiteSpace());
  2118. case CSSPropertyWidows:
  2119. if (style->hasAutoWidows())
  2120. return cssValuePool().createIdentifierValue(CSSValueAuto);
  2121. return cssValuePool().createValue(style->widows(), CSSPrimitiveValue::CSS_NUMBER);
  2122. case CSSPropertyWidth:
  2123. if (renderer) {
  2124. // According to http://www.w3.org/TR/CSS2/visudet.html#the-width-property,
  2125. // the "width" property does not apply for non-replaced inline elements.
  2126. if (!renderer->isReplaced() && renderer->isInline())
  2127. return cssValuePool().createIdentifierValue(CSSValueAuto);
  2128. return zoomAdjustedPixelValue(sizingBox(renderer).width(), style.get());
  2129. }
  2130. return zoomAdjustedPixelValueForLength(style->width(), style.get());
  2131. case CSSPropertyWordBreak:
  2132. return cssValuePool().createValue(style->wordBreak());
  2133. case CSSPropertyWordSpacing:
  2134. return zoomAdjustedPixelValue(style->wordSpacing(), style.get());
  2135. case CSSPropertyWordWrap:
  2136. return cssValuePool().createValue(style->overflowWrap());
  2137. case CSSPropertyWebkitLineBreak:
  2138. return cssValuePool().createValue(style->lineBreak());
  2139. case CSSPropertyWebkitNbspMode:
  2140. return cssValuePool().createValue(style->nbspMode());
  2141. case CSSPropertyResize:
  2142. return cssValuePool().createValue(style->resize());
  2143. case CSSPropertyWebkitFontKerning:
  2144. return cssValuePool().createValue(style->fontDescription().kerning());
  2145. case CSSPropertyWebkitFontSmoothing:
  2146. return cssValuePool().createValue(style->fontDescription().fontSmoothing());
  2147. case CSSPropertyWebkitFontVariantLigatures: {
  2148. FontDescription::LigaturesState commonLigaturesState = style->fontDescription().commonLigaturesState();
  2149. FontDescription::LigaturesState discretionaryLigaturesState = style->fontDescription().discretionaryLigaturesState();
  2150. FontDescription::LigaturesState historicalLigaturesState = style->fontDescription().historicalLigaturesState();
  2151. if (commonLigaturesState == FontDescription::NormalLigaturesState && discretionaryLigaturesState == FontDescription::NormalLigaturesState
  2152. && historicalLigaturesState == FontDescription::NormalLigaturesState)
  2153. return cssValuePool().createIdentifierValue(CSSValueNormal);
  2154. RefPtr<CSSValueList> valueList = CSSValueList::createSpaceSeparated();
  2155. if (commonLigaturesState != FontDescription::NormalLigaturesState)
  2156. valueList->append(cssValuePool().createIdentifierValue(commonLigaturesState == FontDescription::DisabledLigaturesState ? CSSValueNoCommonLigatures : CSSValueCommonLigatures));
  2157. if (discretionaryLigaturesState != FontDescription::NormalLigaturesState)
  2158. valueList->append(cssValuePool().createIdentifierValue(discretionaryLigaturesState == FontDescription::DisabledLigaturesState ? CSSValueNoDiscretionaryLigatures : CSSValueDiscretionaryLigatures));
  2159. if (historicalLigaturesState != FontDescription::NormalLigaturesState)
  2160. valueList->append(cssValuePool().createIdentifierValue(historicalLigaturesState == FontDescription::DisabledLigaturesState ? CSSValueNoHistoricalLigatures : CSSValueHistoricalLigatures));
  2161. return valueList;
  2162. }
  2163. case CSSPropertyZIndex:
  2164. if (style->hasAutoZIndex())
  2165. return cssValuePool().createIdentifierValue(CSSValueAuto);
  2166. return cssValuePool().createValue(style->zIndex(), CSSPrimitiveValue::CSS_NUMBER);
  2167. case CSSPropertyZoom:
  2168. return cssValuePool().createValue(style->zoom(), CSSPrimitiveValue::CSS_NUMBER);
  2169. case CSSPropertyBoxSizing:
  2170. if (style->boxSizing() == CONTENT_BOX)
  2171. return cssValuePool().createIdentifierValue(CSSValueContentBox);
  2172. return cssValuePool().createIdentifierValue(CSSValueBorderBox);
  2173. #if ENABLE(DASHBOARD_SUPPORT)
  2174. case CSSPropertyWebkitDashboardRegion:
  2175. {
  2176. const Vector<StyleDashboardRegion>& regions = style->dashboardRegions();
  2177. unsigned count = regions.size();
  2178. if (count == 1 && regions[0].type == StyleDashboardRegion::None)
  2179. return cssValuePool().createIdentifierValue(CSSValueNone);
  2180. RefPtr<DashboardRegion> firstRegion;
  2181. DashboardRegion* previousRegion = 0;
  2182. for (unsigned i = 0; i < count; i++) {
  2183. RefPtr<DashboardRegion> region = DashboardRegion::create();
  2184. StyleDashboardRegion styleRegion = regions[i];
  2185. region->m_label = styleRegion.label;
  2186. LengthBox offset = styleRegion.offset;
  2187. region->setTop(zoomAdjustedPixelValue(offset.top().value(), style.get()));
  2188. region->setRight(zoomAdjustedPixelValue(offset.right().value(), style.get()));
  2189. region->setBottom(zoomAdjustedPixelValue(offset.bottom().value(), style.get()));
  2190. region->setLeft(zoomAdjustedPixelValue(offset.left().value(), style.get()));
  2191. region->m_isRectangle = (styleRegion.type == StyleDashboardRegion::Rectangle);
  2192. region->m_isCircle = (styleRegion.type == StyleDashboardRegion::Circle);
  2193. if (previousRegion)
  2194. previousRegion->m_next = region;
  2195. else
  2196. firstRegion = region;
  2197. previousRegion = region.get();
  2198. }
  2199. return cssValuePool().createValue(firstRegion.release());
  2200. }
  2201. #endif
  2202. #if ENABLE(DRAGGABLE_REGION)
  2203. case CSSPropertyWebkitAppRegion:
  2204. return cssValuePool().createIdentifierValue(style->getDraggableRegionMode() == DraggableRegionDrag ? CSSValueDrag : CSSValueNoDrag);
  2205. #endif
  2206. case CSSPropertyWebkitAnimationDelay:
  2207. return getDelayValue(style->animations());
  2208. case CSSPropertyWebkitAnimationDirection: {
  2209. RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
  2210. const AnimationList* t = style->animations();
  2211. if (t) {
  2212. for (size_t i = 0; i < t->size(); ++i) {
  2213. if (t->animation(i)->direction())
  2214. list->append(cssValuePool().createIdentifierValue(CSSValueAlternate));
  2215. else
  2216. list->append(cssValuePool().createIdentifierValue(CSSValueNormal));
  2217. }
  2218. } else
  2219. list->append(cssValuePool().createIdentifierValue(CSSValueNormal));
  2220. return list.release();
  2221. }
  2222. case CSSPropertyWebkitAnimationDuration:
  2223. return getDurationValue(style->animations());
  2224. case CSSPropertyWebkitAnimationFillMode: {
  2225. RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
  2226. const AnimationList* t = style->animations();
  2227. if (t) {
  2228. for (size_t i = 0; i < t->size(); ++i) {
  2229. switch (t->animation(i)->fillMode()) {
  2230. case AnimationFillModeNone:
  2231. list->append(cssValuePool().createIdentifierValue(CSSValueNone));
  2232. break;
  2233. case AnimationFillModeForwards:
  2234. list->append(cssValuePool().createIdentifierValue(CSSValueForwards));
  2235. break;
  2236. case AnimationFillModeBackwards:
  2237. list->append(cssValuePool().createIdentifierValue(CSSValueBackwards));
  2238. break;
  2239. case AnimationFillModeBoth:
  2240. list->append(cssValuePool().createIdentifierValue(CSSValueBoth));
  2241. break;
  2242. }
  2243. }
  2244. } else
  2245. list->append(cssValuePool().createIdentifierValue(CSSValueNone));
  2246. return list.release();
  2247. }
  2248. case CSSPropertyWebkitAnimationIterationCount: {
  2249. RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
  2250. const AnimationList* t = style->animations();
  2251. if (t) {
  2252. for (size_t i = 0; i < t->size(); ++i) {
  2253. double iterationCount = t->animation(i)->iterationCount();
  2254. if (iterationCount == Animation::IterationCountInfinite)
  2255. list->append(cssValuePool().createIdentifierValue(CSSValueInfinite));
  2256. else
  2257. list->append(cssValuePool().createValue(iterationCount, CSSPrimitiveValue::CSS_NUMBER));
  2258. }
  2259. } else
  2260. list->append(cssValuePool().createValue(Animation::initialAnimationIterationCount(), CSSPrimitiveValue::CSS_NUMBER));
  2261. return list.release();
  2262. }
  2263. case CSSPropertyWebkitAnimationName: {
  2264. RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
  2265. const AnimationList* t = style->animations();
  2266. if (t) {
  2267. for (size_t i = 0; i < t->size(); ++i)
  2268. list->append(cssValuePool().createValue(t->animation(i)->name(), CSSPrimitiveValue::CSS_STRING));
  2269. } else
  2270. list->append(cssValuePool().createIdentifierValue(CSSValueNone));
  2271. return list.release();
  2272. }
  2273. case CSSPropertyWebkitAnimationPlayState: {
  2274. RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
  2275. const AnimationList* t = style->animations();
  2276. if (t) {
  2277. for (size_t i = 0; i < t->size(); ++i) {
  2278. int prop = t->animation(i)->playState();
  2279. if (prop == AnimPlayStatePlaying)
  2280. list->append(cssValuePool().createIdentifierValue(CSSValueRunning));
  2281. else
  2282. list->append(cssValuePool().createIdentifierValue(CSSValuePaused));
  2283. }
  2284. } else
  2285. list->append(cssValuePool().createIdentifierValue(CSSValueRunning));
  2286. return list.release();
  2287. }
  2288. case CSSPropertyWebkitAnimationTimingFunction:
  2289. return getTimingFunctionValue(style->animations());
  2290. case CSSPropertyWebkitAppearance:
  2291. return cssValuePool().createValue(style->appearance());
  2292. case CSSPropertyWebkitAspectRatio:
  2293. if (!style->hasAspectRatio())
  2294. return cssValuePool().createIdentifierValue(CSSValueNone);
  2295. return CSSAspectRatioValue::create(style->aspectRatioNumerator(), style->aspectRatioDenominator());
  2296. case CSSPropertyWebkitBackfaceVisibility:
  2297. return cssValuePool().createIdentifierValue((style->backfaceVisibility() == BackfaceVisibilityHidden) ? CSSValueHidden : CSSValueVisible);
  2298. case CSSPropertyWebkitBorderImage:
  2299. return valueForNinePieceImage(style->borderImage());
  2300. case CSSPropertyBorderImageOutset:
  2301. return valueForNinePieceImageQuad(style->borderImage().outset());
  2302. case CSSPropertyBorderImageRepeat:
  2303. return valueForNinePieceImageRepeat(style->borderImage());
  2304. case CSSPropertyBorderImageSlice:
  2305. return valueForNinePieceImageSlice(style->borderImage());
  2306. case CSSPropertyBorderImageWidth:
  2307. return valueForNinePieceImageQuad(style->borderImage().borderSlices());
  2308. case CSSPropertyWebkitMaskBoxImage:
  2309. return valueForNinePieceImage(style->maskBoxImage());
  2310. case CSSPropertyWebkitMaskBoxImageOutset:
  2311. return valueForNinePieceImageQuad(style->maskBoxImage().outset());
  2312. case CSSPropertyWebkitMaskBoxImageRepeat:
  2313. return valueForNinePieceImageRepeat(style->maskBoxImage());
  2314. case CSSPropertyWebkitMaskBoxImageSlice:
  2315. return valueForNinePieceImageSlice(style->maskBoxImage());
  2316. case CSSPropertyWebkitMaskBoxImageWidth:
  2317. return valueForNinePieceImageQuad(style->maskBoxImage().borderSlices());
  2318. case CSSPropertyWebkitMaskBoxImageSource:
  2319. if (style->maskBoxImageSource())
  2320. return style->maskBoxImageSource()->cssValue();
  2321. return cssValuePool().createIdentifierValue(CSSValueNone);
  2322. case CSSPropertyWebkitFontSizeDelta:
  2323. // Not a real style property -- used by the editing engine -- so has no computed value.
  2324. break;
  2325. case CSSPropertyWebkitMarginBottomCollapse:
  2326. case CSSPropertyWebkitMarginAfterCollapse:
  2327. return cssValuePool().createValue(style->marginAfterCollapse());
  2328. case CSSPropertyWebkitMarginTopCollapse:
  2329. case CSSPropertyWebkitMarginBeforeCollapse:
  2330. return cssValuePool().createValue(style->marginBeforeCollapse());
  2331. #if ENABLE(ACCELERATED_OVERFLOW_SCROLLING)
  2332. case CSSPropertyWebkitOverflowScrolling:
  2333. if (!style->useTouchOverflowScrolling())
  2334. return cssValuePool().createIdentifierValue(CSSValueAuto);
  2335. return cssValuePool().createIdentifierValue(CSSValueTouch);
  2336. #endif
  2337. case CSSPropertyWebkitPerspective:
  2338. if (!style->hasPerspective())
  2339. return cssValuePool().createIdentifierValue(CSSValueNone);
  2340. return zoomAdjustedPixelValue(style->perspective(), style.get());
  2341. case CSSPropertyWebkitPerspectiveOrigin: {
  2342. RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
  2343. if (renderer) {
  2344. LayoutRect box;
  2345. if (renderer->isBox())
  2346. box = toRenderBox(renderer)->borderBoxRect();
  2347. RenderView* renderView = m_node->document()->renderView();
  2348. list->append(zoomAdjustedPixelValue(minimumValueForLength(style->perspectiveOriginX(), box.width(), renderView), style.get()));
  2349. list->append(zoomAdjustedPixelValue(minimumValueForLength(style->perspectiveOriginY(), box.height(), renderView), style.get()));
  2350. }
  2351. else {
  2352. list->append(zoomAdjustedPixelValueForLength(style->perspectiveOriginX(), style.get()));
  2353. list->append(zoomAdjustedPixelValueForLength(style->perspectiveOriginY(), style.get()));
  2354. }
  2355. return list.release();
  2356. }
  2357. case CSSPropertyWebkitRtlOrdering:
  2358. return cssValuePool().createIdentifierValue(style->rtlOrdering() ? CSSValueVisual : CSSValueLogical);
  2359. #if ENABLE(TOUCH_EVENTS)
  2360. case CSSPropertyWebkitTapHighlightColor:
  2361. return currentColorOrValidColor(style.get(), style->tapHighlightColor());
  2362. #endif
  2363. case CSSPropertyWebkitUserDrag:
  2364. return cssValuePool().createValue(style->userDrag());
  2365. case CSSPropertyWebkitUserSelect:
  2366. return cssValuePool().createValue(style->userSelect());
  2367. case CSSPropertyBorderBottomLeftRadius:
  2368. return getBorderRadiusCornerValue(style->borderBottomLeftRadius(), style.get(), m_node->document()->renderView());
  2369. case CSSPropertyBorderBottomRightRadius:
  2370. return getBorderRadiusCornerValue(style->borderBottomRightRadius(), style.get(), m_node->document()->renderView());
  2371. case CSSPropertyBorderTopLeftRadius:
  2372. return getBorderRadiusCornerValue(style->borderTopLeftRadius(), style.get(), m_node->document()->renderView());
  2373. case CSSPropertyBorderTopRightRadius:
  2374. return getBorderRadiusCornerValue(style->borderTopRightRadius(), style.get(), m_node->document()->renderView());
  2375. case CSSPropertyClip: {
  2376. if (!style->hasClip())
  2377. return cssValuePool().createIdentifierValue(CSSValueAuto);
  2378. RefPtr<Rect> rect = Rect::create();
  2379. rect->setTop(zoomAdjustedPixelValue(style->clip().top().value(), style.get()));
  2380. rect->setRight(zoomAdjustedPixelValue(style->clip().right().value(), style.get()));
  2381. rect->setBottom(zoomAdjustedPixelValue(style->clip().bottom().value(), style.get()));
  2382. rect->setLeft(zoomAdjustedPixelValue(style->clip().left().value(), style.get()));
  2383. return cssValuePool().createValue(rect.release());
  2384. }
  2385. case CSSPropertySpeak:
  2386. return cssValuePool().createValue(style->speak());
  2387. case CSSPropertyWebkitTransform:
  2388. return computedTransform(renderer, style.get());
  2389. case CSSPropertyWebkitTransformOrigin: {
  2390. RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
  2391. if (renderer) {
  2392. LayoutRect box;
  2393. if (renderer->isBox())
  2394. box = toRenderBox(renderer)->borderBoxRect();
  2395. RenderView* renderView = m_node->document()->renderView();
  2396. list->append(zoomAdjustedPixelValue(minimumValueForLength(style->transformOriginX(), box.width(), renderView), style.get()));
  2397. list->append(zoomAdjustedPixelValue(minimumValueForLength(style->transformOriginY(), box.height(), renderView), style.get()));
  2398. if (style->transformOriginZ() != 0)
  2399. list->append(zoomAdjustedPixelValue(style->transformOriginZ(), style.get()));
  2400. } else {
  2401. list->append(zoomAdjustedPixelValueForLength(style->transformOriginX(), style.get()));
  2402. list->append(zoomAdjustedPixelValueForLength(style->transformOriginY(), style.get()));
  2403. if (style->transformOriginZ() != 0)
  2404. list->append(zoomAdjustedPixelValue(style->transformOriginZ(), style.get()));
  2405. }
  2406. return list.release();
  2407. }
  2408. case CSSPropertyWebkitTransformStyle:
  2409. return cssValuePool().createIdentifierValue((style->transformStyle3D() == TransformStyle3DPreserve3D) ? CSSValuePreserve3d : CSSValueFlat);
  2410. case CSSPropertyTransitionDelay:
  2411. case CSSPropertyWebkitTransitionDelay:
  2412. return getDelayValue(style->transitions());
  2413. case CSSPropertyTransitionDuration:
  2414. case CSSPropertyWebkitTransitionDuration:
  2415. return getDurationValue(style->transitions());
  2416. case CSSPropertyTransitionProperty:
  2417. case CSSPropertyWebkitTransitionProperty:
  2418. return getTransitionPropertyValue(style->transitions());
  2419. case CSSPropertyTransitionTimingFunction:
  2420. case CSSPropertyWebkitTransitionTimingFunction:
  2421. return getTimingFunctionValue(style->transitions());
  2422. case CSSPropertyTransition:
  2423. case CSSPropertyWebkitTransition: {
  2424. const AnimationList* animList = style->transitions();
  2425. if (animList) {
  2426. RefPtr<CSSValueList> transitionsList = CSSValueList::createCommaSeparated();
  2427. for (size_t i = 0; i < animList->size(); ++i) {
  2428. RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
  2429. const Animation* animation = animList->animation(i);
  2430. list->append(createTransitionPropertyValue(animation));
  2431. list->append(cssValuePool().createValue(animation->duration(), CSSPrimitiveValue::CSS_S));
  2432. list->append(createTimingFunctionValue(animation->timingFunction().get()));
  2433. list->append(cssValuePool().createValue(animation->delay(), CSSPrimitiveValue::CSS_S));
  2434. transitionsList->append(list);
  2435. }
  2436. return transitionsList.release();
  2437. }
  2438. RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
  2439. // transition-property default value.
  2440. list->append(cssValuePool().createIdentifierValue(CSSValueAll));
  2441. list->append(cssValuePool().createValue(Animation::initialAnimationDuration(), CSSPrimitiveValue::CSS_S));
  2442. list->append(createTimingFunctionValue(Animation::initialAnimationTimingFunction().get()));
  2443. list->append(cssValuePool().createValue(Animation::initialAnimationDelay(), CSSPrimitiveValue::CSS_S));
  2444. return list.release();
  2445. }
  2446. case CSSPropertyPointerEvents:
  2447. return cssValuePool().createValue(style->pointerEvents());
  2448. case CSSPropertyWebkitColorCorrection:
  2449. return cssValuePool().createValue(style->colorSpace());
  2450. case CSSPropertyWebkitLineGrid:
  2451. if (style->lineGrid().isNull())
  2452. return cssValuePool().createIdentifierValue(CSSValueNone);
  2453. return cssValuePool().createValue(style->lineGrid(), CSSPrimitiveValue::CSS_STRING);
  2454. case CSSPropertyWebkitLineSnap:
  2455. return CSSPrimitiveValue::create(style->lineSnap());
  2456. case CSSPropertyWebkitLineAlign:
  2457. return CSSPrimitiveValue::create(style->lineAlign());
  2458. case CSSPropertyWebkitWritingMode:
  2459. return cssValuePool().createValue(style->writingMode());
  2460. case CSSPropertyWebkitTextCombine:
  2461. return cssValuePool().createValue(style->textCombine());
  2462. case CSSPropertyWebkitTextOrientation:
  2463. return CSSPrimitiveValue::create(style->textOrientation());
  2464. case CSSPropertyWebkitLineBoxContain:
  2465. return createLineBoxContainValue(style->lineBoxContain());
  2466. case CSSPropertyContent:
  2467. return contentToCSSValue(style.get());
  2468. case CSSPropertyCounterIncrement:
  2469. return counterToCSSValue(style.get(), propertyID);
  2470. case CSSPropertyCounterReset:
  2471. return counterToCSSValue(style.get(), propertyID);
  2472. case CSSPropertyWebkitClipPath:
  2473. if (ClipPathOperation* operation = style->clipPath()) {
  2474. if (operation->getOperationType() == ClipPathOperation::SHAPE)
  2475. return valueForBasicShape(static_cast<ShapeClipPathOperation*>(operation)->basicShape());
  2476. #if ENABLE(SVG)
  2477. else if (operation->getOperationType() == ClipPathOperation::REFERENCE) {
  2478. ReferenceClipPathOperation* referenceOperation = static_cast<ReferenceClipPathOperation*>(operation);
  2479. return CSSPrimitiveValue::create(referenceOperation->url(), CSSPrimitiveValue::CSS_URI);
  2480. }
  2481. #endif
  2482. }
  2483. return cssValuePool().createIdentifierValue(CSSValueNone);
  2484. #if ENABLE(CSS_REGIONS)
  2485. case CSSPropertyWebkitFlowInto:
  2486. if (style->flowThread().isNull())
  2487. return cssValuePool().createIdentifierValue(CSSValueNone);
  2488. return cssValuePool().createValue(style->flowThread(), CSSPrimitiveValue::CSS_STRING);
  2489. case CSSPropertyWebkitFlowFrom:
  2490. if (style->regionThread().isNull())
  2491. return cssValuePool().createIdentifierValue(CSSValueNone);
  2492. return cssValuePool().createValue(style->regionThread(), CSSPrimitiveValue::CSS_STRING);
  2493. case CSSPropertyWebkitRegionFragment:
  2494. return cssValuePool().createValue(style->regionFragment());
  2495. #endif
  2496. #if ENABLE(CSS_EXCLUSIONS)
  2497. case CSSPropertyWebkitWrapFlow:
  2498. return cssValuePool().createValue(style->wrapFlow());
  2499. case CSSPropertyWebkitWrapThrough:
  2500. return cssValuePool().createValue(style->wrapThrough());
  2501. #endif
  2502. #if ENABLE(CSS_SHAPES)
  2503. case CSSPropertyWebkitShapeMargin:
  2504. return cssValuePool().createValue(style->shapeMargin());
  2505. case CSSPropertyWebkitShapePadding:
  2506. return cssValuePool().createValue(style->shapePadding());
  2507. case CSSPropertyWebkitShapeInside:
  2508. if (!style->shapeInside())
  2509. return cssValuePool().createIdentifierValue(CSSValueAuto);
  2510. if (style->shapeInside()->type() == ShapeValue::Outside)
  2511. return cssValuePool().createIdentifierValue(CSSValueOutsideShape);
  2512. if (style->shapeInside()->type() == ShapeValue::Image) {
  2513. if (style->shapeInside()->image())
  2514. return style->shapeInside()->image()->cssValue();
  2515. return cssValuePool().createIdentifierValue(CSSValueNone);
  2516. }
  2517. ASSERT(style->shapeInside()->type() == ShapeValue::Shape);
  2518. return valueForBasicShape(style->shapeInside()->shape());
  2519. case CSSPropertyWebkitShapeOutside:
  2520. if (!style->shapeOutside())
  2521. return cssValuePool().createIdentifierValue(CSSValueAuto);
  2522. if (style->shapeOutside()->type() == ShapeValue::Image) {
  2523. if (style->shapeOutside()->image())
  2524. return style->shapeOutside()->image()->cssValue();
  2525. return cssValuePool().createIdentifierValue(CSSValueNone);
  2526. }
  2527. ASSERT(style->shapeOutside()->type() == ShapeValue::Shape);
  2528. return valueForBasicShape(style->shapeOutside()->shape());
  2529. #endif
  2530. #if ENABLE(CSS_FILTERS)
  2531. case CSSPropertyWebkitFilter:
  2532. return valueForFilter(renderer, style.get());
  2533. #endif
  2534. #if ENABLE(CSS_COMPOSITING)
  2535. case CSSPropertyWebkitBlendMode:
  2536. return cssValuePool().createValue(style->blendMode());
  2537. case CSSPropertyWebkitBackgroundBlendMode: {
  2538. const FillLayer* layers = style->backgroundLayers();
  2539. if (!layers->next())
  2540. return cssValuePool().createValue(layers->blendMode());
  2541. RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
  2542. for (const FillLayer* currLayer = layers; currLayer; currLayer = currLayer->next())
  2543. list->append(cssValuePool().createValue(currLayer->blendMode()));
  2544. return list.release();
  2545. }
  2546. #endif
  2547. case CSSPropertyBackground:
  2548. return getBackgroundShorthandValue();
  2549. case CSSPropertyBorder: {
  2550. RefPtr<CSSValue> value = propertyValue(CSSPropertyBorderTop, DoNotUpdateLayout);
  2551. const CSSPropertyID properties[3] = { CSSPropertyBorderRight, CSSPropertyBorderBottom,
  2552. CSSPropertyBorderLeft };
  2553. for (size_t i = 0; i < WTF_ARRAY_LENGTH(properties); ++i) {
  2554. if (!compareCSSValuePtr<CSSValue>(value, propertyValue(properties[i], DoNotUpdateLayout)))
  2555. return 0;
  2556. }
  2557. return value.release();
  2558. }
  2559. case CSSPropertyBorderBottom:
  2560. return getCSSPropertyValuesForShorthandProperties(borderBottomShorthand());
  2561. case CSSPropertyBorderColor:
  2562. return getCSSPropertyValuesForSidesShorthand(borderColorShorthand());
  2563. case CSSPropertyBorderLeft:
  2564. return getCSSPropertyValuesForShorthandProperties(borderLeftShorthand());
  2565. case CSSPropertyBorderImage:
  2566. return valueForNinePieceImage(style->borderImage());
  2567. case CSSPropertyBorderRadius:
  2568. return getBorderRadiusShorthandValue(style.get(), m_node->document()->renderView());
  2569. case CSSPropertyBorderRight:
  2570. return getCSSPropertyValuesForShorthandProperties(borderRightShorthand());
  2571. case CSSPropertyBorderStyle:
  2572. return getCSSPropertyValuesForSidesShorthand(borderStyleShorthand());
  2573. case CSSPropertyBorderTop:
  2574. return getCSSPropertyValuesForShorthandProperties(borderTopShorthand());
  2575. case CSSPropertyBorderWidth:
  2576. return getCSSPropertyValuesForSidesShorthand(borderWidthShorthand());
  2577. case CSSPropertyWebkitColumnRule:
  2578. return getCSSPropertyValuesForShorthandProperties(webkitColumnRuleShorthand());
  2579. case CSSPropertyWebkitColumns:
  2580. return getCSSPropertyValuesForShorthandProperties(webkitColumnsShorthand());
  2581. case CSSPropertyListStyle:
  2582. return getCSSPropertyValuesForShorthandProperties(listStyleShorthand());
  2583. case CSSPropertyMargin:
  2584. return getCSSPropertyValuesForSidesShorthand(marginShorthand());
  2585. case CSSPropertyOutline:
  2586. return getCSSPropertyValuesForShorthandProperties(outlineShorthand());
  2587. case CSSPropertyPadding:
  2588. return getCSSPropertyValuesForSidesShorthand(paddingShorthand());
  2589. /* Individual properties not part of the spec */
  2590. case CSSPropertyBackgroundRepeatX:
  2591. case CSSPropertyBackgroundRepeatY:
  2592. break;
  2593. /* Unimplemented CSS 3 properties (including CSS3 shorthand properties) */
  2594. case CSSPropertyWebkitTextEmphasis:
  2595. case CSSPropertyTextLineThrough:
  2596. case CSSPropertyTextLineThroughColor:
  2597. case CSSPropertyTextLineThroughMode:
  2598. case CSSPropertyTextLineThroughStyle:
  2599. case CSSPropertyTextLineThroughWidth:
  2600. case CSSPropertyTextOverline:
  2601. case CSSPropertyTextOverlineColor:
  2602. case CSSPropertyTextOverlineMode:
  2603. case CSSPropertyTextOverlineStyle:
  2604. case CSSPropertyTextOverlineWidth:
  2605. case CSSPropertyTextUnderline:
  2606. case CSSPropertyTextUnderlineColor:
  2607. case CSSPropertyTextUnderlineMode:
  2608. case CSSPropertyTextUnderlineStyle:
  2609. case CSSPropertyTextUnderlineWidth:
  2610. break;
  2611. /* Directional properties are resolved by resolveDirectionAwareProperty() before the switch. */
  2612. case CSSPropertyWebkitBorderEnd:
  2613. case CSSPropertyWebkitBorderEndColor:
  2614. case CSSPropertyWebkitBorderEndStyle:
  2615. case CSSPropertyWebkitBorderEndWidth:
  2616. case CSSPropertyWebkitBorderStart:
  2617. case CSSPropertyWebkitBorderStartColor:
  2618. case CSSPropertyWebkitBorderStartStyle:
  2619. case CSSPropertyWebkitBorderStartWidth:
  2620. case CSSPropertyWebkitBorderAfter:
  2621. case CSSPropertyWebkitBorderAfterColor:
  2622. case CSSPropertyWebkitBorderAfterStyle:
  2623. case CSSPropertyWebkitBorderAfterWidth:
  2624. case CSSPropertyWebkitBorderBefore:
  2625. case CSSPropertyWebkitBorderBeforeColor:
  2626. case CSSPropertyWebkitBorderBeforeStyle:
  2627. case CSSPropertyWebkitBorderBeforeWidth:
  2628. case CSSPropertyWebkitMarginEnd:
  2629. case CSSPropertyWebkitMarginStart:
  2630. case CSSPropertyWebkitMarginAfter:
  2631. case CSSPropertyWebkitMarginBefore:
  2632. case CSSPropertyWebkitPaddingEnd:
  2633. case CSSPropertyWebkitPaddingStart:
  2634. case CSSPropertyWebkitPaddingAfter:
  2635. case CSSPropertyWebkitPaddingBefore:
  2636. case CSSPropertyWebkitLogicalWidth:
  2637. case CSSPropertyWebkitLogicalHeight:
  2638. case CSSPropertyWebkitMinLogicalWidth:
  2639. case CSSPropertyWebkitMinLogicalHeight:
  2640. case CSSPropertyWebkitMaxLogicalWidth:
  2641. case CSSPropertyWebkitMaxLogicalHeight:
  2642. ASSERT_NOT_REACHED();
  2643. break;
  2644. /* Unimplemented @font-face properties */
  2645. case CSSPropertyFontStretch:
  2646. case CSSPropertySrc:
  2647. case CSSPropertyUnicodeRange:
  2648. break;
  2649. /* Other unimplemented properties */
  2650. #if ENABLE(CSS_SHADERS)
  2651. case CSSPropertyGeometry:
  2652. #endif
  2653. case CSSPropertyPage: // for @page
  2654. case CSSPropertyQuotes: // FIXME: needs implementation
  2655. case CSSPropertySize: // for @page
  2656. break;
  2657. /* Unimplemented -webkit- properties */
  2658. case CSSPropertyWebkitAnimation:
  2659. case CSSPropertyWebkitBorderRadius:
  2660. case CSSPropertyWebkitMarginCollapse:
  2661. case CSSPropertyWebkitMarquee:
  2662. case CSSPropertyWebkitMarqueeSpeed:
  2663. case CSSPropertyWebkitMask:
  2664. case CSSPropertyWebkitMaskRepeatX:
  2665. case CSSPropertyWebkitMaskRepeatY:
  2666. case CSSPropertyWebkitPerspectiveOriginX:
  2667. case CSSPropertyWebkitPerspectiveOriginY:
  2668. case CSSPropertyWebkitTextStroke:
  2669. case CSSPropertyWebkitTransformOriginX:
  2670. case CSSPropertyWebkitTransformOriginY:
  2671. case CSSPropertyWebkitTransformOriginZ:
  2672. #if ENABLE(CSS_SHADERS)
  2673. case CSSPropertyMix:
  2674. case CSSPropertyParameters:
  2675. #endif
  2676. break;
  2677. #if ENABLE(CSS_DEVICE_ADAPTATION)
  2678. case CSSPropertyMaxZoom:
  2679. case CSSPropertyMinZoom:
  2680. case CSSPropertyOrientation:
  2681. case CSSPropertyUserZoom:
  2682. break;
  2683. #endif
  2684. #if ENABLE(SVG)
  2685. case CSSPropertyBufferedRendering:
  2686. case CSSPropertyClipPath:
  2687. case CSSPropertyClipRule:
  2688. case CSSPropertyMask:
  2689. case CSSPropertyEnableBackground:
  2690. case CSSPropertyFilter:
  2691. case CSSPropertyFloodColor:
  2692. case CSSPropertyFloodOpacity:
  2693. case CSSPropertyLightingColor:
  2694. case CSSPropertyStopColor:
  2695. case CSSPropertyStopOpacity:
  2696. case CSSPropertyColorInterpolation:
  2697. case CSSPropertyColorInterpolationFilters:
  2698. case CSSPropertyColorProfile:
  2699. case CSSPropertyColorRendering:
  2700. case CSSPropertyFill:
  2701. case CSSPropertyFillOpacity:
  2702. case CSSPropertyFillRule:
  2703. case CSSPropertyMarker:
  2704. case CSSPropertyMarkerEnd:
  2705. case CSSPropertyMarkerMid:
  2706. case CSSPropertyMarkerStart:
  2707. case CSSPropertyMaskType:
  2708. case CSSPropertyShapeRendering:
  2709. case CSSPropertyStroke:
  2710. case CSSPropertyStrokeDasharray:
  2711. case CSSPropertyStrokeDashoffset:
  2712. case CSSPropertyStrokeLinecap:
  2713. case CSSPropertyStrokeLinejoin:
  2714. case CSSPropertyStrokeMiterlimit:
  2715. case CSSPropertyStrokeOpacity:
  2716. case CSSPropertyStrokeWidth:
  2717. case CSSPropertyAlignmentBaseline:
  2718. case CSSPropertyBaselineShift:
  2719. case CSSPropertyDominantBaseline:
  2720. case CSSPropertyGlyphOrientationHorizontal:
  2721. case CSSPropertyGlyphOrientationVertical:
  2722. case CSSPropertyKerning:
  2723. case CSSPropertyTextAnchor:
  2724. case CSSPropertyVectorEffect:
  2725. case CSSPropertyWritingMode:
  2726. case CSSPropertyWebkitSvgShadow:
  2727. return svgPropertyValue(propertyID, DoNotUpdateLayout);
  2728. #endif
  2729. }
  2730. logUnimplementedPropertyID(propertyID);
  2731. return 0;
  2732. }
  2733. String CSSComputedStyleDeclaration::getPropertyValue(CSSPropertyID propertyID) const
  2734. {
  2735. RefPtr<CSSValue> value = getPropertyCSSValue(propertyID);
  2736. if (value)
  2737. return value->cssText();
  2738. return "";
  2739. }
  2740. unsigned CSSComputedStyleDeclaration::length() const
  2741. {
  2742. Node* node = m_node.get();
  2743. if (!node)
  2744. return 0;
  2745. RenderStyle* style = node->computedStyle(m_pseudoElementSpecifier);
  2746. if (!style)
  2747. return 0;
  2748. return numComputedProperties;
  2749. }
  2750. String CSSComputedStyleDeclaration::item(unsigned i) const
  2751. {
  2752. if (i >= length())
  2753. return "";
  2754. return getPropertyNameString(computedProperties[i]);
  2755. }
  2756. bool ComputedStyleExtractor::propertyMatches(CSSPropertyID propertyID, const CSSValue* value) const
  2757. {
  2758. if (propertyID == CSSPropertyFontSize && value->isPrimitiveValue() && m_node) {
  2759. m_node->document()->updateLayoutIgnorePendingStylesheets();
  2760. RenderStyle* style = m_node->computedStyle(m_pseudoElementSpecifier);
  2761. if (style && style->fontDescription().keywordSize()) {
  2762. int sizeValue = cssIdentifierForFontSizeKeyword(style->fontDescription().keywordSize());
  2763. const CSSPrimitiveValue* primitiveValue = static_cast<const CSSPrimitiveValue*>(value);
  2764. if (primitiveValue->isIdent() && primitiveValue->getIdent() == sizeValue)
  2765. return true;
  2766. }
  2767. }
  2768. RefPtr<CSSValue> computedValue = propertyValue(propertyID);
  2769. return computedValue && value && computedValue->equals(*value);
  2770. }
  2771. PassRefPtr<MutableStylePropertySet> ComputedStyleExtractor::copyProperties() const
  2772. {
  2773. return copyPropertiesInSet(computedProperties, numComputedProperties);
  2774. }
  2775. PassRefPtr<CSSValueList> ComputedStyleExtractor::getCSSPropertyValuesForShorthandProperties(const StylePropertyShorthand& shorthand) const
  2776. {
  2777. RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
  2778. for (size_t i = 0; i < shorthand.length(); ++i) {
  2779. RefPtr<CSSValue> value = propertyValue(shorthand.properties()[i], DoNotUpdateLayout);
  2780. list->append(value);
  2781. }
  2782. return list.release();
  2783. }
  2784. PassRefPtr<CSSValueList> ComputedStyleExtractor::getCSSPropertyValuesForSidesShorthand(const StylePropertyShorthand& shorthand) const
  2785. {
  2786. RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
  2787. // Assume the properties are in the usual order top, right, bottom, left.
  2788. RefPtr<CSSValue> topValue = propertyValue(shorthand.properties()[0], DoNotUpdateLayout);
  2789. RefPtr<CSSValue> rightValue = propertyValue(shorthand.properties()[1], DoNotUpdateLayout);
  2790. RefPtr<CSSValue> bottomValue = propertyValue(shorthand.properties()[2], DoNotUpdateLayout);
  2791. RefPtr<CSSValue> leftValue = propertyValue(shorthand.properties()[3], DoNotUpdateLayout);
  2792. // All 4 properties must be specified.
  2793. if (!topValue || !rightValue || !bottomValue || !leftValue)
  2794. return 0;
  2795. bool showLeft = !compareCSSValuePtr(rightValue, leftValue);
  2796. bool showBottom = !compareCSSValuePtr(topValue, bottomValue) || showLeft;
  2797. bool showRight = !compareCSSValuePtr(topValue, rightValue) || showBottom;
  2798. list->append(topValue.release());
  2799. if (showRight)
  2800. list->append(rightValue.release());
  2801. if (showBottom)
  2802. list->append(bottomValue.release());
  2803. if (showLeft)
  2804. list->append(leftValue.release());
  2805. return list.release();
  2806. }
  2807. PassRefPtr<CSSValueList> ComputedStyleExtractor::getCSSPropertyValuesForGridShorthand(const StylePropertyShorthand& shorthand) const
  2808. {
  2809. RefPtr<CSSValueList> list = CSSValueList::createSlashSeparated();
  2810. for (size_t i = 0; i < shorthand.length(); ++i) {
  2811. RefPtr<CSSValue> value = propertyValue(shorthand.properties()[i], DoNotUpdateLayout);
  2812. list->append(value.release());
  2813. }
  2814. return list.release();
  2815. }
  2816. PassRefPtr<MutableStylePropertySet> ComputedStyleExtractor::copyPropertiesInSet(const CSSPropertyID* set, unsigned length) const
  2817. {
  2818. Vector<CSSProperty, 256> list;
  2819. list.reserveInitialCapacity(length);
  2820. for (unsigned i = 0; i < length; ++i) {
  2821. RefPtr<CSSValue> value = propertyValue(set[i]);
  2822. if (value)
  2823. list.append(CSSProperty(set[i], value.release(), false));
  2824. }
  2825. return MutableStylePropertySet::create(list.data(), list.size());
  2826. }
  2827. CSSRule* CSSComputedStyleDeclaration::parentRule() const
  2828. {
  2829. return 0;
  2830. }
  2831. PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(const String& propertyName)
  2832. {
  2833. CSSPropertyID propertyID = cssPropertyID(propertyName);
  2834. if (!propertyID)
  2835. return 0;
  2836. RefPtr<CSSValue> value = getPropertyCSSValue(propertyID);
  2837. return value ? value->cloneForCSSOM() : 0;
  2838. }
  2839. String CSSComputedStyleDeclaration::getPropertyValue(const String &propertyName)
  2840. {
  2841. CSSPropertyID propertyID = cssPropertyID(propertyName);
  2842. if (!propertyID)
  2843. return String();
  2844. return getPropertyValue(propertyID);
  2845. }
  2846. String CSSComputedStyleDeclaration::getPropertyPriority(const String&)
  2847. {
  2848. // All computed styles have a priority of not "important".
  2849. return "";
  2850. }
  2851. String CSSComputedStyleDeclaration::getPropertyShorthand(const String&)
  2852. {
  2853. return "";
  2854. }
  2855. bool CSSComputedStyleDeclaration::isPropertyImplicit(const String&)
  2856. {
  2857. return false;
  2858. }
  2859. void CSSComputedStyleDeclaration::setProperty(const String&, const String&, const String&, ExceptionCode& ec)
  2860. {
  2861. ec = NO_MODIFICATION_ALLOWED_ERR;
  2862. }
  2863. String CSSComputedStyleDeclaration::removeProperty(const String&, ExceptionCode& ec)
  2864. {
  2865. ec = NO_MODIFICATION_ALLOWED_ERR;
  2866. return String();
  2867. }
  2868. PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValueInternal(CSSPropertyID propertyID)
  2869. {
  2870. return getPropertyCSSValue(propertyID);
  2871. }
  2872. String CSSComputedStyleDeclaration::getPropertyValueInternal(CSSPropertyID propertyID)
  2873. {
  2874. return getPropertyValue(propertyID);
  2875. }
  2876. void CSSComputedStyleDeclaration::setPropertyInternal(CSSPropertyID, const String&, bool, ExceptionCode& ec)
  2877. {
  2878. ec = NO_MODIFICATION_ALLOWED_ERR;
  2879. }
  2880. PassRefPtr<CSSValueList> ComputedStyleExtractor::getBackgroundShorthandValue() const
  2881. {
  2882. static const CSSPropertyID propertiesBeforeSlashSeperator[5] = { CSSPropertyBackgroundColor, CSSPropertyBackgroundImage,
  2883. CSSPropertyBackgroundRepeat, CSSPropertyBackgroundAttachment,
  2884. CSSPropertyBackgroundPosition };
  2885. static const CSSPropertyID propertiesAfterSlashSeperator[3] = { CSSPropertyBackgroundSize, CSSPropertyBackgroundOrigin,
  2886. CSSPropertyBackgroundClip };
  2887. RefPtr<CSSValueList> list = CSSValueList::createSlashSeparated();
  2888. list->append(getCSSPropertyValuesForShorthandProperties(StylePropertyShorthand(propertiesBeforeSlashSeperator, WTF_ARRAY_LENGTH(propertiesBeforeSlashSeperator))));
  2889. list->append(getCSSPropertyValuesForShorthandProperties(StylePropertyShorthand(propertiesAfterSlashSeperator, WTF_ARRAY_LENGTH(propertiesAfterSlashSeperator))));
  2890. return list.release();
  2891. }
  2892. } // namespace WebCore