OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) | 3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) |
4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) | 4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) |
5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc.
All rights reserved. | 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc.
All rights reserved. |
6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> | 6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> |
7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> | 7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> |
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) | 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) |
9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. | 9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. |
10 * Copyright (C) Research In Motion Limited 2011. All rights reserved. | 10 * Copyright (C) Research In Motion Limited 2011. All rights reserved. |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 // Perhaps this should move onto ElementResolveContext or even Element? | 59 // Perhaps this should move onto ElementResolveContext or even Element? |
60 static inline bool isAtShadowBoundary(const Element* element) | 60 static inline bool isAtShadowBoundary(const Element* element) |
61 { | 61 { |
62 if (!element) | 62 if (!element) |
63 return false; | 63 return false; |
64 ContainerNode* parentNode = element->parentNode(); | 64 ContainerNode* parentNode = element->parentNode(); |
65 return parentNode && parentNode->isShadowRoot(); | 65 return parentNode && parentNode->isShadowRoot(); |
66 } | 66 } |
67 | 67 |
68 | 68 |
69 static void addIntrinsicMargins(RenderStyle* style) | |
70 { | |
71 // Intrinsic margin value. | |
72 const int intrinsicMargin = 2 * style->effectiveZoom(); | |
73 | |
74 // FIXME: Using width/height alone and not also dealing with min-width/max-w
idth is flawed. | |
75 // FIXME: Using "quirk" to decide the margin wasn't set is kind of lame. | |
76 if (style->width().isIntrinsicOrAuto()) { | |
77 if (style->marginLeft().quirk()) | |
78 style->setMarginLeft(Length(intrinsicMargin, Fixed)); | |
79 if (style->marginRight().quirk()) | |
80 style->setMarginRight(Length(intrinsicMargin, Fixed)); | |
81 } | |
82 | |
83 if (style->height().isAuto()) { | |
84 if (style->marginTop().quirk()) | |
85 style->setMarginTop(Length(intrinsicMargin, Fixed)); | |
86 if (style->marginBottom().quirk()) | |
87 style->setMarginBottom(Length(intrinsicMargin, Fixed)); | |
88 } | |
89 } | |
90 | |
91 static EDisplay equivalentBlockDisplay(EDisplay display, bool isFloating, bool s
trictParsing) | 69 static EDisplay equivalentBlockDisplay(EDisplay display, bool isFloating, bool s
trictParsing) |
92 { | 70 { |
93 switch (display) { | 71 switch (display) { |
94 case BLOCK: | 72 case BLOCK: |
95 case TABLE: | 73 case TABLE: |
96 case BOX: | 74 case BOX: |
97 case FLEX: | 75 case FLEX: |
98 case GRID: | 76 case GRID: |
99 return display; | 77 return display; |
100 | 78 |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 return; | 327 return; |
350 } | 328 } |
351 | 329 |
352 if (isHTMLMarqueeElement(element)) { | 330 if (isHTMLMarqueeElement(element)) { |
353 // For now, <marquee> requires an overflow clip to work properly. | 331 // For now, <marquee> requires an overflow clip to work properly. |
354 style->setOverflowX(OHIDDEN); | 332 style->setOverflowX(OHIDDEN); |
355 style->setOverflowY(OHIDDEN); | 333 style->setOverflowY(OHIDDEN); |
356 return; | 334 return; |
357 } | 335 } |
358 | 336 |
359 if (element.isFormControlElement()) { | 337 if (isHTMLTextAreaElement(element)) { |
360 if (isHTMLTextAreaElement(element)) { | 338 // Textarea considers overflow visible as auto. |
361 // Textarea considers overflow visible as auto. | 339 style->setOverflowX(style->overflowX() == OVISIBLE ? OAUTO : style->over
flowX()); |
362 style->setOverflowX(style->overflowX() == OVISIBLE ? OAUTO : style->
overflowX()); | 340 style->setOverflowY(style->overflowY() == OVISIBLE ? OAUTO : style->over
flowY()); |
363 style->setOverflowY(style->overflowY() == OVISIBLE ? OAUTO : style->
overflowY()); | |
364 } | |
365 | |
366 // Important: Intrinsic margins get added to controls before the theme h
as adjusted the style, | |
367 // since the theme will alter fonts and heights/widths. | |
368 // | |
369 // Don't apply intrinsic margins to image buttons. The designer knows ho
w big the images are, | |
370 // so we have to treat all image buttons as though they were explicitly
sized. | |
371 if (style->fontSize() >= 11 && (!isHTMLInputElement(element) || !toHTMLI
nputElement(element).isImageButton())) | |
372 addIntrinsicMargins(style); | |
373 return; | 341 return; |
374 } | 342 } |
375 | 343 |
376 if (isHTMLPlugInElement(element)) { | 344 if (isHTMLPlugInElement(element)) { |
377 style->setRequiresAcceleratedCompositingForExternalReasons(toHTMLPlugInE
lement(element).shouldAccelerate()); | 345 style->setRequiresAcceleratedCompositingForExternalReasons(toHTMLPlugInE
lement(element).shouldAccelerate()); |
378 return; | 346 return; |
379 } | 347 } |
380 } | 348 } |
381 | 349 |
382 void StyleAdjuster::adjustOverflow(RenderStyle* style) | 350 void StyleAdjuster::adjustOverflow(RenderStyle* style) |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 if (style->writingMode() != TopToBottomWritingMode && (style->display() == B
OX || style->display() == INLINE_BOX)) | 415 if (style->writingMode() != TopToBottomWritingMode && (style->display() == B
OX || style->display() == INLINE_BOX)) |
448 style->setWritingMode(TopToBottomWritingMode); | 416 style->setWritingMode(TopToBottomWritingMode); |
449 | 417 |
450 if (isDisplayFlexibleBox(parentStyle->display()) || isDisplayGridBox(parentS
tyle->display())) { | 418 if (isDisplayFlexibleBox(parentStyle->display()) || isDisplayGridBox(parentS
tyle->display())) { |
451 style->setFloating(NoFloat); | 419 style->setFloating(NoFloat); |
452 style->setDisplay(equivalentBlockDisplay(style->display(), style->isFloa
ting(), !m_useQuirksModeStyles)); | 420 style->setDisplay(equivalentBlockDisplay(style->display(), style->isFloa
ting(), !m_useQuirksModeStyles)); |
453 } | 421 } |
454 } | 422 } |
455 | 423 |
456 } | 424 } |
OLD | NEW |