Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(649)

Side by Side Diff: third_party/WebKit/Source/core/html/shadow/AppearanceSwitchElement.cpp

Issue 1958073002: Introduce :-internal-shadow-host-has-appearance pseudo class, and apply it to METER element. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove null host check Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "core/html/shadow/AppearanceSwitchElement.h"
6
7 #include "core/dom/NodeComputedStyle.h"
8
9 namespace blink {
10
11 inline AppearanceSwitchElement::AppearanceSwitchElement(Document& doc, Mode mode )
12 : HTMLDivElement(doc)
13 , m_mode(mode)
14 {
15 setHasCustomStyleCallbacks();
16 }
17
18 AppearanceSwitchElement* AppearanceSwitchElement::create(Document& doc, Mode mod e)
19 {
20 return new AppearanceSwitchElement(doc, mode);
21 }
22
23 PassRefPtr<ComputedStyle> AppearanceSwitchElement::customStyleForLayoutObject()
24 {
25 // We can't use setInlineStyleProperty() because it updates the DOM tree.
26 // We shouldn't do it during style calculation.
27 // TODO(tkent): Injecting a CSS variable by host is a better approach?
28 Element* host = shadowHost();
29 RefPtr<ComputedStyle> style = originalStyleForLayoutObject();
30 if (!host || !host->computedStyle())
31 return style.release();
32 if (m_mode == ShowIfHostHasAppearance) {
33 if (host->computedStyle()->hasAppearance())
34 return style.release();
35 } else {
36 if (!host->computedStyle()->hasAppearance())
37 return style.release();
38 }
39 if (style->display() == NONE)
40 return style.release();
41 RefPtr<ComputedStyle> newStyle = ComputedStyle::clone(*style);
42 newStyle->setDisplay(NONE);
43 newStyle->setUnique();
44 return newStyle.release();
45 }
46
47 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698