Commit 573bcd01 authored by Joey Arhar's avatar Joey Arhar Committed by Commit Bot

Beforematch and hidden-matchable origin trial

Bug: 1117589
Change-Id: Id2e0e344553189018324ebfe30418419944400c5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2363434
Commit-Queue: Joey Arhar <jarhar@chromium.org>
Reviewed-by: default avatarRune Lillesveen <futhark@chromium.org>
Reviewed-by: default avatarvmpstr <vmpstr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#799910}
parent bfd2cd56
...@@ -5987,17 +5987,14 @@ const CSSValue* ContentVisibility::ParseSingleValue( ...@@ -5987,17 +5987,14 @@ const CSSValue* ContentVisibility::ParseSingleValue(
CSSParserTokenRange& range, CSSParserTokenRange& range,
const CSSParserContext& context, const CSSParserContext& context,
const CSSParserLocalContext&) const { const CSSParserLocalContext&) const {
auto id = range.Peek().Id(); if (range.Peek().Id() == CSSValueID::kHiddenMatchable &&
if (id == CSSValueID::kHiddenMatchable && !RuntimeEnabledFeatures::CSSContentVisibilityHiddenMatchableEnabled(
!RuntimeEnabledFeatures::CSSContentVisibilityHiddenMatchableEnabled()) { context.GetExecutionContext())) {
return nullptr; return nullptr;
} }
if (!css_parsing_utils::IdentMatches<CSSValueID::kVisible, CSSValueID::kAuto, return css_parsing_utils::ConsumeIdent<CSSValueID::kVisible,
CSSValueID::kHidden, CSSValueID::kAuto, CSSValueID::kHidden,
CSSValueID::kHiddenMatchable>(id)) { CSSValueID::kHiddenMatchable>(range);
return nullptr;
}
return css_parsing_utils::ConsumeIdent(range);
} }
const CSSValue* TabSize::ParseSingleValue(CSSParserTokenRange& range, const CSSValue* TabSize::ParseSingleValue(CSSParserTokenRange& range,
......
...@@ -828,7 +828,8 @@ void TextFinder::FireBeforematchEvent( ...@@ -828,7 +828,8 @@ void TextFinder::FireBeforematchEvent(
return; return;
} }
if (RuntimeEnabledFeatures::BeforeMatchEventEnabled()) { if (RuntimeEnabledFeatures::BeforeMatchEventEnabled(
GetFrame()->GetDocument()->GetExecutionContext())) {
Element* beforematch_element = GetBeforematchElement(*context->range); Element* beforematch_element = GetBeforematchElement(*context->range);
// Note that we don't check the `range.EndPosition()` since we just activate // Note that we don't check the `range.EndPosition()` since we just activate
// the beginning of the range. In find-in-page cases, the end position is // the beginning of the range. In find-in-page cases, the end position is
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "third_party/blink/renderer/core/dom/element.h" #include "third_party/blink/renderer/core/dom/element.h"
#include "third_party/blink/renderer/core/dom/events/event.h" #include "third_party/blink/renderer/core/dom/events/event.h"
#include "third_party/blink/renderer/core/dom/node.h" #include "third_party/blink/renderer/core/dom/node.h"
#include "third_party/blink/renderer/core/execution_context/execution_context.h"
#include "third_party/blink/renderer/core/frame/local_frame.h" #include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/svg/svg_svg_element.h" #include "third_party/blink/renderer/core/svg/svg_svg_element.h"
#include "third_party/blink/renderer/platform/bindings/script_forbidden_scope.h" #include "third_party/blink/renderer/platform/bindings/script_forbidden_scope.h"
...@@ -89,9 +90,11 @@ ElementFragmentAnchor* ElementFragmentAnchor::TryCreate(const KURL& url, ...@@ -89,9 +90,11 @@ ElementFragmentAnchor* ElementFragmentAnchor::TryCreate(const KURL& url,
if (!should_scroll) if (!should_scroll)
return nullptr; return nullptr;
if (RuntimeEnabledFeatures::BeforeMatchEventEnabled()) if (RuntimeEnabledFeatures::BeforeMatchEventEnabled(
frame.GetDocument()->GetExecutionContext())) {
anchor_node->DispatchEvent( anchor_node->DispatchEvent(
*Event::CreateBubble(event_type_names::kBeforematch)); *Event::CreateBubble(event_type_names::kBeforematch));
}
return MakeGarbageCollected<ElementFragmentAnchor>(*anchor_node, frame); return MakeGarbageCollected<ElementFragmentAnchor>(*anchor_node, frame);
} }
......
...@@ -485,9 +485,11 @@ void TextFragmentAnchor::ApplyTargetToCommonAncestor( ...@@ -485,9 +485,11 @@ void TextFragmentAnchor::ApplyTargetToCommonAncestor(
} }
void TextFragmentAnchor::FireBeforeMatchEvent(Element* element) { void TextFragmentAnchor::FireBeforeMatchEvent(Element* element) {
if (RuntimeEnabledFeatures::BeforeMatchEventEnabled()) if (RuntimeEnabledFeatures::BeforeMatchEventEnabled(
frame_->GetDocument()->GetExecutionContext())) {
element->DispatchEvent( element->DispatchEvent(
*Event::CreateBubble(event_type_names::kBeforematch)); *Event::CreateBubble(event_type_names::kBeforematch));
}
beforematch_state_ = kFiredEvent; beforematch_state_ = kFiredEvent;
} }
......
...@@ -248,6 +248,7 @@ ...@@ -248,6 +248,7 @@
{ {
// https://github.com/WICG/display-locking/blob/master/explainer-beforematch.md // https://github.com/WICG/display-locking/blob/master/explainer-beforematch.md
name: "BeforeMatchEvent", name: "BeforeMatchEvent",
origin_trial_feature_name: "BeforeMatchEvent",
status: "experimental", status: "experimental",
}, },
{ {
...@@ -433,6 +434,7 @@ ...@@ -433,6 +434,7 @@
// by a different flag. // by a different flag.
// https://wicg.github.io/display-locking/ // https://wicg.github.io/display-locking/
name: "CSSContentVisibilityHiddenMatchable", name: "CSSContentVisibilityHiddenMatchable",
origin_trial_feature_name: "BeforeMatchEvent",
status: "experimental" status: "experimental"
}, },
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment