worker-css.js 307 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000
  1. "no use strict";
  2. !(function(window) {
  3. if (typeof window.window != "undefined" && window.document)
  4. return;
  5. if (window.require && window.define)
  6. return;
  7. if (!window.console) {
  8. window.console = function() {
  9. var msgs = Array.prototype.slice.call(arguments, 0);
  10. postMessage({type: "log", data: msgs});
  11. };
  12. window.console.error =
  13. window.console.warn =
  14. window.console.log =
  15. window.console.trace = window.console;
  16. }
  17. window.window = window;
  18. window.ace = window;
  19. window.onerror = function(message, file, line, col, err) {
  20. postMessage({type: "error", data: {
  21. message: message,
  22. data: err.data,
  23. file: file,
  24. line: line,
  25. col: col,
  26. stack: err.stack
  27. }});
  28. };
  29. window.normalizeModule = function(parentId, moduleName) {
  30. // normalize plugin requires
  31. if (moduleName.indexOf("!") !== -1) {
  32. var chunks = moduleName.split("!");
  33. return window.normalizeModule(parentId, chunks[0]) + "!" + window.normalizeModule(parentId, chunks[1]);
  34. }
  35. // normalize relative requires
  36. if (moduleName.charAt(0) == ".") {
  37. var base = parentId.split("/").slice(0, -1).join("/");
  38. moduleName = (base ? base + "/" : "") + moduleName;
  39. while (moduleName.indexOf(".") !== -1 && previous != moduleName) {
  40. var previous = moduleName;
  41. moduleName = moduleName.replace(/^\.\//, "").replace(/\/\.\//, "/").replace(/[^\/]+\/\.\.\//, "");
  42. }
  43. }
  44. return moduleName;
  45. };
  46. window.require = function require(parentId, id) {
  47. if (!id) {
  48. id = parentId;
  49. parentId = null;
  50. }
  51. if (!id.charAt)
  52. throw new Error("worker.js require() accepts only (parentId, id) as arguments");
  53. id = window.normalizeModule(parentId, id);
  54. var module = window.require.modules[id];
  55. if (module) {
  56. if (!module.initialized) {
  57. module.initialized = true;
  58. module.exports = module.factory().exports;
  59. }
  60. return module.exports;
  61. }
  62. if (!window.require.tlns)
  63. return console.log("unable to load " + id);
  64. var path = resolveModuleId(id, window.require.tlns);
  65. if (path.slice(-3) != ".js") path += ".js";
  66. window.require.id = id;
  67. window.require.modules[id] = {}; // prevent infinite loop on broken modules
  68. importScripts(path);
  69. return window.require(parentId, id);
  70. };
  71. function resolveModuleId(id, paths) {
  72. var testPath = id, tail = "";
  73. while (testPath) {
  74. var alias = paths[testPath];
  75. if (typeof alias == "string") {
  76. return alias + tail;
  77. } else if (alias) {
  78. return alias.location.replace(/\/*$/, "/") + (tail || alias.main || alias.name);
  79. } else if (alias === false) {
  80. return "";
  81. }
  82. var i = testPath.lastIndexOf("/");
  83. if (i === -1) break;
  84. tail = testPath.substr(i) + tail;
  85. testPath = testPath.slice(0, i);
  86. }
  87. return id;
  88. }
  89. window.require.modules = {};
  90. window.require.tlns = {};
  91. window.define = function(id, deps, factory) {
  92. if (arguments.length == 2) {
  93. factory = deps;
  94. if (typeof id != "string") {
  95. deps = id;
  96. id = window.require.id;
  97. }
  98. } else if (arguments.length == 1) {
  99. factory = id;
  100. deps = [];
  101. id = window.require.id;
  102. }
  103. if (typeof factory != "function") {
  104. window.require.modules[id] = {
  105. exports: factory,
  106. initialized: true
  107. };
  108. return;
  109. }
  110. if (!deps.length)
  111. // If there is no dependencies, we inject "require", "exports" and
  112. // "module" as dependencies, to provide CommonJS compatibility.
  113. deps = ["require", "exports", "module"];
  114. var req = function(childId) {
  115. return window.require(id, childId);
  116. };
  117. window.require.modules[id] = {
  118. exports: {},
  119. factory: function() {
  120. var module = this;
  121. var returnExports = factory.apply(this, deps.slice(0, factory.length).map(function(dep) {
  122. switch (dep) {
  123. // Because "require", "exports" and "module" aren't actual
  124. // dependencies, we must handle them seperately.
  125. case "require": return req;
  126. case "exports": return module.exports;
  127. case "module": return module;
  128. // But for all other dependencies, we can just go ahead and
  129. // require them.
  130. default: return req(dep);
  131. }
  132. }));
  133. if (returnExports)
  134. module.exports = returnExports;
  135. return module;
  136. }
  137. };
  138. };
  139. window.define.amd = {};
  140. require.tlns = {};
  141. window.initBaseUrls = function initBaseUrls(topLevelNamespaces) {
  142. for (var i in topLevelNamespaces)
  143. require.tlns[i] = topLevelNamespaces[i];
  144. };
  145. window.initSender = function initSender() {
  146. var EventEmitter = window.require("ace/lib/event_emitter").EventEmitter;
  147. var oop = window.require("ace/lib/oop");
  148. var Sender = function() {};
  149. (function() {
  150. oop.implement(this, EventEmitter);
  151. this.callback = function(data, callbackId) {
  152. postMessage({
  153. type: "call",
  154. id: callbackId,
  155. data: data
  156. });
  157. };
  158. this.emit = function(name, data) {
  159. postMessage({
  160. type: "event",
  161. name: name,
  162. data: data
  163. });
  164. };
  165. }).call(Sender.prototype);
  166. return new Sender();
  167. };
  168. var main = window.main = null;
  169. var sender = window.sender = null;
  170. window.onmessage = function(e) {
  171. var msg = e.data;
  172. if (msg.event && sender) {
  173. sender._signal(msg.event, msg.data);
  174. }
  175. else if (msg.command) {
  176. if (main[msg.command])
  177. main[msg.command].apply(main, msg.args);
  178. else if (window[msg.command])
  179. window[msg.command].apply(window, msg.args);
  180. else
  181. throw new Error("Unknown command:" + msg.command);
  182. }
  183. else if (msg.init) {
  184. window.initBaseUrls(msg.tlns);
  185. sender = window.sender = window.initSender();
  186. var clazz = require(msg.module)[msg.classname];
  187. main = window.main = new clazz(sender);
  188. }
  189. };
  190. })(this);
  191. define("ace/lib/oop",[], function(require, exports, module) {
  192. "use strict";
  193. exports.inherits = function(ctor, superCtor) {
  194. ctor.super_ = superCtor;
  195. ctor.prototype = Object.create(superCtor.prototype, {
  196. constructor: {
  197. value: ctor,
  198. enumerable: false,
  199. writable: true,
  200. configurable: true
  201. }
  202. });
  203. };
  204. exports.mixin = function(obj, mixin) {
  205. for (var key in mixin) {
  206. obj[key] = mixin[key];
  207. }
  208. return obj;
  209. };
  210. exports.implement = function(proto, mixin) {
  211. exports.mixin(proto, mixin);
  212. };
  213. });
  214. define("ace/lib/lang",[], function(require, exports, module) {
  215. "use strict";
  216. exports.last = function(a) {
  217. return a[a.length - 1];
  218. };
  219. exports.stringReverse = function(string) {
  220. return string.split("").reverse().join("");
  221. };
  222. exports.stringRepeat = function (string, count) {
  223. var result = '';
  224. while (count > 0) {
  225. if (count & 1)
  226. result += string;
  227. if (count >>= 1)
  228. string += string;
  229. }
  230. return result;
  231. };
  232. var trimBeginRegexp = /^\s\s*/;
  233. var trimEndRegexp = /\s\s*$/;
  234. exports.stringTrimLeft = function (string) {
  235. return string.replace(trimBeginRegexp, '');
  236. };
  237. exports.stringTrimRight = function (string) {
  238. return string.replace(trimEndRegexp, '');
  239. };
  240. exports.copyObject = function(obj) {
  241. var copy = {};
  242. for (var key in obj) {
  243. copy[key] = obj[key];
  244. }
  245. return copy;
  246. };
  247. exports.copyArray = function(array){
  248. var copy = [];
  249. for (var i=0, l=array.length; i<l; i++) {
  250. if (array[i] && typeof array[i] == "object")
  251. copy[i] = this.copyObject(array[i]);
  252. else
  253. copy[i] = array[i];
  254. }
  255. return copy;
  256. };
  257. exports.deepCopy = function deepCopy(obj) {
  258. if (typeof obj !== "object" || !obj)
  259. return obj;
  260. var copy;
  261. if (Array.isArray(obj)) {
  262. copy = [];
  263. for (var key = 0; key < obj.length; key++) {
  264. copy[key] = deepCopy(obj[key]);
  265. }
  266. return copy;
  267. }
  268. if (Object.prototype.toString.call(obj) !== "[object Object]")
  269. return obj;
  270. copy = {};
  271. for (var key in obj)
  272. copy[key] = deepCopy(obj[key]);
  273. return copy;
  274. };
  275. exports.arrayToMap = function(arr) {
  276. var map = {};
  277. for (var i=0; i<arr.length; i++) {
  278. map[arr[i]] = 1;
  279. }
  280. return map;
  281. };
  282. exports.createMap = function(props) {
  283. var map = Object.create(null);
  284. for (var i in props) {
  285. map[i] = props[i];
  286. }
  287. return map;
  288. };
  289. exports.arrayRemove = function(array, value) {
  290. for (var i = 0; i <= array.length; i++) {
  291. if (value === array[i]) {
  292. array.splice(i, 1);
  293. }
  294. }
  295. };
  296. exports.escapeRegExp = function(str) {
  297. return str.replace(/([.*+?^${}()|[\]\/\\])/g, '\\$1');
  298. };
  299. exports.escapeHTML = function(str) {
  300. return ("" + str).replace(/&/g, "&#38;").replace(/"/g, "&#34;").replace(/'/g, "&#39;").replace(/</g, "&#60;");
  301. };
  302. exports.getMatchOffsets = function(string, regExp) {
  303. var matches = [];
  304. string.replace(regExp, function(str) {
  305. matches.push({
  306. offset: arguments[arguments.length-2],
  307. length: str.length
  308. });
  309. });
  310. return matches;
  311. };
  312. exports.deferredCall = function(fcn) {
  313. var timer = null;
  314. var callback = function() {
  315. timer = null;
  316. fcn();
  317. };
  318. var deferred = function(timeout) {
  319. deferred.cancel();
  320. timer = setTimeout(callback, timeout || 0);
  321. return deferred;
  322. };
  323. deferred.schedule = deferred;
  324. deferred.call = function() {
  325. this.cancel();
  326. fcn();
  327. return deferred;
  328. };
  329. deferred.cancel = function() {
  330. clearTimeout(timer);
  331. timer = null;
  332. return deferred;
  333. };
  334. deferred.isPending = function() {
  335. return timer;
  336. };
  337. return deferred;
  338. };
  339. exports.delayedCall = function(fcn, defaultTimeout) {
  340. var timer = null;
  341. var callback = function() {
  342. timer = null;
  343. fcn();
  344. };
  345. var _self = function(timeout) {
  346. if (timer == null)
  347. timer = setTimeout(callback, timeout || defaultTimeout);
  348. };
  349. _self.delay = function(timeout) {
  350. timer && clearTimeout(timer);
  351. timer = setTimeout(callback, timeout || defaultTimeout);
  352. };
  353. _self.schedule = _self;
  354. _self.call = function() {
  355. this.cancel();
  356. fcn();
  357. };
  358. _self.cancel = function() {
  359. timer && clearTimeout(timer);
  360. timer = null;
  361. };
  362. _self.isPending = function() {
  363. return timer;
  364. };
  365. return _self;
  366. };
  367. });
  368. define("ace/range",[], function(require, exports, module) {
  369. "use strict";
  370. var comparePoints = function(p1, p2) {
  371. return p1.row - p2.row || p1.column - p2.column;
  372. };
  373. var Range = function(startRow, startColumn, endRow, endColumn) {
  374. this.start = {
  375. row: startRow,
  376. column: startColumn
  377. };
  378. this.end = {
  379. row: endRow,
  380. column: endColumn
  381. };
  382. };
  383. (function() {
  384. this.isEqual = function(range) {
  385. return this.start.row === range.start.row &&
  386. this.end.row === range.end.row &&
  387. this.start.column === range.start.column &&
  388. this.end.column === range.end.column;
  389. };
  390. this.toString = function() {
  391. return ("Range: [" + this.start.row + "/" + this.start.column +
  392. "] -> [" + this.end.row + "/" + this.end.column + "]");
  393. };
  394. this.contains = function(row, column) {
  395. return this.compare(row, column) == 0;
  396. };
  397. this.compareRange = function(range) {
  398. var cmp,
  399. end = range.end,
  400. start = range.start;
  401. cmp = this.compare(end.row, end.column);
  402. if (cmp == 1) {
  403. cmp = this.compare(start.row, start.column);
  404. if (cmp == 1) {
  405. return 2;
  406. } else if (cmp == 0) {
  407. return 1;
  408. } else {
  409. return 0;
  410. }
  411. } else if (cmp == -1) {
  412. return -2;
  413. } else {
  414. cmp = this.compare(start.row, start.column);
  415. if (cmp == -1) {
  416. return -1;
  417. } else if (cmp == 1) {
  418. return 42;
  419. } else {
  420. return 0;
  421. }
  422. }
  423. };
  424. this.comparePoint = function(p) {
  425. return this.compare(p.row, p.column);
  426. };
  427. this.containsRange = function(range) {
  428. return this.comparePoint(range.start) == 0 && this.comparePoint(range.end) == 0;
  429. };
  430. this.intersects = function(range) {
  431. var cmp = this.compareRange(range);
  432. return (cmp == -1 || cmp == 0 || cmp == 1);
  433. };
  434. this.isEnd = function(row, column) {
  435. return this.end.row == row && this.end.column == column;
  436. };
  437. this.isStart = function(row, column) {
  438. return this.start.row == row && this.start.column == column;
  439. };
  440. this.setStart = function(row, column) {
  441. if (typeof row == "object") {
  442. this.start.column = row.column;
  443. this.start.row = row.row;
  444. } else {
  445. this.start.row = row;
  446. this.start.column = column;
  447. }
  448. };
  449. this.setEnd = function(row, column) {
  450. if (typeof row == "object") {
  451. this.end.column = row.column;
  452. this.end.row = row.row;
  453. } else {
  454. this.end.row = row;
  455. this.end.column = column;
  456. }
  457. };
  458. this.inside = function(row, column) {
  459. if (this.compare(row, column) == 0) {
  460. if (this.isEnd(row, column) || this.isStart(row, column)) {
  461. return false;
  462. } else {
  463. return true;
  464. }
  465. }
  466. return false;
  467. };
  468. this.insideStart = function(row, column) {
  469. if (this.compare(row, column) == 0) {
  470. if (this.isEnd(row, column)) {
  471. return false;
  472. } else {
  473. return true;
  474. }
  475. }
  476. return false;
  477. };
  478. this.insideEnd = function(row, column) {
  479. if (this.compare(row, column) == 0) {
  480. if (this.isStart(row, column)) {
  481. return false;
  482. } else {
  483. return true;
  484. }
  485. }
  486. return false;
  487. };
  488. this.compare = function(row, column) {
  489. if (!this.isMultiLine()) {
  490. if (row === this.start.row) {
  491. return column < this.start.column ? -1 : (column > this.end.column ? 1 : 0);
  492. }
  493. }
  494. if (row < this.start.row)
  495. return -1;
  496. if (row > this.end.row)
  497. return 1;
  498. if (this.start.row === row)
  499. return column >= this.start.column ? 0 : -1;
  500. if (this.end.row === row)
  501. return column <= this.end.column ? 0 : 1;
  502. return 0;
  503. };
  504. this.compareStart = function(row, column) {
  505. if (this.start.row == row && this.start.column == column) {
  506. return -1;
  507. } else {
  508. return this.compare(row, column);
  509. }
  510. };
  511. this.compareEnd = function(row, column) {
  512. if (this.end.row == row && this.end.column == column) {
  513. return 1;
  514. } else {
  515. return this.compare(row, column);
  516. }
  517. };
  518. this.compareInside = function(row, column) {
  519. if (this.end.row == row && this.end.column == column) {
  520. return 1;
  521. } else if (this.start.row == row && this.start.column == column) {
  522. return -1;
  523. } else {
  524. return this.compare(row, column);
  525. }
  526. };
  527. this.clipRows = function(firstRow, lastRow) {
  528. if (this.end.row > lastRow)
  529. var end = {row: lastRow + 1, column: 0};
  530. else if (this.end.row < firstRow)
  531. var end = {row: firstRow, column: 0};
  532. if (this.start.row > lastRow)
  533. var start = {row: lastRow + 1, column: 0};
  534. else if (this.start.row < firstRow)
  535. var start = {row: firstRow, column: 0};
  536. return Range.fromPoints(start || this.start, end || this.end);
  537. };
  538. this.extend = function(row, column) {
  539. var cmp = this.compare(row, column);
  540. if (cmp == 0)
  541. return this;
  542. else if (cmp == -1)
  543. var start = {row: row, column: column};
  544. else
  545. var end = {row: row, column: column};
  546. return Range.fromPoints(start || this.start, end || this.end);
  547. };
  548. this.isEmpty = function() {
  549. return (this.start.row === this.end.row && this.start.column === this.end.column);
  550. };
  551. this.isMultiLine = function() {
  552. return (this.start.row !== this.end.row);
  553. };
  554. this.clone = function() {
  555. return Range.fromPoints(this.start, this.end);
  556. };
  557. this.collapseRows = function() {
  558. if (this.end.column == 0)
  559. return new Range(this.start.row, 0, Math.max(this.start.row, this.end.row-1), 0);
  560. else
  561. return new Range(this.start.row, 0, this.end.row, 0);
  562. };
  563. this.toScreenRange = function(session) {
  564. var screenPosStart = session.documentToScreenPosition(this.start);
  565. var screenPosEnd = session.documentToScreenPosition(this.end);
  566. return new Range(
  567. screenPosStart.row, screenPosStart.column,
  568. screenPosEnd.row, screenPosEnd.column
  569. );
  570. };
  571. this.moveBy = function(row, column) {
  572. this.start.row += row;
  573. this.start.column += column;
  574. this.end.row += row;
  575. this.end.column += column;
  576. };
  577. }).call(Range.prototype);
  578. Range.fromPoints = function(start, end) {
  579. return new Range(start.row, start.column, end.row, end.column);
  580. };
  581. Range.comparePoints = comparePoints;
  582. Range.comparePoints = function(p1, p2) {
  583. return p1.row - p2.row || p1.column - p2.column;
  584. };
  585. exports.Range = Range;
  586. });
  587. define("ace/apply_delta",[], function(require, exports, module) {
  588. "use strict";
  589. function throwDeltaError(delta, errorText){
  590. console.log("Invalid Delta:", delta);
  591. throw "Invalid Delta: " + errorText;
  592. }
  593. function positionInDocument(docLines, position) {
  594. return position.row >= 0 && position.row < docLines.length &&
  595. position.column >= 0 && position.column <= docLines[position.row].length;
  596. }
  597. function validateDelta(docLines, delta) {
  598. if (delta.action != "insert" && delta.action != "remove")
  599. throwDeltaError(delta, "delta.action must be 'insert' or 'remove'");
  600. if (!(delta.lines instanceof Array))
  601. throwDeltaError(delta, "delta.lines must be an Array");
  602. if (!delta.start || !delta.end)
  603. throwDeltaError(delta, "delta.start/end must be an present");
  604. var start = delta.start;
  605. if (!positionInDocument(docLines, delta.start))
  606. throwDeltaError(delta, "delta.start must be contained in document");
  607. var end = delta.end;
  608. if (delta.action == "remove" && !positionInDocument(docLines, end))
  609. throwDeltaError(delta, "delta.end must contained in document for 'remove' actions");
  610. var numRangeRows = end.row - start.row;
  611. var numRangeLastLineChars = (end.column - (numRangeRows == 0 ? start.column : 0));
  612. if (numRangeRows != delta.lines.length - 1 || delta.lines[numRangeRows].length != numRangeLastLineChars)
  613. throwDeltaError(delta, "delta.range must match delta lines");
  614. }
  615. exports.applyDelta = function(docLines, delta, doNotValidate) {
  616. var row = delta.start.row;
  617. var startColumn = delta.start.column;
  618. var line = docLines[row] || "";
  619. switch (delta.action) {
  620. case "insert":
  621. var lines = delta.lines;
  622. if (lines.length === 1) {
  623. docLines[row] = line.substring(0, startColumn) + delta.lines[0] + line.substring(startColumn);
  624. } else {
  625. var args = [row, 1].concat(delta.lines);
  626. docLines.splice.apply(docLines, args);
  627. docLines[row] = line.substring(0, startColumn) + docLines[row];
  628. docLines[row + delta.lines.length - 1] += line.substring(startColumn);
  629. }
  630. break;
  631. case "remove":
  632. var endColumn = delta.end.column;
  633. var endRow = delta.end.row;
  634. if (row === endRow) {
  635. docLines[row] = line.substring(0, startColumn) + line.substring(endColumn);
  636. } else {
  637. docLines.splice(
  638. row, endRow - row + 1,
  639. line.substring(0, startColumn) + docLines[endRow].substring(endColumn)
  640. );
  641. }
  642. break;
  643. }
  644. };
  645. });
  646. define("ace/lib/event_emitter",[], function(require, exports, module) {
  647. "use strict";
  648. var EventEmitter = {};
  649. var stopPropagation = function() { this.propagationStopped = true; };
  650. var preventDefault = function() { this.defaultPrevented = true; };
  651. EventEmitter._emit =
  652. EventEmitter._dispatchEvent = function(eventName, e) {
  653. this._eventRegistry || (this._eventRegistry = {});
  654. this._defaultHandlers || (this._defaultHandlers = {});
  655. var listeners = this._eventRegistry[eventName] || [];
  656. var defaultHandler = this._defaultHandlers[eventName];
  657. if (!listeners.length && !defaultHandler)
  658. return;
  659. if (typeof e != "object" || !e)
  660. e = {};
  661. if (!e.type)
  662. e.type = eventName;
  663. if (!e.stopPropagation)
  664. e.stopPropagation = stopPropagation;
  665. if (!e.preventDefault)
  666. e.preventDefault = preventDefault;
  667. listeners = listeners.slice();
  668. for (var i=0; i<listeners.length; i++) {
  669. listeners[i](e, this);
  670. if (e.propagationStopped)
  671. break;
  672. }
  673. if (defaultHandler && !e.defaultPrevented)
  674. return defaultHandler(e, this);
  675. };
  676. EventEmitter._signal = function(eventName, e) {
  677. var listeners = (this._eventRegistry || {})[eventName];
  678. if (!listeners)
  679. return;
  680. listeners = listeners.slice();
  681. for (var i=0; i<listeners.length; i++)
  682. listeners[i](e, this);
  683. };
  684. EventEmitter.once = function(eventName, callback) {
  685. var _self = this;
  686. this.on(eventName, function newCallback() {
  687. _self.off(eventName, newCallback);
  688. callback.apply(null, arguments);
  689. });
  690. if (!callback) {
  691. return new Promise(function(resolve) {
  692. callback = resolve;
  693. });
  694. }
  695. };
  696. EventEmitter.setDefaultHandler = function(eventName, callback) {
  697. var handlers = this._defaultHandlers;
  698. if (!handlers)
  699. handlers = this._defaultHandlers = {_disabled_: {}};
  700. if (handlers[eventName]) {
  701. var old = handlers[eventName];
  702. var disabled = handlers._disabled_[eventName];
  703. if (!disabled)
  704. handlers._disabled_[eventName] = disabled = [];
  705. disabled.push(old);
  706. var i = disabled.indexOf(callback);
  707. if (i != -1)
  708. disabled.splice(i, 1);
  709. }
  710. handlers[eventName] = callback;
  711. };
  712. EventEmitter.removeDefaultHandler = function(eventName, callback) {
  713. var handlers = this._defaultHandlers;
  714. if (!handlers)
  715. return;
  716. var disabled = handlers._disabled_[eventName];
  717. if (handlers[eventName] == callback) {
  718. if (disabled)
  719. this.setDefaultHandler(eventName, disabled.pop());
  720. } else if (disabled) {
  721. var i = disabled.indexOf(callback);
  722. if (i != -1)
  723. disabled.splice(i, 1);
  724. }
  725. };
  726. EventEmitter.on =
  727. EventEmitter.addEventListener = function(eventName, callback, capturing) {
  728. this._eventRegistry = this._eventRegistry || {};
  729. var listeners = this._eventRegistry[eventName];
  730. if (!listeners)
  731. listeners = this._eventRegistry[eventName] = [];
  732. if (listeners.indexOf(callback) == -1)
  733. listeners[capturing ? "unshift" : "push"](callback);
  734. return callback;
  735. };
  736. EventEmitter.off =
  737. EventEmitter.removeListener =
  738. EventEmitter.removeEventListener = function(eventName, callback) {
  739. this._eventRegistry = this._eventRegistry || {};
  740. var listeners = this._eventRegistry[eventName];
  741. if (!listeners)
  742. return;
  743. var index = listeners.indexOf(callback);
  744. if (index !== -1)
  745. listeners.splice(index, 1);
  746. };
  747. EventEmitter.removeAllListeners = function(eventName) {
  748. if (!eventName) this._eventRegistry = this._defaultHandlers = undefined;
  749. if (this._eventRegistry) this._eventRegistry[eventName] = undefined;
  750. if (this._defaultHandlers) this._defaultHandlers[eventName] = undefined;
  751. };
  752. exports.EventEmitter = EventEmitter;
  753. });
  754. define("ace/anchor",[], function(require, exports, module) {
  755. "use strict";
  756. var oop = require("./lib/oop");
  757. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  758. var Anchor = exports.Anchor = function(doc, row, column) {
  759. this.$onChange = this.onChange.bind(this);
  760. this.attach(doc);
  761. if (typeof column == "undefined")
  762. this.setPosition(row.row, row.column);
  763. else
  764. this.setPosition(row, column);
  765. };
  766. (function() {
  767. oop.implement(this, EventEmitter);
  768. this.getPosition = function() {
  769. return this.$clipPositionToDocument(this.row, this.column);
  770. };
  771. this.getDocument = function() {
  772. return this.document;
  773. };
  774. this.$insertRight = false;
  775. this.onChange = function(delta) {
  776. if (delta.start.row == delta.end.row && delta.start.row != this.row)
  777. return;
  778. if (delta.start.row > this.row)
  779. return;
  780. var point = $getTransformedPoint(delta, {row: this.row, column: this.column}, this.$insertRight);
  781. this.setPosition(point.row, point.column, true);
  782. };
  783. function $pointsInOrder(point1, point2, equalPointsInOrder) {
  784. var bColIsAfter = equalPointsInOrder ? point1.column <= point2.column : point1.column < point2.column;
  785. return (point1.row < point2.row) || (point1.row == point2.row && bColIsAfter);
  786. }
  787. function $getTransformedPoint(delta, point, moveIfEqual) {
  788. var deltaIsInsert = delta.action == "insert";
  789. var deltaRowShift = (deltaIsInsert ? 1 : -1) * (delta.end.row - delta.start.row);
  790. var deltaColShift = (deltaIsInsert ? 1 : -1) * (delta.end.column - delta.start.column);
  791. var deltaStart = delta.start;
  792. var deltaEnd = deltaIsInsert ? deltaStart : delta.end; // Collapse insert range.
  793. if ($pointsInOrder(point, deltaStart, moveIfEqual)) {
  794. return {
  795. row: point.row,
  796. column: point.column
  797. };
  798. }
  799. if ($pointsInOrder(deltaEnd, point, !moveIfEqual)) {
  800. return {
  801. row: point.row + deltaRowShift,
  802. column: point.column + (point.row == deltaEnd.row ? deltaColShift : 0)
  803. };
  804. }
  805. return {
  806. row: deltaStart.row,
  807. column: deltaStart.column
  808. };
  809. }
  810. this.setPosition = function(row, column, noClip) {
  811. var pos;
  812. if (noClip) {
  813. pos = {
  814. row: row,
  815. column: column
  816. };
  817. } else {
  818. pos = this.$clipPositionToDocument(row, column);
  819. }
  820. if (this.row == pos.row && this.column == pos.column)
  821. return;
  822. var old = {
  823. row: this.row,
  824. column: this.column
  825. };
  826. this.row = pos.row;
  827. this.column = pos.column;
  828. this._signal("change", {
  829. old: old,
  830. value: pos
  831. });
  832. };
  833. this.detach = function() {
  834. this.document.off("change", this.$onChange);
  835. };
  836. this.attach = function(doc) {
  837. this.document = doc || this.document;
  838. this.document.on("change", this.$onChange);
  839. };
  840. this.$clipPositionToDocument = function(row, column) {
  841. var pos = {};
  842. if (row >= this.document.getLength()) {
  843. pos.row = Math.max(0, this.document.getLength() - 1);
  844. pos.column = this.document.getLine(pos.row).length;
  845. }
  846. else if (row < 0) {
  847. pos.row = 0;
  848. pos.column = 0;
  849. }
  850. else {
  851. pos.row = row;
  852. pos.column = Math.min(this.document.getLine(pos.row).length, Math.max(0, column));
  853. }
  854. if (column < 0)
  855. pos.column = 0;
  856. return pos;
  857. };
  858. }).call(Anchor.prototype);
  859. });
  860. define("ace/document",[], function(require, exports, module) {
  861. "use strict";
  862. var oop = require("./lib/oop");
  863. var applyDelta = require("./apply_delta").applyDelta;
  864. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  865. var Range = require("./range").Range;
  866. var Anchor = require("./anchor").Anchor;
  867. var Document = function(textOrLines) {
  868. this.$lines = [""];
  869. if (textOrLines.length === 0) {
  870. this.$lines = [""];
  871. } else if (Array.isArray(textOrLines)) {
  872. this.insertMergedLines({row: 0, column: 0}, textOrLines);
  873. } else {
  874. this.insert({row: 0, column:0}, textOrLines);
  875. }
  876. };
  877. (function() {
  878. oop.implement(this, EventEmitter);
  879. this.setValue = function(text) {
  880. var len = this.getLength() - 1;
  881. this.remove(new Range(0, 0, len, this.getLine(len).length));
  882. this.insert({row: 0, column: 0}, text);
  883. };
  884. this.getValue = function() {
  885. return this.getAllLines().join(this.getNewLineCharacter());
  886. };
  887. this.createAnchor = function(row, column) {
  888. return new Anchor(this, row, column);
  889. };
  890. if ("aaa".split(/a/).length === 0) {
  891. this.$split = function(text) {
  892. return text.replace(/\r\n|\r/g, "\n").split("\n");
  893. };
  894. } else {
  895. this.$split = function(text) {
  896. return text.split(/\r\n|\r|\n/);
  897. };
  898. }
  899. this.$detectNewLine = function(text) {
  900. var match = text.match(/^.*?(\r\n|\r|\n)/m);
  901. this.$autoNewLine = match ? match[1] : "\n";
  902. this._signal("changeNewLineMode");
  903. };
  904. this.getNewLineCharacter = function() {
  905. switch (this.$newLineMode) {
  906. case "windows":
  907. return "\r\n";
  908. case "unix":
  909. return "\n";
  910. default:
  911. return this.$autoNewLine || "\n";
  912. }
  913. };
  914. this.$autoNewLine = "";
  915. this.$newLineMode = "auto";
  916. this.setNewLineMode = function(newLineMode) {
  917. if (this.$newLineMode === newLineMode)
  918. return;
  919. this.$newLineMode = newLineMode;
  920. this._signal("changeNewLineMode");
  921. };
  922. this.getNewLineMode = function() {
  923. return this.$newLineMode;
  924. };
  925. this.isNewLine = function(text) {
  926. return (text == "\r\n" || text == "\r" || text == "\n");
  927. };
  928. this.getLine = function(row) {
  929. return this.$lines[row] || "";
  930. };
  931. this.getLines = function(firstRow, lastRow) {
  932. return this.$lines.slice(firstRow, lastRow + 1);
  933. };
  934. this.getAllLines = function() {
  935. return this.getLines(0, this.getLength());
  936. };
  937. this.getLength = function() {
  938. return this.$lines.length;
  939. };
  940. this.getTextRange = function(range) {
  941. return this.getLinesForRange(range).join(this.getNewLineCharacter());
  942. };
  943. this.getLinesForRange = function(range) {
  944. var lines;
  945. if (range.start.row === range.end.row) {
  946. lines = [this.getLine(range.start.row).substring(range.start.column, range.end.column)];
  947. } else {
  948. lines = this.getLines(range.start.row, range.end.row);
  949. lines[0] = (lines[0] || "").substring(range.start.column);
  950. var l = lines.length - 1;
  951. if (range.end.row - range.start.row == l)
  952. lines[l] = lines[l].substring(0, range.end.column);
  953. }
  954. return lines;
  955. };
  956. this.insertLines = function(row, lines) {
  957. console.warn("Use of document.insertLines is deprecated. Use the insertFullLines method instead.");
  958. return this.insertFullLines(row, lines);
  959. };
  960. this.removeLines = function(firstRow, lastRow) {
  961. console.warn("Use of document.removeLines is deprecated. Use the removeFullLines method instead.");
  962. return this.removeFullLines(firstRow, lastRow);
  963. };
  964. this.insertNewLine = function(position) {
  965. console.warn("Use of document.insertNewLine is deprecated. Use insertMergedLines(position, ['', '']) instead.");
  966. return this.insertMergedLines(position, ["", ""]);
  967. };
  968. this.insert = function(position, text) {
  969. if (this.getLength() <= 1)
  970. this.$detectNewLine(text);
  971. return this.insertMergedLines(position, this.$split(text));
  972. };
  973. this.insertInLine = function(position, text) {
  974. var start = this.clippedPos(position.row, position.column);
  975. var end = this.pos(position.row, position.column + text.length);
  976. this.applyDelta({
  977. start: start,
  978. end: end,
  979. action: "insert",
  980. lines: [text]
  981. }, true);
  982. return this.clonePos(end);
  983. };
  984. this.clippedPos = function(row, column) {
  985. var length = this.getLength();
  986. if (row === undefined) {
  987. row = length;
  988. } else if (row < 0) {
  989. row = 0;
  990. } else if (row >= length) {
  991. row = length - 1;
  992. column = undefined;
  993. }
  994. var line = this.getLine(row);
  995. if (column == undefined)
  996. column = line.length;
  997. column = Math.min(Math.max(column, 0), line.length);
  998. return {row: row, column: column};
  999. };
  1000. this.clonePos = function(pos) {
  1001. return {row: pos.row, column: pos.column};
  1002. };
  1003. this.pos = function(row, column) {
  1004. return {row: row, column: column};
  1005. };
  1006. this.$clipPosition = function(position) {
  1007. var length = this.getLength();
  1008. if (position.row >= length) {
  1009. position.row = Math.max(0, length - 1);
  1010. position.column = this.getLine(length - 1).length;
  1011. } else {
  1012. position.row = Math.max(0, position.row);
  1013. position.column = Math.min(Math.max(position.column, 0), this.getLine(position.row).length);
  1014. }
  1015. return position;
  1016. };
  1017. this.insertFullLines = function(row, lines) {
  1018. row = Math.min(Math.max(row, 0), this.getLength());
  1019. var column = 0;
  1020. if (row < this.getLength()) {
  1021. lines = lines.concat([""]);
  1022. column = 0;
  1023. } else {
  1024. lines = [""].concat(lines);
  1025. row--;
  1026. column = this.$lines[row].length;
  1027. }
  1028. this.insertMergedLines({row: row, column: column}, lines);
  1029. };
  1030. this.insertMergedLines = function(position, lines) {
  1031. var start = this.clippedPos(position.row, position.column);
  1032. var end = {
  1033. row: start.row + lines.length - 1,
  1034. column: (lines.length == 1 ? start.column : 0) + lines[lines.length - 1].length
  1035. };
  1036. this.applyDelta({
  1037. start: start,
  1038. end: end,
  1039. action: "insert",
  1040. lines: lines
  1041. });
  1042. return this.clonePos(end);
  1043. };
  1044. this.remove = function(range) {
  1045. var start = this.clippedPos(range.start.row, range.start.column);
  1046. var end = this.clippedPos(range.end.row, range.end.column);
  1047. this.applyDelta({
  1048. start: start,
  1049. end: end,
  1050. action: "remove",
  1051. lines: this.getLinesForRange({start: start, end: end})
  1052. });
  1053. return this.clonePos(start);
  1054. };
  1055. this.removeInLine = function(row, startColumn, endColumn) {
  1056. var start = this.clippedPos(row, startColumn);
  1057. var end = this.clippedPos(row, endColumn);
  1058. this.applyDelta({
  1059. start: start,
  1060. end: end,
  1061. action: "remove",
  1062. lines: this.getLinesForRange({start: start, end: end})
  1063. }, true);
  1064. return this.clonePos(start);
  1065. };
  1066. this.removeFullLines = function(firstRow, lastRow) {
  1067. firstRow = Math.min(Math.max(0, firstRow), this.getLength() - 1);
  1068. lastRow = Math.min(Math.max(0, lastRow ), this.getLength() - 1);
  1069. var deleteFirstNewLine = lastRow == this.getLength() - 1 && firstRow > 0;
  1070. var deleteLastNewLine = lastRow < this.getLength() - 1;
  1071. var startRow = ( deleteFirstNewLine ? firstRow - 1 : firstRow );
  1072. var startCol = ( deleteFirstNewLine ? this.getLine(startRow).length : 0 );
  1073. var endRow = ( deleteLastNewLine ? lastRow + 1 : lastRow );
  1074. var endCol = ( deleteLastNewLine ? 0 : this.getLine(endRow).length );
  1075. var range = new Range(startRow, startCol, endRow, endCol);
  1076. var deletedLines = this.$lines.slice(firstRow, lastRow + 1);
  1077. this.applyDelta({
  1078. start: range.start,
  1079. end: range.end,
  1080. action: "remove",
  1081. lines: this.getLinesForRange(range)
  1082. });
  1083. return deletedLines;
  1084. };
  1085. this.removeNewLine = function(row) {
  1086. if (row < this.getLength() - 1 && row >= 0) {
  1087. this.applyDelta({
  1088. start: this.pos(row, this.getLine(row).length),
  1089. end: this.pos(row + 1, 0),
  1090. action: "remove",
  1091. lines: ["", ""]
  1092. });
  1093. }
  1094. };
  1095. this.replace = function(range, text) {
  1096. if (!(range instanceof Range))
  1097. range = Range.fromPoints(range.start, range.end);
  1098. if (text.length === 0 && range.isEmpty())
  1099. return range.start;
  1100. if (text == this.getTextRange(range))
  1101. return range.end;
  1102. this.remove(range);
  1103. var end;
  1104. if (text) {
  1105. end = this.insert(range.start, text);
  1106. }
  1107. else {
  1108. end = range.start;
  1109. }
  1110. return end;
  1111. };
  1112. this.applyDeltas = function(deltas) {
  1113. for (var i=0; i<deltas.length; i++) {
  1114. this.applyDelta(deltas[i]);
  1115. }
  1116. };
  1117. this.revertDeltas = function(deltas) {
  1118. for (var i=deltas.length-1; i>=0; i--) {
  1119. this.revertDelta(deltas[i]);
  1120. }
  1121. };
  1122. this.applyDelta = function(delta, doNotValidate) {
  1123. var isInsert = delta.action == "insert";
  1124. if (isInsert ? delta.lines.length <= 1 && !delta.lines[0]
  1125. : !Range.comparePoints(delta.start, delta.end)) {
  1126. return;
  1127. }
  1128. if (isInsert && delta.lines.length > 20000) {
  1129. this.$splitAndapplyLargeDelta(delta, 20000);
  1130. }
  1131. else {
  1132. applyDelta(this.$lines, delta, doNotValidate);
  1133. this._signal("change", delta);
  1134. }
  1135. };
  1136. this.$safeApplyDelta = function(delta) {
  1137. var docLength = this.$lines.length;
  1138. if (
  1139. delta.action == "remove" && delta.start.row < docLength && delta.end.row < docLength
  1140. || delta.action == "insert" && delta.start.row <= docLength
  1141. ) {
  1142. this.applyDelta(delta);
  1143. }
  1144. };
  1145. this.$splitAndapplyLargeDelta = function(delta, MAX) {
  1146. var lines = delta.lines;
  1147. var l = lines.length - MAX + 1;
  1148. var row = delta.start.row;
  1149. var column = delta.start.column;
  1150. for (var from = 0, to = 0; from < l; from = to) {
  1151. to += MAX - 1;
  1152. var chunk = lines.slice(from, to);
  1153. chunk.push("");
  1154. this.applyDelta({
  1155. start: this.pos(row + from, column),
  1156. end: this.pos(row + to, column = 0),
  1157. action: delta.action,
  1158. lines: chunk
  1159. }, true);
  1160. }
  1161. delta.lines = lines.slice(from);
  1162. delta.start.row = row + from;
  1163. delta.start.column = column;
  1164. this.applyDelta(delta, true);
  1165. };
  1166. this.revertDelta = function(delta) {
  1167. this.$safeApplyDelta({
  1168. start: this.clonePos(delta.start),
  1169. end: this.clonePos(delta.end),
  1170. action: (delta.action == "insert" ? "remove" : "insert"),
  1171. lines: delta.lines.slice()
  1172. });
  1173. };
  1174. this.indexToPosition = function(index, startRow) {
  1175. var lines = this.$lines || this.getAllLines();
  1176. var newlineLength = this.getNewLineCharacter().length;
  1177. for (var i = startRow || 0, l = lines.length; i < l; i++) {
  1178. index -= lines[i].length + newlineLength;
  1179. if (index < 0)
  1180. return {row: i, column: index + lines[i].length + newlineLength};
  1181. }
  1182. return {row: l-1, column: index + lines[l-1].length + newlineLength};
  1183. };
  1184. this.positionToIndex = function(pos, startRow) {
  1185. var lines = this.$lines || this.getAllLines();
  1186. var newlineLength = this.getNewLineCharacter().length;
  1187. var index = 0;
  1188. var row = Math.min(pos.row, lines.length);
  1189. for (var i = startRow || 0; i < row; ++i)
  1190. index += lines[i].length + newlineLength;
  1191. return index + pos.column;
  1192. };
  1193. }).call(Document.prototype);
  1194. exports.Document = Document;
  1195. });
  1196. define("ace/worker/mirror",[], function(require, exports, module) {
  1197. "use strict";
  1198. var Range = require("../range").Range;
  1199. var Document = require("../document").Document;
  1200. var lang = require("../lib/lang");
  1201. var Mirror = exports.Mirror = function(sender) {
  1202. this.sender = sender;
  1203. var doc = this.doc = new Document("");
  1204. var deferredUpdate = this.deferredUpdate = lang.delayedCall(this.onUpdate.bind(this));
  1205. var _self = this;
  1206. sender.on("change", function(e) {
  1207. var data = e.data;
  1208. if (data[0].start) {
  1209. doc.applyDeltas(data);
  1210. } else {
  1211. for (var i = 0; i < data.length; i += 2) {
  1212. if (Array.isArray(data[i+1])) {
  1213. var d = {action: "insert", start: data[i], lines: data[i+1]};
  1214. } else {
  1215. var d = {action: "remove", start: data[i], end: data[i+1]};
  1216. }
  1217. doc.applyDelta(d, true);
  1218. }
  1219. }
  1220. if (_self.$timeout)
  1221. return deferredUpdate.schedule(_self.$timeout);
  1222. _self.onUpdate();
  1223. });
  1224. };
  1225. (function() {
  1226. this.$timeout = 500;
  1227. this.setTimeout = function(timeout) {
  1228. this.$timeout = timeout;
  1229. };
  1230. this.setValue = function(value) {
  1231. this.doc.setValue(value);
  1232. this.deferredUpdate.schedule(this.$timeout);
  1233. };
  1234. this.getValue = function(callbackId) {
  1235. this.sender.callback(this.doc.getValue(), callbackId);
  1236. };
  1237. this.onUpdate = function() {
  1238. };
  1239. this.isPending = function() {
  1240. return this.deferredUpdate.isPending();
  1241. };
  1242. }).call(Mirror.prototype);
  1243. });
  1244. define("ace/mode/css/csslint",[], function(require, exports, module) {
  1245. var CSSLint = (function(){
  1246. var module = module || {},
  1247. exports = exports || {};
  1248. var parserlib = (function () {
  1249. var require;
  1250. require=(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
  1251. "use strict";
  1252. var Colors = module.exports = {
  1253. __proto__ : null,
  1254. aliceblue : "#f0f8ff",
  1255. antiquewhite : "#faebd7",
  1256. aqua : "#00ffff",
  1257. aquamarine : "#7fffd4",
  1258. azure : "#f0ffff",
  1259. beige : "#f5f5dc",
  1260. bisque : "#ffe4c4",
  1261. black : "#000000",
  1262. blanchedalmond : "#ffebcd",
  1263. blue : "#0000ff",
  1264. blueviolet : "#8a2be2",
  1265. brown : "#a52a2a",
  1266. burlywood : "#deb887",
  1267. cadetblue : "#5f9ea0",
  1268. chartreuse : "#7fff00",
  1269. chocolate : "#d2691e",
  1270. coral : "#ff7f50",
  1271. cornflowerblue : "#6495ed",
  1272. cornsilk : "#fff8dc",
  1273. crimson : "#dc143c",
  1274. cyan : "#00ffff",
  1275. darkblue : "#00008b",
  1276. darkcyan : "#008b8b",
  1277. darkgoldenrod : "#b8860b",
  1278. darkgray : "#a9a9a9",
  1279. darkgreen : "#006400",
  1280. darkgrey : "#a9a9a9",
  1281. darkkhaki : "#bdb76b",
  1282. darkmagenta : "#8b008b",
  1283. darkolivegreen : "#556b2f",
  1284. darkorange : "#ff8c00",
  1285. darkorchid : "#9932cc",
  1286. darkred : "#8b0000",
  1287. darksalmon : "#e9967a",
  1288. darkseagreen : "#8fbc8f",
  1289. darkslateblue : "#483d8b",
  1290. darkslategray : "#2f4f4f",
  1291. darkslategrey : "#2f4f4f",
  1292. darkturquoise : "#00ced1",
  1293. darkviolet : "#9400d3",
  1294. deeppink : "#ff1493",
  1295. deepskyblue : "#00bfff",
  1296. dimgray : "#696969",
  1297. dimgrey : "#696969",
  1298. dodgerblue : "#1e90ff",
  1299. firebrick : "#b22222",
  1300. floralwhite : "#fffaf0",
  1301. forestgreen : "#228b22",
  1302. fuchsia : "#ff00ff",
  1303. gainsboro : "#dcdcdc",
  1304. ghostwhite : "#f8f8ff",
  1305. gold : "#ffd700",
  1306. goldenrod : "#daa520",
  1307. gray : "#808080",
  1308. green : "#008000",
  1309. greenyellow : "#adff2f",
  1310. grey : "#808080",
  1311. honeydew : "#f0fff0",
  1312. hotpink : "#ff69b4",
  1313. indianred : "#cd5c5c",
  1314. indigo : "#4b0082",
  1315. ivory : "#fffff0",
  1316. khaki : "#f0e68c",
  1317. lavender : "#e6e6fa",
  1318. lavenderblush : "#fff0f5",
  1319. lawngreen : "#7cfc00",
  1320. lemonchiffon : "#fffacd",
  1321. lightblue : "#add8e6",
  1322. lightcoral : "#f08080",
  1323. lightcyan : "#e0ffff",
  1324. lightgoldenrodyellow : "#fafad2",
  1325. lightgray : "#d3d3d3",
  1326. lightgreen : "#90ee90",
  1327. lightgrey : "#d3d3d3",
  1328. lightpink : "#ffb6c1",
  1329. lightsalmon : "#ffa07a",
  1330. lightseagreen : "#20b2aa",
  1331. lightskyblue : "#87cefa",
  1332. lightslategray : "#778899",
  1333. lightslategrey : "#778899",
  1334. lightsteelblue : "#b0c4de",
  1335. lightyellow : "#ffffe0",
  1336. lime : "#00ff00",
  1337. limegreen : "#32cd32",
  1338. linen : "#faf0e6",
  1339. magenta : "#ff00ff",
  1340. maroon : "#800000",
  1341. mediumaquamarine : "#66cdaa",
  1342. mediumblue : "#0000cd",
  1343. mediumorchid : "#ba55d3",
  1344. mediumpurple : "#9370db",
  1345. mediumseagreen : "#3cb371",
  1346. mediumslateblue : "#7b68ee",
  1347. mediumspringgreen : "#00fa9a",
  1348. mediumturquoise : "#48d1cc",
  1349. mediumvioletred : "#c71585",
  1350. midnightblue : "#191970",
  1351. mintcream : "#f5fffa",
  1352. mistyrose : "#ffe4e1",
  1353. moccasin : "#ffe4b5",
  1354. navajowhite : "#ffdead",
  1355. navy : "#000080",
  1356. oldlace : "#fdf5e6",
  1357. olive : "#808000",
  1358. olivedrab : "#6b8e23",
  1359. orange : "#ffa500",
  1360. orangered : "#ff4500",
  1361. orchid : "#da70d6",
  1362. palegoldenrod : "#eee8aa",
  1363. palegreen : "#98fb98",
  1364. paleturquoise : "#afeeee",
  1365. palevioletred : "#db7093",
  1366. papayawhip : "#ffefd5",
  1367. peachpuff : "#ffdab9",
  1368. peru : "#cd853f",
  1369. pink : "#ffc0cb",
  1370. plum : "#dda0dd",
  1371. powderblue : "#b0e0e6",
  1372. purple : "#800080",
  1373. rebeccapurple : "#663399",
  1374. red : "#ff0000",
  1375. rosybrown : "#bc8f8f",
  1376. royalblue : "#4169e1",
  1377. saddlebrown : "#8b4513",
  1378. salmon : "#fa8072",
  1379. sandybrown : "#f4a460",
  1380. seagreen : "#2e8b57",
  1381. seashell : "#fff5ee",
  1382. sienna : "#a0522d",
  1383. silver : "#c0c0c0",
  1384. skyblue : "#87ceeb",
  1385. slateblue : "#6a5acd",
  1386. slategray : "#708090",
  1387. slategrey : "#708090",
  1388. snow : "#fffafa",
  1389. springgreen : "#00ff7f",
  1390. steelblue : "#4682b4",
  1391. tan : "#d2b48c",
  1392. teal : "#008080",
  1393. thistle : "#d8bfd8",
  1394. tomato : "#ff6347",
  1395. turquoise : "#40e0d0",
  1396. violet : "#ee82ee",
  1397. wheat : "#f5deb3",
  1398. white : "#ffffff",
  1399. whitesmoke : "#f5f5f5",
  1400. yellow : "#ffff00",
  1401. yellowgreen : "#9acd32",
  1402. currentColor : "The value of the 'color' property.",
  1403. activeborder : "Active window border.",
  1404. activecaption : "Active window caption.",
  1405. appworkspace : "Background color of multiple document interface.",
  1406. background : "Desktop background.",
  1407. buttonface : "The face background color for 3-D elements that appear 3-D due to one layer of surrounding border.",
  1408. buttonhighlight : "The color of the border facing the light source for 3-D elements that appear 3-D due to one layer of surrounding border.",
  1409. buttonshadow : "The color of the border away from the light source for 3-D elements that appear 3-D due to one layer of surrounding border.",
  1410. buttontext : "Text on push buttons.",
  1411. captiontext : "Text in caption, size box, and scrollbar arrow box.",
  1412. graytext : "Grayed (disabled) text. This color is set to #000 if the current display driver does not support a solid gray color.",
  1413. greytext : "Greyed (disabled) text. This color is set to #000 if the current display driver does not support a solid grey color.",
  1414. highlight : "Item(s) selected in a control.",
  1415. highlighttext : "Text of item(s) selected in a control.",
  1416. inactiveborder : "Inactive window border.",
  1417. inactivecaption : "Inactive window caption.",
  1418. inactivecaptiontext : "Color of text in an inactive caption.",
  1419. infobackground : "Background color for tooltip controls.",
  1420. infotext : "Text color for tooltip controls.",
  1421. menu : "Menu background.",
  1422. menutext : "Text in menus.",
  1423. scrollbar : "Scroll bar gray area.",
  1424. threeddarkshadow : "The color of the darker (generally outer) of the two borders away from the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",
  1425. threedface : "The face background color for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",
  1426. threedhighlight : "The color of the lighter (generally outer) of the two borders facing the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",
  1427. threedlightshadow : "The color of the darker (generally inner) of the two borders facing the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",
  1428. threedshadow : "The color of the lighter (generally inner) of the two borders away from the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",
  1429. window : "Window background.",
  1430. windowframe : "Window frame.",
  1431. windowtext : "Text in windows."
  1432. };
  1433. },{}],2:[function(require,module,exports){
  1434. "use strict";
  1435. module.exports = Combinator;
  1436. var SyntaxUnit = require("../util/SyntaxUnit");
  1437. var Parser = require("./Parser");
  1438. function Combinator(text, line, col) {
  1439. SyntaxUnit.call(this, text, line, col, Parser.COMBINATOR_TYPE);
  1440. this.type = "unknown";
  1441. if (/^\s+$/.test(text)) {
  1442. this.type = "descendant";
  1443. } else if (text === ">") {
  1444. this.type = "child";
  1445. } else if (text === "+") {
  1446. this.type = "adjacent-sibling";
  1447. } else if (text === "~") {
  1448. this.type = "sibling";
  1449. }
  1450. }
  1451. Combinator.prototype = new SyntaxUnit();
  1452. Combinator.prototype.constructor = Combinator;
  1453. },{"../util/SyntaxUnit":26,"./Parser":6}],3:[function(require,module,exports){
  1454. "use strict";
  1455. module.exports = Matcher;
  1456. var StringReader = require("../util/StringReader");
  1457. var SyntaxError = require("../util/SyntaxError");
  1458. function Matcher(matchFunc, toString) {
  1459. this.match = function(expression) {
  1460. var result;
  1461. expression.mark();
  1462. result = matchFunc(expression);
  1463. if (result) {
  1464. expression.drop();
  1465. } else {
  1466. expression.restore();
  1467. }
  1468. return result;
  1469. };
  1470. this.toString = typeof toString === "function" ? toString : function() {
  1471. return toString;
  1472. };
  1473. }
  1474. Matcher.prec = {
  1475. MOD: 5,
  1476. SEQ: 4,
  1477. ANDAND: 3,
  1478. OROR: 2,
  1479. ALT: 1
  1480. };
  1481. Matcher.parse = function(str) {
  1482. var reader, eat, expr, oror, andand, seq, mod, term, result;
  1483. reader = new StringReader(str);
  1484. eat = function(matcher) {
  1485. var result = reader.readMatch(matcher);
  1486. if (result === null) {
  1487. throw new SyntaxError(
  1488. "Expected " + matcher, reader.getLine(), reader.getCol());
  1489. }
  1490. return result;
  1491. };
  1492. expr = function() {
  1493. var m = [ oror() ];
  1494. while (reader.readMatch(" | ") !== null) {
  1495. m.push(oror());
  1496. }
  1497. return m.length === 1 ? m[0] : Matcher.alt.apply(Matcher, m);
  1498. };
  1499. oror = function() {
  1500. var m = [ andand() ];
  1501. while (reader.readMatch(" || ") !== null) {
  1502. m.push(andand());
  1503. }
  1504. return m.length === 1 ? m[0] : Matcher.oror.apply(Matcher, m);
  1505. };
  1506. andand = function() {
  1507. var m = [ seq() ];
  1508. while (reader.readMatch(" && ") !== null) {
  1509. m.push(seq());
  1510. }
  1511. return m.length === 1 ? m[0] : Matcher.andand.apply(Matcher, m);
  1512. };
  1513. seq = function() {
  1514. var m = [ mod() ];
  1515. while (reader.readMatch(/^ (?![&|\]])/) !== null) {
  1516. m.push(mod());
  1517. }
  1518. return m.length === 1 ? m[0] : Matcher.seq.apply(Matcher, m);
  1519. };
  1520. mod = function() {
  1521. var m = term();
  1522. if (reader.readMatch("?") !== null) {
  1523. return m.question();
  1524. } else if (reader.readMatch("*") !== null) {
  1525. return m.star();
  1526. } else if (reader.readMatch("+") !== null) {
  1527. return m.plus();
  1528. } else if (reader.readMatch("#") !== null) {
  1529. return m.hash();
  1530. } else if (reader.readMatch(/^\{\s*/) !== null) {
  1531. var min = eat(/^\d+/);
  1532. eat(/^\s*,\s*/);
  1533. var max = eat(/^\d+/);
  1534. eat(/^\s*\}/);
  1535. return m.braces(Number(min), Number(max));
  1536. }
  1537. return m;
  1538. };
  1539. term = function() {
  1540. if (reader.readMatch("[ ") !== null) {
  1541. var m = expr();
  1542. eat(" ]");
  1543. return m;
  1544. }
  1545. return Matcher.fromType(eat(/^[^ ?*+#{]+/));
  1546. };
  1547. result = expr();
  1548. if (!reader.eof()) {
  1549. throw new SyntaxError(
  1550. "Expected end of string", reader.getLine(), reader.getCol());
  1551. }
  1552. return result;
  1553. };
  1554. Matcher.cast = function(m) {
  1555. if (m instanceof Matcher) {
  1556. return m;
  1557. }
  1558. return Matcher.parse(m);
  1559. };
  1560. Matcher.fromType = function(type) {
  1561. var ValidationTypes = require("./ValidationTypes");
  1562. return new Matcher(function(expression) {
  1563. return expression.hasNext() && ValidationTypes.isType(expression, type);
  1564. }, type);
  1565. };
  1566. Matcher.seq = function() {
  1567. var ms = Array.prototype.slice.call(arguments).map(Matcher.cast);
  1568. if (ms.length === 1) {
  1569. return ms[0];
  1570. }
  1571. return new Matcher(function(expression) {
  1572. var i, result = true;
  1573. for (i = 0; result && i < ms.length; i++) {
  1574. result = ms[i].match(expression);
  1575. }
  1576. return result;
  1577. }, function(prec) {
  1578. var p = Matcher.prec.SEQ;
  1579. var s = ms.map(function(m) {
  1580. return m.toString(p);
  1581. }).join(" ");
  1582. if (prec > p) {
  1583. s = "[ " + s + " ]";
  1584. }
  1585. return s;
  1586. });
  1587. };
  1588. Matcher.alt = function() {
  1589. var ms = Array.prototype.slice.call(arguments).map(Matcher.cast);
  1590. if (ms.length === 1) {
  1591. return ms[0];
  1592. }
  1593. return new Matcher(function(expression) {
  1594. var i, result = false;
  1595. for (i = 0; !result && i < ms.length; i++) {
  1596. result = ms[i].match(expression);
  1597. }
  1598. return result;
  1599. }, function(prec) {
  1600. var p = Matcher.prec.ALT;
  1601. var s = ms.map(function(m) {
  1602. return m.toString(p);
  1603. }).join(" | ");
  1604. if (prec > p) {
  1605. s = "[ " + s + " ]";
  1606. }
  1607. return s;
  1608. });
  1609. };
  1610. Matcher.many = function(required) {
  1611. var ms = Array.prototype.slice.call(arguments, 1).reduce(function(acc, v) {
  1612. if (v.expand) {
  1613. var ValidationTypes = require("./ValidationTypes");
  1614. acc.push.apply(acc, ValidationTypes.complex[v.expand].options);
  1615. } else {
  1616. acc.push(Matcher.cast(v));
  1617. }
  1618. return acc;
  1619. }, []);
  1620. if (required === true) {
  1621. required = ms.map(function() {
  1622. return true;
  1623. });
  1624. }
  1625. var result = new Matcher(function(expression) {
  1626. var seen = [], max = 0, pass = 0;
  1627. var success = function(matchCount) {
  1628. if (pass === 0) {
  1629. max = Math.max(matchCount, max);
  1630. return matchCount === ms.length;
  1631. } else {
  1632. return matchCount === max;
  1633. }
  1634. };
  1635. var tryMatch = function(matchCount) {
  1636. for (var i = 0; i < ms.length; i++) {
  1637. if (seen[i]) {
  1638. continue;
  1639. }
  1640. expression.mark();
  1641. if (ms[i].match(expression)) {
  1642. seen[i] = true;
  1643. if (tryMatch(matchCount + (required === false || required[i] ? 1 : 0))) {
  1644. expression.drop();
  1645. return true;
  1646. }
  1647. expression.restore();
  1648. seen[i] = false;
  1649. } else {
  1650. expression.drop();
  1651. }
  1652. }
  1653. return success(matchCount);
  1654. };
  1655. if (!tryMatch(0)) {
  1656. pass++;
  1657. tryMatch(0);
  1658. }
  1659. if (required === false) {
  1660. return max > 0;
  1661. }
  1662. for (var i = 0; i < ms.length; i++) {
  1663. if (required[i] && !seen[i]) {
  1664. return false;
  1665. }
  1666. }
  1667. return true;
  1668. }, function(prec) {
  1669. var p = required === false ? Matcher.prec.OROR : Matcher.prec.ANDAND;
  1670. var s = ms.map(function(m, i) {
  1671. if (required !== false && !required[i]) {
  1672. return m.toString(Matcher.prec.MOD) + "?";
  1673. }
  1674. return m.toString(p);
  1675. }).join(required === false ? " || " : " && ");
  1676. if (prec > p) {
  1677. s = "[ " + s + " ]";
  1678. }
  1679. return s;
  1680. });
  1681. result.options = ms;
  1682. return result;
  1683. };
  1684. Matcher.andand = function() {
  1685. var args = Array.prototype.slice.call(arguments);
  1686. args.unshift(true);
  1687. return Matcher.many.apply(Matcher, args);
  1688. };
  1689. Matcher.oror = function() {
  1690. var args = Array.prototype.slice.call(arguments);
  1691. args.unshift(false);
  1692. return Matcher.many.apply(Matcher, args);
  1693. };
  1694. Matcher.prototype = {
  1695. constructor: Matcher,
  1696. match: function() {
  1697. throw new Error("unimplemented");
  1698. },
  1699. toString: function() {
  1700. throw new Error("unimplemented");
  1701. },
  1702. func: function() {
  1703. return this.match.bind(this);
  1704. },
  1705. then: function(m) {
  1706. return Matcher.seq(this, m);
  1707. },
  1708. or: function(m) {
  1709. return Matcher.alt(this, m);
  1710. },
  1711. andand: function(m) {
  1712. return Matcher.many(true, this, m);
  1713. },
  1714. oror: function(m) {
  1715. return Matcher.many(false, this, m);
  1716. },
  1717. star: function() {
  1718. return this.braces(0, Infinity, "*");
  1719. },
  1720. plus: function() {
  1721. return this.braces(1, Infinity, "+");
  1722. },
  1723. question: function() {
  1724. return this.braces(0, 1, "?");
  1725. },
  1726. hash: function() {
  1727. return this.braces(1, Infinity, "#", Matcher.cast(","));
  1728. },
  1729. braces: function(min, max, marker, optSep) {
  1730. var m1 = this, m2 = optSep ? optSep.then(this) : this;
  1731. if (!marker) {
  1732. marker = "{" + min + "," + max + "}";
  1733. }
  1734. return new Matcher(function(expression) {
  1735. var result = true, i;
  1736. for (i = 0; i < max; i++) {
  1737. if (i > 0 && optSep) {
  1738. result = m2.match(expression);
  1739. } else {
  1740. result = m1.match(expression);
  1741. }
  1742. if (!result) {
  1743. break;
  1744. }
  1745. }
  1746. return i >= min;
  1747. }, function() {
  1748. return m1.toString(Matcher.prec.MOD) + marker;
  1749. });
  1750. }
  1751. };
  1752. },{"../util/StringReader":24,"../util/SyntaxError":25,"./ValidationTypes":21}],4:[function(require,module,exports){
  1753. "use strict";
  1754. module.exports = MediaFeature;
  1755. var SyntaxUnit = require("../util/SyntaxUnit");
  1756. var Parser = require("./Parser");
  1757. function MediaFeature(name, value) {
  1758. SyntaxUnit.call(this, "(" + name + (value !== null ? ":" + value : "") + ")", name.startLine, name.startCol, Parser.MEDIA_FEATURE_TYPE);
  1759. this.name = name;
  1760. this.value = value;
  1761. }
  1762. MediaFeature.prototype = new SyntaxUnit();
  1763. MediaFeature.prototype.constructor = MediaFeature;
  1764. },{"../util/SyntaxUnit":26,"./Parser":6}],5:[function(require,module,exports){
  1765. "use strict";
  1766. module.exports = MediaQuery;
  1767. var SyntaxUnit = require("../util/SyntaxUnit");
  1768. var Parser = require("./Parser");
  1769. function MediaQuery(modifier, mediaType, features, line, col) {
  1770. SyntaxUnit.call(this, (modifier ? modifier + " " : "") + (mediaType ? mediaType : "") + (mediaType && features.length > 0 ? " and " : "") + features.join(" and "), line, col, Parser.MEDIA_QUERY_TYPE);
  1771. this.modifier = modifier;
  1772. this.mediaType = mediaType;
  1773. this.features = features;
  1774. }
  1775. MediaQuery.prototype = new SyntaxUnit();
  1776. MediaQuery.prototype.constructor = MediaQuery;
  1777. },{"../util/SyntaxUnit":26,"./Parser":6}],6:[function(require,module,exports){
  1778. "use strict";
  1779. module.exports = Parser;
  1780. var EventTarget = require("../util/EventTarget");
  1781. var SyntaxError = require("../util/SyntaxError");
  1782. var SyntaxUnit = require("../util/SyntaxUnit");
  1783. var Combinator = require("./Combinator");
  1784. var MediaFeature = require("./MediaFeature");
  1785. var MediaQuery = require("./MediaQuery");
  1786. var PropertyName = require("./PropertyName");
  1787. var PropertyValue = require("./PropertyValue");
  1788. var PropertyValuePart = require("./PropertyValuePart");
  1789. var Selector = require("./Selector");
  1790. var SelectorPart = require("./SelectorPart");
  1791. var SelectorSubPart = require("./SelectorSubPart");
  1792. var TokenStream = require("./TokenStream");
  1793. var Tokens = require("./Tokens");
  1794. var Validation = require("./Validation");
  1795. function Parser(options) {
  1796. EventTarget.call(this);
  1797. this.options = options || {};
  1798. this._tokenStream = null;
  1799. }
  1800. Parser.DEFAULT_TYPE = 0;
  1801. Parser.COMBINATOR_TYPE = 1;
  1802. Parser.MEDIA_FEATURE_TYPE = 2;
  1803. Parser.MEDIA_QUERY_TYPE = 3;
  1804. Parser.PROPERTY_NAME_TYPE = 4;
  1805. Parser.PROPERTY_VALUE_TYPE = 5;
  1806. Parser.PROPERTY_VALUE_PART_TYPE = 6;
  1807. Parser.SELECTOR_TYPE = 7;
  1808. Parser.SELECTOR_PART_TYPE = 8;
  1809. Parser.SELECTOR_SUB_PART_TYPE = 9;
  1810. Parser.prototype = function() {
  1811. var proto = new EventTarget(), // new prototype
  1812. prop,
  1813. additions = {
  1814. __proto__: null,
  1815. constructor: Parser,
  1816. DEFAULT_TYPE : 0,
  1817. COMBINATOR_TYPE : 1,
  1818. MEDIA_FEATURE_TYPE : 2,
  1819. MEDIA_QUERY_TYPE : 3,
  1820. PROPERTY_NAME_TYPE : 4,
  1821. PROPERTY_VALUE_TYPE : 5,
  1822. PROPERTY_VALUE_PART_TYPE : 6,
  1823. SELECTOR_TYPE : 7,
  1824. SELECTOR_PART_TYPE : 8,
  1825. SELECTOR_SUB_PART_TYPE : 9,
  1826. _stylesheet: function() {
  1827. var tokenStream = this._tokenStream,
  1828. count,
  1829. token,
  1830. tt;
  1831. this.fire("startstylesheet");
  1832. this._charset();
  1833. this._skipCruft();
  1834. while (tokenStream.peek() === Tokens.IMPORT_SYM) {
  1835. this._import();
  1836. this._skipCruft();
  1837. }
  1838. while (tokenStream.peek() === Tokens.NAMESPACE_SYM) {
  1839. this._namespace();
  1840. this._skipCruft();
  1841. }
  1842. tt = tokenStream.peek();
  1843. while (tt > Tokens.EOF) {
  1844. try {
  1845. switch (tt) {
  1846. case Tokens.MEDIA_SYM:
  1847. this._media();
  1848. this._skipCruft();
  1849. break;
  1850. case Tokens.PAGE_SYM:
  1851. this._page();
  1852. this._skipCruft();
  1853. break;
  1854. case Tokens.FONT_FACE_SYM:
  1855. this._font_face();
  1856. this._skipCruft();
  1857. break;
  1858. case Tokens.KEYFRAMES_SYM:
  1859. this._keyframes();
  1860. this._skipCruft();
  1861. break;
  1862. case Tokens.VIEWPORT_SYM:
  1863. this._viewport();
  1864. this._skipCruft();
  1865. break;
  1866. case Tokens.DOCUMENT_SYM:
  1867. this._document();
  1868. this._skipCruft();
  1869. break;
  1870. case Tokens.SUPPORTS_SYM:
  1871. this._supports();
  1872. this._skipCruft();
  1873. break;
  1874. case Tokens.UNKNOWN_SYM: // unknown @ rule
  1875. tokenStream.get();
  1876. if (!this.options.strict) {
  1877. this.fire({
  1878. type: "error",
  1879. error: null,
  1880. message: "Unknown @ rule: " + tokenStream.LT(0).value + ".",
  1881. line: tokenStream.LT(0).startLine,
  1882. col: tokenStream.LT(0).startCol
  1883. });
  1884. count = 0;
  1885. while (tokenStream.advance([Tokens.LBRACE, Tokens.RBRACE]) === Tokens.LBRACE) {
  1886. count++; // keep track of nesting depth
  1887. }
  1888. while (count) {
  1889. tokenStream.advance([Tokens.RBRACE]);
  1890. count--;
  1891. }
  1892. } else {
  1893. throw new SyntaxError("Unknown @ rule.", tokenStream.LT(0).startLine, tokenStream.LT(0).startCol);
  1894. }
  1895. break;
  1896. case Tokens.S:
  1897. this._readWhitespace();
  1898. break;
  1899. default:
  1900. if (!this._ruleset()) {
  1901. switch (tt) {
  1902. case Tokens.CHARSET_SYM:
  1903. token = tokenStream.LT(1);
  1904. this._charset(false);
  1905. throw new SyntaxError("@charset not allowed here.", token.startLine, token.startCol);
  1906. case Tokens.IMPORT_SYM:
  1907. token = tokenStream.LT(1);
  1908. this._import(false);
  1909. throw new SyntaxError("@import not allowed here.", token.startLine, token.startCol);
  1910. case Tokens.NAMESPACE_SYM:
  1911. token = tokenStream.LT(1);
  1912. this._namespace(false);
  1913. throw new SyntaxError("@namespace not allowed here.", token.startLine, token.startCol);
  1914. default:
  1915. tokenStream.get(); // get the last token
  1916. this._unexpectedToken(tokenStream.token());
  1917. }
  1918. }
  1919. }
  1920. } catch (ex) {
  1921. if (ex instanceof SyntaxError && !this.options.strict) {
  1922. this.fire({
  1923. type: "error",
  1924. error: ex,
  1925. message: ex.message,
  1926. line: ex.line,
  1927. col: ex.col
  1928. });
  1929. } else {
  1930. throw ex;
  1931. }
  1932. }
  1933. tt = tokenStream.peek();
  1934. }
  1935. if (tt !== Tokens.EOF) {
  1936. this._unexpectedToken(tokenStream.token());
  1937. }
  1938. this.fire("endstylesheet");
  1939. },
  1940. _charset: function(emit) {
  1941. var tokenStream = this._tokenStream,
  1942. charset,
  1943. token,
  1944. line,
  1945. col;
  1946. if (tokenStream.match(Tokens.CHARSET_SYM)) {
  1947. line = tokenStream.token().startLine;
  1948. col = tokenStream.token().startCol;
  1949. this._readWhitespace();
  1950. tokenStream.mustMatch(Tokens.STRING);
  1951. token = tokenStream.token();
  1952. charset = token.value;
  1953. this._readWhitespace();
  1954. tokenStream.mustMatch(Tokens.SEMICOLON);
  1955. if (emit !== false) {
  1956. this.fire({
  1957. type: "charset",
  1958. charset:charset,
  1959. line: line,
  1960. col: col
  1961. });
  1962. }
  1963. }
  1964. },
  1965. _import: function(emit) {
  1966. var tokenStream = this._tokenStream,
  1967. uri,
  1968. importToken,
  1969. mediaList = [];
  1970. tokenStream.mustMatch(Tokens.IMPORT_SYM);
  1971. importToken = tokenStream.token();
  1972. this._readWhitespace();
  1973. tokenStream.mustMatch([Tokens.STRING, Tokens.URI]);
  1974. uri = tokenStream.token().value.replace(/^(?:url\()?["']?([^"']+?)["']?\)?$/, "$1");
  1975. this._readWhitespace();
  1976. mediaList = this._media_query_list();
  1977. tokenStream.mustMatch(Tokens.SEMICOLON);
  1978. this._readWhitespace();
  1979. if (emit !== false) {
  1980. this.fire({
  1981. type: "import",
  1982. uri: uri,
  1983. media: mediaList,
  1984. line: importToken.startLine,
  1985. col: importToken.startCol
  1986. });
  1987. }
  1988. },
  1989. _namespace: function(emit) {
  1990. var tokenStream = this._tokenStream,
  1991. line,
  1992. col,
  1993. prefix,
  1994. uri;
  1995. tokenStream.mustMatch(Tokens.NAMESPACE_SYM);
  1996. line = tokenStream.token().startLine;
  1997. col = tokenStream.token().startCol;
  1998. this._readWhitespace();
  1999. if (tokenStream.match(Tokens.IDENT)) {
  2000. prefix = tokenStream.token().value;
  2001. this._readWhitespace();
  2002. }
  2003. tokenStream.mustMatch([Tokens.STRING, Tokens.URI]);
  2004. uri = tokenStream.token().value.replace(/(?:url\()?["']([^"']+)["']\)?/, "$1");
  2005. this._readWhitespace();
  2006. tokenStream.mustMatch(Tokens.SEMICOLON);
  2007. this._readWhitespace();
  2008. if (emit !== false) {
  2009. this.fire({
  2010. type: "namespace",
  2011. prefix: prefix,
  2012. uri: uri,
  2013. line: line,
  2014. col: col
  2015. });
  2016. }
  2017. },
  2018. _supports: function(emit) {
  2019. var tokenStream = this._tokenStream,
  2020. line,
  2021. col;
  2022. if (tokenStream.match(Tokens.SUPPORTS_SYM)) {
  2023. line = tokenStream.token().startLine;
  2024. col = tokenStream.token().startCol;
  2025. this._readWhitespace();
  2026. this._supports_condition();
  2027. this._readWhitespace();
  2028. tokenStream.mustMatch(Tokens.LBRACE);
  2029. this._readWhitespace();
  2030. if (emit !== false) {
  2031. this.fire({
  2032. type: "startsupports",
  2033. line: line,
  2034. col: col
  2035. });
  2036. }
  2037. while (true) {
  2038. if (!this._ruleset()) {
  2039. break;
  2040. }
  2041. }
  2042. tokenStream.mustMatch(Tokens.RBRACE);
  2043. this._readWhitespace();
  2044. this.fire({
  2045. type: "endsupports",
  2046. line: line,
  2047. col: col
  2048. });
  2049. }
  2050. },
  2051. _supports_condition: function() {
  2052. var tokenStream = this._tokenStream,
  2053. ident;
  2054. if (tokenStream.match(Tokens.IDENT)) {
  2055. ident = tokenStream.token().value.toLowerCase();
  2056. if (ident === "not") {
  2057. tokenStream.mustMatch(Tokens.S);
  2058. this._supports_condition_in_parens();
  2059. } else {
  2060. tokenStream.unget();
  2061. }
  2062. } else {
  2063. this._supports_condition_in_parens();
  2064. this._readWhitespace();
  2065. while (tokenStream.peek() === Tokens.IDENT) {
  2066. ident = tokenStream.LT(1).value.toLowerCase();
  2067. if (ident === "and" || ident === "or") {
  2068. tokenStream.mustMatch(Tokens.IDENT);
  2069. this._readWhitespace();
  2070. this._supports_condition_in_parens();
  2071. this._readWhitespace();
  2072. }
  2073. }
  2074. }
  2075. },
  2076. _supports_condition_in_parens: function() {
  2077. var tokenStream = this._tokenStream,
  2078. ident;
  2079. if (tokenStream.match(Tokens.LPAREN)) {
  2080. this._readWhitespace();
  2081. if (tokenStream.match(Tokens.IDENT)) {
  2082. ident = tokenStream.token().value.toLowerCase();
  2083. if (ident === "not") {
  2084. this._readWhitespace();
  2085. this._supports_condition();
  2086. this._readWhitespace();
  2087. tokenStream.mustMatch(Tokens.RPAREN);
  2088. } else {
  2089. tokenStream.unget();
  2090. this._supports_declaration_condition(false);
  2091. }
  2092. } else {
  2093. this._supports_condition();
  2094. this._readWhitespace();
  2095. tokenStream.mustMatch(Tokens.RPAREN);
  2096. }
  2097. } else {
  2098. this._supports_declaration_condition();
  2099. }
  2100. },
  2101. _supports_declaration_condition: function(requireStartParen) {
  2102. var tokenStream = this._tokenStream;
  2103. if (requireStartParen !== false) {
  2104. tokenStream.mustMatch(Tokens.LPAREN);
  2105. }
  2106. this._readWhitespace();
  2107. this._declaration();
  2108. tokenStream.mustMatch(Tokens.RPAREN);
  2109. },
  2110. _media: function() {
  2111. var tokenStream = this._tokenStream,
  2112. line,
  2113. col,
  2114. mediaList; // = [];
  2115. tokenStream.mustMatch(Tokens.MEDIA_SYM);
  2116. line = tokenStream.token().startLine;
  2117. col = tokenStream.token().startCol;
  2118. this._readWhitespace();
  2119. mediaList = this._media_query_list();
  2120. tokenStream.mustMatch(Tokens.LBRACE);
  2121. this._readWhitespace();
  2122. this.fire({
  2123. type: "startmedia",
  2124. media: mediaList,
  2125. line: line,
  2126. col: col
  2127. });
  2128. while (true) {
  2129. if (tokenStream.peek() === Tokens.PAGE_SYM) {
  2130. this._page();
  2131. } else if (tokenStream.peek() === Tokens.FONT_FACE_SYM) {
  2132. this._font_face();
  2133. } else if (tokenStream.peek() === Tokens.VIEWPORT_SYM) {
  2134. this._viewport();
  2135. } else if (tokenStream.peek() === Tokens.DOCUMENT_SYM) {
  2136. this._document();
  2137. } else if (tokenStream.peek() === Tokens.SUPPORTS_SYM) {
  2138. this._supports();
  2139. } else if (tokenStream.peek() === Tokens.MEDIA_SYM) {
  2140. this._media();
  2141. } else if (!this._ruleset()) {
  2142. break;
  2143. }
  2144. }
  2145. tokenStream.mustMatch(Tokens.RBRACE);
  2146. this._readWhitespace();
  2147. this.fire({
  2148. type: "endmedia",
  2149. media: mediaList,
  2150. line: line,
  2151. col: col
  2152. });
  2153. },
  2154. _media_query_list: function() {
  2155. var tokenStream = this._tokenStream,
  2156. mediaList = [];
  2157. this._readWhitespace();
  2158. if (tokenStream.peek() === Tokens.IDENT || tokenStream.peek() === Tokens.LPAREN) {
  2159. mediaList.push(this._media_query());
  2160. }
  2161. while (tokenStream.match(Tokens.COMMA)) {
  2162. this._readWhitespace();
  2163. mediaList.push(this._media_query());
  2164. }
  2165. return mediaList;
  2166. },
  2167. _media_query: function() {
  2168. var tokenStream = this._tokenStream,
  2169. type = null,
  2170. ident = null,
  2171. token = null,
  2172. expressions = [];
  2173. if (tokenStream.match(Tokens.IDENT)) {
  2174. ident = tokenStream.token().value.toLowerCase();
  2175. if (ident !== "only" && ident !== "not") {
  2176. tokenStream.unget();
  2177. ident = null;
  2178. } else {
  2179. token = tokenStream.token();
  2180. }
  2181. }
  2182. this._readWhitespace();
  2183. if (tokenStream.peek() === Tokens.IDENT) {
  2184. type = this._media_type();
  2185. if (token === null) {
  2186. token = tokenStream.token();
  2187. }
  2188. } else if (tokenStream.peek() === Tokens.LPAREN) {
  2189. if (token === null) {
  2190. token = tokenStream.LT(1);
  2191. }
  2192. expressions.push(this._media_expression());
  2193. }
  2194. if (type === null && expressions.length === 0) {
  2195. return null;
  2196. } else {
  2197. this._readWhitespace();
  2198. while (tokenStream.match(Tokens.IDENT)) {
  2199. if (tokenStream.token().value.toLowerCase() !== "and") {
  2200. this._unexpectedToken(tokenStream.token());
  2201. }
  2202. this._readWhitespace();
  2203. expressions.push(this._media_expression());
  2204. }
  2205. }
  2206. return new MediaQuery(ident, type, expressions, token.startLine, token.startCol);
  2207. },
  2208. _media_type: function() {
  2209. return this._media_feature();
  2210. },
  2211. _media_expression: function() {
  2212. var tokenStream = this._tokenStream,
  2213. feature = null,
  2214. token,
  2215. expression = null;
  2216. tokenStream.mustMatch(Tokens.LPAREN);
  2217. this._readWhitespace();
  2218. feature = this._media_feature();
  2219. this._readWhitespace();
  2220. if (tokenStream.match(Tokens.COLON)) {
  2221. this._readWhitespace();
  2222. token = tokenStream.LT(1);
  2223. expression = this._expression();
  2224. }
  2225. tokenStream.mustMatch(Tokens.RPAREN);
  2226. this._readWhitespace();
  2227. return new MediaFeature(feature, expression ? new SyntaxUnit(expression, token.startLine, token.startCol) : null);
  2228. },
  2229. _media_feature: function() {
  2230. var tokenStream = this._tokenStream;
  2231. this._readWhitespace();
  2232. tokenStream.mustMatch(Tokens.IDENT);
  2233. return SyntaxUnit.fromToken(tokenStream.token());
  2234. },
  2235. _page: function() {
  2236. var tokenStream = this._tokenStream,
  2237. line,
  2238. col,
  2239. identifier = null,
  2240. pseudoPage = null;
  2241. tokenStream.mustMatch(Tokens.PAGE_SYM);
  2242. line = tokenStream.token().startLine;
  2243. col = tokenStream.token().startCol;
  2244. this._readWhitespace();
  2245. if (tokenStream.match(Tokens.IDENT)) {
  2246. identifier = tokenStream.token().value;
  2247. if (identifier.toLowerCase() === "auto") {
  2248. this._unexpectedToken(tokenStream.token());
  2249. }
  2250. }
  2251. if (tokenStream.peek() === Tokens.COLON) {
  2252. pseudoPage = this._pseudo_page();
  2253. }
  2254. this._readWhitespace();
  2255. this.fire({
  2256. type: "startpage",
  2257. id: identifier,
  2258. pseudo: pseudoPage,
  2259. line: line,
  2260. col: col
  2261. });
  2262. this._readDeclarations(true, true);
  2263. this.fire({
  2264. type: "endpage",
  2265. id: identifier,
  2266. pseudo: pseudoPage,
  2267. line: line,
  2268. col: col
  2269. });
  2270. },
  2271. _margin: function() {
  2272. var tokenStream = this._tokenStream,
  2273. line,
  2274. col,
  2275. marginSym = this._margin_sym();
  2276. if (marginSym) {
  2277. line = tokenStream.token().startLine;
  2278. col = tokenStream.token().startCol;
  2279. this.fire({
  2280. type: "startpagemargin",
  2281. margin: marginSym,
  2282. line: line,
  2283. col: col
  2284. });
  2285. this._readDeclarations(true);
  2286. this.fire({
  2287. type: "endpagemargin",
  2288. margin: marginSym,
  2289. line: line,
  2290. col: col
  2291. });
  2292. return true;
  2293. } else {
  2294. return false;
  2295. }
  2296. },
  2297. _margin_sym: function() {
  2298. var tokenStream = this._tokenStream;
  2299. if (tokenStream.match([Tokens.TOPLEFTCORNER_SYM, Tokens.TOPLEFT_SYM,
  2300. Tokens.TOPCENTER_SYM, Tokens.TOPRIGHT_SYM, Tokens.TOPRIGHTCORNER_SYM,
  2301. Tokens.BOTTOMLEFTCORNER_SYM, Tokens.BOTTOMLEFT_SYM,
  2302. Tokens.BOTTOMCENTER_SYM, Tokens.BOTTOMRIGHT_SYM,
  2303. Tokens.BOTTOMRIGHTCORNER_SYM, Tokens.LEFTTOP_SYM,
  2304. Tokens.LEFTMIDDLE_SYM, Tokens.LEFTBOTTOM_SYM, Tokens.RIGHTTOP_SYM,
  2305. Tokens.RIGHTMIDDLE_SYM, Tokens.RIGHTBOTTOM_SYM])) {
  2306. return SyntaxUnit.fromToken(tokenStream.token());
  2307. } else {
  2308. return null;
  2309. }
  2310. },
  2311. _pseudo_page: function() {
  2312. var tokenStream = this._tokenStream;
  2313. tokenStream.mustMatch(Tokens.COLON);
  2314. tokenStream.mustMatch(Tokens.IDENT);
  2315. return tokenStream.token().value;
  2316. },
  2317. _font_face: function() {
  2318. var tokenStream = this._tokenStream,
  2319. line,
  2320. col;
  2321. tokenStream.mustMatch(Tokens.FONT_FACE_SYM);
  2322. line = tokenStream.token().startLine;
  2323. col = tokenStream.token().startCol;
  2324. this._readWhitespace();
  2325. this.fire({
  2326. type: "startfontface",
  2327. line: line,
  2328. col: col
  2329. });
  2330. this._readDeclarations(true);
  2331. this.fire({
  2332. type: "endfontface",
  2333. line: line,
  2334. col: col
  2335. });
  2336. },
  2337. _viewport: function() {
  2338. var tokenStream = this._tokenStream,
  2339. line,
  2340. col;
  2341. tokenStream.mustMatch(Tokens.VIEWPORT_SYM);
  2342. line = tokenStream.token().startLine;
  2343. col = tokenStream.token().startCol;
  2344. this._readWhitespace();
  2345. this.fire({
  2346. type: "startviewport",
  2347. line: line,
  2348. col: col
  2349. });
  2350. this._readDeclarations(true);
  2351. this.fire({
  2352. type: "endviewport",
  2353. line: line,
  2354. col: col
  2355. });
  2356. },
  2357. _document: function() {
  2358. var tokenStream = this._tokenStream,
  2359. token,
  2360. functions = [],
  2361. prefix = "";
  2362. tokenStream.mustMatch(Tokens.DOCUMENT_SYM);
  2363. token = tokenStream.token();
  2364. if (/^@-([^-]+)-/.test(token.value)) {
  2365. prefix = RegExp.$1;
  2366. }
  2367. this._readWhitespace();
  2368. functions.push(this._document_function());
  2369. while (tokenStream.match(Tokens.COMMA)) {
  2370. this._readWhitespace();
  2371. functions.push(this._document_function());
  2372. }
  2373. tokenStream.mustMatch(Tokens.LBRACE);
  2374. this._readWhitespace();
  2375. this.fire({
  2376. type: "startdocument",
  2377. functions: functions,
  2378. prefix: prefix,
  2379. line: token.startLine,
  2380. col: token.startCol
  2381. });
  2382. var ok = true;
  2383. while (ok) {
  2384. switch (tokenStream.peek()) {
  2385. case Tokens.PAGE_SYM:
  2386. this._page();
  2387. break;
  2388. case Tokens.FONT_FACE_SYM:
  2389. this._font_face();
  2390. break;
  2391. case Tokens.VIEWPORT_SYM:
  2392. this._viewport();
  2393. break;
  2394. case Tokens.MEDIA_SYM:
  2395. this._media();
  2396. break;
  2397. case Tokens.KEYFRAMES_SYM:
  2398. this._keyframes();
  2399. break;
  2400. case Tokens.DOCUMENT_SYM:
  2401. this._document();
  2402. break;
  2403. default:
  2404. ok = Boolean(this._ruleset());
  2405. }
  2406. }
  2407. tokenStream.mustMatch(Tokens.RBRACE);
  2408. token = tokenStream.token();
  2409. this._readWhitespace();
  2410. this.fire({
  2411. type: "enddocument",
  2412. functions: functions,
  2413. prefix: prefix,
  2414. line: token.startLine,
  2415. col: token.startCol
  2416. });
  2417. },
  2418. _document_function: function() {
  2419. var tokenStream = this._tokenStream,
  2420. value;
  2421. if (tokenStream.match(Tokens.URI)) {
  2422. value = tokenStream.token().value;
  2423. this._readWhitespace();
  2424. } else {
  2425. value = this._function();
  2426. }
  2427. return value;
  2428. },
  2429. _operator: function(inFunction) {
  2430. var tokenStream = this._tokenStream,
  2431. token = null;
  2432. if (tokenStream.match([Tokens.SLASH, Tokens.COMMA]) ||
  2433. inFunction && tokenStream.match([Tokens.PLUS, Tokens.STAR, Tokens.MINUS])) {
  2434. token = tokenStream.token();
  2435. this._readWhitespace();
  2436. }
  2437. return token ? PropertyValuePart.fromToken(token) : null;
  2438. },
  2439. _combinator: function() {
  2440. var tokenStream = this._tokenStream,
  2441. value = null,
  2442. token;
  2443. if (tokenStream.match([Tokens.PLUS, Tokens.GREATER, Tokens.TILDE])) {
  2444. token = tokenStream.token();
  2445. value = new Combinator(token.value, token.startLine, token.startCol);
  2446. this._readWhitespace();
  2447. }
  2448. return value;
  2449. },
  2450. _unary_operator: function() {
  2451. var tokenStream = this._tokenStream;
  2452. if (tokenStream.match([Tokens.MINUS, Tokens.PLUS])) {
  2453. return tokenStream.token().value;
  2454. } else {
  2455. return null;
  2456. }
  2457. },
  2458. _property: function() {
  2459. var tokenStream = this._tokenStream,
  2460. value = null,
  2461. hack = null,
  2462. propertyName = "",
  2463. token,
  2464. line,
  2465. col;
  2466. if (tokenStream.peek() === Tokens.STAR && this.options.starHack) {
  2467. tokenStream.get();
  2468. token = tokenStream.token();
  2469. hack = token.value;
  2470. line = token.startLine;
  2471. col = token.startCol;
  2472. }
  2473. if (tokenStream.peek() === Tokens.MINUS) {
  2474. tokenStream.get();
  2475. token = tokenStream.token();
  2476. propertyName = token.value;
  2477. line = token.startLine;
  2478. col = token.startCol;
  2479. }
  2480. if (tokenStream.match(Tokens.IDENT)) {
  2481. token = tokenStream.token();
  2482. propertyName += token.value;
  2483. if (propertyName.charAt(0) === "_" && this.options.underscoreHack) {
  2484. hack = "_";
  2485. propertyName = propertyName.substring(1);
  2486. }
  2487. value = new PropertyName(propertyName, hack, line || token.startLine, col || token.startCol);
  2488. this._readWhitespace();
  2489. } else if (tokenStream.peek() === Tokens.RBRACE) {
  2490. } else {
  2491. this._unexpectedToken(tokenStream.LT(1));
  2492. }
  2493. return value;
  2494. },
  2495. _ruleset: function() {
  2496. var tokenStream = this._tokenStream,
  2497. tt,
  2498. selectors;
  2499. try {
  2500. selectors = this._selectors_group();
  2501. } catch (ex) {
  2502. if (ex instanceof SyntaxError && !this.options.strict) {
  2503. this.fire({
  2504. type: "error",
  2505. error: ex,
  2506. message: ex.message,
  2507. line: ex.line,
  2508. col: ex.col
  2509. });
  2510. tt = tokenStream.advance([Tokens.RBRACE]);
  2511. if (tt === Tokens.RBRACE) {
  2512. } else {
  2513. throw ex;
  2514. }
  2515. } else {
  2516. throw ex;
  2517. }
  2518. return true;
  2519. }
  2520. if (selectors) {
  2521. this.fire({
  2522. type: "startrule",
  2523. selectors: selectors,
  2524. line: selectors[0].line,
  2525. col: selectors[0].col
  2526. });
  2527. this._readDeclarations(true);
  2528. this.fire({
  2529. type: "endrule",
  2530. selectors: selectors,
  2531. line: selectors[0].line,
  2532. col: selectors[0].col
  2533. });
  2534. }
  2535. return selectors;
  2536. },
  2537. _selectors_group: function() {
  2538. var tokenStream = this._tokenStream,
  2539. selectors = [],
  2540. selector;
  2541. selector = this._selector();
  2542. if (selector !== null) {
  2543. selectors.push(selector);
  2544. while (tokenStream.match(Tokens.COMMA)) {
  2545. this._readWhitespace();
  2546. selector = this._selector();
  2547. if (selector !== null) {
  2548. selectors.push(selector);
  2549. } else {
  2550. this._unexpectedToken(tokenStream.LT(1));
  2551. }
  2552. }
  2553. }
  2554. return selectors.length ? selectors : null;
  2555. },
  2556. _selector: function() {
  2557. var tokenStream = this._tokenStream,
  2558. selector = [],
  2559. nextSelector = null,
  2560. combinator = null,
  2561. ws = null;
  2562. nextSelector = this._simple_selector_sequence();
  2563. if (nextSelector === null) {
  2564. return null;
  2565. }
  2566. selector.push(nextSelector);
  2567. do {
  2568. combinator = this._combinator();
  2569. if (combinator !== null) {
  2570. selector.push(combinator);
  2571. nextSelector = this._simple_selector_sequence();
  2572. if (nextSelector === null) {
  2573. this._unexpectedToken(tokenStream.LT(1));
  2574. } else {
  2575. selector.push(nextSelector);
  2576. }
  2577. } else {
  2578. if (this._readWhitespace()) {
  2579. ws = new Combinator(tokenStream.token().value, tokenStream.token().startLine, tokenStream.token().startCol);
  2580. combinator = this._combinator();
  2581. nextSelector = this._simple_selector_sequence();
  2582. if (nextSelector === null) {
  2583. if (combinator !== null) {
  2584. this._unexpectedToken(tokenStream.LT(1));
  2585. }
  2586. } else {
  2587. if (combinator !== null) {
  2588. selector.push(combinator);
  2589. } else {
  2590. selector.push(ws);
  2591. }
  2592. selector.push(nextSelector);
  2593. }
  2594. } else {
  2595. break;
  2596. }
  2597. }
  2598. } while (true);
  2599. return new Selector(selector, selector[0].line, selector[0].col);
  2600. },
  2601. _simple_selector_sequence: function() {
  2602. var tokenStream = this._tokenStream,
  2603. elementName = null,
  2604. modifiers = [],
  2605. selectorText = "",
  2606. components = [
  2607. function() {
  2608. return tokenStream.match(Tokens.HASH) ?
  2609. new SelectorSubPart(tokenStream.token().value, "id", tokenStream.token().startLine, tokenStream.token().startCol) :
  2610. null;
  2611. },
  2612. this._class,
  2613. this._attrib,
  2614. this._pseudo,
  2615. this._negation
  2616. ],
  2617. i = 0,
  2618. len = components.length,
  2619. component = null,
  2620. line,
  2621. col;
  2622. line = tokenStream.LT(1).startLine;
  2623. col = tokenStream.LT(1).startCol;
  2624. elementName = this._type_selector();
  2625. if (!elementName) {
  2626. elementName = this._universal();
  2627. }
  2628. if (elementName !== null) {
  2629. selectorText += elementName;
  2630. }
  2631. while (true) {
  2632. if (tokenStream.peek() === Tokens.S) {
  2633. break;
  2634. }
  2635. while (i < len && component === null) {
  2636. component = components[i++].call(this);
  2637. }
  2638. if (component === null) {
  2639. if (selectorText === "") {
  2640. return null;
  2641. } else {
  2642. break;
  2643. }
  2644. } else {
  2645. i = 0;
  2646. modifiers.push(component);
  2647. selectorText += component.toString();
  2648. component = null;
  2649. }
  2650. }
  2651. return selectorText !== "" ?
  2652. new SelectorPart(elementName, modifiers, selectorText, line, col) :
  2653. null;
  2654. },
  2655. _type_selector: function() {
  2656. var tokenStream = this._tokenStream,
  2657. ns = this._namespace_prefix(),
  2658. elementName = this._element_name();
  2659. if (!elementName) {
  2660. if (ns) {
  2661. tokenStream.unget();
  2662. if (ns.length > 1) {
  2663. tokenStream.unget();
  2664. }
  2665. }
  2666. return null;
  2667. } else {
  2668. if (ns) {
  2669. elementName.text = ns + elementName.text;
  2670. elementName.col -= ns.length;
  2671. }
  2672. return elementName;
  2673. }
  2674. },
  2675. _class: function() {
  2676. var tokenStream = this._tokenStream,
  2677. token;
  2678. if (tokenStream.match(Tokens.DOT)) {
  2679. tokenStream.mustMatch(Tokens.IDENT);
  2680. token = tokenStream.token();
  2681. return new SelectorSubPart("." + token.value, "class", token.startLine, token.startCol - 1);
  2682. } else {
  2683. return null;
  2684. }
  2685. },
  2686. _element_name: function() {
  2687. var tokenStream = this._tokenStream,
  2688. token;
  2689. if (tokenStream.match(Tokens.IDENT)) {
  2690. token = tokenStream.token();
  2691. return new SelectorSubPart(token.value, "elementName", token.startLine, token.startCol);
  2692. } else {
  2693. return null;
  2694. }
  2695. },
  2696. _namespace_prefix: function() {
  2697. var tokenStream = this._tokenStream,
  2698. value = "";
  2699. if (tokenStream.LA(1) === Tokens.PIPE || tokenStream.LA(2) === Tokens.PIPE) {
  2700. if (tokenStream.match([Tokens.IDENT, Tokens.STAR])) {
  2701. value += tokenStream.token().value;
  2702. }
  2703. tokenStream.mustMatch(Tokens.PIPE);
  2704. value += "|";
  2705. }
  2706. return value.length ? value : null;
  2707. },
  2708. _universal: function() {
  2709. var tokenStream = this._tokenStream,
  2710. value = "",
  2711. ns;
  2712. ns = this._namespace_prefix();
  2713. if (ns) {
  2714. value += ns;
  2715. }
  2716. if (tokenStream.match(Tokens.STAR)) {
  2717. value += "*";
  2718. }
  2719. return value.length ? value : null;
  2720. },
  2721. _attrib: function() {
  2722. var tokenStream = this._tokenStream,
  2723. value = null,
  2724. ns,
  2725. token;
  2726. if (tokenStream.match(Tokens.LBRACKET)) {
  2727. token = tokenStream.token();
  2728. value = token.value;
  2729. value += this._readWhitespace();
  2730. ns = this._namespace_prefix();
  2731. if (ns) {
  2732. value += ns;
  2733. }
  2734. tokenStream.mustMatch(Tokens.IDENT);
  2735. value += tokenStream.token().value;
  2736. value += this._readWhitespace();
  2737. if (tokenStream.match([Tokens.PREFIXMATCH, Tokens.SUFFIXMATCH, Tokens.SUBSTRINGMATCH,
  2738. Tokens.EQUALS, Tokens.INCLUDES, Tokens.DASHMATCH])) {
  2739. value += tokenStream.token().value;
  2740. value += this._readWhitespace();
  2741. tokenStream.mustMatch([Tokens.IDENT, Tokens.STRING]);
  2742. value += tokenStream.token().value;
  2743. value += this._readWhitespace();
  2744. }
  2745. tokenStream.mustMatch(Tokens.RBRACKET);
  2746. return new SelectorSubPart(value + "]", "attribute", token.startLine, token.startCol);
  2747. } else {
  2748. return null;
  2749. }
  2750. },
  2751. _pseudo: function() {
  2752. var tokenStream = this._tokenStream,
  2753. pseudo = null,
  2754. colons = ":",
  2755. line,
  2756. col;
  2757. if (tokenStream.match(Tokens.COLON)) {
  2758. if (tokenStream.match(Tokens.COLON)) {
  2759. colons += ":";
  2760. }
  2761. if (tokenStream.match(Tokens.IDENT)) {
  2762. pseudo = tokenStream.token().value;
  2763. line = tokenStream.token().startLine;
  2764. col = tokenStream.token().startCol - colons.length;
  2765. } else if (tokenStream.peek() === Tokens.FUNCTION) {
  2766. line = tokenStream.LT(1).startLine;
  2767. col = tokenStream.LT(1).startCol - colons.length;
  2768. pseudo = this._functional_pseudo();
  2769. }
  2770. if (pseudo) {
  2771. pseudo = new SelectorSubPart(colons + pseudo, "pseudo", line, col);
  2772. } else {
  2773. var startLine = tokenStream.LT(1).startLine,
  2774. startCol = tokenStream.LT(0).startCol;
  2775. throw new SyntaxError("Expected a `FUNCTION` or `IDENT` after colon at line " + startLine + ", col " + startCol + ".", startLine, startCol);
  2776. }
  2777. }
  2778. return pseudo;
  2779. },
  2780. _functional_pseudo: function() {
  2781. var tokenStream = this._tokenStream,
  2782. value = null;
  2783. if (tokenStream.match(Tokens.FUNCTION)) {
  2784. value = tokenStream.token().value;
  2785. value += this._readWhitespace();
  2786. value += this._expression();
  2787. tokenStream.mustMatch(Tokens.RPAREN);
  2788. value += ")";
  2789. }
  2790. return value;
  2791. },
  2792. _expression: function() {
  2793. var tokenStream = this._tokenStream,
  2794. value = "";
  2795. while (tokenStream.match([Tokens.PLUS, Tokens.MINUS, Tokens.DIMENSION,
  2796. Tokens.NUMBER, Tokens.STRING, Tokens.IDENT, Tokens.LENGTH,
  2797. Tokens.FREQ, Tokens.ANGLE, Tokens.TIME,
  2798. Tokens.RESOLUTION, Tokens.SLASH])) {
  2799. value += tokenStream.token().value;
  2800. value += this._readWhitespace();
  2801. }
  2802. return value.length ? value : null;
  2803. },
  2804. _negation: function() {
  2805. var tokenStream = this._tokenStream,
  2806. line,
  2807. col,
  2808. value = "",
  2809. arg,
  2810. subpart = null;
  2811. if (tokenStream.match(Tokens.NOT)) {
  2812. value = tokenStream.token().value;
  2813. line = tokenStream.token().startLine;
  2814. col = tokenStream.token().startCol;
  2815. value += this._readWhitespace();
  2816. arg = this._negation_arg();
  2817. value += arg;
  2818. value += this._readWhitespace();
  2819. tokenStream.match(Tokens.RPAREN);
  2820. value += tokenStream.token().value;
  2821. subpart = new SelectorSubPart(value, "not", line, col);
  2822. subpart.args.push(arg);
  2823. }
  2824. return subpart;
  2825. },
  2826. _negation_arg: function() {
  2827. var tokenStream = this._tokenStream,
  2828. args = [
  2829. this._type_selector,
  2830. this._universal,
  2831. function() {
  2832. return tokenStream.match(Tokens.HASH) ?
  2833. new SelectorSubPart(tokenStream.token().value, "id", tokenStream.token().startLine, tokenStream.token().startCol) :
  2834. null;
  2835. },
  2836. this._class,
  2837. this._attrib,
  2838. this._pseudo
  2839. ],
  2840. arg = null,
  2841. i = 0,
  2842. len = args.length,
  2843. line,
  2844. col,
  2845. part;
  2846. line = tokenStream.LT(1).startLine;
  2847. col = tokenStream.LT(1).startCol;
  2848. while (i < len && arg === null) {
  2849. arg = args[i].call(this);
  2850. i++;
  2851. }
  2852. if (arg === null) {
  2853. this._unexpectedToken(tokenStream.LT(1));
  2854. }
  2855. if (arg.type === "elementName") {
  2856. part = new SelectorPart(arg, [], arg.toString(), line, col);
  2857. } else {
  2858. part = new SelectorPart(null, [arg], arg.toString(), line, col);
  2859. }
  2860. return part;
  2861. },
  2862. _declaration: function() {
  2863. var tokenStream = this._tokenStream,
  2864. property = null,
  2865. expr = null,
  2866. prio = null,
  2867. invalid = null,
  2868. propertyName = "";
  2869. property = this._property();
  2870. if (property !== null) {
  2871. tokenStream.mustMatch(Tokens.COLON);
  2872. this._readWhitespace();
  2873. expr = this._expr();
  2874. if (!expr || expr.length === 0) {
  2875. this._unexpectedToken(tokenStream.LT(1));
  2876. }
  2877. prio = this._prio();
  2878. propertyName = property.toString();
  2879. if (this.options.starHack && property.hack === "*" ||
  2880. this.options.underscoreHack && property.hack === "_") {
  2881. propertyName = property.text;
  2882. }
  2883. try {
  2884. this._validateProperty(propertyName, expr);
  2885. } catch (ex) {
  2886. invalid = ex;
  2887. }
  2888. this.fire({
  2889. type: "property",
  2890. property: property,
  2891. value: expr,
  2892. important: prio,
  2893. line: property.line,
  2894. col: property.col,
  2895. invalid: invalid
  2896. });
  2897. return true;
  2898. } else {
  2899. return false;
  2900. }
  2901. },
  2902. _prio: function() {
  2903. var tokenStream = this._tokenStream,
  2904. result = tokenStream.match(Tokens.IMPORTANT_SYM);
  2905. this._readWhitespace();
  2906. return result;
  2907. },
  2908. _expr: function(inFunction) {
  2909. var values = [],
  2910. value = null,
  2911. operator = null;
  2912. value = this._term(inFunction);
  2913. if (value !== null) {
  2914. values.push(value);
  2915. do {
  2916. operator = this._operator(inFunction);
  2917. if (operator) {
  2918. values.push(operator);
  2919. } /*else {
  2920. values.push(new PropertyValue(valueParts, valueParts[0].line, valueParts[0].col));
  2921. valueParts = [];
  2922. }*/
  2923. value = this._term(inFunction);
  2924. if (value === null) {
  2925. break;
  2926. } else {
  2927. values.push(value);
  2928. }
  2929. } while (true);
  2930. }
  2931. return values.length > 0 ? new PropertyValue(values, values[0].line, values[0].col) : null;
  2932. },
  2933. _term: function(inFunction) {
  2934. var tokenStream = this._tokenStream,
  2935. unary = null,
  2936. value = null,
  2937. endChar = null,
  2938. part = null,
  2939. token,
  2940. line,
  2941. col;
  2942. unary = this._unary_operator();
  2943. if (unary !== null) {
  2944. line = tokenStream.token().startLine;
  2945. col = tokenStream.token().startCol;
  2946. }
  2947. if (tokenStream.peek() === Tokens.IE_FUNCTION && this.options.ieFilters) {
  2948. value = this._ie_function();
  2949. if (unary === null) {
  2950. line = tokenStream.token().startLine;
  2951. col = tokenStream.token().startCol;
  2952. }
  2953. } else if (inFunction && tokenStream.match([Tokens.LPAREN, Tokens.LBRACE, Tokens.LBRACKET])) {
  2954. token = tokenStream.token();
  2955. endChar = token.endChar;
  2956. value = token.value + this._expr(inFunction).text;
  2957. if (unary === null) {
  2958. line = tokenStream.token().startLine;
  2959. col = tokenStream.token().startCol;
  2960. }
  2961. tokenStream.mustMatch(Tokens.type(endChar));
  2962. value += endChar;
  2963. this._readWhitespace();
  2964. } else if (tokenStream.match([Tokens.NUMBER, Tokens.PERCENTAGE, Tokens.LENGTH,
  2965. Tokens.ANGLE, Tokens.TIME,
  2966. Tokens.FREQ, Tokens.STRING, Tokens.IDENT, Tokens.URI, Tokens.UNICODE_RANGE])) {
  2967. value = tokenStream.token().value;
  2968. if (unary === null) {
  2969. line = tokenStream.token().startLine;
  2970. col = tokenStream.token().startCol;
  2971. part = PropertyValuePart.fromToken(tokenStream.token());
  2972. }
  2973. this._readWhitespace();
  2974. } else {
  2975. token = this._hexcolor();
  2976. if (token === null) {
  2977. if (unary === null) {
  2978. line = tokenStream.LT(1).startLine;
  2979. col = tokenStream.LT(1).startCol;
  2980. }
  2981. if (value === null) {
  2982. if (tokenStream.LA(3) === Tokens.EQUALS && this.options.ieFilters) {
  2983. value = this._ie_function();
  2984. } else {
  2985. value = this._function();
  2986. }
  2987. }
  2988. } else {
  2989. value = token.value;
  2990. if (unary === null) {
  2991. line = token.startLine;
  2992. col = token.startCol;
  2993. }
  2994. }
  2995. }
  2996. return part !== null ? part : value !== null ?
  2997. new PropertyValuePart(unary !== null ? unary + value : value, line, col) :
  2998. null;
  2999. },
  3000. _function: function() {
  3001. var tokenStream = this._tokenStream,
  3002. functionText = null,
  3003. expr = null,
  3004. lt;
  3005. if (tokenStream.match(Tokens.FUNCTION)) {
  3006. functionText = tokenStream.token().value;
  3007. this._readWhitespace();
  3008. expr = this._expr(true);
  3009. functionText += expr;
  3010. if (this.options.ieFilters && tokenStream.peek() === Tokens.EQUALS) {
  3011. do {
  3012. if (this._readWhitespace()) {
  3013. functionText += tokenStream.token().value;
  3014. }
  3015. if (tokenStream.LA(0) === Tokens.COMMA) {
  3016. functionText += tokenStream.token().value;
  3017. }
  3018. tokenStream.match(Tokens.IDENT);
  3019. functionText += tokenStream.token().value;
  3020. tokenStream.match(Tokens.EQUALS);
  3021. functionText += tokenStream.token().value;
  3022. lt = tokenStream.peek();
  3023. while (lt !== Tokens.COMMA && lt !== Tokens.S && lt !== Tokens.RPAREN) {
  3024. tokenStream.get();
  3025. functionText += tokenStream.token().value;
  3026. lt = tokenStream.peek();
  3027. }
  3028. } while (tokenStream.match([Tokens.COMMA, Tokens.S]));
  3029. }
  3030. tokenStream.match(Tokens.RPAREN);
  3031. functionText += ")";
  3032. this._readWhitespace();
  3033. }
  3034. return functionText;
  3035. },
  3036. _ie_function: function() {
  3037. var tokenStream = this._tokenStream,
  3038. functionText = null,
  3039. lt;
  3040. if (tokenStream.match([Tokens.IE_FUNCTION, Tokens.FUNCTION])) {
  3041. functionText = tokenStream.token().value;
  3042. do {
  3043. if (this._readWhitespace()) {
  3044. functionText += tokenStream.token().value;
  3045. }
  3046. if (tokenStream.LA(0) === Tokens.COMMA) {
  3047. functionText += tokenStream.token().value;
  3048. }
  3049. tokenStream.match(Tokens.IDENT);
  3050. functionText += tokenStream.token().value;
  3051. tokenStream.match(Tokens.EQUALS);
  3052. functionText += tokenStream.token().value;
  3053. lt = tokenStream.peek();
  3054. while (lt !== Tokens.COMMA && lt !== Tokens.S && lt !== Tokens.RPAREN) {
  3055. tokenStream.get();
  3056. functionText += tokenStream.token().value;
  3057. lt = tokenStream.peek();
  3058. }
  3059. } while (tokenStream.match([Tokens.COMMA, Tokens.S]));
  3060. tokenStream.match(Tokens.RPAREN);
  3061. functionText += ")";
  3062. this._readWhitespace();
  3063. }
  3064. return functionText;
  3065. },
  3066. _hexcolor: function() {
  3067. var tokenStream = this._tokenStream,
  3068. token = null,
  3069. color;
  3070. if (tokenStream.match(Tokens.HASH)) {
  3071. token = tokenStream.token();
  3072. color = token.value;
  3073. if (!/#[a-f0-9]{3,6}/i.test(color)) {
  3074. throw new SyntaxError("Expected a hex color but found '" + color + "' at line " + token.startLine + ", col " + token.startCol + ".", token.startLine, token.startCol);
  3075. }
  3076. this._readWhitespace();
  3077. }
  3078. return token;
  3079. },
  3080. _keyframes: function() {
  3081. var tokenStream = this._tokenStream,
  3082. token,
  3083. tt,
  3084. name,
  3085. prefix = "";
  3086. tokenStream.mustMatch(Tokens.KEYFRAMES_SYM);
  3087. token = tokenStream.token();
  3088. if (/^@-([^-]+)-/.test(token.value)) {
  3089. prefix = RegExp.$1;
  3090. }
  3091. this._readWhitespace();
  3092. name = this._keyframe_name();
  3093. this._readWhitespace();
  3094. tokenStream.mustMatch(Tokens.LBRACE);
  3095. this.fire({
  3096. type: "startkeyframes",
  3097. name: name,
  3098. prefix: prefix,
  3099. line: token.startLine,
  3100. col: token.startCol
  3101. });
  3102. this._readWhitespace();
  3103. tt = tokenStream.peek();
  3104. while (tt === Tokens.IDENT || tt === Tokens.PERCENTAGE) {
  3105. this._keyframe_rule();
  3106. this._readWhitespace();
  3107. tt = tokenStream.peek();
  3108. }
  3109. this.fire({
  3110. type: "endkeyframes",
  3111. name: name,
  3112. prefix: prefix,
  3113. line: token.startLine,
  3114. col: token.startCol
  3115. });
  3116. this._readWhitespace();
  3117. tokenStream.mustMatch(Tokens.RBRACE);
  3118. this._readWhitespace();
  3119. },
  3120. _keyframe_name: function() {
  3121. var tokenStream = this._tokenStream;
  3122. tokenStream.mustMatch([Tokens.IDENT, Tokens.STRING]);
  3123. return SyntaxUnit.fromToken(tokenStream.token());
  3124. },
  3125. _keyframe_rule: function() {
  3126. var keyList = this._key_list();
  3127. this.fire({
  3128. type: "startkeyframerule",
  3129. keys: keyList,
  3130. line: keyList[0].line,
  3131. col: keyList[0].col
  3132. });
  3133. this._readDeclarations(true);
  3134. this.fire({
  3135. type: "endkeyframerule",
  3136. keys: keyList,
  3137. line: keyList[0].line,
  3138. col: keyList[0].col
  3139. });
  3140. },
  3141. _key_list: function() {
  3142. var tokenStream = this._tokenStream,
  3143. keyList = [];
  3144. keyList.push(this._key());
  3145. this._readWhitespace();
  3146. while (tokenStream.match(Tokens.COMMA)) {
  3147. this._readWhitespace();
  3148. keyList.push(this._key());
  3149. this._readWhitespace();
  3150. }
  3151. return keyList;
  3152. },
  3153. _key: function() {
  3154. var tokenStream = this._tokenStream,
  3155. token;
  3156. if (tokenStream.match(Tokens.PERCENTAGE)) {
  3157. return SyntaxUnit.fromToken(tokenStream.token());
  3158. } else if (tokenStream.match(Tokens.IDENT)) {
  3159. token = tokenStream.token();
  3160. if (/from|to/i.test(token.value)) {
  3161. return SyntaxUnit.fromToken(token);
  3162. }
  3163. tokenStream.unget();
  3164. }
  3165. this._unexpectedToken(tokenStream.LT(1));
  3166. },
  3167. _skipCruft: function() {
  3168. while (this._tokenStream.match([Tokens.S, Tokens.CDO, Tokens.CDC])) {
  3169. }
  3170. },
  3171. _readDeclarations: function(checkStart, readMargins) {
  3172. var tokenStream = this._tokenStream,
  3173. tt;
  3174. this._readWhitespace();
  3175. if (checkStart) {
  3176. tokenStream.mustMatch(Tokens.LBRACE);
  3177. }
  3178. this._readWhitespace();
  3179. try {
  3180. while (true) {
  3181. if (tokenStream.match(Tokens.SEMICOLON) || (readMargins && this._margin())) {
  3182. } else if (this._declaration()) {
  3183. if (!tokenStream.match(Tokens.SEMICOLON)) {
  3184. break;
  3185. }
  3186. } else {
  3187. break;
  3188. }
  3189. this._readWhitespace();
  3190. }
  3191. tokenStream.mustMatch(Tokens.RBRACE);
  3192. this._readWhitespace();
  3193. } catch (ex) {
  3194. if (ex instanceof SyntaxError && !this.options.strict) {
  3195. this.fire({
  3196. type: "error",
  3197. error: ex,
  3198. message: ex.message,
  3199. line: ex.line,
  3200. col: ex.col
  3201. });
  3202. tt = tokenStream.advance([Tokens.SEMICOLON, Tokens.RBRACE]);
  3203. if (tt === Tokens.SEMICOLON) {
  3204. this._readDeclarations(false, readMargins);
  3205. } else if (tt !== Tokens.RBRACE) {
  3206. throw ex;
  3207. }
  3208. } else {
  3209. throw ex;
  3210. }
  3211. }
  3212. },
  3213. _readWhitespace: function() {
  3214. var tokenStream = this._tokenStream,
  3215. ws = "";
  3216. while (tokenStream.match(Tokens.S)) {
  3217. ws += tokenStream.token().value;
  3218. }
  3219. return ws;
  3220. },
  3221. _unexpectedToken: function(token) {
  3222. throw new SyntaxError("Unexpected token '" + token.value + "' at line " + token.startLine + ", col " + token.startCol + ".", token.startLine, token.startCol);
  3223. },
  3224. _verifyEnd: function() {
  3225. if (this._tokenStream.LA(1) !== Tokens.EOF) {
  3226. this._unexpectedToken(this._tokenStream.LT(1));
  3227. }
  3228. },
  3229. _validateProperty: function(property, value) {
  3230. Validation.validate(property, value);
  3231. },
  3232. parse: function(input) {
  3233. this._tokenStream = new TokenStream(input, Tokens);
  3234. this._stylesheet();
  3235. },
  3236. parseStyleSheet: function(input) {
  3237. return this.parse(input);
  3238. },
  3239. parseMediaQuery: function(input) {
  3240. this._tokenStream = new TokenStream(input, Tokens);
  3241. var result = this._media_query();
  3242. this._verifyEnd();
  3243. return result;
  3244. },
  3245. parsePropertyValue: function(input) {
  3246. this._tokenStream = new TokenStream(input, Tokens);
  3247. this._readWhitespace();
  3248. var result = this._expr();
  3249. this._readWhitespace();
  3250. this._verifyEnd();
  3251. return result;
  3252. },
  3253. parseRule: function(input) {
  3254. this._tokenStream = new TokenStream(input, Tokens);
  3255. this._readWhitespace();
  3256. var result = this._ruleset();
  3257. this._readWhitespace();
  3258. this._verifyEnd();
  3259. return result;
  3260. },
  3261. parseSelector: function(input) {
  3262. this._tokenStream = new TokenStream(input, Tokens);
  3263. this._readWhitespace();
  3264. var result = this._selector();
  3265. this._readWhitespace();
  3266. this._verifyEnd();
  3267. return result;
  3268. },
  3269. parseStyleAttribute: function(input) {
  3270. input += "}"; // for error recovery in _readDeclarations()
  3271. this._tokenStream = new TokenStream(input, Tokens);
  3272. this._readDeclarations();
  3273. }
  3274. };
  3275. for (prop in additions) {
  3276. if (Object.prototype.hasOwnProperty.call(additions, prop)) {
  3277. proto[prop] = additions[prop];
  3278. }
  3279. }
  3280. return proto;
  3281. }();
  3282. },{"../util/EventTarget":23,"../util/SyntaxError":25,"../util/SyntaxUnit":26,"./Combinator":2,"./MediaFeature":4,"./MediaQuery":5,"./PropertyName":8,"./PropertyValue":9,"./PropertyValuePart":11,"./Selector":13,"./SelectorPart":14,"./SelectorSubPart":15,"./TokenStream":17,"./Tokens":18,"./Validation":19}],7:[function(require,module,exports){
  3283. "use strict";
  3284. var Properties = module.exports = {
  3285. __proto__: null,
  3286. "align-items" : "flex-start | flex-end | center | baseline | stretch",
  3287. "align-content" : "flex-start | flex-end | center | space-between | space-around | stretch",
  3288. "align-self" : "auto | flex-start | flex-end | center | baseline | stretch",
  3289. "all" : "initial | inherit | unset",
  3290. "-webkit-align-items" : "flex-start | flex-end | center | baseline | stretch",
  3291. "-webkit-align-content" : "flex-start | flex-end | center | space-between | space-around | stretch",
  3292. "-webkit-align-self" : "auto | flex-start | flex-end | center | baseline | stretch",
  3293. "alignment-adjust" : "auto | baseline | before-edge | text-before-edge | middle | central | after-edge | text-after-edge | ideographic | alphabetic | hanging | mathematical | <percentage> | <length>",
  3294. "alignment-baseline" : "auto | baseline | use-script | before-edge | text-before-edge | after-edge | text-after-edge | central | middle | ideographic | alphabetic | hanging | mathematical",
  3295. "animation" : 1,
  3296. "animation-delay" : "<time>#",
  3297. "animation-direction" : "<single-animation-direction>#",
  3298. "animation-duration" : "<time>#",
  3299. "animation-fill-mode" : "[ none | forwards | backwards | both ]#",
  3300. "animation-iteration-count" : "[ <number> | infinite ]#",
  3301. "animation-name" : "[ none | <single-animation-name> ]#",
  3302. "animation-play-state" : "[ running | paused ]#",
  3303. "animation-timing-function" : 1,
  3304. "-moz-animation-delay" : "<time>#",
  3305. "-moz-animation-direction" : "[ normal | alternate ]#",
  3306. "-moz-animation-duration" : "<time>#",
  3307. "-moz-animation-iteration-count" : "[ <number> | infinite ]#",
  3308. "-moz-animation-name" : "[ none | <single-animation-name> ]#",
  3309. "-moz-animation-play-state" : "[ running | paused ]#",
  3310. "-ms-animation-delay" : "<time>#",
  3311. "-ms-animation-direction" : "[ normal | alternate ]#",
  3312. "-ms-animation-duration" : "<time>#",
  3313. "-ms-animation-iteration-count" : "[ <number> | infinite ]#",
  3314. "-ms-animation-name" : "[ none | <single-animation-name> ]#",
  3315. "-ms-animation-play-state" : "[ running | paused ]#",
  3316. "-webkit-animation-delay" : "<time>#",
  3317. "-webkit-animation-direction" : "[ normal | alternate ]#",
  3318. "-webkit-animation-duration" : "<time>#",
  3319. "-webkit-animation-fill-mode" : "[ none | forwards | backwards | both ]#",
  3320. "-webkit-animation-iteration-count" : "[ <number> | infinite ]#",
  3321. "-webkit-animation-name" : "[ none | <single-animation-name> ]#",
  3322. "-webkit-animation-play-state" : "[ running | paused ]#",
  3323. "-o-animation-delay" : "<time>#",
  3324. "-o-animation-direction" : "[ normal | alternate ]#",
  3325. "-o-animation-duration" : "<time>#",
  3326. "-o-animation-iteration-count" : "[ <number> | infinite ]#",
  3327. "-o-animation-name" : "[ none | <single-animation-name> ]#",
  3328. "-o-animation-play-state" : "[ running | paused ]#",
  3329. "appearance" : "none | auto",
  3330. "-moz-appearance" : "none | button | button-arrow-down | button-arrow-next | button-arrow-previous | button-arrow-up | button-bevel | button-focus | caret | checkbox | checkbox-container | checkbox-label | checkmenuitem | dualbutton | groupbox | listbox | listitem | menuarrow | menubar | menucheckbox | menuimage | menuitem | menuitemtext | menulist | menulist-button | menulist-text | menulist-textfield | menupopup | menuradio | menuseparator | meterbar | meterchunk | progressbar | progressbar-vertical | progresschunk | progresschunk-vertical | radio | radio-container | radio-label | radiomenuitem | range | range-thumb | resizer | resizerpanel | scale-horizontal | scalethumbend | scalethumb-horizontal | scalethumbstart | scalethumbtick | scalethumb-vertical | scale-vertical | scrollbarbutton-down | scrollbarbutton-left | scrollbarbutton-right | scrollbarbutton-up | scrollbarthumb-horizontal | scrollbarthumb-vertical | scrollbartrack-horizontal | scrollbartrack-vertical | searchfield | separator | sheet | spinner | spinner-downbutton | spinner-textfield | spinner-upbutton | splitter | statusbar | statusbarpanel | tab | tabpanel | tabpanels | tab-scroll-arrow-back | tab-scroll-arrow-forward | textfield | textfield-multiline | toolbar | toolbarbutton | toolbarbutton-dropdown | toolbargripper | toolbox | tooltip | treeheader | treeheadercell | treeheadersortarrow | treeitem | treeline | treetwisty | treetwistyopen | treeview | -moz-mac-unified-toolbar | -moz-win-borderless-glass | -moz-win-browsertabbar-toolbox | -moz-win-communicationstext | -moz-win-communications-toolbox | -moz-win-exclude-glass | -moz-win-glass | -moz-win-mediatext | -moz-win-media-toolbox | -moz-window-button-box | -moz-window-button-box-maximized | -moz-window-button-close | -moz-window-button-maximize | -moz-window-button-minimize | -moz-window-button-restore | -moz-window-frame-bottom | -moz-window-frame-left | -moz-window-frame-right | -moz-window-titlebar | -moz-window-titlebar-maximized",
  3331. "-ms-appearance" : "none | icon | window | desktop | workspace | document | tooltip | dialog | button | push-button | hyperlink | radio | radio-button | checkbox | menu-item | tab | menu | menubar | pull-down-menu | pop-up-menu | list-menu | radio-group | checkbox-group | outline-tree | range | field | combo-box | signature | password | normal",
  3332. "-webkit-appearance" : "none | button | button-bevel | caps-lock-indicator | caret | checkbox | default-button | listbox | listitem | media-fullscreen-button | media-mute-button | media-play-button | media-seek-back-button | media-seek-forward-button | media-slider | media-sliderthumb | menulist | menulist-button | menulist-text | menulist-textfield | push-button | radio | searchfield | searchfield-cancel-button | searchfield-decoration | searchfield-results-button | searchfield-results-decoration | slider-horizontal | slider-vertical | sliderthumb-horizontal | sliderthumb-vertical | square-button | textarea | textfield | scrollbarbutton-down | scrollbarbutton-left | scrollbarbutton-right | scrollbarbutton-up | scrollbargripper-horizontal | scrollbargripper-vertical | scrollbarthumb-horizontal | scrollbarthumb-vertical | scrollbartrack-horizontal | scrollbartrack-vertical",
  3333. "-o-appearance" : "none | window | desktop | workspace | document | tooltip | dialog | button | push-button | hyperlink | radio | radio-button | checkbox | menu-item | tab | menu | menubar | pull-down-menu | pop-up-menu | list-menu | radio-group | checkbox-group | outline-tree | range | field | combo-box | signature | password | normal",
  3334. "azimuth" : "<azimuth>",
  3335. "backface-visibility" : "visible | hidden",
  3336. "background" : 1,
  3337. "background-attachment" : "<attachment>#",
  3338. "background-clip" : "<box>#",
  3339. "background-color" : "<color>",
  3340. "background-image" : "<bg-image>#",
  3341. "background-origin" : "<box>#",
  3342. "background-position" : "<bg-position>",
  3343. "background-repeat" : "<repeat-style>#",
  3344. "background-size" : "<bg-size>#",
  3345. "baseline-shift" : "baseline | sub | super | <percentage> | <length>",
  3346. "behavior" : 1,
  3347. "binding" : 1,
  3348. "bleed" : "<length>",
  3349. "bookmark-label" : "<content> | <attr> | <string>",
  3350. "bookmark-level" : "none | <integer>",
  3351. "bookmark-state" : "open | closed",
  3352. "bookmark-target" : "none | <uri> | <attr>",
  3353. "border" : "<border-width> || <border-style> || <color>",
  3354. "border-bottom" : "<border-width> || <border-style> || <color>",
  3355. "border-bottom-color" : "<color>",
  3356. "border-bottom-left-radius" : "<x-one-radius>",
  3357. "border-bottom-right-radius" : "<x-one-radius>",
  3358. "border-bottom-style" : "<border-style>",
  3359. "border-bottom-width" : "<border-width>",
  3360. "border-collapse" : "collapse | separate",
  3361. "border-color" : "<color>{1,4}",
  3362. "border-image" : 1,
  3363. "border-image-outset" : "[ <length> | <number> ]{1,4}",
  3364. "border-image-repeat" : "[ stretch | repeat | round | space ]{1,2}",
  3365. "border-image-slice" : "<border-image-slice>",
  3366. "border-image-source" : "<image> | none",
  3367. "border-image-width" : "[ <length> | <percentage> | <number> | auto ]{1,4}",
  3368. "border-left" : "<border-width> || <border-style> || <color>",
  3369. "border-left-color" : "<color>",
  3370. "border-left-style" : "<border-style>",
  3371. "border-left-width" : "<border-width>",
  3372. "border-radius" : "<border-radius>",
  3373. "border-right" : "<border-width> || <border-style> || <color>",
  3374. "border-right-color" : "<color>",
  3375. "border-right-style" : "<border-style>",
  3376. "border-right-width" : "<border-width>",
  3377. "border-spacing" : "<length>{1,2}",
  3378. "border-style" : "<border-style>{1,4}",
  3379. "border-top" : "<border-width> || <border-style> || <color>",
  3380. "border-top-color" : "<color>",
  3381. "border-top-left-radius" : "<x-one-radius>",
  3382. "border-top-right-radius" : "<x-one-radius>",
  3383. "border-top-style" : "<border-style>",
  3384. "border-top-width" : "<border-width>",
  3385. "border-width" : "<border-width>{1,4}",
  3386. "bottom" : "<margin-width>",
  3387. "-moz-box-align" : "start | end | center | baseline | stretch",
  3388. "-moz-box-decoration-break" : "slice | clone",
  3389. "-moz-box-direction" : "normal | reverse",
  3390. "-moz-box-flex" : "<number>",
  3391. "-moz-box-flex-group" : "<integer>",
  3392. "-moz-box-lines" : "single | multiple",
  3393. "-moz-box-ordinal-group" : "<integer>",
  3394. "-moz-box-orient" : "horizontal | vertical | inline-axis | block-axis",
  3395. "-moz-box-pack" : "start | end | center | justify",
  3396. "-o-box-decoration-break" : "slice | clone",
  3397. "-webkit-box-align" : "start | end | center | baseline | stretch",
  3398. "-webkit-box-decoration-break" : "slice | clone",
  3399. "-webkit-box-direction" : "normal | reverse",
  3400. "-webkit-box-flex" : "<number>",
  3401. "-webkit-box-flex-group" : "<integer>",
  3402. "-webkit-box-lines" : "single | multiple",
  3403. "-webkit-box-ordinal-group" : "<integer>",
  3404. "-webkit-box-orient" : "horizontal | vertical | inline-axis | block-axis",
  3405. "-webkit-box-pack" : "start | end | center | justify",
  3406. "box-decoration-break" : "slice | clone",
  3407. "box-shadow" : "<box-shadow>",
  3408. "box-sizing" : "content-box | border-box",
  3409. "break-after" : "auto | always | avoid | left | right | page | column | avoid-page | avoid-column",
  3410. "break-before" : "auto | always | avoid | left | right | page | column | avoid-page | avoid-column",
  3411. "break-inside" : "auto | avoid | avoid-page | avoid-column",
  3412. "caption-side" : "top | bottom",
  3413. "clear" : "none | right | left | both",
  3414. "clip" : "<shape> | auto",
  3415. "-webkit-clip-path" : "<clip-source> | <clip-path> | none",
  3416. "clip-path" : "<clip-source> | <clip-path> | none",
  3417. "clip-rule" : "nonzero | evenodd",
  3418. "color" : "<color>",
  3419. "color-interpolation" : "auto | sRGB | linearRGB",
  3420. "color-interpolation-filters" : "auto | sRGB | linearRGB",
  3421. "color-profile" : 1,
  3422. "color-rendering" : "auto | optimizeSpeed | optimizeQuality",
  3423. "column-count" : "<integer> | auto", // https ://www.w3.org/TR/css3-multicol/
  3424. "column-fill" : "auto | balance",
  3425. "column-gap" : "<length> | normal",
  3426. "column-rule" : "<border-width> || <border-style> || <color>",
  3427. "column-rule-color" : "<color>",
  3428. "column-rule-style" : "<border-style>",
  3429. "column-rule-width" : "<border-width>",
  3430. "column-span" : "none | all",
  3431. "column-width" : "<length> | auto",
  3432. "columns" : 1,
  3433. "content" : 1,
  3434. "counter-increment" : 1,
  3435. "counter-reset" : 1,
  3436. "crop" : "<shape> | auto",
  3437. "cue" : "cue-after | cue-before",
  3438. "cue-after" : 1,
  3439. "cue-before" : 1,
  3440. "cursor" : 1,
  3441. "direction" : "ltr | rtl",
  3442. "display" : "inline | block | list-item | inline-block | table | inline-table | table-row-group | table-header-group | table-footer-group | table-row | table-column-group | table-column | table-cell | table-caption | grid | inline-grid | run-in | ruby | ruby-base | ruby-text | ruby-base-container | ruby-text-container | contents | none | -moz-box | -moz-inline-block | -moz-inline-box | -moz-inline-grid | -moz-inline-stack | -moz-inline-table | -moz-grid | -moz-grid-group | -moz-grid-line | -moz-groupbox | -moz-deck | -moz-popup | -moz-stack | -moz-marker | -webkit-box | -webkit-inline-box | -ms-flexbox | -ms-inline-flexbox | flex | -webkit-flex | inline-flex | -webkit-inline-flex",
  3443. "dominant-baseline" : "auto | use-script | no-change | reset-size | ideographic | alphabetic | hanging | mathematical | central | middle | text-after-edge | text-before-edge",
  3444. "drop-initial-after-adjust" : "central | middle | after-edge | text-after-edge | ideographic | alphabetic | mathematical | <percentage> | <length>",
  3445. "drop-initial-after-align" : "baseline | use-script | before-edge | text-before-edge | after-edge | text-after-edge | central | middle | ideographic | alphabetic | hanging | mathematical",
  3446. "drop-initial-before-adjust" : "before-edge | text-before-edge | central | middle | hanging | mathematical | <percentage> | <length>",
  3447. "drop-initial-before-align" : "caps-height | baseline | use-script | before-edge | text-before-edge | after-edge | text-after-edge | central | middle | ideographic | alphabetic | hanging | mathematical",
  3448. "drop-initial-size" : "auto | line | <length> | <percentage>",
  3449. "drop-initial-value" : "<integer>",
  3450. "elevation" : "<angle> | below | level | above | higher | lower",
  3451. "empty-cells" : "show | hide",
  3452. "enable-background" : 1,
  3453. "fill" : "<paint>",
  3454. "fill-opacity" : "<opacity-value>",
  3455. "fill-rule" : "nonzero | evenodd",
  3456. "filter" : "<filter-function-list> | none",
  3457. "fit" : "fill | hidden | meet | slice",
  3458. "fit-position" : 1,
  3459. "flex" : "<flex>",
  3460. "flex-basis" : "<width>",
  3461. "flex-direction" : "row | row-reverse | column | column-reverse",
  3462. "flex-flow" : "<flex-direction> || <flex-wrap>",
  3463. "flex-grow" : "<number>",
  3464. "flex-shrink" : "<number>",
  3465. "flex-wrap" : "nowrap | wrap | wrap-reverse",
  3466. "-webkit-flex" : "<flex>",
  3467. "-webkit-flex-basis" : "<width>",
  3468. "-webkit-flex-direction" : "row | row-reverse | column | column-reverse",
  3469. "-webkit-flex-flow" : "<flex-direction> || <flex-wrap>",
  3470. "-webkit-flex-grow" : "<number>",
  3471. "-webkit-flex-shrink" : "<number>",
  3472. "-webkit-flex-wrap" : "nowrap | wrap | wrap-reverse",
  3473. "-ms-flex" : "<flex>",
  3474. "-ms-flex-align" : "start | end | center | stretch | baseline",
  3475. "-ms-flex-direction" : "row | row-reverse | column | column-reverse",
  3476. "-ms-flex-order" : "<number>",
  3477. "-ms-flex-pack" : "start | end | center | justify | distribute",
  3478. "-ms-flex-wrap" : "nowrap | wrap | wrap-reverse",
  3479. "float" : "left | right | none",
  3480. "float-offset" : 1,
  3481. "flood-color" : 1,
  3482. "flood-opacity" : "<opacity-value>",
  3483. "font" : "<font-shorthand> | caption | icon | menu | message-box | small-caption | status-bar",
  3484. "font-family" : "<font-family>",
  3485. "font-feature-settings" : "<feature-tag-value> | normal",
  3486. "font-kerning" : "auto | normal | none",
  3487. "font-size" : "<font-size>",
  3488. "font-size-adjust" : "<number> | none",
  3489. "font-stretch" : "<font-stretch>",
  3490. "font-style" : "<font-style>",
  3491. "font-variant" : "<font-variant> | normal | none",
  3492. "font-variant-alternates" : "<font-variant-alternates> | normal",
  3493. "font-variant-caps" : "<font-variant-caps> | normal",
  3494. "font-variant-east-asian" : "<font-variant-east-asian> | normal",
  3495. "font-variant-ligatures" : "<font-variant-ligatures> | normal | none",
  3496. "font-variant-numeric" : "<font-variant-numeric> | normal",
  3497. "font-variant-position" : "normal | sub | super",
  3498. "font-weight" : "<font-weight>",
  3499. "gap" : "[ <length> | <percentage> ]{1,2}",
  3500. "glyph-orientation-horizontal" : "<glyph-angle>",
  3501. "glyph-orientation-vertical" : "auto | <glyph-angle>",
  3502. "grid" : 1,
  3503. "grid-area" : 1,
  3504. "grid-auto-columns" : 1,
  3505. "grid-auto-flow" : 1,
  3506. "grid-auto-position" : 1,
  3507. "grid-auto-rows" : 1,
  3508. "grid-cell-stacking" : "columns | rows | layer",
  3509. "grid-column" : 1,
  3510. "grid-columns" : 1,
  3511. "grid-column-align" : "start | end | center | stretch",
  3512. "grid-column-sizing" : 1,
  3513. "grid-column-start" : 1,
  3514. "grid-column-end" : 1,
  3515. "grid-column-span" : "<integer>",
  3516. "grid-flow" : "none | rows | columns",
  3517. "grid-gap" : "[ <length> | <percentage> ]{1,2}",
  3518. "grid-layer" : "<integer>",
  3519. "grid-row" : 1,
  3520. "grid-rows" : 1,
  3521. "grid-row-align" : "start | end | center | stretch",
  3522. "grid-row-gap" : 1,
  3523. "grid-row-start" : 1,
  3524. "grid-row-end" : 1,
  3525. "grid-row-span" : "<integer>",
  3526. "grid-row-sizing" : 1,
  3527. "grid-template" : 1,
  3528. "grid-template-areas" : 1,
  3529. "grid-template-columns" : 1,
  3530. "grid-template-rows" : 1,
  3531. "hanging-punctuation" : 1,
  3532. "height" : "<margin-width> | <content-sizing>",
  3533. "hyphenate-after" : "<integer> | auto",
  3534. "hyphenate-before" : "<integer> | auto",
  3535. "hyphenate-character" : "<string> | auto",
  3536. "hyphenate-lines" : "no-limit | <integer>",
  3537. "hyphenate-resource" : 1,
  3538. "hyphens" : "none | manual | auto",
  3539. "icon" : 1,
  3540. "image-orientation" : "angle | auto",
  3541. "image-rendering" : "auto | optimizeSpeed | optimizeQuality",
  3542. "image-resolution" : 1,
  3543. "ime-mode" : "auto | normal | active | inactive | disabled",
  3544. "inline-box-align" : "last | <integer>",
  3545. "justify-content" : "flex-start | flex-end | center | space-between | space-around | space-evenly | stretch",
  3546. "-webkit-justify-content" : "flex-start | flex-end | center | space-between | space-around | space-evenly | stretch",
  3547. "kerning" : "auto | <length>",
  3548. "left" : "<margin-width>",
  3549. "letter-spacing" : "<length> | normal",
  3550. "line-height" : "<line-height>",
  3551. "line-break" : "auto | loose | normal | strict",
  3552. "line-stacking" : 1,
  3553. "line-stacking-ruby" : "exclude-ruby | include-ruby",
  3554. "line-stacking-shift" : "consider-shifts | disregard-shifts",
  3555. "line-stacking-strategy" : "inline-line-height | block-line-height | max-height | grid-height",
  3556. "list-style" : 1,
  3557. "list-style-image" : "<uri> | none",
  3558. "list-style-position" : "inside | outside",
  3559. "list-style-type" : "disc | circle | square | decimal | decimal-leading-zero | lower-roman | upper-roman | lower-greek | lower-latin | upper-latin | armenian | georgian | lower-alpha | upper-alpha | none",
  3560. "margin" : "<margin-width>{1,4}",
  3561. "margin-bottom" : "<margin-width>",
  3562. "margin-left" : "<margin-width>",
  3563. "margin-right" : "<margin-width>",
  3564. "margin-top" : "<margin-width>",
  3565. "mark" : 1,
  3566. "mark-after" : 1,
  3567. "mark-before" : 1,
  3568. "marker" : 1,
  3569. "marker-end" : 1,
  3570. "marker-mid" : 1,
  3571. "marker-start" : 1,
  3572. "marks" : 1,
  3573. "marquee-direction" : 1,
  3574. "marquee-play-count" : 1,
  3575. "marquee-speed" : 1,
  3576. "marquee-style" : 1,
  3577. "mask" : 1,
  3578. "max-height" : "<length> | <percentage> | <content-sizing> | none",
  3579. "max-width" : "<length> | <percentage> | <content-sizing> | none",
  3580. "min-height" : "<length> | <percentage> | <content-sizing> | contain-floats | -moz-contain-floats | -webkit-contain-floats",
  3581. "min-width" : "<length> | <percentage> | <content-sizing> | contain-floats | -moz-contain-floats | -webkit-contain-floats",
  3582. "mix-blend-mode" : "<blend-mode>",
  3583. "move-to" : 1,
  3584. "nav-down" : 1,
  3585. "nav-index" : 1,
  3586. "nav-left" : 1,
  3587. "nav-right" : 1,
  3588. "nav-up" : 1,
  3589. "object-fit" : "fill | contain | cover | none | scale-down",
  3590. "object-position" : "<position>",
  3591. "opacity" : "<opacity-value>",
  3592. "order" : "<integer>",
  3593. "-webkit-order" : "<integer>",
  3594. "orphans" : "<integer>",
  3595. "outline" : 1,
  3596. "outline-color" : "<color> | invert",
  3597. "outline-offset" : 1,
  3598. "outline-style" : "<border-style>",
  3599. "outline-width" : "<border-width>",
  3600. "overflow" : "visible | hidden | scroll | auto",
  3601. "overflow-style" : 1,
  3602. "overflow-wrap" : "normal | break-word",
  3603. "overflow-x" : 1,
  3604. "overflow-y" : 1,
  3605. "padding" : "<padding-width>{1,4}",
  3606. "padding-bottom" : "<padding-width>",
  3607. "padding-left" : "<padding-width>",
  3608. "padding-right" : "<padding-width>",
  3609. "padding-top" : "<padding-width>",
  3610. "page" : 1,
  3611. "page-break-after" : "auto | always | avoid | left | right",
  3612. "page-break-before" : "auto | always | avoid | left | right",
  3613. "page-break-inside" : "auto | avoid",
  3614. "page-policy" : 1,
  3615. "pause" : 1,
  3616. "pause-after" : 1,
  3617. "pause-before" : 1,
  3618. "perspective" : 1,
  3619. "perspective-origin" : 1,
  3620. "phonemes" : 1,
  3621. "pitch" : 1,
  3622. "pitch-range" : 1,
  3623. "play-during" : 1,
  3624. "pointer-events" : "auto | none | visiblePainted | visibleFill | visibleStroke | visible | painted | fill | stroke | all",
  3625. "position" : "static | relative | absolute | fixed | sticky | -webkit-sticky",
  3626. "presentation-level" : 1,
  3627. "punctuation-trim" : 1,
  3628. "quotes" : 1,
  3629. "rendering-intent" : 1,
  3630. "resize" : 1,
  3631. "rest" : 1,
  3632. "rest-after" : 1,
  3633. "rest-before" : 1,
  3634. "richness" : 1,
  3635. "right" : "<margin-width>",
  3636. "rotation" : 1,
  3637. "rotation-point" : 1,
  3638. "ruby-align" : 1,
  3639. "ruby-overhang" : 1,
  3640. "ruby-position" : 1,
  3641. "ruby-span" : 1,
  3642. "shape-rendering" : "auto | optimizeSpeed | crispEdges | geometricPrecision",
  3643. "size" : 1,
  3644. "speak" : "normal | none | spell-out",
  3645. "speak-header" : "once | always",
  3646. "speak-numeral" : "digits | continuous",
  3647. "speak-punctuation" : "code | none",
  3648. "speech-rate" : 1,
  3649. "src" : 1,
  3650. "stop-color" : 1,
  3651. "stop-opacity" : "<opacity-value>",
  3652. "stress" : 1,
  3653. "string-set" : 1,
  3654. "stroke" : "<paint>",
  3655. "stroke-dasharray" : "none | <dasharray>",
  3656. "stroke-dashoffset" : "<percentage> | <length>",
  3657. "stroke-linecap" : "butt | round | square",
  3658. "stroke-linejoin" : "miter | round | bevel",
  3659. "stroke-miterlimit" : "<miterlimit>",
  3660. "stroke-opacity" : "<opacity-value>",
  3661. "stroke-width" : "<percentage> | <length>",
  3662. "table-layout" : "auto | fixed",
  3663. "tab-size" : "<integer> | <length>",
  3664. "target" : 1,
  3665. "target-name" : 1,
  3666. "target-new" : 1,
  3667. "target-position" : 1,
  3668. "text-align" : "left | right | center | justify | match-parent | start | end",
  3669. "text-align-last" : 1,
  3670. "text-anchor" : "start | middle | end",
  3671. "text-decoration" : "<text-decoration-line> || <text-decoration-style> || <text-decoration-color>",
  3672. "text-decoration-color" : "<text-decoration-color>",
  3673. "text-decoration-line" : "<text-decoration-line>",
  3674. "text-decoration-style" : "<text-decoration-style>",
  3675. "text-decoration-skip" : "none | [ objects || spaces || ink || edges || box-decoration ]",
  3676. "-webkit-text-decoration-skip" : "none | [ objects || spaces || ink || edges || box-decoration ]",
  3677. "text-underline-position" : "auto | [ under || [ left | right ] ]",
  3678. "text-emphasis" : 1,
  3679. "text-height" : 1,
  3680. "text-indent" : "<length> | <percentage>",
  3681. "text-justify" : "auto | none | inter-word | inter-ideograph | inter-cluster | distribute | kashida",
  3682. "text-outline" : 1,
  3683. "text-overflow" : 1,
  3684. "text-rendering" : "auto | optimizeSpeed | optimizeLegibility | geometricPrecision",
  3685. "text-shadow" : 1,
  3686. "text-transform" : "capitalize | uppercase | lowercase | none",
  3687. "text-wrap" : "normal | none | avoid",
  3688. "top" : "<margin-width>",
  3689. "-ms-touch-action" : "auto | none | pan-x | pan-y | pan-left | pan-right | pan-up | pan-down | manipulation",
  3690. "touch-action" : "auto | none | pan-x | pan-y | pan-left | pan-right | pan-up | pan-down | manipulation",
  3691. "transform" : 1,
  3692. "transform-origin" : 1,
  3693. "transform-style" : 1,
  3694. "transition" : 1,
  3695. "transition-delay" : 1,
  3696. "transition-duration" : 1,
  3697. "transition-property" : 1,
  3698. "transition-timing-function" : 1,
  3699. "unicode-bidi" : "normal | embed | isolate | bidi-override | isolate-override | plaintext",
  3700. "user-modify" : "read-only | read-write | write-only",
  3701. "user-select" : "auto | text | none | contain | all",
  3702. "vertical-align" : "auto | use-script | baseline | sub | super | top | text-top | central | middle | bottom | text-bottom | <percentage> | <length>",
  3703. "visibility" : "visible | hidden | collapse",
  3704. "voice-balance" : 1,
  3705. "voice-duration" : 1,
  3706. "voice-family" : 1,
  3707. "voice-pitch" : 1,
  3708. "voice-pitch-range" : 1,
  3709. "voice-rate" : 1,
  3710. "voice-stress" : 1,
  3711. "voice-volume" : 1,
  3712. "volume" : 1,
  3713. "white-space" : "normal | pre | nowrap | pre-wrap | pre-line | -pre-wrap | -o-pre-wrap | -moz-pre-wrap | -hp-pre-wrap", // https ://perishablepress.com/wrapping-content/
  3714. "white-space-collapse" : 1,
  3715. "widows" : "<integer>",
  3716. "width" : "<length> | <percentage> | <content-sizing> | auto",
  3717. "will-change" : "<will-change>",
  3718. "word-break" : "normal | keep-all | break-all | break-word",
  3719. "word-spacing" : "<length> | normal",
  3720. "word-wrap" : "normal | break-word",
  3721. "writing-mode" : "horizontal-tb | vertical-rl | vertical-lr | lr-tb | rl-tb | tb-rl | bt-rl | tb-lr | bt-lr | lr-bt | rl-bt | lr | rl | tb",
  3722. "z-index" : "<integer> | auto",
  3723. "zoom" : "<number> | <percentage> | normal"
  3724. };
  3725. },{}],8:[function(require,module,exports){
  3726. "use strict";
  3727. module.exports = PropertyName;
  3728. var SyntaxUnit = require("../util/SyntaxUnit");
  3729. var Parser = require("./Parser");
  3730. function PropertyName(text, hack, line, col) {
  3731. SyntaxUnit.call(this, text, line, col, Parser.PROPERTY_NAME_TYPE);
  3732. this.hack = hack;
  3733. }
  3734. PropertyName.prototype = new SyntaxUnit();
  3735. PropertyName.prototype.constructor = PropertyName;
  3736. PropertyName.prototype.toString = function() {
  3737. return (this.hack ? this.hack : "") + this.text;
  3738. };
  3739. },{"../util/SyntaxUnit":26,"./Parser":6}],9:[function(require,module,exports){
  3740. "use strict";
  3741. module.exports = PropertyValue;
  3742. var SyntaxUnit = require("../util/SyntaxUnit");
  3743. var Parser = require("./Parser");
  3744. function PropertyValue(parts, line, col) {
  3745. SyntaxUnit.call(this, parts.join(" "), line, col, Parser.PROPERTY_VALUE_TYPE);
  3746. this.parts = parts;
  3747. }
  3748. PropertyValue.prototype = new SyntaxUnit();
  3749. PropertyValue.prototype.constructor = PropertyValue;
  3750. },{"../util/SyntaxUnit":26,"./Parser":6}],10:[function(require,module,exports){
  3751. "use strict";
  3752. module.exports = PropertyValueIterator;
  3753. function PropertyValueIterator(value) {
  3754. this._i = 0;
  3755. this._parts = value.parts;
  3756. this._marks = [];
  3757. this.value = value;
  3758. }
  3759. PropertyValueIterator.prototype.count = function() {
  3760. return this._parts.length;
  3761. };
  3762. PropertyValueIterator.prototype.isFirst = function() {
  3763. return this._i === 0;
  3764. };
  3765. PropertyValueIterator.prototype.hasNext = function() {
  3766. return this._i < this._parts.length;
  3767. };
  3768. PropertyValueIterator.prototype.mark = function() {
  3769. this._marks.push(this._i);
  3770. };
  3771. PropertyValueIterator.prototype.peek = function(count) {
  3772. return this.hasNext() ? this._parts[this._i + (count || 0)] : null;
  3773. };
  3774. PropertyValueIterator.prototype.next = function() {
  3775. return this.hasNext() ? this._parts[this._i++] : null;
  3776. };
  3777. PropertyValueIterator.prototype.previous = function() {
  3778. return this._i > 0 ? this._parts[--this._i] : null;
  3779. };
  3780. PropertyValueIterator.prototype.restore = function() {
  3781. if (this._marks.length) {
  3782. this._i = this._marks.pop();
  3783. }
  3784. };
  3785. PropertyValueIterator.prototype.drop = function() {
  3786. this._marks.pop();
  3787. };
  3788. },{}],11:[function(require,module,exports){
  3789. "use strict";
  3790. module.exports = PropertyValuePart;
  3791. var SyntaxUnit = require("../util/SyntaxUnit");
  3792. var Colors = require("./Colors");
  3793. var Parser = require("./Parser");
  3794. var Tokens = require("./Tokens");
  3795. function PropertyValuePart(text, line, col, optionalHint) {
  3796. var hint = optionalHint || {};
  3797. SyntaxUnit.call(this, text, line, col, Parser.PROPERTY_VALUE_PART_TYPE);
  3798. this.type = "unknown";
  3799. var temp;
  3800. if (/^([+-]?[\d.]+)([a-z]+)$/i.test(text)) { // dimension
  3801. this.type = "dimension";
  3802. this.value = Number(RegExp.$1);
  3803. this.units = RegExp.$2;
  3804. switch (this.units.toLowerCase()) {
  3805. case "em":
  3806. case "rem":
  3807. case "ex":
  3808. case "px":
  3809. case "cm":
  3810. case "mm":
  3811. case "in":
  3812. case "pt":
  3813. case "pc":
  3814. case "ch":
  3815. case "vh":
  3816. case "vw":
  3817. case "vmax":
  3818. case "vmin":
  3819. this.type = "length";
  3820. break;
  3821. case "fr":
  3822. this.type = "grid";
  3823. break;
  3824. case "deg":
  3825. case "rad":
  3826. case "grad":
  3827. case "turn":
  3828. this.type = "angle";
  3829. break;
  3830. case "ms":
  3831. case "s":
  3832. this.type = "time";
  3833. break;
  3834. case "hz":
  3835. case "khz":
  3836. this.type = "frequency";
  3837. break;
  3838. case "dpi":
  3839. case "dpcm":
  3840. this.type = "resolution";
  3841. break;
  3842. }
  3843. } else if (/^([+-]?[\d.]+)%$/i.test(text)) { // percentage
  3844. this.type = "percentage";
  3845. this.value = Number(RegExp.$1);
  3846. } else if (/^([+-]?\d+)$/i.test(text)) { // integer
  3847. this.type = "integer";
  3848. this.value = Number(RegExp.$1);
  3849. } else if (/^([+-]?[\d.]+)$/i.test(text)) { // number
  3850. this.type = "number";
  3851. this.value = Number(RegExp.$1);
  3852. } else if (/^#([a-f0-9]{3,6})/i.test(text)) { // hexcolor
  3853. this.type = "color";
  3854. temp = RegExp.$1;
  3855. if (temp.length === 3) {
  3856. this.red = parseInt(temp.charAt(0) + temp.charAt(0), 16);
  3857. this.green = parseInt(temp.charAt(1) + temp.charAt(1), 16);
  3858. this.blue = parseInt(temp.charAt(2) + temp.charAt(2), 16);
  3859. } else {
  3860. this.red = parseInt(temp.substring(0, 2), 16);
  3861. this.green = parseInt(temp.substring(2, 4), 16);
  3862. this.blue = parseInt(temp.substring(4, 6), 16);
  3863. }
  3864. } else if (/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/i.test(text)) { // rgb() color with absolute numbers
  3865. this.type = "color";
  3866. this.red = Number(RegExp.$1);
  3867. this.green = Number(RegExp.$2);
  3868. this.blue = Number(RegExp.$3);
  3869. } else if (/^rgb\(\s*(\d+)%\s*,\s*(\d+)%\s*,\s*(\d+)%\s*\)/i.test(text)) { // rgb() color with percentages
  3870. this.type = "color";
  3871. this.red = Number(RegExp.$1) * 255 / 100;
  3872. this.green = Number(RegExp.$2) * 255 / 100;
  3873. this.blue = Number(RegExp.$3) * 255 / 100;
  3874. } else if (/^rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*([\d.]+)\s*\)/i.test(text)) { // rgba() color with absolute numbers
  3875. this.type = "color";
  3876. this.red = Number(RegExp.$1);
  3877. this.green = Number(RegExp.$2);
  3878. this.blue = Number(RegExp.$3);
  3879. this.alpha = Number(RegExp.$4);
  3880. } else if (/^rgba\(\s*(\d+)%\s*,\s*(\d+)%\s*,\s*(\d+)%\s*,\s*([\d.]+)\s*\)/i.test(text)) { // rgba() color with percentages
  3881. this.type = "color";
  3882. this.red = Number(RegExp.$1) * 255 / 100;
  3883. this.green = Number(RegExp.$2) * 255 / 100;
  3884. this.blue = Number(RegExp.$3) * 255 / 100;
  3885. this.alpha = Number(RegExp.$4);
  3886. } else if (/^hsl\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*\)/i.test(text)) { // hsl()
  3887. this.type = "color";
  3888. this.hue = Number(RegExp.$1);
  3889. this.saturation = Number(RegExp.$2) / 100;
  3890. this.lightness = Number(RegExp.$3) / 100;
  3891. } else if (/^hsla\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*,\s*([\d.]+)\s*\)/i.test(text)) { // hsla() color with percentages
  3892. this.type = "color";
  3893. this.hue = Number(RegExp.$1);
  3894. this.saturation = Number(RegExp.$2) / 100;
  3895. this.lightness = Number(RegExp.$3) / 100;
  3896. this.alpha = Number(RegExp.$4);
  3897. } else if (/^url\(("([^\\"]|\.)*")\)/i.test(text)) { // URI
  3898. this.type = "uri";
  3899. this.uri = PropertyValuePart.parseString(RegExp.$1);
  3900. } else if (/^([^(]+)\(/i.test(text)) {
  3901. this.type = "function";
  3902. this.name = RegExp.$1;
  3903. this.value = text;
  3904. } else if (/^"([^\n\r\f\\"]|\\\r\n|\\[^\r0-9a-f]|\\[0-9a-f]{1,6}(\r\n|[ \n\r\t\f])?)*"/i.test(text)) { // double-quoted string
  3905. this.type = "string";
  3906. this.value = PropertyValuePart.parseString(text);
  3907. } else if (/^'([^\n\r\f\\']|\\\r\n|\\[^\r0-9a-f]|\\[0-9a-f]{1,6}(\r\n|[ \n\r\t\f])?)*'/i.test(text)) { // single-quoted string
  3908. this.type = "string";
  3909. this.value = PropertyValuePart.parseString(text);
  3910. } else if (Colors[text.toLowerCase()]) { // named color
  3911. this.type = "color";
  3912. temp = Colors[text.toLowerCase()].substring(1);
  3913. this.red = parseInt(temp.substring(0, 2), 16);
  3914. this.green = parseInt(temp.substring(2, 4), 16);
  3915. this.blue = parseInt(temp.substring(4, 6), 16);
  3916. } else if (/^[,/]$/.test(text)) {
  3917. this.type = "operator";
  3918. this.value = text;
  3919. } else if (/^-?[a-z_\u00A0-\uFFFF][a-z0-9\-_\u00A0-\uFFFF]*$/i.test(text)) {
  3920. this.type = "identifier";
  3921. this.value = text;
  3922. }
  3923. this.wasIdent = Boolean(hint.ident);
  3924. }
  3925. PropertyValuePart.prototype = new SyntaxUnit();
  3926. PropertyValuePart.prototype.constructor = PropertyValuePart;
  3927. PropertyValuePart.parseString = function(str) {
  3928. str = str.slice(1, -1); // Strip surrounding single/double quotes
  3929. var replacer = function(match, esc) {
  3930. if (/^(\n|\r\n|\r|\f)$/.test(esc)) {
  3931. return "";
  3932. }
  3933. var m = /^[0-9a-f]{1,6}/i.exec(esc);
  3934. if (m) {
  3935. var codePoint = parseInt(m[0], 16);
  3936. if (String.fromCodePoint) {
  3937. return String.fromCodePoint(codePoint);
  3938. } else {
  3939. return String.fromCharCode(codePoint);
  3940. }
  3941. }
  3942. return esc;
  3943. };
  3944. return str.replace(/\\(\r\n|[^\r0-9a-f]|[0-9a-f]{1,6}(\r\n|[ \n\r\t\f])?)/ig,
  3945. replacer);
  3946. };
  3947. PropertyValuePart.serializeString = function(value) {
  3948. var replacer = function(match, c) {
  3949. if (c === "\"") {
  3950. return "\\" + c;
  3951. }
  3952. var cp = String.codePointAt ? String.codePointAt(0) :
  3953. String.charCodeAt(0);
  3954. return "\\" + cp.toString(16) + " ";
  3955. };
  3956. return "\"" + value.replace(/["\r\n\f]/g, replacer) + "\"";
  3957. };
  3958. PropertyValuePart.fromToken = function(token) {
  3959. var part = new PropertyValuePart(token.value, token.startLine, token.startCol, {
  3960. ident: token.type === Tokens.IDENT
  3961. });
  3962. return part;
  3963. };
  3964. },{"../util/SyntaxUnit":26,"./Colors":1,"./Parser":6,"./Tokens":18}],12:[function(require,module,exports){
  3965. "use strict";
  3966. var Pseudos = module.exports = {
  3967. __proto__: null,
  3968. ":first-letter": 1,
  3969. ":first-line": 1,
  3970. ":before": 1,
  3971. ":after": 1
  3972. };
  3973. Pseudos.ELEMENT = 1;
  3974. Pseudos.CLASS = 2;
  3975. Pseudos.isElement = function(pseudo) {
  3976. return pseudo.indexOf("::") === 0 || Pseudos[pseudo.toLowerCase()] === Pseudos.ELEMENT;
  3977. };
  3978. },{}],13:[function(require,module,exports){
  3979. "use strict";
  3980. module.exports = Selector;
  3981. var SyntaxUnit = require("../util/SyntaxUnit");
  3982. var Parser = require("./Parser");
  3983. var Specificity = require("./Specificity");
  3984. function Selector(parts, line, col) {
  3985. SyntaxUnit.call(this, parts.join(" "), line, col, Parser.SELECTOR_TYPE);
  3986. this.parts = parts;
  3987. this.specificity = Specificity.calculate(this);
  3988. }
  3989. Selector.prototype = new SyntaxUnit();
  3990. Selector.prototype.constructor = Selector;
  3991. },{"../util/SyntaxUnit":26,"./Parser":6,"./Specificity":16}],14:[function(require,module,exports){
  3992. "use strict";
  3993. module.exports = SelectorPart;
  3994. var SyntaxUnit = require("../util/SyntaxUnit");
  3995. var Parser = require("./Parser");
  3996. function SelectorPart(elementName, modifiers, text, line, col) {
  3997. SyntaxUnit.call(this, text, line, col, Parser.SELECTOR_PART_TYPE);
  3998. this.elementName = elementName;
  3999. this.modifiers = modifiers;
  4000. }
  4001. SelectorPart.prototype = new SyntaxUnit();
  4002. SelectorPart.prototype.constructor = SelectorPart;
  4003. },{"../util/SyntaxUnit":26,"./Parser":6}],15:[function(require,module,exports){
  4004. "use strict";
  4005. module.exports = SelectorSubPart;
  4006. var SyntaxUnit = require("../util/SyntaxUnit");
  4007. var Parser = require("./Parser");
  4008. function SelectorSubPart(text, type, line, col) {
  4009. SyntaxUnit.call(this, text, line, col, Parser.SELECTOR_SUB_PART_TYPE);
  4010. this.type = type;
  4011. this.args = [];
  4012. }
  4013. SelectorSubPart.prototype = new SyntaxUnit();
  4014. SelectorSubPart.prototype.constructor = SelectorSubPart;
  4015. },{"../util/SyntaxUnit":26,"./Parser":6}],16:[function(require,module,exports){
  4016. "use strict";
  4017. module.exports = Specificity;
  4018. var Pseudos = require("./Pseudos");
  4019. var SelectorPart = require("./SelectorPart");
  4020. function Specificity(a, b, c, d) {
  4021. this.a = a;
  4022. this.b = b;
  4023. this.c = c;
  4024. this.d = d;
  4025. }
  4026. Specificity.prototype = {
  4027. constructor: Specificity,
  4028. compare: function(other) {
  4029. var comps = ["a", "b", "c", "d"],
  4030. i, len;
  4031. for (i = 0, len = comps.length; i < len; i++) {
  4032. if (this[comps[i]] < other[comps[i]]) {
  4033. return -1;
  4034. } else if (this[comps[i]] > other[comps[i]]) {
  4035. return 1;
  4036. }
  4037. }
  4038. return 0;
  4039. },
  4040. valueOf: function() {
  4041. return (this.a * 1000) + (this.b * 100) + (this.c * 10) + this.d;
  4042. },
  4043. toString: function() {
  4044. return this.a + "," + this.b + "," + this.c + "," + this.d;
  4045. }
  4046. };
  4047. Specificity.calculate = function(selector) {
  4048. var i,
  4049. len,
  4050. part,
  4051. b = 0,
  4052. c = 0,
  4053. d = 0;
  4054. function updateValues(part) {
  4055. var i, j, len, num,
  4056. elementName = part.elementName ? part.elementName.text : "",
  4057. modifier;
  4058. if (elementName && elementName.charAt(elementName.length - 1) !== "*") {
  4059. d++;
  4060. }
  4061. for (i = 0, len = part.modifiers.length; i < len; i++) {
  4062. modifier = part.modifiers[i];
  4063. switch (modifier.type) {
  4064. case "class":
  4065. case "attribute":
  4066. c++;
  4067. break;
  4068. case "id":
  4069. b++;
  4070. break;
  4071. case "pseudo":
  4072. if (Pseudos.isElement(modifier.text)) {
  4073. d++;
  4074. } else {
  4075. c++;
  4076. }
  4077. break;
  4078. case "not":
  4079. for (j = 0, num = modifier.args.length; j < num; j++) {
  4080. updateValues(modifier.args[j]);
  4081. }
  4082. }
  4083. }
  4084. }
  4085. for (i = 0, len = selector.parts.length; i < len; i++) {
  4086. part = selector.parts[i];
  4087. if (part instanceof SelectorPart) {
  4088. updateValues(part);
  4089. }
  4090. }
  4091. return new Specificity(0, b, c, d);
  4092. };
  4093. },{"./Pseudos":12,"./SelectorPart":14}],17:[function(require,module,exports){
  4094. "use strict";
  4095. module.exports = TokenStream;
  4096. var TokenStreamBase = require("../util/TokenStreamBase");
  4097. var PropertyValuePart = require("./PropertyValuePart");
  4098. var Tokens = require("./Tokens");
  4099. var h = /^[0-9a-fA-F]$/,
  4100. nonascii = /^[\u00A0-\uFFFF]$/,
  4101. nl = /\n|\r\n|\r|\f/,
  4102. whitespace = /\u0009|\u000a|\u000c|\u000d|\u0020/;
  4103. function isHexDigit(c) {
  4104. return c != null && h.test(c);
  4105. }
  4106. function isDigit(c) {
  4107. return c != null && /\d/.test(c);
  4108. }
  4109. function isWhitespace(c) {
  4110. return c != null && whitespace.test(c);
  4111. }
  4112. function isNewLine(c) {
  4113. return c != null && nl.test(c);
  4114. }
  4115. function isNameStart(c) {
  4116. return c != null && /[a-z_\u00A0-\uFFFF\\]/i.test(c);
  4117. }
  4118. function isNameChar(c) {
  4119. return c != null && (isNameStart(c) || /[0-9\-\\]/.test(c));
  4120. }
  4121. function isIdentStart(c) {
  4122. return c != null && (isNameStart(c) || /-\\/.test(c));
  4123. }
  4124. function mix(receiver, supplier) {
  4125. for (var prop in supplier) {
  4126. if (Object.prototype.hasOwnProperty.call(supplier, prop)) {
  4127. receiver[prop] = supplier[prop];
  4128. }
  4129. }
  4130. return receiver;
  4131. }
  4132. function wouldStartIdent(twoCodePoints) {
  4133. return typeof twoCodePoints === "string" &&
  4134. (twoCodePoints[0] === "-" && isNameStart(twoCodePoints[1]) || isNameStart(twoCodePoints[0]));
  4135. }
  4136. function wouldStartUnsignedNumber(twoCodePoints) {
  4137. return typeof twoCodePoints === "string" &&
  4138. (isDigit(twoCodePoints[0]) || (twoCodePoints[0] === "." && isDigit(twoCodePoints[1])));
  4139. }
  4140. function TokenStream(input) {
  4141. TokenStreamBase.call(this, input, Tokens);
  4142. }
  4143. TokenStream.prototype = mix(new TokenStreamBase(), {
  4144. _getToken: function() {
  4145. var c,
  4146. reader = this._reader,
  4147. token = null,
  4148. startLine = reader.getLine(),
  4149. startCol = reader.getCol();
  4150. c = reader.read();
  4151. while (c) {
  4152. switch (c) {
  4153. case "/":
  4154. if (reader.peek() === "*") {
  4155. token = this.commentToken(c, startLine, startCol);
  4156. } else {
  4157. token = this.charToken(c, startLine, startCol);
  4158. }
  4159. break;
  4160. case "|":
  4161. case "~":
  4162. case "^":
  4163. case "$":
  4164. case "*":
  4165. if (reader.peek() === "=") {
  4166. token = this.comparisonToken(c, startLine, startCol);
  4167. } else {
  4168. token = this.charToken(c, startLine, startCol);
  4169. }
  4170. break;
  4171. case "\"":
  4172. case "'":
  4173. token = this.stringToken(c, startLine, startCol);
  4174. break;
  4175. case "#":
  4176. if (isNameChar(reader.peek())) {
  4177. token = this.hashToken(c, startLine, startCol);
  4178. } else {
  4179. token = this.charToken(c, startLine, startCol);
  4180. }
  4181. break;
  4182. case ".":
  4183. if (isDigit(reader.peek())) {
  4184. token = this.numberToken(c, startLine, startCol);
  4185. } else {
  4186. token = this.charToken(c, startLine, startCol);
  4187. }
  4188. break;
  4189. case "-":
  4190. if (wouldStartUnsignedNumber(reader.peekCount(2))) {
  4191. token = this.numberToken(c, startLine, startCol);
  4192. break;
  4193. } else if (reader.peekCount(2) === "->") {
  4194. token = this.htmlCommentEndToken(c, startLine, startCol);
  4195. } else {
  4196. token = this._getDefaultToken(c, startLine, startCol);
  4197. }
  4198. break;
  4199. case "+":
  4200. if (wouldStartUnsignedNumber(reader.peekCount(2))) {
  4201. token = this.numberToken(c, startLine, startCol);
  4202. } else {
  4203. token = this.charToken(c, startLine, startCol);
  4204. }
  4205. break;
  4206. case "!":
  4207. token = this.importantToken(c, startLine, startCol);
  4208. break;
  4209. case "@":
  4210. token = this.atRuleToken(c, startLine, startCol);
  4211. break;
  4212. case ":":
  4213. token = this.notToken(c, startLine, startCol);
  4214. break;
  4215. case "<":
  4216. token = this.htmlCommentStartToken(c, startLine, startCol);
  4217. break;
  4218. case "\\":
  4219. if (/[^\r\n\f]/.test(reader.peek())) {
  4220. token = this.identOrFunctionToken(this.readEscape(c, true), startLine, startCol);
  4221. } else {
  4222. token = this.charToken(c, startLine, startCol);
  4223. }
  4224. break;
  4225. case "U":
  4226. case "u":
  4227. if (reader.peek() === "+") {
  4228. token = this.unicodeRangeToken(c, startLine, startCol);
  4229. } else {
  4230. token = this._getDefaultToken(c, startLine, startCol);
  4231. }
  4232. break;
  4233. default:
  4234. token = this._getDefaultToken(c, startLine, startCol);
  4235. }
  4236. break;
  4237. }
  4238. if (!token && c === null) {
  4239. token = this.createToken(Tokens.EOF, null, startLine, startCol);
  4240. }
  4241. return token;
  4242. },
  4243. _getDefaultToken: function(c, startLine, startCol) {
  4244. var reader = this._reader,
  4245. token = null;
  4246. if (isDigit(c)) {
  4247. token = this.numberToken(c, startLine, startCol);
  4248. } else
  4249. if (isWhitespace(c)) {
  4250. token = this.whitespaceToken(c, startLine, startCol);
  4251. } else
  4252. if (wouldStartIdent(c + reader.peekCount(1))) {
  4253. token = this.identOrFunctionToken(c, startLine, startCol);
  4254. } else {
  4255. token = this.charToken(c, startLine, startCol);
  4256. }
  4257. return token;
  4258. },
  4259. createToken: function(tt, value, startLine, startCol, options) {
  4260. var reader = this._reader;
  4261. options = options || {};
  4262. return {
  4263. value: value,
  4264. type: tt,
  4265. channel: options.channel,
  4266. endChar: options.endChar,
  4267. hide: options.hide || false,
  4268. startLine: startLine,
  4269. startCol: startCol,
  4270. endLine: reader.getLine(),
  4271. endCol: reader.getCol()
  4272. };
  4273. },
  4274. atRuleToken: function(first, startLine, startCol) {
  4275. var rule = first,
  4276. reader = this._reader,
  4277. tt = Tokens.CHAR,
  4278. ident;
  4279. reader.mark();
  4280. ident = this.readName();
  4281. rule = first + ident;
  4282. tt = Tokens.type(rule.toLowerCase());
  4283. if (tt === Tokens.CHAR || tt === Tokens.UNKNOWN) {
  4284. if (rule.length > 1) {
  4285. tt = Tokens.UNKNOWN_SYM;
  4286. } else {
  4287. tt = Tokens.CHAR;
  4288. rule = first;
  4289. reader.reset();
  4290. }
  4291. }
  4292. return this.createToken(tt, rule, startLine, startCol);
  4293. },
  4294. charToken: function(c, startLine, startCol) {
  4295. var tt = Tokens.type(c);
  4296. var opts = {};
  4297. if (tt === -1) {
  4298. tt = Tokens.CHAR;
  4299. } else {
  4300. opts.endChar = Tokens[tt].endChar;
  4301. }
  4302. return this.createToken(tt, c, startLine, startCol, opts);
  4303. },
  4304. commentToken: function(first, startLine, startCol) {
  4305. var comment = this.readComment(first);
  4306. return this.createToken(Tokens.COMMENT, comment, startLine, startCol);
  4307. },
  4308. comparisonToken: function(c, startLine, startCol) {
  4309. var reader = this._reader,
  4310. comparison = c + reader.read(),
  4311. tt = Tokens.type(comparison) || Tokens.CHAR;
  4312. return this.createToken(tt, comparison, startLine, startCol);
  4313. },
  4314. hashToken: function(first, startLine, startCol) {
  4315. var name = this.readName(first);
  4316. return this.createToken(Tokens.HASH, name, startLine, startCol);
  4317. },
  4318. htmlCommentStartToken: function(first, startLine, startCol) {
  4319. var reader = this._reader,
  4320. text = first;
  4321. reader.mark();
  4322. text += reader.readCount(3);
  4323. if (text === "<!--") {
  4324. return this.createToken(Tokens.CDO, text, startLine, startCol);
  4325. } else {
  4326. reader.reset();
  4327. return this.charToken(first, startLine, startCol);
  4328. }
  4329. },
  4330. htmlCommentEndToken: function(first, startLine, startCol) {
  4331. var reader = this._reader,
  4332. text = first;
  4333. reader.mark();
  4334. text += reader.readCount(2);
  4335. if (text === "-->") {
  4336. return this.createToken(Tokens.CDC, text, startLine, startCol);
  4337. } else {
  4338. reader.reset();
  4339. return this.charToken(first, startLine, startCol);
  4340. }
  4341. },
  4342. identOrFunctionToken: function(first, startLine, startCol) {
  4343. var reader = this._reader,
  4344. ident = this.readName(first),
  4345. tt = Tokens.IDENT,
  4346. uriFns = ["url(", "url-prefix(", "domain("],
  4347. uri;
  4348. if (reader.peek() === "(") {
  4349. ident += reader.read();
  4350. if (uriFns.indexOf(ident.toLowerCase()) > -1) {
  4351. reader.mark();
  4352. uri = this.readURI(ident);
  4353. if (uri === null) {
  4354. reader.reset();
  4355. tt = Tokens.FUNCTION;
  4356. } else {
  4357. tt = Tokens.URI;
  4358. ident = uri;
  4359. }
  4360. } else {
  4361. tt = Tokens.FUNCTION;
  4362. }
  4363. } else if (reader.peek() === ":") { // might be an IE function
  4364. if (ident.toLowerCase() === "progid") {
  4365. ident += reader.readTo("(");
  4366. tt = Tokens.IE_FUNCTION;
  4367. }
  4368. }
  4369. return this.createToken(tt, ident, startLine, startCol);
  4370. },
  4371. importantToken: function(first, startLine, startCol) {
  4372. var reader = this._reader,
  4373. important = first,
  4374. tt = Tokens.CHAR,
  4375. temp,
  4376. c;
  4377. reader.mark();
  4378. c = reader.read();
  4379. while (c) {
  4380. if (c === "/") {
  4381. if (reader.peek() !== "*") {
  4382. break;
  4383. } else {
  4384. temp = this.readComment(c);
  4385. if (temp === "") { // broken!
  4386. break;
  4387. }
  4388. }
  4389. } else if (isWhitespace(c)) {
  4390. important += c + this.readWhitespace();
  4391. } else if (/i/i.test(c)) {
  4392. temp = reader.readCount(8);
  4393. if (/mportant/i.test(temp)) {
  4394. important += c + temp;
  4395. tt = Tokens.IMPORTANT_SYM;
  4396. }
  4397. break; // we're done
  4398. } else {
  4399. break;
  4400. }
  4401. c = reader.read();
  4402. }
  4403. if (tt === Tokens.CHAR) {
  4404. reader.reset();
  4405. return this.charToken(first, startLine, startCol);
  4406. } else {
  4407. return this.createToken(tt, important, startLine, startCol);
  4408. }
  4409. },
  4410. notToken: function(first, startLine, startCol) {
  4411. var reader = this._reader,
  4412. text = first;
  4413. reader.mark();
  4414. text += reader.readCount(4);
  4415. if (text.toLowerCase() === ":not(") {
  4416. return this.createToken(Tokens.NOT, text, startLine, startCol);
  4417. } else {
  4418. reader.reset();
  4419. return this.charToken(first, startLine, startCol);
  4420. }
  4421. },
  4422. numberToken: function(first, startLine, startCol) {
  4423. var reader = this._reader,
  4424. value = this.readNumber(first),
  4425. ident,
  4426. tt = Tokens.NUMBER,
  4427. c = reader.peek();
  4428. if (isIdentStart(c)) {
  4429. ident = this.readName(reader.read());
  4430. value += ident;
  4431. if (/^em$|^ex$|^px$|^gd$|^rem$|^vw$|^vh$|^fr$|^vmax$|^vmin$|^ch$|^cm$|^mm$|^in$|^pt$|^pc$/i.test(ident)) {
  4432. tt = Tokens.LENGTH;
  4433. } else if (/^deg|^rad$|^grad$|^turn$/i.test(ident)) {
  4434. tt = Tokens.ANGLE;
  4435. } else if (/^ms$|^s$/i.test(ident)) {
  4436. tt = Tokens.TIME;
  4437. } else if (/^hz$|^khz$/i.test(ident)) {
  4438. tt = Tokens.FREQ;
  4439. } else if (/^dpi$|^dpcm$/i.test(ident)) {
  4440. tt = Tokens.RESOLUTION;
  4441. } else {
  4442. tt = Tokens.DIMENSION;
  4443. }
  4444. } else if (c === "%") {
  4445. value += reader.read();
  4446. tt = Tokens.PERCENTAGE;
  4447. }
  4448. return this.createToken(tt, value, startLine, startCol);
  4449. },
  4450. stringToken: function(first, startLine, startCol) {
  4451. var delim = first,
  4452. string = first,
  4453. reader = this._reader,
  4454. tt = Tokens.STRING,
  4455. c = reader.read(),
  4456. i;
  4457. while (c) {
  4458. string += c;
  4459. if (c === "\\") {
  4460. c = reader.read();
  4461. if (c === null) {
  4462. break; // premature EOF after backslash
  4463. } else if (/[^\r\n\f0-9a-f]/i.test(c)) {
  4464. string += c;
  4465. } else {
  4466. for (i = 0; isHexDigit(c) && i < 6; i++) {
  4467. string += c;
  4468. c = reader.read();
  4469. }
  4470. if (c === "\r" && reader.peek() === "\n") {
  4471. string += c;
  4472. c = reader.read();
  4473. }
  4474. if (isWhitespace(c)) {
  4475. string += c;
  4476. } else {
  4477. continue;
  4478. }
  4479. }
  4480. } else if (c === delim) {
  4481. break; // delimiter found.
  4482. } else if (isNewLine(reader.peek())) {
  4483. tt = Tokens.INVALID;
  4484. break;
  4485. }
  4486. c = reader.read();
  4487. }
  4488. if (c === null) {
  4489. tt = Tokens.INVALID;
  4490. }
  4491. return this.createToken(tt, string, startLine, startCol);
  4492. },
  4493. unicodeRangeToken: function(first, startLine, startCol) {
  4494. var reader = this._reader,
  4495. value = first,
  4496. temp,
  4497. tt = Tokens.CHAR;
  4498. if (reader.peek() === "+") {
  4499. reader.mark();
  4500. value += reader.read();
  4501. value += this.readUnicodeRangePart(true);
  4502. if (value.length === 2) {
  4503. reader.reset();
  4504. } else {
  4505. tt = Tokens.UNICODE_RANGE;
  4506. if (value.indexOf("?") === -1) {
  4507. if (reader.peek() === "-") {
  4508. reader.mark();
  4509. temp = reader.read();
  4510. temp += this.readUnicodeRangePart(false);
  4511. if (temp.length === 1) {
  4512. reader.reset();
  4513. } else {
  4514. value += temp;
  4515. }
  4516. }
  4517. }
  4518. }
  4519. }
  4520. return this.createToken(tt, value, startLine, startCol);
  4521. },
  4522. whitespaceToken: function(first, startLine, startCol) {
  4523. var value = first + this.readWhitespace();
  4524. return this.createToken(Tokens.S, value, startLine, startCol);
  4525. },
  4526. readUnicodeRangePart: function(allowQuestionMark) {
  4527. var reader = this._reader,
  4528. part = "",
  4529. c = reader.peek();
  4530. while (isHexDigit(c) && part.length < 6) {
  4531. reader.read();
  4532. part += c;
  4533. c = reader.peek();
  4534. }
  4535. if (allowQuestionMark) {
  4536. while (c === "?" && part.length < 6) {
  4537. reader.read();
  4538. part += c;
  4539. c = reader.peek();
  4540. }
  4541. }
  4542. return part;
  4543. },
  4544. readWhitespace: function() {
  4545. var reader = this._reader,
  4546. whitespace = "",
  4547. c = reader.peek();
  4548. while (isWhitespace(c)) {
  4549. reader.read();
  4550. whitespace += c;
  4551. c = reader.peek();
  4552. }
  4553. return whitespace;
  4554. },
  4555. readNumber: function(first) {
  4556. var reader = this._reader,
  4557. number = first,
  4558. hasDot = first === ".",
  4559. c = reader.peek();
  4560. while (c) {
  4561. if (isDigit(c)) {
  4562. number += reader.read();
  4563. } else if (c === ".") {
  4564. if (hasDot) {
  4565. break;
  4566. } else {
  4567. hasDot = true;
  4568. number += reader.read();
  4569. }
  4570. } else {
  4571. break;
  4572. }
  4573. c = reader.peek();
  4574. }
  4575. return number;
  4576. },
  4577. readString: function() {
  4578. var token = this.stringToken(this._reader.read(), 0, 0);
  4579. return token.type === Tokens.INVALID ? null : token.value;
  4580. },
  4581. readURI: function(first) {
  4582. var reader = this._reader,
  4583. uri = first,
  4584. inner = "",
  4585. c = reader.peek();
  4586. while (c && isWhitespace(c)) {
  4587. reader.read();
  4588. c = reader.peek();
  4589. }
  4590. if (c === "'" || c === "\"") {
  4591. inner = this.readString();
  4592. if (inner !== null) {
  4593. inner = PropertyValuePart.parseString(inner);
  4594. }
  4595. } else {
  4596. inner = this.readUnquotedURL();
  4597. }
  4598. c = reader.peek();
  4599. while (c && isWhitespace(c)) {
  4600. reader.read();
  4601. c = reader.peek();
  4602. }
  4603. if (inner === null || c !== ")") {
  4604. uri = null;
  4605. } else {
  4606. uri += PropertyValuePart.serializeString(inner) + reader.read();
  4607. }
  4608. return uri;
  4609. },
  4610. readUnquotedURL: function(first) {
  4611. var reader = this._reader,
  4612. url = first || "",
  4613. c;
  4614. for (c = reader.peek(); c; c = reader.peek()) {
  4615. if (nonascii.test(c) || /^[-!#$%&*-[\]-~]$/.test(c)) {
  4616. url += c;
  4617. reader.read();
  4618. } else if (c === "\\") {
  4619. if (/^[^\r\n\f]$/.test(reader.peek(2))) {
  4620. url += this.readEscape(reader.read(), true);
  4621. } else {
  4622. break; // bad escape sequence.
  4623. }
  4624. } else {
  4625. break; // bad character
  4626. }
  4627. }
  4628. return url;
  4629. },
  4630. readName: function(first) {
  4631. var reader = this._reader,
  4632. ident = first || "",
  4633. c;
  4634. for (c = reader.peek(); c; c = reader.peek()) {
  4635. if (c === "\\") {
  4636. if (/^[^\r\n\f]$/.test(reader.peek(2))) {
  4637. ident += this.readEscape(reader.read(), true);
  4638. } else {
  4639. break;
  4640. }
  4641. } else if (isNameChar(c)) {
  4642. ident += reader.read();
  4643. } else {
  4644. break;
  4645. }
  4646. }
  4647. return ident;
  4648. },
  4649. readEscape: function(first, unescape) {
  4650. var reader = this._reader,
  4651. cssEscape = first || "",
  4652. i = 0,
  4653. c = reader.peek();
  4654. if (isHexDigit(c)) {
  4655. do {
  4656. cssEscape += reader.read();
  4657. c = reader.peek();
  4658. } while (c && isHexDigit(c) && ++i < 6);
  4659. }
  4660. if (cssEscape.length === 1) {
  4661. if (/^[^\r\n\f0-9a-f]$/.test(c)) {
  4662. reader.read();
  4663. if (unescape) {
  4664. return c;
  4665. }
  4666. } else {
  4667. throw new Error("Bad escape sequence.");
  4668. }
  4669. } else if (c === "\r") {
  4670. reader.read();
  4671. if (reader.peek() === "\n") {
  4672. c += reader.read();
  4673. }
  4674. } else if (/^[ \t\n\f]$/.test(c)) {
  4675. reader.read();
  4676. } else {
  4677. c = "";
  4678. }
  4679. if (unescape) {
  4680. var cp = parseInt(cssEscape.slice(first.length), 16);
  4681. return String.fromCodePoint ? String.fromCodePoint(cp) :
  4682. String.fromCharCode(cp);
  4683. }
  4684. return cssEscape + c;
  4685. },
  4686. readComment: function(first) {
  4687. var reader = this._reader,
  4688. comment = first || "",
  4689. c = reader.read();
  4690. if (c === "*") {
  4691. while (c) {
  4692. comment += c;
  4693. if (comment.length > 2 && c === "*" && reader.peek() === "/") {
  4694. comment += reader.read();
  4695. break;
  4696. }
  4697. c = reader.read();
  4698. }
  4699. return comment;
  4700. } else {
  4701. return "";
  4702. }
  4703. }
  4704. });
  4705. },{"../util/TokenStreamBase":27,"./PropertyValuePart":11,"./Tokens":18}],18:[function(require,module,exports){
  4706. "use strict";
  4707. var Tokens = module.exports = [
  4708. { name: "CDO" },
  4709. { name: "CDC" },
  4710. { name: "S", whitespace: true/*, channel: "ws"*/ },
  4711. { name: "COMMENT", comment: true, hide: true, channel: "comment" },
  4712. { name: "INCLUDES", text: "~=" },
  4713. { name: "DASHMATCH", text: "|=" },
  4714. { name: "PREFIXMATCH", text: "^=" },
  4715. { name: "SUFFIXMATCH", text: "$=" },
  4716. { name: "SUBSTRINGMATCH", text: "*=" },
  4717. { name: "STRING" },
  4718. { name: "IDENT" },
  4719. { name: "HASH" },
  4720. { name: "IMPORT_SYM", text: "@import" },
  4721. { name: "PAGE_SYM", text: "@page" },
  4722. { name: "MEDIA_SYM", text: "@media" },
  4723. { name: "FONT_FACE_SYM", text: "@font-face" },
  4724. { name: "CHARSET_SYM", text: "@charset" },
  4725. { name: "NAMESPACE_SYM", text: "@namespace" },
  4726. { name: "SUPPORTS_SYM", text: "@supports" },
  4727. { name: "VIEWPORT_SYM", text: ["@viewport", "@-ms-viewport", "@-o-viewport"] },
  4728. { name: "DOCUMENT_SYM", text: ["@document", "@-moz-document"] },
  4729. { name: "UNKNOWN_SYM" },
  4730. { name: "KEYFRAMES_SYM", text: [ "@keyframes", "@-webkit-keyframes", "@-moz-keyframes", "@-o-keyframes" ] },
  4731. { name: "IMPORTANT_SYM" },
  4732. { name: "LENGTH" },
  4733. { name: "ANGLE" },
  4734. { name: "TIME" },
  4735. { name: "FREQ" },
  4736. { name: "DIMENSION" },
  4737. { name: "PERCENTAGE" },
  4738. { name: "NUMBER" },
  4739. { name: "URI" },
  4740. { name: "FUNCTION" },
  4741. { name: "UNICODE_RANGE" },
  4742. { name: "INVALID" },
  4743. { name: "PLUS", text: "+" },
  4744. { name: "GREATER", text: ">" },
  4745. { name: "COMMA", text: "," },
  4746. { name: "TILDE", text: "~" },
  4747. { name: "NOT" },
  4748. { name: "TOPLEFTCORNER_SYM", text: "@top-left-corner" },
  4749. { name: "TOPLEFT_SYM", text: "@top-left" },
  4750. { name: "TOPCENTER_SYM", text: "@top-center" },
  4751. { name: "TOPRIGHT_SYM", text: "@top-right" },
  4752. { name: "TOPRIGHTCORNER_SYM", text: "@top-right-corner" },
  4753. { name: "BOTTOMLEFTCORNER_SYM", text: "@bottom-left-corner" },
  4754. { name: "BOTTOMLEFT_SYM", text: "@bottom-left" },
  4755. { name: "BOTTOMCENTER_SYM", text: "@bottom-center" },
  4756. { name: "BOTTOMRIGHT_SYM", text: "@bottom-right" },
  4757. { name: "BOTTOMRIGHTCORNER_SYM", text: "@bottom-right-corner" },
  4758. { name: "LEFTTOP_SYM", text: "@left-top" },
  4759. { name: "LEFTMIDDLE_SYM", text: "@left-middle" },
  4760. { name: "LEFTBOTTOM_SYM", text: "@left-bottom" },
  4761. { name: "RIGHTTOP_SYM", text: "@right-top" },
  4762. { name: "RIGHTMIDDLE_SYM", text: "@right-middle" },
  4763. { name: "RIGHTBOTTOM_SYM", text: "@right-bottom" },
  4764. { name: "RESOLUTION", state: "media" },
  4765. { name: "IE_FUNCTION" },
  4766. { name: "CHAR" },
  4767. {
  4768. name: "PIPE",
  4769. text: "|"
  4770. },
  4771. {
  4772. name: "SLASH",
  4773. text: "/"
  4774. },
  4775. {
  4776. name: "MINUS",
  4777. text: "-"
  4778. },
  4779. {
  4780. name: "STAR",
  4781. text: "*"
  4782. },
  4783. {
  4784. name: "LBRACE",
  4785. endChar: "}",
  4786. text: "{"
  4787. },
  4788. {
  4789. name: "RBRACE",
  4790. text: "}"
  4791. },
  4792. {
  4793. name: "LBRACKET",
  4794. endChar: "]",
  4795. text: "["
  4796. },
  4797. {
  4798. name: "RBRACKET",
  4799. text: "]"
  4800. },
  4801. {
  4802. name: "EQUALS",
  4803. text: "="
  4804. },
  4805. {
  4806. name: "COLON",
  4807. text: ":"
  4808. },
  4809. {
  4810. name: "SEMICOLON",
  4811. text: ";"
  4812. },
  4813. {
  4814. name: "LPAREN",
  4815. endChar: ")",
  4816. text: "("
  4817. },
  4818. {
  4819. name: "RPAREN",
  4820. text: ")"
  4821. },
  4822. {
  4823. name: "DOT",
  4824. text: "."
  4825. }
  4826. ];
  4827. (function() {
  4828. var nameMap = [],
  4829. typeMap = Object.create(null);
  4830. Tokens.UNKNOWN = -1;
  4831. Tokens.unshift({ name:"EOF" });
  4832. for (var i = 0, len = Tokens.length; i < len; i++) {
  4833. nameMap.push(Tokens[i].name);
  4834. Tokens[Tokens[i].name] = i;
  4835. if (Tokens[i].text) {
  4836. if (Tokens[i].text instanceof Array) {
  4837. for (var j = 0; j < Tokens[i].text.length; j++) {
  4838. typeMap[Tokens[i].text[j]] = i;
  4839. }
  4840. } else {
  4841. typeMap[Tokens[i].text] = i;
  4842. }
  4843. }
  4844. }
  4845. Tokens.name = function(tt) {
  4846. return nameMap[tt];
  4847. };
  4848. Tokens.type = function(c) {
  4849. return typeMap[c] || -1;
  4850. };
  4851. })();
  4852. },{}],19:[function(require,module,exports){
  4853. "use strict";
  4854. var Matcher = require("./Matcher");
  4855. var Properties = require("./Properties");
  4856. var ValidationTypes = require("./ValidationTypes");
  4857. var ValidationError = require("./ValidationError");
  4858. var PropertyValueIterator = require("./PropertyValueIterator");
  4859. var Validation = module.exports = {
  4860. validate: function(property, value) {
  4861. var name = property.toString().toLowerCase(),
  4862. expression = new PropertyValueIterator(value),
  4863. spec = Properties[name],
  4864. part;
  4865. if (!spec) {
  4866. if (name.indexOf("-") !== 0) { // vendor prefixed are ok
  4867. throw new ValidationError("Unknown property '" + property + "'.", property.line, property.col);
  4868. }
  4869. } else if (typeof spec !== "number") {
  4870. if (ValidationTypes.isAny(expression, "inherit | initial | unset")) {
  4871. if (expression.hasNext()) {
  4872. part = expression.next();
  4873. throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
  4874. }
  4875. return;
  4876. }
  4877. this.singleProperty(spec, expression);
  4878. }
  4879. },
  4880. singleProperty: function(types, expression) {
  4881. var result = false,
  4882. value = expression.value,
  4883. part;
  4884. result = Matcher.parse(types).match(expression);
  4885. if (!result) {
  4886. if (expression.hasNext() && !expression.isFirst()) {
  4887. part = expression.peek();
  4888. throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
  4889. } else {
  4890. throw new ValidationError("Expected (" + ValidationTypes.describe(types) + ") but found '" + value + "'.", value.line, value.col);
  4891. }
  4892. } else if (expression.hasNext()) {
  4893. part = expression.next();
  4894. throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
  4895. }
  4896. }
  4897. };
  4898. },{"./Matcher":3,"./Properties":7,"./PropertyValueIterator":10,"./ValidationError":20,"./ValidationTypes":21}],20:[function(require,module,exports){
  4899. "use strict";
  4900. module.exports = ValidationError;
  4901. function ValidationError(message, line, col) {
  4902. this.col = col;
  4903. this.line = line;
  4904. this.message = message;
  4905. }
  4906. ValidationError.prototype = new Error();
  4907. },{}],21:[function(require,module,exports){
  4908. "use strict";
  4909. var ValidationTypes = module.exports;
  4910. var Matcher = require("./Matcher");
  4911. function copy(to, from) {
  4912. Object.keys(from).forEach(function(prop) {
  4913. to[prop] = from[prop];
  4914. });
  4915. }
  4916. copy(ValidationTypes, {
  4917. isLiteral: function (part, literals) {
  4918. var text = part.text.toString().toLowerCase(),
  4919. args = literals.split(" | "),
  4920. i,
  4921. len,
  4922. found = false;
  4923. for (i = 0, len = args.length; i < len && !found; i++) {
  4924. if (args[i].charAt(0) === "<") {
  4925. found = this.simple[args[i]](part);
  4926. } else if (args[i].slice(-2) === "()") {
  4927. found = (part.type === "function" &&
  4928. part.name === args[i].slice(0, -2));
  4929. } else if (text === args[i].toLowerCase()) {
  4930. found = true;
  4931. }
  4932. }
  4933. return found;
  4934. },
  4935. isSimple: function(type) {
  4936. return Boolean(this.simple[type]);
  4937. },
  4938. isComplex: function(type) {
  4939. return Boolean(this.complex[type]);
  4940. },
  4941. describe: function(type) {
  4942. if (this.complex[type] instanceof Matcher) {
  4943. return this.complex[type].toString(0);
  4944. }
  4945. return type;
  4946. },
  4947. isAny: function (expression, types) {
  4948. var args = types.split(" | "),
  4949. i,
  4950. len,
  4951. found = false;
  4952. for (i = 0, len = args.length; i < len && !found && expression.hasNext(); i++) {
  4953. found = this.isType(expression, args[i]);
  4954. }
  4955. return found;
  4956. },
  4957. isAnyOfGroup: function(expression, types) {
  4958. var args = types.split(" || "),
  4959. i,
  4960. len,
  4961. found = false;
  4962. for (i = 0, len = args.length; i < len && !found; i++) {
  4963. found = this.isType(expression, args[i]);
  4964. }
  4965. return found ? args[i - 1] : false;
  4966. },
  4967. isType: function (expression, type) {
  4968. var part = expression.peek(),
  4969. result = false;
  4970. if (type.charAt(0) !== "<") {
  4971. result = this.isLiteral(part, type);
  4972. if (result) {
  4973. expression.next();
  4974. }
  4975. } else if (this.simple[type]) {
  4976. result = this.simple[type](part);
  4977. if (result) {
  4978. expression.next();
  4979. }
  4980. } else if (this.complex[type] instanceof Matcher) {
  4981. result = this.complex[type].match(expression);
  4982. } else {
  4983. result = this.complex[type](expression);
  4984. }
  4985. return result;
  4986. },
  4987. simple: {
  4988. __proto__: null,
  4989. "<absolute-size>":
  4990. "xx-small | x-small | small | medium | large | x-large | xx-large",
  4991. "<animateable-feature>":
  4992. "scroll-position | contents | <animateable-feature-name>",
  4993. "<animateable-feature-name>": function(part) {
  4994. return this["<ident>"](part) &&
  4995. !/^(unset|initial|inherit|will-change|auto|scroll-position|contents)$/i.test(part);
  4996. },
  4997. "<angle>": function(part) {
  4998. return part.type === "angle";
  4999. },
  5000. "<attachment>": "scroll | fixed | local",
  5001. "<attr>": "attr()",
  5002. "<basic-shape>": "inset() | circle() | ellipse() | polygon()",
  5003. "<bg-image>": "<image> | <gradient> | none",
  5004. "<border-style>":
  5005. "none | hidden | dotted | dashed | solid | double | groove | " +
  5006. "ridge | inset | outset",
  5007. "<border-width>": "<length> | thin | medium | thick",
  5008. "<box>": "padding-box | border-box | content-box",
  5009. "<clip-source>": "<uri>",
  5010. "<color>": function(part) {
  5011. return part.type === "color" || String(part) === "transparent" || String(part) === "currentColor";
  5012. },
  5013. "<color-svg>": function(part) {
  5014. return part.type === "color";
  5015. },
  5016. "<content>": "content()",
  5017. "<content-sizing>":
  5018. "fill-available | -moz-available | -webkit-fill-available | " +
  5019. "max-content | -moz-max-content | -webkit-max-content | " +
  5020. "min-content | -moz-min-content | -webkit-min-content | " +
  5021. "fit-content | -moz-fit-content | -webkit-fit-content",
  5022. "<feature-tag-value>": function(part) {
  5023. return part.type === "function" && /^[A-Z0-9]{4}$/i.test(part);
  5024. },
  5025. "<filter-function>":
  5026. "blur() | brightness() | contrast() | custom() | " +
  5027. "drop-shadow() | grayscale() | hue-rotate() | invert() | " +
  5028. "opacity() | saturate() | sepia()",
  5029. "<flex-basis>": "<width>",
  5030. "<flex-direction>": "row | row-reverse | column | column-reverse",
  5031. "<flex-grow>": "<number>",
  5032. "<flex-shrink>": "<number>",
  5033. "<flex-wrap>": "nowrap | wrap | wrap-reverse",
  5034. "<font-size>":
  5035. "<absolute-size> | <relative-size> | <length> | <percentage>",
  5036. "<font-stretch>":
  5037. "normal | ultra-condensed | extra-condensed | condensed | " +
  5038. "semi-condensed | semi-expanded | expanded | extra-expanded | " +
  5039. "ultra-expanded",
  5040. "<font-style>": "normal | italic | oblique",
  5041. "<font-variant-caps>":
  5042. "small-caps | all-small-caps | petite-caps | all-petite-caps | " +
  5043. "unicase | titling-caps",
  5044. "<font-variant-css21>": "normal | small-caps",
  5045. "<font-weight>":
  5046. "normal | bold | bolder | lighter | " +
  5047. "100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900",
  5048. "<generic-family>":
  5049. "serif | sans-serif | cursive | fantasy | monospace",
  5050. "<geometry-box>": "<shape-box> | fill-box | stroke-box | view-box",
  5051. "<glyph-angle>": function(part) {
  5052. return part.type === "angle" && part.units === "deg";
  5053. },
  5054. "<gradient>": function(part) {
  5055. return part.type === "function" && /^(?:-(?:ms|moz|o|webkit)-)?(?:repeating-)?(?:radial-|linear-)?gradient/i.test(part);
  5056. },
  5057. "<icccolor>":
  5058. "cielab() | cielch() | cielchab() | " +
  5059. "icc-color() | icc-named-color()",
  5060. "<ident>": function(part) {
  5061. return part.type === "identifier" || part.wasIdent;
  5062. },
  5063. "<ident-not-generic-family>": function(part) {
  5064. return this["<ident>"](part) && !this["<generic-family>"](part);
  5065. },
  5066. "<image>": "<uri>",
  5067. "<integer>": function(part) {
  5068. return part.type === "integer";
  5069. },
  5070. "<length>": function(part) {
  5071. if (part.type === "function" && /^(?:-(?:ms|moz|o|webkit)-)?calc/i.test(part)) {
  5072. return true;
  5073. } else {
  5074. return part.type === "length" || part.type === "number" || part.type === "integer" || String(part) === "0";
  5075. }
  5076. },
  5077. "<line>": function(part) {
  5078. return part.type === "integer";
  5079. },
  5080. "<line-height>": "<number> | <length> | <percentage> | normal",
  5081. "<margin-width>": "<length> | <percentage> | auto",
  5082. "<miterlimit>": function(part) {
  5083. return this["<number>"](part) && part.value >= 1;
  5084. },
  5085. "<nonnegative-length-or-percentage>": function(part) {
  5086. return (this["<length>"](part) || this["<percentage>"](part)) &&
  5087. (String(part) === "0" || part.type === "function" || (part.value) >= 0);
  5088. },
  5089. "<nonnegative-number-or-percentage>": function(part) {
  5090. return (this["<number>"](part) || this["<percentage>"](part)) &&
  5091. (String(part) === "0" || part.type === "function" || (part.value) >= 0);
  5092. },
  5093. "<number>": function(part) {
  5094. return part.type === "number" || this["<integer>"](part);
  5095. },
  5096. "<opacity-value>": function(part) {
  5097. return this["<number>"](part) && part.value >= 0 && part.value <= 1;
  5098. },
  5099. "<padding-width>": "<nonnegative-length-or-percentage>",
  5100. "<percentage>": function(part) {
  5101. return part.type === "percentage" || String(part) === "0";
  5102. },
  5103. "<relative-size>": "smaller | larger",
  5104. "<shape>": "rect() | inset-rect()",
  5105. "<shape-box>": "<box> | margin-box",
  5106. "<single-animation-direction>":
  5107. "normal | reverse | alternate | alternate-reverse",
  5108. "<single-animation-name>": function(part) {
  5109. return this["<ident>"](part) &&
  5110. /^-?[a-z_][-a-z0-9_]+$/i.test(part) &&
  5111. !/^(none|unset|initial|inherit)$/i.test(part);
  5112. },
  5113. "<string>": function(part) {
  5114. return part.type === "string";
  5115. },
  5116. "<time>": function(part) {
  5117. return part.type === "time";
  5118. },
  5119. "<uri>": function(part) {
  5120. return part.type === "uri";
  5121. },
  5122. "<width>": "<margin-width>"
  5123. },
  5124. complex: {
  5125. __proto__: null,
  5126. "<azimuth>":
  5127. "<angle>" +
  5128. " | " +
  5129. "[ [ left-side | far-left | left | center-left | center | " +
  5130. "center-right | right | far-right | right-side ] || behind ]" +
  5131. " | " +
  5132. "leftwards | rightwards",
  5133. "<bg-position>": "<position>#",
  5134. "<bg-size>":
  5135. "[ <length> | <percentage> | auto ]{1,2} | cover | contain",
  5136. "<blend-mode>":
  5137. "normal | multiply | screen | overlay | darken | lighten | color-dodge | " +
  5138. "color-burn | hard-light | soft-light | difference | exclusion | hue | " +
  5139. "saturation | color | luminosity",
  5140. "<border-image-slice>":
  5141. Matcher.many([true /* first element is required */],
  5142. Matcher.cast("<nonnegative-number-or-percentage>"),
  5143. Matcher.cast("<nonnegative-number-or-percentage>"),
  5144. Matcher.cast("<nonnegative-number-or-percentage>"),
  5145. Matcher.cast("<nonnegative-number-or-percentage>"),
  5146. "fill"),
  5147. "<border-radius>":
  5148. "<nonnegative-length-or-percentage>{1,4} " +
  5149. "[ / <nonnegative-length-or-percentage>{1,4} ]?",
  5150. "<box-shadow>": "none | <shadow>#",
  5151. "<clip-path>": "<basic-shape> || <geometry-box>",
  5152. "<dasharray>":
  5153. Matcher.cast("<nonnegative-length-or-percentage>")
  5154. .braces(1, Infinity, "#", Matcher.cast(",").question()),
  5155. "<family-name>":
  5156. "<string> | <ident-not-generic-family> <ident>*",
  5157. "<filter-function-list>": "[ <filter-function> | <uri> ]+",
  5158. "<flex>":
  5159. "none | [ <flex-grow> <flex-shrink>? || <flex-basis> ]",
  5160. "<font-family>": "[ <generic-family> | <family-name> ]#",
  5161. "<font-shorthand>":
  5162. "[ <font-style> || <font-variant-css21> || " +
  5163. "<font-weight> || <font-stretch> ]? <font-size> " +
  5164. "[ / <line-height> ]? <font-family>",
  5165. "<font-variant-alternates>":
  5166. "stylistic() || " +
  5167. "historical-forms || " +
  5168. "styleset() || " +
  5169. "character-variant() || " +
  5170. "swash() || " +
  5171. "ornaments() || " +
  5172. "annotation()",
  5173. "<font-variant-ligatures>":
  5174. "[ common-ligatures | no-common-ligatures ] || " +
  5175. "[ discretionary-ligatures | no-discretionary-ligatures ] || " +
  5176. "[ historical-ligatures | no-historical-ligatures ] || " +
  5177. "[ contextual | no-contextual ]",
  5178. "<font-variant-numeric>":
  5179. "[ lining-nums | oldstyle-nums ] || " +
  5180. "[ proportional-nums | tabular-nums ] || " +
  5181. "[ diagonal-fractions | stacked-fractions ] || " +
  5182. "ordinal || slashed-zero",
  5183. "<font-variant-east-asian>":
  5184. "[ jis78 | jis83 | jis90 | jis04 | simplified | traditional ] || " +
  5185. "[ full-width | proportional-width ] || " +
  5186. "ruby",
  5187. "<paint>": "<paint-basic> | <uri> <paint-basic>?",
  5188. "<paint-basic>": "none | currentColor | <color-svg> <icccolor>?",
  5189. "<position>":
  5190. "[ center | [ left | right ] [ <percentage> | <length> ]? ] && " +
  5191. "[ center | [ top | bottom ] [ <percentage> | <length> ]? ]" +
  5192. " | " +
  5193. "[ left | center | right | <percentage> | <length> ] " +
  5194. "[ top | center | bottom | <percentage> | <length> ]" +
  5195. " | " +
  5196. "[ left | center | right | top | bottom | <percentage> | <length> ]",
  5197. "<repeat-style>":
  5198. "repeat-x | repeat-y | [ repeat | space | round | no-repeat ]{1,2}",
  5199. "<shadow>":
  5200. Matcher.many([true /* length is required */],
  5201. Matcher.cast("<length>").braces(2, 4), "inset", "<color>"),
  5202. "<text-decoration-color>":
  5203. "<color>",
  5204. "<text-decoration-line>":
  5205. "none | [ underline || overline || line-through || blink ]",
  5206. "<text-decoration-style>":
  5207. "solid | double | dotted | dashed | wavy",
  5208. "<will-change>":
  5209. "auto | <animateable-feature>#",
  5210. "<x-one-radius>":
  5211. "[ <length> | <percentage> ]{1,2}"
  5212. }
  5213. });
  5214. Object.keys(ValidationTypes.simple).forEach(function(nt) {
  5215. var rule = ValidationTypes.simple[nt];
  5216. if (typeof rule === "string") {
  5217. ValidationTypes.simple[nt] = function(part) {
  5218. return ValidationTypes.isLiteral(part, rule);
  5219. };
  5220. }
  5221. });
  5222. Object.keys(ValidationTypes.complex).forEach(function(nt) {
  5223. var rule = ValidationTypes.complex[nt];
  5224. if (typeof rule === "string") {
  5225. ValidationTypes.complex[nt] = Matcher.parse(rule);
  5226. }
  5227. });
  5228. ValidationTypes.complex["<font-variant>"] =
  5229. Matcher.oror({ expand: "<font-variant-ligatures>" },
  5230. { expand: "<font-variant-alternates>" },
  5231. "<font-variant-caps>",
  5232. { expand: "<font-variant-numeric>" },
  5233. { expand: "<font-variant-east-asian>" });
  5234. },{"./Matcher":3}],22:[function(require,module,exports){
  5235. "use strict";
  5236. module.exports = {
  5237. Colors : require("./Colors"),
  5238. Combinator : require("./Combinator"),
  5239. Parser : require("./Parser"),
  5240. PropertyName : require("./PropertyName"),
  5241. PropertyValue : require("./PropertyValue"),
  5242. PropertyValuePart : require("./PropertyValuePart"),
  5243. Matcher : require("./Matcher"),
  5244. MediaFeature : require("./MediaFeature"),
  5245. MediaQuery : require("./MediaQuery"),
  5246. Selector : require("./Selector"),
  5247. SelectorPart : require("./SelectorPart"),
  5248. SelectorSubPart : require("./SelectorSubPart"),
  5249. Specificity : require("./Specificity"),
  5250. TokenStream : require("./TokenStream"),
  5251. Tokens : require("./Tokens"),
  5252. ValidationError : require("./ValidationError")
  5253. };
  5254. },{"./Colors":1,"./Combinator":2,"./Matcher":3,"./MediaFeature":4,"./MediaQuery":5,"./Parser":6,"./PropertyName":8,"./PropertyValue":9,"./PropertyValuePart":11,"./Selector":13,"./SelectorPart":14,"./SelectorSubPart":15,"./Specificity":16,"./TokenStream":17,"./Tokens":18,"./ValidationError":20}],23:[function(require,module,exports){
  5255. "use strict";
  5256. module.exports = EventTarget;
  5257. function EventTarget() {
  5258. this._listeners = Object.create(null);
  5259. }
  5260. EventTarget.prototype = {
  5261. constructor: EventTarget,
  5262. addListener: function(type, listener) {
  5263. if (!this._listeners[type]) {
  5264. this._listeners[type] = [];
  5265. }
  5266. this._listeners[type].push(listener);
  5267. },
  5268. fire: function(event) {
  5269. if (typeof event === "string") {
  5270. event = { type: event };
  5271. }
  5272. if (typeof event.target !== "undefined") {
  5273. event.target = this;
  5274. }
  5275. if (typeof event.type === "undefined") {
  5276. throw new Error("Event object missing 'type' property.");
  5277. }
  5278. if (this._listeners[event.type]) {
  5279. var listeners = this._listeners[event.type].concat();
  5280. for (var i = 0, len = listeners.length; i < len; i++) {
  5281. listeners[i].call(this, event);
  5282. }
  5283. }
  5284. },
  5285. removeListener: function(type, listener) {
  5286. if (this._listeners[type]) {
  5287. var listeners = this._listeners[type];
  5288. for (var i = 0, len = listeners.length; i < len; i++) {
  5289. if (listeners[i] === listener) {
  5290. listeners.splice(i, 1);
  5291. break;
  5292. }
  5293. }
  5294. }
  5295. }
  5296. };
  5297. },{}],24:[function(require,module,exports){
  5298. "use strict";
  5299. module.exports = StringReader;
  5300. function StringReader(text) {
  5301. this._input = text.replace(/(\r\n?|\n)/g, "\n");
  5302. this._line = 1;
  5303. this._col = 1;
  5304. this._cursor = 0;
  5305. }
  5306. StringReader.prototype = {
  5307. constructor: StringReader,
  5308. getCol: function() {
  5309. return this._col;
  5310. },
  5311. getLine: function() {
  5312. return this._line;
  5313. },
  5314. eof: function() {
  5315. return this._cursor === this._input.length;
  5316. },
  5317. peek: function(count) {
  5318. var c = null;
  5319. count = typeof count === "undefined" ? 1 : count;
  5320. if (this._cursor < this._input.length) {
  5321. c = this._input.charAt(this._cursor + count - 1);
  5322. }
  5323. return c;
  5324. },
  5325. read: function() {
  5326. var c = null;
  5327. if (this._cursor < this._input.length) {
  5328. if (this._input.charAt(this._cursor) === "\n") {
  5329. this._line++;
  5330. this._col = 1;
  5331. } else {
  5332. this._col++;
  5333. }
  5334. c = this._input.charAt(this._cursor++);
  5335. }
  5336. return c;
  5337. },
  5338. mark: function() {
  5339. this._bookmark = {
  5340. cursor: this._cursor,
  5341. line: this._line,
  5342. col: this._col
  5343. };
  5344. },
  5345. reset: function() {
  5346. if (this._bookmark) {
  5347. this._cursor = this._bookmark.cursor;
  5348. this._line = this._bookmark.line;
  5349. this._col = this._bookmark.col;
  5350. delete this._bookmark;
  5351. }
  5352. },
  5353. peekCount: function(count) {
  5354. count = typeof count === "undefined" ? 1 : Math.max(count, 0);
  5355. return this._input.substring(this._cursor, this._cursor + count);
  5356. },
  5357. readTo: function(pattern) {
  5358. var buffer = "",
  5359. c;
  5360. while (buffer.length < pattern.length || buffer.lastIndexOf(pattern) !== buffer.length - pattern.length) {
  5361. c = this.read();
  5362. if (c) {
  5363. buffer += c;
  5364. } else {
  5365. throw new Error("Expected \"" + pattern + "\" at line " + this._line + ", col " + this._col + ".");
  5366. }
  5367. }
  5368. return buffer;
  5369. },
  5370. readWhile: function(filter) {
  5371. var buffer = "",
  5372. c = this.peek();
  5373. while (c !== null && filter(c)) {
  5374. buffer += this.read();
  5375. c = this.peek();
  5376. }
  5377. return buffer;
  5378. },
  5379. readMatch: function(matcher) {
  5380. var source = this._input.substring(this._cursor),
  5381. value = null;
  5382. if (typeof matcher === "string") {
  5383. if (source.slice(0, matcher.length) === matcher) {
  5384. value = this.readCount(matcher.length);
  5385. }
  5386. } else if (matcher instanceof RegExp) {
  5387. if (matcher.test(source)) {
  5388. value = this.readCount(RegExp.lastMatch.length);
  5389. }
  5390. }
  5391. return value;
  5392. },
  5393. readCount: function(count) {
  5394. var buffer = "";
  5395. while (count--) {
  5396. buffer += this.read();
  5397. }
  5398. return buffer;
  5399. }
  5400. };
  5401. },{}],25:[function(require,module,exports){
  5402. "use strict";
  5403. module.exports = SyntaxError;
  5404. function SyntaxError(message, line, col) {
  5405. Error.call(this);
  5406. this.name = this.constructor.name;
  5407. this.col = col;
  5408. this.line = line;
  5409. this.message = message;
  5410. }
  5411. SyntaxError.prototype = Object.create(Error.prototype); // jshint ignore:line
  5412. SyntaxError.prototype.constructor = SyntaxError; // jshint ignore:line
  5413. },{}],26:[function(require,module,exports){
  5414. "use strict";
  5415. module.exports = SyntaxUnit;
  5416. function SyntaxUnit(text, line, col, type) {
  5417. this.col = col;
  5418. this.line = line;
  5419. this.text = text;
  5420. this.type = type;
  5421. }
  5422. SyntaxUnit.fromToken = function(token) {
  5423. return new SyntaxUnit(token.value, token.startLine, token.startCol);
  5424. };
  5425. SyntaxUnit.prototype = {
  5426. constructor: SyntaxUnit,
  5427. valueOf: function() {
  5428. return this.toString();
  5429. },
  5430. toString: function() {
  5431. return this.text;
  5432. }
  5433. };
  5434. },{}],27:[function(require,module,exports){
  5435. "use strict";
  5436. module.exports = TokenStreamBase;
  5437. var StringReader = require("./StringReader");
  5438. var SyntaxError = require("./SyntaxError");
  5439. function TokenStreamBase(input, tokenData) {
  5440. this._reader = new StringReader(input ? input.toString() : "");
  5441. this._token = null;
  5442. this._tokenData = tokenData;
  5443. this._lt = [];
  5444. this._ltIndex = 0;
  5445. this._ltIndexCache = [];
  5446. }
  5447. TokenStreamBase.createTokenData = function(tokens) {
  5448. var nameMap = [],
  5449. typeMap = Object.create(null),
  5450. tokenData = tokens.concat([]),
  5451. i = 0,
  5452. len = tokenData.length + 1;
  5453. tokenData.UNKNOWN = -1;
  5454. tokenData.unshift({ name:"EOF" });
  5455. for (; i < len; i++) {
  5456. nameMap.push(tokenData[i].name);
  5457. tokenData[tokenData[i].name] = i;
  5458. if (tokenData[i].text) {
  5459. typeMap[tokenData[i].text] = i;
  5460. }
  5461. }
  5462. tokenData.name = function(tt) {
  5463. return nameMap[tt];
  5464. };
  5465. tokenData.type = function(c) {
  5466. return typeMap[c];
  5467. };
  5468. return tokenData;
  5469. };
  5470. TokenStreamBase.prototype = {
  5471. constructor: TokenStreamBase,
  5472. match: function(tokenTypes, channel) {
  5473. if (!(tokenTypes instanceof Array)) {
  5474. tokenTypes = [tokenTypes];
  5475. }
  5476. var tt = this.get(channel),
  5477. i = 0,
  5478. len = tokenTypes.length;
  5479. while (i < len) {
  5480. if (tt === tokenTypes[i++]) {
  5481. return true;
  5482. }
  5483. }
  5484. this.unget();
  5485. return false;
  5486. },
  5487. mustMatch: function(tokenTypes) {
  5488. var token;
  5489. if (!(tokenTypes instanceof Array)) {
  5490. tokenTypes = [tokenTypes];
  5491. }
  5492. if (!this.match.apply(this, arguments)) {
  5493. token = this.LT(1);
  5494. throw new SyntaxError("Expected " + this._tokenData[tokenTypes[0]].name +
  5495. " at line " + token.startLine + ", col " + token.startCol + ".", token.startLine, token.startCol);
  5496. }
  5497. },
  5498. advance: function(tokenTypes, channel) {
  5499. while (this.LA(0) !== 0 && !this.match(tokenTypes, channel)) {
  5500. this.get();
  5501. }
  5502. return this.LA(0);
  5503. },
  5504. get: function(channel) {
  5505. var tokenInfo = this._tokenData,
  5506. i = 0,
  5507. token,
  5508. info;
  5509. if (this._lt.length && this._ltIndex >= 0 && this._ltIndex < this._lt.length) {
  5510. i++;
  5511. this._token = this._lt[this._ltIndex++];
  5512. info = tokenInfo[this._token.type];
  5513. while ((typeof info.channel !== "undefined" && channel !== info.channel) &&
  5514. this._ltIndex < this._lt.length) {
  5515. this._token = this._lt[this._ltIndex++];
  5516. info = tokenInfo[this._token.type];
  5517. i++;
  5518. }
  5519. if ((typeof info.channel === "undefined" || channel === info.channel) &&
  5520. this._ltIndex <= this._lt.length) {
  5521. this._ltIndexCache.push(i);
  5522. return this._token.type;
  5523. }
  5524. }
  5525. token = this._getToken();
  5526. if (token.type > -1 && !tokenInfo[token.type].hide) {
  5527. token.channel = tokenInfo[token.type].channel;
  5528. this._token = token;
  5529. this._lt.push(token);
  5530. this._ltIndexCache.push(this._lt.length - this._ltIndex + i);
  5531. if (this._lt.length > 5) {
  5532. this._lt.shift();
  5533. }
  5534. if (this._ltIndexCache.length > 5) {
  5535. this._ltIndexCache.shift();
  5536. }
  5537. this._ltIndex = this._lt.length;
  5538. }
  5539. info = tokenInfo[token.type];
  5540. if (info &&
  5541. (info.hide ||
  5542. (typeof info.channel !== "undefined" && channel !== info.channel))) {
  5543. return this.get(channel);
  5544. } else {
  5545. return token.type;
  5546. }
  5547. },
  5548. LA: function(index) {
  5549. var total = index,
  5550. tt;
  5551. if (index > 0) {
  5552. if (index > 5) {
  5553. throw new Error("Too much lookahead.");
  5554. }
  5555. while (total) {
  5556. tt = this.get();
  5557. total--;
  5558. }
  5559. while (total < index) {
  5560. this.unget();
  5561. total++;
  5562. }
  5563. } else if (index < 0) {
  5564. if (this._lt[this._ltIndex + index]) {
  5565. tt = this._lt[this._ltIndex + index].type;
  5566. } else {
  5567. throw new Error("Too much lookbehind.");
  5568. }
  5569. } else {
  5570. tt = this._token.type;
  5571. }
  5572. return tt;
  5573. },
  5574. LT: function(index) {
  5575. this.LA(index);
  5576. return this._lt[this._ltIndex + index - 1];
  5577. },
  5578. peek: function() {
  5579. return this.LA(1);
  5580. },
  5581. token: function() {
  5582. return this._token;
  5583. },
  5584. tokenName: function(tokenType) {
  5585. if (tokenType < 0 || tokenType > this._tokenData.length) {
  5586. return "UNKNOWN_TOKEN";
  5587. } else {
  5588. return this._tokenData[tokenType].name;
  5589. }
  5590. },
  5591. tokenType: function(tokenName) {
  5592. return this._tokenData[tokenName] || -1;
  5593. },
  5594. unget: function() {
  5595. if (this._ltIndexCache.length) {
  5596. this._ltIndex -= this._ltIndexCache.pop();//--;
  5597. this._token = this._lt[this._ltIndex - 1];
  5598. } else {
  5599. throw new Error("Too much lookahead.");
  5600. }
  5601. }
  5602. };
  5603. },{"./StringReader":24,"./SyntaxError":25}],28:[function(require,module,exports){
  5604. "use strict";
  5605. module.exports = {
  5606. StringReader : require("./StringReader"),
  5607. SyntaxError : require("./SyntaxError"),
  5608. SyntaxUnit : require("./SyntaxUnit"),
  5609. EventTarget : require("./EventTarget"),
  5610. TokenStreamBase : require("./TokenStreamBase")
  5611. };
  5612. },{"./EventTarget":23,"./StringReader":24,"./SyntaxError":25,"./SyntaxUnit":26,"./TokenStreamBase":27}],"parserlib":[function(require,module,exports){
  5613. "use strict";
  5614. module.exports = {
  5615. css : require("./css"),
  5616. util : require("./util")
  5617. };
  5618. },{"./css":22,"./util":28}]},{},[]);
  5619. return require('parserlib');
  5620. })();
  5621. var clone = (function() {
  5622. 'use strict';
  5623. function _instanceof(obj, type) {
  5624. return type != null && obj instanceof type;
  5625. }
  5626. var nativeMap;
  5627. try {
  5628. nativeMap = Map;
  5629. } catch(_) {
  5630. nativeMap = function() {};
  5631. }
  5632. var nativeSet;
  5633. try {
  5634. nativeSet = Set;
  5635. } catch(_) {
  5636. nativeSet = function() {};
  5637. }
  5638. var nativePromise;
  5639. try {
  5640. nativePromise = Promise;
  5641. } catch(_) {
  5642. nativePromise = function() {};
  5643. }
  5644. function clone(parent, circular, depth, prototype, includeNonEnumerable) {
  5645. if (typeof circular === 'object') {
  5646. depth = circular.depth;
  5647. prototype = circular.prototype;
  5648. includeNonEnumerable = circular.includeNonEnumerable;
  5649. circular = circular.circular;
  5650. }
  5651. var allParents = [];
  5652. var allChildren = [];
  5653. var useBuffer = typeof Buffer != 'undefined';
  5654. if (typeof circular == 'undefined')
  5655. circular = true;
  5656. if (typeof depth == 'undefined')
  5657. depth = Infinity;
  5658. function _clone(parent, depth) {
  5659. if (parent === null)
  5660. return null;
  5661. if (depth === 0)
  5662. return parent;
  5663. var child;
  5664. var proto;
  5665. if (typeof parent != 'object') {
  5666. return parent;
  5667. }
  5668. if (_instanceof(parent, nativeMap)) {
  5669. child = new nativeMap();
  5670. } else if (_instanceof(parent, nativeSet)) {
  5671. child = new nativeSet();
  5672. } else if (_instanceof(parent, nativePromise)) {
  5673. child = new nativePromise(function (resolve, reject) {
  5674. parent.then(function(value) {
  5675. resolve(_clone(value, depth - 1));
  5676. }, function(err) {
  5677. reject(_clone(err, depth - 1));
  5678. });
  5679. });
  5680. } else if (clone.__isArray(parent)) {
  5681. child = [];
  5682. } else if (clone.__isRegExp(parent)) {
  5683. child = new RegExp(parent.source, __getRegExpFlags(parent));
  5684. if (parent.lastIndex) child.lastIndex = parent.lastIndex;
  5685. } else if (clone.__isDate(parent)) {
  5686. child = new Date(parent.getTime());
  5687. } else if (useBuffer && Buffer.isBuffer(parent)) {
  5688. if (Buffer.allocUnsafe) {
  5689. child = Buffer.allocUnsafe(parent.length);
  5690. } else {
  5691. child = new Buffer(parent.length);
  5692. }
  5693. parent.copy(child);
  5694. return child;
  5695. } else if (_instanceof(parent, Error)) {
  5696. child = Object.create(parent);
  5697. } else {
  5698. if (typeof prototype == 'undefined') {
  5699. proto = Object.getPrototypeOf(parent);
  5700. child = Object.create(proto);
  5701. }
  5702. else {
  5703. child = Object.create(prototype);
  5704. proto = prototype;
  5705. }
  5706. }
  5707. if (circular) {
  5708. var index = allParents.indexOf(parent);
  5709. if (index != -1) {
  5710. return allChildren[index];
  5711. }
  5712. allParents.push(parent);
  5713. allChildren.push(child);
  5714. }
  5715. if (_instanceof(parent, nativeMap)) {
  5716. parent.forEach(function(value, key) {
  5717. var keyChild = _clone(key, depth - 1);
  5718. var valueChild = _clone(value, depth - 1);
  5719. child.set(keyChild, valueChild);
  5720. });
  5721. }
  5722. if (_instanceof(parent, nativeSet)) {
  5723. parent.forEach(function(value) {
  5724. var entryChild = _clone(value, depth - 1);
  5725. child.add(entryChild);
  5726. });
  5727. }
  5728. for (var i in parent) {
  5729. var attrs;
  5730. if (proto) {
  5731. attrs = Object.getOwnPropertyDescriptor(proto, i);
  5732. }
  5733. if (attrs && attrs.set == null) {
  5734. continue;
  5735. }
  5736. child[i] = _clone(parent[i], depth - 1);
  5737. }
  5738. if (Object.getOwnPropertySymbols) {
  5739. var symbols = Object.getOwnPropertySymbols(parent);
  5740. for (var i = 0; i < symbols.length; i++) {
  5741. var symbol = symbols[i];
  5742. var descriptor = Object.getOwnPropertyDescriptor(parent, symbol);
  5743. if (descriptor && !descriptor.enumerable && !includeNonEnumerable) {
  5744. continue;
  5745. }
  5746. child[symbol] = _clone(parent[symbol], depth - 1);
  5747. if (!descriptor.enumerable) {
  5748. Object.defineProperty(child, symbol, {
  5749. enumerable: false
  5750. });
  5751. }
  5752. }
  5753. }
  5754. if (includeNonEnumerable) {
  5755. var allPropertyNames = Object.getOwnPropertyNames(parent);
  5756. for (var i = 0; i < allPropertyNames.length; i++) {
  5757. var propertyName = allPropertyNames[i];
  5758. var descriptor = Object.getOwnPropertyDescriptor(parent, propertyName);
  5759. if (descriptor && descriptor.enumerable) {
  5760. continue;
  5761. }
  5762. child[propertyName] = _clone(parent[propertyName], depth - 1);
  5763. Object.defineProperty(child, propertyName, {
  5764. enumerable: false
  5765. });
  5766. }
  5767. }
  5768. return child;
  5769. }
  5770. return _clone(parent, depth);
  5771. }
  5772. clone.clonePrototype = function clonePrototype(parent) {
  5773. if (parent === null)
  5774. return null;
  5775. var c = function () {};
  5776. c.prototype = parent;
  5777. return new c();
  5778. };
  5779. function __objToStr(o) {
  5780. return Object.prototype.toString.call(o);
  5781. }
  5782. clone.__objToStr = __objToStr;
  5783. function __isDate(o) {
  5784. return typeof o === 'object' && __objToStr(o) === '[object Date]';
  5785. }
  5786. clone.__isDate = __isDate;
  5787. function __isArray(o) {
  5788. return typeof o === 'object' && __objToStr(o) === '[object Array]';
  5789. }
  5790. clone.__isArray = __isArray;
  5791. function __isRegExp(o) {
  5792. return typeof o === 'object' && __objToStr(o) === '[object RegExp]';
  5793. }
  5794. clone.__isRegExp = __isRegExp;
  5795. function __getRegExpFlags(re) {
  5796. var flags = '';
  5797. if (re.global) flags += 'g';
  5798. if (re.ignoreCase) flags += 'i';
  5799. if (re.multiline) flags += 'm';
  5800. return flags;
  5801. }
  5802. clone.__getRegExpFlags = __getRegExpFlags;
  5803. return clone;
  5804. })();
  5805. if (typeof module === 'object' && module.exports) {
  5806. module.exports = clone;
  5807. }
  5808. var CSSLint = (function() {
  5809. "use strict";
  5810. var rules = [],
  5811. formatters = [],
  5812. embeddedRuleset = /\/\*\s*csslint([^\*]*)\*\//,
  5813. api = new parserlib.util.EventTarget();
  5814. api.version = "1.0.5";
  5815. api.addRule = function(rule) {
  5816. rules.push(rule);
  5817. rules[rule.id] = rule;
  5818. };
  5819. api.clearRules = function() {
  5820. rules = [];
  5821. };
  5822. api.getRules = function() {
  5823. return [].concat(rules).sort(function(a, b) {
  5824. return a.id > b.id ? 1 : 0;
  5825. });
  5826. };
  5827. api.getRuleset = function() {
  5828. var ruleset = {},
  5829. i = 0,
  5830. len = rules.length;
  5831. while (i < len) {
  5832. ruleset[rules[i++].id] = 1; // by default, everything is a warning
  5833. }
  5834. return ruleset;
  5835. };
  5836. function applyEmbeddedRuleset(text, ruleset) {
  5837. var valueMap,
  5838. embedded = text && text.match(embeddedRuleset),
  5839. rules = embedded && embedded[1];
  5840. if (rules) {
  5841. valueMap = {
  5842. "true": 2, // true is error
  5843. "": 1, // blank is warning
  5844. "false": 0, // false is ignore
  5845. "2": 2, // explicit error
  5846. "1": 1, // explicit warning
  5847. "0": 0 // explicit ignore
  5848. };
  5849. rules.toLowerCase().split(",").forEach(function(rule) {
  5850. var pair = rule.split(":"),
  5851. property = pair[0] || "",
  5852. value = pair[1] || "";
  5853. ruleset[property.trim()] = valueMap[value.trim()];
  5854. });
  5855. }
  5856. return ruleset;
  5857. }
  5858. api.addFormatter = function(formatter) {
  5859. formatters[formatter.id] = formatter;
  5860. };
  5861. api.getFormatter = function(formatId) {
  5862. return formatters[formatId];
  5863. };
  5864. api.format = function(results, filename, formatId, options) {
  5865. var formatter = api.getFormatter(formatId),
  5866. result = null;
  5867. if (formatter) {
  5868. result = formatter.startFormat();
  5869. result += formatter.formatResults(results, filename, options || {});
  5870. result += formatter.endFormat();
  5871. }
  5872. return result;
  5873. };
  5874. api.hasFormat = function(formatId) {
  5875. return formatters.hasOwnProperty(formatId);
  5876. };
  5877. api.verify = function(text, ruleset) {
  5878. var i = 0,
  5879. reporter,
  5880. lines,
  5881. allow = {},
  5882. ignore = [],
  5883. report,
  5884. parser = new parserlib.css.Parser({
  5885. starHack: true,
  5886. ieFilters: true,
  5887. underscoreHack: true,
  5888. strict: false
  5889. });
  5890. lines = text.replace(/\n\r?/g, "$split$").split("$split$");
  5891. CSSLint.Util.forEach(lines, function (line, lineno) {
  5892. var allowLine = line && line.match(/\/\*[ \t]*csslint[ \t]+allow:[ \t]*([^\*]*)\*\//i),
  5893. allowRules = allowLine && allowLine[1],
  5894. allowRuleset = {};
  5895. if (allowRules) {
  5896. allowRules.toLowerCase().split(",").forEach(function(allowRule) {
  5897. allowRuleset[allowRule.trim()] = true;
  5898. });
  5899. if (Object.keys(allowRuleset).length > 0) {
  5900. allow[lineno + 1] = allowRuleset;
  5901. }
  5902. }
  5903. });
  5904. var ignoreStart = null,
  5905. ignoreEnd = null;
  5906. CSSLint.Util.forEach(lines, function (line, lineno) {
  5907. if (ignoreStart === null && line.match(/\/\*[ \t]*csslint[ \t]+ignore:start[ \t]*\*\//i)) {
  5908. ignoreStart = lineno;
  5909. }
  5910. if (line.match(/\/\*[ \t]*csslint[ \t]+ignore:end[ \t]*\*\//i)) {
  5911. ignoreEnd = lineno;
  5912. }
  5913. if (ignoreStart !== null && ignoreEnd !== null) {
  5914. ignore.push([ignoreStart, ignoreEnd]);
  5915. ignoreStart = ignoreEnd = null;
  5916. }
  5917. });
  5918. if (ignoreStart !== null) {
  5919. ignore.push([ignoreStart, lines.length]);
  5920. }
  5921. if (!ruleset) {
  5922. ruleset = api.getRuleset();
  5923. }
  5924. if (embeddedRuleset.test(text)) {
  5925. ruleset = clone(ruleset);
  5926. ruleset = applyEmbeddedRuleset(text, ruleset);
  5927. }
  5928. reporter = new Reporter(lines, ruleset, allow, ignore);
  5929. ruleset.errors = 2; // always report parsing errors as errors
  5930. for (i in ruleset) {
  5931. if (ruleset.hasOwnProperty(i) && ruleset[i]) {
  5932. if (rules[i]) {
  5933. rules[i].init(parser, reporter);
  5934. }
  5935. }
  5936. }
  5937. try {
  5938. parser.parse(text);
  5939. } catch (ex) {
  5940. reporter.error("Fatal error, cannot continue: " + ex.message, ex.line, ex.col, {});
  5941. }
  5942. report = {
  5943. messages : reporter.messages,
  5944. stats : reporter.stats,
  5945. ruleset : reporter.ruleset,
  5946. allow : reporter.allow,
  5947. ignore : reporter.ignore
  5948. };
  5949. report.messages.sort(function (a, b) {
  5950. if (a.rollup && !b.rollup) {
  5951. return 1;
  5952. } else if (!a.rollup && b.rollup) {
  5953. return -1;
  5954. } else {
  5955. return a.line - b.line;
  5956. }
  5957. });
  5958. return report;
  5959. };
  5960. return api;
  5961. })();
  5962. function Reporter(lines, ruleset, allow, ignore) {
  5963. "use strict";
  5964. this.messages = [];
  5965. this.stats = [];
  5966. this.lines = lines;
  5967. this.ruleset = ruleset;
  5968. this.allow = allow;
  5969. if (!this.allow) {
  5970. this.allow = {};
  5971. }
  5972. this.ignore = ignore;
  5973. if (!this.ignore) {
  5974. this.ignore = [];
  5975. }
  5976. }
  5977. Reporter.prototype = {
  5978. constructor: Reporter,
  5979. error: function(message, line, col, rule) {
  5980. "use strict";
  5981. this.messages.push({
  5982. type : "error",
  5983. line : line,
  5984. col : col,
  5985. message : message,
  5986. evidence: this.lines[line-1],
  5987. rule : rule || {}
  5988. });
  5989. },
  5990. warn: function(message, line, col, rule) {
  5991. "use strict";
  5992. this.report(message, line, col, rule);
  5993. },
  5994. report: function(message, line, col, rule) {
  5995. "use strict";
  5996. if (this.allow.hasOwnProperty(line) && this.allow[line].hasOwnProperty(rule.id)) {
  5997. return;
  5998. }
  5999. if (this.isIgnored(line)) {
  6000. return;
  6001. }
  6002. this.messages.push({
  6003. type : this.ruleset[rule.id] === 2 ? "error" : "warning",
  6004. line : line,
  6005. col : col,
  6006. message : message,
  6007. evidence: this.lines[line-1],
  6008. rule : rule
  6009. });
  6010. },
  6011. info: function(message, line, col, rule) {
  6012. "use strict";
  6013. this.messages.push({
  6014. type : "info",
  6015. line : line,
  6016. col : col,
  6017. message : message,
  6018. evidence: this.lines[line-1],
  6019. rule : rule
  6020. });
  6021. },
  6022. rollupError: function(message, rule) {
  6023. "use strict";
  6024. this.messages.push({
  6025. type : "error",
  6026. rollup : true,
  6027. message : message,
  6028. rule : rule
  6029. });
  6030. },
  6031. rollupWarn: function(message, rule) {
  6032. "use strict";
  6033. this.messages.push({
  6034. type : "warning",
  6035. rollup : true,
  6036. message : message,
  6037. rule : rule
  6038. });
  6039. },
  6040. stat: function(name, value) {
  6041. "use strict";
  6042. this.stats[name] = value;
  6043. },
  6044. isIgnored: function(line) {
  6045. "use strict";
  6046. var ignore = false;
  6047. CSSLint.Util.forEach(this.ignore, function (range) {
  6048. if (range[0] <= line && line <= range[1]) {
  6049. ignore = true;
  6050. }
  6051. });
  6052. return ignore;
  6053. }
  6054. };
  6055. CSSLint._Reporter = Reporter;
  6056. CSSLint.Util = {
  6057. mix: function(receiver, supplier) {
  6058. "use strict";
  6059. var prop;
  6060. for (prop in supplier) {
  6061. if (supplier.hasOwnProperty(prop)) {
  6062. receiver[prop] = supplier[prop];
  6063. }
  6064. }
  6065. return prop;
  6066. },
  6067. indexOf: function(values, value) {
  6068. "use strict";
  6069. if (values.indexOf) {
  6070. return values.indexOf(value);
  6071. } else {
  6072. for (var i=0, len=values.length; i < len; i++) {
  6073. if (values[i] === value) {
  6074. return i;
  6075. }
  6076. }
  6077. return -1;
  6078. }
  6079. },
  6080. forEach: function(values, func) {
  6081. "use strict";
  6082. if (values.forEach) {
  6083. return values.forEach(func);
  6084. } else {
  6085. for (var i=0, len=values.length; i < len; i++) {
  6086. func(values[i], i, values);
  6087. }
  6088. }
  6089. }
  6090. };
  6091. CSSLint.addRule({
  6092. id: "box-model",
  6093. name: "Beware of broken box size",
  6094. desc: "Don't use width or height when using padding or border.",
  6095. url: "https://github.com/CSSLint/csslint/wiki/Beware-of-box-model-size",
  6096. browsers: "All",
  6097. init: function(parser, reporter) {
  6098. "use strict";
  6099. var rule = this,
  6100. widthProperties = {
  6101. border: 1,
  6102. "border-left": 1,
  6103. "border-right": 1,
  6104. padding: 1,
  6105. "padding-left": 1,
  6106. "padding-right": 1
  6107. },
  6108. heightProperties = {
  6109. border: 1,
  6110. "border-bottom": 1,
  6111. "border-top": 1,
  6112. padding: 1,
  6113. "padding-bottom": 1,
  6114. "padding-top": 1
  6115. },
  6116. properties,
  6117. boxSizing = false;
  6118. function startRule() {
  6119. properties = {};
  6120. boxSizing = false;
  6121. }
  6122. function endRule() {
  6123. var prop, value;
  6124. if (!boxSizing) {
  6125. if (properties.height) {
  6126. for (prop in heightProperties) {
  6127. if (heightProperties.hasOwnProperty(prop) && properties[prop]) {
  6128. value = properties[prop].value;
  6129. if (!(prop === "padding" && value.parts.length === 2 && value.parts[0].value === 0)) {
  6130. reporter.report("Using height with " + prop + " can sometimes make elements larger than you expect.", properties[prop].line, properties[prop].col, rule);
  6131. }
  6132. }
  6133. }
  6134. }
  6135. if (properties.width) {
  6136. for (prop in widthProperties) {
  6137. if (widthProperties.hasOwnProperty(prop) && properties[prop]) {
  6138. value = properties[prop].value;
  6139. if (!(prop === "padding" && value.parts.length === 2 && value.parts[1].value === 0)) {
  6140. reporter.report("Using width with " + prop + " can sometimes make elements larger than you expect.", properties[prop].line, properties[prop].col, rule);
  6141. }
  6142. }
  6143. }
  6144. }
  6145. }
  6146. }
  6147. parser.addListener("startrule", startRule);
  6148. parser.addListener("startfontface", startRule);
  6149. parser.addListener("startpage", startRule);
  6150. parser.addListener("startpagemargin", startRule);
  6151. parser.addListener("startkeyframerule", startRule);
  6152. parser.addListener("startviewport", startRule);
  6153. parser.addListener("property", function(event) {
  6154. var name = event.property.text.toLowerCase();
  6155. if (heightProperties[name] || widthProperties[name]) {
  6156. if (!/^0\S*$/.test(event.value) && !(name === "border" && event.value.toString() === "none")) {
  6157. properties[name] = {
  6158. line: event.property.line,
  6159. col: event.property.col,
  6160. value: event.value
  6161. };
  6162. }
  6163. } else {
  6164. if (/^(width|height)/i.test(name) && /^(length|percentage)/.test(event.value.parts[0].type)) {
  6165. properties[name] = 1;
  6166. } else if (name === "box-sizing") {
  6167. boxSizing = true;
  6168. }
  6169. }
  6170. });
  6171. parser.addListener("endrule", endRule);
  6172. parser.addListener("endfontface", endRule);
  6173. parser.addListener("endpage", endRule);
  6174. parser.addListener("endpagemargin", endRule);
  6175. parser.addListener("endkeyframerule", endRule);
  6176. parser.addListener("endviewport", endRule);
  6177. }
  6178. });
  6179. CSSLint.addRule({
  6180. id: "bulletproof-font-face",
  6181. name: "Use the bulletproof @font-face syntax",
  6182. desc: "Use the bulletproof @font-face syntax to avoid 404's in old IE (http://www.fontspring.com/blog/the-new-bulletproof-font-face-syntax).",
  6183. url: "https://github.com/CSSLint/csslint/wiki/Bulletproof-font-face",
  6184. browsers: "All",
  6185. init: function(parser, reporter) {
  6186. "use strict";
  6187. var rule = this,
  6188. fontFaceRule = false,
  6189. firstSrc = true,
  6190. ruleFailed = false,
  6191. line, col;
  6192. parser.addListener("startfontface", function() {
  6193. fontFaceRule = true;
  6194. });
  6195. parser.addListener("property", function(event) {
  6196. if (!fontFaceRule) {
  6197. return;
  6198. }
  6199. var propertyName = event.property.toString().toLowerCase(),
  6200. value = event.value.toString();
  6201. line = event.line;
  6202. col = event.col;
  6203. if (propertyName === "src") {
  6204. var regex = /^\s?url\(['"].+\.eot\?.*['"]\)\s*format\(['"]embedded-opentype['"]\).*$/i;
  6205. if (!value.match(regex) && firstSrc) {
  6206. ruleFailed = true;
  6207. firstSrc = false;
  6208. } else if (value.match(regex) && !firstSrc) {
  6209. ruleFailed = false;
  6210. }
  6211. }
  6212. });
  6213. parser.addListener("endfontface", function() {
  6214. fontFaceRule = false;
  6215. if (ruleFailed) {
  6216. reporter.report("@font-face declaration doesn't follow the fontspring bulletproof syntax.", line, col, rule);
  6217. }
  6218. });
  6219. }
  6220. });
  6221. CSSLint.addRule({
  6222. id: "compatible-vendor-prefixes",
  6223. name: "Require compatible vendor prefixes",
  6224. desc: "Include all compatible vendor prefixes to reach a wider range of users.",
  6225. url: "https://github.com/CSSLint/csslint/wiki/Require-compatible-vendor-prefixes",
  6226. browsers: "All",
  6227. init: function (parser, reporter) {
  6228. "use strict";
  6229. var rule = this,
  6230. compatiblePrefixes,
  6231. properties,
  6232. prop,
  6233. variations,
  6234. prefixed,
  6235. i,
  6236. len,
  6237. inKeyFrame = false,
  6238. arrayPush = Array.prototype.push,
  6239. applyTo = [];
  6240. compatiblePrefixes = {
  6241. "animation" : "webkit",
  6242. "animation-delay" : "webkit",
  6243. "animation-direction" : "webkit",
  6244. "animation-duration" : "webkit",
  6245. "animation-fill-mode" : "webkit",
  6246. "animation-iteration-count" : "webkit",
  6247. "animation-name" : "webkit",
  6248. "animation-play-state" : "webkit",
  6249. "animation-timing-function" : "webkit",
  6250. "appearance" : "webkit moz",
  6251. "border-end" : "webkit moz",
  6252. "border-end-color" : "webkit moz",
  6253. "border-end-style" : "webkit moz",
  6254. "border-end-width" : "webkit moz",
  6255. "border-image" : "webkit moz o",
  6256. "border-radius" : "webkit",
  6257. "border-start" : "webkit moz",
  6258. "border-start-color" : "webkit moz",
  6259. "border-start-style" : "webkit moz",
  6260. "border-start-width" : "webkit moz",
  6261. "box-align" : "webkit moz",
  6262. "box-direction" : "webkit moz",
  6263. "box-flex" : "webkit moz",
  6264. "box-lines" : "webkit",
  6265. "box-ordinal-group" : "webkit moz",
  6266. "box-orient" : "webkit moz",
  6267. "box-pack" : "webkit moz",
  6268. "box-sizing" : "",
  6269. "box-shadow" : "",
  6270. "column-count" : "webkit moz ms",
  6271. "column-gap" : "webkit moz ms",
  6272. "column-rule" : "webkit moz ms",
  6273. "column-rule-color" : "webkit moz ms",
  6274. "column-rule-style" : "webkit moz ms",
  6275. "column-rule-width" : "webkit moz ms",
  6276. "column-width" : "webkit moz ms",
  6277. "flex" : "webkit ms",
  6278. "flex-basis" : "webkit",
  6279. "flex-direction" : "webkit ms",
  6280. "flex-flow" : "webkit",
  6281. "flex-grow" : "webkit",
  6282. "flex-shrink" : "webkit",
  6283. "hyphens" : "epub moz",
  6284. "line-break" : "webkit ms",
  6285. "margin-end" : "webkit moz",
  6286. "margin-start" : "webkit moz",
  6287. "marquee-speed" : "webkit wap",
  6288. "marquee-style" : "webkit wap",
  6289. "padding-end" : "webkit moz",
  6290. "padding-start" : "webkit moz",
  6291. "tab-size" : "moz o",
  6292. "text-size-adjust" : "webkit ms",
  6293. "transform" : "webkit ms",
  6294. "transform-origin" : "webkit ms",
  6295. "transition" : "",
  6296. "transition-delay" : "",
  6297. "transition-duration" : "",
  6298. "transition-property" : "",
  6299. "transition-timing-function" : "",
  6300. "user-modify" : "webkit moz",
  6301. "user-select" : "webkit moz ms",
  6302. "word-break" : "epub ms",
  6303. "writing-mode" : "epub ms"
  6304. };
  6305. for (prop in compatiblePrefixes) {
  6306. if (compatiblePrefixes.hasOwnProperty(prop)) {
  6307. variations = [];
  6308. prefixed = compatiblePrefixes[prop].split(" ");
  6309. for (i = 0, len = prefixed.length; i < len; i++) {
  6310. variations.push("-" + prefixed[i] + "-" + prop);
  6311. }
  6312. compatiblePrefixes[prop] = variations;
  6313. arrayPush.apply(applyTo, variations);
  6314. }
  6315. }
  6316. parser.addListener("startrule", function () {
  6317. properties = [];
  6318. });
  6319. parser.addListener("startkeyframes", function (event) {
  6320. inKeyFrame = event.prefix || true;
  6321. });
  6322. parser.addListener("endkeyframes", function () {
  6323. inKeyFrame = false;
  6324. });
  6325. parser.addListener("property", function (event) {
  6326. var name = event.property;
  6327. if (CSSLint.Util.indexOf(applyTo, name.text) > -1) {
  6328. if (!inKeyFrame || typeof inKeyFrame !== "string" ||
  6329. name.text.indexOf("-" + inKeyFrame + "-") !== 0) {
  6330. properties.push(name);
  6331. }
  6332. }
  6333. });
  6334. parser.addListener("endrule", function () {
  6335. if (!properties.length) {
  6336. return;
  6337. }
  6338. var propertyGroups = {},
  6339. i,
  6340. len,
  6341. name,
  6342. prop,
  6343. variations,
  6344. value,
  6345. full,
  6346. actual,
  6347. item,
  6348. propertiesSpecified;
  6349. for (i = 0, len = properties.length; i < len; i++) {
  6350. name = properties[i];
  6351. for (prop in compatiblePrefixes) {
  6352. if (compatiblePrefixes.hasOwnProperty(prop)) {
  6353. variations = compatiblePrefixes[prop];
  6354. if (CSSLint.Util.indexOf(variations, name.text) > -1) {
  6355. if (!propertyGroups[prop]) {
  6356. propertyGroups[prop] = {
  6357. full: variations.slice(0),
  6358. actual: [],
  6359. actualNodes: []
  6360. };
  6361. }
  6362. if (CSSLint.Util.indexOf(propertyGroups[prop].actual, name.text) === -1) {
  6363. propertyGroups[prop].actual.push(name.text);
  6364. propertyGroups[prop].actualNodes.push(name);
  6365. }
  6366. }
  6367. }
  6368. }
  6369. }
  6370. for (prop in propertyGroups) {
  6371. if (propertyGroups.hasOwnProperty(prop)) {
  6372. value = propertyGroups[prop];
  6373. full = value.full;
  6374. actual = value.actual;
  6375. if (full.length > actual.length) {
  6376. for (i = 0, len = full.length; i < len; i++) {
  6377. item = full[i];
  6378. if (CSSLint.Util.indexOf(actual, item) === -1) {
  6379. propertiesSpecified = (actual.length === 1) ? actual[0] : (actual.length === 2) ? actual.join(" and ") : actual.join(", ");
  6380. reporter.report("The property " + item + " is compatible with " + propertiesSpecified + " and should be included as well.", value.actualNodes[0].line, value.actualNodes[0].col, rule);
  6381. }
  6382. }
  6383. }
  6384. }
  6385. }
  6386. });
  6387. }
  6388. });
  6389. CSSLint.addRule({
  6390. id: "display-property-grouping",
  6391. name: "Require properties appropriate for display",
  6392. desc: "Certain properties shouldn't be used with certain display property values.",
  6393. url: "https://github.com/CSSLint/csslint/wiki/Require-properties-appropriate-for-display",
  6394. browsers: "All",
  6395. init: function(parser, reporter) {
  6396. "use strict";
  6397. var rule = this;
  6398. var propertiesToCheck = {
  6399. display: 1,
  6400. "float": "none",
  6401. height: 1,
  6402. width: 1,
  6403. margin: 1,
  6404. "margin-left": 1,
  6405. "margin-right": 1,
  6406. "margin-bottom": 1,
  6407. "margin-top": 1,
  6408. padding: 1,
  6409. "padding-left": 1,
  6410. "padding-right": 1,
  6411. "padding-bottom": 1,
  6412. "padding-top": 1,
  6413. "vertical-align": 1
  6414. },
  6415. properties;
  6416. function reportProperty(name, display, msg) {
  6417. if (properties[name]) {
  6418. if (typeof propertiesToCheck[name] !== "string" || properties[name].value.toLowerCase() !== propertiesToCheck[name]) {
  6419. reporter.report(msg || name + " can't be used with display: " + display + ".", properties[name].line, properties[name].col, rule);
  6420. }
  6421. }
  6422. }
  6423. function startRule() {
  6424. properties = {};
  6425. }
  6426. function endRule() {
  6427. var display = properties.display ? properties.display.value : null;
  6428. if (display) {
  6429. switch (display) {
  6430. case "inline":
  6431. reportProperty("height", display);
  6432. reportProperty("width", display);
  6433. reportProperty("margin", display);
  6434. reportProperty("margin-top", display);
  6435. reportProperty("margin-bottom", display);
  6436. reportProperty("float", display, "display:inline has no effect on floated elements (but may be used to fix the IE6 double-margin bug).");
  6437. break;
  6438. case "block":
  6439. reportProperty("vertical-align", display);
  6440. break;
  6441. case "inline-block":
  6442. reportProperty("float", display);
  6443. break;
  6444. default:
  6445. if (display.indexOf("table-") === 0) {
  6446. reportProperty("margin", display);
  6447. reportProperty("margin-left", display);
  6448. reportProperty("margin-right", display);
  6449. reportProperty("margin-top", display);
  6450. reportProperty("margin-bottom", display);
  6451. reportProperty("float", display);
  6452. }
  6453. }
  6454. }
  6455. }
  6456. parser.addListener("startrule", startRule);
  6457. parser.addListener("startfontface", startRule);
  6458. parser.addListener("startkeyframerule", startRule);
  6459. parser.addListener("startpagemargin", startRule);
  6460. parser.addListener("startpage", startRule);
  6461. parser.addListener("startviewport", startRule);
  6462. parser.addListener("property", function(event) {
  6463. var name = event.property.text.toLowerCase();
  6464. if (propertiesToCheck[name]) {
  6465. properties[name] = {
  6466. value: event.value.text,
  6467. line: event.property.line,
  6468. col: event.property.col
  6469. };
  6470. }
  6471. });
  6472. parser.addListener("endrule", endRule);
  6473. parser.addListener("endfontface", endRule);
  6474. parser.addListener("endkeyframerule", endRule);
  6475. parser.addListener("endpagemargin", endRule);
  6476. parser.addListener("endpage", endRule);
  6477. parser.addListener("endviewport", endRule);
  6478. }
  6479. });
  6480. CSSLint.addRule({
  6481. id: "duplicate-background-images",
  6482. name: "Disallow duplicate background images",
  6483. desc: "Every background-image should be unique. Use a common class for e.g. sprites.",
  6484. url: "https://github.com/CSSLint/csslint/wiki/Disallow-duplicate-background-images",
  6485. browsers: "All",
  6486. init: function(parser, reporter) {
  6487. "use strict";
  6488. var rule = this,
  6489. stack = {};
  6490. parser.addListener("property", function(event) {
  6491. var name = event.property.text,
  6492. value = event.value,
  6493. i, len;
  6494. if (name.match(/background/i)) {
  6495. for (i=0, len=value.parts.length; i < len; i++) {
  6496. if (value.parts[i].type === "uri") {
  6497. if (typeof stack[value.parts[i].uri] === "undefined") {
  6498. stack[value.parts[i].uri] = event;
  6499. } else {
  6500. reporter.report("Background image '" + value.parts[i].uri + "' was used multiple times, first declared at line " + stack[value.parts[i].uri].line + ", col " + stack[value.parts[i].uri].col + ".", event.line, event.col, rule);
  6501. }
  6502. }
  6503. }
  6504. }
  6505. });
  6506. }
  6507. });
  6508. CSSLint.addRule({
  6509. id: "duplicate-properties",
  6510. name: "Disallow duplicate properties",
  6511. desc: "Duplicate properties must appear one after the other.",
  6512. url: "https://github.com/CSSLint/csslint/wiki/Disallow-duplicate-properties",
  6513. browsers: "All",
  6514. init: function(parser, reporter) {
  6515. "use strict";
  6516. var rule = this,
  6517. properties,
  6518. lastProperty;
  6519. function startRule() {
  6520. properties = {};
  6521. }
  6522. parser.addListener("startrule", startRule);
  6523. parser.addListener("startfontface", startRule);
  6524. parser.addListener("startpage", startRule);
  6525. parser.addListener("startpagemargin", startRule);
  6526. parser.addListener("startkeyframerule", startRule);
  6527. parser.addListener("startviewport", startRule);
  6528. parser.addListener("property", function(event) {
  6529. var property = event.property,
  6530. name = property.text.toLowerCase();
  6531. if (properties[name] && (lastProperty !== name || properties[name] === event.value.text)) {
  6532. reporter.report("Duplicate property '" + event.property + "' found.", event.line, event.col, rule);
  6533. }
  6534. properties[name] = event.value.text;
  6535. lastProperty = name;
  6536. });
  6537. }
  6538. });
  6539. CSSLint.addRule({
  6540. id: "empty-rules",
  6541. name: "Disallow empty rules",
  6542. desc: "Rules without any properties specified should be removed.",
  6543. url: "https://github.com/CSSLint/csslint/wiki/Disallow-empty-rules",
  6544. browsers: "All",
  6545. init: function(parser, reporter) {
  6546. "use strict";
  6547. var rule = this,
  6548. count = 0;
  6549. parser.addListener("startrule", function() {
  6550. count=0;
  6551. });
  6552. parser.addListener("property", function() {
  6553. count++;
  6554. });
  6555. parser.addListener("endrule", function(event) {
  6556. var selectors = event.selectors;
  6557. if (count === 0) {
  6558. reporter.report("Rule is empty.", selectors[0].line, selectors[0].col, rule);
  6559. }
  6560. });
  6561. }
  6562. });
  6563. CSSLint.addRule({
  6564. id: "errors",
  6565. name: "Parsing Errors",
  6566. desc: "This rule looks for recoverable syntax errors.",
  6567. browsers: "All",
  6568. init: function(parser, reporter) {
  6569. "use strict";
  6570. var rule = this;
  6571. parser.addListener("error", function(event) {
  6572. reporter.error(event.message, event.line, event.col, rule);
  6573. });
  6574. }
  6575. });
  6576. CSSLint.addRule({
  6577. id: "floats",
  6578. name: "Disallow too many floats",
  6579. desc: "This rule tests if the float property is used too many times",
  6580. url: "https://github.com/CSSLint/csslint/wiki/Disallow-too-many-floats",
  6581. browsers: "All",
  6582. init: function(parser, reporter) {
  6583. "use strict";
  6584. var rule = this;
  6585. var count = 0;
  6586. parser.addListener("property", function(event) {
  6587. if (!reporter.isIgnored(event.property.line)) {
  6588. if (event.property.text.toLowerCase() === "float" &&
  6589. event.value.text.toLowerCase() !== "none") {
  6590. count++;
  6591. }
  6592. }
  6593. });
  6594. parser.addListener("endstylesheet", function() {
  6595. reporter.stat("floats", count);
  6596. if (count >= 10) {
  6597. reporter.rollupWarn("Too many floats (" + count + "), you're probably using them for layout. Consider using a grid system instead.", rule);
  6598. }
  6599. });
  6600. }
  6601. });
  6602. CSSLint.addRule({
  6603. id: "font-faces",
  6604. name: "Don't use too many web fonts",
  6605. desc: "Too many different web fonts in the same stylesheet.",
  6606. url: "https://github.com/CSSLint/csslint/wiki/Don%27t-use-too-many-web-fonts",
  6607. browsers: "All",
  6608. init: function(parser, reporter) {
  6609. "use strict";
  6610. var rule = this,
  6611. count = 0;
  6612. parser.addListener("startfontface", function(event) {
  6613. if (!reporter.isIgnored(event.line)) {
  6614. count++;
  6615. }
  6616. });
  6617. parser.addListener("endstylesheet", function() {
  6618. if (count > 5) {
  6619. reporter.rollupWarn("Too many @font-face declarations (" + count + ").", rule);
  6620. }
  6621. });
  6622. }
  6623. });
  6624. CSSLint.addRule({
  6625. id: "font-sizes",
  6626. name: "Disallow too many font sizes",
  6627. desc: "Checks the number of font-size declarations.",
  6628. url: "https://github.com/CSSLint/csslint/wiki/Don%27t-use-too-many-font-size-declarations",
  6629. browsers: "All",
  6630. init: function(parser, reporter) {
  6631. "use strict";
  6632. var rule = this,
  6633. count = 0;
  6634. parser.addListener("property", function(event) {
  6635. if (!reporter.isIgnored(event.property.line)) {
  6636. if (event.property.toString() === "font-size") {
  6637. count++;
  6638. }
  6639. }
  6640. });
  6641. parser.addListener("endstylesheet", function() {
  6642. reporter.stat("font-sizes", count);
  6643. if (count >= 10) {
  6644. reporter.rollupWarn("Too many font-size declarations (" + count + "), abstraction needed.", rule);
  6645. }
  6646. });
  6647. }
  6648. });
  6649. CSSLint.addRule({
  6650. id: "gradients",
  6651. name: "Require all gradient definitions",
  6652. desc: "When using a vendor-prefixed gradient, make sure to use them all.",
  6653. url: "https://github.com/CSSLint/csslint/wiki/Require-all-gradient-definitions",
  6654. browsers: "All",
  6655. init: function(parser, reporter) {
  6656. "use strict";
  6657. var rule = this,
  6658. gradients;
  6659. parser.addListener("startrule", function() {
  6660. gradients = {
  6661. moz: 0,
  6662. webkit: 0,
  6663. oldWebkit: 0,
  6664. o: 0
  6665. };
  6666. });
  6667. parser.addListener("property", function(event) {
  6668. if (/\-(moz|o|webkit)(?:\-(?:linear|radial))\-gradient/i.test(event.value)) {
  6669. gradients[RegExp.$1] = 1;
  6670. } else if (/\-webkit\-gradient/i.test(event.value)) {
  6671. gradients.oldWebkit = 1;
  6672. }
  6673. });
  6674. parser.addListener("endrule", function(event) {
  6675. var missing = [];
  6676. if (!gradients.moz) {
  6677. missing.push("Firefox 3.6+");
  6678. }
  6679. if (!gradients.webkit) {
  6680. missing.push("Webkit (Safari 5+, Chrome)");
  6681. }
  6682. if (!gradients.oldWebkit) {
  6683. missing.push("Old Webkit (Safari 4+, Chrome)");
  6684. }
  6685. if (!gradients.o) {
  6686. missing.push("Opera 11.1+");
  6687. }
  6688. if (missing.length && missing.length < 4) {
  6689. reporter.report("Missing vendor-prefixed CSS gradients for " + missing.join(", ") + ".", event.selectors[0].line, event.selectors[0].col, rule);
  6690. }
  6691. });
  6692. }
  6693. });
  6694. CSSLint.addRule({
  6695. id: "ids",
  6696. name: "Disallow IDs in selectors",
  6697. desc: "Selectors should not contain IDs.",
  6698. url: "https://github.com/CSSLint/csslint/wiki/Disallow-IDs-in-selectors",
  6699. browsers: "All",
  6700. init: function(parser, reporter) {
  6701. "use strict";
  6702. var rule = this;
  6703. parser.addListener("startrule", function(event) {
  6704. var selectors = event.selectors,
  6705. selector,
  6706. part,
  6707. modifier,
  6708. idCount,
  6709. i, j, k;
  6710. for (i=0; i < selectors.length; i++) {
  6711. selector = selectors[i];
  6712. idCount = 0;
  6713. for (j=0; j < selector.parts.length; j++) {
  6714. part = selector.parts[j];
  6715. if (part.type === parser.SELECTOR_PART_TYPE) {
  6716. for (k=0; k < part.modifiers.length; k++) {
  6717. modifier = part.modifiers[k];
  6718. if (modifier.type === "id") {
  6719. idCount++;
  6720. }
  6721. }
  6722. }
  6723. }
  6724. if (idCount === 1) {
  6725. reporter.report("Don't use IDs in selectors.", selector.line, selector.col, rule);
  6726. } else if (idCount > 1) {
  6727. reporter.report(idCount + " IDs in the selector, really?", selector.line, selector.col, rule);
  6728. }
  6729. }
  6730. });
  6731. }
  6732. });
  6733. CSSLint.addRule({
  6734. id: "import-ie-limit",
  6735. name: "@import limit on IE6-IE9",
  6736. desc: "IE6-9 supports up to 31 @import per stylesheet",
  6737. browsers: "IE6, IE7, IE8, IE9",
  6738. init: function(parser, reporter) {
  6739. "use strict";
  6740. var rule = this,
  6741. MAX_IMPORT_COUNT = 31,
  6742. count = 0;
  6743. function startPage() {
  6744. count = 0;
  6745. }
  6746. parser.addListener("startpage", startPage);
  6747. parser.addListener("import", function() {
  6748. count++;
  6749. });
  6750. parser.addListener("endstylesheet", function() {
  6751. if (count > MAX_IMPORT_COUNT) {
  6752. reporter.rollupError(
  6753. "Too many @import rules (" + count + "). IE6-9 supports up to 31 import per stylesheet.",
  6754. rule
  6755. );
  6756. }
  6757. });
  6758. }
  6759. });
  6760. CSSLint.addRule({
  6761. id: "import",
  6762. name: "Disallow @import",
  6763. desc: "Don't use @import, use <link> instead.",
  6764. url: "https://github.com/CSSLint/csslint/wiki/Disallow-%40import",
  6765. browsers: "All",
  6766. init: function(parser, reporter) {
  6767. "use strict";
  6768. var rule = this;
  6769. parser.addListener("import", function(event) {
  6770. reporter.report("@import prevents parallel downloads, use <link> instead.", event.line, event.col, rule);
  6771. });
  6772. }
  6773. });
  6774. CSSLint.addRule({
  6775. id: "important",
  6776. name: "Disallow !important",
  6777. desc: "Be careful when using !important declaration",
  6778. url: "https://github.com/CSSLint/csslint/wiki/Disallow-%21important",
  6779. browsers: "All",
  6780. init: function(parser, reporter) {
  6781. "use strict";
  6782. var rule = this,
  6783. count = 0;
  6784. parser.addListener("property", function(event) {
  6785. if (!reporter.isIgnored(event.line)) {
  6786. if (event.important === true) {
  6787. count++;
  6788. reporter.report("Use of !important", event.line, event.col, rule);
  6789. }
  6790. }
  6791. });
  6792. parser.addListener("endstylesheet", function() {
  6793. reporter.stat("important", count);
  6794. if (count >= 10) {
  6795. reporter.rollupWarn("Too many !important declarations (" + count + "), try to use less than 10 to avoid specificity issues.", rule);
  6796. }
  6797. });
  6798. }
  6799. });
  6800. CSSLint.addRule({
  6801. id: "known-properties",
  6802. name: "Require use of known properties",
  6803. desc: "Properties should be known (listed in CSS3 specification) or be a vendor-prefixed property.",
  6804. url: "https://github.com/CSSLint/csslint/wiki/Require-use-of-known-properties",
  6805. browsers: "All",
  6806. init: function(parser, reporter) {
  6807. "use strict";
  6808. var rule = this;
  6809. parser.addListener("property", function(event) {
  6810. if (event.invalid) {
  6811. reporter.report(event.invalid.message, event.line, event.col, rule);
  6812. }
  6813. });
  6814. }
  6815. });
  6816. CSSLint.addRule({
  6817. id: "order-alphabetical",
  6818. name: "Alphabetical order",
  6819. desc: "Assure properties are in alphabetical order",
  6820. browsers: "All",
  6821. init: function(parser, reporter) {
  6822. "use strict";
  6823. var rule = this,
  6824. properties;
  6825. var startRule = function () {
  6826. properties = [];
  6827. };
  6828. var endRule = function(event) {
  6829. var currentProperties = properties.join(","),
  6830. expectedProperties = properties.sort().join(",");
  6831. if (currentProperties !== expectedProperties) {
  6832. reporter.report("Rule doesn't have all its properties in alphabetical order.", event.line, event.col, rule);
  6833. }
  6834. };
  6835. parser.addListener("startrule", startRule);
  6836. parser.addListener("startfontface", startRule);
  6837. parser.addListener("startpage", startRule);
  6838. parser.addListener("startpagemargin", startRule);
  6839. parser.addListener("startkeyframerule", startRule);
  6840. parser.addListener("startviewport", startRule);
  6841. parser.addListener("property", function(event) {
  6842. var name = event.property.text,
  6843. lowerCasePrefixLessName = name.toLowerCase().replace(/^-.*?-/, "");
  6844. properties.push(lowerCasePrefixLessName);
  6845. });
  6846. parser.addListener("endrule", endRule);
  6847. parser.addListener("endfontface", endRule);
  6848. parser.addListener("endpage", endRule);
  6849. parser.addListener("endpagemargin", endRule);
  6850. parser.addListener("endkeyframerule", endRule);
  6851. parser.addListener("endviewport", endRule);
  6852. }
  6853. });
  6854. CSSLint.addRule({
  6855. id: "outline-none",
  6856. name: "Disallow outline: none",
  6857. desc: "Use of outline: none or outline: 0 should be limited to :focus rules.",
  6858. url: "https://github.com/CSSLint/csslint/wiki/Disallow-outline%3Anone",
  6859. browsers: "All",
  6860. tags: ["Accessibility"],
  6861. init: function(parser, reporter) {
  6862. "use strict";
  6863. var rule = this,
  6864. lastRule;
  6865. function startRule(event) {
  6866. if (event.selectors) {
  6867. lastRule = {
  6868. line: event.line,
  6869. col: event.col,
  6870. selectors: event.selectors,
  6871. propCount: 0,
  6872. outline: false
  6873. };
  6874. } else {
  6875. lastRule = null;
  6876. }
  6877. }
  6878. function endRule() {
  6879. if (lastRule) {
  6880. if (lastRule.outline) {
  6881. if (lastRule.selectors.toString().toLowerCase().indexOf(":focus") === -1) {
  6882. reporter.report("Outlines should only be modified using :focus.", lastRule.line, lastRule.col, rule);
  6883. } else if (lastRule.propCount === 1) {
  6884. reporter.report("Outlines shouldn't be hidden unless other visual changes are made.", lastRule.line, lastRule.col, rule);
  6885. }
  6886. }
  6887. }
  6888. }
  6889. parser.addListener("startrule", startRule);
  6890. parser.addListener("startfontface", startRule);
  6891. parser.addListener("startpage", startRule);
  6892. parser.addListener("startpagemargin", startRule);
  6893. parser.addListener("startkeyframerule", startRule);
  6894. parser.addListener("startviewport", startRule);
  6895. parser.addListener("property", function(event) {
  6896. var name = event.property.text.toLowerCase(),
  6897. value = event.value;
  6898. if (lastRule) {
  6899. lastRule.propCount++;
  6900. if (name === "outline" && (value.toString() === "none" || value.toString() === "0")) {
  6901. lastRule.outline = true;
  6902. }
  6903. }
  6904. });
  6905. parser.addListener("endrule", endRule);
  6906. parser.addListener("endfontface", endRule);
  6907. parser.addListener("endpage", endRule);
  6908. parser.addListener("endpagemargin", endRule);
  6909. parser.addListener("endkeyframerule", endRule);
  6910. parser.addListener("endviewport", endRule);
  6911. }
  6912. });
  6913. CSSLint.addRule({
  6914. id: "overqualified-elements",
  6915. name: "Disallow overqualified elements",
  6916. desc: "Don't use classes or IDs with elements (a.foo or a#foo).",
  6917. url: "https://github.com/CSSLint/csslint/wiki/Disallow-overqualified-elements",
  6918. browsers: "All",
  6919. init: function(parser, reporter) {
  6920. "use strict";
  6921. var rule = this,
  6922. classes = {};
  6923. parser.addListener("startrule", function(event) {
  6924. var selectors = event.selectors,
  6925. selector,
  6926. part,
  6927. modifier,
  6928. i, j, k;
  6929. for (i=0; i < selectors.length; i++) {
  6930. selector = selectors[i];
  6931. for (j=0; j < selector.parts.length; j++) {
  6932. part = selector.parts[j];
  6933. if (part.type === parser.SELECTOR_PART_TYPE) {
  6934. for (k=0; k < part.modifiers.length; k++) {
  6935. modifier = part.modifiers[k];
  6936. if (part.elementName && modifier.type === "id") {
  6937. reporter.report("Element (" + part + ") is overqualified, just use " + modifier + " without element name.", part.line, part.col, rule);
  6938. } else if (modifier.type === "class") {
  6939. if (!classes[modifier]) {
  6940. classes[modifier] = [];
  6941. }
  6942. classes[modifier].push({
  6943. modifier: modifier,
  6944. part: part
  6945. });
  6946. }
  6947. }
  6948. }
  6949. }
  6950. }
  6951. });
  6952. parser.addListener("endstylesheet", function() {
  6953. var prop;
  6954. for (prop in classes) {
  6955. if (classes.hasOwnProperty(prop)) {
  6956. if (classes[prop].length === 1 && classes[prop][0].part.elementName) {
  6957. reporter.report("Element (" + classes[prop][0].part + ") is overqualified, just use " + classes[prop][0].modifier + " without element name.", classes[prop][0].part.line, classes[prop][0].part.col, rule);
  6958. }
  6959. }
  6960. }
  6961. });
  6962. }
  6963. });
  6964. CSSLint.addRule({
  6965. id: "regex-selectors",
  6966. name: "Disallow selectors that look like regexs",
  6967. desc: "Selectors that look like regular expressions are slow and should be avoided.",
  6968. url: "https://github.com/CSSLint/csslint/wiki/Disallow-selectors-that-look-like-regular-expressions",
  6969. browsers: "All",
  6970. init: function(parser, reporter) {
  6971. "use strict";
  6972. var rule = this;
  6973. parser.addListener("startrule", function(event) {
  6974. var selectors = event.selectors,
  6975. selector,
  6976. part,
  6977. modifier,
  6978. i, j, k;
  6979. for (i=0; i < selectors.length; i++) {
  6980. selector = selectors[i];
  6981. for (j=0; j < selector.parts.length; j++) {
  6982. part = selector.parts[j];
  6983. if (part.type === parser.SELECTOR_PART_TYPE) {
  6984. for (k=0; k < part.modifiers.length; k++) {
  6985. modifier = part.modifiers[k];
  6986. if (modifier.type === "attribute") {
  6987. if (/([~\|\^\$\*]=)/.test(modifier)) {
  6988. reporter.report("Attribute selectors with " + RegExp.$1 + " are slow!", modifier.line, modifier.col, rule);
  6989. }
  6990. }
  6991. }
  6992. }
  6993. }
  6994. }
  6995. });
  6996. }
  6997. });
  6998. CSSLint.addRule({
  6999. id: "rules-count",
  7000. name: "Rules Count",
  7001. desc: "Track how many rules there are.",
  7002. browsers: "All",
  7003. init: function(parser, reporter) {
  7004. "use strict";
  7005. var count = 0;
  7006. parser.addListener("startrule", function() {
  7007. count++;
  7008. });
  7009. parser.addListener("endstylesheet", function() {
  7010. reporter.stat("rule-count", count);
  7011. });
  7012. }
  7013. });
  7014. CSSLint.addRule({
  7015. id: "selector-max-approaching",
  7016. name: "Warn when approaching the 4095 selector limit for IE",
  7017. desc: "Will warn when selector count is >= 3800 selectors.",
  7018. browsers: "IE",
  7019. init: function(parser, reporter) {
  7020. "use strict";
  7021. var rule = this, count = 0;
  7022. parser.addListener("startrule", function(event) {
  7023. count += event.selectors.length;
  7024. });
  7025. parser.addListener("endstylesheet", function() {
  7026. if (count >= 3800) {
  7027. reporter.report("You have " + count + " selectors. Internet Explorer supports a maximum of 4095 selectors per stylesheet. Consider refactoring.", 0, 0, rule);
  7028. }
  7029. });
  7030. }
  7031. });
  7032. CSSLint.addRule({
  7033. id: "selector-max",
  7034. name: "Error when past the 4095 selector limit for IE",
  7035. desc: "Will error when selector count is > 4095.",
  7036. browsers: "IE",
  7037. init: function(parser, reporter) {
  7038. "use strict";
  7039. var rule = this, count = 0;
  7040. parser.addListener("startrule", function(event) {
  7041. count += event.selectors.length;
  7042. });
  7043. parser.addListener("endstylesheet", function() {
  7044. if (count > 4095) {
  7045. reporter.report("You have " + count + " selectors. Internet Explorer supports a maximum of 4095 selectors per stylesheet. Consider refactoring.", 0, 0, rule);
  7046. }
  7047. });
  7048. }
  7049. });
  7050. CSSLint.addRule({
  7051. id: "selector-newline",
  7052. name: "Disallow new-line characters in selectors",
  7053. desc: "New-line characters in selectors are usually a forgotten comma and not a descendant combinator.",
  7054. browsers: "All",
  7055. init: function(parser, reporter) {
  7056. "use strict";
  7057. var rule = this;
  7058. function startRule(event) {
  7059. var i, len, selector, p, n, pLen, part, part2, type, currentLine, nextLine,
  7060. selectors = event.selectors;
  7061. for (i = 0, len = selectors.length; i < len; i++) {
  7062. selector = selectors[i];
  7063. for (p = 0, pLen = selector.parts.length; p < pLen; p++) {
  7064. for (n = p + 1; n < pLen; n++) {
  7065. part = selector.parts[p];
  7066. part2 = selector.parts[n];
  7067. type = part.type;
  7068. currentLine = part.line;
  7069. nextLine = part2.line;
  7070. if (type === "descendant" && nextLine > currentLine) {
  7071. reporter.report("newline character found in selector (forgot a comma?)", currentLine, selectors[i].parts[0].col, rule);
  7072. }
  7073. }
  7074. }
  7075. }
  7076. }
  7077. parser.addListener("startrule", startRule);
  7078. }
  7079. });
  7080. CSSLint.addRule({
  7081. id: "shorthand",
  7082. name: "Require shorthand properties",
  7083. desc: "Use shorthand properties where possible.",
  7084. url: "https://github.com/CSSLint/csslint/wiki/Require-shorthand-properties",
  7085. browsers: "All",
  7086. init: function(parser, reporter) {
  7087. "use strict";
  7088. var rule = this,
  7089. prop, i, len,
  7090. propertiesToCheck = {},
  7091. properties,
  7092. mapping = {
  7093. "margin": [
  7094. "margin-top",
  7095. "margin-bottom",
  7096. "margin-left",
  7097. "margin-right"
  7098. ],
  7099. "padding": [
  7100. "padding-top",
  7101. "padding-bottom",
  7102. "padding-left",
  7103. "padding-right"
  7104. ]
  7105. };
  7106. for (prop in mapping) {
  7107. if (mapping.hasOwnProperty(prop)) {
  7108. for (i=0, len=mapping[prop].length; i < len; i++) {
  7109. propertiesToCheck[mapping[prop][i]] = prop;
  7110. }
  7111. }
  7112. }
  7113. function startRule() {
  7114. properties = {};
  7115. }
  7116. function endRule(event) {
  7117. var prop, i, len, total;
  7118. for (prop in mapping) {
  7119. if (mapping.hasOwnProperty(prop)) {
  7120. total=0;
  7121. for (i=0, len=mapping[prop].length; i < len; i++) {
  7122. total += properties[mapping[prop][i]] ? 1 : 0;
  7123. }
  7124. if (total === mapping[prop].length) {
  7125. reporter.report("The properties " + mapping[prop].join(", ") + " can be replaced by " + prop + ".", event.line, event.col, rule);
  7126. }
  7127. }
  7128. }
  7129. }
  7130. parser.addListener("startrule", startRule);
  7131. parser.addListener("startfontface", startRule);
  7132. parser.addListener("property", function(event) {
  7133. var name = event.property.toString().toLowerCase();
  7134. if (propertiesToCheck[name]) {
  7135. properties[name] = 1;
  7136. }
  7137. });
  7138. parser.addListener("endrule", endRule);
  7139. parser.addListener("endfontface", endRule);
  7140. }
  7141. });
  7142. CSSLint.addRule({
  7143. id: "star-property-hack",
  7144. name: "Disallow properties with a star prefix",
  7145. desc: "Checks for the star property hack (targets IE6/7)",
  7146. url: "https://github.com/CSSLint/csslint/wiki/Disallow-star-hack",
  7147. browsers: "All",
  7148. init: function(parser, reporter) {
  7149. "use strict";
  7150. var rule = this;
  7151. parser.addListener("property", function(event) {
  7152. var property = event.property;
  7153. if (property.hack === "*") {
  7154. reporter.report("Property with star prefix found.", event.property.line, event.property.col, rule);
  7155. }
  7156. });
  7157. }
  7158. });
  7159. CSSLint.addRule({
  7160. id: "text-indent",
  7161. name: "Disallow negative text-indent",
  7162. desc: "Checks for text indent less than -99px",
  7163. url: "https://github.com/CSSLint/csslint/wiki/Disallow-negative-text-indent",
  7164. browsers: "All",
  7165. init: function(parser, reporter) {
  7166. "use strict";
  7167. var rule = this,
  7168. textIndent,
  7169. direction;
  7170. function startRule() {
  7171. textIndent = false;
  7172. direction = "inherit";
  7173. }
  7174. function endRule() {
  7175. if (textIndent && direction !== "ltr") {
  7176. reporter.report("Negative text-indent doesn't work well with RTL. If you use text-indent for image replacement explicitly set direction for that item to ltr.", textIndent.line, textIndent.col, rule);
  7177. }
  7178. }
  7179. parser.addListener("startrule", startRule);
  7180. parser.addListener("startfontface", startRule);
  7181. parser.addListener("property", function(event) {
  7182. var name = event.property.toString().toLowerCase(),
  7183. value = event.value;
  7184. if (name === "text-indent" && value.parts[0].value < -99) {
  7185. textIndent = event.property;
  7186. } else if (name === "direction" && value.toString() === "ltr") {
  7187. direction = "ltr";
  7188. }
  7189. });
  7190. parser.addListener("endrule", endRule);
  7191. parser.addListener("endfontface", endRule);
  7192. }
  7193. });
  7194. CSSLint.addRule({
  7195. id: "underscore-property-hack",
  7196. name: "Disallow properties with an underscore prefix",
  7197. desc: "Checks for the underscore property hack (targets IE6)",
  7198. url: "https://github.com/CSSLint/csslint/wiki/Disallow-underscore-hack",
  7199. browsers: "All",
  7200. init: function(parser, reporter) {
  7201. "use strict";
  7202. var rule = this;
  7203. parser.addListener("property", function(event) {
  7204. var property = event.property;
  7205. if (property.hack === "_") {
  7206. reporter.report("Property with underscore prefix found.", event.property.line, event.property.col, rule);
  7207. }
  7208. });
  7209. }
  7210. });
  7211. CSSLint.addRule({
  7212. id: "universal-selector",
  7213. name: "Disallow universal selector",
  7214. desc: "The universal selector (*) is known to be slow.",
  7215. url: "https://github.com/CSSLint/csslint/wiki/Disallow-universal-selector",
  7216. browsers: "All",
  7217. init: function(parser, reporter) {
  7218. "use strict";
  7219. var rule = this;
  7220. parser.addListener("startrule", function(event) {
  7221. var selectors = event.selectors,
  7222. selector,
  7223. part,
  7224. i;
  7225. for (i=0; i < selectors.length; i++) {
  7226. selector = selectors[i];
  7227. part = selector.parts[selector.parts.length-1];
  7228. if (part.elementName === "*") {
  7229. reporter.report(rule.desc, part.line, part.col, rule);
  7230. }
  7231. }
  7232. });
  7233. }
  7234. });
  7235. CSSLint.addRule({
  7236. id: "unqualified-attributes",
  7237. name: "Disallow unqualified attribute selectors",
  7238. desc: "Unqualified attribute selectors are known to be slow.",
  7239. url: "https://github.com/CSSLint/csslint/wiki/Disallow-unqualified-attribute-selectors",
  7240. browsers: "All",
  7241. init: function(parser, reporter) {
  7242. "use strict";
  7243. var rule = this;
  7244. parser.addListener("startrule", function(event) {
  7245. var selectors = event.selectors,
  7246. selectorContainsClassOrId = false,
  7247. selector,
  7248. part,
  7249. modifier,
  7250. i, k;
  7251. for (i=0; i < selectors.length; i++) {
  7252. selector = selectors[i];
  7253. part = selector.parts[selector.parts.length-1];
  7254. if (part.type === parser.SELECTOR_PART_TYPE) {
  7255. for (k=0; k < part.modifiers.length; k++) {
  7256. modifier = part.modifiers[k];
  7257. if (modifier.type === "class" || modifier.type === "id") {
  7258. selectorContainsClassOrId = true;
  7259. break;
  7260. }
  7261. }
  7262. if (!selectorContainsClassOrId) {
  7263. for (k=0; k < part.modifiers.length; k++) {
  7264. modifier = part.modifiers[k];
  7265. if (modifier.type === "attribute" && (!part.elementName || part.elementName === "*")) {
  7266. reporter.report(rule.desc, part.line, part.col, rule);
  7267. }
  7268. }
  7269. }
  7270. }
  7271. }
  7272. });
  7273. }
  7274. });
  7275. CSSLint.addRule({
  7276. id: "vendor-prefix",
  7277. name: "Require standard property with vendor prefix",
  7278. desc: "When using a vendor-prefixed property, make sure to include the standard one.",
  7279. url: "https://github.com/CSSLint/csslint/wiki/Require-standard-property-with-vendor-prefix",
  7280. browsers: "All",
  7281. init: function(parser, reporter) {
  7282. "use strict";
  7283. var rule = this,
  7284. properties,
  7285. num,
  7286. propertiesToCheck = {
  7287. "-webkit-border-radius": "border-radius",
  7288. "-webkit-border-top-left-radius": "border-top-left-radius",
  7289. "-webkit-border-top-right-radius": "border-top-right-radius",
  7290. "-webkit-border-bottom-left-radius": "border-bottom-left-radius",
  7291. "-webkit-border-bottom-right-radius": "border-bottom-right-radius",
  7292. "-o-border-radius": "border-radius",
  7293. "-o-border-top-left-radius": "border-top-left-radius",
  7294. "-o-border-top-right-radius": "border-top-right-radius",
  7295. "-o-border-bottom-left-radius": "border-bottom-left-radius",
  7296. "-o-border-bottom-right-radius": "border-bottom-right-radius",
  7297. "-moz-border-radius": "border-radius",
  7298. "-moz-border-radius-topleft": "border-top-left-radius",
  7299. "-moz-border-radius-topright": "border-top-right-radius",
  7300. "-moz-border-radius-bottomleft": "border-bottom-left-radius",
  7301. "-moz-border-radius-bottomright": "border-bottom-right-radius",
  7302. "-moz-column-count": "column-count",
  7303. "-webkit-column-count": "column-count",
  7304. "-moz-column-gap": "column-gap",
  7305. "-webkit-column-gap": "column-gap",
  7306. "-moz-column-rule": "column-rule",
  7307. "-webkit-column-rule": "column-rule",
  7308. "-moz-column-rule-style": "column-rule-style",
  7309. "-webkit-column-rule-style": "column-rule-style",
  7310. "-moz-column-rule-color": "column-rule-color",
  7311. "-webkit-column-rule-color": "column-rule-color",
  7312. "-moz-column-rule-width": "column-rule-width",
  7313. "-webkit-column-rule-width": "column-rule-width",
  7314. "-moz-column-width": "column-width",
  7315. "-webkit-column-width": "column-width",
  7316. "-webkit-column-span": "column-span",
  7317. "-webkit-columns": "columns",
  7318. "-moz-box-shadow": "box-shadow",
  7319. "-webkit-box-shadow": "box-shadow",
  7320. "-moz-transform": "transform",
  7321. "-webkit-transform": "transform",
  7322. "-o-transform": "transform",
  7323. "-ms-transform": "transform",
  7324. "-moz-transform-origin": "transform-origin",
  7325. "-webkit-transform-origin": "transform-origin",
  7326. "-o-transform-origin": "transform-origin",
  7327. "-ms-transform-origin": "transform-origin",
  7328. "-moz-box-sizing": "box-sizing",
  7329. "-webkit-box-sizing": "box-sizing"
  7330. };
  7331. function startRule() {
  7332. properties = {};
  7333. num = 1;
  7334. }
  7335. function endRule() {
  7336. var prop,
  7337. i,
  7338. len,
  7339. needed,
  7340. actual,
  7341. needsStandard = [];
  7342. for (prop in properties) {
  7343. if (propertiesToCheck[prop]) {
  7344. needsStandard.push({
  7345. actual: prop,
  7346. needed: propertiesToCheck[prop]
  7347. });
  7348. }
  7349. }
  7350. for (i=0, len=needsStandard.length; i < len; i++) {
  7351. needed = needsStandard[i].needed;
  7352. actual = needsStandard[i].actual;
  7353. if (!properties[needed]) {
  7354. reporter.report("Missing standard property '" + needed + "' to go along with '" + actual + "'.", properties[actual][0].name.line, properties[actual][0].name.col, rule);
  7355. } else {
  7356. if (properties[needed][0].pos < properties[actual][0].pos) {
  7357. reporter.report("Standard property '" + needed + "' should come after vendor-prefixed property '" + actual + "'.", properties[actual][0].name.line, properties[actual][0].name.col, rule);
  7358. }
  7359. }
  7360. }
  7361. }
  7362. parser.addListener("startrule", startRule);
  7363. parser.addListener("startfontface", startRule);
  7364. parser.addListener("startpage", startRule);
  7365. parser.addListener("startpagemargin", startRule);
  7366. parser.addListener("startkeyframerule", startRule);
  7367. parser.addListener("startviewport", startRule);
  7368. parser.addListener("property", function(event) {
  7369. var name = event.property.text.toLowerCase();
  7370. if (!properties[name]) {
  7371. properties[name] = [];
  7372. }
  7373. properties[name].push({
  7374. name: event.property,
  7375. value: event.value,
  7376. pos: num++
  7377. });
  7378. });
  7379. parser.addListener("endrule", endRule);
  7380. parser.addListener("endfontface", endRule);
  7381. parser.addListener("endpage", endRule);
  7382. parser.addListener("endpagemargin", endRule);
  7383. parser.addListener("endkeyframerule", endRule);
  7384. parser.addListener("endviewport", endRule);
  7385. }
  7386. });
  7387. CSSLint.addRule({
  7388. id: "zero-units",
  7389. name: "Disallow units for 0 values",
  7390. desc: "You don't need to specify units when a value is 0.",
  7391. url: "https://github.com/CSSLint/csslint/wiki/Disallow-units-for-zero-values",
  7392. browsers: "All",
  7393. init: function(parser, reporter) {
  7394. "use strict";
  7395. var rule = this;
  7396. parser.addListener("property", function(event) {
  7397. var parts = event.value.parts,
  7398. i = 0,
  7399. len = parts.length;
  7400. while (i < len) {
  7401. if ((parts[i].units || parts[i].type === "percentage") && parts[i].value === 0 && parts[i].type !== "time") {
  7402. reporter.report("Values of 0 shouldn't have units specified.", parts[i].line, parts[i].col, rule);
  7403. }
  7404. i++;
  7405. }
  7406. });
  7407. }
  7408. });
  7409. (function() {
  7410. "use strict";
  7411. var xmlEscape = function(str) {
  7412. if (!str || str.constructor !== String) {
  7413. return "";
  7414. }
  7415. return str.replace(/["&><]/g, function(match) {
  7416. switch (match) {
  7417. case "\"":
  7418. return "&quot;";
  7419. case "&":
  7420. return "&amp;";
  7421. case "<":
  7422. return "&lt;";
  7423. case ">":
  7424. return "&gt;";
  7425. }
  7426. });
  7427. };
  7428. CSSLint.addFormatter({
  7429. id: "checkstyle-xml",
  7430. name: "Checkstyle XML format",
  7431. startFormat: function() {
  7432. return "<?xml version=\"1.0\" encoding=\"utf-8\"?><checkstyle>";
  7433. },
  7434. endFormat: function() {
  7435. return "</checkstyle>";
  7436. },
  7437. readError: function(filename, message) {
  7438. return "<file name=\"" + xmlEscape(filename) + "\"><error line=\"0\" column=\"0\" severty=\"error\" message=\"" + xmlEscape(message) + "\"></error></file>";
  7439. },
  7440. formatResults: function(results, filename/*, options*/) {
  7441. var messages = results.messages,
  7442. output = [];
  7443. var generateSource = function(rule) {
  7444. if (!rule || !("name" in rule)) {
  7445. return "";
  7446. }
  7447. return "net.csslint." + rule.name.replace(/\s/g, "");
  7448. };
  7449. if (messages.length > 0) {
  7450. output.push("<file name=\""+filename+"\">");
  7451. CSSLint.Util.forEach(messages, function (message) {
  7452. if (!message.rollup) {
  7453. output.push("<error line=\"" + message.line + "\" column=\"" + message.col + "\" severity=\"" + message.type + "\"" +
  7454. " message=\"" + xmlEscape(message.message) + "\" source=\"" + generateSource(message.rule) +"\"/>");
  7455. }
  7456. });
  7457. output.push("</file>");
  7458. }
  7459. return output.join("");
  7460. }
  7461. });
  7462. }());
  7463. CSSLint.addFormatter({
  7464. id: "compact",
  7465. name: "Compact, 'porcelain' format",
  7466. startFormat: function() {
  7467. "use strict";
  7468. return "";
  7469. },
  7470. endFormat: function() {
  7471. "use strict";
  7472. return "";
  7473. },
  7474. formatResults: function(results, filename, options) {
  7475. "use strict";
  7476. var messages = results.messages,
  7477. output = "";
  7478. options = options || {};
  7479. var capitalize = function(str) {
  7480. return str.charAt(0).toUpperCase() + str.slice(1);
  7481. };
  7482. if (messages.length === 0) {
  7483. return options.quiet ? "" : filename + ": Lint Free!";
  7484. }
  7485. CSSLint.Util.forEach(messages, function(message) {
  7486. if (message.rollup) {
  7487. output += filename + ": " + capitalize(message.type) + " - " + message.message + " (" + message.rule.id + ")\n";
  7488. } else {
  7489. output += filename + ": line " + message.line +
  7490. ", col " + message.col + ", " + capitalize(message.type) + " - " + message.message + " (" + message.rule.id + ")\n";
  7491. }
  7492. });
  7493. return output;
  7494. }
  7495. });
  7496. CSSLint.addFormatter({
  7497. id: "csslint-xml",
  7498. name: "CSSLint XML format",
  7499. startFormat: function() {
  7500. "use strict";
  7501. return "<?xml version=\"1.0\" encoding=\"utf-8\"?><csslint>";
  7502. },
  7503. endFormat: function() {
  7504. "use strict";
  7505. return "</csslint>";
  7506. },
  7507. formatResults: function(results, filename/*, options*/) {
  7508. "use strict";
  7509. var messages = results.messages,
  7510. output = [];
  7511. var escapeSpecialCharacters = function(str) {
  7512. if (!str || str.constructor !== String) {
  7513. return "";
  7514. }
  7515. return str.replace(/"/g, "'").replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
  7516. };
  7517. if (messages.length > 0) {
  7518. output.push("<file name=\""+filename+"\">");
  7519. CSSLint.Util.forEach(messages, function (message) {
  7520. if (message.rollup) {
  7521. output.push("<issue severity=\"" + message.type + "\" reason=\"" + escapeSpecialCharacters(message.message) + "\" evidence=\"" + escapeSpecialCharacters(message.evidence) + "\"/>");
  7522. } else {
  7523. output.push("<issue line=\"" + message.line + "\" char=\"" + message.col + "\" severity=\"" + message.type + "\"" +
  7524. " reason=\"" + escapeSpecialCharacters(message.message) + "\" evidence=\"" + escapeSpecialCharacters(message.evidence) + "\"/>");
  7525. }
  7526. });
  7527. output.push("</file>");
  7528. }
  7529. return output.join("");
  7530. }
  7531. });
  7532. CSSLint.addFormatter({
  7533. id: "json",
  7534. name: "JSON",
  7535. startFormat: function() {
  7536. "use strict";
  7537. this.json = [];
  7538. return "";
  7539. },
  7540. endFormat: function() {
  7541. "use strict";
  7542. var ret = "";
  7543. if (this.json.length > 0) {
  7544. if (this.json.length === 1) {
  7545. ret = JSON.stringify(this.json[0]);
  7546. } else {
  7547. ret = JSON.stringify(this.json);
  7548. }
  7549. }
  7550. return ret;
  7551. },
  7552. formatResults: function(results, filename, options) {
  7553. "use strict";
  7554. if (results.messages.length > 0 || !options.quiet) {
  7555. this.json.push({
  7556. filename: filename,
  7557. messages: results.messages,
  7558. stats: results.stats
  7559. });
  7560. }
  7561. return "";
  7562. }
  7563. });
  7564. CSSLint.addFormatter({
  7565. id: "junit-xml",
  7566. name: "JUNIT XML format",
  7567. startFormat: function() {
  7568. "use strict";
  7569. return "<?xml version=\"1.0\" encoding=\"utf-8\"?><testsuites>";
  7570. },
  7571. endFormat: function() {
  7572. "use strict";
  7573. return "</testsuites>";
  7574. },
  7575. formatResults: function(results, filename/*, options*/) {
  7576. "use strict";
  7577. var messages = results.messages,
  7578. output = [],
  7579. tests = {
  7580. "error": 0,
  7581. "failure": 0
  7582. };
  7583. var generateSource = function(rule) {
  7584. if (!rule || !("name" in rule)) {
  7585. return "";
  7586. }
  7587. return "net.csslint." + rule.name.replace(/\s/g, "");
  7588. };
  7589. var escapeSpecialCharacters = function(str) {
  7590. if (!str || str.constructor !== String) {
  7591. return "";
  7592. }
  7593. return str.replace(/"/g, "'").replace(/</g, "&lt;").replace(/>/g, "&gt;");
  7594. };
  7595. if (messages.length > 0) {
  7596. messages.forEach(function (message) {
  7597. var type = message.type === "warning" ? "error" : message.type;
  7598. if (!message.rollup) {
  7599. output.push("<testcase time=\"0\" name=\"" + generateSource(message.rule) + "\">");
  7600. output.push("<" + type + " message=\"" + escapeSpecialCharacters(message.message) + "\"><![CDATA[" + message.line + ":" + message.col + ":" + escapeSpecialCharacters(message.evidence) + "]]></" + type + ">");
  7601. output.push("</testcase>");
  7602. tests[type] += 1;
  7603. }
  7604. });
  7605. output.unshift("<testsuite time=\"0\" tests=\"" + messages.length + "\" skipped=\"0\" errors=\"" + tests.error + "\" failures=\"" + tests.failure + "\" package=\"net.csslint\" name=\"" + filename + "\">");
  7606. output.push("</testsuite>");
  7607. }
  7608. return output.join("");
  7609. }
  7610. });
  7611. CSSLint.addFormatter({
  7612. id: "lint-xml",
  7613. name: "Lint XML format",
  7614. startFormat: function() {
  7615. "use strict";
  7616. return "<?xml version=\"1.0\" encoding=\"utf-8\"?><lint>";
  7617. },
  7618. endFormat: function() {
  7619. "use strict";
  7620. return "</lint>";
  7621. },
  7622. formatResults: function(results, filename/*, options*/) {
  7623. "use strict";
  7624. var messages = results.messages,
  7625. output = [];
  7626. var escapeSpecialCharacters = function(str) {
  7627. if (!str || str.constructor !== String) {
  7628. return "";
  7629. }
  7630. return str.replace(/"/g, "'").replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
  7631. };
  7632. if (messages.length > 0) {
  7633. output.push("<file name=\""+filename+"\">");
  7634. CSSLint.Util.forEach(messages, function (message) {
  7635. if (message.rollup) {
  7636. output.push("<issue severity=\"" + message.type + "\" reason=\"" + escapeSpecialCharacters(message.message) + "\" evidence=\"" + escapeSpecialCharacters(message.evidence) + "\"/>");
  7637. } else {
  7638. var rule = "";
  7639. if (message.rule && message.rule.id) {
  7640. rule = "rule=\"" + escapeSpecialCharacters(message.rule.id) + "\" ";
  7641. }
  7642. output.push("<issue " + rule + "line=\"" + message.line + "\" char=\"" + message.col + "\" severity=\"" + message.type + "\"" +
  7643. " reason=\"" + escapeSpecialCharacters(message.message) + "\" evidence=\"" + escapeSpecialCharacters(message.evidence) + "\"/>");
  7644. }
  7645. });
  7646. output.push("</file>");
  7647. }
  7648. return output.join("");
  7649. }
  7650. });
  7651. CSSLint.addFormatter({
  7652. id: "text",
  7653. name: "Plain Text",
  7654. startFormat: function() {
  7655. "use strict";
  7656. return "";
  7657. },
  7658. endFormat: function() {
  7659. "use strict";
  7660. return "";
  7661. },
  7662. formatResults: function(results, filename, options) {
  7663. "use strict";
  7664. var messages = results.messages,
  7665. output = "";
  7666. options = options || {};
  7667. if (messages.length === 0) {
  7668. return options.quiet ? "" : "\n\ncsslint: No errors in " + filename + ".";
  7669. }
  7670. output = "\n\ncsslint: There ";
  7671. if (messages.length === 1) {
  7672. output += "is 1 problem";
  7673. } else {
  7674. output += "are " + messages.length + " problems";
  7675. }
  7676. output += " in " + filename + ".";
  7677. var pos = filename.lastIndexOf("/"),
  7678. shortFilename = filename;
  7679. if (pos === -1) {
  7680. pos = filename.lastIndexOf("\\");
  7681. }
  7682. if (pos > -1) {
  7683. shortFilename = filename.substring(pos+1);
  7684. }
  7685. CSSLint.Util.forEach(messages, function (message, i) {
  7686. output = output + "\n\n" + shortFilename;
  7687. if (message.rollup) {
  7688. output += "\n" + (i+1) + ": " + message.type;
  7689. output += "\n" + message.message;
  7690. } else {
  7691. output += "\n" + (i+1) + ": " + message.type + " at line " + message.line + ", col " + message.col;
  7692. output += "\n" + message.message;
  7693. output += "\n" + message.evidence;
  7694. }
  7695. });
  7696. return output;
  7697. }
  7698. });
  7699. return CSSLint;
  7700. })();
  7701. module.exports.CSSLint = CSSLint;
  7702. });
  7703. define("ace/mode/css_worker",[], function(require, exports, module) {
  7704. "use strict";
  7705. var oop = require("../lib/oop");
  7706. var lang = require("../lib/lang");
  7707. var Mirror = require("../worker/mirror").Mirror;
  7708. var CSSLint = require("./css/csslint").CSSLint;
  7709. var Worker = exports.Worker = function(sender) {
  7710. Mirror.call(this, sender);
  7711. this.setTimeout(400);
  7712. this.ruleset = null;
  7713. this.setDisabledRules("ids|order-alphabetical");
  7714. this.setInfoRules(
  7715. "adjoining-classes|zero-units|gradients|box-model|" +
  7716. "import|outline-none|vendor-prefix"
  7717. );
  7718. };
  7719. oop.inherits(Worker, Mirror);
  7720. (function() {
  7721. this.setInfoRules = function(ruleNames) {
  7722. if (typeof ruleNames == "string")
  7723. ruleNames = ruleNames.split("|");
  7724. this.infoRules = lang.arrayToMap(ruleNames);
  7725. this.doc.getValue() && this.deferredUpdate.schedule(100);
  7726. };
  7727. this.setDisabledRules = function(ruleNames) {
  7728. if (!ruleNames) {
  7729. this.ruleset = null;
  7730. } else {
  7731. if (typeof ruleNames == "string")
  7732. ruleNames = ruleNames.split("|");
  7733. var all = {};
  7734. CSSLint.getRules().forEach(function(x){
  7735. all[x.id] = true;
  7736. });
  7737. ruleNames.forEach(function(x) {
  7738. delete all[x];
  7739. });
  7740. this.ruleset = all;
  7741. }
  7742. this.doc.getValue() && this.deferredUpdate.schedule(100);
  7743. };
  7744. this.onUpdate = function() {
  7745. var value = this.doc.getValue();
  7746. if (!value)
  7747. return this.sender.emit("annotate", []);
  7748. var infoRules = this.infoRules;
  7749. var result = CSSLint.verify(value, this.ruleset);
  7750. this.sender.emit("annotate", result.messages.map(function(msg) {
  7751. return {
  7752. row: msg.line - 1,
  7753. column: msg.col - 1,
  7754. text: msg.message,
  7755. type: infoRules[msg.rule.id] ? "info" : msg.type,
  7756. rule: msg.rule.name
  7757. };
  7758. }));
  7759. };
  7760. }).call(Worker.prototype);
  7761. });