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 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 359 if (style.PaddingBefore().IsPercentOrCalc() || | 361 if (style.PaddingBefore().IsPercentOrCalc() || |
| 360 style.PaddingAfter().IsPercentOrCalc()) | 362 style.PaddingAfter().IsPercentOrCalc()) |
| 361 UseCounter::Count(document, | 363 UseCounter::Count(document, |
| 362 UseCounter::kFlexboxPercentagePaddingVertical); | 364 UseCounter::kFlexboxPercentagePaddingVertical); |
| 363 if (style.MarginBefore().IsPercentOrCalc() || | 365 if (style.MarginBefore().IsPercentOrCalc() || |
| 364 style.MarginAfter().IsPercentOrCalc()) | 366 style.MarginAfter().IsPercentOrCalc()) |
| 365 UseCounter::Count(document, UseCounter::kFlexboxPercentageMarginVertical); | 367 UseCounter::Count(document, UseCounter::kFlexboxPercentageMarginVertical); |
| 366 } | 368 } |
| 367 } | 369 } |
| 368 | 370 |
| 371 static void AdjustEffectiveTouchAction(ComputedStyle& style, | |
| 372 const ComputedStyle& parent_style, | |
| 373 Element* element) { | |
| 374 TouchAction action = parent_style.GetEffectiveTouchAction(); | |
| 375 | |
| 376 bool is_svg_root = element && element->IsSVGElement() && | |
| 377 isSVGSVGElement(*element) && element->parentNode() && | |
| 378 !element->parentNode()->IsSVGElement(); | |
| 379 bool is_non_replaced_inline_elements = | |
| 380 style.IsDisplayInlineType() && | |
| 381 !(style.IsDisplayReplacedType() || is_svg_root || | |
| 382 isHTMLImageElement(element)); | |
| 383 bool is_table_row_or_column = style.IsDisplayTableRowOrColumnType(); | |
| 384 | |
| 385 // According to W3C specs, touch actions are only supported by elements that | |
| 386 // support both the CSS width and height properties. | |
|
flackr
2017/06/07 18:21:47
Should we remove the computed touch action then? i
sunxd
2017/06/08 19:08:11
I think in the original code, we continue with tre
flackr
2017/06/08 19:35:21
Sorry, I think there may be a misunderstanding, St
sunxd
2017/06/09 21:00:35
OK, that sounds reasonable to me, done!
| |
| 387 // See https://www.w3.org/TR/pointerevents/#the-touch-action-css-property. | |
| 388 if (is_non_replaced_inline_elements || is_table_row_or_column) { | |
| 389 style.SetEffectiveTouchAction(action); | |
| 390 return; | |
| 391 } | |
| 392 | |
| 393 // When a gesture is started, the browser intersects the touch-action values | |
| 394 // of the touched element and all its ancestors up to the one that implements | |
|
flackr
2017/06/07 18:21:47
Since we won't actually do a walk intersecting the
sunxd
2017/06/08 19:08:12
Done.
| |
| 395 // the gesture. So a scrolling element should cancel all panning-restricted | |
| 396 // touch actions applied by ancestors of the scrolling element. | |
| 397 if (style.ScrollsOverflow()) | |
| 398 action |= TouchAction::kTouchActionPan; | |
| 399 | |
| 400 // The panning-restricted cancellation should also apply to iframes, so we | |
| 401 // allow (panning & local touch action) on the first descendant element of a | |
| 402 // iframe element. | |
| 403 if (element && element == element->GetDocument().documentElement() && | |
| 404 element->GetDocument().LocalOwner()) { | |
| 405 const ComputedStyle* frame_style = | |
| 406 element->GetDocument().LocalOwner()->GetComputedStyle(); | |
|
flackr
2017/06/07 18:21:47
This confuses me, why do we need to mask with the
sunxd
2017/06/08 19:08:11
I think we are masking with iframe's touch action
flackr
2017/06/08 19:35:21
Ah I see, so if I understand correctly, we're grab
sunxd
2017/06/12 17:27:04
Yes, now I made iframe updates only trigger the re
| |
| 407 if (frame_style) { | |
| 408 action &= | |
| 409 frame_style->GetEffectiveTouchAction() | TouchAction::kTouchActionPan; | |
|
flackr
2017/06/07 18:21:47
Shouldn't we re-enable panning if it was disabled
sunxd
2017/06/08 19:08:11
Oh I think I should write:
action = frame_style->
flackr
2017/06/08 19:35:20
Yes, that makes more sense.
sunxd
2017/06/09 21:00:35
Done.
| |
| 410 } | |
| 411 } | |
| 412 | |
| 413 // Apply the adjusted parent effective touch actions. | |
| 414 style.SetEffectiveTouchAction(style.GetTouchAction() & action); | |
| 415 } | |
| 416 | |
| 369 void StyleAdjuster::AdjustComputedStyle( | 417 void StyleAdjuster::AdjustComputedStyle( |
| 370 ComputedStyle& style, | 418 ComputedStyle& style, |
| 371 const ComputedStyle& parent_style, | 419 const ComputedStyle& parent_style, |
| 372 const ComputedStyle& layout_parent_style, | 420 const ComputedStyle& layout_parent_style, |
| 373 Element* element) { | 421 Element* element) { |
| 374 if (style.Display() != EDisplay::kNone) { | 422 if (style.Display() != EDisplay::kNone) { |
| 375 if (element && element->IsHTMLElement()) | 423 if (element && element->IsHTMLElement()) |
| 376 AdjustStyleForHTMLElement(style, ToHTMLElement(*element)); | 424 AdjustStyleForHTMLElement(style, ToHTMLElement(*element)); |
| 377 | 425 |
| 378 // Per the spec, position 'static' and 'relative' in the top layer compute | 426 // Per the spec, position 'static' and 'relative' in the top layer compute |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 489 if (style.GetPosition() == EPosition::kSticky) | 537 if (style.GetPosition() == EPosition::kSticky) |
| 490 style.SetSubtreeIsSticky(true); | 538 style.SetSubtreeIsSticky(true); |
| 491 | 539 |
| 492 // If the inherited value of justify-items includes the 'legacy' keyword, | 540 // If the inherited value of justify-items includes the 'legacy' keyword, |
| 493 // 'auto' computes to the the inherited value. Otherwise, 'auto' computes to | 541 // 'auto' computes to the the inherited value. Otherwise, 'auto' computes to |
| 494 // 'normal'. | 542 // 'normal'. |
| 495 if (style.JustifyItemsPosition() == kItemPositionAuto) { | 543 if (style.JustifyItemsPosition() == kItemPositionAuto) { |
| 496 if (parent_style.JustifyItemsPositionType() == kLegacyPosition) | 544 if (parent_style.JustifyItemsPositionType() == kLegacyPosition) |
| 497 style.SetJustifyItems(parent_style.JustifyItems()); | 545 style.SetJustifyItems(parent_style.JustifyItems()); |
| 498 } | 546 } |
| 547 | |
| 548 AdjustEffectiveTouchAction(style, parent_style, element); | |
| 499 } | 549 } |
| 500 | |
| 501 } // namespace blink | 550 } // namespace blink |
| OLD | NEW |