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/AnimatedStyleBuilder.cpp

Issue 2640143005: Support subpixel layout for borders. (Closed)
Patch Set: Created 3 years, 11 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 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 } 122 }
123 123
124 template <typename T> 124 template <typename T>
125 T animatableLineWidthClamp(const AnimatableValue* value, 125 T animatableLineWidthClamp(const AnimatableValue* value,
126 const StyleResolverState& state) { 126 const StyleResolverState& state) {
127 double lineWidth = animatableValueToPixels(value, state); 127 double lineWidth = animatableValueToPixels(value, state);
128 // This matches StyleBuilderConverter::convertLineWidth(). 128 // This matches StyleBuilderConverter::convertLineWidth().
129 return (lineWidth > 0 && lineWidth < 1) ? 1 : roundedClampTo<T>(lineWidth); 129 return (lineWidth > 0 && lineWidth < 1) ? 1 : roundedClampTo<T>(lineWidth);
130 } 130 }
131 131
132 float animatableLineWidth(const AnimatableValue* value,
133 const StyleResolverState& state) {
134 double lineWidth =
135 toAnimatableLength(value)
136 ->getLength(state.style()->effectiveZoom(), ValueRangeNonNegative)
137 .pixels();
138 // This matches StyleBuilderConverter::convertLineWidth().
139 return (lineWidth > 0 && lineWidth < 1) ? 1 : lineWidth;
140 }
141
132 LengthBox animatableValueToLengthBox(const AnimatableValue* value, 142 LengthBox animatableValueToLengthBox(const AnimatableValue* value,
133 const StyleResolverState& state, 143 const StyleResolverState& state,
134 ValueRange range = ValueRangeAll) { 144 ValueRange range = ValueRangeAll) {
135 const AnimatableLengthBox* animatableLengthBox = toAnimatableLengthBox(value); 145 const AnimatableLengthBox* animatableLengthBox = toAnimatableLengthBox(value);
136 return LengthBox( 146 return LengthBox(
137 animatableValueToLength(animatableLengthBox->top(), state, range), 147 animatableValueToLength(animatableLengthBox->top(), state, range),
138 animatableValueToLength(animatableLengthBox->right(), state, range), 148 animatableValueToLength(animatableLengthBox->right(), state, range),
139 animatableValueToLength(animatableLengthBox->bottom(), state, range), 149 animatableValueToLength(animatableLengthBox->bottom(), state, range),
140 animatableValueToLength(animatableLengthBox->left(), state, range)); 150 animatableValueToLength(animatableLengthBox->left(), state, range));
141 } 151 }
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 return; 361 return;
352 case CSSPropertyBorderBottomLeftRadius: 362 case CSSPropertyBorderBottomLeftRadius:
353 style->setBorderBottomLeftRadius( 363 style->setBorderBottomLeftRadius(
354 animatableValueToLengthSize(value, state, ValueRangeNonNegative)); 364 animatableValueToLengthSize(value, state, ValueRangeNonNegative));
355 return; 365 return;
356 case CSSPropertyBorderBottomRightRadius: 366 case CSSPropertyBorderBottomRightRadius:
357 style->setBorderBottomRightRadius( 367 style->setBorderBottomRightRadius(
358 animatableValueToLengthSize(value, state, ValueRangeNonNegative)); 368 animatableValueToLengthSize(value, state, ValueRangeNonNegative));
359 return; 369 return;
360 case CSSPropertyBorderBottomWidth: 370 case CSSPropertyBorderBottomWidth:
361 style->setBorderBottomWidth( 371 style->setBorderBottomWidth(animatableLineWidth(value, state));
362 animatableLineWidthClamp<unsigned>(value, state));
363 return; 372 return;
364 case CSSPropertyBorderImageOutset: 373 case CSSPropertyBorderImageOutset:
365 style->setBorderImageOutset( 374 style->setBorderImageOutset(
366 animatableValueToBorderImageLengthBox(value, state)); 375 animatableValueToBorderImageLengthBox(value, state));
367 return; 376 return;
368 case CSSPropertyBorderImageSlice: 377 case CSSPropertyBorderImageSlice:
369 style->setBorderImageSlices( 378 style->setBorderImageSlices(
370 animatableValueToLengthBox(toAnimatableLengthBoxAndBool(value)->box(), 379 animatableValueToLengthBox(toAnimatableLengthBoxAndBool(value)->box(),
371 state, ValueRangeNonNegative)); 380 state, ValueRangeNonNegative));
372 style->setBorderImageSlicesFill( 381 style->setBorderImageSlicesFill(
373 toAnimatableLengthBoxAndBool(value)->flag()); 382 toAnimatableLengthBoxAndBool(value)->flag());
374 return; 383 return;
375 case CSSPropertyBorderImageSource: 384 case CSSPropertyBorderImageSource:
376 style->setBorderImageSource( 385 style->setBorderImageSource(
377 state.styleImage(property, *toAnimatableImage(value)->toCSSValue())); 386 state.styleImage(property, *toAnimatableImage(value)->toCSSValue()));
378 return; 387 return;
379 case CSSPropertyBorderImageWidth: 388 case CSSPropertyBorderImageWidth:
380 style->setBorderImageWidth( 389 style->setBorderImageWidth(
381 animatableValueToBorderImageLengthBox(value, state)); 390 animatableValueToBorderImageLengthBox(value, state));
382 return; 391 return;
383 case CSSPropertyBorderLeftColor: 392 case CSSPropertyBorderLeftColor:
384 style->setBorderLeftColor(toAnimatableColor(value)->getColor()); 393 style->setBorderLeftColor(toAnimatableColor(value)->getColor());
385 style->setVisitedLinkBorderLeftColor( 394 style->setVisitedLinkBorderLeftColor(
386 toAnimatableColor(value)->visitedLinkColor()); 395 toAnimatableColor(value)->visitedLinkColor());
387 return; 396 return;
388 case CSSPropertyBorderLeftWidth: 397 case CSSPropertyBorderLeftWidth:
389 style->setBorderLeftWidth( 398 style->setBorderLeftWidth(animatableLineWidth(value, state));
390 animatableLineWidthClamp<unsigned>(value, state));
391 return; 399 return;
392 case CSSPropertyBorderRightColor: 400 case CSSPropertyBorderRightColor:
393 style->setBorderRightColor(toAnimatableColor(value)->getColor()); 401 style->setBorderRightColor(toAnimatableColor(value)->getColor());
394 style->setVisitedLinkBorderRightColor( 402 style->setVisitedLinkBorderRightColor(
395 toAnimatableColor(value)->visitedLinkColor()); 403 toAnimatableColor(value)->visitedLinkColor());
396 return; 404 return;
397 case CSSPropertyBorderRightWidth: 405 case CSSPropertyBorderRightWidth:
398 style->setBorderRightWidth( 406 style->setBorderRightWidth(animatableLineWidth(value, state));
399 animatableLineWidthClamp<unsigned>(value, state));
400 return; 407 return;
401 case CSSPropertyBorderTopColor: 408 case CSSPropertyBorderTopColor:
402 style->setBorderTopColor(toAnimatableColor(value)->getColor()); 409 style->setBorderTopColor(toAnimatableColor(value)->getColor());
403 style->setVisitedLinkBorderTopColor( 410 style->setVisitedLinkBorderTopColor(
404 toAnimatableColor(value)->visitedLinkColor()); 411 toAnimatableColor(value)->visitedLinkColor());
405 return; 412 return;
406 case CSSPropertyBorderTopLeftRadius: 413 case CSSPropertyBorderTopLeftRadius:
407 style->setBorderTopLeftRadius( 414 style->setBorderTopLeftRadius(
408 animatableValueToLengthSize(value, state, ValueRangeNonNegative)); 415 animatableValueToLengthSize(value, state, ValueRangeNonNegative));
409 return; 416 return;
410 case CSSPropertyBorderTopRightRadius: 417 case CSSPropertyBorderTopRightRadius:
411 style->setBorderTopRightRadius( 418 style->setBorderTopRightRadius(
412 animatableValueToLengthSize(value, state, ValueRangeNonNegative)); 419 animatableValueToLengthSize(value, state, ValueRangeNonNegative));
413 return; 420 return;
414 case CSSPropertyBorderTopWidth: 421 case CSSPropertyBorderTopWidth:
415 style->setBorderTopWidth( 422 style->setBorderTopWidth(animatableLineWidth(value, state));
416 animatableLineWidthClamp<unsigned>(value, state));
417 return; 423 return;
418 case CSSPropertyBottom: 424 case CSSPropertyBottom:
419 style->setBottom(animatableValueToLength(value, state)); 425 style->setBottom(animatableValueToLength(value, state));
420 return; 426 return;
421 case CSSPropertyBoxShadow: 427 case CSSPropertyBoxShadow:
422 style->setBoxShadow(toAnimatableShadow(value)->getShadowList()); 428 style->setBoxShadow(toAnimatableShadow(value)->getShadowList());
423 return; 429 return;
424 case CSSPropertyCaretColor: 430 case CSSPropertyCaretColor:
425 style->setCaretColor(toAnimatableColor(value)->getColor()); 431 style->setCaretColor(toAnimatableColor(value)->getColor());
426 style->setVisitedLinkCaretColor( 432 style->setVisitedLinkCaretColor(
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
849 style->setRy( 855 style->setRy(
850 animatableValueToLength(value, state, ValueRangeNonNegative)); 856 animatableValueToLength(value, state, ValueRangeNonNegative));
851 return; 857 return;
852 858
853 default: 859 default:
854 ASSERT_NOT_REACHED(); 860 ASSERT_NOT_REACHED();
855 } 861 }
856 } 862 }
857 863
858 } // namespace blink 864 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698