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

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

Issue 2399633003: reflow comments in core/css/resolver (Closed)
Patch Set: 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.
7 * All rights reserved.
7 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> 8 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
8 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> 9 * 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/) 10 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved.
11 * (http://www.torchmobile.com/)
10 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. 12 * Copyright (c) 2011, Code Aurora Forum. All rights reserved.
11 * Copyright (C) Research In Motion Limited 2011. All rights reserved. 13 * Copyright (C) Research In Motion Limited 2011. All rights reserved.
12 * Redistribution and use in source and binary forms, with or without 14 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions are 15 * modification, are permitted provided that the following conditions are
14 * met: 16 * met:
15 * 17 *
16 * * Redistributions of source code must retain the above copyright 18 * * Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer. 19 * notice, this list of conditions and the following disclaimer.
18 * * Redistributions in binary form must reproduce the above 20 * * Redistributions in binary form must reproduce the above
19 * copyright notice, this list of conditions and the following disclaimer 21 * copyright notice, this list of conditions and the following disclaimer
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 return; 124 return;
123 } 125 }
124 126
125 DCHECK(!isShorthandProperty(id)) << "Shorthand property id = " << id 127 DCHECK(!isShorthandProperty(id)) << "Shorthand property id = " << id
126 << " wasn't expanded at parsing time"; 128 << " wasn't expanded at parsing time";
127 129
128 bool isInherit = state.parentNode() && value.isInheritedValue(); 130 bool isInherit = state.parentNode() && value.isInheritedValue();
129 bool isInitial = value.isInitialValue() || 131 bool isInitial = value.isInitialValue() ||
130 (!state.parentNode() && value.isInheritedValue()); 132 (!state.parentNode() && value.isInheritedValue());
131 133
132 DCHECK(!isInherit || 134 // isInherit => !isInitial && isInitial => !isInherit
133 !isInitial); // isInherit -> !isInitial && isInitial -> !isInherit 135 DCHECK(!isInherit || !isInitial);
134 DCHECK( 136 // isInherit => (state.parentNode() && state.parentStyle())
135 !isInherit || 137 DCHECK(!isInherit || (state.parentNode() && state.parentStyle()));
136 (state.parentNode() &&
137 state
138 .parentStyle())); // isInherit -> (state.parentNode() && state.paren tStyle())
139 138
140 if (!state.applyPropertyToRegularStyle() && 139 if (!state.applyPropertyToRegularStyle() &&
141 (!state.applyPropertyToVisitedLinkStyle() || 140 (!state.applyPropertyToVisitedLinkStyle() ||
142 !isValidVisitedLinkProperty(id))) { 141 !isValidVisitedLinkProperty(id))) {
143 // Limit the properties that can be applied to only the ones honored by :vis ited. 142 // Limit the properties that can be applied to only the ones honored by
143 // :visited.
144 return; 144 return;
145 } 145 }
146 146
147 if (isInherit && !state.parentStyle()->hasExplicitlyInheritedProperties() && 147 if (isInherit && !state.parentStyle()->hasExplicitlyInheritedProperties() &&
148 !CSSPropertyMetadata::isInheritedProperty(id)) { 148 !CSSPropertyMetadata::isInheritedProperty(id)) {
149 state.parentStyle()->setHasExplicitlyInheritedProperties(); 149 state.parentStyle()->setHasExplicitlyInheritedProperties();
150 } else if (value.isUnsetValue()) { 150 } else if (value.isUnsetValue()) {
151 DCHECK(!isInherit && !isInitial); 151 DCHECK(!isInherit && !isInitial);
152 if (CSSPropertyMetadata::isInheritedProperty(id)) 152 if (CSSPropertyMetadata::isInheritedProperty(id))
153 isInherit = true; 153 isInherit = true;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 bool hotSpotSpecified = image.hotSpotSpecified(); 221 bool hotSpotSpecified = image.hotSpotSpecified();
222 222
223 Element* element = state.element(); 223 Element* element = state.element();
224 if (SVGCursorElement* cursorElement = 224 if (SVGCursorElement* cursorElement =
225 image.getSVGCursorElement(element)) { 225 image.getSVGCursorElement(element)) {
226 if (image.cachedImageURL() != 226 if (image.cachedImageURL() !=
227 element->document().completeURL( 227 element->document().completeURL(
228 cursorElement->href()->currentValue()->value())) 228 cursorElement->href()->currentValue()->value()))
229 image.clearImageResource(); 229 image.clearImageResource();
230 230
231 // Set the hot spot if it wasn't specified in the CSS but is specified in the SVG. 231 // Set the hot spot if it wasn't specified in the CSS but is specified
232 // in the SVG.
232 if (!hotSpotSpecified) { 233 if (!hotSpotSpecified) {
233 hotSpotSpecified = true; 234 hotSpotSpecified = true;
234 SVGLengthContext lengthContext(0); 235 SVGLengthContext lengthContext(0);
235 // x() and y() return 0 if they're not specified in cursorElement. 236 // x() and y() return 0 if they're not specified in cursorElement.
236 float svgX = roundf( 237 float svgX = roundf(
237 cursorElement->x()->currentValue()->value(lengthContext)); 238 cursorElement->x()->currentValue()->value(lengthContext));
238 hotSpot.setX(static_cast<int>(svgX)); 239 hotSpot.setX(static_cast<int>(svgX));
239 float svgY = roundf( 240 float svgY = roundf(
240 cursorElement->y()->currentValue()->value(lengthContext)); 241 cursorElement->y()->currentValue()->value(lengthContext));
241 hotSpot.setY(static_cast<int>(svgY)); 242 hotSpot.setY(static_cast<int>(svgY));
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 int position = second.getIntValue(); 491 int position = second.getIntValue();
491 DCHECK(position > 0 && position <= 100); 492 DCHECK(position > 0 && position <= 100);
492 state.style()->setSnapHeightPosition(position); 493 state.style()->setSnapHeightPosition(position);
493 } 494 }
494 495
495 void StyleBuilderFunctions::applyValueCSSPropertyTextAlign( 496 void StyleBuilderFunctions::applyValueCSSPropertyTextAlign(
496 StyleResolverState& state, 497 StyleResolverState& state,
497 const CSSValue& value) { 498 const CSSValue& value) {
498 if (value.isIdentifierValue() && 499 if (value.isIdentifierValue() &&
499 toCSSIdentifierValue(value).getValueID() != CSSValueWebkitMatchParent) { 500 toCSSIdentifierValue(value).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 501 // Special case for th elements - UA stylesheet text-align does not apply if
502 // parent's computed value for text-align is not its initial value
501 // https://html.spec.whatwg.org/multipage/rendering.html#tables-2 503 // https://html.spec.whatwg.org/multipage/rendering.html#tables-2
502 const CSSIdentifierValue& identValue = toCSSIdentifierValue(value); 504 const CSSIdentifierValue& identValue = toCSSIdentifierValue(value);
503 if (identValue.getValueID() == CSSValueInternalCenter && 505 if (identValue.getValueID() == CSSValueInternalCenter &&
504 state.parentStyle()->textAlign() != ComputedStyle::initialTextAlign()) 506 state.parentStyle()->textAlign() != ComputedStyle::initialTextAlign())
505 state.style()->setTextAlign(state.parentStyle()->textAlign()); 507 state.style()->setTextAlign(state.parentStyle()->textAlign());
506 else 508 else
507 state.style()->setTextAlign(identValue.convertTo<ETextAlign>()); 509 state.style()->setTextAlign(identValue.convertTo<ETextAlign>());
508 } else if (state.parentStyle()->textAlign() == TASTART) 510 } else if (state.parentStyle()->textAlign() == TASTART)
509 state.style()->setTextAlign( 511 state.style()->setTextAlign(
510 state.parentStyle()->isLeftToRightDirection() ? LEFT : RIGHT); 512 state.parentStyle()->isLeftToRightDirection() ? LEFT : RIGHT);
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 state.style()->setVerticalAlign( 585 state.style()->setVerticalAlign(
584 toCSSIdentifierValue(value).convertTo<EVerticalAlign>()); 586 toCSSIdentifierValue(value).convertTo<EVerticalAlign>());
585 } else { 587 } else {
586 state.style()->setVerticalAlignLength( 588 state.style()->setVerticalAlignLength(
587 toCSSPrimitiveValue(value).convertToLength( 589 toCSSPrimitiveValue(value).convertToLength(
588 state.cssToLengthConversionData())); 590 state.cssToLengthConversionData()));
589 } 591 }
590 } 592 }
591 593
592 static void resetEffectiveZoom(StyleResolverState& state) { 594 static void resetEffectiveZoom(StyleResolverState& state) {
593 // Reset the zoom in effect. This allows the setZoom method to accurately comp ute a new zoom in effect. 595 // Reset the zoom in effect. This allows the setZoom method to accurately
596 // compute a new zoom in effect.
594 state.setEffectiveZoom(state.parentStyle() 597 state.setEffectiveZoom(state.parentStyle()
595 ? state.parentStyle()->effectiveZoom() 598 ? state.parentStyle()->effectiveZoom()
596 : ComputedStyle::initialZoom()); 599 : ComputedStyle::initialZoom());
597 } 600 }
598 601
599 void StyleBuilderFunctions::applyInitialCSSPropertyZoom( 602 void StyleBuilderFunctions::applyInitialCSSPropertyZoom(
600 StyleResolverState& state) { 603 StyleResolverState& state) {
601 resetEffectiveZoom(state); 604 resetEffectiveZoom(state);
602 state.setZoom(ComputedStyle::initialZoom()); 605 state.setZoom(ComputedStyle::initialZoom());
603 } 606 }
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
763 willChangeContents || state.parentStyle()->subtreeWillChangeContents()); 766 willChangeContents || state.parentStyle()->subtreeWillChangeContents());
764 } 767 }
765 768
766 void StyleBuilderFunctions::applyInitialCSSPropertyContent( 769 void StyleBuilderFunctions::applyInitialCSSPropertyContent(
767 StyleResolverState& state) { 770 StyleResolverState& state) {
768 state.style()->setContent(nullptr); 771 state.style()->setContent(nullptr);
769 } 772 }
770 773
771 void StyleBuilderFunctions::applyInheritCSSPropertyContent( 774 void StyleBuilderFunctions::applyInheritCSSPropertyContent(
772 StyleResolverState&) { 775 StyleResolverState&) {
773 // FIXME: In CSS3, it will be possible to inherit content. In CSS2 it is not. This 776 // FIXME: In CSS3, it will be possible to inherit content. In CSS2 it is not.
774 // note is a reminder that eventually "inherit" needs to be supported. 777 // This note is a reminder that eventually "inherit" needs to be supported.
775 } 778 }
776 779
777 void StyleBuilderFunctions::applyValueCSSPropertyContent( 780 void StyleBuilderFunctions::applyValueCSSPropertyContent(
778 StyleResolverState& state, 781 StyleResolverState& state,
779 const CSSValue& value) { 782 const CSSValue& value) {
780 if (value.isIdentifierValue()) { 783 if (value.isIdentifierValue()) {
781 DCHECK(toCSSIdentifierValue(value).getValueID() == CSSValueNormal || 784 DCHECK(toCSSIdentifierValue(value).getValueID() == CSSValueNormal ||
782 toCSSIdentifierValue(value).getValueID() == CSSValueNone); 785 toCSSIdentifierValue(value).getValueID() == CSSValueNone);
783 state.style()->setContent(nullptr); 786 state.style()->setContent(nullptr);
784 return; 787 return;
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
1039 } 1042 }
1040 } 1043 }
1041 1044
1042 void StyleBuilderFunctions::applyInheritCSSPropertyPosition( 1045 void StyleBuilderFunctions::applyInheritCSSPropertyPosition(
1043 StyleResolverState& state) { 1046 StyleResolverState& state) {
1044 if (!state.parentNode()->isDocumentNode()) 1047 if (!state.parentNode()->isDocumentNode())
1045 state.style()->setPosition(state.parentStyle()->position()); 1048 state.style()->setPosition(state.parentStyle()->position());
1046 } 1049 }
1047 1050
1048 } // namespace blink 1051 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698