bool AbstractCompositeHelpTopic::writeSubTopicList(const HelpWriterContext &context, const std::string &title) const { if (context.outputFormat() != eHelpOutputFormat_Console) { Impl::SubTopicList::const_iterator topic; for (topic = impl_->subTopics_.begin(); topic != impl_->subTopics_.end(); ++topic) { const char *const title = (*topic)->title(); if (!isNullOrEmpty(title)) { context.outputFile().writeLine(); HelpWriterContext subContext(context); subContext.enterSubSection(title); (*topic)->writeHelp(subContext); } } return true; } int maxNameLength = 0; Impl::SubTopicMap::const_iterator topic; for (topic = impl_->subTopicMap_.begin(); topic != impl_->subTopicMap_.end(); ++topic) { const char *const title = topic->second->title(); if (!isNullOrEmpty(title)) { int nameLength = static_cast<int>(topic->first.length()); if (nameLength > maxNameLength) { maxNameLength = nameLength; } } } if (maxNameLength == 0) { return false; } TextWriter &file = context.outputFile(); TextTableFormatter formatter; formatter.addColumn(NULL, maxNameLength + 1, false); formatter.addColumn(NULL, 72 - maxNameLength, true); formatter.setFirstColumnIndent(4); file.writeLine(title); for (topic = impl_->subTopicMap_.begin(); topic != impl_->subTopicMap_.end(); ++topic) { const char *const name = topic->first.c_str(); const char *const title = topic->second->title(); if (!isNullOrEmpty(title)) { formatter.clear(); formatter.addColumnLine(0, name); formatter.addColumnLine(1, title); file.writeString(formatter.formatRow()); } } return true; }
bool SelectorChecker::checkPseudoClass(const SelectorCheckingContext& context) const { ASSERT(context.element); Element& element = *context.element; ASSERT(context.selector); const CSSSelector& selector = *context.selector; ASSERT(selector.match() == CSSSelector::PseudoClass); // Normal element pseudo class checking. switch (selector.pseudoType()) { case CSSSelector::PseudoFocus: if (m_mode == ResolvingStyle) { if (context.elementStyle) context.elementStyle->setAffectedByFocus(); } return matchesFocusPseudoClass(element); case CSSSelector::PseudoHover: if (m_mode == ResolvingStyle) { if (context.elementStyle) context.elementStyle->setAffectedByHover(); } return element.hovered(); case CSSSelector::PseudoActive: if (m_mode == ResolvingStyle) { if (context.elementStyle) context.elementStyle->setAffectedByActive(); } return element.active(); case CSSSelector::PseudoLang: { AtomicString value = element.computeInheritedLanguage(); const AtomicString& argument = selector.argument(); if (value.isEmpty() || !value.startsWith(argument, false)) break; if (value.length() != argument.length() && value[argument.length()] != '-') break; return true; } case CSSSelector::PseudoUnresolved: return element.isUnresolvedCustomElement(); case CSSSelector::PseudoHost: { if (m_mode == SharingRules) return true; // :host only matches a shadow host when :host is in a shadow tree of the shadow host. if (!context.scope) return false; const ContainerNode* shadowHost = context.scope->shadowHost(); if (!shadowHost || shadowHost != element) return false; ASSERT(element.shadow()); // For empty parameter case, i.e. just :host or :host(). if (!selector.selectorList()) return true; SelectorCheckingContext subContext(context); subContext.contextFlags = TreatShadowHostAsNormalScope; for (subContext.selector = selector.selectorList()->first(); subContext.selector; subContext.selector = CSSSelectorList::next(*subContext.selector)) { if (match(subContext)) return true; } return false; } case CSSSelector::PseudoUnknown: case CSSSelector::PseudoNotParsed: case CSSSelector::PseudoUserAgentCustomElement: return false; } ASSERT_NOT_REACHED(); return false; }