Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(462)

Side by Side Diff: third_party/WebKit/Source/core/css/resolver/StyleBuilderCustom.cpp

Issue 2382653006: Split CSSPrimitiveValue into CSSPrimitiveValue and CSSIdentifierValue (Closed)
Patch Set: Make check-webkit-style happy Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 3 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
4 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) 4 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com)
5 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) 5 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com)
6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved. 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved.
7 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> 7 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
8 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> 8 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org>
9 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 9 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
10 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. 10 * Copyright (c) 2011, Code Aurora Forum. All rights reserved.
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 if (state.applyPropertyToRegularStyle()) 173 if (state.applyPropertyToRegularStyle())
174 state.style()->setColor(color); 174 state.style()->setColor(color);
175 if (state.applyPropertyToVisitedLinkStyle()) 175 if (state.applyPropertyToVisitedLinkStyle())
176 state.style()->setVisitedLinkColor(color); 176 state.style()->setVisitedLinkColor(color);
177 } 177 }
178 178
179 void StyleBuilderFunctions::applyValueCSSPropertyColor( 179 void StyleBuilderFunctions::applyValueCSSPropertyColor(
180 StyleResolverState& state, 180 StyleResolverState& state,
181 const CSSValue& value) { 181 const CSSValue& value) {
182 // As per the spec, 'color: currentColor' is treated as 'color: inherit' 182 // As per the spec, 'color: currentColor' is treated as 'color: inherit'
183 if (value.isPrimitiveValue() && 183 if (value.isIdentifierValue() &&
184 toCSSPrimitiveValue(value).getValueID() == CSSValueCurrentcolor) { 184 toCSSIdentifierValue(value).getValueID() == CSSValueCurrentcolor) {
185 applyInheritCSSPropertyColor(state); 185 applyInheritCSSPropertyColor(state);
186 return; 186 return;
187 } 187 }
188 188
189 if (state.applyPropertyToRegularStyle()) 189 if (state.applyPropertyToRegularStyle())
190 state.style()->setColor(StyleBuilderConverter::convertColor(state, value)); 190 state.style()->setColor(StyleBuilderConverter::convertColor(state, value));
191 if (state.applyPropertyToVisitedLinkStyle()) 191 if (state.applyPropertyToVisitedLinkStyle())
192 state.style()->setVisitedLinkColor( 192 state.style()->setVisitedLinkColor(
193 StyleBuilderConverter::convertColor(state, value, true)); 193 StyleBuilderConverter::convertColor(state, value, true));
194 } 194 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 cursorElement->addClient(svgElement); 246 cursorElement->addClient(svgElement);
247 247
248 // Elements with SVG cursors are not allowed to share style. 248 // Elements with SVG cursors are not allowed to share style.
249 state.style()->setUnique(); 249 state.style()->setUnique();
250 } 250 }
251 251
252 state.style()->addCursor(state.styleImage(CSSPropertyCursor, image), 252 state.style()->addCursor(state.styleImage(CSSPropertyCursor, image),
253 hotSpotSpecified, hotSpot); 253 hotSpotSpecified, hotSpot);
254 } else { 254 } else {
255 state.style()->setCursor( 255 state.style()->setCursor(
256 toCSSPrimitiveValue(item).convertTo<ECursor>()); 256 toCSSIdentifierValue(item).convertTo<ECursor>());
257 } 257 }
258 } 258 }
259 } else { 259 } else {
260 state.style()->setCursor(toCSSPrimitiveValue(value).convertTo<ECursor>()); 260 state.style()->setCursor(toCSSIdentifierValue(value).convertTo<ECursor>());
261 } 261 }
262 } 262 }
263 263
264 void StyleBuilderFunctions::applyValueCSSPropertyDirection( 264 void StyleBuilderFunctions::applyValueCSSPropertyDirection(
265 StyleResolverState& state, 265 StyleResolverState& state,
266 const CSSValue& value) { 266 const CSSValue& value) {
267 state.style()->setDirection( 267 state.style()->setDirection(
268 toCSSPrimitiveValue(value).convertTo<TextDirection>()); 268 toCSSIdentifierValue(value).convertTo<TextDirection>());
269 } 269 }
270 270
271 void StyleBuilderFunctions::applyInitialCSSPropertyGridTemplateAreas( 271 void StyleBuilderFunctions::applyInitialCSSPropertyGridTemplateAreas(
272 StyleResolverState& state) { 272 StyleResolverState& state) {
273 state.style()->setNamedGridArea(ComputedStyle::initialNamedGridArea()); 273 state.style()->setNamedGridArea(ComputedStyle::initialNamedGridArea());
274 state.style()->setNamedGridAreaRowCount( 274 state.style()->setNamedGridAreaRowCount(
275 ComputedStyle::initialNamedGridAreaCount()); 275 ComputedStyle::initialNamedGridAreaCount());
276 state.style()->setNamedGridAreaColumnCount( 276 state.style()->setNamedGridAreaColumnCount(
277 ComputedStyle::initialNamedGridAreaCount()); 277 ComputedStyle::initialNamedGridAreaCount());
278 } 278 }
279 279
280 void StyleBuilderFunctions::applyInheritCSSPropertyGridTemplateAreas( 280 void StyleBuilderFunctions::applyInheritCSSPropertyGridTemplateAreas(
281 StyleResolverState& state) { 281 StyleResolverState& state) {
282 state.style()->setNamedGridArea(state.parentStyle()->namedGridArea()); 282 state.style()->setNamedGridArea(state.parentStyle()->namedGridArea());
283 state.style()->setNamedGridAreaRowCount( 283 state.style()->setNamedGridAreaRowCount(
284 state.parentStyle()->namedGridAreaRowCount()); 284 state.parentStyle()->namedGridAreaRowCount());
285 state.style()->setNamedGridAreaColumnCount( 285 state.style()->setNamedGridAreaColumnCount(
286 state.parentStyle()->namedGridAreaColumnCount()); 286 state.parentStyle()->namedGridAreaColumnCount());
287 } 287 }
288 288
289 void StyleBuilderFunctions::applyValueCSSPropertyGridTemplateAreas( 289 void StyleBuilderFunctions::applyValueCSSPropertyGridTemplateAreas(
290 StyleResolverState& state, 290 StyleResolverState& state,
291 const CSSValue& value) { 291 const CSSValue& value) {
292 if (value.isPrimitiveValue()) { 292 if (value.isIdentifierValue()) {
293 // FIXME: Shouldn't we clear the grid-area values 293 // FIXME: Shouldn't we clear the grid-area values
294 DCHECK_EQ(toCSSPrimitiveValue(value).getValueID(), CSSValueNone); 294 DCHECK_EQ(toCSSIdentifierValue(value).getValueID(), CSSValueNone);
295 return; 295 return;
296 } 296 }
297 297
298 const CSSGridTemplateAreasValue& gridTemplateAreasValue = 298 const CSSGridTemplateAreasValue& gridTemplateAreasValue =
299 toCSSGridTemplateAreasValue(value); 299 toCSSGridTemplateAreasValue(value);
300 const NamedGridAreaMap& newNamedGridAreas = 300 const NamedGridAreaMap& newNamedGridAreas =
301 gridTemplateAreasValue.gridAreaMap(); 301 gridTemplateAreasValue.gridAreaMap();
302 302
303 NamedGridLinesMap namedGridColumnLines; 303 NamedGridLinesMap namedGridColumnLines;
304 NamedGridLinesMap namedGridRowLines; 304 NamedGridLinesMap namedGridRowLines;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 void StyleBuilderFunctions::applyInheritCSSPropertyOutlineStyle( 336 void StyleBuilderFunctions::applyInheritCSSPropertyOutlineStyle(
337 StyleResolverState& state) { 337 StyleResolverState& state) {
338 state.style()->setOutlineStyleIsAuto( 338 state.style()->setOutlineStyleIsAuto(
339 state.parentStyle()->outlineStyleIsAuto()); 339 state.parentStyle()->outlineStyleIsAuto());
340 state.style()->setOutlineStyle(state.parentStyle()->outlineStyle()); 340 state.style()->setOutlineStyle(state.parentStyle()->outlineStyle());
341 } 341 }
342 342
343 void StyleBuilderFunctions::applyValueCSSPropertyOutlineStyle( 343 void StyleBuilderFunctions::applyValueCSSPropertyOutlineStyle(
344 StyleResolverState& state, 344 StyleResolverState& state,
345 const CSSValue& value) { 345 const CSSValue& value) {
346 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); 346 const CSSIdentifierValue& identifierValue = toCSSIdentifierValue(value);
347 state.style()->setOutlineStyleIsAuto( 347 state.style()->setOutlineStyleIsAuto(
348 primitiveValue.convertTo<OutlineIsAuto>()); 348 identifierValue.convertTo<OutlineIsAuto>());
349 state.style()->setOutlineStyle(primitiveValue.convertTo<EBorderStyle>()); 349 state.style()->setOutlineStyle(identifierValue.convertTo<EBorderStyle>());
350 } 350 }
351 351
352 void StyleBuilderFunctions::applyValueCSSPropertyResize( 352 void StyleBuilderFunctions::applyValueCSSPropertyResize(
353 StyleResolverState& state, 353 StyleResolverState& state,
354 const CSSValue& value) { 354 const CSSValue& value) {
355 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); 355 const CSSIdentifierValue& identifierValue = toCSSIdentifierValue(value);
356 356
357 EResize r = RESIZE_NONE; 357 EResize r = RESIZE_NONE;
358 if (primitiveValue.getValueID() == CSSValueAuto) { 358 if (identifierValue.getValueID() == CSSValueAuto) {
359 if (Settings* settings = state.document().settings()) 359 if (Settings* settings = state.document().settings())
360 r = settings->textAreasAreResizable() ? RESIZE_BOTH : RESIZE_NONE; 360 r = settings->textAreasAreResizable() ? RESIZE_BOTH : RESIZE_NONE;
361 } else { 361 } else {
362 r = primitiveValue.convertTo<EResize>(); 362 r = identifierValue.convertTo<EResize>();
363 } 363 }
364 state.style()->setResize(r); 364 state.style()->setResize(r);
365 } 365 }
366 366
367 static float mmToPx(float mm) { 367 static float mmToPx(float mm) {
368 return mm * cssPixelsPerMillimeter; 368 return mm * cssPixelsPerMillimeter;
369 } 369 }
370 static float inchToPx(float inch) { 370 static float inchToPx(float inch) {
371 return inch * cssPixelsPerInch; 371 return inch * cssPixelsPerInch;
372 } 372 }
373 static FloatSize getPageSizeFromName(const CSSPrimitiveValue& pageSizeName) { 373 static FloatSize getPageSizeFromName(const CSSIdentifierValue& pageSizeName) {
374 switch (pageSizeName.getValueID()) { 374 switch (pageSizeName.getValueID()) {
375 case CSSValueA5: 375 case CSSValueA5:
376 return FloatSize(mmToPx(148), mmToPx(210)); 376 return FloatSize(mmToPx(148), mmToPx(210));
377 case CSSValueA4: 377 case CSSValueA4:
378 return FloatSize(mmToPx(210), mmToPx(297)); 378 return FloatSize(mmToPx(210), mmToPx(297));
379 case CSSValueA3: 379 case CSSValueA3:
380 return FloatSize(mmToPx(297), mmToPx(420)); 380 return FloatSize(mmToPx(297), mmToPx(420));
381 case CSSValueB5: 381 case CSSValueB5:
382 return FloatSize(mmToPx(176), mmToPx(250)); 382 return FloatSize(mmToPx(176), mmToPx(250));
383 case CSSValueB4: 383 case CSSValueB4:
(...skipping 13 matching lines...) Expand all
397 void StyleBuilderFunctions::applyInitialCSSPropertySize(StyleResolverState&) {} 397 void StyleBuilderFunctions::applyInitialCSSPropertySize(StyleResolverState&) {}
398 void StyleBuilderFunctions::applyInheritCSSPropertySize(StyleResolverState&) {} 398 void StyleBuilderFunctions::applyInheritCSSPropertySize(StyleResolverState&) {}
399 void StyleBuilderFunctions::applyValueCSSPropertySize(StyleResolverState& state, 399 void StyleBuilderFunctions::applyValueCSSPropertySize(StyleResolverState& state,
400 const CSSValue& value) { 400 const CSSValue& value) {
401 state.style()->resetPageSizeType(); 401 state.style()->resetPageSizeType();
402 FloatSize size; 402 FloatSize size;
403 PageSizeType pageSizeType = PAGE_SIZE_AUTO; 403 PageSizeType pageSizeType = PAGE_SIZE_AUTO;
404 const CSSValueList& list = toCSSValueList(value); 404 const CSSValueList& list = toCSSValueList(value);
405 if (list.length() == 2) { 405 if (list.length() == 2) {
406 // <length>{2} | <page-size> <orientation> 406 // <length>{2} | <page-size> <orientation>
407 const CSSPrimitiveValue& first = toCSSPrimitiveValue(list.item(0)); 407 const CSSValue& first = list.item(0);
408 const CSSPrimitiveValue& second = toCSSPrimitiveValue(list.item(1)); 408 const CSSValue& second = list.item(1);
409 if (first.isLength()) { 409 if (first.isPrimitiveValue() && toCSSPrimitiveValue(first).isLength()) {
410 // <length>{2} 410 // <length>{2}
411 size = FloatSize( 411 size = FloatSize(
412 first.computeLength<float>( 412 toCSSPrimitiveValue(first).computeLength<float>(
413 state.cssToLengthConversionData().copyWithAdjustedZoom(1.0)), 413 state.cssToLengthConversionData().copyWithAdjustedZoom(1.0)),
414 second.computeLength<float>( 414 toCSSPrimitiveValue(second).computeLength<float>(
415 state.cssToLengthConversionData().copyWithAdjustedZoom(1.0))); 415 state.cssToLengthConversionData().copyWithAdjustedZoom(1.0)));
416 } else { 416 } else {
417 // <page-size> <orientation> 417 // <page-size> <orientation>
418 size = getPageSizeFromName(first); 418 size = getPageSizeFromName(toCSSIdentifierValue(first));
419 419
420 DCHECK(second.getValueID() == CSSValueLandscape || 420 DCHECK(toCSSIdentifierValue(second).getValueID() == CSSValueLandscape ||
421 second.getValueID() == CSSValuePortrait); 421 toCSSIdentifierValue(second).getValueID() == CSSValuePortrait);
422 if (second.getValueID() == CSSValueLandscape) 422 if (toCSSIdentifierValue(second).getValueID() == CSSValueLandscape)
423 size = size.transposedSize(); 423 size = size.transposedSize();
424 } 424 }
425 pageSizeType = PAGE_SIZE_RESOLVED; 425 pageSizeType = PAGE_SIZE_RESOLVED;
426 } else { 426 } else {
427 DCHECK_EQ(list.length(), 1U); 427 DCHECK_EQ(list.length(), 1U);
428 // <length> | auto | <page-size> | [ portrait | landscape] 428 // <length> | auto | <page-size> | [ portrait | landscape]
429 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(list.item(0)); 429 const CSSValue& first = list.item(0);
430 if (primitiveValue.isLength()) { 430 if (first.isPrimitiveValue() && toCSSPrimitiveValue(first).isLength()) {
431 // <length> 431 // <length>
432 pageSizeType = PAGE_SIZE_RESOLVED; 432 pageSizeType = PAGE_SIZE_RESOLVED;
433 float width = primitiveValue.computeLength<float>( 433 float width = toCSSPrimitiveValue(first).computeLength<float>(
434 state.cssToLengthConversionData().copyWithAdjustedZoom(1.0)); 434 state.cssToLengthConversionData().copyWithAdjustedZoom(1.0));
435 size = FloatSize(width, width); 435 size = FloatSize(width, width);
436 } else { 436 } else {
437 switch (primitiveValue.getValueID()) { 437 const CSSIdentifierValue& ident = toCSSIdentifierValue(first);
438 switch (ident.getValueID()) {
438 case CSSValueAuto: 439 case CSSValueAuto:
439 pageSizeType = PAGE_SIZE_AUTO; 440 pageSizeType = PAGE_SIZE_AUTO;
440 break; 441 break;
441 case CSSValuePortrait: 442 case CSSValuePortrait:
442 pageSizeType = PAGE_SIZE_AUTO_PORTRAIT; 443 pageSizeType = PAGE_SIZE_AUTO_PORTRAIT;
443 break; 444 break;
444 case CSSValueLandscape: 445 case CSSValueLandscape:
445 pageSizeType = PAGE_SIZE_AUTO_LANDSCAPE; 446 pageSizeType = PAGE_SIZE_AUTO_LANDSCAPE;
446 break; 447 break;
447 default: 448 default:
448 // <page-size> 449 // <page-size>
449 pageSizeType = PAGE_SIZE_RESOLVED; 450 pageSizeType = PAGE_SIZE_RESOLVED;
450 size = getPageSizeFromName(primitiveValue); 451 size = getPageSizeFromName(ident);
451 } 452 }
452 } 453 }
453 } 454 }
454 state.style()->setPageSizeType(pageSizeType); 455 state.style()->setPageSizeType(pageSizeType);
455 state.style()->setPageSize(size); 456 state.style()->setPageSize(size);
456 } 457 }
457 458
458 void StyleBuilderFunctions::applyInitialCSSPropertySnapHeight( 459 void StyleBuilderFunctions::applyInitialCSSPropertySnapHeight(
459 StyleResolverState& state) { 460 StyleResolverState& state) {
460 state.style()->setSnapHeightUnit(0); 461 state.style()->setSnapHeightUnit(0);
(...skipping 26 matching lines...) Expand all
487 const CSSPrimitiveValue& second = toCSSPrimitiveValue(list.item(1)); 488 const CSSPrimitiveValue& second = toCSSPrimitiveValue(list.item(1));
488 DCHECK(second.isNumber()); 489 DCHECK(second.isNumber());
489 int position = second.getIntValue(); 490 int position = second.getIntValue();
490 DCHECK(position > 0 && position <= 100); 491 DCHECK(position > 0 && position <= 100);
491 state.style()->setSnapHeightPosition(position); 492 state.style()->setSnapHeightPosition(position);
492 } 493 }
493 494
494 void StyleBuilderFunctions::applyValueCSSPropertyTextAlign( 495 void StyleBuilderFunctions::applyValueCSSPropertyTextAlign(
495 StyleResolverState& state, 496 StyleResolverState& state,
496 const CSSValue& value) { 497 const CSSValue& value) {
497 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); 498 if (value.isIdentifierValue() &&
498 if (primitiveValue.isValueID() && 499 toCSSIdentifierValue(value).getValueID() != CSSValueWebkitMatchParent) {
499 primitiveValue.getValueID() != CSSValueWebkitMatchParent) {
500 // Special case for th elements - UA stylesheet text-align does not apply if parent's computed value for text-align is not its initial value 500 // Special case for th elements - UA stylesheet text-align does not apply if parent's computed value for text-align is not its initial value
501 // https://html.spec.whatwg.org/multipage/rendering.html#tables-2 501 // https://html.spec.whatwg.org/multipage/rendering.html#tables-2
502 if (primitiveValue.getValueID() == CSSValueInternalCenter && 502 const CSSIdentifierValue& identValue = toCSSIdentifierValue(value);
503 if (identValue.getValueID() == CSSValueInternalCenter &&
503 state.parentStyle()->textAlign() != ComputedStyle::initialTextAlign()) 504 state.parentStyle()->textAlign() != ComputedStyle::initialTextAlign())
504 state.style()->setTextAlign(state.parentStyle()->textAlign()); 505 state.style()->setTextAlign(state.parentStyle()->textAlign());
505 else 506 else
506 state.style()->setTextAlign(primitiveValue.convertTo<ETextAlign>()); 507 state.style()->setTextAlign(identValue.convertTo<ETextAlign>());
507 } else if (state.parentStyle()->textAlign() == TASTART) 508 } else if (state.parentStyle()->textAlign() == TASTART)
508 state.style()->setTextAlign( 509 state.style()->setTextAlign(
509 state.parentStyle()->isLeftToRightDirection() ? LEFT : RIGHT); 510 state.parentStyle()->isLeftToRightDirection() ? LEFT : RIGHT);
510 else if (state.parentStyle()->textAlign() == TAEND) 511 else if (state.parentStyle()->textAlign() == TAEND)
511 state.style()->setTextAlign( 512 state.style()->setTextAlign(
512 state.parentStyle()->isLeftToRightDirection() ? RIGHT : LEFT); 513 state.parentStyle()->isLeftToRightDirection() ? RIGHT : LEFT);
513 else 514 else
514 state.style()->setTextAlign(state.parentStyle()->textAlign()); 515 state.style()->setTextAlign(state.parentStyle()->textAlign());
515 } 516 }
516 517
(...skipping 12 matching lines...) Expand all
529 } 530 }
530 531
531 void StyleBuilderFunctions::applyValueCSSPropertyTextIndent( 532 void StyleBuilderFunctions::applyValueCSSPropertyTextIndent(
532 StyleResolverState& state, 533 StyleResolverState& state,
533 const CSSValue& value) { 534 const CSSValue& value) {
534 Length lengthOrPercentageValue; 535 Length lengthOrPercentageValue;
535 TextIndentLine textIndentLineValue = ComputedStyle::initialTextIndentLine(); 536 TextIndentLine textIndentLineValue = ComputedStyle::initialTextIndentLine();
536 TextIndentType textIndentTypeValue = ComputedStyle::initialTextIndentType(); 537 TextIndentType textIndentTypeValue = ComputedStyle::initialTextIndentType();
537 538
538 for (auto& listValue : toCSSValueList(value)) { 539 for (auto& listValue : toCSSValueList(value)) {
539 const CSSPrimitiveValue* primitiveValue = 540 if (listValue->isPrimitiveValue()) {
540 toCSSPrimitiveValue(listValue.get());
541 if (!primitiveValue->getValueID())
542 lengthOrPercentageValue = 541 lengthOrPercentageValue =
543 primitiveValue->convertToLength(state.cssToLengthConversionData()); 542 toCSSPrimitiveValue(*listValue)
544 else if (primitiveValue->getValueID() == CSSValueEachLine) 543 .convertToLength(state.cssToLengthConversionData());
544 } else if (toCSSIdentifierValue(*listValue).getValueID() ==
545 CSSValueEachLine) {
545 textIndentLineValue = TextIndentEachLine; 546 textIndentLineValue = TextIndentEachLine;
546 else if (primitiveValue->getValueID() == CSSValueHanging) 547 } else if (toCSSIdentifierValue(*listValue).getValueID() ==
548 CSSValueHanging) {
547 textIndentTypeValue = TextIndentHanging; 549 textIndentTypeValue = TextIndentHanging;
548 else 550 } else {
549 NOTREACHED(); 551 NOTREACHED();
552 }
550 } 553 }
551 554
552 state.style()->setTextIndent(lengthOrPercentageValue); 555 state.style()->setTextIndent(lengthOrPercentageValue);
553 state.style()->setTextIndentLine(textIndentLineValue); 556 state.style()->setTextIndentLine(textIndentLineValue);
554 state.style()->setTextIndentType(textIndentTypeValue); 557 state.style()->setTextIndentType(textIndentTypeValue);
555 } 558 }
556 559
557 void StyleBuilderFunctions::applyValueCSSPropertyTransform( 560 void StyleBuilderFunctions::applyValueCSSPropertyTransform(
558 StyleResolverState& state, 561 StyleResolverState& state,
559 const CSSValue& value) { 562 const CSSValue& value) {
560 // FIXME: We should just make this a converter 563 // FIXME: We should just make this a converter
561 TransformOperations operations; 564 TransformOperations operations;
562 TransformBuilder::createTransformOperations( 565 TransformBuilder::createTransformOperations(
563 value, state.cssToLengthConversionData(), operations); 566 value, state.cssToLengthConversionData(), operations);
564 state.style()->setTransform(operations); 567 state.style()->setTransform(operations);
565 } 568 }
566 569
567 void StyleBuilderFunctions::applyInheritCSSPropertyVerticalAlign( 570 void StyleBuilderFunctions::applyInheritCSSPropertyVerticalAlign(
568 StyleResolverState& state) { 571 StyleResolverState& state) {
569 EVerticalAlign verticalAlign = state.parentStyle()->verticalAlign(); 572 EVerticalAlign verticalAlign = state.parentStyle()->verticalAlign();
570 state.style()->setVerticalAlign(verticalAlign); 573 state.style()->setVerticalAlign(verticalAlign);
571 if (verticalAlign == VerticalAlignLength) 574 if (verticalAlign == VerticalAlignLength)
572 state.style()->setVerticalAlignLength( 575 state.style()->setVerticalAlignLength(
573 state.parentStyle()->getVerticalAlignLength()); 576 state.parentStyle()->getVerticalAlignLength());
574 } 577 }
575 578
576 void StyleBuilderFunctions::applyValueCSSPropertyVerticalAlign( 579 void StyleBuilderFunctions::applyValueCSSPropertyVerticalAlign(
577 StyleResolverState& state, 580 StyleResolverState& state,
578 const CSSValue& value) { 581 const CSSValue& value) {
579 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); 582 if (value.isIdentifierValue()) {
580 583 state.style()->setVerticalAlign(
581 if (primitiveValue.getValueID()) 584 toCSSIdentifierValue(value).convertTo<EVerticalAlign>());
582 state.style()->setVerticalAlign(primitiveValue.convertTo<EVerticalAlign>()); 585 } else {
583 else
584 state.style()->setVerticalAlignLength( 586 state.style()->setVerticalAlignLength(
585 primitiveValue.convertToLength(state.cssToLengthConversionData())); 587 toCSSPrimitiveValue(value).convertToLength(
588 state.cssToLengthConversionData()));
589 }
586 } 590 }
587 591
588 static void resetEffectiveZoom(StyleResolverState& state) { 592 static void resetEffectiveZoom(StyleResolverState& state) {
589 // Reset the zoom in effect. This allows the setZoom method to accurately comp ute a new zoom in effect. 593 // Reset the zoom in effect. This allows the setZoom method to accurately comp ute a new zoom in effect.
590 state.setEffectiveZoom(state.parentStyle() 594 state.setEffectiveZoom(state.parentStyle()
591 ? state.parentStyle()->effectiveZoom() 595 ? state.parentStyle()->effectiveZoom()
592 : ComputedStyle::initialZoom()); 596 : ComputedStyle::initialZoom());
593 } 597 }
594 598
595 void StyleBuilderFunctions::applyInitialCSSPropertyZoom( 599 void StyleBuilderFunctions::applyInitialCSSPropertyZoom(
596 StyleResolverState& state) { 600 StyleResolverState& state) {
597 resetEffectiveZoom(state); 601 resetEffectiveZoom(state);
598 state.setZoom(ComputedStyle::initialZoom()); 602 state.setZoom(ComputedStyle::initialZoom());
599 } 603 }
600 604
601 void StyleBuilderFunctions::applyInheritCSSPropertyZoom( 605 void StyleBuilderFunctions::applyInheritCSSPropertyZoom(
602 StyleResolverState& state) { 606 StyleResolverState& state) {
603 resetEffectiveZoom(state); 607 resetEffectiveZoom(state);
604 state.setZoom(state.parentStyle()->zoom()); 608 state.setZoom(state.parentStyle()->zoom());
605 } 609 }
606 610
607 void StyleBuilderFunctions::applyValueCSSPropertyZoom(StyleResolverState& state, 611 void StyleBuilderFunctions::applyValueCSSPropertyZoom(StyleResolverState& state,
608 const CSSValue& value) { 612 const CSSValue& value) {
609 SECURITY_DCHECK(value.isPrimitiveValue()); 613 SECURITY_DCHECK(value.isPrimitiveValue() || value.isIdentifierValue());
610 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value);
611 614
612 if (primitiveValue.getValueID() == CSSValueNormal) { 615 if (value.isIdentifierValue()) {
613 resetEffectiveZoom(state); 616 const CSSIdentifierValue& identifierValue = toCSSIdentifierValue(value);
614 state.setZoom(ComputedStyle::initialZoom()); 617 if (identifierValue.getValueID() == CSSValueNormal) {
615 } else if (primitiveValue.getValueID() == CSSValueReset) { 618 resetEffectiveZoom(state);
616 state.setEffectiveZoom(ComputedStyle::initialZoom()); 619 state.setZoom(ComputedStyle::initialZoom());
617 state.setZoom(ComputedStyle::initialZoom()); 620 } else if (identifierValue.getValueID() == CSSValueReset) {
618 } else if (primitiveValue.getValueID() == CSSValueDocument) { 621 state.setEffectiveZoom(ComputedStyle::initialZoom());
619 float docZoom = state.rootElementStyle() ? state.rootElementStyle()->zoom() 622 state.setZoom(ComputedStyle::initialZoom());
620 : ComputedStyle::initialZoom(); 623 } else if (identifierValue.getValueID() == CSSValueDocument) {
621 state.setEffectiveZoom(docZoom); 624 float docZoom = state.rootElementStyle()
622 state.setZoom(docZoom); 625 ? state.rootElementStyle()->zoom()
623 } else if (primitiveValue.isPercentage()) { 626 : ComputedStyle::initialZoom();
624 resetEffectiveZoom(state); 627 state.setEffectiveZoom(docZoom);
625 if (float percent = primitiveValue.getFloatValue()) 628 state.setZoom(docZoom);
626 state.setZoom(percent / 100.0f); 629 }
627 } else if (primitiveValue.isNumber()) { 630 } else if (value.isPrimitiveValue()) {
628 resetEffectiveZoom(state); 631 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value);
629 if (float number = primitiveValue.getFloatValue()) 632 if (primitiveValue.isPercentage()) {
630 state.setZoom(number); 633 resetEffectiveZoom(state);
634 if (float percent = primitiveValue.getFloatValue())
635 state.setZoom(percent / 100.0f);
636 } else if (primitiveValue.isNumber()) {
637 resetEffectiveZoom(state);
638 if (float number = primitiveValue.getFloatValue())
639 state.setZoom(number);
640 }
631 } 641 }
632 } 642 }
633 643
634 void StyleBuilderFunctions::applyValueCSSPropertyWebkitBorderImage( 644 void StyleBuilderFunctions::applyValueCSSPropertyWebkitBorderImage(
635 StyleResolverState& state, 645 StyleResolverState& state,
636 const CSSValue& value) { 646 const CSSValue& value) {
637 NinePieceImage image; 647 NinePieceImage image;
638 CSSToStyleMap::mapNinePieceImage(state, CSSPropertyWebkitBorderImage, value, 648 CSSToStyleMap::mapNinePieceImage(state, CSSPropertyWebkitBorderImage, value,
639 image); 649 image);
640 state.style()->setBorderImage(image); 650 state.style()->setBorderImage(image);
(...skipping 17 matching lines...) Expand all
658 state.parentStyle()->textEmphasisCustomMark()); 668 state.parentStyle()->textEmphasisCustomMark());
659 } 669 }
660 670
661 void StyleBuilderFunctions::applyValueCSSPropertyWebkitTextEmphasisStyle( 671 void StyleBuilderFunctions::applyValueCSSPropertyWebkitTextEmphasisStyle(
662 StyleResolverState& state, 672 StyleResolverState& state,
663 const CSSValue& value) { 673 const CSSValue& value) {
664 if (value.isValueList()) { 674 if (value.isValueList()) {
665 const CSSValueList& list = toCSSValueList(value); 675 const CSSValueList& list = toCSSValueList(value);
666 DCHECK_EQ(list.length(), 2U); 676 DCHECK_EQ(list.length(), 2U);
667 for (unsigned i = 0; i < 2; ++i) { 677 for (unsigned i = 0; i < 2; ++i) {
668 const CSSPrimitiveValue& value = toCSSPrimitiveValue(list.item(i)); 678 const CSSIdentifierValue& value = toCSSIdentifierValue(list.item(i));
669 if (value.getValueID() == CSSValueFilled || 679 if (value.getValueID() == CSSValueFilled ||
670 value.getValueID() == CSSValueOpen) 680 value.getValueID() == CSSValueOpen)
671 state.style()->setTextEmphasisFill(value.convertTo<TextEmphasisFill>()); 681 state.style()->setTextEmphasisFill(value.convertTo<TextEmphasisFill>());
672 else 682 else
673 state.style()->setTextEmphasisMark(value.convertTo<TextEmphasisMark>()); 683 state.style()->setTextEmphasisMark(value.convertTo<TextEmphasisMark>());
674 } 684 }
675 state.style()->setTextEmphasisCustomMark(nullAtom); 685 state.style()->setTextEmphasisCustomMark(nullAtom);
676 return; 686 return;
677 } 687 }
678 688
679 if (value.isStringValue()) { 689 if (value.isStringValue()) {
680 state.style()->setTextEmphasisFill(TextEmphasisFillFilled); 690 state.style()->setTextEmphasisFill(TextEmphasisFillFilled);
681 state.style()->setTextEmphasisMark(TextEmphasisMarkCustom); 691 state.style()->setTextEmphasisMark(TextEmphasisMarkCustom);
682 state.style()->setTextEmphasisCustomMark( 692 state.style()->setTextEmphasisCustomMark(
683 AtomicString(toCSSStringValue(value).value())); 693 AtomicString(toCSSStringValue(value).value()));
684 return; 694 return;
685 } 695 }
686 696
687 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); 697 const CSSIdentifierValue& identifierValue = toCSSIdentifierValue(value);
688 698
689 state.style()->setTextEmphasisCustomMark(nullAtom); 699 state.style()->setTextEmphasisCustomMark(nullAtom);
690 700
691 if (primitiveValue.getValueID() == CSSValueFilled || 701 if (identifierValue.getValueID() == CSSValueFilled ||
692 primitiveValue.getValueID() == CSSValueOpen) { 702 identifierValue.getValueID() == CSSValueOpen) {
693 state.style()->setTextEmphasisFill( 703 state.style()->setTextEmphasisFill(
694 primitiveValue.convertTo<TextEmphasisFill>()); 704 identifierValue.convertTo<TextEmphasisFill>());
695 state.style()->setTextEmphasisMark(TextEmphasisMarkAuto); 705 state.style()->setTextEmphasisMark(TextEmphasisMarkAuto);
696 } else { 706 } else {
697 state.style()->setTextEmphasisFill(TextEmphasisFillFilled); 707 state.style()->setTextEmphasisFill(TextEmphasisFillFilled);
698 state.style()->setTextEmphasisMark( 708 state.style()->setTextEmphasisMark(
699 primitiveValue.convertTo<TextEmphasisMark>()); 709 identifierValue.convertTo<TextEmphasisMark>());
700 } 710 }
701 } 711 }
702 712
703 void StyleBuilderFunctions::applyInitialCSSPropertyWillChange( 713 void StyleBuilderFunctions::applyInitialCSSPropertyWillChange(
704 StyleResolverState& state) { 714 StyleResolverState& state) {
705 state.style()->setWillChangeContents(false); 715 state.style()->setWillChangeContents(false);
706 state.style()->setWillChangeScrollPosition(false); 716 state.style()->setWillChangeScrollPosition(false);
707 state.style()->setWillChangeProperties(Vector<CSSPropertyID>()); 717 state.style()->setWillChangeProperties(Vector<CSSPropertyID>());
708 state.style()->setSubtreeWillChangeContents( 718 state.style()->setSubtreeWillChangeContents(
709 state.parentStyle()->subtreeWillChangeContents()); 719 state.parentStyle()->subtreeWillChangeContents());
(...skipping 11 matching lines...) Expand all
721 state.parentStyle()->subtreeWillChangeContents()); 731 state.parentStyle()->subtreeWillChangeContents());
722 } 732 }
723 733
724 void StyleBuilderFunctions::applyValueCSSPropertyWillChange( 734 void StyleBuilderFunctions::applyValueCSSPropertyWillChange(
725 StyleResolverState& state, 735 StyleResolverState& state,
726 const CSSValue& value) { 736 const CSSValue& value) {
727 bool willChangeContents = false; 737 bool willChangeContents = false;
728 bool willChangeScrollPosition = false; 738 bool willChangeScrollPosition = false;
729 Vector<CSSPropertyID> willChangeProperties; 739 Vector<CSSPropertyID> willChangeProperties;
730 740
731 if (value.isPrimitiveValue()) { 741 if (value.isIdentifierValue()) {
732 DCHECK_EQ(toCSSPrimitiveValue(value).getValueID(), CSSValueAuto); 742 DCHECK_EQ(toCSSIdentifierValue(value).getValueID(), CSSValueAuto);
733 } else { 743 } else {
734 DCHECK(value.isValueList()); 744 DCHECK(value.isValueList());
735 for (auto& willChangeValue : toCSSValueList(value)) { 745 for (auto& willChangeValue : toCSSValueList(value)) {
736 if (willChangeValue->isCustomIdentValue()) 746 if (willChangeValue->isCustomIdentValue())
737 willChangeProperties.append( 747 willChangeProperties.append(
738 toCSSCustomIdentValue(*willChangeValue).valueAsPropertyID()); 748 toCSSCustomIdentValue(*willChangeValue).valueAsPropertyID());
739 else if (toCSSPrimitiveValue(*willChangeValue).getValueID() == 749 else if (toCSSIdentifierValue(*willChangeValue).getValueID() ==
740 CSSValueContents) 750 CSSValueContents)
741 willChangeContents = true; 751 willChangeContents = true;
742 else if (toCSSPrimitiveValue(*willChangeValue).getValueID() == 752 else if (toCSSIdentifierValue(*willChangeValue).getValueID() ==
743 CSSValueScrollPosition) 753 CSSValueScrollPosition)
744 willChangeScrollPosition = true; 754 willChangeScrollPosition = true;
745 else 755 else
746 NOTREACHED(); 756 NOTREACHED();
747 } 757 }
748 } 758 }
749 state.style()->setWillChangeContents(willChangeContents); 759 state.style()->setWillChangeContents(willChangeContents);
750 state.style()->setWillChangeScrollPosition(willChangeScrollPosition); 760 state.style()->setWillChangeScrollPosition(willChangeScrollPosition);
751 state.style()->setWillChangeProperties(willChangeProperties); 761 state.style()->setWillChangeProperties(willChangeProperties);
752 state.style()->setSubtreeWillChangeContents( 762 state.style()->setSubtreeWillChangeContents(
753 willChangeContents || state.parentStyle()->subtreeWillChangeContents()); 763 willChangeContents || state.parentStyle()->subtreeWillChangeContents());
754 } 764 }
755 765
756 void StyleBuilderFunctions::applyInitialCSSPropertyContent( 766 void StyleBuilderFunctions::applyInitialCSSPropertyContent(
757 StyleResolverState& state) { 767 StyleResolverState& state) {
758 state.style()->setContent(nullptr); 768 state.style()->setContent(nullptr);
759 } 769 }
760 770
761 void StyleBuilderFunctions::applyInheritCSSPropertyContent( 771 void StyleBuilderFunctions::applyInheritCSSPropertyContent(
762 StyleResolverState&) { 772 StyleResolverState&) {
763 // FIXME: In CSS3, it will be possible to inherit content. In CSS2 it is not. This 773 // FIXME: In CSS3, it will be possible to inherit content. In CSS2 it is not. This
764 // note is a reminder that eventually "inherit" needs to be supported. 774 // note is a reminder that eventually "inherit" needs to be supported.
765 } 775 }
766 776
767 void StyleBuilderFunctions::applyValueCSSPropertyContent( 777 void StyleBuilderFunctions::applyValueCSSPropertyContent(
768 StyleResolverState& state, 778 StyleResolverState& state,
769 const CSSValue& value) { 779 const CSSValue& value) {
770 if (value.isPrimitiveValue()) { 780 if (value.isIdentifierValue()) {
771 DCHECK(toCSSPrimitiveValue(value).getValueID() == CSSValueNormal || 781 DCHECK(toCSSIdentifierValue(value).getValueID() == CSSValueNormal ||
772 toCSSPrimitiveValue(value).getValueID() == CSSValueNone); 782 toCSSIdentifierValue(value).getValueID() == CSSValueNone);
773 state.style()->setContent(nullptr); 783 state.style()->setContent(nullptr);
774 return; 784 return;
775 } 785 }
776 786
777 ContentData* firstContent = nullptr; 787 ContentData* firstContent = nullptr;
778 ContentData* prevContent = nullptr; 788 ContentData* prevContent = nullptr;
779 for (auto& item : toCSSValueList(value)) { 789 for (auto& item : toCSSValueList(value)) {
780 ContentData* nextContent = nullptr; 790 ContentData* nextContent = nullptr;
781 if (item->isImageGeneratorValue() || item->isImageSetValue() || 791 if (item->isImageGeneratorValue() || item->isImageSetValue() ||
782 item->isImageValue()) { 792 item->isImageValue()) {
783 nextContent = 793 nextContent =
784 ContentData::create(state.styleImage(CSSPropertyContent, *item)); 794 ContentData::create(state.styleImage(CSSPropertyContent, *item));
785 } else if (item->isCounterValue()) { 795 } else if (item->isCounterValue()) {
786 const CSSCounterValue* counterValue = toCSSCounterValue(item.get()); 796 const CSSCounterValue* counterValue = toCSSCounterValue(item.get());
787 EListStyleType listStyleType = NoneListStyle; 797 EListStyleType listStyleType = NoneListStyle;
788 CSSValueID listStyleIdent = counterValue->listStyle(); 798 CSSValueID listStyleIdent = counterValue->listStyle();
789 if (listStyleIdent != CSSValueNone) 799 if (listStyleIdent != CSSValueNone)
790 listStyleType = 800 listStyleType =
791 static_cast<EListStyleType>(listStyleIdent - CSSValueDisc); 801 static_cast<EListStyleType>(listStyleIdent - CSSValueDisc);
792 std::unique_ptr<CounterContent> counter = wrapUnique(new CounterContent( 802 std::unique_ptr<CounterContent> counter = wrapUnique(new CounterContent(
793 AtomicString(counterValue->identifier()), listStyleType, 803 AtomicString(counterValue->identifier()), listStyleType,
794 AtomicString(counterValue->separator()))); 804 AtomicString(counterValue->separator())));
795 nextContent = ContentData::create(std::move(counter)); 805 nextContent = ContentData::create(std::move(counter));
796 } else if (item->isPrimitiveValue()) { 806 } else if (item->isIdentifierValue()) {
797 QuoteType quoteType; 807 QuoteType quoteType;
798 switch (toCSSPrimitiveValue(*item).getValueID()) { 808 switch (toCSSIdentifierValue(*item).getValueID()) {
799 default: 809 default:
800 NOTREACHED(); 810 NOTREACHED();
801 case CSSValueOpenQuote: 811 case CSSValueOpenQuote:
802 quoteType = OPEN_QUOTE; 812 quoteType = OPEN_QUOTE;
803 break; 813 break;
804 case CSSValueCloseQuote: 814 case CSSValueCloseQuote:
805 quoteType = CLOSE_QUOTE; 815 quoteType = CLOSE_QUOTE;
806 break; 816 break;
807 case CSSValueNoOpenQuote: 817 case CSSValueNoOpenQuote:
808 quoteType = NO_OPEN_QUOTE; 818 quoteType = NO_OPEN_QUOTE;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
845 855
846 prevContent = nextContent; 856 prevContent = nextContent;
847 } 857 }
848 DCHECK(firstContent); 858 DCHECK(firstContent);
849 state.style()->setContent(firstContent); 859 state.style()->setContent(firstContent);
850 } 860 }
851 861
852 void StyleBuilderFunctions::applyValueCSSPropertyWebkitLocale( 862 void StyleBuilderFunctions::applyValueCSSPropertyWebkitLocale(
853 StyleResolverState& state, 863 StyleResolverState& state,
854 const CSSValue& value) { 864 const CSSValue& value) {
855 if (value.isPrimitiveValue()) { 865 if (value.isIdentifierValue()) {
856 DCHECK_EQ(toCSSPrimitiveValue(value).getValueID(), CSSValueAuto); 866 DCHECK_EQ(toCSSIdentifierValue(value).getValueID(), CSSValueAuto);
857 state.fontBuilder().setLocale(nullptr); 867 state.fontBuilder().setLocale(nullptr);
858 } else { 868 } else {
859 state.fontBuilder().setLocale( 869 state.fontBuilder().setLocale(
860 LayoutLocale::get(AtomicString(toCSSStringValue(value).value()))); 870 LayoutLocale::get(AtomicString(toCSSStringValue(value).value())));
861 } 871 }
862 } 872 }
863 873
864 void StyleBuilderFunctions::applyInitialCSSPropertyWebkitAppRegion( 874 void StyleBuilderFunctions::applyInitialCSSPropertyWebkitAppRegion(
865 StyleResolverState&) {} 875 StyleResolverState&) {}
866 876
867 void StyleBuilderFunctions::applyInheritCSSPropertyWebkitAppRegion( 877 void StyleBuilderFunctions::applyInheritCSSPropertyWebkitAppRegion(
868 StyleResolverState&) {} 878 StyleResolverState&) {}
869 879
870 void StyleBuilderFunctions::applyValueCSSPropertyWebkitAppRegion( 880 void StyleBuilderFunctions::applyValueCSSPropertyWebkitAppRegion(
871 StyleResolverState& state, 881 StyleResolverState& state,
872 const CSSValue& value) { 882 const CSSValue& value) {
873 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); 883 const CSSIdentifierValue& identifierValue = toCSSIdentifierValue(value);
874 state.style()->setDraggableRegionMode( 884 state.style()->setDraggableRegionMode(
875 primitiveValue.getValueID() == CSSValueDrag ? DraggableRegionDrag 885 identifierValue.getValueID() == CSSValueDrag ? DraggableRegionDrag
876 : DraggableRegionNoDrag); 886 : DraggableRegionNoDrag);
877 state.document().setHasAnnotatedRegions(true); 887 state.document().setHasAnnotatedRegions(true);
878 } 888 }
879 889
880 void StyleBuilderFunctions::applyValueCSSPropertyWritingMode( 890 void StyleBuilderFunctions::applyValueCSSPropertyWritingMode(
881 StyleResolverState& state, 891 StyleResolverState& state,
882 const CSSValue& value) { 892 const CSSValue& value) {
883 state.setWritingMode(toCSSPrimitiveValue(value).convertTo<WritingMode>()); 893 state.setWritingMode(toCSSIdentifierValue(value).convertTo<WritingMode>());
884 } 894 }
885 895
886 void StyleBuilderFunctions::applyValueCSSPropertyWebkitWritingMode( 896 void StyleBuilderFunctions::applyValueCSSPropertyWebkitWritingMode(
887 StyleResolverState& state, 897 StyleResolverState& state,
888 const CSSValue& value) { 898 const CSSValue& value) {
889 state.setWritingMode(toCSSPrimitiveValue(value).convertTo<WritingMode>()); 899 state.setWritingMode(toCSSIdentifierValue(value).convertTo<WritingMode>());
890 } 900 }
891 901
892 void StyleBuilderFunctions::applyValueCSSPropertyTextOrientation( 902 void StyleBuilderFunctions::applyValueCSSPropertyTextOrientation(
893 StyleResolverState& state, 903 StyleResolverState& state,
894 const CSSValue& value) { 904 const CSSValue& value) {
895 state.setTextOrientation( 905 state.setTextOrientation(
896 toCSSPrimitiveValue(value).convertTo<TextOrientation>()); 906 toCSSIdentifierValue(value).convertTo<TextOrientation>());
897 } 907 }
898 908
899 void StyleBuilderFunctions::applyValueCSSPropertyWebkitTextOrientation( 909 void StyleBuilderFunctions::applyValueCSSPropertyWebkitTextOrientation(
900 StyleResolverState& state, 910 StyleResolverState& state,
901 const CSSValue& value) { 911 const CSSValue& value) {
902 state.setTextOrientation( 912 state.setTextOrientation(
903 toCSSPrimitiveValue(value).convertTo<TextOrientation>()); 913 toCSSIdentifierValue(value).convertTo<TextOrientation>());
904 } 914 }
905 915
906 void StyleBuilderFunctions::applyValueCSSPropertyVariable( 916 void StyleBuilderFunctions::applyValueCSSPropertyVariable(
907 StyleResolverState& state, 917 StyleResolverState& state,
908 const CSSValue& value) { 918 const CSSValue& value) {
909 const CSSCustomPropertyDeclaration& declaration = 919 const CSSCustomPropertyDeclaration& declaration =
910 toCSSCustomPropertyDeclaration(value); 920 toCSSCustomPropertyDeclaration(value);
911 const AtomicString& name = declaration.name(); 921 const AtomicString& name = declaration.name();
912 const PropertyRegistry::Registration* registration = nullptr; 922 const PropertyRegistry::Registration* registration = nullptr;
913 const PropertyRegistry* registry = state.document().propertyRegistry(); 923 const PropertyRegistry* registry = state.document().propertyRegistry();
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
1000 SVGComputedStyle& svgStyle = state.style()->accessSVGStyle(); 1010 SVGComputedStyle& svgStyle = state.style()->accessSVGStyle();
1001 svgStyle.setBaselineShift(baselineShift); 1011 svgStyle.setBaselineShift(baselineShift);
1002 if (baselineShift == BS_LENGTH) 1012 if (baselineShift == BS_LENGTH)
1003 svgStyle.setBaselineShiftValue(parentSvgStyle.baselineShiftValue()); 1013 svgStyle.setBaselineShiftValue(parentSvgStyle.baselineShiftValue());
1004 } 1014 }
1005 1015
1006 void StyleBuilderFunctions::applyValueCSSPropertyBaselineShift( 1016 void StyleBuilderFunctions::applyValueCSSPropertyBaselineShift(
1007 StyleResolverState& state, 1017 StyleResolverState& state,
1008 const CSSValue& value) { 1018 const CSSValue& value) {
1009 SVGComputedStyle& svgStyle = state.style()->accessSVGStyle(); 1019 SVGComputedStyle& svgStyle = state.style()->accessSVGStyle();
1010 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); 1020 if (!value.isIdentifierValue()) {
1011 if (!primitiveValue.isValueID()) {
1012 svgStyle.setBaselineShift(BS_LENGTH); 1021 svgStyle.setBaselineShift(BS_LENGTH);
1013 svgStyle.setBaselineShiftValue( 1022 svgStyle.setBaselineShiftValue(StyleBuilderConverter::convertLength(
1014 StyleBuilderConverter::convertLength(state, primitiveValue)); 1023 state, toCSSPrimitiveValue(value)));
1015 return; 1024 return;
1016 } 1025 }
1017 switch (primitiveValue.getValueID()) { 1026 switch (toCSSIdentifierValue(value).getValueID()) {
1018 case CSSValueBaseline: 1027 case CSSValueBaseline:
1019 svgStyle.setBaselineShift(BS_LENGTH); 1028 svgStyle.setBaselineShift(BS_LENGTH);
1020 svgStyle.setBaselineShiftValue(Length(Fixed)); 1029 svgStyle.setBaselineShiftValue(Length(Fixed));
1021 return; 1030 return;
1022 case CSSValueSub: 1031 case CSSValueSub:
1023 svgStyle.setBaselineShift(BS_SUB); 1032 svgStyle.setBaselineShift(BS_SUB);
1024 return; 1033 return;
1025 case CSSValueSuper: 1034 case CSSValueSuper:
1026 svgStyle.setBaselineShift(BS_SUPER); 1035 svgStyle.setBaselineShift(BS_SUPER);
1027 return; 1036 return;
1028 default: 1037 default:
1029 NOTREACHED(); 1038 NOTREACHED();
1030 } 1039 }
1031 } 1040 }
1032 1041
1033 void StyleBuilderFunctions::applyInheritCSSPropertyPosition( 1042 void StyleBuilderFunctions::applyInheritCSSPropertyPosition(
1034 StyleResolverState& state) { 1043 StyleResolverState& state) {
1035 if (!state.parentNode()->isDocumentNode()) 1044 if (!state.parentNode()->isDocumentNode())
1036 state.style()->setPosition(state.parentStyle()->position()); 1045 state.style()->setPosition(state.parentStyle()->position());
1037 } 1046 }
1038 1047
1039 } // namespace blink 1048 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698