OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) | 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) |
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All |
7 * rights reserved. | 7 * rights reserved. |
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. | 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. |
9 * (http://www.torchmobile.com/) | 9 * (http://www.torchmobile.com/) |
10 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. | 10 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. |
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
553 DCHECK(contents); | 553 DCHECK(contents); |
554 DCHECK(contents->IsCacheableForStyleElement()); | 554 DCHECK(contents->IsCacheableForStyleElement()); |
555 DCHECK(contents->HasSingleOwnerDocument()); | 555 DCHECK(contents->HasSingleOwnerDocument()); |
556 contents->SetIsUsedFromTextCache(); | 556 contents->SetIsUsedFromTextCache(); |
557 style_sheet = | 557 style_sheet = |
558 CSSStyleSheet::CreateInline(contents, element, start_position); | 558 CSSStyleSheet::CreateInline(contents, element, start_position); |
559 } | 559 } |
560 | 560 |
561 DCHECK(style_sheet); | 561 DCHECK(style_sheet); |
562 if (!element.IsInShadowTree()) { | 562 if (!element.IsInShadowTree()) { |
563 style_sheet->SetTitle(element.title()); | 563 String title = element.title(); |
564 SetPreferredStylesheetSetNameIfNotSet(element.title()); | 564 if (!title.IsEmpty()) { |
| 565 style_sheet->SetTitle(title); |
| 566 SetPreferredStylesheetSetNameIfNotSet(title); |
| 567 } |
565 } | 568 } |
566 return style_sheet; | 569 return style_sheet; |
567 } | 570 } |
568 | 571 |
569 CSSStyleSheet* StyleEngine::ParseSheet(Element& element, | 572 CSSStyleSheet* StyleEngine::ParseSheet(Element& element, |
570 const String& text, | 573 const String& text, |
571 TextPosition start_position) { | 574 TextPosition start_position) { |
572 CSSStyleSheet* style_sheet = nullptr; | 575 CSSStyleSheet* style_sheet = nullptr; |
573 style_sheet = CSSStyleSheet::CreateInline(element, KURL(), start_position, | 576 style_sheet = CSSStyleSheet::CreateInline(element, KURL(), start_position, |
574 GetDocument().characterSet()); | 577 GetDocument().characterSet()); |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
917 style_resolver_stats_ = nullptr; | 920 style_resolver_stats_ = nullptr; |
918 return; | 921 return; |
919 } | 922 } |
920 if (!style_resolver_stats_) | 923 if (!style_resolver_stats_) |
921 style_resolver_stats_ = StyleResolverStats::Create(); | 924 style_resolver_stats_ = StyleResolverStats::Create(); |
922 else | 925 else |
923 style_resolver_stats_->Reset(); | 926 style_resolver_stats_->Reset(); |
924 } | 927 } |
925 | 928 |
926 void StyleEngine::SetPreferredStylesheetSetNameIfNotSet(const String& name) { | 929 void StyleEngine::SetPreferredStylesheetSetNameIfNotSet(const String& name) { |
| 930 DCHECK(!name.IsEmpty()); |
927 if (!preferred_stylesheet_set_name_.IsEmpty()) | 931 if (!preferred_stylesheet_set_name_.IsEmpty()) |
928 return; | 932 return; |
929 preferred_stylesheet_set_name_ = name; | 933 preferred_stylesheet_set_name_ = name; |
930 // TODO(rune@opera.com): Setting the selected set here is wrong if the set | 934 // TODO(rune@opera.com): Setting the selected set here is wrong if the set |
931 // has been previously set by through Document.selectedStylesheetSet. Our | 935 // has been previously set by through Document.selectedStylesheetSet. Our |
932 // current implementation ignores the effect of Document.selectedStylesheetSet | 936 // current implementation ignores the effect of Document.selectedStylesheetSet |
933 // and either only collects persistent style, or additionally preferred | 937 // and either only collects persistent style, or additionally preferred |
934 // style when present. | 938 // style when present. |
935 selected_stylesheet_set_name_ = name; | 939 selected_stylesheet_set_name_ = name; |
936 MarkDocumentDirty(); | 940 MarkDocumentDirty(); |
937 } | 941 } |
938 | 942 |
939 void StyleEngine::SetSelectedStylesheetSetName(const String& name) { | 943 void StyleEngine::SetSelectedStylesheetSetName(const String& name) { |
940 selected_stylesheet_set_name_ = name; | 944 selected_stylesheet_set_name_ = name; |
941 // TODO(rune@opera.com): Setting Document.selectedStylesheetSet currently | 945 // TODO(rune@opera.com): Setting Document.selectedStylesheetSet currently |
942 // has no other effect than the ability to read back the set value using | 946 // has no other effect than the ability to read back the set value using |
943 // the same api. If it did have an effect, we should have marked the | 947 // the same api. If it did have an effect, we should have marked the |
944 // document scope dirty and triggered an update of the active stylesheets | 948 // document scope dirty and triggered an update of the active stylesheets |
945 // from here. | 949 // from here. |
946 } | 950 } |
947 | 951 |
948 void StyleEngine::SetHttpDefaultStyle(const String& content) { | 952 void StyleEngine::SetHttpDefaultStyle(const String& content) { |
949 SetPreferredStylesheetSetNameIfNotSet(content); | 953 if (!content.IsEmpty()) |
| 954 SetPreferredStylesheetSetNameIfNotSet(content); |
950 } | 955 } |
951 | 956 |
952 void StyleEngine::EnsureUAStyleForFullscreen() { | 957 void StyleEngine::EnsureUAStyleForFullscreen() { |
953 if (global_rule_set_.HasFullscreenUAStyle()) | 958 if (global_rule_set_.HasFullscreenUAStyle()) |
954 return; | 959 return; |
955 CSSDefaultStyleSheets::Instance().EnsureDefaultStyleSheetForFullscreen(); | 960 CSSDefaultStyleSheets::Instance().EnsureDefaultStyleSheetForFullscreen(); |
956 global_rule_set_.MarkDirty(); | 961 global_rule_set_.MarkDirty(); |
957 UpdateActiveStyle(); | 962 UpdateActiveStyle(); |
958 } | 963 } |
959 | 964 |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1175 } | 1180 } |
1176 | 1181 |
1177 DEFINE_TRACE_WRAPPERS(StyleEngine) { | 1182 DEFINE_TRACE_WRAPPERS(StyleEngine) { |
1178 for (auto sheet : injected_author_style_sheets_) { | 1183 for (auto sheet : injected_author_style_sheets_) { |
1179 visitor->TraceWrappers(sheet); | 1184 visitor->TraceWrappers(sheet); |
1180 } | 1185 } |
1181 visitor->TraceWrappers(document_style_sheet_collection_); | 1186 visitor->TraceWrappers(document_style_sheet_collection_); |
1182 } | 1187 } |
1183 | 1188 |
1184 } // namespace blink | 1189 } // namespace blink |
OLD | NEW |