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

Unified Diff: Source/core/css/resolver/StyleBuilderCustom.cpp

Issue 17450016: Implementation of CSS3 nav-up/down/left/right properties from CSS3 UI. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebased once again to master, fixed layout test. Created 6 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 side-by-side diff with in-line comments
Download patch
Index: Source/core/css/resolver/StyleBuilderCustom.cpp
diff --git a/Source/core/css/resolver/StyleBuilderCustom.cpp b/Source/core/css/resolver/StyleBuilderCustom.cpp
index 25509fd0ab228e582dfe903da87f56a19be9f972..3d08de6870b665221bdd093c59ac57c0cf1b165e 100644
--- a/Source/core/css/resolver/StyleBuilderCustom.cpp
+++ b/Source/core/css/resolver/StyleBuilderCustom.cpp
@@ -8,6 +8,7 @@
* Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org>
* Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
+ * Copyright (C) 2013 Opera Software ASA. All rights reserved.
* Copyright (C) Research In Motion Limited 2011. All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -77,6 +78,7 @@
#include "core/rendering/style/SVGRenderStyle.h"
#include "core/rendering/style/SVGRenderStyleDefs.h"
#include "core/rendering/style/StyleGeneratedImage.h"
+#include "core/rendering/style/StyleNavigationValue.h"
#include "core/svg/SVGPaint.h"
#include "platform/fonts/FontDescription.h"
#include "wtf/MathExtras.h"
@@ -158,6 +160,106 @@ void StyleBuilderFunctions::applyValueCSSPropertyColor(StyleResolverState& state
state.style()->setVisitedLinkColor(state.document().textLinkColors().colorFromPrimitiveValue(primitiveValue, state.style()->color(), true));
}
+namespace {
+void applyInitialCSSPropertyNavDir(StyleResolverState& state, StyleNavigationData::NavigationDirection direction)
+{
+ state.style()->setNavigation(direction, StyleNavigationValue(), true);
+}
+
+void applyInheritCSSPropertyNavDir(StyleResolverState& state, StyleNavigationData::NavigationDirection direction)
+{
+ StyleNavigationData* inheritedNavigation = state.parentStyle()->navigation();
+ if (inheritedNavigation)
+ state.style()->setNavigation(*inheritedNavigation);
+ else
+ applyInitialCSSPropertyNavDir(state, direction);
+}
+
+void applyValueCSSPropertyNavDir(StyleResolverState& state, CSSValue* value, StyleNavigationData::NavigationDirection direction)
+{
+ StyleNavigationValue navigationValue;
+ if (value->isPrimitiveValue()) {
+ CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
+ if (primitiveValue->isString())
+ navigationValue = StyleNavigationValue(primitiveValue->getStringValue());
+ } else if (value->isValueList()) {
+ String vals[2];
+ CSSValueListIterator iterator = value;
+
+ for (int i = 0; i < 2 && iterator.hasMore(); iterator.advance()) {
+ CSSValue* item = iterator.value();
+ if (!item->isPrimitiveValue())
+ continue;
+ vals[i++] = (static_cast<CSSPrimitiveValue*>(item))->getStringValue();
+ }
+
+ navigationValue = StyleNavigationValue(vals[0], vals[1]);
+ }
+
+ state.style()->setNavigation(direction, navigationValue, true);
+}
+} // namespace
+
+void StyleBuilderFunctions::applyInitialCSSPropertyNavDown(StyleResolverState& state)
+{
+ applyInitialCSSPropertyNavDir(state, StyleNavigationData::NavigationDown);
+}
+
+void StyleBuilderFunctions::applyInheritCSSPropertyNavDown(StyleResolverState& state)
+{
+ applyInheritCSSPropertyNavDir(state, StyleNavigationData::NavigationDown);
+}
+
+void StyleBuilderFunctions::applyValueCSSPropertyNavDown(StyleResolverState& state, CSSValue* value)
+{
+ applyValueCSSPropertyNavDir(state, value, StyleNavigationData::NavigationDown);
+}
+
+void StyleBuilderFunctions::applyInitialCSSPropertyNavLeft(StyleResolverState& state)
+{
+ applyInitialCSSPropertyNavDir(state, StyleNavigationData::NavigationLeft);
+}
+
+void StyleBuilderFunctions::applyInheritCSSPropertyNavLeft(StyleResolverState& state)
+{
+ applyInheritCSSPropertyNavDir(state, StyleNavigationData::NavigationLeft);
+}
+
+void StyleBuilderFunctions::applyValueCSSPropertyNavLeft(StyleResolverState& state, CSSValue* value)
+{
+ applyValueCSSPropertyNavDir(state, value, StyleNavigationData::NavigationLeft);
+}
+
+void StyleBuilderFunctions::applyInitialCSSPropertyNavRight(StyleResolverState& state)
+{
+ applyInitialCSSPropertyNavDir(state, StyleNavigationData::NavigationRight);
+}
+
+void StyleBuilderFunctions::applyInheritCSSPropertyNavRight(StyleResolverState& state)
+{
+ applyInheritCSSPropertyNavDir(state, StyleNavigationData::NavigationRight);
+}
+
+void StyleBuilderFunctions::applyValueCSSPropertyNavRight(StyleResolverState& state, CSSValue* value)
+{
+ applyValueCSSPropertyNavDir(state, value, StyleNavigationData::NavigationRight);
+}
+
+void StyleBuilderFunctions::applyInitialCSSPropertyNavUp(StyleResolverState& state)
+{
+ applyInitialCSSPropertyNavDir(state, StyleNavigationData::NavigationUp);
+}
+
+void StyleBuilderFunctions::applyInheritCSSPropertyNavUp(StyleResolverState& state)
+{
+ applyInheritCSSPropertyNavDir(state, StyleNavigationData::NavigationUp);
+}
+
+void StyleBuilderFunctions::applyValueCSSPropertyNavUp(StyleResolverState& state, CSSValue* value)
+{
+ applyValueCSSPropertyNavDir(state, value, StyleNavigationData::NavigationUp);
+}
+
void StyleBuilderFunctions::applyInitialCSSPropertyCursor(StyleResolverState& state)
{
state.style()->clearCursorList();
@@ -1944,6 +2046,10 @@ void StyleBuilder::oldApplyProperty(CSSPropertyID id, StyleResolverState& state,
case CSSPropertyMinHeight:
case CSSPropertyMixBlendMode:
case CSSPropertyMinWidth:
+ case CSSPropertyNavDown:
+ case CSSPropertyNavLeft:
+ case CSSPropertyNavRight:
+ case CSSPropertyNavUp:
case CSSPropertyObjectFit:
case CSSPropertyOpacity:
case CSSPropertyOrphans:

Powered by Google App Engine
This is Rietveld 408576698