| 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" |
| 39 #include "core/dom/StyleChangeReason.h" |
| 38 #include "core/frame/LocalFrameView.h" | 40 #include "core/frame/LocalFrameView.h" |
| 39 #include "core/frame/Settings.h" | 41 #include "core/frame/Settings.h" |
| 40 #include "core/frame/UseCounter.h" | 42 #include "core/frame/UseCounter.h" |
| 41 #include "core/html/HTMLIFrameElement.h" | 43 #include "core/html/HTMLIFrameElement.h" |
| 42 #include "core/html/HTMLImageElement.h" | 44 #include "core/html/HTMLImageElement.h" |
| 43 #include "core/html/HTMLInputElement.h" | 45 #include "core/html/HTMLInputElement.h" |
| 44 #include "core/html/HTMLPlugInElement.h" | 46 #include "core/html/HTMLPlugInElement.h" |
| 45 #include "core/html/HTMLTableCellElement.h" | 47 #include "core/html/HTMLTableCellElement.h" |
| 46 #include "core/html/HTMLTextAreaElement.h" | 48 #include "core/html/HTMLTextAreaElement.h" |
| 49 #include "core/layout/LayoutObject.h" |
| 47 #include "core/layout/LayoutTheme.h" | 50 #include "core/layout/LayoutTheme.h" |
| 48 #include "core/style/ComputedStyle.h" | 51 #include "core/style/ComputedStyle.h" |
| 49 #include "core/style/ComputedStyleConstants.h" | 52 #include "core/style/ComputedStyleConstants.h" |
| 50 #include "core/svg/SVGSVGElement.h" | 53 #include "core/svg/SVGSVGElement.h" |
| 51 #include "platform/Length.h" | 54 #include "platform/Length.h" |
| 52 #include "platform/transforms/TransformOperations.h" | 55 #include "platform/transforms/TransformOperations.h" |
| 53 #include "platform/wtf/Assertions.h" | 56 #include "platform/wtf/Assertions.h" |
| 54 | 57 |
| 55 namespace blink { | 58 namespace blink { |
| 56 | 59 |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 UseCounter::Count(document, | 364 UseCounter::Count(document, |
| 362 WebFeature::kFlexboxPercentagePaddingVertical); | 365 WebFeature::kFlexboxPercentagePaddingVertical); |
| 363 } | 366 } |
| 364 if (style.MarginBefore().IsPercentOrCalc() || | 367 if (style.MarginBefore().IsPercentOrCalc() || |
| 365 style.MarginAfter().IsPercentOrCalc()) { | 368 style.MarginAfter().IsPercentOrCalc()) { |
| 366 UseCounter::Count(document, WebFeature::kFlexboxPercentageMarginVertical); | 369 UseCounter::Count(document, WebFeature::kFlexboxPercentageMarginVertical); |
| 367 } | 370 } |
| 368 } | 371 } |
| 369 } | 372 } |
| 370 | 373 |
| 374 static void AdjustEffectiveTouchAction(ComputedStyle& style, |
| 375 const ComputedStyle& parent_style, |
| 376 Element* element) { |
| 377 TouchAction action = parent_style.GetEffectiveTouchAction(); |
| 378 |
| 379 bool is_svg_root = element && element->IsSVGElement() && |
| 380 isSVGSVGElement(*element) && element->parentNode() && |
| 381 !element->parentNode()->IsSVGElement(); |
| 382 bool is_non_replaced_inline_elements = |
| 383 style.IsDisplayInlineType() && |
| 384 !(style.IsDisplayReplacedType() || is_svg_root || |
| 385 isHTMLImageElement(element)); |
| 386 bool is_table_row_or_column = style.IsDisplayTableRowOrColumnType(); |
| 387 bool is_layout_object_needed = |
| 388 element && element->LayoutObjectIsNeeded(style); |
| 389 |
| 390 // According to W3C specs, touch actions are only supported by elements that |
| 391 // support both the CSS width and height properties. |
| 392 // See https://www.w3.org/TR/pointerevents/#the-touch-action-css-property. |
| 393 if (is_non_replaced_inline_elements || is_table_row_or_column || |
| 394 !is_layout_object_needed) { |
| 395 style.SetEffectiveTouchAction(action); |
| 396 return; |
| 397 } |
| 398 |
| 399 bool is_child_document = |
| 400 element && element == element->GetDocument().documentElement() && |
| 401 element->GetDocument().LocalOwner(); |
| 402 |
| 403 if (is_child_document) { |
| 404 const ComputedStyle* frame_style = |
| 405 element->GetDocument().LocalOwner()->GetComputedStyle(); |
| 406 if (frame_style) |
| 407 action = frame_style->GetEffectiveTouchAction(); |
| 408 } |
| 409 |
| 410 // The effective touch action is the intersection of the touch-action values |
| 411 // of the current element and all of its ancestors up to the one that |
| 412 // implements the gesture. Since panning is implemented by the scroller it is |
| 413 // re-enabled for scrolling elements. |
| 414 // The panning-restricted cancellation should also apply to iframes, so we |
| 415 // allow (panning & local touch action) on the first descendant element of a |
| 416 // iframe element. |
| 417 if (style.ScrollsOverflow() || is_child_document) |
| 418 action |= TouchAction::kTouchActionPan; |
| 419 |
| 420 // Apply the adjusted parent effective touch actions. |
| 421 style.SetEffectiveTouchAction(style.GetTouchAction() & action); |
| 422 |
| 423 // Touch action is inherited across frames. |
| 424 if (element && element->IsFrameOwnerElement() && |
| 425 ToHTMLFrameOwnerElement(element)->contentDocument()) { |
| 426 Element* content_document_element = |
| 427 ToHTMLFrameOwnerElement(element)->contentDocument()->documentElement(); |
| 428 if (content_document_element) { |
| 429 content_document_element->SetNeedsStyleRecalc( |
| 430 kSubtreeStyleChange, |
| 431 StyleChangeReasonForTracing::Create( |
| 432 StyleChangeReason::kInheritedStyleChangeFromParentFrame)); |
| 433 } |
| 434 } |
| 435 } |
| 436 |
| 371 void StyleAdjuster::AdjustComputedStyle( | 437 void StyleAdjuster::AdjustComputedStyle( |
| 372 ComputedStyle& style, | 438 ComputedStyle& style, |
| 373 const ComputedStyle& parent_style, | 439 const ComputedStyle& parent_style, |
| 374 const ComputedStyle& layout_parent_style, | 440 const ComputedStyle& layout_parent_style, |
| 375 Element* element) { | 441 Element* element) { |
| 376 if (style.Display() != EDisplay::kNone) { | 442 if (style.Display() != EDisplay::kNone) { |
| 377 if (element && element->IsHTMLElement()) | 443 if (element && element->IsHTMLElement()) |
| 378 AdjustStyleForHTMLElement(style, ToHTMLElement(*element)); | 444 AdjustStyleForHTMLElement(style, ToHTMLElement(*element)); |
| 379 | 445 |
| 380 // Per the spec, position 'static' and 'relative' in the top layer compute | 446 // Per the spec, position 'static' and 'relative' in the top layer compute |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 if (style.GetPosition() == EPosition::kSticky) | 554 if (style.GetPosition() == EPosition::kSticky) |
| 489 style.SetSubtreeIsSticky(true); | 555 style.SetSubtreeIsSticky(true); |
| 490 | 556 |
| 491 // If the inherited value of justify-items includes the 'legacy' keyword, | 557 // If the inherited value of justify-items includes the 'legacy' keyword, |
| 492 // 'auto' computes to the the inherited value. Otherwise, 'auto' computes to | 558 // 'auto' computes to the the inherited value. Otherwise, 'auto' computes to |
| 493 // 'normal'. | 559 // 'normal'. |
| 494 if (style.JustifyItemsPosition() == kItemPositionAuto) { | 560 if (style.JustifyItemsPosition() == kItemPositionAuto) { |
| 495 if (parent_style.JustifyItemsPositionType() == kLegacyPosition) | 561 if (parent_style.JustifyItemsPositionType() == kLegacyPosition) |
| 496 style.SetJustifyItems(parent_style.JustifyItems()); | 562 style.SetJustifyItems(parent_style.JustifyItems()); |
| 497 } | 563 } |
| 564 |
| 565 AdjustEffectiveTouchAction(style, parent_style, element); |
| 498 } | 566 } |
| 499 | |
| 500 } // namespace blink | 567 } // namespace blink |
| OLD | NEW |