Chromium Code Reviews| 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. | 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. |
| 6 * All rights reserved. | 6 * 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. | 9 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. |
| 10 * (http://www.torchmobile.com/) | 10 * (http://www.torchmobile.com/) |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 28 * Boston, MA 02110-1301, USA. | 28 * Boston, MA 02110-1301, USA. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "core/css/resolver/StyleAdjuster.h" | 31 #include "core/css/resolver/StyleAdjuster.h" |
| 32 | 32 |
| 33 #include "core/HTMLNames.h" | 33 #include "core/HTMLNames.h" |
| 34 #include "core/SVGNames.h" | 34 #include "core/SVGNames.h" |
| 35 #include "core/dom/ContainerNode.h" | 35 #include "core/dom/ContainerNode.h" |
| 36 #include "core/dom/Document.h" | 36 #include "core/dom/Document.h" |
| 37 #include "core/dom/Element.h" | 37 #include "core/dom/Element.h" |
| 38 #include "core/dom/NodeComputedStyle.h" | |
| 38 #include "core/frame/LocalFrameView.h" | 39 #include "core/frame/LocalFrameView.h" |
| 39 #include "core/frame/Settings.h" | 40 #include "core/frame/Settings.h" |
| 40 #include "core/frame/UseCounter.h" | 41 #include "core/frame/UseCounter.h" |
| 41 #include "core/html/HTMLIFrameElement.h" | 42 #include "core/html/HTMLIFrameElement.h" |
| 42 #include "core/html/HTMLImageElement.h" | 43 #include "core/html/HTMLImageElement.h" |
| 43 #include "core/html/HTMLInputElement.h" | 44 #include "core/html/HTMLInputElement.h" |
| 44 #include "core/html/HTMLPlugInElement.h" | 45 #include "core/html/HTMLPlugInElement.h" |
| 45 #include "core/html/HTMLTableCellElement.h" | 46 #include "core/html/HTMLTableCellElement.h" |
| 46 #include "core/html/HTMLTextAreaElement.h" | 47 #include "core/html/HTMLTextAreaElement.h" |
| 48 #include "core/layout/LayoutObject.h" | |
| 47 #include "core/layout/LayoutTheme.h" | 49 #include "core/layout/LayoutTheme.h" |
| 48 #include "core/style/ComputedStyle.h" | 50 #include "core/style/ComputedStyle.h" |
| 49 #include "core/style/ComputedStyleConstants.h" | 51 #include "core/style/ComputedStyleConstants.h" |
| 50 #include "core/svg/SVGSVGElement.h" | 52 #include "core/svg/SVGSVGElement.h" |
| 51 #include "platform/Length.h" | 53 #include "platform/Length.h" |
| 52 #include "platform/transforms/TransformOperations.h" | 54 #include "platform/transforms/TransformOperations.h" |
| 53 #include "platform/wtf/Assertions.h" | 55 #include "platform/wtf/Assertions.h" |
| 54 | 56 |
| 55 namespace blink { | 57 namespace blink { |
| 56 | 58 |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 444 | 446 |
| 445 // If we have first-letter pseudo style, transitions, or animations, do not | 447 // If we have first-letter pseudo style, transitions, or animations, do not |
| 446 // share this style. | 448 // share this style. |
| 447 if (style.HasPseudoStyle(kPseudoIdFirstLetter) || style.Transitions() || | 449 if (style.HasPseudoStyle(kPseudoIdFirstLetter) || style.Transitions() || |
| 448 style.Animations()) | 450 style.Animations()) |
| 449 style.SetUnique(); | 451 style.SetUnique(); |
| 450 | 452 |
| 451 AdjustStyleForEditing(style); | 453 AdjustStyleForEditing(style); |
| 452 | 454 |
| 453 bool is_svg_element = element && element->IsSVGElement(); | 455 bool is_svg_element = element && element->IsSVGElement(); |
| 456 bool is_svg_root = false; | |
|
wkorman
2017/06/02 03:07:05
Please add unit tests for this new logic. I haven'
flackr
2017/06/05 18:43:10
nit: Calculate this here, i.e.
bool is_svg_root =
sunxd
2017/06/05 20:12:04
Done % StyleAdjusterTest.
sunxd
2017/06/05 20:12:04
Sure I'll look into this.
sunxd
2017/06/05 20:12:04
Acknowledged.
| |
| 454 if (is_svg_element) { | 457 if (is_svg_element) { |
| 455 // display: contents computes to inline for replaced elements and form | 458 // display: contents computes to inline for replaced elements and form |
| 456 // controls, and isn't specified for other kinds of SVG content[1], so let's | 459 // controls, and isn't specified for other kinds of SVG content[1], so let's |
| 457 // just do the same here for all other SVG elements. | 460 // just do the same here for all other SVG elements. |
| 458 // | 461 // |
| 459 // If we wouldn't do this, then we'd need to ensure that display: contents | 462 // If we wouldn't do this, then we'd need to ensure that display: contents |
| 460 // doesn't prevent SVG elements from generating a LayoutObject in | 463 // doesn't prevent SVG elements from generating a LayoutObject in |
| 461 // SVGElement::LayoutObjectIsNeeded. | 464 // SVGElement::LayoutObjectIsNeeded. |
| 462 // | 465 // |
| 463 // [1]: https://www.w3.org/TR/SVG/painting.html#DisplayProperty | 466 // [1]: https://www.w3.org/TR/SVG/painting.html#DisplayProperty |
| 464 if (style.Display() == EDisplay::kContents) | 467 if (style.Display() == EDisplay::kContents) |
| 465 style.SetDisplay(EDisplay::kInline); | 468 style.SetDisplay(EDisplay::kInline); |
| 466 | 469 |
| 467 // Only the root <svg> element in an SVG document fragment tree honors css | 470 // Only the root <svg> element in an SVG document fragment tree honors css |
| 468 // position. | 471 // position. |
| 469 if (!(isSVGSVGElement(*element) && element->parentNode() && | 472 if (!(isSVGSVGElement(*element) && element->parentNode() && |
| 470 !element->parentNode()->IsSVGElement())) | 473 !element->parentNode()->IsSVGElement())) { |
| 471 style.SetPosition(ComputedStyle::InitialPosition()); | 474 style.SetPosition(ComputedStyle::InitialPosition()); |
| 475 } else { | |
| 476 is_svg_root = true; | |
| 477 } | |
| 472 | 478 |
| 473 // SVG text layout code expects us to be a block-level style element. | 479 // SVG text layout code expects us to be a block-level style element. |
| 474 if ((isSVGForeignObjectElement(*element) || isSVGTextElement(*element)) && | 480 if ((isSVGForeignObjectElement(*element) || isSVGTextElement(*element)) && |
| 475 style.IsDisplayInlineType()) | 481 style.IsDisplayInlineType()) |
| 476 style.SetDisplay(EDisplay::kBlock); | 482 style.SetDisplay(EDisplay::kBlock); |
| 477 | 483 |
| 478 // Columns don't apply to svg text elements. | 484 // Columns don't apply to svg text elements. |
| 479 if (isSVGTextElement(*element)) | 485 if (isSVGTextElement(*element)) |
| 480 style.ClearMultiCol(); | 486 style.ClearMultiCol(); |
| 481 } | 487 } |
| 482 | 488 |
| 483 // If this node is sticky it marks the creation of a sticky subtree, which we | 489 // If this node is sticky it marks the creation of a sticky subtree, which we |
| 484 // must track to properly handle document lifecycle in some cases. | 490 // must track to properly handle document lifecycle in some cases. |
| 485 // | 491 // |
| 486 // It is possible that this node is already in a sticky subtree (i.e. we have | 492 // It is possible that this node is already in a sticky subtree (i.e. we have |
| 487 // nested sticky nodes) - in that case the bit will already be set via | 493 // nested sticky nodes) - in that case the bit will already be set via |
| 488 // inheritance from the ancestor and there is no harm to setting it again. | 494 // inheritance from the ancestor and there is no harm to setting it again. |
| 489 if (style.GetPosition() == EPosition::kSticky) | 495 if (style.GetPosition() == EPosition::kSticky) |
| 490 style.SetSubtreeIsSticky(true); | 496 style.SetSubtreeIsSticky(true); |
| 491 | 497 |
| 492 // If the inherited value of justify-items includes the 'legacy' keyword, | 498 // If the inherited value of justify-items includes the 'legacy' keyword, |
| 493 // 'auto' computes to the the inherited value. Otherwise, 'auto' computes to | 499 // 'auto' computes to the the inherited value. Otherwise, 'auto' computes to |
| 494 // 'normal'. | 500 // 'normal'. |
| 495 if (style.JustifyItemsPosition() == kItemPositionAuto) { | 501 if (style.JustifyItemsPosition() == kItemPositionAuto) { |
| 496 if (parent_style.JustifyItemsPositionType() == kLegacyPosition) | 502 if (parent_style.JustifyItemsPositionType() == kLegacyPosition) |
| 497 style.SetJustifyItems(parent_style.JustifyItems()); | 503 style.SetJustifyItems(parent_style.JustifyItems()); |
| 498 } | 504 } |
| 505 | |
| 506 TouchAction action = parent_style.GetEffectiveTouchAction(); | |
| 507 bool is_non_replaced_inline_elements = | |
| 508 style.IsDisplayInlineType() && | |
| 509 !(style.IsDisplayReplacedType() || is_svg_root || | |
| 510 isHTMLImageElement(element)); | |
| 511 bool is_table_row_or_column = style.Display() == EDisplay::kTableRow || | |
|
wkorman
2017/06/02 03:07:05
Can we use IsDisplayTableType() or is that too bro
sunxd
2017/06/05 20:12:03
Yes that function is too broad. I think table capt
sunxd
2017/06/06 15:24:59
Done.
| |
| 512 style.Display() == EDisplay::kTableRowGroup || | |
| 513 style.Display() == EDisplay::kTableColumn || | |
| 514 style.Display() == EDisplay::kTableColumnGroup; | |
| 515 if (is_non_replaced_inline_elements || is_table_row_or_column) { | |
|
wkorman
2017/06/02 03:07:05
What made us choose this filtering criteria? If th
sunxd
2017/06/05 20:12:03
Sure I'll add one here. According to spec, the tou
sunxd
2017/06/05 20:12:04
Acknowledged.
sunxd
2017/06/06 15:24:58
Done.
| |
| 516 style.SetEffectiveTouchAction(action); | |
| 517 return; | |
|
flackr
2017/06/05 18:43:10
Seems to me early returns are dangerous in a long
sunxd
2017/06/05 20:12:04
Acknowledged.
sunxd
2017/06/06 15:24:58
Done.
| |
| 518 } | |
| 519 | |
| 520 bool overflow_x = style.OverflowX() == EOverflow::kScroll || | |
| 521 style.OverflowX() == EOverflow::kAuto || | |
| 522 style.OverflowX() == EOverflow::kOverlay; | |
|
flackr
2017/06/05 18:43:10
Seems like this could use a helper function on Com
sunxd
2017/06/05 20:12:03
Acknowledged.
sunxd
2017/06/06 15:24:59
Done.
| |
| 523 bool overflow_y = style.OverflowY() == EOverflow::kScroll || | |
| 524 style.OverflowY() == EOverflow::kAuto || | |
| 525 style.OverflowY() == EOverflow::kWebkitPagedY || | |
|
flackr
2017/06/05 18:43:10
Why only kWebkitPagedY? Should overflow_x also che
sunxd
2017/06/05 20:12:03
I adopted the logic from here:
https://cs.chromium
sunxd
2017/06/12 17:27:04
Done.
| |
| 526 style.OverflowY() == EOverflow::kOverlay; | |
| 527 if (overflow_x || overflow_y) | |
| 528 action |= TouchAction::kTouchActionPan; | |
|
wkorman
2017/06/02 03:07:05
Add a comment re: why we or-in kTouchActionPan her
sunxd
2017/06/05 20:12:04
Acknowledged.
sunxd
2017/06/06 15:24:58
Done.
| |
| 529 | |
| 530 if (element && element == element->GetDocument().documentElement() && | |
|
wkorman
2017/06/02 03:07:05
Add a brief comment re: what we are doing at a hig
sunxd
2017/06/05 20:12:03
Acknowledged.
sunxd
2017/06/06 15:24:59
Done.
| |
| 531 element->GetDocument().LocalOwner()) { | |
| 532 const ComputedStyle* frame_style = | |
| 533 element->GetDocument().LocalOwner()->GetComputedStyle(); | |
| 534 if (frame_style) { | |
| 535 action &= | |
| 536 frame_style->GetEffectiveTouchAction() | TouchAction::kTouchActionPan; | |
|
flackr
2017/06/05 18:43:10
This won't re-enable panning since it is strictly
sunxd
2017/06/05 20:12:04
Yes. Scrollers / frames only mask its ancestors pa
| |
| 537 } | |
| 538 } | |
| 539 | |
| 540 // Apply TouchAction bits from its parent style | |
|
wkorman
2017/06/02 03:07:05
Clarify comment to note that we've incorporated ot
sunxd
2017/06/05 20:12:04
Acknowledged.
sunxd
2017/06/12 17:27:04
Done.
| |
| 541 style.SetEffectiveTouchAction(style.GetTouchAction() & action); | |
| 499 } | 542 } |
| 500 | 543 |
| 501 } // namespace blink | 544 } // namespace blink |
| OLD | NEW |