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

Side by Side Diff: Source/core/css/resolver/StyleBuilderConverter.cpp

Issue 1070143002: [Alignment] Single class for holding the alignment data. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Using the StyleConverter. Created 5 years, 8 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 * * Redistributions of source code must retain the above copyright 4 * * Redistributions of source code must retain the above copyright
5 * notice, this list of conditions and the following disclaimer. 5 * notice, this list of conditions and the following disclaimer.
6 * * Redistributions in binary form must reproduce the above 6 * * Redistributions in binary form must reproduce the above
7 * copyright notice, this list of conditions and the following disclaimer 7 * copyright notice, this list of conditions and the following disclaimer
8 * in the documentation and/or other materials provided with the 8 * in the documentation and/or other materials provided with the
9 * distribution. 9 * distribution.
10 * * Neither the name of Google Inc. nor the names of its 10 * * Neither the name of Google Inc. nor the names of its
(...skipping 10 matching lines...) Expand all
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */ 25 */
26 26
27 #include "config.h" 27 #include "config.h"
28 #include "core/css/resolver/StyleBuilderConverter.h" 28 #include "core/css/resolver/StyleBuilderConverter.h"
29 29
30 #include "core/css/BasicShapeFunctions.h" 30 #include "core/css/BasicShapeFunctions.h"
31 #include "core/css/CSSContentDistributionValue.h"
31 #include "core/css/CSSFontFeatureValue.h" 32 #include "core/css/CSSFontFeatureValue.h"
32 #include "core/css/CSSFunctionValue.h" 33 #include "core/css/CSSFunctionValue.h"
33 #include "core/css/CSSGridLineNamesValue.h" 34 #include "core/css/CSSGridLineNamesValue.h"
34 #include "core/css/CSSPrimitiveValueMappings.h" 35 #include "core/css/CSSPrimitiveValueMappings.h"
35 #include "core/css/CSSReflectValue.h" 36 #include "core/css/CSSReflectValue.h"
36 #include "core/css/CSSShadowValue.h" 37 #include "core/css/CSSShadowValue.h"
37 #include "core/css/Pair.h" 38 #include "core/css/Pair.h"
38 #include "core/css/Rect.h" 39 #include "core/css/Rect.h"
39 #include "core/svg/SVGElement.h" 40 #include "core/svg/SVGElement.h"
40 #include "core/svg/SVGURIReference.h" 41 #include "core/svg/SVGURIReference.h"
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 325
325 if (angle <= 45.0f || angle > 315.0f) 326 if (angle <= 45.0f || angle > 315.0f)
326 return GO_0DEG; 327 return GO_0DEG;
327 if (angle > 45.0f && angle <= 135.0f) 328 if (angle > 45.0f && angle <= 135.0f)
328 return GO_90DEG; 329 return GO_90DEG;
329 if (angle > 135.0f && angle <= 225.0f) 330 if (angle > 135.0f && angle <= 225.0f)
330 return GO_180DEG; 331 return GO_180DEG;
331 return GO_270DEG; 332 return GO_270DEG;
332 } 333 }
333 334
335 StyleAlignmentData StyleBuilderConverter::convertSelfAlignmentData(StyleResolver State&, CSSValue* value)
336 {
337 ItemPosition position = ItemPositionAuto;
338 OverflowAlignment overflow = OverflowAlignmentDefault;
339 ItemPositionType positionType = NonLegacyPosition;
Julien - ping for review 2015/04/13 14:46:20 This is subtly duplicating the logic from the init
jfernandez 2015/04/14 00:18:42 Done.
340
341 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
342 if (Pair* pairValue = primitiveValue->getPairValue()) {
343 if (pairValue->first()->getValueID() == CSSValueLegacy) {
344 positionType = LegacyPosition;
345 position = *pairValue->second();
346 } else {
347 position = *pairValue->first();
348 overflow = *pairValue->second();
349 }
350 } else {
351 position = *primitiveValue;
352 }
353
354 return StyleAlignmentData(position, overflow, positionType);
355 }
356
357 StyleAlignmentData StyleBuilderConverter::convertContentAlignmentData(StyleResol verState&, CSSValue* value)
358 {
359 ContentPosition position = ContentPositionAuto;
360 ContentDistributionType distribution = ContentDistributionDefault;
361 OverflowAlignment overflow = OverflowAlignmentDefault;
Julien - ping for review 2015/04/13 14:46:20 Same comment.
jfernandez 2015/04/14 00:18:42 Done.
362
363 CSSContentDistributionValue* contentValue = toCSSContentDistributionValue(va lue);
364 if (contentValue->distribution()->getValueID() != CSSValueInvalid)
365 distribution = *contentValue->distribution();
366 if (contentValue->position()->getValueID() != CSSValueInvalid)
367 position = *contentValue->position();
368 if (contentValue->overflow()->getValueID() != CSSValueInvalid)
369 overflow = *contentValue->overflow();
370
371 return StyleAlignmentData(position, distribution, overflow);
372 }
373
334 GridAutoFlow StyleBuilderConverter::convertGridAutoFlow(StyleResolverState&, CSS Value* value) 374 GridAutoFlow StyleBuilderConverter::convertGridAutoFlow(StyleResolverState&, CSS Value* value)
335 { 375 {
336 CSSValueList* list = toCSSValueList(value); 376 CSSValueList* list = toCSSValueList(value);
337 377
338 ASSERT(list->length() >= 1); 378 ASSERT(list->length() >= 1);
339 CSSPrimitiveValue* first = toCSSPrimitiveValue(list->item(0)); 379 CSSPrimitiveValue* first = toCSSPrimitiveValue(list->item(0));
340 CSSPrimitiveValue* second = list->length() == 2 ? toCSSPrimitiveValue(list-> item(1)) : nullptr; 380 CSSPrimitiveValue* second = list->length() == 2 ? toCSSPrimitiveValue(list-> item(1)) : nullptr;
341 381
342 switch (first->getValueID()) { 382 switch (first->getValueID()) {
343 case CSSValueRow: 383 case CSSValueRow:
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after
872 CSSPrimitiveValue* primitiveValueZ = toCSSPrimitiveValue(list->item(2)); 912 CSSPrimitiveValue* primitiveValueZ = toCSSPrimitiveValue(list->item(2));
873 913
874 return TransformOrigin( 914 return TransformOrigin(
875 convertOriginLength<CSSValueLeft, CSSValueRight>(state, primitiveValueX) , 915 convertOriginLength<CSSValueLeft, CSSValueRight>(state, primitiveValueX) ,
876 convertOriginLength<CSSValueTop, CSSValueBottom>(state, primitiveValueY) , 916 convertOriginLength<CSSValueTop, CSSValueBottom>(state, primitiveValueY) ,
877 StyleBuilderConverter::convertComputedLength<float>(state, primitiveValu eZ) 917 StyleBuilderConverter::convertComputedLength<float>(state, primitiveValu eZ)
878 ); 918 );
879 } 919 }
880 920
881 } // namespace blink 921 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698