Beispiel #1
0
void ScrollAnchor::findAnchor() {
  TRACE_EVENT0("blink", "ScrollAnchor::findAnchor");
  SCOPED_BLINK_UMA_HISTOGRAM_TIMER("Layout.ScrollAnchor.TimeToFindAnchor");

  LayoutObject* stayWithin = scrollerLayoutBox(m_scroller);
  LayoutObject* candidate = stayWithin->nextInPreOrder(stayWithin);
  while (candidate) {
    ExamineResult result = examine(candidate);
    if (result.viable) {
      m_anchorObject = candidate;
      m_corner = result.corner;
    }
    switch (result.status) {
      case Skip:
        candidate = candidate->nextInPreOrderAfterChildren(stayWithin);
        break;
      case Constrain:
        stayWithin = candidate;
      // fall through
      case Continue:
        candidate = candidate->nextInPreOrder(stayWithin);
        break;
      case Return:
        return;
    }
  }
}
Beispiel #2
0
bool WindowProxy::initialize() {
  TRACE_EVENT0("v8", "WindowProxy::initialize");
  SCOPED_BLINK_UMA_HISTOGRAM_TIMER("Blink.Binding.InitializeWindowProxy");

  ScriptForbiddenScope::AllowUserAgentScript allowScript;

  v8::HandleScope handleScope(m_isolate);

  createContext();

  if (!isContextInitialized())
    return false;

  ScriptState::Scope scope(m_scriptState.get());
  v8::Local<v8::Context> context = m_scriptState->context();
  if (m_global.isEmpty()) {
    m_global.set(m_isolate, context->Global());
    if (m_global.isEmpty()) {
      disposeContext(DoNotDetachGlobal);
      return false;
    }
  }

  if (!setupWindowPrototypeChain()) {
    disposeContext(DoNotDetachGlobal);
    return false;
  }

  SecurityOrigin* origin = 0;
  if (m_world->isMainWorld()) {
    // ActivityLogger for main world is updated within updateDocument().
    updateDocument();
    origin = m_frame->securityContext()->getSecurityOrigin();
    // FIXME: Can this be removed when CSP moves to browser?
    ContentSecurityPolicy* csp =
        m_frame->securityContext()->contentSecurityPolicy();
    context->AllowCodeGenerationFromStrings(
        csp->allowEval(0, ContentSecurityPolicy::SuppressReport));
    context->SetErrorMessageForCodeGenerationFromStrings(
        v8String(m_isolate, csp->evalDisabledErrorMessage()));
  } else {
    updateActivityLogger();
    origin = m_world->isolatedWorldSecurityOrigin();
    setSecurityToken(origin);
  }

  // All interfaces must be registered to V8PerContextData.
  // So we explicitly call constructorForType for the global object.
  V8PerContextData::from(context)->constructorForType(
      &V8Window::wrapperTypeInfo);

  if (m_frame->isLocalFrame()) {
    LocalFrame* frame = toLocalFrame(m_frame);
    MainThreadDebugger::instance()->contextCreated(m_scriptState.get(), frame,
                                                   origin);
    frame->loader().client()->didCreateScriptContext(
        context, m_world->extensionGroup(), m_world->worldId());
  }
  return true;
}
bool WindowProxy::initialize()
{
    TRACE_EVENT0("v8", "WindowProxy::initialize");
    TRACE_EVENT_SCOPED_SAMPLING_STATE("blink", "InitializeWindow");
    SCOPED_BLINK_UMA_HISTOGRAM_TIMER("Blink.Binding.InitializeWindowProxy");

    ScriptForbiddenScope::AllowUserAgentScript allowScript;

    v8::HandleScope handleScope(m_isolate);

    createContext();

    if (!isContextInitialized())
        return false;

    ScriptState::Scope scope(m_scriptState.get());
    v8::Local<v8::Context> context = m_scriptState->context();
    if (m_global.isEmpty()) {
        m_global.set(m_isolate, context->Global());
        if (m_global.isEmpty()) {
            disposeContext(DoNotDetachGlobal);
            return false;
        }
    }

    if (!setupWindowPrototypeChain()) {
        disposeContext(DoNotDetachGlobal);
        return false;
    }

    SecurityOrigin* origin = 0;
    if (m_world->isMainWorld()) {
        // ActivityLogger for main world is updated within updateDocument().
        updateDocument();
        origin = m_frame->securityContext()->getSecurityOrigin();
        // FIXME: Can this be removed when CSP moves to browser?
        ContentSecurityPolicy* csp = m_frame->securityContext()->contentSecurityPolicy();
        context->AllowCodeGenerationFromStrings(csp->allowEval(0, ContentSecurityPolicy::SuppressReport));
        context->SetErrorMessageForCodeGenerationFromStrings(v8String(m_isolate, csp->evalDisabledErrorMessage()));
    } else {
        updateActivityLogger();
        origin = m_world->isolatedWorldSecurityOrigin();
        setSecurityToken(origin);
    }
    if (m_frame->isLocalFrame()) {
        LocalFrame* frame = toLocalFrame(m_frame);
        MainThreadDebugger::instance()->contextCreated(m_scriptState.get(), frame, origin);
        frame->loader().client()->didCreateScriptContext(context, m_world->extensionGroup(), m_world->worldId());
    }
    // If Origin Trials have been registered before the V8 context was ready,
    // then inject them into the context now
    ExecutionContext* executionContext = m_scriptState->getExecutionContext();
    if (executionContext) {
        OriginTrialContext* originTrialContext = OriginTrialContext::from(executionContext);
        if (originTrialContext)
            originTrialContext->initializePendingFeatures();
    }
    return true;
}
Beispiel #4
0
void StyleSheetContents::parseAuthorStyleSheet(
    const CSSStyleSheetResource* cachedStyleSheet,
    const SecurityOrigin* securityOrigin) {
    TRACE_EVENT1("blink,devtools.timeline", "ParseAuthorStyleSheet", "data",
                 InspectorParseAuthorStyleSheetEvent::data(cachedStyleSheet));
    SCOPED_BLINK_UMA_HISTOGRAM_TIMER("Style.AuthorStyleSheet.ParseTime");

    bool isSameOriginRequest =
        securityOrigin && securityOrigin->canRequest(baseURL());

    // When the response was fetched via the Service Worker, the original URL may
    // not be same as the base URL.
    // TODO(horo): When we will use the original URL as the base URL, we can
    // remove this check. crbug.com/553535
    if (cachedStyleSheet->response().wasFetchedViaServiceWorker()) {
        const KURL originalURL(
            cachedStyleSheet->response().originalURLViaServiceWorker());
        // |originalURL| is empty when the response is created in the SW.
        if (!originalURL.isEmpty() && !securityOrigin->canRequest(originalURL))
            isSameOriginRequest = false;
    }

    CSSStyleSheetResource::MIMETypeCheck mimeTypeCheck =
        isQuirksModeBehavior(m_parserContext.mode()) && isSameOriginRequest
        ? CSSStyleSheetResource::MIMETypeCheck::Lax
        : CSSStyleSheetResource::MIMETypeCheck::Strict;
    String sheetText = cachedStyleSheet->sheetText(mimeTypeCheck);

    const ResourceResponse& response = cachedStyleSheet->response();
    m_sourceMapURL = response.httpHeaderField(HTTPNames::SourceMap);
    if (m_sourceMapURL.isEmpty()) {
        // Try to get deprecated header.
        m_sourceMapURL = response.httpHeaderField(HTTPNames::X_SourceMap);
    }

    CSSParserContext context(parserContext(), UseCounter::getFrom(this));
    CSSParser::parseSheet(context, this, sheetText,
                          RuntimeEnabledFeatures::lazyParseCSSEnabled());
}