| OLD | NEW |
| 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 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 state.style()->setOutlineStyle(state.parentStyle()->outlineStyle()); | 185 state.style()->setOutlineStyle(state.parentStyle()->outlineStyle()); |
| 186 } | 186 } |
| 187 | 187 |
| 188 void StyleBuilderFunctions::applyValueCSSPropertyOutlineStyle(StyleResolverState
& state, CSSValue* value) | 188 void StyleBuilderFunctions::applyValueCSSPropertyOutlineStyle(StyleResolverState
& state, CSSValue* value) |
| 189 { | 189 { |
| 190 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 190 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); |
| 191 state.style()->setOutlineStyleIsAuto(*primitiveValue); | 191 state.style()->setOutlineStyleIsAuto(*primitiveValue); |
| 192 state.style()->setOutlineStyle(*primitiveValue); | 192 state.style()->setOutlineStyle(*primitiveValue); |
| 193 } | 193 } |
| 194 | 194 |
| 195 static Length mmLength(double mm) { return Length(mm * cssPixelsPerMillimeter, F
ixed); } | |
| 196 static Length inchLength(double inch) { return Length(inch * cssPixelsPerInch, F
ixed); } | |
| 197 static bool getPageSizeFromName(CSSPrimitiveValue* pageSizeName, CSSPrimitiveVal
ue* pageOrientation, Length& width, Length& height) | |
| 198 { | |
| 199 DEFINE_STATIC_LOCAL(Length, a5Width, (mmLength(148))); | |
| 200 DEFINE_STATIC_LOCAL(Length, a5Height, (mmLength(210))); | |
| 201 DEFINE_STATIC_LOCAL(Length, a4Width, (mmLength(210))); | |
| 202 DEFINE_STATIC_LOCAL(Length, a4Height, (mmLength(297))); | |
| 203 DEFINE_STATIC_LOCAL(Length, a3Width, (mmLength(297))); | |
| 204 DEFINE_STATIC_LOCAL(Length, a3Height, (mmLength(420))); | |
| 205 DEFINE_STATIC_LOCAL(Length, b5Width, (mmLength(176))); | |
| 206 DEFINE_STATIC_LOCAL(Length, b5Height, (mmLength(250))); | |
| 207 DEFINE_STATIC_LOCAL(Length, b4Width, (mmLength(250))); | |
| 208 DEFINE_STATIC_LOCAL(Length, b4Height, (mmLength(353))); | |
| 209 DEFINE_STATIC_LOCAL(Length, letterWidth, (inchLength(8.5))); | |
| 210 DEFINE_STATIC_LOCAL(Length, letterHeight, (inchLength(11))); | |
| 211 DEFINE_STATIC_LOCAL(Length, legalWidth, (inchLength(8.5))); | |
| 212 DEFINE_STATIC_LOCAL(Length, legalHeight, (inchLength(14))); | |
| 213 DEFINE_STATIC_LOCAL(Length, ledgerWidth, (inchLength(11))); | |
| 214 DEFINE_STATIC_LOCAL(Length, ledgerHeight, (inchLength(17))); | |
| 215 | |
| 216 if (!pageSizeName) | |
| 217 return false; | |
| 218 | |
| 219 switch (pageSizeName->getValueID()) { | |
| 220 case CSSValueA5: | |
| 221 width = a5Width; | |
| 222 height = a5Height; | |
| 223 break; | |
| 224 case CSSValueA4: | |
| 225 width = a4Width; | |
| 226 height = a4Height; | |
| 227 break; | |
| 228 case CSSValueA3: | |
| 229 width = a3Width; | |
| 230 height = a3Height; | |
| 231 break; | |
| 232 case CSSValueB5: | |
| 233 width = b5Width; | |
| 234 height = b5Height; | |
| 235 break; | |
| 236 case CSSValueB4: | |
| 237 width = b4Width; | |
| 238 height = b4Height; | |
| 239 break; | |
| 240 case CSSValueLetter: | |
| 241 width = letterWidth; | |
| 242 height = letterHeight; | |
| 243 break; | |
| 244 case CSSValueLegal: | |
| 245 width = legalWidth; | |
| 246 height = legalHeight; | |
| 247 break; | |
| 248 case CSSValueLedger: | |
| 249 width = ledgerWidth; | |
| 250 height = ledgerHeight; | |
| 251 break; | |
| 252 default: | |
| 253 return false; | |
| 254 } | |
| 255 | |
| 256 if (pageOrientation) { | |
| 257 switch (pageOrientation->getValueID()) { | |
| 258 case CSSValueLandscape: | |
| 259 std::swap(width, height); | |
| 260 break; | |
| 261 case CSSValuePortrait: | |
| 262 // Nothing to do. | |
| 263 break; | |
| 264 default: | |
| 265 return false; | |
| 266 } | |
| 267 } | |
| 268 return true; | |
| 269 } | |
| 270 | |
| 271 void StyleBuilderFunctions::applyInitialCSSPropertySize(StyleResolverState&) { } | |
| 272 void StyleBuilderFunctions::applyInheritCSSPropertySize(StyleResolverState&) { } | |
| 273 void StyleBuilderFunctions::applyValueCSSPropertySize(StyleResolverState& state,
CSSValue* value) | |
| 274 { | |
| 275 state.style()->resetPageSizeType(); | |
| 276 Length width; | |
| 277 Length height; | |
| 278 PageSizeType pageSizeType = PAGE_SIZE_AUTO; | |
| 279 CSSValueListInspector inspector(value); | |
| 280 switch (inspector.length()) { | |
| 281 case 2: { | |
| 282 // <length>{2} | <page-size> <orientation> | |
| 283 if (!inspector.first()->isPrimitiveValue() || !inspector.second()->isPri
mitiveValue()) | |
| 284 return; | |
| 285 CSSPrimitiveValue* first = toCSSPrimitiveValue(inspector.first()); | |
| 286 CSSPrimitiveValue* second = toCSSPrimitiveValue(inspector.second()); | |
| 287 if (first->isLength()) { | |
| 288 // <length>{2} | |
| 289 if (!second->isLength()) | |
| 290 return; | |
| 291 width = first->computeLength<Length>(state.cssToLengthConversionData
()); | |
| 292 height = second->computeLength<Length>(state.cssToLengthConversionDa
ta()); | |
| 293 } else { | |
| 294 // <page-size> <orientation> | |
| 295 // The value order is guaranteed. See BisonCSSParser::parseSizeParam
eter. | |
| 296 if (!getPageSizeFromName(first, second, width, height)) | |
| 297 return; | |
| 298 } | |
| 299 pageSizeType = PAGE_SIZE_RESOLVED; | |
| 300 break; | |
| 301 } | |
| 302 case 1: { | |
| 303 // <length> | auto | <page-size> | [ portrait | landscape] | |
| 304 if (!inspector.first()->isPrimitiveValue()) | |
| 305 return; | |
| 306 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(inspector.first(
)); | |
| 307 if (primitiveValue->isLength()) { | |
| 308 // <length> | |
| 309 pageSizeType = PAGE_SIZE_RESOLVED; | |
| 310 width = height = primitiveValue->computeLength<Length>(state.cssToLe
ngthConversionData()); | |
| 311 } else { | |
| 312 switch (primitiveValue->getValueID()) { | |
| 313 case 0: | |
| 314 return; | |
| 315 case CSSValueAuto: | |
| 316 pageSizeType = PAGE_SIZE_AUTO; | |
| 317 break; | |
| 318 case CSSValuePortrait: | |
| 319 pageSizeType = PAGE_SIZE_AUTO_PORTRAIT; | |
| 320 break; | |
| 321 case CSSValueLandscape: | |
| 322 pageSizeType = PAGE_SIZE_AUTO_LANDSCAPE; | |
| 323 break; | |
| 324 default: | |
| 325 // <page-size> | |
| 326 pageSizeType = PAGE_SIZE_RESOLVED; | |
| 327 if (!getPageSizeFromName(primitiveValue, 0, width, height)) | |
| 328 return; | |
| 329 } | |
| 330 } | |
| 331 break; | |
| 332 } | |
| 333 default: | |
| 334 return; | |
| 335 } | |
| 336 state.style()->setPageSizeType(pageSizeType); | |
| 337 state.style()->setPageSize(LengthSize(width, height)); | |
| 338 } | |
| 339 | |
| 340 void StyleBuilderFunctions::applyValueCSSPropertyTextAlign(StyleResolverState& s
tate, CSSValue* value) | 195 void StyleBuilderFunctions::applyValueCSSPropertyTextAlign(StyleResolverState& s
tate, CSSValue* value) |
| 341 { | 196 { |
| 342 if (!value->isPrimitiveValue()) | 197 if (!value->isPrimitiveValue()) |
| 343 return; | 198 return; |
| 344 | 199 |
| 345 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 200 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); |
| 346 // FIXME : Per http://www.w3.org/TR/css3-text/#text-align0 can now take <str
ing> but this is not implemented in the | 201 // FIXME : Per http://www.w3.org/TR/css3-text/#text-align0 can now take <str
ing> but this is not implemented in the |
| 347 // rendering code. | 202 // rendering code. |
| 348 if (primitiveValue->isString()) | 203 if (primitiveValue->isString()) |
| 349 return; | 204 return; |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 783 state.style()->setPerspective(perspectiveValue); | 638 state.style()->setPerspective(perspectiveValue); |
| 784 } | 639 } |
| 785 | 640 |
| 786 void StyleBuilderFunctions::applyValueCSSPropertyWebkitTextOrientation(StyleReso
lverState& state, CSSValue* value) | 641 void StyleBuilderFunctions::applyValueCSSPropertyWebkitTextOrientation(StyleReso
lverState& state, CSSValue* value) |
| 787 { | 642 { |
| 788 if (value->isPrimitiveValue()) | 643 if (value->isPrimitiveValue()) |
| 789 state.setTextOrientation(*toCSSPrimitiveValue(value)); | 644 state.setTextOrientation(*toCSSPrimitiveValue(value)); |
| 790 } | 645 } |
| 791 | 646 |
| 792 } // namespace blink | 647 } // namespace blink |
| OLD | NEW |